From ff7c092581369dd61e87e646a017dc54e9df7092 Mon Sep 17 00:00:00 2001 From: mothcompute Date: Thu, 9 Mar 2023 21:35:56 -0800 Subject: [PATCH] initial work on port updated readme, new "build system," fixed some errors --- .gitignore | 3 + MAKEFILE.MAK | 9 - README.md | 29 +- SWITCH.INC | 44 - SoundDrivers/AD1816.ASM | 4232 +++--- SoundDrivers/AMD3DI.MIX | 112 +- SoundDrivers/AMD3DNI.MIX | 608 +- SoundDrivers/AWE32B.ASM | 8620 ++++++------ SoundDrivers/AWE32DRV.ASM | 7922 +++++------ SoundDrivers/BASE1.ASM | 4140 +++--- SoundDrivers/DEBUG.INC | 202 +- SoundDrivers/DMA.INC | 226 +- SoundDrivers/DMANAI.INC | 226 +- SoundDrivers/DMASIRQ.INC | 232 +- SoundDrivers/DRHEAD.INC | 16 +- SoundDrivers/ENVIVO.ASM | 4600 +++--- SoundDrivers/EQUALIZE.INC | 322 +- SoundDrivers/ES1688.ASM | 4530 +++--- SoundDrivers/ES1688MX.ASM | 3502 ++--- SoundDrivers/ES1868.ASM | 4656 +++---- SoundDrivers/ES1868MX.ASM | 3468 ++--- SoundDrivers/ES1869.ASM | 4656 +++---- SoundDrivers/ES1869MX.ASM | 3468 ++--- SoundDrivers/EWS64.ASM | 1866 +-- SoundDrivers/EWSCODEC.ASM | 6032 ++++---- SoundDrivers/EWSCODMX.ASM | 5062 +++---- SoundDrivers/EXECOM.COM | Bin 1248 -> 1232 bytes SoundDrivers/FOURIER.INC | 166 +- SoundDrivers/FREQ.INC | 68 +- SoundDrivers/GOLD16.ASM | 4656 +++---- SoundDrivers/GUS.INC | 4632 +++---- SoundDrivers/GUSDRV.ASM | 10 +- SoundDrivers/GUSDRV2.ASM | 6 +- SoundDrivers/GUSHIQ2.ASM | 10 +- SoundDrivers/GUSHIQDR.ASM | 8 +- SoundDrivers/GUSMAX.ASM | 4182 +++--- SoundDrivers/GUSMAXMX.ASM | 3178 ++--- SoundDrivers/GUSMIXDR.ASM | 4924 +++---- SoundDrivers/GUSNRAMP.INC | 54 +- SoundDrivers/GUSNRIC.INC | 830 +- SoundDrivers/GUSPNPM.ASM | 4540 +++--- SoundDrivers/GUSPNPMX.ASM | 3538 ++--- SoundDrivers/GUSRAMP.INC | 228 +- SoundDrivers/GUSRIC.INC | 1302 +- SoundDrivers/IRQ.INC | 40 +- SoundDrivers/IWCODEC.ASM | 4604 +++--- SoundDrivers/IWDRV.ASM | 5426 ++++---- SoundDrivers/K6MSAM.INC | 776 +- SoundDrivers/K6TRANS.INC | 238 +- SoundDrivers/LOADSAM.INC | 142 +- SoundDrivers/LPT1DRV.ASM | 1808 +-- SoundDrivers/LPT2DRV.ASM | 1808 +-- SoundDrivers/M12BIT.INC | 98 +- SoundDrivers/M12BIT.MIX | 1626 +-- SoundDrivers/M12BITF.INC | 98 +- SoundDrivers/M12BITF.MIX | 1614 +-- SoundDrivers/M12BITI.INC | 98 +- SoundDrivers/M12BITI.MIX | 1732 +-- SoundDrivers/M12BITST.MIX | 1664 +-- SoundDrivers/M16.ASM | 4550 +++--- SoundDrivers/M16.BAT | 10 +- SoundDrivers/M32.ASM | 4542 +++--- SoundDrivers/M32.BAT | 10 +- SoundDrivers/M32BIT.INC | 98 +- SoundDrivers/M32BIT.MIX | 1606 +-- SoundDrivers/M32BITFF.MIX | 12 +- SoundDrivers/M32BITI.INC | 98 +- SoundDrivers/M32BITI.MIX | 1636 +-- SoundDrivers/M32BITM.INC | 22 +- SoundDrivers/M32BITM.MIX | 1004 +- SoundDrivers/M32BITMF.INC | 24 +- SoundDrivers/M32BITMF.MIX | 1416 +- SoundDrivers/M32BITMI.INC | 22 +- SoundDrivers/M32BITMI.MIX | 1372 +- SoundDrivers/M32BITMV.INC | 24 +- SoundDrivers/M32BITMV.MIX | 1596 +-- SoundDrivers/M32ULTRA.INC | 98 +- SoundDrivers/M32ULTRA.MIX | 1540 +-- SoundDrivers/MAD.BAT | 10 +- SoundDrivers/MAWE.BAT | 8 +- SoundDrivers/MAWEB.BAT | 8 +- SoundDrivers/MB.BAT | 12 +- SoundDrivers/MES.BAT | 10 +- SoundDrivers/MES1688.BAT | 10 +- SoundDrivers/MES1688M.BAT | 10 +- SoundDrivers/MES1788.BAT | 10 +- SoundDrivers/MES1869.BAT | 10 +- SoundDrivers/MES1869M.BAT | 10 +- SoundDrivers/MESM.BAT | 10 +- SoundDrivers/MEWS.BAT | 8 +- SoundDrivers/MEWSC.BAT | 10 +- SoundDrivers/MEWSCM.BAT | 10 +- SoundDrivers/MG16.BAT | 10 +- SoundDrivers/MGP.BAT | 8 +- SoundDrivers/MGPM.BAT | 8 +- SoundDrivers/MGUS.BAT | 8 +- SoundDrivers/MGUS2.BAT | 8 +- SoundDrivers/MGUSLO.BAT | 8 +- SoundDrivers/MGUSMAX.BAT | 10 +- SoundDrivers/MGUSMAXM.BAT | 10 +- SoundDrivers/MGUSMIX.BAT | 8 +- SoundDrivers/MIDDRV.ASM | 1730 +-- SoundDrivers/MIDDRV2.ASM | 1656 +-- SoundDrivers/MIDIDRV.ASM | 1050 +- SoundDrivers/MIW.BAT | 8 +- SoundDrivers/MIX.INC | 2028 +-- SoundDrivers/MIXWAV.INC | 2130 +-- SoundDrivers/MLPT1.BAT | 8 +- SoundDrivers/MLPT2.BAT | 8 +- SoundDrivers/MMID.BAT | 8 +- SoundDrivers/MMIDI.BAT | 8 +- SoundDrivers/MMX.INC | 612 +- SoundDrivers/MMXMSAM.INC | 776 +- SoundDrivers/MMXTRANS.INC | 232 +- SoundDrivers/MNOMIX.INC | 18 +- SoundDrivers/MONO12B.INC | 34 +- SoundDrivers/MONO12B.MIX | 376 +- SoundDrivers/MONO12BI.INC | 34 +- SoundDrivers/MONO12BI.MIX | 484 +- SoundDrivers/MPAS.BAT | 8 +- SoundDrivers/MPAS16.BAT | 8 +- SoundDrivers/MPC.BAT | 8 +- SoundDrivers/MSAM.BAT | 10 +- SoundDrivers/MSB.BAT | 8 +- SoundDrivers/MSB16.BAT | 10 +- SoundDrivers/MSB16A.BAT | 10 +- SoundDrivers/MSB16B.BAT | 8 +- SoundDrivers/MSB16C.BAT | 8 +- SoundDrivers/MSB16D.BAT | 8 +- SoundDrivers/MSB16M.BAT | 10 +- SoundDrivers/MSB16MB.BAT | 10 +- SoundDrivers/MSB2.BAT | 8 +- SoundDrivers/MSBPRO.BAT | 8 +- SoundDrivers/MST97.BAT | 8 +- SoundDrivers/MSTC.BAT | 10 +- SoundDrivers/MSTCM.BAT | 8 +- SoundDrivers/MSTP.BAT | 10 +- SoundDrivers/MT.BAT | 10 +- SoundDrivers/MV.BAT | 10 +- SoundDrivers/MVIVO.BAT | 10 +- SoundDrivers/MVM.BAT | 10 +- SoundDrivers/MWAV.BAT | 8 +- SoundDrivers/MWSS.BAT | 10 +- SoundDrivers/MWSS2.BAT | 10 +- SoundDrivers/NODEBUG.INC | 14 +- SoundDrivers/NOISE.ASM | 4182 +++--- SoundDrivers/PAS16DRV.ASM | 3972 +++--- SoundDrivers/PASDRV.ASM | 3806 ++--- SoundDrivers/PCSPKDRV.ASM | 1868 +-- SoundDrivers/PNP.INC | 448 +- SoundDrivers/Q.INC | 68 +- SoundDrivers/REQPROC.INC | 62 +- SoundDrivers/SAM9407.ASM | 2016 +-- SoundDrivers/SB16B.ASM | 4002 +++--- SoundDrivers/SB16C.ASM | 3390 ++--- SoundDrivers/SB16D.ASM | 5330 +++---- SoundDrivers/SB16DRV.ASM | 5344 +++---- SoundDrivers/SB16K6.ASM | 4574 +++--- SoundDrivers/SB16MMX.ASM | 4544 +++--- SoundDrivers/SB16MMXB.ASM | 4530 +++--- SoundDrivers/SB2DRV.ASM | 2842 ++-- SoundDrivers/SBDRV.ASM | 2832 ++-- SoundDrivers/SBMIDI.INC | 266 +- SoundDrivers/SBPRODRV.ASM | 4018 +++--- SoundDrivers/SNDDRV.ASM | 566 +- SoundDrivers/ST97.ASM | 1732 +-- SoundDrivers/ST97CMMX.ASM | 5546 ++++---- SoundDrivers/ST97CODE.ASM | 6342 ++++----- SoundDrivers/ST97PNP.ASM | 5246 +++---- SoundDrivers/TEST.ASM | 612 +- SoundDrivers/VSND.ASM | 2562 ++-- SoundDrivers/VSNDMMX.ASM | 2194 +-- SoundDrivers/VTABLE.INC | 22 +- SoundDrivers/WAV.MIX | 3216 ++--- SoundDrivers/WAVDRV.ASM | 3202 ++--- SoundDrivers/WAVPRO.ASM | 1706 +-- SoundDrivers/WSSDRV.ASM | 4350 +++--- SoundDrivers/WSSDRV2.ASM | 4536 +++--- build | 9 + DEBUG.INC => debug.inc | 214 +- errors-sorted | 29 + gen_deps | 13 + IT.ASM => it.s | 2302 +-- IT_D_INF.INC => it_d_inf.inc | 2252 +-- IT_D_RI.INC => it_d_ri.inc | 1542 +-- IT_D_RIS.INC => it_d_ris.inc | 2996 ++-- IT_D_RM.INC => it_d_rm.inc | 5778 ++++---- IT_D_WM.INC => it_d_wm.inc | 3570 ++--- IT_DISK.ASM => it_disk.s | 21880 ++++++++++++++--------------- IT_DISPL.ASM => it_displ.s | 8970 ++++++------ IT_EMS.ASM => it_ems.s | 1946 +-- IT_ERR.ASM => it_err.s | 337 +- IT_F.ASM => it_f.s | 11900 ++++++++-------- IT_FOUR.ASM => it_four.s | 1224 +- IT_G.ASM => it_g.s | 2052 +-- IT_H.ASM => it_h.s | 3104 ++--- IT_I.ASM => it_i.s | 18046 ++++++++++++------------ IT_K.ASM => it_k.s | 3624 ++--- IT_L.ASM => it_l.s | 1118 +- IT_M.ASM => it_m.s | 1328 +- IT_M_EFF.INC => it_m_eff.inc | 5890 ++++---- IT_MDATA.ASM => it_mdata.s | 7309 +++++----- IT_MMTSR.ASM => it_mmtsr.s | 2056 +-- IT_MOUSE.ASM => it_mouse.s | 2824 ++-- IT_MSG.ASM => it_msg.s | 2062 +-- IT_MUSIC.ASM => it_music.s | 14962 ++++++++++---------- IT_NET.ASM => it_net.s | 5444 ++++---- IT_OBJ1.ASM => it_obj1.s | 17804 ++++++++++++------------ IT_PE.ASM => it_pe.s | 24624 ++++++++++++++++----------------- IT_PE_V.INC => it_pe_v.inc | 280 +- IT_S.ASM => it_s.s | 3370 ++--- IT_TIMER.INC => it_timer.inc | 180 +- IT_TUTE.ASM => it_tute.s | 1038 +- IT_VESA.ASM => it_vesa.s | 452 +- main.c | 12 + NETWORK.INC => network.inc | 64 +- PE_TRANS.INC => pe_trans.inc | 3406 ++--- switch.inc | 32 + USERNAME.INC => username.inc | 0 WAVSWITC.INC => wavswitc.inc | 44 +- 220 files changed, 220138 insertions(+), 220096 deletions(-) create mode 100644 .gitignore delete mode 100644 MAKEFILE.MAK delete mode 100644 SWITCH.INC create mode 100755 build rename DEBUG.INC => debug.inc (82%) create mode 100644 errors-sorted create mode 100755 gen_deps rename IT.ASM => it.s (96%) rename IT_D_INF.INC => it_d_inf.inc (96%) rename IT_D_RI.INC => it_d_ri.inc (96%) rename IT_D_RIS.INC => it_d_ris.inc (96%) rename IT_D_RM.INC => it_d_rm.inc (96%) rename IT_D_WM.INC => it_d_wm.inc (96%) rename IT_DISK.ASM => it_disk.s (96%) rename IT_DISPL.ASM => it_displ.s (96%) rename IT_EMS.ASM => it_ems.s (96%) rename IT_ERR.ASM => it_err.s (86%) rename IT_F.ASM => it_f.s (96%) rename IT_FOUR.ASM => it_four.s (95%) rename IT_G.ASM => it_g.s (96%) rename IT_H.ASM => it_h.s (98%) rename IT_I.ASM => it_i.s (96%) rename IT_K.ASM => it_k.s (96%) rename IT_L.ASM => it_l.s (96%) rename IT_M.ASM => it_m.s (97%) rename IT_M_EFF.INC => it_m_eff.inc (96%) rename IT_MDATA.ASM => it_mdata.s (97%) rename IT_MMTSR.ASM => it_mmtsr.s (95%) rename IT_MOUSE.ASM => it_mouse.s (96%) rename IT_MSG.ASM => it_msg.s (96%) rename IT_MUSIC.ASM => it_music.s (96%) rename IT_NET.ASM => it_net.s (96%) rename IT_OBJ1.ASM => it_obj1.s (97%) rename IT_PE.ASM => it_pe.s (96%) rename IT_PE_V.INC => it_pe_v.inc (94%) rename IT_S.ASM => it_s.s (96%) rename IT_TIMER.INC => it_timer.inc (96%) rename IT_TUTE.ASM => it_tute.s (97%) rename IT_VESA.ASM => it_vesa.s (97%) create mode 100644 main.c rename NETWORK.INC => network.inc (97%) rename PE_TRANS.INC => pe_trans.inc (96%) create mode 100644 switch.inc rename USERNAME.INC => username.inc (100%) rename WAVSWITC.INC => wavswitc.inc (94%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..845747a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +obj +gen +test.s diff --git a/MAKEFILE.MAK b/MAKEFILE.MAK deleted file mode 100644 index c00a2f8..0000000 --- a/MAKEFILE.MAK +++ /dev/null @@ -1,9 +0,0 @@ -IT.EXE: IT.OBJ IT_DISK.OBJ IT_DISPL.OBJ IT_EMS.OBJ IT_ERR.OBJ IT_F.OBJ IT_G.OBJ IT_H.OBJ \ -IT_I.OBJ IT_K.OBJ IT_L.OBJ IT_M.OBJ IT_NET.OBJ IT_MSG.OBJ IT_MUSIC.OBJ IT_NET.OBJ IT_OBJ1.OBJ IT_PE.OBJ IT_S.OBJ \ -IT_TUTE.OBJ IT_MMTSR.OBJ IT_MOUSE.OBJ IT_MDATA.OBJ IT_FOUR.OBJ IT_VESA.OBJ - tlink /3 /s /v @source.lst - -.ASM.OBJ: -# TASM /Zi /m /uT310 /jSMART $*.asm - TASM /m /uT310 /jSMART $*.asm - diff --git a/README.md b/README.md index ba510c0..3522c99 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,20 @@ Impulse Tracker =============== -Full source code for Impulse Tracker, including sound drivers, network drivers, -and some supporting documentation - -  +Eventually, maybe, a version of IT for modern systems Pre-Requisite Software ---------------------- To build Impulse Tracker, you will need: -- Turbo Assembler v4.1 +- Netwide Assembler -- Turbo Link v3.01 +- GCC -- Borland MAKE v4.0 +- sh -- A DOS environment - -  - -Once you have these, building IT.EXE should be just a single call to `MAKE` - - -Sound drivers are build individually via M\*.BAT files inside the SoundDrivers -subdirectory - -  +Once you have these, building IT should be just a single call to `./build` Quick File Overview ------------------- @@ -105,8 +92,6 @@ Quick File Overview - SWITCH.INC: High level switches for the program - - Frequently Asked Questions -------------------------- @@ -129,10 +114,8 @@ A: The original code was compatible all the way back to an 8086 machine. 8086 wo conditional jumps only within +/-128 bytes, so I spent too much time shuffling code around to meet this restriction. When I shifted away from this 8086 restriction, I never went back to update the code that was mutilated by it. -  - License ------- -License for this source code is pending. +Refer to LICENSE.TXT diff --git a/SWITCH.INC b/SWITCH.INC deleted file mode 100644 index e984f26..0000000 --- a/SWITCH.INC +++ /dev/null @@ -1,44 +0,0 @@ - -TRACEENABLED EQU 0 - -TUTORIAL = 0 - - EMSUSE41 = 0 - - SHOWVERSION = 0 - SHOWREGISTERNAME = 1 - - USE32BITSCREENCOPY = 0 - - SORTENABLED = 1 - DDCOMPRESS = 1 - ORDERSORT = 1 - FILTERENVELOPES = 1 - CHORDENTRY = 1 - SPECTRUMANALYSER = 1 - SAVESAMPLEWAV = 1 - ENABLEPRESETENVELOPES = 1 - ENABLESOLO = 1 - - DEFAULTFORMAT = 3 ; 0 = IT214, 1 = S3M, 2 = IT2xx, 3 = IT215 - - USEFPUCODE = 1 ; For IT_MUSIC, this will change from LUT to FPU code - - OLDDRIVER = 0 - - MUSICDEBUG = 0 - EMSDEBUG = 0 - MEMORYDEBUG = 0 - ENABLEINT3 = 0 ; For debugging. - - TIMERSCREEN = 1 - - NETWORKENABLED = 1 - SHOWPATTERNLENGTH = 0 - -IF TUTORIAL - SORTENABLED = 1 - DDCOMPRESS = 1 -ENDIF - -TRACKERVERSION = 217h ; Still have to change text in IT.ASM, IT_F.ASM diff --git a/SoundDrivers/AD1816.ASM b/SoundDrivers/AD1816.ASM index 0f10386..c7ea86d 100755 --- a/SoundDrivers/AD1816.ASM +++ b/SoundDrivers/AD1816.ASM @@ -1,2116 +1,2116 @@ -; -; Analog Device's AD1816 -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 80719304h - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -Debug DW 0 -Debug2 DW 0 -DMASize DW 2048 - -ESSMsg DB "SoundPort AD1816 found", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "SoundPort AD1816 found", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "SoundPort AD1816 reinitialised", 0 - -DriverName DB "ITAD1816.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -ESSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldESSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -ESSScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr ESSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - DW Near Ptr PhatStereo ; 18 - - DW Near Ptr DebugText - DW Near Ptr DebugText2 - - DW 0 - -ESSHeaderLine DW 10 - DB "SoundPort AD1816 Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "SoundPort AD1816 Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB "3D Phat Stereo", 13 - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 39, 17 - DB 25 - -PhatStereo DW 14 - DB 22, 16 - DW 0, 15 - DW 9, 2 - DW 17, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 16 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 16 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 18, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 16 - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 44100 - -MixModeButton1 DW 2 - DW 18, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -DebugText DW 1 - DB 2, 47 - DB 20h - DB "MIDI Port: ", 0FDh, "Xh", 0 -MIDIPort DW 0 - -DebugText2 DW 1 - DB 2, 48 - DB 20h - DB "MIDI IRQ: ", 0FDh, "Dh", 0 -MIDIIRQ DW 0 - -VolumeTable DB 56, 56, 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dmasirq.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816Wait - - PushA - Xor CX, CX - Mov DX, CS:BasePort - -AD1816Wait1: - In AL, DX - Test AL, 80h - LoopZ AD1816Wait1 - - PopA - Ret - -EndP AD1816Wait - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816RegisterOut ; AL = indirect register, BX = contents - - Call AD1816Wait - - Push DX - PushF - - ClI - - Mov DX, CS:BasePort - Out DX, AL - Add DL, 2 - - Mov AL, BL - Out DX, AL - Inc DX - Mov AL, BH - Out DX, AL - - PopF - Pop DX - - Ret - -EndP AD1816RegisterOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816RegisterIn ; AL = register - ; Returns BX - - Call AD1816Wait - - Push AX - Push DX - - Mov DX, CS:BasePort - Out DX, AL - Add DL, 2 - - In AL, DX - Mov BL, AL - Inc DX - In AL, DX - Mov BH, AL - - Pop DX - Pop AX - - Ret - -EndP AD1816RegisterIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - - Mov AX, 1 - Ret - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - Mov AX, 007h - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov CX, 107h - -MIDISearchLoop: - Mov AX, CX - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - - Test AX, 0Fh - JNZ NextMIDI - Cmp AX, 300h - JB NextMIDI - Cmp AX, 400h - JAE NextMIDI - - Mov MIDIPort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - Mov MIDIIRQ, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -NextMIDI: - Add CX, 100h - Cmp CX, 0F07h - JBE MIDISearchLoop - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Inc Debug - - Inc DX - In AL, DX - Mov AH, AL - Xor AL, AL - Out DX, AL -; Call AD1816Out - - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB ESSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -ESSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB ESSIRQHandler6 - JE ESSIRQHFilter - - Cmp CS:Stereo, 0 - JE ESSIRQ3QFilterMono - -ESSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -ESSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -ESSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -ESSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilter: - Cmp CS:Stereo, 0 - JE ESSIRQHFilterMono - -ESSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -ESSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -ESSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -ESSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL ESSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG ESSIRQHandlerClip2 - -ESSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ ESSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -ESSIRQHandlerClip1: - Mov AX, 8000h - Jmp ESSIRQHandler7 - -ESSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp ESSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo3 - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopAD1816 - - PushA - - Mov AL, 1 - Call AD1816RegisterIn - And BX, 07FFFh ; Disable PIE - Call AD1816RegisterOut - - Mov DX, CS:BasePort - Inc DX - In AL, DX - And AL, Not 80h - Out DX, AL - - Add DL, 7 - In AL, DX - And AL, Not 1 - Out DX, AL - - PopA - Ret - -EndP StopAD1816 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartAD1816 - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov AL, 4 - Call AD1816RegisterIn - - Mov AL, 32 - Call AD1816RegisterIn - Or BX, 08000h - Call AD1816RegisterOut - - Mov AL, 2 ; Sample rate - Mov BX, MixSpeed - Call AD1816RegisterOut - - Mov AL, 8 ; DMA Size - Mov BX, DMASize - ShR BX, 2 - Dec BX - Call AD1816RegisterOut - - Mov DX, BasePort ; Wave Format - Add DL, 8 - - Mov AL, 00010001b - Cmp Stereo, 0 - JE StartAD1816A - - Or AL, 4 - -StartAD1816A: - Out DX, AL - - Mov AL, 1 ; Enable Playback interrupt - Call AD1816RegisterIn - Or BX, 8000h - Call AD1816RegisterOut - - Pop DS - Pop ES - PopA - - Ret - -EndP StartAD1816 - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov AX, CmdLineMixSpeed - Test AX, AX - JZ ClipMixSpeed3 - - Cmp AX, 11050 - JA ClipMixSpeed1 - - Mov AX, 11050 - -ClipMixSpeed1: - Cmp AX, 55200 - JB ClipMixSpeed2 - - Mov AX, 55200 - -ClipMixSpeed2: - Mov MixSpeed, AX - -ClipMixSpeed3: - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Call UpdateSoundcardVariables - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Push AX - - Call StopAD1816 - Call ResetIRQ - - Pop ES - Mov AH, 49h ; Release MixSegment - Int 21h - - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL - -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Mov CS:Debug2, BX - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopAD1816 - Call StartAD1816 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - Mov AL, 4 - Mov BX, 3F3Fh - Sub BX, [Word Ptr CS:VolumeTable] - Call AD1816RegisterOut - - Mov AL, 33 - Mov BX, 40h - Call AD1816RegisterOut - - Mov AL, 39 - Call AD1816RegisterIn - Mov CL, [CS:VolumeTable+2] - ShL CX, 9 - And BX, 0110000111111111b - Or BX, CX - Call AD1816RegisterOut - - Mov AL, 14 - Xor BX, BX - Call AD1816RegisterOut - - Mov AL, 44 - Xor BX, BX - Call AD1816RegisterOut - - Ret - -EndP UpdateSoundcardVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - Call UpdateSoundcardVariables - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Analog Device's AD1816 +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 80719304h + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +Debug DW 0 +Debug2 DW 0 +DMASize DW 2048 + +ESSMsg DB "SoundPort AD1816 found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "SoundPort AD1816 found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "SoundPort AD1816 reinitialised", 0 + +DriverName DB "ITAD1816.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +ESSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + DW Near Ptr PhatStereo ; 18 + + DW Near Ptr DebugText + DW Near Ptr DebugText2 + + DW 0 + +ESSHeaderLine DW 10 + DB "SoundPort AD1816 Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "SoundPort AD1816 Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB "3D Phat Stereo", 13 + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 39, 17 + DB 25 + +PhatStereo DW 14 + DB 22, 16 + DW 0, 15 + DW 9, 2 + DW 17, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 16 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 16 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 18, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 16 + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + +MixModeButton1 DW 2 + DW 18, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +DebugText DW 1 + DB 2, 47 + DB 20h + DB "MIDI Port: ", 0FDh, "Xh", 0 +MIDIPort DW 0 + +DebugText2 DW 1 + DB 2, 48 + DB 20h + DB "MIDI IRQ: ", 0FDh, "Dh", 0 +MIDIIRQ DW 0 + +VolumeTable DB 56, 56, 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dmasirq.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816Wait + + PushA + Xor CX, CX + Mov DX, CS:BasePort + +AD1816Wait1: + In AL, DX + Test AL, 80h + LoopZ AD1816Wait1 + + PopA + Ret + +EndP AD1816Wait + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816RegisterOut ; AL = indirect register, BX = contents + + Call AD1816Wait + + Push DX + PushF + + ClI + + Mov DX, CS:BasePort + Out DX, AL + Add DL, 2 + + Mov AL, BL + Out DX, AL + Inc DX + Mov AL, BH + Out DX, AL + + PopF + Pop DX + + Ret + +EndP AD1816RegisterOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816RegisterIn ; AL = register + ; Returns BX + + Call AD1816Wait + + Push AX + Push DX + + Mov DX, CS:BasePort + Out DX, AL + Add DL, 2 + + In AL, DX + Mov BL, AL + Inc DX + In AL, DX + Mov BH, AL + + Pop DX + Pop AX + + Ret + +EndP AD1816RegisterIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + + Mov AX, 1 + Ret + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + Mov AX, 007h + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov CX, 107h + +MIDISearchLoop: + Mov AX, CX + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + + Test AX, 0Fh + JNZ NextMIDI + Cmp AX, 300h + JB NextMIDI + Cmp AX, 400h + JAE NextMIDI + + Mov MIDIPort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + Mov MIDIIRQ, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +NextMIDI: + Add CX, 100h + Cmp CX, 0F07h + JBE MIDISearchLoop + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Inc Debug + + Inc DX + In AL, DX + Mov AH, AL + Xor AL, AL + Out DX, AL +; Call AD1816Out + + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB ESSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +ESSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB ESSIRQHandler6 + JE ESSIRQHFilter + + Cmp CS:Stereo, 0 + JE ESSIRQ3QFilterMono + +ESSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +ESSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +ESSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +ESSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilter: + Cmp CS:Stereo, 0 + JE ESSIRQHFilterMono + +ESSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +ESSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +ESSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +ESSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL ESSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG ESSIRQHandlerClip2 + +ESSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ ESSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +ESSIRQHandlerClip1: + Mov AX, 8000h + Jmp ESSIRQHandler7 + +ESSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp ESSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo3 + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopAD1816 + + PushA + + Mov AL, 1 + Call AD1816RegisterIn + And BX, 07FFFh ; Disable PIE + Call AD1816RegisterOut + + Mov DX, CS:BasePort + Inc DX + In AL, DX + And AL, Not 80h + Out DX, AL + + Add DL, 7 + In AL, DX + And AL, Not 1 + Out DX, AL + + PopA + Ret + +EndP StopAD1816 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartAD1816 + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov AL, 4 + Call AD1816RegisterIn + + Mov AL, 32 + Call AD1816RegisterIn + Or BX, 08000h + Call AD1816RegisterOut + + Mov AL, 2 ; Sample rate + Mov BX, MixSpeed + Call AD1816RegisterOut + + Mov AL, 8 ; DMA Size + Mov BX, DMASize + ShR BX, 2 + Dec BX + Call AD1816RegisterOut + + Mov DX, BasePort ; Wave Format + Add DL, 8 + + Mov AL, 00010001b + Cmp Stereo, 0 + JE StartAD1816A + + Or AL, 4 + +StartAD1816A: + Out DX, AL + + Mov AL, 1 ; Enable Playback interrupt + Call AD1816RegisterIn + Or BX, 8000h + Call AD1816RegisterOut + + Pop DS + Pop ES + PopA + + Ret + +EndP StartAD1816 + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov AX, CmdLineMixSpeed + Test AX, AX + JZ ClipMixSpeed3 + + Cmp AX, 11050 + JA ClipMixSpeed1 + + Mov AX, 11050 + +ClipMixSpeed1: + Cmp AX, 55200 + JB ClipMixSpeed2 + + Mov AX, 55200 + +ClipMixSpeed2: + Mov MixSpeed, AX + +ClipMixSpeed3: + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Call UpdateSoundcardVariables + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Push AX + + Call StopAD1816 + Call ResetIRQ + + Pop ES + Mov AH, 49h ; Release MixSegment + Int 21h + + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL + +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Mov CS:Debug2, BX + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopAD1816 + Call StartAD1816 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + Mov AL, 4 + Mov BX, 3F3Fh + Sub BX, [Word Ptr CS:VolumeTable] + Call AD1816RegisterOut + + Mov AL, 33 + Mov BX, 40h + Call AD1816RegisterOut + + Mov AL, 39 + Call AD1816RegisterIn + Mov CL, [CS:VolumeTable+2] + ShL CX, 9 + And BX, 0110000111111111b + Or BX, CX + Call AD1816RegisterOut + + Mov AL, 14 + Xor BX, BX + Call AD1816RegisterOut + + Mov AL, 44 + Xor BX, BX + Call AD1816RegisterOut + + Ret + +EndP UpdateSoundcardVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + Call UpdateSoundcardVariables + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/AMD3DI.MIX b/SoundDrivers/AMD3DI.MIX index dc3a759..b8d892c 100755 --- a/SoundDrivers/AMD3DI.MIX +++ b/SoundDrivers/AMD3DI.MIX @@ -1,56 +1,56 @@ - -; 8-bit interpolated mixing routine, 4 samples at a time. Rearranged -; MM7 contains volume as packed floating point -; MM6 contains offset as packed integer offset -; MM5 = DeltaOffset - -; MM7 = RVol|LVol -; MM6 = (1-Offset2)|Offset2|(1-Offset1)|Offset1 - - MovD MM0, [SampleBlock1] ; MM0 = x|x|x|x|S2H|S2L|S1H|S1L - MovQ MM2, MM6 - - PSRAW MM2, 1 - PUnpckLBW MM0, MM0 ; MM0 = S2H|S2L|S1H|S1L - - PAddW MM6, MM5 - PMAddWD MM0, MM2 ; MM0 = IS2|IS1 - - MovD MM1, [SampleBlock2] ; MM1 = x|x|x|x|S4H|S4L|S3H|S3L - MovQ MM2, MM6 - - PUnpckLBW MM1, MM1 ; MM1 = S4H|S4L|S3H|S3L - PSRAW MM2, 1 - - PI2FD MM0, MM0 ; MM0 = FIS2|FIS1 - PMAddWD MM1, MM2 ; MM1 = IS4|IS3 - - MovQ MM2, MM0 - PUnpckLDQ MM0, MM0 ; MM0 = FIS1|FIS1 - - PUnpckHDQ MM2, MM2 ; MM2 = FIS2|FIS2 - PI2FD MM1, MM1 ; MM1 = FIS4|FIS3 - - PFMul MM0, MM7 ; MM0 = R1|L1 - PAddW MM6, MM5 - - PFMul MM2, MM7 ; MM2 = R2|L2 - MovQ MM3, MM1 - - PFAdd MM0, [Buffer1] - PUnpckLDQ MM1, MM1 ; MM1 = FIS3|FIS3 - - PFAdd MM2, [Buffer2] - PUnpckHDQ MM3, MM3 ; MM3 = FIS4|FIS4 - - PFMul MM1, MM7 - MovQ [Buffer1], MM0 - - PFMul MM3, MM7 - PFAdd MM1, [Buffer3] - - MovQ [Buffer2], MM2 - PFAdd MM3, [Buffer4] - - MovQ [Buffer3], MM1 - MovQ [Buffer4], MM3 + +; 8-bit interpolated mixing routine, 4 samples at a time. Rearranged +; MM7 contains volume as packed floating point +; MM6 contains offset as packed integer offset +; MM5 = DeltaOffset + +; MM7 = RVol|LVol +; MM6 = (1-Offset2)|Offset2|(1-Offset1)|Offset1 + + MovD MM0, [SampleBlock1] ; MM0 = x|x|x|x|S2H|S2L|S1H|S1L + MovQ MM2, MM6 + + PSRAW MM2, 1 + PUnpckLBW MM0, MM0 ; MM0 = S2H|S2L|S1H|S1L + + PAddW MM6, MM5 + PMAddWD MM0, MM2 ; MM0 = IS2|IS1 + + MovD MM1, [SampleBlock2] ; MM1 = x|x|x|x|S4H|S4L|S3H|S3L + MovQ MM2, MM6 + + PUnpckLBW MM1, MM1 ; MM1 = S4H|S4L|S3H|S3L + PSRAW MM2, 1 + + PI2FD MM0, MM0 ; MM0 = FIS2|FIS1 + PMAddWD MM1, MM2 ; MM1 = IS4|IS3 + + MovQ MM2, MM0 + PUnpckLDQ MM0, MM0 ; MM0 = FIS1|FIS1 + + PUnpckHDQ MM2, MM2 ; MM2 = FIS2|FIS2 + PI2FD MM1, MM1 ; MM1 = FIS4|FIS3 + + PFMul MM0, MM7 ; MM0 = R1|L1 + PAddW MM6, MM5 + + PFMul MM2, MM7 ; MM2 = R2|L2 + MovQ MM3, MM1 + + PFAdd MM0, [Buffer1] + PUnpckLDQ MM1, MM1 ; MM1 = FIS3|FIS3 + + PFAdd MM2, [Buffer2] + PUnpckHDQ MM3, MM3 ; MM3 = FIS4|FIS4 + + PFMul MM1, MM7 + MovQ [Buffer1], MM0 + + PFMul MM3, MM7 + PFAdd MM1, [Buffer3] + + MovQ [Buffer2], MM2 + PFAdd MM3, [Buffer4] + + MovQ [Buffer3], MM1 + MovQ [Buffer4], MM3 diff --git a/SoundDrivers/AMD3DNI.MIX b/SoundDrivers/AMD3DNI.MIX index 203d218..c5c9ea1 100755 --- a/SoundDrivers/AMD3DNI.MIX +++ b/SoundDrivers/AMD3DNI.MIX @@ -1,304 +1,304 @@ - -; 8-bit non interpolated mixing routine, 8 samples at a time. Not rearranged - -; MM7 contains volume as packed floating point MM7 = RVol|LVol - - MovD MM0, [SampleBlock1] ; Low 4 bytes contain samples 1-4 - MovD MM1, [SampleBlock2] ; Low 4 bytes contain samples 5-8 - - PUnpckLBW MM0, MM0 ; MM0 = S4|S3|S2|S1 - PUnpckLBW MM1, MM1 ; MM1 = S8|S7|S6|S5 - - MovQ MM2, MM0 - MovQ MM3, MM1 - - PUnpckLWD MM0, MM0 ; MM0 = S2|S1 - PUnpckLWD MM1, MM1 ; MM1 = S6|S5 - - PUnpckHWD MM2, MM2 ; MM2 = S4|S3 - PUnpckHWD MM3, MM3 ; MM3 = S8|S7 - -; What category do PI2FD instructions fall under? Are they AMD-3D ALU (ie. -; only one resource shared between pipes?) - - PI2FD MM0, MM0 ; MM0 = FS2|FS1 - PI2FD MM1, MM1 ; MM1 = FS6|FS5 - PI2FD MM2, MM2 ; MM2 = FS4|FS3 - PI2FD MM3, MM3 ; MM3 = FS8|FS7 - - MovQ MM4, MM0 - MovQ MM5, MM2 - - PUnpckLDQ MM0, MM0 ; MM0 = FS1|FS1 - PUnpckHDQ MM4, MM4 ; MM4 = FS2|FS2 - PUnpckLDQ MM2, MM2 ; MM2 = FS3|FS3 - PUnpckHDQ MM5, MM5 ; MM5 = FS4|FS4 - - PFMul MM0, MM7 ; MM0 = R1|L1 - PFMul MM4, MM7 ; MM4 = R2|L2 - PFMul MM2, MM7 ; MM2 = R3|L3 - PFMul MM5, MM7 ; MM5 = R4|L4 - - PFAdd MM0, [Buffer1] - PFAdd MM4, [Buffer2] - PFAdd MM2, [Buffer3] - PFAdd MM5, [Buffer4] - - MovQ [Buffer1], MM0 - MovQ [Buffer2], MM4 - MovQ [Buffer3], MM2 - MovQ [Buffer4], MM5 - - MovQ MM0, MM1 - MovQ MM2, MM3 - - PUnpckLDQ MM0, MM0 ; MM0 = FS5|FS5 - PUnpckHDQ MM1, MM1 ; MM1 = FS6|FS6 - PUnpckLDQ MM2, MM2 ; MM2 = FS7|FS7 - PUnpckHDQ MM3, MM3 ; MM3 = FS8|FS8 - - PFMul MM0, MM7 - PFMul MM1, MM7 - PFMul MM2, MM7 - PFMul MM3, MM7 - - PFAdd MM0, [Buffer5] - PFAdd MM1, [Buffer6] - PFAdd MM2, [Buffer7] - PFAdd MM3, [Buffer8] - - MovQ [Buffer5], MM0 - MovQ [Buffer6], MM1 - MovQ [Buffer7], MM2 - MovQ [Buffer8], MM3 - -;----------------------------------------------------------------------------- -; Rearranged to improve pairing -; MM7 contains volume as packed floating point MM7 = RVol|LVol - - MovD MM0, [SampleBlock1] ; Low 4 bytes contain samples 1-4 - MovD MM1, [SampleBlock2] ; Low 4 bytes contain samples 5-8 - - PUnpckLBW MM0, MM0 ; MM0 = S4|S3|S2|S1 - PUnpckLBW MM1, MM1 ; MM1 = S8|S7|S6|S5 - - MovQ MM2, MM0 - PUnpckLWD MM0, MM0 ; MM0 = S2|S1 - - MovQ MM3, MM1 - PUnpckLWD MM1, MM1 ; MM1 = S6|S5 - - PUnpckHWD MM2, MM2 ; MM2 = S4|S3 - PI2FD MM0, MM0 ; MM0 = FS2|FS1 - - PUnpckHWD MM3, MM3 ; MM3 = S8|S7 - PI2FD MM1, MM1 ; MM1 = FS6|FS5 - - MovQ MM4, MM0 - PI2FD MM2, MM2 ; MM2 = FS4|FS3 - - MovQ MM5, MM2 - PI2FD MM3, MM3 ; MM3 = FS8|FS7 - - PUnpckLDQ MM0, MM0 ; MM0 = FS1|FS1 - PUnpckHDQ MM4, MM4 ; MM4 = FS2|FS2 - - PFMul MM0, MM7 ; MM0 = R1|L1 - PUnpckLDQ MM2, MM2 ; MM2 = FS3|FS3 - - PFMul MM4, MM7 ; MM4 = R2|L2 - PUnpckHDQ MM5, MM5 ; MM5 = FS4|FS4 - - PFMul MM2, MM7 ; MM2 = R3|L3 - PFAdd MM0, [Buffer1] - - PFMul MM5, MM7 ; MM5 = R4|L4 - PFAdd MM4, [Buffer2] - - PFAdd MM2, [Buffer3] - MovQ [Buffer1], MM0 - - MovQ [Buffer2], MM4 - PFAdd MM5, [Buffer4] - - MovQ [Buffer3], MM2 - MovQ MM0, MM1 - - MovQ [Buffer4], MM5 - MovQ MM2, MM3 - - PUnpckLDQ MM0, MM0 ; MM0 = FS5|FS5 - PUnpckHDQ MM1, MM1 ; MM1 = FS6|FS6 - - PFMul MM0, MM7 - PUnpckLDQ MM2, MM2 ; MM2 = FS7|FS7 - - PFMul MM1, MM7 - PUnpckHDQ MM3, MM3 ; MM3 = FS8|FS8 - - PFAdd MM0, [Buffer5] - PFMul MM2, MM7 - - PFAdd MM1, [Buffer6] - PFMul MM3, MM7 - - MovQ [Buffer5], MM0 - PFAdd MM2, [Buffer7] - - MovQ [Buffer6], MM1 - PFAdd MM3, [Buffer8] - - MovQ [Buffer7], MM2 ; These will be rearranged to match - MovQ [Buffer8], MM3 ; the next iteration. - - - -; 16-bit non interpolated mixing routine, 8 samples at a time. Not rearranged - -; MM7 contains volume as packed floating point MM7 = RVol|LVol - - MovQ MM0, [SampleBlock1] ; MM0 = S4|S3|S2|S1 - MovQ MM1, [SampleBlock2] ; MM1 = S8|S7|S6|S5 - - MovQ MM2, MM0 - MovQ MM3, MM1 - - PUnpckLWD MM0, MM0 ; MM0 = S2|S1 - PUnpckLWD MM1, MM1 ; MM1 = S6|S5 - - PUnpckHWD MM2, MM2 ; MM2 = S4|S3 - PUnpckHWD MM3, MM3 ; MM3 = S8|S7 - -; What category do PI2FD instructions fall under? Are they AMD-3D ALU (ie. -; only one resource shared between pipes?) - - PI2FD MM0, MM0 ; MM0 = FS2|FS1 - PI2FD MM1, MM1 ; MM1 = FS6|FS5 - PI2FD MM2, MM2 ; MM2 = FS4|FS3 - PI2FD MM3, MM3 ; MM3 = FS8|FS7 - - MovQ MM4, MM0 - MovQ MM5, MM2 - - PUnpckLDQ MM0, MM0 ; MM0 = FS1|FS1 - PUnpckHDQ MM4, MM4 ; MM4 = FS2|FS2 - PUnpckLDQ MM2, MM2 ; MM2 = FS3|FS3 - PUnpckHDQ MM5, MM5 ; MM5 = FS4|FS4 - - PFMul MM0, MM7 ; MM0 = R1|L1 - PFMul MM4, MM7 ; MM4 = R2|L2 - PFMul MM2, MM7 ; MM2 = R3|L3 - PFMul MM5, MM7 ; MM5 = R4|L4 - - PFAdd MM0, [Buffer1] - PFAdd MM4, [Buffer2] - PFAdd MM2, [Buffer3] - PFAdd MM5, [Buffer4] - - MovQ [Buffer1], MM0 - MovQ [Buffer2], MM4 - MovQ [Buffer3], MM2 - MovQ [Buffer4], MM5 - - MovQ MM0, MM1 - MovQ MM2, MM3 - - PUnpckLDQ MM0, MM0 ; MM0 = FS5|FS5 - PUnpckHDQ MM1, MM1 ; MM1 = FS6|FS6 - PUnpckLDQ MM2, MM2 ; MM2 = FS7|FS7 - PUnpckHDQ MM3, MM3 ; MM3 = FS8|FS8 - - PFMul MM0, MM7 - PFMul MM1, MM7 - PFMul MM2, MM7 - PFMul MM3, MM7 - - PFAdd MM0, [Buffer5] - PFAdd MM1, [Buffer6] - PFAdd MM2, [Buffer7] - PFAdd MM3, [Buffer8] - - MovQ [Buffer5], MM0 - MovQ [Buffer6], MM1 - MovQ [Buffer7], MM2 - MovQ [Buffer8], MM3 - -;----------------------------------------------------------------------------- -; Rearranged to improve pairing -; MM7 contains volume as packed floating point MM7 = RVol|LVol - - MovQ MM0, [SampleBlock1] ; MM0 = S4|S3|S2|S1 - MovQ MM1, [SampleBlock2] ; MM1 = S8|S7|S6|S5 - - MovQ MM2, MM0 - PUnpckLWD MM0, MM0 ; MM0 = S2|S1 - - MovQ MM3, MM1 - PUnpckLWD MM1, MM1 ; MM1 = S6|S5 - - PI2FD MM0, MM0 ; MM0 = FS2|FS1 - PUnpckHWD MM2, MM2 ; MM2 = S4|S3 - - PI2FD MM1, MM1 ; MM1 = FS6|FS5 - PUnpckHWD MM3, MM3 ; MM3 = S8|S7 - -; What category do PI2FD instructions fall under? Are they AMD-3D ALU (ie. -; only one resource shared between pipes?) - - MovQ MM4, MM0 - PI2FD MM2, MM2 ; MM2 = FS4|FS3 - - MovQ MM5, MM2 - PI2FD MM3, MM3 ; MM3 = FS8|FS7 - - PUnpckLDQ MM0, MM0 ; MM0 = FS1|FS1 - PUnpckHDQ MM4, MM4 ; MM4 = FS2|FS2 - - PFMul MM0, MM7 ; MM0 = R1|L1 - PUnpckLDQ MM2, MM2 ; MM2 = FS3|FS3 - - PFMul MM4, MM7 ; MM4 = R2|L2 - PUnpckHDQ MM5, MM5 ; MM5 = FS4|FS4 - - PFAdd MM0, [Buffer1] - PFMul MM2, MM7 ; MM2 = R3|L3 - - PFAdd MM4, [Buffer2] - PFMul MM5, MM7 ; MM5 = R4|L4 - - PFAdd MM2, [Buffer3] - MovQ [Buffer1], MM0 - - PFAdd MM5, [Buffer4] - MovQ [Buffer2], MM4 - - MovQ MM0, MM1 - MovQ [Buffer3], MM2 - - MovQ MM2, MM3 - MovQ [Buffer4], MM5 - - PUnpckLDQ MM0, MM0 ; MM0 = FS5|FS5 - PUnpckHDQ MM1, MM1 ; MM1 = FS6|FS6 - - PFMul MM0, MM7 - PUnpckLDQ MM2, MM2 ; MM2 = FS7|FS7 - - PFMul MM1, MM7 - PUnpckHDQ MM3, MM3 ; MM3 = FS8|FS8 - - PFAdd MM0, [Buffer5] - PFMul MM2, MM7 - - PFAdd MM1, [Buffer6] - PFMul MM3, MM7 - - MovQ [Buffer5], MM0 - PFAdd MM2, [Buffer7] - - MovQ [Buffer6], MM1 - PFAdd MM3, [Buffer8] - - MovQ [Buffer7], MM2 - MovQ [Buffer8], MM3 - + +; 8-bit non interpolated mixing routine, 8 samples at a time. Not rearranged + +; MM7 contains volume as packed floating point MM7 = RVol|LVol + + MovD MM0, [SampleBlock1] ; Low 4 bytes contain samples 1-4 + MovD MM1, [SampleBlock2] ; Low 4 bytes contain samples 5-8 + + PUnpckLBW MM0, MM0 ; MM0 = S4|S3|S2|S1 + PUnpckLBW MM1, MM1 ; MM1 = S8|S7|S6|S5 + + MovQ MM2, MM0 + MovQ MM3, MM1 + + PUnpckLWD MM0, MM0 ; MM0 = S2|S1 + PUnpckLWD MM1, MM1 ; MM1 = S6|S5 + + PUnpckHWD MM2, MM2 ; MM2 = S4|S3 + PUnpckHWD MM3, MM3 ; MM3 = S8|S7 + +; What category do PI2FD instructions fall under? Are they AMD-3D ALU (ie. +; only one resource shared between pipes?) + + PI2FD MM0, MM0 ; MM0 = FS2|FS1 + PI2FD MM1, MM1 ; MM1 = FS6|FS5 + PI2FD MM2, MM2 ; MM2 = FS4|FS3 + PI2FD MM3, MM3 ; MM3 = FS8|FS7 + + MovQ MM4, MM0 + MovQ MM5, MM2 + + PUnpckLDQ MM0, MM0 ; MM0 = FS1|FS1 + PUnpckHDQ MM4, MM4 ; MM4 = FS2|FS2 + PUnpckLDQ MM2, MM2 ; MM2 = FS3|FS3 + PUnpckHDQ MM5, MM5 ; MM5 = FS4|FS4 + + PFMul MM0, MM7 ; MM0 = R1|L1 + PFMul MM4, MM7 ; MM4 = R2|L2 + PFMul MM2, MM7 ; MM2 = R3|L3 + PFMul MM5, MM7 ; MM5 = R4|L4 + + PFAdd MM0, [Buffer1] + PFAdd MM4, [Buffer2] + PFAdd MM2, [Buffer3] + PFAdd MM5, [Buffer4] + + MovQ [Buffer1], MM0 + MovQ [Buffer2], MM4 + MovQ [Buffer3], MM2 + MovQ [Buffer4], MM5 + + MovQ MM0, MM1 + MovQ MM2, MM3 + + PUnpckLDQ MM0, MM0 ; MM0 = FS5|FS5 + PUnpckHDQ MM1, MM1 ; MM1 = FS6|FS6 + PUnpckLDQ MM2, MM2 ; MM2 = FS7|FS7 + PUnpckHDQ MM3, MM3 ; MM3 = FS8|FS8 + + PFMul MM0, MM7 + PFMul MM1, MM7 + PFMul MM2, MM7 + PFMul MM3, MM7 + + PFAdd MM0, [Buffer5] + PFAdd MM1, [Buffer6] + PFAdd MM2, [Buffer7] + PFAdd MM3, [Buffer8] + + MovQ [Buffer5], MM0 + MovQ [Buffer6], MM1 + MovQ [Buffer7], MM2 + MovQ [Buffer8], MM3 + +;----------------------------------------------------------------------------- +; Rearranged to improve pairing +; MM7 contains volume as packed floating point MM7 = RVol|LVol + + MovD MM0, [SampleBlock1] ; Low 4 bytes contain samples 1-4 + MovD MM1, [SampleBlock2] ; Low 4 bytes contain samples 5-8 + + PUnpckLBW MM0, MM0 ; MM0 = S4|S3|S2|S1 + PUnpckLBW MM1, MM1 ; MM1 = S8|S7|S6|S5 + + MovQ MM2, MM0 + PUnpckLWD MM0, MM0 ; MM0 = S2|S1 + + MovQ MM3, MM1 + PUnpckLWD MM1, MM1 ; MM1 = S6|S5 + + PUnpckHWD MM2, MM2 ; MM2 = S4|S3 + PI2FD MM0, MM0 ; MM0 = FS2|FS1 + + PUnpckHWD MM3, MM3 ; MM3 = S8|S7 + PI2FD MM1, MM1 ; MM1 = FS6|FS5 + + MovQ MM4, MM0 + PI2FD MM2, MM2 ; MM2 = FS4|FS3 + + MovQ MM5, MM2 + PI2FD MM3, MM3 ; MM3 = FS8|FS7 + + PUnpckLDQ MM0, MM0 ; MM0 = FS1|FS1 + PUnpckHDQ MM4, MM4 ; MM4 = FS2|FS2 + + PFMul MM0, MM7 ; MM0 = R1|L1 + PUnpckLDQ MM2, MM2 ; MM2 = FS3|FS3 + + PFMul MM4, MM7 ; MM4 = R2|L2 + PUnpckHDQ MM5, MM5 ; MM5 = FS4|FS4 + + PFMul MM2, MM7 ; MM2 = R3|L3 + PFAdd MM0, [Buffer1] + + PFMul MM5, MM7 ; MM5 = R4|L4 + PFAdd MM4, [Buffer2] + + PFAdd MM2, [Buffer3] + MovQ [Buffer1], MM0 + + MovQ [Buffer2], MM4 + PFAdd MM5, [Buffer4] + + MovQ [Buffer3], MM2 + MovQ MM0, MM1 + + MovQ [Buffer4], MM5 + MovQ MM2, MM3 + + PUnpckLDQ MM0, MM0 ; MM0 = FS5|FS5 + PUnpckHDQ MM1, MM1 ; MM1 = FS6|FS6 + + PFMul MM0, MM7 + PUnpckLDQ MM2, MM2 ; MM2 = FS7|FS7 + + PFMul MM1, MM7 + PUnpckHDQ MM3, MM3 ; MM3 = FS8|FS8 + + PFAdd MM0, [Buffer5] + PFMul MM2, MM7 + + PFAdd MM1, [Buffer6] + PFMul MM3, MM7 + + MovQ [Buffer5], MM0 + PFAdd MM2, [Buffer7] + + MovQ [Buffer6], MM1 + PFAdd MM3, [Buffer8] + + MovQ [Buffer7], MM2 ; These will be rearranged to match + MovQ [Buffer8], MM3 ; the next iteration. + + + +; 16-bit non interpolated mixing routine, 8 samples at a time. Not rearranged + +; MM7 contains volume as packed floating point MM7 = RVol|LVol + + MovQ MM0, [SampleBlock1] ; MM0 = S4|S3|S2|S1 + MovQ MM1, [SampleBlock2] ; MM1 = S8|S7|S6|S5 + + MovQ MM2, MM0 + MovQ MM3, MM1 + + PUnpckLWD MM0, MM0 ; MM0 = S2|S1 + PUnpckLWD MM1, MM1 ; MM1 = S6|S5 + + PUnpckHWD MM2, MM2 ; MM2 = S4|S3 + PUnpckHWD MM3, MM3 ; MM3 = S8|S7 + +; What category do PI2FD instructions fall under? Are they AMD-3D ALU (ie. +; only one resource shared between pipes?) + + PI2FD MM0, MM0 ; MM0 = FS2|FS1 + PI2FD MM1, MM1 ; MM1 = FS6|FS5 + PI2FD MM2, MM2 ; MM2 = FS4|FS3 + PI2FD MM3, MM3 ; MM3 = FS8|FS7 + + MovQ MM4, MM0 + MovQ MM5, MM2 + + PUnpckLDQ MM0, MM0 ; MM0 = FS1|FS1 + PUnpckHDQ MM4, MM4 ; MM4 = FS2|FS2 + PUnpckLDQ MM2, MM2 ; MM2 = FS3|FS3 + PUnpckHDQ MM5, MM5 ; MM5 = FS4|FS4 + + PFMul MM0, MM7 ; MM0 = R1|L1 + PFMul MM4, MM7 ; MM4 = R2|L2 + PFMul MM2, MM7 ; MM2 = R3|L3 + PFMul MM5, MM7 ; MM5 = R4|L4 + + PFAdd MM0, [Buffer1] + PFAdd MM4, [Buffer2] + PFAdd MM2, [Buffer3] + PFAdd MM5, [Buffer4] + + MovQ [Buffer1], MM0 + MovQ [Buffer2], MM4 + MovQ [Buffer3], MM2 + MovQ [Buffer4], MM5 + + MovQ MM0, MM1 + MovQ MM2, MM3 + + PUnpckLDQ MM0, MM0 ; MM0 = FS5|FS5 + PUnpckHDQ MM1, MM1 ; MM1 = FS6|FS6 + PUnpckLDQ MM2, MM2 ; MM2 = FS7|FS7 + PUnpckHDQ MM3, MM3 ; MM3 = FS8|FS8 + + PFMul MM0, MM7 + PFMul MM1, MM7 + PFMul MM2, MM7 + PFMul MM3, MM7 + + PFAdd MM0, [Buffer5] + PFAdd MM1, [Buffer6] + PFAdd MM2, [Buffer7] + PFAdd MM3, [Buffer8] + + MovQ [Buffer5], MM0 + MovQ [Buffer6], MM1 + MovQ [Buffer7], MM2 + MovQ [Buffer8], MM3 + +;----------------------------------------------------------------------------- +; Rearranged to improve pairing +; MM7 contains volume as packed floating point MM7 = RVol|LVol + + MovQ MM0, [SampleBlock1] ; MM0 = S4|S3|S2|S1 + MovQ MM1, [SampleBlock2] ; MM1 = S8|S7|S6|S5 + + MovQ MM2, MM0 + PUnpckLWD MM0, MM0 ; MM0 = S2|S1 + + MovQ MM3, MM1 + PUnpckLWD MM1, MM1 ; MM1 = S6|S5 + + PI2FD MM0, MM0 ; MM0 = FS2|FS1 + PUnpckHWD MM2, MM2 ; MM2 = S4|S3 + + PI2FD MM1, MM1 ; MM1 = FS6|FS5 + PUnpckHWD MM3, MM3 ; MM3 = S8|S7 + +; What category do PI2FD instructions fall under? Are they AMD-3D ALU (ie. +; only one resource shared between pipes?) + + MovQ MM4, MM0 + PI2FD MM2, MM2 ; MM2 = FS4|FS3 + + MovQ MM5, MM2 + PI2FD MM3, MM3 ; MM3 = FS8|FS7 + + PUnpckLDQ MM0, MM0 ; MM0 = FS1|FS1 + PUnpckHDQ MM4, MM4 ; MM4 = FS2|FS2 + + PFMul MM0, MM7 ; MM0 = R1|L1 + PUnpckLDQ MM2, MM2 ; MM2 = FS3|FS3 + + PFMul MM4, MM7 ; MM4 = R2|L2 + PUnpckHDQ MM5, MM5 ; MM5 = FS4|FS4 + + PFAdd MM0, [Buffer1] + PFMul MM2, MM7 ; MM2 = R3|L3 + + PFAdd MM4, [Buffer2] + PFMul MM5, MM7 ; MM5 = R4|L4 + + PFAdd MM2, [Buffer3] + MovQ [Buffer1], MM0 + + PFAdd MM5, [Buffer4] + MovQ [Buffer2], MM4 + + MovQ MM0, MM1 + MovQ [Buffer3], MM2 + + MovQ MM2, MM3 + MovQ [Buffer4], MM5 + + PUnpckLDQ MM0, MM0 ; MM0 = FS5|FS5 + PUnpckHDQ MM1, MM1 ; MM1 = FS6|FS6 + + PFMul MM0, MM7 + PUnpckLDQ MM2, MM2 ; MM2 = FS7|FS7 + + PFMul MM1, MM7 + PUnpckHDQ MM3, MM3 ; MM3 = FS8|FS8 + + PFAdd MM0, [Buffer5] + PFMul MM2, MM7 + + PFAdd MM1, [Buffer6] + PFMul MM3, MM7 + + MovQ [Buffer5], MM0 + PFAdd MM2, [Buffer7] + + MovQ [Buffer6], MM1 + PFAdd MM3, [Buffer8] + + MovQ [Buffer7], MM2 + MovQ [Buffer8], MM3 + diff --git a/SoundDrivers/AWE32B.ASM b/SoundDrivers/AWE32B.ASM index d728681..b883972 100755 --- a/SoundDrivers/AWE32B.ASM +++ b/SoundDrivers/AWE32B.ASM @@ -1,4310 +1,4310 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - - Comment ~ - -Index = BasePort + 802h - - 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ - ³ .............................. ³ Register ³ Channel Number ³ - ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - - ~ - -OldIRQHandler DD 0 -AWEMemory DD 0 -AWEMemoryUsed DD 0 -AWEUpdateCount DW 0 - -AWEUpdateTimer DW 0 - -LoadSampleFuncF DW 0 -LoadSampleFuncB DW 0 - -AWEDataTable DD 5*100 Dup (0) ; Start, Startloop, Endloop, Size -MIDIPort DW 0 -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -SB16BasePort DW 0 -MixerPort DW 0 -Step DW 1 -AWEUpdateFlag DB 0 -Compress DB 0 - DB 0 - -SBIRQMode DB 0 -BlockLength DW 100 -BlockLength2 DW 100 - -AWE32Msg DB "Sound Blaster AWE 32 detected", 13 - DB "Address ", 0FDh, "Xh, ", 0FDh, "Dk Memory", 0 - -AWE32Msg2 DB "Sound Blaster AWE 32 detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 - -AWE32Status DB "FreeAWE ", 0FDh, "Dk", 0 - -AWE32ReinitMsg DB "Sound Blaster AWE 32 reinitialised", 0 -Stereo DB 0 -Forced DB 0 -DriverName DB "ITAWE32B.DRV", 0 - -FrequencyError DB "AWE Hardware frequency limit exceeded -> Note terminated", 0 - -IRQFlag DB 0FFh - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -IMR DW 0 - - CPF EQU 0 - PTRX EQU 20h - CVCF EQU 40h - VTFT EQU 60h - PSST EQU 0C0h - CSL EQU 0E0h - - CCCA EQU 100h - HWCF4 EQU 129h - HWCF5 EQU 12Ah - HWCF6 EQU 12Dh - SMALR EQU 134h - SMARR EQU 135h - SMALW EQU 136h - SMARW EQU 137h - SMLD EQU 43Ah - SMRD EQU 23Ah - WC EQU 23Bh - HWCF1 EQU 43Dh - HWCF2 EQU 43Eh - CFG2 EQU 43Eh - HWCF3 EQU 43Fh - INIT1 EQU 440h - INIT2 EQU 240h - INIT3 EQU 460h - INIT4 EQU 260h - ENVVOL EQU 480h - DCYSUSV EQU 4A0h - ENVVAL EQU 4C0h - DCYSUS EQU 4E0h - SUSDCY EQU 4E0h - ATKHLDV EQU 280h - LFO1VAL EQU 2A0h - ATKHLD EQU 2C0h - HLDATK EQU 2C0h - LFO2VAL EQU 2E0h - IP EQU 300h - IFATN EQU 320h - PEFE EQU 340h - FMMOD EQU 360h - TREMFRQ EQU 380h - FM2FRQ2 EQU 3A0h - -ALIGN 4 - -InitTable1 Label - DW 003FFh, 0030h, 007FFh, 0130h, 00BFFh, 0230h, 00FFFh, 0330h - DW 013FFh, 0430h, 017FFh, 0530h, 01BFFh, 0630h, 01FFFh, 0730h - DW 023FFh, 0830h, 027FFh, 0930h, 02BFFh, 0A30h, 02FFFh, 0B30h - DW 033FFh, 0C30h, 037FFh, 0D30h, 03BFFh, 0E30h, 03FFFh, 0F30h - - DW 043FFh, 0030h, 047FFh, 0130h, 04BFFh, 0230h, 04FFFh, 0330h - DW 053FFh, 0430h, 057FFh, 0530h, 05BFFh, 0630h, 05FFFh, 0730h - DW 063FFh, 0830h, 067FFh, 0930h, 06BFFh, 0A30h, 06FFFh, 0B30h - DW 073FFh, 0C30h, 077FFh, 0D30h, 07BFFh, 0E30h, 07FFFh, 0F30h - - DW 083FFh, 0030h, 087FFh, 0130h, 08BFFh, 0230h, 08FFFh, 0330h - DW 093FFh, 0430h, 097FFh, 0530h, 09BFFh, 0630h, 09FFFh, 0730h - DW 0A3FFh, 0830h, 0A7FFh, 0930h, 0ABFFh, 0A30h, 0AFFFh, 0B30h - DW 0B3FFh, 0C30h, 0B7FFh, 0D30h, 0BBFFh, 0E30h, 0BFFFh, 0F30h - - DW 0C3FFh, 0030h, 0C7FFh, 0130h, 0CBFFh, 0230h, 0CFFFh, 0330h - DW 0D3FFh, 0430h, 0D7FFh, 0530h, 0DBFFh, 0630h, 0DFFFh, 0730h - DW 0E3FFh, 0830h, 0E7FFh, 0930h, 0EBFFh, 0A30h, 0EFFFh, 0B30h - DW 0F3FFh, 0C30h, 0F7FFh, 0D30h, 0FBFFh, 0E30h, 0FFFFh, 0F30h - -InitTable2 Label - DW 003FFh, 8030h, 007FFh, 8130h, 00BFFh, 8230h, 00FFFh, 8330h - DW 013FFh, 8430h, 017FFh, 8530h, 01BFFh, 8630h, 01FFFh, 8730h - DW 023FFh, 8830h, 027FFh, 8930h, 02BFFh, 8A30h, 02FFFh, 8B30h - DW 033FFh, 8C30h, 037FFh, 8D30h, 03BFFh, 8E30h, 03FFFh, 8F30h - - DW 043FFh, 8030h, 047FFh, 8130h, 04BFFh, 8230h, 04FFFh, 8330h - DW 053FFh, 8430h, 057FFh, 8530h, 05BFFh, 8630h, 05FFFh, 8730h - DW 063FFh, 8830h, 067FFh, 8930h, 06BFFh, 8A30h, 06FFFh, 8B30h - DW 073FFh, 8C30h, 077FFh, 8D30h, 07BFFh, 8E30h, 07FFFh, 8F30h - - DW 083FFh, 8030h, 087FFh, 8130h, 08BFFh, 8230h, 08FFFh, 8330h - DW 093FFh, 8430h, 097FFh, 8530h, 09BFFh, 8630h, 09FFFh, 8730h - DW 0A3FFh, 8830h, 0A7FFh, 8930h, 0ABFFh, 8A30h, 0AFFFh, 8B30h - DW 0B3FFh, 8C30h, 0B7FFh, 8D30h, 0BBFFh, 8E30h, 0BFFFh, 8F30h - - DW 0C3FFh, 8030h, 0C7FFh, 8130h, 0CBFFh, 8230h, 0CFFFh, 8330h - DW 0D3FFh, 8430h, 0D7FFh, 8530h, 0DBFFh, 8630h, 0DFFFh, 8730h - DW 0E3FFh, 8830h, 0E7FFh, 8930h, 0EBFFh, 8A30h, 0EFFFh, 8B30h - DW 0F3FFh, 8C30h, 0F7FFh, 8D30h, 0FBFFh, 8E30h, 0FFFFh, 8F30h - -InitTable3 Label - DW 0C10h, 8470h, 14FEh, 0B488h, 167Fh, 0A470h, 18E7h, 84B5h - DW 1B6Eh, 842Ah, 1F1Dh, 852Ah, 0DA3h, 8F7Ch, 167Eh, 7254h - DW 0, 842Ah, 1, 852Ah, 18E6h, 8BAAh, 1B6Dh, 7234h - DW 229Fh, 8429h, 2746h, 8529h, 1F1Ch, 86E7h, 229Eh, 7224h - - DW 0DA4h, 8429h, 2C29h, 8529h, 2745h, 87F6h, 2C28h, 7254h - DW 383Bh, 8428h, 320Fh, 8528h, 320Eh, 8F02h, 1341h, 7264h - DW 3EB6h, 8428h, 3EB9h, 8528h, 383Ah, 8FA9h, 3EB5h, 7294h - DW 3EB7h, 8474h, 3EBAh, 8575h, 3EB8h, 0C4C3h, 3EBBh, 45C3h - - DW 00000, 0A404h, 00001, 0A504h, 141Fh, 8671h, 14FDh, 8287h - DW 3EBCh, 0E610h, 3EC8h, 8C7Bh, 31Ah, 87E6h, 3EC8h, 86F7h - DW 3EC0h, 821Eh, 3EBEh, 0D208h, 3EBDh, 821Fh, 3ECAh, 8386h - DW 3EC1h, 8C03h, 3EC9h, 831Eh, 3ECAh, 8C4Ch, 3EBFh, 8C55h - - DW 3EC9h, 0C208h, 3EC4h, 0BC84h, 3EC8h, 8EADh, 3EC8h, 0D308h - DW 3EC2h, 8F7Eh, 3ECBh, 821Eh, 3ECBh, 0D208h, 3EC5h, 831Fh - DW 3EC6h, 0C308h, 3EC3h, 32FFh, 3EC9h, 8265h, 3EC9h, 831Eh - DW 1342h, 0D308h, 3EC7h, 33FFh, 0, 8365h, 1420h, 9570h - -InitTable4 Label - DW 0C10h, 8470h, 14FEh, 0B488h, 167Fh, 0A470h, 18E7h, 84B5h - DW 1B6Eh, 842Ah, 1F1Dh, 852Ah, 0DA3h, 0F7Ch, 167Eh, 7254h - DW 0, 842Ah, 1, 852Ah, 18E6h, 0BAAh, 1B6Dh, 7234h - DW 229Fh, 8429h, 2746h, 8529h, 1F1Ch, 6E7h, 229Eh, 7224h - - DW 0DA4h, 8429h, 2C29h, 8529h, 2745h, 07F6h, 2C28h, 7254h - DW 383Bh, 8428h, 320Fh, 8528h, 320Eh, 0F02h, 1341h, 7264h - DW 3EB6h, 8428h, 3EB9h, 8528h, 383Ah, 0FA9h, 3EB5h, 7294h - DW 3EB7h, 8474h, 3EBAh, 8575h, 3EB8h, 44C3h, 3EBBh, 45C3h - - DW 00000, 0A404h, 00001, 0A504h, 141Fh, 0671h, 14FDh, 287h - DW 3EBCh, 0E610h, 3EC8h, 0C7Bh, 31Ah, 7E6h, 3EC8h, 86F7h - DW 3EC0h, 821Eh, 3EBEh, 0D208h, 3EBDh, 021Fh, 3ECAh, 386h - DW 3EC1h, 0C03h, 3EC9h, 31Eh, 3ECAh, 8C4Ch, 3EBFh, 0C55h - - DW 3EC9h, 0C208h, 3EC4h, 0BC84h, 3EC8h, 0EADh, 3EC8h, 0D308h - DW 3EC2h, 8F7Eh, 3ECBh, 021Eh, 3ECBh, 0D208h, 3EC5h, 31Fh - DW 3EC6h, 0C308h, 3EC3h, 32FFh, 3EC9h, 0265h, 3EC9h, 831Eh - DW 1342h, 0D308h, 3EC7h, 33FFh, 0, 8365h, 1420h, 9570h - -AWEVolumeTable Label Byte ; Value = -log(vol/256)*(20/.375) - ; = -log(vol/256)*(160/3) - - DB 255, 128, 112, 103, 96, 91, 87, 83 ; 0->7 - DB 80, 78, 75, 73, 71, 69, 67, 66 ; 8->15 - DB 64, 63, 61, 60, 59, 58, 57, 56 ; 16->23 - DB 55, 54, 53, 52, 51, 50, 50, 49 ; 24->31 - DB 48, 47, 47, 46, 45, 45, 44, 44 ; 32->39 - DB 43, 42, 42, 41, 41, 40, 40, 39 ; 40->47 - DB 39, 38, 38, 37, 37, 36, 36, 36 ; 48->55 - DB 35, 35, 34, 34, 34, 33, 33, 32 ; 56->63 - DB 32, 32, 31, 31, 31, 30, 30, 30 ; 64->71 - DB 29, 29, 29, 28, 28, 28, 28, 27 ; 72->79 - DB 27, 27, 26, 26, 26, 26, 25, 25 ; 80->87 - DB 25, 25, 24, 24, 24, 23, 23, 23 ; 88->95 - DB 23, 22, 22, 22, 22, 22, 21, 21 ; 96->103 - DB 21, 21, 20, 20, 20, 20, 20, 19 ; 104->111 - DB 19, 19, 19, 19, 18, 18, 18, 18 ; 112->119 - DB 18, 17, 17, 17, 17, 17, 16, 16 ; 120->127 - DB 16 ; 128 - - Comment ~ ; Value = -log(vol/128)*(20/.375) - ; = -log(vol/128)*(160/3) - ; This is mathematically the correct table, but it seems too - ; loud, and it overloads on playback. - - DB 255, 112, 96, 87, 80, 75, 71, 67 ; 0->7 - DB 64, 61, 59, 57, 55, 53, 51, 50 ; 8->15 - DB 48, 47, 45, 44, 43, 42, 41, 40 ; 16->23 - DB 39, 38, 37, 36, 35, 34, 34, 33 ; 24->31 - DB 32, 31, 31, 30, 29, 29, 28, 28 ; 32->39 - DB 27, 26, 26, 25, 25, 24, 24, 23 ; 40->47 - DB 23, 22, 22, 21, 21, 20, 20, 20 ; 48->55 - DB 19, 19, 18, 18, 18, 17, 17, 16 ; 56->63 - DB 16, 16, 15, 15, 15, 14, 14, 14 ; 64->71 - DB 13, 13, 13, 13, 12, 12, 12, 11 ; 72->79 - DB 11, 11, 10, 10, 10, 9, 9, 9 ; 80->87 - DB 9, 8, 8, 8, 8, 7, 7, 7 ; 88->95 - DB 7, 6, 6, 6, 6, 5, 5, 5 ; 96->103 - DB 5, 4, 4, 4, 4, 4, 4, 3 ; 104->111 - DB 3, 3, 3, 2, 2, 2, 2, 2 ; 112->119 - DB 1, 1, 1, 1, 1, 1, 1, 1 ; 120->127 - DB 0 - - ~ - -AWEPitchTable Label DWord ; Pitchval = 88200 * 2^(Pos / 4096) - DD 88200, 88215, 88230, 88245, 88260, 88275, 88290, 88305 - DD 88320, 88335, 88350, 88365, 88380, 88395, 88410, 88425 - DD 88440, 88455, 88470, 88485, 88500, 88514, 88529, 88544 - DD 88559, 88574, 88589, 88604, 88619, 88634, 88649, 88664 - DD 88679, 88694, 88709, 88724, 88739, 88754, 88770, 88785 - DD 88800, 88815, 88830, 88845, 88860, 88875, 88890, 88905 - DD 88920, 88935, 88950, 88965, 88980, 88995, 89010, 89025 - DD 89040, 89055, 89070, 89086, 89101, 89116, 89131, 89146 - DD 89161, 89176, 89191, 89206, 89221, 89236, 89252, 89267 - DD 89282, 89297, 89312, 89327, 89342, 89357, 89372, 89388 - DD 89403, 89418, 89433, 89448, 89463, 89478, 89493, 89509 - DD 89524, 89539, 89554, 89569, 89584, 89600, 89615, 89630 - DD 89645, 89660, 89675, 89691, 89706, 89721, 89736, 89751 - DD 89767, 89782, 89797, 89812, 89827, 89842, 89858, 89873 - DD 89888, 89903, 89919, 89934, 89949, 89964, 89979, 89995 - DD 90010, 90025, 90040, 90056, 90071, 90086, 90101, 90117 - DD 90132, 90147, 90162, 90178, 90193, 90208, 90223, 90239 - DD 90254, 90269, 90284, 90300, 90315, 90330, 90346, 90361 - DD 90376, 90391, 90407, 90422, 90437, 90453, 90468, 90483 - DD 90499, 90514, 90529, 90545, 90560, 90575, 90591, 90606 - DD 90621, 90637, 90652, 90667, 90683, 90698, 90713, 90729 - DD 90744, 90759, 90775, 90790, 90805, 90821, 90836, 90852 - DD 90867, 90882, 90898, 90913, 90928, 90944, 90959, 90975 - DD 90990, 91005, 91021, 91036, 91052, 91067, 91082, 91098 - DD 91113, 91129, 91144, 91160, 91175, 91190, 91206, 91221 - DD 91237, 91252, 91268, 91283, 91299, 91314, 91329, 91345 - DD 91360, 91376, 91391, 91407, 91422, 91438, 91453, 91469 - DD 91484, 91500, 91515, 91531, 91546, 91562, 91577, 91593 - DD 91608, 91624, 91639, 91655, 91670, 91686, 91701, 91717 - DD 91732, 91748, 91763, 91779, 91794, 91810, 91825, 91841 - DD 91856, 91872, 91887, 91903, 91919, 91934, 91950, 91965 - DD 91981, 91996, 92012, 92028, 92043, 92059, 92074, 92090 - DD 92105, 92121, 92137, 92152, 92168, 92183, 92199, 92215 - DD 92230, 92246, 92261, 92277, 92293, 92308, 92324, 92340 - DD 92355, 92371, 92386, 92402, 92418, 92433, 92449, 92465 - DD 92480, 92496, 92512, 92527, 92543, 92559, 92574, 92590 - DD 92606, 92621, 92637, 92653, 92668, 92684, 92700, 92715 - DD 92731, 92747, 92762, 92778, 92794, 92810, 92825, 92841 - DD 92857, 92872, 92888, 92904, 92920, 92935, 92951, 92967 - DD 92982, 92998, 93014, 93030, 93045, 93061, 93077, 93093 - DD 93108, 93124, 93140, 93156, 93171, 93187, 93203, 93219 - DD 93235, 93250, 93266, 93282, 93298, 93313, 93329, 93345 - DD 93361, 93377, 93392, 93408, 93424, 93440, 93456, 93472 - DD 93487, 93503, 93519, 93535, 93551, 93566, 93582, 93598 - DD 93614, 93630, 93646, 93662, 93677, 93693, 93709, 93725 - DD 93741, 93757, 93773, 93788, 93804, 93820, 93836, 93852 - DD 93868, 93884, 93900, 93915, 93931, 93947, 93963, 93979 - DD 93995, 94011, 94027, 94043, 94059, 94075, 94090, 94106 - DD 94122, 94138, 94154, 94170, 94186, 94202, 94218, 94234 - DD 94250, 94266, 94282, 94298, 94314, 94330, 94346, 94362 - DD 94377, 94393, 94409, 94425, 94441, 94457, 94473, 94489 - DD 94505, 94521, 94537, 94553, 94569, 94585, 94601, 94617 - DD 94633, 94649, 94665, 94681, 94697, 94713, 94729, 94746 - DD 94762, 94778, 94794, 94810, 94826, 94842, 94858, 94874 - DD 94890, 94906, 94922, 94938, 94954, 94970, 94986, 95002 - DD 95018, 95035, 95051, 95067, 95083, 95099, 95115, 95131 - DD 95147, 95163, 95179, 95196, 95212, 95228, 95244, 95260 - DD 95276, 95292, 95308, 95324, 95341, 95357, 95373, 95389 - DD 95405, 95421, 95437, 95454, 95470, 95486, 95502, 95518 - DD 95534, 95551, 95567, 95583, 95599, 95615, 95631, 95648 - DD 95664, 95680, 95696, 95712, 95729, 95745, 95761, 95777 - DD 95793, 95810, 95826, 95842, 95858, 95875, 95891, 95907 - DD 95923, 95939, 95956, 95972, 95988, 96004, 96021, 96037 - DD 96053, 96069, 96086, 96102, 96118, 96134, 96151, 96167 - DD 96183, 96200, 96216, 96232, 96248, 96265, 96281, 96297 - DD 96314, 96330, 96346, 96362, 96379, 96395, 96411, 96428 - DD 96444, 96460, 96477, 96493, 96509, 96526, 96542, 96558 - DD 96575, 96591, 96607, 96624, 96640, 96656, 96673, 96689 - DD 96706, 96722, 96738, 96755, 96771, 96787, 96804, 96820 - DD 96837, 96853, 96869, 96886, 96902, 96919, 96935, 96951 - DD 96968, 96984, 97001, 97017, 97033, 97050, 97066, 97083 - DD 97099, 97116, 97132, 97148, 97165, 97181, 97198, 97214 - DD 97231, 97247, 97264, 97280, 97296, 97313, 97329, 97346 - DD 97362, 97379, 97395, 97412, 97428, 97445, 97461, 97478 - DD 97494, 97511, 97527, 97544, 97560, 97577, 97593, 97610 - DD 97626, 97643, 97659, 97676, 97692, 97709, 97726, 97742 - DD 97759, 97775, 97792, 97808, 97825, 97841, 97858, 97874 - DD 97891, 97908, 97924, 97941, 97957, 97974, 97990, 98007 - DD 98024, 98040, 98057, 98073, 98090, 98107, 98123, 98140 - DD 98156, 98173, 98190, 98206, 98223, 98240, 98256, 98273 - DD 98289, 98306, 98323, 98339, 98356, 98373, 98389, 98406 - DD 98423, 98439, 98456, 98473, 98489, 98506, 98523, 98539 - DD 98556, 98573, 98589, 98606, 98623, 98639, 98656, 98673 - DD 98689, 98706, 98723, 98740, 98756, 98773, 98790, 98806 - DD 98823, 98840, 98857, 98873, 98890, 98907, 98924, 98940 - DD 98957, 98974, 98990, 99007, 99024, 99041, 99058, 99074 - DD 99091, 99108, 99125, 99141, 99158, 99175, 99192, 99208 - DD 99225, 99242, 99259, 99276, 99292, 99309, 99326, 99343 - DD 99360, 99377, 99393, 99410, 99427, 99444, 99461, 99477 - DD 99494, 99511, 99528, 99545, 99562, 99579, 99595, 99612 - DD 99629, 99646, 99663, 99680, 99697, 99713, 99730, 99747 - DD 99764, 99781, 99798, 99815, 99832, 99849, 99865, 99882 - DD 99899, 99916, 99933, 99950, 99967, 99984, 100001, 100018 - DD 100035, 100051, 100068, 100085, 100102, 100119, 100136, 100153 - DD 100170, 100187, 100204, 100221, 100238, 100255, 100272, 100289 - DD 100306, 100323, 100340, 100357, 100374, 100391, 100408, 100425 - DD 100442, 100459, 100476, 100493, 100510, 100527, 100544, 100561 - DD 100578, 100595, 100612, 100629, 100646, 100663, 100680, 100697 - DD 100714, 100731, 100748, 100765, 100782, 100799, 100816, 100833 - DD 100850, 100867, 100885, 100902, 100919, 100936, 100953, 100970 - DD 100987, 101004, 101021, 101038, 101055, 101073, 101090, 101107 - DD 101124, 101141, 101158, 101175, 101192, 101209, 101227, 101244 - DD 101261, 101278, 101295, 101312, 101329, 101347, 101364, 101381 - DD 101398, 101415, 101432, 101450, 101467, 101484, 101501, 101518 - DD 101535, 101553, 101570, 101587, 101604, 101621, 101639, 101656 - DD 101673, 101690, 101707, 101725, 101742, 101759, 101776, 101793 - DD 101811, 101828, 101845, 101862, 101880, 101897, 101914, 101931 - DD 101949, 101966, 101983, 102000, 102018, 102035, 102052, 102069 - DD 102087, 102104, 102121, 102139, 102156, 102173, 102190, 102208 - DD 102225, 102242, 102260, 102277, 102294, 102312, 102329, 102346 - DD 102363, 102381, 102398, 102415, 102433, 102450, 102467, 102485 - DD 102502, 102520, 102537, 102554, 102572, 102589, 102606, 102624 - DD 102641, 102658, 102676, 102693, 102711, 102728, 102745, 102763 - DD 102780, 102797, 102815, 102832, 102850, 102867, 102884, 102902 - DD 102919, 102937, 102954, 102972, 102989, 103006, 103024, 103041 - DD 103059, 103076, 103094, 103111, 103129, 103146, 103163, 103181 - DD 103198, 103216, 103233, 103251, 103268, 103286, 103303, 103321 - DD 103338, 103356, 103373, 103391, 103408, 103426, 103443, 103461 - DD 103478, 103496, 103513, 103531, 103548, 103566, 103583, 103601 - DD 103618, 103636, 103653, 103671, 103689, 103706, 103724, 103741 - DD 103759, 103776, 103794, 103811, 103829, 103847, 103864, 103882 - DD 103899, 103917, 103934, 103952, 103970, 103987, 104005, 104022 - DD 104040, 104058, 104075, 104093, 104110, 104128, 104146, 104163 - DD 104181, 104199, 104216, 104234, 104252, 104269, 104287, 104304 - DD 104322, 104340, 104357, 104375, 104393, 104410, 104428, 104446 - DD 104463, 104481, 104499, 104516, 104534, 104552, 104570, 104587 - DD 104605, 104623, 104640, 104658, 104676, 104694, 104711, 104729 - DD 104747, 104764, 104782, 104800, 104818, 104835, 104853, 104871 - DD 104889, 104906, 104924, 104942, 104960, 104977, 104995, 105013 - DD 105031, 105048, 105066, 105084, 105102, 105120, 105137, 105155 - DD 105173, 105191, 105209, 105226, 105244, 105262, 105280, 105298 - DD 105315, 105333, 105351, 105369, 105387, 105405, 105422, 105440 - DD 105458, 105476, 105494, 105512, 105530, 105547, 105565, 105583 - DD 105601, 105619, 105637, 105655, 105672, 105690, 105708, 105726 - DD 105744, 105762, 105780, 105798, 105816, 105834, 105851, 105869 - DD 105887, 105905, 105923, 105941, 105959, 105977, 105995, 106013 - DD 106031, 106049, 106067, 106085, 106103, 106120, 106138, 106156 - DD 106174, 106192, 106210, 106228, 106246, 106264, 106282, 106300 - DD 106318, 106336, 106354, 106372, 106390, 106408, 106426, 106444 - DD 106462, 106480, 106498, 106516, 106534, 106552, 106570, 106588 - DD 106606, 106624, 106643, 106661, 106679, 106697, 106715, 106733 - DD 106751, 106769, 106787, 106805, 106823, 106841, 106859, 106877 - DD 106895, 106914, 106932, 106950, 106968, 106986, 107004, 107022 - DD 107040, 107058, 107077, 107095, 107113, 107131, 107149, 107167 - DD 107185, 107203, 107222, 107240, 107258, 107276, 107294, 107312 - DD 107331, 107349, 107367, 107385, 107403, 107421, 107440, 107458 - DD 107476, 107494, 107512, 107531, 107549, 107567, 107585, 107603 - DD 107622, 107640, 107658, 107676, 107694, 107713, 107731, 107749 - DD 107767, 107786, 107804, 107822, 107840, 107859, 107877, 107895 - DD 107913, 107932, 107950, 107968, 107986, 108005, 108023, 108041 - DD 108060, 108078, 108096, 108114, 108133, 108151, 108169, 108188 - DD 108206, 108224, 108243, 108261, 108279, 108297, 108316, 108334 - DD 108352, 108371, 108389, 108408, 108426, 108444, 108463, 108481 - DD 108499, 108518, 108536, 108554, 108573, 108591, 108609, 108628 - DD 108646, 108665, 108683, 108701, 108720, 108738, 108757, 108775 - DD 108793, 108812, 108830, 108849, 108867, 108886, 108904, 108922 - DD 108941, 108959, 108978, 108996, 109015, 109033, 109051, 109070 - DD 109088, 109107, 109125, 109144, 109162, 109181, 109199, 109218 - DD 109236, 109255, 109273, 109292, 109310, 109329, 109347, 109366 - DD 109384, 109403, 109421, 109440, 109458, 109477, 109495, 109514 - DD 109532, 109551, 109569, 109588, 109607, 109625, 109644, 109662 - DD 109681, 109699, 109718, 109736, 109755, 109774, 109792, 109811 - DD 109829, 109848, 109867, 109885, 109904, 109922, 109941, 109960 - DD 109978, 109997, 110015, 110034, 110053, 110071, 110090, 110108 - DD 110127, 110146, 110164, 110183, 110202, 110220, 110239, 110258 - DD 110276, 110295, 110314, 110332, 110351, 110370, 110388, 110407 - DD 110426, 110444, 110463, 110482, 110500, 110519, 110538, 110557 - DD 110575, 110594, 110613, 110631, 110650, 110669, 110688, 110706 - DD 110725, 110744, 110763, 110781, 110800, 110819, 110838, 110856 - DD 110875, 110894, 110913, 110931, 110950, 110969, 110988, 111007 - DD 111025, 111044, 111063, 111082, 111100, 111119, 111138, 111157 - DD 111176, 111195, 111213, 111232, 111251, 111270, 111289, 111307 - DD 111326, 111345, 111364, 111383, 111402, 111421, 111439, 111458 - DD 111477, 111496, 111515, 111534, 111553, 111571, 111590, 111609 - DD 111628, 111647, 111666, 111685, 111704, 111723, 111742, 111760 - DD 111779, 111798, 111817, 111836, 111855, 111874, 111893, 111912 - DD 111931, 111950, 111969, 111988, 112007, 112026, 112045, 112063 - DD 112082, 112101, 112120, 112139, 112158, 112177, 112196, 112215 - DD 112234, 112253, 112272, 112291, 112310, 112329, 112348, 112367 - DD 112386, 112405, 112424, 112443, 112462, 112481, 112500, 112520 - DD 112539, 112558, 112577, 112596, 112615, 112634, 112653, 112672 - DD 112691, 112710, 112729, 112748, 112767, 112786, 112806, 112825 - DD 112844, 112863, 112882, 112901, 112920, 112939, 112958, 112977 - DD 112997, 113016, 113035, 113054, 113073, 113092, 113111, 113130 - DD 113150, 113169, 113188, 113207, 113226, 113245, 113265, 113284 - DD 113303, 113322, 113341, 113360, 113380, 113399, 113418, 113437 - DD 113456, 113476, 113495, 113514, 113533, 113552, 113572, 113591 - DD 113610, 113629, 113649, 113668, 113687, 113706, 113726, 113745 - DD 113764, 113783, 113803, 113822, 113841, 113860, 113880, 113899 - DD 113918, 113937, 113957, 113976, 113995, 114015, 114034, 114053 - DD 114072, 114092, 114111, 114130, 114150, 114169, 114188, 114208 - DD 114227, 114246, 114266, 114285, 114304, 114324, 114343, 114362 - DD 114382, 114401, 114420, 114440, 114459, 114479, 114498, 114517 - DD 114537, 114556, 114575, 114595, 114614, 114634, 114653, 114672 - DD 114692, 114711, 114731, 114750, 114770, 114789, 114808, 114828 - DD 114847, 114867, 114886, 114906, 114925, 114944, 114964, 114983 - DD 115003, 115022, 115042, 115061, 115081, 115100, 115120, 115139 - DD 115159, 115178, 115198, 115217, 115237, 115256, 115276, 115295 - DD 115315, 115334, 115354, 115373, 115393, 115412, 115432, 115451 - DD 115471, 115490, 115510, 115529, 115549, 115569, 115588, 115608 - DD 115627, 115647, 115666, 115686, 115706, 115725, 115745, 115764 - DD 115784, 115804, 115823, 115843, 115862, 115882, 115902, 115921 - DD 115941, 115960, 115980, 116000, 116019, 116039, 116059, 116078 - DD 116098, 116117, 116137, 116157, 116176, 116196, 116216, 116235 - DD 116255, 116275, 116294, 116314, 116334, 116354, 116373, 116393 - DD 116413, 116432, 116452, 116472, 116491, 116511, 116531, 116551 - DD 116570, 116590, 116610, 116630, 116649, 116669, 116689, 116708 - DD 116728, 116748, 116768, 116788, 116807, 116827, 116847, 116867 - DD 116886, 116906, 116926, 116946, 116966, 116985, 117005, 117025 - DD 117045, 117065, 117084, 117104, 117124, 117144, 117164, 117183 - DD 117203, 117223, 117243, 117263, 117283, 117302, 117322, 117342 - DD 117362, 117382, 117402, 117422, 117442, 117461, 117481, 117501 - DD 117521, 117541, 117561, 117581, 117601, 117621, 117640, 117660 - DD 117680, 117700, 117720, 117740, 117760, 117780, 117800, 117820 - DD 117840, 117860, 117880, 117900, 117919, 117939, 117959, 117979 - DD 117999, 118019, 118039, 118059, 118079, 118099, 118119, 118139 - DD 118159, 118179, 118199, 118219, 118239, 118259, 118279, 118299 - DD 118319, 118339, 118359, 118379, 118399, 118419, 118439, 118459 - DD 118480, 118500, 118520, 118540, 118560, 118580, 118600, 118620 - DD 118640, 118660, 118680, 118700, 118720, 118740, 118761, 118781 - DD 118801, 118821, 118841, 118861, 118881, 118901, 118921, 118942 - DD 118962, 118982, 119002, 119022, 119042, 119062, 119083, 119103 - DD 119123, 119143, 119163, 119183, 119204, 119224, 119244, 119264 - DD 119284, 119304, 119325, 119345, 119365, 119385, 119405, 119426 - DD 119446, 119466, 119486, 119506, 119527, 119547, 119567, 119587 - DD 119608, 119628, 119648, 119668, 119689, 119709, 119729, 119749 - DD 119770, 119790, 119810, 119831, 119851, 119871, 119891, 119912 - DD 119932, 119952, 119973, 119993, 120013, 120033, 120054, 120074 - DD 120094, 120115, 120135, 120155, 120176, 120196, 120216, 120237 - DD 120257, 120277, 120298, 120318, 120339, 120359, 120379, 120400 - DD 120420, 120440, 120461, 120481, 120502, 120522, 120542, 120563 - DD 120583, 120604, 120624, 120644, 120665, 120685, 120706, 120726 - DD 120747, 120767, 120787, 120808, 120828, 120849, 120869, 120890 - DD 120910, 120931, 120951, 120971, 120992, 121012, 121033, 121053 - DD 121074, 121094, 121115, 121135, 121156, 121176, 121197, 121217 - DD 121238, 121258, 121279, 121299, 121320, 121341, 121361, 121382 - DD 121402, 121423, 121443, 121464, 121484, 121505, 121525, 121546 - DD 121567, 121587, 121608, 121628, 121649, 121670, 121690, 121711 - DD 121731, 121752, 121773, 121793, 121814, 121834, 121855, 121876 - DD 121896, 121917, 121937, 121958, 121979, 121999, 122020, 122041 - DD 122061, 122082, 122103, 122123, 122144, 122165, 122185, 122206 - DD 122227, 122247, 122268, 122289, 122309, 122330, 122351, 122372 - DD 122392, 122413, 122434, 122454, 122475, 122496, 122517, 122537 - DD 122558, 122579, 122600, 122620, 122641, 122662, 122683, 122703 - DD 122724, 122745, 122766, 122786, 122807, 122828, 122849, 122870 - DD 122890, 122911, 122932, 122953, 122974, 122994, 123015, 123036 - DD 123057, 123078, 123099, 123119, 123140, 123161, 123182, 123203 - DD 123224, 123244, 123265, 123286, 123307, 123328, 123349, 123370 - DD 123391, 123411, 123432, 123453, 123474, 123495, 123516, 123537 - DD 123558, 123579, 123599, 123620, 123641, 123662, 123683, 123704 - DD 123725, 123746, 123767, 123788, 123809, 123830, 123851, 123872 - DD 123893, 123914, 123935, 123956, 123977, 123998, 124019, 124040 - DD 124061, 124081, 124102, 124124, 124145, 124166, 124187, 124208 - DD 124229, 124250, 124271, 124292, 124313, 124334, 124355, 124376 - DD 124397, 124418, 124439, 124460, 124481, 124502, 124523, 124544 - DD 124565, 124586, 124608, 124629, 124650, 124671, 124692, 124713 - DD 124734, 124755, 124776, 124797, 124819, 124840, 124861, 124882 - DD 124903, 124924, 124945, 124967, 124988, 125009, 125030, 125051 - DD 125072, 125093, 125115, 125136, 125157, 125178, 125199, 125221 - DD 125242, 125263, 125284, 125305, 125327, 125348, 125369, 125390 - DD 125411, 125433, 125454, 125475, 125496, 125518, 125539, 125560 - DD 125581, 125603, 125624, 125645, 125666, 125688, 125709, 125730 - DD 125751, 125773, 125794, 125815, 125837, 125858, 125879, 125901 - DD 125922, 125943, 125964, 125986, 126007, 126028, 126050, 126071 - DD 126092, 126114, 126135, 126156, 126178, 126199, 126220, 126242 - DD 126263, 126285, 126306, 126327, 126349, 126370, 126391, 126413 - DD 126434, 126456, 126477, 126498, 126520, 126541, 126563, 126584 - DD 126606, 126627, 126648, 126670, 126691, 126713, 126734, 126756 - DD 126777, 126799, 126820, 126841, 126863, 126884, 126906, 126927 - DD 126949, 126970, 126992, 127013, 127035, 127056, 127078, 127099 - DD 127121, 127142, 127164, 127185, 127207, 127228, 127250, 127271 - DD 127293, 127315, 127336, 127358, 127379, 127401, 127422, 127444 - DD 127465, 127487, 127509, 127530, 127552, 127573, 127595, 127617 - DD 127638, 127660, 127681, 127703, 127725, 127746, 127768, 127789 - DD 127811, 127833, 127854, 127876, 127898, 127919, 127941, 127963 - DD 127984, 128006, 128028, 128049, 128071, 128093, 128114, 128136 - DD 128158, 128179, 128201, 128223, 128244, 128266, 128288, 128309 - DD 128331, 128353, 128375, 128396, 128418, 128440, 128462, 128483 - DD 128505, 128527, 128549, 128570, 128592, 128614, 128636, 128657 - DD 128679, 128701, 128723, 128744, 128766, 128788, 128810, 128832 - DD 128853, 128875, 128897, 128919, 128941, 128963, 128984, 129006 - DD 129028, 129050, 129072, 129094, 129115, 129137, 129159, 129181 - DD 129203, 129225, 129247, 129268, 129290, 129312, 129334, 129356 - DD 129378, 129400, 129422, 129444, 129465, 129487, 129509, 129531 - DD 129553, 129575, 129597, 129619, 129641, 129663, 129685, 129707 - DD 129729, 129751, 129773, 129794, 129816, 129838, 129860, 129882 - DD 129904, 129926, 129948, 129970, 129992, 130014, 130036, 130058 - DD 130080, 130102, 130124, 130146, 130168, 130190, 130212, 130235 - DD 130257, 130279, 130301, 130323, 130345, 130367, 130389, 130411 - DD 130433, 130455, 130477, 130499, 130521, 130543, 130566, 130588 - DD 130610, 130632, 130654, 130676, 130698, 130720, 130742, 130765 - DD 130787, 130809, 130831, 130853, 130875, 130897, 130920, 130942 - DD 130964, 130986, 131008, 131030, 131053, 131075, 131097, 131119 - DD 131141, 131163, 131186, 131208, 131230, 131252, 131274, 131297 - DD 131319, 131341, 131363, 131386, 131408, 131430, 131452, 131475 - DD 131497, 131519, 131541, 131564, 131586, 131608, 131630, 131653 - DD 131675, 131697, 131720, 131742, 131764, 131786, 131809, 131831 - DD 131853, 131876, 131898, 131920, 131943, 131965, 131987, 132010 - DD 132032, 132054, 132077, 132099, 132121, 132144, 132166, 132188 - DD 132211, 132233, 132256, 132278, 132300, 132323, 132345, 132368 - DD 132390, 132412, 132435, 132457, 132480, 132502, 132524, 132547 - DD 132569, 132592, 132614, 132637, 132659, 132682, 132704, 132726 - DD 132749, 132771, 132794, 132816, 132839, 132861, 132884, 132906 - DD 132929, 132951, 132974, 132996, 133019, 133041, 133064, 133086 - DD 133109, 133131, 133154, 133176, 133199, 133221, 133244, 133267 - DD 133289, 133312, 133334, 133357, 133379, 133402, 133425, 133447 - DD 133470, 133492, 133515, 133537, 133560, 133583, 133605, 133628 - DD 133651, 133673, 133696, 133718, 133741, 133764, 133786, 133809 - DD 133832, 133854, 133877, 133900, 133922, 133945, 133968, 133990 - DD 134013, 134036, 134058, 134081, 134104, 134126, 134149, 134172 - DD 134194, 134217, 134240, 134263, 134285, 134308, 134331, 134353 - DD 134376, 134399, 134422, 134444, 134467, 134490, 134513, 134535 - DD 134558, 134581, 134604, 134627, 134649, 134672, 134695, 134718 - DD 134741, 134763, 134786, 134809, 134832, 134855, 134877, 134900 - DD 134923, 134946, 134969, 134992, 135014, 135037, 135060, 135083 - DD 135106, 135129, 135152, 135174, 135197, 135220, 135243, 135266 - DD 135289, 135312, 135335, 135358, 135381, 135403, 135426, 135449 - DD 135472, 135495, 135518, 135541, 135564, 135587, 135610, 135633 - DD 135656, 135679, 135702, 135725, 135748, 135771, 135794, 135816 - DD 135839, 135862, 135885, 135908, 135931, 135954, 135977, 136000 - DD 136023, 136047, 136070, 136093, 136116, 136139, 136162, 136185 - DD 136208, 136231, 136254, 136277, 136300, 136323, 136346, 136369 - DD 136392, 136415, 136438, 136462, 136485, 136508, 136531, 136554 - DD 136577, 136600, 136623, 136646, 136670, 136693, 136716, 136739 - DD 136762, 136785, 136808, 136832, 136855, 136878, 136901, 136924 - DD 136947, 136971, 136994, 137017, 137040, 137063, 137086, 137110 - DD 137133, 137156, 137179, 137203, 137226, 137249, 137272, 137295 - DD 137319, 137342, 137365, 137388, 137412, 137435, 137458, 137481 - DD 137505, 137528, 137551, 137575, 137598, 137621, 137644, 137668 - DD 137691, 137714, 137738, 137761, 137784, 137808, 137831, 137854 - DD 137877, 137901, 137924, 137948, 137971, 137994, 138018, 138041 - DD 138064, 138088, 138111, 138134, 138158, 138181, 138205, 138228 - DD 138251, 138275, 138298, 138322, 138345, 138368, 138392, 138415 - DD 138439, 138462, 138485, 138509, 138532, 138556, 138579, 138603 - DD 138626, 138650, 138673, 138697, 138720, 138744, 138767, 138790 - DD 138814, 138837, 138861, 138884, 138908, 138931, 138955, 138978 - DD 139002, 139026, 139049, 139073, 139096, 139120, 139143, 139167 - DD 139190, 139214, 139237, 139261, 139285, 139308, 139332, 139355 - DD 139379, 139402, 139426, 139450, 139473, 139497, 139520, 139544 - DD 139568, 139591, 139615, 139639, 139662, 139686, 139709, 139733 - DD 139757, 139780, 139804, 139828, 139851, 139875, 139899, 139922 - DD 139946, 139970, 139993, 140017, 140041, 140065, 140088, 140112 - DD 140136, 140159, 140183, 140207, 140231, 140254, 140278, 140302 - DD 140326, 140349, 140373, 140397, 140421, 140444, 140468, 140492 - DD 140516, 140539, 140563, 140587, 140611, 140635, 140658, 140682 - DD 140706, 140730, 140754, 140777, 140801, 140825, 140849, 140873 - DD 140897, 140920, 140944, 140968, 140992, 141016, 141040, 141064 - DD 141087, 141111, 141135, 141159, 141183, 141207, 141231, 141255 - DD 141279, 141303, 141326, 141350, 141374, 141398, 141422, 141446 - DD 141470, 141494, 141518, 141542, 141566, 141590, 141614, 141638 - DD 141662, 141686, 141710, 141734, 141758, 141782, 141806, 141830 - DD 141854, 141878, 141902, 141926, 141950, 141974, 141998, 142022 - DD 142046, 142070, 142094, 142118, 142142, 142166, 142190, 142214 - DD 142238, 142262, 142286, 142310, 142334, 142359, 142383, 142407 - DD 142431, 142455, 142479, 142503, 142527, 142551, 142576, 142600 - DD 142624, 142648, 142672, 142696, 142720, 142745, 142769, 142793 - DD 142817, 142841, 142865, 142890, 142914, 142938, 142962, 142986 - DD 143011, 143035, 143059, 143083, 143107, 143132, 143156, 143180 - DD 143204, 143228, 143253, 143277, 143301, 143325, 143350, 143374 - DD 143398, 143423, 143447, 143471, 143495, 143520, 143544, 143568 - DD 143593, 143617, 143641, 143665, 143690, 143714, 143738, 143763 - DD 143787, 143811, 143836, 143860, 143884, 143909, 143933, 143957 - DD 143982, 144006, 144031, 144055, 144079, 144104, 144128, 144152 - DD 144177, 144201, 144226, 144250, 144275, 144299, 144323, 144348 - DD 144372, 144397, 144421, 144446, 144470, 144494, 144519, 144543 - DD 144568, 144592, 144617, 144641, 144666, 144690, 144715, 144739 - DD 144764, 144788, 144813, 144837, 144862, 144886, 144911, 144935 - DD 144960, 144984, 145009, 145033, 145058, 145082, 145107, 145132 - DD 145156, 145181, 145205, 145230, 145254, 145279, 145304, 145328 - DD 145353, 145377, 145402, 145427, 145451, 145476, 145500, 145525 - DD 145550, 145574, 145599, 145624, 145648, 145673, 145698, 145722 - DD 145747, 145772, 145796, 145821, 145846, 145870, 145895, 145920 - DD 145944, 145969, 145994, 146018, 146043, 146068, 146093, 146117 - DD 146142, 146167, 146191, 146216, 146241, 146266, 146290, 146315 - DD 146340, 146365, 146390, 146414, 146439, 146464, 146489, 146513 - DD 146538, 146563, 146588, 146613, 146637, 146662, 146687, 146712 - DD 146737, 146762, 146786, 146811, 146836, 146861, 146886, 146911 - DD 146936, 146960, 146985, 147010, 147035, 147060, 147085, 147110 - DD 147135, 147160, 147184, 147209, 147234, 147259, 147284, 147309 - DD 147334, 147359, 147384, 147409, 147434, 147459, 147484, 147509 - DD 147534, 147559, 147583, 147608, 147633, 147658, 147683, 147708 - DD 147733, 147758, 147783, 147808, 147833, 147858, 147883, 147909 - DD 147934, 147959, 147984, 148009, 148034, 148059, 148084, 148109 - DD 148134, 148159, 148184, 148209, 148234, 148259, 148284, 148310 - DD 148335, 148360, 148385, 148410, 148435, 148460, 148485, 148510 - DD 148536, 148561, 148586, 148611, 148636, 148661, 148686, 148712 - DD 148737, 148762, 148787, 148812, 148838, 148863, 148888, 148913 - DD 148938, 148964, 148989, 149014, 149039, 149064, 149090, 149115 - DD 149140, 149165, 149191, 149216, 149241, 149266, 149292, 149317 - DD 149342, 149367, 149393, 149418, 149443, 149469, 149494, 149519 - DD 149544, 149570, 149595, 149620, 149646, 149671, 149696, 149722 - DD 149747, 149772, 149798, 149823, 149848, 149874, 149899, 149925 - DD 149950, 149975, 150001, 150026, 150051, 150077, 150102, 150128 - DD 150153, 150178, 150204, 150229, 150255, 150280, 150306, 150331 - DD 150356, 150382, 150407, 150433, 150458, 150484, 150509, 150535 - DD 150560, 150586, 150611, 150637, 150662, 150688, 150713, 150739 - DD 150764, 150790, 150815, 150841, 150866, 150892, 150917, 150943 - DD 150968, 150994, 151019, 151045, 151071, 151096, 151122, 151147 - DD 151173, 151198, 151224, 151250, 151275, 151301, 151326, 151352 - DD 151378, 151403, 151429, 151455, 151480, 151506, 151531, 151557 - DD 151583, 151608, 151634, 151660, 151685, 151711, 151737, 151762 - DD 151788, 151814, 151839, 151865, 151891, 151917, 151942, 151968 - DD 151994, 152019, 152045, 152071, 152097, 152122, 152148, 152174 - DD 152200, 152225, 152251, 152277, 152303, 152328, 152354, 152380 - DD 152406, 152432, 152457, 152483, 152509, 152535, 152561, 152586 - DD 152612, 152638, 152664, 152690, 152716, 152741, 152767, 152793 - DD 152819, 152845, 152871, 152897, 152922, 152948, 152974, 153000 - DD 153026, 153052, 153078, 153104, 153130, 153156, 153181, 153207 - DD 153233, 153259, 153285, 153311, 153337, 153363, 153389, 153415 - DD 153441, 153467, 153493, 153519, 153545, 153571, 153597, 153623 - DD 153649, 153675, 153701, 153727, 153753, 153779, 153805, 153831 - DD 153857, 153883, 153909, 153935, 153961, 153987, 154013, 154039 - DD 154065, 154091, 154118, 154144, 154170, 154196, 154222, 154248 - DD 154274, 154300, 154326, 154352, 154379, 154405, 154431, 154457 - DD 154483, 154509, 154535, 154562, 154588, 154614, 154640, 154666 - DD 154692, 154719, 154745, 154771, 154797, 154823, 154850, 154876 - DD 154902, 154928, 154954, 154981, 155007, 155033, 155059, 155086 - DD 155112, 155138, 155164, 155191, 155217, 155243, 155269, 155296 - DD 155322, 155348, 155374, 155401, 155427, 155453, 155480, 155506 - DD 155532, 155559, 155585, 155611, 155638, 155664, 155690, 155717 - DD 155743, 155769, 155796, 155822, 155848, 155875, 155901, 155928 - DD 155954, 155980, 156007, 156033, 156060, 156086, 156112, 156139 - DD 156165, 156192, 156218, 156245, 156271, 156297, 156324, 156350 - DD 156377, 156403, 156430, 156456, 156483, 156509, 156536, 156562 - DD 156589, 156615, 156642, 156668, 156695, 156721, 156748, 156774 - DD 156801, 156827, 156854, 156880, 156907, 156934, 156960, 156987 - DD 157013, 157040, 157066, 157093, 157120, 157146, 157173, 157199 - DD 157226, 157253, 157279, 157306, 157332, 157359, 157386, 157412 - DD 157439, 157466, 157492, 157519, 157546, 157572, 157599, 157626 - DD 157652, 157679, 157706, 157732, 157759, 157786, 157812, 157839 - DD 157866, 157893, 157919, 157946, 157973, 157999, 158026, 158053 - DD 158080, 158106, 158133, 158160, 158187, 158213, 158240, 158267 - DD 158294, 158321, 158347, 158374, 158401, 158428, 158455, 158481 - DD 158508, 158535, 158562, 158589, 158616, 158642, 158669, 158696 - DD 158723, 158750, 158777, 158804, 158830, 158857, 158884, 158911 - DD 158938, 158965, 158992, 159019, 159046, 159073, 159100, 159126 - DD 159153, 159180, 159207, 159234, 159261, 159288, 159315, 159342 - DD 159369, 159396, 159423, 159450, 159477, 159504, 159531, 159558 - DD 159585, 159612, 159639, 159666, 159693, 159720, 159747, 159774 - DD 159801, 159828, 159855, 159882, 159909, 159936, 159963, 159990 - DD 160018, 160045, 160072, 160099, 160126, 160153, 160180, 160207 - DD 160234, 160261, 160289, 160316, 160343, 160370, 160397, 160424 - DD 160451, 160479, 160506, 160533, 160560, 160587, 160614, 160642 - DD 160669, 160696, 160723, 160750, 160778, 160805, 160832, 160859 - DD 160886, 160914, 160941, 160968, 160995, 161023, 161050, 161077 - DD 161104, 161132, 161159, 161186, 161213, 161241, 161268, 161295 - DD 161323, 161350, 161377, 161405, 161432, 161459, 161487, 161514 - DD 161541, 161569, 161596, 161623, 161651, 161678, 161705, 161733 - DD 161760, 161787, 161815, 161842, 161870, 161897, 161924, 161952 - DD 161979, 162007, 162034, 162061, 162089, 162116, 162144, 162171 - DD 162199, 162226, 162253, 162281, 162308, 162336, 162363, 162391 - DD 162418, 162446, 162473, 162501, 162528, 162556, 162583, 162611 - DD 162638, 162666, 162693, 162721, 162748, 162776, 162804, 162831 - DD 162859, 162886, 162914, 162941, 162969, 162997, 163024, 163052 - DD 163079, 163107, 163135, 163162, 163190, 163217, 163245, 163273 - DD 163300, 163328, 163356, 163383, 163411, 163438, 163466, 163494 - DD 163521, 163549, 163577, 163604, 163632, 163660, 163688, 163715 - DD 163743, 163771, 163798, 163826, 163854, 163882, 163909, 163937 - DD 163965, 163993, 164020, 164048, 164076, 164104, 164131, 164159 - DD 164187, 164215, 164243, 164270, 164298, 164326, 164354, 164382 - DD 164409, 164437, 164465, 164493, 164521, 164549, 164576, 164604 - DD 164632, 164660, 164688, 164716, 164744, 164771, 164799, 164827 - DD 164855, 164883, 164911, 164939, 164967, 164995, 165023, 165051 - DD 165078, 165106, 165134, 165162, 165190, 165218, 165246, 165274 - DD 165302, 165330, 165358, 165386, 165414, 165442, 165470, 165498 - DD 165526, 165554, 165582, 165610, 165638, 165666, 165694, 165722 - DD 165750, 165778, 165806, 165834, 165862, 165891, 165919, 165947 - DD 165975, 166003, 166031, 166059, 166087, 166115, 166143, 166172 - DD 166200, 166228, 166256, 166284, 166312, 166340, 166368, 166397 - DD 166425, 166453, 166481, 166509, 166538, 166566, 166594, 166622 - DD 166650, 166678, 166707, 166735, 166763, 166791, 166820, 166848 - DD 166876, 166904, 166933, 166961, 166989, 167017, 167046, 167074 - DD 167102, 167130, 167159, 167187, 167215, 167244, 167272, 167300 - DD 167328, 167357, 167385, 167413, 167442, 167470, 167498, 167527 - DD 167555, 167584, 167612, 167640, 167669, 167697, 167725, 167754 - DD 167782, 167811, 167839, 167867, 167896, 167924, 167953, 167981 - DD 168009, 168038, 168066, 168095, 168123, 168152, 168180, 168209 - DD 168237, 168266, 168294, 168322, 168351, 168379, 168408, 168436 - DD 168465, 168493, 168522, 168551, 168579, 168608, 168636, 168665 - DD 168693, 168722, 168750, 168779, 168807, 168836, 168865, 168893 - DD 168922, 168950, 168979, 169007, 169036, 169065, 169093, 169122 - DD 169151, 169179, 169208, 169236, 169265, 169294, 169322, 169351 - DD 169380, 169408, 169437, 169466, 169494, 169523, 169552, 169580 - DD 169609, 169638, 169667, 169695, 169724, 169753, 169781, 169810 - DD 169839, 169868, 169896, 169925, 169954, 169983, 170011, 170040 - DD 170069, 170098, 170127, 170155, 170184, 170213, 170242, 170271 - DD 170299, 170328, 170357, 170386, 170415, 170444, 170472, 170501 - DD 170530, 170559, 170588, 170617, 170646, 170674, 170703, 170732 - DD 170761, 170790, 170819, 170848, 170877, 170906, 170935, 170964 - DD 170992, 171021, 171050, 171079, 171108, 171137, 171166, 171195 - DD 171224, 171253, 171282, 171311, 171340, 171369, 171398, 171427 - DD 171456, 171485, 171514, 171543, 171572, 171601, 171630, 171659 - DD 171688, 171717, 171746, 171776, 171805, 171834, 171863, 171892 - DD 171921, 171950, 171979, 172008, 172037, 172066, 172096, 172125 - DD 172154, 172183, 172212, 172241, 172270, 172300, 172329, 172358 - DD 172387, 172416, 172445, 172475, 172504, 172533, 172562, 172591 - DD 172621, 172650, 172679, 172708, 172737, 172767, 172796, 172825 - DD 172854, 172884, 172913, 172942, 172972, 173001, 173030, 173059 - DD 173089, 173118, 173147, 173177, 173206, 173235, 173264, 173294 - DD 173323, 173352, 173382, 173411, 173440, 173470, 173499, 173529 - DD 173558, 173587, 173617, 173646, 173675, 173705, 173734, 173764 - DD 173793, 173822, 173852, 173881, 173911, 173940, 173970, 173999 - DD 174028, 174058, 174087, 174117, 174146, 174176, 174205, 174235 - DD 174264, 174294, 174323, 174353, 174382, 174412, 174441, 174471 - DD 174500, 174530, 174559, 174589, 174618, 174648, 174678, 174707 - DD 174737, 174766, 174796, 174825, 174855, 174885, 174914, 174944 - DD 174973, 175003, 175033, 175062, 175092, 175122, 175151, 175181 - DD 175210, 175240, 175270, 175299, 175329, 175359, 175388, 175418 - DD 175448, 175478, 175507, 175537, 175567, 175596, 175626, 175656 - DD 175686, 175715, 175745, 175775, 175804, 175834, 175864, 175894 - DD 175924, 175953, 175983, 176013, 176043, 176072, 176102, 176132 - DD 176162, 176192, 176221, 176251, 176281, 176311, 176341, 176371 - -GUSScreenList Label - DW 7 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr GravisHeaderLine - - DW Near Ptr MixerText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr MasterVolumeLeft ; 7 - DW Near Ptr MasterVolumeRight - DW Near Ptr TrebleVolumeLeft - DW Near Ptr TrebleVolumeRight - DW Near Ptr BassVolumeLeft - DW Near Ptr BassVolumeRight ; 12 - - DW Near Ptr SampleText - - DW Near Ptr SampleSize0Button ; 14 - DW Near Ptr SampleSize1Button - DW Near Ptr SampleSize2Button - DW Near Ptr SampleSize3Button ; 17 - - DW Near Ptr EffectText - DW Near Ptr EffectBox - - DW Near Ptr ChorusThumbBar ; 20 - DW Near Ptr ReverbThumbBar - - DW DriverText - - DW 0 - -GravisHeaderLine DW 10 - DB "Sound Blaster AWE 32 Driver", 0 - -DriverText DW 1 - DB 27, 48 - DB 21h - DB "Sound Blaster AWE 32 Driver 1.5 for Impulse Tracker", 0 - -MixerText DW 1 - DB 3, 13 - DB 20h - DB "Mixer options", 13 - DB 13 - DB " Master Volume Left", 13 - DB " Master Volume Right", 13 - DB 13 - DB 13 - DB " Treble Left", 13 - DB " Treble Right", 13 - DB " Bass Left", 13 - DB " Bass Right", 13 - DB 0 - -VolumeBox1 DW 0 - DB 24, 14, 30, 17 - DB 25 - -VolumeBox2 DW 0 - DB 17, 18, 21, 23 - DB 25 - -MasterVolumeLeft DW 9 - DB 25, 15 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 8, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 25, 16 - DW 0, 31 - DW 9, 1 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 18, 19 - DW 0, 15 - DW 9, 2 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 18, 20 - DW 0, 15 - DW 9, 3 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 18, 21 - DW 0, 15 - DW 9, 4 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 18, 22 - DW 0, 15 - DW 9, 5 - DW 11, 14, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -SampleText DW 1 - DB 3, 25 - DB 20h - DB "Sample resizing options", 0 - -SampleSize0Button DW 2 - DW 12, 15, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment1 DW 0 - DW 0 - DW Offset SetCompress -DriverSegment2 DW 0 - DB 7, 27, 20, 29, 8 - DB 0 - DB " Original", 0 - -SampleSize1Button DW 2 - DW 14, 16, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment3 DW 0 - DW 1 - DW Offset SetCompress -DriverSegment4 DW 0 - DB 7, 30, 20, 32, 8 - DB 0 - DB " Half", 0 - -SampleSize2Button DW 2 - DW 15, 17, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment5 DW 0 - DW 2 - DW Offset SetCompress -DriverSegment6 DW 0 - DB 7, 33, 20, 35, 8 - DB 0 - DB " Quarter", 0 - -SampleSize3Button DW 2 - DW 16, 20, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment7 DW 0 - DW 3 - DW Offset SetCompress -DriverSegment8 DW 0 - DB 7, 36, 20, 38, 8 - DB 0 - DB " Eighth", 0 - -EffectText DW 1 - DB 3, 40 - DB 20h - DB "Effect options", 13 - DB 13 - DB " Chorus", 13 - DB " Reverb", 0 - - -EffectBox DW 0 - DB 12, 41, 30, 44 - DB 25 - -ChorusThumbBar DW 9 - DB 13, 42 - DW 0, 127 - DW 9, 6 - DW 17, 21, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -ReverbThumbBar DW 9 - DB 13, 43 - DW 0, 127 - DW 9, 7 - DW 20, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - - - -VolumeTable DB 6 Dup (0) -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 2 -Chorus DB 10, 64 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -AWEParameters DB 64 Dup (0FFh), 64 Dup (0) - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectUART ; Given DX = Port - -; From SB-DevKit - - ClI - - Inc DX - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 40h ; Ready for output - LoopNZ DetectUART1 - JNZ DetectUARTError - - Mov AL, 0FFh ; Reset! - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - JNZ DetectUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART4 - -DetectUART3: - Loop DetectUART2 - -DetectUARTError: - StI - StC - Ret - -DetectUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -DetectUART5: - In AL, DX - Test AL, 40h - LoopNZ DetectUART5 - JNZ DetectUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -DetectUART6: - Xor CX, CX - -DetectUART7: - In AL, DX - Test AL, 80h - JNZ DetectUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART9 - -DetectUART8: - Loop DetectUART7 - - Jmp DetectUARTError - -DetectUART9: - StI - ClC - Ret - -EndP DetectUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReinitUART - - Mov DX, MIDIPort - Test DX, DX - JZ ReinitUART1 - - Call DetectUART - -ReinitUART1: - Ret - -EndP ReinitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, MIDIPort - Test DX, DX - JZ ResetUART1 - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetCompress Far - - Mov CX, [SI+22] - Mov CS:Compress, CL - - Mov AX, 1 - ShL AX, CL - Mov CS:Step, AX - - Call Music_LoadAllSamples - - Mov AX, 1 - Ret - -EndP SetCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetCompress Far - - Push CS - Pop ES - Mov DI, Offset Compress - - Ret - -EndP GetCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load8BitSamplesForwards ; Given DS:SI, ECX = count - - Push BX - - Mov BX, CS:Step - Mov DX, CS:BasePort - Add DX, 400h - Xor AL, AL - -Load8BitSamplesForwards2: - Mov AH, [SI] - Add SI, BX - JC Load8BitSamplesForwards4 - -Load8BitSamplesForwards3: - Out DX, AX - - Dec ECX - JNZ Load8BitSamplesForwards2 - - Pop BX - Ret - -Load8BitSamplesForwards4: - Add ESI, 10000h - Int 3 - Jmp Load8BitSamplesForwards3 - -EndP Load8BitSamplesForwards - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load16BitSamplesForwards ; Given DS:SI, ECX = count - - Push BX - - Mov BX, CS:Step - Mov DX, CS:BasePort - Add DX, 400h - Add BX, BX - -Load16BitSamplesForwards2: - Mov AX, [SI] - Add SI, BX - JC Load16BitSamplesForwards4 - -Load16BitSamplesForwards3: - Out DX, AX - - Dec ECX - JNZ Load16BitSamplesForwards2 - - Pop BX - Ret - -Load16BitSamplesForwards4: - Add ESI, 10000h - Int 3 - Jmp Load16BitSamplesForwards3 - -EndP Load16BitSamplesForwards - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load8BitSamplesBackwards ; Given DS:SI, ECX = count - - Push BX - - Mov BX, CS:Step - Mov DX, CS:BasePort - Add DX, 400h - Xor AL, AL - - Sub SI, BX - JC Load8BitSamplesBackwards6 - -Load8BitSamplesBackwards2: - Sub SI, BX - JC Load8BitSamplesBackwards4 - -Load8BitSamplesBackwards3: - Mov AH, [SI] - Out DX, AX - - Dec ECX - JNZ Load8BitSamplesBackwards2 - - - Pop BX - Ret - -Load8BitSamplesBackwards4: - Sub ESI, 10000h - JC Load8BitSamplesBackwards5 - Int 3 - Jmp Load8BitSamplesBackwards3 - -Load8BitSamplesBackwards5: - Xor ESI, ESI - Jmp Load8BitSamplesBackwards3 - -Load8BitSamplesBackwards6: - Sub ESI, 10000h - Int 3 - Jmp Load8BitSamplesBackwards2 - - -EndP Load8BitSamplesBackwards - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load16BitSamplesBackwards ; Given DS:SI, ECX = count - - Push BX - - Mov BX, CS:Step - Mov DX, CS:BasePort - Add DX, 400h - Add BX, BX - - Sub SI, BX - JC Load16BitSamplesBackwards6 - -Load16BitSamplesBackwards2: - Sub SI, BX - JC Load16BitSamplesBackwards4 - -Load16BitSamplesBackwards3: - Mov AX, [SI] - Out DX, AX - - Dec ECX - JNZ Load16BitSamplesBackwards2 - - Pop BX - Ret - -Load16BitSamplesBackwards4: - Sub ESI, 10000h - JC Load16BitSamplesBackwards5 - Int 3 - Jmp Load16BitSamplesBackwards3 - -Load16BitSamplesBackwards5: - Xor ESI, ESI - Jmp Load16BitSamplesBackwards3 - -Load16BitSamplesBackwards6: - Sub ESI, 10000h - Int 3 - Jmp Load16BitSamplesBackwards2 - - -EndP Load16BitSamplesBackwards - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WriteDataChannel - - Or AX, DX - -Proc WriteData ; Have BX/EBX = value - ; AX = xxyyh - ; ^ ^ - ; | | - ; | \-- value to send to pointer register - ; \---- 0, 1, 2 or 3, 4 - ; 0 = data reg 0 - ; 1 = data reg 1, dword - ; 2 = data reg 2 - ; 3 = data reg 3 - ; 4 = data reg 4, word - - Push DX - Push AX - - Mov DX, BasePort - Add DX, 802h - And AX, 0FFh - Out DX, AX - Pop AX - - Cmp AH, 1 - JB WriteDataReg0 - JE WriteDataReg1DWord - Cmp AH, 3 - JB WriteDataReg2 - JE WriteDataReg3 - Jmp WriteDataReg1Word - -WriteDataReg0: - Sub DX, 802h - Mov EAX, EBX - Out DX, EAX - - Pop DX - Ret - -WriteDataReg1DWord: - Sub DX, 402h - Mov EAX, EBX - Out DX, EAX - - Pop DX - Ret - -WriteDataReg1Word: - Sub DX, 402h - Mov AX, BX - Out DX, AX - - Pop DX - Ret - -WriteDataReg2: - Sub DX, 400h - Mov AX, BX - Out DX, AX - - Pop DX - Ret - -WriteDataReg3: - Sub DL, 2 - Mov AX, BX - Out DX, AX - - Pop DX - Ret - -EndP WriteData - -EndP WriteDataChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReadDataChannel - - Or AX, DX - -Proc ReadData ; AX = xxyyh - ; ^ ^ - ; | | - ; | \-- value to send to pointer register - ; \---- 0, 1, 2 or 3, 4 - ; 0 = data reg 0 - ; 1 = data reg 1, dword - ; 2 = data reg 2 - ; 3 = data reg 3 - ; 4 = data reg 4, word - - Push DX - Push AX - - Mov DX, BasePort - Add DX, 802h - And AX, 0FFh - Out DX, AX - Pop AX - - Cmp AH, 1 - JB ReadDataReg0 - JE ReadDataReg1DWord - Cmp AH, 3 - JB ReadDataReg2 - JE ReadDataReg3 - Jmp ReadDataReg1Word - -ReadDataReg0: - Sub DX, 802h - In EAX, DX - - Pop DX - Ret - -ReadDataReg1DWord: - Sub DX, 402h - In EAX, DX - - Pop DX - Ret - -ReadDataReg1Word: - Sub DX, 402h - In AX, DX - - Pop DX - Ret - -ReadDataReg2: - Sub DX, 400h - In AX, DX - - Pop DX - Ret - -ReadDataReg3: - Sub DL, 2 - In AX, DX - - Pop DX - Ret - -EndP ReadData - -EndP ReadDataChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetAWEFrequency - - Push DS - Push SI - Push CX - Push DX - - Mov EAX, [SI+10h] ; Final freq - - Mov CL, Compress - ShR EAX, CL - - Test EAX, EAX - JZ SetAWEFrequencyError - Cmp EAX, 88200*2 - JAE SetAWEFrequencyError - - Push CS - Pop DS - Assume DS:Driver - - And ESI, 0FFFFh - - Mov BX, 0F000h - Mov CX, 0FFFh ; Use binary search - Xor DX, DX ; CX = upper, DX = lower - -SetAWEFrequency1: - Cmp EAX, 88200 - JAE SetAWEFrequency2 - - Sub BX, 1000h - JC SetAWEFrequencyError - Add EAX, EAX - Jmp SetAWEFrequency1 - -SetAWEFrequency2: - Cmp CX, DX - JBE SetAWEFrequency5 - - Mov SI, CX - Add SI, DX - ShR SI, 1 - - Cmp EAX, [AWEPitchTable+ESI*4] - JE SetAWEFrequency3 - JB SetAWEFrequency4 ; In lower half - - ; In upper half - Inc SI - Mov DX, SI - Jmp SetAWEFrequency2 - -SetAWEFrequency4: ; In lower half - Dec SI - Mov CX, SI - Jmp SetAWEFrequency2 - -SetAWEFrequency5: - Mov SI, CX - -SetAWEFrequency3: - Add BX, SI - - Pop DX - Pop CX - Pop SI - Pop DS - - Mov AX, IP - Call WriteDataChannel - - Ret - Assume DS:Nothing - -SetAWEFrequencyError: - Call StopAWENote - - Mov Word Ptr [SI], 200h - Test Byte Ptr [SI+3Ah], 80h - JNZ SetAWEFrequencyError1 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -SetAWEFrequencyError1: - Mov AX, IP - Xor EBX, EBX - Call WriteDataChannel - - Push CS - Pop DS - Mov SI, Offset FrequencyError - Mov BX, 40 - Call SetInfoLine - - Pop DX - Pop CX - Pop SI - Pop DS - - Ret - -EndP SetAWEFrequency - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetAWEPan - - Mov AX, PSST - Call ReadDataChannel ; Get starting offset - - Cmp CS:Stereo, 0 - JE SetPan2 - - Test CL, 128 - JNZ SetPan2 - - Mov BL, [SI+37h] ; Final pan - Cmp BL, 100 ; Surround -> central - JNE SetPan1 - -SetPan2: - Mov BL, 32 - -SetPan1: ; BL = 0->64, need to extend to 0->255 - Add BL, BL - Add BL, BL - SBB BL, 0 ; BL = 0->255 - Not BL - - ShL EAX, 8 - SHLD EBX, EAX, 24 - Mov AX, PSST - Call WriteDataChannel - - Ret - -EndP SetAWEPan - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetAWEVolume - - Test CH, 8 - JZ SetAWEVolume1 - - Test CH, 1 - JNZ SetAWEVolume5 - - Cmp Byte Ptr [SI+8], 0FFh - JE SetAWEVolume4 - -SetAWEVolume5: - Mov Byte Ptr [SI+8], 0FFh - - Mov AX, IFATN - Call ReadDataChannel - Mov BX, AX - Mov AX, IFATN - Mov BL, 0FFh - Call WriteDataChannel - -SetAWEVolume4: - Ret - -SetAWEVolume1: -; First check if channel has been disowned - Xor BX, BX - Mov BL, [SI+3Ah] ; BL = host channel - - Test BL, BL - JS SetAWEVolume3 - -SetAWEVolume2: - Mov AH, [CS:AWEParameters+BX] ; AH = filter - Mov AL, [CS:AWEParameters+BX+64] ; AL = Q. - - ShR AL, 3 - Mov [SI+5Bh], AH - - Cmp AL, [SI+3Fh] - JE SetAWEVolume3 - - Mov [SI+3Fh], AL - -; Set Q - Mov BL, AL - ShL EBX, 28 - - Mov AX, CCCA - Call ReadDataChannel - And EAX, 0FFFFFFFh - Or EBX, EAX - Mov AX, CCCA - Call WriteDataChannel - -SetAWEVolume3: - Mov AL, [SI+3Eh] - Mul Byte Ptr [SI+5Bh] - ShL AX, 1 - Xor BX, BX - Add AH, 1 - Mov BL, [SI+20h] ; Final volume - Mov [SI+8], BL - Mov BL, [CS:AWEVolumeTable+BX] - Mov BH, AH - Mov AX, IFATN - Call WriteDataChannel - - Ret - -EndP SetAWEVolume - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopAWENote - - Mov AX, DCYSUSV - Mov BX, 80h - Call WriteDataChannel - - Mov AX, VTFT - Mov EBX, 0FFFFh - Call WriteDataChannel - - Mov AX, CVCF - Call WriteDataChannel - - Mov BX, 80h - Mov AX, DCYSUSV - Call WriteDataChannel - - Mov AX, VTFT - Mov EBX, 0FFFFh - Call WriteDataChannel - - Mov AX, CVCF - Call WriteDataChannel - - Xor EBX, EBX - Mov AX, ENVVOL - Call WriteDataChannel - - Mov AX, ENVVAL - Call WriteDataChannel - - Mov AX, SUSDCY - Call WriteDataChannel - - Mov AX, ATKHLDV - Call WriteDataChannel - - Mov AX, LFO1VAL - Call WriteDataChannel - - Mov AX, HLDATK - Call WriteDataChannel - - Mov AX, LFO2VAL - Call WriteDataChannel - - Mov AX, IP - Call WriteDataChannel - - Mov AX, IFATN - Call WriteDataChannel - - Mov AX, PEFE - Call WriteDataChannel - - Mov AX, FMMOD - Call WriteDataChannel - - Mov AX, TREMFRQ - Call WriteDataChannel - - Mov AX, FM2FRQ2 - Call WriteDataChannel - - Mov AX, PTRX - Call WriteDataChannel - - Mov AX, VTFT - Call WriteDataChannel - -; Mov AX, PSST -; Call WriteDataChannel - - Mov BL, 8 - Mov AX, CSL - Call WriteDataChannel - - Xor BX, BX - Mov AX, CCCA - Call WriteDataChannel - - Mov AX, CPF - Call WriteDataChannel - - Ret - -EndP StopAWENote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetAWERegisters ; DS:SI = channel info table - ; CX = number of channels... - - Push CX - Push SI - - ; Stage 1. - ; Turn off any channel which has - ; a new note to play - ; If no new note to play and channel - ; is on, then get current position - - Xor DX, DX ; DX = oscillator number - -GetAWERegisters1: - Mov BX, [SI] - Test BH, 2 ; Note cut command - JZ GetAWERegisters2 - - Mov BX, 200h - Mov [SI], BX - - Call StopAWENote - Jmp GetAWERegisters4 - -GetAWERegisters2: - Test BL, 1 ; Channel on? - JZ GetAWERegisters4 - - Test BH, 1 ; New note? - JZ GetAWERegisters3 - - ; Fade out volume - Mov AX, DCYSUSV - Mov BX, 807Fh - Call WriteDataChannel - -; Call StopAWENote - - Jmp GetAWERegisters4 - -GetAWERegisters3: ; Get offset - Mov AX, CCCA - Call ReadDataChannel - - Xor BX, BX - And EAX, 00000000111111111111111111111111b - Inc EAX ; Interpolator correction - ; EAX = address in sound memory - Mov BL, [SI+36h] ; BL = sample number - LEA BX, [EBX*4+EBX] - ShL BX, 2 - Add BX, Offset AWEDataTable - - Cmp Byte Ptr [SI+0Ah], 8 - JB GetAddressNoLoop - JE GetAddressForwardsLoop - -GetAddressPingPongLoop: - Cmp EAX, [CS:BX+16] - JB SetOldAddress - - Neg EAX - Add EAX, [CS:BX+8] - Jmp SetOldAddress1 - -GetAddressNoLoop: - Cmp EAX, [CS:BX+4] ; Start loop - JB SetOldAddress - - Call StopAWENote - - ; OK.. gotta turn off channel - Mov Word Ptr [SI], 0 - Test Byte Ptr [SI+3Ah], 80h - JNZ GetAWERegisters4 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - - Jmp GetAWERegisters4 - -GetAddressForwardsLoop: -SetOldAddress: - Sub EAX, [CS:BX] ; EAX = address in sample - JNS SetOldAddress1 - - Xor EAX, EAX - -SetOldAddress1: - Push CX - Mov CL, Compress - ShL EAX, CL - Pop CX - - XChg [SI+4Ch], EAX - Mov [SI+2Ch], EAX - -GetAWERegisters4: - Add SI, 128 - - Inc DX - Dec CX - JNZ GetAWERegisters1 - - Pop SI - Pop CX - - Xor DX, DX ; DX = oscillator number - -SetAWERegisters1: - ; Stage 2. - ; If new frequency, play new frequency - ; If new volume, play new volume - ; If new pan, play new pan - ; If new note, set ENVVOL, ENVVAL, SUSDCY, ATKHLDV, LFO1VAL, HLDATK - ; LFO2VAL, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2 - ; PSST, CSL, CCCA - ; VTFT, CVCF, DCYSUSV, PTRX, CPF - - Push CX - Mov CX, [SI] - Test CL, 1 ; Channel on? - JZ SetAWERegistersEnd - - Test CH, 1 ; New note? - JZ SetAWERegisters2 - - Xor BX, BX - Mov BL, [SI+36h] - LEA DI, [EBX*4+EBX] - ShL DI, 2 - Add DI, Offset AWEDataTable - - Mov AX, DCYSUSV - Mov BX, 80h - Call WriteDataChannel - - Mov AX, VTFT - Xor EBX, EBX - Call WriteDataChannel - - Mov AX, CVCF - Call WriteDataChannel - - Cmp DWord Ptr [CS:DI], 0FFFFFFFFh - JE SetAWERegistersError - - Mov AX, PTRX - Call WriteDataChannel - - Mov AX, CPF - Call WriteDataChannel - - - Mov AX, ENVVOL - Mov BX, 8000h - Call WriteDataChannel - - Mov AX, ENVVAL - Mov BX, 8000h - Call WriteDataChannel - - Mov AX, SUSDCY - Mov BX, 7F7Fh - Call WriteDataChannel - - Mov AX, ATKHLDV - Call WriteDataChannel - - Mov AX, LFO1VAL - Mov BX, 8000h - Call WriteDataChannel - - Mov AX, HLDATK - Mov BX, 7F7Fh - Call WriteDataChannel - - Mov AX, LFO2VAL - Mov BX, 8000h - Call WriteDataChannel - - Call SetAWEFrequency - Call SetAWEVolume - - Mov AX, PEFE - Xor BX, BX - Call WriteDataChannel - - Mov AX, FMMOD - Call WriteDataChannel - - Mov AX, TREMFRQ - Mov BX, 10h - Call WriteDataChannel - - Mov AX, FM2FRQ2 - Call WriteDataChannel - - - Mov EBX, [CS:DI+4] - Dec EBX ; Interpolator offset - Mov AX, PSST - Call WriteDataChannel - - Call SetAWEPan - - Mov AL, [CS:VolumeTable+6] ; Chorus - ShL EAX, 24 - Mov EBX, [CS:DI+8] - Dec EBX ; Interpolator offset - Or EBX, EAX - Mov AX, CSL - Call WriteDataChannel - - Mov AL, [SI+3Fh] - ShL EAX, 28 - - Push CX - Mov CL, Compress - Mov EBX, [SI+4Ch] - ShR EBX, CL - Pop CX - Add EBX, [CS:DI] - Dec EBX ; Interpolator offset - Or EBX, EAX - - Mov AX, CCCA ; Current address. - Call WriteDataChannel - - - Mov AX, VTFT - Mov EBX, 0FFFFh - Call WriteDataChannel - - Mov AX, CVCF - Call WriteDataChannel - - Mov AX, DCYSUSV - Mov BX, 7F7Fh - Call WriteDataChannel - - Mov AX, PTRX - Mov EBX, 40000000h ; 25% reverb - Or BH, [CS:VolumeTable+7] - Call WriteDataChannel - - Mov AX, CPF - Call WriteDataChannel - Jmp SetAWERegistersEnd - -SetAWERegisters2: - Test CL, 32 ; Frequency change? - JZ SetAWERegisters3 - - Call SetAWEFrequency - -SetAWERegisters3: - Test CL, 64 ; Volume change? - JZ SetAWERegisters4 - - Call SetAWEVolume - -SetAWERegisters4: - Test CH, 80h ; New pan? - JZ SetAWERegistersEnd - - Call SetAWEPan - -SetAWERegistersEnd: - Pop CX - And Word Ptr [SI], 0111100010011111b - - Add SI, 128 - - Inc DX - Dec CX - JNZ SetAWERegisters1 - - Ret - -SetAWERegistersError: - Call StopAWENote - - Mov Word Ptr [SI], 0 - Test Byte Ptr [SI+3Ah], 80h - JNZ SetAWERegistersEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - - Jmp SetAWERegistersEnd - -EndP SetAWERegisters - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ACKIRQ - - Mov AL, 20h - Cmp CS:IRQ, 7 - JBE ACKIRQ1 - - Out 0A0h, AL - -ACKIRQ1: - Out 20h, AL - Ret - -EndP ACKIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Mov DX, MIDIPort - - Mov BL, [MIDIBufferTail] - Test DX, DX - JZ CheckMIDIEnd - - Inc DX - -CheckMIDIAgain: - In AL, DX - - Test AL, AL - JS CheckMIDIAgain - - Dec DX - In AL, DX - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDIIRQHandler - - Push AX BX DX - - Mov DX, CS:MixerPort - Mov AL, 82h - Out DX, AL - Inc DL - In AL, DX - - Test AL, 4 - JZ MIDIIRQHandlerEnd - - Call CheckMIDI - -MIDIIRQHandlerEnd: - Call AckIRQ - - Pop DX BX AX - IRet - - -EndP MIDIIRQHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIRQHandler - - PushAD - Push DS - Push ES - - StI - - Push CS - Pop DS - Assume DS:Driver - -SBIRQHandlerAgain: - Mov DX, MixerPort - Mov AL, 82h - Out DX, AL - Inc DL - In AL, DX - - Test AL, 4 - JZ NoMIDIIRQ - - Push AX - Call CheckMIDI - Pop AX - -NoMIDIIRQ: -; Test AL, 2 -; JZ No16BitIRQ -; -; Push AX -; Mov DX, MixerPort -; Add DL, 0Fh-4 -; In AL, DX -; Pop AX -; -; No16BitIRQ: - Test AL, 1 - JNZ SB8BitIRQ - -SBNo8BitIRQ: - Call AckIRQ - Jmp SBEndIRQ - -SB8BitIRQ: - Mov DX, MixerPort - Add DL, 0Eh-4 - In AL, DX ; 8-bit IRQ ack. - - Add DL, 0Ch-0Eh - - Mov AL, 80h ; Output block of silence - Call SBOut - Mov AX, BlockLength2 - Call SBOut - Mov AL, AH - Call SBOut - - Mov AL, 0D3h - Call SBOut - - ClD - Call ACKIRQ - - Inc IRQFlag - JNZ SBEndIRQ - - Call SaveEMSPageFrame - Assume DS:Nothing - -SB8BitIRQAgain: - Call Update ; Returns DS:SI, CX - - Mov BX, BlockLength - Cmp BX, BlockLength2 - JE SBIRQHandler2 - Mov BlockLength2, BX - - Mov DX, SB16BasePort - Add DL, 0Ch - - Mov AL, 0D0h - Call SBOut - - Mov AL, 80h ; Output block of silence - Call SBOut - Mov AL, BL - Call SBOut - Mov AL, BH - Call SBOut - -SBIRQHandler2: - Call SetAWERegisters - Sub CS:IRQFlag, 1 - JNC SB8BitIRQAgain - - Call RestoreEMSPageFrame - -SBEndIRQ: - Pop ES - Pop DS - PopAD - - IRet - -EndP SBIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AWEIRQHandler ; IRQ Handler has to - ; 1) Update AWE registers - ; 2) Update song position - Push AX - Push DS - - Mov AX, AWEUpdateTimer - Add AWEUpdateCount, AX - JC AWEIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp AWEIRQHandler2 - -AWEIRQHandler1: - PushF - Call [OldIRQHandler] - -AWEIRQHandler2: - Xor AWEUpdateFlag, 1 - JZ AWEIRQHandlerEnd - - PushAD - Push ES - - ClD - - Call SaveEMSPageFrame - Call Update ; Returns DS:SI, CX - Call SetAWERegisters - Call RestoreEMSPageFrame - - Pop ES - PopAD - -AWEIRQHandlerEnd: - Pop DS - Pop AX - IRet - -EndP AWEIRQHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EnableRAM - - Mov DX, BasePort - Mov CX, 29 - -EnableRAM1: - Mov AX, DCYSUSV - Or AX, CX - Mov BX, 80h - Call WriteData - - Mov AX, VTFT - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CVCF - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, PTRX - Or AX, CX - Mov EBX, 40000000h - Call WriteData - - Mov AX, CPF - Or AX, CX - Mov EBX, 40000000h - Call WriteData - - Mov AX, PSST - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CSL - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CCCA - Or AX, CX - Mov EBX, 6000000h ; Left write - Call WriteData - - Dec CX - JNS EnableRAM1 - - Ret - -EndP EnableRAM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TestAWE ; Given DX = baseport. - - Push DX - - Add DX, 802h - In AL, DX - In AL, DX - Not AL - Mov BL, AL - Out DX, AL - In AL, DX - Cmp AL, BL - JNE TestAWE1 ; Register changed - - In AX, DX ; Is upper part of pointer - Mov BX, AX ; changing? - Mov CX, 128 - -TestAWE2: - In AX, DX - Cmp AL, BL - JNE TestAWE1 - Cmp AH, BH - JNE TestAWE3 - - Dec CX - JNZ TestAWE2 - Jmp TestAWE1 - -TestAWE3: - Pop DX - - ClC - Ret - -TestAWE1: - Pop DX - StC - Ret - -EndP TestAWE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSetAWE - - Mov CX, 31 - -InitSetAWE1: - Mov AX, 31 - Sub AX, CX - Mov BX, [SI] - Or AX, INIT1 - Call WriteData - - Add SI, 2 - - Dec CX - JNS InitSetAWE1 - - Mov CX, 31 - -InitSetAWE2: - Mov AX, 31 - Sub AX, CX - Mov BX, [SI] - Or AX, INIT2 - Call WriteData - - Add SI, 2 - - Dec CX - JNS InitSetAWE2 - - Mov CX, 31 - -InitSetAWE3: - Mov AX, 31 - Sub AX, CX - Mov BX, [SI] - Or AX, INIT3 - Call WriteData - - Add SI, 2 - - Dec CX - JNS InitSetAWE3 - - Mov CX, 31 - -InitSetAWE4: - Mov AX, 31 - Sub AX, CX - Mov BX, [SI] - Or AX, INIT4 - Call WriteData - - Add SI, 2 - - Dec CX - JNS InitSetAWE4 - - Ret - -EndP InitSetAWE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitAWE - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - - Mov AX, HWCF1 - Mov BX, 59h - Call WriteData - - Mov AX, CFG2 - Mov BX, 20h - Call WriteData - - Mov CX, 31 - -InitAwe1: - Mov BX, 80h - Mov AX, DCYSUSV - Or AX, CX - Call WriteData - - Xor EBX, EBX - Mov AX, ENVVOL - Or AX, CX - Call WriteData - - Mov AX, ENVVAL - Or AX, CX - Call WriteData - - Mov AX, SUSDCY - Or AX, CX - Call WriteData - - Mov AX, ATKHLDV - Or AX, CX - Call WriteData - - Mov AX, LFO1VAL - Or AX, CX - Call WriteData - - Mov AX, HLDATK - Or AX, CX - Call WriteData - - Mov AX, LFO2VAL - Or AX, CX - Call WriteData - - Mov AX, IP - Or AX, CX - Call WriteData - - Mov AX, IFATN - Or AX, CX - Call WriteData - - Mov AX, PEFE - Or AX, CX - Call WriteData - - Mov AX, FMMOD - Or AX, CX - Call WriteData - - Mov AX, TREMFRQ - Or AX, CX - Call WriteData - - Mov AX, FM2FRQ2 - Or AX, CX - Call WriteData - - Mov AX, PTRX - Or AX, CX - Call WriteData - - Mov AX, VTFT - Or AX, CX - Call WriteData - - Mov AX, PSST - Or AX, CX - Call WriteData - - Mov AX, CSL - Or AX, CX - Call WriteData - - Mov AX, CCCA - Or AX, CX - Call WriteData - - Dec CX - JNS InitAWE1 - - Mov CX, 31 - -InitAWE8: - Mov AX, CPF - Or AX, CX - Call WriteData - - Mov AX, CVCF - Or AX, CX - Call WriteData - - Dec CX - JNS InitAWE8 - ; Initialise still... - Mov AX, SMALR - Call WriteData - - Mov AX, SMARR - Call WriteData - - Mov AX, SMALW - Call WriteData - - Mov AX, SMARW - Call WriteData - - Mov SI, Offset InitTable1 - Call InitSetAWE - - ; Wait for 1024 sample periods - Mov AX, WC - Call ReadData - - Mov BX, AX - Mov CX, AX - Add CX, 400h ; 1024 - Cmp BX, CX - JB InitAWE3 - -InitAWE4: - Mov AX, WC - Call ReadData - Cmp AX, CX - JA InitAWE4 - -InitAWE3: - Mov AX, WC - Call ReadData - Cmp AX, CX - JB InitAWE3 - - Mov SI, Offset InitTable2 - Call InitSetAWE - - Mov SI, Offset InitTable3 - Call InitSetAWE - - Mov AX, HWCF4 - Xor EBX, EBX - Call WriteData - - Mov AX, HWCF5 - Mov EBX, 83h - Call WriteData - - Mov AX, HWCF6 - Mov EBX, 8000h - Call WriteData - - Mov SI, Offset InitTable4 - Call InitSetAWE - - Mov AX, HWCF3 - Mov BX, 4 - Call WriteData - - Ret - -EndP InitAWE - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitDRAMRefresh - - Mov AX, DCYSUSV+1Eh - Mov BX, 80h - Call WriteData - - Mov AX, DCYSUSV+1Fh - Call WriteData - -; - - Mov AX, VTFT+1Eh - Xor EBX, EBX - Call WriteData - - Mov AX, CVCF+1Eh - Call WriteData - - Mov AX, VTFT+1Fh - Call WriteData - - Mov AX, CVCF+1Fh - Call WriteData - -; - - Mov AX, PTRX+1Eh - Call WriteData - - Mov AX, CPF+1Eh - Call WriteData - - Mov AX, PTRX+1Fh - Call WriteData - - Mov AX, CPF+1Fh - Call WriteData - -; - - Mov AX, PSST+1Eh - Call WriteData - Mov AX, PSST+1Fh - Call WriteData - - Mov BX, 0FFFFh - Mov AX, CSL+1Eh - Call WriteData - Mov AX, CSL+1Fh - Call WriteData - - Xor BX, BX - Mov AX, CCCA+1Eh - Call WriteData - Mov AX, CCCA+1Fh - Call WriteData - - Ret - -EndP InitDRAMRefresh - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - - ShR AL, 7 - LoopZ SBIn - -; Test AL, AL -; JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov DX, BasePort - Cmp DX, 0FFFFh - JE DetectCard1 - - Cmp DX, 620h - JB DetectCard3 - Cmp DX, 680h - JA DetectCard3 - - Call TestAWE - JNC DetectCardFound - Ret - -DetectCard1: - Mov DX, 620h - -DetectCard2: - Call TestAWE - JNC DetectCardFound - - Add DL, 20h - Cmp DL, 80h - JBE DetectCard2 - -DetectCard3: - StC - Ret - -DetectCardFound: - Mov BasePort, DX - - ; Initialise AWE 32 - Call InitAWE - Call InitDRAMRefresh - - ; Detect amount of RAM. - - Mov DX, BasePort - Mov CX, 29 - -DetectCardMemory1: - Mov AX, DCYSUSV - Or AX, CX - Mov BX, 80h - Call WriteData - - Mov AX, VTFT - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CVCF - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, PTRX - Or AX, CX - Mov EBX, 40000000h - Call WriteData - - Mov AX, CPF - Or AX, CX - Mov EBX, 40000000h - Call WriteData - - Mov AX, PSST - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CSL - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CCCA - Or AX, CX - Mov EBX, 4000000h ; Left read - - Test CL, 2 - JZ DetectCardMemory2 - - Mov EBX, 6000000h ; Left write - -DetectCardMemory2: - Call WriteData - - Dec CX - JNS DetectCardMemory1 - - Xor EDI, EDI ; Amount of memory stored in - ; EDI - - Mov AX, SMALW - Mov EBX, 200000h - Call WriteData - - Mov AX, SMLD - Mov BX, 0FFFFh - Call WriteData - - Mov AX, SMLD - Mov BX, 5555h - Call WriteData - - Mov AX, SMLD - Mov BX, 0AAAAh - Call WriteData - - Mov AX, SMALR - Mov EBX, 200000h - Call WriteData - - Mov AX, SMLD - Call ReadData - - Mov AX, SMLD - Call ReadData - Cmp AX, 0FFFFh - JNE DetectCardMemory6 - - Mov AX, SMLD - Call ReadData - Cmp AX, 5555h - JNE DetectCardMemory6 - - Mov AX, SMLD - Call ReadData - Cmp AX, 0AAAAh - JNE DetectCardMemory6 - - Mov EDI, 20000h - -DetectCardMemory3: ; Set read/write addresses.. - Mov AX, SMALW - Mov EBX, EDI - Add EBX, 200000h - Call WriteData - - Mov AX, SMLD - Mov BX, 5555h - Call WriteData - - Mov AX, SMLD - Mov BX, 0AAAAh - Call WriteData - - Mov AX, SMALR - Mov EBX, 200000h - Call WriteData - - Mov AX, SMLD - Call ReadData - - Mov AX, SMLD - Call ReadData - Cmp AX, 0FFFFh - JNE DetectCardMemory5 - - Mov AX, SMALR - Mov EBX, EDI - Add EBX, 200000h - Call WriteData - - Mov AX, SMLD - Call ReadData - - Mov AX, SMLD - Call ReadData - Cmp AX, 5555h - JNE DetectCardMemory5 - - Mov AX, SMLD - Call ReadData - Cmp AX, 0AAAAh - JNE DetectCardMemory5 - -DetectCardMemory4: - Add EDI, 20000h - Cmp EDI, 0E00000h - JB DetectCardMemory3 - -DetectCardMemory5: - Cmp EDI, 0DFFFE0h - JB DetectCardMemory7 - - Mov EDI, 0DFFFE0h - -DetectCardMemory7: - Test EDI, EDI - JZ DetectCardMemory6 - - Mov AWEMemory, EDI - - Mov MixerPort, 210h - Mov AX, BasePort - Sub AX, 400h - Call ResetDSP - JNC DetectMixer2 - -DetectMixer1: - Mov AX, MixerPort - Call ResetDSP - JNC DetectMixer2 - -DetectMixer3: - Add MixerPort, 10h - Cmp MixerPort, 280h - JBE DetectMixer1 - - Mov DX, BasePort - Sub DX, 400h - Mov MixerPort, DX - - Jmp DetectCard4 - -DetectMixer2: ; OK... DSP found. - ; Get DSP version - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - - Mov CX, 200 - -DetectMixerLoop1: - In AL, DX -; Test AL, AL -; JS DetectMixerLoop1 - ShR AL, 7 - LoopNZ DetectMixerLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AX, 40Ch ; SB DSP = 4.12+ - JB DetectMixer3 - - Sub DL, 0Eh - Mov MixerPort, DX - -DetectCard4: - Mov SB16BasePort, DX - Add MixerPort, 4 ; Mixerport - - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Mov DX, MixerPort - Mov AX, 0C034h - Out DX, AX - - Mov AL, 35h - Out DX, AX - - Mov DX, MixerPort - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - Jmp NoWindows - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: - Mov AX, 1600h ; Windows detection. - Int 2Fh - Test AL, 7Fh - JZ NoWindows - - Mov SBIRQMode, 1 - -NoWindows: - Mov EAX, 'Jeff' - ClC - Ret - -DetectCardMemory6: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSamplingRate - - PushA - - Mov AX, CS:SB16BasePort - Mov DX, AX - Call ResetDSP - Add DL, 0Ch - ; Set mixing frequency - Mov AL, 40h - Call SBOut - Mov AL, 211 - Call SBOut ; 22222 Hz. - - Mov AL, 80h - Call SBOut - Mov AX, BlockLength - Dec AX - Call SBOut - Mov AL, AH - Call SBOut - - PopA - Ret - -EndP SetSamplingRate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMIDIIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset MIDIIRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetMIDIIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SBIRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitMIDI - - Mov DX, 330h - Call DetectUART - JC DetectMIDI1 - - Mov MIDIPort, 330h - Jmp DetectMIDIEnd - -DetectMIDI1: - Mov DX, 300h - Call DetectUART - JC DetectMIDIEnd - - Mov MIDIPort, 300h - -DetectMIDIEnd: - Ret - -EndP InitMIDI - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov AX, CS - Mov DriverSegment1, AX - Mov DriverSegment2, AX - Mov DriverSegment3, AX - Mov DriverSegment4, AX - Mov DriverSegment5, AX - Mov DriverSegment6, AX - Mov DriverSegment7, AX - Mov DriverSegment8, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Cmp SBIRQMode, 0 - JE InitSound1 - - Call SetIRQ - Call GetTempo - Call SetTempo - Call ResetMemory - Call SetSamplingRate - - Call InitMIDI - - Mov SI, Offset AWE32Msg2 - Mov AX, BasePort - - Mov BX, IRQ - - Mov ECX, AWEMemory - SHR ECX, 9 - - Ret - -InitSound1: - Call SetMIDIIRQ - Call GetTempo - Call SetTempo - Call ResetMemory - - Xor AX, AX - Mov ES, AX ; ES = 0 - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset AWEIRQHandler - - ClI - - XChg DWord Ptr [ES:20h], EAX ; Clock tick - Mov OldIRQHandler, EAX - - StI - -InitSound2: - Call InitMIDI - - Mov SI, Offset AWE32Msg - Mov AX, BasePort - - Mov EBX, AWEMemory - SHR EBX, 9 - - Ret - -EndP InitSound - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset AWE32ReinitMsg - Mov BX, 40 - Call SetInfoLine - - Call ResetUART - Call InitAWE - Call InitDRAMRefresh - - Cmp SBIRQMode, 0 - JE ReInitSound1 - - Call ResetIRQ - Call SetIRQ - Call SetSamplingRate - Call ReinitUART - Ret - -ReInitSound1: - Xor AX, AX - Mov ES, AX ; ES = 0 - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset AWEIRQHandler - - Mov DWord Ptr [ES:20h], EAX ; Clock tick - - Call ResetIRQ - Call SetMIDIIRQ - Call ReinitUART - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset Chorus - Int 21h - -SaveConfig1: - PushF - Mov AH, 3Eh - Int 21h - PopF - -SaveConfig2: - Call ResetIRQ - - Cmp SBIRQMode, 0 - JE UnInitSound1 - - Mov DX, SB16BasePort - Add DL, 0Ch - - Mov AL, 0D0h - Call SBOut - - Call ResetUART - -; Mov AX, SB16BasePort -; Call ResetDSP - - Call InitAWE - Ret - -UnInitSound1: - Mov AL, 34h - Out 43h, AL - - Xor AX, AX - Out 40h, AL - Out 40h, AL - - Mov ES, AX - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - - Mov AX, SB16BasePort - Call ResetDSP - Call ResetUART - Call InitAWE - Call ResetIRQ - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Cmp CS:SBIRQMode, 0 - JE SetTempo1 - ; BlockLength = 55555/BPM - - Mov AX, 55555 - Xor DX, DX - Div BX - Dec AX - Mov BlockLength, AX - -; Mov DX, SB16BasePort -; Add DL, 0Ch - - Jmp SetTempo2 - -SetTempo1: - ; Frames per second = 2 * (0.4*Tempo) - Mov AX, 0C214h - Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo - Div BX - - ; AX contains counter. - Mov AWEUpdateTimer, AX - - Out 40h, AL ; Timer IRQ. - Mov AL, AH - Out 40h, AL - -SetTempo2: - Pop DX - Pop BX - Pop AX - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - ; if no sample, then do nothing - ; MemoryUsed = length of sample - ; if sustain loop, then use sustain - ; loop information - ; if no sustain loop, then use loop - ; information - ; if no loop or sustain loop, - ; memoryused += 16; (16 zero samples - ; at the end) - ; - PushAD - Push DS - Push ES - Push FS - - Push AX - - ClI - - Call EnableRAM ; Enable access to DRAM. - - ; Set destination address - Mov AX, SMALW - Mov EBX, CS:AWEMemoryUsed - Add EBX, 200000h - Call WriteData - - Mov DX, CS:BasePort - Add DX, 802h ; Index - Mov AX, 32+26 - Out DX, AX - - Pop AX - - Mov FS, CS:SongDataArea - LEA DI, [EAX*4+EAX] - ShL DI, 2 - Add DI, Offset AWEDataTable-20 - - Mov ECX, -1 - - Mov DWord Ptr [CS:DI], ECX ; Start - Mov DWord Ptr [CS:DI+4], ECX ; Loop start - Mov DWord Ptr [CS:DI+8], ECX ; Loop end - Mov DWord Ptr [CS:DI+12], ECX ; Size occupied - Mov DWord Ptr [CS:DI+16], ECX ; Size occupied - - Mov BP, AX - Add BP, BP - Mov BP, [FS:64910+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC LoadSampleNoError - - JZ LoadSample1 - - ; 16 bit - - Mov CS:LoadSampleFuncF, Offset Load16BitSamplesForwards - Mov CS:LoadSampleFuncB, Offset Load16BitSamplesBackwards - - Jmp LoadSample2 - -LoadSample1: ; 8 bit - Mov CS:LoadSampleFuncF, Offset Load8BitSamplesForwards - Mov CS:LoadSampleFuncB, Offset Load8BitSamplesBackwards - -LoadSample2: - Mov AL, [FS:BP+12h] - Test AL, 30h ; Loop or sustain loop? - JZ LoadSampleNoLoop - - Mov EBX, [FS:BP+34h] ; Loop begin - Mov EDX, [FS:BP+38h] ; Loop end - Test AL, 20h ; Sustain loop? - JZ LoadSample3 - - ShR AL, 1 - Mov EBX, [FS:BP+40h] - Mov EDX, [FS:BP+44h] - Jmp LoadSample3 - -LoadSampleError: - ClC - Jmp LoadSampleEnd - -LoadSampleNoError: - StC - -LoadSampleEnd: - StI - Pop FS - Pop ES - Pop DS - PopAD - - Ret - -LoadSampleNoLoop: ; ECX contains length of sample - Mov EAX, ECX - Mov EDX, AWEMemoryUsed - Mov EBX, AWEMemory - Sub EBX, EDX ; EBX = AWEMemory remaining - - Mov CL, Compress - ShR EAX, CL ; Compress sample - Add EAX, 16 ; zeroes at end of sample - - Cmp EAX, EBX - JA LoadSampleError - - Mov ECX, EAX - Add AWEMemoryUsed, EAX ; Record memory as used - Mov [CS:DI+12], EAX - - Add EDX, 200000h - - Sub ECX, 16 ; Number of samples to transfer - Mov [CS:DI], EDX - Add EDX, ECX - Mov [CS:DI+4], EDX ; Loop start - Add EDX, 14 - Mov [CS:DI+8], EDX ; Loop end - - ; Now to transfer samples to AWE32 - Call [CS:LoadSampleFuncF] - ; Now to shove a whole lot of zeroes - Xor AX, AX - Mov CX, 16 - -LoadSampleNoLoop2: - Out DX, AX - Loop LoadsampleNoLoop2 - - Jmp LoadSampleNoError - -LoadSample3: ; OK... EBX = loop start - ; EDX = loop end - ; AL&40h = ping pong - Test AL, 40h - JNZ LoadSamplePingPong - - Mov CL, Compress - - Push EBX - - ShR EDX, CL - ShR EBX, CL - Mov EAX, EDX - Add EAX, 2 ; For loop fixing - - Mov ECX, AWEMemory - Sub ECX, AWEMemoryUsed ; ECX = AWEMemoryRemaining - - Cmp EAX, ECX - Pop ECX - JA LoadSampleError ; Sufficient memory? - Push ECX - - Mov ECX, EAX - Mov EAX, AWEMemoryUsed - Add AWEMemoryUsed, ECX - Mov [CS:DI+12], ECX - - Sub ECX, 2 - - Add EAX, 200000h - Mov [CS:DI], EAX - - Add EDX, EAX - Add EAX, EBX - - Mov [CS:DI+4], EAX - Mov [CS:DI+8], EDX - - Call [CS:LoadSampleFuncF] - ; Now to fix loop.. 1 extra - ; sample. - - Pop ESI ; Loop start - Test Byte Ptr [FS:BP+12h], 2 - JZ LoadSampleForwards1 - - Add ESI, ESI - -LoadSampleForwards1: - Int 3 - - Mov ECX, 2 - Call [CS:LoadSampleFuncF] - - Jmp LoadSampleNoError - -LoadSamplePingPong: - Mov CL, Compress - ShR EDX, CL - ShR EBX, CL - - Mov EAX, EDX - Add EAX, EDX - Sub EAX, EBX - Inc EAX - - Mov ECX, AWEMemory - Sub ECX, AWEMemoryUsed - - Cmp EAX, ECX - JA LoadSampleError - - Mov [CS:DI+12], EAX - Mov ECX, AWEMemoryUsed - Add AWEMemoryUsed, EAX - - Add ECX, 200000h - Add EAX, ECX - Dec EAX - - Mov [CS:DI], ECX - Add ECX, EBX - Mov [CS:DI+4], ECX - Mov [CS:DI+8], EAX - - Mov EAX, [CS:DI] - Add EAX, EDX - Mov [CS:DI+16], EAX - - Mov ECX, EDX - Sub EDX, EBX - Push EDX - - Call [CS:LoadSampleFuncF] - - Pop ECX - Inc ECX - - Call [CS:LoadSampleFuncB] - - Jmp LoadSampleNoError - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - PushAD - - LEA DI, [EAX*4+EAX] ; DI = AX * 5 - ShL DI, 2 - Add DI, Offset AWEDataTable - - Mov EBX, [CS:DI+12] - Mov EAX, CS:AWEMemoryUsed - Sub EAX, EBX - Add EAX, 200000h - Cmp EAX, [CS:DI] - JNE ReleaseSample1 - - Sub AWEMemoryUsed, EBX -ReleaseSample1: - Mov EAX, -1 - Mov [CS:DI], EAX - Mov [CS:DI+4], EAX - Mov [CS:DI+8], EAX - Mov [CS:DI+12], EAX - - PopAD - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Push CS - Pop ES - - Xor EAX, EAX - Mov CS:AWEMemoryUsed, EAX - - Mov DI, Offset AWEDataTable - Mov CX, 1000 - Mov AX, 0FFFFh - Rep StosW - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset AWE32Status - - Mov EAX, AWEMemory - Sub EAX, AWEMemoryUsed - SHR EAX, 9 - - ClC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset GUSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, MixerPort - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:AWEParameters+BX], AL - - Pop BX - - Mov CS:InterpretState, 0 - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Ret - -SendUARTOut3: - Mov InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset AWEParameters - Mov CX, 32 - Or AX, -1 - Rep StosW - Mov CX, 32 - Inc AX - Rep StosW - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 30 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 30 -DriverFlags DW 1 ; MIDI Out supported - - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - - DW Offset SendUARTOut ; For MIDI Out - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + + Comment ~ + +Index = BasePort + 802h + + 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + ³ .............................. ³ Register ³ Channel Number ³ + ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + + ~ + +OldIRQHandler DD 0 +AWEMemory DD 0 +AWEMemoryUsed DD 0 +AWEUpdateCount DW 0 + +AWEUpdateTimer DW 0 + +LoadSampleFuncF DW 0 +LoadSampleFuncB DW 0 + +AWEDataTable DD 5*100 Dup (0) ; Start, Startloop, Endloop, Size +MIDIPort DW 0 +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +SB16BasePort DW 0 +MixerPort DW 0 +Step DW 1 +AWEUpdateFlag DB 0 +Compress DB 0 + DB 0 + +SBIRQMode DB 0 +BlockLength DW 100 +BlockLength2 DW 100 + +AWE32Msg DB "Sound Blaster AWE 32 detected", 13 + DB "Address ", 0FDh, "Xh, ", 0FDh, "Dk Memory", 0 + +AWE32Msg2 DB "Sound Blaster AWE 32 detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 + +AWE32Status DB "FreeAWE ", 0FDh, "Dk", 0 + +AWE32ReinitMsg DB "Sound Blaster AWE 32 reinitialised", 0 +Stereo DB 0 +Forced DB 0 +DriverName DB "ITAWE32B.DRV", 0 + +FrequencyError DB "AWE Hardware frequency limit exceeded -> Note terminated", 0 + +IRQFlag DB 0FFh + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +IMR DW 0 + + CPF EQU 0 + PTRX EQU 20h + CVCF EQU 40h + VTFT EQU 60h + PSST EQU 0C0h + CSL EQU 0E0h + + CCCA EQU 100h + HWCF4 EQU 129h + HWCF5 EQU 12Ah + HWCF6 EQU 12Dh + SMALR EQU 134h + SMARR EQU 135h + SMALW EQU 136h + SMARW EQU 137h + SMLD EQU 43Ah + SMRD EQU 23Ah + WC EQU 23Bh + HWCF1 EQU 43Dh + HWCF2 EQU 43Eh + CFG2 EQU 43Eh + HWCF3 EQU 43Fh + INIT1 EQU 440h + INIT2 EQU 240h + INIT3 EQU 460h + INIT4 EQU 260h + ENVVOL EQU 480h + DCYSUSV EQU 4A0h + ENVVAL EQU 4C0h + DCYSUS EQU 4E0h + SUSDCY EQU 4E0h + ATKHLDV EQU 280h + LFO1VAL EQU 2A0h + ATKHLD EQU 2C0h + HLDATK EQU 2C0h + LFO2VAL EQU 2E0h + IP EQU 300h + IFATN EQU 320h + PEFE EQU 340h + FMMOD EQU 360h + TREMFRQ EQU 380h + FM2FRQ2 EQU 3A0h + +ALIGN 4 + +InitTable1 Label + DW 003FFh, 0030h, 007FFh, 0130h, 00BFFh, 0230h, 00FFFh, 0330h + DW 013FFh, 0430h, 017FFh, 0530h, 01BFFh, 0630h, 01FFFh, 0730h + DW 023FFh, 0830h, 027FFh, 0930h, 02BFFh, 0A30h, 02FFFh, 0B30h + DW 033FFh, 0C30h, 037FFh, 0D30h, 03BFFh, 0E30h, 03FFFh, 0F30h + + DW 043FFh, 0030h, 047FFh, 0130h, 04BFFh, 0230h, 04FFFh, 0330h + DW 053FFh, 0430h, 057FFh, 0530h, 05BFFh, 0630h, 05FFFh, 0730h + DW 063FFh, 0830h, 067FFh, 0930h, 06BFFh, 0A30h, 06FFFh, 0B30h + DW 073FFh, 0C30h, 077FFh, 0D30h, 07BFFh, 0E30h, 07FFFh, 0F30h + + DW 083FFh, 0030h, 087FFh, 0130h, 08BFFh, 0230h, 08FFFh, 0330h + DW 093FFh, 0430h, 097FFh, 0530h, 09BFFh, 0630h, 09FFFh, 0730h + DW 0A3FFh, 0830h, 0A7FFh, 0930h, 0ABFFh, 0A30h, 0AFFFh, 0B30h + DW 0B3FFh, 0C30h, 0B7FFh, 0D30h, 0BBFFh, 0E30h, 0BFFFh, 0F30h + + DW 0C3FFh, 0030h, 0C7FFh, 0130h, 0CBFFh, 0230h, 0CFFFh, 0330h + DW 0D3FFh, 0430h, 0D7FFh, 0530h, 0DBFFh, 0630h, 0DFFFh, 0730h + DW 0E3FFh, 0830h, 0E7FFh, 0930h, 0EBFFh, 0A30h, 0EFFFh, 0B30h + DW 0F3FFh, 0C30h, 0F7FFh, 0D30h, 0FBFFh, 0E30h, 0FFFFh, 0F30h + +InitTable2 Label + DW 003FFh, 8030h, 007FFh, 8130h, 00BFFh, 8230h, 00FFFh, 8330h + DW 013FFh, 8430h, 017FFh, 8530h, 01BFFh, 8630h, 01FFFh, 8730h + DW 023FFh, 8830h, 027FFh, 8930h, 02BFFh, 8A30h, 02FFFh, 8B30h + DW 033FFh, 8C30h, 037FFh, 8D30h, 03BFFh, 8E30h, 03FFFh, 8F30h + + DW 043FFh, 8030h, 047FFh, 8130h, 04BFFh, 8230h, 04FFFh, 8330h + DW 053FFh, 8430h, 057FFh, 8530h, 05BFFh, 8630h, 05FFFh, 8730h + DW 063FFh, 8830h, 067FFh, 8930h, 06BFFh, 8A30h, 06FFFh, 8B30h + DW 073FFh, 8C30h, 077FFh, 8D30h, 07BFFh, 8E30h, 07FFFh, 8F30h + + DW 083FFh, 8030h, 087FFh, 8130h, 08BFFh, 8230h, 08FFFh, 8330h + DW 093FFh, 8430h, 097FFh, 8530h, 09BFFh, 8630h, 09FFFh, 8730h + DW 0A3FFh, 8830h, 0A7FFh, 8930h, 0ABFFh, 8A30h, 0AFFFh, 8B30h + DW 0B3FFh, 8C30h, 0B7FFh, 8D30h, 0BBFFh, 8E30h, 0BFFFh, 8F30h + + DW 0C3FFh, 8030h, 0C7FFh, 8130h, 0CBFFh, 8230h, 0CFFFh, 8330h + DW 0D3FFh, 8430h, 0D7FFh, 8530h, 0DBFFh, 8630h, 0DFFFh, 8730h + DW 0E3FFh, 8830h, 0E7FFh, 8930h, 0EBFFh, 8A30h, 0EFFFh, 8B30h + DW 0F3FFh, 8C30h, 0F7FFh, 8D30h, 0FBFFh, 8E30h, 0FFFFh, 8F30h + +InitTable3 Label + DW 0C10h, 8470h, 14FEh, 0B488h, 167Fh, 0A470h, 18E7h, 84B5h + DW 1B6Eh, 842Ah, 1F1Dh, 852Ah, 0DA3h, 8F7Ch, 167Eh, 7254h + DW 0, 842Ah, 1, 852Ah, 18E6h, 8BAAh, 1B6Dh, 7234h + DW 229Fh, 8429h, 2746h, 8529h, 1F1Ch, 86E7h, 229Eh, 7224h + + DW 0DA4h, 8429h, 2C29h, 8529h, 2745h, 87F6h, 2C28h, 7254h + DW 383Bh, 8428h, 320Fh, 8528h, 320Eh, 8F02h, 1341h, 7264h + DW 3EB6h, 8428h, 3EB9h, 8528h, 383Ah, 8FA9h, 3EB5h, 7294h + DW 3EB7h, 8474h, 3EBAh, 8575h, 3EB8h, 0C4C3h, 3EBBh, 45C3h + + DW 00000, 0A404h, 00001, 0A504h, 141Fh, 8671h, 14FDh, 8287h + DW 3EBCh, 0E610h, 3EC8h, 8C7Bh, 31Ah, 87E6h, 3EC8h, 86F7h + DW 3EC0h, 821Eh, 3EBEh, 0D208h, 3EBDh, 821Fh, 3ECAh, 8386h + DW 3EC1h, 8C03h, 3EC9h, 831Eh, 3ECAh, 8C4Ch, 3EBFh, 8C55h + + DW 3EC9h, 0C208h, 3EC4h, 0BC84h, 3EC8h, 8EADh, 3EC8h, 0D308h + DW 3EC2h, 8F7Eh, 3ECBh, 821Eh, 3ECBh, 0D208h, 3EC5h, 831Fh + DW 3EC6h, 0C308h, 3EC3h, 32FFh, 3EC9h, 8265h, 3EC9h, 831Eh + DW 1342h, 0D308h, 3EC7h, 33FFh, 0, 8365h, 1420h, 9570h + +InitTable4 Label + DW 0C10h, 8470h, 14FEh, 0B488h, 167Fh, 0A470h, 18E7h, 84B5h + DW 1B6Eh, 842Ah, 1F1Dh, 852Ah, 0DA3h, 0F7Ch, 167Eh, 7254h + DW 0, 842Ah, 1, 852Ah, 18E6h, 0BAAh, 1B6Dh, 7234h + DW 229Fh, 8429h, 2746h, 8529h, 1F1Ch, 6E7h, 229Eh, 7224h + + DW 0DA4h, 8429h, 2C29h, 8529h, 2745h, 07F6h, 2C28h, 7254h + DW 383Bh, 8428h, 320Fh, 8528h, 320Eh, 0F02h, 1341h, 7264h + DW 3EB6h, 8428h, 3EB9h, 8528h, 383Ah, 0FA9h, 3EB5h, 7294h + DW 3EB7h, 8474h, 3EBAh, 8575h, 3EB8h, 44C3h, 3EBBh, 45C3h + + DW 00000, 0A404h, 00001, 0A504h, 141Fh, 0671h, 14FDh, 287h + DW 3EBCh, 0E610h, 3EC8h, 0C7Bh, 31Ah, 7E6h, 3EC8h, 86F7h + DW 3EC0h, 821Eh, 3EBEh, 0D208h, 3EBDh, 021Fh, 3ECAh, 386h + DW 3EC1h, 0C03h, 3EC9h, 31Eh, 3ECAh, 8C4Ch, 3EBFh, 0C55h + + DW 3EC9h, 0C208h, 3EC4h, 0BC84h, 3EC8h, 0EADh, 3EC8h, 0D308h + DW 3EC2h, 8F7Eh, 3ECBh, 021Eh, 3ECBh, 0D208h, 3EC5h, 31Fh + DW 3EC6h, 0C308h, 3EC3h, 32FFh, 3EC9h, 0265h, 3EC9h, 831Eh + DW 1342h, 0D308h, 3EC7h, 33FFh, 0, 8365h, 1420h, 9570h + +AWEVolumeTable Label Byte ; Value = -log(vol/256)*(20/.375) + ; = -log(vol/256)*(160/3) + + DB 255, 128, 112, 103, 96, 91, 87, 83 ; 0->7 + DB 80, 78, 75, 73, 71, 69, 67, 66 ; 8->15 + DB 64, 63, 61, 60, 59, 58, 57, 56 ; 16->23 + DB 55, 54, 53, 52, 51, 50, 50, 49 ; 24->31 + DB 48, 47, 47, 46, 45, 45, 44, 44 ; 32->39 + DB 43, 42, 42, 41, 41, 40, 40, 39 ; 40->47 + DB 39, 38, 38, 37, 37, 36, 36, 36 ; 48->55 + DB 35, 35, 34, 34, 34, 33, 33, 32 ; 56->63 + DB 32, 32, 31, 31, 31, 30, 30, 30 ; 64->71 + DB 29, 29, 29, 28, 28, 28, 28, 27 ; 72->79 + DB 27, 27, 26, 26, 26, 26, 25, 25 ; 80->87 + DB 25, 25, 24, 24, 24, 23, 23, 23 ; 88->95 + DB 23, 22, 22, 22, 22, 22, 21, 21 ; 96->103 + DB 21, 21, 20, 20, 20, 20, 20, 19 ; 104->111 + DB 19, 19, 19, 19, 18, 18, 18, 18 ; 112->119 + DB 18, 17, 17, 17, 17, 17, 16, 16 ; 120->127 + DB 16 ; 128 + + Comment ~ ; Value = -log(vol/128)*(20/.375) + ; = -log(vol/128)*(160/3) + ; This is mathematically the correct table, but it seems too + ; loud, and it overloads on playback. + + DB 255, 112, 96, 87, 80, 75, 71, 67 ; 0->7 + DB 64, 61, 59, 57, 55, 53, 51, 50 ; 8->15 + DB 48, 47, 45, 44, 43, 42, 41, 40 ; 16->23 + DB 39, 38, 37, 36, 35, 34, 34, 33 ; 24->31 + DB 32, 31, 31, 30, 29, 29, 28, 28 ; 32->39 + DB 27, 26, 26, 25, 25, 24, 24, 23 ; 40->47 + DB 23, 22, 22, 21, 21, 20, 20, 20 ; 48->55 + DB 19, 19, 18, 18, 18, 17, 17, 16 ; 56->63 + DB 16, 16, 15, 15, 15, 14, 14, 14 ; 64->71 + DB 13, 13, 13, 13, 12, 12, 12, 11 ; 72->79 + DB 11, 11, 10, 10, 10, 9, 9, 9 ; 80->87 + DB 9, 8, 8, 8, 8, 7, 7, 7 ; 88->95 + DB 7, 6, 6, 6, 6, 5, 5, 5 ; 96->103 + DB 5, 4, 4, 4, 4, 4, 4, 3 ; 104->111 + DB 3, 3, 3, 2, 2, 2, 2, 2 ; 112->119 + DB 1, 1, 1, 1, 1, 1, 1, 1 ; 120->127 + DB 0 + + ~ + +AWEPitchTable Label DWord ; Pitchval = 88200 * 2^(Pos / 4096) + DD 88200, 88215, 88230, 88245, 88260, 88275, 88290, 88305 + DD 88320, 88335, 88350, 88365, 88380, 88395, 88410, 88425 + DD 88440, 88455, 88470, 88485, 88500, 88514, 88529, 88544 + DD 88559, 88574, 88589, 88604, 88619, 88634, 88649, 88664 + DD 88679, 88694, 88709, 88724, 88739, 88754, 88770, 88785 + DD 88800, 88815, 88830, 88845, 88860, 88875, 88890, 88905 + DD 88920, 88935, 88950, 88965, 88980, 88995, 89010, 89025 + DD 89040, 89055, 89070, 89086, 89101, 89116, 89131, 89146 + DD 89161, 89176, 89191, 89206, 89221, 89236, 89252, 89267 + DD 89282, 89297, 89312, 89327, 89342, 89357, 89372, 89388 + DD 89403, 89418, 89433, 89448, 89463, 89478, 89493, 89509 + DD 89524, 89539, 89554, 89569, 89584, 89600, 89615, 89630 + DD 89645, 89660, 89675, 89691, 89706, 89721, 89736, 89751 + DD 89767, 89782, 89797, 89812, 89827, 89842, 89858, 89873 + DD 89888, 89903, 89919, 89934, 89949, 89964, 89979, 89995 + DD 90010, 90025, 90040, 90056, 90071, 90086, 90101, 90117 + DD 90132, 90147, 90162, 90178, 90193, 90208, 90223, 90239 + DD 90254, 90269, 90284, 90300, 90315, 90330, 90346, 90361 + DD 90376, 90391, 90407, 90422, 90437, 90453, 90468, 90483 + DD 90499, 90514, 90529, 90545, 90560, 90575, 90591, 90606 + DD 90621, 90637, 90652, 90667, 90683, 90698, 90713, 90729 + DD 90744, 90759, 90775, 90790, 90805, 90821, 90836, 90852 + DD 90867, 90882, 90898, 90913, 90928, 90944, 90959, 90975 + DD 90990, 91005, 91021, 91036, 91052, 91067, 91082, 91098 + DD 91113, 91129, 91144, 91160, 91175, 91190, 91206, 91221 + DD 91237, 91252, 91268, 91283, 91299, 91314, 91329, 91345 + DD 91360, 91376, 91391, 91407, 91422, 91438, 91453, 91469 + DD 91484, 91500, 91515, 91531, 91546, 91562, 91577, 91593 + DD 91608, 91624, 91639, 91655, 91670, 91686, 91701, 91717 + DD 91732, 91748, 91763, 91779, 91794, 91810, 91825, 91841 + DD 91856, 91872, 91887, 91903, 91919, 91934, 91950, 91965 + DD 91981, 91996, 92012, 92028, 92043, 92059, 92074, 92090 + DD 92105, 92121, 92137, 92152, 92168, 92183, 92199, 92215 + DD 92230, 92246, 92261, 92277, 92293, 92308, 92324, 92340 + DD 92355, 92371, 92386, 92402, 92418, 92433, 92449, 92465 + DD 92480, 92496, 92512, 92527, 92543, 92559, 92574, 92590 + DD 92606, 92621, 92637, 92653, 92668, 92684, 92700, 92715 + DD 92731, 92747, 92762, 92778, 92794, 92810, 92825, 92841 + DD 92857, 92872, 92888, 92904, 92920, 92935, 92951, 92967 + DD 92982, 92998, 93014, 93030, 93045, 93061, 93077, 93093 + DD 93108, 93124, 93140, 93156, 93171, 93187, 93203, 93219 + DD 93235, 93250, 93266, 93282, 93298, 93313, 93329, 93345 + DD 93361, 93377, 93392, 93408, 93424, 93440, 93456, 93472 + DD 93487, 93503, 93519, 93535, 93551, 93566, 93582, 93598 + DD 93614, 93630, 93646, 93662, 93677, 93693, 93709, 93725 + DD 93741, 93757, 93773, 93788, 93804, 93820, 93836, 93852 + DD 93868, 93884, 93900, 93915, 93931, 93947, 93963, 93979 + DD 93995, 94011, 94027, 94043, 94059, 94075, 94090, 94106 + DD 94122, 94138, 94154, 94170, 94186, 94202, 94218, 94234 + DD 94250, 94266, 94282, 94298, 94314, 94330, 94346, 94362 + DD 94377, 94393, 94409, 94425, 94441, 94457, 94473, 94489 + DD 94505, 94521, 94537, 94553, 94569, 94585, 94601, 94617 + DD 94633, 94649, 94665, 94681, 94697, 94713, 94729, 94746 + DD 94762, 94778, 94794, 94810, 94826, 94842, 94858, 94874 + DD 94890, 94906, 94922, 94938, 94954, 94970, 94986, 95002 + DD 95018, 95035, 95051, 95067, 95083, 95099, 95115, 95131 + DD 95147, 95163, 95179, 95196, 95212, 95228, 95244, 95260 + DD 95276, 95292, 95308, 95324, 95341, 95357, 95373, 95389 + DD 95405, 95421, 95437, 95454, 95470, 95486, 95502, 95518 + DD 95534, 95551, 95567, 95583, 95599, 95615, 95631, 95648 + DD 95664, 95680, 95696, 95712, 95729, 95745, 95761, 95777 + DD 95793, 95810, 95826, 95842, 95858, 95875, 95891, 95907 + DD 95923, 95939, 95956, 95972, 95988, 96004, 96021, 96037 + DD 96053, 96069, 96086, 96102, 96118, 96134, 96151, 96167 + DD 96183, 96200, 96216, 96232, 96248, 96265, 96281, 96297 + DD 96314, 96330, 96346, 96362, 96379, 96395, 96411, 96428 + DD 96444, 96460, 96477, 96493, 96509, 96526, 96542, 96558 + DD 96575, 96591, 96607, 96624, 96640, 96656, 96673, 96689 + DD 96706, 96722, 96738, 96755, 96771, 96787, 96804, 96820 + DD 96837, 96853, 96869, 96886, 96902, 96919, 96935, 96951 + DD 96968, 96984, 97001, 97017, 97033, 97050, 97066, 97083 + DD 97099, 97116, 97132, 97148, 97165, 97181, 97198, 97214 + DD 97231, 97247, 97264, 97280, 97296, 97313, 97329, 97346 + DD 97362, 97379, 97395, 97412, 97428, 97445, 97461, 97478 + DD 97494, 97511, 97527, 97544, 97560, 97577, 97593, 97610 + DD 97626, 97643, 97659, 97676, 97692, 97709, 97726, 97742 + DD 97759, 97775, 97792, 97808, 97825, 97841, 97858, 97874 + DD 97891, 97908, 97924, 97941, 97957, 97974, 97990, 98007 + DD 98024, 98040, 98057, 98073, 98090, 98107, 98123, 98140 + DD 98156, 98173, 98190, 98206, 98223, 98240, 98256, 98273 + DD 98289, 98306, 98323, 98339, 98356, 98373, 98389, 98406 + DD 98423, 98439, 98456, 98473, 98489, 98506, 98523, 98539 + DD 98556, 98573, 98589, 98606, 98623, 98639, 98656, 98673 + DD 98689, 98706, 98723, 98740, 98756, 98773, 98790, 98806 + DD 98823, 98840, 98857, 98873, 98890, 98907, 98924, 98940 + DD 98957, 98974, 98990, 99007, 99024, 99041, 99058, 99074 + DD 99091, 99108, 99125, 99141, 99158, 99175, 99192, 99208 + DD 99225, 99242, 99259, 99276, 99292, 99309, 99326, 99343 + DD 99360, 99377, 99393, 99410, 99427, 99444, 99461, 99477 + DD 99494, 99511, 99528, 99545, 99562, 99579, 99595, 99612 + DD 99629, 99646, 99663, 99680, 99697, 99713, 99730, 99747 + DD 99764, 99781, 99798, 99815, 99832, 99849, 99865, 99882 + DD 99899, 99916, 99933, 99950, 99967, 99984, 100001, 100018 + DD 100035, 100051, 100068, 100085, 100102, 100119, 100136, 100153 + DD 100170, 100187, 100204, 100221, 100238, 100255, 100272, 100289 + DD 100306, 100323, 100340, 100357, 100374, 100391, 100408, 100425 + DD 100442, 100459, 100476, 100493, 100510, 100527, 100544, 100561 + DD 100578, 100595, 100612, 100629, 100646, 100663, 100680, 100697 + DD 100714, 100731, 100748, 100765, 100782, 100799, 100816, 100833 + DD 100850, 100867, 100885, 100902, 100919, 100936, 100953, 100970 + DD 100987, 101004, 101021, 101038, 101055, 101073, 101090, 101107 + DD 101124, 101141, 101158, 101175, 101192, 101209, 101227, 101244 + DD 101261, 101278, 101295, 101312, 101329, 101347, 101364, 101381 + DD 101398, 101415, 101432, 101450, 101467, 101484, 101501, 101518 + DD 101535, 101553, 101570, 101587, 101604, 101621, 101639, 101656 + DD 101673, 101690, 101707, 101725, 101742, 101759, 101776, 101793 + DD 101811, 101828, 101845, 101862, 101880, 101897, 101914, 101931 + DD 101949, 101966, 101983, 102000, 102018, 102035, 102052, 102069 + DD 102087, 102104, 102121, 102139, 102156, 102173, 102190, 102208 + DD 102225, 102242, 102260, 102277, 102294, 102312, 102329, 102346 + DD 102363, 102381, 102398, 102415, 102433, 102450, 102467, 102485 + DD 102502, 102520, 102537, 102554, 102572, 102589, 102606, 102624 + DD 102641, 102658, 102676, 102693, 102711, 102728, 102745, 102763 + DD 102780, 102797, 102815, 102832, 102850, 102867, 102884, 102902 + DD 102919, 102937, 102954, 102972, 102989, 103006, 103024, 103041 + DD 103059, 103076, 103094, 103111, 103129, 103146, 103163, 103181 + DD 103198, 103216, 103233, 103251, 103268, 103286, 103303, 103321 + DD 103338, 103356, 103373, 103391, 103408, 103426, 103443, 103461 + DD 103478, 103496, 103513, 103531, 103548, 103566, 103583, 103601 + DD 103618, 103636, 103653, 103671, 103689, 103706, 103724, 103741 + DD 103759, 103776, 103794, 103811, 103829, 103847, 103864, 103882 + DD 103899, 103917, 103934, 103952, 103970, 103987, 104005, 104022 + DD 104040, 104058, 104075, 104093, 104110, 104128, 104146, 104163 + DD 104181, 104199, 104216, 104234, 104252, 104269, 104287, 104304 + DD 104322, 104340, 104357, 104375, 104393, 104410, 104428, 104446 + DD 104463, 104481, 104499, 104516, 104534, 104552, 104570, 104587 + DD 104605, 104623, 104640, 104658, 104676, 104694, 104711, 104729 + DD 104747, 104764, 104782, 104800, 104818, 104835, 104853, 104871 + DD 104889, 104906, 104924, 104942, 104960, 104977, 104995, 105013 + DD 105031, 105048, 105066, 105084, 105102, 105120, 105137, 105155 + DD 105173, 105191, 105209, 105226, 105244, 105262, 105280, 105298 + DD 105315, 105333, 105351, 105369, 105387, 105405, 105422, 105440 + DD 105458, 105476, 105494, 105512, 105530, 105547, 105565, 105583 + DD 105601, 105619, 105637, 105655, 105672, 105690, 105708, 105726 + DD 105744, 105762, 105780, 105798, 105816, 105834, 105851, 105869 + DD 105887, 105905, 105923, 105941, 105959, 105977, 105995, 106013 + DD 106031, 106049, 106067, 106085, 106103, 106120, 106138, 106156 + DD 106174, 106192, 106210, 106228, 106246, 106264, 106282, 106300 + DD 106318, 106336, 106354, 106372, 106390, 106408, 106426, 106444 + DD 106462, 106480, 106498, 106516, 106534, 106552, 106570, 106588 + DD 106606, 106624, 106643, 106661, 106679, 106697, 106715, 106733 + DD 106751, 106769, 106787, 106805, 106823, 106841, 106859, 106877 + DD 106895, 106914, 106932, 106950, 106968, 106986, 107004, 107022 + DD 107040, 107058, 107077, 107095, 107113, 107131, 107149, 107167 + DD 107185, 107203, 107222, 107240, 107258, 107276, 107294, 107312 + DD 107331, 107349, 107367, 107385, 107403, 107421, 107440, 107458 + DD 107476, 107494, 107512, 107531, 107549, 107567, 107585, 107603 + DD 107622, 107640, 107658, 107676, 107694, 107713, 107731, 107749 + DD 107767, 107786, 107804, 107822, 107840, 107859, 107877, 107895 + DD 107913, 107932, 107950, 107968, 107986, 108005, 108023, 108041 + DD 108060, 108078, 108096, 108114, 108133, 108151, 108169, 108188 + DD 108206, 108224, 108243, 108261, 108279, 108297, 108316, 108334 + DD 108352, 108371, 108389, 108408, 108426, 108444, 108463, 108481 + DD 108499, 108518, 108536, 108554, 108573, 108591, 108609, 108628 + DD 108646, 108665, 108683, 108701, 108720, 108738, 108757, 108775 + DD 108793, 108812, 108830, 108849, 108867, 108886, 108904, 108922 + DD 108941, 108959, 108978, 108996, 109015, 109033, 109051, 109070 + DD 109088, 109107, 109125, 109144, 109162, 109181, 109199, 109218 + DD 109236, 109255, 109273, 109292, 109310, 109329, 109347, 109366 + DD 109384, 109403, 109421, 109440, 109458, 109477, 109495, 109514 + DD 109532, 109551, 109569, 109588, 109607, 109625, 109644, 109662 + DD 109681, 109699, 109718, 109736, 109755, 109774, 109792, 109811 + DD 109829, 109848, 109867, 109885, 109904, 109922, 109941, 109960 + DD 109978, 109997, 110015, 110034, 110053, 110071, 110090, 110108 + DD 110127, 110146, 110164, 110183, 110202, 110220, 110239, 110258 + DD 110276, 110295, 110314, 110332, 110351, 110370, 110388, 110407 + DD 110426, 110444, 110463, 110482, 110500, 110519, 110538, 110557 + DD 110575, 110594, 110613, 110631, 110650, 110669, 110688, 110706 + DD 110725, 110744, 110763, 110781, 110800, 110819, 110838, 110856 + DD 110875, 110894, 110913, 110931, 110950, 110969, 110988, 111007 + DD 111025, 111044, 111063, 111082, 111100, 111119, 111138, 111157 + DD 111176, 111195, 111213, 111232, 111251, 111270, 111289, 111307 + DD 111326, 111345, 111364, 111383, 111402, 111421, 111439, 111458 + DD 111477, 111496, 111515, 111534, 111553, 111571, 111590, 111609 + DD 111628, 111647, 111666, 111685, 111704, 111723, 111742, 111760 + DD 111779, 111798, 111817, 111836, 111855, 111874, 111893, 111912 + DD 111931, 111950, 111969, 111988, 112007, 112026, 112045, 112063 + DD 112082, 112101, 112120, 112139, 112158, 112177, 112196, 112215 + DD 112234, 112253, 112272, 112291, 112310, 112329, 112348, 112367 + DD 112386, 112405, 112424, 112443, 112462, 112481, 112500, 112520 + DD 112539, 112558, 112577, 112596, 112615, 112634, 112653, 112672 + DD 112691, 112710, 112729, 112748, 112767, 112786, 112806, 112825 + DD 112844, 112863, 112882, 112901, 112920, 112939, 112958, 112977 + DD 112997, 113016, 113035, 113054, 113073, 113092, 113111, 113130 + DD 113150, 113169, 113188, 113207, 113226, 113245, 113265, 113284 + DD 113303, 113322, 113341, 113360, 113380, 113399, 113418, 113437 + DD 113456, 113476, 113495, 113514, 113533, 113552, 113572, 113591 + DD 113610, 113629, 113649, 113668, 113687, 113706, 113726, 113745 + DD 113764, 113783, 113803, 113822, 113841, 113860, 113880, 113899 + DD 113918, 113937, 113957, 113976, 113995, 114015, 114034, 114053 + DD 114072, 114092, 114111, 114130, 114150, 114169, 114188, 114208 + DD 114227, 114246, 114266, 114285, 114304, 114324, 114343, 114362 + DD 114382, 114401, 114420, 114440, 114459, 114479, 114498, 114517 + DD 114537, 114556, 114575, 114595, 114614, 114634, 114653, 114672 + DD 114692, 114711, 114731, 114750, 114770, 114789, 114808, 114828 + DD 114847, 114867, 114886, 114906, 114925, 114944, 114964, 114983 + DD 115003, 115022, 115042, 115061, 115081, 115100, 115120, 115139 + DD 115159, 115178, 115198, 115217, 115237, 115256, 115276, 115295 + DD 115315, 115334, 115354, 115373, 115393, 115412, 115432, 115451 + DD 115471, 115490, 115510, 115529, 115549, 115569, 115588, 115608 + DD 115627, 115647, 115666, 115686, 115706, 115725, 115745, 115764 + DD 115784, 115804, 115823, 115843, 115862, 115882, 115902, 115921 + DD 115941, 115960, 115980, 116000, 116019, 116039, 116059, 116078 + DD 116098, 116117, 116137, 116157, 116176, 116196, 116216, 116235 + DD 116255, 116275, 116294, 116314, 116334, 116354, 116373, 116393 + DD 116413, 116432, 116452, 116472, 116491, 116511, 116531, 116551 + DD 116570, 116590, 116610, 116630, 116649, 116669, 116689, 116708 + DD 116728, 116748, 116768, 116788, 116807, 116827, 116847, 116867 + DD 116886, 116906, 116926, 116946, 116966, 116985, 117005, 117025 + DD 117045, 117065, 117084, 117104, 117124, 117144, 117164, 117183 + DD 117203, 117223, 117243, 117263, 117283, 117302, 117322, 117342 + DD 117362, 117382, 117402, 117422, 117442, 117461, 117481, 117501 + DD 117521, 117541, 117561, 117581, 117601, 117621, 117640, 117660 + DD 117680, 117700, 117720, 117740, 117760, 117780, 117800, 117820 + DD 117840, 117860, 117880, 117900, 117919, 117939, 117959, 117979 + DD 117999, 118019, 118039, 118059, 118079, 118099, 118119, 118139 + DD 118159, 118179, 118199, 118219, 118239, 118259, 118279, 118299 + DD 118319, 118339, 118359, 118379, 118399, 118419, 118439, 118459 + DD 118480, 118500, 118520, 118540, 118560, 118580, 118600, 118620 + DD 118640, 118660, 118680, 118700, 118720, 118740, 118761, 118781 + DD 118801, 118821, 118841, 118861, 118881, 118901, 118921, 118942 + DD 118962, 118982, 119002, 119022, 119042, 119062, 119083, 119103 + DD 119123, 119143, 119163, 119183, 119204, 119224, 119244, 119264 + DD 119284, 119304, 119325, 119345, 119365, 119385, 119405, 119426 + DD 119446, 119466, 119486, 119506, 119527, 119547, 119567, 119587 + DD 119608, 119628, 119648, 119668, 119689, 119709, 119729, 119749 + DD 119770, 119790, 119810, 119831, 119851, 119871, 119891, 119912 + DD 119932, 119952, 119973, 119993, 120013, 120033, 120054, 120074 + DD 120094, 120115, 120135, 120155, 120176, 120196, 120216, 120237 + DD 120257, 120277, 120298, 120318, 120339, 120359, 120379, 120400 + DD 120420, 120440, 120461, 120481, 120502, 120522, 120542, 120563 + DD 120583, 120604, 120624, 120644, 120665, 120685, 120706, 120726 + DD 120747, 120767, 120787, 120808, 120828, 120849, 120869, 120890 + DD 120910, 120931, 120951, 120971, 120992, 121012, 121033, 121053 + DD 121074, 121094, 121115, 121135, 121156, 121176, 121197, 121217 + DD 121238, 121258, 121279, 121299, 121320, 121341, 121361, 121382 + DD 121402, 121423, 121443, 121464, 121484, 121505, 121525, 121546 + DD 121567, 121587, 121608, 121628, 121649, 121670, 121690, 121711 + DD 121731, 121752, 121773, 121793, 121814, 121834, 121855, 121876 + DD 121896, 121917, 121937, 121958, 121979, 121999, 122020, 122041 + DD 122061, 122082, 122103, 122123, 122144, 122165, 122185, 122206 + DD 122227, 122247, 122268, 122289, 122309, 122330, 122351, 122372 + DD 122392, 122413, 122434, 122454, 122475, 122496, 122517, 122537 + DD 122558, 122579, 122600, 122620, 122641, 122662, 122683, 122703 + DD 122724, 122745, 122766, 122786, 122807, 122828, 122849, 122870 + DD 122890, 122911, 122932, 122953, 122974, 122994, 123015, 123036 + DD 123057, 123078, 123099, 123119, 123140, 123161, 123182, 123203 + DD 123224, 123244, 123265, 123286, 123307, 123328, 123349, 123370 + DD 123391, 123411, 123432, 123453, 123474, 123495, 123516, 123537 + DD 123558, 123579, 123599, 123620, 123641, 123662, 123683, 123704 + DD 123725, 123746, 123767, 123788, 123809, 123830, 123851, 123872 + DD 123893, 123914, 123935, 123956, 123977, 123998, 124019, 124040 + DD 124061, 124081, 124102, 124124, 124145, 124166, 124187, 124208 + DD 124229, 124250, 124271, 124292, 124313, 124334, 124355, 124376 + DD 124397, 124418, 124439, 124460, 124481, 124502, 124523, 124544 + DD 124565, 124586, 124608, 124629, 124650, 124671, 124692, 124713 + DD 124734, 124755, 124776, 124797, 124819, 124840, 124861, 124882 + DD 124903, 124924, 124945, 124967, 124988, 125009, 125030, 125051 + DD 125072, 125093, 125115, 125136, 125157, 125178, 125199, 125221 + DD 125242, 125263, 125284, 125305, 125327, 125348, 125369, 125390 + DD 125411, 125433, 125454, 125475, 125496, 125518, 125539, 125560 + DD 125581, 125603, 125624, 125645, 125666, 125688, 125709, 125730 + DD 125751, 125773, 125794, 125815, 125837, 125858, 125879, 125901 + DD 125922, 125943, 125964, 125986, 126007, 126028, 126050, 126071 + DD 126092, 126114, 126135, 126156, 126178, 126199, 126220, 126242 + DD 126263, 126285, 126306, 126327, 126349, 126370, 126391, 126413 + DD 126434, 126456, 126477, 126498, 126520, 126541, 126563, 126584 + DD 126606, 126627, 126648, 126670, 126691, 126713, 126734, 126756 + DD 126777, 126799, 126820, 126841, 126863, 126884, 126906, 126927 + DD 126949, 126970, 126992, 127013, 127035, 127056, 127078, 127099 + DD 127121, 127142, 127164, 127185, 127207, 127228, 127250, 127271 + DD 127293, 127315, 127336, 127358, 127379, 127401, 127422, 127444 + DD 127465, 127487, 127509, 127530, 127552, 127573, 127595, 127617 + DD 127638, 127660, 127681, 127703, 127725, 127746, 127768, 127789 + DD 127811, 127833, 127854, 127876, 127898, 127919, 127941, 127963 + DD 127984, 128006, 128028, 128049, 128071, 128093, 128114, 128136 + DD 128158, 128179, 128201, 128223, 128244, 128266, 128288, 128309 + DD 128331, 128353, 128375, 128396, 128418, 128440, 128462, 128483 + DD 128505, 128527, 128549, 128570, 128592, 128614, 128636, 128657 + DD 128679, 128701, 128723, 128744, 128766, 128788, 128810, 128832 + DD 128853, 128875, 128897, 128919, 128941, 128963, 128984, 129006 + DD 129028, 129050, 129072, 129094, 129115, 129137, 129159, 129181 + DD 129203, 129225, 129247, 129268, 129290, 129312, 129334, 129356 + DD 129378, 129400, 129422, 129444, 129465, 129487, 129509, 129531 + DD 129553, 129575, 129597, 129619, 129641, 129663, 129685, 129707 + DD 129729, 129751, 129773, 129794, 129816, 129838, 129860, 129882 + DD 129904, 129926, 129948, 129970, 129992, 130014, 130036, 130058 + DD 130080, 130102, 130124, 130146, 130168, 130190, 130212, 130235 + DD 130257, 130279, 130301, 130323, 130345, 130367, 130389, 130411 + DD 130433, 130455, 130477, 130499, 130521, 130543, 130566, 130588 + DD 130610, 130632, 130654, 130676, 130698, 130720, 130742, 130765 + DD 130787, 130809, 130831, 130853, 130875, 130897, 130920, 130942 + DD 130964, 130986, 131008, 131030, 131053, 131075, 131097, 131119 + DD 131141, 131163, 131186, 131208, 131230, 131252, 131274, 131297 + DD 131319, 131341, 131363, 131386, 131408, 131430, 131452, 131475 + DD 131497, 131519, 131541, 131564, 131586, 131608, 131630, 131653 + DD 131675, 131697, 131720, 131742, 131764, 131786, 131809, 131831 + DD 131853, 131876, 131898, 131920, 131943, 131965, 131987, 132010 + DD 132032, 132054, 132077, 132099, 132121, 132144, 132166, 132188 + DD 132211, 132233, 132256, 132278, 132300, 132323, 132345, 132368 + DD 132390, 132412, 132435, 132457, 132480, 132502, 132524, 132547 + DD 132569, 132592, 132614, 132637, 132659, 132682, 132704, 132726 + DD 132749, 132771, 132794, 132816, 132839, 132861, 132884, 132906 + DD 132929, 132951, 132974, 132996, 133019, 133041, 133064, 133086 + DD 133109, 133131, 133154, 133176, 133199, 133221, 133244, 133267 + DD 133289, 133312, 133334, 133357, 133379, 133402, 133425, 133447 + DD 133470, 133492, 133515, 133537, 133560, 133583, 133605, 133628 + DD 133651, 133673, 133696, 133718, 133741, 133764, 133786, 133809 + DD 133832, 133854, 133877, 133900, 133922, 133945, 133968, 133990 + DD 134013, 134036, 134058, 134081, 134104, 134126, 134149, 134172 + DD 134194, 134217, 134240, 134263, 134285, 134308, 134331, 134353 + DD 134376, 134399, 134422, 134444, 134467, 134490, 134513, 134535 + DD 134558, 134581, 134604, 134627, 134649, 134672, 134695, 134718 + DD 134741, 134763, 134786, 134809, 134832, 134855, 134877, 134900 + DD 134923, 134946, 134969, 134992, 135014, 135037, 135060, 135083 + DD 135106, 135129, 135152, 135174, 135197, 135220, 135243, 135266 + DD 135289, 135312, 135335, 135358, 135381, 135403, 135426, 135449 + DD 135472, 135495, 135518, 135541, 135564, 135587, 135610, 135633 + DD 135656, 135679, 135702, 135725, 135748, 135771, 135794, 135816 + DD 135839, 135862, 135885, 135908, 135931, 135954, 135977, 136000 + DD 136023, 136047, 136070, 136093, 136116, 136139, 136162, 136185 + DD 136208, 136231, 136254, 136277, 136300, 136323, 136346, 136369 + DD 136392, 136415, 136438, 136462, 136485, 136508, 136531, 136554 + DD 136577, 136600, 136623, 136646, 136670, 136693, 136716, 136739 + DD 136762, 136785, 136808, 136832, 136855, 136878, 136901, 136924 + DD 136947, 136971, 136994, 137017, 137040, 137063, 137086, 137110 + DD 137133, 137156, 137179, 137203, 137226, 137249, 137272, 137295 + DD 137319, 137342, 137365, 137388, 137412, 137435, 137458, 137481 + DD 137505, 137528, 137551, 137575, 137598, 137621, 137644, 137668 + DD 137691, 137714, 137738, 137761, 137784, 137808, 137831, 137854 + DD 137877, 137901, 137924, 137948, 137971, 137994, 138018, 138041 + DD 138064, 138088, 138111, 138134, 138158, 138181, 138205, 138228 + DD 138251, 138275, 138298, 138322, 138345, 138368, 138392, 138415 + DD 138439, 138462, 138485, 138509, 138532, 138556, 138579, 138603 + DD 138626, 138650, 138673, 138697, 138720, 138744, 138767, 138790 + DD 138814, 138837, 138861, 138884, 138908, 138931, 138955, 138978 + DD 139002, 139026, 139049, 139073, 139096, 139120, 139143, 139167 + DD 139190, 139214, 139237, 139261, 139285, 139308, 139332, 139355 + DD 139379, 139402, 139426, 139450, 139473, 139497, 139520, 139544 + DD 139568, 139591, 139615, 139639, 139662, 139686, 139709, 139733 + DD 139757, 139780, 139804, 139828, 139851, 139875, 139899, 139922 + DD 139946, 139970, 139993, 140017, 140041, 140065, 140088, 140112 + DD 140136, 140159, 140183, 140207, 140231, 140254, 140278, 140302 + DD 140326, 140349, 140373, 140397, 140421, 140444, 140468, 140492 + DD 140516, 140539, 140563, 140587, 140611, 140635, 140658, 140682 + DD 140706, 140730, 140754, 140777, 140801, 140825, 140849, 140873 + DD 140897, 140920, 140944, 140968, 140992, 141016, 141040, 141064 + DD 141087, 141111, 141135, 141159, 141183, 141207, 141231, 141255 + DD 141279, 141303, 141326, 141350, 141374, 141398, 141422, 141446 + DD 141470, 141494, 141518, 141542, 141566, 141590, 141614, 141638 + DD 141662, 141686, 141710, 141734, 141758, 141782, 141806, 141830 + DD 141854, 141878, 141902, 141926, 141950, 141974, 141998, 142022 + DD 142046, 142070, 142094, 142118, 142142, 142166, 142190, 142214 + DD 142238, 142262, 142286, 142310, 142334, 142359, 142383, 142407 + DD 142431, 142455, 142479, 142503, 142527, 142551, 142576, 142600 + DD 142624, 142648, 142672, 142696, 142720, 142745, 142769, 142793 + DD 142817, 142841, 142865, 142890, 142914, 142938, 142962, 142986 + DD 143011, 143035, 143059, 143083, 143107, 143132, 143156, 143180 + DD 143204, 143228, 143253, 143277, 143301, 143325, 143350, 143374 + DD 143398, 143423, 143447, 143471, 143495, 143520, 143544, 143568 + DD 143593, 143617, 143641, 143665, 143690, 143714, 143738, 143763 + DD 143787, 143811, 143836, 143860, 143884, 143909, 143933, 143957 + DD 143982, 144006, 144031, 144055, 144079, 144104, 144128, 144152 + DD 144177, 144201, 144226, 144250, 144275, 144299, 144323, 144348 + DD 144372, 144397, 144421, 144446, 144470, 144494, 144519, 144543 + DD 144568, 144592, 144617, 144641, 144666, 144690, 144715, 144739 + DD 144764, 144788, 144813, 144837, 144862, 144886, 144911, 144935 + DD 144960, 144984, 145009, 145033, 145058, 145082, 145107, 145132 + DD 145156, 145181, 145205, 145230, 145254, 145279, 145304, 145328 + DD 145353, 145377, 145402, 145427, 145451, 145476, 145500, 145525 + DD 145550, 145574, 145599, 145624, 145648, 145673, 145698, 145722 + DD 145747, 145772, 145796, 145821, 145846, 145870, 145895, 145920 + DD 145944, 145969, 145994, 146018, 146043, 146068, 146093, 146117 + DD 146142, 146167, 146191, 146216, 146241, 146266, 146290, 146315 + DD 146340, 146365, 146390, 146414, 146439, 146464, 146489, 146513 + DD 146538, 146563, 146588, 146613, 146637, 146662, 146687, 146712 + DD 146737, 146762, 146786, 146811, 146836, 146861, 146886, 146911 + DD 146936, 146960, 146985, 147010, 147035, 147060, 147085, 147110 + DD 147135, 147160, 147184, 147209, 147234, 147259, 147284, 147309 + DD 147334, 147359, 147384, 147409, 147434, 147459, 147484, 147509 + DD 147534, 147559, 147583, 147608, 147633, 147658, 147683, 147708 + DD 147733, 147758, 147783, 147808, 147833, 147858, 147883, 147909 + DD 147934, 147959, 147984, 148009, 148034, 148059, 148084, 148109 + DD 148134, 148159, 148184, 148209, 148234, 148259, 148284, 148310 + DD 148335, 148360, 148385, 148410, 148435, 148460, 148485, 148510 + DD 148536, 148561, 148586, 148611, 148636, 148661, 148686, 148712 + DD 148737, 148762, 148787, 148812, 148838, 148863, 148888, 148913 + DD 148938, 148964, 148989, 149014, 149039, 149064, 149090, 149115 + DD 149140, 149165, 149191, 149216, 149241, 149266, 149292, 149317 + DD 149342, 149367, 149393, 149418, 149443, 149469, 149494, 149519 + DD 149544, 149570, 149595, 149620, 149646, 149671, 149696, 149722 + DD 149747, 149772, 149798, 149823, 149848, 149874, 149899, 149925 + DD 149950, 149975, 150001, 150026, 150051, 150077, 150102, 150128 + DD 150153, 150178, 150204, 150229, 150255, 150280, 150306, 150331 + DD 150356, 150382, 150407, 150433, 150458, 150484, 150509, 150535 + DD 150560, 150586, 150611, 150637, 150662, 150688, 150713, 150739 + DD 150764, 150790, 150815, 150841, 150866, 150892, 150917, 150943 + DD 150968, 150994, 151019, 151045, 151071, 151096, 151122, 151147 + DD 151173, 151198, 151224, 151250, 151275, 151301, 151326, 151352 + DD 151378, 151403, 151429, 151455, 151480, 151506, 151531, 151557 + DD 151583, 151608, 151634, 151660, 151685, 151711, 151737, 151762 + DD 151788, 151814, 151839, 151865, 151891, 151917, 151942, 151968 + DD 151994, 152019, 152045, 152071, 152097, 152122, 152148, 152174 + DD 152200, 152225, 152251, 152277, 152303, 152328, 152354, 152380 + DD 152406, 152432, 152457, 152483, 152509, 152535, 152561, 152586 + DD 152612, 152638, 152664, 152690, 152716, 152741, 152767, 152793 + DD 152819, 152845, 152871, 152897, 152922, 152948, 152974, 153000 + DD 153026, 153052, 153078, 153104, 153130, 153156, 153181, 153207 + DD 153233, 153259, 153285, 153311, 153337, 153363, 153389, 153415 + DD 153441, 153467, 153493, 153519, 153545, 153571, 153597, 153623 + DD 153649, 153675, 153701, 153727, 153753, 153779, 153805, 153831 + DD 153857, 153883, 153909, 153935, 153961, 153987, 154013, 154039 + DD 154065, 154091, 154118, 154144, 154170, 154196, 154222, 154248 + DD 154274, 154300, 154326, 154352, 154379, 154405, 154431, 154457 + DD 154483, 154509, 154535, 154562, 154588, 154614, 154640, 154666 + DD 154692, 154719, 154745, 154771, 154797, 154823, 154850, 154876 + DD 154902, 154928, 154954, 154981, 155007, 155033, 155059, 155086 + DD 155112, 155138, 155164, 155191, 155217, 155243, 155269, 155296 + DD 155322, 155348, 155374, 155401, 155427, 155453, 155480, 155506 + DD 155532, 155559, 155585, 155611, 155638, 155664, 155690, 155717 + DD 155743, 155769, 155796, 155822, 155848, 155875, 155901, 155928 + DD 155954, 155980, 156007, 156033, 156060, 156086, 156112, 156139 + DD 156165, 156192, 156218, 156245, 156271, 156297, 156324, 156350 + DD 156377, 156403, 156430, 156456, 156483, 156509, 156536, 156562 + DD 156589, 156615, 156642, 156668, 156695, 156721, 156748, 156774 + DD 156801, 156827, 156854, 156880, 156907, 156934, 156960, 156987 + DD 157013, 157040, 157066, 157093, 157120, 157146, 157173, 157199 + DD 157226, 157253, 157279, 157306, 157332, 157359, 157386, 157412 + DD 157439, 157466, 157492, 157519, 157546, 157572, 157599, 157626 + DD 157652, 157679, 157706, 157732, 157759, 157786, 157812, 157839 + DD 157866, 157893, 157919, 157946, 157973, 157999, 158026, 158053 + DD 158080, 158106, 158133, 158160, 158187, 158213, 158240, 158267 + DD 158294, 158321, 158347, 158374, 158401, 158428, 158455, 158481 + DD 158508, 158535, 158562, 158589, 158616, 158642, 158669, 158696 + DD 158723, 158750, 158777, 158804, 158830, 158857, 158884, 158911 + DD 158938, 158965, 158992, 159019, 159046, 159073, 159100, 159126 + DD 159153, 159180, 159207, 159234, 159261, 159288, 159315, 159342 + DD 159369, 159396, 159423, 159450, 159477, 159504, 159531, 159558 + DD 159585, 159612, 159639, 159666, 159693, 159720, 159747, 159774 + DD 159801, 159828, 159855, 159882, 159909, 159936, 159963, 159990 + DD 160018, 160045, 160072, 160099, 160126, 160153, 160180, 160207 + DD 160234, 160261, 160289, 160316, 160343, 160370, 160397, 160424 + DD 160451, 160479, 160506, 160533, 160560, 160587, 160614, 160642 + DD 160669, 160696, 160723, 160750, 160778, 160805, 160832, 160859 + DD 160886, 160914, 160941, 160968, 160995, 161023, 161050, 161077 + DD 161104, 161132, 161159, 161186, 161213, 161241, 161268, 161295 + DD 161323, 161350, 161377, 161405, 161432, 161459, 161487, 161514 + DD 161541, 161569, 161596, 161623, 161651, 161678, 161705, 161733 + DD 161760, 161787, 161815, 161842, 161870, 161897, 161924, 161952 + DD 161979, 162007, 162034, 162061, 162089, 162116, 162144, 162171 + DD 162199, 162226, 162253, 162281, 162308, 162336, 162363, 162391 + DD 162418, 162446, 162473, 162501, 162528, 162556, 162583, 162611 + DD 162638, 162666, 162693, 162721, 162748, 162776, 162804, 162831 + DD 162859, 162886, 162914, 162941, 162969, 162997, 163024, 163052 + DD 163079, 163107, 163135, 163162, 163190, 163217, 163245, 163273 + DD 163300, 163328, 163356, 163383, 163411, 163438, 163466, 163494 + DD 163521, 163549, 163577, 163604, 163632, 163660, 163688, 163715 + DD 163743, 163771, 163798, 163826, 163854, 163882, 163909, 163937 + DD 163965, 163993, 164020, 164048, 164076, 164104, 164131, 164159 + DD 164187, 164215, 164243, 164270, 164298, 164326, 164354, 164382 + DD 164409, 164437, 164465, 164493, 164521, 164549, 164576, 164604 + DD 164632, 164660, 164688, 164716, 164744, 164771, 164799, 164827 + DD 164855, 164883, 164911, 164939, 164967, 164995, 165023, 165051 + DD 165078, 165106, 165134, 165162, 165190, 165218, 165246, 165274 + DD 165302, 165330, 165358, 165386, 165414, 165442, 165470, 165498 + DD 165526, 165554, 165582, 165610, 165638, 165666, 165694, 165722 + DD 165750, 165778, 165806, 165834, 165862, 165891, 165919, 165947 + DD 165975, 166003, 166031, 166059, 166087, 166115, 166143, 166172 + DD 166200, 166228, 166256, 166284, 166312, 166340, 166368, 166397 + DD 166425, 166453, 166481, 166509, 166538, 166566, 166594, 166622 + DD 166650, 166678, 166707, 166735, 166763, 166791, 166820, 166848 + DD 166876, 166904, 166933, 166961, 166989, 167017, 167046, 167074 + DD 167102, 167130, 167159, 167187, 167215, 167244, 167272, 167300 + DD 167328, 167357, 167385, 167413, 167442, 167470, 167498, 167527 + DD 167555, 167584, 167612, 167640, 167669, 167697, 167725, 167754 + DD 167782, 167811, 167839, 167867, 167896, 167924, 167953, 167981 + DD 168009, 168038, 168066, 168095, 168123, 168152, 168180, 168209 + DD 168237, 168266, 168294, 168322, 168351, 168379, 168408, 168436 + DD 168465, 168493, 168522, 168551, 168579, 168608, 168636, 168665 + DD 168693, 168722, 168750, 168779, 168807, 168836, 168865, 168893 + DD 168922, 168950, 168979, 169007, 169036, 169065, 169093, 169122 + DD 169151, 169179, 169208, 169236, 169265, 169294, 169322, 169351 + DD 169380, 169408, 169437, 169466, 169494, 169523, 169552, 169580 + DD 169609, 169638, 169667, 169695, 169724, 169753, 169781, 169810 + DD 169839, 169868, 169896, 169925, 169954, 169983, 170011, 170040 + DD 170069, 170098, 170127, 170155, 170184, 170213, 170242, 170271 + DD 170299, 170328, 170357, 170386, 170415, 170444, 170472, 170501 + DD 170530, 170559, 170588, 170617, 170646, 170674, 170703, 170732 + DD 170761, 170790, 170819, 170848, 170877, 170906, 170935, 170964 + DD 170992, 171021, 171050, 171079, 171108, 171137, 171166, 171195 + DD 171224, 171253, 171282, 171311, 171340, 171369, 171398, 171427 + DD 171456, 171485, 171514, 171543, 171572, 171601, 171630, 171659 + DD 171688, 171717, 171746, 171776, 171805, 171834, 171863, 171892 + DD 171921, 171950, 171979, 172008, 172037, 172066, 172096, 172125 + DD 172154, 172183, 172212, 172241, 172270, 172300, 172329, 172358 + DD 172387, 172416, 172445, 172475, 172504, 172533, 172562, 172591 + DD 172621, 172650, 172679, 172708, 172737, 172767, 172796, 172825 + DD 172854, 172884, 172913, 172942, 172972, 173001, 173030, 173059 + DD 173089, 173118, 173147, 173177, 173206, 173235, 173264, 173294 + DD 173323, 173352, 173382, 173411, 173440, 173470, 173499, 173529 + DD 173558, 173587, 173617, 173646, 173675, 173705, 173734, 173764 + DD 173793, 173822, 173852, 173881, 173911, 173940, 173970, 173999 + DD 174028, 174058, 174087, 174117, 174146, 174176, 174205, 174235 + DD 174264, 174294, 174323, 174353, 174382, 174412, 174441, 174471 + DD 174500, 174530, 174559, 174589, 174618, 174648, 174678, 174707 + DD 174737, 174766, 174796, 174825, 174855, 174885, 174914, 174944 + DD 174973, 175003, 175033, 175062, 175092, 175122, 175151, 175181 + DD 175210, 175240, 175270, 175299, 175329, 175359, 175388, 175418 + DD 175448, 175478, 175507, 175537, 175567, 175596, 175626, 175656 + DD 175686, 175715, 175745, 175775, 175804, 175834, 175864, 175894 + DD 175924, 175953, 175983, 176013, 176043, 176072, 176102, 176132 + DD 176162, 176192, 176221, 176251, 176281, 176311, 176341, 176371 + +GUSScreenList Label + DW 7 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr GravisHeaderLine + + DW Near Ptr MixerText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr MasterVolumeLeft ; 7 + DW Near Ptr MasterVolumeRight + DW Near Ptr TrebleVolumeLeft + DW Near Ptr TrebleVolumeRight + DW Near Ptr BassVolumeLeft + DW Near Ptr BassVolumeRight ; 12 + + DW Near Ptr SampleText + + DW Near Ptr SampleSize0Button ; 14 + DW Near Ptr SampleSize1Button + DW Near Ptr SampleSize2Button + DW Near Ptr SampleSize3Button ; 17 + + DW Near Ptr EffectText + DW Near Ptr EffectBox + + DW Near Ptr ChorusThumbBar ; 20 + DW Near Ptr ReverbThumbBar + + DW DriverText + + DW 0 + +GravisHeaderLine DW 10 + DB "Sound Blaster AWE 32 Driver", 0 + +DriverText DW 1 + DB 27, 48 + DB 21h + DB "Sound Blaster AWE 32 Driver 1.5 for Impulse Tracker", 0 + +MixerText DW 1 + DB 3, 13 + DB 20h + DB "Mixer options", 13 + DB 13 + DB " Master Volume Left", 13 + DB " Master Volume Right", 13 + DB 13 + DB 13 + DB " Treble Left", 13 + DB " Treble Right", 13 + DB " Bass Left", 13 + DB " Bass Right", 13 + DB 0 + +VolumeBox1 DW 0 + DB 24, 14, 30, 17 + DB 25 + +VolumeBox2 DW 0 + DB 17, 18, 21, 23 + DB 25 + +MasterVolumeLeft DW 9 + DB 25, 15 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 8, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 25, 16 + DW 0, 31 + DW 9, 1 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 18, 19 + DW 0, 15 + DW 9, 2 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 18, 20 + DW 0, 15 + DW 9, 3 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 18, 21 + DW 0, 15 + DW 9, 4 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 18, 22 + DW 0, 15 + DW 9, 5 + DW 11, 14, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +SampleText DW 1 + DB 3, 25 + DB 20h + DB "Sample resizing options", 0 + +SampleSize0Button DW 2 + DW 12, 15, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment1 DW 0 + DW 0 + DW Offset SetCompress +DriverSegment2 DW 0 + DB 7, 27, 20, 29, 8 + DB 0 + DB " Original", 0 + +SampleSize1Button DW 2 + DW 14, 16, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment3 DW 0 + DW 1 + DW Offset SetCompress +DriverSegment4 DW 0 + DB 7, 30, 20, 32, 8 + DB 0 + DB " Half", 0 + +SampleSize2Button DW 2 + DW 15, 17, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment5 DW 0 + DW 2 + DW Offset SetCompress +DriverSegment6 DW 0 + DB 7, 33, 20, 35, 8 + DB 0 + DB " Quarter", 0 + +SampleSize3Button DW 2 + DW 16, 20, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment7 DW 0 + DW 3 + DW Offset SetCompress +DriverSegment8 DW 0 + DB 7, 36, 20, 38, 8 + DB 0 + DB " Eighth", 0 + +EffectText DW 1 + DB 3, 40 + DB 20h + DB "Effect options", 13 + DB 13 + DB " Chorus", 13 + DB " Reverb", 0 + + +EffectBox DW 0 + DB 12, 41, 30, 44 + DB 25 + +ChorusThumbBar DW 9 + DB 13, 42 + DW 0, 127 + DW 9, 6 + DW 17, 21, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +ReverbThumbBar DW 9 + DB 13, 43 + DW 0, 127 + DW 9, 7 + DW 20, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + + + +VolumeTable DB 6 Dup (0) +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 2 +Chorus DB 10, 64 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +AWEParameters DB 64 Dup (0FFh), 64 Dup (0) + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectUART ; Given DX = Port + +; From SB-DevKit + + ClI + + Inc DX + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 40h ; Ready for output + LoopNZ DetectUART1 + JNZ DetectUARTError + + Mov AL, 0FFh ; Reset! + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + JNZ DetectUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART4 + +DetectUART3: + Loop DetectUART2 + +DetectUARTError: + StI + StC + Ret + +DetectUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +DetectUART5: + In AL, DX + Test AL, 40h + LoopNZ DetectUART5 + JNZ DetectUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +DetectUART6: + Xor CX, CX + +DetectUART7: + In AL, DX + Test AL, 80h + JNZ DetectUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART9 + +DetectUART8: + Loop DetectUART7 + + Jmp DetectUARTError + +DetectUART9: + StI + ClC + Ret + +EndP DetectUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReinitUART + + Mov DX, MIDIPort + Test DX, DX + JZ ReinitUART1 + + Call DetectUART + +ReinitUART1: + Ret + +EndP ReinitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, MIDIPort + Test DX, DX + JZ ResetUART1 + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetCompress Far + + Mov CX, [SI+22] + Mov CS:Compress, CL + + Mov AX, 1 + ShL AX, CL + Mov CS:Step, AX + + Call Music_LoadAllSamples + + Mov AX, 1 + Ret + +EndP SetCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetCompress Far + + Push CS + Pop ES + Mov DI, Offset Compress + + Ret + +EndP GetCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load8BitSamplesForwards ; Given DS:SI, ECX = count + + Push BX + + Mov BX, CS:Step + Mov DX, CS:BasePort + Add DX, 400h + Xor AL, AL + +Load8BitSamplesForwards2: + Mov AH, [SI] + Add SI, BX + JC Load8BitSamplesForwards4 + +Load8BitSamplesForwards3: + Out DX, AX + + Dec ECX + JNZ Load8BitSamplesForwards2 + + Pop BX + Ret + +Load8BitSamplesForwards4: + Add ESI, 10000h + Int 3 + Jmp Load8BitSamplesForwards3 + +EndP Load8BitSamplesForwards + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load16BitSamplesForwards ; Given DS:SI, ECX = count + + Push BX + + Mov BX, CS:Step + Mov DX, CS:BasePort + Add DX, 400h + Add BX, BX + +Load16BitSamplesForwards2: + Mov AX, [SI] + Add SI, BX + JC Load16BitSamplesForwards4 + +Load16BitSamplesForwards3: + Out DX, AX + + Dec ECX + JNZ Load16BitSamplesForwards2 + + Pop BX + Ret + +Load16BitSamplesForwards4: + Add ESI, 10000h + Int 3 + Jmp Load16BitSamplesForwards3 + +EndP Load16BitSamplesForwards + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load8BitSamplesBackwards ; Given DS:SI, ECX = count + + Push BX + + Mov BX, CS:Step + Mov DX, CS:BasePort + Add DX, 400h + Xor AL, AL + + Sub SI, BX + JC Load8BitSamplesBackwards6 + +Load8BitSamplesBackwards2: + Sub SI, BX + JC Load8BitSamplesBackwards4 + +Load8BitSamplesBackwards3: + Mov AH, [SI] + Out DX, AX + + Dec ECX + JNZ Load8BitSamplesBackwards2 + + + Pop BX + Ret + +Load8BitSamplesBackwards4: + Sub ESI, 10000h + JC Load8BitSamplesBackwards5 + Int 3 + Jmp Load8BitSamplesBackwards3 + +Load8BitSamplesBackwards5: + Xor ESI, ESI + Jmp Load8BitSamplesBackwards3 + +Load8BitSamplesBackwards6: + Sub ESI, 10000h + Int 3 + Jmp Load8BitSamplesBackwards2 + + +EndP Load8BitSamplesBackwards + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load16BitSamplesBackwards ; Given DS:SI, ECX = count + + Push BX + + Mov BX, CS:Step + Mov DX, CS:BasePort + Add DX, 400h + Add BX, BX + + Sub SI, BX + JC Load16BitSamplesBackwards6 + +Load16BitSamplesBackwards2: + Sub SI, BX + JC Load16BitSamplesBackwards4 + +Load16BitSamplesBackwards3: + Mov AX, [SI] + Out DX, AX + + Dec ECX + JNZ Load16BitSamplesBackwards2 + + Pop BX + Ret + +Load16BitSamplesBackwards4: + Sub ESI, 10000h + JC Load16BitSamplesBackwards5 + Int 3 + Jmp Load16BitSamplesBackwards3 + +Load16BitSamplesBackwards5: + Xor ESI, ESI + Jmp Load16BitSamplesBackwards3 + +Load16BitSamplesBackwards6: + Sub ESI, 10000h + Int 3 + Jmp Load16BitSamplesBackwards2 + + +EndP Load16BitSamplesBackwards + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WriteDataChannel + + Or AX, DX + +Proc WriteData ; Have BX/EBX = value + ; AX = xxyyh + ; ^ ^ + ; | | + ; | \-- value to send to pointer register + ; \---- 0, 1, 2 or 3, 4 + ; 0 = data reg 0 + ; 1 = data reg 1, dword + ; 2 = data reg 2 + ; 3 = data reg 3 + ; 4 = data reg 4, word + + Push DX + Push AX + + Mov DX, BasePort + Add DX, 802h + And AX, 0FFh + Out DX, AX + Pop AX + + Cmp AH, 1 + JB WriteDataReg0 + JE WriteDataReg1DWord + Cmp AH, 3 + JB WriteDataReg2 + JE WriteDataReg3 + Jmp WriteDataReg1Word + +WriteDataReg0: + Sub DX, 802h + Mov EAX, EBX + Out DX, EAX + + Pop DX + Ret + +WriteDataReg1DWord: + Sub DX, 402h + Mov EAX, EBX + Out DX, EAX + + Pop DX + Ret + +WriteDataReg1Word: + Sub DX, 402h + Mov AX, BX + Out DX, AX + + Pop DX + Ret + +WriteDataReg2: + Sub DX, 400h + Mov AX, BX + Out DX, AX + + Pop DX + Ret + +WriteDataReg3: + Sub DL, 2 + Mov AX, BX + Out DX, AX + + Pop DX + Ret + +EndP WriteData + +EndP WriteDataChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReadDataChannel + + Or AX, DX + +Proc ReadData ; AX = xxyyh + ; ^ ^ + ; | | + ; | \-- value to send to pointer register + ; \---- 0, 1, 2 or 3, 4 + ; 0 = data reg 0 + ; 1 = data reg 1, dword + ; 2 = data reg 2 + ; 3 = data reg 3 + ; 4 = data reg 4, word + + Push DX + Push AX + + Mov DX, BasePort + Add DX, 802h + And AX, 0FFh + Out DX, AX + Pop AX + + Cmp AH, 1 + JB ReadDataReg0 + JE ReadDataReg1DWord + Cmp AH, 3 + JB ReadDataReg2 + JE ReadDataReg3 + Jmp ReadDataReg1Word + +ReadDataReg0: + Sub DX, 802h + In EAX, DX + + Pop DX + Ret + +ReadDataReg1DWord: + Sub DX, 402h + In EAX, DX + + Pop DX + Ret + +ReadDataReg1Word: + Sub DX, 402h + In AX, DX + + Pop DX + Ret + +ReadDataReg2: + Sub DX, 400h + In AX, DX + + Pop DX + Ret + +ReadDataReg3: + Sub DL, 2 + In AX, DX + + Pop DX + Ret + +EndP ReadData + +EndP ReadDataChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetAWEFrequency + + Push DS + Push SI + Push CX + Push DX + + Mov EAX, [SI+10h] ; Final freq + + Mov CL, Compress + ShR EAX, CL + + Test EAX, EAX + JZ SetAWEFrequencyError + Cmp EAX, 88200*2 + JAE SetAWEFrequencyError + + Push CS + Pop DS + Assume DS:Driver + + And ESI, 0FFFFh + + Mov BX, 0F000h + Mov CX, 0FFFh ; Use binary search + Xor DX, DX ; CX = upper, DX = lower + +SetAWEFrequency1: + Cmp EAX, 88200 + JAE SetAWEFrequency2 + + Sub BX, 1000h + JC SetAWEFrequencyError + Add EAX, EAX + Jmp SetAWEFrequency1 + +SetAWEFrequency2: + Cmp CX, DX + JBE SetAWEFrequency5 + + Mov SI, CX + Add SI, DX + ShR SI, 1 + + Cmp EAX, [AWEPitchTable+ESI*4] + JE SetAWEFrequency3 + JB SetAWEFrequency4 ; In lower half + + ; In upper half + Inc SI + Mov DX, SI + Jmp SetAWEFrequency2 + +SetAWEFrequency4: ; In lower half + Dec SI + Mov CX, SI + Jmp SetAWEFrequency2 + +SetAWEFrequency5: + Mov SI, CX + +SetAWEFrequency3: + Add BX, SI + + Pop DX + Pop CX + Pop SI + Pop DS + + Mov AX, IP + Call WriteDataChannel + + Ret + Assume DS:Nothing + +SetAWEFrequencyError: + Call StopAWENote + + Mov Word Ptr [SI], 200h + Test Byte Ptr [SI+3Ah], 80h + JNZ SetAWEFrequencyError1 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +SetAWEFrequencyError1: + Mov AX, IP + Xor EBX, EBX + Call WriteDataChannel + + Push CS + Pop DS + Mov SI, Offset FrequencyError + Mov BX, 40 + Call SetInfoLine + + Pop DX + Pop CX + Pop SI + Pop DS + + Ret + +EndP SetAWEFrequency + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetAWEPan + + Mov AX, PSST + Call ReadDataChannel ; Get starting offset + + Cmp CS:Stereo, 0 + JE SetPan2 + + Test CL, 128 + JNZ SetPan2 + + Mov BL, [SI+37h] ; Final pan + Cmp BL, 100 ; Surround -> central + JNE SetPan1 + +SetPan2: + Mov BL, 32 + +SetPan1: ; BL = 0->64, need to extend to 0->255 + Add BL, BL + Add BL, BL + SBB BL, 0 ; BL = 0->255 + Not BL + + ShL EAX, 8 + SHLD EBX, EAX, 24 + Mov AX, PSST + Call WriteDataChannel + + Ret + +EndP SetAWEPan + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetAWEVolume + + Test CH, 8 + JZ SetAWEVolume1 + + Test CH, 1 + JNZ SetAWEVolume5 + + Cmp Byte Ptr [SI+8], 0FFh + JE SetAWEVolume4 + +SetAWEVolume5: + Mov Byte Ptr [SI+8], 0FFh + + Mov AX, IFATN + Call ReadDataChannel + Mov BX, AX + Mov AX, IFATN + Mov BL, 0FFh + Call WriteDataChannel + +SetAWEVolume4: + Ret + +SetAWEVolume1: +; First check if channel has been disowned + Xor BX, BX + Mov BL, [SI+3Ah] ; BL = host channel + + Test BL, BL + JS SetAWEVolume3 + +SetAWEVolume2: + Mov AH, [CS:AWEParameters+BX] ; AH = filter + Mov AL, [CS:AWEParameters+BX+64] ; AL = Q. + + ShR AL, 3 + Mov [SI+5Bh], AH + + Cmp AL, [SI+3Fh] + JE SetAWEVolume3 + + Mov [SI+3Fh], AL + +; Set Q + Mov BL, AL + ShL EBX, 28 + + Mov AX, CCCA + Call ReadDataChannel + And EAX, 0FFFFFFFh + Or EBX, EAX + Mov AX, CCCA + Call WriteDataChannel + +SetAWEVolume3: + Mov AL, [SI+3Eh] + Mul Byte Ptr [SI+5Bh] + ShL AX, 1 + Xor BX, BX + Add AH, 1 + Mov BL, [SI+20h] ; Final volume + Mov [SI+8], BL + Mov BL, [CS:AWEVolumeTable+BX] + Mov BH, AH + Mov AX, IFATN + Call WriteDataChannel + + Ret + +EndP SetAWEVolume + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopAWENote + + Mov AX, DCYSUSV + Mov BX, 80h + Call WriteDataChannel + + Mov AX, VTFT + Mov EBX, 0FFFFh + Call WriteDataChannel + + Mov AX, CVCF + Call WriteDataChannel + + Mov BX, 80h + Mov AX, DCYSUSV + Call WriteDataChannel + + Mov AX, VTFT + Mov EBX, 0FFFFh + Call WriteDataChannel + + Mov AX, CVCF + Call WriteDataChannel + + Xor EBX, EBX + Mov AX, ENVVOL + Call WriteDataChannel + + Mov AX, ENVVAL + Call WriteDataChannel + + Mov AX, SUSDCY + Call WriteDataChannel + + Mov AX, ATKHLDV + Call WriteDataChannel + + Mov AX, LFO1VAL + Call WriteDataChannel + + Mov AX, HLDATK + Call WriteDataChannel + + Mov AX, LFO2VAL + Call WriteDataChannel + + Mov AX, IP + Call WriteDataChannel + + Mov AX, IFATN + Call WriteDataChannel + + Mov AX, PEFE + Call WriteDataChannel + + Mov AX, FMMOD + Call WriteDataChannel + + Mov AX, TREMFRQ + Call WriteDataChannel + + Mov AX, FM2FRQ2 + Call WriteDataChannel + + Mov AX, PTRX + Call WriteDataChannel + + Mov AX, VTFT + Call WriteDataChannel + +; Mov AX, PSST +; Call WriteDataChannel + + Mov BL, 8 + Mov AX, CSL + Call WriteDataChannel + + Xor BX, BX + Mov AX, CCCA + Call WriteDataChannel + + Mov AX, CPF + Call WriteDataChannel + + Ret + +EndP StopAWENote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetAWERegisters ; DS:SI = channel info table + ; CX = number of channels... + + Push CX + Push SI + + ; Stage 1. + ; Turn off any channel which has + ; a new note to play + ; If no new note to play and channel + ; is on, then get current position + + Xor DX, DX ; DX = oscillator number + +GetAWERegisters1: + Mov BX, [SI] + Test BH, 2 ; Note cut command + JZ GetAWERegisters2 + + Mov BX, 200h + Mov [SI], BX + + Call StopAWENote + Jmp GetAWERegisters4 + +GetAWERegisters2: + Test BL, 1 ; Channel on? + JZ GetAWERegisters4 + + Test BH, 1 ; New note? + JZ GetAWERegisters3 + + ; Fade out volume + Mov AX, DCYSUSV + Mov BX, 807Fh + Call WriteDataChannel + +; Call StopAWENote + + Jmp GetAWERegisters4 + +GetAWERegisters3: ; Get offset + Mov AX, CCCA + Call ReadDataChannel + + Xor BX, BX + And EAX, 00000000111111111111111111111111b + Inc EAX ; Interpolator correction + ; EAX = address in sound memory + Mov BL, [SI+36h] ; BL = sample number + LEA BX, [EBX*4+EBX] + ShL BX, 2 + Add BX, Offset AWEDataTable + + Cmp Byte Ptr [SI+0Ah], 8 + JB GetAddressNoLoop + JE GetAddressForwardsLoop + +GetAddressPingPongLoop: + Cmp EAX, [CS:BX+16] + JB SetOldAddress + + Neg EAX + Add EAX, [CS:BX+8] + Jmp SetOldAddress1 + +GetAddressNoLoop: + Cmp EAX, [CS:BX+4] ; Start loop + JB SetOldAddress + + Call StopAWENote + + ; OK.. gotta turn off channel + Mov Word Ptr [SI], 0 + Test Byte Ptr [SI+3Ah], 80h + JNZ GetAWERegisters4 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + + Jmp GetAWERegisters4 + +GetAddressForwardsLoop: +SetOldAddress: + Sub EAX, [CS:BX] ; EAX = address in sample + JNS SetOldAddress1 + + Xor EAX, EAX + +SetOldAddress1: + Push CX + Mov CL, Compress + ShL EAX, CL + Pop CX + + XChg [SI+4Ch], EAX + Mov [SI+2Ch], EAX + +GetAWERegisters4: + Add SI, 128 + + Inc DX + Dec CX + JNZ GetAWERegisters1 + + Pop SI + Pop CX + + Xor DX, DX ; DX = oscillator number + +SetAWERegisters1: + ; Stage 2. + ; If new frequency, play new frequency + ; If new volume, play new volume + ; If new pan, play new pan + ; If new note, set ENVVOL, ENVVAL, SUSDCY, ATKHLDV, LFO1VAL, HLDATK + ; LFO2VAL, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2 + ; PSST, CSL, CCCA + ; VTFT, CVCF, DCYSUSV, PTRX, CPF + + Push CX + Mov CX, [SI] + Test CL, 1 ; Channel on? + JZ SetAWERegistersEnd + + Test CH, 1 ; New note? + JZ SetAWERegisters2 + + Xor BX, BX + Mov BL, [SI+36h] + LEA DI, [EBX*4+EBX] + ShL DI, 2 + Add DI, Offset AWEDataTable + + Mov AX, DCYSUSV + Mov BX, 80h + Call WriteDataChannel + + Mov AX, VTFT + Xor EBX, EBX + Call WriteDataChannel + + Mov AX, CVCF + Call WriteDataChannel + + Cmp DWord Ptr [CS:DI], 0FFFFFFFFh + JE SetAWERegistersError + + Mov AX, PTRX + Call WriteDataChannel + + Mov AX, CPF + Call WriteDataChannel + + + Mov AX, ENVVOL + Mov BX, 8000h + Call WriteDataChannel + + Mov AX, ENVVAL + Mov BX, 8000h + Call WriteDataChannel + + Mov AX, SUSDCY + Mov BX, 7F7Fh + Call WriteDataChannel + + Mov AX, ATKHLDV + Call WriteDataChannel + + Mov AX, LFO1VAL + Mov BX, 8000h + Call WriteDataChannel + + Mov AX, HLDATK + Mov BX, 7F7Fh + Call WriteDataChannel + + Mov AX, LFO2VAL + Mov BX, 8000h + Call WriteDataChannel + + Call SetAWEFrequency + Call SetAWEVolume + + Mov AX, PEFE + Xor BX, BX + Call WriteDataChannel + + Mov AX, FMMOD + Call WriteDataChannel + + Mov AX, TREMFRQ + Mov BX, 10h + Call WriteDataChannel + + Mov AX, FM2FRQ2 + Call WriteDataChannel + + + Mov EBX, [CS:DI+4] + Dec EBX ; Interpolator offset + Mov AX, PSST + Call WriteDataChannel + + Call SetAWEPan + + Mov AL, [CS:VolumeTable+6] ; Chorus + ShL EAX, 24 + Mov EBX, [CS:DI+8] + Dec EBX ; Interpolator offset + Or EBX, EAX + Mov AX, CSL + Call WriteDataChannel + + Mov AL, [SI+3Fh] + ShL EAX, 28 + + Push CX + Mov CL, Compress + Mov EBX, [SI+4Ch] + ShR EBX, CL + Pop CX + Add EBX, [CS:DI] + Dec EBX ; Interpolator offset + Or EBX, EAX + + Mov AX, CCCA ; Current address. + Call WriteDataChannel + + + Mov AX, VTFT + Mov EBX, 0FFFFh + Call WriteDataChannel + + Mov AX, CVCF + Call WriteDataChannel + + Mov AX, DCYSUSV + Mov BX, 7F7Fh + Call WriteDataChannel + + Mov AX, PTRX + Mov EBX, 40000000h ; 25% reverb + Or BH, [CS:VolumeTable+7] + Call WriteDataChannel + + Mov AX, CPF + Call WriteDataChannel + Jmp SetAWERegistersEnd + +SetAWERegisters2: + Test CL, 32 ; Frequency change? + JZ SetAWERegisters3 + + Call SetAWEFrequency + +SetAWERegisters3: + Test CL, 64 ; Volume change? + JZ SetAWERegisters4 + + Call SetAWEVolume + +SetAWERegisters4: + Test CH, 80h ; New pan? + JZ SetAWERegistersEnd + + Call SetAWEPan + +SetAWERegistersEnd: + Pop CX + And Word Ptr [SI], 0111100010011111b + + Add SI, 128 + + Inc DX + Dec CX + JNZ SetAWERegisters1 + + Ret + +SetAWERegistersError: + Call StopAWENote + + Mov Word Ptr [SI], 0 + Test Byte Ptr [SI+3Ah], 80h + JNZ SetAWERegistersEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + + Jmp SetAWERegistersEnd + +EndP SetAWERegisters + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ACKIRQ + + Mov AL, 20h + Cmp CS:IRQ, 7 + JBE ACKIRQ1 + + Out 0A0h, AL + +ACKIRQ1: + Out 20h, AL + Ret + +EndP ACKIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Mov DX, MIDIPort + + Mov BL, [MIDIBufferTail] + Test DX, DX + JZ CheckMIDIEnd + + Inc DX + +CheckMIDIAgain: + In AL, DX + + Test AL, AL + JS CheckMIDIAgain + + Dec DX + In AL, DX + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDIIRQHandler + + Push AX BX DX + + Mov DX, CS:MixerPort + Mov AL, 82h + Out DX, AL + Inc DL + In AL, DX + + Test AL, 4 + JZ MIDIIRQHandlerEnd + + Call CheckMIDI + +MIDIIRQHandlerEnd: + Call AckIRQ + + Pop DX BX AX + IRet + + +EndP MIDIIRQHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIRQHandler + + PushAD + Push DS + Push ES + + StI + + Push CS + Pop DS + Assume DS:Driver + +SBIRQHandlerAgain: + Mov DX, MixerPort + Mov AL, 82h + Out DX, AL + Inc DL + In AL, DX + + Test AL, 4 + JZ NoMIDIIRQ + + Push AX + Call CheckMIDI + Pop AX + +NoMIDIIRQ: +; Test AL, 2 +; JZ No16BitIRQ +; +; Push AX +; Mov DX, MixerPort +; Add DL, 0Fh-4 +; In AL, DX +; Pop AX +; +; No16BitIRQ: + Test AL, 1 + JNZ SB8BitIRQ + +SBNo8BitIRQ: + Call AckIRQ + Jmp SBEndIRQ + +SB8BitIRQ: + Mov DX, MixerPort + Add DL, 0Eh-4 + In AL, DX ; 8-bit IRQ ack. + + Add DL, 0Ch-0Eh + + Mov AL, 80h ; Output block of silence + Call SBOut + Mov AX, BlockLength2 + Call SBOut + Mov AL, AH + Call SBOut + + Mov AL, 0D3h + Call SBOut + + ClD + Call ACKIRQ + + Inc IRQFlag + JNZ SBEndIRQ + + Call SaveEMSPageFrame + Assume DS:Nothing + +SB8BitIRQAgain: + Call Update ; Returns DS:SI, CX + + Mov BX, BlockLength + Cmp BX, BlockLength2 + JE SBIRQHandler2 + Mov BlockLength2, BX + + Mov DX, SB16BasePort + Add DL, 0Ch + + Mov AL, 0D0h + Call SBOut + + Mov AL, 80h ; Output block of silence + Call SBOut + Mov AL, BL + Call SBOut + Mov AL, BH + Call SBOut + +SBIRQHandler2: + Call SetAWERegisters + Sub CS:IRQFlag, 1 + JNC SB8BitIRQAgain + + Call RestoreEMSPageFrame + +SBEndIRQ: + Pop ES + Pop DS + PopAD + + IRet + +EndP SBIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AWEIRQHandler ; IRQ Handler has to + ; 1) Update AWE registers + ; 2) Update song position + Push AX + Push DS + + Mov AX, AWEUpdateTimer + Add AWEUpdateCount, AX + JC AWEIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp AWEIRQHandler2 + +AWEIRQHandler1: + PushF + Call [OldIRQHandler] + +AWEIRQHandler2: + Xor AWEUpdateFlag, 1 + JZ AWEIRQHandlerEnd + + PushAD + Push ES + + ClD + + Call SaveEMSPageFrame + Call Update ; Returns DS:SI, CX + Call SetAWERegisters + Call RestoreEMSPageFrame + + Pop ES + PopAD + +AWEIRQHandlerEnd: + Pop DS + Pop AX + IRet + +EndP AWEIRQHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EnableRAM + + Mov DX, BasePort + Mov CX, 29 + +EnableRAM1: + Mov AX, DCYSUSV + Or AX, CX + Mov BX, 80h + Call WriteData + + Mov AX, VTFT + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CVCF + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, PTRX + Or AX, CX + Mov EBX, 40000000h + Call WriteData + + Mov AX, CPF + Or AX, CX + Mov EBX, 40000000h + Call WriteData + + Mov AX, PSST + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CSL + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CCCA + Or AX, CX + Mov EBX, 6000000h ; Left write + Call WriteData + + Dec CX + JNS EnableRAM1 + + Ret + +EndP EnableRAM + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TestAWE ; Given DX = baseport. + + Push DX + + Add DX, 802h + In AL, DX + In AL, DX + Not AL + Mov BL, AL + Out DX, AL + In AL, DX + Cmp AL, BL + JNE TestAWE1 ; Register changed + + In AX, DX ; Is upper part of pointer + Mov BX, AX ; changing? + Mov CX, 128 + +TestAWE2: + In AX, DX + Cmp AL, BL + JNE TestAWE1 + Cmp AH, BH + JNE TestAWE3 + + Dec CX + JNZ TestAWE2 + Jmp TestAWE1 + +TestAWE3: + Pop DX + + ClC + Ret + +TestAWE1: + Pop DX + StC + Ret + +EndP TestAWE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSetAWE + + Mov CX, 31 + +InitSetAWE1: + Mov AX, 31 + Sub AX, CX + Mov BX, [SI] + Or AX, INIT1 + Call WriteData + + Add SI, 2 + + Dec CX + JNS InitSetAWE1 + + Mov CX, 31 + +InitSetAWE2: + Mov AX, 31 + Sub AX, CX + Mov BX, [SI] + Or AX, INIT2 + Call WriteData + + Add SI, 2 + + Dec CX + JNS InitSetAWE2 + + Mov CX, 31 + +InitSetAWE3: + Mov AX, 31 + Sub AX, CX + Mov BX, [SI] + Or AX, INIT3 + Call WriteData + + Add SI, 2 + + Dec CX + JNS InitSetAWE3 + + Mov CX, 31 + +InitSetAWE4: + Mov AX, 31 + Sub AX, CX + Mov BX, [SI] + Or AX, INIT4 + Call WriteData + + Add SI, 2 + + Dec CX + JNS InitSetAWE4 + + Ret + +EndP InitSetAWE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitAWE + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + + Mov AX, HWCF1 + Mov BX, 59h + Call WriteData + + Mov AX, CFG2 + Mov BX, 20h + Call WriteData + + Mov CX, 31 + +InitAwe1: + Mov BX, 80h + Mov AX, DCYSUSV + Or AX, CX + Call WriteData + + Xor EBX, EBX + Mov AX, ENVVOL + Or AX, CX + Call WriteData + + Mov AX, ENVVAL + Or AX, CX + Call WriteData + + Mov AX, SUSDCY + Or AX, CX + Call WriteData + + Mov AX, ATKHLDV + Or AX, CX + Call WriteData + + Mov AX, LFO1VAL + Or AX, CX + Call WriteData + + Mov AX, HLDATK + Or AX, CX + Call WriteData + + Mov AX, LFO2VAL + Or AX, CX + Call WriteData + + Mov AX, IP + Or AX, CX + Call WriteData + + Mov AX, IFATN + Or AX, CX + Call WriteData + + Mov AX, PEFE + Or AX, CX + Call WriteData + + Mov AX, FMMOD + Or AX, CX + Call WriteData + + Mov AX, TREMFRQ + Or AX, CX + Call WriteData + + Mov AX, FM2FRQ2 + Or AX, CX + Call WriteData + + Mov AX, PTRX + Or AX, CX + Call WriteData + + Mov AX, VTFT + Or AX, CX + Call WriteData + + Mov AX, PSST + Or AX, CX + Call WriteData + + Mov AX, CSL + Or AX, CX + Call WriteData + + Mov AX, CCCA + Or AX, CX + Call WriteData + + Dec CX + JNS InitAWE1 + + Mov CX, 31 + +InitAWE8: + Mov AX, CPF + Or AX, CX + Call WriteData + + Mov AX, CVCF + Or AX, CX + Call WriteData + + Dec CX + JNS InitAWE8 + ; Initialise still... + Mov AX, SMALR + Call WriteData + + Mov AX, SMARR + Call WriteData + + Mov AX, SMALW + Call WriteData + + Mov AX, SMARW + Call WriteData + + Mov SI, Offset InitTable1 + Call InitSetAWE + + ; Wait for 1024 sample periods + Mov AX, WC + Call ReadData + + Mov BX, AX + Mov CX, AX + Add CX, 400h ; 1024 + Cmp BX, CX + JB InitAWE3 + +InitAWE4: + Mov AX, WC + Call ReadData + Cmp AX, CX + JA InitAWE4 + +InitAWE3: + Mov AX, WC + Call ReadData + Cmp AX, CX + JB InitAWE3 + + Mov SI, Offset InitTable2 + Call InitSetAWE + + Mov SI, Offset InitTable3 + Call InitSetAWE + + Mov AX, HWCF4 + Xor EBX, EBX + Call WriteData + + Mov AX, HWCF5 + Mov EBX, 83h + Call WriteData + + Mov AX, HWCF6 + Mov EBX, 8000h + Call WriteData + + Mov SI, Offset InitTable4 + Call InitSetAWE + + Mov AX, HWCF3 + Mov BX, 4 + Call WriteData + + Ret + +EndP InitAWE + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitDRAMRefresh + + Mov AX, DCYSUSV+1Eh + Mov BX, 80h + Call WriteData + + Mov AX, DCYSUSV+1Fh + Call WriteData + +; + + Mov AX, VTFT+1Eh + Xor EBX, EBX + Call WriteData + + Mov AX, CVCF+1Eh + Call WriteData + + Mov AX, VTFT+1Fh + Call WriteData + + Mov AX, CVCF+1Fh + Call WriteData + +; + + Mov AX, PTRX+1Eh + Call WriteData + + Mov AX, CPF+1Eh + Call WriteData + + Mov AX, PTRX+1Fh + Call WriteData + + Mov AX, CPF+1Fh + Call WriteData + +; + + Mov AX, PSST+1Eh + Call WriteData + Mov AX, PSST+1Fh + Call WriteData + + Mov BX, 0FFFFh + Mov AX, CSL+1Eh + Call WriteData + Mov AX, CSL+1Fh + Call WriteData + + Xor BX, BX + Mov AX, CCCA+1Eh + Call WriteData + Mov AX, CCCA+1Fh + Call WriteData + + Ret + +EndP InitDRAMRefresh + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + + ShR AL, 7 + LoopZ SBIn + +; Test AL, AL +; JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov DX, BasePort + Cmp DX, 0FFFFh + JE DetectCard1 + + Cmp DX, 620h + JB DetectCard3 + Cmp DX, 680h + JA DetectCard3 + + Call TestAWE + JNC DetectCardFound + Ret + +DetectCard1: + Mov DX, 620h + +DetectCard2: + Call TestAWE + JNC DetectCardFound + + Add DL, 20h + Cmp DL, 80h + JBE DetectCard2 + +DetectCard3: + StC + Ret + +DetectCardFound: + Mov BasePort, DX + + ; Initialise AWE 32 + Call InitAWE + Call InitDRAMRefresh + + ; Detect amount of RAM. + + Mov DX, BasePort + Mov CX, 29 + +DetectCardMemory1: + Mov AX, DCYSUSV + Or AX, CX + Mov BX, 80h + Call WriteData + + Mov AX, VTFT + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CVCF + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, PTRX + Or AX, CX + Mov EBX, 40000000h + Call WriteData + + Mov AX, CPF + Or AX, CX + Mov EBX, 40000000h + Call WriteData + + Mov AX, PSST + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CSL + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CCCA + Or AX, CX + Mov EBX, 4000000h ; Left read + + Test CL, 2 + JZ DetectCardMemory2 + + Mov EBX, 6000000h ; Left write + +DetectCardMemory2: + Call WriteData + + Dec CX + JNS DetectCardMemory1 + + Xor EDI, EDI ; Amount of memory stored in + ; EDI + + Mov AX, SMALW + Mov EBX, 200000h + Call WriteData + + Mov AX, SMLD + Mov BX, 0FFFFh + Call WriteData + + Mov AX, SMLD + Mov BX, 5555h + Call WriteData + + Mov AX, SMLD + Mov BX, 0AAAAh + Call WriteData + + Mov AX, SMALR + Mov EBX, 200000h + Call WriteData + + Mov AX, SMLD + Call ReadData + + Mov AX, SMLD + Call ReadData + Cmp AX, 0FFFFh + JNE DetectCardMemory6 + + Mov AX, SMLD + Call ReadData + Cmp AX, 5555h + JNE DetectCardMemory6 + + Mov AX, SMLD + Call ReadData + Cmp AX, 0AAAAh + JNE DetectCardMemory6 + + Mov EDI, 20000h + +DetectCardMemory3: ; Set read/write addresses.. + Mov AX, SMALW + Mov EBX, EDI + Add EBX, 200000h + Call WriteData + + Mov AX, SMLD + Mov BX, 5555h + Call WriteData + + Mov AX, SMLD + Mov BX, 0AAAAh + Call WriteData + + Mov AX, SMALR + Mov EBX, 200000h + Call WriteData + + Mov AX, SMLD + Call ReadData + + Mov AX, SMLD + Call ReadData + Cmp AX, 0FFFFh + JNE DetectCardMemory5 + + Mov AX, SMALR + Mov EBX, EDI + Add EBX, 200000h + Call WriteData + + Mov AX, SMLD + Call ReadData + + Mov AX, SMLD + Call ReadData + Cmp AX, 5555h + JNE DetectCardMemory5 + + Mov AX, SMLD + Call ReadData + Cmp AX, 0AAAAh + JNE DetectCardMemory5 + +DetectCardMemory4: + Add EDI, 20000h + Cmp EDI, 0E00000h + JB DetectCardMemory3 + +DetectCardMemory5: + Cmp EDI, 0DFFFE0h + JB DetectCardMemory7 + + Mov EDI, 0DFFFE0h + +DetectCardMemory7: + Test EDI, EDI + JZ DetectCardMemory6 + + Mov AWEMemory, EDI + + Mov MixerPort, 210h + Mov AX, BasePort + Sub AX, 400h + Call ResetDSP + JNC DetectMixer2 + +DetectMixer1: + Mov AX, MixerPort + Call ResetDSP + JNC DetectMixer2 + +DetectMixer3: + Add MixerPort, 10h + Cmp MixerPort, 280h + JBE DetectMixer1 + + Mov DX, BasePort + Sub DX, 400h + Mov MixerPort, DX + + Jmp DetectCard4 + +DetectMixer2: ; OK... DSP found. + ; Get DSP version + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + + Mov CX, 200 + +DetectMixerLoop1: + In AL, DX +; Test AL, AL +; JS DetectMixerLoop1 + ShR AL, 7 + LoopNZ DetectMixerLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AX, 40Ch ; SB DSP = 4.12+ + JB DetectMixer3 + + Sub DL, 0Eh + Mov MixerPort, DX + +DetectCard4: + Mov SB16BasePort, DX + Add MixerPort, 4 ; Mixerport + + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Mov DX, MixerPort + Mov AX, 0C034h + Out DX, AX + + Mov AL, 35h + Out DX, AX + + Mov DX, MixerPort + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + Jmp NoWindows + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: + Mov AX, 1600h ; Windows detection. + Int 2Fh + Test AL, 7Fh + JZ NoWindows + + Mov SBIRQMode, 1 + +NoWindows: + Mov EAX, 'Jeff' + ClC + Ret + +DetectCardMemory6: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSamplingRate + + PushA + + Mov AX, CS:SB16BasePort + Mov DX, AX + Call ResetDSP + Add DL, 0Ch + ; Set mixing frequency + Mov AL, 40h + Call SBOut + Mov AL, 211 + Call SBOut ; 22222 Hz. + + Mov AL, 80h + Call SBOut + Mov AX, BlockLength + Dec AX + Call SBOut + Mov AL, AH + Call SBOut + + PopA + Ret + +EndP SetSamplingRate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMIDIIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset MIDIIRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetMIDIIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SBIRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitMIDI + + Mov DX, 330h + Call DetectUART + JC DetectMIDI1 + + Mov MIDIPort, 330h + Jmp DetectMIDIEnd + +DetectMIDI1: + Mov DX, 300h + Call DetectUART + JC DetectMIDIEnd + + Mov MIDIPort, 300h + +DetectMIDIEnd: + Ret + +EndP InitMIDI + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov AX, CS + Mov DriverSegment1, AX + Mov DriverSegment2, AX + Mov DriverSegment3, AX + Mov DriverSegment4, AX + Mov DriverSegment5, AX + Mov DriverSegment6, AX + Mov DriverSegment7, AX + Mov DriverSegment8, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Cmp SBIRQMode, 0 + JE InitSound1 + + Call SetIRQ + Call GetTempo + Call SetTempo + Call ResetMemory + Call SetSamplingRate + + Call InitMIDI + + Mov SI, Offset AWE32Msg2 + Mov AX, BasePort + + Mov BX, IRQ + + Mov ECX, AWEMemory + SHR ECX, 9 + + Ret + +InitSound1: + Call SetMIDIIRQ + Call GetTempo + Call SetTempo + Call ResetMemory + + Xor AX, AX + Mov ES, AX ; ES = 0 + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset AWEIRQHandler + + ClI + + XChg DWord Ptr [ES:20h], EAX ; Clock tick + Mov OldIRQHandler, EAX + + StI + +InitSound2: + Call InitMIDI + + Mov SI, Offset AWE32Msg + Mov AX, BasePort + + Mov EBX, AWEMemory + SHR EBX, 9 + + Ret + +EndP InitSound + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset AWE32ReinitMsg + Mov BX, 40 + Call SetInfoLine + + Call ResetUART + Call InitAWE + Call InitDRAMRefresh + + Cmp SBIRQMode, 0 + JE ReInitSound1 + + Call ResetIRQ + Call SetIRQ + Call SetSamplingRate + Call ReinitUART + Ret + +ReInitSound1: + Xor AX, AX + Mov ES, AX ; ES = 0 + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset AWEIRQHandler + + Mov DWord Ptr [ES:20h], EAX ; Clock tick + + Call ResetIRQ + Call SetMIDIIRQ + Call ReinitUART + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset Chorus + Int 21h + +SaveConfig1: + PushF + Mov AH, 3Eh + Int 21h + PopF + +SaveConfig2: + Call ResetIRQ + + Cmp SBIRQMode, 0 + JE UnInitSound1 + + Mov DX, SB16BasePort + Add DL, 0Ch + + Mov AL, 0D0h + Call SBOut + + Call ResetUART + +; Mov AX, SB16BasePort +; Call ResetDSP + + Call InitAWE + Ret + +UnInitSound1: + Mov AL, 34h + Out 43h, AL + + Xor AX, AX + Out 40h, AL + Out 40h, AL + + Mov ES, AX + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + + Mov AX, SB16BasePort + Call ResetDSP + Call ResetUART + Call InitAWE + Call ResetIRQ + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Cmp CS:SBIRQMode, 0 + JE SetTempo1 + ; BlockLength = 55555/BPM + + Mov AX, 55555 + Xor DX, DX + Div BX + Dec AX + Mov BlockLength, AX + +; Mov DX, SB16BasePort +; Add DL, 0Ch + + Jmp SetTempo2 + +SetTempo1: + ; Frames per second = 2 * (0.4*Tempo) + Mov AX, 0C214h + Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo + Div BX + + ; AX contains counter. + Mov AWEUpdateTimer, AX + + Out 40h, AL ; Timer IRQ. + Mov AL, AH + Out 40h, AL + +SetTempo2: + Pop DX + Pop BX + Pop AX + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + ; if no sample, then do nothing + ; MemoryUsed = length of sample + ; if sustain loop, then use sustain + ; loop information + ; if no sustain loop, then use loop + ; information + ; if no loop or sustain loop, + ; memoryused += 16; (16 zero samples + ; at the end) + ; + PushAD + Push DS + Push ES + Push FS + + Push AX + + ClI + + Call EnableRAM ; Enable access to DRAM. + + ; Set destination address + Mov AX, SMALW + Mov EBX, CS:AWEMemoryUsed + Add EBX, 200000h + Call WriteData + + Mov DX, CS:BasePort + Add DX, 802h ; Index + Mov AX, 32+26 + Out DX, AX + + Pop AX + + Mov FS, CS:SongDataArea + LEA DI, [EAX*4+EAX] + ShL DI, 2 + Add DI, Offset AWEDataTable-20 + + Mov ECX, -1 + + Mov DWord Ptr [CS:DI], ECX ; Start + Mov DWord Ptr [CS:DI+4], ECX ; Loop start + Mov DWord Ptr [CS:DI+8], ECX ; Loop end + Mov DWord Ptr [CS:DI+12], ECX ; Size occupied + Mov DWord Ptr [CS:DI+16], ECX ; Size occupied + + Mov BP, AX + Add BP, BP + Mov BP, [FS:64910+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC LoadSampleNoError + + JZ LoadSample1 + + ; 16 bit + + Mov CS:LoadSampleFuncF, Offset Load16BitSamplesForwards + Mov CS:LoadSampleFuncB, Offset Load16BitSamplesBackwards + + Jmp LoadSample2 + +LoadSample1: ; 8 bit + Mov CS:LoadSampleFuncF, Offset Load8BitSamplesForwards + Mov CS:LoadSampleFuncB, Offset Load8BitSamplesBackwards + +LoadSample2: + Mov AL, [FS:BP+12h] + Test AL, 30h ; Loop or sustain loop? + JZ LoadSampleNoLoop + + Mov EBX, [FS:BP+34h] ; Loop begin + Mov EDX, [FS:BP+38h] ; Loop end + Test AL, 20h ; Sustain loop? + JZ LoadSample3 + + ShR AL, 1 + Mov EBX, [FS:BP+40h] + Mov EDX, [FS:BP+44h] + Jmp LoadSample3 + +LoadSampleError: + ClC + Jmp LoadSampleEnd + +LoadSampleNoError: + StC + +LoadSampleEnd: + StI + Pop FS + Pop ES + Pop DS + PopAD + + Ret + +LoadSampleNoLoop: ; ECX contains length of sample + Mov EAX, ECX + Mov EDX, AWEMemoryUsed + Mov EBX, AWEMemory + Sub EBX, EDX ; EBX = AWEMemory remaining + + Mov CL, Compress + ShR EAX, CL ; Compress sample + Add EAX, 16 ; zeroes at end of sample + + Cmp EAX, EBX + JA LoadSampleError + + Mov ECX, EAX + Add AWEMemoryUsed, EAX ; Record memory as used + Mov [CS:DI+12], EAX + + Add EDX, 200000h + + Sub ECX, 16 ; Number of samples to transfer + Mov [CS:DI], EDX + Add EDX, ECX + Mov [CS:DI+4], EDX ; Loop start + Add EDX, 14 + Mov [CS:DI+8], EDX ; Loop end + + ; Now to transfer samples to AWE32 + Call [CS:LoadSampleFuncF] + ; Now to shove a whole lot of zeroes + Xor AX, AX + Mov CX, 16 + +LoadSampleNoLoop2: + Out DX, AX + Loop LoadsampleNoLoop2 + + Jmp LoadSampleNoError + +LoadSample3: ; OK... EBX = loop start + ; EDX = loop end + ; AL&40h = ping pong + Test AL, 40h + JNZ LoadSamplePingPong + + Mov CL, Compress + + Push EBX + + ShR EDX, CL + ShR EBX, CL + Mov EAX, EDX + Add EAX, 2 ; For loop fixing + + Mov ECX, AWEMemory + Sub ECX, AWEMemoryUsed ; ECX = AWEMemoryRemaining + + Cmp EAX, ECX + Pop ECX + JA LoadSampleError ; Sufficient memory? + Push ECX + + Mov ECX, EAX + Mov EAX, AWEMemoryUsed + Add AWEMemoryUsed, ECX + Mov [CS:DI+12], ECX + + Sub ECX, 2 + + Add EAX, 200000h + Mov [CS:DI], EAX + + Add EDX, EAX + Add EAX, EBX + + Mov [CS:DI+4], EAX + Mov [CS:DI+8], EDX + + Call [CS:LoadSampleFuncF] + ; Now to fix loop.. 1 extra + ; sample. + + Pop ESI ; Loop start + Test Byte Ptr [FS:BP+12h], 2 + JZ LoadSampleForwards1 + + Add ESI, ESI + +LoadSampleForwards1: + Int 3 + + Mov ECX, 2 + Call [CS:LoadSampleFuncF] + + Jmp LoadSampleNoError + +LoadSamplePingPong: + Mov CL, Compress + ShR EDX, CL + ShR EBX, CL + + Mov EAX, EDX + Add EAX, EDX + Sub EAX, EBX + Inc EAX + + Mov ECX, AWEMemory + Sub ECX, AWEMemoryUsed + + Cmp EAX, ECX + JA LoadSampleError + + Mov [CS:DI+12], EAX + Mov ECX, AWEMemoryUsed + Add AWEMemoryUsed, EAX + + Add ECX, 200000h + Add EAX, ECX + Dec EAX + + Mov [CS:DI], ECX + Add ECX, EBX + Mov [CS:DI+4], ECX + Mov [CS:DI+8], EAX + + Mov EAX, [CS:DI] + Add EAX, EDX + Mov [CS:DI+16], EAX + + Mov ECX, EDX + Sub EDX, EBX + Push EDX + + Call [CS:LoadSampleFuncF] + + Pop ECX + Inc ECX + + Call [CS:LoadSampleFuncB] + + Jmp LoadSampleNoError + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + PushAD + + LEA DI, [EAX*4+EAX] ; DI = AX * 5 + ShL DI, 2 + Add DI, Offset AWEDataTable + + Mov EBX, [CS:DI+12] + Mov EAX, CS:AWEMemoryUsed + Sub EAX, EBX + Add EAX, 200000h + Cmp EAX, [CS:DI] + JNE ReleaseSample1 + + Sub AWEMemoryUsed, EBX +ReleaseSample1: + Mov EAX, -1 + Mov [CS:DI], EAX + Mov [CS:DI+4], EAX + Mov [CS:DI+8], EAX + Mov [CS:DI+12], EAX + + PopAD + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Push CS + Pop ES + + Xor EAX, EAX + Mov CS:AWEMemoryUsed, EAX + + Mov DI, Offset AWEDataTable + Mov CX, 1000 + Mov AX, 0FFFFh + Rep StosW + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset AWE32Status + + Mov EAX, AWEMemory + Sub EAX, AWEMemoryUsed + SHR EAX, 9 + + ClC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset GUSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, MixerPort + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:AWEParameters+BX], AL + + Pop BX + + Mov CS:InterpretState, 0 + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Ret + +SendUARTOut3: + Mov InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset AWEParameters + Mov CX, 32 + Or AX, -1 + Rep StosW + Mov CX, 32 + Inc AX + Rep StosW + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 30 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 30 +DriverFlags DW 1 ; MIDI Out supported + + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + + DW Offset SendUARTOut ; For MIDI Out + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/AWE32DRV.ASM b/SoundDrivers/AWE32DRV.ASM index e101d68..5bd5a17 100755 --- a/SoundDrivers/AWE32DRV.ASM +++ b/SoundDrivers/AWE32DRV.ASM @@ -1,3961 +1,3961 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - - Comment ~ - -Index = BasePort + 802h - - 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ - ³ .............................. ³ Register ³ Channel Number ³ - ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - - ~ - -OldIRQHandler DD 0 -AWEMemory DD 0 -AWEMemoryUsed DD 0 -AWEUpdateCount DW 0 - -AWEUpdateTimer DW 0 - -LoadSampleFuncF DW 0 -LoadSampleFuncB DW 0 - -AWEDataTable DD 5*100 Dup (0) ; Start, Startloop, Endloop, Size -MIDIPort DW 0 -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -DMABuffer DW 0 - -SB16BasePort DW 0 -MixerPort DW 0 -Step DW 1 -AWEUpdateFlag DB 0 -Compress DB 0 - DB 0 - -SBIRQMode DB 0 -BlockLength DW 100 -BlockLength2 DW 100 - -AWE32Msg DB "Sound Blaster AWE 32 detected", 13 - DB "Address ", 0FDh, "Xh, ", 0FDh, "Dk Memory", 0 - -AWE32Msg2 DB "Sound Blaster AWE 32 detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -AWE32Status DB "FreeAWE ", 0FDh, "Dk", 0 - -AWE32ReinitMsg DB "Sound Blaster AWE 32 reinitialised", 0 -Stereo DB 0 -Forced DB 0 -DriverName DB "ITAWE32.DRV", 0 - -FrequencyError DB "AWE Hardware frequency limit exceeded -> Note terminated", 0 - -IRQFlag DB 0FFh - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -IMR DW 0 - - CPF EQU 0 - PTRX EQU 20h - CVCF EQU 40h - VTFT EQU 60h - PSST EQU 0C0h - CSL EQU 0E0h - - CCCA EQU 100h - HWCF4 EQU 129h - HWCF5 EQU 12Ah - HWCF6 EQU 12Dh - SMALR EQU 134h - SMARR EQU 135h - SMALW EQU 136h - SMARW EQU 137h - SMLD EQU 43Ah - SMRD EQU 23Ah - WC EQU 23Bh - HWCF1 EQU 43Dh - HWCF2 EQU 43Eh - CFG2 EQU 43Eh - HWCF3 EQU 43Fh - INIT1 EQU 440h - INIT2 EQU 240h - INIT3 EQU 460h - INIT4 EQU 260h - ENVVOL EQU 480h - DCYSUSV EQU 4A0h - ENVVAL EQU 4C0h - DCYSUS EQU 4E0h - SUSDCY EQU 4E0h - ATKHLDV EQU 280h - LFO1VAL EQU 2A0h - ATKHLD EQU 2C0h - HLDATK EQU 2C0h - LFO2VAL EQU 2E0h - IP EQU 300h - IFATN EQU 320h - PEFE EQU 340h - FMMOD EQU 360h - TREMFRQ EQU 380h - FM2FRQ2 EQU 3A0h - -ALIGN 4 - -InitTable1 Label - DW 003FFh, 0030h, 007FFh, 0130h, 00BFFh, 0230h, 00FFFh, 0330h - DW 013FFh, 0430h, 017FFh, 0530h, 01BFFh, 0630h, 01FFFh, 0730h - DW 023FFh, 0830h, 027FFh, 0930h, 02BFFh, 0A30h, 02FFFh, 0B30h - DW 033FFh, 0C30h, 037FFh, 0D30h, 03BFFh, 0E30h, 03FFFh, 0F30h - - DW 043FFh, 0030h, 047FFh, 0130h, 04BFFh, 0230h, 04FFFh, 0330h - DW 053FFh, 0430h, 057FFh, 0530h, 05BFFh, 0630h, 05FFFh, 0730h - DW 063FFh, 0830h, 067FFh, 0930h, 06BFFh, 0A30h, 06FFFh, 0B30h - DW 073FFh, 0C30h, 077FFh, 0D30h, 07BFFh, 0E30h, 07FFFh, 0F30h - - DW 083FFh, 0030h, 087FFh, 0130h, 08BFFh, 0230h, 08FFFh, 0330h - DW 093FFh, 0430h, 097FFh, 0530h, 09BFFh, 0630h, 09FFFh, 0730h - DW 0A3FFh, 0830h, 0A7FFh, 0930h, 0ABFFh, 0A30h, 0AFFFh, 0B30h - DW 0B3FFh, 0C30h, 0B7FFh, 0D30h, 0BBFFh, 0E30h, 0BFFFh, 0F30h - - DW 0C3FFh, 0030h, 0C7FFh, 0130h, 0CBFFh, 0230h, 0CFFFh, 0330h - DW 0D3FFh, 0430h, 0D7FFh, 0530h, 0DBFFh, 0630h, 0DFFFh, 0730h - DW 0E3FFh, 0830h, 0E7FFh, 0930h, 0EBFFh, 0A30h, 0EFFFh, 0B30h - DW 0F3FFh, 0C30h, 0F7FFh, 0D30h, 0FBFFh, 0E30h, 0FFFFh, 0F30h - -InitTable2 Label - DW 003FFh, 8030h, 007FFh, 8130h, 00BFFh, 8230h, 00FFFh, 8330h - DW 013FFh, 8430h, 017FFh, 8530h, 01BFFh, 8630h, 01FFFh, 8730h - DW 023FFh, 8830h, 027FFh, 8930h, 02BFFh, 8A30h, 02FFFh, 8B30h - DW 033FFh, 8C30h, 037FFh, 8D30h, 03BFFh, 8E30h, 03FFFh, 8F30h - - DW 043FFh, 8030h, 047FFh, 8130h, 04BFFh, 8230h, 04FFFh, 8330h - DW 053FFh, 8430h, 057FFh, 8530h, 05BFFh, 8630h, 05FFFh, 8730h - DW 063FFh, 8830h, 067FFh, 8930h, 06BFFh, 8A30h, 06FFFh, 8B30h - DW 073FFh, 8C30h, 077FFh, 8D30h, 07BFFh, 8E30h, 07FFFh, 8F30h - - DW 083FFh, 8030h, 087FFh, 8130h, 08BFFh, 8230h, 08FFFh, 8330h - DW 093FFh, 8430h, 097FFh, 8530h, 09BFFh, 8630h, 09FFFh, 8730h - DW 0A3FFh, 8830h, 0A7FFh, 8930h, 0ABFFh, 8A30h, 0AFFFh, 8B30h - DW 0B3FFh, 8C30h, 0B7FFh, 8D30h, 0BBFFh, 8E30h, 0BFFFh, 8F30h - - DW 0C3FFh, 8030h, 0C7FFh, 8130h, 0CBFFh, 8230h, 0CFFFh, 8330h - DW 0D3FFh, 8430h, 0D7FFh, 8530h, 0DBFFh, 8630h, 0DFFFh, 8730h - DW 0E3FFh, 8830h, 0E7FFh, 8930h, 0EBFFh, 8A30h, 0EFFFh, 8B30h - DW 0F3FFh, 8C30h, 0F7FFh, 8D30h, 0FBFFh, 8E30h, 0FFFFh, 8F30h - -InitTable3 Label - DW 0C10h, 8470h, 14FEh, 0B488h, 167Fh, 0A470h, 18E7h, 84B5h - DW 1B6Eh, 842Ah, 1F1Dh, 852Ah, 0DA3h, 9F7Ch, 167Eh, 0F254h - DW 0, 842Ah, 1, 852Ah, 18E6h, 9BAAh, 1B6Dh, 0F234h - DW 229Fh, 8429h, 2746h, 8529h, 1F1Ch, 96E7h, 229Eh, 0F224h - - DW 0DA4h, 8429h, 2C29h, 8529h, 2745h, 97F6h, 2C28h, 0F254h - DW 383Bh, 8428h, 320Fh, 8528h, 320Eh, 9F02h, 1341h, 0F264h - DW 3EB6h, 8428h, 3EB9h, 8528h, 383Ah, 9FA9h, 3EB5h, 0F294h - DW 3EB7h, 8474h, 3EBAh, 8575h, 3EB8h, 0C4C3h, 3EBBh, 0C5C3h - - DW 00000, 0A404h, 00001, 0A504h, 141Fh, 8671h, 14FDh, 8287h - DW 3EBCh, 0E610h, 3EC8h, 8C7Bh, 31Ah, 87E6h, 3EC8h, 86F7h - DW 3EC0h, 821Eh, 3EBEh, 0D208h, 3EBDh, 821Fh, 3ECAh, 8386h - DW 3EC1h, 8C03h, 3EC9h, 831Eh, 3ECAh, 8C4Ch, 3EBFh, 8C55h - - DW 3EC9h, 0C208h, 3EC4h, 0BC84h, 3EC8h, 8EADh, 3EC8h, 0D308h - DW 3EC2h, 8F7Eh, 3ECBh, 821Eh, 3ECBh, 0D208h, 3EC5h, 831Fh - DW 3EC6h, 0C308h, 3EC3h, 0B2FFh, 3EC9h, 8265h, 3EC9h, 831Eh - DW 1342h, 0D308h, 3EC7h, 0B3FFh, 0, 8365h, 1420h, 9570h - -InitTable4 Label - DW 0C10h, 8470h, 14FEh, 0B488h, 167Fh, 0A470h, 18E7h, 84B5h - DW 1B6Eh, 842Ah, 1F1Dh, 852Ah, 0DA3h, 0F7Ch, 167Eh, 7254h - DW 0, 842Ah, 1, 852Ah, 18E6h, 0BAAh, 1B6Dh, 7234h - DW 229Fh, 8429h, 2746h, 8529h, 1F1Ch, 6E7h, 229Eh, 7224h - - DW 0DA4h, 8429h, 2C29h, 8529h, 2745h, 07F6h, 2C28h, 7254h - DW 383Bh, 8428h, 320Fh, 8528h, 320Eh, 0F02h, 1341h, 7264h - DW 3EB6h, 8428h, 3EB9h, 8528h, 383Ah, 0FA9h, 3EB5h, 7294h - DW 3EB7h, 8474h, 3EBAh, 8575h, 3EB8h, 44C3h, 3EBBh, 45C3h - - DW 00000, 0A404h, 00001, 0A504h, 141Fh, 0671h, 14FDh, 287h - DW 3EBCh, 0E610h, 3EC8h, 0C7Bh, 31Ah, 7E6h, 3EC8h, 86F7h - DW 3EC0h, 821Eh, 3EBEh, 0D208h, 3EBDh, 021Fh, 3ECAh, 386h - DW 3EC1h, 0C03h, 3EC9h, 31Eh, 3ECAh, 8C4Ch, 3EBFh, 0C55h - - DW 3EC9h, 0C208h, 3EC4h, 0BC84h, 3EC8h, 0EADh, 3EC8h, 0D308h - DW 3EC2h, 8F7Eh, 3ECBh, 021Eh, 3ECBh, 0D208h, 3EC5h, 31Fh - DW 3EC6h, 0C308h, 3EC3h, 32FFh, 3EC9h, 0265h, 3EC9h, 831Eh - DW 1342h, 0D308h, 3EC7h, 33FFh, 0, 8365h, 1420h, 9570h - -AWEVolumeTable Label Byte ; Value = -log(vol/256)*(20/.375) - ; = -log(vol/256)*(160/3) - - DB 255, 128, 112, 103, 96, 91, 87, 83 ; 0->7 - DB 80, 78, 75, 73, 71, 69, 67, 66 ; 8->15 - DB 64, 63, 61, 60, 59, 58, 57, 56 ; 16->23 - DB 55, 54, 53, 52, 51, 50, 50, 49 ; 24->31 - DB 48, 47, 47, 46, 45, 45, 44, 44 ; 32->39 - DB 43, 42, 42, 41, 41, 40, 40, 39 ; 40->47 - DB 39, 38, 38, 37, 37, 36, 36, 36 ; 48->55 - DB 35, 35, 34, 34, 34, 33, 33, 32 ; 56->63 - DB 32, 32, 31, 31, 31, 30, 30, 30 ; 64->71 - DB 29, 29, 29, 28, 28, 28, 28, 27 ; 72->79 - DB 27, 27, 26, 26, 26, 26, 25, 25 ; 80->87 - DB 25, 25, 24, 24, 24, 23, 23, 23 ; 88->95 - DB 23, 22, 22, 22, 22, 22, 21, 21 ; 96->103 - DB 21, 21, 20, 20, 20, 20, 20, 19 ; 104->111 - DB 19, 19, 19, 19, 18, 18, 18, 18 ; 112->119 - DB 18, 17, 17, 17, 17, 17, 16, 16 ; 120->127 - DB 16 ; 128 - - Comment ~ ; Value = -log(vol/128)*(20/.375) - ; = -log(vol/128)*(160/3) - ; This is mathematically the correct table, but it seems too - ; loud, and it overloads on playback. - - DB 255, 112, 96, 87, 80, 75, 71, 67 ; 0->7 - DB 64, 61, 59, 57, 55, 53, 51, 50 ; 8->15 - DB 48, 47, 45, 44, 43, 42, 41, 40 ; 16->23 - DB 39, 38, 37, 36, 35, 34, 34, 33 ; 24->31 - DB 32, 31, 31, 30, 29, 29, 28, 28 ; 32->39 - DB 27, 26, 26, 25, 25, 24, 24, 23 ; 40->47 - DB 23, 22, 22, 21, 21, 20, 20, 20 ; 48->55 - DB 19, 19, 18, 18, 18, 17, 17, 16 ; 56->63 - DB 16, 16, 15, 15, 15, 14, 14, 14 ; 64->71 - DB 13, 13, 13, 13, 12, 12, 12, 11 ; 72->79 - DB 11, 11, 10, 10, 10, 9, 9, 9 ; 80->87 - DB 9, 8, 8, 8, 8, 7, 7, 7 ; 88->95 - DB 7, 6, 6, 6, 6, 5, 5, 5 ; 96->103 - DB 5, 4, 4, 4, 4, 4, 4, 3 ; 104->111 - DB 3, 3, 3, 2, 2, 2, 2, 2 ; 112->119 - DB 1, 1, 1, 1, 1, 1, 1, 1 ; 120->127 - DB 0 - - ~ - -GUSScreenList Label - DW 7 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr GravisHeaderLine - - DW Near Ptr MixerText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr MasterVolumeLeft ; 7 - DW Near Ptr MasterVolumeRight - DW Near Ptr TrebleVolumeLeft - DW Near Ptr TrebleVolumeRight - DW Near Ptr BassVolumeLeft - DW Near Ptr BassVolumeRight ; 12 - - DW Near Ptr SampleText - - DW Near Ptr SampleSize0Button ; 14 - DW Near Ptr SampleSize1Button - DW Near Ptr SampleSize2Button - DW Near Ptr SampleSize3Button ; 17 - - DW Near Ptr EffectText - DW Near Ptr EffectBox - - DW Near Ptr ChorusThumbBar ; 20 - DW Near Ptr ReverbThumbBar - - DW DriverText - - DW 0 - -GravisHeaderLine DW 10 - DB "Sound Blaster AWE 32 Driver", 0 - -DriverText DW 1 - DB 27, 48 - DB 21h - DB "Sound Blaster AWE 32 Driver 1.5 for Impulse Tracker", 0 - -MixerText DW 1 - DB 3, 13 - DB 20h - DB "Mixer options", 13 - DB 13 - DB " Master Volume Left", 13 - DB " Master Volume Right", 13 - DB 13 - DB 13 - DB " Treble Left", 13 - DB " Treble Right", 13 - DB " Bass Left", 13 - DB " Bass Right", 13 - DB 0 - -VolumeBox1 DW 0 - DB 24, 14, 30, 17 - DB 25 - -VolumeBox2 DW 0 - DB 17, 18, 21, 23 - DB 25 - -MasterVolumeLeft DW 9 - DB 25, 15 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 8, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 25, 16 - DW 0, 31 - DW 9, 1 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 18, 19 - DW 0, 15 - DW 9, 2 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 18, 20 - DW 0, 15 - DW 9, 3 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 18, 21 - DW 0, 15 - DW 9, 4 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 18, 22 - DW 0, 15 - DW 9, 5 - DW 11, 14, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -SampleText DW 1 - DB 3, 25 - DB 20h - DB "Sample resizing options", 0 - -SampleSize0Button DW 2 - DW 12, 15, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment1 DW 0 - DW 0 - DW Offset SetCompress -DriverSegment2 DW 0 - DB 7, 27, 20, 29, 8 - DB 0 - DB " Original", 0 - -SampleSize1Button DW 2 - DW 14, 16, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment3 DW 0 - DW 1 - DW Offset SetCompress -DriverSegment4 DW 0 - DB 7, 30, 20, 32, 8 - DB 0 - DB " Half", 0 - -SampleSize2Button DW 2 - DW 15, 17, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment5 DW 0 - DW 2 - DW Offset SetCompress -DriverSegment6 DW 0 - DB 7, 33, 20, 35, 8 - DB 0 - DB " Quarter", 0 - -SampleSize3Button DW 2 - DW 16, 20, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment7 DW 0 - DW 3 - DW Offset SetCompress -DriverSegment8 DW 0 - DB 7, 36, 20, 38, 8 - DB 0 - DB " Eighth", 0 - -EffectText DW 1 - DB 3, 40 - DB 20h - DB "Effect options", 13 - DB 13 - DB " Chorus", 13 - DB " Reverb", 0 - - -EffectBox DW 0 - DB 12, 41, 30, 44 - DB 25 - -ChorusThumbBar DW 9 - DB 13, 42 - DW 0, 127 - DW 9, 6 - DW 17, 21, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -ReverbThumbBar DW 9 - DB 13, 43 - DW 0, 127 - DW 9, 7 - DW 20, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - - - -VolumeTable DB 6 Dup (0) -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 2 -Chorus DB 10, 64 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -ALIGN 16 -FPSave DB 128 Dup (0) - -AWEParameters DB 64 Dup (0FFh), 64 Dup (0) - -include dma.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut - - Push CX - Push DX - Mov DX, CS:MIDIPort - Test DX, DX - JZ UARTOutEnd - - Push AX - Xor CX, CX - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - LoopNZ UARTOut1 - - Pop AX - JNZ UARTOutEnd - - Dec DX - Out DX, AL - -UARTOutEnd: - Pop DX - Pop CX - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:AWEParameters+BX], AL - - Pop BX - - Mov CS:InterpretState, 0 - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Ret - -SendUARTOut3: - Mov InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset AWEParameters - Mov CX, 32 - Or AX, -1 - Rep StosW - Mov CX, 32 - Inc AX - Rep StosW - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectUART ; Given DX = Port - -; outportb(BasePort+1, 0xFF); -; while(InputUART() != 0xFE); -; outportb(BasePort+1, 0x3F); -; while(InputUART() != 0xFE); - - ClI - - Inc DX - Mov AL, 0FFh ; reset - Out DX, AL - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 80h - LoopNZ DetectUART1 - JNZ DetectUARTFailed - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JNE DetectUART1 - - Xor CX, CX - -DetectUART3: - In AL, DX - Test AL, 40h - LoopNZ DetectUART3 - JNZ DetectUARTFailed - - Mov AL, 03Fh - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - LoopNZ DetectUART2 - JNZ DetectUARTFailed - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JNE DetectUART2 - Dec DX - - ClC - StI - Ret - -DetectUARTFailed: - StC - StI - Ret - -Comment ~ - -; From SB-DevKit - - ClI - - Inc DX - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 40h ; Ready for output - LoopNZ DetectUART1 - JNZ DetectUARTError - - Mov AL, 0FFh ; Reset! - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - JNZ DetectUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART4 - -DetectUART3: - Loop DetectUART2 - -DetectUARTError: - StI - StC - Ret - -DetectUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -DetectUART5: - In AL, DX - Test AL, 40h - LoopNZ DetectUART5 - JNZ DetectUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -DetectUART6: - Xor CX, CX - -DetectUART7: - In AL, DX - Test AL, 80h - JNZ DetectUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART9 - -DetectUART8: - Loop DetectUART7 - - Jmp DetectUARTError - -DetectUART9: - StI - ClC - Ret - -~ - -EndP DetectUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReinitUART - - Mov DX, MIDIPort - Test DX, DX - JZ ReinitUART1 - - Call DetectUART - -ReinitUART1: - Ret - -EndP ReinitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, MIDIPort - Test DX, DX - JZ ResetUART1 - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetCompress Far - - Mov CX, [SI+22] - Mov CS:Compress, CL - - Mov AX, 1 - ShL AX, CL - Mov CS:Step, AX - - Call Music_LoadAllSamples - - Mov AX, 1 - Ret - -EndP SetCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetCompress Far - - Push CS - Pop ES - Mov DI, Offset Compress - - Ret - -EndP GetCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load8BitSamplesForwards ; Given DS:SI, ECX = count - - Push BX - - Mov BX, CS:Step - Mov DX, CS:BasePort - Add DX, 400h - Xor AL, AL - -Load8BitSamplesForwards2: - Mov AH, [SI] - Add SI, BX - JC Load8BitSamplesForwards4 - -Load8BitSamplesForwards3: - Out DX, AX - - Dec ECX - JNZ Load8BitSamplesForwards2 - - Pop BX - Ret - -Load8BitSamplesForwards4: - Add ESI, 10000h - Int 3 - Jmp Load8BitSamplesForwards3 - -EndP Load8BitSamplesForwards - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load16BitSamplesForwards ; Given DS:SI, ECX = count - - Push BX - - Mov BX, CS:Step - Mov DX, CS:BasePort - Add DX, 400h - Add BX, BX - -Load16BitSamplesForwards2: - Mov AX, [SI] - Add SI, BX - JC Load16BitSamplesForwards4 - -Load16BitSamplesForwards3: - Out DX, AX - - Dec ECX - JNZ Load16BitSamplesForwards2 - - Pop BX - Ret - -Load16BitSamplesForwards4: - Add ESI, 10000h - Int 3 - Jmp Load16BitSamplesForwards3 - -EndP Load16BitSamplesForwards - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load8BitSamplesBackwards ; Given DS:SI, ECX = count - - Push BX - - Mov BX, CS:Step - Mov DX, CS:BasePort - Add DX, 400h - Xor AL, AL - - Sub SI, BX - JC Load8BitSamplesBackwards6 - -Load8BitSamplesBackwards2: - Sub SI, BX - JC Load8BitSamplesBackwards4 - -Load8BitSamplesBackwards3: - Mov AH, [SI] - Out DX, AX - - Dec ECX - JNZ Load8BitSamplesBackwards2 - - - Pop BX - Ret - -Load8BitSamplesBackwards4: - Sub ESI, 10000h - JC Load8BitSamplesBackwards5 - Int 3 - Jmp Load8BitSamplesBackwards3 - -Load8BitSamplesBackwards5: - Xor ESI, ESI - Jmp Load8BitSamplesBackwards3 - -Load8BitSamplesBackwards6: - Sub ESI, 10000h - Int 3 - Jmp Load8BitSamplesBackwards2 - - -EndP Load8BitSamplesBackwards - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load16BitSamplesBackwards ; Given DS:SI, ECX = count - - Push BX - - Mov BX, CS:Step - Mov DX, CS:BasePort - Add DX, 400h - Add BX, BX - - Sub SI, BX - JC Load16BitSamplesBackwards6 - -Load16BitSamplesBackwards2: - Sub SI, BX - JC Load16BitSamplesBackwards4 - -Load16BitSamplesBackwards3: - Mov AX, [SI] - Out DX, AX - - Dec ECX - JNZ Load16BitSamplesBackwards2 - - Pop BX - Ret - -Load16BitSamplesBackwards4: - Sub ESI, 10000h - JC Load16BitSamplesBackwards5 - Int 3 - Jmp Load16BitSamplesBackwards3 - -Load16BitSamplesBackwards5: - Xor ESI, ESI - Jmp Load16BitSamplesBackwards3 - -Load16BitSamplesBackwards6: - Sub ESI, 10000h - Int 3 - Jmp Load16BitSamplesBackwards2 - - -EndP Load16BitSamplesBackwards - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WriteDataChannel - - Or AX, DX - -Proc WriteData ; Have BX/EBX = value - ; AX = xxyyh - ; ^ ^ - ; | | - ; | \-- value to send to pointer register - ; \---- 0, 1, 2 or 3, 4 - ; 0 = data reg 0 - ; 1 = data reg 1, dword - ; 2 = data reg 2 - ; 3 = data reg 3 - ; 4 = data reg 4, word - - Jmp $+2 - Jmp $+2 - - Push DX - Push AX - - Mov DX, BasePort - Add DX, 802h - And AX, 0FFh - Out DX, AX - Pop AX - - Jmp $+2 - Jmp $+2 - - Cmp AH, 1 - JB WriteDataReg0 - JE WriteDataReg1DWord - Cmp AH, 3 - JB WriteDataReg2 - JE WriteDataReg3 - Jmp WriteDataReg1Word - -WriteDataReg0: - Sub DX, 802h - Mov EAX, EBX - Out DX, EAX - - Pop DX - Ret - -WriteDataReg1DWord: - Sub DX, 402h - Mov EAX, EBX - Out DX, EAX - - Pop DX - Ret - -WriteDataReg1Word: - Sub DX, 402h - Mov AX, BX - Out DX, AX - - Pop DX - Ret - -WriteDataReg2: - Sub DX, 400h - Mov AX, BX - Out DX, AX - - Pop DX - Ret - -WriteDataReg3: - Sub DL, 2 - Mov AX, BX - Out DX, AX - - Pop DX - Ret - -EndP WriteData - -EndP WriteDataChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReadDataChannel - - Or AX, DX - -Proc ReadData ; AX = xxyyh - ; ^ ^ - ; | | - ; | \-- value to send to pointer register - ; \---- 0, 1, 2 or 3, 4 - ; 0 = data reg 0 - ; 1 = data reg 1, dword - ; 2 = data reg 2 - ; 3 = data reg 3 - ; 4 = data reg 4, word - - Jmp $+2 - Jmp $+2 - - Push DX - Push AX - - Mov DX, BasePort - Add DX, 802h - And AX, 0FFh - Out DX, AX - Pop AX - - Jmp $+2 - Jmp $+2 - - Cmp AH, 1 - JB ReadDataReg0 - JE ReadDataReg1DWord - Cmp AH, 3 - JB ReadDataReg2 - JE ReadDataReg3 - Jmp ReadDataReg1Word - -ReadDataReg0: - Sub DX, 802h - In EAX, DX - - Pop DX - Ret - -ReadDataReg1DWord: - Sub DX, 402h - In EAX, DX - - Pop DX - Ret - -ReadDataReg1Word: - Sub DX, 402h - In AX, DX - - Pop DX - Ret - -ReadDataReg2: - Sub DX, 400h - In AX, DX - - Pop DX - Ret - -ReadDataReg3: - Sub DL, 2 - In AX, DX - - Pop DX - Ret - -EndP ReadData - -EndP ReadDataChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Const44100 DD 44100.0 -Const1000h DD 4096.0 -ConstE000h DD 57344.0 - -Proc SetAWEFrequency - - Mov EAX, [SI+10h] ; Final freq - - Push CX - Mov CL, Compress - ShR EAX, CL - Pop CX - -; Test EAX, EAX - JZ SetAWEFrequencyError - Cmp EAX, 88200*2 - JAE SetAWEFrequencyError - - Mov DWord Ptr [SI+4], EAX - - FLd CS:ConstE000h - FLd CS:Const1000h - FILd DWord Ptr [SI+4] - FDiv CS:Const44100 - FYL2X ; ST = ln(Pitch/44100)/ln(2) * 1000h - FAddP ST(1) - FIStP DWord Ptr [SI+4] - - Mov AX, IP - Mov BX, [SI+4] - Call WriteDataChannel - - Ret - Assume DS:Nothing - -SetAWEFrequencyError: - Call StopAWENote - - Mov Word Ptr [SI], 200h - Test Byte Ptr [SI+3Ah], 80h - JNZ SetAWEFrequencyError1 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -SetAWEFrequencyError1: - Mov AX, IP - Xor EBX, EBX - Call WriteDataChannel - - Push DS SI - - Push CS - Pop DS - Mov SI, Offset FrequencyError - Mov BX, 40 - Call SetInfoLine - - Pop SI DS - - Ret - -EndP SetAWEFrequency - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetAWEPan - - Mov AX, PSST - Call ReadDataChannel ; Get starting offset - - Cmp CS:Stereo, 0 - JE SetPan2 - - Test CL, 128 - JNZ SetPan2 - - Mov BL, [SI+37h] ; Final pan - Cmp BL, 100 ; Surround -> central - JNE SetPan1 - -SetPan2: - Mov BL, 32 - -SetPan1: ; BL = 0->64, need to extend to 0->255 - Add BL, BL - Add BL, BL - SBB BL, 0 ; BL = 0->255 - Not BL - - ShL EAX, 8 - SHLD EBX, EAX, 24 - Mov AX, PSST - Call WriteDataChannel - - Ret - -EndP SetAWEPan - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetAWEVolume - - Test CH, 8 - JZ SetAWEVolume1 - - Test CH, 1 - JNZ SetAWEVolume5 - - Cmp Byte Ptr [SI+8], 0FFh - JE SetAWEVolume4 - -SetAWEVolume5: - Mov Byte Ptr [SI+8], 0FFh - - Mov AX, IFATN - Call ReadDataChannel - Mov BX, AX - Mov AX, IFATN - Mov BL, 0FFh - Call WriteDataChannel - -SetAWEVolume4: - Ret - -SetAWEVolume1: -; First check if channel has been disowned - Xor BX, BX - Mov BL, [SI+3Ah] ; BL = host channel - - Test BL, BL - JS SetAWEVolume3 - -SetAWEVolume2: - Mov AH, [CS:AWEParameters+BX] ; AH = filter - Mov AL, [CS:AWEParameters+BX+64] ; AL = Q. - - ShR AL, 3 - Mov [SI+5Bh], AH - - Cmp AL, [SI+3Fh] - JE SetAWEVolume3 - - Mov [SI+3Fh], AL - -; Set Q - Mov BL, AL - ShL EBX, 28 - - Mov AX, CCCA - Call ReadDataChannel - And EAX, 0FFFFFFFh - Or EBX, EAX - Mov AX, CCCA - Call WriteDataChannel - -SetAWEVolume3: - Mov AL, [SI+3Eh] - Mul Byte Ptr [SI+5Bh] - ShL AX, 1 - Xor BX, BX - Add AH, 1 - Mov BL, [SI+20h] ; Final volume - Mov [SI+8], BL - Mov BL, [CS:AWEVolumeTable+BX] - Mov BH, AH - Mov AX, IFATN - Call WriteDataChannel - - Ret - -EndP SetAWEVolume - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopAWENote - - Mov AX, DCYSUSV - Mov BX, 80h - Call WriteDataChannel - - Mov AX, VTFT - Mov EBX, 0FFFFh - Call WriteDataChannel - - Mov AX, CVCF - Call WriteDataChannel - - Mov BX, 80h - Mov AX, DCYSUSV - Call WriteDataChannel - - Mov AX, VTFT - Mov EBX, 0FFFFh - Call WriteDataChannel - - Mov AX, CVCF - Call WriteDataChannel - - Xor EBX, EBX - Mov AX, ENVVOL - Call WriteDataChannel - - Mov AX, ENVVAL - Call WriteDataChannel - - Mov AX, SUSDCY - Call WriteDataChannel - - Mov AX, ATKHLDV - Call WriteDataChannel - - Mov AX, LFO1VAL - Call WriteDataChannel - - Mov AX, HLDATK - Call WriteDataChannel - - Mov AX, LFO2VAL - Call WriteDataChannel - - Mov AX, IP - Call WriteDataChannel - - Mov AX, IFATN - Call ReadDataChannel - Mov BH, AH - Mov AX, IFATN - Call WriteDataChannel - - Xor EBX, EBX - Mov AX, PEFE - Call WriteDataChannel - - Mov AX, FMMOD - Call WriteDataChannel - - Mov AX, TREMFRQ - Call WriteDataChannel - - Mov AX, FM2FRQ2 - Call WriteDataChannel - - Mov AX, PTRX - Call WriteDataChannel - - Mov AX, VTFT - Call WriteDataChannel - -; Mov AX, PSST -; Call WriteDataChannel - - Mov BL, 8 - Mov AX, CSL - Call WriteDataChannel - - Mov AX, CCCA - Call ReadDataChannel - Mov EBX, EAX - Mov AX, CCCA - And EBX, 0F0000000h - Call WriteDataChannel - - Xor EBX, EBX - Mov AX, CPF - Call WriteDataChannel - - Ret - -EndP StopAWENote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetAWERegisters ; DS:SI = channel info table - ; CX = number of channels... - - Push CX - Push SI - - ; Stage 1. - ; Turn off any channel which has - ; a new note to play - ; If no new note to play and channel - ; is on, then get current position - - Xor DX, DX ; DX = oscillator number - -GetAWERegisters1: - Mov BX, [SI] - Test BH, 2 ; Note cut command - JZ GetAWERegisters2 - - Mov BX, 200h - Mov [SI], BX - - Call StopAWENote - Jmp GetAWERegisters4 - -GetAWERegisters2: - Test BL, 1 ; Channel on? - JZ GetAWERegisters4 - - Test BH, 1 ; New note? - JZ GetAWERegisters3 - - ; Fade out volume -; Mov AX, DCYSUSV -; Mov BX, 807Fh -; Call WriteDataChannel - - Call StopAWENote - - Jmp GetAWERegisters4 - -GetAWERegisters3: ; Get offset - Mov AX, CCCA - Call ReadDataChannel - - Xor BX, BX - And EAX, 00000000111111111111111111111111b - Inc EAX ; Interpolator correction - ; EAX = address in sound memory - Mov BL, [SI+36h] ; BL = sample number - LEA BX, [EBX*4+EBX] - ShL BX, 2 - Add BX, Offset AWEDataTable - - Cmp Byte Ptr [SI+0Ah], 8 - JB GetAddressNoLoop - JE GetAddressForwardsLoop - -GetAddressPingPongLoop: - Cmp EAX, [CS:BX+16] - JB SetOldAddress - - Neg EAX - Add EAX, [CS:BX+8] - Jmp SetOldAddress1 - -GetAddressNoLoop: - Cmp EAX, [CS:BX+4] ; Start loop - JB SetOldAddress - - Call StopAWENote - - ; OK.. gotta turn off channel - Mov Word Ptr [SI], 0 - Test Byte Ptr [SI+3Ah], 80h - JNZ GetAWERegisters4 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - - Jmp GetAWERegisters4 - -GetAddressForwardsLoop: -SetOldAddress: - Sub EAX, [CS:BX] ; EAX = address in sample - JNS SetOldAddress1 - - Xor EAX, EAX - -SetOldAddress1: - Push CX - Mov CL, Compress - ShL EAX, CL - Pop CX - - XChg [SI+4Ch], EAX - Mov [SI+2Ch], EAX - -GetAWERegisters4: - Add SI, 128 - - Inc DX - Dec CX - JNZ GetAWERegisters1 - - Pop SI - Pop CX - - Xor DX, DX ; DX = oscillator number - -SetAWERegisters1: - ; Stage 2. - ; If new frequency, play new frequency - ; If new volume, play new volume - ; If new pan, play new pan - ; If new note, set ENVVOL, ENVVAL, SUSDCY, ATKHLDV, LFO1VAL, HLDATK - ; LFO2VAL, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2 - ; PSST, CSL, CCCA - ; VTFT, CVCF, DCYSUSV, PTRX, CPF - - Push CX - Mov CX, [SI] - Test CL, 1 ; Channel on? - JZ SetAWERegistersEnd - - Test CH, 1 ; New note? - JZ SetAWERegisters2 - - Xor BX, BX - Mov BL, [SI+36h] - LEA DI, [EBX*4+EBX] - ShL DI, 2 - Add DI, Offset AWEDataTable - - Mov AX, DCYSUSV - Mov BX, 80h - Call WriteDataChannel - - Mov AX, VTFT - Xor EBX, EBX - Call WriteDataChannel - - Mov AX, CVCF - Call WriteDataChannel - - Cmp DWord Ptr [CS:DI], 0FFFFFFFFh - JE SetAWERegistersError - - Mov AX, PTRX - Call WriteDataChannel - - Mov AX, CPF - Call WriteDataChannel - - - Mov AX, ENVVOL - Mov BX, 8000h - Call WriteDataChannel - - Mov AX, ENVVAL - Mov BX, 8000h - Call WriteDataChannel - - Mov AX, SUSDCY - Mov BX, 7F7Fh - Call WriteDataChannel - - Mov AX, ATKHLDV - Call WriteDataChannel - - Mov AX, LFO1VAL - Mov BX, 8000h - Call WriteDataChannel - - Mov AX, HLDATK - Mov BX, 7F7Fh - Call WriteDataChannel - - Mov AX, LFO2VAL - Mov BX, 8000h - Call WriteDataChannel - - Call SetAWEFrequency - Call SetAWEVolume - - Mov AX, PEFE - Xor BX, BX - Call WriteDataChannel - - Mov AX, FMMOD - Call WriteDataChannel - - Mov AX, TREMFRQ - Mov BX, 10h - Call WriteDataChannel - - Mov AX, FM2FRQ2 - Call WriteDataChannel - - - Mov EBX, [CS:DI+4] - Dec EBX ; Interpolator offset - Mov AX, PSST - Call WriteDataChannel - - Call SetAWEPan - - Mov AL, [CS:VolumeTable+6] ; Chorus - ShL EAX, 24 - Mov EBX, [CS:DI+8] - Dec EBX ; Interpolator offset - Or EBX, EAX - Mov AX, CSL - Call WriteDataChannel - - Mov AL, [SI+3Fh] - ShL EAX, 28 - - Push CX - Mov CL, Compress - Mov EBX, [SI+4Ch] - ShR EBX, CL - Pop CX - Add EBX, [CS:DI] - Dec EBX ; Interpolator offset - Or EBX, EAX - - Mov AX, CCCA ; Current address. - Call WriteDataChannel - - - Mov AX, VTFT - Mov EBX, 0FFFFh - Call WriteDataChannel - - Mov AX, CVCF - Call WriteDataChannel - - Mov AX, DCYSUSV - Mov BX, 7F7Fh - Call WriteDataChannel - - Mov AX, PTRX - Mov EBX, 40000000h ; 25% reverb - Or BH, [CS:VolumeTable+7] - Call WriteDataChannel - - Mov AX, CPF - Call WriteDataChannel - Jmp SetAWERegistersEnd - -SetAWERegisters2: - Test CL, 32 ; Frequency change? - JZ SetAWERegisters3 - - Call SetAWEFrequency - -SetAWERegisters3: - Test CL, 64 ; Volume change? - JZ SetAWERegisters4 - - Call SetAWEVolume - -SetAWERegisters4: - Test CH, 80h ; New pan? - JZ SetAWERegistersEnd - - Call SetAWEPan - -SetAWERegistersEnd: - Pop CX - And Word Ptr [SI], 0111100010011111b - - Add SI, 128 - - Inc DX - Dec CX - JNZ SetAWERegisters1 - - Ret - -SetAWERegistersError: - Call StopAWENote - - Mov Word Ptr [SI], 0 - Test Byte Ptr [SI+3Ah], 80h - JNZ SetAWERegistersEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - - Jmp SetAWERegistersEnd - -EndP SetAWERegisters - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ACKIRQ - - Mov AL, 20h - Cmp CS:IRQ, 7 - JBE ACKIRQ1 - - Out 0A0h, AL - -ACKIRQ1: - Out 20h, AL - Ret - -EndP ACKIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Mov DX, MIDIPort - - Mov BL, [MIDIBufferTail] - Test DX, DX - JZ CheckMIDIEnd - - Inc DX - -CheckMIDIAgain: - In AL, DX - - Test AL, AL - JS CheckMIDIAgain - - Dec DX - In AL, DX - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDIIRQHandler - - Push AX BX DX - - Mov DX, CS:MixerPort - Mov AL, 82h - Out DX, AL - Inc DL - In AL, DX - - Test AL, 4 - JZ MIDIIRQHandlerEnd - - Call CheckMIDI - -MIDIIRQHandlerEnd: - Call AckIRQ - - Pop DX BX AX - IRet - - -EndP MIDIIRQHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIRQHandler - - PushAD - Push DS - Push ES - - StI - - Push CS - Pop DS - Assume DS:Driver - - FNSave [FPSave] - -SBIRQHandlerAgain: - Mov DX, MixerPort - Mov AL, 82h - Out DX, AL - Inc DL - In AL, DX - - Test AL, 4 - JZ NoMIDIIRQ - - Push AX - Call CheckMIDI - Pop AX - -NoMIDIIRQ: -; Test AL, 2 -; JZ No16BitIRQ -; -; Push AX -; Mov DX, MixerPort -; Add DL, 0Fh-4 -; In AL, DX -; Pop AX -; -; No16BitIRQ: - Test AL, 1 - JNZ SB8BitIRQ - -SBNo8BitIRQ: - Call AckIRQ - Jmp SBEndIRQ - -SB8BitIRQ: - Mov DX, MixerPort - Add DL, 0Eh-4 - In AL, DX ; 8-bit IRQ ack. - - -; Add DL, 0Ch-0Eh - -; Mov AL, 80h ; Output block of silence -; Call SBOut -; Mov AX, BlockLength2 -; Call SBOut -; Mov AL, AH -; Call SBOut - - ClD - Call ACKIRQ - - Inc IRQFlag - JNZ SBEndIRQ - - Call SaveEMSPageFrame - Assume DS:Nothing - -SB8BitIRQAgain: - Call Update ; Returns DS:SI, CX - - Mov BX, BlockLength - Cmp BX, BlockLength2 - JE SBIRQHandler2 - Mov BlockLength2, BX - - Mov DX, SB16BasePort - Add DL, 0Ch - - MOv AL, 0DAh - Call SBOut - Mov AL, 0C6h - Call SBOut - Xor AL, AL - Call SBOut - Mov AL, BL - Call SBOut - Mov AL, BH - Call SBOut - -; Mov AL, 0D0h -; Call SBOut - -; Mov AL, 80h ; Output block of silence -; Call SBOut -; Mov AL, BL -; Call SBOut -; Mov AL, BH -; Call SBOut - -SBIRQHandler2: - Call SetAWERegisters - Sub CS:IRQFlag, 1 - JNC SB8BitIRQAgain - - Call RestoreEMSPageFrame - -SBEndIRQ: - FRstor [CS:FPSave] - - Pop ES - Pop DS - PopAD - - IRet - -EndP SBIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AWEIRQHandler ; IRQ Handler has to - ; 1) Update AWE registers - ; 2) Update song position - Push AX - Push DS - - Mov AX, AWEUpdateTimer - Add AWEUpdateCount, AX - JC AWEIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp AWEIRQHandler2 - -AWEIRQHandler1: - PushF - Call [OldIRQHandler] - -AWEIRQHandler2: - Xor AWEUpdateFlag, 1 - JZ AWEIRQHandlerEnd - - FNSave [CS:FPSave] - - PushAD - Push ES - - ClD - - Call SaveEMSPageFrame - Call Update ; Returns DS:SI, CX - Call SetAWERegisters - Call RestoreEMSPageFrame - - Pop ES - PopAD - - FRstor [CS:FPSave] - -AWEIRQHandlerEnd: - Pop DS - Pop AX - IRet - -EndP AWEIRQHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EnableRAM - - Mov DX, BasePort - Mov CX, 29 - -EnableRAM1: - Mov AX, DCYSUSV - Or AX, CX - Mov BX, 80h - Call WriteData - - Mov AX, VTFT - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CVCF - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, PTRX - Or AX, CX - Mov EBX, 40000000h - Call WriteData - - Mov AX, CPF - Or AX, CX - Mov EBX, 40000000h - Call WriteData - - Mov AX, PSST - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CSL - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CCCA - Or AX, CX - Mov EBX, 6000000h ; Left write - Call WriteData - - Dec CX - JNS EnableRAM1 - - Ret - -EndP EnableRAM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TestAWE ; Given DX = baseport. - - Push DX - - Add DX, 802h - In AL, DX - In AL, DX - Not AL - Mov BL, AL - Out DX, AL - In AL, DX - Cmp AL, BL - JNE TestAWE1 ; Register changed - - In AX, DX ; Is upper part of pointer - Mov BX, AX ; changing? - Mov CX, 128 - -TestAWE2: - In AX, DX - Cmp AL, BL - JNE TestAWE1 - Cmp AH, BH - JNE TestAWE3 - - Dec CX - JNZ TestAWE2 - Jmp TestAWE1 - -TestAWE3: - Pop DX - - ClC - Ret - -TestAWE1: - Pop DX - StC - Ret - -EndP TestAWE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSetAWE - - Mov CX, 31 - -InitSetAWE1: - Mov AX, 31 - Sub AX, CX - Mov BX, [SI] - Or AX, INIT1 - Call WriteData - - Add SI, 2 - - Dec CX - JNS InitSetAWE1 - - Mov CX, 31 - -InitSetAWE2: - Mov AX, 31 - Sub AX, CX - Mov BX, [SI] - Or AX, INIT2 - Call WriteData - - Add SI, 2 - - Dec CX - JNS InitSetAWE2 - - Mov CX, 31 - -InitSetAWE3: - Mov AX, 31 - Sub AX, CX - Mov BX, [SI] - Or AX, INIT3 - Call WriteData - - Add SI, 2 - - Dec CX - JNS InitSetAWE3 - - Mov CX, 31 - -InitSetAWE4: - Mov AX, 31 - Sub AX, CX - Mov BX, [SI] - Or AX, INIT4 - Call WriteData - - Add SI, 2 - - Dec CX - JNS InitSetAWE4 - - Ret - -EndP InitSetAWE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitAWE - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - - Mov AX, HWCF1 - Mov BX, 59h - Call WriteData - - Mov AX, CFG2 - Mov BX, 20h - Call WriteData - - Mov CX, 31 - -InitAwe1: - Mov BX, 80h - Mov AX, DCYSUSV - Or AX, CX - Call WriteData - - Xor EBX, EBX - Mov AX, ENVVOL - Or AX, CX - Call WriteData - - Mov AX, ENVVAL - Or AX, CX - Call WriteData - - Mov AX, SUSDCY - Or AX, CX - Call WriteData - - Mov AX, ATKHLDV - Or AX, CX - Call WriteData - - Mov AX, LFO1VAL - Or AX, CX - Call WriteData - - Mov AX, HLDATK - Or AX, CX - Call WriteData - - Mov AX, LFO2VAL - Or AX, CX - Call WriteData - - Mov AX, IP - Or AX, CX - Call WriteData - - Mov AX, IFATN - Or AX, CX - Call WriteData - - Mov AX, PEFE - Or AX, CX - Call WriteData - - Mov AX, FMMOD - Or AX, CX - Call WriteData - - Mov AX, TREMFRQ - Or AX, CX - Call WriteData - - Mov AX, FM2FRQ2 - Or AX, CX - Call WriteData - - Mov AX, PTRX - Or AX, CX - Call WriteData - - Mov AX, VTFT - Or AX, CX - Call WriteData - - Mov AX, PSST - Or AX, CX - Call WriteData - - Mov AX, CSL - Or AX, CX - Call WriteData - - Mov AX, CCCA - Or AX, CX - Call WriteData - - Dec CX - JNS InitAWE1 - - Mov CX, 31 - -InitAWE8: - Mov AX, CPF - Or AX, CX - Call WriteData - - Mov AX, CVCF - Or AX, CX - Call WriteData - - Dec CX - JNS InitAWE8 - ; Initialise still... - Mov AX, SMALR - Call WriteData - - Mov AX, SMARR - Call WriteData - - Mov AX, SMALW - Call WriteData - - Mov AX, SMARW - Call WriteData - - Mov SI, Offset InitTable1 - Call InitSetAWE - - ; Wait for 1024 sample periods - Mov AX, WC - Call ReadData - - Mov BX, AX - Mov CX, AX - Add CX, 400h ; 1024 - Cmp BX, CX - JB InitAWE3 - -InitAWE4: - Mov AX, WC - Call ReadData - Cmp AX, CX - JA InitAWE4 - -InitAWE3: - Mov AX, WC - Call ReadData - Cmp AX, CX - JB InitAWE3 - - Mov SI, Offset InitTable2 - Call InitSetAWE - - Mov SI, Offset InitTable3 - Call InitSetAWE - - Mov AX, HWCF4 - Xor EBX, EBX - Call WriteData - - Mov AX, HWCF5 - Mov EBX, 83h - Call WriteData - - Mov AX, HWCF6 - Mov EBX, 8000h - Call WriteData - - Mov SI, Offset InitTable4 - Call InitSetAWE - - Mov AX, HWCF3 - Mov BX, 4 - Call WriteData - - Ret - -EndP InitAWE - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitDRAMRefresh - - Mov AX, DCYSUSV+1Eh - Mov BX, 80h - Call WriteData - - Mov AX, DCYSUSV+1Fh - Call WriteData - -; - - Mov AX, VTFT+1Eh - Xor EBX, EBX - Call WriteData - - Mov AX, CVCF+1Eh - Call WriteData - - Mov AX, VTFT+1Fh - Call WriteData - - Mov AX, CVCF+1Fh - Call WriteData - -; - - Mov AX, PTRX+1Eh - Call WriteData - - Mov AX, CPF+1Eh - Call WriteData - - Mov AX, PTRX+1Fh - Call WriteData - - Mov AX, CPF+1Fh - Call WriteData - -; - - Mov AX, PSST+1Eh - Call WriteData - Mov AX, PSST+1Fh - Call WriteData - - Mov BX, 0FFFFh - Mov AX, CSL+1Eh - Call WriteData - Mov AX, CSL+1Fh - Call WriteData - - Xor BX, BX - Mov AX, CCCA+1Eh - Call WriteData - Mov AX, CCCA+1Fh - Call WriteData - - Ret - -EndP InitDRAMRefresh - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - - ShR AL, 7 - LoopZ SBIn - -; Test AL, AL -; JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov DX, BasePort - Cmp DX, 0FFFFh - JE DetectCard1 - - Cmp DX, 620h - JB DetectCard3 - Cmp DX, 680h - JA DetectCard3 - - Call TestAWE - JNC DetectCardFound - Ret - -DetectCard1: - Mov DX, 620h - -DetectCard2: - Call TestAWE - JNC DetectCardFound - - Add DL, 20h - Cmp DL, 80h - JBE DetectCard2 - -DetectCard3: - StC - Ret - -DetectCardFound: - Mov BasePort, DX - - ; Initialise AWE 32 - Call InitAWE - Call InitDRAMRefresh - - ; Detect amount of RAM. - - Mov DX, BasePort - Mov CX, 29 - -DetectCardMemory1: - Mov AX, DCYSUSV - Or AX, CX - Mov BX, 80h - Call WriteData - - Mov AX, VTFT - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CVCF - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, PTRX - Or AX, CX - Mov EBX, 40000000h - Call WriteData - - Mov AX, CPF - Or AX, CX - Mov EBX, 40000000h - Call WriteData - - Mov AX, PSST - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CSL - Or AX, CX - Xor EBX, EBX - Call WriteData - - Mov AX, CCCA - Or AX, CX - Mov EBX, 4000000h ; Left read - - Test CL, 2 - JZ DetectCardMemory2 - - Mov EBX, 6000000h ; Left write - -DetectCardMemory2: - Call WriteData - - Dec CX - JNS DetectCardMemory1 - - Xor EDI, EDI ; Amount of memory stored in - ; EDI - - Mov AX, SMALW - Mov EBX, 200000h - Call WriteData - - Mov AX, SMLD - Mov BX, 0FFFFh - Call WriteData - - Mov AX, SMLD - Mov BX, 5555h - Call WriteData - - Mov AX, SMLD - Mov BX, 0AAAAh - Call WriteData - - Mov AX, SMALR - Mov EBX, 200000h - Call WriteData - - Mov AX, SMLD - Call ReadData - - Mov AX, SMLD - Call ReadData - Cmp AX, 0FFFFh - JNE DetectCardMemory6 - - Mov AX, SMLD - Call ReadData - Cmp AX, 5555h - JNE DetectCardMemory6 - - Mov AX, SMLD - Call ReadData - Cmp AX, 0AAAAh - JNE DetectCardMemory6 - - Mov EDI, 20000h - -DetectCardMemory3: ; Set read/write addresses.. - Mov AX, SMALW - Mov EBX, EDI - Add EBX, 200000h - Call WriteData - - Mov AX, SMLD - Mov BX, 5555h - Call WriteData - - Mov AX, SMLD - Mov BX, 0AAAAh - Call WriteData - - Mov AX, SMALR - Mov EBX, 200000h - Call WriteData - - Mov AX, SMLD - Call ReadData - - Mov AX, SMLD - Call ReadData - Cmp AX, 0FFFFh - JNE DetectCardMemory5 - - Mov AX, SMALR - Mov EBX, EDI - Add EBX, 200000h - Call WriteData - - Mov AX, SMLD - Call ReadData - - Mov AX, SMLD - Call ReadData - Cmp AX, 5555h - JNE DetectCardMemory5 - - Mov AX, SMLD - Call ReadData - Cmp AX, 0AAAAh - JNE DetectCardMemory5 - -DetectCardMemory4: - Add EDI, 20000h - Cmp EDI, 0E00000h - JB DetectCardMemory3 - -DetectCardMemory5: - Cmp EDI, 0DFFFE0h - JB DetectCardMemory7 - - Mov EDI, 0DFFFE0h - -DetectCardMemory7: - Test EDI, EDI - JZ DetectCardMemory6 - - Mov AWEMemory, EDI - - Mov MixerPort, 210h - Mov AX, BasePort - Sub AX, 400h - Call ResetDSP - JNC DetectMixer2 - -DetectMixer1: - Mov AX, MixerPort - Call ResetDSP - JNC DetectMixer2 - -DetectMixer3: - Add MixerPort, 10h - Cmp MixerPort, 280h - JBE DetectMixer1 - - Mov DX, BasePort - Sub DX, 400h - Mov MixerPort, DX - - Jmp DetectCard4 - -DetectMixer2: ; OK... DSP found. - ; Get DSP version - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - - Mov CX, 200 - -DetectMixerLoop1: - In AL, DX -; Test AL, AL -; JS DetectMixerLoop1 - ShR AL, 7 - LoopNZ DetectMixerLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AX, 40Ch ; SB DSP = 4.12+ - JB DetectMixer3 - - Sub DL, 0Eh - Mov MixerPort, DX - -DetectCard4: - Mov SB16BasePort, DX - Add MixerPort, 4 ; Mixerport - - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Mov DX, MixerPort - Mov AX, 0F834h - Out DX, AX - - Mov AL, 35h - Out DX, AX - - Mov DX, MixerPort - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - Jmp NoWindows - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: - Mov AL, 81h - Out DX, AL - Inc DX - In AL, DX - Dec DX - - And AL, 11 - Xor BX, BX - Cmp AL, 1 - JE DetectCardDMA - - Inc BX - Cmp AL, 2 - JE DetectCardDMA - - Inc BX - Inc BX - Cmp AL, 8 - JNE NoWindows - -DetectCardDMA: - Mov DMA, BX - -DetectCardWindows: - Mov AX, 1600h ; Windows detection. - Int 2Fh - Test AL, 7Fh - JZ NoWindows - - Mov SBIRQMode, 1 - -NoWindows: - Mov EAX, 'Jeff' - ClC - Ret - -DetectCardMemory6: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSamplingRate - Assume DS:Driver - - PushA - Push ES - - Mov AX, SB16BasePort - Call ResetDSP - -; Set dma - Mov BX, DMABuffer - Xor AX, AX - Mov DX, DMA - Mov DI, 512 - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, 256 - Rep StosW - - Mov DX, SB16BasePort - Add DL, 0Ch - -; Mov AL, 0D3h ; Turn off speaker -; Call SBOut - ; Set mixing frequency - Mov AL, 40h - Call SBOut - Mov AL, 0EAh - Call SBOut ; 45454Hz -; Mov AL, 211 -; Call SBOut ; 22222 Hz. - - Mov AL, 0C6h - Call SBOut - Xor AL, AL - Call SBOut - Mov AX, BlockLength - Dec AX - Call SBOut - Mov AL, AH - Call SBOut - - Pop ES - PopA - Ret - -EndP SetSamplingRate - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMIDIIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset MIDIIRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetMIDIIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - Assume DS:Driver - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SBIRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitMIDI - Assume DS:Driver - - Mov DX, 330h - Call DetectUART - JC DetectMIDI1 - - Mov MIDIPort, 330h - Jmp DetectMIDIEnd - -DetectMIDI1: - Mov DX, 300h - Call DetectUART - JC DetectMIDIEnd - - Mov MIDIPort, 300h - -DetectMIDIEnd: - Ret - -EndP InitMIDI - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -FControlWord DW 0 - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - FNInit ; Initialise floating point - FNSTCW FControlWord - And FControlWord, 0F0FFh - FLDCW FControlWord - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov AX, CS - Mov DriverSegment1, AX - Mov DriverSegment2, AX - Mov DriverSegment3, AX - Mov DriverSegment4, AX - Mov DriverSegment5, AX - Mov DriverSegment6, AX - Mov DriverSegment7, AX - Mov DriverSegment8, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Cmp SBIRQMode, 0 - JE InitSound1 - - Cmp DMABuffer, 0 - JNE InitSound3 - - Mov AH, 48h - Mov BX, 1024/16 - Int 21h - JNC InitSound4 - - Mov SBIRQMode, 0 - Jmp InitSound1 - -InitSound4: - Mov DMABuffer, AX - -InitSound3: - Call SetIRQ - Call GetTempo - Call SetTempo - Call ResetMemory - Call SetSamplingRate - - Call InitMIDI - - Mov SI, Offset AWE32Msg2 - Mov AX, BasePort - - Mov BX, IRQ - Mov CX, DMA - - Ret - -InitSound1: - Call SetMIDIIRQ - Call GetTempo - Call SetTempo - Call ResetMemory - - Xor AX, AX - Mov ES, AX ; ES = 0 - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset AWEIRQHandler - - ClI - - XChg DWord Ptr [ES:20h], EAX ; Clock tick - Mov OldIRQHandler, EAX - - StI - -InitSound2: - Call InitMIDI - - Mov SI, Offset AWE32Msg - Mov AX, BasePort - - Mov EBX, AWEMemory - SHR EBX, 9 - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset AWE32ReinitMsg - Mov BX, 40 - Call SetInfoLine - - Call ResetUART - Call InitAWE - Call InitDRAMRefresh - - Cmp SBIRQMode, 0 - JE ReInitSound1 - - Call ResetIRQ - Call SetIRQ - Call SetSamplingRate - Call ReinitUART - Ret - -ReInitSound1: - Xor AX, AX - Mov ES, AX ; ES = 0 - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset AWEIRQHandler - - Mov DWord Ptr [ES:20h], EAX ; Clock tick - - Call ResetIRQ - Call SetMIDIIRQ - Call ReinitUART - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset Chorus - Int 21h - -SaveConfig1: - PushF - Mov AH, 3Eh - Int 21h - PopF - -SaveConfig2: - Call ResetIRQ - - Cmp SBIRQMode, 0 - JE UnInitSound1 - - Mov DX, SB16BasePort - Add DL, 0Ch - - Call ResetUART - - Mov AX, SB16BasePort - Call ResetDSP - - Call InitAWE - - Push ES - Mov AH, 49h - Mov ES, DMABuffer - Int 21h - Pop ES - - Ret - -UnInitSound1: - Mov AL, 34h - Out 43h, AL - - Xor AX, AX - Out 40h, AL - Out 40h, AL - - Mov ES, AX - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - - Mov AX, SB16BasePort - Call ResetDSP - Call ResetUART - Call InitAWE - Call ResetIRQ - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Cmp CS:SBIRQMode, 0 - JE SetTempo1 - ; BlockLength = 55555/BPM - ; BlockLength = 45454*5/2 - ; = 113635 - Mov AX, 48099 - Mov DX, 1 - - Div BX - Dec AX - Dec AX - Mov CS:BlockLength, AX - -; Mov DX, SB16BasePort -; Add DL, 0Ch - - Jmp SetTempo2 - -SetTempo1: - ; Frames per second = 2 * (0.4*Tempo) - Mov AX, 0C214h - Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo - Div BX - - ; AX contains counter. - Mov CS:AWEUpdateTimer, AX - - Out 40h, AL ; Timer IRQ. - Mov AL, AH - Out 40h, AL - -SetTempo2: - Pop DX - Pop BX - Pop AX - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - ; if no sample, then do nothing - ; MemoryUsed = length of sample - ; if sustain loop, then use sustain - ; loop information - ; if no sustain loop, then use loop - ; information - ; if no loop or sustain loop, - ; memoryused += 16; (16 zero samples - ; at the end) - ; - PushAD - Push DS - Push ES - Push FS - - Push AX - - ClI - - Call EnableRAM ; Enable access to DRAM. - - ; Set destination address - Mov AX, SMALW - Mov EBX, CS:AWEMemoryUsed - Add EBX, 200000h - Call WriteData - - Mov DX, CS:BasePort - Add DX, 802h ; Index - Mov AX, 32+26 - Out DX, AX - - Pop AX - - Mov FS, CS:SongDataArea - LEA DI, [EAX*4+EAX] - ShL DI, 2 - Add DI, Offset AWEDataTable-20 - - Mov ECX, -1 - - Mov DWord Ptr [CS:DI], ECX ; Start - Mov DWord Ptr [CS:DI+4], ECX ; Loop start - Mov DWord Ptr [CS:DI+8], ECX ; Loop end - Mov DWord Ptr [CS:DI+12], ECX ; Size occupied - Mov DWord Ptr [CS:DI+16], ECX ; Size occupied - - Mov BP, AX - Add BP, BP - Mov BP, [FS:64910+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC LoadSampleNoError - - JZ LoadSample1 - - ; 16 bit - - Mov CS:LoadSampleFuncF, Offset Load16BitSamplesForwards - Mov CS:LoadSampleFuncB, Offset Load16BitSamplesBackwards - - Jmp LoadSample2 - -LoadSample1: ; 8 bit - Mov CS:LoadSampleFuncF, Offset Load8BitSamplesForwards - Mov CS:LoadSampleFuncB, Offset Load8BitSamplesBackwards - -LoadSample2: - Mov AL, [FS:BP+12h] - Test AL, 30h ; Loop or sustain loop? - JZ LoadSampleNoLoop - - Mov EBX, [FS:BP+34h] ; Loop begin - Mov EDX, [FS:BP+38h] ; Loop end - Test AL, 20h ; Sustain loop? - JZ LoadSample3 - - ShR AL, 1 - Mov EBX, [FS:BP+40h] - Mov EDX, [FS:BP+44h] - Jmp LoadSample3 - -LoadSampleError: - ClC - Jmp LoadSampleEnd - -LoadSampleNoError: - StC - -LoadSampleEnd: - StI - Pop FS - Pop ES - Pop DS - PopAD - - Ret - -LoadSampleNoLoop: ; ECX contains length of sample - Mov EAX, ECX - Mov EDX, AWEMemoryUsed - Mov EBX, AWEMemory - Sub EBX, EDX ; EBX = AWEMemory remaining - - Mov CL, Compress - ShR EAX, CL ; Compress sample - Add EAX, 16 ; zeroes at end of sample - - Cmp EAX, EBX - JA LoadSampleError - - Mov ECX, EAX - Add AWEMemoryUsed, EAX ; Record memory as used - Mov [CS:DI+12], EAX - - Add EDX, 200000h - - Sub ECX, 16 ; Number of samples to transfer - Mov [CS:DI], EDX - Add EDX, ECX - Mov [CS:DI+4], EDX ; Loop start - Add EDX, 14 - Mov [CS:DI+8], EDX ; Loop end - - ; Now to transfer samples to AWE32 - Call [CS:LoadSampleFuncF] - ; Now to shove a whole lot of zeroes - Xor AX, AX - Mov CX, 16 - -LoadSampleNoLoop2: - Out DX, AX - Loop LoadsampleNoLoop2 - - Jmp LoadSampleNoError - -LoadSample3: ; OK... EBX = loop start - ; EDX = loop end - ; AL&40h = ping pong - Test AL, 40h - JNZ LoadSamplePingPong - - Mov CL, Compress - - Push EBX - - ShR EDX, CL - ShR EBX, CL - Mov EAX, EDX - Add EAX, 2 ; For loop fixing - - Mov ECX, AWEMemory - Sub ECX, AWEMemoryUsed ; ECX = AWEMemoryRemaining - - Cmp EAX, ECX - Pop ECX - JA LoadSampleError ; Sufficient memory? - Push ECX - - Mov ECX, EAX - Mov EAX, AWEMemoryUsed - Add AWEMemoryUsed, ECX - Mov [CS:DI+12], ECX - - Sub ECX, 2 - - Add EAX, 200000h - Mov [CS:DI], EAX - - Add EDX, EAX - Add EAX, EBX - - Mov [CS:DI+4], EAX - Mov [CS:DI+8], EDX - - Call [CS:LoadSampleFuncF] - ; Now to fix loop.. 1 extra - ; sample. - - Pop ESI ; Loop start - Test Byte Ptr [FS:BP+12h], 2 - JZ LoadSampleForwards1 - - Add ESI, ESI - -LoadSampleForwards1: - Int 3 - - Mov ECX, 2 - Call [CS:LoadSampleFuncF] - - Jmp LoadSampleNoError - -LoadSamplePingPong: - Mov CL, Compress - ShR EDX, CL - ShR EBX, CL - - Mov EAX, EDX - Add EAX, EDX - Sub EAX, EBX - Inc EAX - - Mov ECX, AWEMemory - Sub ECX, AWEMemoryUsed - - Cmp EAX, ECX - JA LoadSampleError - - Mov [CS:DI+12], EAX - Mov ECX, AWEMemoryUsed - Add AWEMemoryUsed, EAX - - Add ECX, 200000h - Add EAX, ECX - Dec EAX - - Mov [CS:DI], ECX - Add ECX, EBX - Mov [CS:DI+4], ECX - Mov [CS:DI+8], EAX - - Mov EAX, [CS:DI] - Add EAX, EDX - Mov [CS:DI+16], EAX - - Mov ECX, EDX - Sub EDX, EBX - Push EDX - - Call [CS:LoadSampleFuncF] - - Pop ECX - Inc ECX - - Call [CS:LoadSampleFuncB] - - Jmp LoadSampleNoError - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - PushAD - - LEA DI, [EAX*4+EAX] ; DI = AX * 5 - ShL DI, 2 - Add DI, Offset AWEDataTable - - Mov EBX, [CS:DI+12] - Mov EAX, CS:AWEMemoryUsed - Sub EAX, EBX - Add EAX, 200000h - Cmp EAX, [CS:DI] - JNE ReleaseSample1 - - Sub AWEMemoryUsed, EBX -ReleaseSample1: - Mov EAX, -1 - Mov [CS:DI], EAX - Mov [CS:DI+4], EAX - Mov [CS:DI+8], EAX - Mov [CS:DI+12], EAX - - PopAD - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Push CS - Pop ES - - Xor EAX, EAX - Mov CS:AWEMemoryUsed, EAX - - Mov DI, Offset AWEDataTable - Mov CX, 1000 - Mov AX, 0FFFFh - Rep StosW - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset AWE32Status - - Mov EAX, AWEMemory - Sub EAX, AWEMemoryUsed - SHR EAX, 9 - - ClC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset GUSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, MixerPort - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 30 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 30 -DriverFlags DW 1 ; MIDI Out supported - - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - - DW Offset SendUARTOut ; For MIDI Out - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + + Comment ~ + +Index = BasePort + 802h + + 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + ³ .............................. ³ Register ³ Channel Number ³ + ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + + ~ + +OldIRQHandler DD 0 +AWEMemory DD 0 +AWEMemoryUsed DD 0 +AWEUpdateCount DW 0 + +AWEUpdateTimer DW 0 + +LoadSampleFuncF DW 0 +LoadSampleFuncB DW 0 + +AWEDataTable DD 5*100 Dup (0) ; Start, Startloop, Endloop, Size +MIDIPort DW 0 +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +DMABuffer DW 0 + +SB16BasePort DW 0 +MixerPort DW 0 +Step DW 1 +AWEUpdateFlag DB 0 +Compress DB 0 + DB 0 + +SBIRQMode DB 0 +BlockLength DW 100 +BlockLength2 DW 100 + +AWE32Msg DB "Sound Blaster AWE 32 detected", 13 + DB "Address ", 0FDh, "Xh, ", 0FDh, "Dk Memory", 0 + +AWE32Msg2 DB "Sound Blaster AWE 32 detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +AWE32Status DB "FreeAWE ", 0FDh, "Dk", 0 + +AWE32ReinitMsg DB "Sound Blaster AWE 32 reinitialised", 0 +Stereo DB 0 +Forced DB 0 +DriverName DB "ITAWE32.DRV", 0 + +FrequencyError DB "AWE Hardware frequency limit exceeded -> Note terminated", 0 + +IRQFlag DB 0FFh + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +IMR DW 0 + + CPF EQU 0 + PTRX EQU 20h + CVCF EQU 40h + VTFT EQU 60h + PSST EQU 0C0h + CSL EQU 0E0h + + CCCA EQU 100h + HWCF4 EQU 129h + HWCF5 EQU 12Ah + HWCF6 EQU 12Dh + SMALR EQU 134h + SMARR EQU 135h + SMALW EQU 136h + SMARW EQU 137h + SMLD EQU 43Ah + SMRD EQU 23Ah + WC EQU 23Bh + HWCF1 EQU 43Dh + HWCF2 EQU 43Eh + CFG2 EQU 43Eh + HWCF3 EQU 43Fh + INIT1 EQU 440h + INIT2 EQU 240h + INIT3 EQU 460h + INIT4 EQU 260h + ENVVOL EQU 480h + DCYSUSV EQU 4A0h + ENVVAL EQU 4C0h + DCYSUS EQU 4E0h + SUSDCY EQU 4E0h + ATKHLDV EQU 280h + LFO1VAL EQU 2A0h + ATKHLD EQU 2C0h + HLDATK EQU 2C0h + LFO2VAL EQU 2E0h + IP EQU 300h + IFATN EQU 320h + PEFE EQU 340h + FMMOD EQU 360h + TREMFRQ EQU 380h + FM2FRQ2 EQU 3A0h + +ALIGN 4 + +InitTable1 Label + DW 003FFh, 0030h, 007FFh, 0130h, 00BFFh, 0230h, 00FFFh, 0330h + DW 013FFh, 0430h, 017FFh, 0530h, 01BFFh, 0630h, 01FFFh, 0730h + DW 023FFh, 0830h, 027FFh, 0930h, 02BFFh, 0A30h, 02FFFh, 0B30h + DW 033FFh, 0C30h, 037FFh, 0D30h, 03BFFh, 0E30h, 03FFFh, 0F30h + + DW 043FFh, 0030h, 047FFh, 0130h, 04BFFh, 0230h, 04FFFh, 0330h + DW 053FFh, 0430h, 057FFh, 0530h, 05BFFh, 0630h, 05FFFh, 0730h + DW 063FFh, 0830h, 067FFh, 0930h, 06BFFh, 0A30h, 06FFFh, 0B30h + DW 073FFh, 0C30h, 077FFh, 0D30h, 07BFFh, 0E30h, 07FFFh, 0F30h + + DW 083FFh, 0030h, 087FFh, 0130h, 08BFFh, 0230h, 08FFFh, 0330h + DW 093FFh, 0430h, 097FFh, 0530h, 09BFFh, 0630h, 09FFFh, 0730h + DW 0A3FFh, 0830h, 0A7FFh, 0930h, 0ABFFh, 0A30h, 0AFFFh, 0B30h + DW 0B3FFh, 0C30h, 0B7FFh, 0D30h, 0BBFFh, 0E30h, 0BFFFh, 0F30h + + DW 0C3FFh, 0030h, 0C7FFh, 0130h, 0CBFFh, 0230h, 0CFFFh, 0330h + DW 0D3FFh, 0430h, 0D7FFh, 0530h, 0DBFFh, 0630h, 0DFFFh, 0730h + DW 0E3FFh, 0830h, 0E7FFh, 0930h, 0EBFFh, 0A30h, 0EFFFh, 0B30h + DW 0F3FFh, 0C30h, 0F7FFh, 0D30h, 0FBFFh, 0E30h, 0FFFFh, 0F30h + +InitTable2 Label + DW 003FFh, 8030h, 007FFh, 8130h, 00BFFh, 8230h, 00FFFh, 8330h + DW 013FFh, 8430h, 017FFh, 8530h, 01BFFh, 8630h, 01FFFh, 8730h + DW 023FFh, 8830h, 027FFh, 8930h, 02BFFh, 8A30h, 02FFFh, 8B30h + DW 033FFh, 8C30h, 037FFh, 8D30h, 03BFFh, 8E30h, 03FFFh, 8F30h + + DW 043FFh, 8030h, 047FFh, 8130h, 04BFFh, 8230h, 04FFFh, 8330h + DW 053FFh, 8430h, 057FFh, 8530h, 05BFFh, 8630h, 05FFFh, 8730h + DW 063FFh, 8830h, 067FFh, 8930h, 06BFFh, 8A30h, 06FFFh, 8B30h + DW 073FFh, 8C30h, 077FFh, 8D30h, 07BFFh, 8E30h, 07FFFh, 8F30h + + DW 083FFh, 8030h, 087FFh, 8130h, 08BFFh, 8230h, 08FFFh, 8330h + DW 093FFh, 8430h, 097FFh, 8530h, 09BFFh, 8630h, 09FFFh, 8730h + DW 0A3FFh, 8830h, 0A7FFh, 8930h, 0ABFFh, 8A30h, 0AFFFh, 8B30h + DW 0B3FFh, 8C30h, 0B7FFh, 8D30h, 0BBFFh, 8E30h, 0BFFFh, 8F30h + + DW 0C3FFh, 8030h, 0C7FFh, 8130h, 0CBFFh, 8230h, 0CFFFh, 8330h + DW 0D3FFh, 8430h, 0D7FFh, 8530h, 0DBFFh, 8630h, 0DFFFh, 8730h + DW 0E3FFh, 8830h, 0E7FFh, 8930h, 0EBFFh, 8A30h, 0EFFFh, 8B30h + DW 0F3FFh, 8C30h, 0F7FFh, 8D30h, 0FBFFh, 8E30h, 0FFFFh, 8F30h + +InitTable3 Label + DW 0C10h, 8470h, 14FEh, 0B488h, 167Fh, 0A470h, 18E7h, 84B5h + DW 1B6Eh, 842Ah, 1F1Dh, 852Ah, 0DA3h, 9F7Ch, 167Eh, 0F254h + DW 0, 842Ah, 1, 852Ah, 18E6h, 9BAAh, 1B6Dh, 0F234h + DW 229Fh, 8429h, 2746h, 8529h, 1F1Ch, 96E7h, 229Eh, 0F224h + + DW 0DA4h, 8429h, 2C29h, 8529h, 2745h, 97F6h, 2C28h, 0F254h + DW 383Bh, 8428h, 320Fh, 8528h, 320Eh, 9F02h, 1341h, 0F264h + DW 3EB6h, 8428h, 3EB9h, 8528h, 383Ah, 9FA9h, 3EB5h, 0F294h + DW 3EB7h, 8474h, 3EBAh, 8575h, 3EB8h, 0C4C3h, 3EBBh, 0C5C3h + + DW 00000, 0A404h, 00001, 0A504h, 141Fh, 8671h, 14FDh, 8287h + DW 3EBCh, 0E610h, 3EC8h, 8C7Bh, 31Ah, 87E6h, 3EC8h, 86F7h + DW 3EC0h, 821Eh, 3EBEh, 0D208h, 3EBDh, 821Fh, 3ECAh, 8386h + DW 3EC1h, 8C03h, 3EC9h, 831Eh, 3ECAh, 8C4Ch, 3EBFh, 8C55h + + DW 3EC9h, 0C208h, 3EC4h, 0BC84h, 3EC8h, 8EADh, 3EC8h, 0D308h + DW 3EC2h, 8F7Eh, 3ECBh, 821Eh, 3ECBh, 0D208h, 3EC5h, 831Fh + DW 3EC6h, 0C308h, 3EC3h, 0B2FFh, 3EC9h, 8265h, 3EC9h, 831Eh + DW 1342h, 0D308h, 3EC7h, 0B3FFh, 0, 8365h, 1420h, 9570h + +InitTable4 Label + DW 0C10h, 8470h, 14FEh, 0B488h, 167Fh, 0A470h, 18E7h, 84B5h + DW 1B6Eh, 842Ah, 1F1Dh, 852Ah, 0DA3h, 0F7Ch, 167Eh, 7254h + DW 0, 842Ah, 1, 852Ah, 18E6h, 0BAAh, 1B6Dh, 7234h + DW 229Fh, 8429h, 2746h, 8529h, 1F1Ch, 6E7h, 229Eh, 7224h + + DW 0DA4h, 8429h, 2C29h, 8529h, 2745h, 07F6h, 2C28h, 7254h + DW 383Bh, 8428h, 320Fh, 8528h, 320Eh, 0F02h, 1341h, 7264h + DW 3EB6h, 8428h, 3EB9h, 8528h, 383Ah, 0FA9h, 3EB5h, 7294h + DW 3EB7h, 8474h, 3EBAh, 8575h, 3EB8h, 44C3h, 3EBBh, 45C3h + + DW 00000, 0A404h, 00001, 0A504h, 141Fh, 0671h, 14FDh, 287h + DW 3EBCh, 0E610h, 3EC8h, 0C7Bh, 31Ah, 7E6h, 3EC8h, 86F7h + DW 3EC0h, 821Eh, 3EBEh, 0D208h, 3EBDh, 021Fh, 3ECAh, 386h + DW 3EC1h, 0C03h, 3EC9h, 31Eh, 3ECAh, 8C4Ch, 3EBFh, 0C55h + + DW 3EC9h, 0C208h, 3EC4h, 0BC84h, 3EC8h, 0EADh, 3EC8h, 0D308h + DW 3EC2h, 8F7Eh, 3ECBh, 021Eh, 3ECBh, 0D208h, 3EC5h, 31Fh + DW 3EC6h, 0C308h, 3EC3h, 32FFh, 3EC9h, 0265h, 3EC9h, 831Eh + DW 1342h, 0D308h, 3EC7h, 33FFh, 0, 8365h, 1420h, 9570h + +AWEVolumeTable Label Byte ; Value = -log(vol/256)*(20/.375) + ; = -log(vol/256)*(160/3) + + DB 255, 128, 112, 103, 96, 91, 87, 83 ; 0->7 + DB 80, 78, 75, 73, 71, 69, 67, 66 ; 8->15 + DB 64, 63, 61, 60, 59, 58, 57, 56 ; 16->23 + DB 55, 54, 53, 52, 51, 50, 50, 49 ; 24->31 + DB 48, 47, 47, 46, 45, 45, 44, 44 ; 32->39 + DB 43, 42, 42, 41, 41, 40, 40, 39 ; 40->47 + DB 39, 38, 38, 37, 37, 36, 36, 36 ; 48->55 + DB 35, 35, 34, 34, 34, 33, 33, 32 ; 56->63 + DB 32, 32, 31, 31, 31, 30, 30, 30 ; 64->71 + DB 29, 29, 29, 28, 28, 28, 28, 27 ; 72->79 + DB 27, 27, 26, 26, 26, 26, 25, 25 ; 80->87 + DB 25, 25, 24, 24, 24, 23, 23, 23 ; 88->95 + DB 23, 22, 22, 22, 22, 22, 21, 21 ; 96->103 + DB 21, 21, 20, 20, 20, 20, 20, 19 ; 104->111 + DB 19, 19, 19, 19, 18, 18, 18, 18 ; 112->119 + DB 18, 17, 17, 17, 17, 17, 16, 16 ; 120->127 + DB 16 ; 128 + + Comment ~ ; Value = -log(vol/128)*(20/.375) + ; = -log(vol/128)*(160/3) + ; This is mathematically the correct table, but it seems too + ; loud, and it overloads on playback. + + DB 255, 112, 96, 87, 80, 75, 71, 67 ; 0->7 + DB 64, 61, 59, 57, 55, 53, 51, 50 ; 8->15 + DB 48, 47, 45, 44, 43, 42, 41, 40 ; 16->23 + DB 39, 38, 37, 36, 35, 34, 34, 33 ; 24->31 + DB 32, 31, 31, 30, 29, 29, 28, 28 ; 32->39 + DB 27, 26, 26, 25, 25, 24, 24, 23 ; 40->47 + DB 23, 22, 22, 21, 21, 20, 20, 20 ; 48->55 + DB 19, 19, 18, 18, 18, 17, 17, 16 ; 56->63 + DB 16, 16, 15, 15, 15, 14, 14, 14 ; 64->71 + DB 13, 13, 13, 13, 12, 12, 12, 11 ; 72->79 + DB 11, 11, 10, 10, 10, 9, 9, 9 ; 80->87 + DB 9, 8, 8, 8, 8, 7, 7, 7 ; 88->95 + DB 7, 6, 6, 6, 6, 5, 5, 5 ; 96->103 + DB 5, 4, 4, 4, 4, 4, 4, 3 ; 104->111 + DB 3, 3, 3, 2, 2, 2, 2, 2 ; 112->119 + DB 1, 1, 1, 1, 1, 1, 1, 1 ; 120->127 + DB 0 + + ~ + +GUSScreenList Label + DW 7 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr GravisHeaderLine + + DW Near Ptr MixerText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr MasterVolumeLeft ; 7 + DW Near Ptr MasterVolumeRight + DW Near Ptr TrebleVolumeLeft + DW Near Ptr TrebleVolumeRight + DW Near Ptr BassVolumeLeft + DW Near Ptr BassVolumeRight ; 12 + + DW Near Ptr SampleText + + DW Near Ptr SampleSize0Button ; 14 + DW Near Ptr SampleSize1Button + DW Near Ptr SampleSize2Button + DW Near Ptr SampleSize3Button ; 17 + + DW Near Ptr EffectText + DW Near Ptr EffectBox + + DW Near Ptr ChorusThumbBar ; 20 + DW Near Ptr ReverbThumbBar + + DW DriverText + + DW 0 + +GravisHeaderLine DW 10 + DB "Sound Blaster AWE 32 Driver", 0 + +DriverText DW 1 + DB 27, 48 + DB 21h + DB "Sound Blaster AWE 32 Driver 1.5 for Impulse Tracker", 0 + +MixerText DW 1 + DB 3, 13 + DB 20h + DB "Mixer options", 13 + DB 13 + DB " Master Volume Left", 13 + DB " Master Volume Right", 13 + DB 13 + DB 13 + DB " Treble Left", 13 + DB " Treble Right", 13 + DB " Bass Left", 13 + DB " Bass Right", 13 + DB 0 + +VolumeBox1 DW 0 + DB 24, 14, 30, 17 + DB 25 + +VolumeBox2 DW 0 + DB 17, 18, 21, 23 + DB 25 + +MasterVolumeLeft DW 9 + DB 25, 15 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 8, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 25, 16 + DW 0, 31 + DW 9, 1 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 18, 19 + DW 0, 15 + DW 9, 2 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 18, 20 + DW 0, 15 + DW 9, 3 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 18, 21 + DW 0, 15 + DW 9, 4 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 18, 22 + DW 0, 15 + DW 9, 5 + DW 11, 14, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +SampleText DW 1 + DB 3, 25 + DB 20h + DB "Sample resizing options", 0 + +SampleSize0Button DW 2 + DW 12, 15, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment1 DW 0 + DW 0 + DW Offset SetCompress +DriverSegment2 DW 0 + DB 7, 27, 20, 29, 8 + DB 0 + DB " Original", 0 + +SampleSize1Button DW 2 + DW 14, 16, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment3 DW 0 + DW 1 + DW Offset SetCompress +DriverSegment4 DW 0 + DB 7, 30, 20, 32, 8 + DB 0 + DB " Half", 0 + +SampleSize2Button DW 2 + DW 15, 17, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment5 DW 0 + DW 2 + DW Offset SetCompress +DriverSegment6 DW 0 + DB 7, 33, 20, 35, 8 + DB 0 + DB " Quarter", 0 + +SampleSize3Button DW 2 + DW 16, 20, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment7 DW 0 + DW 3 + DW Offset SetCompress +DriverSegment8 DW 0 + DB 7, 36, 20, 38, 8 + DB 0 + DB " Eighth", 0 + +EffectText DW 1 + DB 3, 40 + DB 20h + DB "Effect options", 13 + DB 13 + DB " Chorus", 13 + DB " Reverb", 0 + + +EffectBox DW 0 + DB 12, 41, 30, 44 + DB 25 + +ChorusThumbBar DW 9 + DB 13, 42 + DW 0, 127 + DW 9, 6 + DW 17, 21, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +ReverbThumbBar DW 9 + DB 13, 43 + DW 0, 127 + DW 9, 7 + DW 20, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + + + +VolumeTable DB 6 Dup (0) +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 2 +Chorus DB 10, 64 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +ALIGN 16 +FPSave DB 128 Dup (0) + +AWEParameters DB 64 Dup (0FFh), 64 Dup (0) + +include dma.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut + + Push CX + Push DX + Mov DX, CS:MIDIPort + Test DX, DX + JZ UARTOutEnd + + Push AX + Xor CX, CX + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + LoopNZ UARTOut1 + + Pop AX + JNZ UARTOutEnd + + Dec DX + Out DX, AL + +UARTOutEnd: + Pop DX + Pop CX + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:AWEParameters+BX], AL + + Pop BX + + Mov CS:InterpretState, 0 + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Ret + +SendUARTOut3: + Mov InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset AWEParameters + Mov CX, 32 + Or AX, -1 + Rep StosW + Mov CX, 32 + Inc AX + Rep StosW + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectUART ; Given DX = Port + +; outportb(BasePort+1, 0xFF); +; while(InputUART() != 0xFE); +; outportb(BasePort+1, 0x3F); +; while(InputUART() != 0xFE); + + ClI + + Inc DX + Mov AL, 0FFh ; reset + Out DX, AL + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 80h + LoopNZ DetectUART1 + JNZ DetectUARTFailed + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JNE DetectUART1 + + Xor CX, CX + +DetectUART3: + In AL, DX + Test AL, 40h + LoopNZ DetectUART3 + JNZ DetectUARTFailed + + Mov AL, 03Fh + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + LoopNZ DetectUART2 + JNZ DetectUARTFailed + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JNE DetectUART2 + Dec DX + + ClC + StI + Ret + +DetectUARTFailed: + StC + StI + Ret + +Comment ~ + +; From SB-DevKit + + ClI + + Inc DX + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 40h ; Ready for output + LoopNZ DetectUART1 + JNZ DetectUARTError + + Mov AL, 0FFh ; Reset! + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + JNZ DetectUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART4 + +DetectUART3: + Loop DetectUART2 + +DetectUARTError: + StI + StC + Ret + +DetectUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +DetectUART5: + In AL, DX + Test AL, 40h + LoopNZ DetectUART5 + JNZ DetectUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +DetectUART6: + Xor CX, CX + +DetectUART7: + In AL, DX + Test AL, 80h + JNZ DetectUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART9 + +DetectUART8: + Loop DetectUART7 + + Jmp DetectUARTError + +DetectUART9: + StI + ClC + Ret + +~ + +EndP DetectUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReinitUART + + Mov DX, MIDIPort + Test DX, DX + JZ ReinitUART1 + + Call DetectUART + +ReinitUART1: + Ret + +EndP ReinitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, MIDIPort + Test DX, DX + JZ ResetUART1 + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetCompress Far + + Mov CX, [SI+22] + Mov CS:Compress, CL + + Mov AX, 1 + ShL AX, CL + Mov CS:Step, AX + + Call Music_LoadAllSamples + + Mov AX, 1 + Ret + +EndP SetCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetCompress Far + + Push CS + Pop ES + Mov DI, Offset Compress + + Ret + +EndP GetCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load8BitSamplesForwards ; Given DS:SI, ECX = count + + Push BX + + Mov BX, CS:Step + Mov DX, CS:BasePort + Add DX, 400h + Xor AL, AL + +Load8BitSamplesForwards2: + Mov AH, [SI] + Add SI, BX + JC Load8BitSamplesForwards4 + +Load8BitSamplesForwards3: + Out DX, AX + + Dec ECX + JNZ Load8BitSamplesForwards2 + + Pop BX + Ret + +Load8BitSamplesForwards4: + Add ESI, 10000h + Int 3 + Jmp Load8BitSamplesForwards3 + +EndP Load8BitSamplesForwards + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load16BitSamplesForwards ; Given DS:SI, ECX = count + + Push BX + + Mov BX, CS:Step + Mov DX, CS:BasePort + Add DX, 400h + Add BX, BX + +Load16BitSamplesForwards2: + Mov AX, [SI] + Add SI, BX + JC Load16BitSamplesForwards4 + +Load16BitSamplesForwards3: + Out DX, AX + + Dec ECX + JNZ Load16BitSamplesForwards2 + + Pop BX + Ret + +Load16BitSamplesForwards4: + Add ESI, 10000h + Int 3 + Jmp Load16BitSamplesForwards3 + +EndP Load16BitSamplesForwards + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load8BitSamplesBackwards ; Given DS:SI, ECX = count + + Push BX + + Mov BX, CS:Step + Mov DX, CS:BasePort + Add DX, 400h + Xor AL, AL + + Sub SI, BX + JC Load8BitSamplesBackwards6 + +Load8BitSamplesBackwards2: + Sub SI, BX + JC Load8BitSamplesBackwards4 + +Load8BitSamplesBackwards3: + Mov AH, [SI] + Out DX, AX + + Dec ECX + JNZ Load8BitSamplesBackwards2 + + + Pop BX + Ret + +Load8BitSamplesBackwards4: + Sub ESI, 10000h + JC Load8BitSamplesBackwards5 + Int 3 + Jmp Load8BitSamplesBackwards3 + +Load8BitSamplesBackwards5: + Xor ESI, ESI + Jmp Load8BitSamplesBackwards3 + +Load8BitSamplesBackwards6: + Sub ESI, 10000h + Int 3 + Jmp Load8BitSamplesBackwards2 + + +EndP Load8BitSamplesBackwards + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load16BitSamplesBackwards ; Given DS:SI, ECX = count + + Push BX + + Mov BX, CS:Step + Mov DX, CS:BasePort + Add DX, 400h + Add BX, BX + + Sub SI, BX + JC Load16BitSamplesBackwards6 + +Load16BitSamplesBackwards2: + Sub SI, BX + JC Load16BitSamplesBackwards4 + +Load16BitSamplesBackwards3: + Mov AX, [SI] + Out DX, AX + + Dec ECX + JNZ Load16BitSamplesBackwards2 + + Pop BX + Ret + +Load16BitSamplesBackwards4: + Sub ESI, 10000h + JC Load16BitSamplesBackwards5 + Int 3 + Jmp Load16BitSamplesBackwards3 + +Load16BitSamplesBackwards5: + Xor ESI, ESI + Jmp Load16BitSamplesBackwards3 + +Load16BitSamplesBackwards6: + Sub ESI, 10000h + Int 3 + Jmp Load16BitSamplesBackwards2 + + +EndP Load16BitSamplesBackwards + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WriteDataChannel + + Or AX, DX + +Proc WriteData ; Have BX/EBX = value + ; AX = xxyyh + ; ^ ^ + ; | | + ; | \-- value to send to pointer register + ; \---- 0, 1, 2 or 3, 4 + ; 0 = data reg 0 + ; 1 = data reg 1, dword + ; 2 = data reg 2 + ; 3 = data reg 3 + ; 4 = data reg 4, word + + Jmp $+2 + Jmp $+2 + + Push DX + Push AX + + Mov DX, BasePort + Add DX, 802h + And AX, 0FFh + Out DX, AX + Pop AX + + Jmp $+2 + Jmp $+2 + + Cmp AH, 1 + JB WriteDataReg0 + JE WriteDataReg1DWord + Cmp AH, 3 + JB WriteDataReg2 + JE WriteDataReg3 + Jmp WriteDataReg1Word + +WriteDataReg0: + Sub DX, 802h + Mov EAX, EBX + Out DX, EAX + + Pop DX + Ret + +WriteDataReg1DWord: + Sub DX, 402h + Mov EAX, EBX + Out DX, EAX + + Pop DX + Ret + +WriteDataReg1Word: + Sub DX, 402h + Mov AX, BX + Out DX, AX + + Pop DX + Ret + +WriteDataReg2: + Sub DX, 400h + Mov AX, BX + Out DX, AX + + Pop DX + Ret + +WriteDataReg3: + Sub DL, 2 + Mov AX, BX + Out DX, AX + + Pop DX + Ret + +EndP WriteData + +EndP WriteDataChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReadDataChannel + + Or AX, DX + +Proc ReadData ; AX = xxyyh + ; ^ ^ + ; | | + ; | \-- value to send to pointer register + ; \---- 0, 1, 2 or 3, 4 + ; 0 = data reg 0 + ; 1 = data reg 1, dword + ; 2 = data reg 2 + ; 3 = data reg 3 + ; 4 = data reg 4, word + + Jmp $+2 + Jmp $+2 + + Push DX + Push AX + + Mov DX, BasePort + Add DX, 802h + And AX, 0FFh + Out DX, AX + Pop AX + + Jmp $+2 + Jmp $+2 + + Cmp AH, 1 + JB ReadDataReg0 + JE ReadDataReg1DWord + Cmp AH, 3 + JB ReadDataReg2 + JE ReadDataReg3 + Jmp ReadDataReg1Word + +ReadDataReg0: + Sub DX, 802h + In EAX, DX + + Pop DX + Ret + +ReadDataReg1DWord: + Sub DX, 402h + In EAX, DX + + Pop DX + Ret + +ReadDataReg1Word: + Sub DX, 402h + In AX, DX + + Pop DX + Ret + +ReadDataReg2: + Sub DX, 400h + In AX, DX + + Pop DX + Ret + +ReadDataReg3: + Sub DL, 2 + In AX, DX + + Pop DX + Ret + +EndP ReadData + +EndP ReadDataChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Const44100 DD 44100.0 +Const1000h DD 4096.0 +ConstE000h DD 57344.0 + +Proc SetAWEFrequency + + Mov EAX, [SI+10h] ; Final freq + + Push CX + Mov CL, Compress + ShR EAX, CL + Pop CX + +; Test EAX, EAX + JZ SetAWEFrequencyError + Cmp EAX, 88200*2 + JAE SetAWEFrequencyError + + Mov DWord Ptr [SI+4], EAX + + FLd CS:ConstE000h + FLd CS:Const1000h + FILd DWord Ptr [SI+4] + FDiv CS:Const44100 + FYL2X ; ST = ln(Pitch/44100)/ln(2) * 1000h + FAddP ST(1) + FIStP DWord Ptr [SI+4] + + Mov AX, IP + Mov BX, [SI+4] + Call WriteDataChannel + + Ret + Assume DS:Nothing + +SetAWEFrequencyError: + Call StopAWENote + + Mov Word Ptr [SI], 200h + Test Byte Ptr [SI+3Ah], 80h + JNZ SetAWEFrequencyError1 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +SetAWEFrequencyError1: + Mov AX, IP + Xor EBX, EBX + Call WriteDataChannel + + Push DS SI + + Push CS + Pop DS + Mov SI, Offset FrequencyError + Mov BX, 40 + Call SetInfoLine + + Pop SI DS + + Ret + +EndP SetAWEFrequency + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetAWEPan + + Mov AX, PSST + Call ReadDataChannel ; Get starting offset + + Cmp CS:Stereo, 0 + JE SetPan2 + + Test CL, 128 + JNZ SetPan2 + + Mov BL, [SI+37h] ; Final pan + Cmp BL, 100 ; Surround -> central + JNE SetPan1 + +SetPan2: + Mov BL, 32 + +SetPan1: ; BL = 0->64, need to extend to 0->255 + Add BL, BL + Add BL, BL + SBB BL, 0 ; BL = 0->255 + Not BL + + ShL EAX, 8 + SHLD EBX, EAX, 24 + Mov AX, PSST + Call WriteDataChannel + + Ret + +EndP SetAWEPan + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetAWEVolume + + Test CH, 8 + JZ SetAWEVolume1 + + Test CH, 1 + JNZ SetAWEVolume5 + + Cmp Byte Ptr [SI+8], 0FFh + JE SetAWEVolume4 + +SetAWEVolume5: + Mov Byte Ptr [SI+8], 0FFh + + Mov AX, IFATN + Call ReadDataChannel + Mov BX, AX + Mov AX, IFATN + Mov BL, 0FFh + Call WriteDataChannel + +SetAWEVolume4: + Ret + +SetAWEVolume1: +; First check if channel has been disowned + Xor BX, BX + Mov BL, [SI+3Ah] ; BL = host channel + + Test BL, BL + JS SetAWEVolume3 + +SetAWEVolume2: + Mov AH, [CS:AWEParameters+BX] ; AH = filter + Mov AL, [CS:AWEParameters+BX+64] ; AL = Q. + + ShR AL, 3 + Mov [SI+5Bh], AH + + Cmp AL, [SI+3Fh] + JE SetAWEVolume3 + + Mov [SI+3Fh], AL + +; Set Q + Mov BL, AL + ShL EBX, 28 + + Mov AX, CCCA + Call ReadDataChannel + And EAX, 0FFFFFFFh + Or EBX, EAX + Mov AX, CCCA + Call WriteDataChannel + +SetAWEVolume3: + Mov AL, [SI+3Eh] + Mul Byte Ptr [SI+5Bh] + ShL AX, 1 + Xor BX, BX + Add AH, 1 + Mov BL, [SI+20h] ; Final volume + Mov [SI+8], BL + Mov BL, [CS:AWEVolumeTable+BX] + Mov BH, AH + Mov AX, IFATN + Call WriteDataChannel + + Ret + +EndP SetAWEVolume + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopAWENote + + Mov AX, DCYSUSV + Mov BX, 80h + Call WriteDataChannel + + Mov AX, VTFT + Mov EBX, 0FFFFh + Call WriteDataChannel + + Mov AX, CVCF + Call WriteDataChannel + + Mov BX, 80h + Mov AX, DCYSUSV + Call WriteDataChannel + + Mov AX, VTFT + Mov EBX, 0FFFFh + Call WriteDataChannel + + Mov AX, CVCF + Call WriteDataChannel + + Xor EBX, EBX + Mov AX, ENVVOL + Call WriteDataChannel + + Mov AX, ENVVAL + Call WriteDataChannel + + Mov AX, SUSDCY + Call WriteDataChannel + + Mov AX, ATKHLDV + Call WriteDataChannel + + Mov AX, LFO1VAL + Call WriteDataChannel + + Mov AX, HLDATK + Call WriteDataChannel + + Mov AX, LFO2VAL + Call WriteDataChannel + + Mov AX, IP + Call WriteDataChannel + + Mov AX, IFATN + Call ReadDataChannel + Mov BH, AH + Mov AX, IFATN + Call WriteDataChannel + + Xor EBX, EBX + Mov AX, PEFE + Call WriteDataChannel + + Mov AX, FMMOD + Call WriteDataChannel + + Mov AX, TREMFRQ + Call WriteDataChannel + + Mov AX, FM2FRQ2 + Call WriteDataChannel + + Mov AX, PTRX + Call WriteDataChannel + + Mov AX, VTFT + Call WriteDataChannel + +; Mov AX, PSST +; Call WriteDataChannel + + Mov BL, 8 + Mov AX, CSL + Call WriteDataChannel + + Mov AX, CCCA + Call ReadDataChannel + Mov EBX, EAX + Mov AX, CCCA + And EBX, 0F0000000h + Call WriteDataChannel + + Xor EBX, EBX + Mov AX, CPF + Call WriteDataChannel + + Ret + +EndP StopAWENote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetAWERegisters ; DS:SI = channel info table + ; CX = number of channels... + + Push CX + Push SI + + ; Stage 1. + ; Turn off any channel which has + ; a new note to play + ; If no new note to play and channel + ; is on, then get current position + + Xor DX, DX ; DX = oscillator number + +GetAWERegisters1: + Mov BX, [SI] + Test BH, 2 ; Note cut command + JZ GetAWERegisters2 + + Mov BX, 200h + Mov [SI], BX + + Call StopAWENote + Jmp GetAWERegisters4 + +GetAWERegisters2: + Test BL, 1 ; Channel on? + JZ GetAWERegisters4 + + Test BH, 1 ; New note? + JZ GetAWERegisters3 + + ; Fade out volume +; Mov AX, DCYSUSV +; Mov BX, 807Fh +; Call WriteDataChannel + + Call StopAWENote + + Jmp GetAWERegisters4 + +GetAWERegisters3: ; Get offset + Mov AX, CCCA + Call ReadDataChannel + + Xor BX, BX + And EAX, 00000000111111111111111111111111b + Inc EAX ; Interpolator correction + ; EAX = address in sound memory + Mov BL, [SI+36h] ; BL = sample number + LEA BX, [EBX*4+EBX] + ShL BX, 2 + Add BX, Offset AWEDataTable + + Cmp Byte Ptr [SI+0Ah], 8 + JB GetAddressNoLoop + JE GetAddressForwardsLoop + +GetAddressPingPongLoop: + Cmp EAX, [CS:BX+16] + JB SetOldAddress + + Neg EAX + Add EAX, [CS:BX+8] + Jmp SetOldAddress1 + +GetAddressNoLoop: + Cmp EAX, [CS:BX+4] ; Start loop + JB SetOldAddress + + Call StopAWENote + + ; OK.. gotta turn off channel + Mov Word Ptr [SI], 0 + Test Byte Ptr [SI+3Ah], 80h + JNZ GetAWERegisters4 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + + Jmp GetAWERegisters4 + +GetAddressForwardsLoop: +SetOldAddress: + Sub EAX, [CS:BX] ; EAX = address in sample + JNS SetOldAddress1 + + Xor EAX, EAX + +SetOldAddress1: + Push CX + Mov CL, Compress + ShL EAX, CL + Pop CX + + XChg [SI+4Ch], EAX + Mov [SI+2Ch], EAX + +GetAWERegisters4: + Add SI, 128 + + Inc DX + Dec CX + JNZ GetAWERegisters1 + + Pop SI + Pop CX + + Xor DX, DX ; DX = oscillator number + +SetAWERegisters1: + ; Stage 2. + ; If new frequency, play new frequency + ; If new volume, play new volume + ; If new pan, play new pan + ; If new note, set ENVVOL, ENVVAL, SUSDCY, ATKHLDV, LFO1VAL, HLDATK + ; LFO2VAL, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2 + ; PSST, CSL, CCCA + ; VTFT, CVCF, DCYSUSV, PTRX, CPF + + Push CX + Mov CX, [SI] + Test CL, 1 ; Channel on? + JZ SetAWERegistersEnd + + Test CH, 1 ; New note? + JZ SetAWERegisters2 + + Xor BX, BX + Mov BL, [SI+36h] + LEA DI, [EBX*4+EBX] + ShL DI, 2 + Add DI, Offset AWEDataTable + + Mov AX, DCYSUSV + Mov BX, 80h + Call WriteDataChannel + + Mov AX, VTFT + Xor EBX, EBX + Call WriteDataChannel + + Mov AX, CVCF + Call WriteDataChannel + + Cmp DWord Ptr [CS:DI], 0FFFFFFFFh + JE SetAWERegistersError + + Mov AX, PTRX + Call WriteDataChannel + + Mov AX, CPF + Call WriteDataChannel + + + Mov AX, ENVVOL + Mov BX, 8000h + Call WriteDataChannel + + Mov AX, ENVVAL + Mov BX, 8000h + Call WriteDataChannel + + Mov AX, SUSDCY + Mov BX, 7F7Fh + Call WriteDataChannel + + Mov AX, ATKHLDV + Call WriteDataChannel + + Mov AX, LFO1VAL + Mov BX, 8000h + Call WriteDataChannel + + Mov AX, HLDATK + Mov BX, 7F7Fh + Call WriteDataChannel + + Mov AX, LFO2VAL + Mov BX, 8000h + Call WriteDataChannel + + Call SetAWEFrequency + Call SetAWEVolume + + Mov AX, PEFE + Xor BX, BX + Call WriteDataChannel + + Mov AX, FMMOD + Call WriteDataChannel + + Mov AX, TREMFRQ + Mov BX, 10h + Call WriteDataChannel + + Mov AX, FM2FRQ2 + Call WriteDataChannel + + + Mov EBX, [CS:DI+4] + Dec EBX ; Interpolator offset + Mov AX, PSST + Call WriteDataChannel + + Call SetAWEPan + + Mov AL, [CS:VolumeTable+6] ; Chorus + ShL EAX, 24 + Mov EBX, [CS:DI+8] + Dec EBX ; Interpolator offset + Or EBX, EAX + Mov AX, CSL + Call WriteDataChannel + + Mov AL, [SI+3Fh] + ShL EAX, 28 + + Push CX + Mov CL, Compress + Mov EBX, [SI+4Ch] + ShR EBX, CL + Pop CX + Add EBX, [CS:DI] + Dec EBX ; Interpolator offset + Or EBX, EAX + + Mov AX, CCCA ; Current address. + Call WriteDataChannel + + + Mov AX, VTFT + Mov EBX, 0FFFFh + Call WriteDataChannel + + Mov AX, CVCF + Call WriteDataChannel + + Mov AX, DCYSUSV + Mov BX, 7F7Fh + Call WriteDataChannel + + Mov AX, PTRX + Mov EBX, 40000000h ; 25% reverb + Or BH, [CS:VolumeTable+7] + Call WriteDataChannel + + Mov AX, CPF + Call WriteDataChannel + Jmp SetAWERegistersEnd + +SetAWERegisters2: + Test CL, 32 ; Frequency change? + JZ SetAWERegisters3 + + Call SetAWEFrequency + +SetAWERegisters3: + Test CL, 64 ; Volume change? + JZ SetAWERegisters4 + + Call SetAWEVolume + +SetAWERegisters4: + Test CH, 80h ; New pan? + JZ SetAWERegistersEnd + + Call SetAWEPan + +SetAWERegistersEnd: + Pop CX + And Word Ptr [SI], 0111100010011111b + + Add SI, 128 + + Inc DX + Dec CX + JNZ SetAWERegisters1 + + Ret + +SetAWERegistersError: + Call StopAWENote + + Mov Word Ptr [SI], 0 + Test Byte Ptr [SI+3Ah], 80h + JNZ SetAWERegistersEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + + Jmp SetAWERegistersEnd + +EndP SetAWERegisters + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ACKIRQ + + Mov AL, 20h + Cmp CS:IRQ, 7 + JBE ACKIRQ1 + + Out 0A0h, AL + +ACKIRQ1: + Out 20h, AL + Ret + +EndP ACKIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Mov DX, MIDIPort + + Mov BL, [MIDIBufferTail] + Test DX, DX + JZ CheckMIDIEnd + + Inc DX + +CheckMIDIAgain: + In AL, DX + + Test AL, AL + JS CheckMIDIAgain + + Dec DX + In AL, DX + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDIIRQHandler + + Push AX BX DX + + Mov DX, CS:MixerPort + Mov AL, 82h + Out DX, AL + Inc DL + In AL, DX + + Test AL, 4 + JZ MIDIIRQHandlerEnd + + Call CheckMIDI + +MIDIIRQHandlerEnd: + Call AckIRQ + + Pop DX BX AX + IRet + + +EndP MIDIIRQHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIRQHandler + + PushAD + Push DS + Push ES + + StI + + Push CS + Pop DS + Assume DS:Driver + + FNSave [FPSave] + +SBIRQHandlerAgain: + Mov DX, MixerPort + Mov AL, 82h + Out DX, AL + Inc DL + In AL, DX + + Test AL, 4 + JZ NoMIDIIRQ + + Push AX + Call CheckMIDI + Pop AX + +NoMIDIIRQ: +; Test AL, 2 +; JZ No16BitIRQ +; +; Push AX +; Mov DX, MixerPort +; Add DL, 0Fh-4 +; In AL, DX +; Pop AX +; +; No16BitIRQ: + Test AL, 1 + JNZ SB8BitIRQ + +SBNo8BitIRQ: + Call AckIRQ + Jmp SBEndIRQ + +SB8BitIRQ: + Mov DX, MixerPort + Add DL, 0Eh-4 + In AL, DX ; 8-bit IRQ ack. + + +; Add DL, 0Ch-0Eh + +; Mov AL, 80h ; Output block of silence +; Call SBOut +; Mov AX, BlockLength2 +; Call SBOut +; Mov AL, AH +; Call SBOut + + ClD + Call ACKIRQ + + Inc IRQFlag + JNZ SBEndIRQ + + Call SaveEMSPageFrame + Assume DS:Nothing + +SB8BitIRQAgain: + Call Update ; Returns DS:SI, CX + + Mov BX, BlockLength + Cmp BX, BlockLength2 + JE SBIRQHandler2 + Mov BlockLength2, BX + + Mov DX, SB16BasePort + Add DL, 0Ch + + MOv AL, 0DAh + Call SBOut + Mov AL, 0C6h + Call SBOut + Xor AL, AL + Call SBOut + Mov AL, BL + Call SBOut + Mov AL, BH + Call SBOut + +; Mov AL, 0D0h +; Call SBOut + +; Mov AL, 80h ; Output block of silence +; Call SBOut +; Mov AL, BL +; Call SBOut +; Mov AL, BH +; Call SBOut + +SBIRQHandler2: + Call SetAWERegisters + Sub CS:IRQFlag, 1 + JNC SB8BitIRQAgain + + Call RestoreEMSPageFrame + +SBEndIRQ: + FRstor [CS:FPSave] + + Pop ES + Pop DS + PopAD + + IRet + +EndP SBIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AWEIRQHandler ; IRQ Handler has to + ; 1) Update AWE registers + ; 2) Update song position + Push AX + Push DS + + Mov AX, AWEUpdateTimer + Add AWEUpdateCount, AX + JC AWEIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp AWEIRQHandler2 + +AWEIRQHandler1: + PushF + Call [OldIRQHandler] + +AWEIRQHandler2: + Xor AWEUpdateFlag, 1 + JZ AWEIRQHandlerEnd + + FNSave [CS:FPSave] + + PushAD + Push ES + + ClD + + Call SaveEMSPageFrame + Call Update ; Returns DS:SI, CX + Call SetAWERegisters + Call RestoreEMSPageFrame + + Pop ES + PopAD + + FRstor [CS:FPSave] + +AWEIRQHandlerEnd: + Pop DS + Pop AX + IRet + +EndP AWEIRQHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EnableRAM + + Mov DX, BasePort + Mov CX, 29 + +EnableRAM1: + Mov AX, DCYSUSV + Or AX, CX + Mov BX, 80h + Call WriteData + + Mov AX, VTFT + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CVCF + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, PTRX + Or AX, CX + Mov EBX, 40000000h + Call WriteData + + Mov AX, CPF + Or AX, CX + Mov EBX, 40000000h + Call WriteData + + Mov AX, PSST + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CSL + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CCCA + Or AX, CX + Mov EBX, 6000000h ; Left write + Call WriteData + + Dec CX + JNS EnableRAM1 + + Ret + +EndP EnableRAM + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TestAWE ; Given DX = baseport. + + Push DX + + Add DX, 802h + In AL, DX + In AL, DX + Not AL + Mov BL, AL + Out DX, AL + In AL, DX + Cmp AL, BL + JNE TestAWE1 ; Register changed + + In AX, DX ; Is upper part of pointer + Mov BX, AX ; changing? + Mov CX, 128 + +TestAWE2: + In AX, DX + Cmp AL, BL + JNE TestAWE1 + Cmp AH, BH + JNE TestAWE3 + + Dec CX + JNZ TestAWE2 + Jmp TestAWE1 + +TestAWE3: + Pop DX + + ClC + Ret + +TestAWE1: + Pop DX + StC + Ret + +EndP TestAWE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSetAWE + + Mov CX, 31 + +InitSetAWE1: + Mov AX, 31 + Sub AX, CX + Mov BX, [SI] + Or AX, INIT1 + Call WriteData + + Add SI, 2 + + Dec CX + JNS InitSetAWE1 + + Mov CX, 31 + +InitSetAWE2: + Mov AX, 31 + Sub AX, CX + Mov BX, [SI] + Or AX, INIT2 + Call WriteData + + Add SI, 2 + + Dec CX + JNS InitSetAWE2 + + Mov CX, 31 + +InitSetAWE3: + Mov AX, 31 + Sub AX, CX + Mov BX, [SI] + Or AX, INIT3 + Call WriteData + + Add SI, 2 + + Dec CX + JNS InitSetAWE3 + + Mov CX, 31 + +InitSetAWE4: + Mov AX, 31 + Sub AX, CX + Mov BX, [SI] + Or AX, INIT4 + Call WriteData + + Add SI, 2 + + Dec CX + JNS InitSetAWE4 + + Ret + +EndP InitSetAWE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitAWE + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + + Mov AX, HWCF1 + Mov BX, 59h + Call WriteData + + Mov AX, CFG2 + Mov BX, 20h + Call WriteData + + Mov CX, 31 + +InitAwe1: + Mov BX, 80h + Mov AX, DCYSUSV + Or AX, CX + Call WriteData + + Xor EBX, EBX + Mov AX, ENVVOL + Or AX, CX + Call WriteData + + Mov AX, ENVVAL + Or AX, CX + Call WriteData + + Mov AX, SUSDCY + Or AX, CX + Call WriteData + + Mov AX, ATKHLDV + Or AX, CX + Call WriteData + + Mov AX, LFO1VAL + Or AX, CX + Call WriteData + + Mov AX, HLDATK + Or AX, CX + Call WriteData + + Mov AX, LFO2VAL + Or AX, CX + Call WriteData + + Mov AX, IP + Or AX, CX + Call WriteData + + Mov AX, IFATN + Or AX, CX + Call WriteData + + Mov AX, PEFE + Or AX, CX + Call WriteData + + Mov AX, FMMOD + Or AX, CX + Call WriteData + + Mov AX, TREMFRQ + Or AX, CX + Call WriteData + + Mov AX, FM2FRQ2 + Or AX, CX + Call WriteData + + Mov AX, PTRX + Or AX, CX + Call WriteData + + Mov AX, VTFT + Or AX, CX + Call WriteData + + Mov AX, PSST + Or AX, CX + Call WriteData + + Mov AX, CSL + Or AX, CX + Call WriteData + + Mov AX, CCCA + Or AX, CX + Call WriteData + + Dec CX + JNS InitAWE1 + + Mov CX, 31 + +InitAWE8: + Mov AX, CPF + Or AX, CX + Call WriteData + + Mov AX, CVCF + Or AX, CX + Call WriteData + + Dec CX + JNS InitAWE8 + ; Initialise still... + Mov AX, SMALR + Call WriteData + + Mov AX, SMARR + Call WriteData + + Mov AX, SMALW + Call WriteData + + Mov AX, SMARW + Call WriteData + + Mov SI, Offset InitTable1 + Call InitSetAWE + + ; Wait for 1024 sample periods + Mov AX, WC + Call ReadData + + Mov BX, AX + Mov CX, AX + Add CX, 400h ; 1024 + Cmp BX, CX + JB InitAWE3 + +InitAWE4: + Mov AX, WC + Call ReadData + Cmp AX, CX + JA InitAWE4 + +InitAWE3: + Mov AX, WC + Call ReadData + Cmp AX, CX + JB InitAWE3 + + Mov SI, Offset InitTable2 + Call InitSetAWE + + Mov SI, Offset InitTable3 + Call InitSetAWE + + Mov AX, HWCF4 + Xor EBX, EBX + Call WriteData + + Mov AX, HWCF5 + Mov EBX, 83h + Call WriteData + + Mov AX, HWCF6 + Mov EBX, 8000h + Call WriteData + + Mov SI, Offset InitTable4 + Call InitSetAWE + + Mov AX, HWCF3 + Mov BX, 4 + Call WriteData + + Ret + +EndP InitAWE + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitDRAMRefresh + + Mov AX, DCYSUSV+1Eh + Mov BX, 80h + Call WriteData + + Mov AX, DCYSUSV+1Fh + Call WriteData + +; + + Mov AX, VTFT+1Eh + Xor EBX, EBX + Call WriteData + + Mov AX, CVCF+1Eh + Call WriteData + + Mov AX, VTFT+1Fh + Call WriteData + + Mov AX, CVCF+1Fh + Call WriteData + +; + + Mov AX, PTRX+1Eh + Call WriteData + + Mov AX, CPF+1Eh + Call WriteData + + Mov AX, PTRX+1Fh + Call WriteData + + Mov AX, CPF+1Fh + Call WriteData + +; + + Mov AX, PSST+1Eh + Call WriteData + Mov AX, PSST+1Fh + Call WriteData + + Mov BX, 0FFFFh + Mov AX, CSL+1Eh + Call WriteData + Mov AX, CSL+1Fh + Call WriteData + + Xor BX, BX + Mov AX, CCCA+1Eh + Call WriteData + Mov AX, CCCA+1Fh + Call WriteData + + Ret + +EndP InitDRAMRefresh + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + + ShR AL, 7 + LoopZ SBIn + +; Test AL, AL +; JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov DX, BasePort + Cmp DX, 0FFFFh + JE DetectCard1 + + Cmp DX, 620h + JB DetectCard3 + Cmp DX, 680h + JA DetectCard3 + + Call TestAWE + JNC DetectCardFound + Ret + +DetectCard1: + Mov DX, 620h + +DetectCard2: + Call TestAWE + JNC DetectCardFound + + Add DL, 20h + Cmp DL, 80h + JBE DetectCard2 + +DetectCard3: + StC + Ret + +DetectCardFound: + Mov BasePort, DX + + ; Initialise AWE 32 + Call InitAWE + Call InitDRAMRefresh + + ; Detect amount of RAM. + + Mov DX, BasePort + Mov CX, 29 + +DetectCardMemory1: + Mov AX, DCYSUSV + Or AX, CX + Mov BX, 80h + Call WriteData + + Mov AX, VTFT + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CVCF + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, PTRX + Or AX, CX + Mov EBX, 40000000h + Call WriteData + + Mov AX, CPF + Or AX, CX + Mov EBX, 40000000h + Call WriteData + + Mov AX, PSST + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CSL + Or AX, CX + Xor EBX, EBX + Call WriteData + + Mov AX, CCCA + Or AX, CX + Mov EBX, 4000000h ; Left read + + Test CL, 2 + JZ DetectCardMemory2 + + Mov EBX, 6000000h ; Left write + +DetectCardMemory2: + Call WriteData + + Dec CX + JNS DetectCardMemory1 + + Xor EDI, EDI ; Amount of memory stored in + ; EDI + + Mov AX, SMALW + Mov EBX, 200000h + Call WriteData + + Mov AX, SMLD + Mov BX, 0FFFFh + Call WriteData + + Mov AX, SMLD + Mov BX, 5555h + Call WriteData + + Mov AX, SMLD + Mov BX, 0AAAAh + Call WriteData + + Mov AX, SMALR + Mov EBX, 200000h + Call WriteData + + Mov AX, SMLD + Call ReadData + + Mov AX, SMLD + Call ReadData + Cmp AX, 0FFFFh + JNE DetectCardMemory6 + + Mov AX, SMLD + Call ReadData + Cmp AX, 5555h + JNE DetectCardMemory6 + + Mov AX, SMLD + Call ReadData + Cmp AX, 0AAAAh + JNE DetectCardMemory6 + + Mov EDI, 20000h + +DetectCardMemory3: ; Set read/write addresses.. + Mov AX, SMALW + Mov EBX, EDI + Add EBX, 200000h + Call WriteData + + Mov AX, SMLD + Mov BX, 5555h + Call WriteData + + Mov AX, SMLD + Mov BX, 0AAAAh + Call WriteData + + Mov AX, SMALR + Mov EBX, 200000h + Call WriteData + + Mov AX, SMLD + Call ReadData + + Mov AX, SMLD + Call ReadData + Cmp AX, 0FFFFh + JNE DetectCardMemory5 + + Mov AX, SMALR + Mov EBX, EDI + Add EBX, 200000h + Call WriteData + + Mov AX, SMLD + Call ReadData + + Mov AX, SMLD + Call ReadData + Cmp AX, 5555h + JNE DetectCardMemory5 + + Mov AX, SMLD + Call ReadData + Cmp AX, 0AAAAh + JNE DetectCardMemory5 + +DetectCardMemory4: + Add EDI, 20000h + Cmp EDI, 0E00000h + JB DetectCardMemory3 + +DetectCardMemory5: + Cmp EDI, 0DFFFE0h + JB DetectCardMemory7 + + Mov EDI, 0DFFFE0h + +DetectCardMemory7: + Test EDI, EDI + JZ DetectCardMemory6 + + Mov AWEMemory, EDI + + Mov MixerPort, 210h + Mov AX, BasePort + Sub AX, 400h + Call ResetDSP + JNC DetectMixer2 + +DetectMixer1: + Mov AX, MixerPort + Call ResetDSP + JNC DetectMixer2 + +DetectMixer3: + Add MixerPort, 10h + Cmp MixerPort, 280h + JBE DetectMixer1 + + Mov DX, BasePort + Sub DX, 400h + Mov MixerPort, DX + + Jmp DetectCard4 + +DetectMixer2: ; OK... DSP found. + ; Get DSP version + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + + Mov CX, 200 + +DetectMixerLoop1: + In AL, DX +; Test AL, AL +; JS DetectMixerLoop1 + ShR AL, 7 + LoopNZ DetectMixerLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AX, 40Ch ; SB DSP = 4.12+ + JB DetectMixer3 + + Sub DL, 0Eh + Mov MixerPort, DX + +DetectCard4: + Mov SB16BasePort, DX + Add MixerPort, 4 ; Mixerport + + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Mov DX, MixerPort + Mov AX, 0F834h + Out DX, AX + + Mov AL, 35h + Out DX, AX + + Mov DX, MixerPort + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + Jmp NoWindows + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: + Mov AL, 81h + Out DX, AL + Inc DX + In AL, DX + Dec DX + + And AL, 11 + Xor BX, BX + Cmp AL, 1 + JE DetectCardDMA + + Inc BX + Cmp AL, 2 + JE DetectCardDMA + + Inc BX + Inc BX + Cmp AL, 8 + JNE NoWindows + +DetectCardDMA: + Mov DMA, BX + +DetectCardWindows: + Mov AX, 1600h ; Windows detection. + Int 2Fh + Test AL, 7Fh + JZ NoWindows + + Mov SBIRQMode, 1 + +NoWindows: + Mov EAX, 'Jeff' + ClC + Ret + +DetectCardMemory6: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSamplingRate + Assume DS:Driver + + PushA + Push ES + + Mov AX, SB16BasePort + Call ResetDSP + +; Set dma + Mov BX, DMABuffer + Xor AX, AX + Mov DX, DMA + Mov DI, 512 + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, 256 + Rep StosW + + Mov DX, SB16BasePort + Add DL, 0Ch + +; Mov AL, 0D3h ; Turn off speaker +; Call SBOut + ; Set mixing frequency + Mov AL, 40h + Call SBOut + Mov AL, 0EAh + Call SBOut ; 45454Hz +; Mov AL, 211 +; Call SBOut ; 22222 Hz. + + Mov AL, 0C6h + Call SBOut + Xor AL, AL + Call SBOut + Mov AX, BlockLength + Dec AX + Call SBOut + Mov AL, AH + Call SBOut + + Pop ES + PopA + Ret + +EndP SetSamplingRate + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMIDIIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset MIDIIRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetMIDIIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + Assume DS:Driver + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SBIRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitMIDI + Assume DS:Driver + + Mov DX, 330h + Call DetectUART + JC DetectMIDI1 + + Mov MIDIPort, 330h + Jmp DetectMIDIEnd + +DetectMIDI1: + Mov DX, 300h + Call DetectUART + JC DetectMIDIEnd + + Mov MIDIPort, 300h + +DetectMIDIEnd: + Ret + +EndP InitMIDI + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +FControlWord DW 0 + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + FNInit ; Initialise floating point + FNSTCW FControlWord + And FControlWord, 0F0FFh + FLDCW FControlWord + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov AX, CS + Mov DriverSegment1, AX + Mov DriverSegment2, AX + Mov DriverSegment3, AX + Mov DriverSegment4, AX + Mov DriverSegment5, AX + Mov DriverSegment6, AX + Mov DriverSegment7, AX + Mov DriverSegment8, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Cmp SBIRQMode, 0 + JE InitSound1 + + Cmp DMABuffer, 0 + JNE InitSound3 + + Mov AH, 48h + Mov BX, 1024/16 + Int 21h + JNC InitSound4 + + Mov SBIRQMode, 0 + Jmp InitSound1 + +InitSound4: + Mov DMABuffer, AX + +InitSound3: + Call SetIRQ + Call GetTempo + Call SetTempo + Call ResetMemory + Call SetSamplingRate + + Call InitMIDI + + Mov SI, Offset AWE32Msg2 + Mov AX, BasePort + + Mov BX, IRQ + Mov CX, DMA + + Ret + +InitSound1: + Call SetMIDIIRQ + Call GetTempo + Call SetTempo + Call ResetMemory + + Xor AX, AX + Mov ES, AX ; ES = 0 + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset AWEIRQHandler + + ClI + + XChg DWord Ptr [ES:20h], EAX ; Clock tick + Mov OldIRQHandler, EAX + + StI + +InitSound2: + Call InitMIDI + + Mov SI, Offset AWE32Msg + Mov AX, BasePort + + Mov EBX, AWEMemory + SHR EBX, 9 + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset AWE32ReinitMsg + Mov BX, 40 + Call SetInfoLine + + Call ResetUART + Call InitAWE + Call InitDRAMRefresh + + Cmp SBIRQMode, 0 + JE ReInitSound1 + + Call ResetIRQ + Call SetIRQ + Call SetSamplingRate + Call ReinitUART + Ret + +ReInitSound1: + Xor AX, AX + Mov ES, AX ; ES = 0 + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset AWEIRQHandler + + Mov DWord Ptr [ES:20h], EAX ; Clock tick + + Call ResetIRQ + Call SetMIDIIRQ + Call ReinitUART + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset Chorus + Int 21h + +SaveConfig1: + PushF + Mov AH, 3Eh + Int 21h + PopF + +SaveConfig2: + Call ResetIRQ + + Cmp SBIRQMode, 0 + JE UnInitSound1 + + Mov DX, SB16BasePort + Add DL, 0Ch + + Call ResetUART + + Mov AX, SB16BasePort + Call ResetDSP + + Call InitAWE + + Push ES + Mov AH, 49h + Mov ES, DMABuffer + Int 21h + Pop ES + + Ret + +UnInitSound1: + Mov AL, 34h + Out 43h, AL + + Xor AX, AX + Out 40h, AL + Out 40h, AL + + Mov ES, AX + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + + Mov AX, SB16BasePort + Call ResetDSP + Call ResetUART + Call InitAWE + Call ResetIRQ + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Cmp CS:SBIRQMode, 0 + JE SetTempo1 + ; BlockLength = 55555/BPM + ; BlockLength = 45454*5/2 + ; = 113635 + Mov AX, 48099 + Mov DX, 1 + + Div BX + Dec AX + Dec AX + Mov CS:BlockLength, AX + +; Mov DX, SB16BasePort +; Add DL, 0Ch + + Jmp SetTempo2 + +SetTempo1: + ; Frames per second = 2 * (0.4*Tempo) + Mov AX, 0C214h + Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo + Div BX + + ; AX contains counter. + Mov CS:AWEUpdateTimer, AX + + Out 40h, AL ; Timer IRQ. + Mov AL, AH + Out 40h, AL + +SetTempo2: + Pop DX + Pop BX + Pop AX + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + ; if no sample, then do nothing + ; MemoryUsed = length of sample + ; if sustain loop, then use sustain + ; loop information + ; if no sustain loop, then use loop + ; information + ; if no loop or sustain loop, + ; memoryused += 16; (16 zero samples + ; at the end) + ; + PushAD + Push DS + Push ES + Push FS + + Push AX + + ClI + + Call EnableRAM ; Enable access to DRAM. + + ; Set destination address + Mov AX, SMALW + Mov EBX, CS:AWEMemoryUsed + Add EBX, 200000h + Call WriteData + + Mov DX, CS:BasePort + Add DX, 802h ; Index + Mov AX, 32+26 + Out DX, AX + + Pop AX + + Mov FS, CS:SongDataArea + LEA DI, [EAX*4+EAX] + ShL DI, 2 + Add DI, Offset AWEDataTable-20 + + Mov ECX, -1 + + Mov DWord Ptr [CS:DI], ECX ; Start + Mov DWord Ptr [CS:DI+4], ECX ; Loop start + Mov DWord Ptr [CS:DI+8], ECX ; Loop end + Mov DWord Ptr [CS:DI+12], ECX ; Size occupied + Mov DWord Ptr [CS:DI+16], ECX ; Size occupied + + Mov BP, AX + Add BP, BP + Mov BP, [FS:64910+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC LoadSampleNoError + + JZ LoadSample1 + + ; 16 bit + + Mov CS:LoadSampleFuncF, Offset Load16BitSamplesForwards + Mov CS:LoadSampleFuncB, Offset Load16BitSamplesBackwards + + Jmp LoadSample2 + +LoadSample1: ; 8 bit + Mov CS:LoadSampleFuncF, Offset Load8BitSamplesForwards + Mov CS:LoadSampleFuncB, Offset Load8BitSamplesBackwards + +LoadSample2: + Mov AL, [FS:BP+12h] + Test AL, 30h ; Loop or sustain loop? + JZ LoadSampleNoLoop + + Mov EBX, [FS:BP+34h] ; Loop begin + Mov EDX, [FS:BP+38h] ; Loop end + Test AL, 20h ; Sustain loop? + JZ LoadSample3 + + ShR AL, 1 + Mov EBX, [FS:BP+40h] + Mov EDX, [FS:BP+44h] + Jmp LoadSample3 + +LoadSampleError: + ClC + Jmp LoadSampleEnd + +LoadSampleNoError: + StC + +LoadSampleEnd: + StI + Pop FS + Pop ES + Pop DS + PopAD + + Ret + +LoadSampleNoLoop: ; ECX contains length of sample + Mov EAX, ECX + Mov EDX, AWEMemoryUsed + Mov EBX, AWEMemory + Sub EBX, EDX ; EBX = AWEMemory remaining + + Mov CL, Compress + ShR EAX, CL ; Compress sample + Add EAX, 16 ; zeroes at end of sample + + Cmp EAX, EBX + JA LoadSampleError + + Mov ECX, EAX + Add AWEMemoryUsed, EAX ; Record memory as used + Mov [CS:DI+12], EAX + + Add EDX, 200000h + + Sub ECX, 16 ; Number of samples to transfer + Mov [CS:DI], EDX + Add EDX, ECX + Mov [CS:DI+4], EDX ; Loop start + Add EDX, 14 + Mov [CS:DI+8], EDX ; Loop end + + ; Now to transfer samples to AWE32 + Call [CS:LoadSampleFuncF] + ; Now to shove a whole lot of zeroes + Xor AX, AX + Mov CX, 16 + +LoadSampleNoLoop2: + Out DX, AX + Loop LoadsampleNoLoop2 + + Jmp LoadSampleNoError + +LoadSample3: ; OK... EBX = loop start + ; EDX = loop end + ; AL&40h = ping pong + Test AL, 40h + JNZ LoadSamplePingPong + + Mov CL, Compress + + Push EBX + + ShR EDX, CL + ShR EBX, CL + Mov EAX, EDX + Add EAX, 2 ; For loop fixing + + Mov ECX, AWEMemory + Sub ECX, AWEMemoryUsed ; ECX = AWEMemoryRemaining + + Cmp EAX, ECX + Pop ECX + JA LoadSampleError ; Sufficient memory? + Push ECX + + Mov ECX, EAX + Mov EAX, AWEMemoryUsed + Add AWEMemoryUsed, ECX + Mov [CS:DI+12], ECX + + Sub ECX, 2 + + Add EAX, 200000h + Mov [CS:DI], EAX + + Add EDX, EAX + Add EAX, EBX + + Mov [CS:DI+4], EAX + Mov [CS:DI+8], EDX + + Call [CS:LoadSampleFuncF] + ; Now to fix loop.. 1 extra + ; sample. + + Pop ESI ; Loop start + Test Byte Ptr [FS:BP+12h], 2 + JZ LoadSampleForwards1 + + Add ESI, ESI + +LoadSampleForwards1: + Int 3 + + Mov ECX, 2 + Call [CS:LoadSampleFuncF] + + Jmp LoadSampleNoError + +LoadSamplePingPong: + Mov CL, Compress + ShR EDX, CL + ShR EBX, CL + + Mov EAX, EDX + Add EAX, EDX + Sub EAX, EBX + Inc EAX + + Mov ECX, AWEMemory + Sub ECX, AWEMemoryUsed + + Cmp EAX, ECX + JA LoadSampleError + + Mov [CS:DI+12], EAX + Mov ECX, AWEMemoryUsed + Add AWEMemoryUsed, EAX + + Add ECX, 200000h + Add EAX, ECX + Dec EAX + + Mov [CS:DI], ECX + Add ECX, EBX + Mov [CS:DI+4], ECX + Mov [CS:DI+8], EAX + + Mov EAX, [CS:DI] + Add EAX, EDX + Mov [CS:DI+16], EAX + + Mov ECX, EDX + Sub EDX, EBX + Push EDX + + Call [CS:LoadSampleFuncF] + + Pop ECX + Inc ECX + + Call [CS:LoadSampleFuncB] + + Jmp LoadSampleNoError + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + PushAD + + LEA DI, [EAX*4+EAX] ; DI = AX * 5 + ShL DI, 2 + Add DI, Offset AWEDataTable + + Mov EBX, [CS:DI+12] + Mov EAX, CS:AWEMemoryUsed + Sub EAX, EBX + Add EAX, 200000h + Cmp EAX, [CS:DI] + JNE ReleaseSample1 + + Sub AWEMemoryUsed, EBX +ReleaseSample1: + Mov EAX, -1 + Mov [CS:DI], EAX + Mov [CS:DI+4], EAX + Mov [CS:DI+8], EAX + Mov [CS:DI+12], EAX + + PopAD + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Push CS + Pop ES + + Xor EAX, EAX + Mov CS:AWEMemoryUsed, EAX + + Mov DI, Offset AWEDataTable + Mov CX, 1000 + Mov AX, 0FFFFh + Rep StosW + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset AWE32Status + + Mov EAX, AWEMemory + Sub EAX, AWEMemoryUsed + SHR EAX, 9 + + ClC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset GUSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, MixerPort + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 30 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 30 +DriverFlags DW 1 ; MIDI Out supported + + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + + DW Offset SendUARTOut ; For MIDI Out + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/BASE1.ASM b/SoundDrivers/BASE1.ASM index 01ff0a5..5b1ac47 100755 --- a/SoundDrivers/BASE1.ASM +++ b/SoundDrivers/BASE1.ASM @@ -1,2070 +1,2070 @@ -; -; Analog Device's AD1816 -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 1114B250h - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -DMASize DW DMABUFFERLENGTH/2 - -ESSMsg DB "SoundSystem Base 1 found", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "SoundSystem Base 1 found", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "SoundSystem Base 1 reinitialised", 0 - -DriverName DB "ITBASE1.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -ESSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldESSIRQHandler DD 0 - -MIDIIRQ DW 0 -MIDIPort DW 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -ESSScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr ESSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - DW Near Ptr PhatStereo ; 18 - - DW 0 - -ESSHeaderLine DW 10 - DB "SoundSystem Base 1 Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 29, 48 - DB 21h - DB "SoundSystem Base 1 Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB "3D Phat Stereo", 13 - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 39, 17 - DB 25 - -PhatStereo DW 14 - DB 22, 16 - DW 0, 15 - DW 9, 2 - DW 17, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 16 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 16 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 18, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 16 - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 44100 - -MixModeButton1 DW 2 - DW 18, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 56, 56, 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dmasirq.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816Wait - - PushA - Xor CX, CX - Mov DX, CS:BasePort - -AD1816Wait1: - In AL, DX - Test AL, 80h - LoopZ AD1816Wait1 - - PopA - Ret - -EndP AD1816Wait - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816RegisterOut ; AL = indirect register, BX = contents - - Call AD1816Wait - - Push DX - PushF - - ClI - - Mov DX, CS:BasePort - Out DX, AL - Add DL, 2 - - Mov AL, BL - Out DX, AL - Inc DX - Mov AL, BH - Out DX, AL - - PopF - Pop DX - - Ret - -EndP AD1816RegisterOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816RegisterIn ; AL = register - ; Returns BX - - Call AD1816Wait - - Push AX - Push DX - - Mov DX, CS:BasePort - Out DX, AL - Add DL, 2 - - In AL, DX - Mov BL, AL - Inc DX - In AL, DX - Mov BH, AL - - Pop DX - Pop AX - - Ret - -EndP AD1816RegisterIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - - Mov AX, 1 - Ret - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - Mov AX, 007h - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov AX, 107h ; LDN 1 - MIDI device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Mov MIDIPort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - Mov MIDIIRQ, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - - Inc DX - In AL, DX - Mov AH, AL - Xor AL, AL - Out DX, AL - - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB ESSIRQHandler6 - JE ESSIRQHFilter - - Cmp CS:Stereo, 0 - JE ESSIRQ3QFilterMono - -ESSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -ESSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -ESSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -ESSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilter: - Cmp CS:Stereo, 0 - JE ESSIRQHFilterMono - -ESSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -ESSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -ESSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -ESSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL ESSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG ESSIRQHandlerClip2 - -ESSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ ESSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -ESSIRQHandlerClip1: - Mov AX, 8000h - Jmp ESSIRQHandler7 - -ESSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp ESSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo3 - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopAD1816 - - PushA - - Mov AL, 1 - Call AD1816RegisterIn - And BX, 07FFFh ; Disable PIE - Call AD1816RegisterOut - - Mov DX, CS:BasePort - Inc DX - In AL, DX - And AL, Not 80h - Out DX, AL - - Add DL, 7 - In AL, DX - And AL, Not 1 - Out DX, AL - - PopA - Ret - -EndP StopAD1816 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartAD1816 - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov AL, 4 - Call AD1816RegisterIn - - Mov AL, 32 - Call AD1816RegisterIn - Or BX, 08000h - Call AD1816RegisterOut - - Mov AL, 2 ; Sample rate - Mov BX, MixSpeed - Call AD1816RegisterOut - - Mov AL, 8 ; DMA Size - Mov BX, DMASize - ShR BX, 2 - Dec BX - Call AD1816RegisterOut - - Mov DX, BasePort ; Wave Format - Add DL, 8 - - Mov AL, 00010001b - Cmp Stereo, 0 - JE StartAD1816A - - Or AL, 4 - -StartAD1816A: - Out DX, AL - - Mov AL, 1 ; Enable Playback interrupt - Call AD1816RegisterIn - Or BX, 8000h - Call AD1816RegisterOut - - Pop DS - Pop ES - PopA - - Ret - -EndP StartAD1816 - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, CmdLineMixSpeed - Mov AX, 44100 - - Test DX, DX - JZ ClipMixSpeed2 - - Mov AX, DX - Cmp AX, 11050 - JA ClipMixSpeed1 - - Mov AX, 11050 - -ClipMixSpeed1: - Cmp AX, 55200 - JB ClipMixSpeed2 - - Mov AX, 55200 - -ClipMixSpeed2: - Mov MixSpeed, AX - Mov DX, 2643 - Mul DX - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Call UpdateSoundcardVariables - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Push AX - - Call StopAD1816 - Call ResetIRQ - - Pop ES - Mov AH, 49h ; Release MixSegment - Int 21h - - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopAD1816 - Call StartAD1816 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - Mov AL, 4 - Mov BX, 3F3Fh - Sub BX, [Word Ptr CS:VolumeTable] - Call AD1816RegisterOut - - Mov AL, 39 - Call AD1816RegisterIn - Mov CL, [CS:VolumeTable+2] - And BX, 0110000111111111b - ShL CX, 9 - Or BX, CX - Call AD1816RegisterOut - - Mov AL, 14 - Xor BX, BX - Call AD1816RegisterOut - - Ret - -EndP UpdateSoundcardVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - Call UpdateSoundcardVariables - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Analog Device's AD1816 +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 1114B250h + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +DMASize DW DMABUFFERLENGTH/2 + +ESSMsg DB "SoundSystem Base 1 found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "SoundSystem Base 1 found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "SoundSystem Base 1 reinitialised", 0 + +DriverName DB "ITBASE1.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +ESSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +MIDIIRQ DW 0 +MIDIPort DW 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + DW Near Ptr PhatStereo ; 18 + + DW 0 + +ESSHeaderLine DW 10 + DB "SoundSystem Base 1 Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 29, 48 + DB 21h + DB "SoundSystem Base 1 Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB "3D Phat Stereo", 13 + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 39, 17 + DB 25 + +PhatStereo DW 14 + DB 22, 16 + DW 0, 15 + DW 9, 2 + DW 17, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 16 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 16 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 18, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 16 + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + +MixModeButton1 DW 2 + DW 18, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 56, 56, 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dmasirq.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816Wait + + PushA + Xor CX, CX + Mov DX, CS:BasePort + +AD1816Wait1: + In AL, DX + Test AL, 80h + LoopZ AD1816Wait1 + + PopA + Ret + +EndP AD1816Wait + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816RegisterOut ; AL = indirect register, BX = contents + + Call AD1816Wait + + Push DX + PushF + + ClI + + Mov DX, CS:BasePort + Out DX, AL + Add DL, 2 + + Mov AL, BL + Out DX, AL + Inc DX + Mov AL, BH + Out DX, AL + + PopF + Pop DX + + Ret + +EndP AD1816RegisterOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816RegisterIn ; AL = register + ; Returns BX + + Call AD1816Wait + + Push AX + Push DX + + Mov DX, CS:BasePort + Out DX, AL + Add DL, 2 + + In AL, DX + Mov BL, AL + Inc DX + In AL, DX + Mov BH, AL + + Pop DX + Pop AX + + Ret + +EndP AD1816RegisterIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + + Mov AX, 1 + Ret + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + Mov AX, 007h + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov AX, 107h ; LDN 1 - MIDI device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Mov MIDIPort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + Mov MIDIIRQ, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + + Inc DX + In AL, DX + Mov AH, AL + Xor AL, AL + Out DX, AL + + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB ESSIRQHandler6 + JE ESSIRQHFilter + + Cmp CS:Stereo, 0 + JE ESSIRQ3QFilterMono + +ESSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +ESSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +ESSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +ESSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilter: + Cmp CS:Stereo, 0 + JE ESSIRQHFilterMono + +ESSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +ESSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +ESSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +ESSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL ESSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG ESSIRQHandlerClip2 + +ESSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ ESSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +ESSIRQHandlerClip1: + Mov AX, 8000h + Jmp ESSIRQHandler7 + +ESSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp ESSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo3 + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopAD1816 + + PushA + + Mov AL, 1 + Call AD1816RegisterIn + And BX, 07FFFh ; Disable PIE + Call AD1816RegisterOut + + Mov DX, CS:BasePort + Inc DX + In AL, DX + And AL, Not 80h + Out DX, AL + + Add DL, 7 + In AL, DX + And AL, Not 1 + Out DX, AL + + PopA + Ret + +EndP StopAD1816 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartAD1816 + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov AL, 4 + Call AD1816RegisterIn + + Mov AL, 32 + Call AD1816RegisterIn + Or BX, 08000h + Call AD1816RegisterOut + + Mov AL, 2 ; Sample rate + Mov BX, MixSpeed + Call AD1816RegisterOut + + Mov AL, 8 ; DMA Size + Mov BX, DMASize + ShR BX, 2 + Dec BX + Call AD1816RegisterOut + + Mov DX, BasePort ; Wave Format + Add DL, 8 + + Mov AL, 00010001b + Cmp Stereo, 0 + JE StartAD1816A + + Or AL, 4 + +StartAD1816A: + Out DX, AL + + Mov AL, 1 ; Enable Playback interrupt + Call AD1816RegisterIn + Or BX, 8000h + Call AD1816RegisterOut + + Pop DS + Pop ES + PopA + + Ret + +EndP StartAD1816 + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, CmdLineMixSpeed + Mov AX, 44100 + + Test DX, DX + JZ ClipMixSpeed2 + + Mov AX, DX + Cmp AX, 11050 + JA ClipMixSpeed1 + + Mov AX, 11050 + +ClipMixSpeed1: + Cmp AX, 55200 + JB ClipMixSpeed2 + + Mov AX, 55200 + +ClipMixSpeed2: + Mov MixSpeed, AX + Mov DX, 2643 + Mul DX + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Call UpdateSoundcardVariables + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Push AX + + Call StopAD1816 + Call ResetIRQ + + Pop ES + Mov AH, 49h ; Release MixSegment + Int 21h + + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopAD1816 + Call StartAD1816 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + Mov AL, 4 + Mov BX, 3F3Fh + Sub BX, [Word Ptr CS:VolumeTable] + Call AD1816RegisterOut + + Mov AL, 39 + Call AD1816RegisterIn + Mov CL, [CS:VolumeTable+2] + And BX, 0110000111111111b + ShL CX, 9 + Or BX, CX + Call AD1816RegisterOut + + Mov AL, 14 + Xor BX, BX + Call AD1816RegisterOut + + Ret + +EndP UpdateSoundcardVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + Call UpdateSoundcardVariables + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/DEBUG.INC b/SoundDrivers/DEBUG.INC index ef745d7..4606cd3 100755 --- a/SoundDrivers/DEBUG.INC +++ b/SoundDrivers/DEBUG.INC @@ -1,101 +1,101 @@ -; -; Debug macro. To write to the file, use "Trace " -; - -IF TRACEENABLED - -IF CREATENEWLOGFILE -FirstTime DB 0 -ENDIF - -LogFileName DB "Logfile.Txt", 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WriteDebugFile - - PushA - Push DS - - Push CS - Pop DS - - Mov DX, Offset LogFileName - -IF CREATENEWLOGFILE - - Cmp DS:FirstTime, 0 - JNE WriteDebugFile1 - - Mov AH, 3Ch - Xor CX, CX - Int 21h - JC WriteDebugFileEnd - - Mov DS:FirstTime, 1 - XChg AX, BX - Jmp WriteDebugFile2 - - WriteDebugFile1: - -ENDIF - Mov AX, 3D02h - Int 21h - JC WriteDebugFileEnd - - XChg AX, BX - - Mov AX, 4202h - Xor CX, CX - Xor DX, DX - Int 21h ; Move to end of file - -WriteDebugFile2: - Mov AH, 40h - Mov CX, 82 - Mov DX, SI - Int 21h - - Mov AH, 3Eh - Int 21h - -WriteDebugFileEnd: - Pop DS - PopA - Ret - -EndP WriteDebugFile - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Trace Macro LogMessage - Local X, Y - - PushF - Push SI - Jmp Y - X: - DB LogMessage - DB 80-($-Offset X) Dup (0) - DB 0Dh, 0Ah - Y: - Mov SI, Offset X - Call WriteDebugFile - Pop SI - PopF - - EndM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ELSE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Trace Macro LogMessage - EndM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ENDIF - +; +; Debug macro. To write to the file, use "Trace " +; + +IF TRACEENABLED + +IF CREATENEWLOGFILE +FirstTime DB 0 +ENDIF + +LogFileName DB "Logfile.Txt", 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WriteDebugFile + + PushA + Push DS + + Push CS + Pop DS + + Mov DX, Offset LogFileName + +IF CREATENEWLOGFILE + + Cmp DS:FirstTime, 0 + JNE WriteDebugFile1 + + Mov AH, 3Ch + Xor CX, CX + Int 21h + JC WriteDebugFileEnd + + Mov DS:FirstTime, 1 + XChg AX, BX + Jmp WriteDebugFile2 + + WriteDebugFile1: + +ENDIF + Mov AX, 3D02h + Int 21h + JC WriteDebugFileEnd + + XChg AX, BX + + Mov AX, 4202h + Xor CX, CX + Xor DX, DX + Int 21h ; Move to end of file + +WriteDebugFile2: + Mov AH, 40h + Mov CX, 82 + Mov DX, SI + Int 21h + + Mov AH, 3Eh + Int 21h + +WriteDebugFileEnd: + Pop DS + PopA + Ret + +EndP WriteDebugFile + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Trace Macro LogMessage + Local X, Y + + PushF + Push SI + Jmp Y + X: + DB LogMessage + DB 80-($-Offset X) Dup (0) + DB 0Dh, 0Ah + Y: + Mov SI, Offset X + Call WriteDebugFile + Pop SI + PopF + + EndM + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ELSE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Trace Macro LogMessage + EndM + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ENDIF + diff --git a/SoundDrivers/DMA.INC b/SoundDrivers/DMA.INC index c9f1fa9..f5c2ce2 100755 --- a/SoundDrivers/DMA.INC +++ b/SoundDrivers/DMA.INC @@ -1,113 +1,113 @@ - -DMAData Label Byte -; Port/Mask, Port/Clear, Port/DMAMode, Address, Page, Count, Port/Mask - DB 0Ah, 4, 0Ch, 0, 0Bh, 58h, 87h, 0, 1, 0Ah, 0 - DB 0Ah, 5, 0Ch, 0, 0Bh, 59h, 83h, 2, 3, 0Ah, 1 - DB 0Ah, 6, 0Ch, 0, 0Bh, 5Ah, 81h, 4, 5, 0Ah, 2 - DB 0Ah, 7, 0Ch, 0, 0Bh, 5Bh, 82h, 6, 7, 0Ah, 3 - DB 0D4h, 4, 0D8h, 0, 0D6h, 58h, 8Fh, 0C0h, 0C2h, 0D4h, 0 - DB 0D4h, 5, 0D8h, 0, 0D6h, 59h, 8Bh, 0C4h, 0C6h, 0D4h, 1 - DB 0D4h, 6, 0D8h, 0, 0D6h, 5Ah, 89h, 0C8h, 0CAh, 0D4h, 2 - DB 0D4h, 7, 0D8h, 0, 0D6h, 5Bh, 8Ah, 0CCh, 0CEh, 0D4h, 3 - -ActualDMAPtr Label DWord -ActualDMAOffset DW 0 -ActualDMASegment DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetDMA ; BX:AX points to DMA buffer - ; DL = DMA Channel - ; DI = DMA Size - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov ActualDMASegment, BX - Mov ActualDMAOffset, AX - - Mov CH, BH - ShR CH, 4 - ShL BX, 4 - Add BX, AX - AdC CH, 0 - Mov SI, BX ; CH:BH:BL contains 24 bit DMA address - Neg SI - Cmp SI, DI - JA SetDMA1 - - Add ActualDMAOffset, SI - Add BX, SI - AdC CH, 0 - -SetDMA1: - Cmp DL, 3 - JBE SetDMA2 - - ShR DI, 1 - Push CX - ShR CH, 1 - Pop CX - RCR BX, 1 - -SetDMA2: - Mov AL, 11 - Mul DL - Mov SI, AX - Add SI, Offset DMAData - - Xor DX, DX - - LodsB ; Set mask - Mov DL, AL - LodsB - Out DX, AL - - LodsB ; Clear Ptrs - Mov DL, AL - LodsB - Out DX, AL - - LodsB ; Set Mode - Mov DL, AL - LodsB - Out DX, AL - - LodsB - Mov DL, AL ; DL = page port - Mov AL, CH - Out DX, AL - - LodsB - Mov DL, AL ; DL = address port - Mov AL, BL - Out DX, AL - Mov AL, BH - Out DX, AL - - LodsB - Mov DL, AL ; DL = count port - Mov AX, DI - Dec AX - Out DX, AL - Mov AL, AH - Out DX, AL - - LodsB ; Reset mask - Mov DL, AL - LodsB - Out DX, AL - - Pop DS - PopA - - Ret - -EndP SetDMA - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +DMAData Label Byte +; Port/Mask, Port/Clear, Port/DMAMode, Address, Page, Count, Port/Mask + DB 0Ah, 4, 0Ch, 0, 0Bh, 58h, 87h, 0, 1, 0Ah, 0 + DB 0Ah, 5, 0Ch, 0, 0Bh, 59h, 83h, 2, 3, 0Ah, 1 + DB 0Ah, 6, 0Ch, 0, 0Bh, 5Ah, 81h, 4, 5, 0Ah, 2 + DB 0Ah, 7, 0Ch, 0, 0Bh, 5Bh, 82h, 6, 7, 0Ah, 3 + DB 0D4h, 4, 0D8h, 0, 0D6h, 58h, 8Fh, 0C0h, 0C2h, 0D4h, 0 + DB 0D4h, 5, 0D8h, 0, 0D6h, 59h, 8Bh, 0C4h, 0C6h, 0D4h, 1 + DB 0D4h, 6, 0D8h, 0, 0D6h, 5Ah, 89h, 0C8h, 0CAh, 0D4h, 2 + DB 0D4h, 7, 0D8h, 0, 0D6h, 5Bh, 8Ah, 0CCh, 0CEh, 0D4h, 3 + +ActualDMAPtr Label DWord +ActualDMAOffset DW 0 +ActualDMASegment DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetDMA ; BX:AX points to DMA buffer + ; DL = DMA Channel + ; DI = DMA Size + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov ActualDMASegment, BX + Mov ActualDMAOffset, AX + + Mov CH, BH + ShR CH, 4 + ShL BX, 4 + Add BX, AX + AdC CH, 0 + Mov SI, BX ; CH:BH:BL contains 24 bit DMA address + Neg SI + Cmp SI, DI + JA SetDMA1 + + Add ActualDMAOffset, SI + Add BX, SI + AdC CH, 0 + +SetDMA1: + Cmp DL, 3 + JBE SetDMA2 + + ShR DI, 1 + Push CX + ShR CH, 1 + Pop CX + RCR BX, 1 + +SetDMA2: + Mov AL, 11 + Mul DL + Mov SI, AX + Add SI, Offset DMAData + + Xor DX, DX + + LodsB ; Set mask + Mov DL, AL + LodsB + Out DX, AL + + LodsB ; Clear Ptrs + Mov DL, AL + LodsB + Out DX, AL + + LodsB ; Set Mode + Mov DL, AL + LodsB + Out DX, AL + + LodsB + Mov DL, AL ; DL = page port + Mov AL, CH + Out DX, AL + + LodsB + Mov DL, AL ; DL = address port + Mov AL, BL + Out DX, AL + Mov AL, BH + Out DX, AL + + LodsB + Mov DL, AL ; DL = count port + Mov AX, DI + Dec AX + Out DX, AL + Mov AL, AH + Out DX, AL + + LodsB ; Reset mask + Mov DL, AL + LodsB + Out DX, AL + + Pop DS + PopA + + Ret + +EndP SetDMA + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/DMANAI.INC b/SoundDrivers/DMANAI.INC index 31071d5..70afda4 100755 --- a/SoundDrivers/DMANAI.INC +++ b/SoundDrivers/DMANAI.INC @@ -1,113 +1,113 @@ - -DMAData Label Byte -; Port/Mask, Port/Clear, Port/DMAMode, Address, Page, Count, Port/Mask - DB 0Ah, 4, 0Ch, 0, 0Bh, 08h, 87h, 0, 1, 0Ah, 0 - DB 0Ah, 5, 0Ch, 0, 0Bh, 09h, 83h, 2, 3, 0Ah, 1 - DB 0Ah, 6, 0Ch, 0, 0Bh, 0Ah, 81h, 4, 5, 0Ah, 2 - DB 0Ah, 7, 0Ch, 0, 0Bh, 0Bh, 82h, 6, 7, 0Ah, 3 - DB 0D4h, 4, 0D8h, 0, 0D6h, 08h, 8Fh, 0C0h, 0C2h, 0D4h, 0 - DB 0D4h, 5, 0D8h, 0, 0D6h, 09h, 8Bh, 0C4h, 0C6h, 0D4h, 1 - DB 0D4h, 6, 0D8h, 0, 0D6h, 0Ah, 89h, 0C8h, 0CAh, 0D4h, 2 - DB 0D4h, 7, 0D8h, 0, 0D6h, 0Bh, 8Ah, 0CCh, 0CEh, 0D4h, 3 - -ActualDMAPtr Label DWord -ActualDMAOffset DW 0 -ActualDMASegment DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetDMA ; BX:AX points to DMA buffer - ; DL = DMA Channel - ; DI = DMA Size - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov ActualDMASegment, BX - Mov ActualDMAOffset, AX - - Mov CH, BH - ShR CH, 4 - ShL BX, 4 - Add BX, AX - AdC CH, 0 - Mov SI, BX ; CH:BH:BL contains 24 bit DMA address - Neg SI - Cmp SI, DI - JA SetDMA1 - - Add ActualDMAOffset, SI - Add BX, SI - AdC CH, 0 - -SetDMA1: - Cmp DL, 3 - JBE SetDMA2 - - ShR DI, 1 - Push CX - ShR CH, 1 - Pop CX - RCR BX, 1 - -SetDMA2: - Mov AL, 11 - Mul DL - Mov SI, AX - Add SI, Offset DMAData - - Xor DX, DX - - LodsB ; Set mask - Mov DL, AL - LodsB - Out DX, AL - - LodsB ; Clear Ptrs - Mov DL, AL - LodsB - Out DX, AL - - LodsB ; Set Mode - Mov DL, AL - LodsB - Out DX, AL - - LodsB - Mov DL, AL ; DL = page port - Mov AL, CH - Out DX, AL - - LodsB - Mov DL, AL ; DL = address port - Mov AL, BL - Out DX, AL - Mov AL, BH - Out DX, AL - - LodsB - Mov DL, AL ; DL = count port - Mov AX, DI - Dec AX - Out DX, AL - Mov AL, AH - Out DX, AL - - LodsB ; Reset mask - Mov DL, AL - LodsB - Out DX, AL - - Pop DS - PopA - - Ret - -EndP SetDMA - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +DMAData Label Byte +; Port/Mask, Port/Clear, Port/DMAMode, Address, Page, Count, Port/Mask + DB 0Ah, 4, 0Ch, 0, 0Bh, 08h, 87h, 0, 1, 0Ah, 0 + DB 0Ah, 5, 0Ch, 0, 0Bh, 09h, 83h, 2, 3, 0Ah, 1 + DB 0Ah, 6, 0Ch, 0, 0Bh, 0Ah, 81h, 4, 5, 0Ah, 2 + DB 0Ah, 7, 0Ch, 0, 0Bh, 0Bh, 82h, 6, 7, 0Ah, 3 + DB 0D4h, 4, 0D8h, 0, 0D6h, 08h, 8Fh, 0C0h, 0C2h, 0D4h, 0 + DB 0D4h, 5, 0D8h, 0, 0D6h, 09h, 8Bh, 0C4h, 0C6h, 0D4h, 1 + DB 0D4h, 6, 0D8h, 0, 0D6h, 0Ah, 89h, 0C8h, 0CAh, 0D4h, 2 + DB 0D4h, 7, 0D8h, 0, 0D6h, 0Bh, 8Ah, 0CCh, 0CEh, 0D4h, 3 + +ActualDMAPtr Label DWord +ActualDMAOffset DW 0 +ActualDMASegment DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetDMA ; BX:AX points to DMA buffer + ; DL = DMA Channel + ; DI = DMA Size + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov ActualDMASegment, BX + Mov ActualDMAOffset, AX + + Mov CH, BH + ShR CH, 4 + ShL BX, 4 + Add BX, AX + AdC CH, 0 + Mov SI, BX ; CH:BH:BL contains 24 bit DMA address + Neg SI + Cmp SI, DI + JA SetDMA1 + + Add ActualDMAOffset, SI + Add BX, SI + AdC CH, 0 + +SetDMA1: + Cmp DL, 3 + JBE SetDMA2 + + ShR DI, 1 + Push CX + ShR CH, 1 + Pop CX + RCR BX, 1 + +SetDMA2: + Mov AL, 11 + Mul DL + Mov SI, AX + Add SI, Offset DMAData + + Xor DX, DX + + LodsB ; Set mask + Mov DL, AL + LodsB + Out DX, AL + + LodsB ; Clear Ptrs + Mov DL, AL + LodsB + Out DX, AL + + LodsB ; Set Mode + Mov DL, AL + LodsB + Out DX, AL + + LodsB + Mov DL, AL ; DL = page port + Mov AL, CH + Out DX, AL + + LodsB + Mov DL, AL ; DL = address port + Mov AL, BL + Out DX, AL + Mov AL, BH + Out DX, AL + + LodsB + Mov DL, AL ; DL = count port + Mov AX, DI + Dec AX + Out DX, AL + Mov AL, AH + Out DX, AL + + LodsB ; Reset mask + Mov DL, AL + LodsB + Out DX, AL + + Pop DS + PopA + + Ret + +EndP SetDMA + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/DMASIRQ.INC b/SoundDrivers/DMASIRQ.INC index df906c5..8f781f4 100755 --- a/SoundDrivers/DMASIRQ.INC +++ b/SoundDrivers/DMASIRQ.INC @@ -1,116 +1,116 @@ - -DMAData Label Byte -; Port/Mask, Port/Clear, Port/DMAMode, Address, Page, Count, Port/Mask - DB 0Ah, 4, 0Ch, 0, 0Bh, 58h, 87h, 0, 1, 0Ah, 0 - DB 0Ah, 5, 0Ch, 0, 0Bh, 59h, 83h, 2, 3, 0Ah, 1 - DB 0Ah, 6, 0Ch, 0, 0Bh, 5Ah, 81h, 4, 5, 0Ah, 2 - DB 0Ah, 7, 0Ch, 0, 0Bh, 5Bh, 82h, 6, 7, 0Ah, 3 - DB 0D4h, 4, 0D8h, 0, 0D6h, 58h, 8Fh, 0C0h, 0C2h, 0D4h, 0 - DB 0D4h, 5, 0D8h, 0, 0D6h, 59h, 8Bh, 0C4h, 0C6h, 0D4h, 1 - DB 0D4h, 6, 0D8h, 0, 0D6h, 5Ah, 89h, 0C8h, 0CAh, 0D4h, 2 - DB 0D4h, 7, 0D8h, 0, 0D6h, 5Bh, 8Ah, 0CCh, 0CEh, 0D4h, 3 - -ActualDMAPtr Label DWord -ActualDMAOffset DW 0 -ActualDMASegment DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetDMA ; BX:AX points to DMA buffer - ; DL = DMA Channel - ; DI = DMA Size - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov ActualDMASegment, BX - Mov ActualDMAOffset, AX - - Mov CH, BH - ShR CH, 4 - ShL BX, 4 - Add BX, AX - AdC CH, 0 - Mov SI, BX ; CH:BH:BL contains 24 bit DMA address - Neg SI - Cmp SI, DI - JA SetDMA1 - - Add ActualDMAOffset, SI - Add BX, SI - AdC CH, 0 - -SetDMA1: - Cmp DL, 3 - JBE SetDMA2 - - ShR DI, 1 - Push CX - ShR CH, 1 - Pop CX - RCR BX, 1 - -SetDMA2: - Mov AL, 11 - Mul DL - Mov SI, AX - Add SI, Offset DMAData - - Xor DX, DX - - LodsB ; Set mask - Mov DL, AL - LodsB - Out DX, AL - - LodsB ; Clear Ptrs - Mov DL, AL - LodsB - Out DX, AL - - LodsB ; Set Mode - Mov DL, AL - LodsB - Out DX, AL - - LodsB - Mov DL, AL ; DL = page port - Mov AL, CH - Out DX, AL - - LodsB - Mov DL, AL ; DL = address port - Mov AL, BL - Out DX, AL - Mov AL, BH - Out DX, AL - - LodsB - Mov DL, AL ; DL = count port - Mov AX, DI - Dec AX - Out DX, AL - Mov AL, AH - Out DX, AL - - Mov Byte Ptr [CS:DMAPort1], DL - Mov Byte Ptr [CS:DMAPort2], DL - - LodsB ; Reset mask - Mov DL, AL - LodsB - Out DX, AL - - Pop DS - PopA - - Ret - -EndP SetDMA - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +DMAData Label Byte +; Port/Mask, Port/Clear, Port/DMAMode, Address, Page, Count, Port/Mask + DB 0Ah, 4, 0Ch, 0, 0Bh, 58h, 87h, 0, 1, 0Ah, 0 + DB 0Ah, 5, 0Ch, 0, 0Bh, 59h, 83h, 2, 3, 0Ah, 1 + DB 0Ah, 6, 0Ch, 0, 0Bh, 5Ah, 81h, 4, 5, 0Ah, 2 + DB 0Ah, 7, 0Ch, 0, 0Bh, 5Bh, 82h, 6, 7, 0Ah, 3 + DB 0D4h, 4, 0D8h, 0, 0D6h, 58h, 8Fh, 0C0h, 0C2h, 0D4h, 0 + DB 0D4h, 5, 0D8h, 0, 0D6h, 59h, 8Bh, 0C4h, 0C6h, 0D4h, 1 + DB 0D4h, 6, 0D8h, 0, 0D6h, 5Ah, 89h, 0C8h, 0CAh, 0D4h, 2 + DB 0D4h, 7, 0D8h, 0, 0D6h, 5Bh, 8Ah, 0CCh, 0CEh, 0D4h, 3 + +ActualDMAPtr Label DWord +ActualDMAOffset DW 0 +ActualDMASegment DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetDMA ; BX:AX points to DMA buffer + ; DL = DMA Channel + ; DI = DMA Size + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov ActualDMASegment, BX + Mov ActualDMAOffset, AX + + Mov CH, BH + ShR CH, 4 + ShL BX, 4 + Add BX, AX + AdC CH, 0 + Mov SI, BX ; CH:BH:BL contains 24 bit DMA address + Neg SI + Cmp SI, DI + JA SetDMA1 + + Add ActualDMAOffset, SI + Add BX, SI + AdC CH, 0 + +SetDMA1: + Cmp DL, 3 + JBE SetDMA2 + + ShR DI, 1 + Push CX + ShR CH, 1 + Pop CX + RCR BX, 1 + +SetDMA2: + Mov AL, 11 + Mul DL + Mov SI, AX + Add SI, Offset DMAData + + Xor DX, DX + + LodsB ; Set mask + Mov DL, AL + LodsB + Out DX, AL + + LodsB ; Clear Ptrs + Mov DL, AL + LodsB + Out DX, AL + + LodsB ; Set Mode + Mov DL, AL + LodsB + Out DX, AL + + LodsB + Mov DL, AL ; DL = page port + Mov AL, CH + Out DX, AL + + LodsB + Mov DL, AL ; DL = address port + Mov AL, BL + Out DX, AL + Mov AL, BH + Out DX, AL + + LodsB + Mov DL, AL ; DL = count port + Mov AX, DI + Dec AX + Out DX, AL + Mov AL, AH + Out DX, AL + + Mov Byte Ptr [CS:DMAPort1], DL + Mov Byte Ptr [CS:DMAPort2], DL + + LodsB ; Reset mask + Mov DL, AL + LodsB + Out DX, AL + + Pop DS + PopA + + Ret + +EndP SetDMA + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/DRHEAD.INC b/SoundDrivers/DRHEAD.INC index 03186ab..bbec5c8 100755 --- a/SoundDrivers/DRHEAD.INC +++ b/SoundDrivers/DRHEAD.INC @@ -1,8 +1,8 @@ - -ID DB "Impulse Tracker Advanced Sound Driver", 13, 10 - DB "Copyright (C) 1995-1998 Jeffrey Lim", 0 - DB 26 - - DB 126 - ($ - Offset ID) Dup (0) - -LengthOfDriver DW Offset EndDriver - Offset StartDriver + +ID DB "Impulse Tracker Advanced Sound Driver", 13, 10 + DB "Copyright (C) 1995-1998 Jeffrey Lim", 0 + DB 26 + + DB 126 - ($ - Offset ID) Dup (0) + +LengthOfDriver DW Offset EndDriver - Offset StartDriver diff --git a/SoundDrivers/ENVIVO.ASM b/SoundDrivers/ENVIVO.ASM index f4198e1..737313e 100755 --- a/SoundDrivers/ENVIVO.ASM +++ b/SoundDrivers/ENVIVO.ASM @@ -1,2300 +1,2300 @@ -; -; Windows Sound System Driver -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -PNPSERIALID EQU 98B03C20h -PNPVENDORID EQU 8140D315h -PNPVENDORID2 EQU 8040D315h - -DMASize DW 2048 - -WSSMsg DB "Ensoniq SoundscapeVIVO Codec", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Ensoniq SoundscapeVIVO Codec", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Ensoqiq SoundscapeVIVO Codec reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITVIVO.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITVIVO.DRV", 0 - -DriverName DB "ITVIVO.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - -IRQSetupTable DB 0, 0, 0, 0, 0, 0, 0, 8 - DB 0, 10h, 18h, 20h, 0, 0, 0, 0 - -DMASetupTable DB 1, 2, 0, 3, 0, 0, 0, 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "Ensoniq SoundscapeVIVO Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 26, 48 - DB 21h - DB "Ensoniq SoundscapeVIVO Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 14 ; 14 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Add DX, 6 - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID2 - JE VendorAlsoOK - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - -VendorAlsoOK: - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 62h - Call PnP_ReadData - Mov AH, AL - Mov AL, 63h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Mov AX, 202h - Call PnP_WriteData - Ret - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov EAX, 'Jeff' - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 6 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB WSSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -WSSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Add DX, 4 - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +PNPSERIALID EQU 98B03C20h +PNPVENDORID EQU 8140D315h +PNPVENDORID2 EQU 8040D315h + +DMASize DW 2048 + +WSSMsg DB "Ensoniq SoundscapeVIVO Codec", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Ensoniq SoundscapeVIVO Codec", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Ensoqiq SoundscapeVIVO Codec reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITVIVO.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITVIVO.DRV", 0 + +DriverName DB "ITVIVO.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + +IRQSetupTable DB 0, 0, 0, 0, 0, 0, 0, 8 + DB 0, 10h, 18h, 20h, 0, 0, 0, 0 + +DMASetupTable DB 1, 2, 0, 3, 0, 0, 0, 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "Ensoniq SoundscapeVIVO Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 26, 48 + DB 21h + DB "Ensoniq SoundscapeVIVO Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 14 ; 14 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Add DX, 6 + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID2 + JE VendorAlsoOK + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + +VendorAlsoOK: + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 62h + Call PnP_ReadData + Mov AH, AL + Mov AL, 63h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Mov AX, 202h + Call PnP_WriteData + Ret + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov EAX, 'Jeff' + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 6 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB WSSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +WSSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Add DX, 4 + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/EQUALIZE.INC b/SoundDrivers/EQUALIZE.INC index c00c665..858fcdb 100755 --- a/SoundDrivers/EQUALIZE.INC +++ b/SoundDrivers/EQUALIZE.INC @@ -1,161 +1,161 @@ -; Do output filtering -; First copy old contents across -; Assumes destination is MixSegment:0 -; data order is lastvalues, coefficients, volumes - - Push CS - Pop DS - Assume DS:Driver - - Xor DI, DI - Mov SI, Offset LastFilter - - Mov EAX, [SI+40h] - Mov EBX, [SI+44h] - Mov ECX, [SI+48h] - Mov EDX, [SI+4Ch] - Or EAX, EBX - Or ECX, EDX - Or EAX, ECX - JZ NoEqualize - - Mov CX, 80/4 - Mov ES, MixSegment - - Rep MovsD - -; Now do filtering. - FNInit - Mov CX, BytesToMix - - Push ES - Pop DS - Assume DS:Nothing - - Mov SI, DMABUFFERLENGTH*2+80 - -OutputFilter1: - FILD DWord Ptr [SI] ; Left sample - FILD DWord Ptr [SI+4] ; R, L - - FLd DWord Ptr [DS:20h] ; LB, R, L - FMul ST, ST(2) ; L.LB, R, L - FLd DWord Ptr [DS:20h] ; LB, L.LB, R, L - FMul ST, ST(2) ; R.LB, L.LB, R, L - FLd DWord Ptr [DS:0] ; OL, R.LB, L.LB, R, L - FMul DWord Ptr [DS:24h] ; OL.LB, R.LB, L.LB, R, L - FLd DWord Ptr [DS:4] ; OR, OL.LB, R.LB, L.LB, R, L - FMul DWord Ptr [DS:24h] ; OR.LB, OL.LB, R.LB, L.LB, R, L - - FXCh ; OL.LB, OR.LB, R.LB, L.LB, R, L - FAddP ST(3), ST - FAdd ; RLB, LLB, R, L - - FLd DWord Ptr [DS:28h] ; MB, RLB, LLB, R, L - FMul ST, ST(4) ; L.MB, RLB, LLB, R, L - FLd DWord Ptr [DS:28h] ; MB, L.MB, RLB, LLB, R, L - FMul ST, ST(4) ; R.MB, L.MB, RLB, LLB, R, L - FLd DWord Ptr [DS:8] ; OL, R.MB, L.MB, RLB, LLB, R, L - FMul DWord Ptr [DS:2Ch] ; OL.MB, R.MB, L.MB, RLB, LLB, R, L - FLd DWord Ptr [DS:0Ch] ; OR, OL.MB, R.MB, L.MB, RLB, LLB, R, L - FMul DWord Ptr [DS:2Ch] ; OR.MB, OL.MB, R.MB, L.MB, RLB, LLB, R, L - - FXCh ; OL.MB, OR.MB, R.MB, L.MB, RLB, LLB, R, L - FAddP ST(3), ST - FAdd ; RMB, LMB, RLB, LLB, R, L - FXCh ST(3) ; LLB, LMB, RLB, RMB, R, L - FStP DWord Ptr [DS:0] - FStP DWord Ptr [DS:8] - FStP DWord Ptr [DS:4] - FStP DWord Ptr [DS:0Ch] - - FLd DWord Ptr [DS:30h] - FMul ST, ST(2) - FLd DWord Ptr [DS:30h] - FMul ST, ST(2) - FLd DWord Ptr [DS:10h] - FMul DWord Ptr [DS:34h] - FLd DWord Ptr [DS:14h] - FMul DWord Ptr [DS:34h] - - FXCh - FAddP ST(3), ST - FAdd - - FLd DWord Ptr [DS:38h] - FMul ST, ST(4) - FLd DWord Ptr [DS:38h] - FMul ST, ST(4) - FLd DWord Ptr [DS:18h] - FMul DWord Ptr [DS:3Ch] - FLd DWord Ptr [DS:1Ch] - FMul DWord Ptr [DS:3Ch] - - FXCh - FAddP ST(3), ST - FAdd - FXCh ST(3) - FStP DWord Ptr [DS:10h] - FStP DWord Ptr [DS:18h] - FStP DWord Ptr [DS:14h] - FStP DWord Ptr [DS:1Ch] ; R, L - -; For each one, output value += ((band value) - (previous band value)) * Volume - - FLd DWord Ptr [DS:18h] - FSub DWord Ptr [DS:10h] ; L4, R, L - FLd DWord Ptr [DS:1Ch] - FSub DWord Ptr [DS:14h] ; R4, L4, R, L - FLd DWord Ptr [DS:10h] - FSub DWord Ptr [DS:8] - FLd DWord Ptr [DS:14h] - FSub DWord Ptr [DS:0Ch] ; R3, L3, R4, L4, R, L - FLd DWord Ptr [DS:8] - FSub DWord Ptr [DS:0] - FLd DWord Ptr [DS:0Ch] - FSub DWord Ptr [DS:4] ; R2, L2, R3, L3, R4, L4, R, L - FXCh ST(5) ; L4, L2, R3, L3, R4, R2, R, L - FMul DWord Ptr [DS:4Ch] ; L4V, L2, R3, L3, R4, R2, R, L - FXCh ST(4) ; R4, L2, R3, L3, L4V, R2, R, L - FMul DWord Ptr [DS:4Ch] ; R4V, L2, R3, L3, L4V, R2, R, L - FXCh ST(3) ; L3, L2, R3, R4V, L4V, R2, R, L - FMul DWord Ptr [DS:48h] ; L3V, L2, R3, R4V, L4V, R2, R, L - FXCh ST(2) ; R3, L2, L3V, R4V, L4V, R2, R, L - FMul DWord Ptr [DS:48h] ; R3V, L2, L3V, R4V, L4V, R2, R, L - FXCh ; L2, R3V, L3V, R4V, L4V, R2, R, L - FMul DWord Ptr [DS:44h] ; L2V, R3V, L3V, R4V, L4V, R2, R, L - FXCh ST(5) ; R2, R3V, L3V, R4V, L4V, L2V, R, L - FMul DWord Ptr [DS:44h] ; R2V, R3V, L3V, R4V, L4V, L2V, R, L - FXCh ST(4) ; L4V, R3V, L3V, R4V, R2V, L2V, R, L - FAddP ST(7), ST ; R3V, L3V, R4V, R2V, L2V, R, L - FAddP ST(5), ST ; L3V, R4V, R2V, L2V, R, L - FAddP ST(3), ST - FAdd - FLd DWord Ptr [DS:0] - FMul DWord Ptr [DS:40h] ; L1V, RV, LV, R, L - FLd DWord Ptr [DS:4] ; - FMul DWord Ptr [DS:40h] ; R1V, L1V, RV, LV, R, L - FXCh ST(2) ; RV, L1V, R1V, LV, R, L - FAddP ST(4), ST ; L1V, R1V, LV, R, L - FAddP ST(4), ST ; R1V, LV, R, L - FAddP ST(2), ST - FAddP ST(2), ST - - FIStP DWord Ptr [SI+4] - FIStP DWord Ptr [SI] - - Add SI, 8 - Dec CX - JNZ OutputFilter1 - -; Transfer contents out - Push CS - Pop ES - - Mov DI, Offset LastFilter - Xor SI, SI - Mov CX, 32/4 - - Rep MovsD -; Finished output filtering! -NoEqualize: +; Do output filtering +; First copy old contents across +; Assumes destination is MixSegment:0 +; data order is lastvalues, coefficients, volumes + + Push CS + Pop DS + Assume DS:Driver + + Xor DI, DI + Mov SI, Offset LastFilter + + Mov EAX, [SI+40h] + Mov EBX, [SI+44h] + Mov ECX, [SI+48h] + Mov EDX, [SI+4Ch] + Or EAX, EBX + Or ECX, EDX + Or EAX, ECX + JZ NoEqualize + + Mov CX, 80/4 + Mov ES, MixSegment + + Rep MovsD + +; Now do filtering. + FNInit + Mov CX, BytesToMix + + Push ES + Pop DS + Assume DS:Nothing + + Mov SI, DMABUFFERLENGTH*2+80 + +OutputFilter1: + FILD DWord Ptr [SI] ; Left sample + FILD DWord Ptr [SI+4] ; R, L + + FLd DWord Ptr [DS:20h] ; LB, R, L + FMul ST, ST(2) ; L.LB, R, L + FLd DWord Ptr [DS:20h] ; LB, L.LB, R, L + FMul ST, ST(2) ; R.LB, L.LB, R, L + FLd DWord Ptr [DS:0] ; OL, R.LB, L.LB, R, L + FMul DWord Ptr [DS:24h] ; OL.LB, R.LB, L.LB, R, L + FLd DWord Ptr [DS:4] ; OR, OL.LB, R.LB, L.LB, R, L + FMul DWord Ptr [DS:24h] ; OR.LB, OL.LB, R.LB, L.LB, R, L + + FXCh ; OL.LB, OR.LB, R.LB, L.LB, R, L + FAddP ST(3), ST + FAdd ; RLB, LLB, R, L + + FLd DWord Ptr [DS:28h] ; MB, RLB, LLB, R, L + FMul ST, ST(4) ; L.MB, RLB, LLB, R, L + FLd DWord Ptr [DS:28h] ; MB, L.MB, RLB, LLB, R, L + FMul ST, ST(4) ; R.MB, L.MB, RLB, LLB, R, L + FLd DWord Ptr [DS:8] ; OL, R.MB, L.MB, RLB, LLB, R, L + FMul DWord Ptr [DS:2Ch] ; OL.MB, R.MB, L.MB, RLB, LLB, R, L + FLd DWord Ptr [DS:0Ch] ; OR, OL.MB, R.MB, L.MB, RLB, LLB, R, L + FMul DWord Ptr [DS:2Ch] ; OR.MB, OL.MB, R.MB, L.MB, RLB, LLB, R, L + + FXCh ; OL.MB, OR.MB, R.MB, L.MB, RLB, LLB, R, L + FAddP ST(3), ST + FAdd ; RMB, LMB, RLB, LLB, R, L + FXCh ST(3) ; LLB, LMB, RLB, RMB, R, L + FStP DWord Ptr [DS:0] + FStP DWord Ptr [DS:8] + FStP DWord Ptr [DS:4] + FStP DWord Ptr [DS:0Ch] + + FLd DWord Ptr [DS:30h] + FMul ST, ST(2) + FLd DWord Ptr [DS:30h] + FMul ST, ST(2) + FLd DWord Ptr [DS:10h] + FMul DWord Ptr [DS:34h] + FLd DWord Ptr [DS:14h] + FMul DWord Ptr [DS:34h] + + FXCh + FAddP ST(3), ST + FAdd + + FLd DWord Ptr [DS:38h] + FMul ST, ST(4) + FLd DWord Ptr [DS:38h] + FMul ST, ST(4) + FLd DWord Ptr [DS:18h] + FMul DWord Ptr [DS:3Ch] + FLd DWord Ptr [DS:1Ch] + FMul DWord Ptr [DS:3Ch] + + FXCh + FAddP ST(3), ST + FAdd + FXCh ST(3) + FStP DWord Ptr [DS:10h] + FStP DWord Ptr [DS:18h] + FStP DWord Ptr [DS:14h] + FStP DWord Ptr [DS:1Ch] ; R, L + +; For each one, output value += ((band value) - (previous band value)) * Volume + + FLd DWord Ptr [DS:18h] + FSub DWord Ptr [DS:10h] ; L4, R, L + FLd DWord Ptr [DS:1Ch] + FSub DWord Ptr [DS:14h] ; R4, L4, R, L + FLd DWord Ptr [DS:10h] + FSub DWord Ptr [DS:8] + FLd DWord Ptr [DS:14h] + FSub DWord Ptr [DS:0Ch] ; R3, L3, R4, L4, R, L + FLd DWord Ptr [DS:8] + FSub DWord Ptr [DS:0] + FLd DWord Ptr [DS:0Ch] + FSub DWord Ptr [DS:4] ; R2, L2, R3, L3, R4, L4, R, L + FXCh ST(5) ; L4, L2, R3, L3, R4, R2, R, L + FMul DWord Ptr [DS:4Ch] ; L4V, L2, R3, L3, R4, R2, R, L + FXCh ST(4) ; R4, L2, R3, L3, L4V, R2, R, L + FMul DWord Ptr [DS:4Ch] ; R4V, L2, R3, L3, L4V, R2, R, L + FXCh ST(3) ; L3, L2, R3, R4V, L4V, R2, R, L + FMul DWord Ptr [DS:48h] ; L3V, L2, R3, R4V, L4V, R2, R, L + FXCh ST(2) ; R3, L2, L3V, R4V, L4V, R2, R, L + FMul DWord Ptr [DS:48h] ; R3V, L2, L3V, R4V, L4V, R2, R, L + FXCh ; L2, R3V, L3V, R4V, L4V, R2, R, L + FMul DWord Ptr [DS:44h] ; L2V, R3V, L3V, R4V, L4V, R2, R, L + FXCh ST(5) ; R2, R3V, L3V, R4V, L4V, L2V, R, L + FMul DWord Ptr [DS:44h] ; R2V, R3V, L3V, R4V, L4V, L2V, R, L + FXCh ST(4) ; L4V, R3V, L3V, R4V, R2V, L2V, R, L + FAddP ST(7), ST ; R3V, L3V, R4V, R2V, L2V, R, L + FAddP ST(5), ST ; L3V, R4V, R2V, L2V, R, L + FAddP ST(3), ST + FAdd + FLd DWord Ptr [DS:0] + FMul DWord Ptr [DS:40h] ; L1V, RV, LV, R, L + FLd DWord Ptr [DS:4] ; + FMul DWord Ptr [DS:40h] ; R1V, L1V, RV, LV, R, L + FXCh ST(2) ; RV, L1V, R1V, LV, R, L + FAddP ST(4), ST ; L1V, R1V, LV, R, L + FAddP ST(4), ST ; R1V, LV, R, L + FAddP ST(2), ST + FAddP ST(2), ST + + FIStP DWord Ptr [SI+4] + FIStP DWord Ptr [SI] + + Add SI, 8 + Dec CX + JNZ OutputFilter1 + +; Transfer contents out + Push CS + Pop ES + + Mov DI, Offset LastFilter + Xor SI, SI + Mov CX, 32/4 + + Rep MovsD +; Finished output filtering! +NoEqualize: diff --git a/SoundDrivers/ES1688.ASM b/SoundDrivers/ES1688.ASM index 01d3a48..b81f004 100755 --- a/SoundDrivers/ES1688.ASM +++ b/SoundDrivers/ES1688.ASM @@ -1,2265 +1,2265 @@ -; -; ESS Technology's ES1688 Audiodrive chip -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -;Debug DW 0 -;Debug2 DW 0 -ESSMsg DB "ES1688 AudioDrive found", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "ES1688 AudioDrive found", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "ES1688 AudioDrive reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITES1688.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITES1688.DRV", 0 - -DriverName DB "ITES1688.DRV", 0 - -ALIGN 4 -FilterValue DD 0 -FilterValue2 DD 0 -ESSMixConst DB 0, 0 - -DMASize DW 4096 ; Smaller gives better MIDI timing -ConfigPort DW 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldESSIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -ESSScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr ESSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - -Comment ~ - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - -~ - - DW 0 - -ESSHeaderLine DW 10 - DB "ESS AudioDrive Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 33, 48 - DB 21h - DB "ESS AudioDrive Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -Comment ~ - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 15 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 15 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -~ - -MixModeText DW 1 - DB 2, 14 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 44100 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 16, 32, 18, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 19, 32, 21, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 22, 32, 24, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 29 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 31, 29, 33, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 34, 29, 36, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 37, 29, 39, 8 - DB 0 - DB " 75% Filter", 0 - -ALIGN 4 - -VolumeTable DB 2 Dup (0) -MIDIPort DW 0 - -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dmasirq.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSOut ; AL = data - ; DX = 2xCh - - Push AX - -ESSOut1: - In AL, DX - Test AL, AL - JS ESSOut1 - - Pop AX - Out DX, AL - - Ret - -EndP ESSOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSOut2 ; AL = data - ; DX = 2xCh - - Push AX - -ESSOut2A: - In AL, DX - Test AL, 80h - LoopNZ ESSOut2A - - Pop AX - Out DX, AL - - Ret - -EndP ESSOut2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIn2 - -ESSInA1: - In AL, DX - Test AL, 40h - LoopZ ESSInA1 - JZ ESSInA2 - - Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -ESSInA2: - Mov AL, 0FFh - Ret - -EndP ESSIn2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIn ; DX = 2xCh, returns AL - -ESSIn1: - In AL, DX - Test AL, 40h - JZ ESSIn1 - - Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -EndP ESSIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut ; AL = out - - Push DX - Push AX - - Mov DX, CS:MIDIPort - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - JNZ UARTOut1 - - Pop AX - Dec DX - Out DX, AL - - Pop DX - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTIn ; returns AL - - Push DX - - Mov DX, CS:MIDIPort - Inc DX - -UARTIn1: - In AL, DX - Test AL, 80h - JNZ UARTIn1 - - Dec DX - In AL, DX - - Pop DX - Ret - -EndP UARTIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadMixerRegister ; AL = register to read - ; DX = 2xCh - - Add DL, 04-0Ch - Out DX, AL - Inc DX - In AL, DX - Add DL, 0Ch-05 - - Ret - -EndP ESSReadMixerRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadRegister ; AH = register to read. - ; DX = 2xCh - ; returns AL - - Mov AL, 0C0h - Call ESSOut - Mov AL, AH - Call ESSOut - Call ESSIn - - Ret - -EndP ESSReadRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Xor CX, CX - Add DL, 0Ch ; 2xCh -> Data ready to send... - - Mov AL, 0E1h - Call ESSOut2 - - Call ESSIn2 - Mov AH, AL ; AH = Major version number - Call ESSIn2 ; AL = Minor version number - - Cmp AX, 301h - JNE DetectCardFailure - - Mov AL, 0E7h - Call ESSOut2 - Call ESSIn2 - Mov AH, AL - Call ESSIn2 - - Cmp AH, 68h - JNE DetectCardReset - Cmp AL, 88h - JB DetectCardReset - Cmp AL, 90h - JAE DetectCardReset - ; We have an ES1688 Audiodrive chip! - -Comment ~ - Mov AL, 40h - Call ESSReadMixerRegister - ShL AL, 1 - And AX, 30h - Add AX, 300h - Mov MIDIPort, AX -~ - - Mov AH, 0B1h ; IRQ determination - Call ESSReadRegister - - Mov BX, 9 - And AL, 0Ch - JZ DetectCardIRQ - - Mov BX, 5 - Cmp AL, 4 - JE DetectCardIRQ - - Mov BX, 7 - Cmp AL, 8 - JE DetectCardIRQ - - Mov BX, 10 - Cmp AL, 0Ch - JNE DetectCardFailure - - -DetectCardIRQ: - Mov IRQ, BX - - Mov AH, 0B2h - Call ESSReadRegister - - Xor BX, BX - And AL, 0Ch - JZ DetectCardFailure - - Cmp AL, 4 - JE DetectCardDMA - - Inc BX - Cmp AL, 8 - JE DetectCardDMA - - Add BL, 2 - -DetectCardDMA: - Mov DMA, BX - - Mov EAX, 'Jeff' - ClC - Ret - -DetectCardReset: - Sub DL, 0Ch - Mov AX, DX - Call ResetDSP - -DetectCardFailure: - StC - Ret - - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 3 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Call UARTIn - Mov BL, [MIDIBufferTail] - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - -; Inc Debug - -Comment ~ - Mov DX, [ConfigPort] - Add DL, 6 - In AL, DX - Test AL, 8 - JZ ESSNoMIDI - - Push AX - Call CheckMIDI - Pop AX - -ESSNoMIDI: - Test AL, 1 - JZ ESSIRQEnd -~ - Mov DX, [BasePort] - Add DL, 0Eh - In AL, DX - - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB ESSIRQHandler6 - JE ESSIRQHFilter - - Cmp CS:Stereo, 0 - JE ESSIRQ3QFilterMono - -ESSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -ESSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -ESSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -ESSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilter: - Cmp CS:Stereo, 0 - JE ESSIRQHFilterMono - -ESSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -ESSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -ESSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -ESSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL ESSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG ESSIRQHandlerClip2 - -ESSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ ESSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - -ESSIRQEnd: - Pop ES - Pop DS - PopAD - IRet - -ESSIRQHandlerClip1: - Mov AX, 8000h - Jmp ESSIRQHandler7 - -ESSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp ESSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo3 - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetESSMixConst - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetESSMixConst1 - - Mov CX, 22050 - Cmp AX, CX - JB GetESSMixConst1 - - Mov CX, 56821 - Cmp AX, CX - JA GetESSMixConst1 - - Mov CX, AX - -GetESSMixConst1: ; CX = mixspeed. - Mov DX, 0Ch - Mov AX, 236Ch ; DX:AX = 795.5kHz - Div CX - - Mov BX, AX - Neg AL - Mov ESSMixConst, AL - - Mov DX, 0Ch - Mov AX, 236Ch - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetESSMixConst - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartESS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov AX, BasePort - Call ResetDSP - Mov DX, AX - Add DL, 0Ch - -; Extended Functions - - Mov AL, 0C6h - Call ESSOut - -; Autoinit DMA - - Mov AL, 0B8h - Call ESSOut - Mov AL, 4 - Call ESSOut - -; Stereo/Mono select - - Mov AH, 0A8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0A8h - Call ESSOut - Mov AL, AH - And AL, Not 3 - Or AL, 2 - Cmp Stereo, 0 - JE StartESS1 - - Xor AL, 3 - -StartESS1: - Call ESSOut - -; DMA mode - - Mov AL, 0B9h - Call ESSOut - Mov AL, 2 - Call ESSOut - -; Mixspeed - - Mov AL, 0A1h - Call ESSOut - Mov AL, ESSMixConst - Call ESSOut - -; Filter clock divider - Mov AL, 0A2h - Call ESSOut - - Mov AL, 0FEh - Call ESSOut - -; DMA counter - Mov CX, DMASize - Neg CX - - Mov AL, 0A4h - Call ESSOut - Mov AL, CL - Call ESSOut - Mov AL, 0A5h - Call ESSOut - Mov AL, CH - Call ESSOut - -; Initialise DAC - Mov AL, 0B6h - Call ESSOut - Mov AL, 0 - Call ESSOut - -; Configure DACs - - Mov AL, 0B7h - Call ESSOut - Mov AL, 71h - Call ESSOut - - Mov AL, 0B7h - Call ESSOut - - Mov AL, 0BCh - Cmp Stereo, 0 - JNE StartESS2 - - Mov AL, 0F4h - -StartESS2: - Call ESSOut - -; IRQ configuration - Mov AH, 0B1h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B1h - Call ESSOut - Mov AL, AH - And AL, 0Fh - Or AL, 50h - Call ESSOut - -; DMA configuration - Mov AH, 0B2h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B2h - Call ESSOut - Mov AL, AH - And AL, 0Fh - Or AL, 50h - Call ESSOut - -; Enable voice - Mov AL, 0D1h - Call ESSOut - -; Start transfer - Mov AH, 0B8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B8h - Call ESSOut - Mov AL, AH - Or AL, 1 - Call ESSOut - -Comment ~ - -; Init UART - Mov DX, MIDIPort - Inc DX - Mov AL, 3Fh ; Intelligent mode. - Out DX, AL - -; Enable MIDI IRQ - Mov DX, BasePort - Add DL, 4 - Mov AX, 4064h - Out DX, AX - -~ - - Pop DS - Pop ES - PopA - - Ret - -EndP StartESS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - And AX, 0FF0h - ShR AH, 1 - ShR AL, 5 - Mov Word Ptr [VolumeTable], AX - - Call GetESSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Mov AX, BasePort - Call ResetDSP - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver -; -;DMAPort1 EQU $+1 -; In AL, 1 -; Mov BL, AL -;DMAPort2 EQU $+1 -; In AL, 1 -; Mov BH, AL -; -; Mov Debug2, BX - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov AX, BasePort - Call ResetDSP - Call StartESS - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Mov AH, [VolumeTable] - ShL AH, 4 - Or AH, [VolumeTable+1] - ShL AH, 1 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ESS Technology's ES1688 Audiodrive chip +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +;Debug DW 0 +;Debug2 DW 0 +ESSMsg DB "ES1688 AudioDrive found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "ES1688 AudioDrive found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "ES1688 AudioDrive reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITES1688.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITES1688.DRV", 0 + +DriverName DB "ITES1688.DRV", 0 + +ALIGN 4 +FilterValue DD 0 +FilterValue2 DD 0 +ESSMixConst DB 0, 0 + +DMASize DW 4096 ; Smaller gives better MIDI timing +ConfigPort DW 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + +Comment ~ + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + +~ + + DW 0 + +ESSHeaderLine DW 10 + DB "ESS AudioDrive Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 33, 48 + DB 21h + DB "ESS AudioDrive Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +Comment ~ + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 15 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 15 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +~ + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 29 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 31, 29, 33, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 34, 29, 36, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 37, 29, 39, 8 + DB 0 + DB " 75% Filter", 0 + +ALIGN 4 + +VolumeTable DB 2 Dup (0) +MIDIPort DW 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dmasirq.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut1: + In AL, DX + Test AL, AL + JS ESSOut1 + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut2 ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut2A: + In AL, DX + Test AL, 80h + LoopNZ ESSOut2A + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn2 + +ESSInA1: + In AL, DX + Test AL, 40h + LoopZ ESSInA1 + JZ ESSInA2 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +ESSInA2: + Mov AL, 0FFh + Ret + +EndP ESSIn2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn ; DX = 2xCh, returns AL + +ESSIn1: + In AL, DX + Test AL, 40h + JZ ESSIn1 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +EndP ESSIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut ; AL = out + + Push DX + Push AX + + Mov DX, CS:MIDIPort + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + JNZ UARTOut1 + + Pop AX + Dec DX + Out DX, AL + + Pop DX + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTIn ; returns AL + + Push DX + + Mov DX, CS:MIDIPort + Inc DX + +UARTIn1: + In AL, DX + Test AL, 80h + JNZ UARTIn1 + + Dec DX + In AL, DX + + Pop DX + Ret + +EndP UARTIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadMixerRegister ; AL = register to read + ; DX = 2xCh + + Add DL, 04-0Ch + Out DX, AL + Inc DX + In AL, DX + Add DL, 0Ch-05 + + Ret + +EndP ESSReadMixerRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadRegister ; AH = register to read. + ; DX = 2xCh + ; returns AL + + Mov AL, 0C0h + Call ESSOut + Mov AL, AH + Call ESSOut + Call ESSIn + + Ret + +EndP ESSReadRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Xor CX, CX + Add DL, 0Ch ; 2xCh -> Data ready to send... + + Mov AL, 0E1h + Call ESSOut2 + + Call ESSIn2 + Mov AH, AL ; AH = Major version number + Call ESSIn2 ; AL = Minor version number + + Cmp AX, 301h + JNE DetectCardFailure + + Mov AL, 0E7h + Call ESSOut2 + Call ESSIn2 + Mov AH, AL + Call ESSIn2 + + Cmp AH, 68h + JNE DetectCardReset + Cmp AL, 88h + JB DetectCardReset + Cmp AL, 90h + JAE DetectCardReset + ; We have an ES1688 Audiodrive chip! + +Comment ~ + Mov AL, 40h + Call ESSReadMixerRegister + ShL AL, 1 + And AX, 30h + Add AX, 300h + Mov MIDIPort, AX +~ + + Mov AH, 0B1h ; IRQ determination + Call ESSReadRegister + + Mov BX, 9 + And AL, 0Ch + JZ DetectCardIRQ + + Mov BX, 5 + Cmp AL, 4 + JE DetectCardIRQ + + Mov BX, 7 + Cmp AL, 8 + JE DetectCardIRQ + + Mov BX, 10 + Cmp AL, 0Ch + JNE DetectCardFailure + + +DetectCardIRQ: + Mov IRQ, BX + + Mov AH, 0B2h + Call ESSReadRegister + + Xor BX, BX + And AL, 0Ch + JZ DetectCardFailure + + Cmp AL, 4 + JE DetectCardDMA + + Inc BX + Cmp AL, 8 + JE DetectCardDMA + + Add BL, 2 + +DetectCardDMA: + Mov DMA, BX + + Mov EAX, 'Jeff' + ClC + Ret + +DetectCardReset: + Sub DL, 0Ch + Mov AX, DX + Call ResetDSP + +DetectCardFailure: + StC + Ret + + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 3 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Call UARTIn + Mov BL, [MIDIBufferTail] + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + +; Inc Debug + +Comment ~ + Mov DX, [ConfigPort] + Add DL, 6 + In AL, DX + Test AL, 8 + JZ ESSNoMIDI + + Push AX + Call CheckMIDI + Pop AX + +ESSNoMIDI: + Test AL, 1 + JZ ESSIRQEnd +~ + Mov DX, [BasePort] + Add DL, 0Eh + In AL, DX + + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB ESSIRQHandler6 + JE ESSIRQHFilter + + Cmp CS:Stereo, 0 + JE ESSIRQ3QFilterMono + +ESSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +ESSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +ESSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +ESSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilter: + Cmp CS:Stereo, 0 + JE ESSIRQHFilterMono + +ESSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +ESSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +ESSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +ESSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL ESSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG ESSIRQHandlerClip2 + +ESSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ ESSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + +ESSIRQEnd: + Pop ES + Pop DS + PopAD + IRet + +ESSIRQHandlerClip1: + Mov AX, 8000h + Jmp ESSIRQHandler7 + +ESSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp ESSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo3 + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetESSMixConst + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetESSMixConst1 + + Mov CX, 22050 + Cmp AX, CX + JB GetESSMixConst1 + + Mov CX, 56821 + Cmp AX, CX + JA GetESSMixConst1 + + Mov CX, AX + +GetESSMixConst1: ; CX = mixspeed. + Mov DX, 0Ch + Mov AX, 236Ch ; DX:AX = 795.5kHz + Div CX + + Mov BX, AX + Neg AL + Mov ESSMixConst, AL + + Mov DX, 0Ch + Mov AX, 236Ch + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetESSMixConst + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartESS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov AX, BasePort + Call ResetDSP + Mov DX, AX + Add DL, 0Ch + +; Extended Functions + + Mov AL, 0C6h + Call ESSOut + +; Autoinit DMA + + Mov AL, 0B8h + Call ESSOut + Mov AL, 4 + Call ESSOut + +; Stereo/Mono select + + Mov AH, 0A8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0A8h + Call ESSOut + Mov AL, AH + And AL, Not 3 + Or AL, 2 + Cmp Stereo, 0 + JE StartESS1 + + Xor AL, 3 + +StartESS1: + Call ESSOut + +; DMA mode + + Mov AL, 0B9h + Call ESSOut + Mov AL, 2 + Call ESSOut + +; Mixspeed + + Mov AL, 0A1h + Call ESSOut + Mov AL, ESSMixConst + Call ESSOut + +; Filter clock divider + Mov AL, 0A2h + Call ESSOut + + Mov AL, 0FEh + Call ESSOut + +; DMA counter + Mov CX, DMASize + Neg CX + + Mov AL, 0A4h + Call ESSOut + Mov AL, CL + Call ESSOut + Mov AL, 0A5h + Call ESSOut + Mov AL, CH + Call ESSOut + +; Initialise DAC + Mov AL, 0B6h + Call ESSOut + Mov AL, 0 + Call ESSOut + +; Configure DACs + + Mov AL, 0B7h + Call ESSOut + Mov AL, 71h + Call ESSOut + + Mov AL, 0B7h + Call ESSOut + + Mov AL, 0BCh + Cmp Stereo, 0 + JNE StartESS2 + + Mov AL, 0F4h + +StartESS2: + Call ESSOut + +; IRQ configuration + Mov AH, 0B1h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B1h + Call ESSOut + Mov AL, AH + And AL, 0Fh + Or AL, 50h + Call ESSOut + +; DMA configuration + Mov AH, 0B2h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B2h + Call ESSOut + Mov AL, AH + And AL, 0Fh + Or AL, 50h + Call ESSOut + +; Enable voice + Mov AL, 0D1h + Call ESSOut + +; Start transfer + Mov AH, 0B8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B8h + Call ESSOut + Mov AL, AH + Or AL, 1 + Call ESSOut + +Comment ~ + +; Init UART + Mov DX, MIDIPort + Inc DX + Mov AL, 3Fh ; Intelligent mode. + Out DX, AL + +; Enable MIDI IRQ + Mov DX, BasePort + Add DL, 4 + Mov AX, 4064h + Out DX, AX + +~ + + Pop DS + Pop ES + PopA + + Ret + +EndP StartESS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + And AX, 0FF0h + ShR AH, 1 + ShR AL, 5 + Mov Word Ptr [VolumeTable], AX + + Call GetESSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Mov AX, BasePort + Call ResetDSP + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver +; +;DMAPort1 EQU $+1 +; In AL, 1 +; Mov BL, AL +;DMAPort2 EQU $+1 +; In AL, 1 +; Mov BH, AL +; +; Mov Debug2, BX + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov AX, BasePort + Call ResetDSP + Call StartESS + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Mov AH, [VolumeTable] + ShL AH, 4 + Or AH, [VolumeTable+1] + ShL AH, 1 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ES1688MX.ASM b/SoundDrivers/ES1688MX.ASM index 8996d51..7423120 100755 --- a/SoundDrivers/ES1688MX.ASM +++ b/SoundDrivers/ES1688MX.ASM @@ -1,1751 +1,1751 @@ -; -; ESS Technology's ES1688 Audiodrive chip, MMX version. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -OUTPUTFILTERENABLED EQU 0 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -;Debug DW 0 -;Debug2 DW 0 -ESSMsg DB "ES1688 AudioDrive MMX", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "ES1688 AudioDrive MMX", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "ES1688 AudioDrive reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITES1688.MMX", 0 -ConfigOKMsg DB "Configuration saved to ITES1688.MMX", 0 - -DriverName DB "ITES1688.MMX", 0 - -ALIGN 4 -FPSave DB 128 Dup (0) -ESSMixConst DB 0, 0 - -DMASize DW 4096 ; Smaller gives better MIDI timing -ConfigPort DW 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 - -MixSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldESSIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -ESSScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr ESSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - -Comment ~ - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - -~ - - DW 0 - -ESSHeaderLine DW 10 - DB "ESS1688 AudioDrive MMX Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 33, 48 - DB 21h - DB "ESS AudioDrive Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -Comment ~ - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 15 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 15 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -~ - -MixModeText DW 1 - DB 2, 14 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 44100 - DW 0 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 16, 32, 18, 8 - DB 0 - DB " MMX, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 19, 32, 21, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 22, 32, 24, 8 - DB 0 - DB " MMX, Volume Ramped", 0 - -MixModeButton4 DW 2 - DW 8, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " MMX, Filtered", 0 - -ALIGN 4 - -VolumeTable DB 2 Dup (0) -MIDIPort DW 0 - -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dmasirq.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSOut ; AL = data - ; DX = 2xCh - - Push AX - -ESSOut1: - In AL, DX - Test AL, AL - JS ESSOut1 - - Pop AX - Out DX, AL - - Ret - -EndP ESSOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSOut2 ; AL = data - ; DX = 2xCh - - Push AX - -ESSOut2A: - In AL, DX - Test AL, 80h - LoopNZ ESSOut2A - - Pop AX - Out DX, AL - - Ret - -EndP ESSOut2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMMX - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectMMXFail - - Mov EAX, 1 - DB 0Fh, 0A2h ; CPUID - Test EDX, 800000h - JZ DetectMMXFail - - ClC - Ret - -DetectMMXFail: - StC - Ret - -EndP DetectMMX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIn2 - -ESSInA1: - In AL, DX - Test AL, 40h - LoopZ ESSInA1 - JZ ESSInA2 - - Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -ESSInA2: - Mov AL, 0FFh - Ret - -EndP ESSIn2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIn ; DX = 2xCh, returns AL - -ESSIn1: - In AL, DX - Test AL, 40h - JZ ESSIn1 - - Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -EndP ESSIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut ; AL = out - - Push DX - Push AX - - Mov DX, CS:MIDIPort - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - JNZ UARTOut1 - - Pop AX - Dec DX - Out DX, AL - - Pop DX - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTIn ; returns AL - - Push DX - - Mov DX, CS:MIDIPort - Inc DX - -UARTIn1: - In AL, DX - Test AL, 80h - JNZ UARTIn1 - - Dec DX - In AL, DX - - Pop DX - Ret - -EndP UARTIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadMixerRegister ; AL = register to read - ; DX = 2xCh - - Add DL, 04-0Ch - Out DX, AL - Inc DX - In AL, DX - Add DL, 0Ch-05 - - Ret - -EndP ESSReadMixerRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadRegister ; AH = register to read. - ; DX = 2xCh - ; returns AL - - Mov AL, 0C0h - Call ESSOut - Mov AL, AH - Call ESSOut - Call ESSIn - - Ret - -EndP ESSReadRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Call DetectMMX - JC DetectCardFailure - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Xor CX, CX - Add DL, 0Ch ; 2xCh -> Data ready to send... - - Mov AL, 0E1h - Call ESSOut2 - - Call ESSIn2 - Mov AH, AL ; AH = Major version number - Call ESSIn2 ; AL = Minor version number - - Cmp AX, 301h - JNE DetectCardFailure - - Mov AL, 0E7h - Call ESSOut2 - Call ESSIn2 - Mov AH, AL - Call ESSIn2 - - Cmp AH, 68h - JNE DetectCardReset - Cmp AL, 88h - JB DetectCardReset - Cmp AL, 90h - JAE DetectCardReset - ; We have an ES1688 Audiodrive chip! - -Comment ~ - Mov AL, 40h - Call ESSReadMixerRegister - ShL AL, 1 - And AX, 30h - Add AX, 300h - Mov MIDIPort, AX -~ - - Mov AH, 0B1h ; IRQ determination - Call ESSReadRegister - - Mov BX, 9 - And AL, 0Ch - JZ DetectCardIRQ - - Mov BX, 5 - Cmp AL, 4 - JE DetectCardIRQ - - Mov BX, 7 - Cmp AL, 8 - JE DetectCardIRQ - - Mov BX, 10 - Cmp AL, 0Ch - JNE DetectCardFailure - - -DetectCardIRQ: - Mov IRQ, BX - - Mov AH, 0B2h - Call ESSReadRegister - - Xor BX, BX - And AL, 0Ch - JZ DetectCardFailure - - Cmp AL, 4 - JE DetectCardDMA - - Inc BX - Cmp AL, 8 - JE DetectCardDMA - - Add BL, 2 - -DetectCardDMA: - Mov DMA, BX - - Mov EAX, 'Jeff' - ClC - Ret - -DetectCardReset: - Sub DL, 0Ch - Mov AX, DX - Call ResetDSP - -DetectCardFailure: - StC - Ret - - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 3 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Call UARTIn - Mov BL, [MIDIBufferTail] - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - -; Inc Debug - -Comment ~ - Mov DX, [ConfigPort] - Add DL, 6 - In AL, DX - Test AL, 8 - JZ ESSNoMIDI - - Push AX - Call CheckMIDI - Pop AX - -ESSNoMIDI: - Test AL, 1 - JZ ESSIRQEnd -~ - Mov DX, [BasePort] ; ESSAck - Add DL, 0Eh ; ESSAck - In AL, DX ; ESSAck - - Mov AL, 20h ; IRQAck - Cmp IRQ, 8 ; IRQAck - JB WSSAckIRQ1 ; IRQAck - ; IRQAck - Out 0A0h, AL ; IRQAck - ; IRQAck -WSSAckIRQ1: ; IRQAck - Out 20h, AL ; IRQAck - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - FNSave [FPSave] - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Mov BX, DMASize ; BX = bytes required - Add DI, AX - ShR BX, 1 - ; BX = samples required - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRstor [CS:FPSave] - -ESSIRQEnd: - Pop ES - Pop DS - PopAD - IRet - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetESSMixConst - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetESSMixConst1 - - Mov CX, 22050 - Cmp AX, CX - JB GetESSMixConst1 - - Mov CX, 56821 - Cmp AX, CX - JA GetESSMixConst1 - - Mov CX, AX - -GetESSMixConst1: ; CX = mixspeed. - Mov DX, 0Ch - Mov AX, 236Ch ; DX:AX = 795.5kHz - Div CX - - Mov BX, AX - Neg AL - Mov ESSMixConst, AL - - Mov DX, 0Ch - Mov AX, 236Ch - Div BX - Mov MixSpeed, AX - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Pop DS - PopA - Ret - -EndP GetESSMixConst - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartESS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov AX, BasePort - Call ResetDSP - Mov DX, AX - Add DL, 0Ch - -; Extended Functions - - Mov AL, 0C6h - Call ESSOut - -; Autoinit DMA - - Mov AL, 0B8h - Call ESSOut - Mov AL, 4 - Call ESSOut - -; Stereo/Mono select - - Mov AH, 0A8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0A8h - Call ESSOut - Mov AL, AH - And AL, Not 3 - Or AL, 2 - Cmp Stereo, 0 - JE StartESS1 - - Xor AL, 3 - -StartESS1: - Call ESSOut - -; DMA mode - - Mov AL, 0B9h - Call ESSOut - Mov AL, 2 - Call ESSOut - -; Mixspeed - - Mov AL, 0A1h - Call ESSOut - Mov AL, ESSMixConst - Call ESSOut - -; Filter clock divider - Mov AL, 0A2h - Call ESSOut - - Mov AL, 0FEh - Call ESSOut - -; DMA counter - Mov CX, DMASize - Neg CX - - Mov AL, 0A4h - Call ESSOut - Mov AL, CL - Call ESSOut - Mov AL, 0A5h - Call ESSOut - Mov AL, CH - Call ESSOut - -; Initialise DAC - Mov AL, 0B6h - Call ESSOut - Mov AL, 0 - Call ESSOut - -; Configure DACs - - Mov AL, 0B7h - Call ESSOut - Mov AL, 71h - Call ESSOut - - Mov AL, 0B7h - Call ESSOut - - Mov AL, 0BCh - Cmp Stereo, 0 - JNE StartESS2 - - Mov AL, 0F4h - -StartESS2: - Call ESSOut - -; IRQ configuration - Mov AH, 0B1h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B1h - Call ESSOut - Mov AL, AH - And AL, 0Fh - Or AL, 50h - Call ESSOut - -; DMA configuration - Mov AH, 0B2h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B2h - Call ESSOut - Mov AL, AH - And AL, 0Fh - Or AL, 50h - Call ESSOut - -; Enable voice - Mov AL, 0D1h - Call ESSOut - -; Start transfer - Mov AH, 0B8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B8h - Call ESSOut - Mov AL, AH - Or AL, 1 - Call ESSOut - -Comment ~ - -; Init UART - Mov DX, MIDIPort - Inc DX - Mov AL, 3Fh ; Intelligent mode. - Out DX, AL - -; Enable MIDI IRQ - Mov DX, BasePort - Add DL, 4 - Mov AX, 4064h - Out DX, AX - -~ - - Pop DS - Pop ES - PopA - - Ret - -EndP StartESS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - And AX, 0FF0h - ShR AH, 1 - ShR AL, 5 - Mov Word Ptr [VolumeTable], AX - - Call GetESSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, (DMABUFFERLENGTH*2)/16 + 5 - Mov BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Mov AX, BasePort - Call ResetDSP - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver -; -;DMAPort1 EQU $+1 -; In AL, 1 -; Mov BL, AL -;DMAPort2 EQU $+1 -; In AL, 1 -; Mov BH, AL -; -; Mov Debug2, BX - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov AX, BasePort - Call ResetDSP - Call StartESS - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Mov AH, [VolumeTable] - ShL AH, 4 - Or AH, [VolumeTable+1] - ShL AH, 1 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h -; Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: -; Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 - DW 3 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ESS Technology's ES1688 Audiodrive chip, MMX version. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +OUTPUTFILTERENABLED EQU 0 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +;Debug DW 0 +;Debug2 DW 0 +ESSMsg DB "ES1688 AudioDrive MMX", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "ES1688 AudioDrive MMX", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "ES1688 AudioDrive reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITES1688.MMX", 0 +ConfigOKMsg DB "Configuration saved to ITES1688.MMX", 0 + +DriverName DB "ITES1688.MMX", 0 + +ALIGN 4 +FPSave DB 128 Dup (0) +ESSMixConst DB 0, 0 + +DMASize DW 4096 ; Smaller gives better MIDI timing +ConfigPort DW 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + +Comment ~ + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + +~ + + DW 0 + +ESSHeaderLine DW 10 + DB "ESS1688 AudioDrive MMX Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 33, 48 + DB 21h + DB "ESS AudioDrive Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +Comment ~ + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 15 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 15 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +~ + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + DW 0 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " MMX, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " MMX, Volume Ramped", 0 + +MixModeButton4 DW 2 + DW 8, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " MMX, Filtered", 0 + +ALIGN 4 + +VolumeTable DB 2 Dup (0) +MIDIPort DW 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dmasirq.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut1: + In AL, DX + Test AL, AL + JS ESSOut1 + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut2 ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut2A: + In AL, DX + Test AL, 80h + LoopNZ ESSOut2A + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMMX + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectMMXFail + + Mov EAX, 1 + DB 0Fh, 0A2h ; CPUID + Test EDX, 800000h + JZ DetectMMXFail + + ClC + Ret + +DetectMMXFail: + StC + Ret + +EndP DetectMMX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn2 + +ESSInA1: + In AL, DX + Test AL, 40h + LoopZ ESSInA1 + JZ ESSInA2 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +ESSInA2: + Mov AL, 0FFh + Ret + +EndP ESSIn2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn ; DX = 2xCh, returns AL + +ESSIn1: + In AL, DX + Test AL, 40h + JZ ESSIn1 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +EndP ESSIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut ; AL = out + + Push DX + Push AX + + Mov DX, CS:MIDIPort + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + JNZ UARTOut1 + + Pop AX + Dec DX + Out DX, AL + + Pop DX + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTIn ; returns AL + + Push DX + + Mov DX, CS:MIDIPort + Inc DX + +UARTIn1: + In AL, DX + Test AL, 80h + JNZ UARTIn1 + + Dec DX + In AL, DX + + Pop DX + Ret + +EndP UARTIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadMixerRegister ; AL = register to read + ; DX = 2xCh + + Add DL, 04-0Ch + Out DX, AL + Inc DX + In AL, DX + Add DL, 0Ch-05 + + Ret + +EndP ESSReadMixerRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadRegister ; AH = register to read. + ; DX = 2xCh + ; returns AL + + Mov AL, 0C0h + Call ESSOut + Mov AL, AH + Call ESSOut + Call ESSIn + + Ret + +EndP ESSReadRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Call DetectMMX + JC DetectCardFailure + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Xor CX, CX + Add DL, 0Ch ; 2xCh -> Data ready to send... + + Mov AL, 0E1h + Call ESSOut2 + + Call ESSIn2 + Mov AH, AL ; AH = Major version number + Call ESSIn2 ; AL = Minor version number + + Cmp AX, 301h + JNE DetectCardFailure + + Mov AL, 0E7h + Call ESSOut2 + Call ESSIn2 + Mov AH, AL + Call ESSIn2 + + Cmp AH, 68h + JNE DetectCardReset + Cmp AL, 88h + JB DetectCardReset + Cmp AL, 90h + JAE DetectCardReset + ; We have an ES1688 Audiodrive chip! + +Comment ~ + Mov AL, 40h + Call ESSReadMixerRegister + ShL AL, 1 + And AX, 30h + Add AX, 300h + Mov MIDIPort, AX +~ + + Mov AH, 0B1h ; IRQ determination + Call ESSReadRegister + + Mov BX, 9 + And AL, 0Ch + JZ DetectCardIRQ + + Mov BX, 5 + Cmp AL, 4 + JE DetectCardIRQ + + Mov BX, 7 + Cmp AL, 8 + JE DetectCardIRQ + + Mov BX, 10 + Cmp AL, 0Ch + JNE DetectCardFailure + + +DetectCardIRQ: + Mov IRQ, BX + + Mov AH, 0B2h + Call ESSReadRegister + + Xor BX, BX + And AL, 0Ch + JZ DetectCardFailure + + Cmp AL, 4 + JE DetectCardDMA + + Inc BX + Cmp AL, 8 + JE DetectCardDMA + + Add BL, 2 + +DetectCardDMA: + Mov DMA, BX + + Mov EAX, 'Jeff' + ClC + Ret + +DetectCardReset: + Sub DL, 0Ch + Mov AX, DX + Call ResetDSP + +DetectCardFailure: + StC + Ret + + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 3 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Call UARTIn + Mov BL, [MIDIBufferTail] + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + +; Inc Debug + +Comment ~ + Mov DX, [ConfigPort] + Add DL, 6 + In AL, DX + Test AL, 8 + JZ ESSNoMIDI + + Push AX + Call CheckMIDI + Pop AX + +ESSNoMIDI: + Test AL, 1 + JZ ESSIRQEnd +~ + Mov DX, [BasePort] ; ESSAck + Add DL, 0Eh ; ESSAck + In AL, DX ; ESSAck + + Mov AL, 20h ; IRQAck + Cmp IRQ, 8 ; IRQAck + JB WSSAckIRQ1 ; IRQAck + ; IRQAck + Out 0A0h, AL ; IRQAck + ; IRQAck +WSSAckIRQ1: ; IRQAck + Out 20h, AL ; IRQAck + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + FNSave [FPSave] + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Mov BX, DMASize ; BX = bytes required + Add DI, AX + ShR BX, 1 + ; BX = samples required + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRstor [CS:FPSave] + +ESSIRQEnd: + Pop ES + Pop DS + PopAD + IRet + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetESSMixConst + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetESSMixConst1 + + Mov CX, 22050 + Cmp AX, CX + JB GetESSMixConst1 + + Mov CX, 56821 + Cmp AX, CX + JA GetESSMixConst1 + + Mov CX, AX + +GetESSMixConst1: ; CX = mixspeed. + Mov DX, 0Ch + Mov AX, 236Ch ; DX:AX = 795.5kHz + Div CX + + Mov BX, AX + Neg AL + Mov ESSMixConst, AL + + Mov DX, 0Ch + Mov AX, 236Ch + Div BX + Mov MixSpeed, AX + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Pop DS + PopA + Ret + +EndP GetESSMixConst + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartESS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov AX, BasePort + Call ResetDSP + Mov DX, AX + Add DL, 0Ch + +; Extended Functions + + Mov AL, 0C6h + Call ESSOut + +; Autoinit DMA + + Mov AL, 0B8h + Call ESSOut + Mov AL, 4 + Call ESSOut + +; Stereo/Mono select + + Mov AH, 0A8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0A8h + Call ESSOut + Mov AL, AH + And AL, Not 3 + Or AL, 2 + Cmp Stereo, 0 + JE StartESS1 + + Xor AL, 3 + +StartESS1: + Call ESSOut + +; DMA mode + + Mov AL, 0B9h + Call ESSOut + Mov AL, 2 + Call ESSOut + +; Mixspeed + + Mov AL, 0A1h + Call ESSOut + Mov AL, ESSMixConst + Call ESSOut + +; Filter clock divider + Mov AL, 0A2h + Call ESSOut + + Mov AL, 0FEh + Call ESSOut + +; DMA counter + Mov CX, DMASize + Neg CX + + Mov AL, 0A4h + Call ESSOut + Mov AL, CL + Call ESSOut + Mov AL, 0A5h + Call ESSOut + Mov AL, CH + Call ESSOut + +; Initialise DAC + Mov AL, 0B6h + Call ESSOut + Mov AL, 0 + Call ESSOut + +; Configure DACs + + Mov AL, 0B7h + Call ESSOut + Mov AL, 71h + Call ESSOut + + Mov AL, 0B7h + Call ESSOut + + Mov AL, 0BCh + Cmp Stereo, 0 + JNE StartESS2 + + Mov AL, 0F4h + +StartESS2: + Call ESSOut + +; IRQ configuration + Mov AH, 0B1h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B1h + Call ESSOut + Mov AL, AH + And AL, 0Fh + Or AL, 50h + Call ESSOut + +; DMA configuration + Mov AH, 0B2h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B2h + Call ESSOut + Mov AL, AH + And AL, 0Fh + Or AL, 50h + Call ESSOut + +; Enable voice + Mov AL, 0D1h + Call ESSOut + +; Start transfer + Mov AH, 0B8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B8h + Call ESSOut + Mov AL, AH + Or AL, 1 + Call ESSOut + +Comment ~ + +; Init UART + Mov DX, MIDIPort + Inc DX + Mov AL, 3Fh ; Intelligent mode. + Out DX, AL + +; Enable MIDI IRQ + Mov DX, BasePort + Add DL, 4 + Mov AX, 4064h + Out DX, AX + +~ + + Pop DS + Pop ES + PopA + + Ret + +EndP StartESS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + And AX, 0FF0h + ShR AH, 1 + ShR AL, 5 + Mov Word Ptr [VolumeTable], AX + + Call GetESSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, (DMABUFFERLENGTH*2)/16 + 5 + Mov BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Mov AX, BasePort + Call ResetDSP + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver +; +;DMAPort1 EQU $+1 +; In AL, 1 +; Mov BL, AL +;DMAPort2 EQU $+1 +; In AL, 1 +; Mov BH, AL +; +; Mov Debug2, BX + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov AX, BasePort + Call ResetDSP + Call StartESS + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Mov AH, [VolumeTable] + ShL AH, 4 + Or AH, [VolumeTable+1] + ShL AH, 1 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h +; Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: +; Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 + DW 3 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ES1868.ASM b/SoundDrivers/ES1868.ASM index ab64c5f..4d75c70 100755 --- a/SoundDrivers/ES1868.ASM +++ b/SoundDrivers/ES1868.ASM @@ -1,2328 +1,2328 @@ -; -; ESS Technology's ES1868 AudioDrive chip. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 68187316h - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -ESSMsg DB "ESS ES1868 AudioDrive found", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "ESS ES1868 AudioDrive found", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "ESS ES1868 AudioDrive reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITES1868.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITES1868.DRV", 0 - -DriverName DB "ITES1868.DRV", 0 - -ALIGN 4 -FilterValue DD 0 -FilterValue2 DD 0 -ESSMixConst DB 0, 0 - -DMASize DW 2048 ; Smaller gives better MIDI timing -ConfigPort DW 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldESSIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -ESSScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr ESSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - -Comment ~ - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - -~ - - DW 0 - -ESSHeaderLine DW 10 - DB "ESS ES1868 AudioDrive Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 26, 48 - DB 21h - DB "ESS ES1868 AudioDrive Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -Comment ~ - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 15 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 15 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -~ - -MixModeText DW 1 - DB 2, 14 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 44100 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 16, 32, 18, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 19, 32, 21, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 22, 32, 24, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 29 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 31, 29, 33, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 34, 29, 36, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 37, 29, 39, 8 - DB 0 - DB " 75% Filter", 0 - -ALIGN 4 - -VolumeTable DB 2 Dup (0) -MIDIPort DW 0 - -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSOut ; AL = data - ; DX = 2xCh - - Push AX - -ESSOut1: - In AL, DX - Test AL, AL - JS ESSOut1 - - Pop AX - Out DX, AL - - Ret - -EndP ESSOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIn ; DX = 2xCh, returns AL - -ESSIn1: - In AL, DX - Test AL, 40h - JZ ESSIn1 - - Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -EndP ESSIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut ; AL = out - - Push DX - Push AX - - Mov DX, CS:MIDIPort - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - JNZ UARTOut1 - - Pop AX - Dec DX - Out DX, AL - - Pop DX - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTIn ; returns AL - - Push DX - - Mov DX, CS:MIDIPort - Inc DX - -UARTIn1: - In AL, DX - Test AL, 80h - JNZ UARTIn1 - - Dec DX - In AL, DX - - Pop DX - Ret - -EndP UARTIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadRegister ; AH = register to read. - ; DX = 2xCh - ; returns AL - - Mov AL, 0C0h - Call ESSOut - Mov AL, AH - Call ESSOut - Call ESSIn - - Ret - -EndP ESSReadRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - -; Cmp PnP_VendorID, PNPVENDORID -; JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Mov ConfigPort, AX - - Mov AX, 107h ; Audio device - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - Mov MIDIPort, AX - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, CS:MIDIPort - Inc DX - Mov AL, 0FFh - Out DX, AL - - Mov DX, CS:BasePort - Add DL, 6 - Mov AL, 3 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Call UARTIn - Mov BL, [MIDIBufferTail] - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [ConfigPort] - Add DL, 6 - In AL, DX - Test AL, 8 - JZ ESSNoMIDI - - Push AX - Call CheckMIDI - Pop AX - -ESSNoMIDI: - Test AL, 1 - JZ ESSIRQEnd - - Mov DX, [BasePort] - Add DL, 0Eh - In AL, DX - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB ESSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -ESSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB ESSIRQHandler6 - JE ESSIRQHFilter - - Cmp CS:Stereo, 0 - JE ESSIRQ3QFilterMono - -ESSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -ESSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -ESSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -ESSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilter: - Cmp CS:Stereo, 0 - JE ESSIRQHFilterMono - -ESSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -ESSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -ESSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -ESSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL ESSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG ESSIRQHandlerClip2 - -ESSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ ESSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - -ESSIRQEnd: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Pop ES - Pop DS - PopAD - IRet - -ESSIRQHandlerClip1: - Mov AX, 8000h - Jmp ESSIRQHandler7 - -ESSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp ESSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo3 - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetESSMixConst - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetESSMixConst1 - - Mov CX, 22050 - Cmp AX, CX - JB GetESSMixConst1 - - Mov CX, 56821 - Cmp AX, CX - JA GetESSMixConst1 - - Mov CX, AX - -GetESSMixConst1: ; CX = mixspeed. - Mov DX, 0Ch - Mov AX, 236Ch ; DX:AX = 795.5kHz - Div CX - - Mov BX, AX - Neg AL - Mov ESSMixConst, AL - - Mov DX, 0Ch - Mov AX, 236Ch - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetESSMixConst - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartESS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Call ResetDSP - Mov DX, BasePort - Add DL, 0Ch - -; Extended Functions - - Mov AL, 0C6h - Call ESSOut - -; Autoinit DMA - - Mov AL, 0B8h - Call ESSOut - Mov AL, 4 - Call ESSOut - -; Stereo/Mono select - - Mov AH, 0A8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0A8h - Call ESSOut - Mov AL, AH - And AL, Not 3 - Or AL, 2 - Cmp Stereo, 0 - JE StartESS1 - - Xor AL, 3 - -StartESS1: - Call ESSOut - -; DMA mode - - Mov AL, 0B9h - Call ESSOut - Mov AL, 2 - Call ESSOut - -; Mixspeed - - Mov AL, 0A1h - Call ESSOut - Mov AL, ESSMixConst - Call ESSOut - -; Filter clock divider - Mov AL, 0A2h - Call ESSOut - - Mov AL, 0FEh - Call ESSOut - -; DMA counter - Mov CX, DMASize - Neg CX - - Mov AL, 0A4h - Call ESSOut - Mov AL, CL - Call ESSOut - Mov AL, 0A5h - Call ESSOut - Mov AL, CH - Call ESSOut - -; Initialise DAC - Mov AL, 0B6h - Call ESSOut - Mov AL, 0 - Call ESSOut - -; Configure DACs - - Mov AL, 0B7h - Call ESSOut - Mov AL, 71h - Call ESSOut - - Mov AL, 0B7h - Call ESSOut - - Mov AL, 0BCh - Cmp Stereo, 0 - JNE StartESS2 - - Mov AL, 0F4h - -StartESS2: - Call ESSOut - -; IRQ configuration - Mov AL, 0B1h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; DMA configuration - Mov AL, 0B2h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; Enable voice - Mov AL, 0D1h - Call ESSOut - -; Start transfer - Mov AH, 0B8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B8h - Call ESSOut - Mov AL, AH - Or AL, 1 - Call ESSOut - -; Init UART - Mov DX, MIDIPort - Inc DX - Mov AL, 3Fh ; Intelligent mode. - Out DX, AL - -; Enable MIDI IRQ - Mov DX, BasePort - Add DL, 4 - Mov AX, 4064h - Out DX, AX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartESS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - And AX, 0FF0h - ShR AH, 1 - ShR AL, 5 - Mov Word Ptr [VolumeTable], AX - - Call GetESSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetDSP - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call ResetDSP - Call StartESS - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Mov AH, [VolumeTable] - ShL AH, 4 - Or AH, [VolumeTable+1] - ShL AH, 1 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ESS Technology's ES1868 AudioDrive chip. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 68187316h + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +ESSMsg DB "ESS ES1868 AudioDrive found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "ESS ES1868 AudioDrive found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "ESS ES1868 AudioDrive reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITES1868.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITES1868.DRV", 0 + +DriverName DB "ITES1868.DRV", 0 + +ALIGN 4 +FilterValue DD 0 +FilterValue2 DD 0 +ESSMixConst DB 0, 0 + +DMASize DW 2048 ; Smaller gives better MIDI timing +ConfigPort DW 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + +Comment ~ + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + +~ + + DW 0 + +ESSHeaderLine DW 10 + DB "ESS ES1868 AudioDrive Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 26, 48 + DB 21h + DB "ESS ES1868 AudioDrive Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +Comment ~ + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 15 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 15 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +~ + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 29 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 31, 29, 33, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 34, 29, 36, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 37, 29, 39, 8 + DB 0 + DB " 75% Filter", 0 + +ALIGN 4 + +VolumeTable DB 2 Dup (0) +MIDIPort DW 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut1: + In AL, DX + Test AL, AL + JS ESSOut1 + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn ; DX = 2xCh, returns AL + +ESSIn1: + In AL, DX + Test AL, 40h + JZ ESSIn1 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +EndP ESSIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut ; AL = out + + Push DX + Push AX + + Mov DX, CS:MIDIPort + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + JNZ UARTOut1 + + Pop AX + Dec DX + Out DX, AL + + Pop DX + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTIn ; returns AL + + Push DX + + Mov DX, CS:MIDIPort + Inc DX + +UARTIn1: + In AL, DX + Test AL, 80h + JNZ UARTIn1 + + Dec DX + In AL, DX + + Pop DX + Ret + +EndP UARTIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadRegister ; AH = register to read. + ; DX = 2xCh + ; returns AL + + Mov AL, 0C0h + Call ESSOut + Mov AL, AH + Call ESSOut + Call ESSIn + + Ret + +EndP ESSReadRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + +; Cmp PnP_VendorID, PNPVENDORID +; JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Mov ConfigPort, AX + + Mov AX, 107h ; Audio device + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + Mov MIDIPort, AX + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, CS:MIDIPort + Inc DX + Mov AL, 0FFh + Out DX, AL + + Mov DX, CS:BasePort + Add DL, 6 + Mov AL, 3 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Call UARTIn + Mov BL, [MIDIBufferTail] + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [ConfigPort] + Add DL, 6 + In AL, DX + Test AL, 8 + JZ ESSNoMIDI + + Push AX + Call CheckMIDI + Pop AX + +ESSNoMIDI: + Test AL, 1 + JZ ESSIRQEnd + + Mov DX, [BasePort] + Add DL, 0Eh + In AL, DX + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB ESSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +ESSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB ESSIRQHandler6 + JE ESSIRQHFilter + + Cmp CS:Stereo, 0 + JE ESSIRQ3QFilterMono + +ESSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +ESSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +ESSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +ESSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilter: + Cmp CS:Stereo, 0 + JE ESSIRQHFilterMono + +ESSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +ESSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +ESSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +ESSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL ESSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG ESSIRQHandlerClip2 + +ESSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ ESSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + +ESSIRQEnd: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Pop ES + Pop DS + PopAD + IRet + +ESSIRQHandlerClip1: + Mov AX, 8000h + Jmp ESSIRQHandler7 + +ESSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp ESSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo3 + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetESSMixConst + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetESSMixConst1 + + Mov CX, 22050 + Cmp AX, CX + JB GetESSMixConst1 + + Mov CX, 56821 + Cmp AX, CX + JA GetESSMixConst1 + + Mov CX, AX + +GetESSMixConst1: ; CX = mixspeed. + Mov DX, 0Ch + Mov AX, 236Ch ; DX:AX = 795.5kHz + Div CX + + Mov BX, AX + Neg AL + Mov ESSMixConst, AL + + Mov DX, 0Ch + Mov AX, 236Ch + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetESSMixConst + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartESS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Call ResetDSP + Mov DX, BasePort + Add DL, 0Ch + +; Extended Functions + + Mov AL, 0C6h + Call ESSOut + +; Autoinit DMA + + Mov AL, 0B8h + Call ESSOut + Mov AL, 4 + Call ESSOut + +; Stereo/Mono select + + Mov AH, 0A8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0A8h + Call ESSOut + Mov AL, AH + And AL, Not 3 + Or AL, 2 + Cmp Stereo, 0 + JE StartESS1 + + Xor AL, 3 + +StartESS1: + Call ESSOut + +; DMA mode + + Mov AL, 0B9h + Call ESSOut + Mov AL, 2 + Call ESSOut + +; Mixspeed + + Mov AL, 0A1h + Call ESSOut + Mov AL, ESSMixConst + Call ESSOut + +; Filter clock divider + Mov AL, 0A2h + Call ESSOut + + Mov AL, 0FEh + Call ESSOut + +; DMA counter + Mov CX, DMASize + Neg CX + + Mov AL, 0A4h + Call ESSOut + Mov AL, CL + Call ESSOut + Mov AL, 0A5h + Call ESSOut + Mov AL, CH + Call ESSOut + +; Initialise DAC + Mov AL, 0B6h + Call ESSOut + Mov AL, 0 + Call ESSOut + +; Configure DACs + + Mov AL, 0B7h + Call ESSOut + Mov AL, 71h + Call ESSOut + + Mov AL, 0B7h + Call ESSOut + + Mov AL, 0BCh + Cmp Stereo, 0 + JNE StartESS2 + + Mov AL, 0F4h + +StartESS2: + Call ESSOut + +; IRQ configuration + Mov AL, 0B1h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; DMA configuration + Mov AL, 0B2h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; Enable voice + Mov AL, 0D1h + Call ESSOut + +; Start transfer + Mov AH, 0B8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B8h + Call ESSOut + Mov AL, AH + Or AL, 1 + Call ESSOut + +; Init UART + Mov DX, MIDIPort + Inc DX + Mov AL, 3Fh ; Intelligent mode. + Out DX, AL + +; Enable MIDI IRQ + Mov DX, BasePort + Add DL, 4 + Mov AX, 4064h + Out DX, AX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartESS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + And AX, 0FF0h + ShR AH, 1 + ShR AL, 5 + Mov Word Ptr [VolumeTable], AX + + Call GetESSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetDSP + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call ResetDSP + Call StartESS + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Mov AH, [VolumeTable] + ShL AH, 4 + Or AH, [VolumeTable+1] + ShL AH, 1 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ES1868MX.ASM b/SoundDrivers/ES1868MX.ASM index 36f4721..ba2bc35 100755 --- a/SoundDrivers/ES1868MX.ASM +++ b/SoundDrivers/ES1868MX.ASM @@ -1,1734 +1,1734 @@ -; -; ESS Technology's ES1868 AudioDrive chip. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 68187316h - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -OUTPUTFILTERENABLED EQU 0 - -FPSave DB 128 Dup (0) - -ESSMsg DB "ESS ES1868 AudioDrive MMX", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "ESS ES1868 AudioDrive MMX", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "ESS ES1868 AudioDrive reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITES1868.MMX", 0 -ConfigOKMsg DB "Configuration saved to ITES1868.MMX", 0 - -DriverName DB "ITES1868.MMX", 0 - -ALIGN 4 -ESSMixConst DB 0, 0 - -DMASize DW 2048 ; Smaller gives better MIDI timing -ConfigPort DW 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 - -MixSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 4 -MixMode DW 0 -MixModeOffset DW 0 - -IMR DW 0 -OldESSIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -ESSScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr ESSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW 0 - -ESSHeaderLine DW 10 - DB "ESS ES1868 AudioDrive MMX Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 22, 48 - DB 21h - DB "ESS ES1868 AudioDrive MMX Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MixModeText DW 1 - DB 2, 14 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 44100 - DW 0 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 16, 32, 18, 8 - DB 0 - DB " MMX, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 19, 32, 21, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 22, 32, 24, 8 - DB 0 - DB " MMX, Volume Ramped", 0 - -MixModeButton4 DW 2 - DW 8, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " MMX, Filtered", 0 - -ALIGN 4 - -VolumeTable DB 2 Dup (0) -MIDIPort DW 0 - -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSOut ; AL = data - ; DX = 2xCh - - Push AX - -ESSOut1: - In AL, DX - Test AL, AL - JS ESSOut1 - - Pop AX - Out DX, AL - - Ret - -EndP ESSOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIn ; DX = 2xCh, returns AL - -ESSIn1: - In AL, DX - Test AL, 40h - JZ ESSIn1 - - Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -EndP ESSIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut ; AL = out - - Push DX - Push AX - - Mov DX, CS:MIDIPort - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - JNZ UARTOut1 - - Pop AX - Dec DX - Out DX, AL - - Pop DX - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTIn ; returns AL - - Push DX - - Mov DX, CS:MIDIPort - Inc DX - -UARTIn1: - In AL, DX - Test AL, 80h - JNZ UARTIn1 - - Dec DX - In AL, DX - - Pop DX - Ret - -EndP UARTIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadRegister ; AH = register to read. - ; DX = 2xCh - ; returns AL - - Mov AL, 0C0h - Call ESSOut - Mov AL, AH - Call ESSOut - Call ESSIn - - Ret - -EndP ESSReadRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - -; Cmp PnP_VendorID, PNPVENDORID -; JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Mov ConfigPort, AX - - Mov AX, 107h ; Audio device - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - Mov MIDIPort, AX - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, CS:MIDIPort - Inc DX - Mov AL, 0FFh - Out DX, AL - - Mov DX, CS:BasePort - Add DL, 6 - Mov AL, 3 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Call UARTIn - Mov BL, [MIDIBufferTail] - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [ConfigPort] - Add DL, 6 - In AL, DX - Test AL, 8 - JZ ESSNoMIDI - - Push AX - Call CheckMIDI - Pop AX - -ESSNoMIDI: - Test AL, 1 - JZ ESSIRQEnd - - Mov DX, [BasePort] - Add DL, 0Eh - In AL, DX - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB ESSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -ESSIRQHandler2: - FNSave [FPSave] - - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRStor [CS:FPSave] - -ESSIRQEnd: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Pop ES - Pop DS - PopAD - IRet - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetESSMixConst - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetESSMixConst1 - - Mov CX, 22050 - Cmp AX, CX - JB GetESSMixConst1 - - Mov CX, 56821 - Cmp AX, CX - JA GetESSMixConst1 - - Mov CX, AX - -GetESSMixConst1: ; CX = mixspeed. - Mov DX, 0Ch - Mov AX, 236Ch ; DX:AX = 795.5kHz - Div CX - - Mov BX, AX - Neg AL - Mov ESSMixConst, AL - - Mov DX, 0Ch - Mov AX, 236Ch - Div BX - Mov MixSpeed, AX - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Pop DS - PopA - Ret - -EndP GetESSMixConst - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartESS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Call ResetDSP - Mov DX, BasePort - Add DL, 0Ch - -; Extended Functions - - Mov AL, 0C6h - Call ESSOut - -; Autoinit DMA - - Mov AL, 0B8h - Call ESSOut - Mov AL, 4 - Call ESSOut - -; Stereo/Mono select - - Mov AH, 0A8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0A8h - Call ESSOut - Mov AL, AH - And AL, Not 3 - Or AL, 2 - Cmp Stereo, 0 - JE StartESS1 - - Xor AL, 3 - -StartESS1: - Call ESSOut - -; DMA mode - - Mov AL, 0B9h - Call ESSOut - Mov AL, 2 - Call ESSOut - -; Mixspeed - - Mov AL, 0A1h - Call ESSOut - Mov AL, ESSMixConst - Call ESSOut - -; Filter clock divider - Mov AL, 0A2h - Call ESSOut - - Mov AL, 0FEh - Call ESSOut - -; DMA counter - Mov CX, DMASize - Neg CX - - Mov AL, 0A4h - Call ESSOut - Mov AL, CL - Call ESSOut - Mov AL, 0A5h - Call ESSOut - Mov AL, CH - Call ESSOut - -; Initialise DAC - Mov AL, 0B6h - Call ESSOut - Mov AL, 0 - Call ESSOut - -; Configure DACs - - Mov AL, 0B7h - Call ESSOut - Mov AL, 71h - Call ESSOut - - Mov AL, 0B7h - Call ESSOut - - Mov AL, 0BCh - Cmp Stereo, 0 - JNE StartESS2 - - Mov AL, 0F4h - -StartESS2: - Call ESSOut - -; IRQ configuration - Mov AL, 0B1h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; DMA configuration - Mov AL, 0B2h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; Enable voice - Mov AL, 0D1h - Call ESSOut - -; Start transfer - Mov AH, 0B8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B8h - Call ESSOut - Mov AL, AH - Or AL, 1 - Call ESSOut - -; Init UART - Mov DX, MIDIPort - Inc DX - Mov AL, 3Fh ; Intelligent mode. - Out DX, AL - -; Enable MIDI IRQ - Mov DX, BasePort - Add DL, 4 - Mov AX, 4064h - Out DX, AX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartESS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - And AX, 0FF0h - ShR AH, 1 - ShR AL, 5 - Mov Word Ptr [VolumeTable], AX - - Call GetESSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, (DMABUFFERLENGTH*2)/16+5 - Mov BX, DX - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetDSP - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call ResetDSP - Call StartESS - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Mov AH, [VolumeTable] - ShL AH, 4 - Or AH, [VolumeTable+1] - ShL AH, 1 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 - DW 3 ; MIDI, hiqual - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ESS Technology's ES1868 AudioDrive chip. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 68187316h + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +OUTPUTFILTERENABLED EQU 0 + +FPSave DB 128 Dup (0) + +ESSMsg DB "ESS ES1868 AudioDrive MMX", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "ESS ES1868 AudioDrive MMX", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "ESS ES1868 AudioDrive reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITES1868.MMX", 0 +ConfigOKMsg DB "Configuration saved to ITES1868.MMX", 0 + +DriverName DB "ITES1868.MMX", 0 + +ALIGN 4 +ESSMixConst DB 0, 0 + +DMASize DW 2048 ; Smaller gives better MIDI timing +ConfigPort DW 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 4 +MixMode DW 0 +MixModeOffset DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW 0 + +ESSHeaderLine DW 10 + DB "ESS ES1868 AudioDrive MMX Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 22, 48 + DB 21h + DB "ESS ES1868 AudioDrive MMX Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + DW 0 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " MMX, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " MMX, Volume Ramped", 0 + +MixModeButton4 DW 2 + DW 8, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " MMX, Filtered", 0 + +ALIGN 4 + +VolumeTable DB 2 Dup (0) +MIDIPort DW 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut1: + In AL, DX + Test AL, AL + JS ESSOut1 + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn ; DX = 2xCh, returns AL + +ESSIn1: + In AL, DX + Test AL, 40h + JZ ESSIn1 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +EndP ESSIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut ; AL = out + + Push DX + Push AX + + Mov DX, CS:MIDIPort + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + JNZ UARTOut1 + + Pop AX + Dec DX + Out DX, AL + + Pop DX + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTIn ; returns AL + + Push DX + + Mov DX, CS:MIDIPort + Inc DX + +UARTIn1: + In AL, DX + Test AL, 80h + JNZ UARTIn1 + + Dec DX + In AL, DX + + Pop DX + Ret + +EndP UARTIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadRegister ; AH = register to read. + ; DX = 2xCh + ; returns AL + + Mov AL, 0C0h + Call ESSOut + Mov AL, AH + Call ESSOut + Call ESSIn + + Ret + +EndP ESSReadRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + +; Cmp PnP_VendorID, PNPVENDORID +; JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Mov ConfigPort, AX + + Mov AX, 107h ; Audio device + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + Mov MIDIPort, AX + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, CS:MIDIPort + Inc DX + Mov AL, 0FFh + Out DX, AL + + Mov DX, CS:BasePort + Add DL, 6 + Mov AL, 3 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Call UARTIn + Mov BL, [MIDIBufferTail] + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [ConfigPort] + Add DL, 6 + In AL, DX + Test AL, 8 + JZ ESSNoMIDI + + Push AX + Call CheckMIDI + Pop AX + +ESSNoMIDI: + Test AL, 1 + JZ ESSIRQEnd + + Mov DX, [BasePort] + Add DL, 0Eh + In AL, DX + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB ESSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +ESSIRQHandler2: + FNSave [FPSave] + + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRStor [CS:FPSave] + +ESSIRQEnd: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Pop ES + Pop DS + PopAD + IRet + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetESSMixConst + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetESSMixConst1 + + Mov CX, 22050 + Cmp AX, CX + JB GetESSMixConst1 + + Mov CX, 56821 + Cmp AX, CX + JA GetESSMixConst1 + + Mov CX, AX + +GetESSMixConst1: ; CX = mixspeed. + Mov DX, 0Ch + Mov AX, 236Ch ; DX:AX = 795.5kHz + Div CX + + Mov BX, AX + Neg AL + Mov ESSMixConst, AL + + Mov DX, 0Ch + Mov AX, 236Ch + Div BX + Mov MixSpeed, AX + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Pop DS + PopA + Ret + +EndP GetESSMixConst + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartESS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Call ResetDSP + Mov DX, BasePort + Add DL, 0Ch + +; Extended Functions + + Mov AL, 0C6h + Call ESSOut + +; Autoinit DMA + + Mov AL, 0B8h + Call ESSOut + Mov AL, 4 + Call ESSOut + +; Stereo/Mono select + + Mov AH, 0A8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0A8h + Call ESSOut + Mov AL, AH + And AL, Not 3 + Or AL, 2 + Cmp Stereo, 0 + JE StartESS1 + + Xor AL, 3 + +StartESS1: + Call ESSOut + +; DMA mode + + Mov AL, 0B9h + Call ESSOut + Mov AL, 2 + Call ESSOut + +; Mixspeed + + Mov AL, 0A1h + Call ESSOut + Mov AL, ESSMixConst + Call ESSOut + +; Filter clock divider + Mov AL, 0A2h + Call ESSOut + + Mov AL, 0FEh + Call ESSOut + +; DMA counter + Mov CX, DMASize + Neg CX + + Mov AL, 0A4h + Call ESSOut + Mov AL, CL + Call ESSOut + Mov AL, 0A5h + Call ESSOut + Mov AL, CH + Call ESSOut + +; Initialise DAC + Mov AL, 0B6h + Call ESSOut + Mov AL, 0 + Call ESSOut + +; Configure DACs + + Mov AL, 0B7h + Call ESSOut + Mov AL, 71h + Call ESSOut + + Mov AL, 0B7h + Call ESSOut + + Mov AL, 0BCh + Cmp Stereo, 0 + JNE StartESS2 + + Mov AL, 0F4h + +StartESS2: + Call ESSOut + +; IRQ configuration + Mov AL, 0B1h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; DMA configuration + Mov AL, 0B2h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; Enable voice + Mov AL, 0D1h + Call ESSOut + +; Start transfer + Mov AH, 0B8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B8h + Call ESSOut + Mov AL, AH + Or AL, 1 + Call ESSOut + +; Init UART + Mov DX, MIDIPort + Inc DX + Mov AL, 3Fh ; Intelligent mode. + Out DX, AL + +; Enable MIDI IRQ + Mov DX, BasePort + Add DL, 4 + Mov AX, 4064h + Out DX, AX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartESS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + And AX, 0FF0h + ShR AH, 1 + ShR AL, 5 + Mov Word Ptr [VolumeTable], AX + + Call GetESSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, (DMABUFFERLENGTH*2)/16+5 + Mov BX, DX + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetDSP + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call ResetDSP + Call StartESS + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Mov AH, [VolumeTable] + ShL AH, 4 + Or AH, [VolumeTable+1] + ShL AH, 1 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 + DW 3 ; MIDI, hiqual + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ES1869.ASM b/SoundDrivers/ES1869.ASM index d85d4f5..a690643 100755 --- a/SoundDrivers/ES1869.ASM +++ b/SoundDrivers/ES1869.ASM @@ -1,2328 +1,2328 @@ -; -; ESS Technology's ES1869 AudioDrive chip. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 03007316h - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -ESSMsg DB "ESS ES1869 AudioDrive found", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "ESS ES1869 AudioDrive found", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "ESS ES1869 AudioDrive reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITES1869.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITES1869.DRV", 0 - -DriverName DB "ITES1869.DRV", 0 - -ALIGN 4 -FilterValue DD 0 -FilterValue2 DD 0 -ESSMixConst DB 0, 0 - -DMASize DW 2048 ; Smaller gives better MIDI timing -ConfigPort DW 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldESSIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -ESSScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr ESSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - -Comment ~ - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - -~ - - DW 0 - -ESSHeaderLine DW 10 - DB "ESS ES1869 AudioDrive Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 26, 48 - DB 21h - DB "ESS ES1869 AudioDrive Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -Comment ~ - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 15 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 15 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -~ - -MixModeText DW 1 - DB 2, 14 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 44100 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 16, 32, 18, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 19, 32, 21, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 22, 32, 24, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 29 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 31, 29, 33, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 34, 29, 36, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 37, 29, 39, 8 - DB 0 - DB " 75% Filter", 0 - -ALIGN 4 - -VolumeTable DB 2 Dup (0) -MIDIPort DW 0 - -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSOut ; AL = data - ; DX = 2xCh - - Push AX - -ESSOut1: - In AL, DX - Test AL, AL - JS ESSOut1 - - Pop AX - Out DX, AL - - Ret - -EndP ESSOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIn ; DX = 2xCh, returns AL - -ESSIn1: - In AL, DX - Test AL, 40h - JZ ESSIn1 - - Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -EndP ESSIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut ; AL = out - - Push DX - Push AX - - Mov DX, CS:MIDIPort - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - JNZ UARTOut1 - - Pop AX - Dec DX - Out DX, AL - - Pop DX - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTIn ; returns AL - - Push DX - - Mov DX, CS:MIDIPort - Inc DX - -UARTIn1: - In AL, DX - Test AL, 80h - JNZ UARTIn1 - - Dec DX - In AL, DX - - Pop DX - Ret - -EndP UARTIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadRegister ; AH = register to read. - ; DX = 2xCh - ; returns AL - - Mov AL, 0C0h - Call ESSOut - Mov AL, AH - Call ESSOut - Call ESSIn - - Ret - -EndP ESSReadRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - -; Cmp PnP_VendorID, PNPVENDORID -; JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Mov ConfigPort, AX - - Mov AX, 107h ; Audio device - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - Mov MIDIPort, AX - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, CS:MIDIPort - Inc DX - Mov AL, 0FFh - Out DX, AL - - Mov DX, CS:BasePort - Add DL, 6 - Mov AL, 3 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Call UARTIn - Mov BL, [MIDIBufferTail] - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [ConfigPort] - Add DL, 6 - In AL, DX - Test AL, 8 - JZ ESSNoMIDI - - Push AX - Call CheckMIDI - Pop AX - -ESSNoMIDI: - Test AL, 1 - JZ ESSIRQEnd - - Mov DX, [BasePort] - Add DL, 0Eh - In AL, DX - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB ESSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -ESSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB ESSIRQHandler6 - JE ESSIRQHFilter - - Cmp CS:Stereo, 0 - JE ESSIRQ3QFilterMono - -ESSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -ESSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -ESSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -ESSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilter: - Cmp CS:Stereo, 0 - JE ESSIRQHFilterMono - -ESSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -ESSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -ESSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -ESSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL ESSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG ESSIRQHandlerClip2 - -ESSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ ESSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - -ESSIRQEnd: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Pop ES - Pop DS - PopAD - IRet - -ESSIRQHandlerClip1: - Mov AX, 8000h - Jmp ESSIRQHandler7 - -ESSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp ESSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo3 - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetESSMixConst - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetESSMixConst1 - - Mov CX, 22050 - Cmp AX, CX - JB GetESSMixConst1 - - Mov CX, 56821 - Cmp AX, CX - JA GetESSMixConst1 - - Mov CX, AX - -GetESSMixConst1: ; CX = mixspeed. - Mov DX, 0Ch - Mov AX, 236Ch ; DX:AX = 795.5kHz - Div CX - - Mov BX, AX - Neg AL - Mov ESSMixConst, AL - - Mov DX, 0Ch - Mov AX, 236Ch - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetESSMixConst - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartESS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Call ResetDSP - Mov DX, BasePort - Add DL, 0Ch - -; Extended Functions - - Mov AL, 0C6h - Call ESSOut - -; Autoinit DMA - - Mov AL, 0B8h - Call ESSOut - Mov AL, 4 - Call ESSOut - -; Stereo/Mono select - - Mov AH, 0A8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0A8h - Call ESSOut - Mov AL, AH - And AL, Not 3 - Or AL, 2 - Cmp Stereo, 0 - JE StartESS1 - - Xor AL, 3 - -StartESS1: - Call ESSOut - -; DMA mode - - Mov AL, 0B9h - Call ESSOut - Mov AL, 2 - Call ESSOut - -; Mixspeed - - Mov AL, 0A1h - Call ESSOut - Mov AL, ESSMixConst - Call ESSOut - -; Filter clock divider - Mov AL, 0A2h - Call ESSOut - - Mov AL, 0FEh - Call ESSOut - -; DMA counter - Mov CX, DMASize - Neg CX - - Mov AL, 0A4h - Call ESSOut - Mov AL, CL - Call ESSOut - Mov AL, 0A5h - Call ESSOut - Mov AL, CH - Call ESSOut - -; Initialise DAC - Mov AL, 0B6h - Call ESSOut - Mov AL, 0 - Call ESSOut - -; Configure DACs - - Mov AL, 0B7h - Call ESSOut - Mov AL, 71h - Call ESSOut - - Mov AL, 0B7h - Call ESSOut - - Mov AL, 0BCh - Cmp Stereo, 0 - JNE StartESS2 - - Mov AL, 0F4h - -StartESS2: - Call ESSOut - -; IRQ configuration - Mov AL, 0B1h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; DMA configuration - Mov AL, 0B2h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; Enable voice - Mov AL, 0D1h - Call ESSOut - -; Start transfer - Mov AH, 0B8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B8h - Call ESSOut - Mov AL, AH - Or AL, 1 - Call ESSOut - -; Init UART - Mov DX, MIDIPort - Inc DX - Mov AL, 3Fh ; Intelligent mode. - Out DX, AL - -; Enable MIDI IRQ - Mov DX, BasePort - Add DL, 4 - Mov AX, 4064h - Out DX, AX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartESS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - And AX, 0FF0h - ShR AH, 1 - ShR AL, 5 - Mov Word Ptr [VolumeTable], AX - - Call GetESSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetDSP - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call ResetDSP - Call StartESS - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Mov AH, [VolumeTable] - ShL AH, 4 - Or AH, [VolumeTable+1] - ShL AH, 1 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ESS Technology's ES1869 AudioDrive chip. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 03007316h + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +ESSMsg DB "ESS ES1869 AudioDrive found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "ESS ES1869 AudioDrive found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "ESS ES1869 AudioDrive reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITES1869.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITES1869.DRV", 0 + +DriverName DB "ITES1869.DRV", 0 + +ALIGN 4 +FilterValue DD 0 +FilterValue2 DD 0 +ESSMixConst DB 0, 0 + +DMASize DW 2048 ; Smaller gives better MIDI timing +ConfigPort DW 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + +Comment ~ + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + +~ + + DW 0 + +ESSHeaderLine DW 10 + DB "ESS ES1869 AudioDrive Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 26, 48 + DB 21h + DB "ESS ES1869 AudioDrive Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +Comment ~ + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 15 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 15 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +~ + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 29 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 31, 29, 33, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 34, 29, 36, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 37, 29, 39, 8 + DB 0 + DB " 75% Filter", 0 + +ALIGN 4 + +VolumeTable DB 2 Dup (0) +MIDIPort DW 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut1: + In AL, DX + Test AL, AL + JS ESSOut1 + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn ; DX = 2xCh, returns AL + +ESSIn1: + In AL, DX + Test AL, 40h + JZ ESSIn1 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +EndP ESSIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut ; AL = out + + Push DX + Push AX + + Mov DX, CS:MIDIPort + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + JNZ UARTOut1 + + Pop AX + Dec DX + Out DX, AL + + Pop DX + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTIn ; returns AL + + Push DX + + Mov DX, CS:MIDIPort + Inc DX + +UARTIn1: + In AL, DX + Test AL, 80h + JNZ UARTIn1 + + Dec DX + In AL, DX + + Pop DX + Ret + +EndP UARTIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadRegister ; AH = register to read. + ; DX = 2xCh + ; returns AL + + Mov AL, 0C0h + Call ESSOut + Mov AL, AH + Call ESSOut + Call ESSIn + + Ret + +EndP ESSReadRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + +; Cmp PnP_VendorID, PNPVENDORID +; JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Mov ConfigPort, AX + + Mov AX, 107h ; Audio device + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + Mov MIDIPort, AX + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, CS:MIDIPort + Inc DX + Mov AL, 0FFh + Out DX, AL + + Mov DX, CS:BasePort + Add DL, 6 + Mov AL, 3 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Call UARTIn + Mov BL, [MIDIBufferTail] + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [ConfigPort] + Add DL, 6 + In AL, DX + Test AL, 8 + JZ ESSNoMIDI + + Push AX + Call CheckMIDI + Pop AX + +ESSNoMIDI: + Test AL, 1 + JZ ESSIRQEnd + + Mov DX, [BasePort] + Add DL, 0Eh + In AL, DX + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB ESSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +ESSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB ESSIRQHandler6 + JE ESSIRQHFilter + + Cmp CS:Stereo, 0 + JE ESSIRQ3QFilterMono + +ESSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +ESSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +ESSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +ESSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilter: + Cmp CS:Stereo, 0 + JE ESSIRQHFilterMono + +ESSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +ESSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +ESSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +ESSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL ESSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG ESSIRQHandlerClip2 + +ESSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ ESSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + +ESSIRQEnd: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Pop ES + Pop DS + PopAD + IRet + +ESSIRQHandlerClip1: + Mov AX, 8000h + Jmp ESSIRQHandler7 + +ESSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp ESSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo3 + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetESSMixConst + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetESSMixConst1 + + Mov CX, 22050 + Cmp AX, CX + JB GetESSMixConst1 + + Mov CX, 56821 + Cmp AX, CX + JA GetESSMixConst1 + + Mov CX, AX + +GetESSMixConst1: ; CX = mixspeed. + Mov DX, 0Ch + Mov AX, 236Ch ; DX:AX = 795.5kHz + Div CX + + Mov BX, AX + Neg AL + Mov ESSMixConst, AL + + Mov DX, 0Ch + Mov AX, 236Ch + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetESSMixConst + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartESS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Call ResetDSP + Mov DX, BasePort + Add DL, 0Ch + +; Extended Functions + + Mov AL, 0C6h + Call ESSOut + +; Autoinit DMA + + Mov AL, 0B8h + Call ESSOut + Mov AL, 4 + Call ESSOut + +; Stereo/Mono select + + Mov AH, 0A8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0A8h + Call ESSOut + Mov AL, AH + And AL, Not 3 + Or AL, 2 + Cmp Stereo, 0 + JE StartESS1 + + Xor AL, 3 + +StartESS1: + Call ESSOut + +; DMA mode + + Mov AL, 0B9h + Call ESSOut + Mov AL, 2 + Call ESSOut + +; Mixspeed + + Mov AL, 0A1h + Call ESSOut + Mov AL, ESSMixConst + Call ESSOut + +; Filter clock divider + Mov AL, 0A2h + Call ESSOut + + Mov AL, 0FEh + Call ESSOut + +; DMA counter + Mov CX, DMASize + Neg CX + + Mov AL, 0A4h + Call ESSOut + Mov AL, CL + Call ESSOut + Mov AL, 0A5h + Call ESSOut + Mov AL, CH + Call ESSOut + +; Initialise DAC + Mov AL, 0B6h + Call ESSOut + Mov AL, 0 + Call ESSOut + +; Configure DACs + + Mov AL, 0B7h + Call ESSOut + Mov AL, 71h + Call ESSOut + + Mov AL, 0B7h + Call ESSOut + + Mov AL, 0BCh + Cmp Stereo, 0 + JNE StartESS2 + + Mov AL, 0F4h + +StartESS2: + Call ESSOut + +; IRQ configuration + Mov AL, 0B1h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; DMA configuration + Mov AL, 0B2h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; Enable voice + Mov AL, 0D1h + Call ESSOut + +; Start transfer + Mov AH, 0B8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B8h + Call ESSOut + Mov AL, AH + Or AL, 1 + Call ESSOut + +; Init UART + Mov DX, MIDIPort + Inc DX + Mov AL, 3Fh ; Intelligent mode. + Out DX, AL + +; Enable MIDI IRQ + Mov DX, BasePort + Add DL, 4 + Mov AX, 4064h + Out DX, AX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartESS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + And AX, 0FF0h + ShR AH, 1 + ShR AL, 5 + Mov Word Ptr [VolumeTable], AX + + Call GetESSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetDSP + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call ResetDSP + Call StartESS + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Mov AH, [VolumeTable] + ShL AH, 4 + Or AH, [VolumeTable+1] + ShL AH, 1 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ES1869MX.ASM b/SoundDrivers/ES1869MX.ASM index a6c64c0..f2c77c6 100755 --- a/SoundDrivers/ES1869MX.ASM +++ b/SoundDrivers/ES1869MX.ASM @@ -1,1734 +1,1734 @@ -; -; ESS Technology's ES1869 AudioDrive chip. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 03007316h - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -OUTPUTFILTERENABLED EQU 0 - -FPSave DB 128 Dup (0) - -ESSMsg DB "ESS ES1869 AudioDrive MMX", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "ESS ES1869 AudioDrive MMX", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "ESS ES1869 AudioDrive reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITES1869.MMX", 0 -ConfigOKMsg DB "Configuration saved to ITES1869.MMX", 0 - -DriverName DB "ITES1869.MMX", 0 - -ALIGN 4 -ESSMixConst DB 0, 0 - -DMASize DW 2048 ; Smaller gives better MIDI timing -ConfigPort DW 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 - -MixSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 4 -MixMode DW 0 -MixModeOffset DW 0 - -IMR DW 0 -OldESSIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -ESSScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr ESSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW 0 - -ESSHeaderLine DW 10 - DB "ESS ES1869 AudioDrive MMX Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 22, 48 - DB 21h - DB "ESS ES1869 AudioDrive MMX Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MixModeText DW 1 - DB 2, 14 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 44100 - DW 0 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 16, 32, 18, 8 - DB 0 - DB " MMX, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 19, 32, 21, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 22, 32, 24, 8 - DB 0 - DB " MMX, Volume Ramped", 0 - -MixModeButton4 DW 2 - DW 8, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " MMX, Filtered", 0 - -ALIGN 4 - -VolumeTable DB 2 Dup (0) -MIDIPort DW 0 - -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSOut ; AL = data - ; DX = 2xCh - - Push AX - -ESSOut1: - In AL, DX - Test AL, AL - JS ESSOut1 - - Pop AX - Out DX, AL - - Ret - -EndP ESSOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIn ; DX = 2xCh, returns AL - -ESSIn1: - In AL, DX - Test AL, 40h - JZ ESSIn1 - - Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -EndP ESSIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut ; AL = out - - Push DX - Push AX - - Mov DX, CS:MIDIPort - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - JNZ UARTOut1 - - Pop AX - Dec DX - Out DX, AL - - Pop DX - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTIn ; returns AL - - Push DX - - Mov DX, CS:MIDIPort - Inc DX - -UARTIn1: - In AL, DX - Test AL, 80h - JNZ UARTIn1 - - Dec DX - In AL, DX - - Pop DX - Ret - -EndP UARTIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadRegister ; AH = register to read. - ; DX = 2xCh - ; returns AL - - Mov AL, 0C0h - Call ESSOut - Mov AL, AH - Call ESSOut - Call ESSIn - - Ret - -EndP ESSReadRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - -; Cmp PnP_VendorID, PNPVENDORID -; JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Mov ConfigPort, AX - - Mov AX, 107h ; Audio device - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - Mov MIDIPort, AX - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, CS:MIDIPort - Inc DX - Mov AL, 0FFh - Out DX, AL - - Mov DX, CS:BasePort - Add DL, 6 - Mov AL, 3 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Call UARTIn - Mov BL, [MIDIBufferTail] - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [ConfigPort] - Add DL, 6 - In AL, DX - Test AL, 8 - JZ ESSNoMIDI - - Push AX - Call CheckMIDI - Pop AX - -ESSNoMIDI: - Test AL, 1 - JZ ESSIRQEnd - - Mov DX, [BasePort] - Add DL, 0Eh - In AL, DX - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB ESSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -ESSIRQHandler2: - FNSave [FPSave] - - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRStor [CS:FPSave] - -ESSIRQEnd: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Pop ES - Pop DS - PopAD - IRet - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetESSMixConst - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetESSMixConst1 - - Mov CX, 22050 - Cmp AX, CX - JB GetESSMixConst1 - - Mov CX, 56821 - Cmp AX, CX - JA GetESSMixConst1 - - Mov CX, AX - -GetESSMixConst1: ; CX = mixspeed. - Mov DX, 0Ch - Mov AX, 236Ch ; DX:AX = 795.5kHz - Div CX - - Mov BX, AX - Neg AL - Mov ESSMixConst, AL - - Mov DX, 0Ch - Mov AX, 236Ch - Div BX - Mov MixSpeed, AX - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Pop DS - PopA - Ret - -EndP GetESSMixConst - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartESS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Call ResetDSP - Mov DX, BasePort - Add DL, 0Ch - -; Extended Functions - - Mov AL, 0C6h - Call ESSOut - -; Autoinit DMA - - Mov AL, 0B8h - Call ESSOut - Mov AL, 4 - Call ESSOut - -; Stereo/Mono select - - Mov AH, 0A8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0A8h - Call ESSOut - Mov AL, AH - And AL, Not 3 - Or AL, 2 - Cmp Stereo, 0 - JE StartESS1 - - Xor AL, 3 - -StartESS1: - Call ESSOut - -; DMA mode - - Mov AL, 0B9h - Call ESSOut - Mov AL, 2 - Call ESSOut - -; Mixspeed - - Mov AL, 0A1h - Call ESSOut - Mov AL, ESSMixConst - Call ESSOut - -; Filter clock divider - Mov AL, 0A2h - Call ESSOut - - Mov AL, 0FEh - Call ESSOut - -; DMA counter - Mov CX, DMASize - Neg CX - - Mov AL, 0A4h - Call ESSOut - Mov AL, CL - Call ESSOut - Mov AL, 0A5h - Call ESSOut - Mov AL, CH - Call ESSOut - -; Initialise DAC - Mov AL, 0B6h - Call ESSOut - Mov AL, 0 - Call ESSOut - -; Configure DACs - - Mov AL, 0B7h - Call ESSOut - Mov AL, 71h - Call ESSOut - - Mov AL, 0B7h - Call ESSOut - - Mov AL, 0BCh - Cmp Stereo, 0 - JNE StartESS2 - - Mov AL, 0F4h - -StartESS2: - Call ESSOut - -; IRQ configuration - Mov AL, 0B1h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; DMA configuration - Mov AL, 0B2h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; Enable voice - Mov AL, 0D1h - Call ESSOut - -; Start transfer - Mov AH, 0B8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B8h - Call ESSOut - Mov AL, AH - Or AL, 1 - Call ESSOut - -; Init UART - Mov DX, MIDIPort - Inc DX - Mov AL, 3Fh ; Intelligent mode. - Out DX, AL - -; Enable MIDI IRQ - Mov DX, BasePort - Add DL, 4 - Mov AX, 4064h - Out DX, AX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartESS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - And AX, 0FF0h - ShR AH, 1 - ShR AL, 5 - Mov Word Ptr [VolumeTable], AX - - Call GetESSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, (DMABUFFERLENGTH*2)/16+5 - Mov BX, DX - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetDSP - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call ResetDSP - Call StartESS - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Mov AH, [VolumeTable] - ShL AH, 4 - Or AH, [VolumeTable+1] - ShL AH, 1 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 - DW 3 ; MIDI, hiqual - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ESS Technology's ES1869 AudioDrive chip. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 03007316h + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +OUTPUTFILTERENABLED EQU 0 + +FPSave DB 128 Dup (0) + +ESSMsg DB "ESS ES1869 AudioDrive MMX", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "ESS ES1869 AudioDrive MMX", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "ESS ES1869 AudioDrive reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITES1869.MMX", 0 +ConfigOKMsg DB "Configuration saved to ITES1869.MMX", 0 + +DriverName DB "ITES1869.MMX", 0 + +ALIGN 4 +ESSMixConst DB 0, 0 + +DMASize DW 2048 ; Smaller gives better MIDI timing +ConfigPort DW 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 4 +MixMode DW 0 +MixModeOffset DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW 0 + +ESSHeaderLine DW 10 + DB "ESS ES1869 AudioDrive MMX Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 22, 48 + DB 21h + DB "ESS ES1869 AudioDrive MMX Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + DW 0 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " MMX, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " MMX, Volume Ramped", 0 + +MixModeButton4 DW 2 + DW 8, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " MMX, Filtered", 0 + +ALIGN 4 + +VolumeTable DB 2 Dup (0) +MIDIPort DW 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut1: + In AL, DX + Test AL, AL + JS ESSOut1 + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn ; DX = 2xCh, returns AL + +ESSIn1: + In AL, DX + Test AL, 40h + JZ ESSIn1 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +EndP ESSIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut ; AL = out + + Push DX + Push AX + + Mov DX, CS:MIDIPort + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + JNZ UARTOut1 + + Pop AX + Dec DX + Out DX, AL + + Pop DX + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTIn ; returns AL + + Push DX + + Mov DX, CS:MIDIPort + Inc DX + +UARTIn1: + In AL, DX + Test AL, 80h + JNZ UARTIn1 + + Dec DX + In AL, DX + + Pop DX + Ret + +EndP UARTIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadRegister ; AH = register to read. + ; DX = 2xCh + ; returns AL + + Mov AL, 0C0h + Call ESSOut + Mov AL, AH + Call ESSOut + Call ESSIn + + Ret + +EndP ESSReadRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + +; Cmp PnP_VendorID, PNPVENDORID +; JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Mov ConfigPort, AX + + Mov AX, 107h ; Audio device + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + Mov MIDIPort, AX + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, CS:MIDIPort + Inc DX + Mov AL, 0FFh + Out DX, AL + + Mov DX, CS:BasePort + Add DL, 6 + Mov AL, 3 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Call UARTIn + Mov BL, [MIDIBufferTail] + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [ConfigPort] + Add DL, 6 + In AL, DX + Test AL, 8 + JZ ESSNoMIDI + + Push AX + Call CheckMIDI + Pop AX + +ESSNoMIDI: + Test AL, 1 + JZ ESSIRQEnd + + Mov DX, [BasePort] + Add DL, 0Eh + In AL, DX + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB ESSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +ESSIRQHandler2: + FNSave [FPSave] + + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRStor [CS:FPSave] + +ESSIRQEnd: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Pop ES + Pop DS + PopAD + IRet + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetESSMixConst + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetESSMixConst1 + + Mov CX, 22050 + Cmp AX, CX + JB GetESSMixConst1 + + Mov CX, 56821 + Cmp AX, CX + JA GetESSMixConst1 + + Mov CX, AX + +GetESSMixConst1: ; CX = mixspeed. + Mov DX, 0Ch + Mov AX, 236Ch ; DX:AX = 795.5kHz + Div CX + + Mov BX, AX + Neg AL + Mov ESSMixConst, AL + + Mov DX, 0Ch + Mov AX, 236Ch + Div BX + Mov MixSpeed, AX + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Pop DS + PopA + Ret + +EndP GetESSMixConst + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartESS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Call ResetDSP + Mov DX, BasePort + Add DL, 0Ch + +; Extended Functions + + Mov AL, 0C6h + Call ESSOut + +; Autoinit DMA + + Mov AL, 0B8h + Call ESSOut + Mov AL, 4 + Call ESSOut + +; Stereo/Mono select + + Mov AH, 0A8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0A8h + Call ESSOut + Mov AL, AH + And AL, Not 3 + Or AL, 2 + Cmp Stereo, 0 + JE StartESS1 + + Xor AL, 3 + +StartESS1: + Call ESSOut + +; DMA mode + + Mov AL, 0B9h + Call ESSOut + Mov AL, 2 + Call ESSOut + +; Mixspeed + + Mov AL, 0A1h + Call ESSOut + Mov AL, ESSMixConst + Call ESSOut + +; Filter clock divider + Mov AL, 0A2h + Call ESSOut + + Mov AL, 0FEh + Call ESSOut + +; DMA counter + Mov CX, DMASize + Neg CX + + Mov AL, 0A4h + Call ESSOut + Mov AL, CL + Call ESSOut + Mov AL, 0A5h + Call ESSOut + Mov AL, CH + Call ESSOut + +; Initialise DAC + Mov AL, 0B6h + Call ESSOut + Mov AL, 0 + Call ESSOut + +; Configure DACs + + Mov AL, 0B7h + Call ESSOut + Mov AL, 71h + Call ESSOut + + Mov AL, 0B7h + Call ESSOut + + Mov AL, 0BCh + Cmp Stereo, 0 + JNE StartESS2 + + Mov AL, 0F4h + +StartESS2: + Call ESSOut + +; IRQ configuration + Mov AL, 0B1h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; DMA configuration + Mov AL, 0B2h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; Enable voice + Mov AL, 0D1h + Call ESSOut + +; Start transfer + Mov AH, 0B8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B8h + Call ESSOut + Mov AL, AH + Or AL, 1 + Call ESSOut + +; Init UART + Mov DX, MIDIPort + Inc DX + Mov AL, 3Fh ; Intelligent mode. + Out DX, AL + +; Enable MIDI IRQ + Mov DX, BasePort + Add DL, 4 + Mov AX, 4064h + Out DX, AX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartESS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + And AX, 0FF0h + ShR AH, 1 + ShR AL, 5 + Mov Word Ptr [VolumeTable], AX + + Call GetESSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, (DMABUFFERLENGTH*2)/16+5 + Mov BX, DX + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetDSP + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call ResetDSP + Call StartESS + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Mov AH, [VolumeTable] + ShL AH, 4 + Or AH, [VolumeTable+1] + ShL AH, 1 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 + DW 3 ; MIDI, hiqual + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/EWS64.ASM b/SoundDrivers/EWS64.ASM index abd573f..4e67661 100755 --- a/SoundDrivers/EWS64.ASM +++ b/SoundDrivers/EWS64.ASM @@ -1,933 +1,933 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;*********************************************** - -TRACEENABLED = 0 -CREATENEWLOGFILE = 1 - -include debug.inc - -PNPVENDORID EQU 36A8630Eh - -MMT_MAXENTRIES EQU 64 -MMT_MAXSIZE EQU 3*MMT_MAXENTRIES - -ST97Message DB "EWS 64 Synthesizer Detected", 13 -; DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 - DB "Port ", 0FDh, "Xh, ", 0FDh, "D Voices, ", 0FDh, "Dk", 0 - -StatusLine DB "FreeEWS ", 0FDh, "Dk", 0 - -MMTData DW MMT_MAXSIZE Dup (0) - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EmptyFunction Far - - Xor AX, AX - StC - Ret - -EndP EmptyFunction - -; ÄÄ ST97InString ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97InString ; ES:DI points to deposit point. - ; EAX = memory address - ; CX = count - - ClI - - Mov BL, 2 ; Ctrl=RD_MEM, Data=Memory Address - Call ST97OutDWord - - Mov DX, CS:BasePort ; Length - Mov AX, CX - Call ST97SendByte - - Mov AL, AH - Call ST97SendByte - -ST97InString1: - Call ST97InByte - Cmp AL, 0ABh - JE ST97InStringError - Cmp AL, 0ACh - JNE ST97InString1 - -ST97InString2: - Inc DX - Inc DX - - Rep InsW - - ClC - StI - Ret - -ST97InStringError: - StC - StI - Ret - -EndP ST97InString - -; ÄÄ ST97ReceiveByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97ReceiveByte ; Returns AL - - Push DX - Mov DX, CS:BasePort - Inc DX - -ST97ReceiveByte1: - In AL, DX - Test AL, AL - JS ST97ReceiveByte1 - - Dec DX - In AL, DX - Pop DX - - Ret - -EndP ST97ReceiveByte - -; ÄÄ ST97InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97InByte ; Returns AL - - Jmp ST97ReceiveByte - -EndP ST97InByte - -; ÄÄ ST97InWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97InWord ; Returns AX - - ClI - - Call ST97ReceiveByte - Mov AL, AH - - Call ST97ReceiveByte - XChg AL, AH - - StI - - Ret - -EndP ST97InWord - -; ÄÄ ST97InDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97InDWord ; Returns EAX - - ClI - - Call ST97ReceiveByte - RoR EAX, 8 - - Call ST97ReceiveByte - RoR EAX, 8 - - Call ST97ReceiveByte - RoR EAX, 8 - - Call ST97ReceiveByte - RoR EAX, 8 - - StI - Ret - -EndP ST97InDWord - -; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97SendByte ; DX = port, AL = data - - Push AX - Push DX - Mov DX, CS:BasePort - Inc DX - -ST97SendByte1: - In AL, DX - Test AL, 40h - JNZ ST97SendByte1 - - Pop DX - Pop AX - - Out DX, AL - - Ret - -EndP ST97SendByte - -; ÄÄ ST97OutByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97OutByte ; AL = data, AH = command, destroys AX - - ClI - Push DX - - Mov DX, CS:BasePort - Inc DX - - XChg AH, AL - Call ST97SendByte - - Dec DX - - Mov AL, AH - Call ST97SendByte - - Pop DX - StI - - Ret - -EndP ST97OutByte - -; ÄÄ ST97OutWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97OutWord ; AX = data, BL = command, destroys AX - - ClI - Push DX - Push AX - - Mov DX, CS:BasePort - Mov AL, BL - Inc DX - Call ST97SendByte - - Pop AX - Dec DX - Call ST97SendByte - - Mov AL, AH - Call ST97SendByte - - Pop DX - StI - - Ret - -EndP ST97OutWord - -; ÄÄ ST97OutDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97OutDWord ; EAX = data, BL = command - - ClI - Push DX - Push AX - - Mov DX, CS:BasePort - Mov AL, BL - Inc DX - Call ST97SendByte - - Pop AX - Dec DX - Call ST97SendByte - - ShR EAX, 8 - Call ST97SendByte - - ShR EAX, 8 - Call ST97SendByte - - ShR EAX, 8 - Call ST97SendByte - - Pop DX - StI - - Ret - -EndP ST97OutDWord - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART ; Given DX = Port - - ClI - - Inc DX - - Mov AL, 0FFh ; Reset! - Out DX, AL - Out DX, AL ; Two resets required to ensure it'll work - - Xor CX, CX - -ResetUART2: - In AL, DX - Test AL, 80h - JNZ ResetUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE ResetUART4 - -ResetUART3: - Loop ResetUART2 - -ResetUARTError: - StI - StC - Ret - -ResetUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -ResetUART5: - In AL, DX - Test AL, 40h - LoopNZ ResetUART5 - JNZ ResetUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -ResetUART6: - Xor CX, CX - -ResetUART7: - In AL, DX - Test AL, 80h - JNZ ResetUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE ResetUART9 - -ResetUART8: - Loop ResetUART7 - Jmp ResetUARTError - -ResetUART9: - StI - ClC - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - Mov AX, 407h ; LDN 4 - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Trace "Detecting EWS64XL" - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - Trace "EWS64XL Not found" - - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - -; Check whether the MPU can be reset - Mov DX, BasePort - Call ResetUART - JC PnP_DetectCardNotFound - -; Find memory mapping table - Mov AX, 300h ; Ctrl 3 (GET_MMT), Data 0 - Call ST97OutByte - Call ST97InDWord - - Push CS - Pop ES - Mov CX, MMT_MAXSIZE - Mov DI, Offset MMTData - Call ST97InString - - Trace "EWS64XL Found" - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Trace "EWS64XL InitSound" - - Mov SI, Offset ST97Message -Comment ~ - Mov AX, BasePort - Mov BX, IRQ - Mov ECX, DWord Ptr [MMTData+2] - ShR ECX, 9 -~ - Xor BX, BX - Mov AX, 5100h ; Cntrl = GET_VOI, Data = 0 - Call ST97OutByte - Call ST97InByte - Mov BL, AL - Mov AX, BasePort - Mov ECX, DWord Ptr [MMTData+2] - ShR ECX, 9 - - Trace "EWS64XL InitSoundEnd" - - ClC - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov DX, CS:BasePort - Inc DX - Mov AL, 0FFh - Out DX, AL - - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load (0 based) -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release (1 based) -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset MMTData+6 - Xor EAX, EAX - -GetStatus1: - Mov CX, [SI] - Add SI, 6 - - Cmp CX, -1 - JE GetStatus2 - - Cmp CX, 1 - JA GetStatus1 - JB GetStatus1 - - Add EAX, [SI+2] - Sub EAX, [SI-4] - Jmp GetStatus1 - -GetStatus2: - Mov SI, Offset StatusLine - ShR EAX, 9 - - ClC - Ret - -EndP GetStatus - Assume DS:Nothing - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Xor AX, AX - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 64 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 64 - - DW 5 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;*********************************************** + +TRACEENABLED = 0 +CREATENEWLOGFILE = 1 + +include debug.inc + +PNPVENDORID EQU 36A8630Eh + +MMT_MAXENTRIES EQU 64 +MMT_MAXSIZE EQU 3*MMT_MAXENTRIES + +ST97Message DB "EWS 64 Synthesizer Detected", 13 +; DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 + DB "Port ", 0FDh, "Xh, ", 0FDh, "D Voices, ", 0FDh, "Dk", 0 + +StatusLine DB "FreeEWS ", 0FDh, "Dk", 0 + +MMTData DW MMT_MAXSIZE Dup (0) + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EmptyFunction Far + + Xor AX, AX + StC + Ret + +EndP EmptyFunction + +; ÄÄ ST97InString ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97InString ; ES:DI points to deposit point. + ; EAX = memory address + ; CX = count + + ClI + + Mov BL, 2 ; Ctrl=RD_MEM, Data=Memory Address + Call ST97OutDWord + + Mov DX, CS:BasePort ; Length + Mov AX, CX + Call ST97SendByte + + Mov AL, AH + Call ST97SendByte + +ST97InString1: + Call ST97InByte + Cmp AL, 0ABh + JE ST97InStringError + Cmp AL, 0ACh + JNE ST97InString1 + +ST97InString2: + Inc DX + Inc DX + + Rep InsW + + ClC + StI + Ret + +ST97InStringError: + StC + StI + Ret + +EndP ST97InString + +; ÄÄ ST97ReceiveByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97ReceiveByte ; Returns AL + + Push DX + Mov DX, CS:BasePort + Inc DX + +ST97ReceiveByte1: + In AL, DX + Test AL, AL + JS ST97ReceiveByte1 + + Dec DX + In AL, DX + Pop DX + + Ret + +EndP ST97ReceiveByte + +; ÄÄ ST97InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97InByte ; Returns AL + + Jmp ST97ReceiveByte + +EndP ST97InByte + +; ÄÄ ST97InWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97InWord ; Returns AX + + ClI + + Call ST97ReceiveByte + Mov AL, AH + + Call ST97ReceiveByte + XChg AL, AH + + StI + + Ret + +EndP ST97InWord + +; ÄÄ ST97InDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97InDWord ; Returns EAX + + ClI + + Call ST97ReceiveByte + RoR EAX, 8 + + Call ST97ReceiveByte + RoR EAX, 8 + + Call ST97ReceiveByte + RoR EAX, 8 + + Call ST97ReceiveByte + RoR EAX, 8 + + StI + Ret + +EndP ST97InDWord + +; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97SendByte ; DX = port, AL = data + + Push AX + Push DX + Mov DX, CS:BasePort + Inc DX + +ST97SendByte1: + In AL, DX + Test AL, 40h + JNZ ST97SendByte1 + + Pop DX + Pop AX + + Out DX, AL + + Ret + +EndP ST97SendByte + +; ÄÄ ST97OutByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97OutByte ; AL = data, AH = command, destroys AX + + ClI + Push DX + + Mov DX, CS:BasePort + Inc DX + + XChg AH, AL + Call ST97SendByte + + Dec DX + + Mov AL, AH + Call ST97SendByte + + Pop DX + StI + + Ret + +EndP ST97OutByte + +; ÄÄ ST97OutWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97OutWord ; AX = data, BL = command, destroys AX + + ClI + Push DX + Push AX + + Mov DX, CS:BasePort + Mov AL, BL + Inc DX + Call ST97SendByte + + Pop AX + Dec DX + Call ST97SendByte + + Mov AL, AH + Call ST97SendByte + + Pop DX + StI + + Ret + +EndP ST97OutWord + +; ÄÄ ST97OutDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97OutDWord ; EAX = data, BL = command + + ClI + Push DX + Push AX + + Mov DX, CS:BasePort + Mov AL, BL + Inc DX + Call ST97SendByte + + Pop AX + Dec DX + Call ST97SendByte + + ShR EAX, 8 + Call ST97SendByte + + ShR EAX, 8 + Call ST97SendByte + + ShR EAX, 8 + Call ST97SendByte + + Pop DX + StI + + Ret + +EndP ST97OutDWord + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART ; Given DX = Port + + ClI + + Inc DX + + Mov AL, 0FFh ; Reset! + Out DX, AL + Out DX, AL ; Two resets required to ensure it'll work + + Xor CX, CX + +ResetUART2: + In AL, DX + Test AL, 80h + JNZ ResetUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE ResetUART4 + +ResetUART3: + Loop ResetUART2 + +ResetUARTError: + StI + StC + Ret + +ResetUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +ResetUART5: + In AL, DX + Test AL, 40h + LoopNZ ResetUART5 + JNZ ResetUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +ResetUART6: + Xor CX, CX + +ResetUART7: + In AL, DX + Test AL, 80h + JNZ ResetUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE ResetUART9 + +ResetUART8: + Loop ResetUART7 + Jmp ResetUARTError + +ResetUART9: + StI + ClC + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + Mov AX, 407h ; LDN 4 + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Trace "Detecting EWS64XL" + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + Trace "EWS64XL Not found" + + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + +; Check whether the MPU can be reset + Mov DX, BasePort + Call ResetUART + JC PnP_DetectCardNotFound + +; Find memory mapping table + Mov AX, 300h ; Ctrl 3 (GET_MMT), Data 0 + Call ST97OutByte + Call ST97InDWord + + Push CS + Pop ES + Mov CX, MMT_MAXSIZE + Mov DI, Offset MMTData + Call ST97InString + + Trace "EWS64XL Found" + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Trace "EWS64XL InitSound" + + Mov SI, Offset ST97Message +Comment ~ + Mov AX, BasePort + Mov BX, IRQ + Mov ECX, DWord Ptr [MMTData+2] + ShR ECX, 9 +~ + Xor BX, BX + Mov AX, 5100h ; Cntrl = GET_VOI, Data = 0 + Call ST97OutByte + Call ST97InByte + Mov BL, AL + Mov AX, BasePort + Mov ECX, DWord Ptr [MMTData+2] + ShR ECX, 9 + + Trace "EWS64XL InitSoundEnd" + + ClC + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov DX, CS:BasePort + Inc DX + Mov AL, 0FFh + Out DX, AL + + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load (0 based) +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release (1 based) +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset MMTData+6 + Xor EAX, EAX + +GetStatus1: + Mov CX, [SI] + Add SI, 6 + + Cmp CX, -1 + JE GetStatus2 + + Cmp CX, 1 + JA GetStatus1 + JB GetStatus1 + + Add EAX, [SI+2] + Sub EAX, [SI-4] + Jmp GetStatus1 + +GetStatus2: + Mov SI, Offset StatusLine + ShR EAX, 9 + + ClC + Ret + +EndP GetStatus + Assume DS:Nothing + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Xor AX, AX + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 64 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 64 + + DW 5 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/EWSCODEC.ASM b/SoundDrivers/EWSCODEC.ASM index 604c014..8677432 100755 --- a/SoundDrivers/EWSCODEC.ASM +++ b/SoundDrivers/EWSCODEC.ASM @@ -1,3016 +1,3016 @@ -; -; EWS 64 Codec Driver -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -TRACEENABLED = 0 -CREATENEWLOGFILE = 1 - -include debug.inc - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 -DATAFLAG EQU 200h -ACKFLAG EQU 300h - -PNPSERIALID EQU 98B03C20h -PNPVENDORID EQU 36A8630Eh - -DMASize DW 4096 - -WSSMsg DB "Audiosystem EWS64 XL Codec", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Audiosystem EWS64 XL Codec", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Audiosystem EWS64 XL reinitialised", 0 - -DriverName DB "ITEWSCOD.DRV", 0 - -ALIGN 2 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 37 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 -VolumeTable DB 56, 56 - DB 60h, 60h, 0Ch ; Low Band - DB 40h, 40h, 1Bh ; Med Low Band - DB 40h, 40h, 72h ; Med High Band - DB 60h, 60h, 40h ; High Band - DB 0, 0, 0 ; Echo - DB 0, 2 ; Surround - DB 0, 90h, 4, 7Fh, 22h ; Reverb - DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus - -IMR DW 0 -OldWSSIRQHandler DD 0 - -; String format, Count, [Data/Port]*Count -; Port = 1 for Control port, 0 for data port. - -SAM9407Reset DW 66 - DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on - DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on - DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on - DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on - DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type - DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on - DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in - DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus - DW 1BEh, 133h, 0, 0 ; 2 Speaker - DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 - DW 1BEh, 134h, 0FFh, 0FFh ; Left gain - DW 1BEh, 135h, 0FFh, 0FFh ; Right gain - DW 1BEh, 136h, 0, 0 ; Left pan - DW 1BEh, 137h, 7Fh, 7Fh ; Right pan - DW 1BEh, 107h, 0FFh, 0FFh ; Master volume - -SAM9407EqLBL DW 4 - DW 1BEh, 110h, DATAFLAG, 60h -SAM9407EqLBR DW 4 - DW 1BEh, 114h, DATAFLAG, 60h -SAM9407EqLBF DW 4 - DW 1BEh, 118h, DATAFLAG, 0Ch -SAM9407EqMLBL DW 4 - DW 1BEh, 111h, DATAFLAG, 40h -SAM9407EqMLBR DW 4 - DW 1BEh, 115h, DATAFLAG, 40h -SAM9407EqMLBF DW 4 - DW 1BEh, 119h, DATAFLAG, 1Bh -SAM9407EqMHBL DW 4 - DW 1BEh, 112h, DATAFLAG, 40h -SAM9407EqMHBR DW 4 - DW 1BEh, 116h, DATAFLAG, 40h -SAM9407EqMHBF DW 4 - DW 1BEh, 11Ah, DATAFLAG, 72h -SAM9407EqHBL DW 4 - DW 1BEh, 113h, DATAFLAG, 60h -SAM9407EqHBR DW 4 - DW 1BEh, 117h, DATAFLAG, 60h -SAM9407EqHBF DW 4 - DW 1BEh, 11Bh, DATAFLAG, 0Ch -SAM9407EchoLevel DW 4 - DW 1BEh, 128h, DATAFLAG, 0 -SAM9407EchoTime DW 4 - DW 1BEh, 129h, DATAFLAG, 2Bh -SAM9407EchoFeed DW 4 - DW 1BEh, 12Ah, DATAFLAG, 40h -SAM9407SurroundVolume DW 4 - DW 1BEh, 130h, DATAFLAG, 0 -SAM9407SurroundDelay DW 4 - DW 1BEh, 131h, DATAFLAG, 2 -SAM9407ReverbSend DW 4 - DW 1BEh, 127h, DATAFLAG, 0 -SAM9407ReverbVolume DW 3 - DW 1BEh, 13Ah, DATAFLAG -SAM9407ReverbType DW 4 - DW 1BEh, 169h, DATAFLAG, 4 -SAM9407ReverbTime DW 3 - DW 1BEh, 178h, DATAFLAG -SAM9407ReverbFeedback DW 3 - DW 1BEh, 179h, DATAFLAG -SAM9407ChorusSend DW 4 - DW 1BEh, 124h, DATAFLAG, 0 -SAM9407ChorusVolume DW 3 - DW 1BEh, 13Bh, DATAFLAG -SAM9407ChorusType DW 4 - DW 1BEh, 16Ah, DATAFLAG, 2 -SAM9407ChorusDelay DW 3 - DW 1BEh, 174h, DATAFLAG -SAM9407ChorusFeedback DW 3 - DW 1BEh, 175h, DATAFLAG -SAM9407ChorusRate DW 3 - DW 1BEh, 176h, DATAFLAG -SAM9407ChorusDepth DW 3 - DW 1BEh, 177h, DATAFLAG -SAM9407Mono DW 4 - DW 1BEh, 132h, 7Fh, 0 -SAM9407Stereo DW 4 - DW 1BEh, 132h, 0, 0 - -SAM9407Strings DW Offset SAM9407Reset ;1 - DW Offset SAM9407EqLBL, Offset SAM9407EqLBR - DW Offset SAM9407EqLBF - DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR - DW Offset SAM9407EqMLBF - DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR - DW Offset SAM9407EqMHBF - DW Offset SAM9407EqHBL, Offset SAM9407EqHBR - DW Offset SAM9407EqHBF - DW Offset SAM9407EchoLevel ; 14 - DW Offset SAM9407EchoTime - DW Offset SAM9407EchoFeed - DW Offset SAM9407SurroundVolume ; 17 - DW Offset SAM9407SurroundDelay - DW Offset SAM9407ReverbSend ; 19 - DW Offset SAM9407ReverbVolume - DW Offset SAM9407ReverbType - DW Offset SAM9407ReverbTime - DW Offset SAM9407ReverbFeedback ; 23 - DW Offset SAM9407ChorusSend ; 24 - DW Offset SAM9407ChorusVolume - DW Offset SAM9407ChorusType - DW Offset SAM9407ChorusDelay - DW Offset SAM9407ChorusFeedback - DW Offset SAM9407ChorusRate - DW Offset SAM9407ChorusDepth ; 30 - DW Offset SAM9407Mono ; 31 - DW Offset SAM9407Stereo - - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW Near Ptr SAM9407PortText - DW Near Ptr SAM9407ParametersText - DW Near Ptr SAM9407ParametersBox - - DW Near Ptr EqLBL ; 21 - DW Near Ptr EqLBR - DW Near Ptr EqLBF - - DW Near Ptr EqMLBL - DW Near Ptr EqMLBR - DW Near Ptr EqMLBF - - DW Near Ptr EqMHBL - DW Near Ptr EqMHBR - DW Near Ptr EqMHBF - - DW Near Ptr EqHBL - DW Near Ptr EqHBR - DW Near Ptr EqHBF - - DW Near Ptr EchoLevel - DW Near Ptr EchoTime - DW Near Ptr EchoFeedback - - DW Near Ptr SurroundVolume - DW Near Ptr SurroundDelay - - DW Near Ptr ReverbSend - DW Near Ptr ReverbVolume - DW Near Ptr ReverbType - DW Near Ptr ReverbTime - DW Near Ptr ReverbFeedback - - DW Near Ptr ChorusSend - DW Near Ptr ChorusVolume - DW Near Ptr ChorusType - DW Near Ptr ChorusDelay - DW Near Ptr ChorusFeedback - DW Near Ptr ChorusRate - DW Near Ptr ChorusDepth - - DW 0 - -WSSHeaderLine DW 10 - DB "Audiosystem EWS64 XL Codec Driver", 0 - -SAM9407ParametersText DW 1 - DB 36, 14 - DB 20h - DB "Low Band Left", 13 - DB "Low Band Right", 13 - DB "Low Band Frequency", 13 - DB "Med Low Band Left", 13 - DB "Med Low Band Right", 13 - DB "Med Low Band Frequency", 13 - DB "Med High Band Left", 13 - DB "Med High Band Right", 13 - DB "Med High Band Frequency", 13 - DB "High Band Left", 13 - DB "High Band Right", 13 - DB "High Band Frequency", 13 - DB "Echo Level", 13 - DB "Echo Time", 13 - DB "Echo Feedback", 13 - DB "Surround Volume", 13 - DB "Surround Delay", 13 - DB "Reverb Send", 13 - DB "Reverb Volume", 13 - DB "Reverb Type", 13 - DB "Reverb Time", 13 - DB "Reverb Feedback", 13 - DB "Chorus Send", 13 - DB "Chorus Volume", 13 - DB "Chorus Type", 13 - DB "Chorus Delay", 13 - DB "Chorus Feedback", 13 - DB "Chorus Rate", 13 - DB "Chorus Depth", 13 - DB 0 - -EqLBL DW 14 - DB 60, 14 - DW 0, 127 - DW 9, 2 - DW 13, 22, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBR DW 14 - DB 60, 15 - DW 0, 127 - DW 9, 3 - DW 21, 23, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBF DW 14 - DB 60, 16 - DW 0, 127 - DW 9, 4 - DW 22, 24, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBL DW 14 - DB 60, 17 - DW 0, 127 - DW 9, 5 - DW 23, 25, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBR DW 14 - DB 60, 18 - DW 0, 127 - DW 9, 6 - DW 24, 26, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBF DW 14 - DB 60, 19 - DW 0, 127 - DW 9, 7 - DW 25, 27, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBL DW 14 - DB 60, 20 - DW 0, 127 - DW 9, 8 - DW 26, 28, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBR DW 14 - DB 60, 21 - DW 0, 127 - DW 9, 9 - DW 27, 29, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBF DW 14 - DB 60, 22 - DW 0, 127 - DW 9, 10 - DW 28, 30, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBL DW 14 - DB 60, 23 - DW 0, 127 - DW 9, 11 - DW 29, 31, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBR DW 14 - DB 60, 24 - DW 0, 127 - DW 9, 12 - DW 30, 32, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBF DW 14 - DB 60, 25 - DW 0, 127 - DW 9, 13 - DW 31, 33, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoLevel DW 14 - DB 60, 26 - DW 0, 127 - DW 9, 15 - DW 32, 34, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoTime DW 14 - DB 60, 27 - DW 0, 127 - DW 9, 14 - DW 33, 35, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoFeedback DW 14 - DB 60, 28 - DW 0, 127 - DW 9, 16 - DW 34, 36, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundVolume DW 14 - DB 60, 29 - DW 0, 255 - DW 9, 17 - DW 35, 37, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundDelay DW 14 - DB 60, 30 - DW 0, 127 - DW 9, 18 - DW 36, 38, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbSend DW 14 - DB 60, 31 - DW 0, 127 - DW 9, 19 - DW 37, 39, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbVolume DW 14 - DB 60, 32 - DW 0, 255 - DW 9, 20 - DW 38, 40, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - - -ReverbType DW 14 - DB 60, 33 - DW 0, 7 - DW 9, 21 - DW 39, 41, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbTime DW 14 - DB 60, 34 - DW 0, 127 - DW 9, 22 - DW 40, 42, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbFeedback DW 14 - DB 60, 35 - DW 0, 127 - DW 9, 23 - DW 41, 43, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusSend DW 14 - DB 60, 36 - DW 0, 127 - DW 9, 24 - DW 42, 44, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusVolume DW 14 - DB 60, 37 - DW 0, 255 - DW 9, 25 - DW 43, 45, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusType DW 14 - DB 60, 38 - DW 0, 7 - DW 9, 26 - DW 44, 46, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDelay DW 14 - DB 60, 39 - DW 0, 127 - DW 9, 27 - DW 45, 47, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusFeedback DW 14 - DB 60, 40 - DW 0, 127 - DW 9, 28 - DW 46, 48, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusRate DW 14 - DB 60, 41 - DW 0, 127 - DW 9, 29 - DW 47, 49, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDepth DW 14 - DB 60, 42 - DW 0, 127 - DW 9, 30 - DW 48, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SAM9407ParametersBox DW 0 - DB 59, 13, 75, 43 - DB 25 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -SAM9407PortText DW 1 - DB 21, 47 - DB 21h - DB "Audiosystem EWS64 SAM9407 Port ", 0FDh, "Xh, Mixing Rate: ", 0FDh, "D", 0 -MixSpeed DW 48000 -SAM9407Port DW 0 - -DriverText DW 1 - DB 21, 48 - DB 21h - DB "Audiosystem EWS64 XL Codec Driver 1.2 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode", 0 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 21, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -include dmasirq.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InByte ; Returns AL - - Push DX - Mov DX, CS:SAM9407Port - Inc DX - -SAM9407InByte1: - In AL, DX - Test AL, AL - JS SAM9407InByte1 - - Dec DX - In AL, DX - Pop DX - - Ret - -EndP SAM9407InByte - -Comment ~ - -; ÄÄ ST97InWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InWord ; Returns AX - - ClI - - Call SAM9407InByte - Mov AL, AH - - Call SAM9407InByte - XChg AL, AH - - StI - - Ret - -EndP SAM9407InWord - -; ÄÄ SAM9407InDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InDWord ; Returns EAX - - ClI - - Call SAM9407InByte - RoR EAX, 8 - - Call SAM9407InByte - RoR EAX, 8 - - Call SAM9407InByte - RoR EAX, 8 - - Call SAM9407InByte - RoR EAX, 8 - - StI - Ret - -EndP SAM9407InDWord - -~ - -; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendByte ; DX = port, AL = data - - Push AX - Push DX - Mov DX, CS:SAM9407Port - Inc DX - -SAM9407SendByte1: - In AL, DX - Test AL, 40h - JNZ SAM9407SendByte1 - - Pop DX - Pop AX - - Out DX, AL - - Ret - -EndP SAM9407SendByte - -Comment ~ - -; ÄÄ ST97OutByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407OutByte ; AL = data, AH = command, destroys AX - - ClI - Push DX - - Mov DX, CS:SAM9407Port - Inc DX - - XChg AH, AL - Call SAM9407SendByte - - Dec DX - - Mov AL, AH - Call SAM9407SendByte - - Pop DX - StI - - Ret - -EndP SAM9407OutByte - -; ÄÄ ST97OutWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407OutWord ; AX = data, BL = command, destroys AX - - ClI - Push DX - Push AX - - Mov DX, CS:SAM9407Port - Mov AL, BL - Inc DX - Call SAM9407SendByte - - Pop AX - Dec DX - Call SAM9407SendByte - - Mov AL, AH - Call SAM9407SendByte - - Pop DX - StI - - Ret - -EndP SAM9407OutWord - -; ÄÄ ST97OutDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407OutDWord ; EAX = data, BL = command - - ClI - Push DX - Push AX - - Mov DX, CS:SAM9407Port - Mov AL, BL - Inc DX - Call SAM9407SendByte - - Pop AX - Dec DX - Call SAM9407SendByte - - ShR EAX, 8 - Call SAM9407SendByte - - ShR EAX, 8 - Call SAM9407SendByte - - ShR EAX, 8 - Call SAM9407SendByte - - Pop DX - StI - - Ret - -EndP SAM9407OutDWord - -~ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSAM9407 ; DI = index. 1 = full reinit. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - LEA SI, [SAM9407Strings+EDI+EDI-2] - Mov SI, [SI] - - LodsW - Mov CX, AX - -SetSAM9407_1: -; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. - - Mov DX, SAM9407Port - LodsW - - Cmp AH, 2 - JB SetSAM9407_3 - JA SetSAM9407_4 - - Mov AL, [VolumeTable+DI] - Jmp SetSAM9407_2 - -SetSAM9407_4: - Push CX - - Mov CX, 1024 - -SetSAM9407_6: - Call SAM9407InByte - Test AL, AL - LoopNZ SetSAM9407_6 - - Pop CX - - Jmp SetSAM9407_5 - -SetSAM9407_3: - And AH, 1 - Add DL, AH - -SetSAM9407_2: - Call SAM9407SendByte - -SetSAM9407_5: - Dec CX - JNZ SetSAM9407_1 - - Pop DS - PopA - - Ret - -EndP SetSAM9407 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - - Mov AX, 1 - Ret - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 48000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 14 ; 14 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov AX, 407h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Test AX, AX - JZ PnP_IsolateNextCard - - Mov SAM9407Port, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Trace "Detecting EWS64XL" - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - Trace "EWS64XL Not Found" - - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - Trace "EWS64XL Found" - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - CLD - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Trace "EWS64XL InitSound" - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Trace "EWS64XL Memory Allocated" - - - Call SetIRQ - Call GetTempo - Call SetTempo - - Trace "EWS64XL IRQ Hooked" - - Mov DX, BasePort - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Trace "EWS64XL Volume Settings Received" - - Mov DI, 1 - Call SetSAM9407 - - Trace "EWS64XL SAM9407 InitString finished" - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call StopWSS - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Push AX - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - - Pop DI - - And DI, 1 - Add DI, 31 - Call SetSAM9407 - - Mov DI, 2 -SetStereo2: - Call SetSAM9407 - Inc DI - Cmp DI, 30 - JBE SetStereo2 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - - Pop DS - PopA - - Ret - -EndP UpdateSoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Mov [CS:VolumeTable+DI], AL - Cmp DI, 2 - JB SetVariable1 - - Call SetSAM9407 - Ret - -SetVariable1: - Call UpdateSoundcardVariables - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; EWS 64 Codec Driver +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +TRACEENABLED = 0 +CREATENEWLOGFILE = 1 + +include debug.inc + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 +DATAFLAG EQU 200h +ACKFLAG EQU 300h + +PNPSERIALID EQU 98B03C20h +PNPVENDORID EQU 36A8630Eh + +DMASize DW 4096 + +WSSMsg DB "Audiosystem EWS64 XL Codec", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Audiosystem EWS64 XL Codec", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Audiosystem EWS64 XL reinitialised", 0 + +DriverName DB "ITEWSCOD.DRV", 0 + +ALIGN 2 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 37 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 +VolumeTable DB 56, 56 + DB 60h, 60h, 0Ch ; Low Band + DB 40h, 40h, 1Bh ; Med Low Band + DB 40h, 40h, 72h ; Med High Band + DB 60h, 60h, 40h ; High Band + DB 0, 0, 0 ; Echo + DB 0, 2 ; Surround + DB 0, 90h, 4, 7Fh, 22h ; Reverb + DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus + +IMR DW 0 +OldWSSIRQHandler DD 0 + +; String format, Count, [Data/Port]*Count +; Port = 1 for Control port, 0 for data port. + +SAM9407Reset DW 66 + DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on + DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on + DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on + DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on + DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type + DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on + DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in + DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus + DW 1BEh, 133h, 0, 0 ; 2 Speaker + DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 + DW 1BEh, 134h, 0FFh, 0FFh ; Left gain + DW 1BEh, 135h, 0FFh, 0FFh ; Right gain + DW 1BEh, 136h, 0, 0 ; Left pan + DW 1BEh, 137h, 7Fh, 7Fh ; Right pan + DW 1BEh, 107h, 0FFh, 0FFh ; Master volume + +SAM9407EqLBL DW 4 + DW 1BEh, 110h, DATAFLAG, 60h +SAM9407EqLBR DW 4 + DW 1BEh, 114h, DATAFLAG, 60h +SAM9407EqLBF DW 4 + DW 1BEh, 118h, DATAFLAG, 0Ch +SAM9407EqMLBL DW 4 + DW 1BEh, 111h, DATAFLAG, 40h +SAM9407EqMLBR DW 4 + DW 1BEh, 115h, DATAFLAG, 40h +SAM9407EqMLBF DW 4 + DW 1BEh, 119h, DATAFLAG, 1Bh +SAM9407EqMHBL DW 4 + DW 1BEh, 112h, DATAFLAG, 40h +SAM9407EqMHBR DW 4 + DW 1BEh, 116h, DATAFLAG, 40h +SAM9407EqMHBF DW 4 + DW 1BEh, 11Ah, DATAFLAG, 72h +SAM9407EqHBL DW 4 + DW 1BEh, 113h, DATAFLAG, 60h +SAM9407EqHBR DW 4 + DW 1BEh, 117h, DATAFLAG, 60h +SAM9407EqHBF DW 4 + DW 1BEh, 11Bh, DATAFLAG, 0Ch +SAM9407EchoLevel DW 4 + DW 1BEh, 128h, DATAFLAG, 0 +SAM9407EchoTime DW 4 + DW 1BEh, 129h, DATAFLAG, 2Bh +SAM9407EchoFeed DW 4 + DW 1BEh, 12Ah, DATAFLAG, 40h +SAM9407SurroundVolume DW 4 + DW 1BEh, 130h, DATAFLAG, 0 +SAM9407SurroundDelay DW 4 + DW 1BEh, 131h, DATAFLAG, 2 +SAM9407ReverbSend DW 4 + DW 1BEh, 127h, DATAFLAG, 0 +SAM9407ReverbVolume DW 3 + DW 1BEh, 13Ah, DATAFLAG +SAM9407ReverbType DW 4 + DW 1BEh, 169h, DATAFLAG, 4 +SAM9407ReverbTime DW 3 + DW 1BEh, 178h, DATAFLAG +SAM9407ReverbFeedback DW 3 + DW 1BEh, 179h, DATAFLAG +SAM9407ChorusSend DW 4 + DW 1BEh, 124h, DATAFLAG, 0 +SAM9407ChorusVolume DW 3 + DW 1BEh, 13Bh, DATAFLAG +SAM9407ChorusType DW 4 + DW 1BEh, 16Ah, DATAFLAG, 2 +SAM9407ChorusDelay DW 3 + DW 1BEh, 174h, DATAFLAG +SAM9407ChorusFeedback DW 3 + DW 1BEh, 175h, DATAFLAG +SAM9407ChorusRate DW 3 + DW 1BEh, 176h, DATAFLAG +SAM9407ChorusDepth DW 3 + DW 1BEh, 177h, DATAFLAG +SAM9407Mono DW 4 + DW 1BEh, 132h, 7Fh, 0 +SAM9407Stereo DW 4 + DW 1BEh, 132h, 0, 0 + +SAM9407Strings DW Offset SAM9407Reset ;1 + DW Offset SAM9407EqLBL, Offset SAM9407EqLBR + DW Offset SAM9407EqLBF + DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR + DW Offset SAM9407EqMLBF + DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR + DW Offset SAM9407EqMHBF + DW Offset SAM9407EqHBL, Offset SAM9407EqHBR + DW Offset SAM9407EqHBF + DW Offset SAM9407EchoLevel ; 14 + DW Offset SAM9407EchoTime + DW Offset SAM9407EchoFeed + DW Offset SAM9407SurroundVolume ; 17 + DW Offset SAM9407SurroundDelay + DW Offset SAM9407ReverbSend ; 19 + DW Offset SAM9407ReverbVolume + DW Offset SAM9407ReverbType + DW Offset SAM9407ReverbTime + DW Offset SAM9407ReverbFeedback ; 23 + DW Offset SAM9407ChorusSend ; 24 + DW Offset SAM9407ChorusVolume + DW Offset SAM9407ChorusType + DW Offset SAM9407ChorusDelay + DW Offset SAM9407ChorusFeedback + DW Offset SAM9407ChorusRate + DW Offset SAM9407ChorusDepth ; 30 + DW Offset SAM9407Mono ; 31 + DW Offset SAM9407Stereo + + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW Near Ptr SAM9407PortText + DW Near Ptr SAM9407ParametersText + DW Near Ptr SAM9407ParametersBox + + DW Near Ptr EqLBL ; 21 + DW Near Ptr EqLBR + DW Near Ptr EqLBF + + DW Near Ptr EqMLBL + DW Near Ptr EqMLBR + DW Near Ptr EqMLBF + + DW Near Ptr EqMHBL + DW Near Ptr EqMHBR + DW Near Ptr EqMHBF + + DW Near Ptr EqHBL + DW Near Ptr EqHBR + DW Near Ptr EqHBF + + DW Near Ptr EchoLevel + DW Near Ptr EchoTime + DW Near Ptr EchoFeedback + + DW Near Ptr SurroundVolume + DW Near Ptr SurroundDelay + + DW Near Ptr ReverbSend + DW Near Ptr ReverbVolume + DW Near Ptr ReverbType + DW Near Ptr ReverbTime + DW Near Ptr ReverbFeedback + + DW Near Ptr ChorusSend + DW Near Ptr ChorusVolume + DW Near Ptr ChorusType + DW Near Ptr ChorusDelay + DW Near Ptr ChorusFeedback + DW Near Ptr ChorusRate + DW Near Ptr ChorusDepth + + DW 0 + +WSSHeaderLine DW 10 + DB "Audiosystem EWS64 XL Codec Driver", 0 + +SAM9407ParametersText DW 1 + DB 36, 14 + DB 20h + DB "Low Band Left", 13 + DB "Low Band Right", 13 + DB "Low Band Frequency", 13 + DB "Med Low Band Left", 13 + DB "Med Low Band Right", 13 + DB "Med Low Band Frequency", 13 + DB "Med High Band Left", 13 + DB "Med High Band Right", 13 + DB "Med High Band Frequency", 13 + DB "High Band Left", 13 + DB "High Band Right", 13 + DB "High Band Frequency", 13 + DB "Echo Level", 13 + DB "Echo Time", 13 + DB "Echo Feedback", 13 + DB "Surround Volume", 13 + DB "Surround Delay", 13 + DB "Reverb Send", 13 + DB "Reverb Volume", 13 + DB "Reverb Type", 13 + DB "Reverb Time", 13 + DB "Reverb Feedback", 13 + DB "Chorus Send", 13 + DB "Chorus Volume", 13 + DB "Chorus Type", 13 + DB "Chorus Delay", 13 + DB "Chorus Feedback", 13 + DB "Chorus Rate", 13 + DB "Chorus Depth", 13 + DB 0 + +EqLBL DW 14 + DB 60, 14 + DW 0, 127 + DW 9, 2 + DW 13, 22, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBR DW 14 + DB 60, 15 + DW 0, 127 + DW 9, 3 + DW 21, 23, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBF DW 14 + DB 60, 16 + DW 0, 127 + DW 9, 4 + DW 22, 24, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBL DW 14 + DB 60, 17 + DW 0, 127 + DW 9, 5 + DW 23, 25, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBR DW 14 + DB 60, 18 + DW 0, 127 + DW 9, 6 + DW 24, 26, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBF DW 14 + DB 60, 19 + DW 0, 127 + DW 9, 7 + DW 25, 27, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBL DW 14 + DB 60, 20 + DW 0, 127 + DW 9, 8 + DW 26, 28, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBR DW 14 + DB 60, 21 + DW 0, 127 + DW 9, 9 + DW 27, 29, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBF DW 14 + DB 60, 22 + DW 0, 127 + DW 9, 10 + DW 28, 30, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBL DW 14 + DB 60, 23 + DW 0, 127 + DW 9, 11 + DW 29, 31, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBR DW 14 + DB 60, 24 + DW 0, 127 + DW 9, 12 + DW 30, 32, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBF DW 14 + DB 60, 25 + DW 0, 127 + DW 9, 13 + DW 31, 33, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoLevel DW 14 + DB 60, 26 + DW 0, 127 + DW 9, 15 + DW 32, 34, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoTime DW 14 + DB 60, 27 + DW 0, 127 + DW 9, 14 + DW 33, 35, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoFeedback DW 14 + DB 60, 28 + DW 0, 127 + DW 9, 16 + DW 34, 36, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundVolume DW 14 + DB 60, 29 + DW 0, 255 + DW 9, 17 + DW 35, 37, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundDelay DW 14 + DB 60, 30 + DW 0, 127 + DW 9, 18 + DW 36, 38, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbSend DW 14 + DB 60, 31 + DW 0, 127 + DW 9, 19 + DW 37, 39, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbVolume DW 14 + DB 60, 32 + DW 0, 255 + DW 9, 20 + DW 38, 40, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + + +ReverbType DW 14 + DB 60, 33 + DW 0, 7 + DW 9, 21 + DW 39, 41, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbTime DW 14 + DB 60, 34 + DW 0, 127 + DW 9, 22 + DW 40, 42, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbFeedback DW 14 + DB 60, 35 + DW 0, 127 + DW 9, 23 + DW 41, 43, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusSend DW 14 + DB 60, 36 + DW 0, 127 + DW 9, 24 + DW 42, 44, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusVolume DW 14 + DB 60, 37 + DW 0, 255 + DW 9, 25 + DW 43, 45, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusType DW 14 + DB 60, 38 + DW 0, 7 + DW 9, 26 + DW 44, 46, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDelay DW 14 + DB 60, 39 + DW 0, 127 + DW 9, 27 + DW 45, 47, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusFeedback DW 14 + DB 60, 40 + DW 0, 127 + DW 9, 28 + DW 46, 48, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusRate DW 14 + DB 60, 41 + DW 0, 127 + DW 9, 29 + DW 47, 49, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDepth DW 14 + DB 60, 42 + DW 0, 127 + DW 9, 30 + DW 48, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SAM9407ParametersBox DW 0 + DB 59, 13, 75, 43 + DB 25 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +SAM9407PortText DW 1 + DB 21, 47 + DB 21h + DB "Audiosystem EWS64 SAM9407 Port ", 0FDh, "Xh, Mixing Rate: ", 0FDh, "D", 0 +MixSpeed DW 48000 +SAM9407Port DW 0 + +DriverText DW 1 + DB 21, 48 + DB 21h + DB "Audiosystem EWS64 XL Codec Driver 1.2 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode", 0 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 21, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +include dmasirq.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InByte ; Returns AL + + Push DX + Mov DX, CS:SAM9407Port + Inc DX + +SAM9407InByte1: + In AL, DX + Test AL, AL + JS SAM9407InByte1 + + Dec DX + In AL, DX + Pop DX + + Ret + +EndP SAM9407InByte + +Comment ~ + +; ÄÄ ST97InWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InWord ; Returns AX + + ClI + + Call SAM9407InByte + Mov AL, AH + + Call SAM9407InByte + XChg AL, AH + + StI + + Ret + +EndP SAM9407InWord + +; ÄÄ SAM9407InDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InDWord ; Returns EAX + + ClI + + Call SAM9407InByte + RoR EAX, 8 + + Call SAM9407InByte + RoR EAX, 8 + + Call SAM9407InByte + RoR EAX, 8 + + Call SAM9407InByte + RoR EAX, 8 + + StI + Ret + +EndP SAM9407InDWord + +~ + +; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendByte ; DX = port, AL = data + + Push AX + Push DX + Mov DX, CS:SAM9407Port + Inc DX + +SAM9407SendByte1: + In AL, DX + Test AL, 40h + JNZ SAM9407SendByte1 + + Pop DX + Pop AX + + Out DX, AL + + Ret + +EndP SAM9407SendByte + +Comment ~ + +; ÄÄ ST97OutByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407OutByte ; AL = data, AH = command, destroys AX + + ClI + Push DX + + Mov DX, CS:SAM9407Port + Inc DX + + XChg AH, AL + Call SAM9407SendByte + + Dec DX + + Mov AL, AH + Call SAM9407SendByte + + Pop DX + StI + + Ret + +EndP SAM9407OutByte + +; ÄÄ ST97OutWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407OutWord ; AX = data, BL = command, destroys AX + + ClI + Push DX + Push AX + + Mov DX, CS:SAM9407Port + Mov AL, BL + Inc DX + Call SAM9407SendByte + + Pop AX + Dec DX + Call SAM9407SendByte + + Mov AL, AH + Call SAM9407SendByte + + Pop DX + StI + + Ret + +EndP SAM9407OutWord + +; ÄÄ ST97OutDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407OutDWord ; EAX = data, BL = command + + ClI + Push DX + Push AX + + Mov DX, CS:SAM9407Port + Mov AL, BL + Inc DX + Call SAM9407SendByte + + Pop AX + Dec DX + Call SAM9407SendByte + + ShR EAX, 8 + Call SAM9407SendByte + + ShR EAX, 8 + Call SAM9407SendByte + + ShR EAX, 8 + Call SAM9407SendByte + + Pop DX + StI + + Ret + +EndP SAM9407OutDWord + +~ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSAM9407 ; DI = index. 1 = full reinit. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + LEA SI, [SAM9407Strings+EDI+EDI-2] + Mov SI, [SI] + + LodsW + Mov CX, AX + +SetSAM9407_1: +; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. + + Mov DX, SAM9407Port + LodsW + + Cmp AH, 2 + JB SetSAM9407_3 + JA SetSAM9407_4 + + Mov AL, [VolumeTable+DI] + Jmp SetSAM9407_2 + +SetSAM9407_4: + Push CX + + Mov CX, 1024 + +SetSAM9407_6: + Call SAM9407InByte + Test AL, AL + LoopNZ SetSAM9407_6 + + Pop CX + + Jmp SetSAM9407_5 + +SetSAM9407_3: + And AH, 1 + Add DL, AH + +SetSAM9407_2: + Call SAM9407SendByte + +SetSAM9407_5: + Dec CX + JNZ SetSAM9407_1 + + Pop DS + PopA + + Ret + +EndP SetSAM9407 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + + Mov AX, 1 + Ret + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 48000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 14 ; 14 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov AX, 407h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Test AX, AX + JZ PnP_IsolateNextCard + + Mov SAM9407Port, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Trace "Detecting EWS64XL" + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + Trace "EWS64XL Not Found" + + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + Trace "EWS64XL Found" + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + CLD + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Trace "EWS64XL InitSound" + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Trace "EWS64XL Memory Allocated" + + + Call SetIRQ + Call GetTempo + Call SetTempo + + Trace "EWS64XL IRQ Hooked" + + Mov DX, BasePort + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Trace "EWS64XL Volume Settings Received" + + Mov DI, 1 + Call SetSAM9407 + + Trace "EWS64XL SAM9407 InitString finished" + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call StopWSS + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Push AX + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + + Pop DI + + And DI, 1 + Add DI, 31 + Call SetSAM9407 + + Mov DI, 2 +SetStereo2: + Call SetSAM9407 + Inc DI + Cmp DI, 30 + JBE SetStereo2 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + + Pop DS + PopA + + Ret + +EndP UpdateSoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Mov [CS:VolumeTable+DI], AL + Cmp DI, 2 + JB SetVariable1 + + Call SetSAM9407 + Ret + +SetVariable1: + Call UpdateSoundcardVariables + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/EWSCODMX.ASM b/SoundDrivers/EWSCODMX.ASM index 12da420..b2a216e 100755 --- a/SoundDrivers/EWSCODMX.ASM +++ b/SoundDrivers/EWSCODMX.ASM @@ -1,2531 +1,2531 @@ -; -; EWS 64 Codec Driver -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -TRACEENABLED = 0 -CREATENEWLOGFILE = 1 - -include debug.inc - -OUTPUTFILTERENABLED EQU 0 -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -DATAFLAG EQU 200h -ACKFLAG EQU 300h - -PNPSERIALID EQU 98B03C20h -PNPVENDORID EQU 36A8630Eh - -DMASize DW 4096 - -WSSMsg DB "Audiosystem EWS64 XL Codec", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Audiosystem EWS64 XL Codec", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Audiosystem EWS64 XL reinitialised", 0 - -DriverName DB "ITEWSCOD.MMX", 0 - -ALIGN 2 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 35 -MixMode DW 0 -MixModeOffset DW 0 -VolumeTable DB 56, 56 - DB 60h, 60h, 0Ch ; Low Band - DB 40h, 40h, 1Bh ; Med Low Band - DB 40h, 40h, 72h ; Med High Band - DB 60h, 60h, 40h ; High Band - DB 0, 0, 0 ; Echo - DB 0, 2 ; Surround - DB 0, 90h, 4, 7Fh, 22h ; Reverb - DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus - -IMR DW 0 -OldWSSIRQHandler DD 0 - -; String format, Count, [Data/Port]*Count -; Port = 1 for Control port, 0 for data port. - -SAM9407Reset DW 66 - DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on - DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on - DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on - DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on - DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type - DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on - DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in - DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus - DW 1BEh, 133h, 0, 0 ; 2 Speaker - DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 - DW 1BEh, 134h, 0FFh, 0FFh ; Left gain - DW 1BEh, 135h, 0FFh, 0FFh ; Right gain - DW 1BEh, 136h, 0, 0 ; Left pan - DW 1BEh, 137h, 7Fh, 7Fh ; Right pan - DW 1BEh, 107h, 0FFh, 0FFh ; Master volume - -SAM9407EqLBL DW 4 - DW 1BEh, 110h, DATAFLAG, 60h -SAM9407EqLBR DW 4 - DW 1BEh, 114h, DATAFLAG, 60h -SAM9407EqLBF DW 4 - DW 1BEh, 118h, DATAFLAG, 0Ch -SAM9407EqMLBL DW 4 - DW 1BEh, 111h, DATAFLAG, 40h -SAM9407EqMLBR DW 4 - DW 1BEh, 115h, DATAFLAG, 40h -SAM9407EqMLBF DW 4 - DW 1BEh, 119h, DATAFLAG, 1Bh -SAM9407EqMHBL DW 4 - DW 1BEh, 112h, DATAFLAG, 40h -SAM9407EqMHBR DW 4 - DW 1BEh, 116h, DATAFLAG, 40h -SAM9407EqMHBF DW 4 - DW 1BEh, 11Ah, DATAFLAG, 72h -SAM9407EqHBL DW 4 - DW 1BEh, 113h, DATAFLAG, 60h -SAM9407EqHBR DW 4 - DW 1BEh, 117h, DATAFLAG, 60h -SAM9407EqHBF DW 4 - DW 1BEh, 11Bh, DATAFLAG, 0Ch -SAM9407EchoLevel DW 4 - DW 1BEh, 128h, DATAFLAG, 0 -SAM9407EchoTime DW 4 - DW 1BEh, 129h, DATAFLAG, 2Bh -SAM9407EchoFeed DW 4 - DW 1BEh, 12Ah, DATAFLAG, 40h -SAM9407SurroundVolume DW 4 - DW 1BEh, 130h, DATAFLAG, 0 -SAM9407SurroundDelay DW 4 - DW 1BEh, 131h, DATAFLAG, 2 -SAM9407ReverbSend DW 4 - DW 1BEh, 127h, DATAFLAG, 0 -SAM9407ReverbVolume DW 3 - DW 1BEh, 13Ah, DATAFLAG -SAM9407ReverbType DW 4 - DW 1BEh, 169h, DATAFLAG, 4 -SAM9407ReverbTime DW 3 - DW 1BEh, 178h, DATAFLAG -SAM9407ReverbFeedback DW 3 - DW 1BEh, 179h, DATAFLAG -SAM9407ChorusSend DW 4 - DW 1BEh, 124h, DATAFLAG, 0 -SAM9407ChorusVolume DW 3 - DW 1BEh, 13Bh, DATAFLAG -SAM9407ChorusType DW 4 - DW 1BEh, 16Ah, DATAFLAG, 2 -SAM9407ChorusDelay DW 3 - DW 1BEh, 174h, DATAFLAG -SAM9407ChorusFeedback DW 3 - DW 1BEh, 175h, DATAFLAG -SAM9407ChorusRate DW 3 - DW 1BEh, 176h, DATAFLAG -SAM9407ChorusDepth DW 3 - DW 1BEh, 177h, DATAFLAG -SAM9407Mono DW 4 - DW 1BEh, 132h, 7Fh, 0 -SAM9407Stereo DW 4 - DW 1BEh, 132h, 0, 0 - -SAM9407Strings DW Offset SAM9407Reset ;1 - DW Offset SAM9407EqLBL, Offset SAM9407EqLBR - DW Offset SAM9407EqLBF - DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR - DW Offset SAM9407EqMLBF - DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR - DW Offset SAM9407EqMHBF - DW Offset SAM9407EqHBL, Offset SAM9407EqHBR - DW Offset SAM9407EqHBF - DW Offset SAM9407EchoLevel ; 14 - DW Offset SAM9407EchoTime - DW Offset SAM9407EchoFeed - DW Offset SAM9407SurroundVolume ; 17 - DW Offset SAM9407SurroundDelay - DW Offset SAM9407ReverbSend ; 19 - DW Offset SAM9407ReverbVolume - DW Offset SAM9407ReverbType - DW Offset SAM9407ReverbTime - DW Offset SAM9407ReverbFeedback ; 23 - DW Offset SAM9407ChorusSend ; 24 - DW Offset SAM9407ChorusVolume - DW Offset SAM9407ChorusType - DW Offset SAM9407ChorusDelay - DW Offset SAM9407ChorusFeedback - DW Offset SAM9407ChorusRate - DW Offset SAM9407ChorusDepth ; 30 - DW Offset SAM9407Mono ; 31 - DW Offset SAM9407Stereo - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - -include irq.inc - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr EmptyObject - DW Near Ptr EmptyObject - DW Near Ptr EmptyObject - DW Near Ptr EmptyObject - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW Near Ptr SAM9407PortText - DW Near Ptr SAM9407ParametersText - DW Near Ptr SAM9407ParametersBox - - DW Near Ptr EqLBL ; 21 - DW Near Ptr EqLBR - DW Near Ptr EqLBF - - DW Near Ptr EqMLBL - DW Near Ptr EqMLBR - DW Near Ptr EqMLBF - - DW Near Ptr EqMHBL - DW Near Ptr EqMHBR - DW Near Ptr EqMHBF - - DW Near Ptr EqHBL - DW Near Ptr EqHBR - DW Near Ptr EqHBF - - DW Near Ptr EchoLevel - DW Near Ptr EchoTime - DW Near Ptr EchoFeedback - - DW Near Ptr SurroundVolume - DW Near Ptr SurroundDelay - - DW Near Ptr ReverbSend - DW Near Ptr ReverbVolume - DW Near Ptr ReverbType - DW Near Ptr ReverbTime - DW Near Ptr ReverbFeedback - - DW Near Ptr ChorusSend - DW Near Ptr ChorusVolume - DW Near Ptr ChorusType - DW Near Ptr ChorusDelay - DW Near Ptr ChorusFeedback - DW Near Ptr ChorusRate - DW Near Ptr ChorusDepth - - DW 0 - -WSSHeaderLine DW 10 - DB "Audiosystem EWS64 XL Codec Driver", 0 - -SAM9407ParametersText DW 1 - DB 36, 14 - DB 20h - DB "Low Band Left", 13 - DB "Low Band Right", 13 - DB "Low Band Frequency", 13 - DB "Med Low Band Left", 13 - DB "Med Low Band Right", 13 - DB "Med Low Band Frequency", 13 - DB "Med High Band Left", 13 - DB "Med High Band Right", 13 - DB "Med High Band Frequency", 13 - DB "High Band Left", 13 - DB "High Band Right", 13 - DB "High Band Frequency", 13 - DB "Echo Level", 13 - DB "Echo Time", 13 - DB "Echo Feedback", 13 - DB "Surround Volume", 13 - DB "Surround Delay", 13 - DB "Reverb Send", 13 - DB "Reverb Volume", 13 - DB "Reverb Type", 13 - DB "Reverb Time", 13 - DB "Reverb Feedback", 13 - DB "Chorus Send", 13 - DB "Chorus Volume", 13 - DB "Chorus Type", 13 - DB "Chorus Delay", 13 - DB "Chorus Feedback", 13 - DB "Chorus Rate", 13 - DB "Chorus Depth", 13 - DB 0 - -EqLBL DW 14 - DB 60, 14 - DW 0, 127 - DW 9, 2 - DW 9, 22, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBR DW 14 - DB 60, 15 - DW 0, 127 - DW 9, 3 - DW 21, 23, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBF DW 14 - DB 60, 16 - DW 0, 127 - DW 9, 4 - DW 22, 24, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBL DW 14 - DB 60, 17 - DW 0, 127 - DW 9, 5 - DW 23, 25, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBR DW 14 - DB 60, 18 - DW 0, 127 - DW 9, 6 - DW 24, 26, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBF DW 14 - DB 60, 19 - DW 0, 127 - DW 9, 7 - DW 25, 27, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBL DW 14 - DB 60, 20 - DW 0, 127 - DW 9, 8 - DW 26, 28, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBR DW 14 - DB 60, 21 - DW 0, 127 - DW 9, 9 - DW 27, 29, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBF DW 14 - DB 60, 22 - DW 0, 127 - DW 9, 10 - DW 28, 30, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBL DW 14 - DB 60, 23 - DW 0, 127 - DW 9, 11 - DW 29, 31, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBR DW 14 - DB 60, 24 - DW 0, 127 - DW 9, 12 - DW 30, 32, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBF DW 14 - DB 60, 25 - DW 0, 127 - DW 9, 13 - DW 31, 33, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoLevel DW 14 - DB 60, 26 - DW 0, 127 - DW 9, 15 - DW 32, 34, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoTime DW 14 - DB 60, 27 - DW 0, 127 - DW 9, 14 - DW 33, 35, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoFeedback DW 14 - DB 60, 28 - DW 0, 127 - DW 9, 16 - DW 34, 36, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundVolume DW 14 - DB 60, 29 - DW 0, 255 - DW 9, 17 - DW 35, 37, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundDelay DW 14 - DB 60, 30 - DW 0, 127 - DW 9, 18 - DW 36, 38, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbSend DW 14 - DB 60, 31 - DW 0, 127 - DW 9, 19 - DW 37, 39, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbVolume DW 14 - DB 60, 32 - DW 0, 255 - DW 9, 20 - DW 38, 40, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - - -ReverbType DW 14 - DB 60, 33 - DW 0, 7 - DW 9, 21 - DW 39, 41, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbTime DW 14 - DB 60, 34 - DW 0, 127 - DW 9, 22 - DW 40, 42, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbFeedback DW 14 - DB 60, 35 - DW 0, 127 - DW 9, 23 - DW 41, 43, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusSend DW 14 - DB 60, 36 - DW 0, 127 - DW 9, 24 - DW 42, 44, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusVolume DW 14 - DB 60, 37 - DW 0, 255 - DW 9, 25 - DW 43, 45, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusType DW 14 - DB 60, 38 - DW 0, 7 - DW 9, 26 - DW 44, 46, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDelay DW 14 - DB 60, 39 - DW 0, 127 - DW 9, 27 - DW 45, 47, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusFeedback DW 14 - DB 60, 40 - DW 0, 127 - DW 9, 28 - DW 46, 48, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusRate DW 14 - DB 60, 41 - DW 0, 127 - DW 9, 29 - DW 47, 49, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDepth DW 14 - DB 60, 42 - DW 0, 127 - DW 9, 30 - DW 48, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SAM9407ParametersBox DW 0 - DB 59, 13, 75, 43 - DB 25 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -SAM9407PortText DW 1 - DB 21, 47 - DB 21h - DB "Audiosystem EWS64 SAM9407 Port ", 0FDh, "Xh, Mixing Rate: ", 0FDh, "D", 0 -MixSpeed DW 48000 -SAM9407Port DW 0 - -DriverText DW 1 - DB 21, 48 - DB 21h - DB "Audiosystem EWS64 XL Codec Driver 1.2 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode", 0 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 21, 32, 23, 8 - DB 0 - DB " MMX, Non-interpolated", 0 - -MixModeButton2 DW 2 - DW 6 - DW 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 24, 32, 26, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 27, 32, 29, 8 - DB 0 - DB " MMX, Volume Ramp", 0 - -MixModeButton4 DW 2 - DW 8, 21, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 30, 32, 32, 8 - DB 0 - DB " MMX, Filtered", 0 - -LongMixSpeed DD 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include dmasirq.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InByte ; Returns AL - - Push DX - Mov DX, CS:SAM9407Port - Inc DX - -SAM9407InByte1: - In AL, DX - Test AL, AL - JS SAM9407InByte1 - - Dec DX - In AL, DX - Pop DX - - Ret - -EndP SAM9407InByte - -Comment ~ - -; ÄÄ ST97InWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InWord ; Returns AX - - ClI - - Call SAM9407InByte - Mov AL, AH - - Call SAM9407InByte - XChg AL, AH - - StI - - Ret - -EndP SAM9407InWord - -; ÄÄ SAM9407InDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InDWord ; Returns EAX - - ClI - - Call SAM9407InByte - RoR EAX, 8 - - Call SAM9407InByte - RoR EAX, 8 - - Call SAM9407InByte - RoR EAX, 8 - - Call SAM9407InByte - RoR EAX, 8 - - StI - Ret - -EndP SAM9407InDWord - -~ - -; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendByte ; DX = port, AL = data - - Push AX - Push DX - Mov DX, CS:SAM9407Port - Inc DX - -SAM9407SendByte1: - In AL, DX - Test AL, 40h - JNZ SAM9407SendByte1 - - Pop DX - Pop AX - - Out DX, AL - - Ret - -EndP SAM9407SendByte - -Comment ~ - -; ÄÄ ST97OutByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407OutByte ; AL = data, AH = command, destroys AX - - ClI - Push DX - - Mov DX, CS:SAM9407Port - Inc DX - - XChg AH, AL - Call SAM9407SendByte - - Dec DX - - Mov AL, AH - Call SAM9407SendByte - - Pop DX - StI - - Ret - -EndP SAM9407OutByte - -; ÄÄ ST97OutWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407OutWord ; AX = data, BL = command, destroys AX - - ClI - Push DX - Push AX - - Mov DX, CS:SAM9407Port - Mov AL, BL - Inc DX - Call SAM9407SendByte - - Pop AX - Dec DX - Call SAM9407SendByte - - Mov AL, AH - Call SAM9407SendByte - - Pop DX - StI - - Ret - -EndP SAM9407OutWord - -; ÄÄ ST97OutDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407OutDWord ; EAX = data, BL = command - - ClI - Push DX - Push AX - - Mov DX, CS:SAM9407Port - Mov AL, BL - Inc DX - Call SAM9407SendByte - - Pop AX - Dec DX - Call SAM9407SendByte - - ShR EAX, 8 - Call SAM9407SendByte - - ShR EAX, 8 - Call SAM9407SendByte - - ShR EAX, 8 - Call SAM9407SendByte - - Pop DX - StI - - Ret - -EndP SAM9407OutDWord - -~ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSAM9407 ; DI = index. 1 = full reinit. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - LEA SI, [SAM9407Strings+EDI+EDI-2] - Mov SI, [SI] - - LodsW - Mov CX, AX - -SetSAM9407_1: -; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. - - Mov DX, SAM9407Port - LodsW - - Cmp AH, 2 - JB SetSAM9407_3 - JA SetSAM9407_4 - - Mov AL, [VolumeTable+DI] - Jmp SetSAM9407_2 - -SetSAM9407_4: - Push CX - - Mov CX, 1024 - -SetSAM9407_6: - Call SAM9407InByte - Test AL, AL - LoopNZ SetSAM9407_6 - - Pop CX - - Jmp SetSAM9407_5 - -SetSAM9407_3: - And AH, 1 - Add DL, AH - -SetSAM9407_2: - Call SAM9407SendByte - -SetSAM9407_5: - Dec CX - JNZ SetSAM9407_1 - - Pop DS - PopA - - Ret - -EndP SetSAM9407 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 48000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 14 ; 14 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov Word Ptr LongMixSpeed, BX - Mov WSSMixConst, DH - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMMX - - Trace "Detecting MMX" - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectMMXFail - - Mov EAX, 1 - DB 0Fh, 0A2h ; CPUID - Test EDX, 800000h - JZ DetectMMXFail - - Trace "MMX Detected" - - ClC - Ret - -DetectMMXFail: - Trace "MMX not detected" - - StC - Ret - -EndP DetectMMX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov AX, 407h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Test AX, AX - JZ PnP_IsolateNextCard - - Mov SAM9407Port, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Call DetectMMX - JNC DetectCard1 - - Ret - -DetectCard1: - Trace "Detecting EWS64XL" - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - Trace "EWS64XL Not Found" - - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - Trace "EWS64XL Found" - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - CLD - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Trace "EWS64XL InitSound" - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 5 + (DMABUFFERLENGTH*2)/16 - Mov BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - - Trace "EWS64XL Memory Allocated" - - Call SetIRQ - Call GetTempo - Call SetTempo - - Trace "EWS64XL IRQ Hooked" - - Mov DX, BasePort - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Trace "EWS64XL Volume Settings Received" - - Mov DI, 1 - Call SetSAM9407 - - Trace "EWS64XL SAM9407 InitString finished" - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call StopWSS - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Push AX - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - - Pop DI - - And DI, 1 - Add DI, 31 - Call SetSAM9407 - - Mov DI, 2 -SetStereo2: - Call SetSAM9407 - Inc DI - Cmp DI, 30 - JBE SetStereo2 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - - Pop DS - PopA - - Ret - -EndP UpdateSoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Mov [CS:VolumeTable+DI], AL - Cmp DI, 2 - JB SetVariable1 - - Call SetSAM9407 - Ret - -SetVariable1: - Call UpdateSoundcardVariables - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut - - Push CX - Push DX - Mov DX, CS:SAM9407Port - - Push AX - Xor CX, CX - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - LoopNZ UARTOut1 - - Pop AX - JNZ UARTOutEnd - - Dec DX - Out DX, AL - -UARTOutEnd: - Pop DX - Pop CX - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 -DriverFlags DW 3 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; EWS 64 Codec Driver +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +TRACEENABLED = 0 +CREATENEWLOGFILE = 1 + +include debug.inc + +OUTPUTFILTERENABLED EQU 0 +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +DATAFLAG EQU 200h +ACKFLAG EQU 300h + +PNPSERIALID EQU 98B03C20h +PNPVENDORID EQU 36A8630Eh + +DMASize DW 4096 + +WSSMsg DB "Audiosystem EWS64 XL Codec", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Audiosystem EWS64 XL Codec", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Audiosystem EWS64 XL reinitialised", 0 + +DriverName DB "ITEWSCOD.MMX", 0 + +ALIGN 2 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 35 +MixMode DW 0 +MixModeOffset DW 0 +VolumeTable DB 56, 56 + DB 60h, 60h, 0Ch ; Low Band + DB 40h, 40h, 1Bh ; Med Low Band + DB 40h, 40h, 72h ; Med High Band + DB 60h, 60h, 40h ; High Band + DB 0, 0, 0 ; Echo + DB 0, 2 ; Surround + DB 0, 90h, 4, 7Fh, 22h ; Reverb + DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus + +IMR DW 0 +OldWSSIRQHandler DD 0 + +; String format, Count, [Data/Port]*Count +; Port = 1 for Control port, 0 for data port. + +SAM9407Reset DW 66 + DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on + DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on + DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on + DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on + DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type + DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on + DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in + DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus + DW 1BEh, 133h, 0, 0 ; 2 Speaker + DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 + DW 1BEh, 134h, 0FFh, 0FFh ; Left gain + DW 1BEh, 135h, 0FFh, 0FFh ; Right gain + DW 1BEh, 136h, 0, 0 ; Left pan + DW 1BEh, 137h, 7Fh, 7Fh ; Right pan + DW 1BEh, 107h, 0FFh, 0FFh ; Master volume + +SAM9407EqLBL DW 4 + DW 1BEh, 110h, DATAFLAG, 60h +SAM9407EqLBR DW 4 + DW 1BEh, 114h, DATAFLAG, 60h +SAM9407EqLBF DW 4 + DW 1BEh, 118h, DATAFLAG, 0Ch +SAM9407EqMLBL DW 4 + DW 1BEh, 111h, DATAFLAG, 40h +SAM9407EqMLBR DW 4 + DW 1BEh, 115h, DATAFLAG, 40h +SAM9407EqMLBF DW 4 + DW 1BEh, 119h, DATAFLAG, 1Bh +SAM9407EqMHBL DW 4 + DW 1BEh, 112h, DATAFLAG, 40h +SAM9407EqMHBR DW 4 + DW 1BEh, 116h, DATAFLAG, 40h +SAM9407EqMHBF DW 4 + DW 1BEh, 11Ah, DATAFLAG, 72h +SAM9407EqHBL DW 4 + DW 1BEh, 113h, DATAFLAG, 60h +SAM9407EqHBR DW 4 + DW 1BEh, 117h, DATAFLAG, 60h +SAM9407EqHBF DW 4 + DW 1BEh, 11Bh, DATAFLAG, 0Ch +SAM9407EchoLevel DW 4 + DW 1BEh, 128h, DATAFLAG, 0 +SAM9407EchoTime DW 4 + DW 1BEh, 129h, DATAFLAG, 2Bh +SAM9407EchoFeed DW 4 + DW 1BEh, 12Ah, DATAFLAG, 40h +SAM9407SurroundVolume DW 4 + DW 1BEh, 130h, DATAFLAG, 0 +SAM9407SurroundDelay DW 4 + DW 1BEh, 131h, DATAFLAG, 2 +SAM9407ReverbSend DW 4 + DW 1BEh, 127h, DATAFLAG, 0 +SAM9407ReverbVolume DW 3 + DW 1BEh, 13Ah, DATAFLAG +SAM9407ReverbType DW 4 + DW 1BEh, 169h, DATAFLAG, 4 +SAM9407ReverbTime DW 3 + DW 1BEh, 178h, DATAFLAG +SAM9407ReverbFeedback DW 3 + DW 1BEh, 179h, DATAFLAG +SAM9407ChorusSend DW 4 + DW 1BEh, 124h, DATAFLAG, 0 +SAM9407ChorusVolume DW 3 + DW 1BEh, 13Bh, DATAFLAG +SAM9407ChorusType DW 4 + DW 1BEh, 16Ah, DATAFLAG, 2 +SAM9407ChorusDelay DW 3 + DW 1BEh, 174h, DATAFLAG +SAM9407ChorusFeedback DW 3 + DW 1BEh, 175h, DATAFLAG +SAM9407ChorusRate DW 3 + DW 1BEh, 176h, DATAFLAG +SAM9407ChorusDepth DW 3 + DW 1BEh, 177h, DATAFLAG +SAM9407Mono DW 4 + DW 1BEh, 132h, 7Fh, 0 +SAM9407Stereo DW 4 + DW 1BEh, 132h, 0, 0 + +SAM9407Strings DW Offset SAM9407Reset ;1 + DW Offset SAM9407EqLBL, Offset SAM9407EqLBR + DW Offset SAM9407EqLBF + DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR + DW Offset SAM9407EqMLBF + DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR + DW Offset SAM9407EqMHBF + DW Offset SAM9407EqHBL, Offset SAM9407EqHBR + DW Offset SAM9407EqHBF + DW Offset SAM9407EchoLevel ; 14 + DW Offset SAM9407EchoTime + DW Offset SAM9407EchoFeed + DW Offset SAM9407SurroundVolume ; 17 + DW Offset SAM9407SurroundDelay + DW Offset SAM9407ReverbSend ; 19 + DW Offset SAM9407ReverbVolume + DW Offset SAM9407ReverbType + DW Offset SAM9407ReverbTime + DW Offset SAM9407ReverbFeedback ; 23 + DW Offset SAM9407ChorusSend ; 24 + DW Offset SAM9407ChorusVolume + DW Offset SAM9407ChorusType + DW Offset SAM9407ChorusDelay + DW Offset SAM9407ChorusFeedback + DW Offset SAM9407ChorusRate + DW Offset SAM9407ChorusDepth ; 30 + DW Offset SAM9407Mono ; 31 + DW Offset SAM9407Stereo + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + +include irq.inc + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr EmptyObject + DW Near Ptr EmptyObject + DW Near Ptr EmptyObject + DW Near Ptr EmptyObject + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW Near Ptr SAM9407PortText + DW Near Ptr SAM9407ParametersText + DW Near Ptr SAM9407ParametersBox + + DW Near Ptr EqLBL ; 21 + DW Near Ptr EqLBR + DW Near Ptr EqLBF + + DW Near Ptr EqMLBL + DW Near Ptr EqMLBR + DW Near Ptr EqMLBF + + DW Near Ptr EqMHBL + DW Near Ptr EqMHBR + DW Near Ptr EqMHBF + + DW Near Ptr EqHBL + DW Near Ptr EqHBR + DW Near Ptr EqHBF + + DW Near Ptr EchoLevel + DW Near Ptr EchoTime + DW Near Ptr EchoFeedback + + DW Near Ptr SurroundVolume + DW Near Ptr SurroundDelay + + DW Near Ptr ReverbSend + DW Near Ptr ReverbVolume + DW Near Ptr ReverbType + DW Near Ptr ReverbTime + DW Near Ptr ReverbFeedback + + DW Near Ptr ChorusSend + DW Near Ptr ChorusVolume + DW Near Ptr ChorusType + DW Near Ptr ChorusDelay + DW Near Ptr ChorusFeedback + DW Near Ptr ChorusRate + DW Near Ptr ChorusDepth + + DW 0 + +WSSHeaderLine DW 10 + DB "Audiosystem EWS64 XL Codec Driver", 0 + +SAM9407ParametersText DW 1 + DB 36, 14 + DB 20h + DB "Low Band Left", 13 + DB "Low Band Right", 13 + DB "Low Band Frequency", 13 + DB "Med Low Band Left", 13 + DB "Med Low Band Right", 13 + DB "Med Low Band Frequency", 13 + DB "Med High Band Left", 13 + DB "Med High Band Right", 13 + DB "Med High Band Frequency", 13 + DB "High Band Left", 13 + DB "High Band Right", 13 + DB "High Band Frequency", 13 + DB "Echo Level", 13 + DB "Echo Time", 13 + DB "Echo Feedback", 13 + DB "Surround Volume", 13 + DB "Surround Delay", 13 + DB "Reverb Send", 13 + DB "Reverb Volume", 13 + DB "Reverb Type", 13 + DB "Reverb Time", 13 + DB "Reverb Feedback", 13 + DB "Chorus Send", 13 + DB "Chorus Volume", 13 + DB "Chorus Type", 13 + DB "Chorus Delay", 13 + DB "Chorus Feedback", 13 + DB "Chorus Rate", 13 + DB "Chorus Depth", 13 + DB 0 + +EqLBL DW 14 + DB 60, 14 + DW 0, 127 + DW 9, 2 + DW 9, 22, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBR DW 14 + DB 60, 15 + DW 0, 127 + DW 9, 3 + DW 21, 23, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBF DW 14 + DB 60, 16 + DW 0, 127 + DW 9, 4 + DW 22, 24, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBL DW 14 + DB 60, 17 + DW 0, 127 + DW 9, 5 + DW 23, 25, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBR DW 14 + DB 60, 18 + DW 0, 127 + DW 9, 6 + DW 24, 26, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBF DW 14 + DB 60, 19 + DW 0, 127 + DW 9, 7 + DW 25, 27, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBL DW 14 + DB 60, 20 + DW 0, 127 + DW 9, 8 + DW 26, 28, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBR DW 14 + DB 60, 21 + DW 0, 127 + DW 9, 9 + DW 27, 29, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBF DW 14 + DB 60, 22 + DW 0, 127 + DW 9, 10 + DW 28, 30, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBL DW 14 + DB 60, 23 + DW 0, 127 + DW 9, 11 + DW 29, 31, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBR DW 14 + DB 60, 24 + DW 0, 127 + DW 9, 12 + DW 30, 32, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBF DW 14 + DB 60, 25 + DW 0, 127 + DW 9, 13 + DW 31, 33, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoLevel DW 14 + DB 60, 26 + DW 0, 127 + DW 9, 15 + DW 32, 34, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoTime DW 14 + DB 60, 27 + DW 0, 127 + DW 9, 14 + DW 33, 35, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoFeedback DW 14 + DB 60, 28 + DW 0, 127 + DW 9, 16 + DW 34, 36, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundVolume DW 14 + DB 60, 29 + DW 0, 255 + DW 9, 17 + DW 35, 37, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundDelay DW 14 + DB 60, 30 + DW 0, 127 + DW 9, 18 + DW 36, 38, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbSend DW 14 + DB 60, 31 + DW 0, 127 + DW 9, 19 + DW 37, 39, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbVolume DW 14 + DB 60, 32 + DW 0, 255 + DW 9, 20 + DW 38, 40, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + + +ReverbType DW 14 + DB 60, 33 + DW 0, 7 + DW 9, 21 + DW 39, 41, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbTime DW 14 + DB 60, 34 + DW 0, 127 + DW 9, 22 + DW 40, 42, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbFeedback DW 14 + DB 60, 35 + DW 0, 127 + DW 9, 23 + DW 41, 43, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusSend DW 14 + DB 60, 36 + DW 0, 127 + DW 9, 24 + DW 42, 44, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusVolume DW 14 + DB 60, 37 + DW 0, 255 + DW 9, 25 + DW 43, 45, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusType DW 14 + DB 60, 38 + DW 0, 7 + DW 9, 26 + DW 44, 46, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDelay DW 14 + DB 60, 39 + DW 0, 127 + DW 9, 27 + DW 45, 47, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusFeedback DW 14 + DB 60, 40 + DW 0, 127 + DW 9, 28 + DW 46, 48, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusRate DW 14 + DB 60, 41 + DW 0, 127 + DW 9, 29 + DW 47, 49, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDepth DW 14 + DB 60, 42 + DW 0, 127 + DW 9, 30 + DW 48, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SAM9407ParametersBox DW 0 + DB 59, 13, 75, 43 + DB 25 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +SAM9407PortText DW 1 + DB 21, 47 + DB 21h + DB "Audiosystem EWS64 SAM9407 Port ", 0FDh, "Xh, Mixing Rate: ", 0FDh, "D", 0 +MixSpeed DW 48000 +SAM9407Port DW 0 + +DriverText DW 1 + DB 21, 48 + DB 21h + DB "Audiosystem EWS64 XL Codec Driver 1.2 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode", 0 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 21, 32, 23, 8 + DB 0 + DB " MMX, Non-interpolated", 0 + +MixModeButton2 DW 2 + DW 6 + DW 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 24, 32, 26, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 27, 32, 29, 8 + DB 0 + DB " MMX, Volume Ramp", 0 + +MixModeButton4 DW 2 + DW 8, 21, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 30, 32, 32, 8 + DB 0 + DB " MMX, Filtered", 0 + +LongMixSpeed DD 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include dmasirq.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InByte ; Returns AL + + Push DX + Mov DX, CS:SAM9407Port + Inc DX + +SAM9407InByte1: + In AL, DX + Test AL, AL + JS SAM9407InByte1 + + Dec DX + In AL, DX + Pop DX + + Ret + +EndP SAM9407InByte + +Comment ~ + +; ÄÄ ST97InWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InWord ; Returns AX + + ClI + + Call SAM9407InByte + Mov AL, AH + + Call SAM9407InByte + XChg AL, AH + + StI + + Ret + +EndP SAM9407InWord + +; ÄÄ SAM9407InDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InDWord ; Returns EAX + + ClI + + Call SAM9407InByte + RoR EAX, 8 + + Call SAM9407InByte + RoR EAX, 8 + + Call SAM9407InByte + RoR EAX, 8 + + Call SAM9407InByte + RoR EAX, 8 + + StI + Ret + +EndP SAM9407InDWord + +~ + +; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendByte ; DX = port, AL = data + + Push AX + Push DX + Mov DX, CS:SAM9407Port + Inc DX + +SAM9407SendByte1: + In AL, DX + Test AL, 40h + JNZ SAM9407SendByte1 + + Pop DX + Pop AX + + Out DX, AL + + Ret + +EndP SAM9407SendByte + +Comment ~ + +; ÄÄ ST97OutByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407OutByte ; AL = data, AH = command, destroys AX + + ClI + Push DX + + Mov DX, CS:SAM9407Port + Inc DX + + XChg AH, AL + Call SAM9407SendByte + + Dec DX + + Mov AL, AH + Call SAM9407SendByte + + Pop DX + StI + + Ret + +EndP SAM9407OutByte + +; ÄÄ ST97OutWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407OutWord ; AX = data, BL = command, destroys AX + + ClI + Push DX + Push AX + + Mov DX, CS:SAM9407Port + Mov AL, BL + Inc DX + Call SAM9407SendByte + + Pop AX + Dec DX + Call SAM9407SendByte + + Mov AL, AH + Call SAM9407SendByte + + Pop DX + StI + + Ret + +EndP SAM9407OutWord + +; ÄÄ ST97OutDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407OutDWord ; EAX = data, BL = command + + ClI + Push DX + Push AX + + Mov DX, CS:SAM9407Port + Mov AL, BL + Inc DX + Call SAM9407SendByte + + Pop AX + Dec DX + Call SAM9407SendByte + + ShR EAX, 8 + Call SAM9407SendByte + + ShR EAX, 8 + Call SAM9407SendByte + + ShR EAX, 8 + Call SAM9407SendByte + + Pop DX + StI + + Ret + +EndP SAM9407OutDWord + +~ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSAM9407 ; DI = index. 1 = full reinit. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + LEA SI, [SAM9407Strings+EDI+EDI-2] + Mov SI, [SI] + + LodsW + Mov CX, AX + +SetSAM9407_1: +; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. + + Mov DX, SAM9407Port + LodsW + + Cmp AH, 2 + JB SetSAM9407_3 + JA SetSAM9407_4 + + Mov AL, [VolumeTable+DI] + Jmp SetSAM9407_2 + +SetSAM9407_4: + Push CX + + Mov CX, 1024 + +SetSAM9407_6: + Call SAM9407InByte + Test AL, AL + LoopNZ SetSAM9407_6 + + Pop CX + + Jmp SetSAM9407_5 + +SetSAM9407_3: + And AH, 1 + Add DL, AH + +SetSAM9407_2: + Call SAM9407SendByte + +SetSAM9407_5: + Dec CX + JNZ SetSAM9407_1 + + Pop DS + PopA + + Ret + +EndP SetSAM9407 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 48000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 14 ; 14 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov Word Ptr LongMixSpeed, BX + Mov WSSMixConst, DH + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMMX + + Trace "Detecting MMX" + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectMMXFail + + Mov EAX, 1 + DB 0Fh, 0A2h ; CPUID + Test EDX, 800000h + JZ DetectMMXFail + + Trace "MMX Detected" + + ClC + Ret + +DetectMMXFail: + Trace "MMX not detected" + + StC + Ret + +EndP DetectMMX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov AX, 407h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Test AX, AX + JZ PnP_IsolateNextCard + + Mov SAM9407Port, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Call DetectMMX + JNC DetectCard1 + + Ret + +DetectCard1: + Trace "Detecting EWS64XL" + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + Trace "EWS64XL Not Found" + + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + Trace "EWS64XL Found" + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + CLD + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Trace "EWS64XL InitSound" + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 5 + (DMABUFFERLENGTH*2)/16 + Mov BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + + Trace "EWS64XL Memory Allocated" + + Call SetIRQ + Call GetTempo + Call SetTempo + + Trace "EWS64XL IRQ Hooked" + + Mov DX, BasePort + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Trace "EWS64XL Volume Settings Received" + + Mov DI, 1 + Call SetSAM9407 + + Trace "EWS64XL SAM9407 InitString finished" + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call StopWSS + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Push AX + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + + Pop DI + + And DI, 1 + Add DI, 31 + Call SetSAM9407 + + Mov DI, 2 +SetStereo2: + Call SetSAM9407 + Inc DI + Cmp DI, 30 + JBE SetStereo2 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + + Pop DS + PopA + + Ret + +EndP UpdateSoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Mov [CS:VolumeTable+DI], AL + Cmp DI, 2 + JB SetVariable1 + + Call SetSAM9407 + Ret + +SetVariable1: + Call UpdateSoundcardVariables + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut + + Push CX + Push DX + Mov DX, CS:SAM9407Port + + Push AX + Xor CX, CX + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + LoopNZ UARTOut1 + + Pop AX + JNZ UARTOutEnd + + Dec DX + Out DX, AL + +UARTOutEnd: + Pop DX + Pop CX + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 +DriverFlags DW 3 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/EXECOM.COM b/SoundDrivers/EXECOM.COM index dc9924543eea3e59ec6e2b36cf473010fdefd41e..406a048bba32f85051b415b749b396234307a32d 100755 GIT binary patch delta 94 zcmV-k0HOcj3D60Uf3bjs0h0v+D3dM%DU(3CKL)JK_GK%ZC zWoBt^Wn`1t0vnU{0w|Ln11ytE0~?cP10a)#12&Vt12L2F12qB)B$F`&uaiIo2(*$N Az5oCK delta 148 zcmcb>`G9jmJtObN`W8k;-pR~N8bDH;NmGHBOC>ZfF)1fip(I}+xhOTUBvm25w4|W4 zL?JCRCzW?{5tAxV>2xMFF`!aMh2oOL Data read port - In AL, DX - Add DL, 0Ch-0Ah - - Ret - -EndP ESSIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut ; AL = out - - Push DX - Push AX - - Mov DX, CS:MIDIPort - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - JNZ UARTOut1 - - Pop AX - Dec DX - Out DX, AL - - Pop DX - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTIn ; returns AL - - Push DX - - Mov DX, CS:MIDIPort - Inc DX - -UARTIn1: - In AL, DX - Test AL, 80h - JNZ UARTIn1 - - Dec DX - In AL, DX - - Pop DX - Ret - -EndP UARTIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSReadRegister ; AH = register to read. - ; DX = 2xCh - ; returns AL - - Mov AL, 0C0h - Call ESSOut - Mov AL, AH - Call ESSOut - Call ESSIn - - Ret - -EndP ESSReadRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Mov ConfigPort, AX - - Mov AX, 107h ; Audio device - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - Mov MIDIPort, AX - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, CS:MIDIPort - Inc DX - Mov AL, 0FFh - Out DX, AL - - Mov DX, CS:BasePort - Add DL, 6 - Mov AL, 3 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Call UARTIn - Mov BL, [MIDIBufferTail] - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [ConfigPort] - Add DL, 6 - In AL, DX - Test AL, 8 - JZ ESSNoMIDI - - Push AX - Call CheckMIDI - Pop AX - -ESSNoMIDI: - Test AL, 1 - JZ ESSIRQEnd - - Mov DX, [BasePort] - Add DL, 0Eh - In AL, DX - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB ESSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -ESSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB ESSIRQHandler6 - JE ESSIRQHFilter - - Cmp CS:Stereo, 0 - JE ESSIRQ3QFilterMono - -ESSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -ESSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -ESSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -ESSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilter: - Cmp CS:Stereo, 0 - JE ESSIRQHFilterMono - -ESSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -ESSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -ESSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -ESSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL ESSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG ESSIRQHandlerClip2 - -ESSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ ESSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - -ESSIRQEnd: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Pop ES - Pop DS - PopAD - IRet - -ESSIRQHandlerClip1: - Mov AX, 8000h - Jmp ESSIRQHandler7 - -ESSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp ESSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo3 - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetESSMixConst - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetESSMixConst1 - - Mov CX, 22050 - Cmp AX, CX - JB GetESSMixConst1 - - Mov CX, 56821 - Cmp AX, CX - JA GetESSMixConst1 - - Mov CX, AX - -GetESSMixConst1: ; CX = mixspeed. - Mov DX, 0Ch - Mov AX, 236Ch ; DX:AX = 795.5kHz - Div CX - - Mov BX, AX - Neg AL - Mov ESSMixConst, AL - - Mov DX, 0Ch - Mov AX, 236Ch - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetESSMixConst - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartESS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Call ResetDSP - Mov DX, BasePort - Add DL, 0Ch - -; Extended Functions - - Mov AL, 0C6h - Call ESSOut - -; Autoinit DMA - - Mov AL, 0B8h - Call ESSOut - Mov AL, 4 - Call ESSOut - -; Stereo/Mono select - - Mov AH, 0A8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0A8h - Call ESSOut - Mov AL, AH - And AL, Not 3 - Or AL, 2 - Cmp Stereo, 0 - JE StartESS1 - - Xor AL, 3 - -StartESS1: - Call ESSOut - -; DMA mode - - Mov AL, 0B9h - Call ESSOut - Mov AL, 2 - Call ESSOut - -; Mixspeed - - Mov AL, 0A1h - Call ESSOut - Mov AL, ESSMixConst - Call ESSOut - -; Filter clock divider - Mov AL, 0A2h - Call ESSOut - - Mov AL, 0FEh - Call ESSOut - -; DMA counter - Mov CX, DMASize - Neg CX - - Mov AL, 0A4h - Call ESSOut - Mov AL, CL - Call ESSOut - Mov AL, 0A5h - Call ESSOut - Mov AL, CH - Call ESSOut - -; Initialise DAC - Mov AL, 0B6h - Call ESSOut - Mov AL, 0 - Call ESSOut - -; Configure DACs - - Mov AL, 0B7h - Call ESSOut - Mov AL, 71h - Call ESSOut - - Mov AL, 0B7h - Call ESSOut - - Mov AL, 0BCh - Cmp Stereo, 0 - JNE StartESS2 - - Mov AL, 0F4h - -StartESS2: - Call ESSOut - -; IRQ configuration - Mov AL, 0B1h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; DMA configuration - Mov AL, 0B2h - Call ESSOut - Mov AL, 50h - Call ESSOut - -; Enable voice - Mov AL, 0D1h - Call ESSOut - -; Start transfer - Mov AH, 0B8h - Call ESSReadRegister - Mov AH, AL - Mov AL, 0B8h - Call ESSOut - Mov AL, AH - Or AL, 1 - Call ESSOut - -; Init UART - Mov DX, MIDIPort - Inc DX - Mov AL, 3Fh ; Intelligent mode. - Out DX, AL - -; Enable MIDI IRQ - Mov DX, BasePort - Add DL, 4 - Mov AX, 4064h - Out DX, AX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartESS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - And AX, 0FF0h - ShR AH, 1 - ShR AL, 5 - Mov Word Ptr [VolumeTable], AX - - Call GetESSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetDSP - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call ResetDSP - Call StartESS - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset ESSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 22h - Out DX, AL - Mov AH, [VolumeTable] - ShL AH, 4 - Or AH, [VolumeTable+1] - ShL AH, 1 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ESS Technology's ES1868 AudioDrive chip. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 68187316h + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +ESSMsg DB "ESS ES1868 AudioDrive found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "ESS ES1868 AudioDrive found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "ESS ES1868 AudioDrive reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITES1868.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITES1868.DRV", 0 + +DriverName DB "ITES1868.DRV", 0 + +ALIGN 4 +FilterValue DD 0 +FilterValue2 DD 0 +ESSMixConst DB 0, 0 + +DMASize DW 2048 ; Smaller gives better MIDI timing +ConfigPort DW 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldESSIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +ESSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr ESSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + +Comment ~ + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + +~ + + DW 0 + +ESSHeaderLine DW 10 + DB "ESS ES1868 AudioDrive Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 26, 48 + DB 21h + DB "ESS ES1868 AudioDrive Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +Comment ~ + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 15 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 15 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +~ + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 44100 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 29 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 31, 29, 33, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 34, 29, 36, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 37, 29, 39, 8 + DB 0 + DB " 75% Filter", 0 + +ALIGN 4 + +VolumeTable DB 2 Dup (0) +MIDIPort DW 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSOut ; AL = data + ; DX = 2xCh + + Push AX + +ESSOut1: + In AL, DX + Test AL, AL + JS ESSOut1 + + Pop AX + Out DX, AL + + Ret + +EndP ESSOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIn ; DX = 2xCh, returns AL + +ESSIn1: + In AL, DX + Test AL, 40h + JZ ESSIn1 + + Add DL, 0Ah-0Ch ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Ch-0Ah + + Ret + +EndP ESSIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut ; AL = out + + Push DX + Push AX + + Mov DX, CS:MIDIPort + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + JNZ UARTOut1 + + Pop AX + Dec DX + Out DX, AL + + Pop DX + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTIn ; returns AL + + Push DX + + Mov DX, CS:MIDIPort + Inc DX + +UARTIn1: + In AL, DX + Test AL, 80h + JNZ UARTIn1 + + Dec DX + In AL, DX + + Pop DX + Ret + +EndP UARTIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSReadRegister ; AH = register to read. + ; DX = 2xCh + ; returns AL + + Mov AL, 0C0h + Call ESSOut + Mov AL, AH + Call ESSOut + Call ESSIn + + Ret + +EndP ESSReadRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Mov ConfigPort, AX + + Mov AX, 107h ; Audio device + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + Mov MIDIPort, AX + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, CS:MIDIPort + Inc DX + Mov AL, 0FFh + Out DX, AL + + Mov DX, CS:BasePort + Add DL, 6 + Mov AL, 3 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Call UARTIn + Mov BL, [MIDIBufferTail] + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [ConfigPort] + Add DL, 6 + In AL, DX + Test AL, 8 + JZ ESSNoMIDI + + Push AX + Call CheckMIDI + Pop AX + +ESSNoMIDI: + Test AL, 1 + JZ ESSIRQEnd + + Mov DX, [BasePort] + Add DL, 0Eh + In AL, DX + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB ESSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +ESSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB ESSIRQHandler6 + JE ESSIRQHFilter + + Cmp CS:Stereo, 0 + JE ESSIRQ3QFilterMono + +ESSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +ESSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +ESSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +ESSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilter: + Cmp CS:Stereo, 0 + JE ESSIRQHFilterMono + +ESSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +ESSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +ESSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +ESSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL ESSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG ESSIRQHandlerClip2 + +ESSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ ESSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + +ESSIRQEnd: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Pop ES + Pop DS + PopAD + IRet + +ESSIRQHandlerClip1: + Mov AX, 8000h + Jmp ESSIRQHandler7 + +ESSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp ESSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo3 + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetESSMixConst + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetESSMixConst1 + + Mov CX, 22050 + Cmp AX, CX + JB GetESSMixConst1 + + Mov CX, 56821 + Cmp AX, CX + JA GetESSMixConst1 + + Mov CX, AX + +GetESSMixConst1: ; CX = mixspeed. + Mov DX, 0Ch + Mov AX, 236Ch ; DX:AX = 795.5kHz + Div CX + + Mov BX, AX + Neg AL + Mov ESSMixConst, AL + + Mov DX, 0Ch + Mov AX, 236Ch + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetESSMixConst + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartESS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Call ResetDSP + Mov DX, BasePort + Add DL, 0Ch + +; Extended Functions + + Mov AL, 0C6h + Call ESSOut + +; Autoinit DMA + + Mov AL, 0B8h + Call ESSOut + Mov AL, 4 + Call ESSOut + +; Stereo/Mono select + + Mov AH, 0A8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0A8h + Call ESSOut + Mov AL, AH + And AL, Not 3 + Or AL, 2 + Cmp Stereo, 0 + JE StartESS1 + + Xor AL, 3 + +StartESS1: + Call ESSOut + +; DMA mode + + Mov AL, 0B9h + Call ESSOut + Mov AL, 2 + Call ESSOut + +; Mixspeed + + Mov AL, 0A1h + Call ESSOut + Mov AL, ESSMixConst + Call ESSOut + +; Filter clock divider + Mov AL, 0A2h + Call ESSOut + + Mov AL, 0FEh + Call ESSOut + +; DMA counter + Mov CX, DMASize + Neg CX + + Mov AL, 0A4h + Call ESSOut + Mov AL, CL + Call ESSOut + Mov AL, 0A5h + Call ESSOut + Mov AL, CH + Call ESSOut + +; Initialise DAC + Mov AL, 0B6h + Call ESSOut + Mov AL, 0 + Call ESSOut + +; Configure DACs + + Mov AL, 0B7h + Call ESSOut + Mov AL, 71h + Call ESSOut + + Mov AL, 0B7h + Call ESSOut + + Mov AL, 0BCh + Cmp Stereo, 0 + JNE StartESS2 + + Mov AL, 0F4h + +StartESS2: + Call ESSOut + +; IRQ configuration + Mov AL, 0B1h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; DMA configuration + Mov AL, 0B2h + Call ESSOut + Mov AL, 50h + Call ESSOut + +; Enable voice + Mov AL, 0D1h + Call ESSOut + +; Start transfer + Mov AH, 0B8h + Call ESSReadRegister + Mov AH, AL + Mov AL, 0B8h + Call ESSOut + Mov AL, AH + Or AL, 1 + Call ESSOut + +; Init UART + Mov DX, MIDIPort + Inc DX + Mov AL, 3Fh ; Intelligent mode. + Out DX, AL + +; Enable MIDI IRQ + Mov DX, BasePort + Add DL, 4 + Mov AX, 4064h + Out DX, AX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartESS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + And AX, 0FF0h + ShR AH, 1 + ShR AL, 5 + Mov Word Ptr [VolumeTable], AX + + Call GetESSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetDSP + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call ResetDSP + Call StartESS + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset ESSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 22h + Out DX, AL + Mov AH, [VolumeTable] + ShL AH, 4 + Or AH, [VolumeTable+1] + ShL AH, 1 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/GUS.INC b/SoundDrivers/GUS.INC index 4770d30..38009b0 100755 --- a/SoundDrivers/GUS.INC +++ b/SoundDrivers/GUS.INC @@ -1,2316 +1,2316 @@ - - .386P - Jumps - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -;************************** - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;************** Local variables **************** - -SLAVECHANNELSIZE EQU 128 - -GUSReinitMsg DB "Gravis UltraSound reinitialised", 0 - -GUSID DB "Gravis UltraSound detected", 13 - DB "Port ", 0FDh, "Xh, ", 0FDh, "Dk Memory", 0 - -GUSID2 DB "Gravis UltraSound detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 - -GUSFreeMsg DB "FreeGUS ", 0FDh, "Dk", 0 - -IFDEF RIC - -GUSFreeMsg2 DB "FreeGUS ", 0FDh, "Dk", 13, 13 - DB "GUSInit ", 0FDh, "D", 0 - - IFDEF RAMP - DriverName DB "ITGUS.DRV", 0 - ELSE - DriverName DB "ITGUS2.DRV", 0 - ENDIF - -ENDIF - -ULTRASndString DB "ULTRASND" - -GUSMixTable Label Word - - DW 44100, 41160, 38588, 36318, 34300, 32495, 30870, 29400, 28064 - DW 26844, 25725, 24696, 23746, 22867, 22050, 21290, 20580, 19916 - DW 19294 - -GUSVolumeTable Label Word - DW 04000h, 07FF0h, 08FF0h, 09800h, 09FF0h, 0A400h, 0A800h, 0AC00h - DW 0AFF0h, 0B200h, 0B400h, 0B600h, 0B800h, 0BA00h, 0BC00h, 0BE00h - DW 0BFF0h, 0C100h, 0C200h, 0C300h, 0C400h, 0C500h, 0C600h, 0C700h - DW 0C800h, 0C900h, 0CA00h, 0CB00h, 0CC00h, 0CD00h, 0CE00h, 0CF00h - - DW 0CFF0h, 0D080h, 0D100h, 0D180h, 0D200h, 0D280h, 0D300h, 0D380h - DW 0D400h, 0D480h, 0D500h, 0D580h, 0D600h, 0D680h, 0D700h, 0D780h - DW 0D800h, 0D880h, 0D900h, 0D980h, 0DA00h, 0DA80h, 0DB00h, 0DB80h - DW 0DC00h, 0DC80h, 0DD00h, 0DD80h, 0DE00h, 0DE80h, 0DF00h, 0DF80h - - DW 0DFF0h, 0E040h, 0E080h, 0E0C0h, 0E100h, 0E140h, 0E180h, 0E1C0h - DW 0E200h, 0E240h, 0E280h, 0E2C0h, 0E300h, 0E340h, 0E380h, 0E3C0h - DW 0E400h, 0E440h, 0E480h, 0E4C0h, 0E500h, 0E540h, 0E580h, 0E5C0h - DW 0E600h, 0E640h, 0E680h, 0E6C0h, 0E700h, 0E740h, 0E780h, 0E7C0h - - DW 0E800h, 0E840h, 0E880h, 0E8C0h, 0E900h, 0E940h, 0E980h, 0E9C0h - DW 0EA00h, 0EA40h, 0EA80h, 0EAC0h, 0EB00h, 0EB40h, 0EB80h, 0EBC0h - DW 0EC00h, 0EC40h, 0EC80h, 0ECC0h, 0ED00h, 0ED40h, 0ED80h, 0EDC0h - DW 0EE00h, 0EE40h, 0EE80h, 0EEC0h, 0EF00h, 0EF40h, 0EF80h, 0EFC0h - - DW 0EFF0h - -ALIGN 4 - -GUSDataTable DD 100 Dup (0FFFFFFFFh) -GUSMemory DW 0 ; kb of memory on GUS -GUSRegisterSelect DW 0 -GUSVoiceSelect DW 0 -GUSUpdateTimer DW 0 -GUSUpdateCount DW 0 -GUSMemoryFree DD 0 -MixSpeed DW 0 -OldIRQHandler DD 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 8 - -Convert16To8Bit DB 0 - DB 0 -Compress DB 0 - DB 0 - -IFDEF RIC - ShowReinit DB 0 - DB 0 - UsedChannels DW ? -ENDIF - -Stereo DB 0 -GUSUpdateFlag DB 0 - -MIDIIRQ DW 0FFFFh -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 -MIDIOldIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -IMR DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -GUSScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr GravisHeaderLine - - DW SampleText ; 4 - - DW ConvertSampleText - DW ConvertDisabledButton ; 6 - DW ConvertEnabledButton - - DW SampleSizeText ; 8 - DW SampleSize0Button ; 9 - DW SampleSize1Button - DW SampleSize2Button - - -IFDEF RIC - DW ReinitText ; 12 - DW ReinitButton0 - DW ReinitButton1 - DW ReinitButton2 - -ENDIF - - DW DriverText - - DW 0 - -GravisHeaderLine DW 10 - DB "Gravis UltraSound Driver", 0 - -DriverText DW 1 - DB 30, 48 - DB 21h - DB "Gravis UltraSound Driver 1.3 for Impulse Tracker", 0 - -SampleText DW 1 - DB 3, 13 - DB 20h - DB "Sample resizing options", 0 - -ConvertSampleText DW 1 - DB 5, 15 - DB 20h - DB "Reduce 16 bit samples to 8 bit", 0 - -ConvertDisabledButton DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetConvert -DriverSegment1 DW 0 - DW 0 - DW Offset SetConvert -DriverSegment2 DW 0 - DB 7, 17, 20, 19, 8 - DB 0 - DB " Disabled", 0 - -ConvertEnabledButton DW 2 - DW 6, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetConvert -DriverSegment3 DW 0 - DW 1 - DW Offset SetConvert -DriverSegment4 DW 0 - DB 7, 20, 20, 22, 8 - DB 0 - DB " Enabled", 0 - -SampleSizeText DW 1 - DB 5, 24 - DB 20h - DB "Sample size", 0 - -SampleSize0Button DW 2 - DW 7, 10, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment5 DW 0 - DW 0 - DW Offset SetCompress -DriverSegment6 DW 0 - DB 7, 26, 20, 28, 8 - DB 0 - DB " Original", 0 - -SampleSize1Button DW 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment7 DW 0 - DW 1 - DW Offset SetCompress -DriverSegment8 DW 0 - DB 7, 29, 20, 31, 8 - DB 0 - DB " Half", 0 - -IFDEF RIC - - SampleSize2Button DW 2 - DW 10, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress - DriverSegment9 DW 0 - DW 2 - DW Offset SetCompress - DriverSegment10 DW 0 - DB 7, 32, 20, 34, 8 - DB 0 - DB " Quarter", 0 - - ReinitText DW 1 - DB 3, 36 - DB 20h - DB "Show channel reinitialisation", 0 - - ReinitButton0 DW 2 - DW 11, 14, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetReinit - DriverSegment11 DW 0 - DW 0 - DW Offset SetReinit - DriverSegment12 DW 0 - DB 7, 38, 21, 40, 8 - DB 0 - DB " Disabled", 0 - - ReinitButton1 DW 2 - DW 13, 15, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetReinit - DriverSegment13 DW 0 - DW 1 - DW Offset SetReinit - DriverSegment14 DW 0 - DB 7, 41, 21, 43, 8 - DB 0 - DB " Channels", 0 - - ReinitButton2 DW 2 - DW 14, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetReinit - DriverSegment15 DW 0 - DW 2 - DW Offset SetReinit - DriverSegment16 DW 0 - DB 7, 44, 21, 46, 8 - DB 0 - DB " Frequency", 0 - -ELSE - - SampleSize2Button DW 2 - DW 10, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress - DriverSegment9 DW 0 - DW 2 - DW Offset SetCompress - DriverSegment10 DW 0 - DB 7, 32, 20, 34, 8 - DB 0 - DB " Quarter", 0 - - -ENDIF - - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -RelocationTable Label - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - -IFDEF RIC - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW Offset DriverSegment15, Offset DriverSegment16 -ENDIF - DW 0FFFFh - -;*********** Local functions ******************* -; -; GUSDelay - produces delay between GUS commands -; TestGUS - Checks for the presence of a GUS by detecting amount of memory. -; LoadGUSSample - Loads a byte to GUS, EDI = position in memory, AL = value -; LoadGUSSamples - Loads ECX bytes from DS:SI to EDI -; -;*********************************************** - -Proc GUSDelay - - Push AX - Push DX - - Mov DX, 300h - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Pop DX - Pop AX - - Ret - -EndP GUSDelay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetGUS ; AX = baseport. - - Push AX - Push DX - - Mov DX, AX - Add DX, 103h ; Select register - - Mov AL, 4Ch ; Reset global register - Out DX, AL - - Add DL, 2 ; 8 bit data - Xor AL, AL - Out DX, AL ; Reset GUS! - - Call GUSDelay - Call GUSDelay - - Mov AL, 1 - Out DX, AL - - Call GUSDelay - Call GUSDelay - - Pop DX - Pop AX - - Ret - -EndP ResetGUS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TestGUS - - Push AX - - Call ResetGUS - - Mov GUSMemory, 0 - - Mov DX, AX - Add DX, 103h ; DX = Select Register - - Mov CX, 4 ; Max amount is 1MB of memory - Xor BL, BL ; Start with first 256k pool - -TestGUS1: - Mov AL, 44h ; GUS DRAM High, 8 bit - Out DX, AL - - Add DL, 2 - Mov AL, BL - Out DX, AL - - Sub DL, 2 ; DX = Select Register - - Mov AL, 43h ; GUS DRAM Low, 16 bit - Out DX, AL - - Inc DX ; DX = Baseport+104h - Xor AX, AX - Out DX, AX ; Address 0 - - Add DL, 3 ; DX = Baseport+107h (DRAM I/O) - Mov AL, 55h - Out DX, AL ; Write value 055h - - Sub DL, 3 ; DX = Baseport+104h - Mov AX, 1 - Out DX, AX ; Address 1 - - Add DL, 3 ; DX = Baseport+107h - Mov AL, 0AAh - Out DX, AL ; Write value 0AAh - - Sub DL, 3 ; DX = Baseport+104h - Mov AX, 2 - Out DX, AX ; Address 2 - - Add DL, 3 ; DX = Baseport+107h - Mov AL, 0 - Out DX, AL ; Write value - - Sub DL, 3 ; DX = Baseport+104h - Xor AX, AX - Out DX, AX ; Address 0 - - Add DL, 3 ; DX = Baseport+107h - In AL, DX ; Read value.. should be 055h - Cmp AL, 55h - JNE TestGUS2 - - Sub DL, 3 ; DX = Baseport+104h - Mov AX, 1 - Out DX, AX ; Address 1 - - Add DL, 3 ; DX = Baseport+107h - In AL, DX ; Read value.. should be 0AAh - Cmp AL, 0AAh - JNE TestGUS2 - - Sub DL, 3 ; DX = Baseport+104h - Mov AX, 2 - Out DX, AX ; Address 2 - - Add DL, 3 ; DX = Baseport+107h - In AL, DX ; Read value.. - Cmp AL, 0 - JNE TestGUS2 - - Sub DL, 4 ; DX = Baseport+103h - - Add GUSMemory, 256 ; Another 256k! - - Add BL, 4 ; Next memory chunk - Loop TestGUS1 - - -TestGUS2: - Pop AX - - Cmp GUSMemory, 0 - JNE TestGUS3 - - StC - Ret - -TestGUS3: - ClC - Ret - -EndP TestGUS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadGUSSample ; EDI = position, AL = value - - Push EAX - - Mov DX, CS:GUSRegisterSelect - Mov AL, 44h - Out DX, AL - - Add DL, 2 - Mov EAX, EDI - ShR EAX, 16 - Out DX, AL - Sub DL, 2 ; Select register again. - - Mov AL, 43h ; Address Low, 16 bit - Out DX, AL - Inc DX ; DX = 3x4h - - Mov AX, DI ; Memory location high - Out DX, AX ; Memory location done. - - Add DL, 3 - - Pop EAX - - Out DX, AL - Sub DL, 3 - - Inc EDI - - Ret - -EndP LoadGUSSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadGUSSamples ; Given DS:SI, EDI = pos, ECX = count - ; EBP = step value. - -LoadGUSSamples1: - Mov DX, CS:GUSRegisterSelect - Mov AL, 44h - Out DX, AL - - Add DL, 2 - Mov EAX, EDI - ShR EAX, 16 - Out DX, AL - Sub DL, 2 ; Select register again. - - Mov AL, 43h ; Address Low, 16 bit - Out DX, AL - Inc DX ; DX = 3x4h - -LoadGUSSamples2: - Mov AX, DI ; Memory location high - Out DX, AX ; Memory location done. - - Add DL, 3 - - Mov AL, [SI] - Add SI, BP - JC LoadGUSSamples4 - -LoadGUSSamples3: - Out DX, AL - Sub DL, 3 - - Inc DI - JZ LoadGUSSamples5 - - Dec ECX - JNZ LoadGUSSamples2 - Ret - -LoadGUSSamples4: - Add ESI, 10000h - Call UpdateSampleLocation - Jmp LoadGUSSamples3 - -LoadGUSSamples5: - Add EDI, 10000h - LoopD LoadGUSSamples1 - Ret - -EndP LoadGUSSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load16GUSSamples ; Given DS:SI, EDI = pos, ECX = count - ; EBP = step value. - - Add BP, BP - Dec BP - Mov BX, 1 - Xor BP, BX - Xor BX, BP - -Load16GUSSamples1: - Mov DX, CS:GUSRegisterSelect - Mov AL, 44h - Out DX, AL - - Add DL, 2 - Mov EAX, EDI - ShR EAX, 16 - Out DX, AL - Sub DL, 2 ; Select register again. - - Mov AL, 43h ; Address Low, 16 bit - Out DX, AL - Inc DX ; DX = 3x4h - -Load16GUSSamples2: - Mov AX, DI ; Memory location high - Out DX, AX ; Memory location done. - - Add DL, 3 - - Xor BX, BP - Mov AL, [SI] - Add SI, BX - JC Load16GUSSamples4 - -Load16GUSSamples3: - Out DX, AL - Sub DL, 3 - - Inc DI - JZ Load16GUSSamples5 - - LoopD Load16GUSSamples2 - Ret - -Load16GUSSamples4: - Add ESI, 10000h - Call UpdateSampleLocation - Jmp Load16GUSSamples3 - -Load16GUSSamples5: - Add EDI, 10000h - LoopD Load16GUSSamples1 - Ret - -EndP Load16GUSSamples - -;*********** Public functions ****************** - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectGUS Far - - Push CS - Pop DS - Assume DS:Driver - - Cmp BasePort, 0FFFFh - JE DetectGUS1 - - Mov AX, BasePort - - Cmp AX, 210h - JB DetectCardError - Cmp AX, 280h - JA DetectCardError - - Call TestGUS - JNC DetectGUS3 - Jmp DetectCardError - -DetectGUS1: - Mov AX, 210h - -DetectGUS2: - Call TestGUS - JNC DetectGUS3 - - Add AL, 10h - Cmp AL, 60h - JBE DetectGUS2 - -DetectCardError: - StC - Ret - -DetectGUS3: - Mov BasePort, AX - Add AX, 102h - Mov GUSVoiceSelect, AX - Inc AX - Mov GUSRegisterSelect, AX - -Comment ~ - - ; If Windows *AND* IRQ = 0FFFFh, then grab from ULTRASND variable - - Mov SI, Offset ULTRASNDString - Mov CX, 8 - Call GetEnvironment ; Returns ES:DI, Carry if error - JC DetectCardOK - - Mov CX, 3 ; Find 3 commas first. - ; Eg. skip baseport + 2 DMAs - -DetectCard1: - Mov AL, [ES:DI] - Inc DI - - Cmp AL, ',' - JNE DetectCard1 - Loop DetectCard1 - - ; GUS IRQ.. - Xor DX, DX - -DetectCardIRQ1_1: - Mov AL, [ES:DI] - Inc DI - Cmp AL, ',' - JE DetectCardIRQ1_2 - - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCardIRQ1_1 - -DetectCardIRQ1_2: ; DX = IRQ to use. - Cmp DX, 15 - JA DetectCardError - - Mov AX, 1600h - Int 2Fh ; Windows Detect. - - Test AL, 7Fh - JZ DetectCardIRQ2_1 - - Mov AX, IRQ - Cmp AX, -1 - JNE DetectCardIRQ2_2 - Mov IRQ, DX - Mov MIDIIRQ, DX - Jmp DetectCardOK - -DetectCardIRQ2_2: - Mov DX, AX - -DetectCardIRQ2_1: ; No Windows. - Mov MIDIIRQ, DX - -DetectCardOK: - -~ - - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectGUS - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GUSIRQHandler ; IRQ Handler has to - ; 1) Update GUS registers - ; 2) Update song position - Push AX - Push DS - - Mov AX, GUSUpdateTimer - Add GUSUpdateCount, AX - JC GUSIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp GUSIRQHandler2 - -GUSIRQHandler1: - PushF - Call [OldIRQHandler] - -GUSIRQHandler2: - Xor GUSUpdateFlag, 1 - JZ GUSIRQHandlerEnd - - PushAD - Push ES - - ClD - - Call SaveEMSPageFrame - Call Update ; Returns DS:SI, CX - Call SetGUSRegisters - Call RestoreEMSPageFrame - - Pop ES - PopAD - -GUSIRQHandlerEnd: - Pop DS - Pop AX - IRet - -EndP GUSIRQHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Comment ~ - -Proc CheckMIDI - - Push AX BX DX DS - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - Inc DH - -CheckMIDIAgain: - In AL, DX - Test AL, 1 - JZ CheckMIDI1 - - Inc DX - In AL, DX - Dec DX - - Cmp AL, 0F0h -; JAE CheckMIDIAgain - JAE CheckMIDI1 - - Mov BL, [MIDIBufferTail] - Inc BL - Cmp BL, [MIDIBufferHead] - JE CheckMIDI1 -; JE CheckMIDIAgain - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL -; Jmp CheckMIDIAgain - -CheckMIDI1: - Pop DS DX BX AX - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GUSMIDIIRQHandler - - Push AX BX DX DS - - Push CS - Pop DS - Assume DS:Driver - - Call CheckMIDI - - Mov AL, 20h - - Cmp MIDIIRQ, 8 - JB GUSMIDIIRQHandler1 - - Out 0A0h, AL - -GUSMIDIIRQHandler1: - Out 20h, AL - - Pop DS DX BX AX - IRet - -EndP GUSMIDIIRQHandler - Assume DS:Nothing - -~ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GUSIRQOnlyHandler - - PushAD - Push DS - Push ES - - Mov AL, 20h - - Cmp CS:IRQ, 8 - JB GUSIRQOnlyHandler1 - - Out 0A0h, AL - -GUSIRQOnlyHandler1: - Out 20h, AL - -GUSIRQAgain: - Mov DX, CS:BasePort - Add DL, 6 - In AL, DX - -; Test AL, 2 ; MIDI receive? -; JZ GUSIRQOnlyHandlerNoMIDI -; -; Call CheckMIDI -; -; Jmp GUSIRQAgain - -GUSIRQOnlyHandlerNoMIDI: - Test AL, 8 - JZ GUSIRQOnlyHandler3 - - Mov DX, CS:GUSRegisterSelect - Mov AL, 45h - Out DX, AL - Mov AL, 0 - Add DL, 2 - Out DX, AL - Mov AL, 8 - Out DX, AL - Sub DL, 2 - - CLD - - Call SaveEMSPageFrame - Call Update - Call SetGUSRegisters - Call RestoreEMSPageFrame - Jmp GUSIRQAgain - -GUSIRQOnlyHandler3: - Test AL, 60h - JZ GUSIRQOnlyHandler2 - - Mov DX, CS:GUSVoiceSelect - In AL, DX - Push AX - -GUSIRQOnlyHandler4: - Mov DX, CS:GUSRegisterSelect - Mov AL, 8Fh - Out DX, AL - Add DL, 2 - In AL, DX ; Bit 6 = waveramp IRQ - ; Bit 7 = wavetable IRQ... - ; Bit 0-5 = voice - - Test AL, 080h - JZ GUSIRQOnlyHandler5 - Test AL, 040h - JZ GUSIRQOnlyHandler6 - - Pop AX - Mov DX, CS:GUSVoiceSelect - Out DX, AL - -; Jmp GUSIRQAgain - Jmp GUSIRQOnlyHandler2 - -GUSIRQOnlyHandler5: ; Wavetable IRQ - Push AX - Mov DX, CS:GUSVoiceSelect - And AL, 31 - Out DX, AL - Call GUSDelay - - Inc DX - - Xor AL, AL - Out DX, AL ; AL = 0 (Mode control) - Mov AL, 2 - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - - Pop AX - Test AL, 40h - JNZ GUSIRQOnlyHandler4 - -GUSIRQOnlyHandler6: ; Volume IRQ - Mov DX, CS:GUSVoiceSelect - And AL, 31 - Out DX, AL - Call GUSDelay - - Inc DX - Mov AL, 0Dh ; Volume Ramp. - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 6 ; Ramp rate - Out DX, AL - - Mov AL, 63 ; Ramp rate - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Jmp GUSIRQOnlyHandler4 - - -GUSIRQOnlyHandler2: - Pop ES - Pop DS - PopAD - - IRet - -EndP GUSIRQOnlyHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IFDEF RAMP - include gusramp.inc -ELSE - include gusnramp.inc -ENDIF - -IFDEF RIC - include gusric.inc -ELSE - include gusnric.inc -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GUSGetAddress ; Given EAX - Assume DS:Nothing - - Push CX - - Mov CL, CS:Compress - ShR EAX, CL - - Pop CX - Add EAX, [CS:GUSDataTable+BX] - ShL EAX, 9 - - Ret - -EndP GUSGetAddress - -;ÄÄ InitMIDIIRQ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Comment ~ - -Proc InitMIDIIRQ - - Ret - - - PushA - Push DS - Push ES - - Mov AX, CS - Mov DS, AX - ShL EAX, 16 - Mov ES, AX - Assume DS:Driver - - Mov BX, MIDIIRQ - Cmp BX, 15 - JA InitMIDIIRQ1 - - ShL BX, 2 - Mov SI, [IRQData+BX] - - Mov AX, Offset GUSMIDIIRQHandler - XChg [ES:SI], EAX - - Mov MIDIOldIRQHandler, EAX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - - And AX, [IRQData+BX+2] ; Update mask - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov DX, BasePort - Inc DH - Mov AL, 0FFh - Out DX, AL - Mov AL, 0FCh - Out DX, AL - Jmp InitMIDIIRQEnd - -InitMIDIIRQ1: - Mov DX, BasePort - Inc DH - Mov AL, 0FFh - Out DX, AL - Mov AL, 0h - Out DX, AL - -InitMIDIIRQEnd: - Pop ES - Pop DS - PopA - - Ret - -EndP InitMIDIIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitMIDIIRQ - - Ret - - PushA - Push DS - Push ES - - Mov BX, MIDIIRQ - Cmp BX, 15 - JA UnInitMIDIIRQ1 - - ShL BX, 2 - Mov BX, [IRQData+BX] - Xor AX, AX - Mov ES, AX - - Mov EAX, MIDIOldIRQHandler - Mov [ES:BX], EAX - -UnInitMIDIIRQ1: - Mov DX, Baseport - Inc DH - Mov AL, 0FFh - Out DX, AL - - Pop ES - Pop DS - PopA - - Ret - -EndP UnInitMIDIIRQ - Assume DS:Nothing - -~ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov SI, Offset RelocationTable - -RelocationSetup: - Mov BX, [SI] - Cmp BX, 0FFFFh - JE RelocationSetupFinished - - Mov [BX], CS - - Add SI, 2 - Jmp RelocationSetup - -RelocationSetupFinished: - ; OK... disable the GUS Line In - ; & Enable Line Out - Mov BX, AX - - Mov DX, BasePort - Mov AL, 1 - Out DX, AL - - Call ResetGUS - - Cmp BL, 14 - JAE InitSound_GUS4 - - Mov BL, 14 - -InitSound_GUS4: - -IFDEF RIC - Mov UsedChannels, BX -ENDIF - - Mov DX, GUSRegisterSelect ; Tell the GUS how many voices - Mov AL, 0Eh ; to use - Out DX, AL - - Add DL, 2 ; DX = BasePort + 105h - Mov AL, BL - Dec AL - Or AL, 0C0h - Out DX, AL ; Number of Voices set - - ; Reset each voice - Mov CX, 32 ; 32 voices to clear. - - Sub BX, 14 ; Now get mixspeed - Add BX, BX - Mov AX, [GUSMixTable+BX] - Mov MixSpeed, AX - - Sub DL, 3 ; DX = Voice select register - -GUSResetVoice: - Mov AL, CL - Dec AL - Out DX, AL - - Inc DX ; DX = BasePort + 103h - Xor AL, AL ; Voice control register, 8 bit - Out DX, AL - - - Add DL, 2 - Mov AL, 2 - Out DX, AL ; Stop voice - Sub DL, 2 - - Mov AL, 0Dh ; Volume Ramp. - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Mov AL, 6 ; Ramp rate - Out DX, AL - - Mov AL, 63 ; Ramp rate - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 9 ; Volume register, 16 bit - Out DX, AL - - Inc DX - Xor AX, AX - Out DX, AX ; No volume - Call GUSDelay - Out DX, AX - - ClI - Sub DL, 2 ; DX = BasePort + 102h = Voice select. - - Loop GUSResetVoice - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - -; Call InitMIDIIRQ - - Cmp IRQ, 0FFFFh - JE InitSound_GUS1 - - Mov AX, BasePort - Call ResetGUS - - ; Set IRQ - Mov BX, IRQ - ShL BX, 2 ; BX points to offset in IRQData - - Xor DI, DI - Mov ES, DI - Mov DI, [BX+IRQData] - - In AL, 0A1h - Mov AH, AL - In AL, 21h - - And AX, [BX+IRQData+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset GUSIRQOnlyHandler - - XChg [ES:DI], EAX - Mov OldIRQHandler, EAX - - StI - - Mov DX, BasePort - Mov AL, 9 ; + 16 - Out DX, AL - - Mov DX, GUSRegisterSelect - Mov AL, 4Ch - Out DX, AL - Add DL, 2 - Mov AL, 7 - Out DX, AL - - Call GetTempo - Call SetTempo - Call ResetMemory - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, GUSMemory - - Mov SI, Offset GUSID2 - - ClC - Ret - -InitSound_GUS1: - Inc DL - Mov AL, 4Ch - Out DX, AL - Add DL, 2 - Mov AL, 3 ; 7 - Out DX, AL - - Mov DX, BasePort - Mov AL, 9 ; + 16 - Out DX, AL - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Call GetTempo - Call SetTempo - Call ResetMemory - - Xor AX, AX - Mov ES, AX ; ES = 0 - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset GUSIRQHandler - - ClI - - XChg DWord Ptr [ES:20h], EAX ; Clock tick - Mov OldIRQHandler, EAX - - StI - - Mov AX, BasePort - Mov BX, GUSMemory - Mov SI, Offset GUSID - - ClC - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push AX - - Push CS - Pop DS - Mov SI, Offset GUSReinitMsg - Mov BX, 40 - Call SetInfoLine - - Call UnInitSound - - Pop AX - Jmp InitSound - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Push CS - Pop DS - Assume DS:Driver - -IFDEF RIC - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset Convert16To8Bit - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h -SaveConfig2: - -ENDIF - Mov AX, BasePort - Call ResetGUS - - ClI - - Mov BX, CS:IRQ - Cmp BX, 0FFFFh - JE UnInitSound1 - - Mov AX, CS:IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - ShL BX, 2 - Xor DI, DI - Mov ES, DI - Mov DI, [CS:BX+IRQData] - Mov EAX, CS:OldIRQHandler - - Mov [ES:DI], EAX - -; Call UnInitMIDIIRQ - - StI - Ret - -UnInitSound1: - Mov AL, 34h - Out 43h, AL - - Xor AX, AX - Out 40h, AL - Out 40h, AL - - Mov ES, AX - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - -; Call UnInitMIDIIRQ - - StI - - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - Ret - -EndP Poll - Assume DS:Nothing - -Proc UARTOut Far - - Push DX - Push AX - - Mov DX, [CS:BasePort] - Inc DH - -UARTOut1: - In AL, DX - Test AL, 2 - JZ UARTOut1 - - Pop AX - Inc DX - - Out DX, AL - - Pop DX - - Ret - -EndP UARTOut - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far ; BX = tempo... - - Push AX - Push BX - Push DX - - Cmp CS:IRQ, 0FFFFh - JE SetTempo1 - - ShL BX, 8 - Mov DX, 1Eh - Mov AX, 8480h - Div BX - Neg AL - - Mov AH, AL - - Mov DX, CS:GUSRegisterSelect - - Mov AL, 47h - Out DX, AL - Add DL, 2 - Mov AL, AH - Out DX, AL ; Set Timer control register 2 - Sub DL, 2 - - Mov AL, 45h - Out DX, AL - Add DL, 2 - Mov AL, 8 - Out DX, AL -; Sub DL, 2 - - Mov DX, CS:BasePort - Add DL, 8 - Mov AL, 4 - Out DX, AL - - Inc DL - Mov AL, 2 - Out DX, AL - - Jmp SetTempo2 - -SetTempo1: - ; Frames per second = 2 * (0.4*Tempo) - Mov AX, 0C214h - Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo - Div BX - - ; AX contains counter. - Mov GUSUpdateTimer, AX - - Out 40h, AL ; Timer IRQ. - Mov AL, AH - Out 40h, AL - -SetTempo2: - Pop DX - Pop BX - Pop AX - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - PushAD - Push DS - Push ES - Push FS - - Mov FS, CS:SongDataArea - Mov BP, AX - Dec BP - Add BP, BP - Mov BP, [FS:64912+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC Music_GUSLoadSampleEnd - - Mov BL, [FS:BP+12h] - Test BL, 16 - JZ Music_GUSLoadSample12 - - Cmp ECX, [FS:BP+38h] - JBE Music_GUSLoadSample12 - - Mov ECX, [FS:BP+38h] - Test BL, 32 - JZ Music_GUSLoadSample12 - - Cmp ECX, [FS:BP+44h] - JAE Music_GUSLoadSample12 - - Mov ECX, [FS:BP+44h] - -Music_GUSLoadSample12: - Mov EBX, ECX - Mov CL, CS:Compress - Mov EDX, 1 - ShR EBX, CL - ShL EDX, CL ; EDX = step value. - - Mov ECX, EBX - - ; Now find location to put it in - - Dec AX ; AX = sample number - Push AX ; AX = sample number (0 based) - - And EAX, 0FFh - Mov DWord Ptr [CS:GUSDataTable+4*EAX], 0FFFFFFFFh - - Add ECX, 2 - Mov EAX, GUSMemoryFree - - Test Byte Ptr [FS:BP+12h], 2 ; 16 bit?? - JZ Music_GUSLoadSamples13 - - Cmp CS:Convert16To8Bit, 0 - JNZ Music_GUSLoadSamples5 - - Sub EAX, 1 - JC Music_GUSLoadSampleWarning - And EAX, Not 1 ; For alignment - Add ECX, ECX - - Mov EBX, EAX - - Sub EBX, 1 - JC Music_GUSLoadSampleWarning - And EBX, 3FFFFh ; Get bytes remaining in 'segment' - Inc EBX - - Cmp ECX, 256*1024 - JAE Music_GUSLoadSamples13 - - Cmp ECX, EBX - JBE Music_GUSLoadSample2 - - Sub EAX, EBX - Jmp Music_GUSLoadSamples13 - -Music_GUSLoadSamples5: - Inc ESI - Add EDX, EDX ; Step value. - -Music_GUSLoadSamples13: - Cmp ECX, EAX - JBE Music_GUSLoadSample2 - - ; Warning msg here. -Music_GUSLoadSampleWarning: - Pop AX - -Music_GUSLoadSampleEndNoError: - ClC - Jmp Music_GUSLoadSampleEnd - -Music_GUSLoadSample3: - StC - -Music_GUSLoadSampleEnd: - Pop FS - Pop ES - Pop DS - PopAD - - Ret - -Music_GUSLoadSample2: ; EAX = number of bytes free. - ; DS:SI = sample. - ; ECX = number of bytes of memory - ; ES:DI = num bytes free ptr - ; BP = sample number. - - ; Location = MaxMem - DX:AX - ; = -(DX:AX - GUSBanks*4:0) - MovZX EBX, CS:GUSMemory - ShL EBX, 10 - ; BX = bytes avail. - Sub EBX, EAX - Sub EAX, ECX - Mov GUSMemoryFree, EAX - - Pop DI ; DI = sample number - - ShL DI, 2 - - Cmp CS:Convert16To8Bit, 0 - JNZ LoadGUSForced8Bit - - Test Byte Ptr [FS:BP+12h], 2 - JNZ Music_GUSLoad16BitSample - -LoadGUSForced8Bit: - Push EBX - Inc EBX - Mov [CS:GUSDataTable+DI], EBX ; Store pointer - - Mov ES, CS:SongDataArea - Pop EDI ; EDI = location in GUS mem - - Sub ECX, 2 - ; EDI = location in GUS mem - ; DS:SI = sample data - ; ECX = length. - ; EDX = step value. - ClI - - Push BP - - Mov EBP, EDX - - Mov AL, [DS:SI+BP] - Call LoadGUSSample - Call LoadGUSSamples - - Mov BH, AL - - Pop BP - - Mov AL, [FS:BP+12h] - Test AL, 16 - JZ Music_GUSLoadSample10 - - Mov ESI, [FS:BP+34h] - Test AL, 64 - JZ Music_GUSLoadSample11 - - Mov ESI, [FS:BP+38h] - Sub ESI, 2 - AdC ESI, 0 - - Mov EAX, Not 0 - Mov CL, CS:Compress - ShL EAX, CL - And ESI, EAX - -Music_GUSLoadSample11: - Test Byte Ptr [FS:BP+12h], 2 - JZ Music_GUSLoadSample6 - - Add ESI, ESI - Inc SI - -Music_GUSLoadSample6: - Call UpdateSampleLocation - - Mov BH, [SI] - -Music_GUSLoadSample10: - Mov AL, BH - Call LoadGUSSample - - StI - Jmp Music_GUSLoadSample3 ; Return.. no error. - -Music_GUSLoad16BitSample: - Push EBX - - Add EBX, 2 - Mov EAX, EBX - And EBX, 3FFFFh - And EAX, Not 3FFFFh - ShR EBX, 1 - Or EAX, EBX - Mov [CS:GUSDataTable+DI], EAX - - Mov ES, CS:SongDataArea - Pop EDI ; EDI = location in GUS mem - - Sub ECX, 4 - ClI - - Push BP - - Mov EBP, EDX - - Mov AX, [DS:ESI+EBP*2] - Call LoadGUSSample - Mov AL, AH - Call LoadGUSSample - - Call Load16GUSSamples - - Pop BP - - Xor BX, BX - - Mov AL, [FS:BP+12h] - Test AL, 16 - JZ Music_GUSLoad16BitSample11B - - Mov ESI, [FS:BP+34h] - - Test AL, 64 - JZ Music_GUSLoad16BitSample11 - - Mov ESI, [FS:BP+38h] - Sub ESI, 2 - JNC Music_GUSLoad16BitSample11 - - Xor ESI, ESI - -Music_GUSLoad16BitSample11: - Mov EAX, Not 0 - Mov CL, CS:Compress - ShL EAX, CL - And ESI, EAX - - Add ESI, ESI - Call UpdateSampleLocation - - Mov BX, [SI] - -Music_GUSLoad16BitSample11B: - Mov AX, BX - Call LoadGUSSample - Mov AL, AH - Call LoadGUSSample - - StI - Jmp Music_GUSLoadSample3 ; Return.. no error. - - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release, 0 based -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - LEA DI, [EAX*4+Offset GUSDataTable] - ; Now to release the last - ; sample from GUS memory if - ; able to. - - Cmp DWord Ptr [CS:DI], 0FFFFFFFFh - JE ReleaseSample3 - -ReleaseSample4: - MovZX EAX, CS:GUSMemory - SHL EAX, 10 - - Mov EBP, [CS:DI] ; EBP = sample pointer. - - ; If (MaxMem-(sample location in bank + sample length + 2)) = memory remaining, - ; then release memory. - - Mov ECX, [SI+30h] - Mov DL, [SI+12h] - Test DL, 16 - JZ ReleaseSample7 - - Cmp ECX, [SI+38h] - JBE ReleaseSample7 - - Mov ECX, [SI+38h] - - Test DL, 32 - JZ ReleaseSample7 - - Cmp ECX, [SI+44h] - JAE ReleaseSample7 - - Mov ECX, [SI+44h] - -ReleaseSample7: - Push EBX - Mov EBX, ECX - Mov CL, CS:Compress - ShR EBX, CL - Mov ECX, EBX - Pop EBX - - Inc ECX - Mov EDI, 1 - - Test DL, 2 - JZ ReleaseSample8Bit - - Cmp CS:Convert16To8Bit, 0 - JNZ ReleaseSample8Bit - - Add ECX, ECX - Inc DI - - ; EBP = pointer for 16 bit - ; need to convert back: - Mov EDX, EBP - Add EBP, EBP - And EBP, 3FFFFh - And EDX, Not 3FFFFh - Or EBP, EDX - -ReleaseSample8Bit: - Sub EAX, EBP - Sub EAX, ECX - - Cmp EAX, GUSMemoryFree - JNE ReleaseSample3 - - Add ECX, EDI - Add GUSMemoryFree, ECX - -ReleaseSample3: - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Push EAX - Push CX - Push ES - Push DI - - MovZX EAX, GUSMemory ; Number of kbytes - ShL EAX, 10 ; Translate to bytes - - Sub EAX, 64 ; Safety bytes. - Mov GUSMemoryFree, EAX - - Push CS - Pop ES - Mov DI, Offset GUSDataTable - Mov CX, 200 - Mov AX, 0FFFFh - Rep StosW - - Pop DI - Pop ES - Pop CX - Pop EAX - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - Push CS - Pop DS - Assume DS:Driver - - Mov EAX, GUSMemoryFree - Mov SI, Offset GUSFreeMsg - ShR EAX, 10 - -IFDEF RIC - Cmp ShowReinit, 0 - JE NoShowInit - - Mov SI, Offset GUSFreeMsg2 - Mov BX, UsedChannels - Cmp ShowReinit, 1 - JE NoShowInit - - Add BX, BX - Mov BX, [GUSMixTable+BX-28] - - NoShowInit: - -ENDIF - ClC - - Ret - -EndP GetStatus - Assume DS:Nothing - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset GUSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetConvert Far - - Mov AX, [SI+22] - Mov CS:Convert16To8Bit, AL - Call Music_LoadAllSamples - - Mov AX, 1 - Ret - -EndP SetConvert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetConvert Far - - Push CS - Pop ES - Mov DI, Offset Convert16To8Bit - Ret - -EndP GetConvert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetCompress Far - - Mov AX, [SI+22] - Mov CS:Compress, AL - Call Music_LoadAllSamples - - Mov AX, 1 - Ret - -EndP SetCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetCompress Far - - Push CS - Pop ES - Mov DI, Offset Compress - - Ret - -EndP GetCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IFDEF RIC - -Proc SetReinit Far - - Mov AX, [SI+22] - Mov CS:ShowReinit, AL - - Mov AX, 1 - Ret - -EndP SetReinit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetReinit Far - - Push CS - Pop ES - Mov DI, Offset ShowReinit - - Ret - -EndP GetReinit - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Constants Table ************* - -MaxNumberOfChannels DW 32 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 32 -DriverFlags DW 1 ; Driver supports MIDI Out - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - DW Offset DetectGUS - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - - DW Offset UARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End - - *********************** Notes ******************* - - UltraSound Output Structure - - 0 1 2 3 4 5 6 7 8 9 - ÚÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂ -0000:³(Flags)³LastVol ³ - ÃÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÅ - - + + .386P + Jumps + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +;************************** + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;************** Local variables **************** + +SLAVECHANNELSIZE EQU 128 + +GUSReinitMsg DB "Gravis UltraSound reinitialised", 0 + +GUSID DB "Gravis UltraSound detected", 13 + DB "Port ", 0FDh, "Xh, ", 0FDh, "Dk Memory", 0 + +GUSID2 DB "Gravis UltraSound detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 + +GUSFreeMsg DB "FreeGUS ", 0FDh, "Dk", 0 + +IFDEF RIC + +GUSFreeMsg2 DB "FreeGUS ", 0FDh, "Dk", 13, 13 + DB "GUSInit ", 0FDh, "D", 0 + + IFDEF RAMP + DriverName DB "ITGUS.DRV", 0 + ELSE + DriverName DB "ITGUS2.DRV", 0 + ENDIF + +ENDIF + +ULTRASndString DB "ULTRASND" + +GUSMixTable Label Word + + DW 44100, 41160, 38588, 36318, 34300, 32495, 30870, 29400, 28064 + DW 26844, 25725, 24696, 23746, 22867, 22050, 21290, 20580, 19916 + DW 19294 + +GUSVolumeTable Label Word + DW 04000h, 07FF0h, 08FF0h, 09800h, 09FF0h, 0A400h, 0A800h, 0AC00h + DW 0AFF0h, 0B200h, 0B400h, 0B600h, 0B800h, 0BA00h, 0BC00h, 0BE00h + DW 0BFF0h, 0C100h, 0C200h, 0C300h, 0C400h, 0C500h, 0C600h, 0C700h + DW 0C800h, 0C900h, 0CA00h, 0CB00h, 0CC00h, 0CD00h, 0CE00h, 0CF00h + + DW 0CFF0h, 0D080h, 0D100h, 0D180h, 0D200h, 0D280h, 0D300h, 0D380h + DW 0D400h, 0D480h, 0D500h, 0D580h, 0D600h, 0D680h, 0D700h, 0D780h + DW 0D800h, 0D880h, 0D900h, 0D980h, 0DA00h, 0DA80h, 0DB00h, 0DB80h + DW 0DC00h, 0DC80h, 0DD00h, 0DD80h, 0DE00h, 0DE80h, 0DF00h, 0DF80h + + DW 0DFF0h, 0E040h, 0E080h, 0E0C0h, 0E100h, 0E140h, 0E180h, 0E1C0h + DW 0E200h, 0E240h, 0E280h, 0E2C0h, 0E300h, 0E340h, 0E380h, 0E3C0h + DW 0E400h, 0E440h, 0E480h, 0E4C0h, 0E500h, 0E540h, 0E580h, 0E5C0h + DW 0E600h, 0E640h, 0E680h, 0E6C0h, 0E700h, 0E740h, 0E780h, 0E7C0h + + DW 0E800h, 0E840h, 0E880h, 0E8C0h, 0E900h, 0E940h, 0E980h, 0E9C0h + DW 0EA00h, 0EA40h, 0EA80h, 0EAC0h, 0EB00h, 0EB40h, 0EB80h, 0EBC0h + DW 0EC00h, 0EC40h, 0EC80h, 0ECC0h, 0ED00h, 0ED40h, 0ED80h, 0EDC0h + DW 0EE00h, 0EE40h, 0EE80h, 0EEC0h, 0EF00h, 0EF40h, 0EF80h, 0EFC0h + + DW 0EFF0h + +ALIGN 4 + +GUSDataTable DD 100 Dup (0FFFFFFFFh) +GUSMemory DW 0 ; kb of memory on GUS +GUSRegisterSelect DW 0 +GUSVoiceSelect DW 0 +GUSUpdateTimer DW 0 +GUSUpdateCount DW 0 +GUSMemoryFree DD 0 +MixSpeed DW 0 +OldIRQHandler DD 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 8 + +Convert16To8Bit DB 0 + DB 0 +Compress DB 0 + DB 0 + +IFDEF RIC + ShowReinit DB 0 + DB 0 + UsedChannels DW ? +ENDIF + +Stereo DB 0 +GUSUpdateFlag DB 0 + +MIDIIRQ DW 0FFFFh +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 +MIDIOldIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +IMR DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +GUSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr GravisHeaderLine + + DW SampleText ; 4 + + DW ConvertSampleText + DW ConvertDisabledButton ; 6 + DW ConvertEnabledButton + + DW SampleSizeText ; 8 + DW SampleSize0Button ; 9 + DW SampleSize1Button + DW SampleSize2Button + + +IFDEF RIC + DW ReinitText ; 12 + DW ReinitButton0 + DW ReinitButton1 + DW ReinitButton2 + +ENDIF + + DW DriverText + + DW 0 + +GravisHeaderLine DW 10 + DB "Gravis UltraSound Driver", 0 + +DriverText DW 1 + DB 30, 48 + DB 21h + DB "Gravis UltraSound Driver 1.3 for Impulse Tracker", 0 + +SampleText DW 1 + DB 3, 13 + DB 20h + DB "Sample resizing options", 0 + +ConvertSampleText DW 1 + DB 5, 15 + DB 20h + DB "Reduce 16 bit samples to 8 bit", 0 + +ConvertDisabledButton DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetConvert +DriverSegment1 DW 0 + DW 0 + DW Offset SetConvert +DriverSegment2 DW 0 + DB 7, 17, 20, 19, 8 + DB 0 + DB " Disabled", 0 + +ConvertEnabledButton DW 2 + DW 6, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetConvert +DriverSegment3 DW 0 + DW 1 + DW Offset SetConvert +DriverSegment4 DW 0 + DB 7, 20, 20, 22, 8 + DB 0 + DB " Enabled", 0 + +SampleSizeText DW 1 + DB 5, 24 + DB 20h + DB "Sample size", 0 + +SampleSize0Button DW 2 + DW 7, 10, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment5 DW 0 + DW 0 + DW Offset SetCompress +DriverSegment6 DW 0 + DB 7, 26, 20, 28, 8 + DB 0 + DB " Original", 0 + +SampleSize1Button DW 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment7 DW 0 + DW 1 + DW Offset SetCompress +DriverSegment8 DW 0 + DB 7, 29, 20, 31, 8 + DB 0 + DB " Half", 0 + +IFDEF RIC + + SampleSize2Button DW 2 + DW 10, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress + DriverSegment9 DW 0 + DW 2 + DW Offset SetCompress + DriverSegment10 DW 0 + DB 7, 32, 20, 34, 8 + DB 0 + DB " Quarter", 0 + + ReinitText DW 1 + DB 3, 36 + DB 20h + DB "Show channel reinitialisation", 0 + + ReinitButton0 DW 2 + DW 11, 14, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetReinit + DriverSegment11 DW 0 + DW 0 + DW Offset SetReinit + DriverSegment12 DW 0 + DB 7, 38, 21, 40, 8 + DB 0 + DB " Disabled", 0 + + ReinitButton1 DW 2 + DW 13, 15, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetReinit + DriverSegment13 DW 0 + DW 1 + DW Offset SetReinit + DriverSegment14 DW 0 + DB 7, 41, 21, 43, 8 + DB 0 + DB " Channels", 0 + + ReinitButton2 DW 2 + DW 14, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetReinit + DriverSegment15 DW 0 + DW 2 + DW Offset SetReinit + DriverSegment16 DW 0 + DB 7, 44, 21, 46, 8 + DB 0 + DB " Frequency", 0 + +ELSE + + SampleSize2Button DW 2 + DW 10, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress + DriverSegment9 DW 0 + DW 2 + DW Offset SetCompress + DriverSegment10 DW 0 + DB 7, 32, 20, 34, 8 + DB 0 + DB " Quarter", 0 + + +ENDIF + + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +RelocationTable Label + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + +IFDEF RIC + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW Offset DriverSegment15, Offset DriverSegment16 +ENDIF + DW 0FFFFh + +;*********** Local functions ******************* +; +; GUSDelay - produces delay between GUS commands +; TestGUS - Checks for the presence of a GUS by detecting amount of memory. +; LoadGUSSample - Loads a byte to GUS, EDI = position in memory, AL = value +; LoadGUSSamples - Loads ECX bytes from DS:SI to EDI +; +;*********************************************** + +Proc GUSDelay + + Push AX + Push DX + + Mov DX, 300h + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Pop DX + Pop AX + + Ret + +EndP GUSDelay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetGUS ; AX = baseport. + + Push AX + Push DX + + Mov DX, AX + Add DX, 103h ; Select register + + Mov AL, 4Ch ; Reset global register + Out DX, AL + + Add DL, 2 ; 8 bit data + Xor AL, AL + Out DX, AL ; Reset GUS! + + Call GUSDelay + Call GUSDelay + + Mov AL, 1 + Out DX, AL + + Call GUSDelay + Call GUSDelay + + Pop DX + Pop AX + + Ret + +EndP ResetGUS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TestGUS + + Push AX + + Call ResetGUS + + Mov GUSMemory, 0 + + Mov DX, AX + Add DX, 103h ; DX = Select Register + + Mov CX, 4 ; Max amount is 1MB of memory + Xor BL, BL ; Start with first 256k pool + +TestGUS1: + Mov AL, 44h ; GUS DRAM High, 8 bit + Out DX, AL + + Add DL, 2 + Mov AL, BL + Out DX, AL + + Sub DL, 2 ; DX = Select Register + + Mov AL, 43h ; GUS DRAM Low, 16 bit + Out DX, AL + + Inc DX ; DX = Baseport+104h + Xor AX, AX + Out DX, AX ; Address 0 + + Add DL, 3 ; DX = Baseport+107h (DRAM I/O) + Mov AL, 55h + Out DX, AL ; Write value 055h + + Sub DL, 3 ; DX = Baseport+104h + Mov AX, 1 + Out DX, AX ; Address 1 + + Add DL, 3 ; DX = Baseport+107h + Mov AL, 0AAh + Out DX, AL ; Write value 0AAh + + Sub DL, 3 ; DX = Baseport+104h + Mov AX, 2 + Out DX, AX ; Address 2 + + Add DL, 3 ; DX = Baseport+107h + Mov AL, 0 + Out DX, AL ; Write value + + Sub DL, 3 ; DX = Baseport+104h + Xor AX, AX + Out DX, AX ; Address 0 + + Add DL, 3 ; DX = Baseport+107h + In AL, DX ; Read value.. should be 055h + Cmp AL, 55h + JNE TestGUS2 + + Sub DL, 3 ; DX = Baseport+104h + Mov AX, 1 + Out DX, AX ; Address 1 + + Add DL, 3 ; DX = Baseport+107h + In AL, DX ; Read value.. should be 0AAh + Cmp AL, 0AAh + JNE TestGUS2 + + Sub DL, 3 ; DX = Baseport+104h + Mov AX, 2 + Out DX, AX ; Address 2 + + Add DL, 3 ; DX = Baseport+107h + In AL, DX ; Read value.. + Cmp AL, 0 + JNE TestGUS2 + + Sub DL, 4 ; DX = Baseport+103h + + Add GUSMemory, 256 ; Another 256k! + + Add BL, 4 ; Next memory chunk + Loop TestGUS1 + + +TestGUS2: + Pop AX + + Cmp GUSMemory, 0 + JNE TestGUS3 + + StC + Ret + +TestGUS3: + ClC + Ret + +EndP TestGUS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadGUSSample ; EDI = position, AL = value + + Push EAX + + Mov DX, CS:GUSRegisterSelect + Mov AL, 44h + Out DX, AL + + Add DL, 2 + Mov EAX, EDI + ShR EAX, 16 + Out DX, AL + Sub DL, 2 ; Select register again. + + Mov AL, 43h ; Address Low, 16 bit + Out DX, AL + Inc DX ; DX = 3x4h + + Mov AX, DI ; Memory location high + Out DX, AX ; Memory location done. + + Add DL, 3 + + Pop EAX + + Out DX, AL + Sub DL, 3 + + Inc EDI + + Ret + +EndP LoadGUSSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadGUSSamples ; Given DS:SI, EDI = pos, ECX = count + ; EBP = step value. + +LoadGUSSamples1: + Mov DX, CS:GUSRegisterSelect + Mov AL, 44h + Out DX, AL + + Add DL, 2 + Mov EAX, EDI + ShR EAX, 16 + Out DX, AL + Sub DL, 2 ; Select register again. + + Mov AL, 43h ; Address Low, 16 bit + Out DX, AL + Inc DX ; DX = 3x4h + +LoadGUSSamples2: + Mov AX, DI ; Memory location high + Out DX, AX ; Memory location done. + + Add DL, 3 + + Mov AL, [SI] + Add SI, BP + JC LoadGUSSamples4 + +LoadGUSSamples3: + Out DX, AL + Sub DL, 3 + + Inc DI + JZ LoadGUSSamples5 + + Dec ECX + JNZ LoadGUSSamples2 + Ret + +LoadGUSSamples4: + Add ESI, 10000h + Call UpdateSampleLocation + Jmp LoadGUSSamples3 + +LoadGUSSamples5: + Add EDI, 10000h + LoopD LoadGUSSamples1 + Ret + +EndP LoadGUSSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load16GUSSamples ; Given DS:SI, EDI = pos, ECX = count + ; EBP = step value. + + Add BP, BP + Dec BP + Mov BX, 1 + Xor BP, BX + Xor BX, BP + +Load16GUSSamples1: + Mov DX, CS:GUSRegisterSelect + Mov AL, 44h + Out DX, AL + + Add DL, 2 + Mov EAX, EDI + ShR EAX, 16 + Out DX, AL + Sub DL, 2 ; Select register again. + + Mov AL, 43h ; Address Low, 16 bit + Out DX, AL + Inc DX ; DX = 3x4h + +Load16GUSSamples2: + Mov AX, DI ; Memory location high + Out DX, AX ; Memory location done. + + Add DL, 3 + + Xor BX, BP + Mov AL, [SI] + Add SI, BX + JC Load16GUSSamples4 + +Load16GUSSamples3: + Out DX, AL + Sub DL, 3 + + Inc DI + JZ Load16GUSSamples5 + + LoopD Load16GUSSamples2 + Ret + +Load16GUSSamples4: + Add ESI, 10000h + Call UpdateSampleLocation + Jmp Load16GUSSamples3 + +Load16GUSSamples5: + Add EDI, 10000h + LoopD Load16GUSSamples1 + Ret + +EndP Load16GUSSamples + +;*********** Public functions ****************** + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectGUS Far + + Push CS + Pop DS + Assume DS:Driver + + Cmp BasePort, 0FFFFh + JE DetectGUS1 + + Mov AX, BasePort + + Cmp AX, 210h + JB DetectCardError + Cmp AX, 280h + JA DetectCardError + + Call TestGUS + JNC DetectGUS3 + Jmp DetectCardError + +DetectGUS1: + Mov AX, 210h + +DetectGUS2: + Call TestGUS + JNC DetectGUS3 + + Add AL, 10h + Cmp AL, 60h + JBE DetectGUS2 + +DetectCardError: + StC + Ret + +DetectGUS3: + Mov BasePort, AX + Add AX, 102h + Mov GUSVoiceSelect, AX + Inc AX + Mov GUSRegisterSelect, AX + +Comment ~ + + ; If Windows *AND* IRQ = 0FFFFh, then grab from ULTRASND variable + + Mov SI, Offset ULTRASNDString + Mov CX, 8 + Call GetEnvironment ; Returns ES:DI, Carry if error + JC DetectCardOK + + Mov CX, 3 ; Find 3 commas first. + ; Eg. skip baseport + 2 DMAs + +DetectCard1: + Mov AL, [ES:DI] + Inc DI + + Cmp AL, ',' + JNE DetectCard1 + Loop DetectCard1 + + ; GUS IRQ.. + Xor DX, DX + +DetectCardIRQ1_1: + Mov AL, [ES:DI] + Inc DI + Cmp AL, ',' + JE DetectCardIRQ1_2 + + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCardIRQ1_1 + +DetectCardIRQ1_2: ; DX = IRQ to use. + Cmp DX, 15 + JA DetectCardError + + Mov AX, 1600h + Int 2Fh ; Windows Detect. + + Test AL, 7Fh + JZ DetectCardIRQ2_1 + + Mov AX, IRQ + Cmp AX, -1 + JNE DetectCardIRQ2_2 + Mov IRQ, DX + Mov MIDIIRQ, DX + Jmp DetectCardOK + +DetectCardIRQ2_2: + Mov DX, AX + +DetectCardIRQ2_1: ; No Windows. + Mov MIDIIRQ, DX + +DetectCardOK: + +~ + + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectGUS + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GUSIRQHandler ; IRQ Handler has to + ; 1) Update GUS registers + ; 2) Update song position + Push AX + Push DS + + Mov AX, GUSUpdateTimer + Add GUSUpdateCount, AX + JC GUSIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp GUSIRQHandler2 + +GUSIRQHandler1: + PushF + Call [OldIRQHandler] + +GUSIRQHandler2: + Xor GUSUpdateFlag, 1 + JZ GUSIRQHandlerEnd + + PushAD + Push ES + + ClD + + Call SaveEMSPageFrame + Call Update ; Returns DS:SI, CX + Call SetGUSRegisters + Call RestoreEMSPageFrame + + Pop ES + PopAD + +GUSIRQHandlerEnd: + Pop DS + Pop AX + IRet + +EndP GUSIRQHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Comment ~ + +Proc CheckMIDI + + Push AX BX DX DS + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + Inc DH + +CheckMIDIAgain: + In AL, DX + Test AL, 1 + JZ CheckMIDI1 + + Inc DX + In AL, DX + Dec DX + + Cmp AL, 0F0h +; JAE CheckMIDIAgain + JAE CheckMIDI1 + + Mov BL, [MIDIBufferTail] + Inc BL + Cmp BL, [MIDIBufferHead] + JE CheckMIDI1 +; JE CheckMIDIAgain + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL +; Jmp CheckMIDIAgain + +CheckMIDI1: + Pop DS DX BX AX + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GUSMIDIIRQHandler + + Push AX BX DX DS + + Push CS + Pop DS + Assume DS:Driver + + Call CheckMIDI + + Mov AL, 20h + + Cmp MIDIIRQ, 8 + JB GUSMIDIIRQHandler1 + + Out 0A0h, AL + +GUSMIDIIRQHandler1: + Out 20h, AL + + Pop DS DX BX AX + IRet + +EndP GUSMIDIIRQHandler + Assume DS:Nothing + +~ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GUSIRQOnlyHandler + + PushAD + Push DS + Push ES + + Mov AL, 20h + + Cmp CS:IRQ, 8 + JB GUSIRQOnlyHandler1 + + Out 0A0h, AL + +GUSIRQOnlyHandler1: + Out 20h, AL + +GUSIRQAgain: + Mov DX, CS:BasePort + Add DL, 6 + In AL, DX + +; Test AL, 2 ; MIDI receive? +; JZ GUSIRQOnlyHandlerNoMIDI +; +; Call CheckMIDI +; +; Jmp GUSIRQAgain + +GUSIRQOnlyHandlerNoMIDI: + Test AL, 8 + JZ GUSIRQOnlyHandler3 + + Mov DX, CS:GUSRegisterSelect + Mov AL, 45h + Out DX, AL + Mov AL, 0 + Add DL, 2 + Out DX, AL + Mov AL, 8 + Out DX, AL + Sub DL, 2 + + CLD + + Call SaveEMSPageFrame + Call Update + Call SetGUSRegisters + Call RestoreEMSPageFrame + Jmp GUSIRQAgain + +GUSIRQOnlyHandler3: + Test AL, 60h + JZ GUSIRQOnlyHandler2 + + Mov DX, CS:GUSVoiceSelect + In AL, DX + Push AX + +GUSIRQOnlyHandler4: + Mov DX, CS:GUSRegisterSelect + Mov AL, 8Fh + Out DX, AL + Add DL, 2 + In AL, DX ; Bit 6 = waveramp IRQ + ; Bit 7 = wavetable IRQ... + ; Bit 0-5 = voice + + Test AL, 080h + JZ GUSIRQOnlyHandler5 + Test AL, 040h + JZ GUSIRQOnlyHandler6 + + Pop AX + Mov DX, CS:GUSVoiceSelect + Out DX, AL + +; Jmp GUSIRQAgain + Jmp GUSIRQOnlyHandler2 + +GUSIRQOnlyHandler5: ; Wavetable IRQ + Push AX + Mov DX, CS:GUSVoiceSelect + And AL, 31 + Out DX, AL + Call GUSDelay + + Inc DX + + Xor AL, AL + Out DX, AL ; AL = 0 (Mode control) + Mov AL, 2 + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + + Pop AX + Test AL, 40h + JNZ GUSIRQOnlyHandler4 + +GUSIRQOnlyHandler6: ; Volume IRQ + Mov DX, CS:GUSVoiceSelect + And AL, 31 + Out DX, AL + Call GUSDelay + + Inc DX + Mov AL, 0Dh ; Volume Ramp. + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 6 ; Ramp rate + Out DX, AL + + Mov AL, 63 ; Ramp rate + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Jmp GUSIRQOnlyHandler4 + + +GUSIRQOnlyHandler2: + Pop ES + Pop DS + PopAD + + IRet + +EndP GUSIRQOnlyHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IFDEF RAMP + include gusramp.inc +ELSE + include gusnramp.inc +ENDIF + +IFDEF RIC + include gusric.inc +ELSE + include gusnric.inc +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GUSGetAddress ; Given EAX + Assume DS:Nothing + + Push CX + + Mov CL, CS:Compress + ShR EAX, CL + + Pop CX + Add EAX, [CS:GUSDataTable+BX] + ShL EAX, 9 + + Ret + +EndP GUSGetAddress + +;ÄÄ InitMIDIIRQ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Comment ~ + +Proc InitMIDIIRQ + + Ret + + + PushA + Push DS + Push ES + + Mov AX, CS + Mov DS, AX + ShL EAX, 16 + Mov ES, AX + Assume DS:Driver + + Mov BX, MIDIIRQ + Cmp BX, 15 + JA InitMIDIIRQ1 + + ShL BX, 2 + Mov SI, [IRQData+BX] + + Mov AX, Offset GUSMIDIIRQHandler + XChg [ES:SI], EAX + + Mov MIDIOldIRQHandler, EAX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + + And AX, [IRQData+BX+2] ; Update mask + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov DX, BasePort + Inc DH + Mov AL, 0FFh + Out DX, AL + Mov AL, 0FCh + Out DX, AL + Jmp InitMIDIIRQEnd + +InitMIDIIRQ1: + Mov DX, BasePort + Inc DH + Mov AL, 0FFh + Out DX, AL + Mov AL, 0h + Out DX, AL + +InitMIDIIRQEnd: + Pop ES + Pop DS + PopA + + Ret + +EndP InitMIDIIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitMIDIIRQ + + Ret + + PushA + Push DS + Push ES + + Mov BX, MIDIIRQ + Cmp BX, 15 + JA UnInitMIDIIRQ1 + + ShL BX, 2 + Mov BX, [IRQData+BX] + Xor AX, AX + Mov ES, AX + + Mov EAX, MIDIOldIRQHandler + Mov [ES:BX], EAX + +UnInitMIDIIRQ1: + Mov DX, Baseport + Inc DH + Mov AL, 0FFh + Out DX, AL + + Pop ES + Pop DS + PopA + + Ret + +EndP UnInitMIDIIRQ + Assume DS:Nothing + +~ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov SI, Offset RelocationTable + +RelocationSetup: + Mov BX, [SI] + Cmp BX, 0FFFFh + JE RelocationSetupFinished + + Mov [BX], CS + + Add SI, 2 + Jmp RelocationSetup + +RelocationSetupFinished: + ; OK... disable the GUS Line In + ; & Enable Line Out + Mov BX, AX + + Mov DX, BasePort + Mov AL, 1 + Out DX, AL + + Call ResetGUS + + Cmp BL, 14 + JAE InitSound_GUS4 + + Mov BL, 14 + +InitSound_GUS4: + +IFDEF RIC + Mov UsedChannels, BX +ENDIF + + Mov DX, GUSRegisterSelect ; Tell the GUS how many voices + Mov AL, 0Eh ; to use + Out DX, AL + + Add DL, 2 ; DX = BasePort + 105h + Mov AL, BL + Dec AL + Or AL, 0C0h + Out DX, AL ; Number of Voices set + + ; Reset each voice + Mov CX, 32 ; 32 voices to clear. + + Sub BX, 14 ; Now get mixspeed + Add BX, BX + Mov AX, [GUSMixTable+BX] + Mov MixSpeed, AX + + Sub DL, 3 ; DX = Voice select register + +GUSResetVoice: + Mov AL, CL + Dec AL + Out DX, AL + + Inc DX ; DX = BasePort + 103h + Xor AL, AL ; Voice control register, 8 bit + Out DX, AL + + + Add DL, 2 + Mov AL, 2 + Out DX, AL ; Stop voice + Sub DL, 2 + + Mov AL, 0Dh ; Volume Ramp. + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Mov AL, 6 ; Ramp rate + Out DX, AL + + Mov AL, 63 ; Ramp rate + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 9 ; Volume register, 16 bit + Out DX, AL + + Inc DX + Xor AX, AX + Out DX, AX ; No volume + Call GUSDelay + Out DX, AX + + ClI + Sub DL, 2 ; DX = BasePort + 102h = Voice select. + + Loop GUSResetVoice + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + +; Call InitMIDIIRQ + + Cmp IRQ, 0FFFFh + JE InitSound_GUS1 + + Mov AX, BasePort + Call ResetGUS + + ; Set IRQ + Mov BX, IRQ + ShL BX, 2 ; BX points to offset in IRQData + + Xor DI, DI + Mov ES, DI + Mov DI, [BX+IRQData] + + In AL, 0A1h + Mov AH, AL + In AL, 21h + + And AX, [BX+IRQData+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset GUSIRQOnlyHandler + + XChg [ES:DI], EAX + Mov OldIRQHandler, EAX + + StI + + Mov DX, BasePort + Mov AL, 9 ; + 16 + Out DX, AL + + Mov DX, GUSRegisterSelect + Mov AL, 4Ch + Out DX, AL + Add DL, 2 + Mov AL, 7 + Out DX, AL + + Call GetTempo + Call SetTempo + Call ResetMemory + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, GUSMemory + + Mov SI, Offset GUSID2 + + ClC + Ret + +InitSound_GUS1: + Inc DL + Mov AL, 4Ch + Out DX, AL + Add DL, 2 + Mov AL, 3 ; 7 + Out DX, AL + + Mov DX, BasePort + Mov AL, 9 ; + 16 + Out DX, AL + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Call GetTempo + Call SetTempo + Call ResetMemory + + Xor AX, AX + Mov ES, AX ; ES = 0 + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset GUSIRQHandler + + ClI + + XChg DWord Ptr [ES:20h], EAX ; Clock tick + Mov OldIRQHandler, EAX + + StI + + Mov AX, BasePort + Mov BX, GUSMemory + Mov SI, Offset GUSID + + ClC + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push AX + + Push CS + Pop DS + Mov SI, Offset GUSReinitMsg + Mov BX, 40 + Call SetInfoLine + + Call UnInitSound + + Pop AX + Jmp InitSound + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Push CS + Pop DS + Assume DS:Driver + +IFDEF RIC + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset Convert16To8Bit + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h +SaveConfig2: + +ENDIF + Mov AX, BasePort + Call ResetGUS + + ClI + + Mov BX, CS:IRQ + Cmp BX, 0FFFFh + JE UnInitSound1 + + Mov AX, CS:IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + ShL BX, 2 + Xor DI, DI + Mov ES, DI + Mov DI, [CS:BX+IRQData] + Mov EAX, CS:OldIRQHandler + + Mov [ES:DI], EAX + +; Call UnInitMIDIIRQ + + StI + Ret + +UnInitSound1: + Mov AL, 34h + Out 43h, AL + + Xor AX, AX + Out 40h, AL + Out 40h, AL + + Mov ES, AX + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + +; Call UnInitMIDIIRQ + + StI + + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + Ret + +EndP Poll + Assume DS:Nothing + +Proc UARTOut Far + + Push DX + Push AX + + Mov DX, [CS:BasePort] + Inc DH + +UARTOut1: + In AL, DX + Test AL, 2 + JZ UARTOut1 + + Pop AX + Inc DX + + Out DX, AL + + Pop DX + + Ret + +EndP UARTOut + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far ; BX = tempo... + + Push AX + Push BX + Push DX + + Cmp CS:IRQ, 0FFFFh + JE SetTempo1 + + ShL BX, 8 + Mov DX, 1Eh + Mov AX, 8480h + Div BX + Neg AL + + Mov AH, AL + + Mov DX, CS:GUSRegisterSelect + + Mov AL, 47h + Out DX, AL + Add DL, 2 + Mov AL, AH + Out DX, AL ; Set Timer control register 2 + Sub DL, 2 + + Mov AL, 45h + Out DX, AL + Add DL, 2 + Mov AL, 8 + Out DX, AL +; Sub DL, 2 + + Mov DX, CS:BasePort + Add DL, 8 + Mov AL, 4 + Out DX, AL + + Inc DL + Mov AL, 2 + Out DX, AL + + Jmp SetTempo2 + +SetTempo1: + ; Frames per second = 2 * (0.4*Tempo) + Mov AX, 0C214h + Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo + Div BX + + ; AX contains counter. + Mov GUSUpdateTimer, AX + + Out 40h, AL ; Timer IRQ. + Mov AL, AH + Out 40h, AL + +SetTempo2: + Pop DX + Pop BX + Pop AX + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + PushAD + Push DS + Push ES + Push FS + + Mov FS, CS:SongDataArea + Mov BP, AX + Dec BP + Add BP, BP + Mov BP, [FS:64912+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC Music_GUSLoadSampleEnd + + Mov BL, [FS:BP+12h] + Test BL, 16 + JZ Music_GUSLoadSample12 + + Cmp ECX, [FS:BP+38h] + JBE Music_GUSLoadSample12 + + Mov ECX, [FS:BP+38h] + Test BL, 32 + JZ Music_GUSLoadSample12 + + Cmp ECX, [FS:BP+44h] + JAE Music_GUSLoadSample12 + + Mov ECX, [FS:BP+44h] + +Music_GUSLoadSample12: + Mov EBX, ECX + Mov CL, CS:Compress + Mov EDX, 1 + ShR EBX, CL + ShL EDX, CL ; EDX = step value. + + Mov ECX, EBX + + ; Now find location to put it in + + Dec AX ; AX = sample number + Push AX ; AX = sample number (0 based) + + And EAX, 0FFh + Mov DWord Ptr [CS:GUSDataTable+4*EAX], 0FFFFFFFFh + + Add ECX, 2 + Mov EAX, GUSMemoryFree + + Test Byte Ptr [FS:BP+12h], 2 ; 16 bit?? + JZ Music_GUSLoadSamples13 + + Cmp CS:Convert16To8Bit, 0 + JNZ Music_GUSLoadSamples5 + + Sub EAX, 1 + JC Music_GUSLoadSampleWarning + And EAX, Not 1 ; For alignment + Add ECX, ECX + + Mov EBX, EAX + + Sub EBX, 1 + JC Music_GUSLoadSampleWarning + And EBX, 3FFFFh ; Get bytes remaining in 'segment' + Inc EBX + + Cmp ECX, 256*1024 + JAE Music_GUSLoadSamples13 + + Cmp ECX, EBX + JBE Music_GUSLoadSample2 + + Sub EAX, EBX + Jmp Music_GUSLoadSamples13 + +Music_GUSLoadSamples5: + Inc ESI + Add EDX, EDX ; Step value. + +Music_GUSLoadSamples13: + Cmp ECX, EAX + JBE Music_GUSLoadSample2 + + ; Warning msg here. +Music_GUSLoadSampleWarning: + Pop AX + +Music_GUSLoadSampleEndNoError: + ClC + Jmp Music_GUSLoadSampleEnd + +Music_GUSLoadSample3: + StC + +Music_GUSLoadSampleEnd: + Pop FS + Pop ES + Pop DS + PopAD + + Ret + +Music_GUSLoadSample2: ; EAX = number of bytes free. + ; DS:SI = sample. + ; ECX = number of bytes of memory + ; ES:DI = num bytes free ptr + ; BP = sample number. + + ; Location = MaxMem - DX:AX + ; = -(DX:AX - GUSBanks*4:0) + MovZX EBX, CS:GUSMemory + ShL EBX, 10 + ; BX = bytes avail. + Sub EBX, EAX + Sub EAX, ECX + Mov GUSMemoryFree, EAX + + Pop DI ; DI = sample number + + ShL DI, 2 + + Cmp CS:Convert16To8Bit, 0 + JNZ LoadGUSForced8Bit + + Test Byte Ptr [FS:BP+12h], 2 + JNZ Music_GUSLoad16BitSample + +LoadGUSForced8Bit: + Push EBX + Inc EBX + Mov [CS:GUSDataTable+DI], EBX ; Store pointer + + Mov ES, CS:SongDataArea + Pop EDI ; EDI = location in GUS mem + + Sub ECX, 2 + ; EDI = location in GUS mem + ; DS:SI = sample data + ; ECX = length. + ; EDX = step value. + ClI + + Push BP + + Mov EBP, EDX + + Mov AL, [DS:SI+BP] + Call LoadGUSSample + Call LoadGUSSamples + + Mov BH, AL + + Pop BP + + Mov AL, [FS:BP+12h] + Test AL, 16 + JZ Music_GUSLoadSample10 + + Mov ESI, [FS:BP+34h] + Test AL, 64 + JZ Music_GUSLoadSample11 + + Mov ESI, [FS:BP+38h] + Sub ESI, 2 + AdC ESI, 0 + + Mov EAX, Not 0 + Mov CL, CS:Compress + ShL EAX, CL + And ESI, EAX + +Music_GUSLoadSample11: + Test Byte Ptr [FS:BP+12h], 2 + JZ Music_GUSLoadSample6 + + Add ESI, ESI + Inc SI + +Music_GUSLoadSample6: + Call UpdateSampleLocation + + Mov BH, [SI] + +Music_GUSLoadSample10: + Mov AL, BH + Call LoadGUSSample + + StI + Jmp Music_GUSLoadSample3 ; Return.. no error. + +Music_GUSLoad16BitSample: + Push EBX + + Add EBX, 2 + Mov EAX, EBX + And EBX, 3FFFFh + And EAX, Not 3FFFFh + ShR EBX, 1 + Or EAX, EBX + Mov [CS:GUSDataTable+DI], EAX + + Mov ES, CS:SongDataArea + Pop EDI ; EDI = location in GUS mem + + Sub ECX, 4 + ClI + + Push BP + + Mov EBP, EDX + + Mov AX, [DS:ESI+EBP*2] + Call LoadGUSSample + Mov AL, AH + Call LoadGUSSample + + Call Load16GUSSamples + + Pop BP + + Xor BX, BX + + Mov AL, [FS:BP+12h] + Test AL, 16 + JZ Music_GUSLoad16BitSample11B + + Mov ESI, [FS:BP+34h] + + Test AL, 64 + JZ Music_GUSLoad16BitSample11 + + Mov ESI, [FS:BP+38h] + Sub ESI, 2 + JNC Music_GUSLoad16BitSample11 + + Xor ESI, ESI + +Music_GUSLoad16BitSample11: + Mov EAX, Not 0 + Mov CL, CS:Compress + ShL EAX, CL + And ESI, EAX + + Add ESI, ESI + Call UpdateSampleLocation + + Mov BX, [SI] + +Music_GUSLoad16BitSample11B: + Mov AX, BX + Call LoadGUSSample + Mov AL, AH + Call LoadGUSSample + + StI + Jmp Music_GUSLoadSample3 ; Return.. no error. + + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release, 0 based +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + LEA DI, [EAX*4+Offset GUSDataTable] + ; Now to release the last + ; sample from GUS memory if + ; able to. + + Cmp DWord Ptr [CS:DI], 0FFFFFFFFh + JE ReleaseSample3 + +ReleaseSample4: + MovZX EAX, CS:GUSMemory + SHL EAX, 10 + + Mov EBP, [CS:DI] ; EBP = sample pointer. + + ; If (MaxMem-(sample location in bank + sample length + 2)) = memory remaining, + ; then release memory. + + Mov ECX, [SI+30h] + Mov DL, [SI+12h] + Test DL, 16 + JZ ReleaseSample7 + + Cmp ECX, [SI+38h] + JBE ReleaseSample7 + + Mov ECX, [SI+38h] + + Test DL, 32 + JZ ReleaseSample7 + + Cmp ECX, [SI+44h] + JAE ReleaseSample7 + + Mov ECX, [SI+44h] + +ReleaseSample7: + Push EBX + Mov EBX, ECX + Mov CL, CS:Compress + ShR EBX, CL + Mov ECX, EBX + Pop EBX + + Inc ECX + Mov EDI, 1 + + Test DL, 2 + JZ ReleaseSample8Bit + + Cmp CS:Convert16To8Bit, 0 + JNZ ReleaseSample8Bit + + Add ECX, ECX + Inc DI + + ; EBP = pointer for 16 bit + ; need to convert back: + Mov EDX, EBP + Add EBP, EBP + And EBP, 3FFFFh + And EDX, Not 3FFFFh + Or EBP, EDX + +ReleaseSample8Bit: + Sub EAX, EBP + Sub EAX, ECX + + Cmp EAX, GUSMemoryFree + JNE ReleaseSample3 + + Add ECX, EDI + Add GUSMemoryFree, ECX + +ReleaseSample3: + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Push EAX + Push CX + Push ES + Push DI + + MovZX EAX, GUSMemory ; Number of kbytes + ShL EAX, 10 ; Translate to bytes + + Sub EAX, 64 ; Safety bytes. + Mov GUSMemoryFree, EAX + + Push CS + Pop ES + Mov DI, Offset GUSDataTable + Mov CX, 200 + Mov AX, 0FFFFh + Rep StosW + + Pop DI + Pop ES + Pop CX + Pop EAX + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + Push CS + Pop DS + Assume DS:Driver + + Mov EAX, GUSMemoryFree + Mov SI, Offset GUSFreeMsg + ShR EAX, 10 + +IFDEF RIC + Cmp ShowReinit, 0 + JE NoShowInit + + Mov SI, Offset GUSFreeMsg2 + Mov BX, UsedChannels + Cmp ShowReinit, 1 + JE NoShowInit + + Add BX, BX + Mov BX, [GUSMixTable+BX-28] + + NoShowInit: + +ENDIF + ClC + + Ret + +EndP GetStatus + Assume DS:Nothing + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset GUSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetConvert Far + + Mov AX, [SI+22] + Mov CS:Convert16To8Bit, AL + Call Music_LoadAllSamples + + Mov AX, 1 + Ret + +EndP SetConvert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetConvert Far + + Push CS + Pop ES + Mov DI, Offset Convert16To8Bit + Ret + +EndP GetConvert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetCompress Far + + Mov AX, [SI+22] + Mov CS:Compress, AL + Call Music_LoadAllSamples + + Mov AX, 1 + Ret + +EndP SetCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetCompress Far + + Push CS + Pop ES + Mov DI, Offset Compress + + Ret + +EndP GetCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IFDEF RIC + +Proc SetReinit Far + + Mov AX, [SI+22] + Mov CS:ShowReinit, AL + + Mov AX, 1 + Ret + +EndP SetReinit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetReinit Far + + Push CS + Pop ES + Mov DI, Offset ShowReinit + + Ret + +EndP GetReinit + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Constants Table ************* + +MaxNumberOfChannels DW 32 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 32 +DriverFlags DW 1 ; Driver supports MIDI Out + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + DW Offset DetectGUS + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + + DW Offset UARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End + + *********************** Notes ******************* + + UltraSound Output Structure + + 0 1 2 3 4 5 6 7 8 9 + ÚÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂ +0000:³(Flags)³LastVol ³ + ÃÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÅ + + diff --git a/SoundDrivers/GUSDRV.ASM b/SoundDrivers/GUSDRV.ASM index ae60f0d..d36b093 100755 --- a/SoundDrivers/GUSDRV.ASM +++ b/SoundDrivers/GUSDRV.ASM @@ -1,5 +1,5 @@ - -RAMP EQU 1 - -include gus.inc - + +RAMP EQU 1 + +include gus.inc + diff --git a/SoundDrivers/GUSDRV2.ASM b/SoundDrivers/GUSDRV2.ASM index 54d73a4..af6fe01 100755 --- a/SoundDrivers/GUSDRV2.ASM +++ b/SoundDrivers/GUSDRV2.ASM @@ -1,3 +1,3 @@ - -include gus.inc - + +include gus.inc + diff --git a/SoundDrivers/GUSHIQ2.ASM b/SoundDrivers/GUSHIQ2.ASM index 2afcc8d..4912491 100755 --- a/SoundDrivers/GUSHIQ2.ASM +++ b/SoundDrivers/GUSHIQ2.ASM @@ -1,5 +1,5 @@ - -RIC EQU 1 - -include gus.inc - + +RIC EQU 1 + +include gus.inc + diff --git a/SoundDrivers/GUSHIQDR.ASM b/SoundDrivers/GUSHIQDR.ASM index 1b46dbc..82847fd 100755 --- a/SoundDrivers/GUSHIQDR.ASM +++ b/SoundDrivers/GUSHIQDR.ASM @@ -1,4 +1,4 @@ -RAMP EQU 1 -RIC EQU 1 - -include gus.inc +RAMP EQU 1 +RIC EQU 1 + +include gus.inc diff --git a/SoundDrivers/GUSMAX.ASM b/SoundDrivers/GUSMAX.ASM index fbdbfd6..ee1b37e 100755 --- a/SoundDrivers/GUSMAX.ASM +++ b/SoundDrivers/GUSMAX.ASM @@ -1,2091 +1,2091 @@ -; -; Windows Sound System Driver -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -DMASize DW 2048 - -WSSMsg DB "Using GUS CS4231 Codec", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Using GUS CS4231 Codec", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "GUS Codec reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITGUSMAX.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITGUSMAX.DRV", 0 - -DriverName DB "ITGUSMAX.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "GUS CS4231 Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "GUS CS4231 Codec Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 16 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Cmp IRQ, 0FFFFh - JE DetectWSSFailure - Cmp DMA, 0FFFFh - JE DetectWSSFailure - - Mov DX, BasePort - Cmp DX, 0FFFFh - JE DetectCardFindBasePort - - Call PingWSS - JNC CheckWSSOK - -DetectWSSFailure: - StC - Ret - -DetectCardFindBasePort: - Mov DX, 31Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 32Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 33Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 34Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 35Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 36Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 530h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 604h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0F40h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0E80h - Call PingWSS - JC DetectWSSFailure - -DetectWSSOK: - Mov BasePort, DX - -CheckWSSOK: ; Check for IRQ - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB WSSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -WSSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +DMASize DW 2048 + +WSSMsg DB "Using GUS CS4231 Codec", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Using GUS CS4231 Codec", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "GUS Codec reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITGUSMAX.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITGUSMAX.DRV", 0 + +DriverName DB "ITGUSMAX.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "GUS CS4231 Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "GUS CS4231 Codec Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 16 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Cmp IRQ, 0FFFFh + JE DetectWSSFailure + Cmp DMA, 0FFFFh + JE DetectWSSFailure + + Mov DX, BasePort + Cmp DX, 0FFFFh + JE DetectCardFindBasePort + + Call PingWSS + JNC CheckWSSOK + +DetectWSSFailure: + StC + Ret + +DetectCardFindBasePort: + Mov DX, 31Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 32Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 33Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 34Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 35Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 36Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 530h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 604h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0F40h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0E80h + Call PingWSS + JC DetectWSSFailure + +DetectWSSOK: + Mov BasePort, DX + +CheckWSSOK: ; Check for IRQ + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB WSSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +WSSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/GUSMAXMX.ASM b/SoundDrivers/GUSMAXMX.ASM index 73e03bb..6df88a7 100755 --- a/SoundDrivers/GUSMAXMX.ASM +++ b/SoundDrivers/GUSMAXMX.ASM @@ -1,1589 +1,1589 @@ -; -; Windows Sound System Driver, with GUS PnP detection, MMX mixing. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -OUTPUTFILTERENABLED EQU 0 - -FPSave DB 128 Dup (0) - -DMASize DW 2048 - -WSSMsg DB "GUS CS4231 Codec MMX", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "GUS CS4231 Codec MMX", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "GUS CS4231 Codec reinitialised", 0 - -DriverName DB "ITGUSMAX.MMX", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 4 -MixMode DW 0 -MixModeOffset DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 12 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 12 - DW Near Ptr MasterVolumeRight ; 13 - - DW 0 - - -WSSHeaderLine DW 10 - DB "GUS CS4231 Codec MMX Driver", 0 - -DriverText DW 1 - DB 28, 48 - DB 21h - DB "GUS CS4231 Codec MMX Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 12, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - DW 0 - -MixModeButton1 DW 2 - DW 13, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " MMX, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " MMX, Volume Ramped", 0 - -MixModeButton4 DW 2 - DW 8, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " MMX, Filtered", 0 - -VolumeTable DB 2 Dup (56) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - - -include nodebug.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Trace "GUSPnP MMX: SetMixMode" - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 14 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMMX - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectMMXFail - - Mov EAX, 1 - DB 0Fh, 0A2h ; CPUID - Test EDX, 800000h - JZ DetectMMXFail - - ClC - Ret - -DetectMMXFail: - StC - Ret - -EndP DetectMMX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Call DetectMMX - JC DetectWSSFailure - - Cmp IRQ, 0FFFFh - JE DetectWSSFailure - Cmp DMA, 0FFFFh - JE DetectWSSFailure - - Mov DX, BasePort - Cmp DX, 0FFFFh - JE DetectCardFindBasePort - - Call PingWSS - JNC CheckWSSOK - -DetectWSSFailure: - StC - Ret - -DetectCardFindBasePort: - Mov DX, 31Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 32Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 33Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 34Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 35Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 36Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 530h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 604h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0F40h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0E80h - Call PingWSS - JC DetectWSSFailure - -DetectWSSOK: - Mov BasePort, DX - -CheckWSSOK: ; Check for IRQ - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - FNSave [FPSave] - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB WSSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -WSSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Mov BX, DMASize ; BX = bytes required - Add DI, AX - - ShR BX, 1 - ; BX = samples required - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRstor [CS:FPSave] - - Pop ES - Pop DS - PopAD - IRet - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Trace "GUSPnP MMX: StopSound" - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Trace "GUSPnP MMX: StartSound" - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Trace "GUSPnP MMX: InitSound" - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, (DMABUFFERLENGTH*2)/16 + 5 - Mov BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Call UpdateSoundcardVariables - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Trace "GUSPnP MMX: SetStereoCall" - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - Trace "GUSPnP MMX: Driver Screen" - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - Push AX DX - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX AX - Ret - -EndP UpdatesoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - Call UpdateSoundcardVariables - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h -; Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: -; Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 - DW 3 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver, with GUS PnP detection, MMX mixing. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +OUTPUTFILTERENABLED EQU 0 + +FPSave DB 128 Dup (0) + +DMASize DW 2048 + +WSSMsg DB "GUS CS4231 Codec MMX", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "GUS CS4231 Codec MMX", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "GUS CS4231 Codec reinitialised", 0 + +DriverName DB "ITGUSMAX.MMX", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 4 +MixMode DW 0 +MixModeOffset DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 12 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 12 + DW Near Ptr MasterVolumeRight ; 13 + + DW 0 + + +WSSHeaderLine DW 10 + DB "GUS CS4231 Codec MMX Driver", 0 + +DriverText DW 1 + DB 28, 48 + DB 21h + DB "GUS CS4231 Codec MMX Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 12, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + DW 0 + +MixModeButton1 DW 2 + DW 13, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " MMX, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " MMX, Volume Ramped", 0 + +MixModeButton4 DW 2 + DW 8, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " MMX, Filtered", 0 + +VolumeTable DB 2 Dup (56) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + + +include nodebug.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Trace "GUSPnP MMX: SetMixMode" + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 14 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMMX + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectMMXFail + + Mov EAX, 1 + DB 0Fh, 0A2h ; CPUID + Test EDX, 800000h + JZ DetectMMXFail + + ClC + Ret + +DetectMMXFail: + StC + Ret + +EndP DetectMMX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Call DetectMMX + JC DetectWSSFailure + + Cmp IRQ, 0FFFFh + JE DetectWSSFailure + Cmp DMA, 0FFFFh + JE DetectWSSFailure + + Mov DX, BasePort + Cmp DX, 0FFFFh + JE DetectCardFindBasePort + + Call PingWSS + JNC CheckWSSOK + +DetectWSSFailure: + StC + Ret + +DetectCardFindBasePort: + Mov DX, 31Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 32Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 33Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 34Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 35Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 36Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 530h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 604h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0F40h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0E80h + Call PingWSS + JC DetectWSSFailure + +DetectWSSOK: + Mov BasePort, DX + +CheckWSSOK: ; Check for IRQ + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + FNSave [FPSave] + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB WSSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +WSSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Mov BX, DMASize ; BX = bytes required + Add DI, AX + + ShR BX, 1 + ; BX = samples required + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRstor [CS:FPSave] + + Pop ES + Pop DS + PopAD + IRet + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Trace "GUSPnP MMX: StopSound" + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Trace "GUSPnP MMX: StartSound" + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Trace "GUSPnP MMX: InitSound" + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, (DMABUFFERLENGTH*2)/16 + 5 + Mov BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Call UpdateSoundcardVariables + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Trace "GUSPnP MMX: SetStereoCall" + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + Trace "GUSPnP MMX: Driver Screen" + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + Push AX DX + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX AX + Ret + +EndP UpdatesoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + Call UpdateSoundcardVariables + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h +; Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: +; Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 + DW 3 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/GUSMIXDR.ASM b/SoundDrivers/GUSMIXDR.ASM index 853b5f5..365ed9b 100755 --- a/SoundDrivers/GUSMIXDR.ASM +++ b/SoundDrivers/GUSMIXDR.ASM @@ -1,2462 +1,2462 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 4096 - -ENDLOCATIONHIGH EQU 1Fh -ENDLOCATIONLOW EQU 0FE00h -HALFENDLOCATIONHIGH EQU 0Fh -HALFENDLOCATIONLOW EQU 0FE00h - -MIXRESOLUTION EQU 32 ; 32 bit mixing for the GUS -MIXTABLESIZE EQU 2*256*65 - -Voice0Position DD 0 -Voice1Position DD 0 - -GUSMsg DB "Gravis Ultrasound detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -GUSNoMemoryMsg DB "Gravis Ultrasound detected", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Gravis Ultrasound reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITGUSMIX.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITGUSMIX.DRV", 0 - -DriverName DB "ITGUSMIX.DRV", 0 -UltrasndString DB "ULTRASND" - -GUSMixTable Label Word - DW 44100, 41160, 38588, 36318, 34300, 32495, 30870, 29400, 28064 - DW 26844, 25725, 24696, 23746, 22867, 22050, 21290, 20580, 19916 - DW 19294 - -DSPVersion DW 0 -DSPIRQValue DB 0 -DSPDMAValue DB 0 -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -MixSpeed DW 44100 -GUSChannels DB 14 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -GUSRegisterSelect DW 0 -GUSVoiceSelect DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 8 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 -DMASize DW 4096 - -IMR DW 0 -OldIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -GUSScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr GUSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; 7 - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW 0 - -GUSHeaderLine DW 10 - DB "Gravis Ultrasound Mixed Driver", 0 - -DriverText DW 1 - DB 30, 48 - DB 21h - DB "Gravis Ultrasound Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MixModeText DW 1 - DB 2, 13 - DB 20h - DB "Mixing Mode", 0 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 15, 32, 17, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 18, 32, 20, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 21, 32, 23, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 24, 32, 26, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 28 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 30, 29, 32, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 33, 29, 35, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 36, 29, 38, 8 - DB 0 - DB " 75% Filter", 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 -MixBufferDestination DW 0 - -include dmanai.inc ; Non-auto-initialise DMA -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;*********************************************** - -Proc GUSDelay - - Push AX - Push DX - - Mov DX, 300h - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Pop DX - Pop AX - - Ret - -EndP GUSDelay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetGUS ; AX = baseport. - - Push AX - Push DX - - Mov DX, AX - Add DX, 103h ; Select register - - Mov AL, 4Ch ; Reset global register - Out DX, AL - - Add DL, 2 ; 8 bit data - Xor AL, AL - Out DX, AL ; Reset GUS! - - Call GUSDelay - Call GUSDelay - - Mov AL, 1 - Out DX, AL - - Call GUSDelay - Call GUSDelay - - Pop DX - Pop AX - - Ret - -EndP ResetGUS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - - Mov BX, 200 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 44100 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - ; OK.. find number of voices to - ; achieve desired mix speed. - Mov SI, Offset GUSMixTable - Mov BL, 14 - Mov CX, 32-14 - -GetSBMixConst2: - LodsW - Cmp AX, CX - JAE GetSBMixConst3 - - Inc BL - Loop GetSBMixConst2 - -GetSBMixConst3: - Mov GUSChannels, BL - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov SI, Offset ULTRASNDString - Mov CX, 8 - Call GetEnvironment ; Returns ES:DI, Carry if error - JC DetectCardError - - Xor DX, DX ; Baseport first. - -DetectCard1: - Mov AL, [ES:DI] - Inc DI - - Cmp AL, ',' - JE DetectCard2 - - Sub AL, '0' - JC DetectCardError - Cmp AL, '9' - JA DetectCardError - - ShL DX, 4 - Add DL, AL - Jmp DetectCard1 - -DetectCard2: - Cmp DX, 210h - JB DetectCardError - Cmp DX, 280h - JA DetectCardError - - Mov BasePort, DX - Add DX, 102h - Mov GUSVoiceSelect, DX - Inc DL - Mov GUSRegisterSelect, DX - - ; Get DMA - Xor DX, DX - -DetectCard3: - Mov AL, [ES:DI] - Inc DI - Cmp AL, ',' - JE DetectCard4 - - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCard3 - -DetectCard4: - Cmp DX, 7 - JA DetectCardError - - Mov DMA, DX - - Xor DX, DX - -DetectCard5: - Mov AL, [ES:DI] - Inc DI - Cmp AL, ',' - JE DetectCard6 - - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCard5 - -DetectCard6: - Cmp DX, 7 - JA DetectCardError - ; Wasted DMA.. - - ; IRQ.. - - Xor DX, DX - -DetectCard7: - Mov AL, [ES:DI] - Inc DI - Cmp AL, ',' - JE DetectCard8 - - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCard7 - -DetectCard8: - Cmp DX, 15 - JA DetectCardError - - Mov IRQ, DX - - Mov EAX, 'Jeff' - ClC - Ret - -DetectCardError: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GUSIRQHandler - - PushAD - Push DS - Push ES - - CLD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov AL, 20h - Cmp IRQ, 7 - JBE GUSIRQHandler1 - - Out 0A0h, AL - -GUSIRQHandler1: - Out 20h, AL - - Mov DX, BasePort - Add DL, 6 - In AL, DX - - Test AL, 20h - JZ GUSIRQHandlerEnd - - ; OK.. need to determine Cause type -GUSIRQAgain: - Mov DX, GUSRegisterSelect - Mov AL, 8Fh - Out DX, AL - Add DL, 2 - In AL, DX ; Bit 6 = waveramp IRQ - - Test AL, 80h - JZ GUSLoopIRQ - - Jmp GUSIRQHandlerEnd - -GUSLoopIRQ: ; Need to disable looping and - ; enable rollover. Set End address - ; to midpoint. - Xor MixBufferPos, 1 - JZ GUSRolloverIRQ - -; Mov MixBufferDestination, DMABUFFERLENGTH/16/2 - Mov MixBufferDestination, DMABUFFERLENGTH - - Mov DX, GUSVoiceSelect - Xor AL, AL - Out DX, AL - - Inc DX - Call GUSDelay - - Mov AL, 4 ; End address high - Out DX, AL - Mov AX, HALFENDLOCATIONHIGH - Inc DX - Out DX, AX - Dec DX - - Mov AL, 5 ; End address low - Out DX, AL - Mov AX, HALFENDLOCATIONLOW -; Cmp CS:Stereo, 0 -; JE HalfEndLocationMono -; -; Mov AX, HALFENDLOCATIONSTEREOLOW -; -; HalfEndLocationMono: - Inc DX - Out DX, AX - Dec DX - - Xor AL, AL - Out DX, AL - Mov AL, 4+32 ; 16-bit data, no loop, no IRQ. - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Mov AL, 0Dh - Out DX, AL - Mov AL, 3+4 ; Enable rollover - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Jmp GUSIRQEnd - -GUSRolloverIRQ: ; Need to disable rollover and - ; enable looping. Set End address - ; to endpoint. - Mov MixBufferDestination, 0 - - Mov DX, GUSVoiceSelect - Xor AL, AL - Out DX, AL - - Call GUSDelay - Inc DX - - Mov AL, 4 ; End address high - Out DX, AL - Mov AX, ENDLOCATIONHIGH - Inc DX - Out DX, AX - Dec DX - - Mov AL, 5 ; End location low - Out DX, AL - Mov AX, ENDLOCATIONLOW - -; Cmp Stereo, 0 -; JE EndLocationMono -; -; Mov AX, ENDLOCATIONSTEREOLOW -; -; EndLocationMono: - Inc DX - Out DX, AX - Dec DX - - Xor AL, AL - Out DX, AL - Mov AL, 4+8+32 ; 16-bit data, looping + Wavetable IRQ - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Mov AL, 0Dh - Out DX, AL - Mov AL, 3 ; Disable rollover - Add DL, 2 - Out DX, AL - Sub DL, 2 - -; Jmp GUSIRQAgain - -GUSIRQEnd: - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE GUSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -GUSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE GUSIRQHandler4 - Assume DS:Nothing - -GUSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -GUSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE GUSIRQHandler5 - - Mov DX, MixTransferRemaining - -GUSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB GUSIRQHandler6 - JE GUSIRQHFilter - - Cmp CS:Stereo, 0 - JE GUSIRQ3QFilterMono - -GUSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -GUSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL GUS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG GUS3QFilterStereoClip2 - -GUSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL GUS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG GUS3QFilterStereoClip4 - -GUSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ GUSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp GUSMixTransferEnd - -GUSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -GUSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL GUS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG GUS3QFilterMonoClip2 - -GUSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ GUSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp GUSMixTransferEnd - -GUSIRQHFilter: - Cmp CS:Stereo, 0 - JE GUSIRQHFilterMono - -GUSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -GUSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL GUSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG GUSHFilterStereoClip2 - -GUSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL GUSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG GUSHFilterStereoClip4 - -GUSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ GUSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp GUSMixTransferEnd - -GUSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -GUSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL GUSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG GUSHFilterMonoClip2 - -GUSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ GUSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp GUSMixTransferEnd - -GUSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL GUSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG GUSIRQHandlerClip2 - -GUSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ GUSIRQHandler6 - -GUSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ GUSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - ; DMA the data to MixBufferDestination - Comment ~ - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - Mov DX, GUSRegisterSelect - Mov AL, 42h ; DMA destination - Out DX, AL - Mov AX, MixBufferDestination - Inc DX - Out DX, AX - Dec DX - - Mov AL, 41h ; DMA control register - Out DX, AL - Mov AL, 1 - Cmp DMA, 4 - JB DMAType - - Or AL, 4 - -DMAType: - Add DL, 2 - Out DX, AL - - ~ - -; Comment ~ - - LDS SI, [ActualDMAPtr] - Mov DX, GUSRegisterSelect - - Mov AL, 44h - Out DX, AL ; High address - Xor AL, AL - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov DI, MixBufferDestination - Mov CX, DMASize - - Mov AL, 43h - Out DX, AL - Inc DX - -Output1: - Mov AX, DI - Out DX, AX - Add DL, 3 - - Mov AL, [SI] - Out DX, AL - - Sub DL, 3 - Inc SI - Inc DI - Dec CX - JNZ Output1 - -; ~ - - Call RestoreEMSPageFrame - -GUSIRQHandlerEnd: - Pop ES - Pop DS - PopAD - IRet - Assume DS:Nothing - -GUSIRQHandlerClip1: - Mov AX, 8000h - Jmp GUSIRQHandler7 - -GUSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp GUSIRQHandler7 - -GUSHFilterMonoClip1: - Mov AX, 8000h - Jmp GUSIRQHFilterMono2 - -GUSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp GUSIRQHFilterMono2 - -GUSHFilterStereoClip1: - Mov AX, 8000h - Jmp GUSIRQHFilterStereo2 - -GUSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp GUSIRQHFilterStereo2 - -GUSHFilterStereoClip3: - Mov AX, 8000h - Jmp GUSIRQHFilterStereo3 - -GUSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp GUSIRQHFilterStereo3 - -GUS3QFilterMonoClip1: - Mov AX, 8000h - Jmp GUSIRQ3QFilterMono2 - -GUS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp GUSIRQ3QFilterMono2 - -GUS3QFilterStereoClip1: - Mov AX, 8000h - Jmp GUSIRQ3QFilterStereo2 - -GUS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp GUSIRQ3QFilterStereo2 - -GUS3QFilterStereoClip3: - Mov AX, 8000h - Jmp GUSIRQ3QFilterStereo3 - -GUS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp GUSIRQ3QFilterStereo3 - -EndP GUSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset GUSIRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartGUS ; - - PushA - Push ES - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Mov AL, 1 - Out DX, AL - - Mov AX, DX - Call ResetGUS - - Mov DX, GUSRegisterSelect ; Tell the GUS how many voices - Mov AL, 0Eh ; to use - Out DX, AL - - Add DL, 2 ; DX = BasePort + 105h - Mov AL, GUSChannels - Dec AL - Or AL, 0C0h - Out DX, AL ; Number of Voices set - - ; Reset each voice - - Mov CX, 32 ; 32 voices to clear. - - Sub DL, 3 ; DX = Voice select register - -GUSResetVoice: - Mov AL, CL - Dec AL - Out DX, AL - - Inc DX ; DX = BasePort + 103h - Xor AL, AL ; Voice control register, 8 bit - Out DX, AL - - Add DL, 2 - Mov AL, 2 - Out DX, AL ; Stop voice - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Mov AL, 0Dh ; Volume Ramp. - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - - Mov AL, 6 ; Ramp rate - Out DX, AL - - Mov AL, 63 ; Ramp rate - Add DL, 2 - Out DX, AL - Sub DL, 2 - - - Mov AL, 9 ; Volume register, 16 bit - Out DX, AL - - Inc DX - Xor AX, AX - Out DX, AX ; No volume - Call GUSDelay - Out DX, AX - - Sub DL, 2 ; DX = BasePort + 102h = Voice select. - - Loop GUSResetVoice - - ; OK.. now... gotta clear memory from - ; 0->DMABUFFERLENGTH*2 - - Mov CX, DMABUFFERLENGTH*2 - Xor DI, DI ; DI = destination - - ClI - - Inc DX ; DX = register select - Mov AL, 44h - Out DX, AL - - Xor AL, AL - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 43h - Out DX, AL - Inc DX - -ClearGUSRAM: - Mov AX, DI ; Memory location low - Out DX, AX ; Memory location done. - - Xor AL, AL - Add DL, 3 - Out DX, AL - Sub DL, 3 - - Inc DI - Dec CX - JNZ ClearGUSRAM - - StI - ; OK.. enable interrupt - Mov DX, BasePort - Mov AL, 9 - Out DX, AL ; Enables DMA/IRQ - - Mov DX, GUSRegisterSelect - Mov AL, 4Ch - Out DX, AL - Add DL, 2 - Mov AL, 7 - Out DX, AL ; Enables IRQ - - ; Setup voices - ClI - Cmp Stereo, 0 - JE StartGUSMono - -StartGUSStereo: ; Uses voices 0 and 1 - Mov DX, GUSVoiceSelect - Xor AL, AL - Out DX, AL - Call GUSDelay - Inc DX - - Mov AL, 1 ; Freq control - Out DX, AL - Inc DX - Mov AX, 0000100000000000b - Out DX, AX - Dec DX - - Mov AL, 2 ; Starting location high - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 3 ; Starting location low - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 4 ; End location high - Out DX, AL - Mov AX, HALFENDLOCATIONHIGH - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 5 ; End location low - Out DX, AL - Mov AX, HALFENDLOCATIONLOW - Inc DX - Out DX, AX - Dec DX - - Mov AL, 9 ; Current volume - Out DX, AL - Mov AX, 0EFF0h - Inc DX - Out DX, AX - Call GUSDelay - Out DX, AX - Dec DX - - Mov AL, 0Ah ; Current location high - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Bh ; Current location low - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ch ; Pan position - Out DX, AL - Mov AL, 0 ; Full left. - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 0Dh ; Set rollover condition - Out DX, AL - Mov AL, 4+2+1 ; Rollover - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov DX, GUSVoiceSelect - Mov AL, 1 ; Voice 1 - Out DX, AL - Call GUSDelay - Inc DX - - Mov AL, 1 ; Freq control - Out DX, AL - Inc DX - Mov AX, 0000100000000000b - Out DX, AX - Dec DX - - Mov AL, 2 ; Starting location high - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 3 ; Starting location low - Out DX, AL - Mov AX, 0000001000000000b - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 4 ; End location high - Out DX, AL - Mov AX, 20h ; ENDLOCATIONHIGH - Inc DX - Out DX, AX - Dec DX - - Mov AL, 5 ; End location low - Out DX, AL - Mov AX, 0 ; ENDLOCATIONLOW - Inc DX - Out DX, AX - Dec DX - - Mov AL, 9 ; Current volume - Out DX, AL - Mov AX, 0EFF0h - Inc DX - Out DX, AX - Call GUSDelay - Out DX, AX - Dec DX - - Mov AL, 0Ah ; Current location high - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Bh ; Current location low - Out DX, AL - Mov AX, 0000001000000000b - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ch ; Pan position - Out DX, AL - Mov AL, 0Fh ; Full right - Add DL, 2 - Out DX, AL - Sub DL, 2 - ; start voices. - - Mov AL, 0Dh - Out DX, AL - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - CLI - - Mov DX, GUSVoiceSelect ; Select voice 0 - Xor AL, AL - Out DX, AL - -; Call GUSDelay - - Inc DX - Out DX, AL - Mov AL, 4+32 ; 16-bit data, IRQ enabled - Add DL, 2 - Out DX, AL - -; Call GUSDelay -; Out DX, AL - - Sub DL, 3 - - Mov AL, 1 ; Select voice 1 - Out DX, AL - -; Call GUSDelay - - Inc DX - Xor AL, AL - Out DX, AL - Mov AL, 4+8 ; 16-bit, Loop - Add DL, 2 - Out DX, AL - -; Call GUSDelay -; Out DX, AL - - Jmp StartGUSEnd - -StartGUSMono: ; Uses voice 0 - Mov DX, GUSVoiceSelect - Xor AL, AL - Out DX, AL - Call GUSDelay - Inc DX - - Mov AL, 1 ; Freq control - Out DX, AL - Inc DX - Mov AX, 0000010000000000b - Out DX, AX - Dec DX - - Mov AL, 2 ; Starting location high - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 3 ; Starting location low - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 4 ; End location high - Out DX, AL - Mov AX, HALFENDLOCATIONHIGH - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 5 ; End location low - Out DX, AL - Mov AX, HALFENDLOCATIONLOW - Inc DX - Out DX, AX - Dec DX - - Mov AL, 9 ; Current volume - Out DX, AL - Mov AX, 0EFF0h - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ah ; Current location high - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Bh ; Current location low - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ch ; Pan position - Out DX, AL - Mov AL, 8 ; Central. - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 0Dh ; Set rollover condition - Out DX, AL - Mov AL, 4+2+1 ; Rollover - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Xor AL, AL - Out DX, AL - Mov AL, 4+32 ; 16-bit data, IRQ enabled - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - -StartGUSEnd: - StI - - Pop ES - PopA - - Ret - - -EndP StartGUS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - -RelocationEnd: - Mov AX, BasePort - Call ResetGUS - - ; SetupMIDI - Mov DX, BasePort - Inc DH - Mov AL, 0FFh - Out DX, AL - Mov AL, 0FCh - Out DX, AL - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - ; Allocate MixSegment first - Mov AH, 48h - Mov BX, 3859+(DMABUFFERLENGTH*2)/16 - ; 3859 = (256*2*65+8*44100/(.4*31))/16 - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset GUSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, 3859 - Mov DMASegment, AX - - Call SetIRQ - Call GetSBMixConst - Call GetTempo - Call SetTempo - - Mov SI, Offset GUSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 200 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov AX, BasePort - Call ResetGUS - - Mov DX, BasePort - Inc DH - Mov AL, 0FFh - Out DX, AL ; Stop MIDI - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Mov DX, CS:GUSVoiceSelect - Xor AL, AL - Out DX, AL - Inc DX - Mov AL, 8Ah - Out DX, AL - Inc DX - In AX, DX - ShL EAX, 16 - Dec DX - Mov AL, 8Bh - OUt DX, AL - Inc DX - In AX, DX - ShR EAX, 9 - Mov CS:Voice0Position, EAX - - Mov DX, CS:GUSVoiceSelect - Mov AL, 1 - Out DX, AL - Inc DX - Mov AL, 8Ah - Out DX, AL - Inc DX - In AX, DX - ShL EAX, 16 - Dec DX - Mov AL, 8Bh - OUt DX, AL - Inc DX - In AX, DX - ShR EAX, 9 - Mov CS:Voice1Position, EAX - - Call [CS:UARTBufferEmpty] - JNC MIDIEnd - - Mov DX, [CS:BasePort] - Inc DH - In AL, DX - Test AL, 1 - JZ MIDIEnd - - Inc DX - In AL, DX - Cmp AL, 0F0h - JAE MIDIEnd - - Call [CS:UARTSend] - -MIDIEnd: - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov CS:Stereo, AL - Call StartGUS - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset GUSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 4096 + +ENDLOCATIONHIGH EQU 1Fh +ENDLOCATIONLOW EQU 0FE00h +HALFENDLOCATIONHIGH EQU 0Fh +HALFENDLOCATIONLOW EQU 0FE00h + +MIXRESOLUTION EQU 32 ; 32 bit mixing for the GUS +MIXTABLESIZE EQU 2*256*65 + +Voice0Position DD 0 +Voice1Position DD 0 + +GUSMsg DB "Gravis Ultrasound detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +GUSNoMemoryMsg DB "Gravis Ultrasound detected", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Gravis Ultrasound reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITGUSMIX.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITGUSMIX.DRV", 0 + +DriverName DB "ITGUSMIX.DRV", 0 +UltrasndString DB "ULTRASND" + +GUSMixTable Label Word + DW 44100, 41160, 38588, 36318, 34300, 32495, 30870, 29400, 28064 + DW 26844, 25725, 24696, 23746, 22867, 22050, 21290, 20580, 19916 + DW 19294 + +DSPVersion DW 0 +DSPIRQValue DB 0 +DSPDMAValue DB 0 +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +MixSpeed DW 44100 +GUSChannels DB 14 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +GUSRegisterSelect DW 0 +GUSVoiceSelect DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 8 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 +DMASize DW 4096 + +IMR DW 0 +OldIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +GUSScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr GUSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; 7 + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW 0 + +GUSHeaderLine DW 10 + DB "Gravis Ultrasound Mixed Driver", 0 + +DriverText DW 1 + DB 30, 48 + DB 21h + DB "Gravis Ultrasound Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MixModeText DW 1 + DB 2, 13 + DB 20h + DB "Mixing Mode", 0 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 15, 32, 17, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 18, 32, 20, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 21, 32, 23, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 24, 32, 26, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 28 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 30, 29, 32, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 33, 29, 35, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 36, 29, 38, 8 + DB 0 + DB " 75% Filter", 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 +MixBufferDestination DW 0 + +include dmanai.inc ; Non-auto-initialise DMA +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;*********************************************** + +Proc GUSDelay + + Push AX + Push DX + + Mov DX, 300h + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Pop DX + Pop AX + + Ret + +EndP GUSDelay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetGUS ; AX = baseport. + + Push AX + Push DX + + Mov DX, AX + Add DX, 103h ; Select register + + Mov AL, 4Ch ; Reset global register + Out DX, AL + + Add DL, 2 ; 8 bit data + Xor AL, AL + Out DX, AL ; Reset GUS! + + Call GUSDelay + Call GUSDelay + + Mov AL, 1 + Out DX, AL + + Call GUSDelay + Call GUSDelay + + Pop DX + Pop AX + + Ret + +EndP ResetGUS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + + Mov BX, 200 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 44100 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + ; OK.. find number of voices to + ; achieve desired mix speed. + Mov SI, Offset GUSMixTable + Mov BL, 14 + Mov CX, 32-14 + +GetSBMixConst2: + LodsW + Cmp AX, CX + JAE GetSBMixConst3 + + Inc BL + Loop GetSBMixConst2 + +GetSBMixConst3: + Mov GUSChannels, BL + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov SI, Offset ULTRASNDString + Mov CX, 8 + Call GetEnvironment ; Returns ES:DI, Carry if error + JC DetectCardError + + Xor DX, DX ; Baseport first. + +DetectCard1: + Mov AL, [ES:DI] + Inc DI + + Cmp AL, ',' + JE DetectCard2 + + Sub AL, '0' + JC DetectCardError + Cmp AL, '9' + JA DetectCardError + + ShL DX, 4 + Add DL, AL + Jmp DetectCard1 + +DetectCard2: + Cmp DX, 210h + JB DetectCardError + Cmp DX, 280h + JA DetectCardError + + Mov BasePort, DX + Add DX, 102h + Mov GUSVoiceSelect, DX + Inc DL + Mov GUSRegisterSelect, DX + + ; Get DMA + Xor DX, DX + +DetectCard3: + Mov AL, [ES:DI] + Inc DI + Cmp AL, ',' + JE DetectCard4 + + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCard3 + +DetectCard4: + Cmp DX, 7 + JA DetectCardError + + Mov DMA, DX + + Xor DX, DX + +DetectCard5: + Mov AL, [ES:DI] + Inc DI + Cmp AL, ',' + JE DetectCard6 + + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCard5 + +DetectCard6: + Cmp DX, 7 + JA DetectCardError + ; Wasted DMA.. + + ; IRQ.. + + Xor DX, DX + +DetectCard7: + Mov AL, [ES:DI] + Inc DI + Cmp AL, ',' + JE DetectCard8 + + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCard7 + +DetectCard8: + Cmp DX, 15 + JA DetectCardError + + Mov IRQ, DX + + Mov EAX, 'Jeff' + ClC + Ret + +DetectCardError: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GUSIRQHandler + + PushAD + Push DS + Push ES + + CLD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov AL, 20h + Cmp IRQ, 7 + JBE GUSIRQHandler1 + + Out 0A0h, AL + +GUSIRQHandler1: + Out 20h, AL + + Mov DX, BasePort + Add DL, 6 + In AL, DX + + Test AL, 20h + JZ GUSIRQHandlerEnd + + ; OK.. need to determine Cause type +GUSIRQAgain: + Mov DX, GUSRegisterSelect + Mov AL, 8Fh + Out DX, AL + Add DL, 2 + In AL, DX ; Bit 6 = waveramp IRQ + + Test AL, 80h + JZ GUSLoopIRQ + + Jmp GUSIRQHandlerEnd + +GUSLoopIRQ: ; Need to disable looping and + ; enable rollover. Set End address + ; to midpoint. + Xor MixBufferPos, 1 + JZ GUSRolloverIRQ + +; Mov MixBufferDestination, DMABUFFERLENGTH/16/2 + Mov MixBufferDestination, DMABUFFERLENGTH + + Mov DX, GUSVoiceSelect + Xor AL, AL + Out DX, AL + + Inc DX + Call GUSDelay + + Mov AL, 4 ; End address high + Out DX, AL + Mov AX, HALFENDLOCATIONHIGH + Inc DX + Out DX, AX + Dec DX + + Mov AL, 5 ; End address low + Out DX, AL + Mov AX, HALFENDLOCATIONLOW +; Cmp CS:Stereo, 0 +; JE HalfEndLocationMono +; +; Mov AX, HALFENDLOCATIONSTEREOLOW +; +; HalfEndLocationMono: + Inc DX + Out DX, AX + Dec DX + + Xor AL, AL + Out DX, AL + Mov AL, 4+32 ; 16-bit data, no loop, no IRQ. + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Mov AL, 0Dh + Out DX, AL + Mov AL, 3+4 ; Enable rollover + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Jmp GUSIRQEnd + +GUSRolloverIRQ: ; Need to disable rollover and + ; enable looping. Set End address + ; to endpoint. + Mov MixBufferDestination, 0 + + Mov DX, GUSVoiceSelect + Xor AL, AL + Out DX, AL + + Call GUSDelay + Inc DX + + Mov AL, 4 ; End address high + Out DX, AL + Mov AX, ENDLOCATIONHIGH + Inc DX + Out DX, AX + Dec DX + + Mov AL, 5 ; End location low + Out DX, AL + Mov AX, ENDLOCATIONLOW + +; Cmp Stereo, 0 +; JE EndLocationMono +; +; Mov AX, ENDLOCATIONSTEREOLOW +; +; EndLocationMono: + Inc DX + Out DX, AX + Dec DX + + Xor AL, AL + Out DX, AL + Mov AL, 4+8+32 ; 16-bit data, looping + Wavetable IRQ + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Mov AL, 0Dh + Out DX, AL + Mov AL, 3 ; Disable rollover + Add DL, 2 + Out DX, AL + Sub DL, 2 + +; Jmp GUSIRQAgain + +GUSIRQEnd: + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE GUSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +GUSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE GUSIRQHandler4 + Assume DS:Nothing + +GUSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +GUSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE GUSIRQHandler5 + + Mov DX, MixTransferRemaining + +GUSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB GUSIRQHandler6 + JE GUSIRQHFilter + + Cmp CS:Stereo, 0 + JE GUSIRQ3QFilterMono + +GUSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +GUSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL GUS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG GUS3QFilterStereoClip2 + +GUSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL GUS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG GUS3QFilterStereoClip4 + +GUSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ GUSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp GUSMixTransferEnd + +GUSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +GUSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL GUS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG GUS3QFilterMonoClip2 + +GUSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ GUSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp GUSMixTransferEnd + +GUSIRQHFilter: + Cmp CS:Stereo, 0 + JE GUSIRQHFilterMono + +GUSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +GUSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL GUSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG GUSHFilterStereoClip2 + +GUSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL GUSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG GUSHFilterStereoClip4 + +GUSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ GUSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp GUSMixTransferEnd + +GUSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +GUSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL GUSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG GUSHFilterMonoClip2 + +GUSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ GUSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp GUSMixTransferEnd + +GUSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL GUSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG GUSIRQHandlerClip2 + +GUSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ GUSIRQHandler6 + +GUSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ GUSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + ; DMA the data to MixBufferDestination + Comment ~ + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + Mov DX, GUSRegisterSelect + Mov AL, 42h ; DMA destination + Out DX, AL + Mov AX, MixBufferDestination + Inc DX + Out DX, AX + Dec DX + + Mov AL, 41h ; DMA control register + Out DX, AL + Mov AL, 1 + Cmp DMA, 4 + JB DMAType + + Or AL, 4 + +DMAType: + Add DL, 2 + Out DX, AL + + ~ + +; Comment ~ + + LDS SI, [ActualDMAPtr] + Mov DX, GUSRegisterSelect + + Mov AL, 44h + Out DX, AL ; High address + Xor AL, AL + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov DI, MixBufferDestination + Mov CX, DMASize + + Mov AL, 43h + Out DX, AL + Inc DX + +Output1: + Mov AX, DI + Out DX, AX + Add DL, 3 + + Mov AL, [SI] + Out DX, AL + + Sub DL, 3 + Inc SI + Inc DI + Dec CX + JNZ Output1 + +; ~ + + Call RestoreEMSPageFrame + +GUSIRQHandlerEnd: + Pop ES + Pop DS + PopAD + IRet + Assume DS:Nothing + +GUSIRQHandlerClip1: + Mov AX, 8000h + Jmp GUSIRQHandler7 + +GUSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp GUSIRQHandler7 + +GUSHFilterMonoClip1: + Mov AX, 8000h + Jmp GUSIRQHFilterMono2 + +GUSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp GUSIRQHFilterMono2 + +GUSHFilterStereoClip1: + Mov AX, 8000h + Jmp GUSIRQHFilterStereo2 + +GUSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp GUSIRQHFilterStereo2 + +GUSHFilterStereoClip3: + Mov AX, 8000h + Jmp GUSIRQHFilterStereo3 + +GUSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp GUSIRQHFilterStereo3 + +GUS3QFilterMonoClip1: + Mov AX, 8000h + Jmp GUSIRQ3QFilterMono2 + +GUS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp GUSIRQ3QFilterMono2 + +GUS3QFilterStereoClip1: + Mov AX, 8000h + Jmp GUSIRQ3QFilterStereo2 + +GUS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp GUSIRQ3QFilterStereo2 + +GUS3QFilterStereoClip3: + Mov AX, 8000h + Jmp GUSIRQ3QFilterStereo3 + +GUS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp GUSIRQ3QFilterStereo3 + +EndP GUSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset GUSIRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartGUS ; + + PushA + Push ES + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Mov AL, 1 + Out DX, AL + + Mov AX, DX + Call ResetGUS + + Mov DX, GUSRegisterSelect ; Tell the GUS how many voices + Mov AL, 0Eh ; to use + Out DX, AL + + Add DL, 2 ; DX = BasePort + 105h + Mov AL, GUSChannels + Dec AL + Or AL, 0C0h + Out DX, AL ; Number of Voices set + + ; Reset each voice + + Mov CX, 32 ; 32 voices to clear. + + Sub DL, 3 ; DX = Voice select register + +GUSResetVoice: + Mov AL, CL + Dec AL + Out DX, AL + + Inc DX ; DX = BasePort + 103h + Xor AL, AL ; Voice control register, 8 bit + Out DX, AL + + Add DL, 2 + Mov AL, 2 + Out DX, AL ; Stop voice + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Mov AL, 0Dh ; Volume Ramp. + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + + Mov AL, 6 ; Ramp rate + Out DX, AL + + Mov AL, 63 ; Ramp rate + Add DL, 2 + Out DX, AL + Sub DL, 2 + + + Mov AL, 9 ; Volume register, 16 bit + Out DX, AL + + Inc DX + Xor AX, AX + Out DX, AX ; No volume + Call GUSDelay + Out DX, AX + + Sub DL, 2 ; DX = BasePort + 102h = Voice select. + + Loop GUSResetVoice + + ; OK.. now... gotta clear memory from + ; 0->DMABUFFERLENGTH*2 + + Mov CX, DMABUFFERLENGTH*2 + Xor DI, DI ; DI = destination + + ClI + + Inc DX ; DX = register select + Mov AL, 44h + Out DX, AL + + Xor AL, AL + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 43h + Out DX, AL + Inc DX + +ClearGUSRAM: + Mov AX, DI ; Memory location low + Out DX, AX ; Memory location done. + + Xor AL, AL + Add DL, 3 + Out DX, AL + Sub DL, 3 + + Inc DI + Dec CX + JNZ ClearGUSRAM + + StI + ; OK.. enable interrupt + Mov DX, BasePort + Mov AL, 9 + Out DX, AL ; Enables DMA/IRQ + + Mov DX, GUSRegisterSelect + Mov AL, 4Ch + Out DX, AL + Add DL, 2 + Mov AL, 7 + Out DX, AL ; Enables IRQ + + ; Setup voices + ClI + Cmp Stereo, 0 + JE StartGUSMono + +StartGUSStereo: ; Uses voices 0 and 1 + Mov DX, GUSVoiceSelect + Xor AL, AL + Out DX, AL + Call GUSDelay + Inc DX + + Mov AL, 1 ; Freq control + Out DX, AL + Inc DX + Mov AX, 0000100000000000b + Out DX, AX + Dec DX + + Mov AL, 2 ; Starting location high + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 3 ; Starting location low + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 4 ; End location high + Out DX, AL + Mov AX, HALFENDLOCATIONHIGH + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 5 ; End location low + Out DX, AL + Mov AX, HALFENDLOCATIONLOW + Inc DX + Out DX, AX + Dec DX + + Mov AL, 9 ; Current volume + Out DX, AL + Mov AX, 0EFF0h + Inc DX + Out DX, AX + Call GUSDelay + Out DX, AX + Dec DX + + Mov AL, 0Ah ; Current location high + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Bh ; Current location low + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ch ; Pan position + Out DX, AL + Mov AL, 0 ; Full left. + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 0Dh ; Set rollover condition + Out DX, AL + Mov AL, 4+2+1 ; Rollover + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov DX, GUSVoiceSelect + Mov AL, 1 ; Voice 1 + Out DX, AL + Call GUSDelay + Inc DX + + Mov AL, 1 ; Freq control + Out DX, AL + Inc DX + Mov AX, 0000100000000000b + Out DX, AX + Dec DX + + Mov AL, 2 ; Starting location high + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 3 ; Starting location low + Out DX, AL + Mov AX, 0000001000000000b + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 4 ; End location high + Out DX, AL + Mov AX, 20h ; ENDLOCATIONHIGH + Inc DX + Out DX, AX + Dec DX + + Mov AL, 5 ; End location low + Out DX, AL + Mov AX, 0 ; ENDLOCATIONLOW + Inc DX + Out DX, AX + Dec DX + + Mov AL, 9 ; Current volume + Out DX, AL + Mov AX, 0EFF0h + Inc DX + Out DX, AX + Call GUSDelay + Out DX, AX + Dec DX + + Mov AL, 0Ah ; Current location high + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Bh ; Current location low + Out DX, AL + Mov AX, 0000001000000000b + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ch ; Pan position + Out DX, AL + Mov AL, 0Fh ; Full right + Add DL, 2 + Out DX, AL + Sub DL, 2 + ; start voices. + + Mov AL, 0Dh + Out DX, AL + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + CLI + + Mov DX, GUSVoiceSelect ; Select voice 0 + Xor AL, AL + Out DX, AL + +; Call GUSDelay + + Inc DX + Out DX, AL + Mov AL, 4+32 ; 16-bit data, IRQ enabled + Add DL, 2 + Out DX, AL + +; Call GUSDelay +; Out DX, AL + + Sub DL, 3 + + Mov AL, 1 ; Select voice 1 + Out DX, AL + +; Call GUSDelay + + Inc DX + Xor AL, AL + Out DX, AL + Mov AL, 4+8 ; 16-bit, Loop + Add DL, 2 + Out DX, AL + +; Call GUSDelay +; Out DX, AL + + Jmp StartGUSEnd + +StartGUSMono: ; Uses voice 0 + Mov DX, GUSVoiceSelect + Xor AL, AL + Out DX, AL + Call GUSDelay + Inc DX + + Mov AL, 1 ; Freq control + Out DX, AL + Inc DX + Mov AX, 0000010000000000b + Out DX, AX + Dec DX + + Mov AL, 2 ; Starting location high + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 3 ; Starting location low + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 4 ; End location high + Out DX, AL + Mov AX, HALFENDLOCATIONHIGH + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 5 ; End location low + Out DX, AL + Mov AX, HALFENDLOCATIONLOW + Inc DX + Out DX, AX + Dec DX + + Mov AL, 9 ; Current volume + Out DX, AL + Mov AX, 0EFF0h + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ah ; Current location high + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Bh ; Current location low + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ch ; Pan position + Out DX, AL + Mov AL, 8 ; Central. + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 0Dh ; Set rollover condition + Out DX, AL + Mov AL, 4+2+1 ; Rollover + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Xor AL, AL + Out DX, AL + Mov AL, 4+32 ; 16-bit data, IRQ enabled + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + +StartGUSEnd: + StI + + Pop ES + PopA + + Ret + + +EndP StartGUS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + +RelocationEnd: + Mov AX, BasePort + Call ResetGUS + + ; SetupMIDI + Mov DX, BasePort + Inc DH + Mov AL, 0FFh + Out DX, AL + Mov AL, 0FCh + Out DX, AL + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + ; Allocate MixSegment first + Mov AH, 48h + Mov BX, 3859+(DMABUFFERLENGTH*2)/16 + ; 3859 = (256*2*65+8*44100/(.4*31))/16 + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset GUSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, 3859 + Mov DMASegment, AX + + Call SetIRQ + Call GetSBMixConst + Call GetTempo + Call SetTempo + + Mov SI, Offset GUSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 200 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov AX, BasePort + Call ResetGUS + + Mov DX, BasePort + Inc DH + Mov AL, 0FFh + Out DX, AL ; Stop MIDI + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Mov DX, CS:GUSVoiceSelect + Xor AL, AL + Out DX, AL + Inc DX + Mov AL, 8Ah + Out DX, AL + Inc DX + In AX, DX + ShL EAX, 16 + Dec DX + Mov AL, 8Bh + OUt DX, AL + Inc DX + In AX, DX + ShR EAX, 9 + Mov CS:Voice0Position, EAX + + Mov DX, CS:GUSVoiceSelect + Mov AL, 1 + Out DX, AL + Inc DX + Mov AL, 8Ah + Out DX, AL + Inc DX + In AX, DX + ShL EAX, 16 + Dec DX + Mov AL, 8Bh + OUt DX, AL + Inc DX + In AX, DX + ShR EAX, 9 + Mov CS:Voice1Position, EAX + + Call [CS:UARTBufferEmpty] + JNC MIDIEnd + + Mov DX, [CS:BasePort] + Inc DH + In AL, DX + Test AL, 1 + JZ MIDIEnd + + Inc DX + In AL, DX + Cmp AL, 0F0h + JAE MIDIEnd + + Call [CS:UARTSend] + +MIDIEnd: + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov CS:Stereo, AL + Call StartGUS + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset GUSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/GUSNRAMP.INC b/SoundDrivers/GUSNRAMP.INC index 02020e2..8caab46 100755 --- a/SoundDrivers/GUSNRAMP.INC +++ b/SoundDrivers/GUSNRAMP.INC @@ -1,27 +1,27 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetGUSVolume ; BX = new volume - - ; To do: - ; 1) Set ramp start - ; 2) Set ramp end - ; 3) Set current volume - ; 4) Start ramp - ; 5) Save new volume. - - Mov AL, 9 - Out DX, AL - - Add BX, BX - Mov AX, [CS:GUSVolumeTable+BX] - Inc DX - Out DX, AX - Call GUSDelay - Out DX, AX - Dec DX - - Ret - -EndP SetGUSVolume - - +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetGUSVolume ; BX = new volume + + ; To do: + ; 1) Set ramp start + ; 2) Set ramp end + ; 3) Set current volume + ; 4) Start ramp + ; 5) Save new volume. + + Mov AL, 9 + Out DX, AL + + Add BX, BX + Mov AX, [CS:GUSVolumeTable+BX] + Inc DX + Out DX, AX + Call GUSDelay + Out DX, AX + Dec DX + + Ret + +EndP SetGUSVolume + + diff --git a/SoundDrivers/GUSNRIC.INC b/SoundDrivers/GUSNRIC.INC index 3863e2f..f38f982 100755 --- a/SoundDrivers/GUSNRIC.INC +++ b/SoundDrivers/GUSNRIC.INC @@ -1,415 +1,415 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetGUSRegisters ; Given DS:SI, CX - - Mov ES, CS:SongDataArea - - Push CX - Push SI - - Xor AX, AX - -GetOffsetLoop: - Push AX - Push CX - - Mov DX, GUSVoiceSelect - Out DX, AL ; OK.. now to play with this - ; voice. - Call GUSDelay - - Inc DL ; DX = select rego - - Mov BX, [SI] - Test BH, 2 - JZ GetOffsetLoop2 - - Mov BX, 200h - Mov [SI], BX - -GetOffsetLoop2: - Test BL, 1 ; Channel not on! - JZ GetOffsetLoop1 - Test BH, 1 - JZ GetOffsetLoop3 ; Prev 1. - - Xor BX, BX - Call SetGUSVolume - - Mov AL, 80h - Out DX, AL - Add DL, 2 - In AL, DX - Sub DL, 2 - Mov AH, AL - And AX, 400h - Out DX, AL ; AL = 0 (Mode control) - Mov AL, 3 - Or AL, AH - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Jmp GetOffsetLoop1 - -GetOffsetLoop3: - Mov EAX, [SI+4Ch] - Mov [SI+2Ch], EAX - - Mov AL, 8Ah - Out DX, AL - - Inc DX - In AX, DX - Dec DX - - And AH, 31 - ShL EAX, 16 ; Load high part of EAX - - Mov AL, 8Bh - Out DX, AL - Inc DX - In AX, DX - ; EAX = 000OOOOO OOOOOOOO OOOOOOOF FFFFFFFF - ; Need: 00000000 0000OOOO OOOOOOOO OOOOOOOO - - ShR EAX, 9 - ; EAX contains current loc. - ; Convert to Offset (in sample) - MovZX EBX, Byte Ptr [SI+36h] - Sub EAX, [CS:GUSDataTable+EBX*4] - Push CX - - Mov CL, CS:Compress - ShL EAX, CL - - Pop CX - Mov [SI+4Ch], EAX - -GetOffsetLoop1: - Add SI, SLAVECHANNELSIZE - - Pop CX - Pop AX - - Inc AX - Loop GetOffsetLoop - - Pop SI - Pop CX - - Xor AX, AX - -SetGUSRegisters1: - Push AX - Push CX - - Mov DX, GUSVoiceSelect - Out DX, AL ; OK.. now to play with this - ; voice. - Call GUSDelay - - Mov CX, [SI] ; CX = flags. - Inc DL ; DX = select rego - -SetGUSRegisters21: - Test CL, 32 ; Frequency change - JZ SetGUSRegisters7 - - Push DX - - Mov EAX, [SI+10h] ; EAX = freq. - - Push CX - Mov CL, CS:Compress - ShR EAX, CL - Pop CX - - Xor EDX, EDX - MovZX EBX, MixSpeed - - Div EBX ; EAX = I portion. - - Test EAX, Not 63 - JNZ SetGUSRegisters6 - - Push EAX - - Xor EAX, EAX - Div EBX - - Pop EBX ; EBX:EAX = IIII FFFF etc. - - SHRD EAX, EBX, 6 - - ; Have: IIIIIIII IIIIIIII FFFFFFFF FFFFFFFF - ; Req: IIIIIIFF FFFFFFF0 - - Pop DX - Mov AL, 1 - Out DX, AL - - ShR EAX, 16 - Add AX, 1 - SBB AX, 0 ; Just in case! - And AX, Not 1 - - Inc DX - Out DX, AX - Dec DX - - Jmp SetGUSRegisters7 - -SetGUSRegisters6: - Mov CH, 2 ; Signify to turn off channel - Pop DX - -SetGUSRegisters7: - MovZX BX, Byte Ptr [SI+36h] ; BX = sample number. - Cmp BL, 99 - JA SetGUSRegisters20 - - ShL BX, 2 ; GUSDataTable+BX = position - - Cmp DWord Ptr [CS:GUSDataTable+BX], 0FFFFFFFFh - JNE SetGUSRegisters10 - -SetGUSRegisters20: - Mov CH, 2 - Jmp SetGUSRegisters9 - -SetGUSRegisters10: - Test CH, 5 ; Loop changed?!??!? - JZ SetGUSRegisters8 - - Mov AL, 3 ; Starting location low. - Out DX, AL - - Mov EAX, [SI+40h] - Call GUSGetAddress - - ; Reqd: ...OOOOO OOOOOOOO OOOOOOOI III..... - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 2 ; Starting location high - Out DX, AL - - ShR EAX, 16 - Inc DX - Out DX, AX - Dec DX - - ; Ending location... - Mov AL, 5 ; Ending location low - Out DX, AL - - Mov EAX, [SI+44h] - Call GUSGetAddress - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 4 ; Ending location high - Out DX, AL - - SHR EAX, 16 - Inc DX - Out DX, AX - Dec DX - -SetGUSRegisters8: - Test CH, 1 ; Do Current position? - JZ SetGUSRegisters9 - - Mov AL, 0Bh ; Current location LOW - Out DX, AL - - Mov EAX, [SI+4Ch] - Mov [SI+2Ch], EAX - - ; EAX = OOOOOOOO OOOOOOOO OOOOOOOO OOOOOOOO - ; Req: xxxOOOOO OOOOOOOO OOOOOOOF FFFFFFFF - Call GUSGetAddress - - Mov DI, AX - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ah ; Current location HIGH - Out DX, AL - - SHR EAX, 16 - Inc DX - Out DX, AX - Call GUSDelay - Out DX, AX - Dec DX - - Mov AL, 0Bh - Out DX, AL - - Mov AX, DI - Inc DX - Out DX, AX - Dec DX - -SetGUSRegisters9: - Test CL, 64 ; New volume?? - JZ SetGUSPanning - -SetGUSRegisters23: - Xor BX, BX - Test CH, 8 - JNZ SetGUSRegistersMuted - - Mov BL, Byte Ptr [SI+20h] ; BL = volume, 0->128 - -SetGUSRegistersMuted: - Call SetGUSVolume - - -SetGUSPanning: - Test CH, 128 ; New panning? - JZ SetGUSRegisters5 - - Mov AL, 0Ch ; Set panning. - Out DX, AL - - Test CS:Stereo, 1 - JZ SetGUSRegisters3 - - Mov AL, [SI+37h] - Cmp AL, 100 - JNE SetGUSRegisters4 - -SetGUSRegisters3: - Mov AL, 32 ; Surround goes to mono :( - -SetGUSRegisters4: ; AL = 0->64 - ShR AL, 1 ; AL = 0->32 - Sub AL, 1 - AdC AL, 0 ; AL = 0->31 - ShR AL, 1 - - Add DL, 2 - Out DX, AL - Sub DL, 2 - -SetGUSRegisters5: - ; Now for control register. - ; If CH | 2, then turn rego OFF - ; If CH | 5, then turn rego ON - ; If CL | 1, then check channel - Test CH, 2 - JNZ SetGUSRegisters11 - - Test CH, 5 - JNZ SetGUSRegisters12 - - Test CL, 1 - JZ SetGUSRegisters13 - - Mov AL, 80h ; Read voice control - Out DX, AL - - Add DL, 2 - In AL, DX - Sub DL, 2 - - Test AL, 1 - JZ SetGUSRegisters13 - - Xor BX, BX - Call SetGUSVolume - - Jmp SetGUSRegisters14 - -SetGUSRegisters11: - ; Turn off. - Xor AL, AL - Out DX, AL ; AL = 0 (Mode control) - Mov AL, 2 - Add DL, 2 - - Mov AH, [SI+18h] ; 16 bit? - Add AH, AH - Or AL, AH - - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Xor BX, BX - Call SetGUSVolume - -SetGUSRegisters14: - Test CL, 1 - JZ SetGUSRegisters13 - - Xor CX, CX ; Turn off channel - Test Byte Ptr [SI+3Ah], 80h - JNZ SetGUSRegisters13 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - - Jmp SetGUSRegisters13 - -SetGUSRegisters12: ; Turn on - Xor AL, AL - Out DX, AL - - Mov AL, [SI+0Ah] - - Cmp CS:Convert16To8Bit, 0 - JNZ SetGUSRegistersNo16Bit - - Mov AH, [SI+18h] ; 16 bit? - Add AH, AH - Or AL, AH - -SetGUSRegistersNo16Bit: - Test CL, 1 - JNZ SetGUSRegisters15 - - Mov AL, 2 - Xor CX, CX - -SetGUSRegisters15: - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - -SetGUSRegisters13: - And CX, 0111100010011111b ; Turns off: - ; 1) Freq, pan & vol recalc - ; 2) New note/note stop/loop cha - - Mov [SI], CX - - Add SI, SLAVECHANNELSIZE - -; Call CheckMIDI - - Pop CX - Pop AX - - Inc AX - Dec CX - JNZ SetGUSRegisters1 - - Ret - - -EndP SetGUSRegisters - +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetGUSRegisters ; Given DS:SI, CX + + Mov ES, CS:SongDataArea + + Push CX + Push SI + + Xor AX, AX + +GetOffsetLoop: + Push AX + Push CX + + Mov DX, GUSVoiceSelect + Out DX, AL ; OK.. now to play with this + ; voice. + Call GUSDelay + + Inc DL ; DX = select rego + + Mov BX, [SI] + Test BH, 2 + JZ GetOffsetLoop2 + + Mov BX, 200h + Mov [SI], BX + +GetOffsetLoop2: + Test BL, 1 ; Channel not on! + JZ GetOffsetLoop1 + Test BH, 1 + JZ GetOffsetLoop3 ; Prev 1. + + Xor BX, BX + Call SetGUSVolume + + Mov AL, 80h + Out DX, AL + Add DL, 2 + In AL, DX + Sub DL, 2 + Mov AH, AL + And AX, 400h + Out DX, AL ; AL = 0 (Mode control) + Mov AL, 3 + Or AL, AH + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Jmp GetOffsetLoop1 + +GetOffsetLoop3: + Mov EAX, [SI+4Ch] + Mov [SI+2Ch], EAX + + Mov AL, 8Ah + Out DX, AL + + Inc DX + In AX, DX + Dec DX + + And AH, 31 + ShL EAX, 16 ; Load high part of EAX + + Mov AL, 8Bh + Out DX, AL + Inc DX + In AX, DX + ; EAX = 000OOOOO OOOOOOOO OOOOOOOF FFFFFFFF + ; Need: 00000000 0000OOOO OOOOOOOO OOOOOOOO + + ShR EAX, 9 + ; EAX contains current loc. + ; Convert to Offset (in sample) + MovZX EBX, Byte Ptr [SI+36h] + Sub EAX, [CS:GUSDataTable+EBX*4] + Push CX + + Mov CL, CS:Compress + ShL EAX, CL + + Pop CX + Mov [SI+4Ch], EAX + +GetOffsetLoop1: + Add SI, SLAVECHANNELSIZE + + Pop CX + Pop AX + + Inc AX + Loop GetOffsetLoop + + Pop SI + Pop CX + + Xor AX, AX + +SetGUSRegisters1: + Push AX + Push CX + + Mov DX, GUSVoiceSelect + Out DX, AL ; OK.. now to play with this + ; voice. + Call GUSDelay + + Mov CX, [SI] ; CX = flags. + Inc DL ; DX = select rego + +SetGUSRegisters21: + Test CL, 32 ; Frequency change + JZ SetGUSRegisters7 + + Push DX + + Mov EAX, [SI+10h] ; EAX = freq. + + Push CX + Mov CL, CS:Compress + ShR EAX, CL + Pop CX + + Xor EDX, EDX + MovZX EBX, MixSpeed + + Div EBX ; EAX = I portion. + + Test EAX, Not 63 + JNZ SetGUSRegisters6 + + Push EAX + + Xor EAX, EAX + Div EBX + + Pop EBX ; EBX:EAX = IIII FFFF etc. + + SHRD EAX, EBX, 6 + + ; Have: IIIIIIII IIIIIIII FFFFFFFF FFFFFFFF + ; Req: IIIIIIFF FFFFFFF0 + + Pop DX + Mov AL, 1 + Out DX, AL + + ShR EAX, 16 + Add AX, 1 + SBB AX, 0 ; Just in case! + And AX, Not 1 + + Inc DX + Out DX, AX + Dec DX + + Jmp SetGUSRegisters7 + +SetGUSRegisters6: + Mov CH, 2 ; Signify to turn off channel + Pop DX + +SetGUSRegisters7: + MovZX BX, Byte Ptr [SI+36h] ; BX = sample number. + Cmp BL, 99 + JA SetGUSRegisters20 + + ShL BX, 2 ; GUSDataTable+BX = position + + Cmp DWord Ptr [CS:GUSDataTable+BX], 0FFFFFFFFh + JNE SetGUSRegisters10 + +SetGUSRegisters20: + Mov CH, 2 + Jmp SetGUSRegisters9 + +SetGUSRegisters10: + Test CH, 5 ; Loop changed?!??!? + JZ SetGUSRegisters8 + + Mov AL, 3 ; Starting location low. + Out DX, AL + + Mov EAX, [SI+40h] + Call GUSGetAddress + + ; Reqd: ...OOOOO OOOOOOOO OOOOOOOI III..... + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 2 ; Starting location high + Out DX, AL + + ShR EAX, 16 + Inc DX + Out DX, AX + Dec DX + + ; Ending location... + Mov AL, 5 ; Ending location low + Out DX, AL + + Mov EAX, [SI+44h] + Call GUSGetAddress + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 4 ; Ending location high + Out DX, AL + + SHR EAX, 16 + Inc DX + Out DX, AX + Dec DX + +SetGUSRegisters8: + Test CH, 1 ; Do Current position? + JZ SetGUSRegisters9 + + Mov AL, 0Bh ; Current location LOW + Out DX, AL + + Mov EAX, [SI+4Ch] + Mov [SI+2Ch], EAX + + ; EAX = OOOOOOOO OOOOOOOO OOOOOOOO OOOOOOOO + ; Req: xxxOOOOO OOOOOOOO OOOOOOOF FFFFFFFF + Call GUSGetAddress + + Mov DI, AX + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ah ; Current location HIGH + Out DX, AL + + SHR EAX, 16 + Inc DX + Out DX, AX + Call GUSDelay + Out DX, AX + Dec DX + + Mov AL, 0Bh + Out DX, AL + + Mov AX, DI + Inc DX + Out DX, AX + Dec DX + +SetGUSRegisters9: + Test CL, 64 ; New volume?? + JZ SetGUSPanning + +SetGUSRegisters23: + Xor BX, BX + Test CH, 8 + JNZ SetGUSRegistersMuted + + Mov BL, Byte Ptr [SI+20h] ; BL = volume, 0->128 + +SetGUSRegistersMuted: + Call SetGUSVolume + + +SetGUSPanning: + Test CH, 128 ; New panning? + JZ SetGUSRegisters5 + + Mov AL, 0Ch ; Set panning. + Out DX, AL + + Test CS:Stereo, 1 + JZ SetGUSRegisters3 + + Mov AL, [SI+37h] + Cmp AL, 100 + JNE SetGUSRegisters4 + +SetGUSRegisters3: + Mov AL, 32 ; Surround goes to mono :( + +SetGUSRegisters4: ; AL = 0->64 + ShR AL, 1 ; AL = 0->32 + Sub AL, 1 + AdC AL, 0 ; AL = 0->31 + ShR AL, 1 + + Add DL, 2 + Out DX, AL + Sub DL, 2 + +SetGUSRegisters5: + ; Now for control register. + ; If CH | 2, then turn rego OFF + ; If CH | 5, then turn rego ON + ; If CL | 1, then check channel + Test CH, 2 + JNZ SetGUSRegisters11 + + Test CH, 5 + JNZ SetGUSRegisters12 + + Test CL, 1 + JZ SetGUSRegisters13 + + Mov AL, 80h ; Read voice control + Out DX, AL + + Add DL, 2 + In AL, DX + Sub DL, 2 + + Test AL, 1 + JZ SetGUSRegisters13 + + Xor BX, BX + Call SetGUSVolume + + Jmp SetGUSRegisters14 + +SetGUSRegisters11: + ; Turn off. + Xor AL, AL + Out DX, AL ; AL = 0 (Mode control) + Mov AL, 2 + Add DL, 2 + + Mov AH, [SI+18h] ; 16 bit? + Add AH, AH + Or AL, AH + + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Xor BX, BX + Call SetGUSVolume + +SetGUSRegisters14: + Test CL, 1 + JZ SetGUSRegisters13 + + Xor CX, CX ; Turn off channel + Test Byte Ptr [SI+3Ah], 80h + JNZ SetGUSRegisters13 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + + Jmp SetGUSRegisters13 + +SetGUSRegisters12: ; Turn on + Xor AL, AL + Out DX, AL + + Mov AL, [SI+0Ah] + + Cmp CS:Convert16To8Bit, 0 + JNZ SetGUSRegistersNo16Bit + + Mov AH, [SI+18h] ; 16 bit? + Add AH, AH + Or AL, AH + +SetGUSRegistersNo16Bit: + Test CL, 1 + JNZ SetGUSRegisters15 + + Mov AL, 2 + Xor CX, CX + +SetGUSRegisters15: + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + +SetGUSRegisters13: + And CX, 0111100010011111b ; Turns off: + ; 1) Freq, pan & vol recalc + ; 2) New note/note stop/loop cha + + Mov [SI], CX + + Add SI, SLAVECHANNELSIZE + +; Call CheckMIDI + + Pop CX + Pop AX + + Inc AX + Dec CX + JNZ SetGUSRegisters1 + + Ret + + +EndP SetGUSRegisters + diff --git a/SoundDrivers/GUSPNPM.ASM b/SoundDrivers/GUSPNPM.ASM index a2c9d5d..0289cde 100755 --- a/SoundDrivers/GUSPNPM.ASM +++ b/SoundDrivers/GUSPNPM.ASM @@ -1,2270 +1,2270 @@ -; -; Windows Sound System Driver, with GUS PnP detection. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -PNPVENDORID EQU 0100561Eh - -DMASize DW 2048 - -WSSMsg DB "Gravis UltraSound PnP Codec", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Gravis UltraSound PnP Codec", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Gravis UltraSound PnP Codec reinitialised", 0 - -DriverName DB "ITGUSPNP.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "Gravis UltraSound PnP Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 19, 48 - DB 21h - DB "Gravis UltraSound PnP Codec Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (56) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - - Mov AX, 1 - Ret - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 14 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 75h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Mov AX, 202h - Call PnP_WriteData - Ret - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - - Mov EAX, 'Jeff' - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB WSSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -WSSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Call UpdateSoundcardVariables - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - Push AX DX - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX AX - Ret - -EndP UpdatesoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - Call UpdateSoundcardVariables - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver, with GUS PnP detection. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +PNPVENDORID EQU 0100561Eh + +DMASize DW 2048 + +WSSMsg DB "Gravis UltraSound PnP Codec", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Gravis UltraSound PnP Codec", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Gravis UltraSound PnP Codec reinitialised", 0 + +DriverName DB "ITGUSPNP.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "Gravis UltraSound PnP Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 19, 48 + DB 21h + DB "Gravis UltraSound PnP Codec Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (56) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + + Mov AX, 1 + Ret + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 14 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 75h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Mov AX, 202h + Call PnP_WriteData + Ret + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + + Mov EAX, 'Jeff' + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB WSSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +WSSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Call UpdateSoundcardVariables + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + Push AX DX + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX AX + Ret + +EndP UpdatesoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + Call UpdateSoundcardVariables + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/GUSPNPMX.ASM b/SoundDrivers/GUSPNPMX.ASM index a94e740..86b8cc3 100755 --- a/SoundDrivers/GUSPNPMX.ASM +++ b/SoundDrivers/GUSPNPMX.ASM @@ -1,1769 +1,1769 @@ -; -; Windows Sound System Driver, with GUS PnP detection, MMX mixing. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -OUTPUTFILTERENABLED EQU 0 - -PNPVENDORID EQU 0100561Eh - -FPSave DB 128 Dup (0) - -DMASize DW 2048 - -WSSMsg DB "Gravis UltraSound PnP MMX", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Gravis UltraSound PnP MMX", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Gravis UltraSound PnP Codec reinitialised", 0 - -DriverName DB "ITGUSPNP.MMX", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 12 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 12 - DW Near Ptr MasterVolumeRight ; 13 - - DW 0 - - -WSSHeaderLine DW 10 - DB "Gravis UltraSound PnP MMX Codec Driver", 0 - -DriverText DW 1 - DB 19, 48 - DB 21h - DB "Gravis UltraSound PnP Codec Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 12, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - DW 0 - -MixModeButton1 DW 2 - DW 13, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " MMX, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " MMX, Volume Ramped", 0 - -MixModeButton4 DW 2 - DW 8, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " MMX, Filtered", 0 - -VolumeTable DB 2 Dup (56) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - - -include nodebug.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Trace "GUSPnP MMX: SetMixMode" - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 14 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 75h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMMX - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectMMXFail - - Mov EAX, 1 - DB 0Fh, 0A2h ; CPUID - Test EDX, 800000h - JZ DetectMMXFail - - ClC - Ret - -DetectMMXFail: - StC - Ret - -EndP DetectMMX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Call DetectMMX - JC DetectCard_MMXNotFound - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - Mov AX, 202h - Call PnP_WriteData - -DetectCard_MMXNotFound: - StC - Ret - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - - Mov EAX, 'Jeff' - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - FNSave [FPSave] - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB WSSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -WSSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Mov BX, DMASize ; BX = bytes required - Add DI, AX - - ShR BX, 1 - ; BX = samples required - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRstor [CS:FPSave] - - Pop ES - Pop DS - PopAD - IRet - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Trace "GUSPnP MMX: StopSound" - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Trace "GUSPnP MMX: StartSound" - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Trace "GUSPnP MMX: InitSound" - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, (DMABUFFERLENGTH*2)/16 + 5 - Mov BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Call UpdateSoundcardVariables - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Trace "GUSPnP MMX: SetStereoCall" - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - Trace "GUSPnP MMX: Driver Screen" - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - Push AX DX - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX AX - Ret - -EndP UpdatesoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - Call UpdateSoundcardVariables - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h -; Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: -; Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 - DW 3 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver, with GUS PnP detection, MMX mixing. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +OUTPUTFILTERENABLED EQU 0 + +PNPVENDORID EQU 0100561Eh + +FPSave DB 128 Dup (0) + +DMASize DW 2048 + +WSSMsg DB "Gravis UltraSound PnP MMX", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Gravis UltraSound PnP MMX", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Gravis UltraSound PnP Codec reinitialised", 0 + +DriverName DB "ITGUSPNP.MMX", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 12 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 12 + DW Near Ptr MasterVolumeRight ; 13 + + DW 0 + + +WSSHeaderLine DW 10 + DB "Gravis UltraSound PnP MMX Codec Driver", 0 + +DriverText DW 1 + DB 19, 48 + DB 21h + DB "Gravis UltraSound PnP Codec Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 12, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + DW 0 + +MixModeButton1 DW 2 + DW 13, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " MMX, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " MMX, Volume Ramped", 0 + +MixModeButton4 DW 2 + DW 8, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " MMX, Filtered", 0 + +VolumeTable DB 2 Dup (56) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + + +include nodebug.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Trace "GUSPnP MMX: SetMixMode" + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 14 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 75h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMMX + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectMMXFail + + Mov EAX, 1 + DB 0Fh, 0A2h ; CPUID + Test EDX, 800000h + JZ DetectMMXFail + + ClC + Ret + +DetectMMXFail: + StC + Ret + +EndP DetectMMX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Call DetectMMX + JC DetectCard_MMXNotFound + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + Mov AX, 202h + Call PnP_WriteData + +DetectCard_MMXNotFound: + StC + Ret + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + + Mov EAX, 'Jeff' + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + FNSave [FPSave] + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB WSSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +WSSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Mov BX, DMASize ; BX = bytes required + Add DI, AX + + ShR BX, 1 + ; BX = samples required + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRstor [CS:FPSave] + + Pop ES + Pop DS + PopAD + IRet + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Trace "GUSPnP MMX: StopSound" + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Trace "GUSPnP MMX: StartSound" + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Trace "GUSPnP MMX: InitSound" + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, (DMABUFFERLENGTH*2)/16 + 5 + Mov BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Call UpdateSoundcardVariables + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Trace "GUSPnP MMX: SetStereoCall" + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + Trace "GUSPnP MMX: Driver Screen" + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + Push AX DX + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX AX + Ret + +EndP UpdatesoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + Call UpdateSoundcardVariables + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h +; Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: +; Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 + DW 3 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/GUSRAMP.INC b/SoundDrivers/GUSRAMP.INC index 15c3271..ea7ccb3 100755 --- a/SoundDrivers/GUSRAMP.INC +++ b/SoundDrivers/GUSRAMP.INC @@ -1,114 +1,114 @@ - -Proc SetGUSVolume ; BX = new volume - - ; To do: - ; 1) Set ramp start - ; 2) Set ramp end - ; 3) Set current volume - ; 4) Start ramp - ; 5) Save new volume. - - Push BX - Push CX - - Mov AL, 0Dh - Out DX, AL - - Mov AL, 3 ; Stop Ramp! - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Add BX, BX - Mov CX, [CS:GUSVolumeTable+BX] ; CX = new volume - Mov BX, [SI+2] - Add BX, BX - Mov BX, [CS:GUSVolumeTable+BX] ; BX = old volume - - Cmp BX, CX - JNE SetGUSVolume2 - - Mov AL, 89h - Out DX, AL - Inc DX - In AX, DX - Dec DX - - Mov BX, AX ; BX = old volume - -SetGUSVolume2: - - Push BX ; Old volume on stack - - Xor AH, AH ; Ramp up - Cmp CX, BX - JAE SetGUSVolume1 - - XChg BX, CX - Mov AH, 40h ; Ramp down - -SetGUSVolume1: - Mov AL, 6 ; Ramp rate - Out DX, AL - - Mov AL, Byte Ptr CS:UsedChannels - ShR AL, 1 - Add AL, 16 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 7 ; Ramp start - Out DX, AL - - Mov AL, BH - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Mov AL, 8 ; Ramp end - Out DX, AL - - Mov AL, CH - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Mov AL, 9 - Out DX, AL - - Pop BX ; BX = old volume - XChg BX, AX - - Inc DX - Out DX, AX - Call GUSDelay - Out DX, AX - Dec DX - - Mov AL, 0Dh ; Ramp control - Out DX, AL - - Mov AL, BH - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Pop CX - Pop BX - - Mov [SI+2], BX - - Ret - -EndP SetGUSVolume - - + +Proc SetGUSVolume ; BX = new volume + + ; To do: + ; 1) Set ramp start + ; 2) Set ramp end + ; 3) Set current volume + ; 4) Start ramp + ; 5) Save new volume. + + Push BX + Push CX + + Mov AL, 0Dh + Out DX, AL + + Mov AL, 3 ; Stop Ramp! + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Add BX, BX + Mov CX, [CS:GUSVolumeTable+BX] ; CX = new volume + Mov BX, [SI+2] + Add BX, BX + Mov BX, [CS:GUSVolumeTable+BX] ; BX = old volume + + Cmp BX, CX + JNE SetGUSVolume2 + + Mov AL, 89h + Out DX, AL + Inc DX + In AX, DX + Dec DX + + Mov BX, AX ; BX = old volume + +SetGUSVolume2: + + Push BX ; Old volume on stack + + Xor AH, AH ; Ramp up + Cmp CX, BX + JAE SetGUSVolume1 + + XChg BX, CX + Mov AH, 40h ; Ramp down + +SetGUSVolume1: + Mov AL, 6 ; Ramp rate + Out DX, AL + + Mov AL, Byte Ptr CS:UsedChannels + ShR AL, 1 + Add AL, 16 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 7 ; Ramp start + Out DX, AL + + Mov AL, BH + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Mov AL, 8 ; Ramp end + Out DX, AL + + Mov AL, CH + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Mov AL, 9 + Out DX, AL + + Pop BX ; BX = old volume + XChg BX, AX + + Inc DX + Out DX, AX + Call GUSDelay + Out DX, AX + Dec DX + + Mov AL, 0Dh ; Ramp control + Out DX, AL + + Mov AL, BH + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Pop CX + Pop BX + + Mov [SI+2], BX + + Ret + +EndP SetGUSVolume + + diff --git a/SoundDrivers/GUSRIC.INC b/SoundDrivers/GUSRIC.INC index cad6258..325e86e 100755 --- a/SoundDrivers/GUSRIC.INC +++ b/SoundDrivers/GUSRIC.INC @@ -1,651 +1,651 @@ - -Proc SetGUSRegisters ; Given DS:SI, CX - - Mov ES, CS:SongDataArea - - Push CX - Push SI - - Xor AX, AX - -GetOffsetLoop: - Push AX - Push CX - - Mov DX, GUSVoiceSelect - Out DX, AL ; OK.. now to play with this - ; voice. - Call GUSDelay - - Inc DL ; DX = select rego - - Mov BX, [SI] - Test BH, 2 - JZ GetOffsetLoop2 - - Mov BX, 200h - Mov [SI], BX - -GetOffsetLoop2: - Test BL, 1 ; Channel not on! - JZ GetOffsetLoop1 - - Test BH, 1 - JZ GetOffsetLoop3 ; Prev 1. - - Xor BX, BX - Call SetGUSVolume - - Mov AL, 80h - Out DX, AL - Add DL, 2 - In AL, DX - Sub DL, 2 - Mov AH, AL - - And AX, 400h - Out DX, AL ; AL = 0 (Mode control) - Mov AL, 3 - Or AL, AH - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Jmp GetOffsetLoop1 - -GetOffsetLoop3: - Mov EAX, [SI+4Ch] - Mov [SI+2Ch], EAX - - Mov AL, 8Ah - Out DX, AL - - Inc DX - In AX, DX - Dec DX - - And AH, 31 - ShL EAX, 16 ; Load high part of EAX - - Mov AL, 8Bh - Out DX, AL - Inc DX - In AX, DX - ; EAX = 000OOOOO OOOOOOOO OOOOOOOF FFFFFFFF - ; Need: 00000000 0000OOOO OOOOOOOO OOOOOOOO - - ShR EAX, 9 - ; EAX contains current loc. - ; Convert to Offset (in sample) - MovZX EBX, Byte Ptr [SI+36h] - Sub EAX, [CS:GUSDataTable+EBX*4] - Push CX - - Mov CL, CS:Compress - ShL EAX, CL - - Pop CX - Mov [SI+4Ch], EAX - Cmp EAX, [SI+44h] - JBE GetOffsetLoop1 - - Cmp Byte Ptr [SI+0Ah], 0 - JNE GetOffsetLoop1 - - Or Word Ptr [SI], 200h - -GetOffsetLoop1: - Add SI, SLAVECHANNELSIZE - - Pop CX - Pop AX - - Inc AX - Dec CX - JNZ GetOffsetLoop - - Pop SI - Pop CX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - Push CX - Push SI - - Push SI - - Mov BX, 1 - Mov DX, 1 - -ReinitChannels1: - Test Byte Ptr [SI], 1 - JZ ReinitChannels2 - - Mov BX, DX - -ReinitChannels2: - Inc DX - Add SI, 128 - Loop ReinitChannels1 - - Pop SI - - Mov CX, BX - - Cmp BX, 14 - JAE RIC3 - - Mov BX, 14 - -RIC3: - Cmp BX, 32 - JB RIC4 - - Mov BX, 32 - -RIC4: - Cmp BX, CS:UsedChannels - JE EndOfFreqChange - - JA RIC5 - Mov BX, CS:UsedChannels - Dec BX - -RIC5: - ; Now.. get new mixspeed. - ; Prepare all new frequencies - ; then write all active voices - ; + all new frequencies. - ; BX = num channels... - Push BX - Push BX - Push BX - - Add BX, BX ; BX = pointer into mixtable. - MovZX EBX, [CS:GUSMixTable+BX-28] - Mov CS:MixSpeed, BX - - Push CX - Push SI - -PrepareNewFreq2: - Test Byte Ptr [SI], 1 - JZ PrepareNewFreq3 - - Test Word Ptr [SI], 100h - JNZ PrepareNewFreq3 - - Mov EAX, [SI+10h] ; EAX = freq. - Push CX - Mov CL, CS:Compress - ShR EAX, CL - Pop CX - Xor EDX, EDX - - Div EBX ; EAX = I portion. - - Push EAX - Xor EAX, EAX - Div EBX - - Pop EDX ; EDX:EAX = IIII FFFF etc. - - SHRD EAX, EDX, 22 - Add AX, 1 - SBB AX, 0 ; Just in case! - And AX, Not 1 - Mov [SI+4], AX - -PrepareNewFreq3: - Add SI, 128 - Loop PrepareNewFreq2 - - Pop SI - Pop CX - - Pop BX - - Mov DI, CS:UsedChannels - Cmp DI, BX - JB KillExtraChannels1 - - Mov DI, BX - Mov BX, 32 -; XChg DI, BX - -KillExtraChannels1: - Cmp DI, BX - JAE KillExtraChannels2 - - Mov DX, GUSVoiceSelect - Mov AX, DI - Out DX, AL - - Inc DX ; Select rego - - Mov AL, 0Dh ; Volume Ramp. - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Xor AL, AL - Out DX, AL ; AL = 0 (Mode control) - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 9 - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ch ; Set panning. - Out DX, AL - Mov AL, 8 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Comment ~ - - Call GUSDelay - - Mov AL, 0Dh ; Volume Ramp. - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Xor AL, AL - Out DX, AL ; AL = 0 (Mode control) - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 9 - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ch ; Set panning. - Out DX, AL - Mov AL, 8 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - ~ - - Inc DI - Jmp KillExtraChannels1 - -KillExtraChannels2: - Xor BX, BX ; BX = channel number - -PrepareNewFreq4: - Mov DX, GUSVoiceSelect - Mov AL, BL - Out DX, AL - Inc DX ; Select rego - - Test Byte Ptr [SI], 1 - JZ PrepareNewFreq5 - - Test Word Ptr [SI], 120h ; New note or new freq? - JNZ PrepareNewFreq5 - - Or Byte Ptr [SI], 2h - - Mov AL, 1 - Out DX, AL - Inc DX - Mov AX, [SI+4] - Out DX, AX - -PrepareNewFreq5: - Inc BX - Add SI, 128 - Loop PrepareNewFreq4 - - Mov DX, GUSRegisterSelect - Mov AL, 0Eh - Out DX, AL - Add DL, 2 - Pop AX - Dec AL - Or AL, 0C0h - Out DX, AL - - Pop CS:UsedChannels - -EndOfFreqChange: - - Pop SI - Pop CX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - Xor AX, AX - -SetGUSRegisters1: - Push AX - Push CX - - Mov DX, GUSVoiceSelect - Out DX, AL ; OK.. now to play with this - ; voice. - Call GUSDelay - - Mov CX, [SI] ; CX = flags. - Inc DL ; DX = select rego - -SetGUSRegisters21: - Test CL, 32 ; Frequency change - JZ SetGUSRegisters7 - - Push DX - - Mov EAX, [SI+10h] ; EAX = freq. - - Push CX - Mov CL, CS:Compress - ShR EAX, CL - Pop CX - - Xor EDX, EDX - MovZX EBX, MixSpeed - - Div EBX ; EAX = I portion. - - Test EAX, Not 63 - JNZ SetGUSRegisters6 - - Push EAX - - Xor EAX, EAX - Div EBX - - Pop EBX ; EBX:EAX = IIII FFFF etc. - - SHRD EAX, EBX, 6 - - ; Have: IIIIIIII IIIIIIII FFFFFFFF FFFFFFFF - ; Req: IIIIIIFF FFFFFFF0 - - Pop DX - Mov AL, 1 - Out DX, AL - - ShR EAX, 16 - Add AX, 1 - SBB AX, 0 ; Just in case! - And AX, Not 1 - - Inc DX - Out DX, AX - Dec DX - - Jmp SetGUSRegisters7 - -SetGUSRegisters6: - Mov CH, 2 ; Signify to turn off channel - Pop DX - -SetGUSRegisters7: - MovZX BX, Byte Ptr [SI+36h] ; BX = sample number. - Cmp BL, 99 - JA SetGUSRegisters20 - - ShL BX, 2 ; GUSDataTable+BX = position - - Cmp DWord Ptr [CS:GUSDataTable+BX], 0FFFFFFFFh - JNE SetGUSRegisters10 - -SetGUSRegisters20: - Mov CH, 2 - Jmp SetGUSRegisters9 - -SetGUSRegisters10: - Test CX, 502h ; Loop changed?!??!? - JZ SetGUSRegisters8 - - Mov AL, 3 ; Starting location low. - Out DX, AL - - Mov EAX, [SI+40h] - Call GUSGetAddress - - ; Reqd: ...OOOOO OOOOOOOO OOOOOOOI III..... - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 2 ; Starting location high - Out DX, AL - - ShR EAX, 16 - Inc DX - Out DX, AX - Dec DX - - ; Ending location... - Mov AL, 5 ; Ending location low - Out DX, AL - - Mov EAX, [SI+44h] - Call GUSGetAddress - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 4 ; Ending location high - Out DX, AL - - SHR EAX, 16 - Inc DX - Out DX, AX - Dec DX - -SetGUSRegisters8: - Test CH, 1 ; Do Current position? - JZ SetGUSRegisters9 - - Mov AL, 0Bh ; Current location LOW - Out DX, AL - - Mov EAX, [SI+4Ch] - Mov [SI+2Ch], EAX - - ; EAX = OOOOOOOO OOOOOOOO OOOOOOOO OOOOOOOO - ; Req: xxxOOOOO OOOOOOOO OOOOOOOF FFFFFFFF - Call GUSGetAddress - - Mov DI, AX - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ah ; Current location HIGH - Out DX, AL - - SHR EAX, 16 - Inc DX - Out DX, AX - Call GUSDelay - Out DX, AX - Dec DX - - Mov AL, 0Bh - Out DX, AL - - Mov AX, DI - Inc DX - Out DX, AX - Dec DX - -SetGUSRegisters9: - Test CL, 64 ; New volume?? - JZ SetGUSPanning - -SetGUSRegisters23: - Xor BX, BX - Test CH, 8 - JNZ SetGUSRegistersMuted - - Mov BL, Byte Ptr [SI+20h] ; BL = volume, 0->128 - -SetGUSRegistersMuted: - Call SetGUSVolume - - -SetGUSPanning: - Test CH, 128 ; New panning? - JZ SetGUSRegisters5 - - Mov AL, 0Ch ; Set panning. - Out DX, AL - - Test CS:Stereo, 1 - JZ SetGUSRegisters3 - - Mov AL, [SI+37h] - Cmp AL, 100 - JNE SetGUSRegisters4 - -SetGUSRegisters3: - Mov AL, 32 ; Surround goes to mono :( - -SetGUSRegisters4: ; AL = 0->64 - ShR AL, 1 ; AL = 0->32 - Sub AL, 1 - AdC AL, 0 ; AL = 0->31 - ShR AL, 1 - - Add DL, 2 - Out DX, AL - Sub DL, 2 - -SetGUSRegisters5: - ; Now for control register. - ; If CH | 2, then turn rego OFF - ; If CH | 5, then turn rego ON - ; If CL | 1, then check channel - Test CH, 2 - JNZ SetGUSRegisters11 - - Test CH, 5 - JNZ SetGUSRegisters12 - - Test CL, 1 - JZ SetGUSRegisters13 - - Mov AL, 80h ; Read voice control - Out DX, AL - - Add DL, 2 - In AL, DX - Sub DL, 2 - - Test AL, 1 - JZ SetGUSRegisters13 - - Xor BX, BX - Call SetGUSVolume - - Jmp SetGUSRegisters14 - -SetGUSRegisters11: - ; Turn off. - Xor AL, AL - Out DX, AL ; AL = 0 (Mode control) - Mov AL, 2 - Add DL, 2 - - Mov AH, [SI+18h] ; 16 bit? - Add AH, AH - Or AL, AH - - Out DX, AL - Call GUSDelay - Out DX, AL - Sub DL, 2 - - Xor BX, BX - Call SetGUSVolume - -SetGUSRegisters14: - Test CL, 1 - JZ SetGUSRegisters13 - - Xor CX, CX ; Turn off channel - Test Byte Ptr [SI+3Ah], 80h - JNZ SetGUSRegisters13 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - - Jmp SetGUSRegisters13 - -SetGUSRegisters12: ; Turn on - Xor AL, AL - Out DX, AL - - Mov AL, [SI+0Ah] - - Cmp CS:Convert16To8Bit, 0 - JNZ SetGUSRegistersNo16Bit - - Mov AH, [SI+18h] ; 16 bit? - Add AH, AH - Or AL, AH - -SetGUSRegistersNo16Bit: - Test CL, 1 - JNZ SetGUSRegisters15 - - Mov AL, 2 - Xor CX, CX - -SetGUSRegisters15: - Add DL, 2 - Out DX, AL - Call GUSDelay - Out DX, AL - -SetGUSRegisters13: - And CX, 0111100010011111b ; Turns off: - ; 1) Freq, pan & vol recalc - ; 2) New note/note stop/loop cha - - Mov [SI], CX - - Add SI, SLAVECHANNELSIZE - - Pop CX - Pop AX - - Inc AX - Dec CX - JNZ SetGUSRegisters1 - - Ret - - -EndP SetGUSRegisters - - + +Proc SetGUSRegisters ; Given DS:SI, CX + + Mov ES, CS:SongDataArea + + Push CX + Push SI + + Xor AX, AX + +GetOffsetLoop: + Push AX + Push CX + + Mov DX, GUSVoiceSelect + Out DX, AL ; OK.. now to play with this + ; voice. + Call GUSDelay + + Inc DL ; DX = select rego + + Mov BX, [SI] + Test BH, 2 + JZ GetOffsetLoop2 + + Mov BX, 200h + Mov [SI], BX + +GetOffsetLoop2: + Test BL, 1 ; Channel not on! + JZ GetOffsetLoop1 + + Test BH, 1 + JZ GetOffsetLoop3 ; Prev 1. + + Xor BX, BX + Call SetGUSVolume + + Mov AL, 80h + Out DX, AL + Add DL, 2 + In AL, DX + Sub DL, 2 + Mov AH, AL + + And AX, 400h + Out DX, AL ; AL = 0 (Mode control) + Mov AL, 3 + Or AL, AH + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Jmp GetOffsetLoop1 + +GetOffsetLoop3: + Mov EAX, [SI+4Ch] + Mov [SI+2Ch], EAX + + Mov AL, 8Ah + Out DX, AL + + Inc DX + In AX, DX + Dec DX + + And AH, 31 + ShL EAX, 16 ; Load high part of EAX + + Mov AL, 8Bh + Out DX, AL + Inc DX + In AX, DX + ; EAX = 000OOOOO OOOOOOOO OOOOOOOF FFFFFFFF + ; Need: 00000000 0000OOOO OOOOOOOO OOOOOOOO + + ShR EAX, 9 + ; EAX contains current loc. + ; Convert to Offset (in sample) + MovZX EBX, Byte Ptr [SI+36h] + Sub EAX, [CS:GUSDataTable+EBX*4] + Push CX + + Mov CL, CS:Compress + ShL EAX, CL + + Pop CX + Mov [SI+4Ch], EAX + Cmp EAX, [SI+44h] + JBE GetOffsetLoop1 + + Cmp Byte Ptr [SI+0Ah], 0 + JNE GetOffsetLoop1 + + Or Word Ptr [SI], 200h + +GetOffsetLoop1: + Add SI, SLAVECHANNELSIZE + + Pop CX + Pop AX + + Inc AX + Dec CX + JNZ GetOffsetLoop + + Pop SI + Pop CX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + Push CX + Push SI + + Push SI + + Mov BX, 1 + Mov DX, 1 + +ReinitChannels1: + Test Byte Ptr [SI], 1 + JZ ReinitChannels2 + + Mov BX, DX + +ReinitChannels2: + Inc DX + Add SI, 128 + Loop ReinitChannels1 + + Pop SI + + Mov CX, BX + + Cmp BX, 14 + JAE RIC3 + + Mov BX, 14 + +RIC3: + Cmp BX, 32 + JB RIC4 + + Mov BX, 32 + +RIC4: + Cmp BX, CS:UsedChannels + JE EndOfFreqChange + + JA RIC5 + Mov BX, CS:UsedChannels + Dec BX + +RIC5: + ; Now.. get new mixspeed. + ; Prepare all new frequencies + ; then write all active voices + ; + all new frequencies. + ; BX = num channels... + Push BX + Push BX + Push BX + + Add BX, BX ; BX = pointer into mixtable. + MovZX EBX, [CS:GUSMixTable+BX-28] + Mov CS:MixSpeed, BX + + Push CX + Push SI + +PrepareNewFreq2: + Test Byte Ptr [SI], 1 + JZ PrepareNewFreq3 + + Test Word Ptr [SI], 100h + JNZ PrepareNewFreq3 + + Mov EAX, [SI+10h] ; EAX = freq. + Push CX + Mov CL, CS:Compress + ShR EAX, CL + Pop CX + Xor EDX, EDX + + Div EBX ; EAX = I portion. + + Push EAX + Xor EAX, EAX + Div EBX + + Pop EDX ; EDX:EAX = IIII FFFF etc. + + SHRD EAX, EDX, 22 + Add AX, 1 + SBB AX, 0 ; Just in case! + And AX, Not 1 + Mov [SI+4], AX + +PrepareNewFreq3: + Add SI, 128 + Loop PrepareNewFreq2 + + Pop SI + Pop CX + + Pop BX + + Mov DI, CS:UsedChannels + Cmp DI, BX + JB KillExtraChannels1 + + Mov DI, BX + Mov BX, 32 +; XChg DI, BX + +KillExtraChannels1: + Cmp DI, BX + JAE KillExtraChannels2 + + Mov DX, GUSVoiceSelect + Mov AX, DI + Out DX, AL + + Inc DX ; Select rego + + Mov AL, 0Dh ; Volume Ramp. + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Xor AL, AL + Out DX, AL ; AL = 0 (Mode control) + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 9 + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ch ; Set panning. + Out DX, AL + Mov AL, 8 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Comment ~ + + Call GUSDelay + + Mov AL, 0Dh ; Volume Ramp. + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Xor AL, AL + Out DX, AL ; AL = 0 (Mode control) + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 9 + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ch ; Set panning. + Out DX, AL + Mov AL, 8 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + ~ + + Inc DI + Jmp KillExtraChannels1 + +KillExtraChannels2: + Xor BX, BX ; BX = channel number + +PrepareNewFreq4: + Mov DX, GUSVoiceSelect + Mov AL, BL + Out DX, AL + Inc DX ; Select rego + + Test Byte Ptr [SI], 1 + JZ PrepareNewFreq5 + + Test Word Ptr [SI], 120h ; New note or new freq? + JNZ PrepareNewFreq5 + + Or Byte Ptr [SI], 2h + + Mov AL, 1 + Out DX, AL + Inc DX + Mov AX, [SI+4] + Out DX, AX + +PrepareNewFreq5: + Inc BX + Add SI, 128 + Loop PrepareNewFreq4 + + Mov DX, GUSRegisterSelect + Mov AL, 0Eh + Out DX, AL + Add DL, 2 + Pop AX + Dec AL + Or AL, 0C0h + Out DX, AL + + Pop CS:UsedChannels + +EndOfFreqChange: + + Pop SI + Pop CX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + Xor AX, AX + +SetGUSRegisters1: + Push AX + Push CX + + Mov DX, GUSVoiceSelect + Out DX, AL ; OK.. now to play with this + ; voice. + Call GUSDelay + + Mov CX, [SI] ; CX = flags. + Inc DL ; DX = select rego + +SetGUSRegisters21: + Test CL, 32 ; Frequency change + JZ SetGUSRegisters7 + + Push DX + + Mov EAX, [SI+10h] ; EAX = freq. + + Push CX + Mov CL, CS:Compress + ShR EAX, CL + Pop CX + + Xor EDX, EDX + MovZX EBX, MixSpeed + + Div EBX ; EAX = I portion. + + Test EAX, Not 63 + JNZ SetGUSRegisters6 + + Push EAX + + Xor EAX, EAX + Div EBX + + Pop EBX ; EBX:EAX = IIII FFFF etc. + + SHRD EAX, EBX, 6 + + ; Have: IIIIIIII IIIIIIII FFFFFFFF FFFFFFFF + ; Req: IIIIIIFF FFFFFFF0 + + Pop DX + Mov AL, 1 + Out DX, AL + + ShR EAX, 16 + Add AX, 1 + SBB AX, 0 ; Just in case! + And AX, Not 1 + + Inc DX + Out DX, AX + Dec DX + + Jmp SetGUSRegisters7 + +SetGUSRegisters6: + Mov CH, 2 ; Signify to turn off channel + Pop DX + +SetGUSRegisters7: + MovZX BX, Byte Ptr [SI+36h] ; BX = sample number. + Cmp BL, 99 + JA SetGUSRegisters20 + + ShL BX, 2 ; GUSDataTable+BX = position + + Cmp DWord Ptr [CS:GUSDataTable+BX], 0FFFFFFFFh + JNE SetGUSRegisters10 + +SetGUSRegisters20: + Mov CH, 2 + Jmp SetGUSRegisters9 + +SetGUSRegisters10: + Test CX, 502h ; Loop changed?!??!? + JZ SetGUSRegisters8 + + Mov AL, 3 ; Starting location low. + Out DX, AL + + Mov EAX, [SI+40h] + Call GUSGetAddress + + ; Reqd: ...OOOOO OOOOOOOO OOOOOOOI III..... + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 2 ; Starting location high + Out DX, AL + + ShR EAX, 16 + Inc DX + Out DX, AX + Dec DX + + ; Ending location... + Mov AL, 5 ; Ending location low + Out DX, AL + + Mov EAX, [SI+44h] + Call GUSGetAddress + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 4 ; Ending location high + Out DX, AL + + SHR EAX, 16 + Inc DX + Out DX, AX + Dec DX + +SetGUSRegisters8: + Test CH, 1 ; Do Current position? + JZ SetGUSRegisters9 + + Mov AL, 0Bh ; Current location LOW + Out DX, AL + + Mov EAX, [SI+4Ch] + Mov [SI+2Ch], EAX + + ; EAX = OOOOOOOO OOOOOOOO OOOOOOOO OOOOOOOO + ; Req: xxxOOOOO OOOOOOOO OOOOOOOF FFFFFFFF + Call GUSGetAddress + + Mov DI, AX + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ah ; Current location HIGH + Out DX, AL + + SHR EAX, 16 + Inc DX + Out DX, AX + Call GUSDelay + Out DX, AX + Dec DX + + Mov AL, 0Bh + Out DX, AL + + Mov AX, DI + Inc DX + Out DX, AX + Dec DX + +SetGUSRegisters9: + Test CL, 64 ; New volume?? + JZ SetGUSPanning + +SetGUSRegisters23: + Xor BX, BX + Test CH, 8 + JNZ SetGUSRegistersMuted + + Mov BL, Byte Ptr [SI+20h] ; BL = volume, 0->128 + +SetGUSRegistersMuted: + Call SetGUSVolume + + +SetGUSPanning: + Test CH, 128 ; New panning? + JZ SetGUSRegisters5 + + Mov AL, 0Ch ; Set panning. + Out DX, AL + + Test CS:Stereo, 1 + JZ SetGUSRegisters3 + + Mov AL, [SI+37h] + Cmp AL, 100 + JNE SetGUSRegisters4 + +SetGUSRegisters3: + Mov AL, 32 ; Surround goes to mono :( + +SetGUSRegisters4: ; AL = 0->64 + ShR AL, 1 ; AL = 0->32 + Sub AL, 1 + AdC AL, 0 ; AL = 0->31 + ShR AL, 1 + + Add DL, 2 + Out DX, AL + Sub DL, 2 + +SetGUSRegisters5: + ; Now for control register. + ; If CH | 2, then turn rego OFF + ; If CH | 5, then turn rego ON + ; If CL | 1, then check channel + Test CH, 2 + JNZ SetGUSRegisters11 + + Test CH, 5 + JNZ SetGUSRegisters12 + + Test CL, 1 + JZ SetGUSRegisters13 + + Mov AL, 80h ; Read voice control + Out DX, AL + + Add DL, 2 + In AL, DX + Sub DL, 2 + + Test AL, 1 + JZ SetGUSRegisters13 + + Xor BX, BX + Call SetGUSVolume + + Jmp SetGUSRegisters14 + +SetGUSRegisters11: + ; Turn off. + Xor AL, AL + Out DX, AL ; AL = 0 (Mode control) + Mov AL, 2 + Add DL, 2 + + Mov AH, [SI+18h] ; 16 bit? + Add AH, AH + Or AL, AH + + Out DX, AL + Call GUSDelay + Out DX, AL + Sub DL, 2 + + Xor BX, BX + Call SetGUSVolume + +SetGUSRegisters14: + Test CL, 1 + JZ SetGUSRegisters13 + + Xor CX, CX ; Turn off channel + Test Byte Ptr [SI+3Ah], 80h + JNZ SetGUSRegisters13 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + + Jmp SetGUSRegisters13 + +SetGUSRegisters12: ; Turn on + Xor AL, AL + Out DX, AL + + Mov AL, [SI+0Ah] + + Cmp CS:Convert16To8Bit, 0 + JNZ SetGUSRegistersNo16Bit + + Mov AH, [SI+18h] ; 16 bit? + Add AH, AH + Or AL, AH + +SetGUSRegistersNo16Bit: + Test CL, 1 + JNZ SetGUSRegisters15 + + Mov AL, 2 + Xor CX, CX + +SetGUSRegisters15: + Add DL, 2 + Out DX, AL + Call GUSDelay + Out DX, AL + +SetGUSRegisters13: + And CX, 0111100010011111b ; Turns off: + ; 1) Freq, pan & vol recalc + ; 2) New note/note stop/loop cha + + Mov [SI], CX + + Add SI, SLAVECHANNELSIZE + + Pop CX + Pop AX + + Inc AX + Dec CX + JNZ SetGUSRegisters1 + + Ret + + +EndP SetGUSRegisters + + diff --git a/SoundDrivers/IRQ.INC b/SoundDrivers/IRQ.INC index 464402b..50cc856 100755 --- a/SoundDrivers/IRQ.INC +++ b/SoundDrivers/IRQ.INC @@ -1,20 +1,20 @@ - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + diff --git a/SoundDrivers/IWCODEC.ASM b/SoundDrivers/IWCODEC.ASM index 7598505..d78b17f 100755 --- a/SoundDrivers/IWCODEC.ASM +++ b/SoundDrivers/IWCODEC.ASM @@ -1,2302 +1,2302 @@ -; -; Windows Sound System Driver, for GUS PnP -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -DMASize DW 2048 - -WSSMsg DB "Using GUS CS4231 Codec", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Using GUS CS4231 Codec", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "GUS Codec reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITGUSMAX.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITGUSMAX.DRV", 0 - -DriverName DB "ITGUSMAX.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "GUS CS4231 Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "GUS CS4231 Codec Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 16 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov AX, 407h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Test AX, AX - JZ PnP_IsolateNextCard - - Mov SAM9407Port, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - Mov DX, - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov EAX, 'Jeff' - ClC - -DetectCardEnd: - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB WSSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -WSSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver, for GUS PnP +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +DMASize DW 2048 + +WSSMsg DB "Using GUS CS4231 Codec", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Using GUS CS4231 Codec", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "GUS Codec reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITGUSMAX.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITGUSMAX.DRV", 0 + +DriverName DB "ITGUSMAX.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "GUS CS4231 Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "GUS CS4231 Codec Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 16 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov AX, 407h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Test AX, AX + JZ PnP_IsolateNextCard + + Mov SAM9407Port, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + Mov DX, + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov EAX, 'Jeff' + ClC + +DetectCardEnd: + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB WSSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +WSSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/IWDRV.ASM b/SoundDrivers/IWDRV.ASM index d29ee51..c2aa9e3 100755 --- a/SoundDrivers/IWDRV.ASM +++ b/SoundDrivers/IWDRV.ASM @@ -1,2713 +1,2713 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -;************************** - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;************** Local variables **************** - -SLAVECHANNELSIZE EQU 128 -MixSpeed = 44100 - -IWReinitMsg DB "Interwave reinitialised", 0 - -IWID DB "AMD Interwave, Revision " -RevisionLetter DB " ", 13 - DB "Port ", 0FDh, "Xh, ", 0FDh, "Dk Memory", 0 - -IWID2 DB "AMD Interwave, Revision " -RevisionLetter2 DB " ", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 - -IWFreeMsg DB "FreeIW ", 0FDh, "Dk", 0 - -IWVolumeTable Label Word - DW 00000h, 0A0C0h, 0ABE0h, 0B250h, 0B6F0h, 0BA80h, 0BD70h, 0BFE0h - DW 0C200h, 0C3F0h, 0C5A0h, 0C720h, 0C880h, 0C9D0h, 0CB00h, 0CC10h - DW 0CD20h, 0CE10h, 0CF00h, 0CFE0h, 0D0B0h, 0D180h, 0D230h, 0D2F0h - DW 0D3A0h, 0D440h, 0D4E0h, 0D580h, 0D610h, 0D6A0h, 0D730h, 0D7B0h - DW 0D830h, 0D8B0h, 0D930h, 0D9A0h, 0DA20h, 0DA90h, 0DAF0h, 0DB60h - DW 0DBC0h, 0DC30h, 0DC90h, 0DCF0h, 0DD50h, 0DDB0h, 0DE00h, 0DE60h - DW 0DEB0h, 0DF00h, 0DF60h, 0DFB0h, 0E000h, 0E050h, 0E090h, 0E0E0h - DW 0E130h, 0E170h, 0E1C0h, 0E200h, 0E240h, 0E290h, 0E2D0h, 0E310h - DW 0E350h, 0E390h, 0E3D0h, 0E410h, 0E440h, 0E480h, 0E4C0h, 0E4F0h - DW 0E530h, 0E560h, 0E5A0h, 0E5D0h, 0E610h, 0E640h, 0E670h, 0E6B0h - DW 0E6E0h, 0E710h, 0E740h, 0E770h, 0E7A0h, 0E7D0h, 0E800h, 0E830h - DW 0E860h, 0E890h, 0E8C0h, 0E8F0h, 0E920h, 0E940h, 0E970h, 0E9A0h - DW 0E9D0h, 0E9F0h, 0EA20h, 0EA40h, 0EA70h, 0EAA0h, 0EAC0h, 0EAF0h - DW 0EB10h, 0EB40h, 0EB60h, 0EB80h, 0EBB0h, 0EBD0h, 0EBF0h, 0EC20h - DW 0EC40h, 0EC60h, 0EC90h, 0ECB0h, 0ECD0h, 0ECF0h, 0ED10h, 0ED40h - DW 0ED60h, 0ED80h, 0EDA0h, 0EDC0h, 0EDE0h, 0EE00h, 0EE20h, 0EE40h - DW 0EE60h - -OffsetTable Label Word - DW 0FFF0h, 03000h, 02800h, 02350h, 02000h, 01D60h, 01B50h, 01980h - DW 01800h, 016A0h, 01560h, 01450h, 01350h, 01260h, 01180h, 010B0h - DW 01000h, 00F40h, 00EA0h, 00E00h, 00D60h, 00CD0h, 00C50h, 00BC0h - DW 00B50h, 00AD0h, 00A60h, 009F0h, 00980h, 00920h, 008B0h, 00850h - DW 00800h, 007A0h, 00740h, 006F0h, 006A0h, 00650h, 00600h, 005B0h - DW 00560h, 00520h, 004D0h, 00490h, 00450h, 00410h, 003C0h, 00390h - DW 00350h, 00310h, 002D0h, 00290h, 00260h, 00220h, 001F0h, 001B0h - DW 00180h, 00150h, 00120h, 000F0h, 000B0h, 00080h, 00050h, 00020h - DW 00000h - - -IWMemory DW 0 ; kb of memory on IW -IWRegisterSelect DW 0 -IWVoiceSelect DW 0 -IWUpdateTimer DW 0 -IWUpdateCount DW 0 -IWMemoryFree DD 0 -IWOutputPort DW 0 -IWUpdateFlag DB 0 -IWMemorySegmented DB 0 - -IWLMCFI DW 0 -IWBankTable DB 0, 0, 0, 0 - -IWBank1 DD 0 -IWBank2 DD 0 -IWBank3 DD 0 -IWBank4 DD 0 - -OldIRQHandler DD 0 - -Convert16To8Bit DB 0 - DB 0 -Compress DB 0 - DB 0 -Stereo DB 0 - -NewIWLMCFI DW 0 - -IWDataTable DD 100 Dup (0FFFFFFFFh) -Revision DB 0 - -BankConfigs Label ; 12 configs.. -; DB 64, 64, 64, 64 ; 12 -; DB 64, 64, 0, 0 ; 11 - DB 64, 0, 0, 0 ; 10 - DB 16, 16, 16, 16 ; 9 - DB 16, 16, 0, 0 ; 8 - DB 16, 0, 0, 0 ; 7 - DB 4, 4, 16, 16 ; 6 - DB 4, 4, 16, 0 ; 5 - DB 4, 16, 16, 16 ; 4 - DB 4, 16, 0, 0 ; 3 - DB 4, 4, 4, 4 ; 2 - DB 4, 4, 0, 0 ; 1 - DB 4, 0, 0, 0 ; 0 - - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -IMR DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IWScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr GravisHeaderLine - - DW SampleText ; 4 - - DW ConvertSampleText - DW ConvertDisabledButton ; 6 - DW ConvertEnabledButton - - DW SampleSizeText ; 8 - DW SampleSize0Button ; 9 - DW SampleSize1Button - DW SampleSize2Button - - DW DriverText - - DW 0 - -GravisHeaderLine DW 10 - DB "Interwave Driver", 0 - -DriverText DW 1 - DB 38, 48 - DB 21h - DB "Interwave Driver 1.1 for Impulse Tracker", 0 - -SampleText DW 1 - DB 3, 13 - DB 20h - DB "Sample resizing options", 0 - -ConvertSampleText DW 1 - DB 5, 15 - DB 20h - DB "Reduce 16 bit samples to 8 bit", 0 - -ConvertDisabledButton DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetConvert -DriverSegment1 DW 0 - DW 0 - DW Offset SetConvert -DriverSegment2 DW 0 - DB 7, 17, 20, 19, 8 - DB 0 - DB " Disabled", 0 - -ConvertEnabledButton DW 2 - DW 6, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetConvert -DriverSegment3 DW 0 - DW 1 - DW Offset SetConvert -DriverSegment4 DW 0 - DB 7, 20, 20, 22, 8 - DB 0 - DB " Enabled", 0 - -SampleSizeText DW 1 - DB 5, 24 - DB 20h - DB "Sample size", 0 - -SampleSize0Button DW 2 - DW 7, 10, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment5 DW 0 - DW 0 - DW Offset SetCompress -DriverSegment6 DW 0 - DB 7, 26, 20, 28, 8 - DB 0 - DB " Original", 0 - -SampleSize1Button DW 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment7 DW 0 - DW 1 - DW Offset SetCompress -DriverSegment8 DW 0 - DB 7, 29, 20, 31, 8 - DB 0 - DB " Half", 0 - -SampleSize2Button DW 2 - DW 10, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetCompress -DriverSegment9 DW 0 - DW 2 - DW Offset SetCompress -DriverSegment10 DW 0 - DB 7, 32, 20, 34, 8 - DB 0 - DB " Quarter", 0 - - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - - -RelocationTable Label - DW Offset DriverSegment1 - DW Offset DriverSegment2 - DW Offset DriverSegment3 - DW Offset DriverSegment4 - DW Offset DriverSegment5 - DW Offset DriverSegment6 - DW Offset DriverSegment7 - DW Offset DriverSegment8 - DW Offset DriverSegment9 - DW Offset DriverSegment10 - DW 0FFFFh - -;*********** Local functions ******************* -; -; TestIW - Checks for the presence of a IW by detecting amount of memory. -; LoadIWSample - Loads a byte to IW memory, AL = value -; LoadIWSamples - Loads ECX bytes from DS:SI to IW memory -; -;*********************************************** - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMemory - - Push DS - Assume DS:Driver - - Push CS - Pop DS - - Mov IWMemory, 0 - - Mov DX, IWRegisterSelect - Mov AL, 52h - Out DX, AL - Inc DX - In AX, DX - Mov IWLMCFI, AX - And AX, 0FFF0h - Or AX, 0Ch ; Allow full 16MB addressing - - Mov NewIWLMCFI, AX - - Out DX, AX - - Mov CX, 256 - Xor EDI, EDI - -DetectMemory1: ; DX = BasePort+103h - Call IWSetPosition - - Xor AL, AL - Call LoadIWSample ; Write a 0 - - Add EDI, 10000h - Loop DetectMemory1 - - Mov EBX, 3 ; 4 banks, 3, 2, 1 and 0 - -DetectMemory2: - Mov EDI, EBX - ShL EDI, 22 ; DI = Bank * 4MB - Call IWSetPosition - - Mov AL, 0AAh - Mov DX, IWOutputPort - Out DX, AL - Mov AL, 055h - Out DX, AL - Call IWSetPosition - - Mov DX, IWOutputPort - - In AL, DX ; Bank doesn't exist? - Cmp AL, 0AAh - JNE DetectMemory3 - - In AL, DX - Cmp AL, 055h - JNE DetectMemory3 - - Mov CX, 64 ; Max of 4MB in 1 bank... - -DetectMemoryInnerLoop1: - Inc [IWBankTable+BX] - Inc IWMemory - - Add EDI, 10000h - Call IWSetPosition - - Mov DX, IWOutputPort - In AL, DX - Cmp AL, 0AAh - JE DetectMemory3 - - Loop DetectMemoryInnerLoop1 - -DetectMemory3: - Dec BX - JNS DetectMemory2 - - ; OK.. have checked each bank.. now to init. - Mov BL, 10 - Mov SI, Offset BankConfigs - Mov EAX, DWord Ptr IWBankTable - -DetectMemory4: - Cmp EAX, [SI] - JE DetectMemory5 - - Add SI, 4 - Dec BL - JNS DetectMemory4 - - Mov IWMemorySegmented, 1 - Jmp DetectMemory6 - -DetectMemory5: ; Set LMCI - Mov DX, IWRegisterSelect - Mov AL, 52h - Out DX, AL - Mov AX, IWLMCFI - - And AX, 0FFF0h - Or AL, BL - - Mov NewIWLMCFI, AX - - Inc DX - Out DX, AX - -DetectMemory6: - ShL IWMemory, 6 - JZ DetectMemory7 - - Pop DS - Ret - -DetectMemory7: - Pop DS - Pop AX ; Add SP, 2 - - StC - RetF - -EndP DetectMemory - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIW ; AX = baseport. - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DX, 103h ; DX = IGIDXR - - Comment ~ - - Mov AL, 4Ch - Out DX, AL - Add DL, 2 - Xor AL, AL - Out DX, AL - - Push DX - Mov DX, 300h - Mov CX, 20 -ResetIW4: - In AL, DX - Loop ResetIW4 - Pop DX - - Mov AL, 1 - Out DX, AL - - Push DX - Mov DX, 300h - Mov CX, 20 -ResetIW3: - In AL, DX - Loop ResetIW3 - Pop DX - - Sub DL, 2 - - ~ - - Mov AL, 19h ; Write SGMI - Out DX, AL - - Add DL, 2 - - Mov AL, 1 - Out DX, AL ; Enhanced mode enabled. - Sub DL, 2 - - Mov AL, 99h ; Read SGMI - Out DX, AL - Add DL, 2 - In AL, DX - Sub DL, 2 - - Cmp AL, 1 - JNE ResetIW1 - - Mov AL, 53h ; LMCI - Out DX, AL - - Add DL, 2 - Mov AL, 1 - Out DX, AL ; Auto increment, DRAM, 8-bit, NoInvert - Sub DL, 2 - - ClC - Jmp ResetIW2 - -ResetIW1: - StC - -ResetIW2: - Pop DX - Pop CX - Pop AX - - Ret - -EndP ResetIW - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TestIW - - - Call ResetIW - JC TestIW3 - - Push AX - - Mov IWMemory, 0 - - Mov DX, AX - Add DX, 103h ; DX = Select Register - - Mov CX, 256 ; Max amount is 16MB of memory - Xor BX, BX ; BX = no of 64k chunks. - -TestIW1: - ClI - - Mov AL, 44h ; IW DRAM High, 8 bit - Out DX, AL - - Add DL, 2 - Mov AX, BX ; BX = IW DRAM High - Out DX, AL - Sub DL, 2 ; DX = Select Register - - Mov AL, 43h ; IW DRAM Low, 16 bit - Out DX, AL - - Inc DX ; DX = Baseport+104h - Xor AX, AX - Out DX, AX ; Address 0 - - StI - - Add DL, 3 ; DX = Baseport+107h (DRAM I/O) - - Mov AL, 55h - Out DX, AL ; Write value 55h - Mov AL, 0AAh - Out DX, AL ; Write value 0AAh - Mov AL, CL - Out DX, AL ; Write value - - Sub DL, 3 ; DX = Baseport+104h - Xor AX, AX - Out DX, AX ; Address 0 - - Add DL, 3 ; DX = Baseport+107h - In AL, DX ; Read value.. - Cmp AL, 55h - JNE TestIW2 - - In AL, DX ; Read value.. - Cmp AL, 0AAh - JNE TestIW2 - - In AL, DX ; Read value.. - Cmp AL, CL - JNE TestIW2 - - Inc BX - Sub DL, 4 ; DX = Baseport+103h - Loop TestIW1 - -TestIW2: - Pop AX - - And BX, BX - JZ TestIW3 - - ShL BX, 6 - Mov IWMemory, BX - ClC - Ret - -TestIW3: - StC - Ret - -EndP TestIW - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc IWSetPosition ; EDI = position - - ClI - Mov DX, CS:IWRegisterSelect - Mov AL, 44h - Out DX, AL - - Add DL, 2 - SHLD EAX, EDI, 16 -; Mov EAX, EDI -; ShR EAX, 16 - Out DX, AL - Sub DL, 2 ; Select register again. - - Mov AL, 43h ; Address Low, 16 bit - Out DX, AL - Inc DX ; DX = 3x4h - - Mov AX, DI ; Memory location high - Out DX, AX ; Memory location done. - - StI - Ret - -EndP IWSetPosition - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadIWSample ; AL = value - - Mov DX, CS:IWOutputPort - Out DX, AL - - Ret - -EndP LoadIWSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadIWSamples ; Given DS:SI, ECX = count - ; EBP = step value. - - Mov DX, CS:IWOutputPort - -LoadIWSamples2: - Mov AL, [SI] - Add SI, BP - JC LoadIWSamples4 - -LoadIWSamples3: - Out DX, AL - - LoopD LoadIWSamples2 - Ret - -LoadIWSamples4: - Add ESI, 10000h - Int 3 - Jmp LoadIWSamples3 - -EndP LoadIWSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load16IWSamples ; Given DS:SI, ECX = count - ; EBP = step value. - - Add BP, BP - Dec BP - Mov BX, 1 - Xor BP, BX - Xor BX, BP - - Mov DX, CS:IWOutputPort - -Load16IWSamples1: - Xor BX, BP - Mov AL, [SI] - Add SI, BX - JC Load16IWSamples4 - -Load16IWSamples3: - Out DX, AL - - Dec ECX - JNZ Load16IWSamples1 - Ret - -Load16IWSamples4: - Add ESI, 10000h - Int 3 - Jmp Load16IWSamples3 - -EndP Load16IWSamples - -;*********** Public functions ****************** - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectIW Far - - Cmp BasePort, 0FFFFh - JE DetectIW1 - - Mov AX, BasePort - Call TestIW - JNC DetectIW3 - - Ret - -DetectIW1: - Mov AX, 210h - -DetectIW2: - Call TestIW - JNC DetectIW3 - - Add AL, 10h - Cmp AL, 60h - JBE DetectIW2 - - StC - Ret - -DetectIW3: - Mov BasePort, AX - Add AX, 102h - Mov IWVoiceSelect, AX - Inc AX - Mov IWRegisterSelect, AX - Add AL, 4 - Mov IWOutputPort, AX - - Call DetectMemory - - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectIW - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc IWIRQOnlyHandler - - PushAD - Push DS - Push ES - - Mov AL, 20h - - Cmp CS:IRQ, 8 - JB IWIRQOnlyHandler1 - - Out 0A0h, AL - -IWIRQOnlyHandler1: - Out 20h, AL - - Mov DX, CS:BasePort - Add DL, 6 - In AL, DX - And AL, 8 - JZ IWIRQOnlyHandler2 - - Mov DX, CS:IWRegisterSelect - Mov AL, 45h - Out DX, AL - Mov AL, 0 - Add DL, 2 - Out DX, AL - Mov AL, 8 - Out DX, AL - Sub DL, 2 - - ClD - - Call SaveEMSPageFrame - Call Update - Call SetIWRegisters - Call RestoreEMSPageFrame - -IWIRQOnlyHandler2: - Pop ES - Pop DS - PopAD - - IRet - -EndP IWIRQOnlyHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc IWIRQHandler ; IRQ Handler has to - ; 1) Update IW registers - ; 2) Update song position - Push AX - Push DS - - Mov AX, IWUpdateTimer - Add IWUpdateCount, AX - JC IWIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp IWIRQHandler2 - -IWIRQHandler1: - PushF - Call [OldIRQHandler] - -IWIRQHandler2: - Xor IWUpdateFlag, 1 - JZ IWIRQHandlerEnd - - PushAD - Push ES - - ClD - - Call SaveEMSPageFrame - Call Update ; Returns DS:SI, CX - Call SetIWRegisters - Call RestoreEMSPageFrame - - Pop ES - PopAD - -IWIRQHandlerEnd: - Pop DS - Pop AX - IRet - -EndP IWIRQHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIWVolume ; BX = new volume - - ; To do: - ; 1) Set ramp start - ; 2) Set ramp end - ; 3) Set current volume - ; 4) Start ramp - ; 5) Save new volume. - - Push BX - Push CX - - Mov AL, 0Dh - Out DX, AL - - Mov AL, 3 ; Stop Ramp! - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Add BX, BX - Mov CX, [CS:IWVolumeTable+BX] ; CX = new volume - Mov BX, [SI+2] - Add BX, BX - Mov BX, [CS:IWVolumeTable+BX] ; BX = old volume - - Cmp BX, CX - JNE SetIWVolume2 - - Mov AL, 89h - Out DX, AL - Inc DX - In AX, DX - Dec DX - - Mov BX, AX ; BX = old volume - -SetIWVolume2: - - Push BX ; Old volume on stack - - Xor AH, AH ; Ramp up - Cmp CX, BX - JE SetIWVolume4 - JA SetIWVolume1 - - XChg BX, CX - Mov AH, 40h ; Ramp down - -SetIWVolume1: - Mov AL, 6 ; Ramp rate - Out DX, AL - - Mov AL, 32 ; Ramp rate - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 7 ; Ramp start - Out DX, AL - - Mov AL, BH - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 8 ; Ramp end - Out DX, AL - - Mov AL, CH - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 9 - Out DX, AL - - Pop BX ; BX = old volume - XChg BX, AX - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Dh ; Ramp control - Out DX, AL - - Mov AL, BH - Add DL, 2 - Out DX, AL - Sub DL, 2 - -SetIWVolume5: - Pop CX - Pop BX - - Mov [SI+2], BX - - Ret - -SetIWVolume4: -; Mov AL, 0Dh ; Volume Ramp. -; Out DX, AL -; -; Mov AL, 3 -; Add DL, 2 -; Out DX, AL -; Sub DL, 2 - - Mov AL, 9 - Out DX, AL - - Pop AX ; AX = old volume - - Inc DX - Out DX, AX - Dec DX - - Jmp SetIWVolume5 - -EndP SetIWVolume - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc IWGetAddress ; Given EAX - - Push CX - - Mov CL, CS:Compress - ShR EAX, CL - - Pop CX - Add EAX, [CS:IWDataTable+BX] - ShL EAX, 9 - And EAX, 7FFFFFFFh - - Ret - -EndP IWGetAddress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIWRegisters ; Given DS:SI, CX - - Mov ES, CS:SongDataArea - - Push CX - Push SI - - Xor AX, AX - -GetOffsetLoop: - Push AX - Push CX - - Mov DX, IWVoiceSelect - Out DX, AL ; OK.. now to play with this - ; voice. - Inc DL ; DX = select rego - - Mov BX, [SI] - Test BH, 2 - JZ GetOffsetLoop2 - - Mov BX, 200h - Mov [SI], BX - -GetOffsetLoop2: - Test BL, 1 ; Channel not on! - JZ GetOffsetLoop1 - Test BH, 1 - JZ GetOffsetLoop3 ; Prev 1. - - Xor BX, BX - Call SetIWVolume - - Jmp GetOffsetLoop1 - -GetOffsetLoop3: - Mov EAX, [SI+4Ch] - Mov [SI+2Ch], EAX - - Mov AL, 8Ah - Out DX, AL - - Inc DX - In AX, DX - Dec DX - - And AH, 7Fh - ShL EAX, 16 ; Load high part of EAX - - Mov AL, 8Bh - Out DX, AL - Inc DX - In AX, DX - ; EAX = 000OOOOO OOOOOOOO OOOOOOOF FFFFFFFF - ; Need: 00000000 0000OOOO OOOOOOOO OOOOOOOO - - ShR EAX, 9 - - MovZX EBX, Byte Ptr [SI+36h] - Mov EBX, [CS:IWDataTable+EBX*4] - And EBX, 03FFFFFh - Sub EAX, EBX - Push CX - - Mov CL, CS:Compress - ShL EAX, CL - - Pop CX - Mov [SI+4Ch], EAX - -GetOffsetLoop1: - Add SI, SLAVECHANNELSIZE - - Pop CX - Pop AX - - Inc AX - Dec CX - JNZ GetOffsetLoop - - Pop SI - Pop CX - - Xor AX, AX - -SetIWRegisters1: - Push AX - Push CX - - Mov DX, IWVoiceSelect - Out DX, AL ; OK.. now to play with this - ; voice. - Mov CX, [SI] ; CX = flags. - Inc DL ; DX = select rego - - Test CH, 1 - JZ SetIWRegisters21 - - Mov AL, [SI+36] - Cmp AL, [SI+4] - JE SetIWRegisters21 - - Xor AL, AL - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - -SetIWRegisters21: - Test CL, 32 ; Frequency change - JZ SetIWRegisters7 - - Push DX - - Mov EAX, [SI+10h] ; EAX = freq. - - Push CX - Mov CL, CS:Compress - ShR EAX, CL - Pop CX - - Xor EDX, EDX - Mov EBX, MixSpeed - - Div EBX ; EAX = I portion. - - Test EAX, Not 63 - JNZ SetIWRegisters6 - - Push EAX - - Xor EAX, EAX - Div EBX - - Pop EBX ; EBX:EAX = IIII FFFF etc. - - SHRD EAX, EBX, 6 - - ; Have: IIIIIIII IIIIIIII FFFFFFFF FFFFFFFF - ; Req: IIIIIIFF FFFFFFF0 - - Pop DX - Mov AL, 1 - Out DX, AL - - ShR EAX, 16 - AdC AX, 0 - SBB AX, 0 ; Just in case! - - Inc DX - Out DX, AX - Dec DX - - Jmp SetIWRegisters7 - -SetIWRegisters6: - Mov CH, 2 ; Signify to turn off channel - Pop DX - -SetIWRegisters7: - MovZX BX, Byte Ptr [SI+36h] ; BX = sample number. - Cmp BL, 99 - JA SetIWRegisters20 - - ShL BX, 2 ; IWDataTable+BX = position - - Cmp DWord Ptr [CS:IWDataTable+BX], 0FFFFFFFFh - JNE SetIWRegisters10 - -SetIWRegisters20: - Mov CH, 2 - Jmp SetIWRegisters9 - -SetIWRegisters10: - Test CH, 5 ; Loop changed?!??!? - JZ SetIWRegisters8 - - Mov AL, 3 ; Starting location low. - Out DX, AL - - Mov EAX, [SI+40h] - Call IWGetAddress - - ; Reqd: .OOOOOOO OOOOOOOO OOOOOOOI III..... - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 2 ; Starting location high - Out DX, AL - - ShR EAX, 16 - Inc DX - Out DX, AX - Dec DX - - ; Ending location... - Mov AL, 5 ; Ending location low - Out DX, AL - - Mov EAX, [SI+44h] - Call IWGetAddress - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 4 ; Ending location high - Out DX, AL - - SHR EAX, 16 - Inc DX - Out DX, AX - Dec DX - -SetIWRegisters8: - Test CH, 1 ; Do Current position? - JZ SetIWRegisters9 - - Xor AL, AL - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 9 - Out DX, AL - Xor AX, AX - Inc DX - Out DX, AX - Dec DX - - Mov AL, 10h - Out DX, AL - Add DL, 2 - Mov AL, Byte Ptr [CS:IWDataTable+BX+2] - ShR AL, 6 - Out DX, AL - Sub DL, 2 - - Mov AL, 0Bh ; Current location LOW - Out DX, AL - - Mov EAX, [SI+4Ch] - Mov [SI+2Ch], EAX - - ; EAX = OOOOOOOO OOOOOOOO OOOOOOOO OOOOOOOO - ; Req: xOOOOOOO OOOOOOOO OOOOOOOF FFFFFFFF - Call IWGetAddress - - Mov DI, AX - - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Ah ; Current location HIGH - Out DX, AL - - SHR EAX, 16 - Inc DX - Out DX, AX - Dec DX - - Mov AL, 0Bh - Out DX, AL - - Mov AX, DI - Inc DX - Out DX, AX - Dec DX - -SetIWRegisters9: - Test CL, 64 ; New volume?? - JZ SetIWPan - -SetIWRegisters23: - Xor BX, BX - Test CH, 8 - JNZ SetIWRegistersMuted - - Mov BL, Byte Ptr [SI+20h] ; BL = volume, 0->128 - -SetIWRegistersMuted: - Call SetIWVolume - -SetIWPan: - Test CH, 128 ; New pan?? - JZ SetIWRegisters5 - - Xor BH, BH - - Test CS:Stereo, 1 - JZ SetIWRegisters3 - - Mov BL, [SI+37h] - Cmp BL, 100 - JNE SetIWRegisters4 - -SetIWRegisters3: - Mov BL, 32 ; Surround goes to mono :( - -SetIWRegisters4: - Add BX, BX ; BX = offset into IWTable - - Test CH, 1 - JZ IWSetPan1 - - Mov AL, 0Ch ; Right offset - Out DX, AL - Inc DX - Mov AX, [CS:OffsetTable+BX] - Out DX, AX - Dec DX - - Neg BX - - Mov AL, 13h ; Left offset final - Out DX, AL - Inc DX - Mov AX, [CS:OffsetTable+128+BX] - Out DX, AX - Dec DX - - Neg BX - -IWSetPan1: - Mov AL, 1Bh ; Right offset final - Out DX, AL - Inc DX - Mov AX, [CS:OffsetTable+BX] - Out DX, AX - Dec DX - - Neg BX - - Mov AL, 1Ch ; Left offset final - Out DX, AL - Inc DX - Mov AX, [CS:OffsetTable+128+BX] - Out DX, AX - Dec DX - -SetIWRegisters5: - ; Now for control register. - ; If CH | 2, then turn rego OFF - ; If CH | 5, then turn rego ON - ; If CL | 1, then check channel - Test CH, 2 - JNZ SetIWRegisters11 - - Test CH, 5 - JNZ SetIWRegisters12 - - Test CL, 1 - JZ SetIWRegisters13 - - Mov AL, 80h ; Read voice control - Out DX, AL - - Add DL, 2 - In AL, DX - Sub DL, 2 - - Test AL, 1 - JZ SetIWRegisters13 - - Xor BX, BX - Call SetIWVolume - - Jmp SetIWRegisters14 - -SetIWRegisters11: ; Turn off. - Mov Byte Ptr [SI+4], 0FFh - - Xor BX, BX - Call SetIWVolume - - Xor AL, AL - Out DX, AL - Mov AL, 2 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 15h - Out DX, AL - - Add DL, 2 ; Synthesizer Mode select - Mov AL, 34 ; Offset enable, enable voice - Out DX, AL - Sub DL, 2 - - -SetIWRegisters14: - Test CL, 1 - JZ SetIWRegisters13 - - Xor CX, CX ; Turn off channel - Test Byte Ptr [SI+3Ah], 80h - JNZ SetIWRegisters13 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - - Jmp SetIWRegisters13 - -SetIWRegisters12: ; Turn on - Mov AL, [SI+36] - Mov [SI+4], AL - - Mov AL, 15h - Out DX, AL - - Add DL, 2 ; Synthesizer Mode select - Mov AL, 32 ; Offset enable, enable voice - Out DX, AL - Sub DL, 2 - - Xor AL, AL - Out DX, AL - - Mov AL, [SI+0Ah] - - Cmp CS:Convert16To8Bit, 0 - JNZ SetIWRegistersNo16Bit - - Mov AH, [SI+18h] ; 16 bit? - Add AH, AH - Or AL, AH - -SetIWRegistersNo16Bit: - Test CL, 1 - JNZ SetIWRegisters15 - - Mov AL, 2 - Xor CX, CX - -SetIWRegisters15: - Add DL, 2 - Out DX, AL - -SetIWRegisters13: - And CX, 0111100010011111b ; Turns off: - ; 1) Freq & vol recalc - ; 2) New note/note stop/loop cha - - Mov [SI], CX - - Add SI, SLAVECHANNELSIZE - - Pop CX - Pop AX - - Inc AX - Dec CX - JNZ SetIWRegisters1 - - Ret - - -EndP SetIWRegisters - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov SI, Offset RelocationTable - -Relocation1: - LodsW - Cmp AX, 0FFFFh - JE RelocationEnd - - Mov BX, AX - Mov [BX], CS - Jmp Relocation1 - -RelocationEnd: ; OK... disable the IW Line In - ; & Enable Line Out - ; SetupMIDI - Mov DX, BasePort - Inc DH - Mov AL, 0FFh - Out DX, AL - Mov AL, 0FCh - Out DX, AL - - ; Setup the rest of it. - Mov DX, BasePort - Mov AL, 1 - Out DX, AL - - Mov DX, IWRegisterSelect - Mov AL, 0Eh - Out DX, AL ; DX = BasePort+103h - - Add DL, 2 ; DX = BasePort+105h - Mov AL, 0CDh - Out DX, AL ; Full mixing rate - - Mov CX, 32 - Sub DL, 3 - -IWResetVoice1: - Mov AL, CL - Dec AL - Out DX, AL - - Inc DX ; DX = BasePort + 103h - Xor AL, AL ; Voice control register, 8 bit - Out DX, AL - - Add DL, 2 - Mov AL, 3 - Out DX, AL ; Stop voice - Sub DL, 2 - - Mov AL, 0Dh ; Volume Ramp. - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 6 ; Ramp rate - Out DX, AL - - Mov AL, 32 ; Ramp rate - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 9 ; Volume register, 16 bit - Out DX, AL - - Inc DX - Xor AX, AX - Out DX, AX ; No volume - Dec DX - - Mov AL, 15h - Out DX, AL - - Add DL, 2 ; Synthesizer Mode select - Mov AL, 32 ; Offset enable, enable voice - Out DX, AL - - ClI - Sub DL, 3 ; DX = BasePort + 102h = Voice select. - - Loop IWResetVoice1 - - Inc DL - Mov AL, 5Bh - Out DX, AL - Add DL, 2 - In AL, DX - Sub DL, 2 - Shr AL, 4 ; AL = revision number - - Add AL, 'A' - Mov Revision, AL -; Cmp AL, 'C' -; JE InitSound_IW2 - -; Mov OffsetTable, Offset IWOffsetTable2 - -InitSound_IW2: - Cmp CS:IRQ, 0FFFFh - JE InitSound_IW1 - - Mov AX, BasePort - Call ResetIW - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - ; Set IRQ - Mov BX, IRQ - ShL BX, 2 ; BX points to offset in IRQData - - Xor DI, DI - Mov ES, DI - Mov DI, [BX+IRQData] - - And AX, [BX+IRQData+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset IWIRQOnlyHandler - - XChg [ES:DI], EAX - Mov OldIRQHandler, EAX - - StI - - Mov DX, BasePort - Mov AL, 9 - Out DX, AL - - Call GetTempo - Call SetTempo - Call ResetMemory - - Mov AL, Revision - Mov RevisionLetter2, AL - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, IWMemory - - Mov SI, Offset IWID2 - - ClC - Ret - -InitSound_IW1: - Mov AL, 4Ch - Out DX, AL - Add DL, 2 - Mov AL, 3 - Out DX, AL - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Call GetTempo - Call SetTempo - Call ResetMemory - - Mov DX, BasePort - Mov AL, 1 - Out DX, AL - - Xor AX, AX - Mov ES, AX ; ES = 0 - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset IWIRQHandler - - ClI - - XChg DWord Ptr [ES:20h], EAX ; Clock tick - Mov OldIRQHandler, EAX - - StI - - Mov AL, Revision - Mov RevisionLetter, AL - - Mov AX, BasePort - Mov BX, IWMemory - Mov SI, Offset IWID - - ClC - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - Mov SI, Offset IWReinitMsg - Mov BX, 40 - Call SetInfoLine - - Mov BX, CS:IRQ - Cmp BX, 0FFFFh - JE ReInitSound1 - - Mov AX, CS:IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - ShL BX, 2 - Xor DI, DI - Mov ES, DI - Mov DI, [CS:BX+IRQData] - Mov EAX, CS:OldIRQHandler - - Mov [ES:DI], EAX - - Jmp ReInitSound2 - -ReInitSound1: - Mov AL, 34h - Out 43h, AL - - Xor AX, AX - Out 40h, AL - Out 40h, AL - - Mov ES, AX - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - -ReInitSound2: - Mov DX, IWRegisterSelect - Mov AL, 52h - Out DX, AL - Inc DX - Mov AX, NewIWLMCFI - Out DX, AX - - Jmp RelocationEnd - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov AX, BasePort - Call ResetIW - - Mov DX, BasePort - Inc DH - Mov AL, 0FFh - Out DX, AL ; Stop MIDI - - Mov CX, 32 - Mov DX, CS:IWVoiceSelect - -IWResetVoice2: - Mov AL, CL - Dec AL - Out DX, AL - - Inc DX ; DX = BasePort + 103h - Xor AL, AL ; Voice control register, 8 bit - Out DX, AL - - Add DL, 2 - Mov AL, 3 - Out DX, AL ; Stop voice - Sub DL, 2 - - Mov AL, 0Dh ; Volume Ramp. - Out DX, AL - - Mov AL, 3 - Add DL, 2 - Out DX, AL - Sub DL, 2 - - Mov AL, 9 ; Volume register, 16 bit - Out DX, AL - - Inc DX - Xor AX, AX - Out DX, AX ; No volume - Dec DX - - Mov AL, 15h - Out DX, AL - - Add DL, 2 - Mov AL, 2 - Out DX, AL ; Deactivate voice - - ClI - Sub DL, 3 ; DX = BasePort + 102h = Voice select. - - Loop IWResetVoice2 - -; Inc DL -; Mov AL, 4Ch -; Out DX, AL -; Xor AL, AL -; Add DL, 2 -; Out DX, AL - - Mov BX, CS:IRQ - Cmp BX, 0FFFFh - JE UnInitSound1 - - Mov AX, CS:IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - ShL BX, 2 - Xor DI, DI - Mov ES, DI - Mov DI, [CS:BX+IRQData] - Mov EAX, CS:OldIRQHandler - - Mov [ES:DI], EAX - - Jmp UnInitSound2 - -UnInitSound1: - Mov AL, 34h - Out 43h, AL - - Xor AX, AX - Out 40h, AL - Out 40h, AL - - Mov ES, AX - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - -UnInitSound2: - Mov DX, IWRegisterSelect - Mov AL, 52h - Out DX, AL - Mov AX, IWLMCFI - Inc DX - Out DX, AX - - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - ClI - -Poll1: - Call [CS:UARTBufferEmpty] - JNC MIDIEnd - - Mov DX, [CS:BasePort] - Inc DH - In AL, DX - Test AL, 1 - JZ MIDIEnd - - Inc DX - In AL, DX - Cmp AL, 0F0h - JAE MIDIEnd - - Call [CS:UARTSend] - Jmp Poll1 - -MIDIEnd: - StI - - Ret - -EndP Poll - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut - - Push DX - Push AX - - Mov DX, [CS:BasePort] - Inc DH - -UARTOut1: - In AL, DX - Test AL, 2 - JZ UARTOut1 - - Pop AX - Inc DX - - Out DX, AL - - Pop DX - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Mov CS:InterpretState, 0 - -SendUARTOut4: - Ret - -SendUARTOut3: - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far ; BX = tempo... - - Push AX - Push BX - Push DX - - Cmp CS:IRQ, 0FFFFh - JE SetTempo1 - - ShL BX, 8 - Mov DX, 1Eh - Mov AX, 8480h - Div BX - Neg AL - - Mov AH, AL - - Mov DX, CS:IWRegisterSelect - - Mov AL, 47h - Out DX, AL - Add DL, 2 - Mov AL, AH - Out DX, AL ; Set Timer control register 2 - Sub DL, 2 - - Mov AL, 45h - Out DX, AL - Add DL, 2 - Mov AL, 8 - Out DX, AL -; Sub DL, 2 - - Mov DX, CS:BasePort - Add DL, 8 - Mov AL, 4 - Out DX, AL - - Inc DL - Mov AL, 2 - Out DX, AL - - Jmp SetTempo2 - -SetTempo1: - ; Frames per second = 2 * (0.4*Tempo) - Mov AX, 0C214h - Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo - Div BX - - ; AX contains counter. - Mov IWUpdateTimer, AX - - Out 40h, AL ; Timer IRQ. - Mov AL, AH - Out 40h, AL - -SetTempo2: - Pop DX - Pop BX - Pop AX - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - PushAD - Push DS - Push ES - Push FS - - Mov FS, CS:SongDataArea - Mov BP, AX - Dec BP - Add BP, BP - Mov BP, [FS:64912+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC Music_IWLoadSampleEnd - - Mov BL, [FS:BP+12h] - Test BL, 16 - JZ Music_IWLoadSample12 - - Cmp ECX, [FS:BP+38h] - JBE Music_IWLoadSample12 - - Mov ECX, [FS:BP+38h] - Test BL, 32 - JZ Music_IWLoadSample12 - - Cmp ECX, [FS:BP+44h] - JAE Music_IWLoadSample12 - - Mov ECX, [FS:BP+44h] - -Music_IWLoadSample12: - Mov EBX, ECX - Mov CL, CS:Compress - Mov EDX, 1 - ShR EBX, CL - ShL EDX, CL ; EDX = step value. - - Mov ECX, EBX - - ; Now find location to put it in - - Dec AX ; AX = sample number - Push AX ; AX = sample number (0 based) - - And EAX, 0FFh - Mov DWord Ptr [CS:IWDataTable+4*EAX], 0FFFFFFFFh - - Add ECX, 2 - - Cmp IWMemorySegmented, 0 - JNE Music_IWLoadSegmented1 - - Mov EAX, IWMemoryFree - - Test Byte Ptr [FS:BP+12h], 2 ; 16 bit?? - JZ Music_IWLoadSamples13 - - Cmp CS:Convert16To8Bit, 0 - JNZ Music_IWLoadSamples5 - - Sub EAX, 1 - JC Music_IWLoadSampleWarning - And EAX, Not 1 ; For alignment - Add ECX, ECX - Jmp Music_IWLoadSamples13 - -Music_IWLoadSamples5: - Inc ESI - Add EDX, EDX ; Step value. - -Music_IWLoadSamples13: - Cmp ECX, EAX - JBE Music_IWLoadSample2 - - ; Warning msg here. -Music_IWLoadSampleWarning: - Pop AX - ClC - Jmp Music_IWLoadSampleEnd - -Music_IWLoadSample3: - StC - -Music_IWLoadSampleEnd: - Pop FS - Pop ES - Pop DS - PopAD - - Ret - -Music_IWLoadSegmented1: - Test Byte Ptr [FS:BP+12h], 2 ; 16 bit?? - JZ Music_IWLoadSegmented3 - - Cmp CS:Convert16To8Bit, 0 - JNZ Music_IWLoadSegmented2 - - Add ECX, ECX - - ; Check each of 4 banks... - Xor BX, BX - -Music_Load16BitSegment1: - Mov EAX, [IWBank1+BX] - And EAX, Not 1 ; For alignment - Cmp ECX, EAX - JBE Music_LoadSegment2 - -Music_Load16BitSegment2: - Add BX, 4 - Cmp BX, 16 - JB Music_Load16BitSegment1 - Jmp Music_IWLoadSampleWarning - -Music_LoadSegment2: - Sub EAX, ECX - Mov [IWBank1+BX], EAX - ShL EBX, 20 - Add EBX, EAX - Jmp LoadIWSampleChain - -Music_IWLoadSegmented2: - Inc ESI - Add EDX, EDX ; Step value. - -Music_IWLoadSegmented3: - Xor BX, BX - -Music_Load8BitSegment1: - Mov EAX, [IWBank1+BX] - Cmp ECX, EAX - JBE Music_LoadSegment2 - - Add BX, 4 - Cmp BX, 16 - JB Music_Load8BitSegment1 - Jmp Music_IWLoadSampleWarning - -Music_IWLoadSample2: ; EAX = number of bytes free. - ; DS:SI = sample. - ; ECX = number of bytes of memory - ; ES:DI = num bytes free ptr - ; BP = sample number. - - ; Location = MaxMem - DX:AX - ; = -(DX:AX - IWBanks*4:0) - MovZX EBX, CS:IWMemory - ShL EBX, 10 - ; BX = bytes avail. - Sub EBX, EAX - Sub EAX, ECX - Mov IWMemoryFree, EAX - -LoadIWSampleChain: - Pop DI ; DI = sample number - - ShL DI, 2 - - Cmp CS:Convert16To8Bit, 0 - JNZ LoadIWForced8Bit - - Test Byte Ptr [FS:BP+12h], 2 - JNZ Music_IWLoad16BitSample - -LoadIWForced8Bit: - Push EBX - Inc EBX - Mov [CS:IWDataTable+DI], EBX ; Store pointer - - Mov ES, CS:SongDataArea - Pop EDI ; EDI = location in IW mem - - Sub ECX, 2 - ; EDI = location in IW mem - ; DS:SI = sample data - ; ECX = length. - ; EDX = step value. - ClI - - Push BP - - Mov EBP, EDX - - Call IWSetPosition - - Mov AL, [DS:SI+BP] - Call LoadIWSample - Call LoadIWSamples - - Mov BH, AL - - Pop BP - - Mov AL, [FS:BP+12h] - Test AL, 16 - JZ Music_IWLoadSample10 - - Mov ESI, [FS:BP+34h] - Test AL, 64 - JZ Music_IWLoadSample11 - - Mov ESI, [FS:BP+38h] - Sub ESI, 2 - AdC ESI, 0 - - Mov EAX, Not 0 - Mov CL, CS:Compress - ShL EAX, CL - And ESI, EAX - -Music_IWLoadSample11: - Test Byte Ptr [FS:BP+12h], 2 - JZ Music_IWLoadSample6 - - Add ESI, ESI - Inc SI - -Music_IWLoadSample6: - Int 3 - - Mov BH, [SI] - -Music_IWLoadSample10: - Mov AL, BH - Call LoadIWSample - - StI - Jmp Music_IWLoadSample3 ; Return.. no error. - -Music_IWLoad16BitSample: - Push EBX - - ShR EBX, 1 - Inc BX - Mov [CS:IWDataTable+DI], EBX - - Mov ES, CS:SongDataArea - Pop EDI ; EDI = location in IW mem - - Sub ECX, 4 - ClI - - Push BP - - Mov EBP, EDX - - Call IWSetPosition - - Mov AX, [DS:ESI+EBP*2] - Call LoadIWSample - Mov AL, AH - Call LoadIWSample - - Call Load16IWSamples - - Pop BP - - Xor BX, BX - - Mov AL, [FS:BP+12h] - Test AL, 16 - JZ Music_IWLoad16BitSample11B - - Mov ESI, [FS:BP+34h] - - Test AL, 64 - JZ Music_IWLoad16BitSample11 - - Mov ESI, [FS:BP+38h] - Sub ESI, 2 - JNC Music_IWLoad16BitSample11 - - Xor ESI, ESI - -Music_IWLoad16BitSample11: - Mov EAX, Not 0 - Mov CL, CS:Compress - ShL EAX, CL - And ESI, EAX - - Add ESI, ESI - Int 3 - - Mov BX, [SI] - -Music_IWLoad16BitSample11B: - Mov AX, BX - Call LoadIWSample - Mov AL, AH - Call LoadIWSample - - StI - Jmp Music_IWLoadSample3 ; Return.. no error. - - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release, 0 based -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - LEA DI, [EAX*4+Offset IWDataTable] - ; Now to release the last - ; sample from IW memory if - ; able to. - - Mov EBP, [CS:DI] ; EBP = sample pointer. - Cmp EBP, 0FFFFFFFFh - JE ReleaseSample3 - -ReleaseSample4: - MovZX EAX, CS:IWMemory - SHL EAX, 10 - - ; If (MaxMem-(sample location in bank + sample length + 2)) = memory remaining, - ; then release memory. - - Mov ECX, [SI+30h] - Mov DL, [SI+12h] - Test DL, 16 - JZ ReleaseSample7 - - Cmp ECX, [SI+38h] - JBE ReleaseSample7 - - Mov ECX, [SI+38h] - - Test DL, 32 - JZ ReleaseSample7 - - Cmp ECX, [SI+44h] - JAE ReleaseSample7 - - Mov ECX, [SI+44h] - -ReleaseSample7: - Push EBX - Mov EBX, ECX - Mov CL, CS:Compress - ShR EBX, CL - Mov ECX, EBX - Pop EBX - - Inc ECX - Mov EDI, 1 - - Test DL, 2 - JZ ReleaseSample8Bit - - Cmp CS:Convert16To8Bit, 0 - JNZ ReleaseSample8Bit - - Add ECX, ECX - Inc DI - - ; EBP = pointer for 16 bit - ; need to convert back: - Add EBP, EBP - -ReleaseSample8Bit: - Cmp IWMemorySegmented, 0 - JNE ReleaseSampleSegmented1 - - Sub EAX, EBP - Sub EAX, ECX - - Cmp EAX, IWMemoryFree - JNE ReleaseSample3 - - Add ECX, EDI - Add IWMemoryFree, ECX - - Ret - -ReleaseSampleSegmented1: ; EBP = sample pointer - ; if EBP-EDI = mem remaining in - ; segment, then add ECX+EDI... - Xor AX, AX - Sub EBP, EDI - Add ECX, EDI - Mov EDI, EBP - - And EBP, 3FFFFFh - - ShR EDI, 22 - And DI, 3 - Mov EAX, [IWBank1+EDI*4] - Cmp EAX, EBP - JNE ReleaseSample3 - - Add [IWBank1+EDI*4], ECX - -ReleaseSample3: - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Push EAX - Push CX - Push ES - Push DI - - MovZX EAX, IWMemory ; Number of kbytes - ShL EAX, 10 ; Translate to bytes - - Cmp IWMemorySegmented, 0 - JE ResetMemory1 - - Xor AH, AH - Mov AL, [IWBankTable] - ShL EAX, 16 - Mov IWBank1, EAX - - Xor AH, AH - Mov AL, [IWBankTable+1] - ShL EAX, 16 - Mov IWBank2, EAX - - Xor AH, AH - Mov AL, [IWBankTable+2] - ShL EAX, 16 - Mov IWBank3, EAX - - Xor AH, AH - Mov AL, [IWBankTable+3] - ShL EAX, 16 - Mov IWBank4, EAX - - Jmp ResetMemory2 - -ResetMemory1: - Sub EAX, 64 ; Safety bytes. - Mov IWMemoryFree, EAX - -ResetMemory2: - Push CS - Pop ES - Mov DI, Offset IWDataTable - Mov CX, 200 - Mov AX, 0FFFFh - Rep StosW - - Pop DI - Pop ES - Pop CX - Pop EAX - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - Push CS - Pop DS - Assume DS:Driver - - Mov EAX, IWMemoryFree - Cmp IWMemorySegmented, 0 - JE GetStatus1 - - Mov EAX, IWBank1 - Add EAX, IWBank2 - Add EAX, IWBank3 - Add EAX, IWBank4 - -GetStatus1: - Mov SI, Offset IWFreeMsg - ShR EAX, 10 - - ClC - - Ret - -EndP GetStatus - Assume DS:Nothing - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset IWScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetConvert Far - - Mov AX, [SI+22] - Mov CS:Convert16To8Bit, AL - Call Music_LoadAllSamples - - Mov AX, 1 - Ret - -EndP SetConvert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetConvert Far - - Push CS - Pop ES - Mov DI, Offset Convert16To8Bit - Ret - -EndP GetConvert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetCompress Far - - Mov AX, [SI+22] - Mov CS:Compress, AL - Call Music_LoadAllSamples - - Mov AX, 1 - Ret - -EndP SetCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetCompress Far - - Push CS - Pop ES - Mov DI, Offset Compress - - Ret - -EndP GetCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Constants Table ************* - -MaxNumberOfChannels DW 32 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 32 - -DriverFlags DW 1 ; MIDI Out suported - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - DW Offset DetectIW - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - - DW Offset SendUARTOut ; MIDI output! - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End - - *********************** Notes ******************* - - UltraSound Output Structure - - 0 1 2 3 4 5 6 7 8 9 - ÚÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂ -0000:³(Flags)³LastVol ³ - ÃÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÅ - - + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +;************************** + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;************** Local variables **************** + +SLAVECHANNELSIZE EQU 128 +MixSpeed = 44100 + +IWReinitMsg DB "Interwave reinitialised", 0 + +IWID DB "AMD Interwave, Revision " +RevisionLetter DB " ", 13 + DB "Port ", 0FDh, "Xh, ", 0FDh, "Dk Memory", 0 + +IWID2 DB "AMD Interwave, Revision " +RevisionLetter2 DB " ", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 + +IWFreeMsg DB "FreeIW ", 0FDh, "Dk", 0 + +IWVolumeTable Label Word + DW 00000h, 0A0C0h, 0ABE0h, 0B250h, 0B6F0h, 0BA80h, 0BD70h, 0BFE0h + DW 0C200h, 0C3F0h, 0C5A0h, 0C720h, 0C880h, 0C9D0h, 0CB00h, 0CC10h + DW 0CD20h, 0CE10h, 0CF00h, 0CFE0h, 0D0B0h, 0D180h, 0D230h, 0D2F0h + DW 0D3A0h, 0D440h, 0D4E0h, 0D580h, 0D610h, 0D6A0h, 0D730h, 0D7B0h + DW 0D830h, 0D8B0h, 0D930h, 0D9A0h, 0DA20h, 0DA90h, 0DAF0h, 0DB60h + DW 0DBC0h, 0DC30h, 0DC90h, 0DCF0h, 0DD50h, 0DDB0h, 0DE00h, 0DE60h + DW 0DEB0h, 0DF00h, 0DF60h, 0DFB0h, 0E000h, 0E050h, 0E090h, 0E0E0h + DW 0E130h, 0E170h, 0E1C0h, 0E200h, 0E240h, 0E290h, 0E2D0h, 0E310h + DW 0E350h, 0E390h, 0E3D0h, 0E410h, 0E440h, 0E480h, 0E4C0h, 0E4F0h + DW 0E530h, 0E560h, 0E5A0h, 0E5D0h, 0E610h, 0E640h, 0E670h, 0E6B0h + DW 0E6E0h, 0E710h, 0E740h, 0E770h, 0E7A0h, 0E7D0h, 0E800h, 0E830h + DW 0E860h, 0E890h, 0E8C0h, 0E8F0h, 0E920h, 0E940h, 0E970h, 0E9A0h + DW 0E9D0h, 0E9F0h, 0EA20h, 0EA40h, 0EA70h, 0EAA0h, 0EAC0h, 0EAF0h + DW 0EB10h, 0EB40h, 0EB60h, 0EB80h, 0EBB0h, 0EBD0h, 0EBF0h, 0EC20h + DW 0EC40h, 0EC60h, 0EC90h, 0ECB0h, 0ECD0h, 0ECF0h, 0ED10h, 0ED40h + DW 0ED60h, 0ED80h, 0EDA0h, 0EDC0h, 0EDE0h, 0EE00h, 0EE20h, 0EE40h + DW 0EE60h + +OffsetTable Label Word + DW 0FFF0h, 03000h, 02800h, 02350h, 02000h, 01D60h, 01B50h, 01980h + DW 01800h, 016A0h, 01560h, 01450h, 01350h, 01260h, 01180h, 010B0h + DW 01000h, 00F40h, 00EA0h, 00E00h, 00D60h, 00CD0h, 00C50h, 00BC0h + DW 00B50h, 00AD0h, 00A60h, 009F0h, 00980h, 00920h, 008B0h, 00850h + DW 00800h, 007A0h, 00740h, 006F0h, 006A0h, 00650h, 00600h, 005B0h + DW 00560h, 00520h, 004D0h, 00490h, 00450h, 00410h, 003C0h, 00390h + DW 00350h, 00310h, 002D0h, 00290h, 00260h, 00220h, 001F0h, 001B0h + DW 00180h, 00150h, 00120h, 000F0h, 000B0h, 00080h, 00050h, 00020h + DW 00000h + + +IWMemory DW 0 ; kb of memory on IW +IWRegisterSelect DW 0 +IWVoiceSelect DW 0 +IWUpdateTimer DW 0 +IWUpdateCount DW 0 +IWMemoryFree DD 0 +IWOutputPort DW 0 +IWUpdateFlag DB 0 +IWMemorySegmented DB 0 + +IWLMCFI DW 0 +IWBankTable DB 0, 0, 0, 0 + +IWBank1 DD 0 +IWBank2 DD 0 +IWBank3 DD 0 +IWBank4 DD 0 + +OldIRQHandler DD 0 + +Convert16To8Bit DB 0 + DB 0 +Compress DB 0 + DB 0 +Stereo DB 0 + +NewIWLMCFI DW 0 + +IWDataTable DD 100 Dup (0FFFFFFFFh) +Revision DB 0 + +BankConfigs Label ; 12 configs.. +; DB 64, 64, 64, 64 ; 12 +; DB 64, 64, 0, 0 ; 11 + DB 64, 0, 0, 0 ; 10 + DB 16, 16, 16, 16 ; 9 + DB 16, 16, 0, 0 ; 8 + DB 16, 0, 0, 0 ; 7 + DB 4, 4, 16, 16 ; 6 + DB 4, 4, 16, 0 ; 5 + DB 4, 16, 16, 16 ; 4 + DB 4, 16, 0, 0 ; 3 + DB 4, 4, 4, 4 ; 2 + DB 4, 4, 0, 0 ; 1 + DB 4, 0, 0, 0 ; 0 + + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +IMR DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IWScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr GravisHeaderLine + + DW SampleText ; 4 + + DW ConvertSampleText + DW ConvertDisabledButton ; 6 + DW ConvertEnabledButton + + DW SampleSizeText ; 8 + DW SampleSize0Button ; 9 + DW SampleSize1Button + DW SampleSize2Button + + DW DriverText + + DW 0 + +GravisHeaderLine DW 10 + DB "Interwave Driver", 0 + +DriverText DW 1 + DB 38, 48 + DB 21h + DB "Interwave Driver 1.1 for Impulse Tracker", 0 + +SampleText DW 1 + DB 3, 13 + DB 20h + DB "Sample resizing options", 0 + +ConvertSampleText DW 1 + DB 5, 15 + DB 20h + DB "Reduce 16 bit samples to 8 bit", 0 + +ConvertDisabledButton DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetConvert +DriverSegment1 DW 0 + DW 0 + DW Offset SetConvert +DriverSegment2 DW 0 + DB 7, 17, 20, 19, 8 + DB 0 + DB " Disabled", 0 + +ConvertEnabledButton DW 2 + DW 6, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetConvert +DriverSegment3 DW 0 + DW 1 + DW Offset SetConvert +DriverSegment4 DW 0 + DB 7, 20, 20, 22, 8 + DB 0 + DB " Enabled", 0 + +SampleSizeText DW 1 + DB 5, 24 + DB 20h + DB "Sample size", 0 + +SampleSize0Button DW 2 + DW 7, 10, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment5 DW 0 + DW 0 + DW Offset SetCompress +DriverSegment6 DW 0 + DB 7, 26, 20, 28, 8 + DB 0 + DB " Original", 0 + +SampleSize1Button DW 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment7 DW 0 + DW 1 + DW Offset SetCompress +DriverSegment8 DW 0 + DB 7, 29, 20, 31, 8 + DB 0 + DB " Half", 0 + +SampleSize2Button DW 2 + DW 10, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetCompress +DriverSegment9 DW 0 + DW 2 + DW Offset SetCompress +DriverSegment10 DW 0 + DB 7, 32, 20, 34, 8 + DB 0 + DB " Quarter", 0 + + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + + +RelocationTable Label + DW Offset DriverSegment1 + DW Offset DriverSegment2 + DW Offset DriverSegment3 + DW Offset DriverSegment4 + DW Offset DriverSegment5 + DW Offset DriverSegment6 + DW Offset DriverSegment7 + DW Offset DriverSegment8 + DW Offset DriverSegment9 + DW Offset DriverSegment10 + DW 0FFFFh + +;*********** Local functions ******************* +; +; TestIW - Checks for the presence of a IW by detecting amount of memory. +; LoadIWSample - Loads a byte to IW memory, AL = value +; LoadIWSamples - Loads ECX bytes from DS:SI to IW memory +; +;*********************************************** + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMemory + + Push DS + Assume DS:Driver + + Push CS + Pop DS + + Mov IWMemory, 0 + + Mov DX, IWRegisterSelect + Mov AL, 52h + Out DX, AL + Inc DX + In AX, DX + Mov IWLMCFI, AX + And AX, 0FFF0h + Or AX, 0Ch ; Allow full 16MB addressing + + Mov NewIWLMCFI, AX + + Out DX, AX + + Mov CX, 256 + Xor EDI, EDI + +DetectMemory1: ; DX = BasePort+103h + Call IWSetPosition + + Xor AL, AL + Call LoadIWSample ; Write a 0 + + Add EDI, 10000h + Loop DetectMemory1 + + Mov EBX, 3 ; 4 banks, 3, 2, 1 and 0 + +DetectMemory2: + Mov EDI, EBX + ShL EDI, 22 ; DI = Bank * 4MB + Call IWSetPosition + + Mov AL, 0AAh + Mov DX, IWOutputPort + Out DX, AL + Mov AL, 055h + Out DX, AL + Call IWSetPosition + + Mov DX, IWOutputPort + + In AL, DX ; Bank doesn't exist? + Cmp AL, 0AAh + JNE DetectMemory3 + + In AL, DX + Cmp AL, 055h + JNE DetectMemory3 + + Mov CX, 64 ; Max of 4MB in 1 bank... + +DetectMemoryInnerLoop1: + Inc [IWBankTable+BX] + Inc IWMemory + + Add EDI, 10000h + Call IWSetPosition + + Mov DX, IWOutputPort + In AL, DX + Cmp AL, 0AAh + JE DetectMemory3 + + Loop DetectMemoryInnerLoop1 + +DetectMemory3: + Dec BX + JNS DetectMemory2 + + ; OK.. have checked each bank.. now to init. + Mov BL, 10 + Mov SI, Offset BankConfigs + Mov EAX, DWord Ptr IWBankTable + +DetectMemory4: + Cmp EAX, [SI] + JE DetectMemory5 + + Add SI, 4 + Dec BL + JNS DetectMemory4 + + Mov IWMemorySegmented, 1 + Jmp DetectMemory6 + +DetectMemory5: ; Set LMCI + Mov DX, IWRegisterSelect + Mov AL, 52h + Out DX, AL + Mov AX, IWLMCFI + + And AX, 0FFF0h + Or AL, BL + + Mov NewIWLMCFI, AX + + Inc DX + Out DX, AX + +DetectMemory6: + ShL IWMemory, 6 + JZ DetectMemory7 + + Pop DS + Ret + +DetectMemory7: + Pop DS + Pop AX ; Add SP, 2 + + StC + RetF + +EndP DetectMemory + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIW ; AX = baseport. + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DX, 103h ; DX = IGIDXR + + Comment ~ + + Mov AL, 4Ch + Out DX, AL + Add DL, 2 + Xor AL, AL + Out DX, AL + + Push DX + Mov DX, 300h + Mov CX, 20 +ResetIW4: + In AL, DX + Loop ResetIW4 + Pop DX + + Mov AL, 1 + Out DX, AL + + Push DX + Mov DX, 300h + Mov CX, 20 +ResetIW3: + In AL, DX + Loop ResetIW3 + Pop DX + + Sub DL, 2 + + ~ + + Mov AL, 19h ; Write SGMI + Out DX, AL + + Add DL, 2 + + Mov AL, 1 + Out DX, AL ; Enhanced mode enabled. + Sub DL, 2 + + Mov AL, 99h ; Read SGMI + Out DX, AL + Add DL, 2 + In AL, DX + Sub DL, 2 + + Cmp AL, 1 + JNE ResetIW1 + + Mov AL, 53h ; LMCI + Out DX, AL + + Add DL, 2 + Mov AL, 1 + Out DX, AL ; Auto increment, DRAM, 8-bit, NoInvert + Sub DL, 2 + + ClC + Jmp ResetIW2 + +ResetIW1: + StC + +ResetIW2: + Pop DX + Pop CX + Pop AX + + Ret + +EndP ResetIW + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TestIW + + + Call ResetIW + JC TestIW3 + + Push AX + + Mov IWMemory, 0 + + Mov DX, AX + Add DX, 103h ; DX = Select Register + + Mov CX, 256 ; Max amount is 16MB of memory + Xor BX, BX ; BX = no of 64k chunks. + +TestIW1: + ClI + + Mov AL, 44h ; IW DRAM High, 8 bit + Out DX, AL + + Add DL, 2 + Mov AX, BX ; BX = IW DRAM High + Out DX, AL + Sub DL, 2 ; DX = Select Register + + Mov AL, 43h ; IW DRAM Low, 16 bit + Out DX, AL + + Inc DX ; DX = Baseport+104h + Xor AX, AX + Out DX, AX ; Address 0 + + StI + + Add DL, 3 ; DX = Baseport+107h (DRAM I/O) + + Mov AL, 55h + Out DX, AL ; Write value 55h + Mov AL, 0AAh + Out DX, AL ; Write value 0AAh + Mov AL, CL + Out DX, AL ; Write value + + Sub DL, 3 ; DX = Baseport+104h + Xor AX, AX + Out DX, AX ; Address 0 + + Add DL, 3 ; DX = Baseport+107h + In AL, DX ; Read value.. + Cmp AL, 55h + JNE TestIW2 + + In AL, DX ; Read value.. + Cmp AL, 0AAh + JNE TestIW2 + + In AL, DX ; Read value.. + Cmp AL, CL + JNE TestIW2 + + Inc BX + Sub DL, 4 ; DX = Baseport+103h + Loop TestIW1 + +TestIW2: + Pop AX + + And BX, BX + JZ TestIW3 + + ShL BX, 6 + Mov IWMemory, BX + ClC + Ret + +TestIW3: + StC + Ret + +EndP TestIW + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc IWSetPosition ; EDI = position + + ClI + Mov DX, CS:IWRegisterSelect + Mov AL, 44h + Out DX, AL + + Add DL, 2 + SHLD EAX, EDI, 16 +; Mov EAX, EDI +; ShR EAX, 16 + Out DX, AL + Sub DL, 2 ; Select register again. + + Mov AL, 43h ; Address Low, 16 bit + Out DX, AL + Inc DX ; DX = 3x4h + + Mov AX, DI ; Memory location high + Out DX, AX ; Memory location done. + + StI + Ret + +EndP IWSetPosition + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadIWSample ; AL = value + + Mov DX, CS:IWOutputPort + Out DX, AL + + Ret + +EndP LoadIWSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadIWSamples ; Given DS:SI, ECX = count + ; EBP = step value. + + Mov DX, CS:IWOutputPort + +LoadIWSamples2: + Mov AL, [SI] + Add SI, BP + JC LoadIWSamples4 + +LoadIWSamples3: + Out DX, AL + + LoopD LoadIWSamples2 + Ret + +LoadIWSamples4: + Add ESI, 10000h + Int 3 + Jmp LoadIWSamples3 + +EndP LoadIWSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load16IWSamples ; Given DS:SI, ECX = count + ; EBP = step value. + + Add BP, BP + Dec BP + Mov BX, 1 + Xor BP, BX + Xor BX, BP + + Mov DX, CS:IWOutputPort + +Load16IWSamples1: + Xor BX, BP + Mov AL, [SI] + Add SI, BX + JC Load16IWSamples4 + +Load16IWSamples3: + Out DX, AL + + Dec ECX + JNZ Load16IWSamples1 + Ret + +Load16IWSamples4: + Add ESI, 10000h + Int 3 + Jmp Load16IWSamples3 + +EndP Load16IWSamples + +;*********** Public functions ****************** + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectIW Far + + Cmp BasePort, 0FFFFh + JE DetectIW1 + + Mov AX, BasePort + Call TestIW + JNC DetectIW3 + + Ret + +DetectIW1: + Mov AX, 210h + +DetectIW2: + Call TestIW + JNC DetectIW3 + + Add AL, 10h + Cmp AL, 60h + JBE DetectIW2 + + StC + Ret + +DetectIW3: + Mov BasePort, AX + Add AX, 102h + Mov IWVoiceSelect, AX + Inc AX + Mov IWRegisterSelect, AX + Add AL, 4 + Mov IWOutputPort, AX + + Call DetectMemory + + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectIW + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc IWIRQOnlyHandler + + PushAD + Push DS + Push ES + + Mov AL, 20h + + Cmp CS:IRQ, 8 + JB IWIRQOnlyHandler1 + + Out 0A0h, AL + +IWIRQOnlyHandler1: + Out 20h, AL + + Mov DX, CS:BasePort + Add DL, 6 + In AL, DX + And AL, 8 + JZ IWIRQOnlyHandler2 + + Mov DX, CS:IWRegisterSelect + Mov AL, 45h + Out DX, AL + Mov AL, 0 + Add DL, 2 + Out DX, AL + Mov AL, 8 + Out DX, AL + Sub DL, 2 + + ClD + + Call SaveEMSPageFrame + Call Update + Call SetIWRegisters + Call RestoreEMSPageFrame + +IWIRQOnlyHandler2: + Pop ES + Pop DS + PopAD + + IRet + +EndP IWIRQOnlyHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc IWIRQHandler ; IRQ Handler has to + ; 1) Update IW registers + ; 2) Update song position + Push AX + Push DS + + Mov AX, IWUpdateTimer + Add IWUpdateCount, AX + JC IWIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp IWIRQHandler2 + +IWIRQHandler1: + PushF + Call [OldIRQHandler] + +IWIRQHandler2: + Xor IWUpdateFlag, 1 + JZ IWIRQHandlerEnd + + PushAD + Push ES + + ClD + + Call SaveEMSPageFrame + Call Update ; Returns DS:SI, CX + Call SetIWRegisters + Call RestoreEMSPageFrame + + Pop ES + PopAD + +IWIRQHandlerEnd: + Pop DS + Pop AX + IRet + +EndP IWIRQHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIWVolume ; BX = new volume + + ; To do: + ; 1) Set ramp start + ; 2) Set ramp end + ; 3) Set current volume + ; 4) Start ramp + ; 5) Save new volume. + + Push BX + Push CX + + Mov AL, 0Dh + Out DX, AL + + Mov AL, 3 ; Stop Ramp! + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Add BX, BX + Mov CX, [CS:IWVolumeTable+BX] ; CX = new volume + Mov BX, [SI+2] + Add BX, BX + Mov BX, [CS:IWVolumeTable+BX] ; BX = old volume + + Cmp BX, CX + JNE SetIWVolume2 + + Mov AL, 89h + Out DX, AL + Inc DX + In AX, DX + Dec DX + + Mov BX, AX ; BX = old volume + +SetIWVolume2: + + Push BX ; Old volume on stack + + Xor AH, AH ; Ramp up + Cmp CX, BX + JE SetIWVolume4 + JA SetIWVolume1 + + XChg BX, CX + Mov AH, 40h ; Ramp down + +SetIWVolume1: + Mov AL, 6 ; Ramp rate + Out DX, AL + + Mov AL, 32 ; Ramp rate + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 7 ; Ramp start + Out DX, AL + + Mov AL, BH + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 8 ; Ramp end + Out DX, AL + + Mov AL, CH + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 9 + Out DX, AL + + Pop BX ; BX = old volume + XChg BX, AX + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Dh ; Ramp control + Out DX, AL + + Mov AL, BH + Add DL, 2 + Out DX, AL + Sub DL, 2 + +SetIWVolume5: + Pop CX + Pop BX + + Mov [SI+2], BX + + Ret + +SetIWVolume4: +; Mov AL, 0Dh ; Volume Ramp. +; Out DX, AL +; +; Mov AL, 3 +; Add DL, 2 +; Out DX, AL +; Sub DL, 2 + + Mov AL, 9 + Out DX, AL + + Pop AX ; AX = old volume + + Inc DX + Out DX, AX + Dec DX + + Jmp SetIWVolume5 + +EndP SetIWVolume + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc IWGetAddress ; Given EAX + + Push CX + + Mov CL, CS:Compress + ShR EAX, CL + + Pop CX + Add EAX, [CS:IWDataTable+BX] + ShL EAX, 9 + And EAX, 7FFFFFFFh + + Ret + +EndP IWGetAddress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIWRegisters ; Given DS:SI, CX + + Mov ES, CS:SongDataArea + + Push CX + Push SI + + Xor AX, AX + +GetOffsetLoop: + Push AX + Push CX + + Mov DX, IWVoiceSelect + Out DX, AL ; OK.. now to play with this + ; voice. + Inc DL ; DX = select rego + + Mov BX, [SI] + Test BH, 2 + JZ GetOffsetLoop2 + + Mov BX, 200h + Mov [SI], BX + +GetOffsetLoop2: + Test BL, 1 ; Channel not on! + JZ GetOffsetLoop1 + Test BH, 1 + JZ GetOffsetLoop3 ; Prev 1. + + Xor BX, BX + Call SetIWVolume + + Jmp GetOffsetLoop1 + +GetOffsetLoop3: + Mov EAX, [SI+4Ch] + Mov [SI+2Ch], EAX + + Mov AL, 8Ah + Out DX, AL + + Inc DX + In AX, DX + Dec DX + + And AH, 7Fh + ShL EAX, 16 ; Load high part of EAX + + Mov AL, 8Bh + Out DX, AL + Inc DX + In AX, DX + ; EAX = 000OOOOO OOOOOOOO OOOOOOOF FFFFFFFF + ; Need: 00000000 0000OOOO OOOOOOOO OOOOOOOO + + ShR EAX, 9 + + MovZX EBX, Byte Ptr [SI+36h] + Mov EBX, [CS:IWDataTable+EBX*4] + And EBX, 03FFFFFh + Sub EAX, EBX + Push CX + + Mov CL, CS:Compress + ShL EAX, CL + + Pop CX + Mov [SI+4Ch], EAX + +GetOffsetLoop1: + Add SI, SLAVECHANNELSIZE + + Pop CX + Pop AX + + Inc AX + Dec CX + JNZ GetOffsetLoop + + Pop SI + Pop CX + + Xor AX, AX + +SetIWRegisters1: + Push AX + Push CX + + Mov DX, IWVoiceSelect + Out DX, AL ; OK.. now to play with this + ; voice. + Mov CX, [SI] ; CX = flags. + Inc DL ; DX = select rego + + Test CH, 1 + JZ SetIWRegisters21 + + Mov AL, [SI+36] + Cmp AL, [SI+4] + JE SetIWRegisters21 + + Xor AL, AL + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + +SetIWRegisters21: + Test CL, 32 ; Frequency change + JZ SetIWRegisters7 + + Push DX + + Mov EAX, [SI+10h] ; EAX = freq. + + Push CX + Mov CL, CS:Compress + ShR EAX, CL + Pop CX + + Xor EDX, EDX + Mov EBX, MixSpeed + + Div EBX ; EAX = I portion. + + Test EAX, Not 63 + JNZ SetIWRegisters6 + + Push EAX + + Xor EAX, EAX + Div EBX + + Pop EBX ; EBX:EAX = IIII FFFF etc. + + SHRD EAX, EBX, 6 + + ; Have: IIIIIIII IIIIIIII FFFFFFFF FFFFFFFF + ; Req: IIIIIIFF FFFFFFF0 + + Pop DX + Mov AL, 1 + Out DX, AL + + ShR EAX, 16 + AdC AX, 0 + SBB AX, 0 ; Just in case! + + Inc DX + Out DX, AX + Dec DX + + Jmp SetIWRegisters7 + +SetIWRegisters6: + Mov CH, 2 ; Signify to turn off channel + Pop DX + +SetIWRegisters7: + MovZX BX, Byte Ptr [SI+36h] ; BX = sample number. + Cmp BL, 99 + JA SetIWRegisters20 + + ShL BX, 2 ; IWDataTable+BX = position + + Cmp DWord Ptr [CS:IWDataTable+BX], 0FFFFFFFFh + JNE SetIWRegisters10 + +SetIWRegisters20: + Mov CH, 2 + Jmp SetIWRegisters9 + +SetIWRegisters10: + Test CH, 5 ; Loop changed?!??!? + JZ SetIWRegisters8 + + Mov AL, 3 ; Starting location low. + Out DX, AL + + Mov EAX, [SI+40h] + Call IWGetAddress + + ; Reqd: .OOOOOOO OOOOOOOO OOOOOOOI III..... + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 2 ; Starting location high + Out DX, AL + + ShR EAX, 16 + Inc DX + Out DX, AX + Dec DX + + ; Ending location... + Mov AL, 5 ; Ending location low + Out DX, AL + + Mov EAX, [SI+44h] + Call IWGetAddress + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 4 ; Ending location high + Out DX, AL + + SHR EAX, 16 + Inc DX + Out DX, AX + Dec DX + +SetIWRegisters8: + Test CH, 1 ; Do Current position? + JZ SetIWRegisters9 + + Xor AL, AL + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 9 + Out DX, AL + Xor AX, AX + Inc DX + Out DX, AX + Dec DX + + Mov AL, 10h + Out DX, AL + Add DL, 2 + Mov AL, Byte Ptr [CS:IWDataTable+BX+2] + ShR AL, 6 + Out DX, AL + Sub DL, 2 + + Mov AL, 0Bh ; Current location LOW + Out DX, AL + + Mov EAX, [SI+4Ch] + Mov [SI+2Ch], EAX + + ; EAX = OOOOOOOO OOOOOOOO OOOOOOOO OOOOOOOO + ; Req: xOOOOOOO OOOOOOOO OOOOOOOF FFFFFFFF + Call IWGetAddress + + Mov DI, AX + + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Ah ; Current location HIGH + Out DX, AL + + SHR EAX, 16 + Inc DX + Out DX, AX + Dec DX + + Mov AL, 0Bh + Out DX, AL + + Mov AX, DI + Inc DX + Out DX, AX + Dec DX + +SetIWRegisters9: + Test CL, 64 ; New volume?? + JZ SetIWPan + +SetIWRegisters23: + Xor BX, BX + Test CH, 8 + JNZ SetIWRegistersMuted + + Mov BL, Byte Ptr [SI+20h] ; BL = volume, 0->128 + +SetIWRegistersMuted: + Call SetIWVolume + +SetIWPan: + Test CH, 128 ; New pan?? + JZ SetIWRegisters5 + + Xor BH, BH + + Test CS:Stereo, 1 + JZ SetIWRegisters3 + + Mov BL, [SI+37h] + Cmp BL, 100 + JNE SetIWRegisters4 + +SetIWRegisters3: + Mov BL, 32 ; Surround goes to mono :( + +SetIWRegisters4: + Add BX, BX ; BX = offset into IWTable + + Test CH, 1 + JZ IWSetPan1 + + Mov AL, 0Ch ; Right offset + Out DX, AL + Inc DX + Mov AX, [CS:OffsetTable+BX] + Out DX, AX + Dec DX + + Neg BX + + Mov AL, 13h ; Left offset final + Out DX, AL + Inc DX + Mov AX, [CS:OffsetTable+128+BX] + Out DX, AX + Dec DX + + Neg BX + +IWSetPan1: + Mov AL, 1Bh ; Right offset final + Out DX, AL + Inc DX + Mov AX, [CS:OffsetTable+BX] + Out DX, AX + Dec DX + + Neg BX + + Mov AL, 1Ch ; Left offset final + Out DX, AL + Inc DX + Mov AX, [CS:OffsetTable+128+BX] + Out DX, AX + Dec DX + +SetIWRegisters5: + ; Now for control register. + ; If CH | 2, then turn rego OFF + ; If CH | 5, then turn rego ON + ; If CL | 1, then check channel + Test CH, 2 + JNZ SetIWRegisters11 + + Test CH, 5 + JNZ SetIWRegisters12 + + Test CL, 1 + JZ SetIWRegisters13 + + Mov AL, 80h ; Read voice control + Out DX, AL + + Add DL, 2 + In AL, DX + Sub DL, 2 + + Test AL, 1 + JZ SetIWRegisters13 + + Xor BX, BX + Call SetIWVolume + + Jmp SetIWRegisters14 + +SetIWRegisters11: ; Turn off. + Mov Byte Ptr [SI+4], 0FFh + + Xor BX, BX + Call SetIWVolume + + Xor AL, AL + Out DX, AL + Mov AL, 2 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 15h + Out DX, AL + + Add DL, 2 ; Synthesizer Mode select + Mov AL, 34 ; Offset enable, enable voice + Out DX, AL + Sub DL, 2 + + +SetIWRegisters14: + Test CL, 1 + JZ SetIWRegisters13 + + Xor CX, CX ; Turn off channel + Test Byte Ptr [SI+3Ah], 80h + JNZ SetIWRegisters13 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + + Jmp SetIWRegisters13 + +SetIWRegisters12: ; Turn on + Mov AL, [SI+36] + Mov [SI+4], AL + + Mov AL, 15h + Out DX, AL + + Add DL, 2 ; Synthesizer Mode select + Mov AL, 32 ; Offset enable, enable voice + Out DX, AL + Sub DL, 2 + + Xor AL, AL + Out DX, AL + + Mov AL, [SI+0Ah] + + Cmp CS:Convert16To8Bit, 0 + JNZ SetIWRegistersNo16Bit + + Mov AH, [SI+18h] ; 16 bit? + Add AH, AH + Or AL, AH + +SetIWRegistersNo16Bit: + Test CL, 1 + JNZ SetIWRegisters15 + + Mov AL, 2 + Xor CX, CX + +SetIWRegisters15: + Add DL, 2 + Out DX, AL + +SetIWRegisters13: + And CX, 0111100010011111b ; Turns off: + ; 1) Freq & vol recalc + ; 2) New note/note stop/loop cha + + Mov [SI], CX + + Add SI, SLAVECHANNELSIZE + + Pop CX + Pop AX + + Inc AX + Dec CX + JNZ SetIWRegisters1 + + Ret + + +EndP SetIWRegisters + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov SI, Offset RelocationTable + +Relocation1: + LodsW + Cmp AX, 0FFFFh + JE RelocationEnd + + Mov BX, AX + Mov [BX], CS + Jmp Relocation1 + +RelocationEnd: ; OK... disable the IW Line In + ; & Enable Line Out + ; SetupMIDI + Mov DX, BasePort + Inc DH + Mov AL, 0FFh + Out DX, AL + Mov AL, 0FCh + Out DX, AL + + ; Setup the rest of it. + Mov DX, BasePort + Mov AL, 1 + Out DX, AL + + Mov DX, IWRegisterSelect + Mov AL, 0Eh + Out DX, AL ; DX = BasePort+103h + + Add DL, 2 ; DX = BasePort+105h + Mov AL, 0CDh + Out DX, AL ; Full mixing rate + + Mov CX, 32 + Sub DL, 3 + +IWResetVoice1: + Mov AL, CL + Dec AL + Out DX, AL + + Inc DX ; DX = BasePort + 103h + Xor AL, AL ; Voice control register, 8 bit + Out DX, AL + + Add DL, 2 + Mov AL, 3 + Out DX, AL ; Stop voice + Sub DL, 2 + + Mov AL, 0Dh ; Volume Ramp. + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 6 ; Ramp rate + Out DX, AL + + Mov AL, 32 ; Ramp rate + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 9 ; Volume register, 16 bit + Out DX, AL + + Inc DX + Xor AX, AX + Out DX, AX ; No volume + Dec DX + + Mov AL, 15h + Out DX, AL + + Add DL, 2 ; Synthesizer Mode select + Mov AL, 32 ; Offset enable, enable voice + Out DX, AL + + ClI + Sub DL, 3 ; DX = BasePort + 102h = Voice select. + + Loop IWResetVoice1 + + Inc DL + Mov AL, 5Bh + Out DX, AL + Add DL, 2 + In AL, DX + Sub DL, 2 + Shr AL, 4 ; AL = revision number + + Add AL, 'A' + Mov Revision, AL +; Cmp AL, 'C' +; JE InitSound_IW2 + +; Mov OffsetTable, Offset IWOffsetTable2 + +InitSound_IW2: + Cmp CS:IRQ, 0FFFFh + JE InitSound_IW1 + + Mov AX, BasePort + Call ResetIW + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + ; Set IRQ + Mov BX, IRQ + ShL BX, 2 ; BX points to offset in IRQData + + Xor DI, DI + Mov ES, DI + Mov DI, [BX+IRQData] + + And AX, [BX+IRQData+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset IWIRQOnlyHandler + + XChg [ES:DI], EAX + Mov OldIRQHandler, EAX + + StI + + Mov DX, BasePort + Mov AL, 9 + Out DX, AL + + Call GetTempo + Call SetTempo + Call ResetMemory + + Mov AL, Revision + Mov RevisionLetter2, AL + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, IWMemory + + Mov SI, Offset IWID2 + + ClC + Ret + +InitSound_IW1: + Mov AL, 4Ch + Out DX, AL + Add DL, 2 + Mov AL, 3 + Out DX, AL + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Call GetTempo + Call SetTempo + Call ResetMemory + + Mov DX, BasePort + Mov AL, 1 + Out DX, AL + + Xor AX, AX + Mov ES, AX ; ES = 0 + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset IWIRQHandler + + ClI + + XChg DWord Ptr [ES:20h], EAX ; Clock tick + Mov OldIRQHandler, EAX + + StI + + Mov AL, Revision + Mov RevisionLetter, AL + + Mov AX, BasePort + Mov BX, IWMemory + Mov SI, Offset IWID + + ClC + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + Mov SI, Offset IWReinitMsg + Mov BX, 40 + Call SetInfoLine + + Mov BX, CS:IRQ + Cmp BX, 0FFFFh + JE ReInitSound1 + + Mov AX, CS:IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + ShL BX, 2 + Xor DI, DI + Mov ES, DI + Mov DI, [CS:BX+IRQData] + Mov EAX, CS:OldIRQHandler + + Mov [ES:DI], EAX + + Jmp ReInitSound2 + +ReInitSound1: + Mov AL, 34h + Out 43h, AL + + Xor AX, AX + Out 40h, AL + Out 40h, AL + + Mov ES, AX + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + +ReInitSound2: + Mov DX, IWRegisterSelect + Mov AL, 52h + Out DX, AL + Inc DX + Mov AX, NewIWLMCFI + Out DX, AX + + Jmp RelocationEnd + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov AX, BasePort + Call ResetIW + + Mov DX, BasePort + Inc DH + Mov AL, 0FFh + Out DX, AL ; Stop MIDI + + Mov CX, 32 + Mov DX, CS:IWVoiceSelect + +IWResetVoice2: + Mov AL, CL + Dec AL + Out DX, AL + + Inc DX ; DX = BasePort + 103h + Xor AL, AL ; Voice control register, 8 bit + Out DX, AL + + Add DL, 2 + Mov AL, 3 + Out DX, AL ; Stop voice + Sub DL, 2 + + Mov AL, 0Dh ; Volume Ramp. + Out DX, AL + + Mov AL, 3 + Add DL, 2 + Out DX, AL + Sub DL, 2 + + Mov AL, 9 ; Volume register, 16 bit + Out DX, AL + + Inc DX + Xor AX, AX + Out DX, AX ; No volume + Dec DX + + Mov AL, 15h + Out DX, AL + + Add DL, 2 + Mov AL, 2 + Out DX, AL ; Deactivate voice + + ClI + Sub DL, 3 ; DX = BasePort + 102h = Voice select. + + Loop IWResetVoice2 + +; Inc DL +; Mov AL, 4Ch +; Out DX, AL +; Xor AL, AL +; Add DL, 2 +; Out DX, AL + + Mov BX, CS:IRQ + Cmp BX, 0FFFFh + JE UnInitSound1 + + Mov AX, CS:IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + ShL BX, 2 + Xor DI, DI + Mov ES, DI + Mov DI, [CS:BX+IRQData] + Mov EAX, CS:OldIRQHandler + + Mov [ES:DI], EAX + + Jmp UnInitSound2 + +UnInitSound1: + Mov AL, 34h + Out 43h, AL + + Xor AX, AX + Out 40h, AL + Out 40h, AL + + Mov ES, AX + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + +UnInitSound2: + Mov DX, IWRegisterSelect + Mov AL, 52h + Out DX, AL + Mov AX, IWLMCFI + Inc DX + Out DX, AX + + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + ClI + +Poll1: + Call [CS:UARTBufferEmpty] + JNC MIDIEnd + + Mov DX, [CS:BasePort] + Inc DH + In AL, DX + Test AL, 1 + JZ MIDIEnd + + Inc DX + In AL, DX + Cmp AL, 0F0h + JAE MIDIEnd + + Call [CS:UARTSend] + Jmp Poll1 + +MIDIEnd: + StI + + Ret + +EndP Poll + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut + + Push DX + Push AX + + Mov DX, [CS:BasePort] + Inc DH + +UARTOut1: + In AL, DX + Test AL, 2 + JZ UARTOut1 + + Pop AX + Inc DX + + Out DX, AL + + Pop DX + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Mov CS:InterpretState, 0 + +SendUARTOut4: + Ret + +SendUARTOut3: + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far ; BX = tempo... + + Push AX + Push BX + Push DX + + Cmp CS:IRQ, 0FFFFh + JE SetTempo1 + + ShL BX, 8 + Mov DX, 1Eh + Mov AX, 8480h + Div BX + Neg AL + + Mov AH, AL + + Mov DX, CS:IWRegisterSelect + + Mov AL, 47h + Out DX, AL + Add DL, 2 + Mov AL, AH + Out DX, AL ; Set Timer control register 2 + Sub DL, 2 + + Mov AL, 45h + Out DX, AL + Add DL, 2 + Mov AL, 8 + Out DX, AL +; Sub DL, 2 + + Mov DX, CS:BasePort + Add DL, 8 + Mov AL, 4 + Out DX, AL + + Inc DL + Mov AL, 2 + Out DX, AL + + Jmp SetTempo2 + +SetTempo1: + ; Frames per second = 2 * (0.4*Tempo) + Mov AX, 0C214h + Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo + Div BX + + ; AX contains counter. + Mov IWUpdateTimer, AX + + Out 40h, AL ; Timer IRQ. + Mov AL, AH + Out 40h, AL + +SetTempo2: + Pop DX + Pop BX + Pop AX + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + PushAD + Push DS + Push ES + Push FS + + Mov FS, CS:SongDataArea + Mov BP, AX + Dec BP + Add BP, BP + Mov BP, [FS:64912+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC Music_IWLoadSampleEnd + + Mov BL, [FS:BP+12h] + Test BL, 16 + JZ Music_IWLoadSample12 + + Cmp ECX, [FS:BP+38h] + JBE Music_IWLoadSample12 + + Mov ECX, [FS:BP+38h] + Test BL, 32 + JZ Music_IWLoadSample12 + + Cmp ECX, [FS:BP+44h] + JAE Music_IWLoadSample12 + + Mov ECX, [FS:BP+44h] + +Music_IWLoadSample12: + Mov EBX, ECX + Mov CL, CS:Compress + Mov EDX, 1 + ShR EBX, CL + ShL EDX, CL ; EDX = step value. + + Mov ECX, EBX + + ; Now find location to put it in + + Dec AX ; AX = sample number + Push AX ; AX = sample number (0 based) + + And EAX, 0FFh + Mov DWord Ptr [CS:IWDataTable+4*EAX], 0FFFFFFFFh + + Add ECX, 2 + + Cmp IWMemorySegmented, 0 + JNE Music_IWLoadSegmented1 + + Mov EAX, IWMemoryFree + + Test Byte Ptr [FS:BP+12h], 2 ; 16 bit?? + JZ Music_IWLoadSamples13 + + Cmp CS:Convert16To8Bit, 0 + JNZ Music_IWLoadSamples5 + + Sub EAX, 1 + JC Music_IWLoadSampleWarning + And EAX, Not 1 ; For alignment + Add ECX, ECX + Jmp Music_IWLoadSamples13 + +Music_IWLoadSamples5: + Inc ESI + Add EDX, EDX ; Step value. + +Music_IWLoadSamples13: + Cmp ECX, EAX + JBE Music_IWLoadSample2 + + ; Warning msg here. +Music_IWLoadSampleWarning: + Pop AX + ClC + Jmp Music_IWLoadSampleEnd + +Music_IWLoadSample3: + StC + +Music_IWLoadSampleEnd: + Pop FS + Pop ES + Pop DS + PopAD + + Ret + +Music_IWLoadSegmented1: + Test Byte Ptr [FS:BP+12h], 2 ; 16 bit?? + JZ Music_IWLoadSegmented3 + + Cmp CS:Convert16To8Bit, 0 + JNZ Music_IWLoadSegmented2 + + Add ECX, ECX + + ; Check each of 4 banks... + Xor BX, BX + +Music_Load16BitSegment1: + Mov EAX, [IWBank1+BX] + And EAX, Not 1 ; For alignment + Cmp ECX, EAX + JBE Music_LoadSegment2 + +Music_Load16BitSegment2: + Add BX, 4 + Cmp BX, 16 + JB Music_Load16BitSegment1 + Jmp Music_IWLoadSampleWarning + +Music_LoadSegment2: + Sub EAX, ECX + Mov [IWBank1+BX], EAX + ShL EBX, 20 + Add EBX, EAX + Jmp LoadIWSampleChain + +Music_IWLoadSegmented2: + Inc ESI + Add EDX, EDX ; Step value. + +Music_IWLoadSegmented3: + Xor BX, BX + +Music_Load8BitSegment1: + Mov EAX, [IWBank1+BX] + Cmp ECX, EAX + JBE Music_LoadSegment2 + + Add BX, 4 + Cmp BX, 16 + JB Music_Load8BitSegment1 + Jmp Music_IWLoadSampleWarning + +Music_IWLoadSample2: ; EAX = number of bytes free. + ; DS:SI = sample. + ; ECX = number of bytes of memory + ; ES:DI = num bytes free ptr + ; BP = sample number. + + ; Location = MaxMem - DX:AX + ; = -(DX:AX - IWBanks*4:0) + MovZX EBX, CS:IWMemory + ShL EBX, 10 + ; BX = bytes avail. + Sub EBX, EAX + Sub EAX, ECX + Mov IWMemoryFree, EAX + +LoadIWSampleChain: + Pop DI ; DI = sample number + + ShL DI, 2 + + Cmp CS:Convert16To8Bit, 0 + JNZ LoadIWForced8Bit + + Test Byte Ptr [FS:BP+12h], 2 + JNZ Music_IWLoad16BitSample + +LoadIWForced8Bit: + Push EBX + Inc EBX + Mov [CS:IWDataTable+DI], EBX ; Store pointer + + Mov ES, CS:SongDataArea + Pop EDI ; EDI = location in IW mem + + Sub ECX, 2 + ; EDI = location in IW mem + ; DS:SI = sample data + ; ECX = length. + ; EDX = step value. + ClI + + Push BP + + Mov EBP, EDX + + Call IWSetPosition + + Mov AL, [DS:SI+BP] + Call LoadIWSample + Call LoadIWSamples + + Mov BH, AL + + Pop BP + + Mov AL, [FS:BP+12h] + Test AL, 16 + JZ Music_IWLoadSample10 + + Mov ESI, [FS:BP+34h] + Test AL, 64 + JZ Music_IWLoadSample11 + + Mov ESI, [FS:BP+38h] + Sub ESI, 2 + AdC ESI, 0 + + Mov EAX, Not 0 + Mov CL, CS:Compress + ShL EAX, CL + And ESI, EAX + +Music_IWLoadSample11: + Test Byte Ptr [FS:BP+12h], 2 + JZ Music_IWLoadSample6 + + Add ESI, ESI + Inc SI + +Music_IWLoadSample6: + Int 3 + + Mov BH, [SI] + +Music_IWLoadSample10: + Mov AL, BH + Call LoadIWSample + + StI + Jmp Music_IWLoadSample3 ; Return.. no error. + +Music_IWLoad16BitSample: + Push EBX + + ShR EBX, 1 + Inc BX + Mov [CS:IWDataTable+DI], EBX + + Mov ES, CS:SongDataArea + Pop EDI ; EDI = location in IW mem + + Sub ECX, 4 + ClI + + Push BP + + Mov EBP, EDX + + Call IWSetPosition + + Mov AX, [DS:ESI+EBP*2] + Call LoadIWSample + Mov AL, AH + Call LoadIWSample + + Call Load16IWSamples + + Pop BP + + Xor BX, BX + + Mov AL, [FS:BP+12h] + Test AL, 16 + JZ Music_IWLoad16BitSample11B + + Mov ESI, [FS:BP+34h] + + Test AL, 64 + JZ Music_IWLoad16BitSample11 + + Mov ESI, [FS:BP+38h] + Sub ESI, 2 + JNC Music_IWLoad16BitSample11 + + Xor ESI, ESI + +Music_IWLoad16BitSample11: + Mov EAX, Not 0 + Mov CL, CS:Compress + ShL EAX, CL + And ESI, EAX + + Add ESI, ESI + Int 3 + + Mov BX, [SI] + +Music_IWLoad16BitSample11B: + Mov AX, BX + Call LoadIWSample + Mov AL, AH + Call LoadIWSample + + StI + Jmp Music_IWLoadSample3 ; Return.. no error. + + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release, 0 based +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + LEA DI, [EAX*4+Offset IWDataTable] + ; Now to release the last + ; sample from IW memory if + ; able to. + + Mov EBP, [CS:DI] ; EBP = sample pointer. + Cmp EBP, 0FFFFFFFFh + JE ReleaseSample3 + +ReleaseSample4: + MovZX EAX, CS:IWMemory + SHL EAX, 10 + + ; If (MaxMem-(sample location in bank + sample length + 2)) = memory remaining, + ; then release memory. + + Mov ECX, [SI+30h] + Mov DL, [SI+12h] + Test DL, 16 + JZ ReleaseSample7 + + Cmp ECX, [SI+38h] + JBE ReleaseSample7 + + Mov ECX, [SI+38h] + + Test DL, 32 + JZ ReleaseSample7 + + Cmp ECX, [SI+44h] + JAE ReleaseSample7 + + Mov ECX, [SI+44h] + +ReleaseSample7: + Push EBX + Mov EBX, ECX + Mov CL, CS:Compress + ShR EBX, CL + Mov ECX, EBX + Pop EBX + + Inc ECX + Mov EDI, 1 + + Test DL, 2 + JZ ReleaseSample8Bit + + Cmp CS:Convert16To8Bit, 0 + JNZ ReleaseSample8Bit + + Add ECX, ECX + Inc DI + + ; EBP = pointer for 16 bit + ; need to convert back: + Add EBP, EBP + +ReleaseSample8Bit: + Cmp IWMemorySegmented, 0 + JNE ReleaseSampleSegmented1 + + Sub EAX, EBP + Sub EAX, ECX + + Cmp EAX, IWMemoryFree + JNE ReleaseSample3 + + Add ECX, EDI + Add IWMemoryFree, ECX + + Ret + +ReleaseSampleSegmented1: ; EBP = sample pointer + ; if EBP-EDI = mem remaining in + ; segment, then add ECX+EDI... + Xor AX, AX + Sub EBP, EDI + Add ECX, EDI + Mov EDI, EBP + + And EBP, 3FFFFFh + + ShR EDI, 22 + And DI, 3 + Mov EAX, [IWBank1+EDI*4] + Cmp EAX, EBP + JNE ReleaseSample3 + + Add [IWBank1+EDI*4], ECX + +ReleaseSample3: + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Push EAX + Push CX + Push ES + Push DI + + MovZX EAX, IWMemory ; Number of kbytes + ShL EAX, 10 ; Translate to bytes + + Cmp IWMemorySegmented, 0 + JE ResetMemory1 + + Xor AH, AH + Mov AL, [IWBankTable] + ShL EAX, 16 + Mov IWBank1, EAX + + Xor AH, AH + Mov AL, [IWBankTable+1] + ShL EAX, 16 + Mov IWBank2, EAX + + Xor AH, AH + Mov AL, [IWBankTable+2] + ShL EAX, 16 + Mov IWBank3, EAX + + Xor AH, AH + Mov AL, [IWBankTable+3] + ShL EAX, 16 + Mov IWBank4, EAX + + Jmp ResetMemory2 + +ResetMemory1: + Sub EAX, 64 ; Safety bytes. + Mov IWMemoryFree, EAX + +ResetMemory2: + Push CS + Pop ES + Mov DI, Offset IWDataTable + Mov CX, 200 + Mov AX, 0FFFFh + Rep StosW + + Pop DI + Pop ES + Pop CX + Pop EAX + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + Push CS + Pop DS + Assume DS:Driver + + Mov EAX, IWMemoryFree + Cmp IWMemorySegmented, 0 + JE GetStatus1 + + Mov EAX, IWBank1 + Add EAX, IWBank2 + Add EAX, IWBank3 + Add EAX, IWBank4 + +GetStatus1: + Mov SI, Offset IWFreeMsg + ShR EAX, 10 + + ClC + + Ret + +EndP GetStatus + Assume DS:Nothing + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset IWScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetConvert Far + + Mov AX, [SI+22] + Mov CS:Convert16To8Bit, AL + Call Music_LoadAllSamples + + Mov AX, 1 + Ret + +EndP SetConvert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetConvert Far + + Push CS + Pop ES + Mov DI, Offset Convert16To8Bit + Ret + +EndP GetConvert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetCompress Far + + Mov AX, [SI+22] + Mov CS:Compress, AL + Call Music_LoadAllSamples + + Mov AX, 1 + Ret + +EndP SetCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetCompress Far + + Push CS + Pop ES + Mov DI, Offset Compress + + Ret + +EndP GetCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Constants Table ************* + +MaxNumberOfChannels DW 32 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 32 + +DriverFlags DW 1 ; MIDI Out suported + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + DW Offset DetectIW + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + + DW Offset SendUARTOut ; MIDI output! + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End + + *********************** Notes ******************* + + UltraSound Output Structure + + 0 1 2 3 4 5 6 7 8 9 + ÚÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂ +0000:³(Flags)³LastVol ³ + ÃÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÅÄÄÄÂÄÄÄÅ + + diff --git a/SoundDrivers/K6MSAM.INC b/SoundDrivers/K6MSAM.INC index 445a223..7f56208 100755 --- a/SoundDrivers/K6MSAM.INC +++ b/SoundDrivers/K6MSAM.INC @@ -1,388 +1,388 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Align 4 -include q.inc -FilterParameters DB 64 Dup (07Fh), 64 Dup (0) -Const2048 DD 16384.0 -FreqMultiplier DD 3A9F7867h ; = 1/(2*PI*110.0*2^0.25) -FreqParameterMultiplier DD 0B92AAAAAh ; = -1/(24*256) - -NUMBEROFFILTERBANDS = 4 - -IF OUTPUTFILTERENABLED -LastFilter DD NUMBEROFFILTERBANDS*2 Dup (0) ; 4 stereo values -FilterCoefficients DD NUMBEROFFILTERBANDS*2 Dup (0) -FilterVolumes DD NUMBEROFFILTERBANDS Dup (0) -ENDIF - -FilterFreqValue DW 0 -NewControlWord DW 7Fh - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - Assume DS:Nothing - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, CS:MixSegment - Mov DI, DMABUFFERLENGTH*2+80 - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov CS:MixTransferOffset, DI - - Cmp CS:Stereo, 0 - JE CS:MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD - Mov CS:MixTransferRemaining, DX - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamplesNoStop - - And Byte Ptr [SI], Not 1 - - Cmp MixMode, 2 - JB MixSamplesEnd - - Mov DWord Ptr [SI+0Ch], 0 - Jmp MixModeCommon - -MixSamplesNoStop: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Xor EAX, EAX - Mov [SI+3Ch], AX ; For filter. - Mov [SI+6Eh], AX - - Mov DWord Ptr [SI+1Ch], EAX ; Current Volume = 0 - ; for volume sliding. - Mov [SI+06h], DX - Mov [SI+5Eh], AX - Mov [SI+7Eh], AX - -MixSamples5: - Test CX, 8540h ; New volume or panning? - JZ MixSamplesMix - - Mov AX, 4*60 - - Test CH, 8 ; Muted? - JZ MixMMXNoMute - - Xor EDX, EDX - Mov [SI+06h], DX - Mov [SI+0Ch], EDX - Mov [SI+5Eh], DX - Mov [SI+1Ch], EDX - Mov [SI+6Eh], DX - Mov [SI+3Ch], DX - Mov [SI+7Eh], DX - - Xor BX, BX - Mov BL, [SI+3Ah] - - Test BL, BL - JS MixModeCommon1 - - Mov DL, [CS:FilterParameters+BX] - Mov BL, [CS:FilterParameters+BX+64] - - Mov [SI+5Bh], DL - Mov [SI+3Fh], BL - - Jmp MixModeCommon1 - -MixMMXNoMute: - Xor BX, BX - Mov BL, [SI+3Ah] - - Test BL, BL ; Disowned? Then use channel filters. - JNS MixGetChannelFilters - - Mov BL, [SI+3Fh] - Jmp MixChannelFilters - -MixGetChannelFilters: - ; Filter = [FilterParameters+BX] - ; Q = [FilterParameters+BX+64] - - Mov AL, [CS:FilterParameters+BX] ; AX = Filter - Mov BL, [CS:FilterParameters+BX+64] ; BX = Q - -; If the values are different, then force recalculate volume. (and hence mixmode) - - Cmp [SI+5Bh], AL - JE MixChannelFiltersSame - Cmp [SI+3Fh], BL - JE MixChannelFiltersSame - - Mov DWord Ptr [SI+0Ch], 0 - -MixChannelFiltersSame: - Mov [SI+5Bh], AL - Mov [SI+3Fh], BL - -MixChannelFilters: - Cmp MixMode, 3 - JNE MixMMXNoFilters - - Mov AL, [SI+3Eh] - Mul Byte Ptr [SI+5Bh] - - Mov CS:FilterFreqValue, AX - - Cmp AX, 127*255 - JNE MixChannelFiltersOK - Test BL, BL - JZ MixMMXNoFilters - -MixChannelFiltersOK: - ShL BX, 2 - - FNInit - FLdCW [CS:NewControlWord] - - FILD [CS:FilterFreqValue] ; 0->127*256 - FMul [CS:FreqParameterMultiplier] ; -i/(24*256) - FLd ST - FRndInt - FSub ST(1), ST - FXCh - F2XM1 - FLd1 - FAdd - FScale ; = 2^(i/24*256) - FMul [CS:FreqMultiplier] ; = r - FLd ST ; r, r - FMul ST(1), ST ; r, r^2 - - FLd [CS:QualityFactorTable+BX] ; 2d, r, r^2 - FMul ST(1), ST ; 2d, 2dr, r^2 - FAdd - - FLd1 ; 1, d+1, e - FXCh ; d+1, 1, e - FSubR ST(1), ST - FAdd ST, ST(2) ; 1+d+e, d, e - FDivR Const2048 ; 1/(1+d+e), d, e - FISt Word Ptr [SI+5Eh] ; - FLd ST(2) ; e, 1/(1+d+e), d, e - FAdd ST, ST - FAddP ST(2), ST ; 1/(1+d+e), d+2e, e - FMul ST(2), ST ; 1/(1+d+e), d+2e, e/(1+d+e) - FMul - FIStP Word Ptr [SI+6Eh] - FChs - FIStP Word Ptr [SI+7Eh] - FStP ST - Mov DWord Ptr [SI+0Ch], 0 - -MixMMXNoFilters: - Mov EBX, [SI+0Ch] - - Cmp Stereo, 0 - JNE MixMMXStereo - -MixMMXMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - - Jmp MixModeVolumeCheck - -MixMMXStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE MixMMXSurround - - Mul Byte Ptr MixVolume ; 0->128 - Mul Word Ptr [SI+4Ah] ; 0->32768 - ShRD AX, DX, 15 ; Maxvol = 8192 - Mov [SI+0Eh], AX ; Store into right volume - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 15 - Mov [SI+0Ch], AX - - Jmp MixModeVolumeCheck - -MixMMXSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 10 - Mov [SI+0Ch], AX - Neg AX - Mov [SI+0Eh], AX - -MixModeVolumeCheck: - Test CH, 3+4 - JNZ MixModeCommon - - Cmp EBX, [SI+0Ch] ; Same as last volume? - JE MixSamplesMix - -MixModeCommon: ; Requires AX = 30 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov AX, MixModeOffset - - Cmp DWord Ptr [SI+0Ch], 0 - JNE MixModeActualMix - - Cmp MixMode, 2 - JB MixMMXGeneralNoRamp - - Cmp DWord Ptr [SI+1Ch], 0 - JNE MixModeActualMix - -MixMMXGeneralNoRamp: - Mov AX, 4*60 - Jmp MixModeCommon1 - -MixModeActualMix: - Cmp MixMode, 3 - JNE MixModeFilter - - Cmp Word Ptr [SI+6Eh], 0 - JNE MixModeFilter - Cmp Word Ptr [SI+7Eh], 0 - JNE MixModeFilter - - Sub AX, 60 - -MixModeFilter: - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 30 - -MixModeCommon1: - Cmp Byte Ptr [SI+0Ah], 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, DMABUFFERLENGTH*2+80 - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Push Word Ptr [SI+8] - Call Word Ptr [CS:BX] - Pop BX - - And Word Ptr [SI], 0111100010001101b - - Cmp BX, Offset MixFunctionTables+60*2 - JB MixSamplesEnd - Cmp BX, Offset MixFunctionTables+60*4 - JAE MixSamplesEnd - - MovDR AX, MM6 - Mov [SI+0Ch], EAX - Mov [SI+1Ch], EAX - - Cmp BX, Offset MixfunctionTables+60*3 - JB MixSamplesEnd - - Mov ES, CS:MixSegment - Mov DX, [ES:10h] - Mov BX, [ES:14h] - Mov [SI+3Ch], DX - Mov [SI+6h], BX - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - -IF OUTPUTFILTERENABLED - include equalize.inc -ENDIF - Ret - -EndP MixSamples - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Align 4 +include q.inc +FilterParameters DB 64 Dup (07Fh), 64 Dup (0) +Const2048 DD 16384.0 +FreqMultiplier DD 3A9F7867h ; = 1/(2*PI*110.0*2^0.25) +FreqParameterMultiplier DD 0B92AAAAAh ; = -1/(24*256) + +NUMBEROFFILTERBANDS = 4 + +IF OUTPUTFILTERENABLED +LastFilter DD NUMBEROFFILTERBANDS*2 Dup (0) ; 4 stereo values +FilterCoefficients DD NUMBEROFFILTERBANDS*2 Dup (0) +FilterVolumes DD NUMBEROFFILTERBANDS Dup (0) +ENDIF + +FilterFreqValue DW 0 +NewControlWord DW 7Fh + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + Assume DS:Nothing + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, CS:MixSegment + Mov DI, DMABUFFERLENGTH*2+80 + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov CS:MixTransferOffset, DI + + Cmp CS:Stereo, 0 + JE CS:MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD + Mov CS:MixTransferRemaining, DX + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamplesNoStop + + And Byte Ptr [SI], Not 1 + + Cmp MixMode, 2 + JB MixSamplesEnd + + Mov DWord Ptr [SI+0Ch], 0 + Jmp MixModeCommon + +MixSamplesNoStop: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Xor EAX, EAX + Mov [SI+3Ch], AX ; For filter. + Mov [SI+6Eh], AX + + Mov DWord Ptr [SI+1Ch], EAX ; Current Volume = 0 + ; for volume sliding. + Mov [SI+06h], DX + Mov [SI+5Eh], AX + Mov [SI+7Eh], AX + +MixSamples5: + Test CX, 8540h ; New volume or panning? + JZ MixSamplesMix + + Mov AX, 4*60 + + Test CH, 8 ; Muted? + JZ MixMMXNoMute + + Xor EDX, EDX + Mov [SI+06h], DX + Mov [SI+0Ch], EDX + Mov [SI+5Eh], DX + Mov [SI+1Ch], EDX + Mov [SI+6Eh], DX + Mov [SI+3Ch], DX + Mov [SI+7Eh], DX + + Xor BX, BX + Mov BL, [SI+3Ah] + + Test BL, BL + JS MixModeCommon1 + + Mov DL, [CS:FilterParameters+BX] + Mov BL, [CS:FilterParameters+BX+64] + + Mov [SI+5Bh], DL + Mov [SI+3Fh], BL + + Jmp MixModeCommon1 + +MixMMXNoMute: + Xor BX, BX + Mov BL, [SI+3Ah] + + Test BL, BL ; Disowned? Then use channel filters. + JNS MixGetChannelFilters + + Mov BL, [SI+3Fh] + Jmp MixChannelFilters + +MixGetChannelFilters: + ; Filter = [FilterParameters+BX] + ; Q = [FilterParameters+BX+64] + + Mov AL, [CS:FilterParameters+BX] ; AX = Filter + Mov BL, [CS:FilterParameters+BX+64] ; BX = Q + +; If the values are different, then force recalculate volume. (and hence mixmode) + + Cmp [SI+5Bh], AL + JE MixChannelFiltersSame + Cmp [SI+3Fh], BL + JE MixChannelFiltersSame + + Mov DWord Ptr [SI+0Ch], 0 + +MixChannelFiltersSame: + Mov [SI+5Bh], AL + Mov [SI+3Fh], BL + +MixChannelFilters: + Cmp MixMode, 3 + JNE MixMMXNoFilters + + Mov AL, [SI+3Eh] + Mul Byte Ptr [SI+5Bh] + + Mov CS:FilterFreqValue, AX + + Cmp AX, 127*255 + JNE MixChannelFiltersOK + Test BL, BL + JZ MixMMXNoFilters + +MixChannelFiltersOK: + ShL BX, 2 + + FNInit + FLdCW [CS:NewControlWord] + + FILD [CS:FilterFreqValue] ; 0->127*256 + FMul [CS:FreqParameterMultiplier] ; -i/(24*256) + FLd ST + FRndInt + FSub ST(1), ST + FXCh + F2XM1 + FLd1 + FAdd + FScale ; = 2^(i/24*256) + FMul [CS:FreqMultiplier] ; = r + FLd ST ; r, r + FMul ST(1), ST ; r, r^2 + + FLd [CS:QualityFactorTable+BX] ; 2d, r, r^2 + FMul ST(1), ST ; 2d, 2dr, r^2 + FAdd + + FLd1 ; 1, d+1, e + FXCh ; d+1, 1, e + FSubR ST(1), ST + FAdd ST, ST(2) ; 1+d+e, d, e + FDivR Const2048 ; 1/(1+d+e), d, e + FISt Word Ptr [SI+5Eh] ; + FLd ST(2) ; e, 1/(1+d+e), d, e + FAdd ST, ST + FAddP ST(2), ST ; 1/(1+d+e), d+2e, e + FMul ST(2), ST ; 1/(1+d+e), d+2e, e/(1+d+e) + FMul + FIStP Word Ptr [SI+6Eh] + FChs + FIStP Word Ptr [SI+7Eh] + FStP ST + Mov DWord Ptr [SI+0Ch], 0 + +MixMMXNoFilters: + Mov EBX, [SI+0Ch] + + Cmp Stereo, 0 + JNE MixMMXStereo + +MixMMXMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + + Jmp MixModeVolumeCheck + +MixMMXStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE MixMMXSurround + + Mul Byte Ptr MixVolume ; 0->128 + Mul Word Ptr [SI+4Ah] ; 0->32768 + ShRD AX, DX, 15 ; Maxvol = 8192 + Mov [SI+0Eh], AX ; Store into right volume + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 15 + Mov [SI+0Ch], AX + + Jmp MixModeVolumeCheck + +MixMMXSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 10 + Mov [SI+0Ch], AX + Neg AX + Mov [SI+0Eh], AX + +MixModeVolumeCheck: + Test CH, 3+4 + JNZ MixModeCommon + + Cmp EBX, [SI+0Ch] ; Same as last volume? + JE MixSamplesMix + +MixModeCommon: ; Requires AX = 30 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov AX, MixModeOffset + + Cmp DWord Ptr [SI+0Ch], 0 + JNE MixModeActualMix + + Cmp MixMode, 2 + JB MixMMXGeneralNoRamp + + Cmp DWord Ptr [SI+1Ch], 0 + JNE MixModeActualMix + +MixMMXGeneralNoRamp: + Mov AX, 4*60 + Jmp MixModeCommon1 + +MixModeActualMix: + Cmp MixMode, 3 + JNE MixModeFilter + + Cmp Word Ptr [SI+6Eh], 0 + JNE MixModeFilter + Cmp Word Ptr [SI+7Eh], 0 + JNE MixModeFilter + + Sub AX, 60 + +MixModeFilter: + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 30 + +MixModeCommon1: + Cmp Byte Ptr [SI+0Ah], 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, DMABUFFERLENGTH*2+80 + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Push Word Ptr [SI+8] + Call Word Ptr [CS:BX] + Pop BX + + And Word Ptr [SI], 0111100010001101b + + Cmp BX, Offset MixFunctionTables+60*2 + JB MixSamplesEnd + Cmp BX, Offset MixFunctionTables+60*4 + JAE MixSamplesEnd + + MovDR AX, MM6 + Mov [SI+0Ch], EAX + Mov [SI+1Ch], EAX + + Cmp BX, Offset MixfunctionTables+60*3 + JB MixSamplesEnd + + Mov ES, CS:MixSegment + Mov DX, [ES:10h] + Mov BX, [ES:14h] + Mov [SI+3Ch], DX + Mov [SI+6h], BX + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + +IF OUTPUTFILTERENABLED + include equalize.inc +ENDIF + Ret + +EndP MixSamples + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/K6TRANS.INC b/SoundDrivers/K6TRANS.INC index 3bfb278..fb5c068 100755 --- a/SoundDrivers/K6TRANS.INC +++ b/SoundDrivers/K6TRANS.INC @@ -1,119 +1,119 @@ - -; To be embedded within the IRQ handler. - - Push DX - - Cmp CS:Stereo, 0 - JNE TransferStereoBufferMMX - -TransferMonoBufferMMX: ; DX = number of 32 bit numbers -> 16 bit. - - Push DX - ShR DX, 3 - JZ TransferMonoBufferMMX2 - -TransferMonoBufferMMX1: - MovD MM0, [SI] - MovD MM1, [SI+8] - MovD MM2, [SI+10h] - MovD MM3, [SI+18h] - MovD MM4, [SI+20h] - MovD MM5, [SI+28h] - MovD MM6, [SI+30h] - MovD MM7, [SI+38h] - - PUnpckLDQ MM0, MM1 ; MM0 = S2|S1 - PUnpckLDQ MM2, MM3 ; MM2 = S4|S3 - PUnpckLDQ MM4, MM5 ; MM4 = S6|S5 - PUnpckLDQ MM6, MM7 ; MM6 = S8|S7 - - PF2ID MM0, MM0 - PF2ID MM2, MM2 - PF2ID MM4, MM4 - PF2ID MM6, MM6 - - - PackSSDW MM0, MM2 - PackSSDW MM4, MM6 - - MovQ [DI], MM0 - MovQ [DI+8], MM4 - - Add SI, 40h - Add DI, 10h - - Dec DX - JNZ TransferMonoBufferMMX1 - -TransferMonoBufferMMX2: - Pop CX - Mov DX, CX - - And CX, 7 - JZ TransferMonoBufferMMX4 - -TransferMonoBufferMMX3: - MovD MM0, [SI] - PF2ID MM0, MM0 - MovD EAX, MM0 - StosW - Add SI, 8 - - Loop TransferMonoBufferMMX3 - -TransferMonoBufferMMX4: - Jmp MMXMixTransferEnd - -TransferStereoBufferMMX: ; DX is always an even number for stereo - Push DX - - ShR DX, 3 - JZ TransferStereoBufferMMX2 - -TransferStereoBufferMMX1: ; DX = number of 32 bit numbers -> 16 bit - MovQ MM0, [SI] - MovQ MM1, [SI+8] - MovQ MM2, [SI+10h] - MovQ MM3, [SI+18h] - - PF2ID MM0, MM0 - PF2ID MM1, MM1 - PF2ID MM2, MM2 - PF2ID MM3, MM3 - - PackSSDW MM0, MM1 - PackSSDW MM2, MM3 - - MovQ [DI], MM0 - MovQ [DI+8], MM2 - - Add SI, 20h - Add DI, 10h - - Dec DX - JNZ TransferStereoBufferMMX1 - -TransferStereoBufferMMX2: - Pop CX - Mov DX, CX - - And CX, 7 - ShR CX, 1 ; Always an even number! - JZ TransferStereoBufferMMX4 - -TransferStereoBufferMMX3: - MovQ MM0, [SI] - PF2ID MM0, MM0 - PackSSDW MM0, MM0 - MovD [DI], MM0 - - Add SI, 8 - Add DI, 4 - - Loop TransferStereoBufferMMX3 - -TransferStereoBufferMMX4: - -MMXMixTransferEnd: - Pop DX - + +; To be embedded within the IRQ handler. + + Push DX + + Cmp CS:Stereo, 0 + JNE TransferStereoBufferMMX + +TransferMonoBufferMMX: ; DX = number of 32 bit numbers -> 16 bit. + + Push DX + ShR DX, 3 + JZ TransferMonoBufferMMX2 + +TransferMonoBufferMMX1: + MovD MM0, [SI] + MovD MM1, [SI+8] + MovD MM2, [SI+10h] + MovD MM3, [SI+18h] + MovD MM4, [SI+20h] + MovD MM5, [SI+28h] + MovD MM6, [SI+30h] + MovD MM7, [SI+38h] + + PUnpckLDQ MM0, MM1 ; MM0 = S2|S1 + PUnpckLDQ MM2, MM3 ; MM2 = S4|S3 + PUnpckLDQ MM4, MM5 ; MM4 = S6|S5 + PUnpckLDQ MM6, MM7 ; MM6 = S8|S7 + + PF2ID MM0, MM0 + PF2ID MM2, MM2 + PF2ID MM4, MM4 + PF2ID MM6, MM6 + + + PackSSDW MM0, MM2 + PackSSDW MM4, MM6 + + MovQ [DI], MM0 + MovQ [DI+8], MM4 + + Add SI, 40h + Add DI, 10h + + Dec DX + JNZ TransferMonoBufferMMX1 + +TransferMonoBufferMMX2: + Pop CX + Mov DX, CX + + And CX, 7 + JZ TransferMonoBufferMMX4 + +TransferMonoBufferMMX3: + MovD MM0, [SI] + PF2ID MM0, MM0 + MovD EAX, MM0 + StosW + Add SI, 8 + + Loop TransferMonoBufferMMX3 + +TransferMonoBufferMMX4: + Jmp MMXMixTransferEnd + +TransferStereoBufferMMX: ; DX is always an even number for stereo + Push DX + + ShR DX, 3 + JZ TransferStereoBufferMMX2 + +TransferStereoBufferMMX1: ; DX = number of 32 bit numbers -> 16 bit + MovQ MM0, [SI] + MovQ MM1, [SI+8] + MovQ MM2, [SI+10h] + MovQ MM3, [SI+18h] + + PF2ID MM0, MM0 + PF2ID MM1, MM1 + PF2ID MM2, MM2 + PF2ID MM3, MM3 + + PackSSDW MM0, MM1 + PackSSDW MM2, MM3 + + MovQ [DI], MM0 + MovQ [DI+8], MM2 + + Add SI, 20h + Add DI, 10h + + Dec DX + JNZ TransferStereoBufferMMX1 + +TransferStereoBufferMMX2: + Pop CX + Mov DX, CX + + And CX, 7 + ShR CX, 1 ; Always an even number! + JZ TransferStereoBufferMMX4 + +TransferStereoBufferMMX3: + MovQ MM0, [SI] + PF2ID MM0, MM0 + PackSSDW MM0, MM0 + MovD [DI], MM0 + + Add SI, 8 + Add DI, 4 + + Loop TransferStereoBufferMMX3 + +TransferStereoBufferMMX4: + +MMXMixTransferEnd: + Pop DX + diff --git a/SoundDrivers/LOADSAM.INC b/SoundDrivers/LOADSAM.INC index 6eb0a12..fe3398b 100755 --- a/SoundDrivers/LOADSAM.INC +++ b/SoundDrivers/LOADSAM.INC @@ -1,71 +1,71 @@ -Proc LoadSample Far ; Fix up end of sample bytes - - PushAD - Push DS - Push ES - Push FS - - Mov FS, CS:SongDataArea - Mov BP, AX - Add BP, BP - Mov BP, [FS:64910+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC LoadSampleEnd ; Zero flag ON if 16 bit.. - - Xor EAX, EAX - Mov BL, [FS:BP+12h] - - Test BL, 10h ; Loop - JZ LoadSample2 - - Mov ESI, [FS:BP+34h] ; Start of loop - Test BL, 40h ; Pingpong? - JZ LoadSample1 - - Mov ESI, [FS:BP+38h] - Sub ESI, 2 - JNC LoadSample1 - - Xor ESI, ESI - -LoadSample1: - Test BL, 2 - JZ LoadSample4 - - Add ESI, ESI - -LoadSample4: - Int 3 - Mov AL, [SI] - Inc ESI - Int 3 - Mov AH, [SI] - -LoadSample2: - Mov ESI, [FS:BP+30h] - Test BL, 2 - JZ LoadSample3 - - Add ESI, ESI - -LoadSample3: - Int 3 - Mov [SI], AL - Inc ESI - Int 3 - Mov [SI], AH - -LoadSampleEnd: - Pop FS - Pop ES - Pop DS - PopAD - - StC - Ret - -EndP LoadSample - - +Proc LoadSample Far ; Fix up end of sample bytes + + PushAD + Push DS + Push ES + Push FS + + Mov FS, CS:SongDataArea + Mov BP, AX + Add BP, BP + Mov BP, [FS:64910+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC LoadSampleEnd ; Zero flag ON if 16 bit.. + + Xor EAX, EAX + Mov BL, [FS:BP+12h] + + Test BL, 10h ; Loop + JZ LoadSample2 + + Mov ESI, [FS:BP+34h] ; Start of loop + Test BL, 40h ; Pingpong? + JZ LoadSample1 + + Mov ESI, [FS:BP+38h] + Sub ESI, 2 + JNC LoadSample1 + + Xor ESI, ESI + +LoadSample1: + Test BL, 2 + JZ LoadSample4 + + Add ESI, ESI + +LoadSample4: + Int 3 + Mov AL, [SI] + Inc ESI + Int 3 + Mov AH, [SI] + +LoadSample2: + Mov ESI, [FS:BP+30h] + Test BL, 2 + JZ LoadSample3 + + Add ESI, ESI + +LoadSample3: + Int 3 + Mov [SI], AL + Inc ESI + Int 3 + Mov [SI], AH + +LoadSampleEnd: + Pop FS + Pop ES + Pop DS + PopAD + + StC + Ret + +EndP LoadSample + + diff --git a/SoundDrivers/LPT1DRV.ASM b/SoundDrivers/LPT1DRV.ASM index c52b0fd..176c75c 100755 --- a/SoundDrivers/LPT1DRV.ASM +++ b/SoundDrivers/LPT1DRV.ASM @@ -1,904 +1,904 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 0 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro -MIXTABLESIZE EQU 2*256*65 - -SBProMsg DB "Using DAC on LPT1, Port ", 0FDh, "Xh", 0 - -SBProNoMemoryMsg DB " Using DAC on LPT1", 13 - DB " Error: Insufficient memory", 0 - -ReinitMsg DB "DAC on LPT1 reinitialised", 0 - -DSPVersion DW 0 -Forced DB 0 -InInterrupt DB 0 - -BytesToMix DW 1000 -MixSpeed DW 22000 -MixConst DW 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -DMASize DW 2048 - -OldIRQHandler DD 0 -TimerAccumulator DW 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 -OutputBufferPos DW 0 -OutputBlockEnd DW 1024 - -include mix.inc -include mono12b.mix - -MixFunctionTables Label - -include mono12b.inc ; contains the tables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - - Cmp AX, 12000 - JB GetMixConst1 - - Cmp AX, 44100 - JA GetMixConst1 - - Mov CX, AX - -GetMixConst1: - Mov DX, 0012h - Mov AX, 34DDh - - Div CX - ; AX = mix const - Mov MixConst, AX - - Mov DX, 12h - Mov AX, 34DDh - Div MixConst - - Mov MixSpeed, AX - - Pop ES - Pop DS - PopA - Ret - -EndP GetMixConst - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push ES - - Xor AX, AX - Mov ES, AX - Mov AX, [ES:408h] ; LPT1 port - - Pop ES - And AX, AX - JZ DetectCard1 - - Mov Word Ptr CS:LPTPortNumber, AX - - Mov EAX, 'Jeff' - ClC - Ret - -DetectCard1: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov AX, 2020h - - Mov BX, CX ; BX = bytes to mix - Mov DX, CX - - Mov MixTransferOffset, DI ; } Memory write - Rep StosW ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - Jmp MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - -Mix0Mode: ; 16-bit mixing, no interpolation, no ramping -Mix0ModeMono: - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AX, 30 ; Use left only-mixing for mono - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 60 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Mov [SI+8], AX ; Offset... - - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, MixTransferRemaining - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PCSpeakerIRQHandler - - Push AX - Push BX - Push DX - Push DS - - Mov DS, CS:DMASegment - Mov BX, CS:OutputBufferPos - -LPTPortNumber EQU $+1 - Mov DX, 1234h - - Mov AL, [BX] - Out DX, AL - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Inc BX - ; OK.. which IRQ handler? - Mov AX, MixConst - Add TimerAccumulator, AX - JC PCSpeakerIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp PCSpeakerIRQHandler2 - -PCSpeakerIRQHandler1: - PushF - Call OldIRQHandler - -PCSpeakerIRQHandler2: - Mov OutputBufferPos, BX - Cmp BX, OutputBlockEnd - JAE PCSpeakerIRQHandler3 - -PCSpeakerIRQHandlerEnd: - Pop DS - Pop DX - Pop BX - Pop AX - - IRet - -PCSpeakerIRQHandler3: - Mov BX, DMASize - Mov AX, OutputBlockEnd - Add AX, BX - Cmp AX, DMABUFFERLENGTH - JBE PCSpeakerIRQHandler4 - - Mov AX, BX - Mov OutputBufferPos, 0 - -PCSpeakerIRQHandler4: - Mov OutputBlockEnd, AX - - Cmp InInterrupt, 0 - JA PCSpeakerIRQHandlerEnd - - Inc InInterrupt - - ClD - - PushAD - Push ES - - Mov ES, CS:DMASegment - Mov DI, OutputBufferPos - - Call SaveEMSPageFrame - - StI - ; BX = bytes required - - Cmp MixTransferRemaining, 0 - JNE SBProIRQHandler4 - Assume DS:Nothing - -SBProIRQHandler3: - Push BX - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BX - -SBProIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SBProIRQHandler5 - - Mov DX, MixTransferRemaining - -SBProIRQHandler5: - Push BX - Push DX - -SBProIRQHandler6: - Mov AX, [SI] - SAR AX, 6 - - Test AH, AH - JNZ SBProIRQHandlerClip1 - -SBProIRQHandler7: - StosB ; } Memory write - - Add SI, 2 - Dec DX - JNZ SBProIRQHandler6 - - Pop DX - Pop BX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SBProIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Dec InInterrupt - -PCSpkEnd2: - Pop ES - PopAD - Pop DS - Pop DX - Pop BX - Pop AX - IRet - -SBProIRQHandlerClip1: - Mov AL, 0 - JS SBProIRQHandler7 - Mov AL, 0FFh - Jmp SBProIRQHandler7 - -EndP PCSpeakerIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov OutputBufferPos, 0 - Mov OutputBlockEnd, 1024 - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Mov AX, MixConst - Out 40h, AL - Mov AL, AH - Out 40h, AL - - Xor AX, AX - Mov ES, AX - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset PCSpeakerIRQHandler - - ClI - - XChg [ES:20h], EAX - Mov OldIRQHandler, EAX - - StI - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AL, 34h ; Reset IRQ calling rate. - Out 43h, AL - Xor AL, AL - Out 40h, AL - Out 40h, AL - - Xor AX, AX - Mov ES, AX - - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - Call GetMixConst - - Mov AX, 661 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, DMABUFFERLENGTH/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SBProNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call GetTempo - Call SetTempo - Call SetIRQ - - Mov SI, Offset SBProMsg - Mov AX, Word Ptr LPTPortNumber - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 0 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro +MIXTABLESIZE EQU 2*256*65 + +SBProMsg DB "Using DAC on LPT1, Port ", 0FDh, "Xh", 0 + +SBProNoMemoryMsg DB " Using DAC on LPT1", 13 + DB " Error: Insufficient memory", 0 + +ReinitMsg DB "DAC on LPT1 reinitialised", 0 + +DSPVersion DW 0 +Forced DB 0 +InInterrupt DB 0 + +BytesToMix DW 1000 +MixSpeed DW 22000 +MixConst DW 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +DMASize DW 2048 + +OldIRQHandler DD 0 +TimerAccumulator DW 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 +OutputBufferPos DW 0 +OutputBlockEnd DW 1024 + +include mix.inc +include mono12b.mix + +MixFunctionTables Label + +include mono12b.inc ; contains the tables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + + Cmp AX, 12000 + JB GetMixConst1 + + Cmp AX, 44100 + JA GetMixConst1 + + Mov CX, AX + +GetMixConst1: + Mov DX, 0012h + Mov AX, 34DDh + + Div CX + ; AX = mix const + Mov MixConst, AX + + Mov DX, 12h + Mov AX, 34DDh + Div MixConst + + Mov MixSpeed, AX + + Pop ES + Pop DS + PopA + Ret + +EndP GetMixConst + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push ES + + Xor AX, AX + Mov ES, AX + Mov AX, [ES:408h] ; LPT1 port + + Pop ES + And AX, AX + JZ DetectCard1 + + Mov Word Ptr CS:LPTPortNumber, AX + + Mov EAX, 'Jeff' + ClC + Ret + +DetectCard1: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov AX, 2020h + + Mov BX, CX ; BX = bytes to mix + Mov DX, CX + + Mov MixTransferOffset, DI ; } Memory write + Rep StosW ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + Jmp MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + +Mix0Mode: ; 16-bit mixing, no interpolation, no ramping +Mix0ModeMono: + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AX, 30 ; Use left only-mixing for mono + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 60 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Mov [SI+8], AX ; Offset... + + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, MixTransferRemaining + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PCSpeakerIRQHandler + + Push AX + Push BX + Push DX + Push DS + + Mov DS, CS:DMASegment + Mov BX, CS:OutputBufferPos + +LPTPortNumber EQU $+1 + Mov DX, 1234h + + Mov AL, [BX] + Out DX, AL + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Inc BX + ; OK.. which IRQ handler? + Mov AX, MixConst + Add TimerAccumulator, AX + JC PCSpeakerIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp PCSpeakerIRQHandler2 + +PCSpeakerIRQHandler1: + PushF + Call OldIRQHandler + +PCSpeakerIRQHandler2: + Mov OutputBufferPos, BX + Cmp BX, OutputBlockEnd + JAE PCSpeakerIRQHandler3 + +PCSpeakerIRQHandlerEnd: + Pop DS + Pop DX + Pop BX + Pop AX + + IRet + +PCSpeakerIRQHandler3: + Mov BX, DMASize + Mov AX, OutputBlockEnd + Add AX, BX + Cmp AX, DMABUFFERLENGTH + JBE PCSpeakerIRQHandler4 + + Mov AX, BX + Mov OutputBufferPos, 0 + +PCSpeakerIRQHandler4: + Mov OutputBlockEnd, AX + + Cmp InInterrupt, 0 + JA PCSpeakerIRQHandlerEnd + + Inc InInterrupt + + ClD + + PushAD + Push ES + + Mov ES, CS:DMASegment + Mov DI, OutputBufferPos + + Call SaveEMSPageFrame + + StI + ; BX = bytes required + + Cmp MixTransferRemaining, 0 + JNE SBProIRQHandler4 + Assume DS:Nothing + +SBProIRQHandler3: + Push BX + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BX + +SBProIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SBProIRQHandler5 + + Mov DX, MixTransferRemaining + +SBProIRQHandler5: + Push BX + Push DX + +SBProIRQHandler6: + Mov AX, [SI] + SAR AX, 6 + + Test AH, AH + JNZ SBProIRQHandlerClip1 + +SBProIRQHandler7: + StosB ; } Memory write + + Add SI, 2 + Dec DX + JNZ SBProIRQHandler6 + + Pop DX + Pop BX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SBProIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Dec InInterrupt + +PCSpkEnd2: + Pop ES + PopAD + Pop DS + Pop DX + Pop BX + Pop AX + IRet + +SBProIRQHandlerClip1: + Mov AL, 0 + JS SBProIRQHandler7 + Mov AL, 0FFh + Jmp SBProIRQHandler7 + +EndP PCSpeakerIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov OutputBufferPos, 0 + Mov OutputBlockEnd, 1024 + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Mov AX, MixConst + Out 40h, AL + Mov AL, AH + Out 40h, AL + + Xor AX, AX + Mov ES, AX + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset PCSpeakerIRQHandler + + ClI + + XChg [ES:20h], EAX + Mov OldIRQHandler, EAX + + StI + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AL, 34h ; Reset IRQ calling rate. + Out 43h, AL + Xor AL, AL + Out 40h, AL + Out 40h, AL + + Xor AX, AX + Mov ES, AX + + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + Call GetMixConst + + Mov AX, 661 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, DMABUFFERLENGTH/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SBProNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call GetTempo + Call SetTempo + Call SetIRQ + + Mov SI, Offset SBProMsg + Mov AX, Word Ptr LPTPortNumber + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/LPT2DRV.ASM b/SoundDrivers/LPT2DRV.ASM index d30e254..ba9857c 100755 --- a/SoundDrivers/LPT2DRV.ASM +++ b/SoundDrivers/LPT2DRV.ASM @@ -1,904 +1,904 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 0 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro -MIXTABLESIZE EQU 2*256*65 - -SBProMsg DB "Using DAC on LPT2, Port ", 0FDh, "Xh", 0 - -SBProNoMemoryMsg DB " Using DAC on LPT2", 13 - DB " Error: Insufficient memory", 0 - -ReinitMsg DB "DAC on LPT2 reinitialised", 0 - -DSPVersion DW 0 -Forced DB 0 -InInterrupt DB 0 - -BytesToMix DW 1000 -MixSpeed DW 22000 -MixConst DW 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -DMASize DW 2048 - -OldIRQHandler DD 0 -TimerAccumulator DW 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 -OutputBufferPos DW 0 -OutputBlockEnd DW 1024 - -include mix.inc -include mono12b.mix - -MixFunctionTables Label - -include mono12b.inc ; contains the tables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - - Cmp AX, 12000 - JB GetMixConst1 - - Cmp AX, 44100 - JA GetMixConst1 - - Mov CX, AX - -GetMixConst1: - Mov DX, 0012h - Mov AX, 34DDh - - Div CX - ; AX = mix const - Mov MixConst, AX - - Mov DX, 12h - Mov AX, 34DDh - Div MixConst - - Mov MixSpeed, AX - - Pop ES - Pop DS - PopA - Ret - -EndP GetMixConst - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push ES - - Xor AX, AX - Mov ES, AX - Mov AX, [ES:40Ah] ; LPT2 port - - Pop ES - And AX, AX - JZ DetectCard1 - - Mov Word Ptr CS:LPTPortNumber, AX - - Mov EAX, 'Jeff' - ClC - Ret - -DetectCard1: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov AX, 2020h - - Mov BX, CX ; BX = bytes to mix - Mov DX, CX - - Mov MixTransferOffset, DI ; } Memory write - Rep StosW ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - Jmp MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - -Mix0Mode: ; 16-bit mixing, no interpolation, no ramping -Mix0ModeMono: - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AX, 30 ; Use left only-mixing for mono - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 60 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Mov [SI+8], AX ; Offset... - - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, MixTransferRemaining - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PCSpeakerIRQHandler - - Push AX - Push BX - Push DX - Push DS - - Mov DS, CS:DMASegment - Mov BX, CS:OutputBufferPos - -LPTPortNumber EQU $+1 - Mov DX, 1234h - - Mov AL, [BX] - Out DX, AL - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Inc BX - ; OK.. which IRQ handler? - Mov AX, MixConst - Add TimerAccumulator, AX - JC PCSpeakerIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp PCSpeakerIRQHandler2 - -PCSpeakerIRQHandler1: - PushF - Call OldIRQHandler - -PCSpeakerIRQHandler2: - Mov OutputBufferPos, BX - Cmp BX, OutputBlockEnd - JAE PCSpeakerIRQHandler3 - -PCSpeakerIRQHandlerEnd: - Pop DS - Pop DX - Pop BX - Pop AX - - IRet - -PCSpeakerIRQHandler3: - Mov BX, DMASize - Mov AX, OutputBlockEnd - Add AX, BX - Cmp AX, DMABUFFERLENGTH - JBE PCSpeakerIRQHandler4 - - Mov AX, BX - Mov OutputBufferPos, 0 - -PCSpeakerIRQHandler4: - Mov OutputBlockEnd, AX - - Cmp InInterrupt, 0 - JA PCSpeakerIRQHandlerEnd - - Inc InInterrupt - - ClD - - PushAD - Push ES - - Mov ES, CS:DMASegment - Mov DI, OutputBufferPos - - Call SaveEMSPageFrame - - StI - ; BX = bytes required - - Cmp MixTransferRemaining, 0 - JNE SBProIRQHandler4 - Assume DS:Nothing - -SBProIRQHandler3: - Push BX - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BX - -SBProIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SBProIRQHandler5 - - Mov DX, MixTransferRemaining - -SBProIRQHandler5: - Push BX - Push DX - -SBProIRQHandler6: - Mov AX, [SI] - SAR AX, 6 - - Test AH, AH - JNZ SBProIRQHandlerClip1 - -SBProIRQHandler7: - StosB ; } Memory write - - Add SI, 2 - Dec DX - JNZ SBProIRQHandler6 - - Pop DX - Pop BX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SBProIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Dec InInterrupt - -PCSpkEnd2: - Pop ES - PopAD - Pop DS - Pop DX - Pop BX - Pop AX - IRet - -SBProIRQHandlerClip1: - Mov AL, 0 - JS SBProIRQHandler7 - Mov AL, 0FFh - Jmp SBProIRQHandler7 - -EndP PCSpeakerIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov OutputBufferPos, 0 - Mov OutputBlockEnd, 1024 - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Mov AX, MixConst - Out 40h, AL - Mov AL, AH - Out 40h, AL - - Xor AX, AX - Mov ES, AX - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset PCSpeakerIRQHandler - - ClI - - XChg [ES:20h], EAX - Mov OldIRQHandler, EAX - - StI - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AL, 34h ; Reset IRQ calling rate. - Out 43h, AL - Xor AL, AL - Out 40h, AL - Out 40h, AL - - Xor AX, AX - Mov ES, AX - - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - Call GetMixConst - - Mov AX, 661 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, DMABUFFERLENGTH/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SBProNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call GetTempo - Call SetTempo - Call SetIRQ - - Mov SI, Offset SBProMsg - Mov AX, Word Ptr LPTPortNumber - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 0 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro +MIXTABLESIZE EQU 2*256*65 + +SBProMsg DB "Using DAC on LPT2, Port ", 0FDh, "Xh", 0 + +SBProNoMemoryMsg DB " Using DAC on LPT2", 13 + DB " Error: Insufficient memory", 0 + +ReinitMsg DB "DAC on LPT2 reinitialised", 0 + +DSPVersion DW 0 +Forced DB 0 +InInterrupt DB 0 + +BytesToMix DW 1000 +MixSpeed DW 22000 +MixConst DW 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +DMASize DW 2048 + +OldIRQHandler DD 0 +TimerAccumulator DW 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 +OutputBufferPos DW 0 +OutputBlockEnd DW 1024 + +include mix.inc +include mono12b.mix + +MixFunctionTables Label + +include mono12b.inc ; contains the tables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + + Cmp AX, 12000 + JB GetMixConst1 + + Cmp AX, 44100 + JA GetMixConst1 + + Mov CX, AX + +GetMixConst1: + Mov DX, 0012h + Mov AX, 34DDh + + Div CX + ; AX = mix const + Mov MixConst, AX + + Mov DX, 12h + Mov AX, 34DDh + Div MixConst + + Mov MixSpeed, AX + + Pop ES + Pop DS + PopA + Ret + +EndP GetMixConst + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push ES + + Xor AX, AX + Mov ES, AX + Mov AX, [ES:40Ah] ; LPT2 port + + Pop ES + And AX, AX + JZ DetectCard1 + + Mov Word Ptr CS:LPTPortNumber, AX + + Mov EAX, 'Jeff' + ClC + Ret + +DetectCard1: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov AX, 2020h + + Mov BX, CX ; BX = bytes to mix + Mov DX, CX + + Mov MixTransferOffset, DI ; } Memory write + Rep StosW ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + Jmp MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + +Mix0Mode: ; 16-bit mixing, no interpolation, no ramping +Mix0ModeMono: + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AX, 30 ; Use left only-mixing for mono + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 60 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Mov [SI+8], AX ; Offset... + + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, MixTransferRemaining + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PCSpeakerIRQHandler + + Push AX + Push BX + Push DX + Push DS + + Mov DS, CS:DMASegment + Mov BX, CS:OutputBufferPos + +LPTPortNumber EQU $+1 + Mov DX, 1234h + + Mov AL, [BX] + Out DX, AL + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Inc BX + ; OK.. which IRQ handler? + Mov AX, MixConst + Add TimerAccumulator, AX + JC PCSpeakerIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp PCSpeakerIRQHandler2 + +PCSpeakerIRQHandler1: + PushF + Call OldIRQHandler + +PCSpeakerIRQHandler2: + Mov OutputBufferPos, BX + Cmp BX, OutputBlockEnd + JAE PCSpeakerIRQHandler3 + +PCSpeakerIRQHandlerEnd: + Pop DS + Pop DX + Pop BX + Pop AX + + IRet + +PCSpeakerIRQHandler3: + Mov BX, DMASize + Mov AX, OutputBlockEnd + Add AX, BX + Cmp AX, DMABUFFERLENGTH + JBE PCSpeakerIRQHandler4 + + Mov AX, BX + Mov OutputBufferPos, 0 + +PCSpeakerIRQHandler4: + Mov OutputBlockEnd, AX + + Cmp InInterrupt, 0 + JA PCSpeakerIRQHandlerEnd + + Inc InInterrupt + + ClD + + PushAD + Push ES + + Mov ES, CS:DMASegment + Mov DI, OutputBufferPos + + Call SaveEMSPageFrame + + StI + ; BX = bytes required + + Cmp MixTransferRemaining, 0 + JNE SBProIRQHandler4 + Assume DS:Nothing + +SBProIRQHandler3: + Push BX + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BX + +SBProIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SBProIRQHandler5 + + Mov DX, MixTransferRemaining + +SBProIRQHandler5: + Push BX + Push DX + +SBProIRQHandler6: + Mov AX, [SI] + SAR AX, 6 + + Test AH, AH + JNZ SBProIRQHandlerClip1 + +SBProIRQHandler7: + StosB ; } Memory write + + Add SI, 2 + Dec DX + JNZ SBProIRQHandler6 + + Pop DX + Pop BX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SBProIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Dec InInterrupt + +PCSpkEnd2: + Pop ES + PopAD + Pop DS + Pop DX + Pop BX + Pop AX + IRet + +SBProIRQHandlerClip1: + Mov AL, 0 + JS SBProIRQHandler7 + Mov AL, 0FFh + Jmp SBProIRQHandler7 + +EndP PCSpeakerIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov OutputBufferPos, 0 + Mov OutputBlockEnd, 1024 + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Mov AX, MixConst + Out 40h, AL + Mov AL, AH + Out 40h, AL + + Xor AX, AX + Mov ES, AX + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset PCSpeakerIRQHandler + + ClI + + XChg [ES:20h], EAX + Mov OldIRQHandler, EAX + + StI + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AL, 34h ; Reset IRQ calling rate. + Out 43h, AL + Xor AL, AL + Out 40h, AL + Out 40h, AL + + Xor AX, AX + Mov ES, AX + + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + Call GetMixConst + + Mov AX, 661 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, DMABUFFERLENGTH/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SBProNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call GetTempo + Call SetTempo + Call SetIRQ + + Mov SI, Offset SBProMsg + Mov AX, Word Ptr LPTPortNumber + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/M12BIT.INC b/SoundDrivers/M12BIT.INC index cc25545..278c857 100755 --- a/SoundDrivers/M12BIT.INC +++ b/SoundDrivers/M12BIT.INC @@ -1,49 +1,49 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix12Left8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit - DW Offset MixForwardsLoop, PreMix12Left8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit - DW Offset MixPingPongLoop, PreMix12Left8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit - ; Right only - DW Offset MixNoLoop, PreMix12Right8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit - DW Offset MixForwardsLoop, PreMix12Right8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit - DW Offset MixPingPongLoop, PreMix12Right8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit - ; Central - DW Offset MixNoLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit - DW Offset MixForwardsLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit - DW Offset MixPingPongLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit - ; Stereo - DW Offset MixNoLoop, PreMix12Panned8Bit, MFS8Bit, MBS8Bit, Mix12Panned8Bit - DW Offset MixForwardsLoop, PreMix12Panned8Bit, MFS8Bit, MBS8Bit, Mix12Panned8Bit - DW Offset MixPingPongLoop, PreMix12Panned8Bit, MFS8Bit, MBS8Bit, Mix12Panned8Bit - ; Surround - DW Offset MixNoLoop, PreMix12Surround8Bit, MFS8Bit, MBS8Bit, Mix12Surround8Bit - DW Offset MixForwardsLoop, PreMix12Surround8Bit, MFS8Bit, MBS8Bit, Mix12Surround8Bit - DW Offset MixPingPongLoop, PreMix12Surround8Bit, MFS8Bit, MBS8Bit, Mix12Surround8Bit - - ; 16 bit tables - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix12Left16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit - DW Offset MixForwardsLoop, PreMix12Left16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit - DW Offset MixPingPongLoop, PreMix12Left16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit - ; Right only - DW Offset MixNoLoop, PreMix12Right16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit - DW Offset MixForwardsLoop, PreMix12Right16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit - DW Offset MixPingPongLoop, PreMix12Right16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit - ; Central - DW Offset MixNoLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit - DW Offset MixForwardsLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit - DW Offset MixPingPongLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit - ; Stereo - DW Offset MixNoLoop, PreMix12Panned16Bit, MFS16Bit, MBS16Bit, Mix12Panned16Bit - DW Offset MixForwardsLoop, PreMix12Panned16Bit, MFS16Bit, MBS16Bit, Mix12Panned16Bit - DW Offset MixPingPongLoop, PreMix12Panned16Bit, MFS16Bit, MBS16Bit, Mix12Panned16Bit - ; Surround - DW Offset MixNoLoop, PreMix12Surround16Bit, MFS16Bit, MBS16Bit, Mix12Surround16Bit - DW Offset MixForwardsLoop, PreMix12Surround16Bit, MFS16Bit, MBS16Bit, Mix12Surround16Bit - DW Offset MixPingPongLoop, PreMix12Surround16Bit, MFS16Bit, MBS16Bit, Mix12Surround16Bit + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix12Left8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit + DW Offset MixForwardsLoop, PreMix12Left8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit + DW Offset MixPingPongLoop, PreMix12Left8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit + ; Right only + DW Offset MixNoLoop, PreMix12Right8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit + DW Offset MixForwardsLoop, PreMix12Right8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit + DW Offset MixPingPongLoop, PreMix12Right8Bit, MFS8Bit, MBS8Bit, Mix12Single8Bit + ; Central + DW Offset MixNoLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit + DW Offset MixForwardsLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit + DW Offset MixPingPongLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit + ; Stereo + DW Offset MixNoLoop, PreMix12Panned8Bit, MFS8Bit, MBS8Bit, Mix12Panned8Bit + DW Offset MixForwardsLoop, PreMix12Panned8Bit, MFS8Bit, MBS8Bit, Mix12Panned8Bit + DW Offset MixPingPongLoop, PreMix12Panned8Bit, MFS8Bit, MBS8Bit, Mix12Panned8Bit + ; Surround + DW Offset MixNoLoop, PreMix12Surround8Bit, MFS8Bit, MBS8Bit, Mix12Surround8Bit + DW Offset MixForwardsLoop, PreMix12Surround8Bit, MFS8Bit, MBS8Bit, Mix12Surround8Bit + DW Offset MixPingPongLoop, PreMix12Surround8Bit, MFS8Bit, MBS8Bit, Mix12Surround8Bit + + ; 16 bit tables + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix12Left16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit + DW Offset MixForwardsLoop, PreMix12Left16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit + DW Offset MixPingPongLoop, PreMix12Left16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit + ; Right only + DW Offset MixNoLoop, PreMix12Right16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit + DW Offset MixForwardsLoop, PreMix12Right16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit + DW Offset MixPingPongLoop, PreMix12Right16Bit, MFS16Bit, MBS16Bit, Mix12Single16Bit + ; Central + DW Offset MixNoLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit + DW Offset MixForwardsLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit + DW Offset MixPingPongLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit + ; Stereo + DW Offset MixNoLoop, PreMix12Panned16Bit, MFS16Bit, MBS16Bit, Mix12Panned16Bit + DW Offset MixForwardsLoop, PreMix12Panned16Bit, MFS16Bit, MBS16Bit, Mix12Panned16Bit + DW Offset MixPingPongLoop, PreMix12Panned16Bit, MFS16Bit, MBS16Bit, Mix12Panned16Bit + ; Surround + DW Offset MixNoLoop, PreMix12Surround16Bit, MFS16Bit, MBS16Bit, Mix12Surround16Bit + DW Offset MixForwardsLoop, PreMix12Surround16Bit, MFS16Bit, MBS16Bit, Mix12Surround16Bit + DW Offset MixPingPongLoop, PreMix12Surround16Bit, MFS16Bit, MBS16Bit, Mix12Surround16Bit diff --git a/SoundDrivers/M12BIT.MIX b/SoundDrivers/M12BIT.MIX index 6c37825..bb8addc 100755 --- a/SoundDrivers/M12BIT.MIX +++ b/SoundDrivers/M12BIT.MIX @@ -1,813 +1,813 @@ - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - -M12Mix8Single Macro Index - -M12Mix8Single&Index&: - Mov BL, [ES:DI] ;; 2 - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8Central Macro Index - -M12Mix8Central&Index&: - Mov BL, [ES:DI] ;; 2 - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8Surround Macro Index - -M12Mix8Surround&Index&: - Mov BL, [ES:DI] ;; 2 - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 - -EndM - - ; Panned output -M12Mix8PannedNext Macro Index - -M12Mix8PannedVolume&Index& EQU $+1 - Mov BH, 12h - Mov BL, [ES:DI] - -EndM - -M12Mix8Panned Macro Index - -M12Mix8Panned&Index&: - Add BX, BX - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [BX] - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -M12Mix8PannedRightVolumeOffset&Index& EQU $+3 - Mov AX, [BX+1200h] - - M12Mix8PannedNext %(Index+1) - - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -M12Mix16Single Macro Index - -M12Mix16Single&Index&: - Mov BL, [ES:EDI+EDI+1] - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -EndM - -M12Mix16Central Macro Index - -M12Mix16Central&Index&: - Mov BL, [ES:EDI+EDI+1] - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -M12Mix16Surround Macro Index - -M12Mix16Surround&Index&: - Mov BL, [ES:EDI+EDI+1] - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - - ; Panned output -M12Mix16PannedNext Macro Index - -M12Mix16PannedVolume&Index& EQU $+1 - Mov BH, 12h - Mov BL, [ES:EDI+EDI+1] - -EndM - -M12Mix16Panned Macro Index - -M12Mix16Panned&Index&: - Add BX, BX - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [BX] - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -M12Mix16PannedRightVolumeOffset&Index& EQU $+3 - Mov AX, [BX+1200h] - - M12Mix16PannedNext %(Index+1) - - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix12Single8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8SingleOffset Macro Index - DW Offset M12Mix8Single&Index& - EndM - - REPT 16 - M12Mix8SingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Single8Bit - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Single8BitOffsetTable+BX] - -M12Single8BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - RetN - - M12Mix8Single 0 - M12Mix8Single 1 - M12Mix8Single 2 - M12Mix8Single 3 - M12Mix8Single 4 - M12Mix8Single 5 - M12Mix8Single 6 - M12Mix8Single 7 - M12Mix8Single 8 - M12Mix8Single 9 - M12Mix8Single 10 - M12Mix8Single 11 - M12Mix8Single 12 - M12Mix8Single 13 - M12Mix8Single 14 - M12Mix8Single 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8Single0 - - Ret - -EndP Mix12Single8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Left8Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Single8BitVolume], AL - Ret - -EndP PreMix12Left8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Right8Bit - - Add MixBufferOffset, MixResolution/8 - Mov AL, [SI+0Ch] - Mov Byte Ptr [CS:M12Single8BitVolume], AL - - Ret - -EndP PreMix12Right8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8CentralOffset Macro Index - DW Offset M12Mix8Central&Index& - EndM - - REPT 16 - M12Mix8CentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central8BitOffsetTable+BX] - -M12Central8BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - RetN - - M12Mix8Central 0 - M12Mix8Central 1 - M12Mix8Central 2 - M12Mix8Central 3 - M12Mix8Central 4 - M12Mix8Central 5 - M12Mix8Central 6 - M12Mix8Central 7 - M12Mix8Central 8 - M12Mix8Central 9 - M12Mix8Central 10 - M12Mix8Central 11 - M12Mix8Central 12 - M12Mix8Central 13 - M12Mix8Central 14 - M12Mix8Central 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8Central0 - - Ret - -EndP Mix12Central8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central8Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Central8BitVolume], AL - - Ret - -EndP PreMix12Central8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Surround8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8SurroundOffset Macro Index - DW Offset M12Mix8Surround&Index& - EndM - - REPT 16 - M12Mix8SurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Surround8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Surround8BitOffsetTable+BX] - -M12Surround8BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - - RetN - - M12Mix8Surround 0 - M12Mix8Surround 1 - M12Mix8Surround 2 - M12Mix8Surround 3 - M12Mix8Surround 4 - M12Mix8Surround 5 - M12Mix8Surround 6 - M12Mix8Surround 7 - M12Mix8Surround 8 - M12Mix8Surround 9 - M12Mix8Surround 10 - M12Mix8Surround 11 - M12Mix8Surround 12 - M12Mix8Surround 13 - M12Mix8Surround 14 - M12Mix8Surround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8Surround0 - - Ret - -EndP Mix12Surround8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Surround8Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Surround8BitVolume], AL - - Ret - -EndP PreMix12Surround8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Panned8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8PannedOffset Macro Index - DW Offset M12Mix8Panned&Index& - EndM - - REPT 16 - M12Mix8PannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Panned8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Panned8BitOffsetTable+BX] - - M12Mix8PannedNext 0 - - RetN - - M12Mix8Panned 0 - M12Mix8Panned 1 - M12Mix8Panned 2 - M12Mix8Panned 3 - M12Mix8Panned 4 - M12Mix8Panned 5 - M12Mix8Panned 6 - M12Mix8Panned 7 - M12Mix8Panned 8 - M12Mix8Panned 9 - M12Mix8Panned 10 - M12Mix8Panned 11 - M12Mix8Panned 12 - M12Mix8Panned 13 - M12Mix8Panned 14 - M12Mix8Panned 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8Panned0 - - Ret - -EndP Mix12Panned8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Panned8Bit - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12PannedMacro Macro Index - Mov Byte Ptr [CS:M12Mix8PannedVolume&Index&], AL - EndM - - REPT 17 - PreMix12PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Mov AL, [SI+0Ch] - Sub AL, [SI+0Eh] - Add AL, AL - - IndexCounter = 0 - - PreMix12PannedMacro2 Macro Index - Mov Byte Ptr [CS:M12Mix8PannedRightVolumeOffset&Index&], AL - EndM - - REPT 16 - PreMix12PannedMacro2 %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Panned8Bit - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix12Single16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16SingleOffset Macro Index - DW Offset M12Mix16Single&Index& - EndM - - REPT 16 - M12Mix16SingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Single16Bit - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Single16BitOffsetTable+BX] - -M12Single16BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - RetN - - M12Mix16Single 0 - M12Mix16Single 1 - M12Mix16Single 2 - M12Mix16Single 3 - M12Mix16Single 4 - M12Mix16Single 5 - M12Mix16Single 6 - M12Mix16Single 7 - M12Mix16Single 8 - M12Mix16Single 9 - M12Mix16Single 10 - M12Mix16Single 11 - M12Mix16Single 12 - M12Mix16Single 13 - M12Mix16Single 14 - M12Mix16Single 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16Single0 - - Ret - -EndP Mix12Single16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Left16Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Single16BitVolume], AL - Ret - -EndP PreMix12Left16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Right16Bit - - Add MixBufferOffset, MixResolution/8 - Mov AL, [SI+0Ch] - Mov Byte Ptr [CS:M12Single16BitVolume], AL - - Ret - -EndP PreMix12Right16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16CentralOffset Macro Index - DW Offset M12Mix16Central&Index& - EndM - - REPT 16 - M12Mix16CentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central16BitOffsetTable+BX] - -M12Central16BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - - RetN - - M12Mix16Central 0 - M12Mix16Central 1 - M12Mix16Central 2 - M12Mix16Central 3 - M12Mix16Central 4 - M12Mix16Central 5 - M12Mix16Central 6 - M12Mix16Central 7 - M12Mix16Central 8 - M12Mix16Central 9 - M12Mix16Central 10 - M12Mix16Central 11 - M12Mix16Central 12 - M12Mix16Central 13 - M12Mix16Central 14 - M12Mix16Central 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16Central0 - - Ret - -EndP Mix12Central16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central16Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Central16BitVolume], AL - - Ret - -EndP PreMix12Central16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Surround16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16SurroundOffset Macro Index - DW Offset M12Mix16Surround&Index& - EndM - - REPT 16 - M12Mix16SurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Surround16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Surround16BitOffsetTable+BX] - -M12Surround16BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - - RetN - - M12Mix16Surround 0 - M12Mix16Surround 1 - M12Mix16Surround 2 - M12Mix16Surround 3 - M12Mix16Surround 4 - M12Mix16Surround 5 - M12Mix16Surround 6 - M12Mix16Surround 7 - M12Mix16Surround 8 - M12Mix16Surround 9 - M12Mix16Surround 10 - M12Mix16Surround 11 - M12Mix16Surround 12 - M12Mix16Surround 13 - M12Mix16Surround 14 - M12Mix16Surround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16Surround0 - - Ret - -EndP Mix12Surround16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Surround16Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Surround16BitVolume], AL - - Ret - -EndP PreMix12Surround16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Panned16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16PannedOffset Macro Index - DW Offset M12Mix16Panned&Index& - EndM - - REPT 16 - M12Mix16PannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Panned16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Panned16BitOffsetTable+BX] - - M12Mix16PannedNext 0 - - RetN - -Pan12Bit16Loop: - M12Mix16PannedNext 16 - - M12Mix16Panned 0 - M12Mix16Panned 1 - M12Mix16Panned 2 - M12Mix16Panned 3 - M12Mix16Panned 4 - M12Mix16Panned 5 - M12Mix16Panned 6 - M12Mix16Panned 7 - M12Mix16Panned 8 - M12Mix16Panned 9 - M12Mix16Panned 10 - M12Mix16Panned 11 - M12Mix16Panned 12 - M12Mix16Panned 13 - M12Mix16Panned 14 - - M12Mix16Panned15: - Add BX, BX - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [BX] - Sub [SI+EXTRAOFFSET], AX - M12Mix16PannedRightVolumeOffset15 EQU $+3 - Mov AX, [BX+1200h] - Sub [SI+MixResolution/8+EXTRAOFFSET], AX - - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ Pan12Bit16Loop - - Ret - -EndP Mix12Panned16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Panned16Bit - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12PannedMacro Macro Index - Mov Byte Ptr [CS:M12Mix16PannedVolume&Index&], AL - EndM - - REPT 17 - PreMix12PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Mov AL, [SI+0Ch] - Sub AL, [SI+0Eh] - Add AL, AL - - IndexCounter = 0 - - PreMix12PannedMacro2 Macro Index - Mov Byte Ptr [CS:M12Mix16PannedRightVolumeOffset&Index&], AL - EndM - - REPT 16 - PreMix12PannedMacro2 %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Panned16Bit - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + +M12Mix8Single Macro Index + +M12Mix8Single&Index&: + Mov BL, [ES:DI] ;; 2 + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8Central Macro Index + +M12Mix8Central&Index&: + Mov BL, [ES:DI] ;; 2 + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8Surround Macro Index + +M12Mix8Surround&Index&: + Mov BL, [ES:DI] ;; 2 + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 + +EndM + + ; Panned output +M12Mix8PannedNext Macro Index + +M12Mix8PannedVolume&Index& EQU $+1 + Mov BH, 12h + Mov BL, [ES:DI] + +EndM + +M12Mix8Panned Macro Index + +M12Mix8Panned&Index&: + Add BX, BX + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [BX] + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +M12Mix8PannedRightVolumeOffset&Index& EQU $+3 + Mov AX, [BX+1200h] + + M12Mix8PannedNext %(Index+1) + + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +M12Mix16Single Macro Index + +M12Mix16Single&Index&: + Mov BL, [ES:EDI+EDI+1] + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +EndM + +M12Mix16Central Macro Index + +M12Mix16Central&Index&: + Mov BL, [ES:EDI+EDI+1] + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +M12Mix16Surround Macro Index + +M12Mix16Surround&Index&: + Mov BL, [ES:EDI+EDI+1] + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + + ; Panned output +M12Mix16PannedNext Macro Index + +M12Mix16PannedVolume&Index& EQU $+1 + Mov BH, 12h + Mov BL, [ES:EDI+EDI+1] + +EndM + +M12Mix16Panned Macro Index + +M12Mix16Panned&Index&: + Add BX, BX + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [BX] + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +M12Mix16PannedRightVolumeOffset&Index& EQU $+3 + Mov AX, [BX+1200h] + + M12Mix16PannedNext %(Index+1) + + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix12Single8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8SingleOffset Macro Index + DW Offset M12Mix8Single&Index& + EndM + + REPT 16 + M12Mix8SingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Single8Bit + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Single8BitOffsetTable+BX] + +M12Single8BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + RetN + + M12Mix8Single 0 + M12Mix8Single 1 + M12Mix8Single 2 + M12Mix8Single 3 + M12Mix8Single 4 + M12Mix8Single 5 + M12Mix8Single 6 + M12Mix8Single 7 + M12Mix8Single 8 + M12Mix8Single 9 + M12Mix8Single 10 + M12Mix8Single 11 + M12Mix8Single 12 + M12Mix8Single 13 + M12Mix8Single 14 + M12Mix8Single 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8Single0 + + Ret + +EndP Mix12Single8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Left8Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Single8BitVolume], AL + Ret + +EndP PreMix12Left8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Right8Bit + + Add MixBufferOffset, MixResolution/8 + Mov AL, [SI+0Ch] + Mov Byte Ptr [CS:M12Single8BitVolume], AL + + Ret + +EndP PreMix12Right8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8CentralOffset Macro Index + DW Offset M12Mix8Central&Index& + EndM + + REPT 16 + M12Mix8CentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central8BitOffsetTable+BX] + +M12Central8BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + RetN + + M12Mix8Central 0 + M12Mix8Central 1 + M12Mix8Central 2 + M12Mix8Central 3 + M12Mix8Central 4 + M12Mix8Central 5 + M12Mix8Central 6 + M12Mix8Central 7 + M12Mix8Central 8 + M12Mix8Central 9 + M12Mix8Central 10 + M12Mix8Central 11 + M12Mix8Central 12 + M12Mix8Central 13 + M12Mix8Central 14 + M12Mix8Central 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8Central0 + + Ret + +EndP Mix12Central8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central8Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Central8BitVolume], AL + + Ret + +EndP PreMix12Central8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Surround8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8SurroundOffset Macro Index + DW Offset M12Mix8Surround&Index& + EndM + + REPT 16 + M12Mix8SurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Surround8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Surround8BitOffsetTable+BX] + +M12Surround8BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + + RetN + + M12Mix8Surround 0 + M12Mix8Surround 1 + M12Mix8Surround 2 + M12Mix8Surround 3 + M12Mix8Surround 4 + M12Mix8Surround 5 + M12Mix8Surround 6 + M12Mix8Surround 7 + M12Mix8Surround 8 + M12Mix8Surround 9 + M12Mix8Surround 10 + M12Mix8Surround 11 + M12Mix8Surround 12 + M12Mix8Surround 13 + M12Mix8Surround 14 + M12Mix8Surround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8Surround0 + + Ret + +EndP Mix12Surround8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Surround8Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Surround8BitVolume], AL + + Ret + +EndP PreMix12Surround8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Panned8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8PannedOffset Macro Index + DW Offset M12Mix8Panned&Index& + EndM + + REPT 16 + M12Mix8PannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Panned8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Panned8BitOffsetTable+BX] + + M12Mix8PannedNext 0 + + RetN + + M12Mix8Panned 0 + M12Mix8Panned 1 + M12Mix8Panned 2 + M12Mix8Panned 3 + M12Mix8Panned 4 + M12Mix8Panned 5 + M12Mix8Panned 6 + M12Mix8Panned 7 + M12Mix8Panned 8 + M12Mix8Panned 9 + M12Mix8Panned 10 + M12Mix8Panned 11 + M12Mix8Panned 12 + M12Mix8Panned 13 + M12Mix8Panned 14 + M12Mix8Panned 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8Panned0 + + Ret + +EndP Mix12Panned8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Panned8Bit + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12PannedMacro Macro Index + Mov Byte Ptr [CS:M12Mix8PannedVolume&Index&], AL + EndM + + REPT 17 + PreMix12PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Mov AL, [SI+0Ch] + Sub AL, [SI+0Eh] + Add AL, AL + + IndexCounter = 0 + + PreMix12PannedMacro2 Macro Index + Mov Byte Ptr [CS:M12Mix8PannedRightVolumeOffset&Index&], AL + EndM + + REPT 16 + PreMix12PannedMacro2 %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Panned8Bit + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix12Single16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16SingleOffset Macro Index + DW Offset M12Mix16Single&Index& + EndM + + REPT 16 + M12Mix16SingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Single16Bit + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Single16BitOffsetTable+BX] + +M12Single16BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + RetN + + M12Mix16Single 0 + M12Mix16Single 1 + M12Mix16Single 2 + M12Mix16Single 3 + M12Mix16Single 4 + M12Mix16Single 5 + M12Mix16Single 6 + M12Mix16Single 7 + M12Mix16Single 8 + M12Mix16Single 9 + M12Mix16Single 10 + M12Mix16Single 11 + M12Mix16Single 12 + M12Mix16Single 13 + M12Mix16Single 14 + M12Mix16Single 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16Single0 + + Ret + +EndP Mix12Single16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Left16Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Single16BitVolume], AL + Ret + +EndP PreMix12Left16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Right16Bit + + Add MixBufferOffset, MixResolution/8 + Mov AL, [SI+0Ch] + Mov Byte Ptr [CS:M12Single16BitVolume], AL + + Ret + +EndP PreMix12Right16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16CentralOffset Macro Index + DW Offset M12Mix16Central&Index& + EndM + + REPT 16 + M12Mix16CentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central16BitOffsetTable+BX] + +M12Central16BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + + RetN + + M12Mix16Central 0 + M12Mix16Central 1 + M12Mix16Central 2 + M12Mix16Central 3 + M12Mix16Central 4 + M12Mix16Central 5 + M12Mix16Central 6 + M12Mix16Central 7 + M12Mix16Central 8 + M12Mix16Central 9 + M12Mix16Central 10 + M12Mix16Central 11 + M12Mix16Central 12 + M12Mix16Central 13 + M12Mix16Central 14 + M12Mix16Central 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16Central0 + + Ret + +EndP Mix12Central16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central16Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Central16BitVolume], AL + + Ret + +EndP PreMix12Central16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Surround16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16SurroundOffset Macro Index + DW Offset M12Mix16Surround&Index& + EndM + + REPT 16 + M12Mix16SurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Surround16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Surround16BitOffsetTable+BX] + +M12Surround16BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + + RetN + + M12Mix16Surround 0 + M12Mix16Surround 1 + M12Mix16Surround 2 + M12Mix16Surround 3 + M12Mix16Surround 4 + M12Mix16Surround 5 + M12Mix16Surround 6 + M12Mix16Surround 7 + M12Mix16Surround 8 + M12Mix16Surround 9 + M12Mix16Surround 10 + M12Mix16Surround 11 + M12Mix16Surround 12 + M12Mix16Surround 13 + M12Mix16Surround 14 + M12Mix16Surround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16Surround0 + + Ret + +EndP Mix12Surround16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Surround16Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Surround16BitVolume], AL + + Ret + +EndP PreMix12Surround16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Panned16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16PannedOffset Macro Index + DW Offset M12Mix16Panned&Index& + EndM + + REPT 16 + M12Mix16PannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Panned16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Panned16BitOffsetTable+BX] + + M12Mix16PannedNext 0 + + RetN + +Pan12Bit16Loop: + M12Mix16PannedNext 16 + + M12Mix16Panned 0 + M12Mix16Panned 1 + M12Mix16Panned 2 + M12Mix16Panned 3 + M12Mix16Panned 4 + M12Mix16Panned 5 + M12Mix16Panned 6 + M12Mix16Panned 7 + M12Mix16Panned 8 + M12Mix16Panned 9 + M12Mix16Panned 10 + M12Mix16Panned 11 + M12Mix16Panned 12 + M12Mix16Panned 13 + M12Mix16Panned 14 + + M12Mix16Panned15: + Add BX, BX + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [BX] + Sub [SI+EXTRAOFFSET], AX + M12Mix16PannedRightVolumeOffset15 EQU $+3 + Mov AX, [BX+1200h] + Sub [SI+MixResolution/8+EXTRAOFFSET], AX + + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ Pan12Bit16Loop + + Ret + +EndP Mix12Panned16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Panned16Bit + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12PannedMacro Macro Index + Mov Byte Ptr [CS:M12Mix16PannedVolume&Index&], AL + EndM + + REPT 17 + PreMix12PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Mov AL, [SI+0Ch] + Sub AL, [SI+0Eh] + Add AL, AL + + IndexCounter = 0 + + PreMix12PannedMacro2 Macro Index + Mov Byte Ptr [CS:M12Mix16PannedRightVolumeOffset&Index&], AL + EndM + + REPT 16 + PreMix12PannedMacro2 %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Panned16Bit + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M12BITF.INC b/SoundDrivers/M12BITF.INC index dec5297..56eb5ce 100755 --- a/SoundDrivers/M12BITF.INC +++ b/SoundDrivers/M12BITF.INC @@ -1,49 +1,49 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix12Left8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF - DW Offset MixForwardsLoop, PreMix12Left8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF - DW Offset MixPingPongLoop, PreMix12Left8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF - ; Right only - DW Offset MixNoLoop, PreMix12Right8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF - DW Offset MixForwardsLoop, PreMix12Right8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF - DW Offset MixPingPongLoop, PreMix12Right8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF - ; Central - DW Offset MixNoLoop, PreMix12Central8BitF, MFS8Bit, MBS8Bit, Mix12Central8BitF - DW Offset MixForwardsLoop, PreMix12Central8BitF, MFS8Bit, MBS8Bit, Mix12Central8BitF - DW Offset MixPingPongLoop, PreMix12Central8BitF, MFS8Bit, MBS8Bit, Mix12Central8BitF - ; Stereo - DW Offset MixNoLoop, PreMix12Panned8BitF, MFS8Bit, MBS8Bit, Mix12Panned8BitF - DW Offset MixForwardsLoop, PreMix12Panned8BitF, MFS8Bit, MBS8Bit, Mix12Panned8BitF - DW Offset MixPingPongLoop, PreMix12Panned8BitF, MFS8Bit, MBS8Bit, Mix12Panned8BitF - ; Surround - DW Offset MixNoLoop, PreMix12Surround8BitF, MFS8Bit, MBS8Bit, Mix12Surround8BitF - DW Offset MixForwardsLoop, PreMix12Surround8BitF, MFS8Bit, MBS8Bit, Mix12Surround8BitF - DW Offset MixPingPongLoop, PreMix12Surround8BitF, MFS8Bit, MBS8Bit, Mix12Surround8BitF - - ; 16 bit tables - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix12Left16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF - DW Offset MixForwardsLoop, PreMix12Left16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF - DW Offset MixPingPongLoop, PreMix12Left16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF - ; Right only - DW Offset MixNoLoop, PreMix12Right16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF - DW Offset MixForwardsLoop, PreMix12Right16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF - DW Offset MixPingPongLoop, PreMix12Right16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF - ; Central - DW Offset MixNoLoop, PreMix12Central16BitF, MFS16Bit, MBS16Bit, Mix12Central16BitF - DW Offset MixForwardsLoop, PreMix12Central16BitF, MFS16Bit, MBS16Bit, Mix12Central16BitF - DW Offset MixPingPongLoop, PreMix12Central16BitF, MFS16Bit, MBS16Bit, Mix12Central16BitF - ; Stereo - DW Offset MixNoLoop, PreMix12Panned16BitF, MFS16Bit, MBS16Bit, Mix12Panned16BitF - DW Offset MixForwardsLoop, PreMix12Panned16BitF, MFS16Bit, MBS16Bit, Mix12Panned16BitF - DW Offset MixPingPongLoop, PreMix12Panned16BitF, MFS16Bit, MBS16Bit, Mix12Panned16BitF - ; Surround - DW Offset MixNoLoop, PreMix12Surround16BitF, MFS16Bit, MBS16Bit, Mix12Surround16BitF - DW Offset MixForwardsLoop, PreMix12Surround16BitF, MFS16Bit, MBS16Bit, Mix12Surround16BitF - DW Offset MixPingPongLoop, PreMix12Surround16BitF, MFS16Bit, MBS16Bit, Mix12Surround16BitF + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix12Left8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF + DW Offset MixForwardsLoop, PreMix12Left8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF + DW Offset MixPingPongLoop, PreMix12Left8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF + ; Right only + DW Offset MixNoLoop, PreMix12Right8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF + DW Offset MixForwardsLoop, PreMix12Right8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF + DW Offset MixPingPongLoop, PreMix12Right8BitF, MFS8Bit, MBS8Bit, Mix12Single8BitF + ; Central + DW Offset MixNoLoop, PreMix12Central8BitF, MFS8Bit, MBS8Bit, Mix12Central8BitF + DW Offset MixForwardsLoop, PreMix12Central8BitF, MFS8Bit, MBS8Bit, Mix12Central8BitF + DW Offset MixPingPongLoop, PreMix12Central8BitF, MFS8Bit, MBS8Bit, Mix12Central8BitF + ; Stereo + DW Offset MixNoLoop, PreMix12Panned8BitF, MFS8Bit, MBS8Bit, Mix12Panned8BitF + DW Offset MixForwardsLoop, PreMix12Panned8BitF, MFS8Bit, MBS8Bit, Mix12Panned8BitF + DW Offset MixPingPongLoop, PreMix12Panned8BitF, MFS8Bit, MBS8Bit, Mix12Panned8BitF + ; Surround + DW Offset MixNoLoop, PreMix12Surround8BitF, MFS8Bit, MBS8Bit, Mix12Surround8BitF + DW Offset MixForwardsLoop, PreMix12Surround8BitF, MFS8Bit, MBS8Bit, Mix12Surround8BitF + DW Offset MixPingPongLoop, PreMix12Surround8BitF, MFS8Bit, MBS8Bit, Mix12Surround8BitF + + ; 16 bit tables + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix12Left16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF + DW Offset MixForwardsLoop, PreMix12Left16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF + DW Offset MixPingPongLoop, PreMix12Left16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF + ; Right only + DW Offset MixNoLoop, PreMix12Right16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF + DW Offset MixForwardsLoop, PreMix12Right16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF + DW Offset MixPingPongLoop, PreMix12Right16BitF, MFS16Bit, MBS16Bit, Mix12Single16BitF + ; Central + DW Offset MixNoLoop, PreMix12Central16BitF, MFS16Bit, MBS16Bit, Mix12Central16BitF + DW Offset MixForwardsLoop, PreMix12Central16BitF, MFS16Bit, MBS16Bit, Mix12Central16BitF + DW Offset MixPingPongLoop, PreMix12Central16BitF, MFS16Bit, MBS16Bit, Mix12Central16BitF + ; Stereo + DW Offset MixNoLoop, PreMix12Panned16BitF, MFS16Bit, MBS16Bit, Mix12Panned16BitF + DW Offset MixForwardsLoop, PreMix12Panned16BitF, MFS16Bit, MBS16Bit, Mix12Panned16BitF + DW Offset MixPingPongLoop, PreMix12Panned16BitF, MFS16Bit, MBS16Bit, Mix12Panned16BitF + ; Surround + DW Offset MixNoLoop, PreMix12Surround16BitF, MFS16Bit, MBS16Bit, Mix12Surround16BitF + DW Offset MixForwardsLoop, PreMix12Surround16BitF, MFS16Bit, MBS16Bit, Mix12Surround16BitF + DW Offset MixPingPongLoop, PreMix12Surround16BitF, MFS16Bit, MBS16Bit, Mix12Surround16BitF diff --git a/SoundDrivers/M12BITF.MIX b/SoundDrivers/M12BITF.MIX index 75bd69b..17a4c6f 100755 --- a/SoundDrivers/M12BITF.MIX +++ b/SoundDrivers/M12BITF.MIX @@ -1,807 +1,807 @@ - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - -Get8BitFWaveform Macro - Mov AL, [ES:DI] - Add BL, 80h - Add AL, 80h - Add BL, AL - RCR BL, 1 - Sub BL, 80h -EndM - -Get16BitFWaveform Macro - Mov AL, [ES:EDI+EDI+1] - Add BL, 80h - Add AL, 80h - Add BL, AL - RCR BL, 1 - Sub BL, 80h - -EndM - -M12Mix8FSingle Macro Index - -M12Mix8FSingle&Index&: - Get8BitFWaveForm - - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8FCentral Macro Index - -M12Mix8FCentral&Index&: - Get8BitFWaveform - - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8FSurround Macro Index - -M12Mix8FSurround&Index&: - Get8BitFWaveform - - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8FPanned Macro Index - -M12Mix8FPanned&Index&: - Get8BitFWaveform - - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [EBX+EBX] - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -M12Mix8FPannedRightVolumeOffset&Index& EQU $+4 - Mov AX, [EBX+EBX+1200h] - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -M12Mix16FSingle Macro Index - -M12Mix16FSingle&Index&: - Get16BitFWaveForm - - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -EndM - -M12Mix16FCentral Macro Index - -M12Mix16FCentral&Index&: - Get16BitFWaveform - - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -M12Mix16FSurround Macro Index - -M12Mix16FSurround&Index&: - Get16BitFWaveform - - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - - ; Panned output -M12Mix16FPanned Macro Index - -M12Mix16FPanned&Index&: - Get16BitFWaveform - - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [EBX+EBX] - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -M12Mix16FPannedRightVolumeOffset&Index& EQU $+4 - Mov AX, [EBX+EBX+1200h] - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix12Single8BitFOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8FSingleOffset Macro Index - DW Offset M12Mix8FSingle&Index& - EndM - - REPT 16 - M12Mix8FSingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Single8BitF - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Single8BitFOffsetTable+BX] - -Mix12Single8BitFVolume EQU $+3 - Mov EBX, 0 - - Mov BL, [ES:DI] - - RetN - - M12Mix8FSingle 0 - M12Mix8FSingle 1 - M12Mix8FSingle 2 - M12Mix8FSingle 3 - M12Mix8FSingle 4 - M12Mix8FSingle 5 - M12Mix8FSingle 6 - M12Mix8FSingle 7 - M12Mix8FSingle 8 - M12Mix8FSingle 9 - M12Mix8FSingle 10 - M12Mix8FSingle 11 - M12Mix8FSingle 12 - M12Mix8FSingle 13 - M12Mix8FSingle 14 - M12Mix8FSingle 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8FSingle0 - - Ret - -EndP Mix12Single8BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Left8BitF - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:Mix12Single8BitFVolume], AL - - Ret - -EndP PreMix12Left8BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Right8BitF - - Add MixBufferOffset, MixResolution/8 - Mov AL, [SI+0Ch] - Mov Byte Ptr [CS:Mix12Single8BitFVolume], AL - - Ret - -EndP PreMix12Right8BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central8BitFOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8FCentralOffset Macro Index - DW Offset M12Mix8FCentral&Index& - EndM - - REPT 16 - M12Mix8FCentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central8BitF - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central8BitFOffsetTable+BX] - -Mix12Central8BitFVolume EQU $+3 - Mov EBX, 0 - - Mov BL, [ES:DI] - - RetN - - M12Mix8FCentral 0 - M12Mix8FCentral 1 - M12Mix8FCentral 2 - M12Mix8FCentral 3 - M12Mix8FCentral 4 - M12Mix8FCentral 5 - M12Mix8FCentral 6 - M12Mix8FCentral 7 - M12Mix8FCentral 8 - M12Mix8FCentral 9 - M12Mix8FCentral 10 - M12Mix8FCentral 11 - M12Mix8FCentral 12 - M12Mix8FCentral 13 - M12Mix8FCentral 14 - M12Mix8FCentral 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8FCentral0 - - Ret - -EndP Mix12Central8BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central8BitF - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:Mix12Central8BitFVolume], AL - - Ret - -EndP PreMix12Central8BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Surround8BitFOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8FSurroundOffset Macro Index - DW Offset M12Mix8FSurround&Index& - EndM - - REPT 16 - M12Mix8FSurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Surround8BitF - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Surround8BitFOffsetTable+BX] - -Mix12Surround8BitFVolume EQU $+3 - Mov EBX, 0 - - Mov BL, [ES:DI] - - RetN - - M12Mix8FSurround 0 - M12Mix8FSurround 1 - M12Mix8FSurround 2 - M12Mix8FSurround 3 - M12Mix8FSurround 4 - M12Mix8FSurround 5 - M12Mix8FSurround 6 - M12Mix8FSurround 7 - M12Mix8FSurround 8 - M12Mix8FSurround 9 - M12Mix8FSurround 10 - M12Mix8FSurround 11 - M12Mix8FSurround 12 - M12Mix8FSurround 13 - M12Mix8FSurround 14 - M12Mix8FSurround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8FSurround0 - - Ret - -EndP Mix12Surround8BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Surround8BitF - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:Mix12Surround8BitFVolume], AL - - Ret - -EndP PreMix12Surround8BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Panned8BitFOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8FPannedOffset Macro Index - DW Offset M12Mix8FPanned&Index& - EndM - - REPT 16 - M12Mix8FPannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Panned8BitF - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Panned8BitFOffsetTable+BX] - -Mix12Panned8BitFVolume EQU $+3 - Mov EBX, 0 - - Mov BL, [ES:DI] - - RetN - - M12Mix8FPanned 0 - M12Mix8FPanned 1 - M12Mix8FPanned 2 - M12Mix8FPanned 3 - M12Mix8FPanned 4 - M12Mix8FPanned 5 - M12Mix8FPanned 6 - M12Mix8FPanned 7 - M12Mix8FPanned 8 - M12Mix8FPanned 9 - M12Mix8FPanned 10 - M12Mix8FPanned 11 - M12Mix8FPanned 12 - M12Mix8FPanned 13 - M12Mix8FPanned 14 - M12Mix8FPanned 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8FPanned0 - - Ret - -EndP Mix12Panned8BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Panned8BitF - - Mov AL, [SI+0Eh] - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:Mix12Panned8BitFVolume], AL - - Xor AL, AL - Mov AH, [SI+0Ch] - Sub AH, [SI+0Eh] - Add AH, AH - MovSX EAX, AX - - IndexCounter = 0 - - PreMix12Panned8BitFMacro2 Macro Index - Mov DWord Ptr [CS:M12Mix8FPannedRightVolumeOffset&Index&], EAX - EndM - - REPT 16 - PreMix12Panned8BitFMacro2 %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Panned8BitF - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix12Single16BitFOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16FSingleOffset Macro Index - DW Offset M12Mix16FSingle&Index& - EndM - - REPT 16 - M12Mix16FSingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Single16BitF - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Single16BitFOffsetTable+BX] - -Mix12Single16BitFVolume EQU $+3 - Mov EBX, 0 - - Mov BL, [ES:EDI+EDI+1] - - RetN - - M12Mix16FSingle 0 - M12Mix16FSingle 1 - M12Mix16FSingle 2 - M12Mix16FSingle 3 - M12Mix16FSingle 4 - M12Mix16FSingle 5 - M12Mix16FSingle 6 - M12Mix16FSingle 7 - M12Mix16FSingle 8 - M12Mix16FSingle 9 - M12Mix16FSingle 10 - M12Mix16FSingle 11 - M12Mix16FSingle 12 - M12Mix16FSingle 13 - M12Mix16FSingle 14 - M12Mix16FSingle 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16FSingle0 - - Ret - -EndP Mix12Single16BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Left16BitF - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:Mix12Single16BitFVolume], AL - - Ret - -EndP PreMix12Left16BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Right16BitF - - Add MixBufferOffset, MixResolution/8 - Mov AL, [SI+0Ch] - Mov Byte Ptr [CS:Mix12Single16BitFVolume], AL - - Ret - -EndP PreMix12Right16BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central16BitFOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16FCentralOffset Macro Index - DW Offset M12Mix16FCentral&Index& - EndM - - REPT 16 - M12Mix16FCentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central16BitF - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central16BitFOffsetTable+BX] - -Mix12Central16BitFVolume EQU $+3 - Mov EBX, 0 - - Mov BL, [ES:EDI+EDI+1] - - RetN - - M12Mix16FCentral 0 - M12Mix16FCentral 1 - M12Mix16FCentral 2 - M12Mix16FCentral 3 - M12Mix16FCentral 4 - M12Mix16FCentral 5 - M12Mix16FCentral 6 - M12Mix16FCentral 7 - M12Mix16FCentral 8 - M12Mix16FCentral 9 - M12Mix16FCentral 10 - M12Mix16FCentral 11 - M12Mix16FCentral 12 - M12Mix16FCentral 13 - M12Mix16FCentral 14 - M12Mix16FCentral 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16FCentral0 - - Ret - -EndP Mix12Central16BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central16BitF - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:Mix12Central16BitFVolume], AL - - Ret - -EndP PreMix12Central16BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Surround16BitFOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16FSurroundOffset Macro Index - DW Offset M12Mix16FSurround&Index& - EndM - - REPT 16 - M12Mix16FSurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Surround16BitF - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Surround16BitFOffsetTable+BX] - -Mix12Surround16BitFVolume EQU $+3 - Mov EBX, 0 - - Mov BL, [ES:EDI+EDI+1] - - RetN - - M12Mix16FSurround 0 - M12Mix16FSurround 1 - M12Mix16FSurround 2 - M12Mix16FSurround 3 - M12Mix16FSurround 4 - M12Mix16FSurround 5 - M12Mix16FSurround 6 - M12Mix16FSurround 7 - M12Mix16FSurround 8 - M12Mix16FSurround 9 - M12Mix16FSurround 10 - M12Mix16FSurround 11 - M12Mix16FSurround 12 - M12Mix16FSurround 13 - M12Mix16FSurround 14 - M12Mix16FSurround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16FSurround0 - - Ret - -EndP Mix12Surround16BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Surround16BitF - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:Mix12Surround16BitFVolume], AL - - Ret - -EndP PreMix12Surround16BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Panned16BitFOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16FPannedOffset Macro Index - DW Offset M12Mix16FPanned&Index& - EndM - - REPT 16 - M12Mix16FPannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Panned16BitF - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Panned16BitFOffsetTable+BX] - -Mix12Panned16BitFVolume EQU $+3 - Mov EBX, 0 - - Mov BL, [ES:EDI+EDI+1] - - RetN - -Pan12BitF16Loop: - M12Mix16FPanned 0 - M12Mix16FPanned 1 - M12Mix16FPanned 2 - M12Mix16FPanned 3 - M12Mix16FPanned 4 - M12Mix16FPanned 5 - M12Mix16FPanned 6 - M12Mix16FPanned 7 - M12Mix16FPanned 8 - M12Mix16FPanned 9 - M12Mix16FPanned 10 - M12Mix16FPanned 11 - M12Mix16FPanned 12 - M12Mix16FPanned 13 - M12Mix16FPanned 14 - M12Mix16FPanned 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ Pan12BitF16Loop - - Ret - -EndP Mix12Panned16BitF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Panned16BitF - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:Mix12Panned16BitFVolume], AL - - Xor AL, AL - Mov AH, [SI+0Ch] - Sub AH, [SI+0Eh] - Add AH, AH - MovSX EAX, AX - - IndexCounter = 0 - - PreMix12PannedMacro2 Macro Index - Mov DWord Ptr [CS:M12Mix16FPannedRightVolumeOffset&Index&], EAX - EndM - - REPT 16 - PreMix12PannedMacro2 %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Panned16BitF - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + +Get8BitFWaveform Macro + Mov AL, [ES:DI] + Add BL, 80h + Add AL, 80h + Add BL, AL + RCR BL, 1 + Sub BL, 80h +EndM + +Get16BitFWaveform Macro + Mov AL, [ES:EDI+EDI+1] + Add BL, 80h + Add AL, 80h + Add BL, AL + RCR BL, 1 + Sub BL, 80h + +EndM + +M12Mix8FSingle Macro Index + +M12Mix8FSingle&Index&: + Get8BitFWaveForm + + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8FCentral Macro Index + +M12Mix8FCentral&Index&: + Get8BitFWaveform + + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8FSurround Macro Index + +M12Mix8FSurround&Index&: + Get8BitFWaveform + + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8FPanned Macro Index + +M12Mix8FPanned&Index&: + Get8BitFWaveform + + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [EBX+EBX] + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +M12Mix8FPannedRightVolumeOffset&Index& EQU $+4 + Mov AX, [EBX+EBX+1200h] + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +M12Mix16FSingle Macro Index + +M12Mix16FSingle&Index&: + Get16BitFWaveForm + + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +EndM + +M12Mix16FCentral Macro Index + +M12Mix16FCentral&Index&: + Get16BitFWaveform + + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +M12Mix16FSurround Macro Index + +M12Mix16FSurround&Index&: + Get16BitFWaveform + + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + + ; Panned output +M12Mix16FPanned Macro Index + +M12Mix16FPanned&Index&: + Get16BitFWaveform + + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [EBX+EBX] + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +M12Mix16FPannedRightVolumeOffset&Index& EQU $+4 + Mov AX, [EBX+EBX+1200h] + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix12Single8BitFOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8FSingleOffset Macro Index + DW Offset M12Mix8FSingle&Index& + EndM + + REPT 16 + M12Mix8FSingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Single8BitF + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Single8BitFOffsetTable+BX] + +Mix12Single8BitFVolume EQU $+3 + Mov EBX, 0 + + Mov BL, [ES:DI] + + RetN + + M12Mix8FSingle 0 + M12Mix8FSingle 1 + M12Mix8FSingle 2 + M12Mix8FSingle 3 + M12Mix8FSingle 4 + M12Mix8FSingle 5 + M12Mix8FSingle 6 + M12Mix8FSingle 7 + M12Mix8FSingle 8 + M12Mix8FSingle 9 + M12Mix8FSingle 10 + M12Mix8FSingle 11 + M12Mix8FSingle 12 + M12Mix8FSingle 13 + M12Mix8FSingle 14 + M12Mix8FSingle 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8FSingle0 + + Ret + +EndP Mix12Single8BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Left8BitF + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:Mix12Single8BitFVolume], AL + + Ret + +EndP PreMix12Left8BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Right8BitF + + Add MixBufferOffset, MixResolution/8 + Mov AL, [SI+0Ch] + Mov Byte Ptr [CS:Mix12Single8BitFVolume], AL + + Ret + +EndP PreMix12Right8BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central8BitFOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8FCentralOffset Macro Index + DW Offset M12Mix8FCentral&Index& + EndM + + REPT 16 + M12Mix8FCentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central8BitF + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central8BitFOffsetTable+BX] + +Mix12Central8BitFVolume EQU $+3 + Mov EBX, 0 + + Mov BL, [ES:DI] + + RetN + + M12Mix8FCentral 0 + M12Mix8FCentral 1 + M12Mix8FCentral 2 + M12Mix8FCentral 3 + M12Mix8FCentral 4 + M12Mix8FCentral 5 + M12Mix8FCentral 6 + M12Mix8FCentral 7 + M12Mix8FCentral 8 + M12Mix8FCentral 9 + M12Mix8FCentral 10 + M12Mix8FCentral 11 + M12Mix8FCentral 12 + M12Mix8FCentral 13 + M12Mix8FCentral 14 + M12Mix8FCentral 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8FCentral0 + + Ret + +EndP Mix12Central8BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central8BitF + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:Mix12Central8BitFVolume], AL + + Ret + +EndP PreMix12Central8BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Surround8BitFOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8FSurroundOffset Macro Index + DW Offset M12Mix8FSurround&Index& + EndM + + REPT 16 + M12Mix8FSurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Surround8BitF + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Surround8BitFOffsetTable+BX] + +Mix12Surround8BitFVolume EQU $+3 + Mov EBX, 0 + + Mov BL, [ES:DI] + + RetN + + M12Mix8FSurround 0 + M12Mix8FSurround 1 + M12Mix8FSurround 2 + M12Mix8FSurround 3 + M12Mix8FSurround 4 + M12Mix8FSurround 5 + M12Mix8FSurround 6 + M12Mix8FSurround 7 + M12Mix8FSurround 8 + M12Mix8FSurround 9 + M12Mix8FSurround 10 + M12Mix8FSurround 11 + M12Mix8FSurround 12 + M12Mix8FSurround 13 + M12Mix8FSurround 14 + M12Mix8FSurround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8FSurround0 + + Ret + +EndP Mix12Surround8BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Surround8BitF + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:Mix12Surround8BitFVolume], AL + + Ret + +EndP PreMix12Surround8BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Panned8BitFOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8FPannedOffset Macro Index + DW Offset M12Mix8FPanned&Index& + EndM + + REPT 16 + M12Mix8FPannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Panned8BitF + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Panned8BitFOffsetTable+BX] + +Mix12Panned8BitFVolume EQU $+3 + Mov EBX, 0 + + Mov BL, [ES:DI] + + RetN + + M12Mix8FPanned 0 + M12Mix8FPanned 1 + M12Mix8FPanned 2 + M12Mix8FPanned 3 + M12Mix8FPanned 4 + M12Mix8FPanned 5 + M12Mix8FPanned 6 + M12Mix8FPanned 7 + M12Mix8FPanned 8 + M12Mix8FPanned 9 + M12Mix8FPanned 10 + M12Mix8FPanned 11 + M12Mix8FPanned 12 + M12Mix8FPanned 13 + M12Mix8FPanned 14 + M12Mix8FPanned 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8FPanned0 + + Ret + +EndP Mix12Panned8BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Panned8BitF + + Mov AL, [SI+0Eh] + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:Mix12Panned8BitFVolume], AL + + Xor AL, AL + Mov AH, [SI+0Ch] + Sub AH, [SI+0Eh] + Add AH, AH + MovSX EAX, AX + + IndexCounter = 0 + + PreMix12Panned8BitFMacro2 Macro Index + Mov DWord Ptr [CS:M12Mix8FPannedRightVolumeOffset&Index&], EAX + EndM + + REPT 16 + PreMix12Panned8BitFMacro2 %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Panned8BitF + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix12Single16BitFOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16FSingleOffset Macro Index + DW Offset M12Mix16FSingle&Index& + EndM + + REPT 16 + M12Mix16FSingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Single16BitF + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Single16BitFOffsetTable+BX] + +Mix12Single16BitFVolume EQU $+3 + Mov EBX, 0 + + Mov BL, [ES:EDI+EDI+1] + + RetN + + M12Mix16FSingle 0 + M12Mix16FSingle 1 + M12Mix16FSingle 2 + M12Mix16FSingle 3 + M12Mix16FSingle 4 + M12Mix16FSingle 5 + M12Mix16FSingle 6 + M12Mix16FSingle 7 + M12Mix16FSingle 8 + M12Mix16FSingle 9 + M12Mix16FSingle 10 + M12Mix16FSingle 11 + M12Mix16FSingle 12 + M12Mix16FSingle 13 + M12Mix16FSingle 14 + M12Mix16FSingle 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16FSingle0 + + Ret + +EndP Mix12Single16BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Left16BitF + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:Mix12Single16BitFVolume], AL + + Ret + +EndP PreMix12Left16BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Right16BitF + + Add MixBufferOffset, MixResolution/8 + Mov AL, [SI+0Ch] + Mov Byte Ptr [CS:Mix12Single16BitFVolume], AL + + Ret + +EndP PreMix12Right16BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central16BitFOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16FCentralOffset Macro Index + DW Offset M12Mix16FCentral&Index& + EndM + + REPT 16 + M12Mix16FCentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central16BitF + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central16BitFOffsetTable+BX] + +Mix12Central16BitFVolume EQU $+3 + Mov EBX, 0 + + Mov BL, [ES:EDI+EDI+1] + + RetN + + M12Mix16FCentral 0 + M12Mix16FCentral 1 + M12Mix16FCentral 2 + M12Mix16FCentral 3 + M12Mix16FCentral 4 + M12Mix16FCentral 5 + M12Mix16FCentral 6 + M12Mix16FCentral 7 + M12Mix16FCentral 8 + M12Mix16FCentral 9 + M12Mix16FCentral 10 + M12Mix16FCentral 11 + M12Mix16FCentral 12 + M12Mix16FCentral 13 + M12Mix16FCentral 14 + M12Mix16FCentral 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16FCentral0 + + Ret + +EndP Mix12Central16BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central16BitF + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:Mix12Central16BitFVolume], AL + + Ret + +EndP PreMix12Central16BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Surround16BitFOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16FSurroundOffset Macro Index + DW Offset M12Mix16FSurround&Index& + EndM + + REPT 16 + M12Mix16FSurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Surround16BitF + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Surround16BitFOffsetTable+BX] + +Mix12Surround16BitFVolume EQU $+3 + Mov EBX, 0 + + Mov BL, [ES:EDI+EDI+1] + + RetN + + M12Mix16FSurround 0 + M12Mix16FSurround 1 + M12Mix16FSurround 2 + M12Mix16FSurround 3 + M12Mix16FSurround 4 + M12Mix16FSurround 5 + M12Mix16FSurround 6 + M12Mix16FSurround 7 + M12Mix16FSurround 8 + M12Mix16FSurround 9 + M12Mix16FSurround 10 + M12Mix16FSurround 11 + M12Mix16FSurround 12 + M12Mix16FSurround 13 + M12Mix16FSurround 14 + M12Mix16FSurround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16FSurround0 + + Ret + +EndP Mix12Surround16BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Surround16BitF + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:Mix12Surround16BitFVolume], AL + + Ret + +EndP PreMix12Surround16BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Panned16BitFOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16FPannedOffset Macro Index + DW Offset M12Mix16FPanned&Index& + EndM + + REPT 16 + M12Mix16FPannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Panned16BitF + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Panned16BitFOffsetTable+BX] + +Mix12Panned16BitFVolume EQU $+3 + Mov EBX, 0 + + Mov BL, [ES:EDI+EDI+1] + + RetN + +Pan12BitF16Loop: + M12Mix16FPanned 0 + M12Mix16FPanned 1 + M12Mix16FPanned 2 + M12Mix16FPanned 3 + M12Mix16FPanned 4 + M12Mix16FPanned 5 + M12Mix16FPanned 6 + M12Mix16FPanned 7 + M12Mix16FPanned 8 + M12Mix16FPanned 9 + M12Mix16FPanned 10 + M12Mix16FPanned 11 + M12Mix16FPanned 12 + M12Mix16FPanned 13 + M12Mix16FPanned 14 + M12Mix16FPanned 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ Pan12BitF16Loop + + Ret + +EndP Mix12Panned16BitF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Panned16BitF + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:Mix12Panned16BitFVolume], AL + + Xor AL, AL + Mov AH, [SI+0Ch] + Sub AH, [SI+0Eh] + Add AH, AH + MovSX EAX, AX + + IndexCounter = 0 + + PreMix12PannedMacro2 Macro Index + Mov DWord Ptr [CS:M12Mix16FPannedRightVolumeOffset&Index&], EAX + EndM + + REPT 16 + PreMix12PannedMacro2 %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Panned16BitF + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M12BITI.INC b/SoundDrivers/M12BITI.INC index b9cd987..046daf8 100755 --- a/SoundDrivers/M12BITI.INC +++ b/SoundDrivers/M12BITI.INC @@ -1,49 +1,49 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix12Left8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI - DW Offset MixForwardsLoop, PreMix12Left8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI - DW Offset MixPingPongLoop, PreMix12Left8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI - ; Right only - DW Offset MixNoLoop, PreMix12Right8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI - DW Offset MixForwardsLoop, PreMix12Right8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI - DW Offset MixPingPongLoop, PreMix12Right8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI - ; Central - DW Offset MixNoLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI - DW Offset MixForwardsLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI - DW Offset MixPingPongLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI - ; Stereo - DW Offset MixNoLoop, PreMix12Panned8BitI, MFS8Bit, MBS8Bit, Mix12Panned8BitI - DW Offset MixForwardsLoop, PreMix12Panned8BitI, MFS8Bit, MBS8Bit, Mix12Panned8BitI - DW Offset MixPingPongLoop, PreMix12Panned8BitI, MFS8Bit, MBS8Bit, Mix12Panned8BitI - ; Surround - DW Offset MixNoLoop, PreMix12Surround8BitI, MFS8Bit, MBS8Bit, Mix12Surround8BitI - DW Offset MixForwardsLoop, PreMix12Surround8BitI, MFS8Bit, MBS8Bit, Mix12Surround8BitI - DW Offset MixPingPongLoop, PreMix12Surround8BitI, MFS8Bit, MBS8Bit, Mix12Surround8BitI - - ; 16 bit tables - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix12Left16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI - DW Offset MixForwardsLoop, PreMix12Left16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI - DW Offset MixPingPongLoop, PreMix12Left16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI - ; Right only - DW Offset MixNoLoop, PreMix12Right16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI - DW Offset MixForwardsLoop, PreMix12Right16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI - DW Offset MixPingPongLoop, PreMix12Right16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI - ; Central - DW Offset MixNoLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI - DW Offset MixForwardsLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI - DW Offset MixPingPongLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI - ; Stereo - DW Offset MixNoLoop, PreMix12Panned16BitI, MFS16Bit, MBS16Bit, Mix12Panned16BitI - DW Offset MixForwardsLoop, PreMix12Panned16BitI, MFS16Bit, MBS16Bit, Mix12Panned16BitI - DW Offset MixPingPongLoop, PreMix12Panned16BitI, MFS16Bit, MBS16Bit, Mix12Panned16BitI - ; Surround - DW Offset MixNoLoop, PreMix12Surround16BitI, MFS16Bit, MBS16Bit, Mix12Surround16BitI - DW Offset MixForwardsLoop, PreMix12Surround16BitI, MFS16Bit, MBS16Bit, Mix12Surround16BitI - DW Offset MixPingPongLoop, PreMix12Surround16BitI, MFS16Bit, MBS16Bit, Mix12Surround16BitI + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix12Left8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI + DW Offset MixForwardsLoop, PreMix12Left8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI + DW Offset MixPingPongLoop, PreMix12Left8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI + ; Right only + DW Offset MixNoLoop, PreMix12Right8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI + DW Offset MixForwardsLoop, PreMix12Right8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI + DW Offset MixPingPongLoop, PreMix12Right8BitI, MFS8Bit, MBS8Bit, Mix12Single8BitI + ; Central + DW Offset MixNoLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI + DW Offset MixForwardsLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI + DW Offset MixPingPongLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI + ; Stereo + DW Offset MixNoLoop, PreMix12Panned8BitI, MFS8Bit, MBS8Bit, Mix12Panned8BitI + DW Offset MixForwardsLoop, PreMix12Panned8BitI, MFS8Bit, MBS8Bit, Mix12Panned8BitI + DW Offset MixPingPongLoop, PreMix12Panned8BitI, MFS8Bit, MBS8Bit, Mix12Panned8BitI + ; Surround + DW Offset MixNoLoop, PreMix12Surround8BitI, MFS8Bit, MBS8Bit, Mix12Surround8BitI + DW Offset MixForwardsLoop, PreMix12Surround8BitI, MFS8Bit, MBS8Bit, Mix12Surround8BitI + DW Offset MixPingPongLoop, PreMix12Surround8BitI, MFS8Bit, MBS8Bit, Mix12Surround8BitI + + ; 16 bit tables + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix12Left16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI + DW Offset MixForwardsLoop, PreMix12Left16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI + DW Offset MixPingPongLoop, PreMix12Left16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI + ; Right only + DW Offset MixNoLoop, PreMix12Right16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI + DW Offset MixForwardsLoop, PreMix12Right16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI + DW Offset MixPingPongLoop, PreMix12Right16BitI, MFS16Bit, MBS16Bit, Mix12Single16BitI + ; Central + DW Offset MixNoLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI + DW Offset MixForwardsLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI + DW Offset MixPingPongLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI + ; Stereo + DW Offset MixNoLoop, PreMix12Panned16BitI, MFS16Bit, MBS16Bit, Mix12Panned16BitI + DW Offset MixForwardsLoop, PreMix12Panned16BitI, MFS16Bit, MBS16Bit, Mix12Panned16BitI + DW Offset MixPingPongLoop, PreMix12Panned16BitI, MFS16Bit, MBS16Bit, Mix12Panned16BitI + ; Surround + DW Offset MixNoLoop, PreMix12Surround16BitI, MFS16Bit, MBS16Bit, Mix12Surround16BitI + DW Offset MixForwardsLoop, PreMix12Surround16BitI, MFS16Bit, MBS16Bit, Mix12Surround16BitI + DW Offset MixPingPongLoop, PreMix12Surround16BitI, MFS16Bit, MBS16Bit, Mix12Surround16BitI diff --git a/SoundDrivers/M12BITI.MIX b/SoundDrivers/M12BITI.MIX index 5bc839b..e951e33 100755 --- a/SoundDrivers/M12BITI.MIX +++ b/SoundDrivers/M12BITI.MIX @@ -1,866 +1,866 @@ - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - - ; Interpolation = [DI+1]*Error + [DI]*(1-Error) - ; = [DI+1]*Error + [DI] - [DI]*Error - ; = Error*([DI+1]-[DI]) + [DI] - - -Get8BitIWaveform Macro - MovSX EBX, Byte Ptr [ES:DI] ; 5 - MovSX EAX, Byte Ptr [ES:DI+1] ; 5 - Sub EAX, EBX ; 2 - IMul EAX, ECX - SAR EAX, 16 ; 3 - Add BL, AL ; 1 - -EndM - -Get16BitIWaveform Macro - MovSX EBX, Byte Ptr [ES:EDI+EDI+1] ; 5 - MovSX EAX, Byte Ptr [ES:EDI+EDI+3] ; 5 - Sub EAX, EBX ; 2 - IMul EAX, ECX - SAR EAX, 16 ; 3 - Add BL, AL ; 1 - -EndM - -M12Mix8ISingle Macro Index - -M12Mix8ISingle&Index&: - Get8BitIWaveform - -M12Mix8ISingleVolume&Index& EQU $+1 - Mov BH, 12h - Add BX, BX - - Add ERROR, DELTAERROR - Mov AX, [BX] - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8ICentral Macro Index - -M12Mix8ICentral&Index&: - Get8BitIWaveform - -M12Mix8ICentralVolume&Index& EQU $+1 - Mov BH, 12h - Add BX, BX - - Add ERROR, DELTAERROR ;; 1 - Mov AX, [BX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8ISurround Macro Index - -M12Mix8ISurround&Index&: - Get8BitIWaveform - -M12Mix8ISurroundVolume&Index& EQU $+1 - Mov BH, 12h - Add BX, BX - - Add ERROR, DELTAERROR ;; 1 - Mov AX, [BX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8IPanned Macro Index - -M12Mix8IPanned&Index&: - Get8BitIWaveform - -M12Mix8IPannedVolume&Index& EQU $+1 - Mov BH, 12h - Add BX, BX - - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [BX] - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -M12Mix8IPannedRightVolumeOffset&Index& EQU $+3 - Mov AX, [BX+1200h] - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -M12Mix16ISingle Macro Index - -M12Mix16ISingle&Index&: - Get16BitIWaveForm - -M12Mix16ISingleVolume&Index& EQU $+1 - Mov BH, 12h - Add BX, BX - - Add ERROR, DELTAERROR - Mov AX, [BX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -EndM - -M12Mix16ICentral Macro Index - -M12Mix16ICentral&Index&: - Get16BitIWaveform - -M12Mix16ICentralVolume&Index& EQU $+1 - Mov BH, 12h - Add BX, BX - - Add ERROR, DELTAERROR - Mov AX, [BX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -M12Mix16ISurround Macro Index - -M12Mix16ISurround&Index&: - Get16BitIWaveform - -M12Mix16ISurroundVolume&Index& EQU $+1 - Mov BH, 12h - Add BX, BX - - Add ERROR, DELTAERROR - Mov AX, [BX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - - ; Panned output -M12Mix16IPanned Macro Index - -M12Mix16IPanned&Index&: - Get16BitIWaveform - -M12Mix16IPannedVolume&Index& EQU $+1 - Mov BH, 12h - Add BX, BX - - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [BX] - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -M12Mix16IPannedRightVolumeOffset&Index& EQU $+3 - Mov AX, [BX+1200h] - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix12Single8BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8ISingleOffset Macro Index - DW Offset M12Mix8ISingle&Index& - EndM - - REPT 16 - M12Mix8ISingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Single8BitI - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix12Single8BitIOffsetTable+BX] - - M12Mix8ISingle 0 - M12Mix8ISingle 1 - M12Mix8ISingle 2 - M12Mix8ISingle 3 - M12Mix8ISingle 4 - M12Mix8ISingle 5 - M12Mix8ISingle 6 - M12Mix8ISingle 7 - M12Mix8ISingle 8 - M12Mix8ISingle 9 - M12Mix8ISingle 10 - M12Mix8ISingle 11 - M12Mix8ISingle 12 - M12Mix8ISingle 13 - M12Mix8ISingle 14 - M12Mix8ISingle 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8ISingle0 - - Ret - -EndP Mix12Single8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Left8BitI - - Mov AL, [SI+0Eh] - -PreMix12Left8BitI1: - - IndexCounter = 0 - - PreMix12Single8BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix8ISingleVolume&Index&], AL - EndM - - REPT 16 - PreMix12Single8BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Left8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Right8BitI - - Add MixBufferOffset, MixResolution/8 - Mov AL, [SI+0Ch] - Jmp PreMix12Left8BitI1 - - Ret - -EndP PreMix12Right8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central8BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8ICentralOffset Macro Index - DW Offset M12Mix8ICentral&Index& - EndM - - REPT 16 - M12Mix8ICentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central8BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix12Central8BitIOffsetTable+BX] - - M12Mix8ICentral 0 - M12Mix8ICentral 1 - M12Mix8ICentral 2 - M12Mix8ICentral 3 - M12Mix8ICentral 4 - M12Mix8ICentral 5 - M12Mix8ICentral 6 - M12Mix8ICentral 7 - M12Mix8ICentral 8 - M12Mix8ICentral 9 - M12Mix8ICentral 10 - M12Mix8ICentral 11 - M12Mix8ICentral 12 - M12Mix8ICentral 13 - M12Mix8ICentral 14 - M12Mix8ICentral 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8ICentral0 - - Ret - -EndP Mix12Central8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central8BitI - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12Central8BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix8ICentralVolume&Index&], AL - EndM - - REPT 16 - PreMix12Central8BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Central8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Surround8BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8ISurroundOffset Macro Index - DW Offset M12Mix8ISurround&Index& - EndM - - REPT 16 - M12Mix8ISurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Surround8BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix12Surround8BitIOffsetTable+BX] - - M12Mix8ISurround 0 - M12Mix8ISurround 1 - M12Mix8ISurround 2 - M12Mix8ISurround 3 - M12Mix8ISurround 4 - M12Mix8ISurround 5 - M12Mix8ISurround 6 - M12Mix8ISurround 7 - M12Mix8ISurround 8 - M12Mix8ISurround 9 - M12Mix8ISurround 10 - M12Mix8ISurround 11 - M12Mix8ISurround 12 - M12Mix8ISurround 13 - M12Mix8ISurround 14 - M12Mix8ISurround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8ISurround0 - - Ret - -EndP Mix12Surround8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Surround8BitI - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12Surround8BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix8ISurroundVolume&Index&], AL - EndM - - REPT 16 - PreMix12Surround8BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Surround8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Panned8BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8IPannedOffset Macro Index - DW Offset M12Mix8IPanned&Index& - EndM - - REPT 16 - M12Mix8IPannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Panned8BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix12Panned8BitIOffsetTable+BX] - - M12Mix8IPanned 0 - M12Mix8IPanned 1 - M12Mix8IPanned 2 - M12Mix8IPanned 3 - M12Mix8IPanned 4 - M12Mix8IPanned 5 - M12Mix8IPanned 6 - M12Mix8IPanned 7 - M12Mix8IPanned 8 - M12Mix8IPanned 9 - M12Mix8IPanned 10 - M12Mix8IPanned 11 - M12Mix8IPanned 12 - M12Mix8IPanned 13 - M12Mix8IPanned 14 - M12Mix8IPanned 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8IPanned0 - - Ret - -EndP Mix12Panned8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Panned8BitI - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12Panned8BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix8IPannedVolume&Index&], AL - EndM - - REPT 16 - PreMix12Panned8BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Mov AL, [SI+0Ch] - Sub AL, [SI+0Eh] - Add AL, AL - - IndexCounter = 0 - - PreMix12Panned8BitIMacro2 Macro Index - Mov Byte Ptr [CS:M12Mix8IPannedRightVolumeOffset&Index&], AL - EndM - - REPT 16 - PreMix12Panned8BitIMacro2 %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Panned8BitI - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix12Single16BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16ISingleOffset Macro Index - DW Offset M12Mix16ISingle&Index& - EndM - - REPT 16 - M12Mix16ISingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Single16BitI - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix12Single16BitIOffsetTable+BX] - - M12Mix16ISingle 0 - M12Mix16ISingle 1 - M12Mix16ISingle 2 - M12Mix16ISingle 3 - M12Mix16ISingle 4 - M12Mix16ISingle 5 - M12Mix16ISingle 6 - M12Mix16ISingle 7 - M12Mix16ISingle 8 - M12Mix16ISingle 9 - M12Mix16ISingle 10 - M12Mix16ISingle 11 - M12Mix16ISingle 12 - M12Mix16ISingle 13 - M12Mix16ISingle 14 - M12Mix16ISingle 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16ISingle0 - - Ret - -EndP Mix12Single16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Left16BitI - - Mov AL, [SI+0Eh] - -PreMix12Left16BitI1: - - IndexCounter = 0 - - PreMix12Single16BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix16ISingleVolume&Index&], AL - EndM - - REPT 16 - PreMix12Single16BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Left16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Right16BitI - - Add MixBufferOffset, MixResolution/8 - Mov AL, [SI+0Ch] - - Jmp PreMix12Left16BitI1 - -EndP PreMix12Right16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central16BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16ICentralOffset Macro Index - DW Offset M12Mix16ICentral&Index& - EndM - - REPT 16 - M12Mix16ICentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central16BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix12Central16BitIOffsetTable+BX] - - M12Mix16ICentral 0 - M12Mix16ICentral 1 - M12Mix16ICentral 2 - M12Mix16ICentral 3 - M12Mix16ICentral 4 - M12Mix16ICentral 5 - M12Mix16ICentral 6 - M12Mix16ICentral 7 - M12Mix16ICentral 8 - M12Mix16ICentral 9 - M12Mix16ICentral 10 - M12Mix16ICentral 11 - M12Mix16ICentral 12 - M12Mix16ICentral 13 - M12Mix16ICentral 14 - M12Mix16ICentral 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16ICentral0 - - Ret - -EndP Mix12Central16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central16BitI - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12Central16BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix16ICentralVolume&Index&], AL - EndM - - REPT 16 - PreMix12Central16BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - Ret - -EndP PreMix12Central16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Surround16BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16ISurroundOffset Macro Index - DW Offset M12Mix16ISurround&Index& - EndM - - REPT 16 - M12Mix16ISurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Surround16BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix12Surround16BitIOffsetTable+BX] - - M12Mix16ISurround 0 - M12Mix16ISurround 1 - M12Mix16ISurround 2 - M12Mix16ISurround 3 - M12Mix16ISurround 4 - M12Mix16ISurround 5 - M12Mix16ISurround 6 - M12Mix16ISurround 7 - M12Mix16ISurround 8 - M12Mix16ISurround 9 - M12Mix16ISurround 10 - M12Mix16ISurround 11 - M12Mix16ISurround 12 - M12Mix16ISurround 13 - M12Mix16ISurround 14 - M12Mix16ISurround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16ISurround0 - - Ret - -EndP Mix12Surround16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Surround16BitI - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12Surround16BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix16ISurroundVolume&Index&], AL - EndM - - REPT 16 - PreMix12Surround16BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Surround16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Panned16BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16IPannedOffset Macro Index - DW Offset M12Mix16IPanned&Index& - EndM - - REPT 16 - M12Mix16IPannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Panned16BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix12Panned16BitIOffsetTable+BX] - -Pan12BitI16Loop: - M12Mix16IPanned 0 - M12Mix16IPanned 1 - M12Mix16IPanned 2 - M12Mix16IPanned 3 - M12Mix16IPanned 4 - M12Mix16IPanned 5 - M12Mix16IPanned 6 - M12Mix16IPanned 7 - M12Mix16IPanned 8 - M12Mix16IPanned 9 - M12Mix16IPanned 10 - M12Mix16IPanned 11 - M12Mix16IPanned 12 - M12Mix16IPanned 13 - M12Mix16IPanned 14 - M12Mix16IPanned 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ Pan12BitI16Loop - - Ret - -EndP Mix12Panned16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Panned16BitI - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12PannedMacro Macro Index - Mov Byte Ptr [CS:M12Mix16IPannedVolume&Index&], AL - EndM - - REPT 16 - PreMix12PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Mov AL, [SI+0Ch] - Sub AL, [SI+0Eh] - Add AL, AL - - IndexCounter = 0 - - PreMix12PannedMacro2 Macro Index - Mov Byte Ptr [CS:M12Mix16IPannedRightVolumeOffset&Index&], AL - EndM - - REPT 16 - PreMix12PannedMacro2 %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Panned16BitI - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + + ; Interpolation = [DI+1]*Error + [DI]*(1-Error) + ; = [DI+1]*Error + [DI] - [DI]*Error + ; = Error*([DI+1]-[DI]) + [DI] + + +Get8BitIWaveform Macro + MovSX EBX, Byte Ptr [ES:DI] ; 5 + MovSX EAX, Byte Ptr [ES:DI+1] ; 5 + Sub EAX, EBX ; 2 + IMul EAX, ECX + SAR EAX, 16 ; 3 + Add BL, AL ; 1 + +EndM + +Get16BitIWaveform Macro + MovSX EBX, Byte Ptr [ES:EDI+EDI+1] ; 5 + MovSX EAX, Byte Ptr [ES:EDI+EDI+3] ; 5 + Sub EAX, EBX ; 2 + IMul EAX, ECX + SAR EAX, 16 ; 3 + Add BL, AL ; 1 + +EndM + +M12Mix8ISingle Macro Index + +M12Mix8ISingle&Index&: + Get8BitIWaveform + +M12Mix8ISingleVolume&Index& EQU $+1 + Mov BH, 12h + Add BX, BX + + Add ERROR, DELTAERROR + Mov AX, [BX] + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8ICentral Macro Index + +M12Mix8ICentral&Index&: + Get8BitIWaveform + +M12Mix8ICentralVolume&Index& EQU $+1 + Mov BH, 12h + Add BX, BX + + Add ERROR, DELTAERROR ;; 1 + Mov AX, [BX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8ISurround Macro Index + +M12Mix8ISurround&Index&: + Get8BitIWaveform + +M12Mix8ISurroundVolume&Index& EQU $+1 + Mov BH, 12h + Add BX, BX + + Add ERROR, DELTAERROR ;; 1 + Mov AX, [BX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8IPanned Macro Index + +M12Mix8IPanned&Index&: + Get8BitIWaveform + +M12Mix8IPannedVolume&Index& EQU $+1 + Mov BH, 12h + Add BX, BX + + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [BX] + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +M12Mix8IPannedRightVolumeOffset&Index& EQU $+3 + Mov AX, [BX+1200h] + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +M12Mix16ISingle Macro Index + +M12Mix16ISingle&Index&: + Get16BitIWaveForm + +M12Mix16ISingleVolume&Index& EQU $+1 + Mov BH, 12h + Add BX, BX + + Add ERROR, DELTAERROR + Mov AX, [BX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +EndM + +M12Mix16ICentral Macro Index + +M12Mix16ICentral&Index&: + Get16BitIWaveform + +M12Mix16ICentralVolume&Index& EQU $+1 + Mov BH, 12h + Add BX, BX + + Add ERROR, DELTAERROR + Mov AX, [BX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +M12Mix16ISurround Macro Index + +M12Mix16ISurround&Index&: + Get16BitIWaveform + +M12Mix16ISurroundVolume&Index& EQU $+1 + Mov BH, 12h + Add BX, BX + + Add ERROR, DELTAERROR + Mov AX, [BX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + + ; Panned output +M12Mix16IPanned Macro Index + +M12Mix16IPanned&Index&: + Get16BitIWaveform + +M12Mix16IPannedVolume&Index& EQU $+1 + Mov BH, 12h + Add BX, BX + + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [BX] + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +M12Mix16IPannedRightVolumeOffset&Index& EQU $+3 + Mov AX, [BX+1200h] + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix12Single8BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8ISingleOffset Macro Index + DW Offset M12Mix8ISingle&Index& + EndM + + REPT 16 + M12Mix8ISingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Single8BitI + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix12Single8BitIOffsetTable+BX] + + M12Mix8ISingle 0 + M12Mix8ISingle 1 + M12Mix8ISingle 2 + M12Mix8ISingle 3 + M12Mix8ISingle 4 + M12Mix8ISingle 5 + M12Mix8ISingle 6 + M12Mix8ISingle 7 + M12Mix8ISingle 8 + M12Mix8ISingle 9 + M12Mix8ISingle 10 + M12Mix8ISingle 11 + M12Mix8ISingle 12 + M12Mix8ISingle 13 + M12Mix8ISingle 14 + M12Mix8ISingle 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8ISingle0 + + Ret + +EndP Mix12Single8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Left8BitI + + Mov AL, [SI+0Eh] + +PreMix12Left8BitI1: + + IndexCounter = 0 + + PreMix12Single8BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix8ISingleVolume&Index&], AL + EndM + + REPT 16 + PreMix12Single8BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Left8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Right8BitI + + Add MixBufferOffset, MixResolution/8 + Mov AL, [SI+0Ch] + Jmp PreMix12Left8BitI1 + + Ret + +EndP PreMix12Right8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central8BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8ICentralOffset Macro Index + DW Offset M12Mix8ICentral&Index& + EndM + + REPT 16 + M12Mix8ICentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central8BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix12Central8BitIOffsetTable+BX] + + M12Mix8ICentral 0 + M12Mix8ICentral 1 + M12Mix8ICentral 2 + M12Mix8ICentral 3 + M12Mix8ICentral 4 + M12Mix8ICentral 5 + M12Mix8ICentral 6 + M12Mix8ICentral 7 + M12Mix8ICentral 8 + M12Mix8ICentral 9 + M12Mix8ICentral 10 + M12Mix8ICentral 11 + M12Mix8ICentral 12 + M12Mix8ICentral 13 + M12Mix8ICentral 14 + M12Mix8ICentral 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8ICentral0 + + Ret + +EndP Mix12Central8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central8BitI + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12Central8BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix8ICentralVolume&Index&], AL + EndM + + REPT 16 + PreMix12Central8BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Central8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Surround8BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8ISurroundOffset Macro Index + DW Offset M12Mix8ISurround&Index& + EndM + + REPT 16 + M12Mix8ISurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Surround8BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix12Surround8BitIOffsetTable+BX] + + M12Mix8ISurround 0 + M12Mix8ISurround 1 + M12Mix8ISurround 2 + M12Mix8ISurround 3 + M12Mix8ISurround 4 + M12Mix8ISurround 5 + M12Mix8ISurround 6 + M12Mix8ISurround 7 + M12Mix8ISurround 8 + M12Mix8ISurround 9 + M12Mix8ISurround 10 + M12Mix8ISurround 11 + M12Mix8ISurround 12 + M12Mix8ISurround 13 + M12Mix8ISurround 14 + M12Mix8ISurround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8ISurround0 + + Ret + +EndP Mix12Surround8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Surround8BitI + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12Surround8BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix8ISurroundVolume&Index&], AL + EndM + + REPT 16 + PreMix12Surround8BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Surround8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Panned8BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8IPannedOffset Macro Index + DW Offset M12Mix8IPanned&Index& + EndM + + REPT 16 + M12Mix8IPannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Panned8BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix12Panned8BitIOffsetTable+BX] + + M12Mix8IPanned 0 + M12Mix8IPanned 1 + M12Mix8IPanned 2 + M12Mix8IPanned 3 + M12Mix8IPanned 4 + M12Mix8IPanned 5 + M12Mix8IPanned 6 + M12Mix8IPanned 7 + M12Mix8IPanned 8 + M12Mix8IPanned 9 + M12Mix8IPanned 10 + M12Mix8IPanned 11 + M12Mix8IPanned 12 + M12Mix8IPanned 13 + M12Mix8IPanned 14 + M12Mix8IPanned 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8IPanned0 + + Ret + +EndP Mix12Panned8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Panned8BitI + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12Panned8BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix8IPannedVolume&Index&], AL + EndM + + REPT 16 + PreMix12Panned8BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Mov AL, [SI+0Ch] + Sub AL, [SI+0Eh] + Add AL, AL + + IndexCounter = 0 + + PreMix12Panned8BitIMacro2 Macro Index + Mov Byte Ptr [CS:M12Mix8IPannedRightVolumeOffset&Index&], AL + EndM + + REPT 16 + PreMix12Panned8BitIMacro2 %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Panned8BitI + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix12Single16BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16ISingleOffset Macro Index + DW Offset M12Mix16ISingle&Index& + EndM + + REPT 16 + M12Mix16ISingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Single16BitI + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix12Single16BitIOffsetTable+BX] + + M12Mix16ISingle 0 + M12Mix16ISingle 1 + M12Mix16ISingle 2 + M12Mix16ISingle 3 + M12Mix16ISingle 4 + M12Mix16ISingle 5 + M12Mix16ISingle 6 + M12Mix16ISingle 7 + M12Mix16ISingle 8 + M12Mix16ISingle 9 + M12Mix16ISingle 10 + M12Mix16ISingle 11 + M12Mix16ISingle 12 + M12Mix16ISingle 13 + M12Mix16ISingle 14 + M12Mix16ISingle 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16ISingle0 + + Ret + +EndP Mix12Single16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Left16BitI + + Mov AL, [SI+0Eh] + +PreMix12Left16BitI1: + + IndexCounter = 0 + + PreMix12Single16BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix16ISingleVolume&Index&], AL + EndM + + REPT 16 + PreMix12Single16BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Left16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Right16BitI + + Add MixBufferOffset, MixResolution/8 + Mov AL, [SI+0Ch] + + Jmp PreMix12Left16BitI1 + +EndP PreMix12Right16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central16BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16ICentralOffset Macro Index + DW Offset M12Mix16ICentral&Index& + EndM + + REPT 16 + M12Mix16ICentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central16BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix12Central16BitIOffsetTable+BX] + + M12Mix16ICentral 0 + M12Mix16ICentral 1 + M12Mix16ICentral 2 + M12Mix16ICentral 3 + M12Mix16ICentral 4 + M12Mix16ICentral 5 + M12Mix16ICentral 6 + M12Mix16ICentral 7 + M12Mix16ICentral 8 + M12Mix16ICentral 9 + M12Mix16ICentral 10 + M12Mix16ICentral 11 + M12Mix16ICentral 12 + M12Mix16ICentral 13 + M12Mix16ICentral 14 + M12Mix16ICentral 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16ICentral0 + + Ret + +EndP Mix12Central16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central16BitI + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12Central16BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix16ICentralVolume&Index&], AL + EndM + + REPT 16 + PreMix12Central16BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + Ret + +EndP PreMix12Central16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Surround16BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16ISurroundOffset Macro Index + DW Offset M12Mix16ISurround&Index& + EndM + + REPT 16 + M12Mix16ISurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Surround16BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix12Surround16BitIOffsetTable+BX] + + M12Mix16ISurround 0 + M12Mix16ISurround 1 + M12Mix16ISurround 2 + M12Mix16ISurround 3 + M12Mix16ISurround 4 + M12Mix16ISurround 5 + M12Mix16ISurround 6 + M12Mix16ISurround 7 + M12Mix16ISurround 8 + M12Mix16ISurround 9 + M12Mix16ISurround 10 + M12Mix16ISurround 11 + M12Mix16ISurround 12 + M12Mix16ISurround 13 + M12Mix16ISurround 14 + M12Mix16ISurround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16ISurround0 + + Ret + +EndP Mix12Surround16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Surround16BitI + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12Surround16BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix16ISurroundVolume&Index&], AL + EndM + + REPT 16 + PreMix12Surround16BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Surround16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Panned16BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16IPannedOffset Macro Index + DW Offset M12Mix16IPanned&Index& + EndM + + REPT 16 + M12Mix16IPannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Panned16BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix12Panned16BitIOffsetTable+BX] + +Pan12BitI16Loop: + M12Mix16IPanned 0 + M12Mix16IPanned 1 + M12Mix16IPanned 2 + M12Mix16IPanned 3 + M12Mix16IPanned 4 + M12Mix16IPanned 5 + M12Mix16IPanned 6 + M12Mix16IPanned 7 + M12Mix16IPanned 8 + M12Mix16IPanned 9 + M12Mix16IPanned 10 + M12Mix16IPanned 11 + M12Mix16IPanned 12 + M12Mix16IPanned 13 + M12Mix16IPanned 14 + M12Mix16IPanned 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ Pan12BitI16Loop + + Ret + +EndP Mix12Panned16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Panned16BitI + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12PannedMacro Macro Index + Mov Byte Ptr [CS:M12Mix16IPannedVolume&Index&], AL + EndM + + REPT 16 + PreMix12PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Mov AL, [SI+0Ch] + Sub AL, [SI+0Eh] + Add AL, AL + + IndexCounter = 0 + + PreMix12PannedMacro2 Macro Index + Mov Byte Ptr [CS:M12Mix16IPannedRightVolumeOffset&Index&], AL + EndM + + REPT 16 + PreMix12PannedMacro2 %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Panned16BitI + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M12BITST.MIX b/SoundDrivers/M12BITST.MIX index 6d87910..195ba12 100755 --- a/SoundDrivers/M12BITST.MIX +++ b/SoundDrivers/M12BITST.MIX @@ -1,832 +1,832 @@ - -; 12 bit mixing routines, using Stack Segment. - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - -M12Mix8Single Macro Index - -M12Mix8Single&Index&: - Add ERROR, DELTAERROR ;; 1 - Mov BL, [SP] ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Mov AX, [EBX+EBX] ;; 2 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8Central Macro Index - -M12Mix8Central&Index&: - Mov BL, [SP] ;; 2 - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 - -EndM - -M12Mix8Surround Macro Index - -M12Mix8Surround&Index&: - Mov BL, [SP] ;; 2 - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 - Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 - -EndM - - ; Panned output -M12Mix8PannedNext Macro Index - -M12Mix8PannedVolume&Index& EQU $+1 - Mov BH, 12h - Mov BL, [SP] - -EndM - -M12Mix8Panned Macro Index - -M12Mix8Panned&Index&: - Add BX, BX - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [BX] - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -M12Mix8PannedRightVolumeOffset&Index& EQU $+3 - Mov AX, [BX+1200h] - - M12Mix8PannedNext %(Index+1) - - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -M12Mix16Single Macro Index - -M12Mix16Single&Index&: - Mov BL, [ES:EDI+EDI+1] - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -EndM - -M12Mix16Central Macro Index - -M12Mix16Central&Index&: - Mov BL, [ES:EDI+EDI+1] - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -M12Mix16Surround Macro Index - -M12Mix16Surround&Index&: - Mov BL, [ES:EDI+EDI+1] - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - - ; Panned output -M12Mix16PannedNext Macro Index - -M12Mix16PannedVolume&Index& EQU $+1 - Mov BH, 12h - Mov BL, [ES:EDI+EDI+1] - -EndM - -M12Mix16Panned Macro Index - -M12Mix16Panned&Index&: - Add BX, BX - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [BX] - Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX - -M12Mix16PannedRightVolumeOffset&Index& EQU $+3 - Mov AX, [BX+1200h] - - M12Mix16PannedNext %(Index+1) - - Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix12Single8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8SingleOffset Macro Index - DW Offset M12Mix8Single&Index& - EndM - - REPT 16 - M12Mix8SingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -ALIGN 2 -OldStackSegment DW 0 -OldStackPointer DW 0 -MixingOffset DW 0 - -Proc Mix12Single8Bit - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Mov AX, [CS:Mix12BitSingle8BitOffsetTable+BX] - Mov [CS:OldStackSegment], SS - Mov [CS:OldStackPointer], SP - Mov [CS:MixingOffset], AX - -M12Single8BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - Mov ESP, EDI - Jmp [CS:MixingOffset] - - M12Mix8Single 0 - M12Mix8Single 1 - M12Mix8Single 2 - M12Mix8Single 3 - M12Mix8Single 4 - M12Mix8Single 5 - M12Mix8Single 6 - M12Mix8Single 7 - M12Mix8Single 8 - M12Mix8Single 9 - M12Mix8Single 10 - M12Mix8Single 11 - M12Mix8Single 12 - M12Mix8Single 13 - M12Mix8Single 14 - M12Mix8Single 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8Single0 - - Mov SS, [CS:StackSegment] - Mov SP, [CS:StackPointer] - - Ret - -EndP Mix12Single8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Left8Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Single8BitVolume], AL - Ret - -EndP PreMix12Left8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Right8Bit - - Add MixBufferOffset, MixResolution/8 - Mov AL, [SI+0Ch] - Mov Byte Ptr [CS:M12Single8BitVolume], AL - - Ret - -EndP PreMix12Right8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8CentralOffset Macro Index - DW Offset M12Mix8Central&Index& - EndM - - REPT 16 - M12Mix8CentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Mov AX, [CS:Mix12BitSingle8BitOffsetTable+BX] - Mov [CS:OldStackSegment], SS - Mov [CS:OldStackPointer], SP - Mov [CS:MixingOffset], AX - -M12Central8BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - Mov ESP, EDI - Jmp [CS:MixingOffset] - - M12Mix8Central 0 - M12Mix8Central 1 - M12Mix8Central 2 - M12Mix8Central 3 - M12Mix8Central 4 - M12Mix8Central 5 - M12Mix8Central 6 - M12Mix8Central 7 - M12Mix8Central 8 - M12Mix8Central 9 - M12Mix8Central 10 - M12Mix8Central 11 - M12Mix8Central 12 - M12Mix8Central 13 - M12Mix8Central 14 - M12Mix8Central 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8Central0 - - Mov SS, [CS:StackSegment] - Mov SP, [CS:StackPointer] - - Ret - -EndP Mix12Central8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central8Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Central8BitVolume], AL - - Ret - -EndP PreMix12Central8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Surround8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8SurroundOffset Macro Index - DW Offset M12Mix8Surround&Index& - EndM - - REPT 16 - M12Mix8SurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Surround8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Surround8BitOffsetTable+BX] - -M12Surround8BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - - RetN - - M12Mix8Surround 0 - M12Mix8Surround 1 - M12Mix8Surround 2 - M12Mix8Surround 3 - M12Mix8Surround 4 - M12Mix8Surround 5 - M12Mix8Surround 6 - M12Mix8Surround 7 - M12Mix8Surround 8 - M12Mix8Surround 9 - M12Mix8Surround 10 - M12Mix8Surround 11 - M12Mix8Surround 12 - M12Mix8Surround 13 - M12Mix8Surround 14 - M12Mix8Surround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8Surround0 - - Ret - -EndP Mix12Surround8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Surround8Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Surround8BitVolume], AL - - Ret - -EndP PreMix12Surround8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Panned8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8PannedOffset Macro Index - DW Offset M12Mix8Panned&Index& - EndM - - REPT 16 - M12Mix8PannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Panned8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Panned8BitOffsetTable+BX] - - M12Mix8PannedNext 0 - - RetN - - M12Mix8Panned 0 - M12Mix8Panned 1 - M12Mix8Panned 2 - M12Mix8Panned 3 - M12Mix8Panned 4 - M12Mix8Panned 5 - M12Mix8Panned 6 - M12Mix8Panned 7 - M12Mix8Panned 8 - M12Mix8Panned 9 - M12Mix8Panned 10 - M12Mix8Panned 11 - M12Mix8Panned 12 - M12Mix8Panned 13 - M12Mix8Panned 14 - M12Mix8Panned 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix8Panned0 - - Ret - -EndP Mix12Panned8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Panned8Bit - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12PannedMacro Macro Index - Mov Byte Ptr [CS:M12Mix8PannedVolume&Index&], AL - EndM - - REPT 17 - PreMix12PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Mov AL, [SI+0Ch] - Sub AL, [SI+0Eh] - Add AL, AL - - IndexCounter = 0 - - PreMix12PannedMacro2 Macro Index - Mov Byte Ptr [CS:M12Mix8PannedRightVolumeOffset&Index&], AL - EndM - - REPT 16 - PreMix12PannedMacro2 %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Panned8Bit - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix12Single16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16SingleOffset Macro Index - DW Offset M12Mix16Single&Index& - EndM - - REPT 16 - M12Mix16SingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Single16Bit - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Single16BitOffsetTable+BX] - -M12Single16BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - RetN - - M12Mix16Single 0 - M12Mix16Single 1 - M12Mix16Single 2 - M12Mix16Single 3 - M12Mix16Single 4 - M12Mix16Single 5 - M12Mix16Single 6 - M12Mix16Single 7 - M12Mix16Single 8 - M12Mix16Single 9 - M12Mix16Single 10 - M12Mix16Single 11 - M12Mix16Single 12 - M12Mix16Single 13 - M12Mix16Single 14 - M12Mix16Single 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16Single0 - - Ret - -EndP Mix12Single16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Left16Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Single16BitVolume], AL - Ret - -EndP PreMix12Left16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Right16Bit - - Add MixBufferOffset, MixResolution/8 - Mov AL, [SI+0Ch] - Mov Byte Ptr [CS:M12Single16BitVolume], AL - - Ret - -EndP PreMix12Right16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16CentralOffset Macro Index - DW Offset M12Mix16Central&Index& - EndM - - REPT 16 - M12Mix16CentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central16BitOffsetTable+BX] - -M12Central16BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - - RetN - - M12Mix16Central 0 - M12Mix16Central 1 - M12Mix16Central 2 - M12Mix16Central 3 - M12Mix16Central 4 - M12Mix16Central 5 - M12Mix16Central 6 - M12Mix16Central 7 - M12Mix16Central 8 - M12Mix16Central 9 - M12Mix16Central 10 - M12Mix16Central 11 - M12Mix16Central 12 - M12Mix16Central 13 - M12Mix16Central 14 - M12Mix16Central 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16Central0 - - Ret - -EndP Mix12Central16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central16Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Central16BitVolume], AL - - Ret - -EndP PreMix12Central16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Surround16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16SurroundOffset Macro Index - DW Offset M12Mix16Surround&Index& - EndM - - REPT 16 - M12Mix16SurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Surround16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Surround16BitOffsetTable+BX] - -M12Surround16BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - - RetN - - M12Mix16Surround 0 - M12Mix16Surround 1 - M12Mix16Surround 2 - M12Mix16Surround 3 - M12Mix16Surround 4 - M12Mix16Surround 5 - M12Mix16Surround 6 - M12Mix16Surround 7 - M12Mix16Surround 8 - M12Mix16Surround 9 - M12Mix16Surround 10 - M12Mix16Surround 11 - M12Mix16Surround 12 - M12Mix16Surround 13 - M12Mix16Surround 14 - M12Mix16Surround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M12Mix16Surround0 - - Ret - -EndP Mix12Surround16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Surround16Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Surround16BitVolume], AL - - Ret - -EndP PreMix12Surround16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Panned16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16PannedOffset Macro Index - DW Offset M12Mix16Panned&Index& - EndM - - REPT 16 - M12Mix16PannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Panned16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Panned16BitOffsetTable+BX] - - M12Mix16PannedNext 0 - - RetN - -Pan12Bit16Loop: - M12Mix16PannedNext 16 - - M12Mix16Panned 0 - M12Mix16Panned 1 - M12Mix16Panned 2 - M12Mix16Panned 3 - M12Mix16Panned 4 - M12Mix16Panned 5 - M12Mix16Panned 6 - M12Mix16Panned 7 - M12Mix16Panned 8 - M12Mix16Panned 9 - M12Mix16Panned 10 - M12Mix16Panned 11 - M12Mix16Panned 12 - M12Mix16Panned 13 - M12Mix16Panned 14 - - M12Mix16Panned15: - Add BX, BX - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov AX, [BX] - Sub [SI+EXTRAOFFSET], AX - M12Mix16PannedRightVolumeOffset15 EQU $+3 - Mov AX, [BX+1200h] - Sub [SI+MixResolution/8+EXTRAOFFSET], AX - - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ Pan12Bit16Loop - - Ret - -EndP Mix12Panned16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Panned16Bit - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12PannedMacro Macro Index - Mov Byte Ptr [CS:M12Mix16PannedVolume&Index&], AL - EndM - - REPT 17 - PreMix12PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Mov AL, [SI+0Ch] - Sub AL, [SI+0Eh] - Add AL, AL - - IndexCounter = 0 - - PreMix12PannedMacro2 Macro Index - Mov Byte Ptr [CS:M12Mix16PannedRightVolumeOffset&Index&], AL - EndM - - REPT 16 - PreMix12PannedMacro2 %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Panned16Bit - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +; 12 bit mixing routines, using Stack Segment. + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + +M12Mix8Single Macro Index + +M12Mix8Single&Index&: + Add ERROR, DELTAERROR ;; 1 + Mov BL, [SP] ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Mov AX, [EBX+EBX] ;; 2 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8Central Macro Index + +M12Mix8Central&Index&: + Mov BL, [SP] ;; 2 + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 + +EndM + +M12Mix8Surround Macro Index + +M12Mix8Surround&Index&: + Mov BL, [SP] ;; 2 + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX ;; 3 + Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX ;; 3 + +EndM + + ; Panned output +M12Mix8PannedNext Macro Index + +M12Mix8PannedVolume&Index& EQU $+1 + Mov BH, 12h + Mov BL, [SP] + +EndM + +M12Mix8Panned Macro Index + +M12Mix8Panned&Index&: + Add BX, BX + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [BX] + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +M12Mix8PannedRightVolumeOffset&Index& EQU $+3 + Mov AX, [BX+1200h] + + M12Mix8PannedNext %(Index+1) + + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +M12Mix16Single Macro Index + +M12Mix16Single&Index&: + Mov BL, [ES:EDI+EDI+1] + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +EndM + +M12Mix16Central Macro Index + +M12Mix16Central&Index&: + Mov BL, [ES:EDI+EDI+1] + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +M12Mix16Surround Macro Index + +M12Mix16Surround&Index&: + Mov BL, [ES:EDI+EDI+1] + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + Add [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + + ; Panned output +M12Mix16PannedNext Macro Index + +M12Mix16PannedVolume&Index& EQU $+1 + Mov BH, 12h + Mov BL, [ES:EDI+EDI+1] + +EndM + +M12Mix16Panned Macro Index + +M12Mix16Panned&Index&: + Add BX, BX + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [BX] + Sub [SI+(Index-15)*MixResolution/4+EXTRAOFFSET], AX + +M12Mix16PannedRightVolumeOffset&Index& EQU $+3 + Mov AX, [BX+1200h] + + M12Mix16PannedNext %(Index+1) + + Sub [SI+(Index-15)*MixResolution/4+MixResolution/8+EXTRAOFFSET], AX + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix12Single8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8SingleOffset Macro Index + DW Offset M12Mix8Single&Index& + EndM + + REPT 16 + M12Mix8SingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +ALIGN 2 +OldStackSegment DW 0 +OldStackPointer DW 0 +MixingOffset DW 0 + +Proc Mix12Single8Bit + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Mov AX, [CS:Mix12BitSingle8BitOffsetTable+BX] + Mov [CS:OldStackSegment], SS + Mov [CS:OldStackPointer], SP + Mov [CS:MixingOffset], AX + +M12Single8BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + Mov ESP, EDI + Jmp [CS:MixingOffset] + + M12Mix8Single 0 + M12Mix8Single 1 + M12Mix8Single 2 + M12Mix8Single 3 + M12Mix8Single 4 + M12Mix8Single 5 + M12Mix8Single 6 + M12Mix8Single 7 + M12Mix8Single 8 + M12Mix8Single 9 + M12Mix8Single 10 + M12Mix8Single 11 + M12Mix8Single 12 + M12Mix8Single 13 + M12Mix8Single 14 + M12Mix8Single 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8Single0 + + Mov SS, [CS:StackSegment] + Mov SP, [CS:StackPointer] + + Ret + +EndP Mix12Single8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Left8Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Single8BitVolume], AL + Ret + +EndP PreMix12Left8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Right8Bit + + Add MixBufferOffset, MixResolution/8 + Mov AL, [SI+0Ch] + Mov Byte Ptr [CS:M12Single8BitVolume], AL + + Ret + +EndP PreMix12Right8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8CentralOffset Macro Index + DW Offset M12Mix8Central&Index& + EndM + + REPT 16 + M12Mix8CentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Mov AX, [CS:Mix12BitSingle8BitOffsetTable+BX] + Mov [CS:OldStackSegment], SS + Mov [CS:OldStackPointer], SP + Mov [CS:MixingOffset], AX + +M12Central8BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + Mov ESP, EDI + Jmp [CS:MixingOffset] + + M12Mix8Central 0 + M12Mix8Central 1 + M12Mix8Central 2 + M12Mix8Central 3 + M12Mix8Central 4 + M12Mix8Central 5 + M12Mix8Central 6 + M12Mix8Central 7 + M12Mix8Central 8 + M12Mix8Central 9 + M12Mix8Central 10 + M12Mix8Central 11 + M12Mix8Central 12 + M12Mix8Central 13 + M12Mix8Central 14 + M12Mix8Central 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8Central0 + + Mov SS, [CS:StackSegment] + Mov SP, [CS:StackPointer] + + Ret + +EndP Mix12Central8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central8Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Central8BitVolume], AL + + Ret + +EndP PreMix12Central8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Surround8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8SurroundOffset Macro Index + DW Offset M12Mix8Surround&Index& + EndM + + REPT 16 + M12Mix8SurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Surround8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Surround8BitOffsetTable+BX] + +M12Surround8BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + + RetN + + M12Mix8Surround 0 + M12Mix8Surround 1 + M12Mix8Surround 2 + M12Mix8Surround 3 + M12Mix8Surround 4 + M12Mix8Surround 5 + M12Mix8Surround 6 + M12Mix8Surround 7 + M12Mix8Surround 8 + M12Mix8Surround 9 + M12Mix8Surround 10 + M12Mix8Surround 11 + M12Mix8Surround 12 + M12Mix8Surround 13 + M12Mix8Surround 14 + M12Mix8Surround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8Surround0 + + Ret + +EndP Mix12Surround8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Surround8Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Surround8BitVolume], AL + + Ret + +EndP PreMix12Surround8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Panned8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8PannedOffset Macro Index + DW Offset M12Mix8Panned&Index& + EndM + + REPT 16 + M12Mix8PannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Panned8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Panned8BitOffsetTable+BX] + + M12Mix8PannedNext 0 + + RetN + + M12Mix8Panned 0 + M12Mix8Panned 1 + M12Mix8Panned 2 + M12Mix8Panned 3 + M12Mix8Panned 4 + M12Mix8Panned 5 + M12Mix8Panned 6 + M12Mix8Panned 7 + M12Mix8Panned 8 + M12Mix8Panned 9 + M12Mix8Panned 10 + M12Mix8Panned 11 + M12Mix8Panned 12 + M12Mix8Panned 13 + M12Mix8Panned 14 + M12Mix8Panned 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix8Panned0 + + Ret + +EndP Mix12Panned8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Panned8Bit + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12PannedMacro Macro Index + Mov Byte Ptr [CS:M12Mix8PannedVolume&Index&], AL + EndM + + REPT 17 + PreMix12PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Mov AL, [SI+0Ch] + Sub AL, [SI+0Eh] + Add AL, AL + + IndexCounter = 0 + + PreMix12PannedMacro2 Macro Index + Mov Byte Ptr [CS:M12Mix8PannedRightVolumeOffset&Index&], AL + EndM + + REPT 16 + PreMix12PannedMacro2 %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Panned8Bit + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix12Single16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16SingleOffset Macro Index + DW Offset M12Mix16Single&Index& + EndM + + REPT 16 + M12Mix16SingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Single16Bit + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Single16BitOffsetTable+BX] + +M12Single16BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + RetN + + M12Mix16Single 0 + M12Mix16Single 1 + M12Mix16Single 2 + M12Mix16Single 3 + M12Mix16Single 4 + M12Mix16Single 5 + M12Mix16Single 6 + M12Mix16Single 7 + M12Mix16Single 8 + M12Mix16Single 9 + M12Mix16Single 10 + M12Mix16Single 11 + M12Mix16Single 12 + M12Mix16Single 13 + M12Mix16Single 14 + M12Mix16Single 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16Single0 + + Ret + +EndP Mix12Single16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Left16Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Single16BitVolume], AL + Ret + +EndP PreMix12Left16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Right16Bit + + Add MixBufferOffset, MixResolution/8 + Mov AL, [SI+0Ch] + Mov Byte Ptr [CS:M12Single16BitVolume], AL + + Ret + +EndP PreMix12Right16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16CentralOffset Macro Index + DW Offset M12Mix16Central&Index& + EndM + + REPT 16 + M12Mix16CentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central16BitOffsetTable+BX] + +M12Central16BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + + RetN + + M12Mix16Central 0 + M12Mix16Central 1 + M12Mix16Central 2 + M12Mix16Central 3 + M12Mix16Central 4 + M12Mix16Central 5 + M12Mix16Central 6 + M12Mix16Central 7 + M12Mix16Central 8 + M12Mix16Central 9 + M12Mix16Central 10 + M12Mix16Central 11 + M12Mix16Central 12 + M12Mix16Central 13 + M12Mix16Central 14 + M12Mix16Central 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16Central0 + + Ret + +EndP Mix12Central16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central16Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Central16BitVolume], AL + + Ret + +EndP PreMix12Central16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Surround16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16SurroundOffset Macro Index + DW Offset M12Mix16Surround&Index& + EndM + + REPT 16 + M12Mix16SurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Surround16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Surround16BitOffsetTable+BX] + +M12Surround16BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + + RetN + + M12Mix16Surround 0 + M12Mix16Surround 1 + M12Mix16Surround 2 + M12Mix16Surround 3 + M12Mix16Surround 4 + M12Mix16Surround 5 + M12Mix16Surround 6 + M12Mix16Surround 7 + M12Mix16Surround 8 + M12Mix16Surround 9 + M12Mix16Surround 10 + M12Mix16Surround 11 + M12Mix16Surround 12 + M12Mix16Surround 13 + M12Mix16Surround 14 + M12Mix16Surround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M12Mix16Surround0 + + Ret + +EndP Mix12Surround16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Surround16Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Surround16BitVolume], AL + + Ret + +EndP PreMix12Surround16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Panned16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16PannedOffset Macro Index + DW Offset M12Mix16Panned&Index& + EndM + + REPT 16 + M12Mix16PannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Panned16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Panned16BitOffsetTable+BX] + + M12Mix16PannedNext 0 + + RetN + +Pan12Bit16Loop: + M12Mix16PannedNext 16 + + M12Mix16Panned 0 + M12Mix16Panned 1 + M12Mix16Panned 2 + M12Mix16Panned 3 + M12Mix16Panned 4 + M12Mix16Panned 5 + M12Mix16Panned 6 + M12Mix16Panned 7 + M12Mix16Panned 8 + M12Mix16Panned 9 + M12Mix16Panned 10 + M12Mix16Panned 11 + M12Mix16Panned 12 + M12Mix16Panned 13 + M12Mix16Panned 14 + + M12Mix16Panned15: + Add BX, BX + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov AX, [BX] + Sub [SI+EXTRAOFFSET], AX + M12Mix16PannedRightVolumeOffset15 EQU $+3 + Mov AX, [BX+1200h] + Sub [SI+MixResolution/8+EXTRAOFFSET], AX + + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ Pan12Bit16Loop + + Ret + +EndP Mix12Panned16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Panned16Bit + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12PannedMacro Macro Index + Mov Byte Ptr [CS:M12Mix16PannedVolume&Index&], AL + EndM + + REPT 17 + PreMix12PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Mov AL, [SI+0Ch] + Sub AL, [SI+0Eh] + Add AL, AL + + IndexCounter = 0 + + PreMix12PannedMacro2 Macro Index + Mov Byte Ptr [CS:M12Mix16PannedRightVolumeOffset&Index&], AL + EndM + + REPT 16 + PreMix12PannedMacro2 %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Panned16Bit + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M16.ASM b/SoundDrivers/M16.ASM index 5b88419..74f38c9 100755 --- a/SoundDrivers/M16.ASM +++ b/SoundDrivers/M16.ASM @@ -1,2275 +1,2275 @@ -; -; Terratec Maestro 16/96 -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -PNPVENDORID EQU 2409143Eh - -DMASize DW DMABUFFERLENGTH/2 - -WSSMsg DB "SoundSystem Maestro 16/96", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "SoundSystem Maestro 16/96", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "SoundSystem Maestro 16/96 Codec reinitialised", 0 - -DriverName DB "ITMAES16.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "SoundSystem Maestro 16/96 Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 15, 48 - DB 21h - DB "SoundSystem Maestro 16/96 Codec Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (56) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dmasirq.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - - Mov AX, 1 - Ret - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 16 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Add DX, 6 - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 62h - Call PnP_ReadData - Mov AH, AL - Mov AL, 63h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Mov AX, 202h - Call PnP_WriteData - Ret - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - - Mov EAX, 'Jeff' - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 6 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - Add DX, 4 - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Call UpdateSoundcardVariables - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - Push AX DX - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX AX - Ret - -EndP UpdatesoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - Call UpdateSoundcardVariables - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Terratec Maestro 16/96 +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +PNPVENDORID EQU 2409143Eh + +DMASize DW DMABUFFERLENGTH/2 + +WSSMsg DB "SoundSystem Maestro 16/96", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "SoundSystem Maestro 16/96", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "SoundSystem Maestro 16/96 Codec reinitialised", 0 + +DriverName DB "ITMAES16.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "SoundSystem Maestro 16/96 Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 15, 48 + DB 21h + DB "SoundSystem Maestro 16/96 Codec Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (56) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dmasirq.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + + Mov AX, 1 + Ret + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 16 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Add DX, 6 + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 62h + Call PnP_ReadData + Mov AH, AL + Mov AL, 63h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Mov AX, 202h + Call PnP_WriteData + Ret + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + + Mov EAX, 'Jeff' + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 6 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + Add DX, 4 + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Call UpdateSoundcardVariables + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + Push AX DX + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX AX + Ret + +EndP UpdatesoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + Call UpdateSoundcardVariables + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/M16.BAT b/SoundDrivers/M16.BAT index f5023d7..b786ac7 100755 --- a/SoundDrivers/M16.BAT +++ b/SoundDrivers/M16.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 m16 -tlink /3 m16 -execom m16 itmaes16.drv -copy itmaes16.drv .. - +tasm /m /ut310 m16 +tlink /3 m16 +execom m16 itmaes16.drv +copy itmaes16.drv .. + diff --git a/SoundDrivers/M32.ASM b/SoundDrivers/M32.ASM index 1736ea8..194e787 100755 --- a/SoundDrivers/M32.ASM +++ b/SoundDrivers/M32.ASM @@ -1,2271 +1,2271 @@ -; -; Windows Sound System Driver -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -PNPVENDORID EQU 321A630Eh - -DMASize DW DMABUFFERLENGTH/2 - -WSSMsg DB "SoundSystem Maestro 32/96", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "SoundSystem Maestro 32/96", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "SoundSystem Maestro 32/96 Codec reinitialised", 0 - -DriverName DB "ITMAES32.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "SoundSystem Maestro 32/96 Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 15, 48 - DB 21h - DB "SoundSystem Maestro 32/96 Codec Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (56) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dmasirq.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - - Mov AX, 1 - Ret - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 48000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 14 ; 14 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 07h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Mov AX, 202h - Call PnP_WriteData - Ret - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - - Mov EAX, 'Jeff' - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Call UpdateSoundcardVariables - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - Push AX DX - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX AX - Ret - -EndP UpdatesoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - Call UpdateSoundcardVariables - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +PNPVENDORID EQU 321A630Eh + +DMASize DW DMABUFFERLENGTH/2 + +WSSMsg DB "SoundSystem Maestro 32/96", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "SoundSystem Maestro 32/96", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "SoundSystem Maestro 32/96 Codec reinitialised", 0 + +DriverName DB "ITMAES32.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "SoundSystem Maestro 32/96 Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 15, 48 + DB 21h + DB "SoundSystem Maestro 32/96 Codec Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (56) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dmasirq.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + + Mov AX, 1 + Ret + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 48000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 14 ; 14 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 07h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Mov AX, 202h + Call PnP_WriteData + Ret + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + + Mov EAX, 'Jeff' + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Call UpdateSoundcardVariables + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + Push AX DX + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX AX + Ret + +EndP UpdatesoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + Call UpdateSoundcardVariables + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/M32.BAT b/SoundDrivers/M32.BAT index 328ebb1..0f34dae 100755 --- a/SoundDrivers/M32.BAT +++ b/SoundDrivers/M32.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 m32 -tlink /3 m32 -execom m32 itmaes32.drv -copy itmaes32.drv .. - +tasm /m /ut310 m32 +tlink /3 m32 +execom m32 itmaes32.drv +copy itmaes32.drv .. + diff --git a/SoundDrivers/M32BIT.INC b/SoundDrivers/M32BIT.INC index 47bebd5..7f5ec0d 100755 --- a/SoundDrivers/M32BIT.INC +++ b/SoundDrivers/M32BIT.INC @@ -1,49 +1,49 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix32Left8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit - DW Offset MixForwardsLoop, PreMix32Left8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit - DW Offset MixPingPongLoop, PreMix32Left8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit - ; Right only - DW Offset MixNoLoop, PreMix32Right8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit - DW Offset MixForwardsLoop, PreMix32Right8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit - DW Offset MixPingPongLoop, PreMix32Right8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit - ; Central - DW Offset MixNoLoop, PreMix32Central8Bit, MFS8Bit, MBS8Bit, Mix32Central8Bit - DW Offset MixForwardsLoop, PreMix32Central8Bit, MFS8Bit, MBS8Bit, Mix32Central8Bit - DW Offset MixPingPongLoop, PreMix32Central8Bit, MFS8Bit, MBS8Bit, Mix32Central8Bit - ; Stereo - DW Offset MixNoLoop, PreMix32Panned8Bit, MFS8Bit, MBS8Bit, Mix32Panned8Bit - DW Offset MixForwardsLoop, PreMix32Panned8Bit, MFS8Bit, MBS8Bit, Mix32Panned8Bit - DW Offset MixPingPongLoop, PreMix32Panned8Bit, MFS8Bit, MBS8Bit, Mix32Panned8Bit - ; Surround - DW Offset MixNoLoop, PreMix32Surround8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit - DW Offset MixForwardsLoop, PreMix32Surround8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit - DW Offset MixPingPongLoop, PreMix32Surround8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit - - ; 16 bit tables - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix32Left16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit - DW Offset MixForwardsLoop, PreMix32Left16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit - DW Offset MixPingPongLoop, PreMix32Left16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit - ; Right only - DW Offset MixNoLoop, PreMix32Right16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit - DW Offset MixForwardsLoop, PreMix32Right16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit - DW Offset MixPingPongLoop, PreMix32Right16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit - ; Central - DW Offset MixNoLoop, PreMix32Central16Bit, MFS16Bit, MBS16Bit, Mix32Central16Bit - DW Offset MixForwardsLoop, PreMix32Central16Bit, MFS16Bit, MBS16Bit, Mix32Central16Bit - DW Offset MixPingPongLoop, PreMix32Central16Bit, MFS16Bit, MBS16Bit, Mix32Central16Bit - ; Stereo - DW Offset MixNoLoop, PreMix32Panned16Bit, MFS16Bit, MBS16Bit, Mix32Panned16Bit - DW Offset MixForwardsLoop, PreMix32Panned16Bit, MFS16Bit, MBS16Bit, Mix32Panned16Bit - DW Offset MixPingPongLoop, PreMix32Panned16Bit, MFS16Bit, MBS16Bit, Mix32Panned16Bit - ; Surround - DW Offset MixNoLoop, PreMix32Surround16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit - DW Offset MixForwardsLoop, PreMix32Surround16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit - DW Offset MixPingPongLoop, PreMix32Surround16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix32Left8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit + DW Offset MixForwardsLoop, PreMix32Left8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit + DW Offset MixPingPongLoop, PreMix32Left8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit + ; Right only + DW Offset MixNoLoop, PreMix32Right8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit + DW Offset MixForwardsLoop, PreMix32Right8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit + DW Offset MixPingPongLoop, PreMix32Right8Bit, MFS8Bit, MBS8Bit, Mix32Single8Bit + ; Central + DW Offset MixNoLoop, PreMix32Central8Bit, MFS8Bit, MBS8Bit, Mix32Central8Bit + DW Offset MixForwardsLoop, PreMix32Central8Bit, MFS8Bit, MBS8Bit, Mix32Central8Bit + DW Offset MixPingPongLoop, PreMix32Central8Bit, MFS8Bit, MBS8Bit, Mix32Central8Bit + ; Stereo + DW Offset MixNoLoop, PreMix32Panned8Bit, MFS8Bit, MBS8Bit, Mix32Panned8Bit + DW Offset MixForwardsLoop, PreMix32Panned8Bit, MFS8Bit, MBS8Bit, Mix32Panned8Bit + DW Offset MixPingPongLoop, PreMix32Panned8Bit, MFS8Bit, MBS8Bit, Mix32Panned8Bit + ; Surround + DW Offset MixNoLoop, PreMix32Surround8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit + DW Offset MixForwardsLoop, PreMix32Surround8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit + DW Offset MixPingPongLoop, PreMix32Surround8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit + + ; 16 bit tables + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix32Left16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit + DW Offset MixForwardsLoop, PreMix32Left16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit + DW Offset MixPingPongLoop, PreMix32Left16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit + ; Right only + DW Offset MixNoLoop, PreMix32Right16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit + DW Offset MixForwardsLoop, PreMix32Right16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit + DW Offset MixPingPongLoop, PreMix32Right16Bit, MFS16Bit, MBS16Bit, Mix32Single16Bit + ; Central + DW Offset MixNoLoop, PreMix32Central16Bit, MFS16Bit, MBS16Bit, Mix32Central16Bit + DW Offset MixForwardsLoop, PreMix32Central16Bit, MFS16Bit, MBS16Bit, Mix32Central16Bit + DW Offset MixPingPongLoop, PreMix32Central16Bit, MFS16Bit, MBS16Bit, Mix32Central16Bit + ; Stereo + DW Offset MixNoLoop, PreMix32Panned16Bit, MFS16Bit, MBS16Bit, Mix32Panned16Bit + DW Offset MixForwardsLoop, PreMix32Panned16Bit, MFS16Bit, MBS16Bit, Mix32Panned16Bit + DW Offset MixPingPongLoop, PreMix32Panned16Bit, MFS16Bit, MBS16Bit, Mix32Panned16Bit + ; Surround + DW Offset MixNoLoop, PreMix32Surround16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit + DW Offset MixForwardsLoop, PreMix32Surround16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit + DW Offset MixPingPongLoop, PreMix32Surround16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit diff --git a/SoundDrivers/M32BIT.MIX b/SoundDrivers/M32BIT.MIX index 4a06c34..074cb55 100755 --- a/SoundDrivers/M32BIT.MIX +++ b/SoundDrivers/M32BIT.MIX @@ -1,803 +1,803 @@ - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - -M32Mix8Single Macro Index - -M32Mix8Single&Index&: - MovSX EBX, Byte Ptr [ES:DI] - -M32Mix8SingleVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - ShL EAX, 8 - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 3 -EndM - -M32Mix8Central Macro Index - -M32Mix8Central&Index&: - MovSX EBX, Byte Ptr [ES:DI] ;; 4 - -M32Mix8CentralVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - ShL EAX, 8 ;; 4 - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 4 - Sub [SI+(Index-15)*8+4], EAX ;; 4 - -EndM - -M32Mix8Surround Macro Index - -M32Mix8Surround&Index&: - MovSX EBX, Byte Ptr [ES:DI] ;; 4 - -M32Mix8SurroundVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - ShL EAX, 8 ;; 4 - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 4 - Add [SI+(Index-15)*8+4], EAX ;; 4 - -EndM - - ; Panned output -M32Mix8Panned Macro Index - -M32Mix8Panned&Index&: - MovSX EBX, Byte Ptr [ES:DI] ;; 4 - -M32Mix8LeftVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h -M32Mix8RightVolume&Index& EQU $+3 - IMul EBX, EBX, 8000h - - ShL EAX, 8 ;; 4 - ShL EBX, 8 ;; 4 - - Sub [SI+(Index-15)*8], EAX ;; 4 - Sub [SI+(Index-15)*8+4], EBX ;; 4 - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - -EndM - -M32Mix16Single Macro Index - -M32Mix16Single&Index&: - MovSX EBX, Word Ptr [ES:EDI+EDI] - -M32Mix16SingleVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 3 - -EndM - -M32Mix16Central Macro Index - -M32Mix16Central&Index&: - MovSX EBX, Word Ptr [ES:EDI+EDI] - -M32Mix16CentralVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 3 - Sub [SI+(Index-15)*8+4], EAX ;; 3 - -EndM - -M32Mix16Surround Macro Index - -M32Mix16Surround&Index&: - MovSX EBX, Word Ptr [ES:EDI+EDI] - -M32Mix16SurroundVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 3 - Add [SI+(Index-15)*8+4], EAX ;; 3 - -EndM - - ; Panned output -M32Mix16Panned Macro Index - -M32Mix16Panned&Index&: - MovSX EBX, Word Ptr [ES:EDI+EDI] - -M32Mix16LeftVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h -M32Mix16RightVolume&Index& EQU $+3 - IMul EBX, EBX, 8000h - - Sub [SI+(Index-15)*8], EAX - Sub [SI+(Index-15)*8+4], EBX - - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix32Single8BitOffsetTable Label Word - - IndexCounter = 15 - - M32Mix8SingleOffset Macro Index - DW Offset M32Mix8Single&Index& - EndM - - REPT 16 - M32Mix8SingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Single8Bit - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Single8BitOffsetTable+BX] - - M32Mix8Single 0 - M32Mix8Single 1 - M32Mix8Single 2 - M32Mix8Single 3 - M32Mix8Single 4 - M32Mix8Single 5 - M32Mix8Single 6 - M32Mix8Single 7 - M32Mix8Single 8 - M32Mix8Single 9 - M32Mix8Single 10 - M32Mix8Single 11 - M32Mix8Single 12 - M32Mix8Single 13 - M32Mix8Single 14 - M32Mix8Single 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix8Single0 - - Ret - -EndP Mix32Single8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Left8Bit - - Mov AX, [SI+0Eh] - -PreMix32Left8Bit1: - IndexCounter = 0 - - PreMix32SingleMacro Macro Index - Mov Word Ptr [CS:M32Mix8SingleVolume&Index&], AX - EndM - - REPT 16 - PreMix32SingleMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - Ret - -EndP PreMix32Left8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Right8Bit - - Add MixBufferOffset, MixResolution/8 - Mov AX, [SI+0Ch] - Jmp PreMix32Left8Bit1 - -EndP PreMix32Right8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Central8BitOffsetTable Label Word - - IndexCounter = 15 - - M32Mix8CentralOffset Macro Index - DW Offset M32Mix8Central&Index& - EndM - - REPT 16 - M32Mix8CentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Central8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Central8BitOffsetTable+BX] - - M32Mix8Central 0 - M32Mix8Central 1 - M32Mix8Central 2 - M32Mix8Central 3 - M32Mix8Central 4 - M32Mix8Central 5 - M32Mix8Central 6 - M32Mix8Central 7 - M32Mix8Central 8 - M32Mix8Central 9 - M32Mix8Central 10 - M32Mix8Central 11 - M32Mix8Central 12 - M32Mix8Central 13 - M32Mix8Central 14 - M32Mix8Central 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix8Central0 - - Ret - -EndP Mix32Central8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Central8Bit - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMix32CentralMacro Macro Index - Mov Word Ptr [CS:M32Mix8CentralVolume&Index&], AX - EndM - - REPT 16 - PreMix32CentralMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Central8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Surround8BitOffsetTable Label Word - - IndexCounter = 15 - - M32Mix8SurroundOffset Macro Index - DW Offset M32Mix8Surround&Index& - EndM - - REPT 16 - M32Mix8SurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Surround8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Surround8BitOffsetTable+BX] - - M32Mix8Surround 0 - M32Mix8Surround 1 - M32Mix8Surround 2 - M32Mix8Surround 3 - M32Mix8Surround 4 - M32Mix8Surround 5 - M32Mix8Surround 6 - M32Mix8Surround 7 - M32Mix8Surround 8 - M32Mix8Surround 9 - M32Mix8Surround 10 - M32Mix8Surround 11 - M32Mix8Surround 12 - M32Mix8Surround 13 - M32Mix8Surround 14 - M32Mix8Surround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix8Surround0 - - Ret - -EndP Mix32Surround8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Surround8Bit - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMix32SurroundMacro Macro Index - Mov Word Ptr [CS:M32Mix8SurroundVolume&Index&], AX - EndM - - REPT 16 - PreMix32SurroundMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Surround8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Panned8BitOffsetTable Label Word - - IndexCounter = 15 - - M32Mix8PannedOffset Macro Index - DW Offset M32Mix8Panned&Index& - EndM - - REPT 16 - M32Mix8PannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Panned8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Panned8BitOffsetTable+BX] - - M32Mix8Panned 0 - M32Mix8Panned 1 - M32Mix8Panned 2 - M32Mix8Panned 3 - M32Mix8Panned 4 - M32Mix8Panned 5 - M32Mix8Panned 6 - M32Mix8Panned 7 - M32Mix8Panned 8 - M32Mix8Panned 9 - M32Mix8Panned 10 - M32Mix8Panned 11 - M32Mix8Panned 12 - M32Mix8Panned 13 - M32Mix8Panned 14 - M32Mix8Panned 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix8Panned0 - - Ret - -EndP Mix32Panned8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Panned8Bit - - Mov AX, [SI+0Eh] ; Left - Mov BX, [SI+0Ch] ; Right - - IndexCounter = 0 - - PreMix32PannedMacro Macro Index - Mov Word Ptr [CS:M32Mix8LeftVolume&Index&], AX - Mov Word Ptr [CS:M32Mix8RightVolume&Index&], BX - EndM - - REPT 16 - PreMix32PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Panned8Bit - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix32Single16BitOffsetTable Label Word - - IndexCounter = 15 - - M32Mix16SingleOffset Macro Index - DW Offset M32Mix16Single&Index& - EndM - - REPT 16 - M32Mix16SingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Single16Bit - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Single16BitOffsetTable+BX] - - M32Mix16Single 0 - M32Mix16Single 1 - M32Mix16Single 2 - M32Mix16Single 3 - M32Mix16Single 4 - M32Mix16Single 5 - M32Mix16Single 6 - M32Mix16Single 7 - M32Mix16Single 8 - M32Mix16Single 9 - M32Mix16Single 10 - M32Mix16Single 11 - M32Mix16Single 12 - M32Mix16Single 13 - M32Mix16Single 14 - M32Mix16Single 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix16Single0 - - Ret - -EndP Mix32Single16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Left16Bit - - Mov AX, [SI+0Eh] ; Left - -PreMix32Left16Bit1: - IndexCounter = 0 - - PreMix32SingleMacro Macro Index - Mov Word Ptr [CS:M32Mix16SingleVolume&Index&], AX - EndM - - REPT 16 - PreMix32SingleMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Left16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Right16Bit - - Add MixBufferOffset, MixResolution/8 - Mov AX, [SI+0Ch] - Jmp PreMix32Left16Bit1 - - Ret - -EndP PreMix32Right16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Central16BitOffsetTable Label Word - - IndexCounter = 15 - - M32Mix16CentralOffset Macro Index - DW Offset M32Mix16Central&Index& - EndM - - REPT 16 - M32Mix16CentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Central16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Central16BitOffsetTable+BX] - - M32Mix16Central 0 - M32Mix16Central 1 - M32Mix16Central 2 - M32Mix16Central 3 - M32Mix16Central 4 - M32Mix16Central 5 - M32Mix16Central 6 - M32Mix16Central 7 - M32Mix16Central 8 - M32Mix16Central 9 - M32Mix16Central 10 - M32Mix16Central 11 - M32Mix16Central 12 - M32Mix16Central 13 - M32Mix16Central 14 - M32Mix16Central 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix16Central0 - - Ret - -EndP Mix32Central16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Central16Bit - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMix32CentralMacro Macro Index - Mov Word Ptr [CS:M32Mix16CentralVolume&Index&], AX - EndM - - REPT 16 - PreMix32CentralMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Central16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Surround16BitOffsetTable Label Word - - IndexCounter = 15 - - M32Mix16SurroundOffset Macro Index - DW Offset M32Mix16Surround&Index& - EndM - - REPT 16 - M32Mix16SurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Surround16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Surround16BitOffsetTable+BX] - - M32Mix16Surround 0 - M32Mix16Surround 1 - M32Mix16Surround 2 - M32Mix16Surround 3 - M32Mix16Surround 4 - M32Mix16Surround 5 - M32Mix16Surround 6 - M32Mix16Surround 7 - M32Mix16Surround 8 - M32Mix16Surround 9 - M32Mix16Surround 10 - M32Mix16Surround 11 - M32Mix16Surround 12 - M32Mix16Surround 13 - M32Mix16Surround 14 - M32Mix16Surround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix16Surround0 - - Ret - -EndP Mix32Surround16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Surround16Bit - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMix32SurroundMacro Macro Index - Mov Word Ptr [CS:M32Mix16SurroundVolume&Index&], AX - EndM - - REPT 16 - PreMix32SurroundMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Surround16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Panned16BitOffsetTable Label Word - - IndexCounter = 15 - - M32Mix16PannedOffset Macro Index - DW Offset M32Mix16Panned&Index& - EndM - - REPT 16 - M32Mix16PannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Panned16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Panned16BitOffsetTable+BX] - -Pan32Bit16Loop: - M32Mix16Panned 0 - M32Mix16Panned 1 - M32Mix16Panned 2 - M32Mix16Panned 3 - M32Mix16Panned 4 - M32Mix16Panned 5 - M32Mix16Panned 6 - M32Mix16Panned 7 - M32Mix16Panned 8 - M32Mix16Panned 9 - M32Mix16Panned 10 - M32Mix16Panned 11 - M32Mix16Panned 12 - M32Mix16Panned 13 - M32Mix16Panned 14 - M32Mix16Panned 15 - - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ Pan32Bit16Loop - - Ret - -EndP Mix32Panned16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Panned16Bit - - Mov AX, [SI+0Eh] ; Left - Mov BX, [SI+0Ch] ; Right - - IndexCounter = 0 - - PreMix32PannedMacro Macro Index - Mov Word Ptr [CS:M32Mix16LeftVolume&Index&], AX - Mov Word Ptr [CS:M32Mix16RightVolume&Index&], BX - EndM - - REPT 16 - PreMix32PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Panned16Bit - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + +M32Mix8Single Macro Index + +M32Mix8Single&Index&: + MovSX EBX, Byte Ptr [ES:DI] + +M32Mix8SingleVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + ShL EAX, 8 + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 3 +EndM + +M32Mix8Central Macro Index + +M32Mix8Central&Index&: + MovSX EBX, Byte Ptr [ES:DI] ;; 4 + +M32Mix8CentralVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + ShL EAX, 8 ;; 4 + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 4 + Sub [SI+(Index-15)*8+4], EAX ;; 4 + +EndM + +M32Mix8Surround Macro Index + +M32Mix8Surround&Index&: + MovSX EBX, Byte Ptr [ES:DI] ;; 4 + +M32Mix8SurroundVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + ShL EAX, 8 ;; 4 + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 4 + Add [SI+(Index-15)*8+4], EAX ;; 4 + +EndM + + ; Panned output +M32Mix8Panned Macro Index + +M32Mix8Panned&Index&: + MovSX EBX, Byte Ptr [ES:DI] ;; 4 + +M32Mix8LeftVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h +M32Mix8RightVolume&Index& EQU $+3 + IMul EBX, EBX, 8000h + + ShL EAX, 8 ;; 4 + ShL EBX, 8 ;; 4 + + Sub [SI+(Index-15)*8], EAX ;; 4 + Sub [SI+(Index-15)*8+4], EBX ;; 4 + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + +EndM + +M32Mix16Single Macro Index + +M32Mix16Single&Index&: + MovSX EBX, Word Ptr [ES:EDI+EDI] + +M32Mix16SingleVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 3 + +EndM + +M32Mix16Central Macro Index + +M32Mix16Central&Index&: + MovSX EBX, Word Ptr [ES:EDI+EDI] + +M32Mix16CentralVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 3 + Sub [SI+(Index-15)*8+4], EAX ;; 3 + +EndM + +M32Mix16Surround Macro Index + +M32Mix16Surround&Index&: + MovSX EBX, Word Ptr [ES:EDI+EDI] + +M32Mix16SurroundVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 3 + Add [SI+(Index-15)*8+4], EAX ;; 3 + +EndM + + ; Panned output +M32Mix16Panned Macro Index + +M32Mix16Panned&Index&: + MovSX EBX, Word Ptr [ES:EDI+EDI] + +M32Mix16LeftVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h +M32Mix16RightVolume&Index& EQU $+3 + IMul EBX, EBX, 8000h + + Sub [SI+(Index-15)*8], EAX + Sub [SI+(Index-15)*8+4], EBX + + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix32Single8BitOffsetTable Label Word + + IndexCounter = 15 + + M32Mix8SingleOffset Macro Index + DW Offset M32Mix8Single&Index& + EndM + + REPT 16 + M32Mix8SingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Single8Bit + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Single8BitOffsetTable+BX] + + M32Mix8Single 0 + M32Mix8Single 1 + M32Mix8Single 2 + M32Mix8Single 3 + M32Mix8Single 4 + M32Mix8Single 5 + M32Mix8Single 6 + M32Mix8Single 7 + M32Mix8Single 8 + M32Mix8Single 9 + M32Mix8Single 10 + M32Mix8Single 11 + M32Mix8Single 12 + M32Mix8Single 13 + M32Mix8Single 14 + M32Mix8Single 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix8Single0 + + Ret + +EndP Mix32Single8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Left8Bit + + Mov AX, [SI+0Eh] + +PreMix32Left8Bit1: + IndexCounter = 0 + + PreMix32SingleMacro Macro Index + Mov Word Ptr [CS:M32Mix8SingleVolume&Index&], AX + EndM + + REPT 16 + PreMix32SingleMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + Ret + +EndP PreMix32Left8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Right8Bit + + Add MixBufferOffset, MixResolution/8 + Mov AX, [SI+0Ch] + Jmp PreMix32Left8Bit1 + +EndP PreMix32Right8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Central8BitOffsetTable Label Word + + IndexCounter = 15 + + M32Mix8CentralOffset Macro Index + DW Offset M32Mix8Central&Index& + EndM + + REPT 16 + M32Mix8CentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Central8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Central8BitOffsetTable+BX] + + M32Mix8Central 0 + M32Mix8Central 1 + M32Mix8Central 2 + M32Mix8Central 3 + M32Mix8Central 4 + M32Mix8Central 5 + M32Mix8Central 6 + M32Mix8Central 7 + M32Mix8Central 8 + M32Mix8Central 9 + M32Mix8Central 10 + M32Mix8Central 11 + M32Mix8Central 12 + M32Mix8Central 13 + M32Mix8Central 14 + M32Mix8Central 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix8Central0 + + Ret + +EndP Mix32Central8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Central8Bit + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMix32CentralMacro Macro Index + Mov Word Ptr [CS:M32Mix8CentralVolume&Index&], AX + EndM + + REPT 16 + PreMix32CentralMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Central8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Surround8BitOffsetTable Label Word + + IndexCounter = 15 + + M32Mix8SurroundOffset Macro Index + DW Offset M32Mix8Surround&Index& + EndM + + REPT 16 + M32Mix8SurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Surround8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Surround8BitOffsetTable+BX] + + M32Mix8Surround 0 + M32Mix8Surround 1 + M32Mix8Surround 2 + M32Mix8Surround 3 + M32Mix8Surround 4 + M32Mix8Surround 5 + M32Mix8Surround 6 + M32Mix8Surround 7 + M32Mix8Surround 8 + M32Mix8Surround 9 + M32Mix8Surround 10 + M32Mix8Surround 11 + M32Mix8Surround 12 + M32Mix8Surround 13 + M32Mix8Surround 14 + M32Mix8Surround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix8Surround0 + + Ret + +EndP Mix32Surround8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Surround8Bit + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMix32SurroundMacro Macro Index + Mov Word Ptr [CS:M32Mix8SurroundVolume&Index&], AX + EndM + + REPT 16 + PreMix32SurroundMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Surround8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Panned8BitOffsetTable Label Word + + IndexCounter = 15 + + M32Mix8PannedOffset Macro Index + DW Offset M32Mix8Panned&Index& + EndM + + REPT 16 + M32Mix8PannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Panned8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Panned8BitOffsetTable+BX] + + M32Mix8Panned 0 + M32Mix8Panned 1 + M32Mix8Panned 2 + M32Mix8Panned 3 + M32Mix8Panned 4 + M32Mix8Panned 5 + M32Mix8Panned 6 + M32Mix8Panned 7 + M32Mix8Panned 8 + M32Mix8Panned 9 + M32Mix8Panned 10 + M32Mix8Panned 11 + M32Mix8Panned 12 + M32Mix8Panned 13 + M32Mix8Panned 14 + M32Mix8Panned 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix8Panned0 + + Ret + +EndP Mix32Panned8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Panned8Bit + + Mov AX, [SI+0Eh] ; Left + Mov BX, [SI+0Ch] ; Right + + IndexCounter = 0 + + PreMix32PannedMacro Macro Index + Mov Word Ptr [CS:M32Mix8LeftVolume&Index&], AX + Mov Word Ptr [CS:M32Mix8RightVolume&Index&], BX + EndM + + REPT 16 + PreMix32PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Panned8Bit + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix32Single16BitOffsetTable Label Word + + IndexCounter = 15 + + M32Mix16SingleOffset Macro Index + DW Offset M32Mix16Single&Index& + EndM + + REPT 16 + M32Mix16SingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Single16Bit + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Single16BitOffsetTable+BX] + + M32Mix16Single 0 + M32Mix16Single 1 + M32Mix16Single 2 + M32Mix16Single 3 + M32Mix16Single 4 + M32Mix16Single 5 + M32Mix16Single 6 + M32Mix16Single 7 + M32Mix16Single 8 + M32Mix16Single 9 + M32Mix16Single 10 + M32Mix16Single 11 + M32Mix16Single 12 + M32Mix16Single 13 + M32Mix16Single 14 + M32Mix16Single 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix16Single0 + + Ret + +EndP Mix32Single16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Left16Bit + + Mov AX, [SI+0Eh] ; Left + +PreMix32Left16Bit1: + IndexCounter = 0 + + PreMix32SingleMacro Macro Index + Mov Word Ptr [CS:M32Mix16SingleVolume&Index&], AX + EndM + + REPT 16 + PreMix32SingleMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Left16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Right16Bit + + Add MixBufferOffset, MixResolution/8 + Mov AX, [SI+0Ch] + Jmp PreMix32Left16Bit1 + + Ret + +EndP PreMix32Right16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Central16BitOffsetTable Label Word + + IndexCounter = 15 + + M32Mix16CentralOffset Macro Index + DW Offset M32Mix16Central&Index& + EndM + + REPT 16 + M32Mix16CentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Central16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Central16BitOffsetTable+BX] + + M32Mix16Central 0 + M32Mix16Central 1 + M32Mix16Central 2 + M32Mix16Central 3 + M32Mix16Central 4 + M32Mix16Central 5 + M32Mix16Central 6 + M32Mix16Central 7 + M32Mix16Central 8 + M32Mix16Central 9 + M32Mix16Central 10 + M32Mix16Central 11 + M32Mix16Central 12 + M32Mix16Central 13 + M32Mix16Central 14 + M32Mix16Central 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix16Central0 + + Ret + +EndP Mix32Central16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Central16Bit + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMix32CentralMacro Macro Index + Mov Word Ptr [CS:M32Mix16CentralVolume&Index&], AX + EndM + + REPT 16 + PreMix32CentralMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Central16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Surround16BitOffsetTable Label Word + + IndexCounter = 15 + + M32Mix16SurroundOffset Macro Index + DW Offset M32Mix16Surround&Index& + EndM + + REPT 16 + M32Mix16SurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Surround16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Surround16BitOffsetTable+BX] + + M32Mix16Surround 0 + M32Mix16Surround 1 + M32Mix16Surround 2 + M32Mix16Surround 3 + M32Mix16Surround 4 + M32Mix16Surround 5 + M32Mix16Surround 6 + M32Mix16Surround 7 + M32Mix16Surround 8 + M32Mix16Surround 9 + M32Mix16Surround 10 + M32Mix16Surround 11 + M32Mix16Surround 12 + M32Mix16Surround 13 + M32Mix16Surround 14 + M32Mix16Surround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix16Surround0 + + Ret + +EndP Mix32Surround16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Surround16Bit + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMix32SurroundMacro Macro Index + Mov Word Ptr [CS:M32Mix16SurroundVolume&Index&], AX + EndM + + REPT 16 + PreMix32SurroundMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Surround16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Panned16BitOffsetTable Label Word + + IndexCounter = 15 + + M32Mix16PannedOffset Macro Index + DW Offset M32Mix16Panned&Index& + EndM + + REPT 16 + M32Mix16PannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Panned16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Panned16BitOffsetTable+BX] + +Pan32Bit16Loop: + M32Mix16Panned 0 + M32Mix16Panned 1 + M32Mix16Panned 2 + M32Mix16Panned 3 + M32Mix16Panned 4 + M32Mix16Panned 5 + M32Mix16Panned 6 + M32Mix16Panned 7 + M32Mix16Panned 8 + M32Mix16Panned 9 + M32Mix16Panned 10 + M32Mix16Panned 11 + M32Mix16Panned 12 + M32Mix16Panned 13 + M32Mix16Panned 14 + M32Mix16Panned 15 + + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ Pan32Bit16Loop + + Ret + +EndP Mix32Panned16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Panned16Bit + + Mov AX, [SI+0Eh] ; Left + Mov BX, [SI+0Ch] ; Right + + IndexCounter = 0 + + PreMix32PannedMacro Macro Index + Mov Word Ptr [CS:M32Mix16LeftVolume&Index&], AX + Mov Word Ptr [CS:M32Mix16RightVolume&Index&], BX + EndM + + REPT 16 + PreMix32PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Panned16Bit + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M32BITFF.MIX b/SoundDrivers/M32BITFF.MIX index 6a6abcd..c64ac45 100755 --- a/SoundDrivers/M32BITFF.MIX +++ b/SoundDrivers/M32BITFF.MIX @@ -1,6 +1,6 @@ -; -; Floating point mixing routines -; DS:0 = a, DS:4 = b, DS:8 = c -; DS:10h = os1, DS:18h = OS2 -; - +; +; Floating point mixing routines +; DS:0 = a, DS:4 = b, DS:8 = c +; DS:10h = os1, DS:18h = OS2 +; + diff --git a/SoundDrivers/M32BITI.INC b/SoundDrivers/M32BITI.INC index 4a229ab..7cfd1e3 100755 --- a/SoundDrivers/M32BITI.INC +++ b/SoundDrivers/M32BITI.INC @@ -1,49 +1,49 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix32Left8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI - DW Offset MixForwardsLoop, PreMix32Left8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI - DW Offset MixPingPongLoop, PreMix32Left8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI - ; Right only - DW Offset MixNoLoop, PreMix32Right8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI - DW Offset MixForwardsLoop, PreMix32Right8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI - DW Offset MixPingPongLoop, PreMix32Right8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI - ; Central - DW Offset MixNoLoop, PreMix32Central8BitI, MFS8Bit, MBS8Bit, Mix32Central8BitI - DW Offset MixForwardsLoop, PreMix32Central8BitI, MFS8Bit, MBS8Bit, Mix32Central8BitI - DW Offset MixPingPongLoop, PreMix32Central8BitI, MFS8Bit, MBS8Bit, Mix32Central8BitI - ; Stereo - DW Offset MixNoLoop, PreMix32Panned8BitI, MFS8Bit, MBS8Bit, Mix32Panned8BitI - DW Offset MixForwardsLoop, PreMix32Panned8BitI, MFS8Bit, MBS8Bit, Mix32Panned8BitI - DW Offset MixPingPongLoop, PreMix32Panned8BitI, MFS8Bit, MBS8Bit, Mix32Panned8BitI - ; Surround - DW Offset MixNoLoop, PreMix32Surround8BitI, MFS8Bit, MBS8Bit, Mix32Surround8BitI - DW Offset MixForwardsLoop, PreMix32Surround8BitI, MFS8Bit, MBS8Bit, Mix32Surround8BitI - DW Offset MixPingPongLoop, PreMix32Surround8BitI, MFS8Bit, MBS8Bit, Mix32Surround8BitI - - ; 16 bit tables - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMix32Left16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI - DW Offset MixForwardsLoop, PreMix32Left16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI - DW Offset MixPingPongLoop, PreMix32Left16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI - ; Right only - DW Offset MixNoLoop, PreMix32Right16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI - DW Offset MixForwardsLoop, PreMix32Right16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI - DW Offset MixPingPongLoop, PreMix32Right16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI - ; Central - DW Offset MixNoLoop, PreMix32Central16BitI, MFS16Bit, MBS16Bit, Mix32Central16BitI - DW Offset MixForwardsLoop, PreMix32Central16BitI, MFS16Bit, MBS16Bit, Mix32Central16BitI - DW Offset MixPingPongLoop, PreMix32Central16BitI, MFS16Bit, MBS16Bit, Mix32Central16BitI - ; Stereo - DW Offset MixNoLoop, PreMix32Panned16BitI, MFS16Bit, MBS16Bit, Mix32Panned16BitI - DW Offset MixForwardsLoop, PreMix32Panned16BitI, MFS16Bit, MBS16Bit, Mix32Panned16BitI - DW Offset MixPingPongLoop, PreMix32Panned16BitI, MFS16Bit, MBS16Bit, Mix32Panned16BitI - ; Surround - DW Offset MixNoLoop, PreMix32Surround16BitI, MFS16Bit, MBS16Bit, Mix32Surround16BitI - DW Offset MixForwardsLoop, PreMix32Surround16BitI, MFS16Bit, MBS16Bit, Mix32Surround16BitI - DW Offset MixPingPongLoop, PreMix32Surround16BitI, MFS16Bit, MBS16Bit, Mix32Surround16BitI + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix32Left8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI + DW Offset MixForwardsLoop, PreMix32Left8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI + DW Offset MixPingPongLoop, PreMix32Left8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI + ; Right only + DW Offset MixNoLoop, PreMix32Right8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI + DW Offset MixForwardsLoop, PreMix32Right8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI + DW Offset MixPingPongLoop, PreMix32Right8BitI, MFS8Bit, MBS8Bit, Mix32Single8BitI + ; Central + DW Offset MixNoLoop, PreMix32Central8BitI, MFS8Bit, MBS8Bit, Mix32Central8BitI + DW Offset MixForwardsLoop, PreMix32Central8BitI, MFS8Bit, MBS8Bit, Mix32Central8BitI + DW Offset MixPingPongLoop, PreMix32Central8BitI, MFS8Bit, MBS8Bit, Mix32Central8BitI + ; Stereo + DW Offset MixNoLoop, PreMix32Panned8BitI, MFS8Bit, MBS8Bit, Mix32Panned8BitI + DW Offset MixForwardsLoop, PreMix32Panned8BitI, MFS8Bit, MBS8Bit, Mix32Panned8BitI + DW Offset MixPingPongLoop, PreMix32Panned8BitI, MFS8Bit, MBS8Bit, Mix32Panned8BitI + ; Surround + DW Offset MixNoLoop, PreMix32Surround8BitI, MFS8Bit, MBS8Bit, Mix32Surround8BitI + DW Offset MixForwardsLoop, PreMix32Surround8BitI, MFS8Bit, MBS8Bit, Mix32Surround8BitI + DW Offset MixPingPongLoop, PreMix32Surround8BitI, MFS8Bit, MBS8Bit, Mix32Surround8BitI + + ; 16 bit tables + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMix32Left16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI + DW Offset MixForwardsLoop, PreMix32Left16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI + DW Offset MixPingPongLoop, PreMix32Left16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI + ; Right only + DW Offset MixNoLoop, PreMix32Right16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI + DW Offset MixForwardsLoop, PreMix32Right16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI + DW Offset MixPingPongLoop, PreMix32Right16BitI, MFS16Bit, MBS16Bit, Mix32Single16BitI + ; Central + DW Offset MixNoLoop, PreMix32Central16BitI, MFS16Bit, MBS16Bit, Mix32Central16BitI + DW Offset MixForwardsLoop, PreMix32Central16BitI, MFS16Bit, MBS16Bit, Mix32Central16BitI + DW Offset MixPingPongLoop, PreMix32Central16BitI, MFS16Bit, MBS16Bit, Mix32Central16BitI + ; Stereo + DW Offset MixNoLoop, PreMix32Panned16BitI, MFS16Bit, MBS16Bit, Mix32Panned16BitI + DW Offset MixForwardsLoop, PreMix32Panned16BitI, MFS16Bit, MBS16Bit, Mix32Panned16BitI + DW Offset MixPingPongLoop, PreMix32Panned16BitI, MFS16Bit, MBS16Bit, Mix32Panned16BitI + ; Surround + DW Offset MixNoLoop, PreMix32Surround16BitI, MFS16Bit, MBS16Bit, Mix32Surround16BitI + DW Offset MixForwardsLoop, PreMix32Surround16BitI, MFS16Bit, MBS16Bit, Mix32Surround16BitI + DW Offset MixPingPongLoop, PreMix32Surround16BitI, MFS16Bit, MBS16Bit, Mix32Surround16BitI diff --git a/SoundDrivers/M32BITI.MIX b/SoundDrivers/M32BITI.MIX index 6d645dd..49ea65a 100755 --- a/SoundDrivers/M32BITI.MIX +++ b/SoundDrivers/M32BITI.MIX @@ -1,818 +1,818 @@ - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - -Get32Bit8Waveform Macro - MovSX EBX, Byte Ptr [ES:DI+1] - MovSX EAX, Byte Ptr [ES:DI] - Sub EBX, EAX - IMul EBX, ECX - SAR EBX, 8 - ShL EAX, 8 - Add EBX, EAX - -EndM - -Get32Bit16Waveform Macro - MovSX EBX, Word Ptr [ES:EDI+EDI+2] - MovSX EAX, Word Ptr [ES:EDI+EDI] - Sub EBX, EAX - SAR EBX, 1 - IMul EBX, ECX - SAR EBX, 15 - Add EBX, EAX -EndM - -M32Mix8ISingle Macro Index - -M32Mix8ISingle&Index&: - Get32Bit8WaveForm - -M32Mix8ISingleVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 3 -EndM - -M32Mix8ICentral Macro Index - -M32Mix8ICentral&Index&: - Get32Bit8WaveForm - -M32Mix8ICentralVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 4 - Sub [SI+(Index-15)*8+4], EAX ;; 4 - -EndM - -M32Mix8ISurround Macro Index - -M32Mix8ISurround&Index&: - Get32Bit8WaveForm - -M32Mix8ISurroundVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 4 - Add [SI+(Index-15)*8+4], EAX ;; 4 - -EndM - - ; Panned output -M32Mix8IPanned Macro Index - -M32Mix8IPanned&Index&: - Get32Bit8WaveForm - -M32Mix8ILeftVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h -M32Mix8IRightVolume&Index& EQU $+3 - IMul EBX, EBX, 8000h - - Sub [SI+(Index-15)*8], EAX ;; 4 - Sub [SI+(Index-15)*8+4], EBX ;; 4 - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - -EndM - -M32Mix16ISingle Macro Index - -M32Mix16ISingle&Index&: - Get32Bit16WaveForm - -M32Mix16ISingleVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 3 - -EndM - -M32Mix16ICentral Macro Index - -M32Mix16ICentral&Index&: - Get32Bit16WaveForm - -M32Mix16ICentralVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 3 - Sub [SI+(Index-15)*8+4], EAX ;; 3 - -EndM - -M32Mix16ISurround Macro Index - -M32Mix16ISurround&Index&: - Get32Bit16WaveForm - -M32Mix16ISurroundVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*8], EAX ;; 3 - Add [SI+(Index-15)*8+4], EAX ;; 3 - -EndM - - ; Panned output -M32Mix16IPanned Macro Index - -M32Mix16IPanned&Index&: - Get32Bit16WaveForm - -M32Mix16ILeftVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h -M32Mix16IRightVolume&Index& EQU $+3 - IMul EBX, EBX, 8000h - - Sub [SI+(Index-15)*8], EAX - Sub [SI+(Index-15)*8+4], EBX - - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix32Single8BitIOffsetTable Label Word - - IndexCounter = 15 - - M32Mix8ISingleOffset Macro Index - DW Offset M32Mix8ISingle&Index& - EndM - - REPT 16 - M32Mix8ISingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Single8BitI - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Single8BitIOffsetTable+BX] - - M32Mix8ISingle 0 - M32Mix8ISingle 1 - M32Mix8ISingle 2 - M32Mix8ISingle 3 - M32Mix8ISingle 4 - M32Mix8ISingle 5 - M32Mix8ISingle 6 - M32Mix8ISingle 7 - M32Mix8ISingle 8 - M32Mix8ISingle 9 - M32Mix8ISingle 10 - M32Mix8ISingle 11 - M32Mix8ISingle 12 - M32Mix8ISingle 13 - M32Mix8ISingle 14 - M32Mix8ISingle 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix8ISingle0 - - Ret - -EndP Mix32Single8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Left8BitI - - Mov AX, [SI+0Eh] - -PreMix32Left8BitI1: - IndexCounter = 0 - - PreMix32SingleMacro Macro Index - Mov Word Ptr [CS:M32Mix8ISingleVolume&Index&], AX - EndM - - REPT 16 - PreMix32SingleMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - Ret - -EndP PreMix32Left8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Right8BitI - - Add MixBufferOffset, MixResolution/8 - Mov AX, [SI+0Ch] - Jmp PreMix32Left8BitI1 - -EndP PreMix32Right8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Central8BitIOffsetTable Label Word - - IndexCounter = 15 - - M32Mix8ICentralOffset Macro Index - DW Offset M32Mix8ICentral&Index& - EndM - - REPT 16 - M32Mix8ICentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Central8BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Central8BitIOffsetTable+BX] - - M32Mix8ICentral 0 - M32Mix8ICentral 1 - M32Mix8ICentral 2 - M32Mix8ICentral 3 - M32Mix8ICentral 4 - M32Mix8ICentral 5 - M32Mix8ICentral 6 - M32Mix8ICentral 7 - M32Mix8ICentral 8 - M32Mix8ICentral 9 - M32Mix8ICentral 10 - M32Mix8ICentral 11 - M32Mix8ICentral 12 - M32Mix8ICentral 13 - M32Mix8ICentral 14 - M32Mix8ICentral 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix8ICentral0 - - Ret - -EndP Mix32Central8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Central8BitI - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMix32CentralMacro Macro Index - Mov Word Ptr [CS:M32Mix8ICentralVolume&Index&], AX - EndM - - REPT 16 - PreMix32CentralMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Central8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Surround8BitIOffsetTable Label Word - - IndexCounter = 15 - - M32Mix8ISurroundOffset Macro Index - DW Offset M32Mix8ISurround&Index& - EndM - - REPT 16 - M32Mix8ISurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Surround8BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Surround8BitIOffsetTable+BX] - - M32Mix8ISurround 0 - M32Mix8ISurround 1 - M32Mix8ISurround 2 - M32Mix8ISurround 3 - M32Mix8ISurround 4 - M32Mix8ISurround 5 - M32Mix8ISurround 6 - M32Mix8ISurround 7 - M32Mix8ISurround 8 - M32Mix8ISurround 9 - M32Mix8ISurround 10 - M32Mix8ISurround 11 - M32Mix8ISurround 12 - M32Mix8ISurround 13 - M32Mix8ISurround 14 - M32Mix8ISurround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix8ISurround0 - - Ret - -EndP Mix32Surround8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Surround8BitI - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMix32SurroundMacro Macro Index - Mov Word Ptr [CS:M32Mix8ISurroundVolume&Index&], AX - EndM - - REPT 16 - PreMix32SurroundMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Surround8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Panned8BitIOffsetTable Label Word - - IndexCounter = 15 - - M32Mix8IPannedOffset Macro Index - DW Offset M32Mix8IPanned&Index& - EndM - - REPT 16 - M32Mix8IPannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Panned8BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Panned8BitIOffsetTable+BX] - - M32Mix8IPanned 0 - M32Mix8IPanned 1 - M32Mix8IPanned 2 - M32Mix8IPanned 3 - M32Mix8IPanned 4 - M32Mix8IPanned 5 - M32Mix8IPanned 6 - M32Mix8IPanned 7 - M32Mix8IPanned 8 - M32Mix8IPanned 9 - M32Mix8IPanned 10 - M32Mix8IPanned 11 - M32Mix8IPanned 12 - M32Mix8IPanned 13 - M32Mix8IPanned 14 - M32Mix8IPanned 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix8IPanned0 - - Ret - -EndP Mix32Panned8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Panned8BitI - - Mov AX, [SI+0Eh] ; Left - Mov BX, [SI+0Ch] ; Right - - IndexCounter = 0 - - PreMix32PannedMacro Macro Index - Mov Word Ptr [CS:M32Mix8ILeftVolume&Index&], AX - Mov Word Ptr [CS:M32Mix8IRightVolume&Index&], BX - EndM - - REPT 16 - PreMix32PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Panned8BitI - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Mix32Single16BitIOffsetTable Label Word - - IndexCounter = 15 - - M32Mix16ISingleOffset Macro Index - DW Offset M32Mix16ISingle&Index& - EndM - - REPT 16 - M32Mix16ISingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Single16BitI - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Single16BitIOffsetTable+BX] - - M32Mix16ISingle 0 - M32Mix16ISingle 1 - M32Mix16ISingle 2 - M32Mix16ISingle 3 - M32Mix16ISingle 4 - M32Mix16ISingle 5 - M32Mix16ISingle 6 - M32Mix16ISingle 7 - M32Mix16ISingle 8 - M32Mix16ISingle 9 - M32Mix16ISingle 10 - M32Mix16ISingle 11 - M32Mix16ISingle 12 - M32Mix16ISingle 13 - M32Mix16ISingle 14 - M32Mix16ISingle 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix16ISingle0 - - Ret - -EndP Mix32Single16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Left16BitI - - Mov AX, [SI+0Eh] ; Left - -PreMix32Left16BitI1: - IndexCounter = 0 - - PreMix32SingleMacro Macro Index - Mov Word Ptr [CS:M32Mix16ISingleVolume&Index&], AX - EndM - - REPT 16 - PreMix32SingleMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Left16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Right16BitI - - Add MixBufferOffset, MixResolution/8 - Mov AX, [SI+0Ch] - Jmp PreMix32Left16BitI1 - - Ret - -EndP PreMix32Right16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Central16BitIOffsetTable Label Word - - IndexCounter = 15 - - M32Mix16ICentralOffset Macro Index - DW Offset M32Mix16ICentral&Index& - EndM - - REPT 16 - M32Mix16ICentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Central16BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Central16BitIOffsetTable+BX] - - M32Mix16ICentral 0 - M32Mix16ICentral 1 - M32Mix16ICentral 2 - M32Mix16ICentral 3 - M32Mix16ICentral 4 - M32Mix16ICentral 5 - M32Mix16ICentral 6 - M32Mix16ICentral 7 - M32Mix16ICentral 8 - M32Mix16ICentral 9 - M32Mix16ICentral 10 - M32Mix16ICentral 11 - M32Mix16ICentral 12 - M32Mix16ICentral 13 - M32Mix16ICentral 14 - M32Mix16ICentral 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix16ICentral0 - - Ret - -EndP Mix32Central16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Central16BitI - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMix32CentralMacro Macro Index - Mov Word Ptr [CS:M32Mix16ICentralVolume&Index&], AX - EndM - - REPT 16 - PreMix32CentralMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Central16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Surround16BitIOffsetTable Label Word - - IndexCounter = 15 - - M32Mix16ISurroundOffset Macro Index - DW Offset M32Mix16ISurround&Index& - EndM - - REPT 16 - M32Mix16ISurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Surround16BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Surround16BitIOffsetTable+BX] - - M32Mix16ISurround 0 - M32Mix16ISurround 1 - M32Mix16ISurround 2 - M32Mix16ISurround 3 - M32Mix16ISurround 4 - M32Mix16ISurround 5 - M32Mix16ISurround 6 - M32Mix16ISurround 7 - M32Mix16ISurround 8 - M32Mix16ISurround 9 - M32Mix16ISurround 10 - M32Mix16ISurround 11 - M32Mix16ISurround 12 - M32Mix16ISurround 13 - M32Mix16ISurround 14 - M32Mix16ISurround 15 - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ M32Mix16ISurround0 - - Ret - -EndP Mix32Surround16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Surround16BitI - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMix32SurroundMacro Macro Index - Mov Word Ptr [CS:M32Mix16ISurroundVolume&Index&], AX - EndM - - REPT 16 - PreMix32SurroundMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Surround16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix32Panned16BitIOffsetTable Label Word - - IndexCounter = 15 - - M32Mix16IPannedOffset Macro Index - DW Offset M32Mix16IPanned&Index& - EndM - - REPT 16 - M32Mix16IPannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix32Panned16BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:Mix32Panned16BitIOffsetTable+BX] - -Pan32Bit16ILoop: - M32Mix16IPanned 0 - M32Mix16IPanned 1 - M32Mix16IPanned 2 - M32Mix16IPanned 3 - M32Mix16IPanned 4 - M32Mix16IPanned 5 - M32Mix16IPanned 6 - M32Mix16IPanned 7 - M32Mix16IPanned 8 - M32Mix16IPanned 9 - M32Mix16IPanned 10 - M32Mix16IPanned 11 - M32Mix16IPanned 12 - M32Mix16IPanned 13 - M32Mix16IPanned 14 - M32Mix16IPanned 15 - - - Add SI, 16*MIXRESOLUTION/4 - Dec LoopCounter - JNZ Pan32Bit16ILoop - - Ret - -EndP Mix32Panned16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix32Panned16BitI - - Mov AX, [SI+0Eh] ; Left - Mov BX, [SI+0Ch] ; Right - - IndexCounter = 0 - - PreMix32PannedMacro Macro Index - Mov Word Ptr [CS:M32Mix16ILeftVolume&Index&], AX - Mov Word Ptr [CS:M32Mix16IRightVolume&Index&], BX - EndM - - REPT 16 - PreMix32PannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix32Panned16BitI - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + +Get32Bit8Waveform Macro + MovSX EBX, Byte Ptr [ES:DI+1] + MovSX EAX, Byte Ptr [ES:DI] + Sub EBX, EAX + IMul EBX, ECX + SAR EBX, 8 + ShL EAX, 8 + Add EBX, EAX + +EndM + +Get32Bit16Waveform Macro + MovSX EBX, Word Ptr [ES:EDI+EDI+2] + MovSX EAX, Word Ptr [ES:EDI+EDI] + Sub EBX, EAX + SAR EBX, 1 + IMul EBX, ECX + SAR EBX, 15 + Add EBX, EAX +EndM + +M32Mix8ISingle Macro Index + +M32Mix8ISingle&Index&: + Get32Bit8WaveForm + +M32Mix8ISingleVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 3 +EndM + +M32Mix8ICentral Macro Index + +M32Mix8ICentral&Index&: + Get32Bit8WaveForm + +M32Mix8ICentralVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 4 + Sub [SI+(Index-15)*8+4], EAX ;; 4 + +EndM + +M32Mix8ISurround Macro Index + +M32Mix8ISurround&Index&: + Get32Bit8WaveForm + +M32Mix8ISurroundVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 4 + Add [SI+(Index-15)*8+4], EAX ;; 4 + +EndM + + ; Panned output +M32Mix8IPanned Macro Index + +M32Mix8IPanned&Index&: + Get32Bit8WaveForm + +M32Mix8ILeftVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h +M32Mix8IRightVolume&Index& EQU $+3 + IMul EBX, EBX, 8000h + + Sub [SI+(Index-15)*8], EAX ;; 4 + Sub [SI+(Index-15)*8+4], EBX ;; 4 + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + +EndM + +M32Mix16ISingle Macro Index + +M32Mix16ISingle&Index&: + Get32Bit16WaveForm + +M32Mix16ISingleVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 3 + +EndM + +M32Mix16ICentral Macro Index + +M32Mix16ICentral&Index&: + Get32Bit16WaveForm + +M32Mix16ICentralVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 3 + Sub [SI+(Index-15)*8+4], EAX ;; 3 + +EndM + +M32Mix16ISurround Macro Index + +M32Mix16ISurround&Index&: + Get32Bit16WaveForm + +M32Mix16ISurroundVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*8], EAX ;; 3 + Add [SI+(Index-15)*8+4], EAX ;; 3 + +EndM + + ; Panned output +M32Mix16IPanned Macro Index + +M32Mix16IPanned&Index&: + Get32Bit16WaveForm + +M32Mix16ILeftVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h +M32Mix16IRightVolume&Index& EQU $+3 + IMul EBX, EBX, 8000h + + Sub [SI+(Index-15)*8], EAX + Sub [SI+(Index-15)*8+4], EBX + + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix32Single8BitIOffsetTable Label Word + + IndexCounter = 15 + + M32Mix8ISingleOffset Macro Index + DW Offset M32Mix8ISingle&Index& + EndM + + REPT 16 + M32Mix8ISingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Single8BitI + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Single8BitIOffsetTable+BX] + + M32Mix8ISingle 0 + M32Mix8ISingle 1 + M32Mix8ISingle 2 + M32Mix8ISingle 3 + M32Mix8ISingle 4 + M32Mix8ISingle 5 + M32Mix8ISingle 6 + M32Mix8ISingle 7 + M32Mix8ISingle 8 + M32Mix8ISingle 9 + M32Mix8ISingle 10 + M32Mix8ISingle 11 + M32Mix8ISingle 12 + M32Mix8ISingle 13 + M32Mix8ISingle 14 + M32Mix8ISingle 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix8ISingle0 + + Ret + +EndP Mix32Single8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Left8BitI + + Mov AX, [SI+0Eh] + +PreMix32Left8BitI1: + IndexCounter = 0 + + PreMix32SingleMacro Macro Index + Mov Word Ptr [CS:M32Mix8ISingleVolume&Index&], AX + EndM + + REPT 16 + PreMix32SingleMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + Ret + +EndP PreMix32Left8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Right8BitI + + Add MixBufferOffset, MixResolution/8 + Mov AX, [SI+0Ch] + Jmp PreMix32Left8BitI1 + +EndP PreMix32Right8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Central8BitIOffsetTable Label Word + + IndexCounter = 15 + + M32Mix8ICentralOffset Macro Index + DW Offset M32Mix8ICentral&Index& + EndM + + REPT 16 + M32Mix8ICentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Central8BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Central8BitIOffsetTable+BX] + + M32Mix8ICentral 0 + M32Mix8ICentral 1 + M32Mix8ICentral 2 + M32Mix8ICentral 3 + M32Mix8ICentral 4 + M32Mix8ICentral 5 + M32Mix8ICentral 6 + M32Mix8ICentral 7 + M32Mix8ICentral 8 + M32Mix8ICentral 9 + M32Mix8ICentral 10 + M32Mix8ICentral 11 + M32Mix8ICentral 12 + M32Mix8ICentral 13 + M32Mix8ICentral 14 + M32Mix8ICentral 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix8ICentral0 + + Ret + +EndP Mix32Central8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Central8BitI + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMix32CentralMacro Macro Index + Mov Word Ptr [CS:M32Mix8ICentralVolume&Index&], AX + EndM + + REPT 16 + PreMix32CentralMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Central8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Surround8BitIOffsetTable Label Word + + IndexCounter = 15 + + M32Mix8ISurroundOffset Macro Index + DW Offset M32Mix8ISurround&Index& + EndM + + REPT 16 + M32Mix8ISurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Surround8BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Surround8BitIOffsetTable+BX] + + M32Mix8ISurround 0 + M32Mix8ISurround 1 + M32Mix8ISurround 2 + M32Mix8ISurround 3 + M32Mix8ISurround 4 + M32Mix8ISurround 5 + M32Mix8ISurround 6 + M32Mix8ISurround 7 + M32Mix8ISurround 8 + M32Mix8ISurround 9 + M32Mix8ISurround 10 + M32Mix8ISurround 11 + M32Mix8ISurround 12 + M32Mix8ISurround 13 + M32Mix8ISurround 14 + M32Mix8ISurround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix8ISurround0 + + Ret + +EndP Mix32Surround8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Surround8BitI + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMix32SurroundMacro Macro Index + Mov Word Ptr [CS:M32Mix8ISurroundVolume&Index&], AX + EndM + + REPT 16 + PreMix32SurroundMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Surround8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Panned8BitIOffsetTable Label Word + + IndexCounter = 15 + + M32Mix8IPannedOffset Macro Index + DW Offset M32Mix8IPanned&Index& + EndM + + REPT 16 + M32Mix8IPannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Panned8BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Panned8BitIOffsetTable+BX] + + M32Mix8IPanned 0 + M32Mix8IPanned 1 + M32Mix8IPanned 2 + M32Mix8IPanned 3 + M32Mix8IPanned 4 + M32Mix8IPanned 5 + M32Mix8IPanned 6 + M32Mix8IPanned 7 + M32Mix8IPanned 8 + M32Mix8IPanned 9 + M32Mix8IPanned 10 + M32Mix8IPanned 11 + M32Mix8IPanned 12 + M32Mix8IPanned 13 + M32Mix8IPanned 14 + M32Mix8IPanned 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix8IPanned0 + + Ret + +EndP Mix32Panned8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Panned8BitI + + Mov AX, [SI+0Eh] ; Left + Mov BX, [SI+0Ch] ; Right + + IndexCounter = 0 + + PreMix32PannedMacro Macro Index + Mov Word Ptr [CS:M32Mix8ILeftVolume&Index&], AX + Mov Word Ptr [CS:M32Mix8IRightVolume&Index&], BX + EndM + + REPT 16 + PreMix32PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Panned8BitI + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Mix32Single16BitIOffsetTable Label Word + + IndexCounter = 15 + + M32Mix16ISingleOffset Macro Index + DW Offset M32Mix16ISingle&Index& + EndM + + REPT 16 + M32Mix16ISingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Single16BitI + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Single16BitIOffsetTable+BX] + + M32Mix16ISingle 0 + M32Mix16ISingle 1 + M32Mix16ISingle 2 + M32Mix16ISingle 3 + M32Mix16ISingle 4 + M32Mix16ISingle 5 + M32Mix16ISingle 6 + M32Mix16ISingle 7 + M32Mix16ISingle 8 + M32Mix16ISingle 9 + M32Mix16ISingle 10 + M32Mix16ISingle 11 + M32Mix16ISingle 12 + M32Mix16ISingle 13 + M32Mix16ISingle 14 + M32Mix16ISingle 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix16ISingle0 + + Ret + +EndP Mix32Single16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Left16BitI + + Mov AX, [SI+0Eh] ; Left + +PreMix32Left16BitI1: + IndexCounter = 0 + + PreMix32SingleMacro Macro Index + Mov Word Ptr [CS:M32Mix16ISingleVolume&Index&], AX + EndM + + REPT 16 + PreMix32SingleMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Left16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Right16BitI + + Add MixBufferOffset, MixResolution/8 + Mov AX, [SI+0Ch] + Jmp PreMix32Left16BitI1 + + Ret + +EndP PreMix32Right16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Central16BitIOffsetTable Label Word + + IndexCounter = 15 + + M32Mix16ICentralOffset Macro Index + DW Offset M32Mix16ICentral&Index& + EndM + + REPT 16 + M32Mix16ICentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Central16BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Central16BitIOffsetTable+BX] + + M32Mix16ICentral 0 + M32Mix16ICentral 1 + M32Mix16ICentral 2 + M32Mix16ICentral 3 + M32Mix16ICentral 4 + M32Mix16ICentral 5 + M32Mix16ICentral 6 + M32Mix16ICentral 7 + M32Mix16ICentral 8 + M32Mix16ICentral 9 + M32Mix16ICentral 10 + M32Mix16ICentral 11 + M32Mix16ICentral 12 + M32Mix16ICentral 13 + M32Mix16ICentral 14 + M32Mix16ICentral 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix16ICentral0 + + Ret + +EndP Mix32Central16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Central16BitI + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMix32CentralMacro Macro Index + Mov Word Ptr [CS:M32Mix16ICentralVolume&Index&], AX + EndM + + REPT 16 + PreMix32CentralMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Central16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Surround16BitIOffsetTable Label Word + + IndexCounter = 15 + + M32Mix16ISurroundOffset Macro Index + DW Offset M32Mix16ISurround&Index& + EndM + + REPT 16 + M32Mix16ISurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Surround16BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Surround16BitIOffsetTable+BX] + + M32Mix16ISurround 0 + M32Mix16ISurround 1 + M32Mix16ISurround 2 + M32Mix16ISurround 3 + M32Mix16ISurround 4 + M32Mix16ISurround 5 + M32Mix16ISurround 6 + M32Mix16ISurround 7 + M32Mix16ISurround 8 + M32Mix16ISurround 9 + M32Mix16ISurround 10 + M32Mix16ISurround 11 + M32Mix16ISurround 12 + M32Mix16ISurround 13 + M32Mix16ISurround 14 + M32Mix16ISurround 15 + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ M32Mix16ISurround0 + + Ret + +EndP Mix32Surround16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Surround16BitI + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMix32SurroundMacro Macro Index + Mov Word Ptr [CS:M32Mix16ISurroundVolume&Index&], AX + EndM + + REPT 16 + PreMix32SurroundMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Surround16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix32Panned16BitIOffsetTable Label Word + + IndexCounter = 15 + + M32Mix16IPannedOffset Macro Index + DW Offset M32Mix16IPanned&Index& + EndM + + REPT 16 + M32Mix16IPannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix32Panned16BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:Mix32Panned16BitIOffsetTable+BX] + +Pan32Bit16ILoop: + M32Mix16IPanned 0 + M32Mix16IPanned 1 + M32Mix16IPanned 2 + M32Mix16IPanned 3 + M32Mix16IPanned 4 + M32Mix16IPanned 5 + M32Mix16IPanned 6 + M32Mix16IPanned 7 + M32Mix16IPanned 8 + M32Mix16IPanned 9 + M32Mix16IPanned 10 + M32Mix16IPanned 11 + M32Mix16IPanned 12 + M32Mix16IPanned 13 + M32Mix16IPanned 14 + M32Mix16IPanned 15 + + + Add SI, 16*MIXRESOLUTION/4 + Dec LoopCounter + JNZ Pan32Bit16ILoop + + Ret + +EndP Mix32Panned16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix32Panned16BitI + + Mov AX, [SI+0Eh] ; Left + Mov BX, [SI+0Ch] ; Right + + IndexCounter = 0 + + PreMix32PannedMacro Macro Index + Mov Word Ptr [CS:M32Mix16ILeftVolume&Index&], AX + Mov Word Ptr [CS:M32Mix16IRightVolume&Index&], BX + EndM + + REPT 16 + PreMix32PannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix32Panned16BitI + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M32BITM.INC b/SoundDrivers/M32BITM.INC index 8a12847..27c22e9 100755 --- a/SoundDrivers/M32BITM.INC +++ b/SoundDrivers/M32BITM.INC @@ -1,11 +1,11 @@ -; 8 bit tables - - DW Offset MixNoLoop, PreM32BitMPanned, MFS8Bit, MBS8Bit, M32Bit8MPanned - DW Offset MixForwardsLoop, PreM32BitMPanned, MFS8Bit, MBS8Bit, M32Bit8MPanned - DW Offset MixPingPongLoop, PreM32BitMPanned, MFS8Bit, MBS8Bit, M32Bit8MPanned - -; 16 bit - - DW Offset MixNoLoop, PreM32BitMPanned, MFS16Bit, MBS16Bit, M32Bit16MPanned - DW Offset MixForwardsLoop, PreM32BitMPanned, MFS16Bit, MBS16Bit, M32Bit16MPanned - DW Offset MixPingPongLoop, PreM32BitMPanned, MFS16Bit, MBS16Bit, M32Bit16MPanned +; 8 bit tables + + DW Offset MixNoLoop, PreM32BitMPanned, MFS8Bit, MBS8Bit, M32Bit8MPanned + DW Offset MixForwardsLoop, PreM32BitMPanned, MFS8Bit, MBS8Bit, M32Bit8MPanned + DW Offset MixPingPongLoop, PreM32BitMPanned, MFS8Bit, MBS8Bit, M32Bit8MPanned + +; 16 bit + + DW Offset MixNoLoop, PreM32BitMPanned, MFS16Bit, MBS16Bit, M32Bit16MPanned + DW Offset MixForwardsLoop, PreM32BitMPanned, MFS16Bit, MBS16Bit, M32Bit16MPanned + DW Offset MixPingPongLoop, PreM32BitMPanned, MFS16Bit, MBS16Bit, M32Bit16MPanned diff --git a/SoundDrivers/M32BITM.MIX b/SoundDrivers/M32BITM.MIX index 33f837a..9d6a96a 100755 --- a/SoundDrivers/M32BITM.MIX +++ b/SoundDrivers/M32BITM.MIX @@ -1,502 +1,502 @@ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MONITORPERFORMANCE = 0 - -ALIGN 16 - -M32BitMVolumeData DW 0, 0, 0, 0 - -IF MONITORPERFORMANCE -M32BitMCounter8BitTicksLow DD 0 -M32BitMCounter8BitTicksHigh DD 0 -M32BitMCounter16BitTicksLow DD 0 -M32BitMCounter16BitTicksHigh DD 0 -M32BitMCounter8BitLow DW 0 -M32BitMCounter8BitHigh DW 0 -M32BitMCounter16BitLow DW 0 -M32BitMCounter16BitHigh DW 0 -ENDIF - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32Bit16MPanned - -; AX = number to mix -; CX = error -; DX = deltaoffset -; BP = deltaerror -; DS:SI = 32-bit output buffer -; ES:EDI+EDI = sample location -; MM6 = L/R volumes -; MM7 = PXor mask - -IF MONITORPERFORMANCE - Push EAX - Push EDX - - Add CS:M32BitMCounter16BitLow, AX - AdC CS:M32BitMCounter16BitHigh, 0 - - RdTSC - Sub CS:M32BitMCounter16BitTicksLow, EAX - SBB CS:M32BitMCounter16BitTicksHigh, EDX - - Pop EDX - Pop EAX -ENDIF - - Mov BX, DI - Add BX, BX - -M32Bit16MPanned1: ; Mix 1 sample - Test AL, 1 - JZ M32Bit16MPanned2 - - Push AX - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:0], AX - Mov BX, DI - - MovQ MM0, [DS:0] - Add BX, BX - - PUnpckLWD MM0, MM0 - MovQ MM2, MM6 - PMulLW MM2, MM0 - PMulHW MM0, MM6 - PUnpckLWD MM2, MM0 - PAddD MM2, [SI] - MovQM [SI], MM2 - - Add SI, 8 - Pop AX - -M32Bit16MPanned2: ; Mix 2 samples - Test AL, 2 - JZ M32Bit16MPanned3 - - Push AX - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:0], AX - Mov BX, DI - Add BX, BX - Add CX, BP - AdC DI, DX - Mov AX, [ES:BX] - Mov BX, DI - Mov [DS:2], AX - Add BX, BX - - MovQ MM0, [DS:0] - PUnpckLWD MM0, MM0 - MovQ MM2, MM6 - PMulLW MM2, MM0 - PMulHW MM0, MM6 - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - PUnpckHWD MM4, MM0 - PAddD MM2, [SI] - PAddD MM4, [SI+8] - MovQM [SI], MM2 - MovQM [SI+8], MM4 - - Add SI, 10h - Pop AX - -M32Bit16MPanned3: - ShR AX, 2 - JZ M32Bit16MPannedEnd - - Mov Word Ptr [DS:20h], AX - - Mov AX, [ES:BX] - Add CX, BP - AdC DI, DX - Mov [DS:0], AX - Mov BX, DI - Add BX, BX - - Mov AX, [ES:BX] - Add CX, BP - AdC DI, DX - Mov [DS:2], AX - Mov BX, DI - Add BX, BX - - Mov AX, [ES:BX] - Add CX, BP - AdC DI, DX - Mov [DS:0Ch], AX - Mov BX, DI - Add BX, BX - - Mov AX, [ES:BX] - Add CX, BP - AdC DI, DX - Mov [DS:0Eh], AX - Mov BX, DI - Add BX, BX - - Dec Word Ptr [DS:20h] - JZ M32Bit16MPanned5 - -M32Bit16MPanned4: - MovQ MM0, [DS:0] - MovQ MM2, MM6 - MovQ MM1, [DS:8] - PUnpckLWD MM0, MM0 - - PMulLW MM2, MM0 - PUnpckHWD MM1, MM1 - - PMulHW MM0, MM6 - MovQ MM3, MM6 - - Mov AX, [ES:BX] - Add CX, BP - AdC DI, DX - Mov [DS:0], AX - Mov BX, DI - Add BX, BX - - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - - PAddD MM2, [SI] - PUnpckHWD MM4, MM0 - - PAddD MM4, [SI+8] - PMulLW MM3, MM1 - - MovQM [SI], MM2 - PMulHW MM1, MM6 - - Mov AX, [ES:BX] - Add CX, BP - AdC DI, DX - Mov [DS:2], AX - Mov BX, DI - Add BX, BX - - MovQM [SI+8], MM4 - MovQ MM5, MM3 - - MovQ MM0, [SI+18h] - PUnpckLWD MM3, MM1 - PAddD MM3, [SI+10h] - PUnpckHWD MM5, MM1 - MovQM [SI+10h], MM3 - PAddD MM5, MM0 - - Mov AX, [ES:BX] - Add CX, BP - AdC DI, DX - Mov [DS:0Ch], AX - Mov BX, DI - Add BX, BX - - MovQM [SI+18h], MM5 - - Mov AX, [ES:BX] - Add CX, BP - AdC DI, DX - Mov [DS:0Eh], AX - Mov BX, DI - Add BX, BX - - Add SI, 20h - - Dec Word Ptr [DS:20h] - JNZ M32Bit16MPanned4 - -M32Bit16MPanned5: - MovQ MM0, [DS:0] - MovQ MM2, MM6 - - MovQ MM1, [DS:8] - PUnpckLWD MM0, MM0 - - PMulLW MM2, MM0 - MovQ MM3, MM6 - - PMulHW MM0, MM6 - PUnpckHWD MM1, MM1 - - MovQ MM4, MM2 - PMulLW MM3, MM1 - - PUnpckLWD MM2, MM0 - PMulHW MM1, MM6 - - PAddD MM2, [SI] - PUnpckHWD MM4, MM0 - - PAddD MM4, [SI+8] - MovQ MM5, MM3 - - MovQM [SI], MM2 - PUnpckLWD MM3, MM1 - - MovQM [SI+8], MM4 - PUnpckHWD MM5, MM1 - - PAddD MM3, [SI+10h] - PAddD MM5, [SI+18h] - - MovQM [SI+10h], MM3 - MovQM [SI+18h], MM5 - -M32Bit16MPannedEnd: -IF MONITORPERFORMANCE - RdTSC - Add CS:M32BitMCounter16BitTicksLow, EAX - AdC CS:M32BitMCounter16BitTicksHigh, EDX -ENDIF - Ret - -EndP M32Bit16MPanned - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32Bit8MPanned - -; AX = number to mix -; CX = error -; DX = deltaoffset -; BP = deltaerror -; DS:SI = 32-bit output buffer -; ES:DI = sample location -; MM6 = L/R volumes -; MM7 = PXor mask - -IF MONITORPERFORMANCE - Push EAX - Push EDX - - Add CS:M32BitMCounter8BitLow, AX - AdC CS:M32BitMCounter8BitHigh, 0 - - RdTSC - Sub CS:M32BitMCounter8BitTicksLow, EAX - SBB CS:M32BitMCounter8BitTicksHigh, EDX - - Pop EDX - Pop EAX -ENDIF - - Mov BX, AX - And AX, 3 - JZ M32Bit8MPanned3 - -M32Bit8MPanned1: ; Mix 1 sample - Test AL, 1 - JZ M32Bit8MPanned2 - - Xor AX, AX - Add ERROR, DELTAERROR - Mov AH, [ES:DI] - AdC DI, DELTAOFFSET - Mov [DS:0], AX - - MovQ MM0, [DS:0] - PUnpckLWD MM0, MM0 - MovQ MM2, MM6 - PMulLW MM2, MM0 - PMulHW MM0, MM6 - PUnpckLWD MM2, MM0 - PAddD MM2, [SI] - MovQM [SI], MM2 - - Add SI, 8 - -M32Bit8MPanned2: ; Mix 2 samples - Test BL, 2 - JZ M32Bit8MPanned3 - - Xor AX, AX - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0], AX - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:2], AX - - MovQ MM0, [DS:0] - PUnpckLWD MM0, MM0 - MovQ MM2, MM6 - PMulLW MM2, MM0 - PMulHW MM0, MM6 - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - PUnpckHWD MM4, MM0 - PAddD MM2, [SI] - PAddD MM4, [SI+8] - MovQM [SI], MM2 - MovQM [SI+8], MM4 - - Add SI, 10h - -M32Bit8MPanned3: - Xor AX, AX - ShR BX, 2 - JZ M32Bit8MPannedEnd - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0], AX - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:2], AX - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0Ch], AX - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0Eh], AX - - Dec BX - JZ M32Bit8MPanned5 - -M32Bit8MPanned4: - MovQ MM0, [DS:0] - MovQ MM2, MM6 - MovQ MM1, [DS:8] - PUnpckLWD MM0, MM0 - - PMulLW MM2, MM0 - PUnpckHWD MM1, MM1 - - PMulHW MM0, MM6 - MovQ MM3, MM6 - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0], AX - - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - - PAddD MM2, [SI] - PUnpckHWD MM4, MM0 - - PAddD MM4, [SI+8] - PMulLW MM3, MM1 - - MovQM [SI], MM2 - PMulHW MM1, MM6 - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:2], AX - - MovQM [SI+8], MM4 - MovQ MM5, MM3 - - MovQ MM0, [SI+18h] - PUnpckLWD MM3, MM1 - PAddD MM3, [SI+10h] - PUnpckHWD MM5, MM1 - MovQM [SI+10h], MM3 - PAddD MM5, MM0 - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0Ch], AX - - MovQM [SI+18h], MM5 - - Mov AH, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0Eh], AX - - Add SI, 20h - - Dec BX - JNZ M32Bit8MPanned4 - -M32Bit8MPanned5: - MovQ MM0, [DS:0] - MovQ MM2, MM6 - - MovQ MM1, [DS:8] - PUnpckLWD MM0, MM0 - - PMulLW MM2, MM0 - MovQ MM3, MM6 - - PMulHW MM0, MM6 - PUnpckHWD MM1, MM1 - - MovQ MM4, MM2 - PMulLW MM3, MM1 - - PUnpckLWD MM2, MM0 - PMulHW MM1, MM6 - - PAddD MM2, [SI] - PUnpckHWD MM4, MM0 - - PAddD MM4, [SI+8] - MovQ MM5, MM3 - - MovQM [SI], MM2 - PUnpckLWD MM3, MM1 - - MovQM [SI+8], MM4 - PUnpckHWD MM5, MM1 - - PAddD MM3, [SI+10h] - PAddD MM5, [SI+18h] - - MovQM [SI+10h], MM3 - MovQM [SI+18h], MM5 - -M32Bit8MPannedEnd: -IF MONITORPERFORMANCE - RdTSC - Add CS:M32BitMCounter8BitTicksLow, EAX - AdC CS:M32BitMCounter8BitTicksHigh, EDX -ENDIF - Ret - -EndP M32Bit8MPanned - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreM32BitMPanned - Assume DS:Driver - - Mov EAX, [SI+0Ch] ; LEAX = left vol, HEAX = right vol - Mov [DWord Ptr CS:M32BitMVolumeData], EAX - Mov [DWord Ptr CS:M32BitMVolumeData+4], EAX - - SegCS MovQ MM6, M32BitMVolumeData - - Ret - -EndP PreM32BitMPanned - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MONITORPERFORMANCE = 0 + +ALIGN 16 + +M32BitMVolumeData DW 0, 0, 0, 0 + +IF MONITORPERFORMANCE +M32BitMCounter8BitTicksLow DD 0 +M32BitMCounter8BitTicksHigh DD 0 +M32BitMCounter16BitTicksLow DD 0 +M32BitMCounter16BitTicksHigh DD 0 +M32BitMCounter8BitLow DW 0 +M32BitMCounter8BitHigh DW 0 +M32BitMCounter16BitLow DW 0 +M32BitMCounter16BitHigh DW 0 +ENDIF + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32Bit16MPanned + +; AX = number to mix +; CX = error +; DX = deltaoffset +; BP = deltaerror +; DS:SI = 32-bit output buffer +; ES:EDI+EDI = sample location +; MM6 = L/R volumes +; MM7 = PXor mask + +IF MONITORPERFORMANCE + Push EAX + Push EDX + + Add CS:M32BitMCounter16BitLow, AX + AdC CS:M32BitMCounter16BitHigh, 0 + + RdTSC + Sub CS:M32BitMCounter16BitTicksLow, EAX + SBB CS:M32BitMCounter16BitTicksHigh, EDX + + Pop EDX + Pop EAX +ENDIF + + Mov BX, DI + Add BX, BX + +M32Bit16MPanned1: ; Mix 1 sample + Test AL, 1 + JZ M32Bit16MPanned2 + + Push AX + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:0], AX + Mov BX, DI + + MovQ MM0, [DS:0] + Add BX, BX + + PUnpckLWD MM0, MM0 + MovQ MM2, MM6 + PMulLW MM2, MM0 + PMulHW MM0, MM6 + PUnpckLWD MM2, MM0 + PAddD MM2, [SI] + MovQM [SI], MM2 + + Add SI, 8 + Pop AX + +M32Bit16MPanned2: ; Mix 2 samples + Test AL, 2 + JZ M32Bit16MPanned3 + + Push AX + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:0], AX + Mov BX, DI + Add BX, BX + Add CX, BP + AdC DI, DX + Mov AX, [ES:BX] + Mov BX, DI + Mov [DS:2], AX + Add BX, BX + + MovQ MM0, [DS:0] + PUnpckLWD MM0, MM0 + MovQ MM2, MM6 + PMulLW MM2, MM0 + PMulHW MM0, MM6 + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + PUnpckHWD MM4, MM0 + PAddD MM2, [SI] + PAddD MM4, [SI+8] + MovQM [SI], MM2 + MovQM [SI+8], MM4 + + Add SI, 10h + Pop AX + +M32Bit16MPanned3: + ShR AX, 2 + JZ M32Bit16MPannedEnd + + Mov Word Ptr [DS:20h], AX + + Mov AX, [ES:BX] + Add CX, BP + AdC DI, DX + Mov [DS:0], AX + Mov BX, DI + Add BX, BX + + Mov AX, [ES:BX] + Add CX, BP + AdC DI, DX + Mov [DS:2], AX + Mov BX, DI + Add BX, BX + + Mov AX, [ES:BX] + Add CX, BP + AdC DI, DX + Mov [DS:0Ch], AX + Mov BX, DI + Add BX, BX + + Mov AX, [ES:BX] + Add CX, BP + AdC DI, DX + Mov [DS:0Eh], AX + Mov BX, DI + Add BX, BX + + Dec Word Ptr [DS:20h] + JZ M32Bit16MPanned5 + +M32Bit16MPanned4: + MovQ MM0, [DS:0] + MovQ MM2, MM6 + MovQ MM1, [DS:8] + PUnpckLWD MM0, MM0 + + PMulLW MM2, MM0 + PUnpckHWD MM1, MM1 + + PMulHW MM0, MM6 + MovQ MM3, MM6 + + Mov AX, [ES:BX] + Add CX, BP + AdC DI, DX + Mov [DS:0], AX + Mov BX, DI + Add BX, BX + + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + + PAddD MM2, [SI] + PUnpckHWD MM4, MM0 + + PAddD MM4, [SI+8] + PMulLW MM3, MM1 + + MovQM [SI], MM2 + PMulHW MM1, MM6 + + Mov AX, [ES:BX] + Add CX, BP + AdC DI, DX + Mov [DS:2], AX + Mov BX, DI + Add BX, BX + + MovQM [SI+8], MM4 + MovQ MM5, MM3 + + MovQ MM0, [SI+18h] + PUnpckLWD MM3, MM1 + PAddD MM3, [SI+10h] + PUnpckHWD MM5, MM1 + MovQM [SI+10h], MM3 + PAddD MM5, MM0 + + Mov AX, [ES:BX] + Add CX, BP + AdC DI, DX + Mov [DS:0Ch], AX + Mov BX, DI + Add BX, BX + + MovQM [SI+18h], MM5 + + Mov AX, [ES:BX] + Add CX, BP + AdC DI, DX + Mov [DS:0Eh], AX + Mov BX, DI + Add BX, BX + + Add SI, 20h + + Dec Word Ptr [DS:20h] + JNZ M32Bit16MPanned4 + +M32Bit16MPanned5: + MovQ MM0, [DS:0] + MovQ MM2, MM6 + + MovQ MM1, [DS:8] + PUnpckLWD MM0, MM0 + + PMulLW MM2, MM0 + MovQ MM3, MM6 + + PMulHW MM0, MM6 + PUnpckHWD MM1, MM1 + + MovQ MM4, MM2 + PMulLW MM3, MM1 + + PUnpckLWD MM2, MM0 + PMulHW MM1, MM6 + + PAddD MM2, [SI] + PUnpckHWD MM4, MM0 + + PAddD MM4, [SI+8] + MovQ MM5, MM3 + + MovQM [SI], MM2 + PUnpckLWD MM3, MM1 + + MovQM [SI+8], MM4 + PUnpckHWD MM5, MM1 + + PAddD MM3, [SI+10h] + PAddD MM5, [SI+18h] + + MovQM [SI+10h], MM3 + MovQM [SI+18h], MM5 + +M32Bit16MPannedEnd: +IF MONITORPERFORMANCE + RdTSC + Add CS:M32BitMCounter16BitTicksLow, EAX + AdC CS:M32BitMCounter16BitTicksHigh, EDX +ENDIF + Ret + +EndP M32Bit16MPanned + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32Bit8MPanned + +; AX = number to mix +; CX = error +; DX = deltaoffset +; BP = deltaerror +; DS:SI = 32-bit output buffer +; ES:DI = sample location +; MM6 = L/R volumes +; MM7 = PXor mask + +IF MONITORPERFORMANCE + Push EAX + Push EDX + + Add CS:M32BitMCounter8BitLow, AX + AdC CS:M32BitMCounter8BitHigh, 0 + + RdTSC + Sub CS:M32BitMCounter8BitTicksLow, EAX + SBB CS:M32BitMCounter8BitTicksHigh, EDX + + Pop EDX + Pop EAX +ENDIF + + Mov BX, AX + And AX, 3 + JZ M32Bit8MPanned3 + +M32Bit8MPanned1: ; Mix 1 sample + Test AL, 1 + JZ M32Bit8MPanned2 + + Xor AX, AX + Add ERROR, DELTAERROR + Mov AH, [ES:DI] + AdC DI, DELTAOFFSET + Mov [DS:0], AX + + MovQ MM0, [DS:0] + PUnpckLWD MM0, MM0 + MovQ MM2, MM6 + PMulLW MM2, MM0 + PMulHW MM0, MM6 + PUnpckLWD MM2, MM0 + PAddD MM2, [SI] + MovQM [SI], MM2 + + Add SI, 8 + +M32Bit8MPanned2: ; Mix 2 samples + Test BL, 2 + JZ M32Bit8MPanned3 + + Xor AX, AX + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0], AX + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:2], AX + + MovQ MM0, [DS:0] + PUnpckLWD MM0, MM0 + MovQ MM2, MM6 + PMulLW MM2, MM0 + PMulHW MM0, MM6 + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + PUnpckHWD MM4, MM0 + PAddD MM2, [SI] + PAddD MM4, [SI+8] + MovQM [SI], MM2 + MovQM [SI+8], MM4 + + Add SI, 10h + +M32Bit8MPanned3: + Xor AX, AX + ShR BX, 2 + JZ M32Bit8MPannedEnd + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0], AX + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:2], AX + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0Ch], AX + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0Eh], AX + + Dec BX + JZ M32Bit8MPanned5 + +M32Bit8MPanned4: + MovQ MM0, [DS:0] + MovQ MM2, MM6 + MovQ MM1, [DS:8] + PUnpckLWD MM0, MM0 + + PMulLW MM2, MM0 + PUnpckHWD MM1, MM1 + + PMulHW MM0, MM6 + MovQ MM3, MM6 + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0], AX + + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + + PAddD MM2, [SI] + PUnpckHWD MM4, MM0 + + PAddD MM4, [SI+8] + PMulLW MM3, MM1 + + MovQM [SI], MM2 + PMulHW MM1, MM6 + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:2], AX + + MovQM [SI+8], MM4 + MovQ MM5, MM3 + + MovQ MM0, [SI+18h] + PUnpckLWD MM3, MM1 + PAddD MM3, [SI+10h] + PUnpckHWD MM5, MM1 + MovQM [SI+10h], MM3 + PAddD MM5, MM0 + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0Ch], AX + + MovQM [SI+18h], MM5 + + Mov AH, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0Eh], AX + + Add SI, 20h + + Dec BX + JNZ M32Bit8MPanned4 + +M32Bit8MPanned5: + MovQ MM0, [DS:0] + MovQ MM2, MM6 + + MovQ MM1, [DS:8] + PUnpckLWD MM0, MM0 + + PMulLW MM2, MM0 + MovQ MM3, MM6 + + PMulHW MM0, MM6 + PUnpckHWD MM1, MM1 + + MovQ MM4, MM2 + PMulLW MM3, MM1 + + PUnpckLWD MM2, MM0 + PMulHW MM1, MM6 + + PAddD MM2, [SI] + PUnpckHWD MM4, MM0 + + PAddD MM4, [SI+8] + MovQ MM5, MM3 + + MovQM [SI], MM2 + PUnpckLWD MM3, MM1 + + MovQM [SI+8], MM4 + PUnpckHWD MM5, MM1 + + PAddD MM3, [SI+10h] + PAddD MM5, [SI+18h] + + MovQM [SI+10h], MM3 + MovQM [SI+18h], MM5 + +M32Bit8MPannedEnd: +IF MONITORPERFORMANCE + RdTSC + Add CS:M32BitMCounter8BitTicksLow, EAX + AdC CS:M32BitMCounter8BitTicksHigh, EDX +ENDIF + Ret + +EndP M32Bit8MPanned + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreM32BitMPanned + Assume DS:Driver + + Mov EAX, [SI+0Ch] ; LEAX = left vol, HEAX = right vol + Mov [DWord Ptr CS:M32BitMVolumeData], EAX + Mov [DWord Ptr CS:M32BitMVolumeData+4], EAX + + SegCS MovQ MM6, M32BitMVolumeData + + Ret + +EndP PreM32BitMPanned + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M32BITMF.INC b/SoundDrivers/M32BITMF.INC index 3f83cf2..17eaa6c 100755 --- a/SoundDrivers/M32BITMF.INC +++ b/SoundDrivers/M32BITMF.INC @@ -1,12 +1,12 @@ -; 8 bit tables - - DW Offset MixNoLoop, PreM32BitMFPanned, MFS8Bit, MBS8Bit, M32Bit8MFPanned - DW Offset MixForwardsLoop, PreM32BitMFPanned, MFS8Bit, MBS8Bit, M32Bit8MFPanned - DW Offset MixPingPongLoop, PreM32BitMFPanned, MFS8Bit, MBS8Bit, M32Bit8MFPanned - -; 16 bit tables - - DW Offset MixNoLoop, PreM32BitMFPanned, MFS16Bit, MBS16Bit, M32Bit16MFPanned - DW Offset MixForwardsLoop, PreM32BitMFPanned, MFS16Bit, MBS16Bit, M32Bit16MFPanned - DW Offset MixPingPongLoop, PreM32BitMFPanned, MFS16Bit, MBS16Bit, M32Bit16MFPanned - +; 8 bit tables + + DW Offset MixNoLoop, PreM32BitMFPanned, MFS8Bit, MBS8Bit, M32Bit8MFPanned + DW Offset MixForwardsLoop, PreM32BitMFPanned, MFS8Bit, MBS8Bit, M32Bit8MFPanned + DW Offset MixPingPongLoop, PreM32BitMFPanned, MFS8Bit, MBS8Bit, M32Bit8MFPanned + +; 16 bit tables + + DW Offset MixNoLoop, PreM32BitMFPanned, MFS16Bit, MBS16Bit, M32Bit16MFPanned + DW Offset MixForwardsLoop, PreM32BitMFPanned, MFS16Bit, MBS16Bit, M32Bit16MFPanned + DW Offset MixPingPongLoop, PreM32BitMFPanned, MFS16Bit, MBS16Bit, M32Bit16MFPanned + diff --git a/SoundDrivers/M32BITMF.MIX b/SoundDrivers/M32BITMF.MIX index e3bb9c3..1efd488 100755 --- a/SoundDrivers/M32BITMF.MIX +++ b/SoundDrivers/M32BITMF.MIX @@ -1,708 +1,708 @@ - -; -; Resonant filter mixing routines -; - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MONITORPERFORMANCE = 0 -RAMPSPEED = 7 -RAMPCOMPENSATE = 63 - -IF MONITORPERFORMANCE -ALIGN 16 -M32BitMICounter8BitTicksLow DD 0 -M32BitMICounter8BitTicksHigh DD 0 -M32BitMICounter16BitTicksLow DD 0 -M32BitMICounter16BitTicksHigh DD 0 -M32BitMICounter8BitLow DW 0 -M32BitMICounter8BitHigh DW 0 -M32BitMICounter16BitLow DW 0 -M32BitMICounter16BitHigh DW 0 -ENDIF - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32Bit16MFPanned - -; AX = number to mix -; CX = error -; DX = deltaoffset -; BP = deltaerror -; DS:SI = 32-bit output buffer -; ES:EDI+EDI = sample location -; MM6 = L/R volumes -; MM7 = PXor mask - -IF MONITORPERFORMANCE - Push EAX - Push EDX - - Add CS:M32BitMICounter16BitLow, AX - AdC CS:M32BitMICounter16BitHigh, 0 - - RdTSC - Sub CS:M32BitMICounter16BitTicksLow, EAX - SBB CS:M32BitMICounter16BitTicksHigh, EDX - - Pop EDX - Pop EAX -ENDIF - -; 16 bit code here - Assume DS:Driver - SegCS MovQ MM2, M32BitMIPNotMask ; = FFFF0000FFFF0000h - Assume DS:Nothing - - Test AX, 1 - JZ M32Bit16MFPanned1 - - Push AX - MovD MM1, CX - - Mov EBX, [ES:EDI+EDI] - Add CX, BP - AdC DI, DX - PUnpckLWD MM1, MM1 - - MovD MM0, BX - PXor MM1, MM2 - - MovQ MM3, [DS:10h] - PSRLWI MM1, 1 - - PMAddWD MM0, MM1 - PMAddWD MM3, [DS:8] - - PSRADI MM0, 16 - MovQ MM1, MM3 - - PMAddWD MM0, [DS:0] - PSRLQI MM3, 32 - - PAddD MM3, MM1 - PAddD MM0, MM3 - PSRADI MM0, 14 - PUnpckLDQ MM0, MM0 - PackSSDW MM0, MM0 - - MovDR AX, MM0 - MovQ MM1, MM6 - PMulLW MM1, MM0 - PMulHW MM0, MM6 - - Mov BX, [DS:10h] - Mov [DS:10h], AX - Mov [DS:14h], BX - - MovQ MM3, [DS:18h] ; VR - PUnpckLWD MM1, MM0 - PSubW MM3, MM6 ; VR - PAddD MM1, [SI] - PSRAWI MM3, RAMPSPEED ; VR - MovQM [SI], MM1 - PAddW MM6, MM3 ; VR - - Add SI, 8 - Pop AX - -M32Bit16MFPanned1: - ShR AX, 1 - JZ M32Bit16MFPannedEnd - - Mov [DS:38h], CX - Mov EBX, [ES:EDI+EDI] - Mov [DS:3Ah], CX - Add CX, BP - AdC DI, DX - Mov [DS:30h], EBX - - Mov [DS:3Ch], CX - Mov EBX, [ES:EDI+EDI] - Mov [DS:3Eh], CX - Add CX, BP - AdC DI, DX - Mov [DS:34h], EBX - - MovQ MM5, [DS:38h] - - Mov [DS:38h], BP - Mov [DS:3Ch], BP - Mov [DS:3Ah], BP - Mov [DS:3Eh], BP - - MovQ MM7, [DS:38h] - PXor MM5, MM2 ; MM5 = offsets. - PAddW MM7, MM7 - PXor MM7, MM2 - PSubW MM7, MM2 ; MM7 = offset step - - Dec AX - JZ M32Bit16MFPanned3 - - Mov [DS:20h], AX - -M32Bit16MFPanned2: - MovQ MM2, [DS:10h] - MovQ MM0, MM5 - - PMAddWD MM2, [DS:8] - PSRLWI MM0, 1 - - PMAddWD MM0, [DS:30h] - PAddW MM5, MM7 - - PSRADI MM0, 16 - MovQ MM1, MM2 - - PMAddWD MM0, [DS:0] - PSRLQI MM2, 32 - - Mov EBX, [ES:EDI+EDI] - Add CX, BP - AdC DI, DX - Mov [DS:30h], EBX - - PAddD MM2, MM1 - MovQ MM3, MM0 - - PAddD MM0, MM2 - - PSRADI MM0, 14 - - MovQ MM1, MM0 - PackSSDW MM0, MM0 - - MovDR AX, MM0 - - Mov BX, [DS:10h] - Mov [DS:14h], BX - Mov [DS:10h], AX - - MovQ MM2, [DS:8] - PUnpckLDQ MM1, MM1 - - PMAddWD MM2, [DS:10h] - - Mov EBX, [ES:EDI+EDI] - Add CX, BP - AdC DI, DX - Mov [DS:34h], EBX - - PAddD MM3, MM2 - PSLLQI MM2, 32 - - PAddD MM3, MM2 ; MM3 = FS2, x - - PSRADI MM3, 14 - - PUnpckHDQ MM3, MM3 - MovQ MM0, MM6 - - PackSSDW MM3, MM1 ; MM3 = FS1, FS1, FS2, FS2 - - PMulLW MM0, MM3 - - MovDR AX, MM3 - PMulHW MM3, MM6 - - MovQ MM1, MM0 - - MovQ MM2, [DS:18h] ; VR - PUnpckHWD MM0, MM3 - - PAddD MM0, [SI] - PUnpckLWD MM1, MM3 - - PAddD MM1, [SI+8] - PSubW MM2, MM6 ; VR - - MovQM [SI], MM0 - PSRAWI MM2, RAMPSPEED-1 ; VR - - MovQM [SI+8], MM1 - PAddW MM6, MM2 ; VR - - Mov BX, [DS:10h] - Add SI, 10h - Mov [DS:10h], AX - Mov [DS:14h], BX - - Dec Word Ptr [DS:20h] - JNZ M32Bit16MFPanned2 - -M32Bit16MFPanned3: - MovQ MM0, [DS:30h] - PSRLWI MM5, 1 - - MovQ MM2, [DS:10h] - - PMAddWD MM0, MM5 - PMAddWD MM2, [DS:8] - - PSRADI MM0, 16 - MovQ MM1, MM2 - - PMAddWD MM0, [DS:0] - PSRLQI MM2, 32 - - PAddD MM2, MM1 - MovQ MM3, MM0 - - PAddD MM0, MM2 - - PSRADI MM0, 14 - - MovQ MM1, MM0 - PackSSDW MM0, MM0 - MovDR AX, MM0 - - Mov BX, [DS:10h] - Mov [DS:10h], AX - Mov [DS:14h], BX - - MovQ MM2, [DS:8] - PUnpckLDQ MM1, MM1 - - PMAddWD MM2, [DS:10h] - - PAddD MM3, MM2 - PSLLQI MM2, 32 - - PAddD MM3, MM2 ; MM3 = FS2, x - - PSRADI MM3, 14 - - PUnpckHDQ MM3, MM3 - MovQ MM0, MM6 - - PackSSDW MM3, MM1 ; MM3 = FS1, FS1, FS2, FS2 - - PMulLW MM0, MM3 - - MovDR AX, MM3 - PMulHW MM3, MM6 - - MovQ MM1, MM0 - - MovQ MM2, [DS:18h] ; VR - PUnpckHWD MM0, MM3 - - PAddD MM0, [SI] - PUnpckLWD MM1, MM3 - - PAddD MM1, [SI+8] - PSubW MM2, MM6 ; VR - - MovQM [SI], MM0 - PSRAWI MM2, RAMPSPEED-1 ; VR - - MovQM [SI+8], MM1 - PAddW MM6, MM2 ; VR - - Mov BX, [DS:10h] - Add SI, 10h - Mov [DS:10h], AX - Mov [DS:14h], BX - -M32Bit16MFPannedEnd: -IF MONITORPERFORMANCE - RdTSC - Add CS:M32BitMICounter16BitTicksLow, EAX - AdC CS:M32BitMICounter16BitTicksHigh, EDX -ENDIF - Ret - -EndP M32Bit16MFPanned - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32Bit8MFPanned - -; Layout of data in data segment -; DS:0 = destination volume -; DS:10h->1Fh = samples -; DS:20h = SS, SP storage - -; AX = number to mix -; CX = error -; DX = deltaoffset -; BP = deltaerror -; DS:SI = 32-bit output buffer -; ES:DI = sample location -; MM6 = L/R volumes -; MM7 = PXor mask - -IF MONITORPERFORMANCE - Push EAX - Push EDX - - Add CS:M32BitMICounter8BitLow, AX - AdC CS:M32BitMICounter8BitHigh, 0 - - RdTSC - Sub CS:M32BitMICounter8BitTicksLow, EAX - SBB CS:M32BitMICounter8BitTicksHigh, EDX - - Pop EDX - Pop EAX -ENDIF - -; AX = number of samples to mix. -; MM6 = current volume. -; DS:0 = filtera -; DS:8 = filterb, filterc -; DS:10h = oldsamples. -; DS:18h = destination volume. -; DS:20h = Count -; DS:24h = ... -; DS:30h = sample area, 38h = offset area - - Assume DS:Driver - SegCS MovQ MM2, M32BitMIPNotMask ; = FFFF0000FFFF0000h - Assume DS:Nothing - - Test AX, 1 - JZ M32Bit8MFPanned1 - - MovD MM1, CX - Push AX - - Mov BX, [ES:DI] - Add CX, BP - AdC DI, DX - - MovD MM0, BX - PUnpckLWD MM1, MM1 - - PUnpckLBW MM0, MM0 - PXor MM1, MM2 - - MovQ MM3, [DS:10h] - PSRLWI MM1, 1 - - PMAddWD MM0, MM1 - PMAddWD MM3, [DS:8] - - PSRADI MM0, 16 - MovQ MM1, MM3 - - PMAddWD MM0, [DS:0] - PSRLQI MM3, 32 - - PAddD MM3, MM1 - PAddD MM0, MM3 - PSRADI MM0, 14 - PUnpckLDQ MM0, MM0 - PackSSDW MM0, MM0 - - MovDR AX, MM0 - MovQ MM1, MM6 - PMulLW MM1, MM0 - PMulHW MM0, MM6 - - Mov BX, [DS:10h] - Mov [DS:14h], BX - Mov [DS:10h], AX - - MovQ MM3, [DS:18h] ; VR - PUnpckLWD MM1, MM0 - PSubW MM3, MM6 ; VR - PAddD MM1, [SI] - PSRAWI MM3, RAMPSPEED ; VR - MovQM [SI], MM1 - PAddW MM6, MM3 ; VR - - Pop AX - Add SI, 8 - -M32Bit8MFPanned1: - ShR AX, 1 - JZ M32Bit8MFPannedEnd - - Mov [DS:38h], CX - Mov BX, [ES:DI] - Mov [DS:3Ah], CX - Add CX, BP - AdC DI, DX - Mov [DS:30h], BX - - Mov [DS:3Ch], CX - Mov BX, [ES:DI] - Mov [DS:3Eh], CX - Add CX, BP - AdC DI, DX - Mov [DS:32h], BX - - MovD MM7, BP - MovQ MM5, [DS:38h] - PUnpckLWD MM7, MM7 - PXor MM5, MM2 ; MM5 = offsets. - PUnpckLDQ MM7, MM7 - PAddW MM7, MM7 - PXor MM7, MM2 - PSubW MM7, MM2 ; MM7 = offset step - - Dec AX - JZ M32Bit8MFPanned3 - - Mov [DS:20h], AX - -M32Bit8MFPanned2: - MovD MM0, [DS:30h] - MovQ MM1, MM5 - - PUnpckLBW MM0, MM0 - PSRLWI MM1, 1 - - MovQ MM2, [DS:10h] - PMAddWD MM0, MM1 - - PMAddWD MM2, [DS:8] - PAddW MM5, MM7 - - MovQ MM1, MM2 - PSRADI MM0, 16 - - PMAddWD MM0, [DS:0] - PSRLQI MM2, 32 - - Mov BX, [ES:DI] - Add CX, BP - AdC DI, DX - Mov [DS:30h], BX - - PAddD MM2, MM1 - MovQ MM3, MM0 - - PAddD MM0, MM2 - - PSRADI MM0, 14 - - MovQ MM1, MM0 - PackSSDW MM0, MM0 - - MovDR AX, MM0 - - Mov BX, [DS:10h] - Mov [DS:10h], AX - Mov [DS:14h], BX - - MovQ MM2, [DS:8] - PUnpckLDQ MM1, MM1 - - PMAddWD MM2, [DS:10h] - - Mov BX, [ES:DI] - Add CX, BP - AdC DI, DX - Mov [DS:32h], BX - - PAddD MM3, MM2 - PSLLQI MM2, 32 - - PAddD MM3, MM2 ; MM3 = FS2, x - - PSRADI MM3, 14 - - PUnpckHDQ MM3, MM3 - MovQ MM0, MM6 - - PackSSDW MM3, MM1 ; MM3 = FS1, FS1, FS2, FS2 - - PMulLW MM0, MM3 - - MovDR AX, MM3 - PMulHW MM3, MM6 - - MovQ MM1, MM0 - - MovQ MM2, [DS:18h] ; VR - PUnpckHWD MM0, MM3 - - PAddD MM0, [SI] - PUnpckLWD MM1, MM3 - - PAddD MM1, [SI+8] - PSubW MM2, MM6 ; VR - - MovQM [SI], MM0 - PSRAWI MM2, RAMPSPEED-1 ; VR - - MovQM [SI+8], MM1 - PAddW MM6, MM2 ; VR - - Mov BX, [DS:10h] - Add SI, 10h - Mov [DS:10h], AX - Mov [DS:14h], BX - - Dec Word Ptr [DS:20h] - JNZ M32Bit8MFPanned2 - -M32Bit8MFPanned3: - MovD MM0, [DS:30h] - PSRLWI MM5, 1 - - MovQ MM2, [DS:10h] - PUnpckLBW MM0, MM0 - - PMAddWD MM0, MM5 - PMAddWD MM2, [DS:8] - - PSRADI MM0, 16 - MovQ MM1, MM2 - - PMAddWD MM0, [DS:0] - PSRLQI MM2, 32 - - PAddD MM2, MM1 - MovQ MM3, MM0 - - PAddD MM0, MM2 - - PSRADI MM0, 14 - - MovQ MM1, MM0 - PackSSDW MM0, MM0 - MovDR AX, MM0 - - Mov BX, [DS:10h] - Mov [DS:14h], BX - Mov [DS:10h], AX - - MovQ MM2, [DS:8] - PUnpckLDQ MM1, MM1 - - PMAddWD MM2, [DS:10h] - - PAddD MM3, MM2 - PSLLQI MM2, 32 - - PAddD MM3, MM2 ; MM3 = FS2, x - - PSRADI MM3, 14 - - PUnpckHDQ MM3, MM3 - MovQ MM0, MM6 - - PackSSDW MM3, MM1 ; MM3 = FS1, FS1, FS2, FS2 - - PMulLW MM0, MM3 - - MovDR AX, MM3 - PMulHW MM3, MM6 - - MovQ MM1, MM0 - - MovQ MM2, [DS:18h] ; VR - PUnpckHWD MM0, MM3 - - PAddD MM0, [SI] - PUnpckLWD MM1, MM3 - - PAddD MM1, [SI+8] - PSubW MM2, MM6 ; VR - - MovQM [SI], MM0 - PSRAWI MM2, RAMPSPEED-1 ; VR - - MovQM [SI+8], MM1 - PAddW MM6, MM2 ; VR - - Mov BX, [DS:10h] - Add SI, 10h - Mov [DS:10h], AX - Mov [DS:14h], BX - -M32Bit8MFPannedEnd: -IF MONITORPERFORMANCE - RdTSC - Add CS:M32BitMICounter8BitTicksLow, EAX - AdC CS:M32BitMICounter8BitTicksHigh, EDX -ENDIF - Ret - -EndP M32Bit8MFPanned - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreM32BitMFPanned - Assume DS:Driver - - Mov ES, CS:MixSegment - - Mov AX, [SI+0Ch] ; AX = destination left - Mov BX, [SI+1Ch] ; BX = current left - Mov CX, [SI+0Eh] ; CX = destination right - Mov DX, [SI+1Eh] ; DX = current right. - - Test Word Ptr [SI], 8540h - JZ PreM32BitMFPannedV4 - - Add CX, CX - Add AX, AX - -PreM32BitMFPannedV4: - Test AX, AX - JNZ PreM32BitMFPannedV3 - Test CX, CX - JNZ PreM32BitMFPannedV3 - - Add Word Ptr [SI+8], 60 - -PreM32BitMFPannedV3: - Cmp AX, BX - JL PreM32BitMFPannedV1 - - Add AX, RAMPCOMPENSATE - -PreM32BitMFPannedV1: - Cmp CX, DX - JL PreM32BitMFPannedV2 - - Add CX, RAMPCOMPENSATE - -PreM32BitMFPannedV2: - Mov [ES:18h], AX - Mov [ES:1Ch], AX - Mov [ES:1Ah], CX - Mov [ES:1Eh], CX ; MixSegment:18h = destination volume - - Mov [CS:M32BitMIVolumeData], BX - Mov [CS:M32BitMIVolumeData+2], DX - Sub AX, BX - Sub CX, DX - SAR AX, RAMPSPEED - SAR CX, RAMPSPEED - Add BX, AX - Add DX, CX - Mov [CS:M32BitMIVolumeData+4], BX - Mov [CS:M32BitMIVolumeData+6], DX - SegCS MovQ MM6, M32BitMIVolumeData ; MM6 = current volume - - Xor EAX, EAX - Mov AX, [SI+5Eh] - Sub AX, 1 - AdC AX, 1 - Mov [ES:0], EAX - Mov [ES:4], EAX ; MixSegment:0 = filtera - - Mov AX, [SI+6Eh] - Mov [ES:8], EAX - Mov AX, [SI+7Eh] - Mov [ES:0Ch], EAX ; MixSegment:8 = filterb, filterc - - Mov AX, [SI+3Ch] - Mov [ES:10h], EAX - Mov AX, [SI+6] - Mov [ES:14h], EAX ; MixSegment:10h = old samples. - - Ret - -EndP PreM32BitMFPanned - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +; +; Resonant filter mixing routines +; + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MONITORPERFORMANCE = 0 +RAMPSPEED = 7 +RAMPCOMPENSATE = 63 + +IF MONITORPERFORMANCE +ALIGN 16 +M32BitMICounter8BitTicksLow DD 0 +M32BitMICounter8BitTicksHigh DD 0 +M32BitMICounter16BitTicksLow DD 0 +M32BitMICounter16BitTicksHigh DD 0 +M32BitMICounter8BitLow DW 0 +M32BitMICounter8BitHigh DW 0 +M32BitMICounter16BitLow DW 0 +M32BitMICounter16BitHigh DW 0 +ENDIF + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32Bit16MFPanned + +; AX = number to mix +; CX = error +; DX = deltaoffset +; BP = deltaerror +; DS:SI = 32-bit output buffer +; ES:EDI+EDI = sample location +; MM6 = L/R volumes +; MM7 = PXor mask + +IF MONITORPERFORMANCE + Push EAX + Push EDX + + Add CS:M32BitMICounter16BitLow, AX + AdC CS:M32BitMICounter16BitHigh, 0 + + RdTSC + Sub CS:M32BitMICounter16BitTicksLow, EAX + SBB CS:M32BitMICounter16BitTicksHigh, EDX + + Pop EDX + Pop EAX +ENDIF + +; 16 bit code here + Assume DS:Driver + SegCS MovQ MM2, M32BitMIPNotMask ; = FFFF0000FFFF0000h + Assume DS:Nothing + + Test AX, 1 + JZ M32Bit16MFPanned1 + + Push AX + MovD MM1, CX + + Mov EBX, [ES:EDI+EDI] + Add CX, BP + AdC DI, DX + PUnpckLWD MM1, MM1 + + MovD MM0, BX + PXor MM1, MM2 + + MovQ MM3, [DS:10h] + PSRLWI MM1, 1 + + PMAddWD MM0, MM1 + PMAddWD MM3, [DS:8] + + PSRADI MM0, 16 + MovQ MM1, MM3 + + PMAddWD MM0, [DS:0] + PSRLQI MM3, 32 + + PAddD MM3, MM1 + PAddD MM0, MM3 + PSRADI MM0, 14 + PUnpckLDQ MM0, MM0 + PackSSDW MM0, MM0 + + MovDR AX, MM0 + MovQ MM1, MM6 + PMulLW MM1, MM0 + PMulHW MM0, MM6 + + Mov BX, [DS:10h] + Mov [DS:10h], AX + Mov [DS:14h], BX + + MovQ MM3, [DS:18h] ; VR + PUnpckLWD MM1, MM0 + PSubW MM3, MM6 ; VR + PAddD MM1, [SI] + PSRAWI MM3, RAMPSPEED ; VR + MovQM [SI], MM1 + PAddW MM6, MM3 ; VR + + Add SI, 8 + Pop AX + +M32Bit16MFPanned1: + ShR AX, 1 + JZ M32Bit16MFPannedEnd + + Mov [DS:38h], CX + Mov EBX, [ES:EDI+EDI] + Mov [DS:3Ah], CX + Add CX, BP + AdC DI, DX + Mov [DS:30h], EBX + + Mov [DS:3Ch], CX + Mov EBX, [ES:EDI+EDI] + Mov [DS:3Eh], CX + Add CX, BP + AdC DI, DX + Mov [DS:34h], EBX + + MovQ MM5, [DS:38h] + + Mov [DS:38h], BP + Mov [DS:3Ch], BP + Mov [DS:3Ah], BP + Mov [DS:3Eh], BP + + MovQ MM7, [DS:38h] + PXor MM5, MM2 ; MM5 = offsets. + PAddW MM7, MM7 + PXor MM7, MM2 + PSubW MM7, MM2 ; MM7 = offset step + + Dec AX + JZ M32Bit16MFPanned3 + + Mov [DS:20h], AX + +M32Bit16MFPanned2: + MovQ MM2, [DS:10h] + MovQ MM0, MM5 + + PMAddWD MM2, [DS:8] + PSRLWI MM0, 1 + + PMAddWD MM0, [DS:30h] + PAddW MM5, MM7 + + PSRADI MM0, 16 + MovQ MM1, MM2 + + PMAddWD MM0, [DS:0] + PSRLQI MM2, 32 + + Mov EBX, [ES:EDI+EDI] + Add CX, BP + AdC DI, DX + Mov [DS:30h], EBX + + PAddD MM2, MM1 + MovQ MM3, MM0 + + PAddD MM0, MM2 + + PSRADI MM0, 14 + + MovQ MM1, MM0 + PackSSDW MM0, MM0 + + MovDR AX, MM0 + + Mov BX, [DS:10h] + Mov [DS:14h], BX + Mov [DS:10h], AX + + MovQ MM2, [DS:8] + PUnpckLDQ MM1, MM1 + + PMAddWD MM2, [DS:10h] + + Mov EBX, [ES:EDI+EDI] + Add CX, BP + AdC DI, DX + Mov [DS:34h], EBX + + PAddD MM3, MM2 + PSLLQI MM2, 32 + + PAddD MM3, MM2 ; MM3 = FS2, x + + PSRADI MM3, 14 + + PUnpckHDQ MM3, MM3 + MovQ MM0, MM6 + + PackSSDW MM3, MM1 ; MM3 = FS1, FS1, FS2, FS2 + + PMulLW MM0, MM3 + + MovDR AX, MM3 + PMulHW MM3, MM6 + + MovQ MM1, MM0 + + MovQ MM2, [DS:18h] ; VR + PUnpckHWD MM0, MM3 + + PAddD MM0, [SI] + PUnpckLWD MM1, MM3 + + PAddD MM1, [SI+8] + PSubW MM2, MM6 ; VR + + MovQM [SI], MM0 + PSRAWI MM2, RAMPSPEED-1 ; VR + + MovQM [SI+8], MM1 + PAddW MM6, MM2 ; VR + + Mov BX, [DS:10h] + Add SI, 10h + Mov [DS:10h], AX + Mov [DS:14h], BX + + Dec Word Ptr [DS:20h] + JNZ M32Bit16MFPanned2 + +M32Bit16MFPanned3: + MovQ MM0, [DS:30h] + PSRLWI MM5, 1 + + MovQ MM2, [DS:10h] + + PMAddWD MM0, MM5 + PMAddWD MM2, [DS:8] + + PSRADI MM0, 16 + MovQ MM1, MM2 + + PMAddWD MM0, [DS:0] + PSRLQI MM2, 32 + + PAddD MM2, MM1 + MovQ MM3, MM0 + + PAddD MM0, MM2 + + PSRADI MM0, 14 + + MovQ MM1, MM0 + PackSSDW MM0, MM0 + MovDR AX, MM0 + + Mov BX, [DS:10h] + Mov [DS:10h], AX + Mov [DS:14h], BX + + MovQ MM2, [DS:8] + PUnpckLDQ MM1, MM1 + + PMAddWD MM2, [DS:10h] + + PAddD MM3, MM2 + PSLLQI MM2, 32 + + PAddD MM3, MM2 ; MM3 = FS2, x + + PSRADI MM3, 14 + + PUnpckHDQ MM3, MM3 + MovQ MM0, MM6 + + PackSSDW MM3, MM1 ; MM3 = FS1, FS1, FS2, FS2 + + PMulLW MM0, MM3 + + MovDR AX, MM3 + PMulHW MM3, MM6 + + MovQ MM1, MM0 + + MovQ MM2, [DS:18h] ; VR + PUnpckHWD MM0, MM3 + + PAddD MM0, [SI] + PUnpckLWD MM1, MM3 + + PAddD MM1, [SI+8] + PSubW MM2, MM6 ; VR + + MovQM [SI], MM0 + PSRAWI MM2, RAMPSPEED-1 ; VR + + MovQM [SI+8], MM1 + PAddW MM6, MM2 ; VR + + Mov BX, [DS:10h] + Add SI, 10h + Mov [DS:10h], AX + Mov [DS:14h], BX + +M32Bit16MFPannedEnd: +IF MONITORPERFORMANCE + RdTSC + Add CS:M32BitMICounter16BitTicksLow, EAX + AdC CS:M32BitMICounter16BitTicksHigh, EDX +ENDIF + Ret + +EndP M32Bit16MFPanned + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32Bit8MFPanned + +; Layout of data in data segment +; DS:0 = destination volume +; DS:10h->1Fh = samples +; DS:20h = SS, SP storage + +; AX = number to mix +; CX = error +; DX = deltaoffset +; BP = deltaerror +; DS:SI = 32-bit output buffer +; ES:DI = sample location +; MM6 = L/R volumes +; MM7 = PXor mask + +IF MONITORPERFORMANCE + Push EAX + Push EDX + + Add CS:M32BitMICounter8BitLow, AX + AdC CS:M32BitMICounter8BitHigh, 0 + + RdTSC + Sub CS:M32BitMICounter8BitTicksLow, EAX + SBB CS:M32BitMICounter8BitTicksHigh, EDX + + Pop EDX + Pop EAX +ENDIF + +; AX = number of samples to mix. +; MM6 = current volume. +; DS:0 = filtera +; DS:8 = filterb, filterc +; DS:10h = oldsamples. +; DS:18h = destination volume. +; DS:20h = Count +; DS:24h = ... +; DS:30h = sample area, 38h = offset area + + Assume DS:Driver + SegCS MovQ MM2, M32BitMIPNotMask ; = FFFF0000FFFF0000h + Assume DS:Nothing + + Test AX, 1 + JZ M32Bit8MFPanned1 + + MovD MM1, CX + Push AX + + Mov BX, [ES:DI] + Add CX, BP + AdC DI, DX + + MovD MM0, BX + PUnpckLWD MM1, MM1 + + PUnpckLBW MM0, MM0 + PXor MM1, MM2 + + MovQ MM3, [DS:10h] + PSRLWI MM1, 1 + + PMAddWD MM0, MM1 + PMAddWD MM3, [DS:8] + + PSRADI MM0, 16 + MovQ MM1, MM3 + + PMAddWD MM0, [DS:0] + PSRLQI MM3, 32 + + PAddD MM3, MM1 + PAddD MM0, MM3 + PSRADI MM0, 14 + PUnpckLDQ MM0, MM0 + PackSSDW MM0, MM0 + + MovDR AX, MM0 + MovQ MM1, MM6 + PMulLW MM1, MM0 + PMulHW MM0, MM6 + + Mov BX, [DS:10h] + Mov [DS:14h], BX + Mov [DS:10h], AX + + MovQ MM3, [DS:18h] ; VR + PUnpckLWD MM1, MM0 + PSubW MM3, MM6 ; VR + PAddD MM1, [SI] + PSRAWI MM3, RAMPSPEED ; VR + MovQM [SI], MM1 + PAddW MM6, MM3 ; VR + + Pop AX + Add SI, 8 + +M32Bit8MFPanned1: + ShR AX, 1 + JZ M32Bit8MFPannedEnd + + Mov [DS:38h], CX + Mov BX, [ES:DI] + Mov [DS:3Ah], CX + Add CX, BP + AdC DI, DX + Mov [DS:30h], BX + + Mov [DS:3Ch], CX + Mov BX, [ES:DI] + Mov [DS:3Eh], CX + Add CX, BP + AdC DI, DX + Mov [DS:32h], BX + + MovD MM7, BP + MovQ MM5, [DS:38h] + PUnpckLWD MM7, MM7 + PXor MM5, MM2 ; MM5 = offsets. + PUnpckLDQ MM7, MM7 + PAddW MM7, MM7 + PXor MM7, MM2 + PSubW MM7, MM2 ; MM7 = offset step + + Dec AX + JZ M32Bit8MFPanned3 + + Mov [DS:20h], AX + +M32Bit8MFPanned2: + MovD MM0, [DS:30h] + MovQ MM1, MM5 + + PUnpckLBW MM0, MM0 + PSRLWI MM1, 1 + + MovQ MM2, [DS:10h] + PMAddWD MM0, MM1 + + PMAddWD MM2, [DS:8] + PAddW MM5, MM7 + + MovQ MM1, MM2 + PSRADI MM0, 16 + + PMAddWD MM0, [DS:0] + PSRLQI MM2, 32 + + Mov BX, [ES:DI] + Add CX, BP + AdC DI, DX + Mov [DS:30h], BX + + PAddD MM2, MM1 + MovQ MM3, MM0 + + PAddD MM0, MM2 + + PSRADI MM0, 14 + + MovQ MM1, MM0 + PackSSDW MM0, MM0 + + MovDR AX, MM0 + + Mov BX, [DS:10h] + Mov [DS:10h], AX + Mov [DS:14h], BX + + MovQ MM2, [DS:8] + PUnpckLDQ MM1, MM1 + + PMAddWD MM2, [DS:10h] + + Mov BX, [ES:DI] + Add CX, BP + AdC DI, DX + Mov [DS:32h], BX + + PAddD MM3, MM2 + PSLLQI MM2, 32 + + PAddD MM3, MM2 ; MM3 = FS2, x + + PSRADI MM3, 14 + + PUnpckHDQ MM3, MM3 + MovQ MM0, MM6 + + PackSSDW MM3, MM1 ; MM3 = FS1, FS1, FS2, FS2 + + PMulLW MM0, MM3 + + MovDR AX, MM3 + PMulHW MM3, MM6 + + MovQ MM1, MM0 + + MovQ MM2, [DS:18h] ; VR + PUnpckHWD MM0, MM3 + + PAddD MM0, [SI] + PUnpckLWD MM1, MM3 + + PAddD MM1, [SI+8] + PSubW MM2, MM6 ; VR + + MovQM [SI], MM0 + PSRAWI MM2, RAMPSPEED-1 ; VR + + MovQM [SI+8], MM1 + PAddW MM6, MM2 ; VR + + Mov BX, [DS:10h] + Add SI, 10h + Mov [DS:10h], AX + Mov [DS:14h], BX + + Dec Word Ptr [DS:20h] + JNZ M32Bit8MFPanned2 + +M32Bit8MFPanned3: + MovD MM0, [DS:30h] + PSRLWI MM5, 1 + + MovQ MM2, [DS:10h] + PUnpckLBW MM0, MM0 + + PMAddWD MM0, MM5 + PMAddWD MM2, [DS:8] + + PSRADI MM0, 16 + MovQ MM1, MM2 + + PMAddWD MM0, [DS:0] + PSRLQI MM2, 32 + + PAddD MM2, MM1 + MovQ MM3, MM0 + + PAddD MM0, MM2 + + PSRADI MM0, 14 + + MovQ MM1, MM0 + PackSSDW MM0, MM0 + MovDR AX, MM0 + + Mov BX, [DS:10h] + Mov [DS:14h], BX + Mov [DS:10h], AX + + MovQ MM2, [DS:8] + PUnpckLDQ MM1, MM1 + + PMAddWD MM2, [DS:10h] + + PAddD MM3, MM2 + PSLLQI MM2, 32 + + PAddD MM3, MM2 ; MM3 = FS2, x + + PSRADI MM3, 14 + + PUnpckHDQ MM3, MM3 + MovQ MM0, MM6 + + PackSSDW MM3, MM1 ; MM3 = FS1, FS1, FS2, FS2 + + PMulLW MM0, MM3 + + MovDR AX, MM3 + PMulHW MM3, MM6 + + MovQ MM1, MM0 + + MovQ MM2, [DS:18h] ; VR + PUnpckHWD MM0, MM3 + + PAddD MM0, [SI] + PUnpckLWD MM1, MM3 + + PAddD MM1, [SI+8] + PSubW MM2, MM6 ; VR + + MovQM [SI], MM0 + PSRAWI MM2, RAMPSPEED-1 ; VR + + MovQM [SI+8], MM1 + PAddW MM6, MM2 ; VR + + Mov BX, [DS:10h] + Add SI, 10h + Mov [DS:10h], AX + Mov [DS:14h], BX + +M32Bit8MFPannedEnd: +IF MONITORPERFORMANCE + RdTSC + Add CS:M32BitMICounter8BitTicksLow, EAX + AdC CS:M32BitMICounter8BitTicksHigh, EDX +ENDIF + Ret + +EndP M32Bit8MFPanned + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreM32BitMFPanned + Assume DS:Driver + + Mov ES, CS:MixSegment + + Mov AX, [SI+0Ch] ; AX = destination left + Mov BX, [SI+1Ch] ; BX = current left + Mov CX, [SI+0Eh] ; CX = destination right + Mov DX, [SI+1Eh] ; DX = current right. + + Test Word Ptr [SI], 8540h + JZ PreM32BitMFPannedV4 + + Add CX, CX + Add AX, AX + +PreM32BitMFPannedV4: + Test AX, AX + JNZ PreM32BitMFPannedV3 + Test CX, CX + JNZ PreM32BitMFPannedV3 + + Add Word Ptr [SI+8], 60 + +PreM32BitMFPannedV3: + Cmp AX, BX + JL PreM32BitMFPannedV1 + + Add AX, RAMPCOMPENSATE + +PreM32BitMFPannedV1: + Cmp CX, DX + JL PreM32BitMFPannedV2 + + Add CX, RAMPCOMPENSATE + +PreM32BitMFPannedV2: + Mov [ES:18h], AX + Mov [ES:1Ch], AX + Mov [ES:1Ah], CX + Mov [ES:1Eh], CX ; MixSegment:18h = destination volume + + Mov [CS:M32BitMIVolumeData], BX + Mov [CS:M32BitMIVolumeData+2], DX + Sub AX, BX + Sub CX, DX + SAR AX, RAMPSPEED + SAR CX, RAMPSPEED + Add BX, AX + Add DX, CX + Mov [CS:M32BitMIVolumeData+4], BX + Mov [CS:M32BitMIVolumeData+6], DX + SegCS MovQ MM6, M32BitMIVolumeData ; MM6 = current volume + + Xor EAX, EAX + Mov AX, [SI+5Eh] + Sub AX, 1 + AdC AX, 1 + Mov [ES:0], EAX + Mov [ES:4], EAX ; MixSegment:0 = filtera + + Mov AX, [SI+6Eh] + Mov [ES:8], EAX + Mov AX, [SI+7Eh] + Mov [ES:0Ch], EAX ; MixSegment:8 = filterb, filterc + + Mov AX, [SI+3Ch] + Mov [ES:10h], EAX + Mov AX, [SI+6] + Mov [ES:14h], EAX ; MixSegment:10h = old samples. + + Ret + +EndP PreM32BitMFPanned + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M32BITMI.INC b/SoundDrivers/M32BITMI.INC index 799880e..093790a 100755 --- a/SoundDrivers/M32BITMI.INC +++ b/SoundDrivers/M32BITMI.INC @@ -1,11 +1,11 @@ -; 8 bit tables - - DW Offset MixNoLoop, PreM32BitMIPanned, MFS8Bit, MBS8Bit, M32Bit8MIPanned - DW Offset MixForwardsLoop, PreM32BitMIPanned, MFS8Bit, MBS8Bit, M32Bit8MIPanned - DW Offset MixPingPongLoop, PreM32BitMIPanned, MFS8Bit, MBS8Bit, M32Bit8MIPanned - -; 16 bit tables - DW Offset MixNoLoop, PreM32BitMIPanned, MFS16Bit, MBS16Bit, M32Bit16MIPanned - DW Offset MixForwardsLoop, PreM32BitMIPanned, MFS16Bit, MBS16Bit, M32Bit16MIPanned - DW Offset MixPingPongLoop, PreM32BitMIPanned, MFS16Bit, MBS16Bit, M32Bit16MIPanned - +; 8 bit tables + + DW Offset MixNoLoop, PreM32BitMIPanned, MFS8Bit, MBS8Bit, M32Bit8MIPanned + DW Offset MixForwardsLoop, PreM32BitMIPanned, MFS8Bit, MBS8Bit, M32Bit8MIPanned + DW Offset MixPingPongLoop, PreM32BitMIPanned, MFS8Bit, MBS8Bit, M32Bit8MIPanned + +; 16 bit tables + DW Offset MixNoLoop, PreM32BitMIPanned, MFS16Bit, MBS16Bit, M32Bit16MIPanned + DW Offset MixForwardsLoop, PreM32BitMIPanned, MFS16Bit, MBS16Bit, M32Bit16MIPanned + DW Offset MixPingPongLoop, PreM32BitMIPanned, MFS16Bit, MBS16Bit, M32Bit16MIPanned + diff --git a/SoundDrivers/M32BITMI.MIX b/SoundDrivers/M32BITMI.MIX index 3bf0fde..0491273 100755 --- a/SoundDrivers/M32BITMI.MIX +++ b/SoundDrivers/M32BITMI.MIX @@ -1,686 +1,686 @@ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MONITORPERFORMANCE = 0 - -ALIGN 16 - -M32BitMIVolumeData DW 0, 0, 0, 0 -M32BitMIPXorMask DW 07FFFh, 0, 07FFFh, 0 -M32BitMIPNotMask DW 0FFFFh, 0, 0FFFFh, 0 - -IF MONITORPERFORMANCE -M32BitMICounter8BitTicksLow DD 0 -M32BitMICounter8BitTicksHigh DD 0 -M32BitMICounter16BitTicksLow DD 0 -M32BitMICounter16BitTicksHigh DD 0 -M32BitMICounter8BitLow DW 0 -M32BitMICounter8BitHigh DW 0 -M32BitMICounter16BitLow DW 0 -M32BitMICounter16BitHigh DW 0 -ENDIF - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32Bit16MIPanned - -; AX = number to mix -; CX = error -; DX = deltaoffset -; BP = deltaerror -; DS:SI = 32-bit output buffer -; ES:EDI+EDI = sample location -; MM6 = L/R volumes -; MM7 = PXor mask - -IF MONITORPERFORMANCE - Push EAX - Push EDX - - Add CS:M32BitMICounter16BitLow, AX - AdC CS:M32BitMICounter16BitHigh, 0 - - RdTSC - Sub CS:M32BitMICounter16BitTicksLow, EAX - SBB CS:M32BitMICounter16BitTicksHigh, EDX - - Pop EDX - Pop EAX -ENDIF - - Mov BX, DI - Add BX, BX - - Assume DS:Driver - SegCS MovQ MM3, M32BitMIPXorMask - Assume DS:Nothing - -M32Bit16MIPanned1: - Test AL, 1 - JZ M32Bit16MIPanned2 - - Push AX - Mov [DS:10h], CX - Mov AX, [ES:BX] - Mov [DS:12h], CX - Add CX, BP - AdC DI, DX - Mov [DS:0], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:2], AX - Add BX, BX - - MovQ MM4, [DS:10h] - MovQ MM2, MM6 - MovQ MM0, [DS:0] - PSRLWI MM4, 1 - PXor MM4, MM3 - PMAddWD MM0, MM4 - PSRADI MM0, 15 - PUnpckLWD MM0, MM0 - PMulLW MM2, MM0 - PMulHW MM0, MM6 - PUnpckLWD MM2, MM0 - PAddD MM2, [SI] - MovQM [SI], MM2 - - Add SI, 8 - Pop AX - -M32Bit16MIPanned2: - Test AL, 2 - JZ M32Bit16MIPanned3 - - Push AX - Mov [DS:10h], CX - Mov AX, [ES:BX] - Mov [DS:12h], CX - Add CX, BP - AdC DI, DX - Mov [DS:0], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:2], AX - Add BX, BX - - Mov [DS:14h], CX - Mov AX, [ES:BX] - Mov [DS:16h], CX - Add CX, BP - AdC DI, DX - Mov [DS:4], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:6], AX - Add BX, BX - - MovQ MM4, [DS:10h] - MovQ MM2, MM6 - MovQ MM0, [DS:0] - PSRLWI MM4, 1 - - PXor MM4, MM3 - - PMAddWD MM0, MM4 - PSRADI MM0, 15 - PackSSDW MM0, MM0 - PUnpckLWD MM0, MM0 - PMulLW MM2, MM0 - PMulHW MM0, MM6 - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - PAddD MM2, [SI] - PUnpckHWD MM4, MM0 - PAddD MM4, [SI+8] - MovQM [SI], MM2 - MovQM [SI+8], MM4 - - Add SI, 10h - Pop AX - -M32Bit16MIPanned3: - ShR AX, 2 - JZ M32Bit16MIPannedEnd - - Mov [DS:20h], AX - - Mov [DS:10h], CX ; AGIs everywhere! - Mov AX, [ES:BX] - Mov [DS:12h], CX - Add CX, BP - AdC DI, DX - Mov [DS:0], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:2], AX - Add BX, BX - - Mov [DS:14h], CX - Mov AX, [ES:BX] - Mov [DS:16h], CX - Add CX, BP - AdC DI, DX - Mov [DS:4], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:6], AX - Add BX, BX - - MovQ MM5, [DS:10h] - - Mov [DS:10h], BP - Mov [DS:14h], BP - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:8], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:0Ah], AX - Add BX, BX - - Mov [DS:12h], BP - Mov [DS:16h], BP - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:0Ch], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:0Eh], AX - Add BX, BX - - Assume DS:Driver - SegCS MovQ MM4, M32BitMIPNotMask - Assume DS:Nothing - - MovQ MM7, [DS:10h] - PXor MM5, MM4 - - PAddW MM7, MM7 - MovQ MM2, MM5 - - PXor MM7, MM4 - PSRLWI MM2, 1 - - PSubW MM7, MM4 - PAddW MM5, MM7 - MovQ MM3, MM5 - - Dec Word Ptr [DS:20h] - JZ M32Bit16MIPanned5 - -M32Bit16MIPanned4: ; MM7 = delta offsets. - PMAddWD MM2, [DS:0] - PSRLWI MM3, 1 - -; Stall (2) - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:0], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:2], AX - Add BX, BX - - PMAddWD MM3, [DS:8] - PSRADI MM2, 15 - - PackSSDW MM2, MM2 - PAddW MM5, MM7 - - PUnpckLWD MM2, MM2 - MovQ MM0, MM6 - - PMulHW MM0, MM2 - PSRADI MM3, 15 - - PMulLW MM2, MM6 - PackSSDW MM3, MM3 - - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:4], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:6], AX - Add BX, BX - -; Stall (1) - MovQ MM4, MM2 - PUnpckLWD MM3, MM3 - - PUnpckLWD MM2, MM0 - MovQ MM1, MM6 - - PMulHW MM1, MM3 - PUnpckHWD MM4, MM0 - - PAddD MM2, [SI] - PMulLW MM3, MM6 - - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:8], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:0Ah], AX - Add BX, BX - -; Stall (1) - PAddD MM4, [SI+8] - MovQ MM0, MM3 ; - - MovQM [SI], MM2 - PUnpckLWD MM3, MM1 - - MovQM [SI+8], MM4 - PUnpckHWD MM0, MM1 - - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:0Ch], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:0Eh], AX - Add BX, BX - - PAddD MM3, [SI+10h] - MovQ MM2, MM5 - - PAddD MM0, [SI+18h] - PAddW MM5, MM7 - - MovQM [SI+10h], MM3 - MovQ MM3, MM5 - - MovQM [SI+18h], MM0 - PSRLWI MM2, 1 - - Add SI, 20h - Dec Word Ptr [DS:20h] - JNZ M32Bit16MIPanned4 - -M32Bit16MIPanned5: - PMAddWD MM2, [DS:0] - PSRLWI MM3, 1 - - PMAddWD MM3, [DS:8] - PSRADI MM2, 15 - - PackSSDW MM2, MM2 - PAddW MM5, MM7 - - PUnpckLWD MM2, MM2 - MovQ MM0, MM6 - - PMulHW MM0, MM2 - PSRADI MM3, 15 - - PMulLW MM2, MM6 - PackSSDW MM3, MM3 - - MovQ MM4, MM2 - PUnpckLWD MM3, MM3 - - PUnpckLWD MM2, MM0 - MovQ MM1, MM6 - - PMulHW MM1, MM3 - PUnpckHWD MM4, MM0 - - PAddD MM2, [SI] - PMulLW MM3, MM6 - - PAddD MM4, [SI+8] - MovQ MM0, MM3 - - MovQM [SI], MM2 - PUnpckLWD MM3, MM1 - - MovQM [SI+8], MM4 - PUnpckHWD MM0, MM1 - - PAddD MM3, [SI+10h] - PAddD MM0, [SI+18h] - MovQM [SI+10h], MM3 - MovQM [SI+18h], MM0 - -M32Bit16MIPannedEnd: -IF MONITORPERFORMANCE - RdTSC - Add CS:M32BitMICounter16BitTicksLow, EAX - AdC CS:M32BitMICounter16BitTicksHigh, EDX -ENDIF - Ret - -EndP M32Bit16MIPanned - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32Bit8MIPanned - -; AX = number to mix -; CX = error -; DX = deltaoffset -; BP = deltaerror -; DS:SI = 32-bit output buffer -; ES:DI = sample location -; MM6 = L/R volumes -; MM7 = PXor mask - -IF MONITORPERFORMANCE - Push EAX - Push EDX - - Add CS:M32BitMICounter8BitLow, AX - AdC CS:M32BitMICounter8BitHigh, 0 - - RdTSC - Sub CS:M32BitMICounter8BitTicksLow, EAX - SBB CS:M32BitMICounter8BitTicksHigh, EDX - - Pop EDX - Pop EAX -ENDIF - - Mov BX, AX - - And AX, 3 - JZ M32Bit8MIPanned3 - - Assume DS:Driver - SegCS MovQ MM3, M32BitMIPXorMask - Assume DS:Nothing - -M32Bit8MIPanned1: - Test AL, 1 - JZ M32Bit8MIPanned2 - - Mov AX, [ES:DI] - Mov [DS:10h], CX - Mov [DS:12h], CX - Add CX, BP - AdC DI, DX - - MovQ MM4, [DS:10h] - MovQ MM2, MM6 - MovD MM0, AX - PSRLWI MM4, 1 - PXor MM4, MM3 - PUnpckLBW MM0, MM0 - PMAddWD MM0, MM4 - PSRADI MM0, 15 - PUnpckLWD MM0, MM0 - PMulLW MM2, MM0 - PMulHW MM0, MM6 - PUnpckLWD MM2, MM0 - PAddD MM2, [SI] - MovQM [SI], MM2 - - Add SI, 8 - -M32Bit8MIPanned2: ; Mix 2 samples - Test BL, 2 - JZ M32Bit8MIPanned3 - - Mov AX, [ES:DI] - Mov [DS:10h], CX - Mov [DS:12h], CX - Add CX, BP - AdC DI, DX - Mov [DS:0], AX - - Mov AX, [ES:DI] - Mov [DS:14h], CX - Mov [DS:16h], CX - Add CX, BP - AdC DI, DX - Mov [DS:2], AX - - MovQ MM4, [DS:10h] - MovQ MM2, MM6 - MovQ MM0, [DS:0] - PSRLWI MM4, 1 - - PUnpckLBW MM0, MM0 - PXor MM4, MM3 - - PMAddWD MM0, MM4 - PSRADI MM0, 15 - PackSSDW MM0, MM0 - PUnpckLWD MM0, MM0 - PMulLW MM2, MM0 - PMulHW MM0, MM6 - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - PAddD MM2, [SI] - PUnpckHWD MM4, MM0 - PAddD MM4, [SI+8] - MovQM [SI], MM2 - MovQM [SI+8], MM4 - - Add SI, 10h - -M32Bit8MIPanned3: - ShR BX, 2 - JZ M32Bit8MIPannedEnd - -; Have to setup offset register and delta-offset register. - - Mov AX, [ES:DI] - Mov [DS:10h], ERROR - Mov [DS:12h], ERROR - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0], AX - - Mov AX, [ES:DI] - Mov [DS:14h], ERROR - Mov [DS:16h], ERROR - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:2], AX - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:18h], DELTAERROR - Mov [DS:8h], AX - Mov [DS:1Ah], DELTAERROR - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:1Ch], DELTAERROR - Mov [DS:0Ah], AX - Mov [DS:1Eh], DELTAERROR - - Assume DS:Driver - SegCS MovQ MM4, M32BitMIPNotMask - Assume DS:Nothing - - MovQ MM7, [DS:18h] - MovQ MM5, [DS:10h] - - PAddW MM7, MM7 - - PXor MM7, MM4 - PXor MM5, MM4 - - PSubW MM7, MM4 - - Dec BX - JZ M32Bit8MIPanned5 - -M32Bit8MIPanned4: - MovQ MM0, [DS:0] - MovQ MM2, MM5 - - MovQ MM1, [DS:8] - PUnpckLBW MM0, MM0 - - PAddW MM5, MM7 - PSRLWI MM2, 1 - - PMAddWD MM0, MM2 - PUnpckLBW MM1, MM1 - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0], AX - - PSRADI MM0, 15 - MovQ MM3, MM5 - - PAddW MM5, MM7 - PSRLWI MM3, 1 - - PMAddWD MM1, MM3 - PackSSDW MM0, MM0 - - MovQ MM2, MM6 - PUnpckLWD MM0, MM0 - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:2], AX - - PMulLW MM2, MM0 - PSRADI MM1, 15 - - PMulHW MM0, MM6 - PackSSDW MM1, MM1 - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - - MovQ MM4, MM2 - PUnpckLWD MM1, MM1 - - AdC DI, DELTAOFFSET - Mov [DS:8], AX - - MovQ MM3, MM6 - PUnpckLWD MM2, MM0 - - PAddD MM2, [SI] - PMulLW MM3, MM1 - - PMulHW MM1, MM6 - PUnpckHWD MM4, MM0 - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:0Ah], AX - - PAddD MM4, [SI+8] - MovQ MM0, MM3 - - MovQM [SI], MM2 - PUnpckLWD MM3, MM1 - - MovQM [SI+8], MM4 - PUnpckHWD MM0, MM1 - - PAddD MM3, [SI+10h] - PAddD MM0, [SI+18h] - - MovQM [SI+10h], MM3 - MovQM [SI+18h], MM0 - - Add SI, 20h - - Dec BX - JNZ M32Bit8MIPanned4 - -M32Bit8MIPanned5: - MovQ MM0, [DS:0] - MovQ MM2, MM5 - MovQ MM1, [DS:8] - PUnpckLBW MM0, MM0 - PAddW MM5, MM7 - PSRLWI MM2, 1 - - PMAddWD MM0, MM2 - PUnpckLBW MM1, MM1 - - PSRLWI MM5, 1 - - PMAddWD MM1, MM5 - PSRADI MM0, 15 - - MovQ MM2, MM6 - PackSSDW MM0, MM0 - - MovQ MM3, MM6 - PUnpckLWD MM0, MM0 - - PMulLW MM2, MM0 - PSRADI MM1, 15 - - PMulHW MM0, MM6 - PackSSDW MM1, MM1 - - PUnpckLWD MM1, MM1 - MovQ MM4, MM2 - - PMulLW MM3, MM1 - PUnpckLWD MM2, MM0 - - PMulHW MM1, MM6 - PUnpckHWD MM4, MM0 - - PAddD MM2, [SI] - MovQ MM5, MM3 - - PAddD MM4, [SI+8] - PUnpckLWD MM3, MM1 - - MovQM [SI], MM2 - PUnpckHWD MM5, MM1 - - PAddD MM3, [SI+10h] - PAddD MM5, [SI+18h] - - MovQM [SI+8], MM4 - MovQM [SI+10h], MM3 - MovQM [SI+18h], MM5 - -M32Bit8MIPannedEnd: -IF MONITORPERFORMANCE - RdTSC - Add CS:M32BitMICounter8BitTicksLow, EAX - AdC CS:M32BitMICounter8BitTicksHigh, EDX -ENDIF - Ret - -EndP M32Bit8MIPanned - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreM32BitMIPanned - Assume DS:Driver - - Mov EAX, [SI+0Ch] ; LEAX = left vol, HEAX = right vol - Mov [DWord Ptr CS:M32BitMIVolumeData], EAX - Mov [DWord Ptr CS:M32BitMIVolumeData+4], EAX - - SegCS MovQ MM6, M32BitMIVolumeData - - Ret - -EndP PreM32BitMIPanned - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MONITORPERFORMANCE = 0 + +ALIGN 16 + +M32BitMIVolumeData DW 0, 0, 0, 0 +M32BitMIPXorMask DW 07FFFh, 0, 07FFFh, 0 +M32BitMIPNotMask DW 0FFFFh, 0, 0FFFFh, 0 + +IF MONITORPERFORMANCE +M32BitMICounter8BitTicksLow DD 0 +M32BitMICounter8BitTicksHigh DD 0 +M32BitMICounter16BitTicksLow DD 0 +M32BitMICounter16BitTicksHigh DD 0 +M32BitMICounter8BitLow DW 0 +M32BitMICounter8BitHigh DW 0 +M32BitMICounter16BitLow DW 0 +M32BitMICounter16BitHigh DW 0 +ENDIF + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32Bit16MIPanned + +; AX = number to mix +; CX = error +; DX = deltaoffset +; BP = deltaerror +; DS:SI = 32-bit output buffer +; ES:EDI+EDI = sample location +; MM6 = L/R volumes +; MM7 = PXor mask + +IF MONITORPERFORMANCE + Push EAX + Push EDX + + Add CS:M32BitMICounter16BitLow, AX + AdC CS:M32BitMICounter16BitHigh, 0 + + RdTSC + Sub CS:M32BitMICounter16BitTicksLow, EAX + SBB CS:M32BitMICounter16BitTicksHigh, EDX + + Pop EDX + Pop EAX +ENDIF + + Mov BX, DI + Add BX, BX + + Assume DS:Driver + SegCS MovQ MM3, M32BitMIPXorMask + Assume DS:Nothing + +M32Bit16MIPanned1: + Test AL, 1 + JZ M32Bit16MIPanned2 + + Push AX + Mov [DS:10h], CX + Mov AX, [ES:BX] + Mov [DS:12h], CX + Add CX, BP + AdC DI, DX + Mov [DS:0], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:2], AX + Add BX, BX + + MovQ MM4, [DS:10h] + MovQ MM2, MM6 + MovQ MM0, [DS:0] + PSRLWI MM4, 1 + PXor MM4, MM3 + PMAddWD MM0, MM4 + PSRADI MM0, 15 + PUnpckLWD MM0, MM0 + PMulLW MM2, MM0 + PMulHW MM0, MM6 + PUnpckLWD MM2, MM0 + PAddD MM2, [SI] + MovQM [SI], MM2 + + Add SI, 8 + Pop AX + +M32Bit16MIPanned2: + Test AL, 2 + JZ M32Bit16MIPanned3 + + Push AX + Mov [DS:10h], CX + Mov AX, [ES:BX] + Mov [DS:12h], CX + Add CX, BP + AdC DI, DX + Mov [DS:0], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:2], AX + Add BX, BX + + Mov [DS:14h], CX + Mov AX, [ES:BX] + Mov [DS:16h], CX + Add CX, BP + AdC DI, DX + Mov [DS:4], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:6], AX + Add BX, BX + + MovQ MM4, [DS:10h] + MovQ MM2, MM6 + MovQ MM0, [DS:0] + PSRLWI MM4, 1 + + PXor MM4, MM3 + + PMAddWD MM0, MM4 + PSRADI MM0, 15 + PackSSDW MM0, MM0 + PUnpckLWD MM0, MM0 + PMulLW MM2, MM0 + PMulHW MM0, MM6 + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + PAddD MM2, [SI] + PUnpckHWD MM4, MM0 + PAddD MM4, [SI+8] + MovQM [SI], MM2 + MovQM [SI+8], MM4 + + Add SI, 10h + Pop AX + +M32Bit16MIPanned3: + ShR AX, 2 + JZ M32Bit16MIPannedEnd + + Mov [DS:20h], AX + + Mov [DS:10h], CX ; AGIs everywhere! + Mov AX, [ES:BX] + Mov [DS:12h], CX + Add CX, BP + AdC DI, DX + Mov [DS:0], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:2], AX + Add BX, BX + + Mov [DS:14h], CX + Mov AX, [ES:BX] + Mov [DS:16h], CX + Add CX, BP + AdC DI, DX + Mov [DS:4], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:6], AX + Add BX, BX + + MovQ MM5, [DS:10h] + + Mov [DS:10h], BP + Mov [DS:14h], BP + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:8], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:0Ah], AX + Add BX, BX + + Mov [DS:12h], BP + Mov [DS:16h], BP + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:0Ch], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:0Eh], AX + Add BX, BX + + Assume DS:Driver + SegCS MovQ MM4, M32BitMIPNotMask + Assume DS:Nothing + + MovQ MM7, [DS:10h] + PXor MM5, MM4 + + PAddW MM7, MM7 + MovQ MM2, MM5 + + PXor MM7, MM4 + PSRLWI MM2, 1 + + PSubW MM7, MM4 + PAddW MM5, MM7 + MovQ MM3, MM5 + + Dec Word Ptr [DS:20h] + JZ M32Bit16MIPanned5 + +M32Bit16MIPanned4: ; MM7 = delta offsets. + PMAddWD MM2, [DS:0] + PSRLWI MM3, 1 + +; Stall (2) + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:0], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:2], AX + Add BX, BX + + PMAddWD MM3, [DS:8] + PSRADI MM2, 15 + + PackSSDW MM2, MM2 + PAddW MM5, MM7 + + PUnpckLWD MM2, MM2 + MovQ MM0, MM6 + + PMulHW MM0, MM2 + PSRADI MM3, 15 + + PMulLW MM2, MM6 + PackSSDW MM3, MM3 + + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:4], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:6], AX + Add BX, BX + +; Stall (1) + MovQ MM4, MM2 + PUnpckLWD MM3, MM3 + + PUnpckLWD MM2, MM0 + MovQ MM1, MM6 + + PMulHW MM1, MM3 + PUnpckHWD MM4, MM0 + + PAddD MM2, [SI] + PMulLW MM3, MM6 + + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:8], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:0Ah], AX + Add BX, BX + +; Stall (1) + PAddD MM4, [SI+8] + MovQ MM0, MM3 ; + + MovQM [SI], MM2 + PUnpckLWD MM3, MM1 + + MovQM [SI+8], MM4 + PUnpckHWD MM0, MM1 + + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:0Ch], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:0Eh], AX + Add BX, BX + + PAddD MM3, [SI+10h] + MovQ MM2, MM5 + + PAddD MM0, [SI+18h] + PAddW MM5, MM7 + + MovQM [SI+10h], MM3 + MovQ MM3, MM5 + + MovQM [SI+18h], MM0 + PSRLWI MM2, 1 + + Add SI, 20h + Dec Word Ptr [DS:20h] + JNZ M32Bit16MIPanned4 + +M32Bit16MIPanned5: + PMAddWD MM2, [DS:0] + PSRLWI MM3, 1 + + PMAddWD MM3, [DS:8] + PSRADI MM2, 15 + + PackSSDW MM2, MM2 + PAddW MM5, MM7 + + PUnpckLWD MM2, MM2 + MovQ MM0, MM6 + + PMulHW MM0, MM2 + PSRADI MM3, 15 + + PMulLW MM2, MM6 + PackSSDW MM3, MM3 + + MovQ MM4, MM2 + PUnpckLWD MM3, MM3 + + PUnpckLWD MM2, MM0 + MovQ MM1, MM6 + + PMulHW MM1, MM3 + PUnpckHWD MM4, MM0 + + PAddD MM2, [SI] + PMulLW MM3, MM6 + + PAddD MM4, [SI+8] + MovQ MM0, MM3 + + MovQM [SI], MM2 + PUnpckLWD MM3, MM1 + + MovQM [SI+8], MM4 + PUnpckHWD MM0, MM1 + + PAddD MM3, [SI+10h] + PAddD MM0, [SI+18h] + MovQM [SI+10h], MM3 + MovQM [SI+18h], MM0 + +M32Bit16MIPannedEnd: +IF MONITORPERFORMANCE + RdTSC + Add CS:M32BitMICounter16BitTicksLow, EAX + AdC CS:M32BitMICounter16BitTicksHigh, EDX +ENDIF + Ret + +EndP M32Bit16MIPanned + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32Bit8MIPanned + +; AX = number to mix +; CX = error +; DX = deltaoffset +; BP = deltaerror +; DS:SI = 32-bit output buffer +; ES:DI = sample location +; MM6 = L/R volumes +; MM7 = PXor mask + +IF MONITORPERFORMANCE + Push EAX + Push EDX + + Add CS:M32BitMICounter8BitLow, AX + AdC CS:M32BitMICounter8BitHigh, 0 + + RdTSC + Sub CS:M32BitMICounter8BitTicksLow, EAX + SBB CS:M32BitMICounter8BitTicksHigh, EDX + + Pop EDX + Pop EAX +ENDIF + + Mov BX, AX + + And AX, 3 + JZ M32Bit8MIPanned3 + + Assume DS:Driver + SegCS MovQ MM3, M32BitMIPXorMask + Assume DS:Nothing + +M32Bit8MIPanned1: + Test AL, 1 + JZ M32Bit8MIPanned2 + + Mov AX, [ES:DI] + Mov [DS:10h], CX + Mov [DS:12h], CX + Add CX, BP + AdC DI, DX + + MovQ MM4, [DS:10h] + MovQ MM2, MM6 + MovD MM0, AX + PSRLWI MM4, 1 + PXor MM4, MM3 + PUnpckLBW MM0, MM0 + PMAddWD MM0, MM4 + PSRADI MM0, 15 + PUnpckLWD MM0, MM0 + PMulLW MM2, MM0 + PMulHW MM0, MM6 + PUnpckLWD MM2, MM0 + PAddD MM2, [SI] + MovQM [SI], MM2 + + Add SI, 8 + +M32Bit8MIPanned2: ; Mix 2 samples + Test BL, 2 + JZ M32Bit8MIPanned3 + + Mov AX, [ES:DI] + Mov [DS:10h], CX + Mov [DS:12h], CX + Add CX, BP + AdC DI, DX + Mov [DS:0], AX + + Mov AX, [ES:DI] + Mov [DS:14h], CX + Mov [DS:16h], CX + Add CX, BP + AdC DI, DX + Mov [DS:2], AX + + MovQ MM4, [DS:10h] + MovQ MM2, MM6 + MovQ MM0, [DS:0] + PSRLWI MM4, 1 + + PUnpckLBW MM0, MM0 + PXor MM4, MM3 + + PMAddWD MM0, MM4 + PSRADI MM0, 15 + PackSSDW MM0, MM0 + PUnpckLWD MM0, MM0 + PMulLW MM2, MM0 + PMulHW MM0, MM6 + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + PAddD MM2, [SI] + PUnpckHWD MM4, MM0 + PAddD MM4, [SI+8] + MovQM [SI], MM2 + MovQM [SI+8], MM4 + + Add SI, 10h + +M32Bit8MIPanned3: + ShR BX, 2 + JZ M32Bit8MIPannedEnd + +; Have to setup offset register and delta-offset register. + + Mov AX, [ES:DI] + Mov [DS:10h], ERROR + Mov [DS:12h], ERROR + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0], AX + + Mov AX, [ES:DI] + Mov [DS:14h], ERROR + Mov [DS:16h], ERROR + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:2], AX + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:18h], DELTAERROR + Mov [DS:8h], AX + Mov [DS:1Ah], DELTAERROR + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:1Ch], DELTAERROR + Mov [DS:0Ah], AX + Mov [DS:1Eh], DELTAERROR + + Assume DS:Driver + SegCS MovQ MM4, M32BitMIPNotMask + Assume DS:Nothing + + MovQ MM7, [DS:18h] + MovQ MM5, [DS:10h] + + PAddW MM7, MM7 + + PXor MM7, MM4 + PXor MM5, MM4 + + PSubW MM7, MM4 + + Dec BX + JZ M32Bit8MIPanned5 + +M32Bit8MIPanned4: + MovQ MM0, [DS:0] + MovQ MM2, MM5 + + MovQ MM1, [DS:8] + PUnpckLBW MM0, MM0 + + PAddW MM5, MM7 + PSRLWI MM2, 1 + + PMAddWD MM0, MM2 + PUnpckLBW MM1, MM1 + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0], AX + + PSRADI MM0, 15 + MovQ MM3, MM5 + + PAddW MM5, MM7 + PSRLWI MM3, 1 + + PMAddWD MM1, MM3 + PackSSDW MM0, MM0 + + MovQ MM2, MM6 + PUnpckLWD MM0, MM0 + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:2], AX + + PMulLW MM2, MM0 + PSRADI MM1, 15 + + PMulHW MM0, MM6 + PackSSDW MM1, MM1 + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + + MovQ MM4, MM2 + PUnpckLWD MM1, MM1 + + AdC DI, DELTAOFFSET + Mov [DS:8], AX + + MovQ MM3, MM6 + PUnpckLWD MM2, MM0 + + PAddD MM2, [SI] + PMulLW MM3, MM1 + + PMulHW MM1, MM6 + PUnpckHWD MM4, MM0 + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:0Ah], AX + + PAddD MM4, [SI+8] + MovQ MM0, MM3 + + MovQM [SI], MM2 + PUnpckLWD MM3, MM1 + + MovQM [SI+8], MM4 + PUnpckHWD MM0, MM1 + + PAddD MM3, [SI+10h] + PAddD MM0, [SI+18h] + + MovQM [SI+10h], MM3 + MovQM [SI+18h], MM0 + + Add SI, 20h + + Dec BX + JNZ M32Bit8MIPanned4 + +M32Bit8MIPanned5: + MovQ MM0, [DS:0] + MovQ MM2, MM5 + MovQ MM1, [DS:8] + PUnpckLBW MM0, MM0 + PAddW MM5, MM7 + PSRLWI MM2, 1 + + PMAddWD MM0, MM2 + PUnpckLBW MM1, MM1 + + PSRLWI MM5, 1 + + PMAddWD MM1, MM5 + PSRADI MM0, 15 + + MovQ MM2, MM6 + PackSSDW MM0, MM0 + + MovQ MM3, MM6 + PUnpckLWD MM0, MM0 + + PMulLW MM2, MM0 + PSRADI MM1, 15 + + PMulHW MM0, MM6 + PackSSDW MM1, MM1 + + PUnpckLWD MM1, MM1 + MovQ MM4, MM2 + + PMulLW MM3, MM1 + PUnpckLWD MM2, MM0 + + PMulHW MM1, MM6 + PUnpckHWD MM4, MM0 + + PAddD MM2, [SI] + MovQ MM5, MM3 + + PAddD MM4, [SI+8] + PUnpckLWD MM3, MM1 + + MovQM [SI], MM2 + PUnpckHWD MM5, MM1 + + PAddD MM3, [SI+10h] + PAddD MM5, [SI+18h] + + MovQM [SI+8], MM4 + MovQM [SI+10h], MM3 + MovQM [SI+18h], MM5 + +M32Bit8MIPannedEnd: +IF MONITORPERFORMANCE + RdTSC + Add CS:M32BitMICounter8BitTicksLow, EAX + AdC CS:M32BitMICounter8BitTicksHigh, EDX +ENDIF + Ret + +EndP M32Bit8MIPanned + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreM32BitMIPanned + Assume DS:Driver + + Mov EAX, [SI+0Ch] ; LEAX = left vol, HEAX = right vol + Mov [DWord Ptr CS:M32BitMIVolumeData], EAX + Mov [DWord Ptr CS:M32BitMIVolumeData+4], EAX + + SegCS MovQ MM6, M32BitMIVolumeData + + Ret + +EndP PreM32BitMIPanned + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M32BITMV.INC b/SoundDrivers/M32BITMV.INC index 2ae7a0f..a1c2603 100755 --- a/SoundDrivers/M32BITMV.INC +++ b/SoundDrivers/M32BITMV.INC @@ -1,12 +1,12 @@ -; 8 bit tables - - DW Offset MixNoLoop, PreM32BitMVPanned, MFS8Bit, MBS8Bit, M32Bit8MVPanned - DW Offset MixForwardsLoop, PreM32BitMVPanned, MFS8Bit, MBS8Bit, M32Bit8MVPanned - DW Offset MixPingPongLoop, PreM32BitMVPanned, MFS8Bit, MBS8Bit, M32Bit8MVPanned - -; 16 bit tables - - DW Offset MixNoLoop, PreM32BitMVPanned, MFS16Bit, MBS16Bit, M32Bit16MVPanned - DW Offset MixForwardsLoop, PreM32BitMVPanned, MFS16Bit, MBS16Bit, M32Bit16MVPanned - DW Offset MixPingPongLoop, PreM32BitMVPanned, MFS16Bit, MBS16Bit, M32Bit16MVPanned - +; 8 bit tables + + DW Offset MixNoLoop, PreM32BitMVPanned, MFS8Bit, MBS8Bit, M32Bit8MVPanned + DW Offset MixForwardsLoop, PreM32BitMVPanned, MFS8Bit, MBS8Bit, M32Bit8MVPanned + DW Offset MixPingPongLoop, PreM32BitMVPanned, MFS8Bit, MBS8Bit, M32Bit8MVPanned + +; 16 bit tables + + DW Offset MixNoLoop, PreM32BitMVPanned, MFS16Bit, MBS16Bit, M32Bit16MVPanned + DW Offset MixForwardsLoop, PreM32BitMVPanned, MFS16Bit, MBS16Bit, M32Bit16MVPanned + DW Offset MixPingPongLoop, PreM32BitMVPanned, MFS16Bit, MBS16Bit, M32Bit16MVPanned + diff --git a/SoundDrivers/M32BITMV.MIX b/SoundDrivers/M32BITMV.MIX index 2334538..133b746 100755 --- a/SoundDrivers/M32BITMV.MIX +++ b/SoundDrivers/M32BITMV.MIX @@ -1,798 +1,798 @@ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MONITORPERFORMANCE = 0 -RAMPSPEED = 7 -RAMPCOMPENSATE = 63 - -IF MONITORPERFORMANCE -ALIGN 16 -M32BitMICounter8BitTicksLow DD 0 -M32BitMICounter8BitTicksHigh DD 0 -M32BitMICounter16BitTicksLow DD 0 -M32BitMICounter16BitTicksHigh DD 0 -M32BitMICounter8BitLow DW 0 -M32BitMICounter8BitHigh DW 0 -M32BitMICounter16BitLow DW 0 -M32BitMICounter16BitHigh DW 0 -ENDIF - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32Bit16MVPanned - -; AX = number to mix -; CX = error -; DX = deltaoffset -; BP = deltaerror -; DS:SI = 32-bit output buffer -; ES:EDI+EDI = sample location -; MM6 = L/R volumes -; MM7 = PXor mask - -IF MONITORPERFORMANCE - Push EAX - Push EDX - - Add CS:M32BitMICounter16BitLow, AX - AdC CS:M32BitMICounter16BitHigh, 0 - - RdTSC - Sub CS:M32BitMICounter16BitTicksLow, EAX - SBB CS:M32BitMICounter16BitTicksHigh, EDX - - Pop EDX - Pop EAX -ENDIF - -; 16 bit code here - - Mov BX, DI - - Assume DS:Driver - SegCS MovQ MM1, M32BitMIPNotMask ; = FFFF0000FFFF0000h - Assume DS:Nothing - - Add BX, BX - - Test AL, 1 - JZ M32Bit16MVPanned2 - - Push AX - Mov [DS:8h], CX ; AGIs everywhere! - Mov AX, [ES:BX] - Mov [DS:0Ah], CX - Add CX, BP - AdC DI, DX - Mov [DS:10h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:12h], AX - Add BX, BX - - MovQ MM0, [DS:8h] - MovQ MM2, MM6 - PXor MM0, MM1 - PSRLWI MM0, 1 - PMAddWD MM0, [DS:10h] - PSRADI MM0, 15 - PUnpckLWD MM0, MM0 - PMulLW MM2, MM0 - MovQ MM4, [DS:0] ; VR - PMulHW MM0, MM6 - PSubW MM4, MM6 ; VR - PUnpckLWD MM2, MM0 - PAddD MM2, [SI] - PSRAWI MM4, RAMPSPEED ; VR - MovQM [SI], MM2 - PAddW MM6, MM4 ; VR - - Add SI, 8 - Pop AX - -M32Bit16MVPanned2: - Test AX, 2 - JZ M32Bit16MVPanned3 - - Push AX - Mov [DS:8h], CX ; AGIs everywhere! - Mov AX, [ES:BX] - Mov [DS:0Ah], CX - Add CX, BP - AdC DI, DX - Mov [DS:10h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:12h], AX - Add BX, BX - - Mov [DS:0Ch], CX - Mov AX, [ES:BX] - Mov [DS:0Eh], CX - Add CX, BP - AdC DI, DX - Mov [DS:14h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:16h], AX - Add BX, BX - - MovQ MM2, [DS:8] - PXor MM2, MM1 - PSRLWI MM2, 1 - PMAddWD MM2, [DS:10h] - PSRADI MM2, 15 - PackSSDW MM2, MM2 - PUnpckLWD MM2, MM2 - MovQ MM0, MM6 - PMulHW MM0, MM2 - PMulLW MM2, MM6 - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - MovQ MM5, [DS:0] ; VR - PUnpckHWD MM4, MM0 - PAddD MM2, [SI] - PSubW MM5, MM6 ; VR - PAddD MM4, [SI+8] - MovQM [SI], MM2 - PSRAWI MM5, RAMPSPEED-1 ; VR - MovQM [SI+8], MM4 - PAddW MM6, MM5 ; VR - - Pop AX - Add SI, 10h - -M32Bit16MVPanned3: - ShR AX, 2 - JZ M32Bit16MVPannedEnd - - Mov Word Ptr [DS:20h], AX - - Mov [DS:8h], CX ; AGIs everywhere! - Mov AX, [ES:BX] - Mov [DS:0Ah], CX - Add CX, BP - AdC DI, DX - Mov [DS:10h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:12h], AX - Add BX, BX - - Mov [DS:0Ch], CX - Mov AX, [ES:BX] - Mov [DS:0Eh], CX - Add CX, BP - AdC DI, DX - Mov [DS:14h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:16h], AX - Add BX, BX - - Mov [DS:28h], BP - Mov [DS:2Ch], BP - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:18h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:1Ah], AX - Add BX, BX - - Mov [DS:2Ah], BP - Mov [DS:2Eh], BP - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:1Ch], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:1Eh], AX - Add BX, BX - - MovQ MM7, [DS:28h] - - MovQ MM5, [DS:8] - PAddW MM7, MM7 - - PXor MM7, MM1 - PXor MM5, MM1 - - PSubW MM7, MM1 - - Dec Word Ptr [DS:20h] - JZ M32Bit16MVPanned5 - -M32Bit16MVPanned4: -; DS:0 = destination volume -; DS:10h = samples -; DS:18h = samples -; MM5 = offsets -; MM6 = current volume -; MM7 = delta offsets - MovQ MM2, MM5 - PAddW MM5, MM7 - - PSRLWI MM2, 1 - MovQ MM3, MM5 - - PMAddWD MM2, [DS:10h] - PSRLWI MM3, 1 - - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:10h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:12h], AX - Add BX, BX - - PSRADI MM2, 15 - PAddW MM5, MM7 - - PMAddWD MM3, [DS:18h] - PackSSDW MM2, MM2 - - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:14h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:16h], AX - Add BX, BX - - PUnpckLWD MM2, MM2 - MovQ MM0, MM6 - - PMulHW MM0, MM2 - PSRADI MM3, 15 - - PMulLW MM2, MM6 - PackSSDW MM3, MM3 - - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:18h], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:1Ah], AX - Add BX, BX - - MovQ MM1, [DS:0] ; Destination volume - PUnpckLWD MM3, MM3 - - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - - PSubW MM1, MM6 - PUnpckHWD MM4, MM0 - - PAddD MM2, [SI] - PSRAWI MM1, RAMPSPEED-1 - - PAddD MM4, [SI+8] - PAddW MM6, MM1 ; MM6 = new volume (ramped) - - MovQM [SI], MM2 - MovQ MM1, MM6 - - MovQ MM2, [DS:0] - PMulHW MM1, MM3 - - MovQM [SI+8], MM4 - PMulLW MM3, MM6 - - Add CX, BP - Mov AX, [ES:BX] - AdC DI, DX - Mov [DS:1Ch], AX - Mov AX, [ES:BX+2] - Mov BX, DI - Mov [DS:1Eh], AX - Add BX, BX - - MovQ MM0, MM3 - PUnpckLWD MM3, MM1 - - PAddD MM3, [SI+10h] - PUnpckHWD MM0, MM1 - - MovQM [SI+10h], MM3 - PSubW MM2, MM6 - - PAddD MM0, [SI+18h] - PSRAWI MM2, RAMPSPEED-1 - - MovQM [SI+18h], MM0 - PAddW MM6, MM2 - - Add SI, 20h - - Dec Word Ptr [DS:20h] - JNZ M32Bit16MVPanned4 - -M32Bit16MVPanned5: - MovQ MM2, MM5 - PAddW MM5, MM7 - - PSRLWI MM2, 1 - MovQ MM3, MM5 - - PMAddWD MM2, [DS:10h] - PSRLWI MM3, 1 - - PSRADI MM2, 15 - PAddW MM5, MM7 - - PMAddWD MM3, [DS:18h] - PackSSDW MM2, MM2 - - PUnpckLWD MM2, MM2 - MovQ MM0, MM6 - - PMulHW MM0, MM2 - PSRADI MM3, 15 - - PMulLW MM2, MM6 - PackSSDW MM3, MM3 - - MovQ MM1, [DS:0] ; Destination volume - PUnpckLWD MM3, MM3 - - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - - PSubW MM1, MM6 - PUnpckHWD MM4, MM0 - - PAddD MM2, [SI] - PSRAWI MM1, RAMPSPEED-1 - - PAddD MM4, [SI+8] - PAddW MM6, MM1 ; MM6 = new volume (ramped) - - MovQM [SI], MM2 - MovQ MM1, MM6 - - MovQ MM2, [DS:0] - PMulHW MM1, MM3 - - MovQM [SI+8], MM4 - PMulLW MM3, MM6 - - MovQ MM0, MM3 - PUnpckLWD MM3, MM1 - - PAddD MM3, [SI+10h] - PUnpckHWD MM0, MM1 - - MovQM [SI+10h], MM3 - PSubW MM2, MM6 - - PAddD MM0, [SI+18h] - PSRAWI MM2, RAMPSPEED-1 - - MovQM [SI+18h], MM0 - PAddW MM6, MM2 - -M32Bit16MVPannedEnd: - -IF MONITORPERFORMANCE - RdTSC - Add CS:M32BitMICounter16BitTicksLow, EAX - AdC CS:M32BitMICounter16BitTicksHigh, EDX -ENDIF - Ret - -EndP M32Bit16MVPanned - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32Bit8MVPanned - -; Layout of data in data segment -; DS:0 = destination volume -; DS:10h->1Fh = samples - -; AX = number to mix -; CX = error -; DX = deltaoffset -; BP = deltaerror -; DS:SI = 32-bit output buffer -; ES:DI = sample location -; MM6 = L/R volumes -; MM7 = PXor mask - -IF MONITORPERFORMANCE - Push EAX - Push EDX - - Add CS:M32BitMICounter8BitLow, AX - AdC CS:M32BitMICounter8BitHigh, 0 - - RdTSC - Sub CS:M32BitMICounter8BitTicksLow, EAX - SBB CS:M32BitMICounter8BitTicksHigh, EDX - - Pop EDX - Pop EAX -ENDIF - -; AX = number of samples to mix. -; DS:0 = destination volume -; DS:8 = SS -; DS:0Ch = SP -; DS:10h = sample setup -; MM6 = current volume. - - Mov BX, AX - - Assume DS:Driver - SegCS MovQ MM1, M32BitMIPNotMask ; = FFFF0000FFFF0000h - Assume DS:Nothing - - And AX, 3 - JZ M32Bit8MVPanned3 - -M32Bit8MVPanned1: - Test AL, 1 - JZ M32Bit8MVPanned2 - - Mov AX, [ES:DI] - Mov [DS:8h], CX - Mov [DS:0Ah], CX - Add CX, BP - AdC DI, DX - - MovQ MM4, [DS:8h] - MovQ MM2, MM6 - MovD MM0, AX - PXor MM4, MM1 - PSRLWI MM4, 1 - PUnpckLBW MM0, MM0 - PMAddWD MM0, MM4 - PSRADI MM0, 15 - PUnpckLWD MM0, MM0 - PMulLW MM2, MM0 - MovQ MM4, [DS:0] ; VR - PMulHW MM0, MM6 - PSubW MM4, MM6 ; VR - PUnpckLWD MM2, MM0 - PAddD MM2, [SI] - PSRAWI MM4, RAMPSPEED ; VR - MovQM [SI], MM2 - PAddW MM6, MM4 ; VR - - Add SI, 8 - -M32Bit8MVPanned2: - Test BL, 2 - JZ M32Bit8MVPanned3 - - Mov AX, [ES:DI] - Mov [DS:8h], CX - Mov [DS:0Ah], CX - Add CX, BP - AdC DI, DX - Mov [DS:10h], AX - - Mov AX, [ES:DI] - Mov [DS:0Ch], CX - Mov [DS:0Eh], CX - Add CX, BP - AdC DI, DX - Mov [DS:12h], AX - - MovQ MM0, [DS:10h] - MovQ MM2, [DS:8] - PXor MM2, MM1 - PUnpckLBW MM0, MM0 - PSRLWI MM2, 1 - PMAddWD MM2, MM0 - PSRADI MM2, 15 - PackSSDW MM2, MM2 - PUnpckLWD MM2, MM2 - MovQ MM0, MM6 - PMulHW MM0, MM2 - PMulLW MM2, MM6 - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - MovQ MM5, [DS:0] ; VR - PUnpckHWD MM4, MM0 - PAddD MM2, [SI] - PSubW MM5, MM6 ; VR - PAddD MM4, [SI+8] - MovQM [SI], MM2 - PSRAWI MM5, RAMPSPEED-1 ; VR - MovQM [SI+8], MM4 - PAddW MM6, MM5 ; VR - - Add SI, 10h - -M32Bit8MVPanned3: - ShR BX, 2 - JZ M32Bit8MVPannedEnd - - Mov AX, [ES:DI] - Mov [DS:8h], ERROR - Mov [DS:0Ah], ERROR - Add ERROR, BP - AdC DI, DELTAOFFSET - Mov [DS:10h], AX - - Mov AX, [ES:DI] - Mov [DS:0Ch], ERROR - Mov [DS:0Eh], ERROR - Add ERROR, BP - AdC DI, DELTAOFFSET - Mov [DS:12h], AX - - Mov AX, [ES:DI] - Add ERROR, BP - AdC DI, DELTAOFFSET - Mov [DS:28h], BP - Mov [DS:18h], AX - Mov [DS:2Ah], BP - - Mov AX, [ES:DI] - Add ERROR, BP - AdC DI, DELTAOFFSET - Mov [DS:2Ch], BP - Mov [DS:1Ah], AX - Mov [DS:2Eh], BP - - MovQ MM7, [DS:28h] - - MovQ MM5, [DS:8] - PAddW MM7, MM7 - - PXor MM7, MM1 - PXor MM5, MM1 - - PSubW MM7, MM1 - - Dec BX - JZ M32Bit8MVPanned5 - -M32Bit8MVPanned4: -; DS:0 = destination volume -; DS:10h = samples -; DS:18h = samples -; MM5 = offsets -; MM6 = current volume -; MM7 = delta offsets - MovQ MM0, [DS:10h] - MovQ MM2, MM5 - - MovQ MM1, [DS:18h] - PUnpckLBW MM0, MM0 - - PSRLWI MM2, 1 - PAddW MM5, MM7 - - PMAddWD MM2, MM0 - PUnpckLBW MM1, MM1 - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:10h], AX - - PSRADI MM2, 15 - MovQ MM3, MM5 - - PAddW MM5, MM7 - PSRLWI MM3, 1 - - PMAddWD MM3, MM1 - PackSSDW MM2, MM2 - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:12h], AX - - PUnpckLWD MM2, MM2 - MovQ MM0, MM6 - - PMulHW MM0, MM2 - PSRADI MM3, 15 - - PMulLW MM2, MM6 - PackSSDW MM3, MM3 - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:18h], AX - - MovQ MM1, [DS:0] ; Destination volume - PUnpckLWD MM3, MM3 - - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - - PSubW MM1, MM6 - PUnpckHWD MM4, MM0 - - PAddD MM2, [SI] - PSRAWI MM1, RAMPSPEED-1 - - PAddD MM4, [SI+8] - PAddW MM6, MM1 ; MM6 = new volume (ramped) - - MovQM [SI], MM2 - MovQ MM1, MM6 - - MovQ MM2, [DS:0] - PMulHW MM1, MM3 - - MovQM [SI+8], MM4 - PMulLW MM3, MM6 - - Mov AX, [ES:DI] - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - Mov [DS:1Ah], AX - - MovQ MM0, MM3 - PUnpckLWD MM3, MM1 - - PAddD MM3, [SI+10h] - PUnpckHWD MM0, MM1 - - MovQM [SI+10h], MM3 - PSubW MM2, MM6 - - PAddD MM0, [SI+18h] - PSRAWI MM2, RAMPSPEED-1 - - MovQM [SI+18h], MM0 - PAddW MM6, MM2 - - Add SI, 20h - - Dec BX - JNZ M32Bit8MVPanned4 - -M32Bit8MVPanned5: - MovQ MM0, [DS:10h] - MovQ MM2, MM5 - - MovQ MM1, [DS:18h] - PUnpckLBW MM0, MM0 - - PSRLWI MM2, 1 - PAddW MM5, MM7 - - PMAddWD MM2, MM0 - PUnpckLBW MM1, MM1 - - PSRADI MM2, 15 - MovQ MM3, MM5 - - PAddW MM5, MM7 - PSRLWI MM3, 1 - - PMAddWD MM3, MM1 - PackSSDW MM2, MM2 - - PUnpckLWD MM2, MM2 - MovQ MM0, MM6 - - PMulHW MM0, MM2 - PSRADI MM3, 15 - - PMulLW MM2, MM6 - PackSSDW MM3, MM3 - - MovQ MM1, [DS:0] ; Destination volume - PUnpckLWD MM3, MM3 - - MovQ MM4, MM2 - PUnpckLWD MM2, MM0 - - PSubW MM1, MM6 - PUnpckHWD MM4, MM0 - - PAddD MM2, [SI] - PSRAWI MM1, RAMPSPEED-1 - - PAddD MM4, [SI+8] - PAddW MM6, MM1 ; MM6 = new volume (ramped) - - MovQM [SI], MM2 - MovQ MM1, MM6 - - MovQ MM2, [DS:0] - PMulHW MM1, MM3 - - MovQM [SI+8], MM4 - PMulLW MM3, MM6 - - MovQ MM0, MM3 - PUnpckLWD MM3, MM1 - - PAddD MM3, [SI+10h] - PUnpckHWD MM0, MM1 - - MovQM [SI+10h], MM3 - PSubW MM2, MM6 - - PAddD MM0, [SI+18h] - PSRAWI MM2, RAMPSPEED-1 - - MovQM [SI+18h], MM0 - PAddW MM6, MM2 - -M32Bit8MVPannedEnd: -IF MONITORPERFORMANCE - RdTSC - Add CS:M32BitMICounter8BitTicksLow, EAX - AdC CS:M32BitMICounter8BitTicksHigh, EDX -ENDIF - Ret - -EndP M32Bit8MVPanned - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreM32BitMVPanned - Assume DS:Driver - - Mov ES, CS:MixSegment - - Mov AX, [SI+0Ch] ; AX = destination left - Mov BX, [SI+1Ch] ; BX = current left - Mov CX, [SI+0Eh] ; CX = destination right - Mov DX, [SI+1Eh] ; DX = current right. - - Cmp AX, BX - JL PreM32BitMVPannedV1 - - Add AX, RAMPCOMPENSATE - -PreM32BitMVPannedV1: - Cmp CX, DX - JL PreM32BitMVPannedV2 - - Add CX, RAMPCOMPENSATE - -PreM32BitMVPannedV2: - Sub Word Ptr [SI+8], 60 - - Mov [Word Ptr ES:0], AX - Mov [Word Ptr ES:4], AX - Mov [Word Ptr ES:2], CX - Mov [Word Ptr ES:6], CX - - Mov [CS:M32BitMIVolumeData], BX - Mov [CS:M32BitMIVolumeData+2], DX - - Sub AX, BX - Sub CX, DX - - SAR AX, RAMPSPEED - SAR CX, RAMPSPEED - - Add BX, AX - Add DX, CX - - Mov [CS:M32BitMIVolumeData+4], BX - Mov [CS:M32BitMIVolumeData+6], DX - - SegCS MovQ MM6, M32BitMIVolumeData - - Ret - -EndP PreM32BitMVPanned - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MONITORPERFORMANCE = 0 +RAMPSPEED = 7 +RAMPCOMPENSATE = 63 + +IF MONITORPERFORMANCE +ALIGN 16 +M32BitMICounter8BitTicksLow DD 0 +M32BitMICounter8BitTicksHigh DD 0 +M32BitMICounter16BitTicksLow DD 0 +M32BitMICounter16BitTicksHigh DD 0 +M32BitMICounter8BitLow DW 0 +M32BitMICounter8BitHigh DW 0 +M32BitMICounter16BitLow DW 0 +M32BitMICounter16BitHigh DW 0 +ENDIF + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32Bit16MVPanned + +; AX = number to mix +; CX = error +; DX = deltaoffset +; BP = deltaerror +; DS:SI = 32-bit output buffer +; ES:EDI+EDI = sample location +; MM6 = L/R volumes +; MM7 = PXor mask + +IF MONITORPERFORMANCE + Push EAX + Push EDX + + Add CS:M32BitMICounter16BitLow, AX + AdC CS:M32BitMICounter16BitHigh, 0 + + RdTSC + Sub CS:M32BitMICounter16BitTicksLow, EAX + SBB CS:M32BitMICounter16BitTicksHigh, EDX + + Pop EDX + Pop EAX +ENDIF + +; 16 bit code here + + Mov BX, DI + + Assume DS:Driver + SegCS MovQ MM1, M32BitMIPNotMask ; = FFFF0000FFFF0000h + Assume DS:Nothing + + Add BX, BX + + Test AL, 1 + JZ M32Bit16MVPanned2 + + Push AX + Mov [DS:8h], CX ; AGIs everywhere! + Mov AX, [ES:BX] + Mov [DS:0Ah], CX + Add CX, BP + AdC DI, DX + Mov [DS:10h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:12h], AX + Add BX, BX + + MovQ MM0, [DS:8h] + MovQ MM2, MM6 + PXor MM0, MM1 + PSRLWI MM0, 1 + PMAddWD MM0, [DS:10h] + PSRADI MM0, 15 + PUnpckLWD MM0, MM0 + PMulLW MM2, MM0 + MovQ MM4, [DS:0] ; VR + PMulHW MM0, MM6 + PSubW MM4, MM6 ; VR + PUnpckLWD MM2, MM0 + PAddD MM2, [SI] + PSRAWI MM4, RAMPSPEED ; VR + MovQM [SI], MM2 + PAddW MM6, MM4 ; VR + + Add SI, 8 + Pop AX + +M32Bit16MVPanned2: + Test AX, 2 + JZ M32Bit16MVPanned3 + + Push AX + Mov [DS:8h], CX ; AGIs everywhere! + Mov AX, [ES:BX] + Mov [DS:0Ah], CX + Add CX, BP + AdC DI, DX + Mov [DS:10h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:12h], AX + Add BX, BX + + Mov [DS:0Ch], CX + Mov AX, [ES:BX] + Mov [DS:0Eh], CX + Add CX, BP + AdC DI, DX + Mov [DS:14h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:16h], AX + Add BX, BX + + MovQ MM2, [DS:8] + PXor MM2, MM1 + PSRLWI MM2, 1 + PMAddWD MM2, [DS:10h] + PSRADI MM2, 15 + PackSSDW MM2, MM2 + PUnpckLWD MM2, MM2 + MovQ MM0, MM6 + PMulHW MM0, MM2 + PMulLW MM2, MM6 + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + MovQ MM5, [DS:0] ; VR + PUnpckHWD MM4, MM0 + PAddD MM2, [SI] + PSubW MM5, MM6 ; VR + PAddD MM4, [SI+8] + MovQM [SI], MM2 + PSRAWI MM5, RAMPSPEED-1 ; VR + MovQM [SI+8], MM4 + PAddW MM6, MM5 ; VR + + Pop AX + Add SI, 10h + +M32Bit16MVPanned3: + ShR AX, 2 + JZ M32Bit16MVPannedEnd + + Mov Word Ptr [DS:20h], AX + + Mov [DS:8h], CX ; AGIs everywhere! + Mov AX, [ES:BX] + Mov [DS:0Ah], CX + Add CX, BP + AdC DI, DX + Mov [DS:10h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:12h], AX + Add BX, BX + + Mov [DS:0Ch], CX + Mov AX, [ES:BX] + Mov [DS:0Eh], CX + Add CX, BP + AdC DI, DX + Mov [DS:14h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:16h], AX + Add BX, BX + + Mov [DS:28h], BP + Mov [DS:2Ch], BP + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:18h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:1Ah], AX + Add BX, BX + + Mov [DS:2Ah], BP + Mov [DS:2Eh], BP + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:1Ch], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:1Eh], AX + Add BX, BX + + MovQ MM7, [DS:28h] + + MovQ MM5, [DS:8] + PAddW MM7, MM7 + + PXor MM7, MM1 + PXor MM5, MM1 + + PSubW MM7, MM1 + + Dec Word Ptr [DS:20h] + JZ M32Bit16MVPanned5 + +M32Bit16MVPanned4: +; DS:0 = destination volume +; DS:10h = samples +; DS:18h = samples +; MM5 = offsets +; MM6 = current volume +; MM7 = delta offsets + MovQ MM2, MM5 + PAddW MM5, MM7 + + PSRLWI MM2, 1 + MovQ MM3, MM5 + + PMAddWD MM2, [DS:10h] + PSRLWI MM3, 1 + + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:10h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:12h], AX + Add BX, BX + + PSRADI MM2, 15 + PAddW MM5, MM7 + + PMAddWD MM3, [DS:18h] + PackSSDW MM2, MM2 + + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:14h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:16h], AX + Add BX, BX + + PUnpckLWD MM2, MM2 + MovQ MM0, MM6 + + PMulHW MM0, MM2 + PSRADI MM3, 15 + + PMulLW MM2, MM6 + PackSSDW MM3, MM3 + + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:18h], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:1Ah], AX + Add BX, BX + + MovQ MM1, [DS:0] ; Destination volume + PUnpckLWD MM3, MM3 + + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + + PSubW MM1, MM6 + PUnpckHWD MM4, MM0 + + PAddD MM2, [SI] + PSRAWI MM1, RAMPSPEED-1 + + PAddD MM4, [SI+8] + PAddW MM6, MM1 ; MM6 = new volume (ramped) + + MovQM [SI], MM2 + MovQ MM1, MM6 + + MovQ MM2, [DS:0] + PMulHW MM1, MM3 + + MovQM [SI+8], MM4 + PMulLW MM3, MM6 + + Add CX, BP + Mov AX, [ES:BX] + AdC DI, DX + Mov [DS:1Ch], AX + Mov AX, [ES:BX+2] + Mov BX, DI + Mov [DS:1Eh], AX + Add BX, BX + + MovQ MM0, MM3 + PUnpckLWD MM3, MM1 + + PAddD MM3, [SI+10h] + PUnpckHWD MM0, MM1 + + MovQM [SI+10h], MM3 + PSubW MM2, MM6 + + PAddD MM0, [SI+18h] + PSRAWI MM2, RAMPSPEED-1 + + MovQM [SI+18h], MM0 + PAddW MM6, MM2 + + Add SI, 20h + + Dec Word Ptr [DS:20h] + JNZ M32Bit16MVPanned4 + +M32Bit16MVPanned5: + MovQ MM2, MM5 + PAddW MM5, MM7 + + PSRLWI MM2, 1 + MovQ MM3, MM5 + + PMAddWD MM2, [DS:10h] + PSRLWI MM3, 1 + + PSRADI MM2, 15 + PAddW MM5, MM7 + + PMAddWD MM3, [DS:18h] + PackSSDW MM2, MM2 + + PUnpckLWD MM2, MM2 + MovQ MM0, MM6 + + PMulHW MM0, MM2 + PSRADI MM3, 15 + + PMulLW MM2, MM6 + PackSSDW MM3, MM3 + + MovQ MM1, [DS:0] ; Destination volume + PUnpckLWD MM3, MM3 + + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + + PSubW MM1, MM6 + PUnpckHWD MM4, MM0 + + PAddD MM2, [SI] + PSRAWI MM1, RAMPSPEED-1 + + PAddD MM4, [SI+8] + PAddW MM6, MM1 ; MM6 = new volume (ramped) + + MovQM [SI], MM2 + MovQ MM1, MM6 + + MovQ MM2, [DS:0] + PMulHW MM1, MM3 + + MovQM [SI+8], MM4 + PMulLW MM3, MM6 + + MovQ MM0, MM3 + PUnpckLWD MM3, MM1 + + PAddD MM3, [SI+10h] + PUnpckHWD MM0, MM1 + + MovQM [SI+10h], MM3 + PSubW MM2, MM6 + + PAddD MM0, [SI+18h] + PSRAWI MM2, RAMPSPEED-1 + + MovQM [SI+18h], MM0 + PAddW MM6, MM2 + +M32Bit16MVPannedEnd: + +IF MONITORPERFORMANCE + RdTSC + Add CS:M32BitMICounter16BitTicksLow, EAX + AdC CS:M32BitMICounter16BitTicksHigh, EDX +ENDIF + Ret + +EndP M32Bit16MVPanned + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32Bit8MVPanned + +; Layout of data in data segment +; DS:0 = destination volume +; DS:10h->1Fh = samples + +; AX = number to mix +; CX = error +; DX = deltaoffset +; BP = deltaerror +; DS:SI = 32-bit output buffer +; ES:DI = sample location +; MM6 = L/R volumes +; MM7 = PXor mask + +IF MONITORPERFORMANCE + Push EAX + Push EDX + + Add CS:M32BitMICounter8BitLow, AX + AdC CS:M32BitMICounter8BitHigh, 0 + + RdTSC + Sub CS:M32BitMICounter8BitTicksLow, EAX + SBB CS:M32BitMICounter8BitTicksHigh, EDX + + Pop EDX + Pop EAX +ENDIF + +; AX = number of samples to mix. +; DS:0 = destination volume +; DS:8 = SS +; DS:0Ch = SP +; DS:10h = sample setup +; MM6 = current volume. + + Mov BX, AX + + Assume DS:Driver + SegCS MovQ MM1, M32BitMIPNotMask ; = FFFF0000FFFF0000h + Assume DS:Nothing + + And AX, 3 + JZ M32Bit8MVPanned3 + +M32Bit8MVPanned1: + Test AL, 1 + JZ M32Bit8MVPanned2 + + Mov AX, [ES:DI] + Mov [DS:8h], CX + Mov [DS:0Ah], CX + Add CX, BP + AdC DI, DX + + MovQ MM4, [DS:8h] + MovQ MM2, MM6 + MovD MM0, AX + PXor MM4, MM1 + PSRLWI MM4, 1 + PUnpckLBW MM0, MM0 + PMAddWD MM0, MM4 + PSRADI MM0, 15 + PUnpckLWD MM0, MM0 + PMulLW MM2, MM0 + MovQ MM4, [DS:0] ; VR + PMulHW MM0, MM6 + PSubW MM4, MM6 ; VR + PUnpckLWD MM2, MM0 + PAddD MM2, [SI] + PSRAWI MM4, RAMPSPEED ; VR + MovQM [SI], MM2 + PAddW MM6, MM4 ; VR + + Add SI, 8 + +M32Bit8MVPanned2: + Test BL, 2 + JZ M32Bit8MVPanned3 + + Mov AX, [ES:DI] + Mov [DS:8h], CX + Mov [DS:0Ah], CX + Add CX, BP + AdC DI, DX + Mov [DS:10h], AX + + Mov AX, [ES:DI] + Mov [DS:0Ch], CX + Mov [DS:0Eh], CX + Add CX, BP + AdC DI, DX + Mov [DS:12h], AX + + MovQ MM0, [DS:10h] + MovQ MM2, [DS:8] + PXor MM2, MM1 + PUnpckLBW MM0, MM0 + PSRLWI MM2, 1 + PMAddWD MM2, MM0 + PSRADI MM2, 15 + PackSSDW MM2, MM2 + PUnpckLWD MM2, MM2 + MovQ MM0, MM6 + PMulHW MM0, MM2 + PMulLW MM2, MM6 + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + MovQ MM5, [DS:0] ; VR + PUnpckHWD MM4, MM0 + PAddD MM2, [SI] + PSubW MM5, MM6 ; VR + PAddD MM4, [SI+8] + MovQM [SI], MM2 + PSRAWI MM5, RAMPSPEED-1 ; VR + MovQM [SI+8], MM4 + PAddW MM6, MM5 ; VR + + Add SI, 10h + +M32Bit8MVPanned3: + ShR BX, 2 + JZ M32Bit8MVPannedEnd + + Mov AX, [ES:DI] + Mov [DS:8h], ERROR + Mov [DS:0Ah], ERROR + Add ERROR, BP + AdC DI, DELTAOFFSET + Mov [DS:10h], AX + + Mov AX, [ES:DI] + Mov [DS:0Ch], ERROR + Mov [DS:0Eh], ERROR + Add ERROR, BP + AdC DI, DELTAOFFSET + Mov [DS:12h], AX + + Mov AX, [ES:DI] + Add ERROR, BP + AdC DI, DELTAOFFSET + Mov [DS:28h], BP + Mov [DS:18h], AX + Mov [DS:2Ah], BP + + Mov AX, [ES:DI] + Add ERROR, BP + AdC DI, DELTAOFFSET + Mov [DS:2Ch], BP + Mov [DS:1Ah], AX + Mov [DS:2Eh], BP + + MovQ MM7, [DS:28h] + + MovQ MM5, [DS:8] + PAddW MM7, MM7 + + PXor MM7, MM1 + PXor MM5, MM1 + + PSubW MM7, MM1 + + Dec BX + JZ M32Bit8MVPanned5 + +M32Bit8MVPanned4: +; DS:0 = destination volume +; DS:10h = samples +; DS:18h = samples +; MM5 = offsets +; MM6 = current volume +; MM7 = delta offsets + MovQ MM0, [DS:10h] + MovQ MM2, MM5 + + MovQ MM1, [DS:18h] + PUnpckLBW MM0, MM0 + + PSRLWI MM2, 1 + PAddW MM5, MM7 + + PMAddWD MM2, MM0 + PUnpckLBW MM1, MM1 + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:10h], AX + + PSRADI MM2, 15 + MovQ MM3, MM5 + + PAddW MM5, MM7 + PSRLWI MM3, 1 + + PMAddWD MM3, MM1 + PackSSDW MM2, MM2 + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:12h], AX + + PUnpckLWD MM2, MM2 + MovQ MM0, MM6 + + PMulHW MM0, MM2 + PSRADI MM3, 15 + + PMulLW MM2, MM6 + PackSSDW MM3, MM3 + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:18h], AX + + MovQ MM1, [DS:0] ; Destination volume + PUnpckLWD MM3, MM3 + + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + + PSubW MM1, MM6 + PUnpckHWD MM4, MM0 + + PAddD MM2, [SI] + PSRAWI MM1, RAMPSPEED-1 + + PAddD MM4, [SI+8] + PAddW MM6, MM1 ; MM6 = new volume (ramped) + + MovQM [SI], MM2 + MovQ MM1, MM6 + + MovQ MM2, [DS:0] + PMulHW MM1, MM3 + + MovQM [SI+8], MM4 + PMulLW MM3, MM6 + + Mov AX, [ES:DI] + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + Mov [DS:1Ah], AX + + MovQ MM0, MM3 + PUnpckLWD MM3, MM1 + + PAddD MM3, [SI+10h] + PUnpckHWD MM0, MM1 + + MovQM [SI+10h], MM3 + PSubW MM2, MM6 + + PAddD MM0, [SI+18h] + PSRAWI MM2, RAMPSPEED-1 + + MovQM [SI+18h], MM0 + PAddW MM6, MM2 + + Add SI, 20h + + Dec BX + JNZ M32Bit8MVPanned4 + +M32Bit8MVPanned5: + MovQ MM0, [DS:10h] + MovQ MM2, MM5 + + MovQ MM1, [DS:18h] + PUnpckLBW MM0, MM0 + + PSRLWI MM2, 1 + PAddW MM5, MM7 + + PMAddWD MM2, MM0 + PUnpckLBW MM1, MM1 + + PSRADI MM2, 15 + MovQ MM3, MM5 + + PAddW MM5, MM7 + PSRLWI MM3, 1 + + PMAddWD MM3, MM1 + PackSSDW MM2, MM2 + + PUnpckLWD MM2, MM2 + MovQ MM0, MM6 + + PMulHW MM0, MM2 + PSRADI MM3, 15 + + PMulLW MM2, MM6 + PackSSDW MM3, MM3 + + MovQ MM1, [DS:0] ; Destination volume + PUnpckLWD MM3, MM3 + + MovQ MM4, MM2 + PUnpckLWD MM2, MM0 + + PSubW MM1, MM6 + PUnpckHWD MM4, MM0 + + PAddD MM2, [SI] + PSRAWI MM1, RAMPSPEED-1 + + PAddD MM4, [SI+8] + PAddW MM6, MM1 ; MM6 = new volume (ramped) + + MovQM [SI], MM2 + MovQ MM1, MM6 + + MovQ MM2, [DS:0] + PMulHW MM1, MM3 + + MovQM [SI+8], MM4 + PMulLW MM3, MM6 + + MovQ MM0, MM3 + PUnpckLWD MM3, MM1 + + PAddD MM3, [SI+10h] + PUnpckHWD MM0, MM1 + + MovQM [SI+10h], MM3 + PSubW MM2, MM6 + + PAddD MM0, [SI+18h] + PSRAWI MM2, RAMPSPEED-1 + + MovQM [SI+18h], MM0 + PAddW MM6, MM2 + +M32Bit8MVPannedEnd: +IF MONITORPERFORMANCE + RdTSC + Add CS:M32BitMICounter8BitTicksLow, EAX + AdC CS:M32BitMICounter8BitTicksHigh, EDX +ENDIF + Ret + +EndP M32Bit8MVPanned + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreM32BitMVPanned + Assume DS:Driver + + Mov ES, CS:MixSegment + + Mov AX, [SI+0Ch] ; AX = destination left + Mov BX, [SI+1Ch] ; BX = current left + Mov CX, [SI+0Eh] ; CX = destination right + Mov DX, [SI+1Eh] ; DX = current right. + + Cmp AX, BX + JL PreM32BitMVPannedV1 + + Add AX, RAMPCOMPENSATE + +PreM32BitMVPannedV1: + Cmp CX, DX + JL PreM32BitMVPannedV2 + + Add CX, RAMPCOMPENSATE + +PreM32BitMVPannedV2: + Sub Word Ptr [SI+8], 60 + + Mov [Word Ptr ES:0], AX + Mov [Word Ptr ES:4], AX + Mov [Word Ptr ES:2], CX + Mov [Word Ptr ES:6], CX + + Mov [CS:M32BitMIVolumeData], BX + Mov [CS:M32BitMIVolumeData+2], DX + + Sub AX, BX + Sub CX, DX + + SAR AX, RAMPSPEED + SAR CX, RAMPSPEED + + Add BX, AX + Add DX, CX + + Mov [CS:M32BitMIVolumeData+4], BX + Mov [CS:M32BitMIVolumeData+6], DX + + SegCS MovQ MM6, M32BitMIVolumeData + + Ret + +EndP PreM32BitMVPanned + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/M32ULTRA.INC b/SoundDrivers/M32ULTRA.INC index 50b693f..ef6ee0f 100755 --- a/SoundDrivers/M32ULTRA.INC +++ b/SoundDrivers/M32ULTRA.INC @@ -1,49 +1,49 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMixUltraLeft8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI - DW Offset MixForwardsLoop, PreMixUltraLeft8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI - DW Offset MixPingPongLoop, PreMixUltraLeft8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI - ; Right only - DW Offset MixNoLoop, PreMixUltraRight8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI - DW Offset MixForwardsLoop, PreMixUltraRight8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI - DW Offset MixPingPongLoop, PreMixUltraRight8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI - ; Central - DW Offset MixNoLoop, PreMixUltraCentral8BitI, MFS8Bit, MBS8Bit, MixUltraCentral8BitI - DW Offset MixForwardsLoop, PreMixUltraCentral8BitI, MFS8Bit, MBS8Bit, MixUltraCentral8BitI - DW Offset MixPingPongLoop, PreMixUltraCentral8BitI, MFS8Bit, MBS8Bit, MixUltraCentral8BitI - ; Stereo - DW Offset MixNoLoop, PreMixUltraPanned8BitI, MFS8Bit, MBS8Bit, MixUltraPanned8BitI - DW Offset MixForwardsLoop, PreMixUltraPanned8BitI, MFS8Bit, MBS8Bit, MixUltraPanned8BitI - DW Offset MixPingPongLoop, PreMixUltraPanned8BitI, MFS8Bit, MBS8Bit, MixUltraPanned8BitI - ; Surround - DW Offset MixNoLoop, PreMixUltraSurround8BitI, MFS8Bit, MBS8Bit, MixUltraSurround8BitI - DW Offset MixForwardsLoop, PreMixUltraSurround8BitI, MFS8Bit, MBS8Bit, MixUltraSurround8BitI - DW Offset MixPingPongLoop, PreMixUltraSurround8BitI, MFS8Bit, MBS8Bit, MixUltraSurround8BitI - - ; 16 bit tables - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Left only - DW Offset MixNoLoop, PreMixUltraLeft16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI - DW Offset MixForwardsLoop, PreMixUltraLeft16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI - DW Offset MixPingPongLoop, PreMixUltraLeft16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI - ; Right only - DW Offset MixNoLoop, PreMixUltraRight16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI - DW Offset MixForwardsLoop, PreMixUltraRight16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI - DW Offset MixPingPongLoop, PreMixUltraRight16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI - ; Central - DW Offset MixNoLoop, PreMixUltraCentral16BitI, MFS16Bit, MBS16Bit, MixUltraCentral16BitI - DW Offset MixForwardsLoop, PreMixUltraCentral16BitI, MFS16Bit, MBS16Bit, MixUltraCentral16BitI - DW Offset MixPingPongLoop, PreMixUltraCentral16BitI, MFS16Bit, MBS16Bit, MixUltraCentral16BitI - ; Stereo - DW Offset MixNoLoop, PreMixUltraPanned16BitI, MFS16Bit, MBS16Bit, MixUltraPanned16BitI - DW Offset MixForwardsLoop, PreMixUltraPanned16BitI, MFS16Bit, MBS16Bit, MixUltraPanned16BitI - DW Offset MixPingPongLoop, PreMixUltraPanned16BitI, MFS16Bit, MBS16Bit, MixUltraPanned16BitI - ; Surround - DW Offset MixNoLoop, PreMixUltraSurround16BitI, MFS16Bit, MBS16Bit, MixUltraSurround16BitI - DW Offset MixForwardsLoop, PreMixUltraSurround16BitI, MFS16Bit, MBS16Bit, MixUltraSurround16BitI - DW Offset MixPingPongLoop, PreMixUltraSurround16BitI, MFS16Bit, MBS16Bit, MixUltraSurround16BitI + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMixUltraLeft8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI + DW Offset MixForwardsLoop, PreMixUltraLeft8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI + DW Offset MixPingPongLoop, PreMixUltraLeft8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI + ; Right only + DW Offset MixNoLoop, PreMixUltraRight8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI + DW Offset MixForwardsLoop, PreMixUltraRight8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI + DW Offset MixPingPongLoop, PreMixUltraRight8BitI, MFS8Bit, MBS8Bit, MixUltraSingle8BitI + ; Central + DW Offset MixNoLoop, PreMixUltraCentral8BitI, MFS8Bit, MBS8Bit, MixUltraCentral8BitI + DW Offset MixForwardsLoop, PreMixUltraCentral8BitI, MFS8Bit, MBS8Bit, MixUltraCentral8BitI + DW Offset MixPingPongLoop, PreMixUltraCentral8BitI, MFS8Bit, MBS8Bit, MixUltraCentral8BitI + ; Stereo + DW Offset MixNoLoop, PreMixUltraPanned8BitI, MFS8Bit, MBS8Bit, MixUltraPanned8BitI + DW Offset MixForwardsLoop, PreMixUltraPanned8BitI, MFS8Bit, MBS8Bit, MixUltraPanned8BitI + DW Offset MixPingPongLoop, PreMixUltraPanned8BitI, MFS8Bit, MBS8Bit, MixUltraPanned8BitI + ; Surround + DW Offset MixNoLoop, PreMixUltraSurround8BitI, MFS8Bit, MBS8Bit, MixUltraSurround8BitI + DW Offset MixForwardsLoop, PreMixUltraSurround8BitI, MFS8Bit, MBS8Bit, MixUltraSurround8BitI + DW Offset MixPingPongLoop, PreMixUltraSurround8BitI, MFS8Bit, MBS8Bit, MixUltraSurround8BitI + + ; 16 bit tables + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Left only + DW Offset MixNoLoop, PreMixUltraLeft16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI + DW Offset MixForwardsLoop, PreMixUltraLeft16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI + DW Offset MixPingPongLoop, PreMixUltraLeft16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI + ; Right only + DW Offset MixNoLoop, PreMixUltraRight16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI + DW Offset MixForwardsLoop, PreMixUltraRight16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI + DW Offset MixPingPongLoop, PreMixUltraRight16BitI, MFS16Bit, MBS16Bit, MixUltraSingle16BitI + ; Central + DW Offset MixNoLoop, PreMixUltraCentral16BitI, MFS16Bit, MBS16Bit, MixUltraCentral16BitI + DW Offset MixForwardsLoop, PreMixUltraCentral16BitI, MFS16Bit, MBS16Bit, MixUltraCentral16BitI + DW Offset MixPingPongLoop, PreMixUltraCentral16BitI, MFS16Bit, MBS16Bit, MixUltraCentral16BitI + ; Stereo + DW Offset MixNoLoop, PreMixUltraPanned16BitI, MFS16Bit, MBS16Bit, MixUltraPanned16BitI + DW Offset MixForwardsLoop, PreMixUltraPanned16BitI, MFS16Bit, MBS16Bit, MixUltraPanned16BitI + DW Offset MixPingPongLoop, PreMixUltraPanned16BitI, MFS16Bit, MBS16Bit, MixUltraPanned16BitI + ; Surround + DW Offset MixNoLoop, PreMixUltraSurround16BitI, MFS16Bit, MBS16Bit, MixUltraSurround16BitI + DW Offset MixForwardsLoop, PreMixUltraSurround16BitI, MFS16Bit, MBS16Bit, MixUltraSurround16BitI + DW Offset MixPingPongLoop, PreMixUltraSurround16BitI, MFS16Bit, MBS16Bit, MixUltraSurround16BitI diff --git a/SoundDrivers/M32ULTRA.MIX b/SoundDrivers/M32ULTRA.MIX index f9d89ad..2e4c933 100755 --- a/SoundDrivers/M32ULTRA.MIX +++ b/SoundDrivers/M32ULTRA.MIX @@ -1,770 +1,770 @@ - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -GetUltra8BitWaveform Macro ; Puts waveform value in EBX, range -32k->+32k - - Push EDX - Push EBP - - MovSX EDX, Byte Ptr [ES:DI+2] ; v - MovSX EBX, Byte Ptr [ES:DI] ; t - MovSX EAX, Byte Ptr [ES:DI+1] ; u - - LEA EBP, [EBX+EDX] ; v+t - SAR EBP, 1 - Sub EBP, EAX ; (v+t)/2 - u - IMul EBP, ECX ; ax in 8.16 format - SAR EBP, 10 ; ax in 8.6 format - - ShL EAX, 7 ; EBX = 2u<<6 - Add EDX, EBX ; EDX = v+t - Add EBX, EBX ; EAX = 2t - Add EBP, EAX ; EBP = ax+2u - Add EDX, EBX ; 3t+v - ShL EDX, 5 ; (3t+v)/2 << 6 - Sub EBP, EDX ; ax+b - - ShL EBX, 7 - - IMul EBP, ECX ; ax^2+bx in 8.22 form - SAR EBP, 14 ; ax^2+bx in 8.8 form - - Add EBX, EBP ; ax^2+bx+c - - Pop EBP - Pop EDX - -EndM - -GetUltra16BitWaveform Macro ; Puts waveform value in EBX, range -32k->+32k - - Push ECX - Push EDX - Push EBP - - MovSX EDX, Word Ptr [ES:EDI+EDI+4] ; v - MovSX EBX, Word Ptr [ES:EDI+EDI] ; t - MovSX EAX, Word Ptr [ES:EDI+EDI+2] ; u - - ShR ECX, 3 ; 0.13 - LEA EBP, [EBX+EDX] - SAR EBP, 1 - Sub EBP, EAX ; (v+t)/2 - u - IMul EBP, ECX ; 16.13 - SAR EBP, 14 ; 15.0 - - Add EDX, EBX ; EDX = v+t - Add EBP, EAX ; EBP = ax+2u - LEA EDX, [EDX+EBX*2] - SAR EDX, 2 ; EDX = (3t+v)/2 - Sub EBP, EDX ; ax + b, 15 form - - IMul EBP, ECX ; ax^2+bx in 15.13 form - SAR EBP, 12 ; ax^2+bx in 16.0 form - - Add EBX, EBP - - Pop EBP - Pop EDX - Pop ECX - -EndM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MUltraMix8ISingle Macro Index - -MUltraMix8ISingle&Index&: - GetUltra8BitWaveForm - -MUltraMix8ISingleVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-3)*8], EAX ;; 3 -EndM - -MUltraMix8ICentral Macro Index - -MUltraMix8ICentral&Index&: - GetUltra8BitWaveForm - -MUltraMix8ICentralVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-3)*8], EAX ;; 4 - Sub [SI+(Index-3)*8+4], EAX ;; 4 - -EndM - -MUltraMix8ISurround Macro Index - -MUltraMix8ISurround&Index&: - GetUltra8BitWaveForm - -MUltraMix8ISurroundVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-3)*8], EAX ;; 4 - Add [SI+(Index-3)*8+4], EAX ;; 4 - -EndM - - ; Panned output -MUltraMix8IPanned Macro Index - -MUltraMix8IPanned&Index&: - Get32Bit8WaveForm - -MUltraMix8ILeftVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h -MUltraMix8IRightVolume&Index& EQU $+3 - IMul EBX, EBX, 8000h - - Sub [SI+(Index-3)*8], EAX ;; 4 - Sub [SI+(Index-3)*8+4], EBX ;; 4 - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - -EndM - -MUltraMix16ISingle Macro Index - -MUltraMix16ISingle&Index&: - GetUltra16BitWaveForm - -MUltraMix16ISingleVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-3)*8], EAX ;; 3 - -EndM - -MUltraMix16ICentral Macro Index - -MUltraMix16ICentral&Index&: - GetUltra16BitWaveForm - -MUltraMix16ICentralVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-3)*8], EAX ;; 3 - Sub [SI+(Index-3)*8+4], EAX ;; 3 - -EndM - -MUltraMix16ISurround Macro Index - -MUltraMix16ISurround&Index&: - GetUltra16BitWaveForm - -MUltraMix16ISurroundVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h - - Add ERROR, DELTAERROR ;; 1 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-3)*8], EAX ;; 3 - Add [SI+(Index-3)*8+4], EAX ;; 3 - -EndM - - ; Panned output -MUltraMix16IPanned Macro Index - -MUltraMix16IPanned&Index&: - GetUltra16BitWaveForm - -MUltraMix16ILeftVolume&Index& EQU $+3 - IMul EAX, EBX, 8000h -MUltraMix16IRightVolume&Index& EQU $+3 - IMul EBX, EBX, 8000h - - Sub [SI+(Index-3)*8], EAX - Sub [SI+(Index-3)*8+4], EBX - - Add ERROR, DELTAERROR - AdC DI, DELTAOFFSET - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -MixUltraSingle8BitIOffsetTable Label Word - - IndexCounter = 3 - - MUltraMix8ISingleOffset Macro Index - DW Offset MUltraMix8ISingle&Index& - EndM - - REPT 4 - MUltraMix8ISingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc MixUltraSingle8BitI - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 3 - ShR BX, 2 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:MixUltraSingle8BitIOffsetTable+BX] - - MUltraMix8ISingle 0 - MUltraMix8ISingle 1 - MUltraMix8ISingle 2 - MUltraMix8ISingle 3 - - Add SI, 4*MIXRESOLUTION/4 - Dec LoopCounter - JNZ MUltraMix8ISingle0 - - Ret - -EndP MixUltraSingle8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraLeft8BitI - - Mov AX, [SI+0Eh] - -PreMixUltraLeft8BitI1: - IndexCounter = 0 - - PreMixUltraSingleMacro Macro Index - Mov Word Ptr [CS:MUltraMix8ISingleVolume&Index&], AX - EndM - - REPT 4 - PreMixUltraSingleMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - Ret - -EndP PreMixUltraLeft8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraRight8BitI - - Add MixBufferOffset, MixResolution/8 - Mov AX, [SI+0Ch] - Jmp PreMixUltraLeft8BitI1 - -EndP PreMixUltraRight8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixUltraCentral8BitIOffsetTable Label Word - - IndexCounter = 3 - - MUltraMix8ICentralOffset Macro Index - DW Offset MUltraMix8ICentral&Index& - EndM - - REPT 4 - MUltraMix8ICentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc MixUltraCentral8BitI - - Dec AX - Mov BX, AX - And AX, 3 - ShR BX, 2 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:MixUltraCentral8BitIOffsetTable+BX] - - MUltraMix8ICentral 0 - MUltraMix8ICentral 1 - MUltraMix8ICentral 2 - MUltraMix8ICentral 3 - - Add SI, 4*MIXRESOLUTION/4 - Dec LoopCounter - JNZ MUltraMix8ICentral0 - - Ret - -EndP MixUltraCentral8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraCentral8BitI - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMixUltraCentralMacro Macro Index - Mov Word Ptr [CS:MUltraMix8ICentralVolume&Index&], AX - EndM - - REPT 4 - PreMixUltraCentralMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMixUltraCentral8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixUltraSurround8BitIOffsetTable Label Word - - IndexCounter = 3 - - MUltraMix8ISurroundOffset Macro Index - DW Offset MUltraMix8ISurround&Index& - EndM - - REPT 4 - MUltraMix8ISurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc MixUltraSurround8BitI - - Dec AX - Mov BX, AX - And AX, 3 - ShR BX, 2 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:MixUltraSurround8BitIOffsetTable+BX] - - MUltraMix8ISurround 0 - MUltraMix8ISurround 1 - MUltraMix8ISurround 2 - MUltraMix8ISurround 3 - - Add SI, 4*MIXRESOLUTION/4 - Dec LoopCounter - JNZ MUltraMix8ISurround0 - - Ret - -EndP MixUltraSurround8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraSurround8BitI - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMixUltraSurroundMacro Macro Index - Mov Word Ptr [CS:MUltraMix8ISurroundVolume&Index&], AX - EndM - - REPT 4 - PreMixUltraSurroundMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMixUltraSurround8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixUltraPanned8BitIOffsetTable Label Word - - IndexCounter = 3 - - MUltraMix8IPannedOffset Macro Index - DW Offset MUltraMix8IPanned&Index& - EndM - - REPT 4 - MUltraMix8IPannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc MixUltraPanned8BitI - - Dec AX - Mov BX, AX - And AX, 3 - ShR BX, 2 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:MixUltraPanned8BitIOffsetTable+BX] - - MUltraMix8IPanned 0 - MUltraMix8IPanned 1 - MUltraMix8IPanned 2 - MUltraMix8IPanned 3 - - Add SI, 4*MIXRESOLUTION/4 - Dec LoopCounter - JNZ MUltraMix8IPanned0 - - Ret - -EndP MixUltraPanned8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraPanned8BitI - - Mov AX, [SI+0Eh] ; Left - Mov BX, [SI+0Ch] ; Right - - IndexCounter = 0 - - PreMixUltraPannedMacro Macro Index - Mov Word Ptr [CS:MUltraMix8ILeftVolume&Index&], AX - Mov Word Ptr [CS:MUltraMix8IRightVolume&Index&], BX - EndM - - REPT 4 - PreMixUltraPannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMixUltraPanned8BitI - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -MixUltraSingle16BitIOffsetTable Label Word - - IndexCounter = 3 - - MUltraMix16ISingleOffset Macro Index - DW Offset MUltraMix16ISingle&Index& - EndM - - REPT 4 - MUltraMix16ISingleOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc MixUltraSingle16BitI - ; AX = count... - - ; Number of times to loop = (Count-1) / 16 - - Dec AX - Mov BX, AX - And AX, 3 - ShR BX, 2 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:MixUltraSingle16BitIOffsetTable+BX] - - MUltraMix16ISingle 0 - MUltraMix16ISingle 1 - MUltraMix16ISingle 2 - MUltraMix16ISingle 3 - - Add SI, 4*MIXRESOLUTION/4 - Dec LoopCounter - JNZ MUltraMix16ISingle0 - - Ret - -EndP MixUltraSingle16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraLeft16BitI - - Mov AX, [SI+0Eh] ; Left - -PreMixUltraLeft16BitI1: - IndexCounter = 0 - - PreMixUltraSingleMacro Macro Index - Mov Word Ptr [CS:MUltraMix16ISingleVolume&Index&], AX - EndM - - REPT 4 - PreMixUltraSingleMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMixUltraLeft16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraRight16BitI - - Add MixBufferOffset, MixResolution/8 - Mov AX, [SI+0Ch] - Jmp PreMixUltraLeft16BitI1 - - Ret - -EndP PreMixUltraRight16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixUltraCentral16BitIOffsetTable Label Word - - IndexCounter = 3 - - MUltraMix16ICentralOffset Macro Index - DW Offset MUltraMix16ICentral&Index& - EndM - - REPT 4 - MUltraMix16ICentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc MixUltraCentral16BitI - - Dec AX - Mov BX, AX - And AX, 3 - ShR BX, 2 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:MixUltraCentral16BitIOffsetTable+BX] - - MUltraMix16ICentral 0 - MUltraMix16ICentral 1 - MUltraMix16ICentral 2 - MUltraMix16ICentral 3 - - Add SI, 4*MIXRESOLUTION/4 - Dec LoopCounter - JNZ MUltraMix16ICentral0 - - Ret - -EndP MixUltraCentral16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraCentral16BitI - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMixUltraCentralMacro Macro Index - Mov Word Ptr [CS:MUltraMix16ICentralVolume&Index&], AX - EndM - - REPT 4 - PreMixUltraCentralMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMixUltraCentral16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixUltraSurround16BitIOffsetTable Label Word - - IndexCounter = 3 - - MUltraMix16ISurroundOffset Macro Index - DW Offset MUltraMix16ISurround&Index& - EndM - - REPT 4 - MUltraMix16ISurroundOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc MixUltraSurround16BitI - - Dec AX - Mov BX, AX - And AX, 3 - ShR BX, 2 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:MixUltraSurround16BitIOffsetTable+BX] - - MUltraMix16ISurround 0 - MUltraMix16ISurround 1 - MUltraMix16ISurround 2 - MUltraMix16ISurround 3 - - Add SI, 4*MIXRESOLUTION/4 - Dec LoopCounter - JNZ MUltraMix16ISurround0 - - Ret - -EndP MixUltraSurround16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraSurround16BitI - - Mov AX, [SI+0Eh] - - IndexCounter = 0 - - PreMixUltraSurroundMacro Macro Index - Mov Word Ptr [CS:MUltraMix16ISurroundVolume&Index&], AX - EndM - - REPT 4 - PreMixUltraSurroundMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMixUltraSurround16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixUltraPanned16BitIOffsetTable Label Word - - IndexCounter = 3 - - MUltraMix16IPannedOffset Macro Index - DW Offset MUltraMix16IPanned&Index& - EndM - - REPT 4 - MUltraMix16IPannedOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc MixUltraPanned16BitI - - Dec AX - Mov BX, AX - And AX, 3 - ShR BX, 2 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Jmp [CS:MixUltraPanned16BitIOffsetTable+BX] - -PanMUltraBit16ILoop: - MUltraMix16IPanned 0 - MUltraMix16IPanned 1 - MUltraMix16IPanned 2 - MUltraMix16IPanned 3 - - Add SI, 4*MIXRESOLUTION/4 - Dec LoopCounter - JNZ PanMUltraBit16ILoop - - Ret - -EndP MixUltraPanned16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMixUltraPanned16BitI - - Mov AX, [SI+0Eh] ; Left - Mov BX, [SI+0Ch] ; Right - - IndexCounter = 0 - - PreMixUltraPannedMacro Macro Index - Mov Word Ptr [CS:MUltraMix16ILeftVolume&Index&], AX - Mov Word Ptr [CS:MUltraMix16IRightVolume&Index&], BX - EndM - - REPT 4 - PreMixUltraPannedMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMixUltraPanned16BitI - - + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +GetUltra8BitWaveform Macro ; Puts waveform value in EBX, range -32k->+32k + + Push EDX + Push EBP + + MovSX EDX, Byte Ptr [ES:DI+2] ; v + MovSX EBX, Byte Ptr [ES:DI] ; t + MovSX EAX, Byte Ptr [ES:DI+1] ; u + + LEA EBP, [EBX+EDX] ; v+t + SAR EBP, 1 + Sub EBP, EAX ; (v+t)/2 - u + IMul EBP, ECX ; ax in 8.16 format + SAR EBP, 10 ; ax in 8.6 format + + ShL EAX, 7 ; EBX = 2u<<6 + Add EDX, EBX ; EDX = v+t + Add EBX, EBX ; EAX = 2t + Add EBP, EAX ; EBP = ax+2u + Add EDX, EBX ; 3t+v + ShL EDX, 5 ; (3t+v)/2 << 6 + Sub EBP, EDX ; ax+b + + ShL EBX, 7 + + IMul EBP, ECX ; ax^2+bx in 8.22 form + SAR EBP, 14 ; ax^2+bx in 8.8 form + + Add EBX, EBP ; ax^2+bx+c + + Pop EBP + Pop EDX + +EndM + +GetUltra16BitWaveform Macro ; Puts waveform value in EBX, range -32k->+32k + + Push ECX + Push EDX + Push EBP + + MovSX EDX, Word Ptr [ES:EDI+EDI+4] ; v + MovSX EBX, Word Ptr [ES:EDI+EDI] ; t + MovSX EAX, Word Ptr [ES:EDI+EDI+2] ; u + + ShR ECX, 3 ; 0.13 + LEA EBP, [EBX+EDX] + SAR EBP, 1 + Sub EBP, EAX ; (v+t)/2 - u + IMul EBP, ECX ; 16.13 + SAR EBP, 14 ; 15.0 + + Add EDX, EBX ; EDX = v+t + Add EBP, EAX ; EBP = ax+2u + LEA EDX, [EDX+EBX*2] + SAR EDX, 2 ; EDX = (3t+v)/2 + Sub EBP, EDX ; ax + b, 15 form + + IMul EBP, ECX ; ax^2+bx in 15.13 form + SAR EBP, 12 ; ax^2+bx in 16.0 form + + Add EBX, EBP + + Pop EBP + Pop EDX + Pop ECX + +EndM + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MUltraMix8ISingle Macro Index + +MUltraMix8ISingle&Index&: + GetUltra8BitWaveForm + +MUltraMix8ISingleVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-3)*8], EAX ;; 3 +EndM + +MUltraMix8ICentral Macro Index + +MUltraMix8ICentral&Index&: + GetUltra8BitWaveForm + +MUltraMix8ICentralVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-3)*8], EAX ;; 4 + Sub [SI+(Index-3)*8+4], EAX ;; 4 + +EndM + +MUltraMix8ISurround Macro Index + +MUltraMix8ISurround&Index&: + GetUltra8BitWaveForm + +MUltraMix8ISurroundVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-3)*8], EAX ;; 4 + Add [SI+(Index-3)*8+4], EAX ;; 4 + +EndM + + ; Panned output +MUltraMix8IPanned Macro Index + +MUltraMix8IPanned&Index&: + Get32Bit8WaveForm + +MUltraMix8ILeftVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h +MUltraMix8IRightVolume&Index& EQU $+3 + IMul EBX, EBX, 8000h + + Sub [SI+(Index-3)*8], EAX ;; 4 + Sub [SI+(Index-3)*8+4], EBX ;; 4 + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + +EndM + +MUltraMix16ISingle Macro Index + +MUltraMix16ISingle&Index&: + GetUltra16BitWaveForm + +MUltraMix16ISingleVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-3)*8], EAX ;; 3 + +EndM + +MUltraMix16ICentral Macro Index + +MUltraMix16ICentral&Index&: + GetUltra16BitWaveForm + +MUltraMix16ICentralVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-3)*8], EAX ;; 3 + Sub [SI+(Index-3)*8+4], EAX ;; 3 + +EndM + +MUltraMix16ISurround Macro Index + +MUltraMix16ISurround&Index&: + GetUltra16BitWaveForm + +MUltraMix16ISurroundVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h + + Add ERROR, DELTAERROR ;; 1 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-3)*8], EAX ;; 3 + Add [SI+(Index-3)*8+4], EAX ;; 3 + +EndM + + ; Panned output +MUltraMix16IPanned Macro Index + +MUltraMix16IPanned&Index&: + GetUltra16BitWaveForm + +MUltraMix16ILeftVolume&Index& EQU $+3 + IMul EAX, EBX, 8000h +MUltraMix16IRightVolume&Index& EQU $+3 + IMul EBX, EBX, 8000h + + Sub [SI+(Index-3)*8], EAX + Sub [SI+(Index-3)*8+4], EBX + + Add ERROR, DELTAERROR + AdC DI, DELTAOFFSET + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +MixUltraSingle8BitIOffsetTable Label Word + + IndexCounter = 3 + + MUltraMix8ISingleOffset Macro Index + DW Offset MUltraMix8ISingle&Index& + EndM + + REPT 4 + MUltraMix8ISingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc MixUltraSingle8BitI + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 3 + ShR BX, 2 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:MixUltraSingle8BitIOffsetTable+BX] + + MUltraMix8ISingle 0 + MUltraMix8ISingle 1 + MUltraMix8ISingle 2 + MUltraMix8ISingle 3 + + Add SI, 4*MIXRESOLUTION/4 + Dec LoopCounter + JNZ MUltraMix8ISingle0 + + Ret + +EndP MixUltraSingle8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraLeft8BitI + + Mov AX, [SI+0Eh] + +PreMixUltraLeft8BitI1: + IndexCounter = 0 + + PreMixUltraSingleMacro Macro Index + Mov Word Ptr [CS:MUltraMix8ISingleVolume&Index&], AX + EndM + + REPT 4 + PreMixUltraSingleMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + Ret + +EndP PreMixUltraLeft8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraRight8BitI + + Add MixBufferOffset, MixResolution/8 + Mov AX, [SI+0Ch] + Jmp PreMixUltraLeft8BitI1 + +EndP PreMixUltraRight8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixUltraCentral8BitIOffsetTable Label Word + + IndexCounter = 3 + + MUltraMix8ICentralOffset Macro Index + DW Offset MUltraMix8ICentral&Index& + EndM + + REPT 4 + MUltraMix8ICentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc MixUltraCentral8BitI + + Dec AX + Mov BX, AX + And AX, 3 + ShR BX, 2 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:MixUltraCentral8BitIOffsetTable+BX] + + MUltraMix8ICentral 0 + MUltraMix8ICentral 1 + MUltraMix8ICentral 2 + MUltraMix8ICentral 3 + + Add SI, 4*MIXRESOLUTION/4 + Dec LoopCounter + JNZ MUltraMix8ICentral0 + + Ret + +EndP MixUltraCentral8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraCentral8BitI + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMixUltraCentralMacro Macro Index + Mov Word Ptr [CS:MUltraMix8ICentralVolume&Index&], AX + EndM + + REPT 4 + PreMixUltraCentralMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMixUltraCentral8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixUltraSurround8BitIOffsetTable Label Word + + IndexCounter = 3 + + MUltraMix8ISurroundOffset Macro Index + DW Offset MUltraMix8ISurround&Index& + EndM + + REPT 4 + MUltraMix8ISurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc MixUltraSurround8BitI + + Dec AX + Mov BX, AX + And AX, 3 + ShR BX, 2 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:MixUltraSurround8BitIOffsetTable+BX] + + MUltraMix8ISurround 0 + MUltraMix8ISurround 1 + MUltraMix8ISurround 2 + MUltraMix8ISurround 3 + + Add SI, 4*MIXRESOLUTION/4 + Dec LoopCounter + JNZ MUltraMix8ISurround0 + + Ret + +EndP MixUltraSurround8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraSurround8BitI + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMixUltraSurroundMacro Macro Index + Mov Word Ptr [CS:MUltraMix8ISurroundVolume&Index&], AX + EndM + + REPT 4 + PreMixUltraSurroundMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMixUltraSurround8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixUltraPanned8BitIOffsetTable Label Word + + IndexCounter = 3 + + MUltraMix8IPannedOffset Macro Index + DW Offset MUltraMix8IPanned&Index& + EndM + + REPT 4 + MUltraMix8IPannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc MixUltraPanned8BitI + + Dec AX + Mov BX, AX + And AX, 3 + ShR BX, 2 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:MixUltraPanned8BitIOffsetTable+BX] + + MUltraMix8IPanned 0 + MUltraMix8IPanned 1 + MUltraMix8IPanned 2 + MUltraMix8IPanned 3 + + Add SI, 4*MIXRESOLUTION/4 + Dec LoopCounter + JNZ MUltraMix8IPanned0 + + Ret + +EndP MixUltraPanned8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraPanned8BitI + + Mov AX, [SI+0Eh] ; Left + Mov BX, [SI+0Ch] ; Right + + IndexCounter = 0 + + PreMixUltraPannedMacro Macro Index + Mov Word Ptr [CS:MUltraMix8ILeftVolume&Index&], AX + Mov Word Ptr [CS:MUltraMix8IRightVolume&Index&], BX + EndM + + REPT 4 + PreMixUltraPannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMixUltraPanned8BitI + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +MixUltraSingle16BitIOffsetTable Label Word + + IndexCounter = 3 + + MUltraMix16ISingleOffset Macro Index + DW Offset MUltraMix16ISingle&Index& + EndM + + REPT 4 + MUltraMix16ISingleOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc MixUltraSingle16BitI + ; AX = count... + + ; Number of times to loop = (Count-1) / 16 + + Dec AX + Mov BX, AX + And AX, 3 + ShR BX, 2 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:MixUltraSingle16BitIOffsetTable+BX] + + MUltraMix16ISingle 0 + MUltraMix16ISingle 1 + MUltraMix16ISingle 2 + MUltraMix16ISingle 3 + + Add SI, 4*MIXRESOLUTION/4 + Dec LoopCounter + JNZ MUltraMix16ISingle0 + + Ret + +EndP MixUltraSingle16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraLeft16BitI + + Mov AX, [SI+0Eh] ; Left + +PreMixUltraLeft16BitI1: + IndexCounter = 0 + + PreMixUltraSingleMacro Macro Index + Mov Word Ptr [CS:MUltraMix16ISingleVolume&Index&], AX + EndM + + REPT 4 + PreMixUltraSingleMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMixUltraLeft16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraRight16BitI + + Add MixBufferOffset, MixResolution/8 + Mov AX, [SI+0Ch] + Jmp PreMixUltraLeft16BitI1 + + Ret + +EndP PreMixUltraRight16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixUltraCentral16BitIOffsetTable Label Word + + IndexCounter = 3 + + MUltraMix16ICentralOffset Macro Index + DW Offset MUltraMix16ICentral&Index& + EndM + + REPT 4 + MUltraMix16ICentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc MixUltraCentral16BitI + + Dec AX + Mov BX, AX + And AX, 3 + ShR BX, 2 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:MixUltraCentral16BitIOffsetTable+BX] + + MUltraMix16ICentral 0 + MUltraMix16ICentral 1 + MUltraMix16ICentral 2 + MUltraMix16ICentral 3 + + Add SI, 4*MIXRESOLUTION/4 + Dec LoopCounter + JNZ MUltraMix16ICentral0 + + Ret + +EndP MixUltraCentral16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraCentral16BitI + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMixUltraCentralMacro Macro Index + Mov Word Ptr [CS:MUltraMix16ICentralVolume&Index&], AX + EndM + + REPT 4 + PreMixUltraCentralMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMixUltraCentral16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixUltraSurround16BitIOffsetTable Label Word + + IndexCounter = 3 + + MUltraMix16ISurroundOffset Macro Index + DW Offset MUltraMix16ISurround&Index& + EndM + + REPT 4 + MUltraMix16ISurroundOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc MixUltraSurround16BitI + + Dec AX + Mov BX, AX + And AX, 3 + ShR BX, 2 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:MixUltraSurround16BitIOffsetTable+BX] + + MUltraMix16ISurround 0 + MUltraMix16ISurround 1 + MUltraMix16ISurround 2 + MUltraMix16ISurround 3 + + Add SI, 4*MIXRESOLUTION/4 + Dec LoopCounter + JNZ MUltraMix16ISurround0 + + Ret + +EndP MixUltraSurround16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraSurround16BitI + + Mov AX, [SI+0Eh] + + IndexCounter = 0 + + PreMixUltraSurroundMacro Macro Index + Mov Word Ptr [CS:MUltraMix16ISurroundVolume&Index&], AX + EndM + + REPT 4 + PreMixUltraSurroundMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMixUltraSurround16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixUltraPanned16BitIOffsetTable Label Word + + IndexCounter = 3 + + MUltraMix16IPannedOffset Macro Index + DW Offset MUltraMix16IPanned&Index& + EndM + + REPT 4 + MUltraMix16IPannedOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc MixUltraPanned16BitI + + Dec AX + Mov BX, AX + And AX, 3 + ShR BX, 2 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Jmp [CS:MixUltraPanned16BitIOffsetTable+BX] + +PanMUltraBit16ILoop: + MUltraMix16IPanned 0 + MUltraMix16IPanned 1 + MUltraMix16IPanned 2 + MUltraMix16IPanned 3 + + Add SI, 4*MIXRESOLUTION/4 + Dec LoopCounter + JNZ PanMUltraBit16ILoop + + Ret + +EndP MixUltraPanned16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMixUltraPanned16BitI + + Mov AX, [SI+0Eh] ; Left + Mov BX, [SI+0Ch] ; Right + + IndexCounter = 0 + + PreMixUltraPannedMacro Macro Index + Mov Word Ptr [CS:MUltraMix16ILeftVolume&Index&], AX + Mov Word Ptr [CS:MUltraMix16IRightVolume&Index&], BX + EndM + + REPT 4 + PreMixUltraPannedMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMixUltraPanned16BitI + + diff --git a/SoundDrivers/MAD.BAT b/SoundDrivers/MAD.BAT index ec622a2..4754c28 100755 --- a/SoundDrivers/MAD.BAT +++ b/SoundDrivers/MAD.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 ad1816 -tlink /3 ad1816 -execom ad1816 itad1816.drv -copy itad1816.drv .. - +tasm /m /ut310 ad1816 +tlink /3 ad1816 +execom ad1816 itad1816.drv +copy itad1816.drv .. + diff --git a/SoundDrivers/MAWE.BAT b/SoundDrivers/MAWE.BAT index 57cafac..91d419e 100755 --- a/SoundDrivers/MAWE.BAT +++ b/SoundDrivers/MAWE.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 awe32drv -tlink /3 awe32drv -execom awe32drv itawe32.drv -copy itawe32.drv .. +tasm /m /ut310 awe32drv +tlink /3 awe32drv +execom awe32drv itawe32.drv +copy itawe32.drv .. diff --git a/SoundDrivers/MAWEB.BAT b/SoundDrivers/MAWEB.BAT index 20145cd..f3834fd 100755 --- a/SoundDrivers/MAWEB.BAT +++ b/SoundDrivers/MAWEB.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 awe32b -tlink /3 awe32b -execom awe32b itawe32b.drv -copy itawe32b.drv .. +tasm /m /ut310 awe32b +tlink /3 awe32b +execom awe32b itawe32b.drv +copy itawe32b.drv .. diff --git a/SoundDrivers/MB.BAT b/SoundDrivers/MB.BAT index de7ae06..e012514 100755 --- a/SoundDrivers/MB.BAT +++ b/SoundDrivers/MB.BAT @@ -1,6 +1,6 @@ -@rem Base1 Driver -tasm /m /ut310 base1 -tlink /3 base1 -execom base1 itbase1.drv -copy itbase1.drv .. - +@rem Base1 Driver +tasm /m /ut310 base1 +tlink /3 base1 +execom base1 itbase1.drv +copy itbase1.drv .. + diff --git a/SoundDrivers/MES.BAT b/SoundDrivers/MES.BAT index c3e86fa..1f94970 100755 --- a/SoundDrivers/MES.BAT +++ b/SoundDrivers/MES.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 es1868 -tlink /3 es1868 -execom es1868 ites1868.drv -copy ites1868.drv .. - +tasm /m /ut310 es1868 +tlink /3 es1868 +execom es1868 ites1868.drv +copy ites1868.drv .. + diff --git a/SoundDrivers/MES1688.BAT b/SoundDrivers/MES1688.BAT index 890cbb1..e96947c 100755 --- a/SoundDrivers/MES1688.BAT +++ b/SoundDrivers/MES1688.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 es1688 -tlink /3 es1688 -execom es1688 ites1688.drv -copy ites1688.drv .. - +tasm /m /ut310 es1688 +tlink /3 es1688 +execom es1688 ites1688.drv +copy ites1688.drv .. + diff --git a/SoundDrivers/MES1688M.BAT b/SoundDrivers/MES1688M.BAT index 0f25644..ecc0b0e 100755 --- a/SoundDrivers/MES1688M.BAT +++ b/SoundDrivers/MES1688M.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 es1688mx -tlink /3 es1688mx -execom es1688mx ites1688.mmx -copy ites1688.mmx .. - +tasm32 /m /ut310 es1688mx +tlink /3 es1688mx +execom es1688mx ites1688.mmx +copy ites1688.mmx .. + diff --git a/SoundDrivers/MES1788.BAT b/SoundDrivers/MES1788.BAT index 01230e5..5e9a649 100755 --- a/SoundDrivers/MES1788.BAT +++ b/SoundDrivers/MES1788.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 es1788 -tlink /3 es1788 -execom es1788 ites1788.drv -copy ites1788.drv .. - +tasm /m /ut310 es1788 +tlink /3 es1788 +execom es1788 ites1788.drv +copy ites1788.drv .. + diff --git a/SoundDrivers/MES1869.BAT b/SoundDrivers/MES1869.BAT index 4e98784..920fd28 100755 --- a/SoundDrivers/MES1869.BAT +++ b/SoundDrivers/MES1869.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 es1869 -tlink /3 es1869 -execom es1869 ites1869.drv -copy ites1869.drv .. - +tasm /m /ut310 es1869 +tlink /3 es1869 +execom es1869 ites1869.drv +copy ites1869.drv .. + diff --git a/SoundDrivers/MES1869M.BAT b/SoundDrivers/MES1869M.BAT index ac92bef..f7d677b 100755 --- a/SoundDrivers/MES1869M.BAT +++ b/SoundDrivers/MES1869M.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 es1869mx -tlink /3 es1869mx -execom es1869mx ites1869.mmx -copy ites1869.mmx .. - +tasm32 /m /ut310 es1869mx +tlink /3 es1869mx +execom es1869mx ites1869.mmx +copy ites1869.mmx .. + diff --git a/SoundDrivers/MESM.BAT b/SoundDrivers/MESM.BAT index 9c3ba08..9ff0e8c 100755 --- a/SoundDrivers/MESM.BAT +++ b/SoundDrivers/MESM.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 es1868mx -tlink /3 es1868mx -execom es1868mx ites1868.mmx -copy ites1868.mmx .. - +tasm32 /m /ut310 es1868mx +tlink /3 es1868mx +execom es1868mx ites1868.mmx +copy ites1868.mmx .. + diff --git a/SoundDrivers/MEWS.BAT b/SoundDrivers/MEWS.BAT index a69f9b3..c2265f0 100755 --- a/SoundDrivers/MEWS.BAT +++ b/SoundDrivers/MEWS.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 ews64 -tlink /3 ews64 -execom ews64 itews64.drv -copy itews64.drv .. +tasm /m /ut310 ews64 +tlink /3 ews64 +execom ews64 itews64.drv +copy itews64.drv .. diff --git a/SoundDrivers/MEWSC.BAT b/SoundDrivers/MEWSC.BAT index 582f17e..1c69143 100755 --- a/SoundDrivers/MEWSC.BAT +++ b/SoundDrivers/MEWSC.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 ewscodec -tlink /3 ewscodec -execom ewscodec itewscod.drv -copy itewscod.drv .. - +tasm /m /ut310 ewscodec +tlink /3 ewscodec +execom ewscodec itewscod.drv +copy itewscod.drv .. + diff --git a/SoundDrivers/MEWSCM.BAT b/SoundDrivers/MEWSCM.BAT index d74f03f..2866406 100755 --- a/SoundDrivers/MEWSCM.BAT +++ b/SoundDrivers/MEWSCM.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 ewscodmx -tlink /3 ewscodmx -execom ewscodmx itewscod.mmx -copy itewscod.mmx .. - +tasm32 /m /ut310 ewscodmx +tlink /3 ewscodmx +execom ewscodmx itewscod.mmx +copy itewscod.mmx .. + diff --git a/SoundDrivers/MG16.BAT b/SoundDrivers/MG16.BAT index b0db2a1..12d9c55 100755 --- a/SoundDrivers/MG16.BAT +++ b/SoundDrivers/MG16.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 gold16 -tlink /3 gold16 -execom m16 itgold16.drv -copy itgold16.drv .. - +tasm /m /ut310 gold16 +tlink /3 gold16 +execom m16 itgold16.drv +copy itgold16.drv .. + diff --git a/SoundDrivers/MGP.BAT b/SoundDrivers/MGP.BAT index b7626ff..a49f9ec 100755 --- a/SoundDrivers/MGP.BAT +++ b/SoundDrivers/MGP.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 guspnpm -tlink /3 guspnpm -execom guspnpm itguspnp.drv -copy itguspnp.drv .. +tasm /m /ut310 guspnpm +tlink /3 guspnpm +execom guspnpm itguspnp.drv +copy itguspnp.drv .. diff --git a/SoundDrivers/MGPM.BAT b/SoundDrivers/MGPM.BAT index c5a95e6..89a7daf 100755 --- a/SoundDrivers/MGPM.BAT +++ b/SoundDrivers/MGPM.BAT @@ -1,4 +1,4 @@ -tasm32 /m /ut310 guspnpmx -tlink /3 guspnpmx -execom guspnpmx itguspnp.mmx -copy itguspnp.mmx .. +tasm32 /m /ut310 guspnpmx +tlink /3 guspnpmx +execom guspnpmx itguspnp.mmx +copy itguspnp.mmx .. diff --git a/SoundDrivers/MGUS.BAT b/SoundDrivers/MGUS.BAT index 30120d1..e8927b8 100755 --- a/SoundDrivers/MGUS.BAT +++ b/SoundDrivers/MGUS.BAT @@ -1,4 +1,4 @@ -tasm /m /uT310 /l gushiqdr -tlink /3 gushiqdr -execom gushiqdr itgus.drv -copy itgus.drv .. +tasm /m /uT310 /l gushiqdr +tlink /3 gushiqdr +execom gushiqdr itgus.drv +copy itgus.drv .. diff --git a/SoundDrivers/MGUS2.BAT b/SoundDrivers/MGUS2.BAT index 328066a..55b89ce 100755 --- a/SoundDrivers/MGUS2.BAT +++ b/SoundDrivers/MGUS2.BAT @@ -1,4 +1,4 @@ -tasm /m /uT310 gushiq2 -tlink /3 gushiq2 -execom gushiq2 itgus2.drv -copy itgus2.drv .. +tasm /m /uT310 gushiq2 +tlink /3 gushiq2 +execom gushiq2 itgus2.drv +copy itgus2.drv .. diff --git a/SoundDrivers/MGUSLO.BAT b/SoundDrivers/MGUSLO.BAT index 7141a75..8b8836b 100755 --- a/SoundDrivers/MGUSLO.BAT +++ b/SoundDrivers/MGUSLO.BAT @@ -1,4 +1,4 @@ -tasm /m /uT310 gusdrv2 -tlink /3 gusdrv2 -execom gusdrv2 itguslo.drv -copy itguslo.drv .. +tasm /m /uT310 gusdrv2 +tlink /3 gusdrv2 +execom gusdrv2 itguslo.drv +copy itguslo.drv .. diff --git a/SoundDrivers/MGUSMAX.BAT b/SoundDrivers/MGUSMAX.BAT index 46b43d4..6534f0f 100755 --- a/SoundDrivers/MGUSMAX.BAT +++ b/SoundDrivers/MGUSMAX.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 gusmax -tlink /3 gusmax -execom gusmax itgusmax.drv -copy itgusmax.drv .. - +tasm /m /ut310 gusmax +tlink /3 gusmax +execom gusmax itgusmax.drv +copy itgusmax.drv .. + diff --git a/SoundDrivers/MGUSMAXM.BAT b/SoundDrivers/MGUSMAXM.BAT index b88175b..13b74a5 100755 --- a/SoundDrivers/MGUSMAXM.BAT +++ b/SoundDrivers/MGUSMAXM.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 gusmaxmx -tlink /3 gusmaxmx -execom gusmaxmx itgusmax.mmx -copy itgusmax.mmx .. - +tasm32 /m /ut310 gusmaxmx +tlink /3 gusmaxmx +execom gusmaxmx itgusmax.mmx +copy itgusmax.mmx .. + diff --git a/SoundDrivers/MGUSMIX.BAT b/SoundDrivers/MGUSMIX.BAT index 3b27517..dd8dd27 100755 --- a/SoundDrivers/MGUSMIX.BAT +++ b/SoundDrivers/MGUSMIX.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 gusmixdr -tlink /3 gusmixdr -execom gusmixdr itgusmix.drv -copy itgusmix.drv .. +tasm /m /ut310 gusmixdr +tlink /3 gusmixdr +execom gusmixdr itgusmix.drv +copy itgusmix.drv .. diff --git a/SoundDrivers/MIDDRV.ASM b/SoundDrivers/MIDDRV.ASM index d9adff2..d371632 100755 --- a/SoundDrivers/MIDDRV.ASM +++ b/SoundDrivers/MIDDRV.ASM @@ -1,865 +1,865 @@ - -; -; MID File generator -; - -REPEATSTATUSBYTE EQU 0 - - .486P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include ..\wavswitc.inc - -FileHandle DW 0 - -MIDOutputMsg DB "MIDI File Generator", 13 - DB "Writing to disk", 0 -MIDOutputError DB "Unable to create output file!", 0FFh, 29, " ", 0 -WriteErrorMsg DB "Error writing to output file. Output file closed", 0FFh, 11, " ", 0 -ClosedMsg DB "Closed output file", 0FFh, 42, " ", 0 -CreateMsg DB "Creating file " -Filename DB " ", 0 -OUTPUT DB "OUTPUT" -DriverName DB "ITMID.DRV", 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 80 -MIDDirectory DB ".", 79 Dup (0) - - -AccumulatedTime DD 0 - -MIDIHEADERSIZE = 22+32+7 -MIDIHeader DB "MThd", 0, 0, 0, 6, 0, 0, 0, 1 - DB 0, 018h ; 24 ppqn - DB "MTrk" -MIDIFileSize DD 0 - DB 0, 0FFh, 01, 28 - DB "Created with Impulse Tracker" - DB 0, 0FFh, 51h, 3 -InitialTempo DD 0 - -MTrkEnd DB 0, 0FFh, 2Fh, 0 - -MIDIBuffer DB 256 Dup (0) -MIDIBufferOffset DW Offset MIDIBuffer - -MIDScreenList DW 6 - DW IdleFunctionList - DW GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr MIDHeader - - DW Near Ptr DirectoryInputText - DW Near Ptr DirectoryInputBox - DW Near Ptr DirectoryInput ; 6 - - DW 0 - -IdleFunctionList DD 0 - DD 0 -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MIDHeader DW 10 - DB "MIDI File Export Driver", 0 - -DirectoryInputText DW 1 - DB 2, 14 - DB 20h - DB "Output Directory", 0 - -DirectoryInputBox DW 0 - DB 18, 13, 78, 15 - DB 25 - -DirectoryInput DW 16 - DB 19, 14 -Segment1 DW 0 - DW Offset MIDDirectory - DW 59 - DD 0 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -TRACEENABLED EQU 0 -CREATENEWLOGFILE EQU 1 -include debug.inc - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - - Mov Segment1, DS - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GotoHomeDirectory - Mov SI, Offset MIDDirectory - Call SetDirectory - - Mov SI, Offset MIDOutputMsg - ClC - Ret - -EndP InitSound - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckFileClosed - - Push CS - Pop DS - Assume DS:Driver - - Mov BX, FileHandle - Test BX, BX - JZ CheckFileClosedEnd - - Mov AH, 40h - Mov CX, 4 - Mov DX, Offset MTrkEnd - Int 21h - - Mov FileHandle, 0 - - Mov AX, 4200h ; Move to start of file - Xor CX, CX - Xor DX, DX - Int 21h ; Start of file - - Mov AX, Word Ptr [MIDIFileSize] - Mov DX, Word Ptr [MIDIFileSize+2] - XChg AL, DH - XChg AH, DL - Mov Word Ptr [MIDIFileSize], AX - Mov Word Ptr [MIDIFileSize+2], DX - - Mov AH, 40h - Mov CX, MIDIHEADERSIZE - Mov DX, Offset MIDIHeader - Int 21h - - Mov AH, 3Eh - Int 21h - - Mov SI, Offset ClosedMsg - Mov BX, 40 - Call SetInfoLine - -CheckFileClosedEnd: - Ret - -EndP CheckFileClosed - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MIDDirectory - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Call CheckFileClosed - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WriteMIDIBlock - Assume DS:Driver - - Xor ECX, ECX - - Mov CX, MIDIBufferOffset - Mov DX, Offset MIDIBuffer - Mov AH, 40h - Mov BX, FileHandle - Sub CX, DX - JZ NoDataToWrite - - Add MIDIFileSize, ECX - - Trace "Writing MIDI block" - - Int 21h - -NoDataToWrite: - Mov MIDIBufferOffset, Offset MIDIBuffer - - Ret - -EndP WriteMIDIBlock - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - Assume DS:Nothing - - Mov CS:Countdown, 0 - Mov CS:MIDIBufferOffset, Offset MIDIBuffer - - Call Update ; Got DS:SI, CX - -; Scan through channels and if any channels are samples, turn them off. - -TurnOffSamples1: - Test Byte Ptr [SI], 1 ; Channel on? - JZ TurnOffSamples2 - - Mov Word Ptr [SI], 0 - - Test Byte Ptr [SI+3Ah], 80h - JNZ TurnOffSamples2 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -TurnOffSamples2: - Add SI, 128 - Loop TurnOffSamples1 - -; OK.. check whether any MIDI data requires dumping... also whether file -; needs to be created. - - Test AX, AX ; Currently not playing - JNZ Poll1 - - Call CheckFileClosed - Ret - -Poll1: - Push CS - Pop DS - Assume DS:Driver - - Cmp FileHandle, 0 - JNE Poll2 - - Trace "New file to create" - - Mov SI, Offset MIDDirectory - Call SetDirectory - - Xor EAX, EAX - Mov AccumulatedTime, EAX - Mov AL, 4+32+7 - Mov MIDIFileSize, EAX - -; Have to create a file - Call GetFileName - Assume DS:Nothing ; Returns DS:SI - Push CS - Pop ES - Mov DI, Offset FileName - - Push DI - - Mov CX, 12 - Mov AL, ' ' - Rep StosB - - Pop DI - - Cmp Byte Ptr [DS:SI], 0 - JE PollFileNameNone - Cmp Byte Ptr [DS:SI], '.' - JE PollFileNameNone - - Mov CX, 8 -PollFileName1: - LodsB - Cmp AL, 0 - JE PollFileNameExt - Cmp AL, '.' - JE PollFileNameExt - StosB - Loop PollFileName1 - Jmp PollFileNameExt - -PollFileNameNone: - Push CS - Pop DS - Mov SI, Offset Output - Mov CX, 6 - Rep MovsB - -PollFileNameExt: - Mov EAX, 'DIM.' - StosD - Xor AL, AL - StosB - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset CreateMsg - Mov BX, 40 - Call SetInfoLine - - Mov AH, 3Ch - Xor CX, CX - Mov DX, Offset Filename - Int 21h - JC WriteError - - Mov BX, AX - Mov FileHandle, BX - Trace "File opened" - -; Write header once - Push BX - Call GetTempo - Mov EAX, 60000000 - And EBX, 0FFFFh - Xor EDX, EDX - Div EBX ; EAX = microseconds per quarter note - - ShL EAX, 8 - BSwap EAX - Mov InitialTempo, EAX - Pop BX - - Mov AH, 40h - Mov CX, MIDIHEADERSIZE - Mov DX, Offset MIDIHeader - Int 21h - JC WriteError - - Trace "Header written" - -Poll2: - Call WriteMIDIBlock - JC WriteError - -; Update time counters - Inc AccumulatedTime - - Ret - -WriteError: - Call CheckFileClosed - Mov SI, Offset WriteErrorMsg - Mov BX, 40 - Call SetInfoLine - Call StopPlayback - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far ; Frames per second = 0.4*BX - ; -> Milliseconds per frame = 1000/(0.4/BX) - ; = 2500/BX - PushAD - Push DS - -; SetTempo: FF 51 03 tt tt tt - - Push CS - Pop DS - Assume DS:Driver - - Push BX - - Mov SI, MIDIBufferOffset - Call WriteDeltaTime - - Pop BX - - Mov DWord Ptr [SI], 351FFh - Add SI, 3 - - Mov EAX, 60000000 - And EBX, 0FFFFh - Xor EDX, EDX - Div EBX ; EAX = microseconds per quarter note - - ShL EAX, 8 - BSwap EAX - Mov DWord Ptr [SI], EAX - Add SI, 3 - - Mov MIDIBufferOffset, SI - - Pop DS - PopAD - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load (0 based) -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release (1 based) -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset MIDScreenList - - ClC - Ret - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -StatusByte DB 0 -CountDown DB 0 - -StatusByteLUT DB 2, 2, 2, 2, 1, 1, 2 -InSysex DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WriteDeltaTime ; Given DS:SI = buffer - - Xor EDX, EDX - Mov EBX, AccumulatedTime - Mov CX, 4 - Mov AccumulatedTime, EDX - -WriteDeltaTime1: - ShL EDX, 8 - Mov DL, BL - Or DL, 80h - ShR EBX, 7 - LoopNZ WriteDeltaTime1 - ; EDX = output bytes, DL = most signif - -WriteDeltaTime2: - Mov [SI], DL - Inc SI - ShR EDX, 8 - JNZ WriteDeltaTime2 - - And Byte Ptr [SI-1], 7Fh - - Ret - -EndP WriteDeltaTime - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc BufferMIDIOutput ; AL = value. - - PushAD - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov BX, InSysex - Mov SI, MIDIBufferOffset - - Test BX, BX - JZ BufferMIDINoSysex - - Cmp AL, 0F7h - JNE BufferMIDIOutput1 - - Mov DX, SI - Sub DX, BX ; DX = count of sysex bytes - Mov [BX], DL - Mov InSysex, 0 - - Jmp BufferMIDIOutput1 - -BufferMIDINoSysex: - Cmp Countdown, 0 - JNE BufferMIDIOutput1 - - Cmp AL, 0F0h - JA BufferMIDIOutput2 - -; Delta time required - Call WriteDeltaTime - - Xor BX, BX - Xor DL, DL - Test AL, AL - JNS BufferMIDINoStatus - Cmp AL, 0F0h - JE BufferMIDISysex - - Mov StatusByte, AL - Inc DX - Jmp BufferMIDINoStatus - -BufferMIDISysex: - Mov [SI], AL - Inc SI - Mov InSysex, SI - Jmp BufferMIDIOutput1 - -BufferMIDINoStatus: - Mov BL, StatusByte - ShR BX, 4 - Sub BL, 8 - JC BufferMIDIOutput1 - - Add DL, [StatusByteLUT+BX] - Mov Countdown, DL - -BufferMIDIOutput1: - Mov [SI], AL - Inc SI - Dec Countdown - - Mov MIDIBufferOffset, SI - - Cmp SI, Offset MIDIBuffer+200 - JB BufferMIDIOutput2 - Cmp InSysex, 0 - JNE BufferMIDIOutput2 - - Call WriteMIDIBlock - -BufferMIDIOutput2: - Pop DS - PopAD - - Ret - -EndP BufferMIDIOutput - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call BufferMIDIOutput - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Call BufferMIDIOutput - - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 32 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 1 -DefaultChannels DW 32 -DriverFlags DW 1 ; Supports MIDI Out. - - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + +; +; MID File generator +; + +REPEATSTATUSBYTE EQU 0 + + .486P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include ..\wavswitc.inc + +FileHandle DW 0 + +MIDOutputMsg DB "MIDI File Generator", 13 + DB "Writing to disk", 0 +MIDOutputError DB "Unable to create output file!", 0FFh, 29, " ", 0 +WriteErrorMsg DB "Error writing to output file. Output file closed", 0FFh, 11, " ", 0 +ClosedMsg DB "Closed output file", 0FFh, 42, " ", 0 +CreateMsg DB "Creating file " +Filename DB " ", 0 +OUTPUT DB "OUTPUT" +DriverName DB "ITMID.DRV", 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 80 +MIDDirectory DB ".", 79 Dup (0) + + +AccumulatedTime DD 0 + +MIDIHEADERSIZE = 22+32+7 +MIDIHeader DB "MThd", 0, 0, 0, 6, 0, 0, 0, 1 + DB 0, 018h ; 24 ppqn + DB "MTrk" +MIDIFileSize DD 0 + DB 0, 0FFh, 01, 28 + DB "Created with Impulse Tracker" + DB 0, 0FFh, 51h, 3 +InitialTempo DD 0 + +MTrkEnd DB 0, 0FFh, 2Fh, 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferOffset DW Offset MIDIBuffer + +MIDScreenList DW 6 + DW IdleFunctionList + DW GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr MIDHeader + + DW Near Ptr DirectoryInputText + DW Near Ptr DirectoryInputBox + DW Near Ptr DirectoryInput ; 6 + + DW 0 + +IdleFunctionList DD 0 + DD 0 +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MIDHeader DW 10 + DB "MIDI File Export Driver", 0 + +DirectoryInputText DW 1 + DB 2, 14 + DB 20h + DB "Output Directory", 0 + +DirectoryInputBox DW 0 + DB 18, 13, 78, 15 + DB 25 + +DirectoryInput DW 16 + DB 19, 14 +Segment1 DW 0 + DW Offset MIDDirectory + DW 59 + DD 0 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +TRACEENABLED EQU 0 +CREATENEWLOGFILE EQU 1 +include debug.inc + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + + Mov Segment1, DS + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GotoHomeDirectory + Mov SI, Offset MIDDirectory + Call SetDirectory + + Mov SI, Offset MIDOutputMsg + ClC + Ret + +EndP InitSound + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckFileClosed + + Push CS + Pop DS + Assume DS:Driver + + Mov BX, FileHandle + Test BX, BX + JZ CheckFileClosedEnd + + Mov AH, 40h + Mov CX, 4 + Mov DX, Offset MTrkEnd + Int 21h + + Mov FileHandle, 0 + + Mov AX, 4200h ; Move to start of file + Xor CX, CX + Xor DX, DX + Int 21h ; Start of file + + Mov AX, Word Ptr [MIDIFileSize] + Mov DX, Word Ptr [MIDIFileSize+2] + XChg AL, DH + XChg AH, DL + Mov Word Ptr [MIDIFileSize], AX + Mov Word Ptr [MIDIFileSize+2], DX + + Mov AH, 40h + Mov CX, MIDIHEADERSIZE + Mov DX, Offset MIDIHeader + Int 21h + + Mov AH, 3Eh + Int 21h + + Mov SI, Offset ClosedMsg + Mov BX, 40 + Call SetInfoLine + +CheckFileClosedEnd: + Ret + +EndP CheckFileClosed + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MIDDirectory + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Call CheckFileClosed + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WriteMIDIBlock + Assume DS:Driver + + Xor ECX, ECX + + Mov CX, MIDIBufferOffset + Mov DX, Offset MIDIBuffer + Mov AH, 40h + Mov BX, FileHandle + Sub CX, DX + JZ NoDataToWrite + + Add MIDIFileSize, ECX + + Trace "Writing MIDI block" + + Int 21h + +NoDataToWrite: + Mov MIDIBufferOffset, Offset MIDIBuffer + + Ret + +EndP WriteMIDIBlock + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + Assume DS:Nothing + + Mov CS:Countdown, 0 + Mov CS:MIDIBufferOffset, Offset MIDIBuffer + + Call Update ; Got DS:SI, CX + +; Scan through channels and if any channels are samples, turn them off. + +TurnOffSamples1: + Test Byte Ptr [SI], 1 ; Channel on? + JZ TurnOffSamples2 + + Mov Word Ptr [SI], 0 + + Test Byte Ptr [SI+3Ah], 80h + JNZ TurnOffSamples2 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +TurnOffSamples2: + Add SI, 128 + Loop TurnOffSamples1 + +; OK.. check whether any MIDI data requires dumping... also whether file +; needs to be created. + + Test AX, AX ; Currently not playing + JNZ Poll1 + + Call CheckFileClosed + Ret + +Poll1: + Push CS + Pop DS + Assume DS:Driver + + Cmp FileHandle, 0 + JNE Poll2 + + Trace "New file to create" + + Mov SI, Offset MIDDirectory + Call SetDirectory + + Xor EAX, EAX + Mov AccumulatedTime, EAX + Mov AL, 4+32+7 + Mov MIDIFileSize, EAX + +; Have to create a file + Call GetFileName + Assume DS:Nothing ; Returns DS:SI + Push CS + Pop ES + Mov DI, Offset FileName + + Push DI + + Mov CX, 12 + Mov AL, ' ' + Rep StosB + + Pop DI + + Cmp Byte Ptr [DS:SI], 0 + JE PollFileNameNone + Cmp Byte Ptr [DS:SI], '.' + JE PollFileNameNone + + Mov CX, 8 +PollFileName1: + LodsB + Cmp AL, 0 + JE PollFileNameExt + Cmp AL, '.' + JE PollFileNameExt + StosB + Loop PollFileName1 + Jmp PollFileNameExt + +PollFileNameNone: + Push CS + Pop DS + Mov SI, Offset Output + Mov CX, 6 + Rep MovsB + +PollFileNameExt: + Mov EAX, 'DIM.' + StosD + Xor AL, AL + StosB + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset CreateMsg + Mov BX, 40 + Call SetInfoLine + + Mov AH, 3Ch + Xor CX, CX + Mov DX, Offset Filename + Int 21h + JC WriteError + + Mov BX, AX + Mov FileHandle, BX + Trace "File opened" + +; Write header once + Push BX + Call GetTempo + Mov EAX, 60000000 + And EBX, 0FFFFh + Xor EDX, EDX + Div EBX ; EAX = microseconds per quarter note + + ShL EAX, 8 + BSwap EAX + Mov InitialTempo, EAX + Pop BX + + Mov AH, 40h + Mov CX, MIDIHEADERSIZE + Mov DX, Offset MIDIHeader + Int 21h + JC WriteError + + Trace "Header written" + +Poll2: + Call WriteMIDIBlock + JC WriteError + +; Update time counters + Inc AccumulatedTime + + Ret + +WriteError: + Call CheckFileClosed + Mov SI, Offset WriteErrorMsg + Mov BX, 40 + Call SetInfoLine + Call StopPlayback + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far ; Frames per second = 0.4*BX + ; -> Milliseconds per frame = 1000/(0.4/BX) + ; = 2500/BX + PushAD + Push DS + +; SetTempo: FF 51 03 tt tt tt + + Push CS + Pop DS + Assume DS:Driver + + Push BX + + Mov SI, MIDIBufferOffset + Call WriteDeltaTime + + Pop BX + + Mov DWord Ptr [SI], 351FFh + Add SI, 3 + + Mov EAX, 60000000 + And EBX, 0FFFFh + Xor EDX, EDX + Div EBX ; EAX = microseconds per quarter note + + ShL EAX, 8 + BSwap EAX + Mov DWord Ptr [SI], EAX + Add SI, 3 + + Mov MIDIBufferOffset, SI + + Pop DS + PopAD + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load (0 based) +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release (1 based) +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset MIDScreenList + + ClC + Ret + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +StatusByte DB 0 +CountDown DB 0 + +StatusByteLUT DB 2, 2, 2, 2, 1, 1, 2 +InSysex DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WriteDeltaTime ; Given DS:SI = buffer + + Xor EDX, EDX + Mov EBX, AccumulatedTime + Mov CX, 4 + Mov AccumulatedTime, EDX + +WriteDeltaTime1: + ShL EDX, 8 + Mov DL, BL + Or DL, 80h + ShR EBX, 7 + LoopNZ WriteDeltaTime1 + ; EDX = output bytes, DL = most signif + +WriteDeltaTime2: + Mov [SI], DL + Inc SI + ShR EDX, 8 + JNZ WriteDeltaTime2 + + And Byte Ptr [SI-1], 7Fh + + Ret + +EndP WriteDeltaTime + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc BufferMIDIOutput ; AL = value. + + PushAD + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov BX, InSysex + Mov SI, MIDIBufferOffset + + Test BX, BX + JZ BufferMIDINoSysex + + Cmp AL, 0F7h + JNE BufferMIDIOutput1 + + Mov DX, SI + Sub DX, BX ; DX = count of sysex bytes + Mov [BX], DL + Mov InSysex, 0 + + Jmp BufferMIDIOutput1 + +BufferMIDINoSysex: + Cmp Countdown, 0 + JNE BufferMIDIOutput1 + + Cmp AL, 0F0h + JA BufferMIDIOutput2 + +; Delta time required + Call WriteDeltaTime + + Xor BX, BX + Xor DL, DL + Test AL, AL + JNS BufferMIDINoStatus + Cmp AL, 0F0h + JE BufferMIDISysex + + Mov StatusByte, AL + Inc DX + Jmp BufferMIDINoStatus + +BufferMIDISysex: + Mov [SI], AL + Inc SI + Mov InSysex, SI + Jmp BufferMIDIOutput1 + +BufferMIDINoStatus: + Mov BL, StatusByte + ShR BX, 4 + Sub BL, 8 + JC BufferMIDIOutput1 + + Add DL, [StatusByteLUT+BX] + Mov Countdown, DL + +BufferMIDIOutput1: + Mov [SI], AL + Inc SI + Dec Countdown + + Mov MIDIBufferOffset, SI + + Cmp SI, Offset MIDIBuffer+200 + JB BufferMIDIOutput2 + Cmp InSysex, 0 + JNE BufferMIDIOutput2 + + Call WriteMIDIBlock + +BufferMIDIOutput2: + Pop DS + PopAD + + Ret + +EndP BufferMIDIOutput + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call BufferMIDIOutput + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Call BufferMIDIOutput + + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 32 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 1 +DefaultChannels DW 32 +DriverFlags DW 1 ; Supports MIDI Out. + + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/MIDDRV2.ASM b/SoundDrivers/MIDDRV2.ASM index 74a2561..4b496be 100755 --- a/SoundDrivers/MIDDRV2.ASM +++ b/SoundDrivers/MIDDRV2.ASM @@ -1,828 +1,828 @@ - -; -; MID File generator -; - -REPEATSTATUSBYTE EQU 0 - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include wavswitc.inc - -FileHandle DW 0 - -MIDOutputMsg DB "MIDI File Generator", 13 - DB "Writing to disk", 0 -MIDOutputError DB "Unable to create output file!", 0FFh, 29, " ", 0 -WriteErrorMsg DB "Error writing to output file. Output file closed", 0FFh, 11, " ", 0 -ClosedMsg DB "Closed output file", 0FFh, 42, " ", 0 -CreateMsg DB "Creating file " -Filename DB " ", 0 -OUTPUT DB "OUTPUT" -DriverName DB "ITMID.DRV", 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 80 -MIDDirectory DB ".", 79 Dup (0) - - -AccumulatedTime DD 0 -AccumulatedTimeError DD 0 - -FrameTime DD 0 -FrameTimeError DD 0 - - -MIDIHeader DB "MThd", 0, 0, 0, 6, 0, 0, 0, 1, 0E7h, 28h - DB "MTrk" -MIDIFileSize DD 0 - DB 0, 0FFh, 01, 28 - DB "Created with Impulse Tracker" - -MTrkEnd DB 0, 0FFh, 2Fh, 0 - -MIDIBuffer DB 256 Dup (0) -MIDIBufferOffset DW Offset MIDIBuffer - -MIDScreenList DW 6 - DW IdleFunctionList - DW GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr MIDHeader - - DW Near Ptr DirectoryInputText - DW Near Ptr DirectoryInputBox - DW Near Ptr DirectoryInput ; 6 - - DW 0 - -IdleFunctionList DD 0 - DD 0 -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MIDHeader DW 10 - DB "MIDI File Export Driver", 0 - -DirectoryInputText DW 1 - DB 2, 14 - DB 20h - DB "Output Directory", 0 - -DirectoryInputBox DW 0 - DB 18, 13, 78, 15 - DB 25 - -DirectoryInput DW 16 - DB 19, 14 -Segment1 DW 0 - DW Offset MIDDirectory - DW 59 - DD 0 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -TRACEENABLED EQU 0 -CREATENEWLOGFILE EQU 1 -include debug.inc - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - - Mov Segment1, DS - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GotoHomeDirectory - Mov SI, Offset MIDDirectory - Call SetDirectory - - Mov SI, Offset MIDOutputMsg - ClC - Ret - -EndP InitSound - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckFileClosed - - Push CS - Pop DS - Assume DS:Driver - - Mov BX, FileHandle - Test BX, BX - JZ CheckFileClosedEnd - - Mov AH, 40h - Mov CX, 4 - Mov DX, Offset MTrkEnd - Int 21h - - Mov FileHandle, 0 - - Mov AX, 4200h ; Move to start of file - Xor CX, CX - Xor DX, DX - Int 21h ; Start of file - - Mov AX, Word Ptr [MIDIFileSize] - Mov DX, Word Ptr [MIDIFileSize+2] - XChg AL, DH - XChg AH, DL - Mov Word Ptr [MIDIFileSize], AX - Mov Word Ptr [MIDIFileSize+2], DX - - Mov AH, 40h - Mov CX, 22+32 - Mov DX, Offset MIDIHeader - Int 21h - - Mov AH, 3Eh - Int 21h - - Mov SI, Offset ClosedMsg - Mov BX, 40 - Call SetInfoLine - -CheckFileClosedEnd: - Ret - -EndP CheckFileClosed - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MIDDirectory - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Call CheckFileClosed - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WriteMIDIBlock - Assume DS:Driver - - Xor ECX, ECX - - Mov CX, MIDIBufferOffset - Mov DX, Offset MIDIBuffer - Mov AH, 40h - Mov BX, FileHandle - Sub CX, DX - JZ NoDataToWrite - - Add MIDIFileSize, ECX - - Trace "Writing MIDI block" - - Int 21h - -NoDataToWrite: - Mov MIDIBufferOffset, Offset MIDIBuffer - - Ret - -EndP WriteMIDIBlock - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - Assume DS:Nothing - - Mov CS:Countdown, 0 - Mov CS:MIDIBufferOffset, Offset MIDIBuffer - - Call Update ; Got DS:SI, CX - -; Scan through channels and if any channels are samples, turn them off. - -TurnOffSamples1: - Test Byte Ptr [SI], 1 ; Channel on? - JZ TurnOffSamples2 - - Mov Word Ptr [SI], 0 - - Test Byte Ptr [SI+3Ah], 80h - JNZ TurnOffSamples2 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -TurnOffSamples2: - Add SI, 128 - Loop TurnOffSamples1 - -; OK.. check whether any MIDI data requires dumping... also whether file -; needs to be created. - - Test AX, AX ; Currently not playing - JNZ Poll1 - - Call CheckFileClosed - Ret - -Poll1: - Push CS - Pop DS - Assume DS:Driver - - Cmp FileHandle, 0 - JNE Poll2 - - Trace "New file to create" - - Mov SI, Offset MIDDirectory - Call SetDirectory - - Xor EAX, EAX - Mov AccumulatedTime, EAX - Mov AccumulatedTimeError, EAX - Mov AL, 4+32 - Mov MIDIFileSize, EAX - -; Have to create a file - Call GetFileName - Assume DS:Nothing ; Returns DS:SI - Push CS - Pop ES - Mov DI, Offset FileName - - Push DI - - Mov CX, 12 - Mov AL, ' ' - Rep StosB - - Pop DI - - Cmp Byte Ptr [DS:SI], 0 - JE PollFileNameNone - Cmp Byte Ptr [DS:SI], '.' - JE PollFileNameNone - - Mov CX, 8 -PollFileName1: - LodsB - Cmp AL, 0 - JE PollFileNameExt - Cmp AL, '.' - JE PollFileNameExt - StosB - Loop PollFileName1 - Jmp PollFileNameExt - -PollFileNameNone: - Push CS - Pop DS - Mov SI, Offset Output - Mov CX, 6 - Rep MovsB - -PollFileNameExt: - Mov EAX, 'DIM.' - StosD - Xor AL, AL - StosB - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset CreateMsg - Mov BX, 40 - Call SetInfoLine - - Mov AH, 3Ch - Xor CX, CX - Mov DX, Offset Filename - Int 21h - JC WriteError - - Mov BX, AX - Mov FileHandle, BX - Trace "File opened" - -; Write header once - Mov AH, 40h - Mov CX, 22+32 - Mov DX, Offset MIDIHeader - Int 21h - JC WriteError - - Trace "Header written" - -Poll2: - Call WriteMIDIBlock - JC WriteError - -; Update time counters - Mov EAX, FrameTimeError - Mov EBX, FrameTime - Add AccumulatedTimeError, EAX - AdC AccumulatedTime, EBX - - Ret - -WriteError: - Call CheckFileClosed - Mov SI, Offset WriteErrorMsg - Mov BX, 40 - Call SetInfoLine - Call StopPlayback - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far ; Frames per second = 0.4*BX - ; -> Milliseconds per frame = 1000/(0.4/BX) - ; = 2500/BX - PushAD - - Mov EAX, 2500 - And EBX, 0FFFFh - Xor EDX, EDX - Div EBX ; EAX = milliseconds - - Mov CS:FrameTime, EAX - Mov CS:FrameTimeError, EDX - - - PopAD - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load (0 based) -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release (1 based) -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset MIDScreenList - - ClC - Ret - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -StatusByte DB 0 -CountDown DB 0 - -StatusByteLUT DB 2, 2, 2, 2, 1, 1, 2 -InSysex DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc BufferMIDIOutput - - PushAD - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov BX, InSysex - Mov SI, MIDIBufferOffset - - Test BX, BX - JZ BufferMIDINoSysex - - Cmp AL, 0F7h - JNE BufferMIDIOutput1 - - Mov DX, SI - Sub DX, BX ; DX = count of sysex bytes - Mov [BX], DL - Mov InSysex, 0 - - Jmp BufferMIDIOutput1 - -BufferMIDINoSysex: - Cmp Countdown, 0 - JNE BufferMIDIOutput1 - - Cmp AL, 0F0h - JA BufferMIDIOutput2 - -; Delta time required - - Xor EDX, EDX - Mov EBX, AccumulatedTime - Mov CX, 4 - Mov AccumulatedTime, EDX - -DeltaTimeOutput1: - ShL EDX, 8 - Mov DL, BL - Or DL, 80h - ShR EBX, 7 - LoopNZ DeltaTimeOutput1 - ; EDX = output bytes, DL = most signif - -DeltaTimeOutput2: - Mov [SI], DL - Inc SI - ShR EDX, 8 - JNZ DeltaTimeOutput2 - - And Byte Ptr [SI-1], 7Fh - - Xor BX, BX - Xor DL, DL - Test AL, AL - JNS BufferMIDINoStatus - Cmp AL, 0F0h - JE BufferMIDISysex - - Mov StatusByte, AL - Inc DX - Jmp BufferMIDINoStatus - -BufferMIDISysex: - Mov [SI], AL - Inc SI - Mov InSysex, SI - Jmp BufferMIDIOutput1 - -BufferMIDINoStatus: - Mov BL, StatusByte - ShR BX, 4 - Sub BL, 8 - JC BufferMIDIOutput1 - - Add DL, [StatusByteLUT+BX] - Mov Countdown, DL - -BufferMIDIOutput1: - Mov [SI], AL - Inc SI - Dec Countdown - - Mov MIDIBufferOffset, SI - - Cmp SI, Offset MIDIBuffer+200 - JB BufferMIDIOutput2 - Cmp InSysex, 0 - JNE BufferMIDIOutput2 - - Call WriteMIDIBlock - -BufferMIDIOutput2: - Pop DS - PopAD - - Ret - -EndP BufferMIDIOutput - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call BufferMIDIOutput - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Call BufferMIDIOutput - - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 32 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 1 -DefaultChannels DW 32 -DriverFlags DW 1 ; Supports MIDI Out. - - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + +; +; MID File generator +; + +REPEATSTATUSBYTE EQU 0 + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include wavswitc.inc + +FileHandle DW 0 + +MIDOutputMsg DB "MIDI File Generator", 13 + DB "Writing to disk", 0 +MIDOutputError DB "Unable to create output file!", 0FFh, 29, " ", 0 +WriteErrorMsg DB "Error writing to output file. Output file closed", 0FFh, 11, " ", 0 +ClosedMsg DB "Closed output file", 0FFh, 42, " ", 0 +CreateMsg DB "Creating file " +Filename DB " ", 0 +OUTPUT DB "OUTPUT" +DriverName DB "ITMID.DRV", 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 80 +MIDDirectory DB ".", 79 Dup (0) + + +AccumulatedTime DD 0 +AccumulatedTimeError DD 0 + +FrameTime DD 0 +FrameTimeError DD 0 + + +MIDIHeader DB "MThd", 0, 0, 0, 6, 0, 0, 0, 1, 0E7h, 28h + DB "MTrk" +MIDIFileSize DD 0 + DB 0, 0FFh, 01, 28 + DB "Created with Impulse Tracker" + +MTrkEnd DB 0, 0FFh, 2Fh, 0 + +MIDIBuffer DB 256 Dup (0) +MIDIBufferOffset DW Offset MIDIBuffer + +MIDScreenList DW 6 + DW IdleFunctionList + DW GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr MIDHeader + + DW Near Ptr DirectoryInputText + DW Near Ptr DirectoryInputBox + DW Near Ptr DirectoryInput ; 6 + + DW 0 + +IdleFunctionList DD 0 + DD 0 +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MIDHeader DW 10 + DB "MIDI File Export Driver", 0 + +DirectoryInputText DW 1 + DB 2, 14 + DB 20h + DB "Output Directory", 0 + +DirectoryInputBox DW 0 + DB 18, 13, 78, 15 + DB 25 + +DirectoryInput DW 16 + DB 19, 14 +Segment1 DW 0 + DW Offset MIDDirectory + DW 59 + DD 0 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +TRACEENABLED EQU 0 +CREATENEWLOGFILE EQU 1 +include debug.inc + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + + Mov Segment1, DS + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GotoHomeDirectory + Mov SI, Offset MIDDirectory + Call SetDirectory + + Mov SI, Offset MIDOutputMsg + ClC + Ret + +EndP InitSound + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckFileClosed + + Push CS + Pop DS + Assume DS:Driver + + Mov BX, FileHandle + Test BX, BX + JZ CheckFileClosedEnd + + Mov AH, 40h + Mov CX, 4 + Mov DX, Offset MTrkEnd + Int 21h + + Mov FileHandle, 0 + + Mov AX, 4200h ; Move to start of file + Xor CX, CX + Xor DX, DX + Int 21h ; Start of file + + Mov AX, Word Ptr [MIDIFileSize] + Mov DX, Word Ptr [MIDIFileSize+2] + XChg AL, DH + XChg AH, DL + Mov Word Ptr [MIDIFileSize], AX + Mov Word Ptr [MIDIFileSize+2], DX + + Mov AH, 40h + Mov CX, 22+32 + Mov DX, Offset MIDIHeader + Int 21h + + Mov AH, 3Eh + Int 21h + + Mov SI, Offset ClosedMsg + Mov BX, 40 + Call SetInfoLine + +CheckFileClosedEnd: + Ret + +EndP CheckFileClosed + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MIDDirectory + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Call CheckFileClosed + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WriteMIDIBlock + Assume DS:Driver + + Xor ECX, ECX + + Mov CX, MIDIBufferOffset + Mov DX, Offset MIDIBuffer + Mov AH, 40h + Mov BX, FileHandle + Sub CX, DX + JZ NoDataToWrite + + Add MIDIFileSize, ECX + + Trace "Writing MIDI block" + + Int 21h + +NoDataToWrite: + Mov MIDIBufferOffset, Offset MIDIBuffer + + Ret + +EndP WriteMIDIBlock + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + Assume DS:Nothing + + Mov CS:Countdown, 0 + Mov CS:MIDIBufferOffset, Offset MIDIBuffer + + Call Update ; Got DS:SI, CX + +; Scan through channels and if any channels are samples, turn them off. + +TurnOffSamples1: + Test Byte Ptr [SI], 1 ; Channel on? + JZ TurnOffSamples2 + + Mov Word Ptr [SI], 0 + + Test Byte Ptr [SI+3Ah], 80h + JNZ TurnOffSamples2 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +TurnOffSamples2: + Add SI, 128 + Loop TurnOffSamples1 + +; OK.. check whether any MIDI data requires dumping... also whether file +; needs to be created. + + Test AX, AX ; Currently not playing + JNZ Poll1 + + Call CheckFileClosed + Ret + +Poll1: + Push CS + Pop DS + Assume DS:Driver + + Cmp FileHandle, 0 + JNE Poll2 + + Trace "New file to create" + + Mov SI, Offset MIDDirectory + Call SetDirectory + + Xor EAX, EAX + Mov AccumulatedTime, EAX + Mov AccumulatedTimeError, EAX + Mov AL, 4+32 + Mov MIDIFileSize, EAX + +; Have to create a file + Call GetFileName + Assume DS:Nothing ; Returns DS:SI + Push CS + Pop ES + Mov DI, Offset FileName + + Push DI + + Mov CX, 12 + Mov AL, ' ' + Rep StosB + + Pop DI + + Cmp Byte Ptr [DS:SI], 0 + JE PollFileNameNone + Cmp Byte Ptr [DS:SI], '.' + JE PollFileNameNone + + Mov CX, 8 +PollFileName1: + LodsB + Cmp AL, 0 + JE PollFileNameExt + Cmp AL, '.' + JE PollFileNameExt + StosB + Loop PollFileName1 + Jmp PollFileNameExt + +PollFileNameNone: + Push CS + Pop DS + Mov SI, Offset Output + Mov CX, 6 + Rep MovsB + +PollFileNameExt: + Mov EAX, 'DIM.' + StosD + Xor AL, AL + StosB + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset CreateMsg + Mov BX, 40 + Call SetInfoLine + + Mov AH, 3Ch + Xor CX, CX + Mov DX, Offset Filename + Int 21h + JC WriteError + + Mov BX, AX + Mov FileHandle, BX + Trace "File opened" + +; Write header once + Mov AH, 40h + Mov CX, 22+32 + Mov DX, Offset MIDIHeader + Int 21h + JC WriteError + + Trace "Header written" + +Poll2: + Call WriteMIDIBlock + JC WriteError + +; Update time counters + Mov EAX, FrameTimeError + Mov EBX, FrameTime + Add AccumulatedTimeError, EAX + AdC AccumulatedTime, EBX + + Ret + +WriteError: + Call CheckFileClosed + Mov SI, Offset WriteErrorMsg + Mov BX, 40 + Call SetInfoLine + Call StopPlayback + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far ; Frames per second = 0.4*BX + ; -> Milliseconds per frame = 1000/(0.4/BX) + ; = 2500/BX + PushAD + + Mov EAX, 2500 + And EBX, 0FFFFh + Xor EDX, EDX + Div EBX ; EAX = milliseconds + + Mov CS:FrameTime, EAX + Mov CS:FrameTimeError, EDX + + + PopAD + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load (0 based) +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release (1 based) +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset MIDScreenList + + ClC + Ret + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +StatusByte DB 0 +CountDown DB 0 + +StatusByteLUT DB 2, 2, 2, 2, 1, 1, 2 +InSysex DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc BufferMIDIOutput + + PushAD + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov BX, InSysex + Mov SI, MIDIBufferOffset + + Test BX, BX + JZ BufferMIDINoSysex + + Cmp AL, 0F7h + JNE BufferMIDIOutput1 + + Mov DX, SI + Sub DX, BX ; DX = count of sysex bytes + Mov [BX], DL + Mov InSysex, 0 + + Jmp BufferMIDIOutput1 + +BufferMIDINoSysex: + Cmp Countdown, 0 + JNE BufferMIDIOutput1 + + Cmp AL, 0F0h + JA BufferMIDIOutput2 + +; Delta time required + + Xor EDX, EDX + Mov EBX, AccumulatedTime + Mov CX, 4 + Mov AccumulatedTime, EDX + +DeltaTimeOutput1: + ShL EDX, 8 + Mov DL, BL + Or DL, 80h + ShR EBX, 7 + LoopNZ DeltaTimeOutput1 + ; EDX = output bytes, DL = most signif + +DeltaTimeOutput2: + Mov [SI], DL + Inc SI + ShR EDX, 8 + JNZ DeltaTimeOutput2 + + And Byte Ptr [SI-1], 7Fh + + Xor BX, BX + Xor DL, DL + Test AL, AL + JNS BufferMIDINoStatus + Cmp AL, 0F0h + JE BufferMIDISysex + + Mov StatusByte, AL + Inc DX + Jmp BufferMIDINoStatus + +BufferMIDISysex: + Mov [SI], AL + Inc SI + Mov InSysex, SI + Jmp BufferMIDIOutput1 + +BufferMIDINoStatus: + Mov BL, StatusByte + ShR BX, 4 + Sub BL, 8 + JC BufferMIDIOutput1 + + Add DL, [StatusByteLUT+BX] + Mov Countdown, DL + +BufferMIDIOutput1: + Mov [SI], AL + Inc SI + Dec Countdown + + Mov MIDIBufferOffset, SI + + Cmp SI, Offset MIDIBuffer+200 + JB BufferMIDIOutput2 + Cmp InSysex, 0 + JNE BufferMIDIOutput2 + + Call WriteMIDIBlock + +BufferMIDIOutput2: + Pop DS + PopAD + + Ret + +EndP BufferMIDIOutput + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call BufferMIDIOutput + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Call BufferMIDIOutput + + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 32 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 1 +DefaultChannels DW 32 +DriverFlags DW 1 ; Supports MIDI Out. + + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/MIDIDRV.ASM b/SoundDrivers/MIDIDRV.ASM index bcc2a53..987ec3e 100755 --- a/SoundDrivers/MIDIDRV.ASM +++ b/SoundDrivers/MIDIDRV.ASM @@ -1,525 +1,525 @@ -; -; MIDI MPU401 Driver for Impulse Tracker. -; Accepts MIDI Input, does MIDI output, but does NOT handle samples at all. -; - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -OldIRQHandler DD 0 -MIDIUpdateTimer DW 0 -MIDIUpdateCount DW 0 -MIDIUpdateFlag DB 0 -MIDIDriverMsg DB "MPU401 or compatible detected", 13 - DB "Address ", 0FDh, "Xh", 0 -MIDIReinitMsg DB "MPU401 reinitialised", 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART ; Given DX = port. - - ClI - - Inc DX - - Xor CX, CX - -ResetUART1: - In AL, DX - Test AL, 40h - LoopNZ ResetUART1 - JNZ ResetUARTFailed - - Mov AL, 0FFh - Out DX, AL - - Xor CX, CX - -ResetUART2: - In AL, DX - Test AL, 80h - LoopNZ ResetUART2 - JNZ ResetUARTFailed - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JNE ResetUART2 - - Dec DX - - DB 85h - -ResetUARTFailed: - StC - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetUARTMode - - Mov DX, CS:BasePort - Inc DX - - Xor CX, CX - -SetUARTMode1: - In AL, DX - Test AL, 40h - LoopNZ SetUARTMode1 - JNZ SetUARTModeFailed - - Mov AL, 3Fh - Out DX, AL - - Xor CX, CX - -SetUARTMode2: - In AL, DX - Test AL, 80h - LoopNZ SetUARTMode2 - JNZ SetUARTModeFailed - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JNE SetUARTMode2 - Dec DX - - DB 85h - -SetUARTModeFailed: - StC - StI - Ret - -EndP SetUARTMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut ; AL = byte out - - Push CX - Push DX - Mov DX, CS:Baseport - - Push AX - Xor CX, CX - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - LoopNZ UARTOut1 - - Pop AX - JNZ UARTOutEnd - - Dec DX - Out DX, AL - -UARTOutEnd: - Pop DX - Pop CX - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - JE SendUARTOutStateInc - - Mov CS:InterpretState, 0 - -SendUARTOut4: - Ret - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDIIRQHandler - - PushAD - - Mov AX, MIDIUpdateTimer - Add MIDIUpdateCount, AX - JC MIDIIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp MIDIIRQHandler2 - -MIDIIRQHandler1: - PushF - Call [OldIRQHandler] - -MIDIIRQHandler2: - Xor MIDIUpdateFlag, 1 - JZ MIDIIRQHandlerEnd - - Push DS - Push ES - - ClD - - Call SaveEMSPageFrame - Call Update ; Returns DS:SI, CX - -; Have to clear any sample channels playing. -; Kill any active channel - -MIDIIRQHandler3: - Test Byte Ptr [SI], 1 ; Channel on? - JZ MIDIIRQHandler4 - - Mov Word Ptr [SI], 0 - - Test Byte Ptr [SI+3Ah], 80h - JNZ MIDIIRQHandler4 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -MIDIIRQHandler4: - Add SI, 128 - Dec CX - JNZ MIDIIRQHandler3 - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - -MIDIIRQHandlerEnd: - PopAD - IRet - -EndP MIDIIRQHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - Mov AL, 34h - Out 43h, AL - - Xor AX, AX - Mov ES, AX - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset MIDIIRQHandler - Mov [ES:20h], EAX - - Ret - -EndP SetIRQ - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Mov DX, CS:BasePort - Cmp DX, 0FFFFh - JNE DetectCard1 - - Mov DX, 330h - Call ResetUART - JNC DetectCard2 - - Mov DX, 300h - -DetectCard1: - Call ResetUART - -DetectCard2: - Mov CS:BasePort, DX - Mov EAX, 'Jeff' - Ret - -EndP DetectCard - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - Mov EAX, [ES:20h] - Mov OldIRQHandler, EAX - Call SetIRQ - - Call SetUARTMode - - Mov SI, Offset MIDIDriverMsg - Mov AX, BasePort - - ClC - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset MIDIReinitMsg - Mov BX, 40 - Call SetInfoLine - - Mov DX, BasePort - Call ResetUART - - Call SetIRQ - Call SetUARTMode - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov DX, CS:BasePort - Call ResetUART - - Xor AX, AX - Mov ES, AX - Mov EAX, CS:OldIRQHandler - Mov [ES:20h], EAX - - Xor AL, AL - Out 40h, AL ; Timer IRQ. - Out 40h, AL - - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - ClI - - Call [UARTBufferEmpty] - JC Poll1 - -PollEnd: - StI - Ret - -Poll1: - Mov DX, BasePort - Inc DX - - In AL, DX - Test AL, AL - JS PollEnd - - Dec DX - In AL, DX - - Call [CS:UARTSend] - Jmp Poll - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - ; Frames per second = 2 * (0.4*Tempo) - Mov AX, 0C214h - Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo - Div BX - - ; AX contains counter. - Mov CS:MIDIUpdateTimer, AX - - Out 40h, AL ; Timer IRQ. - Mov AL, AH - Out 40h, AL - -SetTempo2: - Pop DX - Pop BX - Pop AX - Ret - -EndP SetTempo - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Xor AX, AX - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 64 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 64 -DriverFlags DW 1 ; Handles MIDI Output - - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SoundCardScreen ; SetMixVolume - DW Offset SoundCardScreen ; SetStereo - - DW Offset SoundCardScreen ; LoadSample - DW Offset SoundCardScreen ; ReleaseSample - DW Offset SoundCardScreen ; ResetMemory - - DW Offset SoundCardScreen ; GetStatus - DW Offset SoundCardScreen ; SoundCardScreen - DW Offset SoundCardScreen ; GetVariable - DW Offset SoundCardScreen ; SetVariable - - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; MIDI MPU401 Driver for Impulse Tracker. +; Accepts MIDI Input, does MIDI output, but does NOT handle samples at all. +; + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +OldIRQHandler DD 0 +MIDIUpdateTimer DW 0 +MIDIUpdateCount DW 0 +MIDIUpdateFlag DB 0 +MIDIDriverMsg DB "MPU401 or compatible detected", 13 + DB "Address ", 0FDh, "Xh", 0 +MIDIReinitMsg DB "MPU401 reinitialised", 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART ; Given DX = port. + + ClI + + Inc DX + + Xor CX, CX + +ResetUART1: + In AL, DX + Test AL, 40h + LoopNZ ResetUART1 + JNZ ResetUARTFailed + + Mov AL, 0FFh + Out DX, AL + + Xor CX, CX + +ResetUART2: + In AL, DX + Test AL, 80h + LoopNZ ResetUART2 + JNZ ResetUARTFailed + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JNE ResetUART2 + + Dec DX + + DB 85h + +ResetUARTFailed: + StC + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetUARTMode + + Mov DX, CS:BasePort + Inc DX + + Xor CX, CX + +SetUARTMode1: + In AL, DX + Test AL, 40h + LoopNZ SetUARTMode1 + JNZ SetUARTModeFailed + + Mov AL, 3Fh + Out DX, AL + + Xor CX, CX + +SetUARTMode2: + In AL, DX + Test AL, 80h + LoopNZ SetUARTMode2 + JNZ SetUARTModeFailed + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JNE SetUARTMode2 + Dec DX + + DB 85h + +SetUARTModeFailed: + StC + StI + Ret + +EndP SetUARTMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut ; AL = byte out + + Push CX + Push DX + Mov DX, CS:Baseport + + Push AX + Xor CX, CX + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + LoopNZ UARTOut1 + + Pop AX + JNZ UARTOutEnd + + Dec DX + Out DX, AL + +UARTOutEnd: + Pop DX + Pop CX + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + JE SendUARTOutStateInc + + Mov CS:InterpretState, 0 + +SendUARTOut4: + Ret + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDIIRQHandler + + PushAD + + Mov AX, MIDIUpdateTimer + Add MIDIUpdateCount, AX + JC MIDIIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp MIDIIRQHandler2 + +MIDIIRQHandler1: + PushF + Call [OldIRQHandler] + +MIDIIRQHandler2: + Xor MIDIUpdateFlag, 1 + JZ MIDIIRQHandlerEnd + + Push DS + Push ES + + ClD + + Call SaveEMSPageFrame + Call Update ; Returns DS:SI, CX + +; Have to clear any sample channels playing. +; Kill any active channel + +MIDIIRQHandler3: + Test Byte Ptr [SI], 1 ; Channel on? + JZ MIDIIRQHandler4 + + Mov Word Ptr [SI], 0 + + Test Byte Ptr [SI+3Ah], 80h + JNZ MIDIIRQHandler4 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +MIDIIRQHandler4: + Add SI, 128 + Dec CX + JNZ MIDIIRQHandler3 + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + +MIDIIRQHandlerEnd: + PopAD + IRet + +EndP MIDIIRQHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + Mov AL, 34h + Out 43h, AL + + Xor AX, AX + Mov ES, AX + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset MIDIIRQHandler + Mov [ES:20h], EAX + + Ret + +EndP SetIRQ + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Mov DX, CS:BasePort + Cmp DX, 0FFFFh + JNE DetectCard1 + + Mov DX, 330h + Call ResetUART + JNC DetectCard2 + + Mov DX, 300h + +DetectCard1: + Call ResetUART + +DetectCard2: + Mov CS:BasePort, DX + Mov EAX, 'Jeff' + Ret + +EndP DetectCard + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + Mov EAX, [ES:20h] + Mov OldIRQHandler, EAX + Call SetIRQ + + Call SetUARTMode + + Mov SI, Offset MIDIDriverMsg + Mov AX, BasePort + + ClC + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset MIDIReinitMsg + Mov BX, 40 + Call SetInfoLine + + Mov DX, BasePort + Call ResetUART + + Call SetIRQ + Call SetUARTMode + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov DX, CS:BasePort + Call ResetUART + + Xor AX, AX + Mov ES, AX + Mov EAX, CS:OldIRQHandler + Mov [ES:20h], EAX + + Xor AL, AL + Out 40h, AL ; Timer IRQ. + Out 40h, AL + + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + ClI + + Call [UARTBufferEmpty] + JC Poll1 + +PollEnd: + StI + Ret + +Poll1: + Mov DX, BasePort + Inc DX + + In AL, DX + Test AL, AL + JS PollEnd + + Dec DX + In AL, DX + + Call [CS:UARTSend] + Jmp Poll + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + ; Frames per second = 2 * (0.4*Tempo) + Mov AX, 0C214h + Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo + Div BX + + ; AX contains counter. + Mov CS:MIDIUpdateTimer, AX + + Out 40h, AL ; Timer IRQ. + Mov AL, AH + Out 40h, AL + +SetTempo2: + Pop DX + Pop BX + Pop AX + Ret + +EndP SetTempo + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Xor AX, AX + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 64 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 64 +DriverFlags DW 1 ; Handles MIDI Output + + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SoundCardScreen ; SetMixVolume + DW Offset SoundCardScreen ; SetStereo + + DW Offset SoundCardScreen ; LoadSample + DW Offset SoundCardScreen ; ReleaseSample + DW Offset SoundCardScreen ; ResetMemory + + DW Offset SoundCardScreen ; GetStatus + DW Offset SoundCardScreen ; SoundCardScreen + DW Offset SoundCardScreen ; GetVariable + DW Offset SoundCardScreen ; SetVariable + + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/MIW.BAT b/SoundDrivers/MIW.BAT index 61058f7..9358f42 100755 --- a/SoundDrivers/MIW.BAT +++ b/SoundDrivers/MIW.BAT @@ -1,4 +1,4 @@ -tasm /m /uT310 iwdrv -tlink /3 iwdrv -execom iwdrv itiw.drv -copy itiw.drv .. +tasm /m /uT310 iwdrv +tlink /3 iwdrv +execom iwdrv itiw.drv +copy itiw.drv .. diff --git a/SoundDrivers/MIX.INC b/SoundDrivers/MIX.INC index d11f1a9..22865db 100755 --- a/SoundDrivers/MIX.INC +++ b/SoundDrivers/MIX.INC @@ -1,1014 +1,1014 @@ - - -ERROR EQU CX -DELTAERROR EQU BP -DELTAOFFSET EQU DX -OLDPOSITION EQU [SI+2Ch] -CURRENTPOSITION EQU [SI+4Ch] -CURRENTPOSITIONERROR EQU Word Ptr [SI+48h] -LOOPSTART EQU [SI+40h] -LOOPEND EQU [SI+44h] -STEPVALUE EQU [SI+02h] -; STEPVALUEHIGH EQU Word Ptr [SI+04h] -DIRECTIONFLAG EQU Byte Ptr [SI+0Bh] - -EXTRAOFFSET = MixResolution/8-2 - -IF MIXRESOLUTION GT 16 - RESOLUTIONSHIFT = 2 -ELSE - RESOLUTIONSHIFT = 1 -ENDIF - -IF STEREOENABLED - RESOLUTIONSHIFT = RESOLUTIONSHIFT+1 -ENDIF - -MixBufferOffset DW 0 - -MixBlockSize DW 0 ; Number of bytes to mix - DW 0 ; High order 0 - -PreMixFunction DW 0 -MixFunctionSeparate DW 0 ; Function to separate blocks into 64k - ; chunks. -MixFunctionSeparateBackwards DW 0 ; function to separate blocks into 64k - ; in backwards steps. -MixFunction DW 0 ; Function to mix samples - -LastPage DW 0 - -MemoryType DB 0 -NumPages DB 0 -SampleLocation DW 0 ; Either EMS Handle or Conventional - ; base segment -EMSPageFrame DW 0 - -LoopCounter DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixNoLoop - - Call [PreMixFunction] - Call PrepareSampleSegment - - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - - Xor CX, CX - Mov EBX, LOOPEND - Sub CX, CURRENTPOSITIONERROR - SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) - JC MixNoLoop3 - - Cmp EDX, EBX - JL MixNoLoop1 - JG MixNoLoop2 - Cmp AX, CX - JB MixNoLoop1 - -MixNoLoop2: - ; Turn off - Mov EDX, EBX - Mov AX, CX - - Mov Word Ptr [SI], 200h - Test Byte Ptr [SI+3Ah], 80h - JNZ MixNoLoop1 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -MixNoLoop1: - Jmp [MixFunctionSeparate] - -MixNoLoop3: - Mov Word Ptr [SI], 200h - Test Byte Ptr [SI+3Ah], 80h - JNZ MixNoLoop4 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -MixNoLoop4: - Ret - -EndP MixNoLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixForwardsLoop - - Call [PreMixFunction] - Call PrepareSampleSegment - -MixForwardsLoopAgain: - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - - Xor CX, CX - Mov EBX, LOOPEND - Sub CX, CURRENTPOSITIONERROR - SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) - JC UpdateMixForwardsLoop - - Cmp EDX, EBX - JL MixForwardsLoop1 - JG MixForwardsLoop2 - Cmp AX, CX - JB MixForwardsLoop1 - -MixForwardsLoop2: - Mov EDX, EBX - Mov AX, CX - - Call [MixFunctionSeparate] - -UpdateMixForwardsLoop: - Mov EAX, CURRENTPOSITION - Xor EDX, EDX - - Mov EBX, LOOPEND - SUB EAX, EBX - SUB EBX, LOOPSTART - JBE MixForwardsLoop3 - - Div EBX - Add EDX, LOOPSTART - Mov CURRENTPOSITION, EDX - -; Cmp EBX, 10000h -; JAE MixForwardsLoop4 - -; Mov AX, STEPVALUEHIGH -; Cmp AX, BX -; JAE MixForwardsLoop5 - -; MixForwardsLoop4: - Cmp MixBlockSize, 0 - JG MixForwardsLoopAgain - -MixForwardsLoop3: - Ret - -; MixForwardsLoop5: -; Xor DX, DX -; Div BX -; Mov STEPVALUEHIGH, DX - -; Cmp MixBlockSize, 0 -; JG MixForwardsLoopAgain - -; Ret - -MixForwardsLoop1: - Jmp [MixFunctionSeparate] - -EndP MixForwardsLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixPingPongLoop - - Call [PreMixFunction] - Call PrepareSampleSegment - -MixPingPongLoopAgain: - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - - Cmp DIRECTIONFLAG, 0 - JNE MixPingPongLoopBackwards1 - -MixPingPongLoopForwards1: - Xor CX, CX - Mov EBX, LOOPEND - Sub CX, CURRENTPOSITIONERROR - SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) - JC UpdateMixPingPongLoopForwards1 - - Cmp EDX, EBX - JG MixPingPongLoopForwards3 - JL MixPingPongLoopForwards2 - - Cmp AX, CX - JAE MixPingPongLoopForwards3 - -MixPingPongLoopForwards2: - Jmp [MixFunctionSeparate] - -MixPingPongLoopForwards3: - Mov EDX, EBX - Mov AX, CX - Call [MixFunctionSeparate] - -UpdateMixPingPongLoopForwards1: - Mov EAX, CURRENTPOSITION - Mov EBX, LOOPEND - Xor EDX, EDX - Sub EAX, EBX - Sub EBX, LOOPSTART - JBE MixPingPongError - - Add EBX, EBX - Div EBX - - ShR EBX, 1 - - Cmp EDX, EBX - JAE MixPingPongLoopForwards4 - - Mov DIRECTIONFLAG, 1 - Mov EAX, LOOPEND - Sub EAX, EDX - Dec EAX - Mov CURRENTPOSITION, EAX - Neg Word Ptr CURRENTPOSITIONERROR - Jmp MixPingPongLoopNext - -MixPingPongLoopForwards4: - Sub EDX, EBX - Add EDX, LOOPSTART - Mov CURRENTPOSITION, EDX - Jmp MixPingPongLoopNext - -MixPingPongLoopBackwards1: - Mov EBX, CURRENTPOSITION - Mov CX, CURRENTPOSITIONERROR - - Sub CX, 0FFFFh - SBB EBX, LOOPSTART - JC UpdateMixPingPongLoopBackwards1 - - Cmp EDX, EBX - JG MixPingPongLoopBackwards3 - JL MixPingPongLoopBackwards2 - - Cmp AX, CX - JAE MixPingPongLoopBackwards3 - -MixPingPongLoopBackwards2: - Call [MixFunctionSeparateBackwards] - -MixPingPongError: - Ret - -MixPingPongLoopBackwards3: - Mov EDX, EBX - Mov AX, CX - Call [MixFunctionSeparateBackwards] - -UpdateMixPingPongLoopBackwards1: - Mov EBX, LOOPEND - Mov EAX, LOOPSTART - Sub EBX, EAX - JBE MixPingPongError - - Sub EAX, CURRENTPOSITION - Xor EDX, EDX - Add EBX, EBX - Div EBX - - ShR EBX, 1 - - Cmp EDX, EBX - JAE MixPingPongLoopBackwards4 - - Mov DIRECTIONFLAG, 0 - Add EDX, LOOPSTART - Mov CURRENTPOSITION, EDX - Neg Word Ptr CURRENTPOSITIONERROR - Jmp MixPingPongLoopNext - -MixPingPongLoopBackwards4: - Sub EBX, EDX - Add EBX, LOOPEND - Dec EBX - Mov CURRENTPOSITION, EBX - -MixPingPongLoopNext: - Cmp MixBlockSize, 0 - JG MixPingPongLoopAgain - - Ret - -EndP MixPingPongLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateNoLoop - - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - Add CURRENTPOSITIONERROR, AX - AdC EDX, CURRENTPOSITION - - Cmp EDX, LOOPEND - JL UpdateNoLoop1 - -UpdateNoLoop2: ; Turn off - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ UpdateNoLoop1 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - Ret - -UpdateNoLoop1: - Mov CURRENTPOSITION, EDX - - Ret - -EndP UpdateNoLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateForwardsLoop - - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - Add CURRENTPOSITIONERROR, AX - AdC EDX, CURRENTPOSITION - - Cmp EDX, LOOPEND - JL UpdateForwardsLoop1 - -UpdateForwardsLoop2: ; Reset position... - Mov EBX, LOOPEND - Mov EAX, EDX - Xor EDX, EDX - Sub EAX, EBX - Sub EBX, LOOPSTART - JZ UpdateForwardsLoop1 - Div EBX - - Add EDX, LOOPSTART - -UpdateForwardsLoop1: - Mov CURRENTPOSITION, EDX - Ret - -EndP UpdateForwardsLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdatePingPongLoop - - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - - Cmp DIRECTIONFLAG, 0 - JNE UpdatePingPongLoopBackwards1 - -UpdatePingPongLoopForwards1: - Add CURRENTPOSITIONERROR, AX - AdC EDX, CURRENTPOSITION - - Cmp EDX, LOOPEND - JA UpdatePingPongLoopForwards2 - - Mov CURRENTPOSITION, EDX - Ret - -UpdatePingPongLoopForwards2: - Mov EAX, EDX - Mov EBX, LOOPEND - Xor EDX, EDX - Sub EAX, EBX - Sub EBX, LOOPSTART - Add EBX, EBX - Div EBX - - ShR EBX, 1 - - Cmp EDX, EBX - JAE UpdatePingPongLoopForwards3 - - Mov DIRECTIONFLAG, 1 - Mov EAX, LOOPEND - Sub EAX, EDX - Dec EAX - NEG CURRENTPOSITIONERROR - Mov CURRENTPOSITION, EAX - Ret - -UpdatePingPongLoopForwards3: - Sub EDX, EBX - Add EDX, LOOPSTART - Mov CURRENTPOSITION, EDX - Ret - -UpdatePingPongLoopBackwards1: - Sub CURRENTPOSITIONERROR, AX - Mov ECX, CURRENTPOSITION - SBB ECX, EDX - - Cmp ECX, LOOPSTART - JLE UpdatePingPongLoopBackwards2 - - Mov CURRENTPOSITION, ECX - Ret - -UpdatePingPongLoopBackwards2: - Mov EAX, LOOPSTART - Mov EBX, LOOPEND - Xor EDX, EDX - Sub EBX, EAX - Sub EAX, ECX - Add EBX, EBX - Div EBX - - ShR EBX, 1 - - Cmp EDX, EBX - JAE UpdatePingPongLoopBackwards3 - - Mov DIRECTIONFLAG, 0 - Add EDX, LOOPSTART - NEG CURRENTPOSITIONERROR - Mov CURRENTPOSITION, EDX - Ret - -UpdatePingPongLoopBackwards3: - Sub EBX, EDX - Add EBX, LOOPEND - Dec EBX - Mov CURRENTPOSITION, EBX - - Ret - -EndP UpdatePingPongLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PrepareSampleSegment ; Sets up sample mixing segment - - Mov ES, SongDataArea - - Mov BX, [SI+34h] - Mov EAX, [ES:BX+48h] - - Mov DWord Ptr MemoryType, EAX ; Writes numpages & Sample - ; location also. - Mov LastPage, 0FFFFh - - Ret - -EndP PrepareSampleSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSampleSegment ; Given EDI, Returns ES - - Mov CX, Word Ptr CS:MemoryType - - Cmp CL, 2 - JNE SetSampleSegment1 - - Push EAX - Push EDX - - Mov EBX, EDI - ShR EBX, 14 - And EDI, 16383 - - Cmp BX, LastPage - JE SetSampleEMS2 - - Mov LastPage, BX - Mov DX, SampleLocation ; EMS handle - ; BX = starting page required - Mov AL, 3 - Add BX, 3 - - Cmp BL, CH - JBE SetSampleEMS1 - - Sub CH, BL - Add BL, CH - Add AL, CH - JNC SetSampleEMS2 - -SetSampleEMS1: - Mov AH, 44h - Int 67h - - Dec BX - Dec AL - JNS SetSampleEMS1 - -SetSampleEMS2: - Mov ES, EMSPageFrame - - Pop EDX - Pop EAX - - Ret - -SetSampleSegment1: ; Conventional memory - Mov ECX, EDI - And EDI, 15 - ShR ECX, 4 - Add CX, SampleLocation - Mov ES, CX - - Ret - -EndP SetSampleSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetBackSampleSegment ; Given BX = frame, Returns ES - - Mov CX, Word Ptr CS:MemoryType - - Cmp CL, 2 - JNE SetBackSampleSegment1 - - Push EAX - Push EDX - - Cmp BX, LastPage - JE SetBackSampleEMS2 - - Mov LastPage, BX - Mov DX, SampleLocation ; EMS handle - ; BX = starting page required - Mov AL, 3 - Add BX, 3 - - Cmp BL, CH - JBE SetBackSampleEMS1 - - Sub CH, BL - Add BL, CH - Add AL, CH - JNC SetBackSampleEMS2 - -SetBackSampleEMS1: - Mov AH, 44h - Int 67h - - Dec BX - Dec AL - JNS SetBackSampleEMS1 - -SetBackSampleEMS2: - Mov ES, EMSPageFrame - - Pop EDX - Pop EAX - - Ret - -SetBackSampleSegment1: ; Conventional memory - ShL BX, 10 - Add BX, SampleLocation - Mov ES, BX - - Ret - -EndP SetBackSampleSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MFS8Bit ; EDX:AX = 32.16 bytes offset. - ; to mix - - - Push AX - Push EDX - - Mov EDI, CURRENTPOSITION - Call SetSampleSegment - - Xor CX, CX ; EDI = CurrentPosition & (2^14-1) - - Mov EBX, 0FFFEh - - Sub CX, CURRENTPOSITIONERROR - SBB EBX, EDI - ; EBX:CX = 64k-(CurrentPosition & (2^14-1)) - ; EDX:AX = blocksize - Cmp EDX, EBX - JBE MFS8Bit1 - - Mov EDX, EBX - Mov AX, CX - -MFS8Bit1: - ; Now to calculate bytes to mix... - ShL EAX, 16 - SHRD EAX, EDX, 16 - ShR EDX, 16 ; EDX:EAX = (16)32.16 offset - - Mov EBX, STEPVALUE - Cmp EDX, EBX - JAE MFS8Bit2 - - Div EBX - Add EDX, 0FFFFFFFFh - AdC EAX, 0 ; EAX = no of bytes to mix - JZ MFS8Bit2 - - Push EAX - - Xor ECX, ECX - Mov DELTAOFFSET, [SI+4] ; Stepvalue - Mov DELTAERROR, [SI+2] ; Stepvalue - Mov CX, CURRENTPOSITIONERROR - - Push DS - Push SI - - Mov SI, MixBufferOffset - Mov DS, MixSegment - Call [MixFunction] - - Pop SI - Pop DS - Pop ECX - Jmp MFS8Bit3 - -MFS8Bit2: -; Xor ECX, ECX - Pop EDX - Pop AX - - Ret - -MFS8Bit3: - ; Update pointers... - Mov EAX, STEPVALUE - Mul ECX - - Sub MixBlockSize, CX - ShL CX, RESOLUTIONSHIFT - Add MixBufferOffset, CX - - ; EDX:EAX = offset mixed (32.16) - ShLD EDX, EAX, 16 - Mov BX, AX - Mov ECX, EDX ; ECX:BX = offset mixed - - Add CURRENTPOSITIONERROR, BX - AdC CURRENTPOSITION, ECX - - Pop EDX - Pop AX - - Sub AX, BX - SBB EDX, ECX - - JG MFS8Bit - - Ret - -EndP MFS8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MFS16Bit - - Push AX - Push EDX - - Mov EDI, CURRENTPOSITION - Add EDI, EDI - Call SetSampleSegment - - ShR EDI, 1 ; EDI = number of samples. - - Xor CX, CX - - Mov EBX, 7FFEh - - Sub CX, CURRENTPOSITIONERROR - SBB EBX, EDI - - Cmp EDX, EBX - JBE MFS16Bit1 - - Mov EDX, EBX - Mov AX, CX - -MFS16Bit1: - ; Now to calculate bytes to mix... - ShL EAX, 16 - SHRD EAX, EDX, 16 - ShR EDX, 16 ; EDX:EAX = (16)32.16 offset - - Mov EBX, STEPVALUE - Cmp EDX, EBX - JAE MFS16Bit2 - - Div EBX - Add EDX, 0FFFFFFFFh - AdC EAX, 0 ; EAX = no of bytes to mix - JZ MFS16Bit2 - - Push EAX - - Xor ECX, ECX - Mov DELTAOFFSET, [SI+4] ; Stepvalue - Mov DELTAERROR, [SI+2] ; Stepvalue - Mov CX, CURRENTPOSITIONERROR - - Push DS - Push SI - - Mov SI, MixBufferOffset - Mov DS, MixSegment - Call [MixFunction] - - Pop SI - Pop DS - Pop ECX - Jmp MFS16Bit3 - -MFS16Bit2: -; Xor ECX, ECX - Pop EDX - Pop AX - Ret - -MFS16Bit3: - ; Update pointers... - Mov EAX, STEPVALUE - Mul ECX - - Sub MixBlockSize, CX - ShL CX, RESOLUTIONSHIFT - Add MixBufferOffset, CX - - ; EDX:EAX = offset mixed (32.16) - ShLD EDX, EAX, 16 - Mov BX, AX - Mov ECX, EDX ; ECX:BX = offset mixed - - Add CURRENTPOSITIONERROR, BX - AdC CURRENTPOSITION, ECX - - Pop EDX - Pop AX - - Sub AX, BX - SBB EDX, ECX - - JG MFS16Bit - - Ret - -EndP MFS16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MBS8Bit - - Push AX - Push EDX ; EDX:AX = 32.16 blocksize - - Mov EDI, CURRENTPOSITION - Mov EBX, EDI - Add EBX, 2 - ShR EBX, 14 ; BX = frame - - Sub BX, 3 - JNC MBS8Bit4 - - Xor BX, BX - -MBS8Bit4: - Mov ECX, EBX - ShL ECX, 14 - Sub EDI, ECX - - Call SetBackSampleSegment - - Mov ECX, CURRENTPOSITION - Mov BX, CURRENTPOSITIONERROR - And ECX, 16383 - Add ECX, 0BFFEh - Cmp ECX, EDX - JG MBS8Bit1 - JL MBS8Bit5 - Cmp BX, AX - JG MBS8Bit1 - -MBS8Bit5: - Mov EDX, ECX - Mov AX, BX - -MBS8Bit1: - - ; Now to calculate bytes to mix... - ShL EAX, 16 - SHRD EAX, EDX, 16 - ShR EDX, 16 ; EDX:EAX = (16)32.16 offset - - Mov EBX, STEPVALUE - Cmp EDX, EBX - JAE MBS8Bit2 - - Div EBX - Add EDX, 0FFFFFFFFh - AdC EAX, 0 ; EAX = no of bytes to mix - JZ MBS8Bit2 - - Push EAX - - Xor ECX, ECX - Mov EBP, [SI+2] ; Stepvalue - Neg EBP - ShLD EDX, EBP, 16 - - Mov CX, CURRENTPOSITIONERROR - - Push DS - Push SI - - Mov SI, MixBufferOffset - Mov DS, MixSegment - Call [MixFunction] - - Pop SI - Pop DS - Pop ECX - Jmp MBS8Bit3 - -MBS8Bit2: -; Xor ECX, ECX - Pop EDX - Pop AX - Ret - -MBS8Bit3: - ; Update pointers... - Mov EAX, STEPVALUE - Mul ECX - - Sub MixBlockSize, CX - ShL CX, RESOLUTIONSHIFT - Add MixBufferOffset, CX - - ; EDX:EAX = offset mixed (32.16) - ShLD EDX, EAX, 16 - Mov BX, AX - Mov ECX, EDX ; ECX:BX = offset mixed - - Sub CURRENTPOSITIONERROR, BX - SBB CURRENTPOSITION, ECX - - Pop EDX - Pop AX - - Sub AX, BX - SBB EDX, ECX - - JG MBS8Bit - - Ret - -EndP MBS8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MBS16Bit - - Push AX - Push EDX ; EDX:AX = 32.16 blocksize - - Mov EDI, CURRENTPOSITION - Mov EBX, EDI - Add EBX, 4 - ShR EBX, 13 ; BX = frame - - Sub BX, 3 - JNC MBS16Bit4 - - Xor BX, BX - -MBS16Bit4: - Mov ECX, EBX - ShL ECX, 13 - Sub EDI, ECX - - Call SetBackSampleSegment - - Mov ECX, CURRENTPOSITION - Mov BX, CURRENTPOSITIONERROR - And ECX, 8191 - Add ECX, 05FFEh - Cmp ECX, EDX - JG MBS16Bit1 - JL MBS16Bit5 - Cmp BX, AX - JG MBS16Bit1 - -MBS16Bit5: - Mov EDX, ECX - Mov AX, BX - -MBS16Bit1: - - ; Now to calculate bytes to mix... - ShL EAX, 16 - SHRD EAX, EDX, 16 - ShR EDX, 16 ; EDX:EAX = (16)32.16 offset - - Mov EBX, STEPVALUE - Cmp EDX, EBX - JAE MBS16Bit2 - - Div EBX - Add EDX, 0FFFFFFFFh - AdC EAX, 0 ; EAX = no of bytes to mix - JZ MBS16Bit2 - - Push EAX - - Xor ECX, ECX - Mov EBP, [SI+2] ; Stepvalue - Neg EBP - ShLD EDX, EBP, 16 - - Mov CX, CURRENTPOSITIONERROR - - Push DS - Push SI - - Mov SI, MixBufferOffset - Mov DS, MixSegment - Call [MixFunction] - - Pop SI - Pop DS - Pop ECX - Jmp MBS16Bit3 - -MBS16Bit2: -; Xor ECX, ECX - Pop EDX - Pop AX - Ret - -MBS16Bit3: - ; Update pointers... - Mov EAX, STEPVALUE - Mul ECX - - Sub MixBlockSize, CX - ShL CX, RESOLUTIONSHIFT - Add MixBufferOffset, CX - - ; EDX:EAX = offset mixed (32.16) - ShLD EDX, EAX, 16 - Mov BX, AX - Mov ECX, EDX ; ECX:BX = offset mixed - - Sub CURRENTPOSITIONERROR, BX - SBB CURRENTPOSITION, ECX - - Pop EDX - Pop AX - - Sub AX, BX - SBB EDX, ECX - - JG MBS16Bit - - Ret - -EndP MBS16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReportError - - Ret - -EndP ReportError - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + + +ERROR EQU CX +DELTAERROR EQU BP +DELTAOFFSET EQU DX +OLDPOSITION EQU [SI+2Ch] +CURRENTPOSITION EQU [SI+4Ch] +CURRENTPOSITIONERROR EQU Word Ptr [SI+48h] +LOOPSTART EQU [SI+40h] +LOOPEND EQU [SI+44h] +STEPVALUE EQU [SI+02h] +; STEPVALUEHIGH EQU Word Ptr [SI+04h] +DIRECTIONFLAG EQU Byte Ptr [SI+0Bh] + +EXTRAOFFSET = MixResolution/8-2 + +IF MIXRESOLUTION GT 16 + RESOLUTIONSHIFT = 2 +ELSE + RESOLUTIONSHIFT = 1 +ENDIF + +IF STEREOENABLED + RESOLUTIONSHIFT = RESOLUTIONSHIFT+1 +ENDIF + +MixBufferOffset DW 0 + +MixBlockSize DW 0 ; Number of bytes to mix + DW 0 ; High order 0 + +PreMixFunction DW 0 +MixFunctionSeparate DW 0 ; Function to separate blocks into 64k + ; chunks. +MixFunctionSeparateBackwards DW 0 ; function to separate blocks into 64k + ; in backwards steps. +MixFunction DW 0 ; Function to mix samples + +LastPage DW 0 + +MemoryType DB 0 +NumPages DB 0 +SampleLocation DW 0 ; Either EMS Handle or Conventional + ; base segment +EMSPageFrame DW 0 + +LoopCounter DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixNoLoop + + Call [PreMixFunction] + Call PrepareSampleSegment + + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + + Xor CX, CX + Mov EBX, LOOPEND + Sub CX, CURRENTPOSITIONERROR + SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) + JC MixNoLoop3 + + Cmp EDX, EBX + JL MixNoLoop1 + JG MixNoLoop2 + Cmp AX, CX + JB MixNoLoop1 + +MixNoLoop2: + ; Turn off + Mov EDX, EBX + Mov AX, CX + + Mov Word Ptr [SI], 200h + Test Byte Ptr [SI+3Ah], 80h + JNZ MixNoLoop1 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +MixNoLoop1: + Jmp [MixFunctionSeparate] + +MixNoLoop3: + Mov Word Ptr [SI], 200h + Test Byte Ptr [SI+3Ah], 80h + JNZ MixNoLoop4 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +MixNoLoop4: + Ret + +EndP MixNoLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixForwardsLoop + + Call [PreMixFunction] + Call PrepareSampleSegment + +MixForwardsLoopAgain: + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + + Xor CX, CX + Mov EBX, LOOPEND + Sub CX, CURRENTPOSITIONERROR + SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) + JC UpdateMixForwardsLoop + + Cmp EDX, EBX + JL MixForwardsLoop1 + JG MixForwardsLoop2 + Cmp AX, CX + JB MixForwardsLoop1 + +MixForwardsLoop2: + Mov EDX, EBX + Mov AX, CX + + Call [MixFunctionSeparate] + +UpdateMixForwardsLoop: + Mov EAX, CURRENTPOSITION + Xor EDX, EDX + + Mov EBX, LOOPEND + SUB EAX, EBX + SUB EBX, LOOPSTART + JBE MixForwardsLoop3 + + Div EBX + Add EDX, LOOPSTART + Mov CURRENTPOSITION, EDX + +; Cmp EBX, 10000h +; JAE MixForwardsLoop4 + +; Mov AX, STEPVALUEHIGH +; Cmp AX, BX +; JAE MixForwardsLoop5 + +; MixForwardsLoop4: + Cmp MixBlockSize, 0 + JG MixForwardsLoopAgain + +MixForwardsLoop3: + Ret + +; MixForwardsLoop5: +; Xor DX, DX +; Div BX +; Mov STEPVALUEHIGH, DX + +; Cmp MixBlockSize, 0 +; JG MixForwardsLoopAgain + +; Ret + +MixForwardsLoop1: + Jmp [MixFunctionSeparate] + +EndP MixForwardsLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixPingPongLoop + + Call [PreMixFunction] + Call PrepareSampleSegment + +MixPingPongLoopAgain: + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + + Cmp DIRECTIONFLAG, 0 + JNE MixPingPongLoopBackwards1 + +MixPingPongLoopForwards1: + Xor CX, CX + Mov EBX, LOOPEND + Sub CX, CURRENTPOSITIONERROR + SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) + JC UpdateMixPingPongLoopForwards1 + + Cmp EDX, EBX + JG MixPingPongLoopForwards3 + JL MixPingPongLoopForwards2 + + Cmp AX, CX + JAE MixPingPongLoopForwards3 + +MixPingPongLoopForwards2: + Jmp [MixFunctionSeparate] + +MixPingPongLoopForwards3: + Mov EDX, EBX + Mov AX, CX + Call [MixFunctionSeparate] + +UpdateMixPingPongLoopForwards1: + Mov EAX, CURRENTPOSITION + Mov EBX, LOOPEND + Xor EDX, EDX + Sub EAX, EBX + Sub EBX, LOOPSTART + JBE MixPingPongError + + Add EBX, EBX + Div EBX + + ShR EBX, 1 + + Cmp EDX, EBX + JAE MixPingPongLoopForwards4 + + Mov DIRECTIONFLAG, 1 + Mov EAX, LOOPEND + Sub EAX, EDX + Dec EAX + Mov CURRENTPOSITION, EAX + Neg Word Ptr CURRENTPOSITIONERROR + Jmp MixPingPongLoopNext + +MixPingPongLoopForwards4: + Sub EDX, EBX + Add EDX, LOOPSTART + Mov CURRENTPOSITION, EDX + Jmp MixPingPongLoopNext + +MixPingPongLoopBackwards1: + Mov EBX, CURRENTPOSITION + Mov CX, CURRENTPOSITIONERROR + + Sub CX, 0FFFFh + SBB EBX, LOOPSTART + JC UpdateMixPingPongLoopBackwards1 + + Cmp EDX, EBX + JG MixPingPongLoopBackwards3 + JL MixPingPongLoopBackwards2 + + Cmp AX, CX + JAE MixPingPongLoopBackwards3 + +MixPingPongLoopBackwards2: + Call [MixFunctionSeparateBackwards] + +MixPingPongError: + Ret + +MixPingPongLoopBackwards3: + Mov EDX, EBX + Mov AX, CX + Call [MixFunctionSeparateBackwards] + +UpdateMixPingPongLoopBackwards1: + Mov EBX, LOOPEND + Mov EAX, LOOPSTART + Sub EBX, EAX + JBE MixPingPongError + + Sub EAX, CURRENTPOSITION + Xor EDX, EDX + Add EBX, EBX + Div EBX + + ShR EBX, 1 + + Cmp EDX, EBX + JAE MixPingPongLoopBackwards4 + + Mov DIRECTIONFLAG, 0 + Add EDX, LOOPSTART + Mov CURRENTPOSITION, EDX + Neg Word Ptr CURRENTPOSITIONERROR + Jmp MixPingPongLoopNext + +MixPingPongLoopBackwards4: + Sub EBX, EDX + Add EBX, LOOPEND + Dec EBX + Mov CURRENTPOSITION, EBX + +MixPingPongLoopNext: + Cmp MixBlockSize, 0 + JG MixPingPongLoopAgain + + Ret + +EndP MixPingPongLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateNoLoop + + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + Add CURRENTPOSITIONERROR, AX + AdC EDX, CURRENTPOSITION + + Cmp EDX, LOOPEND + JL UpdateNoLoop1 + +UpdateNoLoop2: ; Turn off + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ UpdateNoLoop1 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + Ret + +UpdateNoLoop1: + Mov CURRENTPOSITION, EDX + + Ret + +EndP UpdateNoLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateForwardsLoop + + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + Add CURRENTPOSITIONERROR, AX + AdC EDX, CURRENTPOSITION + + Cmp EDX, LOOPEND + JL UpdateForwardsLoop1 + +UpdateForwardsLoop2: ; Reset position... + Mov EBX, LOOPEND + Mov EAX, EDX + Xor EDX, EDX + Sub EAX, EBX + Sub EBX, LOOPSTART + JZ UpdateForwardsLoop1 + Div EBX + + Add EDX, LOOPSTART + +UpdateForwardsLoop1: + Mov CURRENTPOSITION, EDX + Ret + +EndP UpdateForwardsLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdatePingPongLoop + + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + + Cmp DIRECTIONFLAG, 0 + JNE UpdatePingPongLoopBackwards1 + +UpdatePingPongLoopForwards1: + Add CURRENTPOSITIONERROR, AX + AdC EDX, CURRENTPOSITION + + Cmp EDX, LOOPEND + JA UpdatePingPongLoopForwards2 + + Mov CURRENTPOSITION, EDX + Ret + +UpdatePingPongLoopForwards2: + Mov EAX, EDX + Mov EBX, LOOPEND + Xor EDX, EDX + Sub EAX, EBX + Sub EBX, LOOPSTART + Add EBX, EBX + Div EBX + + ShR EBX, 1 + + Cmp EDX, EBX + JAE UpdatePingPongLoopForwards3 + + Mov DIRECTIONFLAG, 1 + Mov EAX, LOOPEND + Sub EAX, EDX + Dec EAX + NEG CURRENTPOSITIONERROR + Mov CURRENTPOSITION, EAX + Ret + +UpdatePingPongLoopForwards3: + Sub EDX, EBX + Add EDX, LOOPSTART + Mov CURRENTPOSITION, EDX + Ret + +UpdatePingPongLoopBackwards1: + Sub CURRENTPOSITIONERROR, AX + Mov ECX, CURRENTPOSITION + SBB ECX, EDX + + Cmp ECX, LOOPSTART + JLE UpdatePingPongLoopBackwards2 + + Mov CURRENTPOSITION, ECX + Ret + +UpdatePingPongLoopBackwards2: + Mov EAX, LOOPSTART + Mov EBX, LOOPEND + Xor EDX, EDX + Sub EBX, EAX + Sub EAX, ECX + Add EBX, EBX + Div EBX + + ShR EBX, 1 + + Cmp EDX, EBX + JAE UpdatePingPongLoopBackwards3 + + Mov DIRECTIONFLAG, 0 + Add EDX, LOOPSTART + NEG CURRENTPOSITIONERROR + Mov CURRENTPOSITION, EDX + Ret + +UpdatePingPongLoopBackwards3: + Sub EBX, EDX + Add EBX, LOOPEND + Dec EBX + Mov CURRENTPOSITION, EBX + + Ret + +EndP UpdatePingPongLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PrepareSampleSegment ; Sets up sample mixing segment + + Mov ES, SongDataArea + + Mov BX, [SI+34h] + Mov EAX, [ES:BX+48h] + + Mov DWord Ptr MemoryType, EAX ; Writes numpages & Sample + ; location also. + Mov LastPage, 0FFFFh + + Ret + +EndP PrepareSampleSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSampleSegment ; Given EDI, Returns ES + + Mov CX, Word Ptr CS:MemoryType + + Cmp CL, 2 + JNE SetSampleSegment1 + + Push EAX + Push EDX + + Mov EBX, EDI + ShR EBX, 14 + And EDI, 16383 + + Cmp BX, LastPage + JE SetSampleEMS2 + + Mov LastPage, BX + Mov DX, SampleLocation ; EMS handle + ; BX = starting page required + Mov AL, 3 + Add BX, 3 + + Cmp BL, CH + JBE SetSampleEMS1 + + Sub CH, BL + Add BL, CH + Add AL, CH + JNC SetSampleEMS2 + +SetSampleEMS1: + Mov AH, 44h + Int 67h + + Dec BX + Dec AL + JNS SetSampleEMS1 + +SetSampleEMS2: + Mov ES, EMSPageFrame + + Pop EDX + Pop EAX + + Ret + +SetSampleSegment1: ; Conventional memory + Mov ECX, EDI + And EDI, 15 + ShR ECX, 4 + Add CX, SampleLocation + Mov ES, CX + + Ret + +EndP SetSampleSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetBackSampleSegment ; Given BX = frame, Returns ES + + Mov CX, Word Ptr CS:MemoryType + + Cmp CL, 2 + JNE SetBackSampleSegment1 + + Push EAX + Push EDX + + Cmp BX, LastPage + JE SetBackSampleEMS2 + + Mov LastPage, BX + Mov DX, SampleLocation ; EMS handle + ; BX = starting page required + Mov AL, 3 + Add BX, 3 + + Cmp BL, CH + JBE SetBackSampleEMS1 + + Sub CH, BL + Add BL, CH + Add AL, CH + JNC SetBackSampleEMS2 + +SetBackSampleEMS1: + Mov AH, 44h + Int 67h + + Dec BX + Dec AL + JNS SetBackSampleEMS1 + +SetBackSampleEMS2: + Mov ES, EMSPageFrame + + Pop EDX + Pop EAX + + Ret + +SetBackSampleSegment1: ; Conventional memory + ShL BX, 10 + Add BX, SampleLocation + Mov ES, BX + + Ret + +EndP SetBackSampleSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MFS8Bit ; EDX:AX = 32.16 bytes offset. + ; to mix + + + Push AX + Push EDX + + Mov EDI, CURRENTPOSITION + Call SetSampleSegment + + Xor CX, CX ; EDI = CurrentPosition & (2^14-1) + + Mov EBX, 0FFFEh + + Sub CX, CURRENTPOSITIONERROR + SBB EBX, EDI + ; EBX:CX = 64k-(CurrentPosition & (2^14-1)) + ; EDX:AX = blocksize + Cmp EDX, EBX + JBE MFS8Bit1 + + Mov EDX, EBX + Mov AX, CX + +MFS8Bit1: + ; Now to calculate bytes to mix... + ShL EAX, 16 + SHRD EAX, EDX, 16 + ShR EDX, 16 ; EDX:EAX = (16)32.16 offset + + Mov EBX, STEPVALUE + Cmp EDX, EBX + JAE MFS8Bit2 + + Div EBX + Add EDX, 0FFFFFFFFh + AdC EAX, 0 ; EAX = no of bytes to mix + JZ MFS8Bit2 + + Push EAX + + Xor ECX, ECX + Mov DELTAOFFSET, [SI+4] ; Stepvalue + Mov DELTAERROR, [SI+2] ; Stepvalue + Mov CX, CURRENTPOSITIONERROR + + Push DS + Push SI + + Mov SI, MixBufferOffset + Mov DS, MixSegment + Call [MixFunction] + + Pop SI + Pop DS + Pop ECX + Jmp MFS8Bit3 + +MFS8Bit2: +; Xor ECX, ECX + Pop EDX + Pop AX + + Ret + +MFS8Bit3: + ; Update pointers... + Mov EAX, STEPVALUE + Mul ECX + + Sub MixBlockSize, CX + ShL CX, RESOLUTIONSHIFT + Add MixBufferOffset, CX + + ; EDX:EAX = offset mixed (32.16) + ShLD EDX, EAX, 16 + Mov BX, AX + Mov ECX, EDX ; ECX:BX = offset mixed + + Add CURRENTPOSITIONERROR, BX + AdC CURRENTPOSITION, ECX + + Pop EDX + Pop AX + + Sub AX, BX + SBB EDX, ECX + + JG MFS8Bit + + Ret + +EndP MFS8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MFS16Bit + + Push AX + Push EDX + + Mov EDI, CURRENTPOSITION + Add EDI, EDI + Call SetSampleSegment + + ShR EDI, 1 ; EDI = number of samples. + + Xor CX, CX + + Mov EBX, 7FFEh + + Sub CX, CURRENTPOSITIONERROR + SBB EBX, EDI + + Cmp EDX, EBX + JBE MFS16Bit1 + + Mov EDX, EBX + Mov AX, CX + +MFS16Bit1: + ; Now to calculate bytes to mix... + ShL EAX, 16 + SHRD EAX, EDX, 16 + ShR EDX, 16 ; EDX:EAX = (16)32.16 offset + + Mov EBX, STEPVALUE + Cmp EDX, EBX + JAE MFS16Bit2 + + Div EBX + Add EDX, 0FFFFFFFFh + AdC EAX, 0 ; EAX = no of bytes to mix + JZ MFS16Bit2 + + Push EAX + + Xor ECX, ECX + Mov DELTAOFFSET, [SI+4] ; Stepvalue + Mov DELTAERROR, [SI+2] ; Stepvalue + Mov CX, CURRENTPOSITIONERROR + + Push DS + Push SI + + Mov SI, MixBufferOffset + Mov DS, MixSegment + Call [MixFunction] + + Pop SI + Pop DS + Pop ECX + Jmp MFS16Bit3 + +MFS16Bit2: +; Xor ECX, ECX + Pop EDX + Pop AX + Ret + +MFS16Bit3: + ; Update pointers... + Mov EAX, STEPVALUE + Mul ECX + + Sub MixBlockSize, CX + ShL CX, RESOLUTIONSHIFT + Add MixBufferOffset, CX + + ; EDX:EAX = offset mixed (32.16) + ShLD EDX, EAX, 16 + Mov BX, AX + Mov ECX, EDX ; ECX:BX = offset mixed + + Add CURRENTPOSITIONERROR, BX + AdC CURRENTPOSITION, ECX + + Pop EDX + Pop AX + + Sub AX, BX + SBB EDX, ECX + + JG MFS16Bit + + Ret + +EndP MFS16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MBS8Bit + + Push AX + Push EDX ; EDX:AX = 32.16 blocksize + + Mov EDI, CURRENTPOSITION + Mov EBX, EDI + Add EBX, 2 + ShR EBX, 14 ; BX = frame + + Sub BX, 3 + JNC MBS8Bit4 + + Xor BX, BX + +MBS8Bit4: + Mov ECX, EBX + ShL ECX, 14 + Sub EDI, ECX + + Call SetBackSampleSegment + + Mov ECX, CURRENTPOSITION + Mov BX, CURRENTPOSITIONERROR + And ECX, 16383 + Add ECX, 0BFFEh + Cmp ECX, EDX + JG MBS8Bit1 + JL MBS8Bit5 + Cmp BX, AX + JG MBS8Bit1 + +MBS8Bit5: + Mov EDX, ECX + Mov AX, BX + +MBS8Bit1: + + ; Now to calculate bytes to mix... + ShL EAX, 16 + SHRD EAX, EDX, 16 + ShR EDX, 16 ; EDX:EAX = (16)32.16 offset + + Mov EBX, STEPVALUE + Cmp EDX, EBX + JAE MBS8Bit2 + + Div EBX + Add EDX, 0FFFFFFFFh + AdC EAX, 0 ; EAX = no of bytes to mix + JZ MBS8Bit2 + + Push EAX + + Xor ECX, ECX + Mov EBP, [SI+2] ; Stepvalue + Neg EBP + ShLD EDX, EBP, 16 + + Mov CX, CURRENTPOSITIONERROR + + Push DS + Push SI + + Mov SI, MixBufferOffset + Mov DS, MixSegment + Call [MixFunction] + + Pop SI + Pop DS + Pop ECX + Jmp MBS8Bit3 + +MBS8Bit2: +; Xor ECX, ECX + Pop EDX + Pop AX + Ret + +MBS8Bit3: + ; Update pointers... + Mov EAX, STEPVALUE + Mul ECX + + Sub MixBlockSize, CX + ShL CX, RESOLUTIONSHIFT + Add MixBufferOffset, CX + + ; EDX:EAX = offset mixed (32.16) + ShLD EDX, EAX, 16 + Mov BX, AX + Mov ECX, EDX ; ECX:BX = offset mixed + + Sub CURRENTPOSITIONERROR, BX + SBB CURRENTPOSITION, ECX + + Pop EDX + Pop AX + + Sub AX, BX + SBB EDX, ECX + + JG MBS8Bit + + Ret + +EndP MBS8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MBS16Bit + + Push AX + Push EDX ; EDX:AX = 32.16 blocksize + + Mov EDI, CURRENTPOSITION + Mov EBX, EDI + Add EBX, 4 + ShR EBX, 13 ; BX = frame + + Sub BX, 3 + JNC MBS16Bit4 + + Xor BX, BX + +MBS16Bit4: + Mov ECX, EBX + ShL ECX, 13 + Sub EDI, ECX + + Call SetBackSampleSegment + + Mov ECX, CURRENTPOSITION + Mov BX, CURRENTPOSITIONERROR + And ECX, 8191 + Add ECX, 05FFEh + Cmp ECX, EDX + JG MBS16Bit1 + JL MBS16Bit5 + Cmp BX, AX + JG MBS16Bit1 + +MBS16Bit5: + Mov EDX, ECX + Mov AX, BX + +MBS16Bit1: + + ; Now to calculate bytes to mix... + ShL EAX, 16 + SHRD EAX, EDX, 16 + ShR EDX, 16 ; EDX:EAX = (16)32.16 offset + + Mov EBX, STEPVALUE + Cmp EDX, EBX + JAE MBS16Bit2 + + Div EBX + Add EDX, 0FFFFFFFFh + AdC EAX, 0 ; EAX = no of bytes to mix + JZ MBS16Bit2 + + Push EAX + + Xor ECX, ECX + Mov EBP, [SI+2] ; Stepvalue + Neg EBP + ShLD EDX, EBP, 16 + + Mov CX, CURRENTPOSITIONERROR + + Push DS + Push SI + + Mov SI, MixBufferOffset + Mov DS, MixSegment + Call [MixFunction] + + Pop SI + Pop DS + Pop ECX + Jmp MBS16Bit3 + +MBS16Bit2: +; Xor ECX, ECX + Pop EDX + Pop AX + Ret + +MBS16Bit3: + ; Update pointers... + Mov EAX, STEPVALUE + Mul ECX + + Sub MixBlockSize, CX + ShL CX, RESOLUTIONSHIFT + Add MixBufferOffset, CX + + ; EDX:EAX = offset mixed (32.16) + ShLD EDX, EAX, 16 + Mov BX, AX + Mov ECX, EDX ; ECX:BX = offset mixed + + Sub CURRENTPOSITIONERROR, BX + SBB CURRENTPOSITION, ECX + + Pop EDX + Pop AX + + Sub AX, BX + SBB EDX, ECX + + JG MBS16Bit + + Ret + +EndP MBS16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReportError + + Ret + +EndP ReportError + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/MIXWAV.INC b/SoundDrivers/MIXWAV.INC index cb2045e..95525ec 100755 --- a/SoundDrivers/MIXWAV.INC +++ b/SoundDrivers/MIXWAV.INC @@ -1,1065 +1,1065 @@ - - -ERROR EQU CX -DELTAERROR EQU BP -DELTAOFFSET EQU DX -OLDPOSITION EQU [SI+2Ch] -CURRENTPOSITION EQU [SI+4Ch] -CURRENTPOSITIONERROR EQU Word Ptr [SI+48h] -LOOPSTART EQU [SI+40h] -LOOPEND EQU [SI+44h] -STEPVALUE EQU [SI+02h] -; STEPVALUEHIGH EQU Word Ptr [SI+04h] -DIRECTIONFLAG EQU Byte Ptr [SI+0Bh] - -EXTRAOFFSET = MixResolution/8-2 - -IF MIXRESOLUTION GT 16 - RESOLUTIONSHIFT = 2 -ELSE - RESOLUTIONSHIFT = 1 -ENDIF - -IF STEREOENABLED - RESOLUTIONSHIFT = RESOLUTIONSHIFT+1 -ENDIF - -MixBufferOffset DW 0 - -MixBlockSize DW 0 ; Number of bytes to mix - DW 0 ; High order 0 - -PreMixFunction DW 0 -MixFunctionSeparate DW 0 ; Function to separate blocks into 64k - ; chunks. -MixFunctionSeparateBackwards DW 0 ; function to separate blocks into 64k - ; in backwards steps. -MixFunction DW 0 ; Function to mix samples - -LastPage DW 0 - -MemoryType DB 0 -NumPages DB 0 -SampleLocation DW 0 ; Either EMS Handle or Conventional - ; base segment -EMSPageFrame DW 0 - -LoopCounter DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixNoLoop - - Call [PreMixFunction] - Call PrepareSampleSegment - - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - - Xor CX, CX - Mov EBX, LOOPEND - Sub CX, CURRENTPOSITIONERROR - SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) - JC MixNoLoopEnd - - Cmp EDX, EBX - JL MixNoLoop1 - JG MixNoLoop2 - Cmp AX, CX - JAE MixNoLoop2 - -MixNoLoop1: - Jmp [MixFunctionSeparate] - -MixNoLoop2: ; Turn off - Mov EDX, EBX - Mov AX, CX - - Call [MixFunctionSeparate] - -MixNoLoop3: - Mov Word Ptr [SI], 200h - Test Byte Ptr [SI+3Ah], 80h - JNZ MixNoLoop4 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -MixNoLoop4: - PushAD - Push DS - - Mov EDX, CS:LastLeftValue - Mov EDI, CS:LastRightValue - -IF USECLICKFADETHRESHHOLD - Cmp EDX, CLICKFADETHRESHHOLD - JBE NoClickRemovalLeft - - Xor EDX, EDX - -NoClickRemovalLeft: - Cmp EDI, CLICKFADETHRESHHOLD - JBE NoClickRemovalRight - - Xor EDI, EDI - -NoClickRemovalRight: -ENDIF - Neg EDX - Neg EDI - - Mov CX, CS:MixBlockSize - Mov SI, CS:MixBufferOffset - Mov DS, CS:MixSegment - JCXZ MixNoLoopClickRemovalEnd - -MixNoLoopClickRemoval1: - Mov EAX, EDX - Mov EBX, EDI - - Add [SI], EDX - Add [SI+4], EDI - - SAR EAX, 12 - SAR EBX, 12 - - Sub EAX, 1 - AdC EAX, 1 - Sub EBX, 1 - AdC EBX, 1 - - Sub EDX, EAX - Sub EDI, EBX - - Add SI, 8 - Loop MixNoLoopClickRemoval1 - -MixNoLoopClickRemovalEnd: - Add CS:LastClickRemovalLeft, EDX - Add CS:LastClickRemovalRight, EDI - - Pop DS - PopAD - -MixNoLoopEnd: - Ret - -EndP MixNoLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixForwardsLoop - - Call [PreMixFunction] - Call PrepareSampleSegment - -MixForwardsLoopAgain: - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - - Xor CX, CX - Mov EBX, LOOPEND - Sub CX, CURRENTPOSITIONERROR - SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) - JC UpdateMixForwardsLoop - - Cmp EDX, EBX - JL MixForwardsLoop1 - JG MixForwardsLoop2 - Cmp AX, CX - JB MixForwardsLoop1 - -MixForwardsLoop2: - Mov EDX, EBX - Mov AX, CX - - Call [MixFunctionSeparate] - -UpdateMixForwardsLoop: - Mov EAX, CURRENTPOSITION - Xor EDX, EDX - - Mov EBX, LOOPEND - SUB EAX, EBX - SUB EBX, LOOPSTART - JBE MixForwardsLoop3 - - Div EBX - Add EDX, LOOPSTART - Mov CURRENTPOSITION, EDX - -; Cmp EBX, 10000h -; JAE MixForwardsLoop4 - -; Mov AX, STEPVALUEHIGH -; Cmp AX, BX -; JAE MixForwardsLoop5 - -; MixForwardsLoop4: - Cmp MixBlockSize, 0 - JG MixForwardsLoopAgain - -MixForwardsLoop3: - Ret - -; MixForwardsLoop5: -; Xor DX, DX -; Div BX -; Mov STEPVALUEHIGH, DX - -; Cmp MixBlockSize, 0 -; JG MixForwardsLoopAgain - -; Ret - -MixForwardsLoop1: - Jmp [MixFunctionSeparate] - -EndP MixForwardsLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixPingPongLoop - - Call [PreMixFunction] - Call PrepareSampleSegment - -MixPingPongLoopAgain: - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - - Cmp DIRECTIONFLAG, 0 - JNE MixPingPongLoopBackwards1 - -MixPingPongLoopForwards1: - Xor CX, CX - Mov EBX, LOOPEND - Sub CX, CURRENTPOSITIONERROR - SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) - JC UpdateMixPingPongLoopForwards1 - - Cmp EDX, EBX - JG MixPingPongLoopForwards3 - JL MixPingPongLoopForwards2 - - Cmp AX, CX - JAE MixPingPongLoopForwards3 - -MixPingPongLoopForwards2: - Jmp [MixFunctionSeparate] - -MixPingPongLoopForwards3: - Mov EDX, EBX - Mov AX, CX - Call [MixFunctionSeparate] - -UpdateMixPingPongLoopForwards1: - Mov EAX, CURRENTPOSITION - Mov EBX, LOOPEND - Xor EDX, EDX - Sub EAX, EBX - Sub EBX, LOOPSTART - JBE MixPingPongError - - Add EBX, EBX - Div EBX - - ShR EBX, 1 - - Cmp EDX, EBX - JAE MixPingPongLoopForwards4 - - Mov DIRECTIONFLAG, 1 - Mov EAX, LOOPEND - Sub EAX, EDX - Dec EAX - Mov CURRENTPOSITION, EAX - Neg Word Ptr CURRENTPOSITIONERROR - Jmp MixPingPongLoopNext - -MixPingPongLoopForwards4: - Sub EDX, EBX - Add EDX, LOOPSTART - Mov CURRENTPOSITION, EDX - Jmp MixPingPongLoopNext - -MixPingPongLoopBackwards1: - Mov EBX, CURRENTPOSITION - Mov CX, CURRENTPOSITIONERROR - - Sub CX, 0FFFFh - SBB EBX, LOOPSTART - JC UpdateMixPingPongLoopBackwards1 - - Cmp EDX, EBX - JG MixPingPongLoopBackwards3 - JL MixPingPongLoopBackwards2 - - Cmp AX, CX - JAE MixPingPongLoopBackwards3 - -MixPingPongLoopBackwards2: - Call [MixFunctionSeparateBackwards] - -MixPingPongError: - Ret - -MixPingPongLoopBackwards3: - Mov EDX, EBX - Mov AX, CX - Call [MixFunctionSeparateBackwards] - -UpdateMixPingPongLoopBackwards1: - Mov EBX, LOOPEND - Mov EAX, LOOPSTART - Sub EBX, EAX - JBE MixPingPongError - - Sub EAX, CURRENTPOSITION - Xor EDX, EDX - Add EBX, EBX - Div EBX - - ShR EBX, 1 - - Cmp EDX, EBX - JAE MixPingPongLoopBackwards4 - - Mov DIRECTIONFLAG, 0 - Add EDX, LOOPSTART - Mov CURRENTPOSITION, EDX - Neg Word Ptr CURRENTPOSITIONERROR - Jmp MixPingPongLoopNext - -MixPingPongLoopBackwards4: - Sub EBX, EDX - Add EBX, LOOPEND - Dec EBX - Mov CURRENTPOSITION, EBX - -MixPingPongLoopNext: - Cmp MixBlockSize, 0 - JG MixPingPongLoopAgain - - Ret - -EndP MixPingPongLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateNoLoop - - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - Add CURRENTPOSITIONERROR, AX - AdC EDX, CURRENTPOSITION - - Cmp EDX, LOOPEND - JL UpdateNoLoop1 - -UpdateNoLoop2: ; Turn off - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ UpdateNoLoop1 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - Ret - -UpdateNoLoop1: - Mov CURRENTPOSITION, EDX - - Ret - -EndP UpdateNoLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateForwardsLoop - - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - Add CURRENTPOSITIONERROR, AX - AdC EDX, CURRENTPOSITION - - Cmp EDX, LOOPEND - JL UpdateForwardsLoop1 - -UpdateForwardsLoop2: ; Reset position... - Mov EBX, LOOPEND - Mov EAX, EDX - Xor EDX, EDX - Sub EAX, EBX - Sub EBX, LOOPSTART - JZ UpdateForwardsLoop1 - Div EBX - - Add EDX, LOOPSTART - -UpdateForwardsLoop1: - Mov CURRENTPOSITION, EDX - Ret - -EndP UpdateForwardsLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdatePingPongLoop - - Mov EAX, STEPVALUE ; 16.16 value - Mul DWord Ptr [MixBlockSize] ; 16.0 value - ; EDX:EAX = 32.16 value - ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. - ; EDX.AX = BytesToMix*StepValue - - Cmp DIRECTIONFLAG, 0 - JNE UpdatePingPongLoopBackwards1 - -UpdatePingPongLoopForwards1: - Add CURRENTPOSITIONERROR, AX - AdC EDX, CURRENTPOSITION - - Cmp EDX, LOOPEND - JA UpdatePingPongLoopForwards2 - - Mov CURRENTPOSITION, EDX - Ret - -UpdatePingPongLoopForwards2: - Mov EAX, EDX - Mov EBX, LOOPEND - Xor EDX, EDX - Sub EAX, EBX - Sub EBX, LOOPSTART - Add EBX, EBX - Div EBX - - ShR EBX, 1 - - Cmp EDX, EBX - JAE UpdatePingPongLoopForwards3 - - Mov DIRECTIONFLAG, 1 - Mov EAX, LOOPEND - Sub EAX, EDX - Dec EAX - NEG CURRENTPOSITIONERROR - Mov CURRENTPOSITION, EAX - Ret - -UpdatePingPongLoopForwards3: - Sub EDX, EBX - Add EDX, LOOPSTART - Mov CURRENTPOSITION, EDX - Ret - -UpdatePingPongLoopBackwards1: - Sub CURRENTPOSITIONERROR, AX - Mov ECX, CURRENTPOSITION - SBB ECX, EDX - - Cmp ECX, LOOPSTART - JLE UpdatePingPongLoopBackwards2 - - Mov CURRENTPOSITION, ECX - Ret - -UpdatePingPongLoopBackwards2: - Mov EAX, LOOPSTART - Mov EBX, LOOPEND - Xor EDX, EDX - Sub EBX, EAX - Sub EAX, ECX - Add EBX, EBX - Div EBX - - ShR EBX, 1 - - Cmp EDX, EBX - JAE UpdatePingPongLoopBackwards3 - - Mov DIRECTIONFLAG, 0 - Add EDX, LOOPSTART - NEG CURRENTPOSITIONERROR - Mov CURRENTPOSITION, EDX - Ret - -UpdatePingPongLoopBackwards3: - Sub EBX, EDX - Add EBX, LOOPEND - Dec EBX - Mov CURRENTPOSITION, EBX - - Ret - -EndP UpdatePingPongLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PrepareSampleSegment ; Sets up sample mixing segment - - Mov ES, SongDataArea - - Mov BX, [SI+34h] - Mov EAX, [ES:BX+48h] - - Mov DWord Ptr MemoryType, EAX ; Writes numpages & Sample - ; location also. - Mov LastPage, 0FFFFh - - Ret - -EndP PrepareSampleSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSampleSegment ; Given EDI, Returns ES - - Mov CX, Word Ptr CS:MemoryType - - Cmp CL, 2 - JNE SetSampleSegment1 - - Push EAX - Push EDX - - Mov EBX, EDI - ShR EBX, 14 - And EDI, 16383 - - Cmp BX, LastPage - JE SetSampleEMS2 - - Mov LastPage, BX - Mov DX, SampleLocation ; EMS handle - ; BX = starting page required - Mov AL, 3 - Add BX, 3 - - Cmp BL, CH - JBE SetSampleEMS1 - - Sub CH, BL - Add BL, CH - Add AL, CH - JNC SetSampleEMS2 - -SetSampleEMS1: - Mov AH, 44h - Int 67h - - Dec BX - Dec AL - JNS SetSampleEMS1 - -SetSampleEMS2: - Mov ES, EMSPageFrame - - Pop EDX - Pop EAX - - Ret - -SetSampleSegment1: ; Conventional memory - Mov ECX, EDI - And EDI, 15 - ShR ECX, 4 - Add CX, SampleLocation - Mov ES, CX - - Ret - -EndP SetSampleSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetBackSampleSegment ; Given BX = frame, Returns ES - - Mov CX, Word Ptr CS:MemoryType - - Cmp CL, 2 - JNE SetBackSampleSegment1 - - Push EAX - Push EDX - - Cmp BX, LastPage - JE SetBackSampleEMS2 - - Mov LastPage, BX - Mov DX, SampleLocation ; EMS handle - ; BX = starting page required - Mov AL, 3 - Add BX, 3 - - Cmp BL, CH - JBE SetBackSampleEMS1 - - Sub CH, BL - Add BL, CH - Add AL, CH - JNC SetBackSampleEMS2 - -SetBackSampleEMS1: - Mov AH, 44h - Int 67h - - Dec BX - Dec AL - JNS SetBackSampleEMS1 - -SetBackSampleEMS2: - Mov ES, EMSPageFrame - - Pop EDX - Pop EAX - - Ret - -SetBackSampleSegment1: ; Conventional memory - ShL BX, 10 - Add BX, SampleLocation - Mov ES, BX - - Ret - -EndP SetBackSampleSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MFS8Bit ; EDX:AX = 32.16 bytes offset. - ; to mix - - - Push AX - Push EDX - - Mov EDI, CURRENTPOSITION - Call SetSampleSegment - - Xor CX, CX ; EDI = CurrentPosition & (2^14-1) - - Mov EBX, 0FFFEh - - Sub CX, CURRENTPOSITIONERROR - SBB EBX, EDI - ; EBX:CX = 64k-(CurrentPosition & (2^14-1)) - ; EDX:AX = blocksize - Cmp EDX, EBX - JBE MFS8Bit1 - - Mov EDX, EBX - Mov AX, CX - -MFS8Bit1: - ; Now to calculate bytes to mix... - ShL EAX, 16 - SHRD EAX, EDX, 16 - ShR EDX, 16 ; EDX:EAX = (16)32.16 offset - - Mov EBX, STEPVALUE - Cmp EDX, EBX - JAE MFS8Bit2 - - Div EBX - Add EDX, 0FFFFFFFFh - AdC EAX, 0 ; EAX = no of bytes to mix - JZ MFS8Bit2 - - Push EAX - - Xor ECX, ECX - Mov DELTAOFFSET, [SI+4] ; Stepvalue - Mov DELTAERROR, [SI+2] ; Stepvalue - Mov CX, CURRENTPOSITIONERROR - - Push DS - Push SI - - Mov SI, MixBufferOffset - Mov DS, MixSegment - Call [MixFunction] - - Pop SI - Pop DS - Pop ECX - Jmp MFS8Bit3 - -MFS8Bit2: -; Xor ECX, ECX - Pop EDX - Pop AX - - Ret - -MFS8Bit3: - ; Update pointers... - Mov EAX, STEPVALUE - Mul ECX - - Sub MixBlockSize, CX - ShL CX, RESOLUTIONSHIFT - Add MixBufferOffset, CX - - ; EDX:EAX = offset mixed (32.16) - ShLD EDX, EAX, 16 - Mov BX, AX - Mov ECX, EDX ; ECX:BX = offset mixed - - Add CURRENTPOSITIONERROR, BX - AdC CURRENTPOSITION, ECX - - Pop EDX - Pop AX - - Sub AX, BX - SBB EDX, ECX - - JG MFS8Bit - - Ret - -EndP MFS8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MFS16Bit - - Push AX - Push EDX - - Mov EDI, CURRENTPOSITION - Add EDI, EDI - Call SetSampleSegment - - ShR EDI, 1 ; EDI = number of samples. - - Xor CX, CX - - Mov EBX, 7FFEh - - Sub CX, CURRENTPOSITIONERROR - SBB EBX, EDI - - Cmp EDX, EBX - JBE MFS16Bit1 - - Mov EDX, EBX - Mov AX, CX - -MFS16Bit1: - ; Now to calculate bytes to mix... - ShL EAX, 16 - SHRD EAX, EDX, 16 - ShR EDX, 16 ; EDX:EAX = (16)32.16 offset - - Mov EBX, STEPVALUE - Cmp EDX, EBX - JAE MFS16Bit2 - - Div EBX - Add EDX, 0FFFFFFFFh - AdC EAX, 0 ; EAX = no of bytes to mix - JZ MFS16Bit2 - - Push EAX - - Xor ECX, ECX - Mov DELTAOFFSET, [SI+4] ; Stepvalue - Mov DELTAERROR, [SI+2] ; Stepvalue - Mov CX, CURRENTPOSITIONERROR - - Push DS - Push SI - - Mov SI, MixBufferOffset - Mov DS, MixSegment - Call [MixFunction] - - Pop SI - Pop DS - Pop ECX - Jmp MFS16Bit3 - -MFS16Bit2: -; Xor ECX, ECX - Pop EDX - Pop AX - Ret - -MFS16Bit3: - ; Update pointers... - Mov EAX, STEPVALUE - Mul ECX - - Sub MixBlockSize, CX - ShL CX, RESOLUTIONSHIFT - Add MixBufferOffset, CX - - ; EDX:EAX = offset mixed (32.16) - ShLD EDX, EAX, 16 - Mov BX, AX - Mov ECX, EDX ; ECX:BX = offset mixed - - Add CURRENTPOSITIONERROR, BX - AdC CURRENTPOSITION, ECX - - Pop EDX - Pop AX - - Sub AX, BX - SBB EDX, ECX - - JG MFS16Bit - - Ret - -EndP MFS16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MBS8Bit - - Push AX - Push EDX ; EDX:AX = 32.16 blocksize - - Mov EDI, CURRENTPOSITION - Mov EBX, EDI - Add EBX, 2 - ShR EBX, 14 ; BX = frame - - Sub BX, 3 - JNC MBS8Bit4 - - Xor BX, BX - -MBS8Bit4: - Mov ECX, EBX - ShL ECX, 14 - Sub EDI, ECX - - Call SetBackSampleSegment - - Mov ECX, CURRENTPOSITION - Mov BX, CURRENTPOSITIONERROR - And ECX, 16383 - Add ECX, 0BFFEh - Cmp ECX, EDX - JG MBS8Bit1 - JL MBS8Bit5 - Cmp BX, AX - JG MBS8Bit1 - -MBS8Bit5: - Mov EDX, ECX - Mov AX, BX - -MBS8Bit1: - - ; Now to calculate bytes to mix... - ShL EAX, 16 - SHRD EAX, EDX, 16 - ShR EDX, 16 ; EDX:EAX = (16)32.16 offset - - Mov EBX, STEPVALUE - Cmp EDX, EBX - JAE MBS8Bit2 - - Div EBX - Add EDX, 0FFFFFFFFh - AdC EAX, 0 ; EAX = no of bytes to mix - JZ MBS8Bit2 - - Push EAX - - Xor ECX, ECX - Mov EBP, [SI+2] ; Stepvalue - Neg EBP - ShLD EDX, EBP, 16 - - Mov CX, CURRENTPOSITIONERROR - - Push DS - Push SI - - Mov SI, MixBufferOffset - Mov DS, MixSegment - Call [MixFunction] - - Pop SI - Pop DS - Pop ECX - Jmp MBS8Bit3 - -MBS8Bit2: -; Xor ECX, ECX - Pop EDX - Pop AX - Ret - -MBS8Bit3: - ; Update pointers... - Mov EAX, STEPVALUE - Mul ECX - - Sub MixBlockSize, CX - ShL CX, RESOLUTIONSHIFT - Add MixBufferOffset, CX - - ; EDX:EAX = offset mixed (32.16) - ShLD EDX, EAX, 16 - Mov BX, AX - Mov ECX, EDX ; ECX:BX = offset mixed - - Sub CURRENTPOSITIONERROR, BX - SBB CURRENTPOSITION, ECX - - Pop EDX - Pop AX - - Sub AX, BX - SBB EDX, ECX - - JG MBS8Bit - - Ret - -EndP MBS8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MBS16Bit - - Push AX - Push EDX ; EDX:AX = 32.16 blocksize - - Mov EDI, CURRENTPOSITION - Mov EBX, EDI - Add EBX, 4 - ShR EBX, 13 ; BX = frame - - Sub BX, 3 - JNC MBS16Bit4 - - Xor BX, BX - -MBS16Bit4: - Mov ECX, EBX - ShL ECX, 13 - Sub EDI, ECX - - Call SetBackSampleSegment - - Mov ECX, CURRENTPOSITION - Mov BX, CURRENTPOSITIONERROR - And ECX, 8191 - Add ECX, 05FFEh - Cmp ECX, EDX - JG MBS16Bit1 - JL MBS16Bit5 - Cmp BX, AX - JG MBS16Bit1 - -MBS16Bit5: - Mov EDX, ECX - Mov AX, BX - -MBS16Bit1: - - ; Now to calculate bytes to mix... - ShL EAX, 16 - SHRD EAX, EDX, 16 - ShR EDX, 16 ; EDX:EAX = (16)32.16 offset - - Mov EBX, STEPVALUE - Cmp EDX, EBX - JAE MBS16Bit2 - - Div EBX - Add EDX, 0FFFFFFFFh - AdC EAX, 0 ; EAX = no of bytes to mix - JZ MBS16Bit2 - - Push EAX - - Xor ECX, ECX - Mov EBP, [SI+2] ; Stepvalue - Neg EBP - ShLD EDX, EBP, 16 - - Mov CX, CURRENTPOSITIONERROR - - Push DS - Push SI - - Mov SI, MixBufferOffset - Mov DS, MixSegment - Call [MixFunction] - - Pop SI - Pop DS - Pop ECX - Jmp MBS16Bit3 - -MBS16Bit2: -; Xor ECX, ECX - Pop EDX - Pop AX - Ret - -MBS16Bit3: - ; Update pointers... - Mov EAX, STEPVALUE - Mul ECX - - Sub MixBlockSize, CX - ShL CX, RESOLUTIONSHIFT - Add MixBufferOffset, CX - - ; EDX:EAX = offset mixed (32.16) - ShLD EDX, EAX, 16 - Mov BX, AX - Mov ECX, EDX ; ECX:BX = offset mixed - - Sub CURRENTPOSITIONERROR, BX - SBB CURRENTPOSITION, ECX - - Pop EDX - Pop AX - - Sub AX, BX - SBB EDX, ECX - - JG MBS16Bit - - Ret - -EndP MBS16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReportError - - Ret - -EndP ReportError - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + + +ERROR EQU CX +DELTAERROR EQU BP +DELTAOFFSET EQU DX +OLDPOSITION EQU [SI+2Ch] +CURRENTPOSITION EQU [SI+4Ch] +CURRENTPOSITIONERROR EQU Word Ptr [SI+48h] +LOOPSTART EQU [SI+40h] +LOOPEND EQU [SI+44h] +STEPVALUE EQU [SI+02h] +; STEPVALUEHIGH EQU Word Ptr [SI+04h] +DIRECTIONFLAG EQU Byte Ptr [SI+0Bh] + +EXTRAOFFSET = MixResolution/8-2 + +IF MIXRESOLUTION GT 16 + RESOLUTIONSHIFT = 2 +ELSE + RESOLUTIONSHIFT = 1 +ENDIF + +IF STEREOENABLED + RESOLUTIONSHIFT = RESOLUTIONSHIFT+1 +ENDIF + +MixBufferOffset DW 0 + +MixBlockSize DW 0 ; Number of bytes to mix + DW 0 ; High order 0 + +PreMixFunction DW 0 +MixFunctionSeparate DW 0 ; Function to separate blocks into 64k + ; chunks. +MixFunctionSeparateBackwards DW 0 ; function to separate blocks into 64k + ; in backwards steps. +MixFunction DW 0 ; Function to mix samples + +LastPage DW 0 + +MemoryType DB 0 +NumPages DB 0 +SampleLocation DW 0 ; Either EMS Handle or Conventional + ; base segment +EMSPageFrame DW 0 + +LoopCounter DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixNoLoop + + Call [PreMixFunction] + Call PrepareSampleSegment + + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + + Xor CX, CX + Mov EBX, LOOPEND + Sub CX, CURRENTPOSITIONERROR + SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) + JC MixNoLoopEnd + + Cmp EDX, EBX + JL MixNoLoop1 + JG MixNoLoop2 + Cmp AX, CX + JAE MixNoLoop2 + +MixNoLoop1: + Jmp [MixFunctionSeparate] + +MixNoLoop2: ; Turn off + Mov EDX, EBX + Mov AX, CX + + Call [MixFunctionSeparate] + +MixNoLoop3: + Mov Word Ptr [SI], 200h + Test Byte Ptr [SI+3Ah], 80h + JNZ MixNoLoop4 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +MixNoLoop4: + PushAD + Push DS + + Mov EDX, CS:LastLeftValue + Mov EDI, CS:LastRightValue + +IF USECLICKFADETHRESHHOLD + Cmp EDX, CLICKFADETHRESHHOLD + JBE NoClickRemovalLeft + + Xor EDX, EDX + +NoClickRemovalLeft: + Cmp EDI, CLICKFADETHRESHHOLD + JBE NoClickRemovalRight + + Xor EDI, EDI + +NoClickRemovalRight: +ENDIF + Neg EDX + Neg EDI + + Mov CX, CS:MixBlockSize + Mov SI, CS:MixBufferOffset + Mov DS, CS:MixSegment + JCXZ MixNoLoopClickRemovalEnd + +MixNoLoopClickRemoval1: + Mov EAX, EDX + Mov EBX, EDI + + Add [SI], EDX + Add [SI+4], EDI + + SAR EAX, 12 + SAR EBX, 12 + + Sub EAX, 1 + AdC EAX, 1 + Sub EBX, 1 + AdC EBX, 1 + + Sub EDX, EAX + Sub EDI, EBX + + Add SI, 8 + Loop MixNoLoopClickRemoval1 + +MixNoLoopClickRemovalEnd: + Add CS:LastClickRemovalLeft, EDX + Add CS:LastClickRemovalRight, EDI + + Pop DS + PopAD + +MixNoLoopEnd: + Ret + +EndP MixNoLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixForwardsLoop + + Call [PreMixFunction] + Call PrepareSampleSegment + +MixForwardsLoopAgain: + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + + Xor CX, CX + Mov EBX, LOOPEND + Sub CX, CURRENTPOSITIONERROR + SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) + JC UpdateMixForwardsLoop + + Cmp EDX, EBX + JL MixForwardsLoop1 + JG MixForwardsLoop2 + Cmp AX, CX + JB MixForwardsLoop1 + +MixForwardsLoop2: + Mov EDX, EBX + Mov AX, CX + + Call [MixFunctionSeparate] + +UpdateMixForwardsLoop: + Mov EAX, CURRENTPOSITION + Xor EDX, EDX + + Mov EBX, LOOPEND + SUB EAX, EBX + SUB EBX, LOOPSTART + JBE MixForwardsLoop3 + + Div EBX + Add EDX, LOOPSTART + Mov CURRENTPOSITION, EDX + +; Cmp EBX, 10000h +; JAE MixForwardsLoop4 + +; Mov AX, STEPVALUEHIGH +; Cmp AX, BX +; JAE MixForwardsLoop5 + +; MixForwardsLoop4: + Cmp MixBlockSize, 0 + JG MixForwardsLoopAgain + +MixForwardsLoop3: + Ret + +; MixForwardsLoop5: +; Xor DX, DX +; Div BX +; Mov STEPVALUEHIGH, DX + +; Cmp MixBlockSize, 0 +; JG MixForwardsLoopAgain + +; Ret + +MixForwardsLoop1: + Jmp [MixFunctionSeparate] + +EndP MixForwardsLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixPingPongLoop + + Call [PreMixFunction] + Call PrepareSampleSegment + +MixPingPongLoopAgain: + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + + Cmp DIRECTIONFLAG, 0 + JNE MixPingPongLoopBackwards1 + +MixPingPongLoopForwards1: + Xor CX, CX + Mov EBX, LOOPEND + Sub CX, CURRENTPOSITIONERROR + SBB EBX, CURRENTPOSITION ; EBX.CX = (End-CurrentPosition) + JC UpdateMixPingPongLoopForwards1 + + Cmp EDX, EBX + JG MixPingPongLoopForwards3 + JL MixPingPongLoopForwards2 + + Cmp AX, CX + JAE MixPingPongLoopForwards3 + +MixPingPongLoopForwards2: + Jmp [MixFunctionSeparate] + +MixPingPongLoopForwards3: + Mov EDX, EBX + Mov AX, CX + Call [MixFunctionSeparate] + +UpdateMixPingPongLoopForwards1: + Mov EAX, CURRENTPOSITION + Mov EBX, LOOPEND + Xor EDX, EDX + Sub EAX, EBX + Sub EBX, LOOPSTART + JBE MixPingPongError + + Add EBX, EBX + Div EBX + + ShR EBX, 1 + + Cmp EDX, EBX + JAE MixPingPongLoopForwards4 + + Mov DIRECTIONFLAG, 1 + Mov EAX, LOOPEND + Sub EAX, EDX + Dec EAX + Mov CURRENTPOSITION, EAX + Neg Word Ptr CURRENTPOSITIONERROR + Jmp MixPingPongLoopNext + +MixPingPongLoopForwards4: + Sub EDX, EBX + Add EDX, LOOPSTART + Mov CURRENTPOSITION, EDX + Jmp MixPingPongLoopNext + +MixPingPongLoopBackwards1: + Mov EBX, CURRENTPOSITION + Mov CX, CURRENTPOSITIONERROR + + Sub CX, 0FFFFh + SBB EBX, LOOPSTART + JC UpdateMixPingPongLoopBackwards1 + + Cmp EDX, EBX + JG MixPingPongLoopBackwards3 + JL MixPingPongLoopBackwards2 + + Cmp AX, CX + JAE MixPingPongLoopBackwards3 + +MixPingPongLoopBackwards2: + Call [MixFunctionSeparateBackwards] + +MixPingPongError: + Ret + +MixPingPongLoopBackwards3: + Mov EDX, EBX + Mov AX, CX + Call [MixFunctionSeparateBackwards] + +UpdateMixPingPongLoopBackwards1: + Mov EBX, LOOPEND + Mov EAX, LOOPSTART + Sub EBX, EAX + JBE MixPingPongError + + Sub EAX, CURRENTPOSITION + Xor EDX, EDX + Add EBX, EBX + Div EBX + + ShR EBX, 1 + + Cmp EDX, EBX + JAE MixPingPongLoopBackwards4 + + Mov DIRECTIONFLAG, 0 + Add EDX, LOOPSTART + Mov CURRENTPOSITION, EDX + Neg Word Ptr CURRENTPOSITIONERROR + Jmp MixPingPongLoopNext + +MixPingPongLoopBackwards4: + Sub EBX, EDX + Add EBX, LOOPEND + Dec EBX + Mov CURRENTPOSITION, EBX + +MixPingPongLoopNext: + Cmp MixBlockSize, 0 + JG MixPingPongLoopAgain + + Ret + +EndP MixPingPongLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateNoLoop + + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + Add CURRENTPOSITIONERROR, AX + AdC EDX, CURRENTPOSITION + + Cmp EDX, LOOPEND + JL UpdateNoLoop1 + +UpdateNoLoop2: ; Turn off + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ UpdateNoLoop1 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + Ret + +UpdateNoLoop1: + Mov CURRENTPOSITION, EDX + + Ret + +EndP UpdateNoLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateForwardsLoop + + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + Add CURRENTPOSITIONERROR, AX + AdC EDX, CURRENTPOSITION + + Cmp EDX, LOOPEND + JL UpdateForwardsLoop1 + +UpdateForwardsLoop2: ; Reset position... + Mov EBX, LOOPEND + Mov EAX, EDX + Xor EDX, EDX + Sub EAX, EBX + Sub EBX, LOOPSTART + JZ UpdateForwardsLoop1 + Div EBX + + Add EDX, LOOPSTART + +UpdateForwardsLoop1: + Mov CURRENTPOSITION, EDX + Ret + +EndP UpdateForwardsLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdatePingPongLoop + + Mov EAX, STEPVALUE ; 16.16 value + Mul DWord Ptr [MixBlockSize] ; 16.0 value + ; EDX:EAX = 32.16 value + ShLD EDX, EAX, 16 ; EDX.AX = 32.16 value. + ; EDX.AX = BytesToMix*StepValue + + Cmp DIRECTIONFLAG, 0 + JNE UpdatePingPongLoopBackwards1 + +UpdatePingPongLoopForwards1: + Add CURRENTPOSITIONERROR, AX + AdC EDX, CURRENTPOSITION + + Cmp EDX, LOOPEND + JA UpdatePingPongLoopForwards2 + + Mov CURRENTPOSITION, EDX + Ret + +UpdatePingPongLoopForwards2: + Mov EAX, EDX + Mov EBX, LOOPEND + Xor EDX, EDX + Sub EAX, EBX + Sub EBX, LOOPSTART + Add EBX, EBX + Div EBX + + ShR EBX, 1 + + Cmp EDX, EBX + JAE UpdatePingPongLoopForwards3 + + Mov DIRECTIONFLAG, 1 + Mov EAX, LOOPEND + Sub EAX, EDX + Dec EAX + NEG CURRENTPOSITIONERROR + Mov CURRENTPOSITION, EAX + Ret + +UpdatePingPongLoopForwards3: + Sub EDX, EBX + Add EDX, LOOPSTART + Mov CURRENTPOSITION, EDX + Ret + +UpdatePingPongLoopBackwards1: + Sub CURRENTPOSITIONERROR, AX + Mov ECX, CURRENTPOSITION + SBB ECX, EDX + + Cmp ECX, LOOPSTART + JLE UpdatePingPongLoopBackwards2 + + Mov CURRENTPOSITION, ECX + Ret + +UpdatePingPongLoopBackwards2: + Mov EAX, LOOPSTART + Mov EBX, LOOPEND + Xor EDX, EDX + Sub EBX, EAX + Sub EAX, ECX + Add EBX, EBX + Div EBX + + ShR EBX, 1 + + Cmp EDX, EBX + JAE UpdatePingPongLoopBackwards3 + + Mov DIRECTIONFLAG, 0 + Add EDX, LOOPSTART + NEG CURRENTPOSITIONERROR + Mov CURRENTPOSITION, EDX + Ret + +UpdatePingPongLoopBackwards3: + Sub EBX, EDX + Add EBX, LOOPEND + Dec EBX + Mov CURRENTPOSITION, EBX + + Ret + +EndP UpdatePingPongLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PrepareSampleSegment ; Sets up sample mixing segment + + Mov ES, SongDataArea + + Mov BX, [SI+34h] + Mov EAX, [ES:BX+48h] + + Mov DWord Ptr MemoryType, EAX ; Writes numpages & Sample + ; location also. + Mov LastPage, 0FFFFh + + Ret + +EndP PrepareSampleSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSampleSegment ; Given EDI, Returns ES + + Mov CX, Word Ptr CS:MemoryType + + Cmp CL, 2 + JNE SetSampleSegment1 + + Push EAX + Push EDX + + Mov EBX, EDI + ShR EBX, 14 + And EDI, 16383 + + Cmp BX, LastPage + JE SetSampleEMS2 + + Mov LastPage, BX + Mov DX, SampleLocation ; EMS handle + ; BX = starting page required + Mov AL, 3 + Add BX, 3 + + Cmp BL, CH + JBE SetSampleEMS1 + + Sub CH, BL + Add BL, CH + Add AL, CH + JNC SetSampleEMS2 + +SetSampleEMS1: + Mov AH, 44h + Int 67h + + Dec BX + Dec AL + JNS SetSampleEMS1 + +SetSampleEMS2: + Mov ES, EMSPageFrame + + Pop EDX + Pop EAX + + Ret + +SetSampleSegment1: ; Conventional memory + Mov ECX, EDI + And EDI, 15 + ShR ECX, 4 + Add CX, SampleLocation + Mov ES, CX + + Ret + +EndP SetSampleSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetBackSampleSegment ; Given BX = frame, Returns ES + + Mov CX, Word Ptr CS:MemoryType + + Cmp CL, 2 + JNE SetBackSampleSegment1 + + Push EAX + Push EDX + + Cmp BX, LastPage + JE SetBackSampleEMS2 + + Mov LastPage, BX + Mov DX, SampleLocation ; EMS handle + ; BX = starting page required + Mov AL, 3 + Add BX, 3 + + Cmp BL, CH + JBE SetBackSampleEMS1 + + Sub CH, BL + Add BL, CH + Add AL, CH + JNC SetBackSampleEMS2 + +SetBackSampleEMS1: + Mov AH, 44h + Int 67h + + Dec BX + Dec AL + JNS SetBackSampleEMS1 + +SetBackSampleEMS2: + Mov ES, EMSPageFrame + + Pop EDX + Pop EAX + + Ret + +SetBackSampleSegment1: ; Conventional memory + ShL BX, 10 + Add BX, SampleLocation + Mov ES, BX + + Ret + +EndP SetBackSampleSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MFS8Bit ; EDX:AX = 32.16 bytes offset. + ; to mix + + + Push AX + Push EDX + + Mov EDI, CURRENTPOSITION + Call SetSampleSegment + + Xor CX, CX ; EDI = CurrentPosition & (2^14-1) + + Mov EBX, 0FFFEh + + Sub CX, CURRENTPOSITIONERROR + SBB EBX, EDI + ; EBX:CX = 64k-(CurrentPosition & (2^14-1)) + ; EDX:AX = blocksize + Cmp EDX, EBX + JBE MFS8Bit1 + + Mov EDX, EBX + Mov AX, CX + +MFS8Bit1: + ; Now to calculate bytes to mix... + ShL EAX, 16 + SHRD EAX, EDX, 16 + ShR EDX, 16 ; EDX:EAX = (16)32.16 offset + + Mov EBX, STEPVALUE + Cmp EDX, EBX + JAE MFS8Bit2 + + Div EBX + Add EDX, 0FFFFFFFFh + AdC EAX, 0 ; EAX = no of bytes to mix + JZ MFS8Bit2 + + Push EAX + + Xor ECX, ECX + Mov DELTAOFFSET, [SI+4] ; Stepvalue + Mov DELTAERROR, [SI+2] ; Stepvalue + Mov CX, CURRENTPOSITIONERROR + + Push DS + Push SI + + Mov SI, MixBufferOffset + Mov DS, MixSegment + Call [MixFunction] + + Pop SI + Pop DS + Pop ECX + Jmp MFS8Bit3 + +MFS8Bit2: +; Xor ECX, ECX + Pop EDX + Pop AX + + Ret + +MFS8Bit3: + ; Update pointers... + Mov EAX, STEPVALUE + Mul ECX + + Sub MixBlockSize, CX + ShL CX, RESOLUTIONSHIFT + Add MixBufferOffset, CX + + ; EDX:EAX = offset mixed (32.16) + ShLD EDX, EAX, 16 + Mov BX, AX + Mov ECX, EDX ; ECX:BX = offset mixed + + Add CURRENTPOSITIONERROR, BX + AdC CURRENTPOSITION, ECX + + Pop EDX + Pop AX + + Sub AX, BX + SBB EDX, ECX + + JG MFS8Bit + + Ret + +EndP MFS8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MFS16Bit + + Push AX + Push EDX + + Mov EDI, CURRENTPOSITION + Add EDI, EDI + Call SetSampleSegment + + ShR EDI, 1 ; EDI = number of samples. + + Xor CX, CX + + Mov EBX, 7FFEh + + Sub CX, CURRENTPOSITIONERROR + SBB EBX, EDI + + Cmp EDX, EBX + JBE MFS16Bit1 + + Mov EDX, EBX + Mov AX, CX + +MFS16Bit1: + ; Now to calculate bytes to mix... + ShL EAX, 16 + SHRD EAX, EDX, 16 + ShR EDX, 16 ; EDX:EAX = (16)32.16 offset + + Mov EBX, STEPVALUE + Cmp EDX, EBX + JAE MFS16Bit2 + + Div EBX + Add EDX, 0FFFFFFFFh + AdC EAX, 0 ; EAX = no of bytes to mix + JZ MFS16Bit2 + + Push EAX + + Xor ECX, ECX + Mov DELTAOFFSET, [SI+4] ; Stepvalue + Mov DELTAERROR, [SI+2] ; Stepvalue + Mov CX, CURRENTPOSITIONERROR + + Push DS + Push SI + + Mov SI, MixBufferOffset + Mov DS, MixSegment + Call [MixFunction] + + Pop SI + Pop DS + Pop ECX + Jmp MFS16Bit3 + +MFS16Bit2: +; Xor ECX, ECX + Pop EDX + Pop AX + Ret + +MFS16Bit3: + ; Update pointers... + Mov EAX, STEPVALUE + Mul ECX + + Sub MixBlockSize, CX + ShL CX, RESOLUTIONSHIFT + Add MixBufferOffset, CX + + ; EDX:EAX = offset mixed (32.16) + ShLD EDX, EAX, 16 + Mov BX, AX + Mov ECX, EDX ; ECX:BX = offset mixed + + Add CURRENTPOSITIONERROR, BX + AdC CURRENTPOSITION, ECX + + Pop EDX + Pop AX + + Sub AX, BX + SBB EDX, ECX + + JG MFS16Bit + + Ret + +EndP MFS16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MBS8Bit + + Push AX + Push EDX ; EDX:AX = 32.16 blocksize + + Mov EDI, CURRENTPOSITION + Mov EBX, EDI + Add EBX, 2 + ShR EBX, 14 ; BX = frame + + Sub BX, 3 + JNC MBS8Bit4 + + Xor BX, BX + +MBS8Bit4: + Mov ECX, EBX + ShL ECX, 14 + Sub EDI, ECX + + Call SetBackSampleSegment + + Mov ECX, CURRENTPOSITION + Mov BX, CURRENTPOSITIONERROR + And ECX, 16383 + Add ECX, 0BFFEh + Cmp ECX, EDX + JG MBS8Bit1 + JL MBS8Bit5 + Cmp BX, AX + JG MBS8Bit1 + +MBS8Bit5: + Mov EDX, ECX + Mov AX, BX + +MBS8Bit1: + + ; Now to calculate bytes to mix... + ShL EAX, 16 + SHRD EAX, EDX, 16 + ShR EDX, 16 ; EDX:EAX = (16)32.16 offset + + Mov EBX, STEPVALUE + Cmp EDX, EBX + JAE MBS8Bit2 + + Div EBX + Add EDX, 0FFFFFFFFh + AdC EAX, 0 ; EAX = no of bytes to mix + JZ MBS8Bit2 + + Push EAX + + Xor ECX, ECX + Mov EBP, [SI+2] ; Stepvalue + Neg EBP + ShLD EDX, EBP, 16 + + Mov CX, CURRENTPOSITIONERROR + + Push DS + Push SI + + Mov SI, MixBufferOffset + Mov DS, MixSegment + Call [MixFunction] + + Pop SI + Pop DS + Pop ECX + Jmp MBS8Bit3 + +MBS8Bit2: +; Xor ECX, ECX + Pop EDX + Pop AX + Ret + +MBS8Bit3: + ; Update pointers... + Mov EAX, STEPVALUE + Mul ECX + + Sub MixBlockSize, CX + ShL CX, RESOLUTIONSHIFT + Add MixBufferOffset, CX + + ; EDX:EAX = offset mixed (32.16) + ShLD EDX, EAX, 16 + Mov BX, AX + Mov ECX, EDX ; ECX:BX = offset mixed + + Sub CURRENTPOSITIONERROR, BX + SBB CURRENTPOSITION, ECX + + Pop EDX + Pop AX + + Sub AX, BX + SBB EDX, ECX + + JG MBS8Bit + + Ret + +EndP MBS8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MBS16Bit + + Push AX + Push EDX ; EDX:AX = 32.16 blocksize + + Mov EDI, CURRENTPOSITION + Mov EBX, EDI + Add EBX, 4 + ShR EBX, 13 ; BX = frame + + Sub BX, 3 + JNC MBS16Bit4 + + Xor BX, BX + +MBS16Bit4: + Mov ECX, EBX + ShL ECX, 13 + Sub EDI, ECX + + Call SetBackSampleSegment + + Mov ECX, CURRENTPOSITION + Mov BX, CURRENTPOSITIONERROR + And ECX, 8191 + Add ECX, 05FFEh + Cmp ECX, EDX + JG MBS16Bit1 + JL MBS16Bit5 + Cmp BX, AX + JG MBS16Bit1 + +MBS16Bit5: + Mov EDX, ECX + Mov AX, BX + +MBS16Bit1: + + ; Now to calculate bytes to mix... + ShL EAX, 16 + SHRD EAX, EDX, 16 + ShR EDX, 16 ; EDX:EAX = (16)32.16 offset + + Mov EBX, STEPVALUE + Cmp EDX, EBX + JAE MBS16Bit2 + + Div EBX + Add EDX, 0FFFFFFFFh + AdC EAX, 0 ; EAX = no of bytes to mix + JZ MBS16Bit2 + + Push EAX + + Xor ECX, ECX + Mov EBP, [SI+2] ; Stepvalue + Neg EBP + ShLD EDX, EBP, 16 + + Mov CX, CURRENTPOSITIONERROR + + Push DS + Push SI + + Mov SI, MixBufferOffset + Mov DS, MixSegment + Call [MixFunction] + + Pop SI + Pop DS + Pop ECX + Jmp MBS16Bit3 + +MBS16Bit2: +; Xor ECX, ECX + Pop EDX + Pop AX + Ret + +MBS16Bit3: + ; Update pointers... + Mov EAX, STEPVALUE + Mul ECX + + Sub MixBlockSize, CX + ShL CX, RESOLUTIONSHIFT + Add MixBufferOffset, CX + + ; EDX:EAX = offset mixed (32.16) + ShLD EDX, EAX, 16 + Mov BX, AX + Mov ECX, EDX ; ECX:BX = offset mixed + + Sub CURRENTPOSITIONERROR, BX + SBB CURRENTPOSITION, ECX + + Pop EDX + Pop AX + + Sub AX, BX + SBB EDX, ECX + + JG MBS16Bit + + Ret + +EndP MBS16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReportError + + Ret + +EndP ReportError + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/MLPT1.BAT b/SoundDrivers/MLPT1.BAT index f7b9a13..6764ebf 100755 --- a/SoundDrivers/MLPT1.BAT +++ b/SoundDrivers/MLPT1.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 lpt1drv -tlink /3 lpt1drv -execom lpt1drv itlpt1.drv -copy itlpt1.drv .. +tasm /m /ut310 lpt1drv +tlink /3 lpt1drv +execom lpt1drv itlpt1.drv +copy itlpt1.drv .. diff --git a/SoundDrivers/MLPT2.BAT b/SoundDrivers/MLPT2.BAT index 9f3b39b..9871544 100755 --- a/SoundDrivers/MLPT2.BAT +++ b/SoundDrivers/MLPT2.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 lpt2drv -tlink /3 lpt2drv -execom lpt2drv itlpt2.drv -copy itlpt2.drv .. +tasm /m /ut310 lpt2drv +tlink /3 lpt2drv +execom lpt2drv itlpt2.drv +copy itlpt2.drv .. diff --git a/SoundDrivers/MMID.BAT b/SoundDrivers/MMID.BAT index 9d1760f..3632241 100755 --- a/SoundDrivers/MMID.BAT +++ b/SoundDrivers/MMID.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 middrv -tlink /3 middrv -execom middrv itmid.drv -copy itmid.drv .. +tasm /m /ut310 middrv +tlink /3 middrv +execom middrv itmid.drv +copy itmid.drv .. diff --git a/SoundDrivers/MMIDI.BAT b/SoundDrivers/MMIDI.BAT index d9f2c56..0d1d15d 100755 --- a/SoundDrivers/MMIDI.BAT +++ b/SoundDrivers/MMIDI.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 mididrv -tlink /3 mididrv -execom mididrv itmpu401.drv -copy itmpu401.drv .. +tasm /m /ut310 mididrv +tlink /3 mididrv +execom mididrv itmpu401.drv +copy itmpu401.drv .. diff --git a/SoundDrivers/MMX.INC b/SoundDrivers/MMX.INC index 680eed8..1dd81b4 100755 --- a/SoundDrivers/MMX.INC +++ b/SoundDrivers/MMX.INC @@ -1,306 +1,306 @@ - -; Stuff from Intel's MMX Macro set. - -; This stuff has been written for real mode use - change the EQU below to EAX -; for protected mode use. - -opc_rdTSC = 031h -opc_Rdpmc = 033H -opc_Emms = 077H -opc_Movd_ld = 06EH -opc_Movd_st = 07EH -opc_Movq_ld = 06FH -opc_Movq_st = 07FH -opc_Packssdw = 06BH -opc_Packsswb = 063H -opc_Packuswb = 067H -opc_Paddb = 0FCH -opc_Paddd = 0FEH -opc_Paddsb = 0ECH -opc_Paddsw = 0EDH -opc_Paddusb = 0DCH -opc_Paddusw = 0DDH -opc_Paddw = 0FDH -opc_Pand = 0DBH -opc_Pandn = 0DFH -opc_Pcmpeqb = 074H -opc_Pcmpeqd = 076H -opc_Pcmpeqw = 075H -opc_Pcmpgtb = 064H -opc_Pcmpgtd = 066H -opc_Pcmpgtw = 065H -opc_Pmaddwd = 0F5H -opc_Pmulhw = 0E5H -opc_Pmullw = 0D5H -opc_Por = 0EBH -opc_PSHimd = 072H -opc_PSHimq = 073H -opc_PSHimw = 071H -opc_Pslld = 0F2H -opc_Psllq = 0F3H -opc_Psllw = 0F1H -opc_Psrad = 0E2H -opc_Psraw = 0E1H -opc_Psrld = 0D2H -opc_Psrlq = 0D3H -opc_Psrlw = 0D1H -opc_Psubb = 0F8H -opc_Psubd = 0FAH -opc_Psubsb = 0E8H -opc_Psubsw = 0E9H -opc_Psubusb = 0D8H -opc_Psubusw = 0D9H -opc_Psubw = 0F9H -opc_Punpcklbw = 060H -opc_Punpckldq = 062H -opc_Punpcklwd = 061H -opc_Punpckhbw = 068H -opc_Punpckhdq = 06AH -opc_Punpckhwd = 069H -opc_Pxor = 0EFH - -.486P - -MM0 EQU AX -MM1 EQU CX -MM2 EQU DX -MM3 EQU BX -MM4 EQU SP -MM5 EQU BP -MM6 EQU SI -MM7 EQU DI - -MMXMacro Macro Dst, Src, Opcode - Local X, Y - X: CmpXChg Src, Dst - Y: Org X+1 - DB Opcode - Org Y - EndM - -MMXIMacro Macro Dst, Src, Opcode - Local X, Y - X: BT Dst, Src - Y: Org X+1 - DB Opcode - Org Y - EndM - -MMXSRMacro Macro Dst, Src, Opcode - Local X, Y - X: CmpXChg Dst, MM2 - DB Src - Y: Org X+1 - DB Opcode - Org Y - EndM - -MMXSLMacro Macro Dst, Src, Opcode - Local X, Y - X: BTR Dst, Src - Y: Org X+1 - DB Opcode - Org Y - EndM - - -EMMS Macro - DB 0Fh, opc_Emms - EndM - - -MovQ Macro Dst, Src - MMXMacro Dst, Src, opc_MovQ_LD - EndM - -MovQM Macro Dst, Src - MMXMacro Src, Dst, opc_MovQ_ST - EndM - -MovD Macro Dst, Src - MMXMacro Dst, Src, opc_MovD_LD - EndM - -MovDM Macro Dst, Src - MMXMacro Src, Dst, opc_MovD_ST - EndM - -MovDR Macro Dst, Src - MMXMacro Src, Dst, opc_MovD_ST - EndM - - -PackSSDW Macro Dst, Src - MMXMacro Dst, Src, opc_PackSSDW - EndM - -PackSSWB Macro Dst, Src - MMXMacro Dst, Src, opc_PackSSWB - EndM - - -PAnd Macro Dst, Src - MMXMacro Dst, Src, opc_PAnd - EndM - -PAndN Macro Dst, Src - MMXMacro Dst, Src, opc_PAndN - EndM - - -PAddD Macro Dst, Src - MMXMacro Dst, Src, opc_PAddD - EndM - -PAddSW Macro Dst, Src - MMXMacro Dst, Src, opc_PAddSW - EndM - -PAddW Macro Dst, Src - MMXMacro Dst, Src, opc_PAddW - EndM - - -PMAddWD Macro Dst, Src - MMXMacro Dst, Src, opc_PMAddWD - EndM - -PMulHW Macro Dst, Src - MMXMacro Dst, Src, opc_PMulHW - EndM - -PMulLW Macro Dst, Src - MMXMacro Dst, Src, opc_PMulLW - EndM - - -POr Macro Dst, Src - MMXMacro Dst, Src, opc_POr - EndM - - -PSLLD Macro Dst, Src - MMXMacro Dst, Src, opc_PSLLD - EndM - -PSLLDI Macro Dst, Src - MMXSLMacro Dst, Src, opc_PSHImd - EndM - -PSLLQ Macro Dst, Src - MMXMacro Dst, Src, opc_PSLLQ - EndM - -PSLLQI Macro Dst, Src - MMXSLMacro Dst, Src, opc_PSHImq - EndM - - -PSRAD Macro Dst, Src - MMXMacro Dst, Src, opc_PSRAD - EndM - -PSRADI Macro Dst, Src - MMXIMacro Dst, Src, opc_PSHImd - EndM - -PSRLD Macro Dst, Src - MMXMacro Dst, Src, opc_PSRLD - EndM - -PSRLDI Macro Dst, Src - MMXSRMacro Dst, Src, opc_PSHImd - EndM - -PSRLQ Macro Dst, Src - MMXMacro Dst, Src, opc_PSRLQ - EndM - -PSRLQI Macro Dst, Src - MMXSRMacro Dst, Src, opc_PSHImq - EndM - -PSRAW Macro Dst, Src - MMXMacro Dst, Src, opc_PSRAW - EndM - -PSRAWI Macro Dst, Src - MMXIMacro Dst, Src, opc_PSHImw - EndM - -PSRLW Macro Dst, Src - MMXMacro Dst, Src, opc_PSRLW - EndM - -PSRLWI Macro Dst, Src - MMXSRMacro Dst, Src, opc_PSHImw - EndM - - -PSubB Macro Dst, Src - MMXMacro Dst, Src, opc_PSubB - EndM - -PSubSB Macro Dst, Src - MMXMacro Dst, Src, opc_PSubSB - EndM - -PSubUSB Macro Dst, Src - MMXMacro Dst, Src, opc_PSubUSB - EndM - -PSubD Macro Dst, Src - MMXMacro Dst, Src, opc_PSubD - EndM - -PSubW Macro Dst, Src - MMXMacro Dst, Src, opc_PSubW - EndM - -PSubSW Macro Dst, Src - MMXMacro Dst, Src, opc_PSubSW - EndM - -PSubUSW Macro Dst, Src - MMXMacro Dst, Src, opc_PSubUSW - EndM - - -PUnpckHBW Macro Dst, Src - MMXMacro Dst, Src, opc_PUnpckHBW - EndM - -PUnpckHDQ Macro Dst, Src - MMXMacro Dst, Src, opc_PUnpckHDQ - EndM - -PUnpckHWD Macro Dst, Src - MMXMacro Dst, Src, opc_PUnpckHWD - EndM - -PUnpckLBW Macro Dst, Src - MMXMacro Dst, Src, opc_PUnpckLBW - EndM - -PUnpckLDQ Macro Dst, Src - MMXMacro Dst, Src, opc_PUnpckLDQ - EndM - -PUnpckLWD Macro Dst, Src - MMXMacro Dst, Src, opc_PUnpckLWD - EndM - - -PXor Macro Dst, Src - MMXMacro Dst, Src, opc_PXor - EndM - - -RdPMC Macro - DB 0Fh, opc_Rdpmc - EndM - -RdTSC Macro - DB 0Fh, opc_RdTSC - EndM - + +; Stuff from Intel's MMX Macro set. + +; This stuff has been written for real mode use - change the EQU below to EAX +; for protected mode use. + +opc_rdTSC = 031h +opc_Rdpmc = 033H +opc_Emms = 077H +opc_Movd_ld = 06EH +opc_Movd_st = 07EH +opc_Movq_ld = 06FH +opc_Movq_st = 07FH +opc_Packssdw = 06BH +opc_Packsswb = 063H +opc_Packuswb = 067H +opc_Paddb = 0FCH +opc_Paddd = 0FEH +opc_Paddsb = 0ECH +opc_Paddsw = 0EDH +opc_Paddusb = 0DCH +opc_Paddusw = 0DDH +opc_Paddw = 0FDH +opc_Pand = 0DBH +opc_Pandn = 0DFH +opc_Pcmpeqb = 074H +opc_Pcmpeqd = 076H +opc_Pcmpeqw = 075H +opc_Pcmpgtb = 064H +opc_Pcmpgtd = 066H +opc_Pcmpgtw = 065H +opc_Pmaddwd = 0F5H +opc_Pmulhw = 0E5H +opc_Pmullw = 0D5H +opc_Por = 0EBH +opc_PSHimd = 072H +opc_PSHimq = 073H +opc_PSHimw = 071H +opc_Pslld = 0F2H +opc_Psllq = 0F3H +opc_Psllw = 0F1H +opc_Psrad = 0E2H +opc_Psraw = 0E1H +opc_Psrld = 0D2H +opc_Psrlq = 0D3H +opc_Psrlw = 0D1H +opc_Psubb = 0F8H +opc_Psubd = 0FAH +opc_Psubsb = 0E8H +opc_Psubsw = 0E9H +opc_Psubusb = 0D8H +opc_Psubusw = 0D9H +opc_Psubw = 0F9H +opc_Punpcklbw = 060H +opc_Punpckldq = 062H +opc_Punpcklwd = 061H +opc_Punpckhbw = 068H +opc_Punpckhdq = 06AH +opc_Punpckhwd = 069H +opc_Pxor = 0EFH + +.486P + +MM0 EQU AX +MM1 EQU CX +MM2 EQU DX +MM3 EQU BX +MM4 EQU SP +MM5 EQU BP +MM6 EQU SI +MM7 EQU DI + +MMXMacro Macro Dst, Src, Opcode + Local X, Y + X: CmpXChg Src, Dst + Y: Org X+1 + DB Opcode + Org Y + EndM + +MMXIMacro Macro Dst, Src, Opcode + Local X, Y + X: BT Dst, Src + Y: Org X+1 + DB Opcode + Org Y + EndM + +MMXSRMacro Macro Dst, Src, Opcode + Local X, Y + X: CmpXChg Dst, MM2 + DB Src + Y: Org X+1 + DB Opcode + Org Y + EndM + +MMXSLMacro Macro Dst, Src, Opcode + Local X, Y + X: BTR Dst, Src + Y: Org X+1 + DB Opcode + Org Y + EndM + + +EMMS Macro + DB 0Fh, opc_Emms + EndM + + +MovQ Macro Dst, Src + MMXMacro Dst, Src, opc_MovQ_LD + EndM + +MovQM Macro Dst, Src + MMXMacro Src, Dst, opc_MovQ_ST + EndM + +MovD Macro Dst, Src + MMXMacro Dst, Src, opc_MovD_LD + EndM + +MovDM Macro Dst, Src + MMXMacro Src, Dst, opc_MovD_ST + EndM + +MovDR Macro Dst, Src + MMXMacro Src, Dst, opc_MovD_ST + EndM + + +PackSSDW Macro Dst, Src + MMXMacro Dst, Src, opc_PackSSDW + EndM + +PackSSWB Macro Dst, Src + MMXMacro Dst, Src, opc_PackSSWB + EndM + + +PAnd Macro Dst, Src + MMXMacro Dst, Src, opc_PAnd + EndM + +PAndN Macro Dst, Src + MMXMacro Dst, Src, opc_PAndN + EndM + + +PAddD Macro Dst, Src + MMXMacro Dst, Src, opc_PAddD + EndM + +PAddSW Macro Dst, Src + MMXMacro Dst, Src, opc_PAddSW + EndM + +PAddW Macro Dst, Src + MMXMacro Dst, Src, opc_PAddW + EndM + + +PMAddWD Macro Dst, Src + MMXMacro Dst, Src, opc_PMAddWD + EndM + +PMulHW Macro Dst, Src + MMXMacro Dst, Src, opc_PMulHW + EndM + +PMulLW Macro Dst, Src + MMXMacro Dst, Src, opc_PMulLW + EndM + + +POr Macro Dst, Src + MMXMacro Dst, Src, opc_POr + EndM + + +PSLLD Macro Dst, Src + MMXMacro Dst, Src, opc_PSLLD + EndM + +PSLLDI Macro Dst, Src + MMXSLMacro Dst, Src, opc_PSHImd + EndM + +PSLLQ Macro Dst, Src + MMXMacro Dst, Src, opc_PSLLQ + EndM + +PSLLQI Macro Dst, Src + MMXSLMacro Dst, Src, opc_PSHImq + EndM + + +PSRAD Macro Dst, Src + MMXMacro Dst, Src, opc_PSRAD + EndM + +PSRADI Macro Dst, Src + MMXIMacro Dst, Src, opc_PSHImd + EndM + +PSRLD Macro Dst, Src + MMXMacro Dst, Src, opc_PSRLD + EndM + +PSRLDI Macro Dst, Src + MMXSRMacro Dst, Src, opc_PSHImd + EndM + +PSRLQ Macro Dst, Src + MMXMacro Dst, Src, opc_PSRLQ + EndM + +PSRLQI Macro Dst, Src + MMXSRMacro Dst, Src, opc_PSHImq + EndM + +PSRAW Macro Dst, Src + MMXMacro Dst, Src, opc_PSRAW + EndM + +PSRAWI Macro Dst, Src + MMXIMacro Dst, Src, opc_PSHImw + EndM + +PSRLW Macro Dst, Src + MMXMacro Dst, Src, opc_PSRLW + EndM + +PSRLWI Macro Dst, Src + MMXSRMacro Dst, Src, opc_PSHImw + EndM + + +PSubB Macro Dst, Src + MMXMacro Dst, Src, opc_PSubB + EndM + +PSubSB Macro Dst, Src + MMXMacro Dst, Src, opc_PSubSB + EndM + +PSubUSB Macro Dst, Src + MMXMacro Dst, Src, opc_PSubUSB + EndM + +PSubD Macro Dst, Src + MMXMacro Dst, Src, opc_PSubD + EndM + +PSubW Macro Dst, Src + MMXMacro Dst, Src, opc_PSubW + EndM + +PSubSW Macro Dst, Src + MMXMacro Dst, Src, opc_PSubSW + EndM + +PSubUSW Macro Dst, Src + MMXMacro Dst, Src, opc_PSubUSW + EndM + + +PUnpckHBW Macro Dst, Src + MMXMacro Dst, Src, opc_PUnpckHBW + EndM + +PUnpckHDQ Macro Dst, Src + MMXMacro Dst, Src, opc_PUnpckHDQ + EndM + +PUnpckHWD Macro Dst, Src + MMXMacro Dst, Src, opc_PUnpckHWD + EndM + +PUnpckLBW Macro Dst, Src + MMXMacro Dst, Src, opc_PUnpckLBW + EndM + +PUnpckLDQ Macro Dst, Src + MMXMacro Dst, Src, opc_PUnpckLDQ + EndM + +PUnpckLWD Macro Dst, Src + MMXMacro Dst, Src, opc_PUnpckLWD + EndM + + +PXor Macro Dst, Src + MMXMacro Dst, Src, opc_PXor + EndM + + +RdPMC Macro + DB 0Fh, opc_Rdpmc + EndM + +RdTSC Macro + DB 0Fh, opc_RdTSC + EndM + diff --git a/SoundDrivers/MMXMSAM.INC b/SoundDrivers/MMXMSAM.INC index 72233ee..554c913 100755 --- a/SoundDrivers/MMXMSAM.INC +++ b/SoundDrivers/MMXMSAM.INC @@ -1,388 +1,388 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Align 4 -include q.inc -FilterParameters DB 64 Dup (07Fh), 64 Dup (0) -Const2048 DD 16384.0 -FreqMultiplier DD 3A9F7867h ; = 1/(2*PI*110.0*2^0.25) -FreqParameterMultiplier DD 0B92AAAAAh ; = -1/(24*256) - -NUMBEROFFILTERBANDS = 4 - -IF OUTPUTFILTERENABLED -LastFilter DD NUMBEROFFILTERBANDS*2 Dup (0) ; 4 stereo values -FilterCoefficients DD NUMBEROFFILTERBANDS*2 Dup (0) -FilterVolumes DD NUMBEROFFILTERBANDS Dup (0) -ENDIF - -FilterFreqValue DW 0 -NewControlWord DW 7Fh - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - Assume DS:Nothing - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, CS:MixSegment - Mov DI, DMABUFFERLENGTH*2+80 - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov CS:MixTransferOffset, DI - - Cmp CS:Stereo, 0 - JE CS:MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD - Mov CS:MixTransferRemaining, DX - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamplesNoStop - - And Byte Ptr [SI], Not 1 - - Cmp MixMode, 2 - JB MixSamplesEnd - - Mov DWord Ptr [SI+0Ch], 0 - Jmp MixModeCommon - -MixSamplesNoStop: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Xor EAX, EAX - Mov [SI+3Ch], AX ; For filter. - Mov [SI+6Eh], AX - - Mov DWord Ptr [SI+1Ch], EAX ; Current Volume = 0 - ; for volume sliding. - Mov [SI+06h], DX - Mov [SI+5Eh], AX - Mov [SI+7Eh], AX - -MixSamples5: - Test CX, 8540h ; New volume or panning? - JZ MixSamplesMix - - Mov AX, 4*60 - - Test CH, 8 ; Muted? - JZ MixMMXNoMute - - Xor EDX, EDX - Mov [SI+06h], DX - Mov [SI+0Ch], EDX - Mov [SI+5Eh], DX - Mov [SI+1Ch], EDX - Mov [SI+6Eh], DX - Mov [SI+3Ch], DX - Mov [SI+7Eh], DX - - Xor BX, BX - Mov BL, [SI+3Ah] - - Test BL, BL - JS MixModeCommon1 - - Mov DL, [CS:FilterParameters+BX] - Mov BL, [CS:FilterParameters+BX+64] - - Mov [SI+5Bh], DL - Mov [SI+3Fh], BL - - Jmp MixModeCommon1 - -MixMMXNoMute: - Xor BX, BX - Mov BL, [SI+3Ah] - - Test BL, BL ; Disowned? Then use channel filters. - JNS MixGetChannelFilters - - Mov BL, [SI+3Fh] - Jmp MixChannelFilters - -MixGetChannelFilters: - ; Filter = [FilterParameters+BX] - ; Q = [FilterParameters+BX+64] - - Mov AL, [CS:FilterParameters+BX] ; AX = Filter - Mov BL, [CS:FilterParameters+BX+64] ; BX = Q - -; If the values are different, then force recalculate volume. (and hence mixmode) - - Cmp [SI+5Bh], AL - JE MixChannelFiltersSame - Cmp [SI+3Fh], BL - JE MixChannelFiltersSame - - Mov DWord Ptr [SI+0Ch], 0 - -MixChannelFiltersSame: - Mov [SI+5Bh], AL - Mov [SI+3Fh], BL - -MixChannelFilters: - Cmp MixMode, 3 - JNE MixMMXNoFilters - - Mov AL, [SI+3Eh] - Mul Byte Ptr [SI+5Bh] - - Mov CS:FilterFreqValue, AX - - Cmp AX, 127*255 - JNE MixChannelFiltersOK - Test BL, BL - JZ MixMMXNoFilters - -MixChannelFiltersOK: - ShL BX, 2 - - FNInit - FLdCW [CS:NewControlWord] - - FILD [CS:FilterFreqValue] ; 0->127*256 - FMul [CS:FreqParameterMultiplier] ; -i/(24*256) - FLd ST - FRndInt - FSub ST(1), ST - FXCh - F2XM1 - FLd1 - FAdd - FScale ; = 2^(i/24*256) - FMul [CS:FreqMultiplier] ; = r - FLd ST ; r, r - FMul ST(1), ST ; r, r^2 - - FLd [CS:QualityFactorTable+BX] ; 2d, r, r^2 - FMul ST(1), ST ; 2d, 2dr, r^2 - FAdd - - FLd1 ; 1, d+1, e - FXCh ; d+1, 1, e - FSubR ST(1), ST - FAdd ST, ST(2) ; 1+d+e, d, e - FDivR Const2048 ; 1/(1+d+e), d, e - FISt Word Ptr [SI+5Eh] ; - FLd ST(2) ; e, 1/(1+d+e), d, e - FAdd ST, ST - FAddP ST(2), ST ; 1/(1+d+e), d+2e, e - FMul ST(2), ST ; 1/(1+d+e), d+2e, e/(1+d+e) - FMul - FIStP Word Ptr [SI+6Eh] - FChs - FIStP Word Ptr [SI+7Eh] - FStP ST - Mov DWord Ptr [SI+0Ch], 0 - -MixMMXNoFilters: - Mov EBX, [SI+0Ch] - - Cmp Stereo, 0 - JNE MixMMXStereo - -MixMMXMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - - Jmp MixModeVolumeCheck - -MixMMXStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE MixMMXSurround - - Mul Byte Ptr MixVolume ; 0->128 - Mul Word Ptr [SI+4Ah] ; 0->32768 - ShRD AX, DX, 15 ; Maxvol = 8192 - Mov [SI+0Eh], AX ; Store into right volume - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 15 - Mov [SI+0Ch], AX - - Jmp MixModeVolumeCheck - -MixMMXSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 10 - Mov [SI+0Ch], AX - Neg AX - Mov [SI+0Eh], AX - -MixModeVolumeCheck: - Test CH, 3+4 - JNZ MixModeCommon - - Cmp EBX, [SI+0Ch] ; Same as last volume? - JE MixSamplesMix - -MixModeCommon: ; Requires AX = 30 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov AX, MixModeOffset - - Cmp DWord Ptr [SI+0Ch], 0 - JNE MixModeActualMix - - Cmp MixMode, 2 - JB MixMMXGeneralNoRamp - - Cmp DWord Ptr [SI+1Ch], 0 - JNE MixModeActualMix - -MixMMXGeneralNoRamp: - Mov AX, 4*60 - Jmp MixModeCommon1 - -MixModeActualMix: - Cmp MixMode, 3 - JNE MixModeFilter - - Cmp Word Ptr [SI+6Eh], 0 - JNE MixModeFilter - Cmp Word Ptr [SI+7Eh], 0 - JNE MixModeFilter - - Sub AX, 60 - -MixModeFilter: - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 30 - -MixModeCommon1: - Cmp Byte Ptr [SI+0Ah], 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, DMABUFFERLENGTH*2+80 - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Push Word Ptr [SI+8] - Call Word Ptr [CS:BX] - Pop BX - - And Word Ptr [SI], 0111100010001101b - - Cmp BX, Offset MixFunctionTables+60*2 - JB MixSamplesEnd - Cmp BX, Offset MixFunctionTables+60*4 - JAE MixSamplesEnd - - MovDR AX, MM6 - Mov [SI+0Ch], EAX - Mov [SI+1Ch], EAX - - Cmp BX, Offset MixfunctionTables+60*3 - JB MixSamplesEnd - - Mov ES, CS:MixSegment - Mov DX, [ES:10h] - Mov BX, [ES:14h] - Mov [SI+3Ch], DX - Mov [SI+6h], BX - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - -IF OUTPUTFILTERENABLED - include equalize.inc -ENDIF - Ret - -EndP MixSamples - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Align 4 +include q.inc +FilterParameters DB 64 Dup (07Fh), 64 Dup (0) +Const2048 DD 16384.0 +FreqMultiplier DD 3A9F7867h ; = 1/(2*PI*110.0*2^0.25) +FreqParameterMultiplier DD 0B92AAAAAh ; = -1/(24*256) + +NUMBEROFFILTERBANDS = 4 + +IF OUTPUTFILTERENABLED +LastFilter DD NUMBEROFFILTERBANDS*2 Dup (0) ; 4 stereo values +FilterCoefficients DD NUMBEROFFILTERBANDS*2 Dup (0) +FilterVolumes DD NUMBEROFFILTERBANDS Dup (0) +ENDIF + +FilterFreqValue DW 0 +NewControlWord DW 7Fh + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + Assume DS:Nothing + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, CS:MixSegment + Mov DI, DMABUFFERLENGTH*2+80 + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov CS:MixTransferOffset, DI + + Cmp CS:Stereo, 0 + JE CS:MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD + Mov CS:MixTransferRemaining, DX + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamplesNoStop + + And Byte Ptr [SI], Not 1 + + Cmp MixMode, 2 + JB MixSamplesEnd + + Mov DWord Ptr [SI+0Ch], 0 + Jmp MixModeCommon + +MixSamplesNoStop: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Xor EAX, EAX + Mov [SI+3Ch], AX ; For filter. + Mov [SI+6Eh], AX + + Mov DWord Ptr [SI+1Ch], EAX ; Current Volume = 0 + ; for volume sliding. + Mov [SI+06h], DX + Mov [SI+5Eh], AX + Mov [SI+7Eh], AX + +MixSamples5: + Test CX, 8540h ; New volume or panning? + JZ MixSamplesMix + + Mov AX, 4*60 + + Test CH, 8 ; Muted? + JZ MixMMXNoMute + + Xor EDX, EDX + Mov [SI+06h], DX + Mov [SI+0Ch], EDX + Mov [SI+5Eh], DX + Mov [SI+1Ch], EDX + Mov [SI+6Eh], DX + Mov [SI+3Ch], DX + Mov [SI+7Eh], DX + + Xor BX, BX + Mov BL, [SI+3Ah] + + Test BL, BL + JS MixModeCommon1 + + Mov DL, [CS:FilterParameters+BX] + Mov BL, [CS:FilterParameters+BX+64] + + Mov [SI+5Bh], DL + Mov [SI+3Fh], BL + + Jmp MixModeCommon1 + +MixMMXNoMute: + Xor BX, BX + Mov BL, [SI+3Ah] + + Test BL, BL ; Disowned? Then use channel filters. + JNS MixGetChannelFilters + + Mov BL, [SI+3Fh] + Jmp MixChannelFilters + +MixGetChannelFilters: + ; Filter = [FilterParameters+BX] + ; Q = [FilterParameters+BX+64] + + Mov AL, [CS:FilterParameters+BX] ; AX = Filter + Mov BL, [CS:FilterParameters+BX+64] ; BX = Q + +; If the values are different, then force recalculate volume. (and hence mixmode) + + Cmp [SI+5Bh], AL + JE MixChannelFiltersSame + Cmp [SI+3Fh], BL + JE MixChannelFiltersSame + + Mov DWord Ptr [SI+0Ch], 0 + +MixChannelFiltersSame: + Mov [SI+5Bh], AL + Mov [SI+3Fh], BL + +MixChannelFilters: + Cmp MixMode, 3 + JNE MixMMXNoFilters + + Mov AL, [SI+3Eh] + Mul Byte Ptr [SI+5Bh] + + Mov CS:FilterFreqValue, AX + + Cmp AX, 127*255 + JNE MixChannelFiltersOK + Test BL, BL + JZ MixMMXNoFilters + +MixChannelFiltersOK: + ShL BX, 2 + + FNInit + FLdCW [CS:NewControlWord] + + FILD [CS:FilterFreqValue] ; 0->127*256 + FMul [CS:FreqParameterMultiplier] ; -i/(24*256) + FLd ST + FRndInt + FSub ST(1), ST + FXCh + F2XM1 + FLd1 + FAdd + FScale ; = 2^(i/24*256) + FMul [CS:FreqMultiplier] ; = r + FLd ST ; r, r + FMul ST(1), ST ; r, r^2 + + FLd [CS:QualityFactorTable+BX] ; 2d, r, r^2 + FMul ST(1), ST ; 2d, 2dr, r^2 + FAdd + + FLd1 ; 1, d+1, e + FXCh ; d+1, 1, e + FSubR ST(1), ST + FAdd ST, ST(2) ; 1+d+e, d, e + FDivR Const2048 ; 1/(1+d+e), d, e + FISt Word Ptr [SI+5Eh] ; + FLd ST(2) ; e, 1/(1+d+e), d, e + FAdd ST, ST + FAddP ST(2), ST ; 1/(1+d+e), d+2e, e + FMul ST(2), ST ; 1/(1+d+e), d+2e, e/(1+d+e) + FMul + FIStP Word Ptr [SI+6Eh] + FChs + FIStP Word Ptr [SI+7Eh] + FStP ST + Mov DWord Ptr [SI+0Ch], 0 + +MixMMXNoFilters: + Mov EBX, [SI+0Ch] + + Cmp Stereo, 0 + JNE MixMMXStereo + +MixMMXMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + + Jmp MixModeVolumeCheck + +MixMMXStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE MixMMXSurround + + Mul Byte Ptr MixVolume ; 0->128 + Mul Word Ptr [SI+4Ah] ; 0->32768 + ShRD AX, DX, 15 ; Maxvol = 8192 + Mov [SI+0Eh], AX ; Store into right volume + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 15 + Mov [SI+0Ch], AX + + Jmp MixModeVolumeCheck + +MixMMXSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 10 + Mov [SI+0Ch], AX + Neg AX + Mov [SI+0Eh], AX + +MixModeVolumeCheck: + Test CH, 3+4 + JNZ MixModeCommon + + Cmp EBX, [SI+0Ch] ; Same as last volume? + JE MixSamplesMix + +MixModeCommon: ; Requires AX = 30 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov AX, MixModeOffset + + Cmp DWord Ptr [SI+0Ch], 0 + JNE MixModeActualMix + + Cmp MixMode, 2 + JB MixMMXGeneralNoRamp + + Cmp DWord Ptr [SI+1Ch], 0 + JNE MixModeActualMix + +MixMMXGeneralNoRamp: + Mov AX, 4*60 + Jmp MixModeCommon1 + +MixModeActualMix: + Cmp MixMode, 3 + JNE MixModeFilter + + Cmp Word Ptr [SI+6Eh], 0 + JNE MixModeFilter + Cmp Word Ptr [SI+7Eh], 0 + JNE MixModeFilter + + Sub AX, 60 + +MixModeFilter: + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 30 + +MixModeCommon1: + Cmp Byte Ptr [SI+0Ah], 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, DMABUFFERLENGTH*2+80 + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Push Word Ptr [SI+8] + Call Word Ptr [CS:BX] + Pop BX + + And Word Ptr [SI], 0111100010001101b + + Cmp BX, Offset MixFunctionTables+60*2 + JB MixSamplesEnd + Cmp BX, Offset MixFunctionTables+60*4 + JAE MixSamplesEnd + + MovDR AX, MM6 + Mov [SI+0Ch], EAX + Mov [SI+1Ch], EAX + + Cmp BX, Offset MixfunctionTables+60*3 + JB MixSamplesEnd + + Mov ES, CS:MixSegment + Mov DX, [ES:10h] + Mov BX, [ES:14h] + Mov [SI+3Ch], DX + Mov [SI+6h], BX + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + +IF OUTPUTFILTERENABLED + include equalize.inc +ENDIF + Ret + +EndP MixSamples + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/MMXTRANS.INC b/SoundDrivers/MMXTRANS.INC index 25dd6a0..445a9cb 100755 --- a/SoundDrivers/MMXTRANS.INC +++ b/SoundDrivers/MMXTRANS.INC @@ -1,116 +1,116 @@ - -; To be embedded within the IRQ handler. - - Push DX - - Cmp CS:Stereo, 0 - JNE TransferStereoBufferMMX - -TransferMonoBufferMMX: ; DX = number of 32 bit numbers -> 16 bit. - - Push DX - ShR DX, 3 - JZ TransferMonoBufferMMX2 - -TransferMonoBufferMMX1: - MovD MM0, [SI] - MovD MM4, [SI+8] - MovD MM1, [SI+10h] - PUnpckLDQ MM0, MM4 - MovD MM5, [SI+18h] - PSRADI MM0, 13 - MovD MM2, [SI+20h] - PUnpckLDQ MM1, MM5 - MovD MM6, [SI+28h] - PSRADI MM1, 13 - MovD MM3, [SI+30h] - PUnpckLDQ MM2, MM6 - MovD MM7, [SI+38h] - PSRADI MM2, 13 - - PUnpckLDQ MM3, MM7 - PackSSDW MM0, MM1 - - PSRADI MM3, 13 - - MovQM [DI], MM0 - PackSSDW MM2, MM3 - - MovQM [DI+8], MM2 - - Add SI, 40h - Add DI, 10h - - Dec DX - JNZ TransferMonoBufferMMX1 - -TransferMonoBufferMMX2: - Pop CX - Mov DX, CX - - And CX, 7 - JZ TransferMonoBufferMMX4 - -TransferMonoBufferMMX3: - MovD MM0, [SI] - PSRADI MM0, 13 - PackSSDW MM0, MM1 - MovDR AX, MM0 - StosW - Add SI, 8 - - Loop TransferMonoBufferMMX3 - -TransferMonoBufferMMX4: - Jmp MMXMixTransferEnd - -TransferStereoBufferMMX: ; DX is always an even number for stereo - Push DX - - ShR DX, 3 - JZ TransferStereoBufferMMX2 - -TransferStereoBufferMMX1: ; DX = number of 32 bit numbers -> 16 bit - MovQ MM0, [SI] - MovQ MM1, [SI+10h] - PSRADI MM0, 12 - MovQ MM2, [SI+8] - PSRADI MM1, 12 - MovQ MM3, [SI+18h] - PSRADI MM2, 12 - PackSSDW MM0, MM2 - PSRADI MM3, 12 - MovQM [DI], MM0 - PackSSDW MM1, MM3 - MovQM [DI+8], MM1 ; 8 values done. - - Add SI, 20h - Add DI, 10h - - Dec DX - JNZ TransferStereoBufferMMX1 - -TransferStereoBufferMMX2: - Pop CX - Mov DX, CX - - And CX, 7 - ShR CX, 1 ; Always an even number! - JZ TransferStereoBufferMMX4 - -TransferStereoBufferMMX3: - MovQ MM0, [SI] - PSRADI MM0, 12 - PackSSDW MM0, MM1 ; Dummy register - MovDM [DI], MM0 - Add SI, 8 - Add DI, 4 - - Dec CX - JNZ TransferStereoBufferMMX3 - -TransferStereoBufferMMX4: - -MMXMixTransferEnd: - Pop DX - + +; To be embedded within the IRQ handler. + + Push DX + + Cmp CS:Stereo, 0 + JNE TransferStereoBufferMMX + +TransferMonoBufferMMX: ; DX = number of 32 bit numbers -> 16 bit. + + Push DX + ShR DX, 3 + JZ TransferMonoBufferMMX2 + +TransferMonoBufferMMX1: + MovD MM0, [SI] + MovD MM4, [SI+8] + MovD MM1, [SI+10h] + PUnpckLDQ MM0, MM4 + MovD MM5, [SI+18h] + PSRADI MM0, 13 + MovD MM2, [SI+20h] + PUnpckLDQ MM1, MM5 + MovD MM6, [SI+28h] + PSRADI MM1, 13 + MovD MM3, [SI+30h] + PUnpckLDQ MM2, MM6 + MovD MM7, [SI+38h] + PSRADI MM2, 13 + + PUnpckLDQ MM3, MM7 + PackSSDW MM0, MM1 + + PSRADI MM3, 13 + + MovQM [DI], MM0 + PackSSDW MM2, MM3 + + MovQM [DI+8], MM2 + + Add SI, 40h + Add DI, 10h + + Dec DX + JNZ TransferMonoBufferMMX1 + +TransferMonoBufferMMX2: + Pop CX + Mov DX, CX + + And CX, 7 + JZ TransferMonoBufferMMX4 + +TransferMonoBufferMMX3: + MovD MM0, [SI] + PSRADI MM0, 13 + PackSSDW MM0, MM1 + MovDR AX, MM0 + StosW + Add SI, 8 + + Loop TransferMonoBufferMMX3 + +TransferMonoBufferMMX4: + Jmp MMXMixTransferEnd + +TransferStereoBufferMMX: ; DX is always an even number for stereo + Push DX + + ShR DX, 3 + JZ TransferStereoBufferMMX2 + +TransferStereoBufferMMX1: ; DX = number of 32 bit numbers -> 16 bit + MovQ MM0, [SI] + MovQ MM1, [SI+10h] + PSRADI MM0, 12 + MovQ MM2, [SI+8] + PSRADI MM1, 12 + MovQ MM3, [SI+18h] + PSRADI MM2, 12 + PackSSDW MM0, MM2 + PSRADI MM3, 12 + MovQM [DI], MM0 + PackSSDW MM1, MM3 + MovQM [DI+8], MM1 ; 8 values done. + + Add SI, 20h + Add DI, 10h + + Dec DX + JNZ TransferStereoBufferMMX1 + +TransferStereoBufferMMX2: + Pop CX + Mov DX, CX + + And CX, 7 + ShR CX, 1 ; Always an even number! + JZ TransferStereoBufferMMX4 + +TransferStereoBufferMMX3: + MovQ MM0, [SI] + PSRADI MM0, 12 + PackSSDW MM0, MM1 ; Dummy register + MovDM [DI], MM0 + Add SI, 8 + Add DI, 4 + + Dec CX + JNZ TransferStereoBufferMMX3 + +TransferStereoBufferMMX4: + +MMXMixTransferEnd: + Pop DX + diff --git a/SoundDrivers/MNOMIX.INC b/SoundDrivers/MNOMIX.INC index 5843cd7..6961b87 100755 --- a/SoundDrivers/MNOMIX.INC +++ b/SoundDrivers/MNOMIX.INC @@ -1,9 +1,9 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + diff --git a/SoundDrivers/MONO12B.INC b/SoundDrivers/MONO12B.INC index 59998e9..e1326e3 100755 --- a/SoundDrivers/MONO12B.INC +++ b/SoundDrivers/MONO12B.INC @@ -1,17 +1,17 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Central - DW Offset MixNoLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit - DW Offset MixForwardsLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit - DW Offset MixPingPongLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit - - ; 16 bit tables - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Central - DW Offset MixNoLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit - DW Offset MixForwardsLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit - DW Offset MixPingPongLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Central + DW Offset MixNoLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit + DW Offset MixForwardsLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit + DW Offset MixPingPongLoop, PreMix12Central8Bit, MFS8Bit, MBS8Bit, Mix12Central8Bit + + ; 16 bit tables + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Central + DW Offset MixNoLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit + DW Offset MixForwardsLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit + DW Offset MixPingPongLoop, PreMix12Central16Bit, MFS16Bit, MBS16Bit, Mix12Central16Bit diff --git a/SoundDrivers/MONO12B.MIX b/SoundDrivers/MONO12B.MIX index 9de6da1..be647bc 100755 --- a/SoundDrivers/MONO12B.MIX +++ b/SoundDrivers/MONO12B.MIX @@ -1,188 +1,188 @@ - -ERROR EQU CX -DELTAERROR EQU BP -DELTAOFFSET EQU DX - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - -M12Mix8Central Macro Index - -M12Mix8Central&Index&: - Mov BL, [ES:DI] ;; 2 - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] ;; 2 - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*2], AX - -EndM - -M12Mix16Central Macro Index - -M12Mix16Central&Index&: - Mov BL, [ES:EDI+EDI+1] - Add ERROR, DELTAERROR - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET - Sub [SI+(Index-15)*2], AX - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central8BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8CentralOffset Macro Index - DW Offset M12Mix8Central&Index& - EndM - - REPT 16 - M12Mix8CentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central8Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central8BitOffsetTable+BX] - -M12Central8BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - RetN - - M12Mix8Central 0 - M12Mix8Central 1 - M12Mix8Central 2 - M12Mix8Central 3 - M12Mix8Central 4 - M12Mix8Central 5 - M12Mix8Central 6 - M12Mix8Central 7 - M12Mix8Central 8 - M12Mix8Central 9 - M12Mix8Central 10 - M12Mix8Central 11 - M12Mix8Central 12 - M12Mix8Central 13 - M12Mix8Central 14 - M12Mix8Central 15 - - Add SI, 32 - Dec LoopCounter - JNZ M12Mix8Central0 - - Ret - -EndP Mix12Central8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central8Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Central8BitVolume], AL - - Ret - -EndP PreMix12Central8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central16BitOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16CentralOffset Macro Index - DW Offset M12Mix16Central&Index& - EndM - - REPT 16 - M12Mix16CentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central16Bit - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central16BitOffsetTable+BX] - -M12Central16BitVolume EQU $+3 - Mov EBX, 0 ; Set BH = volume - - - RetN - - M12Mix16Central 0 - M12Mix16Central 1 - M12Mix16Central 2 - M12Mix16Central 3 - M12Mix16Central 4 - M12Mix16Central 5 - M12Mix16Central 6 - M12Mix16Central 7 - M12Mix16Central 8 - M12Mix16Central 9 - M12Mix16Central 10 - M12Mix16Central 11 - M12Mix16Central 12 - M12Mix16Central 13 - M12Mix16Central 14 - M12Mix16Central 15 - - Add SI, 32 - Dec LoopCounter - JNZ M12Mix16Central0 - - Ret - -EndP Mix12Central16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central16Bit - - Mov AL, [SI+0Eh] - Mov Byte Ptr [CS:M12Central16BitVolume], AL - - Ret - -EndP PreMix12Central16Bit - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +ERROR EQU CX +DELTAERROR EQU BP +DELTAOFFSET EQU DX + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + +M12Mix8Central Macro Index + +M12Mix8Central&Index&: + Mov BL, [ES:DI] ;; 2 + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] ;; 2 + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*2], AX + +EndM + +M12Mix16Central Macro Index + +M12Mix16Central&Index&: + Mov BL, [ES:EDI+EDI+1] + Add ERROR, DELTAERROR + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET + Sub [SI+(Index-15)*2], AX + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central8BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8CentralOffset Macro Index + DW Offset M12Mix8Central&Index& + EndM + + REPT 16 + M12Mix8CentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central8Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central8BitOffsetTable+BX] + +M12Central8BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + RetN + + M12Mix8Central 0 + M12Mix8Central 1 + M12Mix8Central 2 + M12Mix8Central 3 + M12Mix8Central 4 + M12Mix8Central 5 + M12Mix8Central 6 + M12Mix8Central 7 + M12Mix8Central 8 + M12Mix8Central 9 + M12Mix8Central 10 + M12Mix8Central 11 + M12Mix8Central 12 + M12Mix8Central 13 + M12Mix8Central 14 + M12Mix8Central 15 + + Add SI, 32 + Dec LoopCounter + JNZ M12Mix8Central0 + + Ret + +EndP Mix12Central8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central8Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Central8BitVolume], AL + + Ret + +EndP PreMix12Central8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central16BitOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16CentralOffset Macro Index + DW Offset M12Mix16Central&Index& + EndM + + REPT 16 + M12Mix16CentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central16Bit + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central16BitOffsetTable+BX] + +M12Central16BitVolume EQU $+3 + Mov EBX, 0 ; Set BH = volume + + + RetN + + M12Mix16Central 0 + M12Mix16Central 1 + M12Mix16Central 2 + M12Mix16Central 3 + M12Mix16Central 4 + M12Mix16Central 5 + M12Mix16Central 6 + M12Mix16Central 7 + M12Mix16Central 8 + M12Mix16Central 9 + M12Mix16Central 10 + M12Mix16Central 11 + M12Mix16Central 12 + M12Mix16Central 13 + M12Mix16Central 14 + M12Mix16Central 15 + + Add SI, 32 + Dec LoopCounter + JNZ M12Mix16Central0 + + Ret + +EndP Mix12Central16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central16Bit + + Mov AL, [SI+0Eh] + Mov Byte Ptr [CS:M12Central16BitVolume], AL + + Ret + +EndP PreMix12Central16Bit + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/MONO12BI.INC b/SoundDrivers/MONO12BI.INC index 4ad266f..c417d5c 100755 --- a/SoundDrivers/MONO12BI.INC +++ b/SoundDrivers/MONO12BI.INC @@ -1,17 +1,17 @@ - - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Central - DW Offset MixNoLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI - DW Offset MixForwardsLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI - DW Offset MixPingPongLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI - - ; 16 bit tables - DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - ; Central - DW Offset MixNoLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI - DW Offset MixForwardsLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI - DW Offset MixPingPongLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI + + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Central + DW Offset MixNoLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI + DW Offset MixForwardsLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI + DW Offset MixPingPongLoop, PreMix12Central8BitI, MFS8Bit, MBS8Bit, Mix12Central8BitI + + ; 16 bit tables + DW Offset UpdateNoLoop, 0, 0, 0, 0 ; Update only + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + ; Central + DW Offset MixNoLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI + DW Offset MixForwardsLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI + DW Offset MixPingPongLoop, PreMix12Central16BitI, MFS16Bit, MBS16Bit, Mix12Central16BitI diff --git a/SoundDrivers/MONO12BI.MIX b/SoundDrivers/MONO12BI.MIX index eb01312..186062a 100755 --- a/SoundDrivers/MONO12BI.MIX +++ b/SoundDrivers/MONO12BI.MIX @@ -1,242 +1,242 @@ - -ERROR EQU CX -DELTAERROR EQU BP -DELTAOFFSET EQU DX -HIGHERROR EQU CH - - ; Different mixing routines required: - ; Left } shared - ; Right } - ; Central - ; Surround - ; Panned ; Each requires 8 bit and 16 bit - ; Single output - for Mono, pure left/pure right - - ; Interpolation = [DI+1]*Error + [DI]*(1-Error) - ; = [DI+1]*Error + [DI] - [DI]*Error - ; = Error*([DI+1]-[DI]) + [DI] - - -M12Mix8ICentral Macro Index - -M12Mix8ICentral&Index&: - Mov AX, [ES:DI] - Mov BL, AL - SAR AL, 1 - SAR AH, 1 - Sub AH, AL - Mov AL, CH - ShR AL, 1 - IMul AH - SHL AX, 2 - Add BL, AH - -M12Mix8ICentralVolume&Index& EQU $+1 - Mov BH, 12h - - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*2], AX - -EndM - -M12Mix16ICentral Macro Index - -M12Mix16ICentral&Index&: - Mov BX, [ES:EDI+EDI] - Mov AH, [ES:EDI+EDI+3] - Mov BL, BH - SAR AH, 1 - SAR BH, 1 - Sub AH, BH - Mov AL, CH - ShR AL, 1 - IMul AH - SHL AX, 2 - Add BL, AH - -M12Mix16ICentralVolume&Index& EQU $+1 - Mov BH, 12h - - Add ERROR, DELTAERROR ;; 1 - Mov AX, [EBX+EBX] - AdC DI, DELTAOFFSET ;; 1 - Sub [SI+(Index-15)*2], AX - -EndM - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central8BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix8ICentralOffset Macro Index - DW Offset M12Mix8ICentral&Index& - EndM - - REPT 16 - M12Mix8ICentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central8BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central8BitIOffsetTable+BX] - - Xor EBX, EBX - - RetN - - M12Mix8ICentral 0 - M12Mix8ICentral 1 - M12Mix8ICentral 2 - M12Mix8ICentral 3 - M12Mix8ICentral 4 - M12Mix8ICentral 5 - M12Mix8ICentral 6 - M12Mix8ICentral 7 - M12Mix8ICentral 8 - M12Mix8ICentral 9 - M12Mix8ICentral 10 - M12Mix8ICentral 11 - M12Mix8ICentral 12 - M12Mix8ICentral 13 - M12Mix8ICentral 14 - M12Mix8ICentral 15 - - Add SI, 32 - Dec LoopCounter - JNZ M12Mix8ICentral0 - - Ret - -EndP Mix12Central8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central8BitI - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12Central8BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix8ICentralVolume&Index&], AL - EndM - - REPT 16 - PreMix12Central8BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - -EndP PreMix12Central8BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Mix12Central16BitIOffsetTable Label Word - - IndexCounter = 15 - - M12Mix16ICentralOffset Macro Index - DW Offset M12Mix16ICentral&Index& - EndM - - REPT 16 - M12Mix16ICentralOffset %IndexCounter - IndexCounter = IndexCounter-1 - EndM - -Proc Mix12Central16BitI - - Dec AX - Mov BX, AX - And AX, 0Fh - ShR BX, 4 - Add AX, AX - Inc BX - Mov LoopCounter, BX - Mov BX, AX - - ShL AX, RESOLUTIONSHIFT-1 - - Add SI, AX - - Push [CS:Mix12Central16BitIOffsetTable+BX] - - Xor EBX, EBX - - - RetN - - M12Mix16ICentral 0 - M12Mix16ICentral 1 - M12Mix16ICentral 2 - M12Mix16ICentral 3 - M12Mix16ICentral 4 - M12Mix16ICentral 5 - M12Mix16ICentral 6 - M12Mix16ICentral 7 - M12Mix16ICentral 8 - M12Mix16ICentral 9 - M12Mix16ICentral 10 - M12Mix16ICentral 11 - M12Mix16ICentral 12 - M12Mix16ICentral 13 - M12Mix16ICentral 14 - M12Mix16ICentral 15 - - Add SI, 32 - Dec LoopCounter - JNZ M12Mix16ICentral0 - - Ret - -EndP Mix12Central16BitI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreMix12Central16BitI - - Mov AL, [SI+0Eh] - - IndexCounter = 0 - - PreMix12Central16BitIMacro Macro Index - Mov Byte Ptr [CS:M12Mix16ICentralVolume&Index&], AL - EndM - - REPT 16 - PreMix12Central16BitIMacro %IndexCounter - IndexCounter = IndexCounter+1 - EndM - - Ret - - - Ret - -EndP PreMix12Central16BitI - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - + +ERROR EQU CX +DELTAERROR EQU BP +DELTAOFFSET EQU DX +HIGHERROR EQU CH + + ; Different mixing routines required: + ; Left } shared + ; Right } + ; Central + ; Surround + ; Panned ; Each requires 8 bit and 16 bit + ; Single output - for Mono, pure left/pure right + + ; Interpolation = [DI+1]*Error + [DI]*(1-Error) + ; = [DI+1]*Error + [DI] - [DI]*Error + ; = Error*([DI+1]-[DI]) + [DI] + + +M12Mix8ICentral Macro Index + +M12Mix8ICentral&Index&: + Mov AX, [ES:DI] + Mov BL, AL + SAR AL, 1 + SAR AH, 1 + Sub AH, AL + Mov AL, CH + ShR AL, 1 + IMul AH + SHL AX, 2 + Add BL, AH + +M12Mix8ICentralVolume&Index& EQU $+1 + Mov BH, 12h + + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*2], AX + +EndM + +M12Mix16ICentral Macro Index + +M12Mix16ICentral&Index&: + Mov BX, [ES:EDI+EDI] + Mov AH, [ES:EDI+EDI+3] + Mov BL, BH + SAR AH, 1 + SAR BH, 1 + Sub AH, BH + Mov AL, CH + ShR AL, 1 + IMul AH + SHL AX, 2 + Add BL, AH + +M12Mix16ICentralVolume&Index& EQU $+1 + Mov BH, 12h + + Add ERROR, DELTAERROR ;; 1 + Mov AX, [EBX+EBX] + AdC DI, DELTAOFFSET ;; 1 + Sub [SI+(Index-15)*2], AX + +EndM + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central8BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix8ICentralOffset Macro Index + DW Offset M12Mix8ICentral&Index& + EndM + + REPT 16 + M12Mix8ICentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central8BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central8BitIOffsetTable+BX] + + Xor EBX, EBX + + RetN + + M12Mix8ICentral 0 + M12Mix8ICentral 1 + M12Mix8ICentral 2 + M12Mix8ICentral 3 + M12Mix8ICentral 4 + M12Mix8ICentral 5 + M12Mix8ICentral 6 + M12Mix8ICentral 7 + M12Mix8ICentral 8 + M12Mix8ICentral 9 + M12Mix8ICentral 10 + M12Mix8ICentral 11 + M12Mix8ICentral 12 + M12Mix8ICentral 13 + M12Mix8ICentral 14 + M12Mix8ICentral 15 + + Add SI, 32 + Dec LoopCounter + JNZ M12Mix8ICentral0 + + Ret + +EndP Mix12Central8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central8BitI + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12Central8BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix8ICentralVolume&Index&], AL + EndM + + REPT 16 + PreMix12Central8BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + +EndP PreMix12Central8BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Mix12Central16BitIOffsetTable Label Word + + IndexCounter = 15 + + M12Mix16ICentralOffset Macro Index + DW Offset M12Mix16ICentral&Index& + EndM + + REPT 16 + M12Mix16ICentralOffset %IndexCounter + IndexCounter = IndexCounter-1 + EndM + +Proc Mix12Central16BitI + + Dec AX + Mov BX, AX + And AX, 0Fh + ShR BX, 4 + Add AX, AX + Inc BX + Mov LoopCounter, BX + Mov BX, AX + + ShL AX, RESOLUTIONSHIFT-1 + + Add SI, AX + + Push [CS:Mix12Central16BitIOffsetTable+BX] + + Xor EBX, EBX + + + RetN + + M12Mix16ICentral 0 + M12Mix16ICentral 1 + M12Mix16ICentral 2 + M12Mix16ICentral 3 + M12Mix16ICentral 4 + M12Mix16ICentral 5 + M12Mix16ICentral 6 + M12Mix16ICentral 7 + M12Mix16ICentral 8 + M12Mix16ICentral 9 + M12Mix16ICentral 10 + M12Mix16ICentral 11 + M12Mix16ICentral 12 + M12Mix16ICentral 13 + M12Mix16ICentral 14 + M12Mix16ICentral 15 + + Add SI, 32 + Dec LoopCounter + JNZ M12Mix16ICentral0 + + Ret + +EndP Mix12Central16BitI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreMix12Central16BitI + + Mov AL, [SI+0Eh] + + IndexCounter = 0 + + PreMix12Central16BitIMacro Macro Index + Mov Byte Ptr [CS:M12Mix16ICentralVolume&Index&], AL + EndM + + REPT 16 + PreMix12Central16BitIMacro %IndexCounter + IndexCounter = IndexCounter+1 + EndM + + Ret + + + Ret + +EndP PreMix12Central16BitI + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/MPAS.BAT b/SoundDrivers/MPAS.BAT index 042d7cc..c5cd0ef 100755 --- a/SoundDrivers/MPAS.BAT +++ b/SoundDrivers/MPAS.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 pasdrv -tlink /3 pasdrv -execom pasdrv itpas.drv -copy itpas.drv .. +tasm /m /ut310 pasdrv +tlink /3 pasdrv +execom pasdrv itpas.drv +copy itpas.drv .. diff --git a/SoundDrivers/MPAS16.BAT b/SoundDrivers/MPAS16.BAT index 5ca635d..607787a 100755 --- a/SoundDrivers/MPAS16.BAT +++ b/SoundDrivers/MPAS16.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 pas16drv -tlink /3 pas16drv -execom pas16drv itpas16.drv -copy itpas16.drv .. +tasm /m /ut310 pas16drv +tlink /3 pas16drv +execom pas16drv itpas16.drv +copy itpas16.drv .. diff --git a/SoundDrivers/MPC.BAT b/SoundDrivers/MPC.BAT index 20b3a4a..9235055 100755 --- a/SoundDrivers/MPC.BAT +++ b/SoundDrivers/MPC.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 pcspkdrv -tlink /3 pcspkdrv -execom pcspkdrv itpcspkr.drv -copy itpcspkr.drv .. +tasm /m /ut310 pcspkdrv +tlink /3 pcspkdrv +execom pcspkdrv itpcspkr.drv +copy itpcspkr.drv .. diff --git a/SoundDrivers/MSAM.BAT b/SoundDrivers/MSAM.BAT index cf35dec..7a14e7c 100755 --- a/SoundDrivers/MSAM.BAT +++ b/SoundDrivers/MSAM.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 sam9407 -tlink /3 sam9407 -execom sam9407 it9407.drv -copy it9407.drv .. - +tasm /m /ut310 sam9407 +tlink /3 sam9407 +execom sam9407 it9407.drv +copy it9407.drv .. + diff --git a/SoundDrivers/MSB.BAT b/SoundDrivers/MSB.BAT index 85d9c8b..37856eb 100755 --- a/SoundDrivers/MSB.BAT +++ b/SoundDrivers/MSB.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 sbdrv -tlink /3 sbdrv -execom sbdrv itsb.drv -copy itsb.drv .. +tasm /m /ut310 sbdrv +tlink /3 sbdrv +execom sbdrv itsb.drv +copy itsb.drv .. diff --git a/SoundDrivers/MSB16.BAT b/SoundDrivers/MSB16.BAT index f99b353..7ceacee 100755 --- a/SoundDrivers/MSB16.BAT +++ b/SoundDrivers/MSB16.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 sb16drv -tlink /3 sb16drv -execom sb16drv itsb16.drv -copy itsb16.drv .. - +tasm /m /ut310 sb16drv +tlink /3 sb16drv +execom sb16drv itsb16.drv +copy itsb16.drv .. + diff --git a/SoundDrivers/MSB16A.BAT b/SoundDrivers/MSB16A.BAT index e503e5d..0399043 100755 --- a/SoundDrivers/MSB16A.BAT +++ b/SoundDrivers/MSB16A.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 sb16k6 -tlink /3 sb16k6 -execom sb16k6 itsb16.3dn -copy itsb16.3dn .. - +tasm32 /m /ut310 sb16k6 +tlink /3 sb16k6 +execom sb16k6 itsb16.3dn +copy itsb16.3dn .. + diff --git a/SoundDrivers/MSB16B.BAT b/SoundDrivers/MSB16B.BAT index fc14dda..9eb138e 100755 --- a/SoundDrivers/MSB16B.BAT +++ b/SoundDrivers/MSB16B.BAT @@ -1,4 +1,4 @@ -tasm /m /uT310 sb16b -tlink /3 sb16b -execom sb16b itsb16b.drv -copy itsb16b.drv .. +tasm /m /uT310 sb16b +tlink /3 sb16b +execom sb16b itsb16b.drv +copy itsb16b.drv .. diff --git a/SoundDrivers/MSB16C.BAT b/SoundDrivers/MSB16C.BAT index 9285cb4..bacdde9 100755 --- a/SoundDrivers/MSB16C.BAT +++ b/SoundDrivers/MSB16C.BAT @@ -1,4 +1,4 @@ -tasm /m /uT310 sb16c -tlink /3 sb16c -execom sb16c itsb16c.drv -copy itsb16c.drv .. +tasm /m /uT310 sb16c +tlink /3 sb16c +execom sb16c itsb16c.drv +copy itsb16c.drv .. diff --git a/SoundDrivers/MSB16D.BAT b/SoundDrivers/MSB16D.BAT index 4f3ad2e..848a37b 100755 --- a/SoundDrivers/MSB16D.BAT +++ b/SoundDrivers/MSB16D.BAT @@ -1,4 +1,4 @@ -tasm /m /uT310 sb16d -tlink /3 sb16d -execom sb16d itsb16d.drv -copy itsb16d.drv .. +tasm /m /uT310 sb16d +tlink /3 sb16d +execom sb16d itsb16d.drv +copy itsb16d.drv .. diff --git a/SoundDrivers/MSB16M.BAT b/SoundDrivers/MSB16M.BAT index e2923f3..1380d53 100755 --- a/SoundDrivers/MSB16M.BAT +++ b/SoundDrivers/MSB16M.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 sb16mmx -tlink /3 sb16mmx -execom sb16mmx itsb16.mmx -copy itsb16.mmx .. - +tasm32 /m /ut310 sb16mmx +tlink /3 sb16mmx +execom sb16mmx itsb16.mmx +copy itsb16.mmx .. + diff --git a/SoundDrivers/MSB16MB.BAT b/SoundDrivers/MSB16MB.BAT index 0839be9..7f2c315 100755 --- a/SoundDrivers/MSB16MB.BAT +++ b/SoundDrivers/MSB16MB.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 sb16mmxb -tlink /3 sb16mmxb -execom sb16mmxb itsb16b.mmx -copy itsb16b.mmx .. - +tasm32 /m /ut310 sb16mmxb +tlink /3 sb16mmxb +execom sb16mmxb itsb16b.mmx +copy itsb16b.mmx .. + diff --git a/SoundDrivers/MSB2.BAT b/SoundDrivers/MSB2.BAT index 65f8c0f..ce78087 100755 --- a/SoundDrivers/MSB2.BAT +++ b/SoundDrivers/MSB2.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 sb2drv -tlink /3 sb2drv -execom sb2drv itsb2.drv -copy itsb2.drv .. +tasm /m /ut310 sb2drv +tlink /3 sb2drv +execom sb2drv itsb2.drv +copy itsb2.drv .. diff --git a/SoundDrivers/MSBPRO.BAT b/SoundDrivers/MSBPRO.BAT index 88bd0d6..f9f8415 100755 --- a/SoundDrivers/MSBPRO.BAT +++ b/SoundDrivers/MSBPRO.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 sbprodrv -tlink /3 sbprodrv -execom sbprodrv itsbpro.drv -copy itsbpro.drv .. +tasm /m /ut310 sbprodrv +tlink /3 sbprodrv +execom sbprodrv itsbpro.drv +copy itsbpro.drv .. diff --git a/SoundDrivers/MST97.BAT b/SoundDrivers/MST97.BAT index b2fd60a..9ef1cd6 100755 --- a/SoundDrivers/MST97.BAT +++ b/SoundDrivers/MST97.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 st97 -tlink /3 st97 -execom st97 itst97.drv -copy itst97.drv .. +tasm /m /ut310 st97 +tlink /3 st97 +execom st97 itst97.drv +copy itst97.drv .. diff --git a/SoundDrivers/MSTC.BAT b/SoundDrivers/MSTC.BAT index fe8212e..7362b53 100755 --- a/SoundDrivers/MSTC.BAT +++ b/SoundDrivers/MSTC.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 st97code -tlink /3 st97code -execom st97code itstcode.drv -copy itstcode.drv .. - +tasm /m /ut310 st97code +tlink /3 st97code +execom st97code itstcode.drv +copy itstcode.drv .. + diff --git a/SoundDrivers/MSTCM.BAT b/SoundDrivers/MSTCM.BAT index 62f7644..4df5782 100755 --- a/SoundDrivers/MSTCM.BAT +++ b/SoundDrivers/MSTCM.BAT @@ -1,4 +1,4 @@ -tasm32 /m /la /ut310 st97cmmx -tlink /3 st97cmmx -execom st97cmmx itstcode.mmx -copy itstcode.mmx .. +tasm32 /m /la /ut310 st97cmmx +tlink /3 st97cmmx +execom st97cmmx itstcode.mmx +copy itstcode.mmx .. diff --git a/SoundDrivers/MSTP.BAT b/SoundDrivers/MSTP.BAT index 23bbdca..cdb0c6e 100755 --- a/SoundDrivers/MSTP.BAT +++ b/SoundDrivers/MSTP.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 st97pnp -tlink /3 st97pnp -execom st97pnp itstpnp.drv -copy itstpnp.drv .. - +tasm /m /ut310 st97pnp +tlink /3 st97pnp +execom st97pnp itstpnp.drv +copy itstpnp.drv .. + diff --git a/SoundDrivers/MT.BAT b/SoundDrivers/MT.BAT index e4c4fd6..c3051a2 100755 --- a/SoundDrivers/MT.BAT +++ b/SoundDrivers/MT.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 test -tlink /3 test -execom test ittest.drv -copy ittest.drv .. - +tasm /m /ut310 test +tlink /3 test +execom test ittest.drv +copy ittest.drv .. + diff --git a/SoundDrivers/MV.BAT b/SoundDrivers/MV.BAT index 38807c4..01d9684 100755 --- a/SoundDrivers/MV.BAT +++ b/SoundDrivers/MV.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 /la vsnd -tlink /3 vsnd -execom vsnd itvsound.drv -copy itvsound.drv .. - +tasm32 /m /ut310 /la vsnd +tlink /3 vsnd +execom vsnd itvsound.drv +copy itvsound.drv .. + diff --git a/SoundDrivers/MVIVO.BAT b/SoundDrivers/MVIVO.BAT index 9394270..895e414 100755 --- a/SoundDrivers/MVIVO.BAT +++ b/SoundDrivers/MVIVO.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 envivo -tlink /3 envivo -execom envivo itvivo.drv -copy itvivo.drv .. - +tasm /m /ut310 envivo +tlink /3 envivo +execom envivo itvivo.drv +copy itvivo.drv .. + diff --git a/SoundDrivers/MVM.BAT b/SoundDrivers/MVM.BAT index dd16587..a07d49e 100755 --- a/SoundDrivers/MVM.BAT +++ b/SoundDrivers/MVM.BAT @@ -1,5 +1,5 @@ -tasm32 /m /ut310 /la vsndmmx -tlink /3 /m vsndmmx -execom vsndmmx itvsound.mmx -copy itvsound.mmx .. - +tasm32 /m /ut310 /la vsndmmx +tlink /3 /m vsndmmx +execom vsndmmx itvsound.mmx +copy itvsound.mmx .. + diff --git a/SoundDrivers/MWAV.BAT b/SoundDrivers/MWAV.BAT index d0210dc..f37b9e3 100755 --- a/SoundDrivers/MWAV.BAT +++ b/SoundDrivers/MWAV.BAT @@ -1,4 +1,4 @@ -tasm /m /ut310 wavdrv -tlink /3 wavdrv -execom wavdrv itwav.drv -call mmid +tasm /m /ut310 wavdrv +tlink /3 wavdrv +execom wavdrv itwav.drv +call mmid diff --git a/SoundDrivers/MWSS.BAT b/SoundDrivers/MWSS.BAT index 11d267d..8466a24 100755 --- a/SoundDrivers/MWSS.BAT +++ b/SoundDrivers/MWSS.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 wssdrv -tlink /3 wssdrv -execom wssdrv itwss.drv -copy itwss.drv .. - +tasm /m /ut310 wssdrv +tlink /3 wssdrv +execom wssdrv itwss.drv +copy itwss.drv .. + diff --git a/SoundDrivers/MWSS2.BAT b/SoundDrivers/MWSS2.BAT index fef0fa1..021b56c 100755 --- a/SoundDrivers/MWSS2.BAT +++ b/SoundDrivers/MWSS2.BAT @@ -1,5 +1,5 @@ -tasm /m /ut310 wssdrv2 -tlink /3 wssdrv2 -execom wssdrv2 itwss2.drv -copy itwss2.drv .. - +tasm /m /ut310 wssdrv2 +tlink /3 wssdrv2 +execom wssdrv2 itwss2.drv +copy itwss2.drv .. + diff --git a/SoundDrivers/NODEBUG.INC b/SoundDrivers/NODEBUG.INC index f7ad96f..fd822f4 100755 --- a/SoundDrivers/NODEBUG.INC +++ b/SoundDrivers/NODEBUG.INC @@ -1,7 +1,7 @@ -; -; Dummy trace commands -; - - -Trace Macro LogMessage - EndM +; +; Dummy trace commands +; + + +Trace Macro LogMessage + EndM diff --git a/SoundDrivers/NOISE.ASM b/SoundDrivers/NOISE.ASM index ed80341..e166938 100755 --- a/SoundDrivers/NOISE.ASM +++ b/SoundDrivers/NOISE.ASM @@ -1,2091 +1,2091 @@ -; -; Windows Sound System Driver -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -DMASize DW 2048 - -WSSMsg DB "Using Noise Source Codec", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Using Noise Source Codec", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Noise Source reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITNOISE.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITNOISE.DRV", 0 - -DriverName DB "ITNOISE.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "Noise Source Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 29, 48 - DB 21h - DB "Noise Source Codec Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 16 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Inc DX - Inc DX - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Cmp IRQ, 0FFFFh - JE DetectWSSFailure - Cmp DMA, 0FFFFh - JE DetectWSSFailure - - Mov DX, BasePort - Cmp DX, 0FFFFh - JE DetectCardFindBasePort - - Call PingWSS - JNC CheckWSSOK - -DetectWSSFailure: - StC - Ret - -DetectCardFindBasePort: - Mov DX, 31Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 32Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 33Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 34Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 35Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 36Ch - Call PingWSS - JNC DetectWSSOK - - Mov DX, 530h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 604h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0F40h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0E80h - Call PingWSS - JC DetectWSSFailure - -DetectWSSOK: - Mov BasePort, DX - -CheckWSSOK: ; Check for IRQ - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 2 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB WSSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -WSSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +DMASize DW 2048 + +WSSMsg DB "Using Noise Source Codec", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Using Noise Source Codec", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Noise Source reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITNOISE.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITNOISE.DRV", 0 + +DriverName DB "ITNOISE.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "Noise Source Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 29, 48 + DB 21h + DB "Noise Source Codec Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 16 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Inc DX + Inc DX + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Cmp IRQ, 0FFFFh + JE DetectWSSFailure + Cmp DMA, 0FFFFh + JE DetectWSSFailure + + Mov DX, BasePort + Cmp DX, 0FFFFh + JE DetectCardFindBasePort + + Call PingWSS + JNC CheckWSSOK + +DetectWSSFailure: + StC + Ret + +DetectCardFindBasePort: + Mov DX, 31Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 32Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 33Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 34Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 35Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 36Ch + Call PingWSS + JNC DetectWSSOK + + Mov DX, 530h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 604h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0F40h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0E80h + Call PingWSS + JC DetectWSSFailure + +DetectWSSOK: + Mov BasePort, DX + +CheckWSSOK: ; Check for IRQ + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 2 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB WSSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +WSSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/PAS16DRV.ASM b/SoundDrivers/PAS16DRV.ASM index 8a72ec4..e84ad44 100755 --- a/SoundDrivers/PAS16DRV.ASM +++ b/SoundDrivers/PAS16DRV.ASM @@ -1,1986 +1,1986 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for the PAS16 -MIXTABLESIZE EQU 2*256*65 -TIMERCONST EQU 11932 - -Debug1 DB 0 -Debug2 DW 0 - -PAS16Msg DB "Pro Audio 16 Spectrum found", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -PAS16NoMemoryMsg DB "Pro Audio 16 Spectrum found", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Pro Audio 16 Spectrum reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITPAS16.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITPAS16.DRV", 0 - -DriverName DB "ITPAS16.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -MixSpeed DW 44100 -PASMixConst DW 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 -TimerAccumulator DW 0 - -DMALengthTable Label Byte - DB 1, 3, 5, 7, 0C2h, 0C6h, 0CAh, 0CEh - -;********************************** - -PAS16ScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr PAS16HeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW 0 - -PAS16HeaderLine DW 10 - DB "Pro Audio Spectrum 16 Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 26, 48 - DB 21h - DB "Pro Audio Spectrum 16 Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MixModeText DW 1 - DB 2, 13 - DB 20h - DB "Mixing Mode", 0 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 15, 32, 17, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 18, 32, 20, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 21, 32, 23, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 24, 32, 26, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 28 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 30, 29, 32, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 33, 29, 35, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 36, 29, 38, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 6 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixSpeed - Assume DS:Driver - - Push AX - Push CX - Push DX - - Mov DX, 12h - Mov AX, 34DCh - Mov CX, PASMixConst - Cmp CS:Stereo, 0 - JE GetMixSpeed1 - - And CX, Not 1 - -GetMixSpeed1: - Div CX - -GetMixSpeed2: - Mov MixSpeed, AX - - Pop DX - Pop CX - Pop AX - Ret - -EndP GetMixSpeed - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetPASMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetPASMixConst1 - - Mov CX, 44100 - Cmp AX, CX - JA GetPASMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetPASMixConst1 - - Mov CX, AX - -GetPASMixConst1: - Mov MixSpeed, CX - - Mov DX, 012h - Mov AX, 34DCh - Div CX - - Mov PASMixConst, AX - Mov BX, AX - - Pop DS - PopA - Ret - -EndP GetPASMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TestPAS ; AX = port - - Push AX - - Mov DX, 803h ; Default is 0B8Bh - Xor DX, AX ; DX = Interrupt Control port - In AL, DX - - Cmp AL, 0FFh - JE TestPAS1 - - Mov AH, AL - Xor AL, 11100000b - Out DX, AL - - Jmp $+2 - Jmp $+2 - In AL, DX - - Cmp AL, AH - XChg AH, AL - Out DX, AL - JNE TestPAS1 - - Pop AX - Push AX - - Mov DX, AX ; PAS 16? - Xor DX, 0EF8Bh xor 388h - In AL, DX - Test AL, 8 - JZ TestPAS1 - - Pop AX - - ClC - Ret - -TestPAS1: - Pop AX - StC - Ret - -EndP TestPAS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 0BC00h - Mov BX, '??' - Xor CX, CX - Xor DX, DX - Int 2Fh - - Xor BX, CX - Xor BX, DX - Cmp BX, 'M'*256+'V' - JE DetectPAS4 ; MVSound.Sys installed! - -DetectPAS7: - StC - Ret - -DetectPAS4: - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectPAS1 - Cmp AX, 388h - JE DetectPAS6 - Cmp AX, 384h - JE DetectPAS6 - Cmp AX, 38Ch - JE DetectPAS6 - Cmp AX, 288h - JNE DetectPAS7 - -DetectPAS6: - Call TestPAS - JNC DetectPAS2 - - Ret - -DetectPAS1: - Mov AX, 388h - Call TestPAS - JNC DetectPAS2 - - Mov AX, 384h - Call TestPAS - JNC DetectPAS2 - - Mov AX, 38Ch - Call TestPAS - JNC DetectPAS2 - - Mov AX, 288h - Call TestPAS - JNC DetectPAS2 - - Ret ; No card! - -DetectPAS2: - Push AX - - Mov AX, 0BC04h - Int 2Fh - - Cmp AX, 'M'*256+'V' - JNE DetectPAS3 - - Pop AX - - Mov BasePort, AX - Mov DMA, BX - Mov IRQ, CX - - Mov AL, [DMALengthTable+BX] - Mov Byte Ptr [DMAPort1], AL - Mov Byte Ptr [DMAPort2], AL - - Mov AX, DMABUFFERLENGTH/2 - Cmp BX, 4 - JB DetectPAS5 - - ShR AX, 1 - -DetectPAS5: - Mov Word Ptr [DMABufferLength1], AX - Mov Word Ptr [DMABufferLength2], AX - - Mov EAX, 'Jeff' - ClC - Ret - -DetectPAS3: - Pop AX - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PAS16IRQHandler - - Push AX - Push BX - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Add TimerAccumulator, TIMERCONST - JC PAS16IRQHandler11 - - Mov AL, 20h - Out 20h, AL - Jmp PAS16IRQHandler12 - -PAS16IRQHandler11: - PushF - Call [OldIRQHandler] - -PAS16IRQHandler12: - -DMAPort1 EQU $+1 - In AL, 1 - Mov AH, AL -DMAPort2 EQU $+1 - In AL, 1 - XChg AL, AH - - Mov Debug2, AX - - Cmp MixBufferPos, 0 - JE PAS16IRQHandler13 - - Xor BX, BX -DMABufferLength1 EQU $+1 - Cmp AX, 1234h - JB PAS16IRQHandler1 - - Pop DS - Pop BX - Pop AX - IRet - -PAS16IRQHandler13: - Mov BX, DMABUFFERLENGTH/2 -DMABufferLength2 EQU $+1 - Cmp AX, 1234h - JAE PAS16IRQHandler1 - - Pop DS - Pop BX - Pop AX - IRet - -PAS16IRQHandler1: - Xor MixBufferPos, 1 - - PushAD - Push ES - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, BX - - Mov BX, DMABUFFERLENGTH/4 ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE PAS16IRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -PAS16IRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE PAS16IRQHandler4 - Assume DS:Nothing - -PAS16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -PAS16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE PAS16IRQHandler5 - - Mov DX, MixTransferRemaining - -PAS16IRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB PAS16IRQHandler6 - JE PAS16IRQHFilter - - Cmp CS:Stereo, 0 - JE PAS16IRQ3QFilterMono - -PAS16IRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -PAS16IRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL PAS163QFilterStereoClip1 - Cmp EAX, 7FFFh - JG PAS163QFilterStereoClip2 - -PAS16IRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL PAS163QFilterStereoClip3 - Cmp EAX, 7FFFh - JG PAS163QFilterStereoClip4 - -PAS16IRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ PAS16IRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp PAS16MixTransferEnd - -PAS16IRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -PAS16IRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL PAS163QFilterMonoClip1 - Cmp EAX, 7FFFh - JG PAS163QFilterMonoClip2 - -PAS16IRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ PAS16IRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp PAS16MixTransferEnd - -PAS16IRQHFilter: - Cmp CS:Stereo, 0 - JE PAS16IRQHFilterMono - -PAS16IRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -PAS16IRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL PAS16HFilterStereoClip1 - Cmp EAX, 7FFFh - JG PAS16HFilterStereoClip2 - -PAS16IRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL PAS16HFilterStereoClip3 - Cmp EAX, 7FFFh - JG PAS16HFilterStereoClip4 - -PAS16IRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ PAS16IRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp PAS16MixTransferEnd - -PAS16IRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -PAS16IRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL PAS16HFilterMonoClip1 - Cmp EAX, 7FFFh - JG PAS16HFilterMonoClip2 - -PAS16IRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ PAS16IRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp PAS16MixTransferEnd - -PAS16IRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL PAS16IRQHandlerClip1 - Cmp EAX, 7FFFh - JG PAS16IRQHandlerClip2 - -PAS16IRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ PAS16IRQHandler6 - -PAS16MixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ PAS16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - PopAD - Pop DS - Pop BX - Pop AX - IRet - -PAS16IRQHandlerClip1: - Mov AX, 8000h - Jmp PAS16IRQHandler7 - -PAS16IRQHandlerClip2: - Mov AX, 7FFFh - Jmp PAS16IRQHandler7 - -PAS16HFilterMonoClip1: - Mov AX, 8000h - Jmp PAS16IRQHFilterMono2 - -PAS16HFilterMonoClip2: - Mov AX, 7FFFh - Jmp PAS16IRQHFilterMono2 - -PAS16HFilterStereoClip1: - Mov AX, 8000h - Jmp PAS16IRQHFilterStereo2 - -PAS16HFilterStereoClip2: - Mov AX, 7FFFh - Jmp PAS16IRQHFilterStereo2 - -PAS16HFilterStereoClip3: - Mov AX, 8000h - Jmp PAS16IRQHFilterStereo3 - -PAS16HFilterStereoClip4: - Mov AX, 7FFFh - Jmp PAS16IRQHFilterStereo3 - -PAS163QFilterMonoClip1: - Mov AX, 8000h - Jmp PAS16IRQ3QFilterMono2 - -PAS163QFilterMonoClip2: - Mov AX, 7FFFh - Jmp PAS16IRQ3QFilterMono2 - -PAS163QFilterStereoClip1: - Mov AX, 8000h - Jmp PAS16IRQ3QFilterStereo2 - -PAS163QFilterStereoClip2: - Mov AX, 7FFFh - Jmp PAS16IRQ3QFilterStereo2 - -PAS163QFilterStereoClip3: - Mov AX, 8000h - Jmp PAS16IRQ3QFilterStereo3 - -PAS163QFilterStereoClip4: - Mov AX, 7FFFh - Jmp PAS16IRQ3QFilterStereo3 - -EndP PAS16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - Push EAX - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - ; bump the interrupt to be called - ; 100 times a second. - Mov AX, TIMERCONST - Out 40h, AL - Mov AL, AH - Out 40h, AL - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset PAS16IRQHandler - - ClI - - XChg [ES:20h], EAX ; Hook to timer interrupt - Mov CS:OldIRQHandler, EAX - - StI - - Pop ES - Pop EAX - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - Push EAX - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Xor AL, AL - Out 40h, AL ; Interrupt called at normal 18.2 times - Out 40h, AL - - Mov EAX, CS:OldIRQHandler - Mov [ES:20h], EAX - - Pop ES - Pop EAX - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopPAS16 - - Mov DX, BasePort - Xor AL, AL - Xor DX, 0B89h xor 388h ; Interrupt Status register - Out DX, AL - - Mov DX, BasePort ; Audio filter control - Mov AL, 1 - Xor DX, 0B8Ah xor 388h ; Disable buffer counter - Out DX, AL ; and PAS 16 output - - Mov DX, BasePort - Xor DX, 8389h xor 388h ; SysConfig2 - In AL, DX ; Get SysConfig2 - And AL, Not 4 ; Reset 8 bits - Out DX, AL - - Mov DX, BasePort - Mov AL, 19h ; Mono, L2L, R2R - Xor DX, 0F8Ah xor 388h ; Cross channel register - Out DX, AL - - Ret - -EndP StopPAS16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartPAS16 ; - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Xor AL, AL - Xor DX, 0B89h xor 388h ; Interrupt Status register - Out DX, AL - - Mov DX, BasePort ; Audio filter control - Mov AL, 1 - Xor DX, 0B8Ah xor 388h ; Disable buffer counter - Out DX, AL ; and PAS 16 output - - Mov DX, BasePort - Mov AL, 19h - Xor DX, 0F8Ah xor 388h ; Cross channel register - Out DX, AL - - Mov DX, BasePort - Xor DX, 138Bh xor 388h ; Timer control, - Mov AL, 00110110b ; 36h - set frequency - Out DX, AL - - Mov DX, BasePort - Xor DX, 1388h xor 388h - Mov AX, PASMixConst - Cmp Stereo, 0 - JE StartPAS16_2 - - ShR AX, 1 - -StartPAS16_2: - Out DX, AL - Mov AL, AH - Out DX, AL - - Call GetMixSpeed - Call GetTempo - Call SetTempo - - Mov DX, BasePort - Xor DX, 138Bh xor 388h ; Timer control - Mov AL, 01110100b ; 74h - set buffer count - Out DX, AL - - Mov DX, BasePort ; Sample count - Mov AX, DMABUFFERLENGTH - Xor DX, 1389h xor 388h - - Cmp DMA, 4 - JB StartPAS16_1 - - ShR AX, 1 - -StartPAS16_1: - Out DX, AL - Mov AL, AH - Out DX, AL - - Mov DX, BasePort - Xor DX, 8389h xor 388h ; SysConfig2 - In AL, DX ; Get SysConfig2 - Or AL, 4 ; Set 16 bits - Out DX, AL - - Mov AL, Stereo - Xor AL, 1 ; 0 if stereo, 1 if mono. - ShL AL, 5 - Mov DX, BasePort - Or AL, 099h ; Enable DRQ, DAC output - Xor DX, 0F8Ah xor 388h - Out DX, AL - Jmp $+2 - Jmp $+2 - Or AL, 40h ; Enable PCM - Out DX, AL - - Mov DX, BasePort - Xor DX, 0B8Bh xor 388h - In AL, DX - Or AL, 8 ; Enable sample buffer intr - Out DX, AL - - Mov DX, BasePort ; Disable output&timers - Mov AL, 0E1h ; disable mute, enable sample rate - ; timer and sample buffer counter. - Xor DX, 0B8Ah xor 388h - Out DX, AL - - Pop DS - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartPAS16 - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetPASMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset PAS16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset PAS16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopPAS16 - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - -; In AL, 1 -; Mov AH, AL -; In AL, 1 -; Mov CS:Debug2, AX - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Call RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopPAS16 - Call StartPAS16 - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset PAS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Comment ~ - - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - - ~ - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for the PAS16 +MIXTABLESIZE EQU 2*256*65 +TIMERCONST EQU 11932 + +Debug1 DB 0 +Debug2 DW 0 + +PAS16Msg DB "Pro Audio 16 Spectrum found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +PAS16NoMemoryMsg DB "Pro Audio 16 Spectrum found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Pro Audio 16 Spectrum reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITPAS16.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITPAS16.DRV", 0 + +DriverName DB "ITPAS16.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +MixSpeed DW 44100 +PASMixConst DW 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 +TimerAccumulator DW 0 + +DMALengthTable Label Byte + DB 1, 3, 5, 7, 0C2h, 0C6h, 0CAh, 0CEh + +;********************************** + +PAS16ScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr PAS16HeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW 0 + +PAS16HeaderLine DW 10 + DB "Pro Audio Spectrum 16 Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 26, 48 + DB 21h + DB "Pro Audio Spectrum 16 Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MixModeText DW 1 + DB 2, 13 + DB 20h + DB "Mixing Mode", 0 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 15, 32, 17, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 18, 32, 20, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 21, 32, 23, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 24, 32, 26, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 28 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 30, 29, 32, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 33, 29, 35, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 36, 29, 38, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 6 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixSpeed + Assume DS:Driver + + Push AX + Push CX + Push DX + + Mov DX, 12h + Mov AX, 34DCh + Mov CX, PASMixConst + Cmp CS:Stereo, 0 + JE GetMixSpeed1 + + And CX, Not 1 + +GetMixSpeed1: + Div CX + +GetMixSpeed2: + Mov MixSpeed, AX + + Pop DX + Pop CX + Pop AX + Ret + +EndP GetMixSpeed + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetPASMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetPASMixConst1 + + Mov CX, 44100 + Cmp AX, CX + JA GetPASMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetPASMixConst1 + + Mov CX, AX + +GetPASMixConst1: + Mov MixSpeed, CX + + Mov DX, 012h + Mov AX, 34DCh + Div CX + + Mov PASMixConst, AX + Mov BX, AX + + Pop DS + PopA + Ret + +EndP GetPASMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TestPAS ; AX = port + + Push AX + + Mov DX, 803h ; Default is 0B8Bh + Xor DX, AX ; DX = Interrupt Control port + In AL, DX + + Cmp AL, 0FFh + JE TestPAS1 + + Mov AH, AL + Xor AL, 11100000b + Out DX, AL + + Jmp $+2 + Jmp $+2 + In AL, DX + + Cmp AL, AH + XChg AH, AL + Out DX, AL + JNE TestPAS1 + + Pop AX + Push AX + + Mov DX, AX ; PAS 16? + Xor DX, 0EF8Bh xor 388h + In AL, DX + Test AL, 8 + JZ TestPAS1 + + Pop AX + + ClC + Ret + +TestPAS1: + Pop AX + StC + Ret + +EndP TestPAS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 0BC00h + Mov BX, '??' + Xor CX, CX + Xor DX, DX + Int 2Fh + + Xor BX, CX + Xor BX, DX + Cmp BX, 'M'*256+'V' + JE DetectPAS4 ; MVSound.Sys installed! + +DetectPAS7: + StC + Ret + +DetectPAS4: + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectPAS1 + Cmp AX, 388h + JE DetectPAS6 + Cmp AX, 384h + JE DetectPAS6 + Cmp AX, 38Ch + JE DetectPAS6 + Cmp AX, 288h + JNE DetectPAS7 + +DetectPAS6: + Call TestPAS + JNC DetectPAS2 + + Ret + +DetectPAS1: + Mov AX, 388h + Call TestPAS + JNC DetectPAS2 + + Mov AX, 384h + Call TestPAS + JNC DetectPAS2 + + Mov AX, 38Ch + Call TestPAS + JNC DetectPAS2 + + Mov AX, 288h + Call TestPAS + JNC DetectPAS2 + + Ret ; No card! + +DetectPAS2: + Push AX + + Mov AX, 0BC04h + Int 2Fh + + Cmp AX, 'M'*256+'V' + JNE DetectPAS3 + + Pop AX + + Mov BasePort, AX + Mov DMA, BX + Mov IRQ, CX + + Mov AL, [DMALengthTable+BX] + Mov Byte Ptr [DMAPort1], AL + Mov Byte Ptr [DMAPort2], AL + + Mov AX, DMABUFFERLENGTH/2 + Cmp BX, 4 + JB DetectPAS5 + + ShR AX, 1 + +DetectPAS5: + Mov Word Ptr [DMABufferLength1], AX + Mov Word Ptr [DMABufferLength2], AX + + Mov EAX, 'Jeff' + ClC + Ret + +DetectPAS3: + Pop AX + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PAS16IRQHandler + + Push AX + Push BX + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Add TimerAccumulator, TIMERCONST + JC PAS16IRQHandler11 + + Mov AL, 20h + Out 20h, AL + Jmp PAS16IRQHandler12 + +PAS16IRQHandler11: + PushF + Call [OldIRQHandler] + +PAS16IRQHandler12: + +DMAPort1 EQU $+1 + In AL, 1 + Mov AH, AL +DMAPort2 EQU $+1 + In AL, 1 + XChg AL, AH + + Mov Debug2, AX + + Cmp MixBufferPos, 0 + JE PAS16IRQHandler13 + + Xor BX, BX +DMABufferLength1 EQU $+1 + Cmp AX, 1234h + JB PAS16IRQHandler1 + + Pop DS + Pop BX + Pop AX + IRet + +PAS16IRQHandler13: + Mov BX, DMABUFFERLENGTH/2 +DMABufferLength2 EQU $+1 + Cmp AX, 1234h + JAE PAS16IRQHandler1 + + Pop DS + Pop BX + Pop AX + IRet + +PAS16IRQHandler1: + Xor MixBufferPos, 1 + + PushAD + Push ES + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, BX + + Mov BX, DMABUFFERLENGTH/4 ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE PAS16IRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +PAS16IRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE PAS16IRQHandler4 + Assume DS:Nothing + +PAS16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +PAS16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE PAS16IRQHandler5 + + Mov DX, MixTransferRemaining + +PAS16IRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB PAS16IRQHandler6 + JE PAS16IRQHFilter + + Cmp CS:Stereo, 0 + JE PAS16IRQ3QFilterMono + +PAS16IRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +PAS16IRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL PAS163QFilterStereoClip1 + Cmp EAX, 7FFFh + JG PAS163QFilterStereoClip2 + +PAS16IRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL PAS163QFilterStereoClip3 + Cmp EAX, 7FFFh + JG PAS163QFilterStereoClip4 + +PAS16IRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ PAS16IRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp PAS16MixTransferEnd + +PAS16IRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +PAS16IRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL PAS163QFilterMonoClip1 + Cmp EAX, 7FFFh + JG PAS163QFilterMonoClip2 + +PAS16IRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ PAS16IRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp PAS16MixTransferEnd + +PAS16IRQHFilter: + Cmp CS:Stereo, 0 + JE PAS16IRQHFilterMono + +PAS16IRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +PAS16IRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL PAS16HFilterStereoClip1 + Cmp EAX, 7FFFh + JG PAS16HFilterStereoClip2 + +PAS16IRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL PAS16HFilterStereoClip3 + Cmp EAX, 7FFFh + JG PAS16HFilterStereoClip4 + +PAS16IRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ PAS16IRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp PAS16MixTransferEnd + +PAS16IRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +PAS16IRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL PAS16HFilterMonoClip1 + Cmp EAX, 7FFFh + JG PAS16HFilterMonoClip2 + +PAS16IRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ PAS16IRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp PAS16MixTransferEnd + +PAS16IRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL PAS16IRQHandlerClip1 + Cmp EAX, 7FFFh + JG PAS16IRQHandlerClip2 + +PAS16IRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ PAS16IRQHandler6 + +PAS16MixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ PAS16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + PopAD + Pop DS + Pop BX + Pop AX + IRet + +PAS16IRQHandlerClip1: + Mov AX, 8000h + Jmp PAS16IRQHandler7 + +PAS16IRQHandlerClip2: + Mov AX, 7FFFh + Jmp PAS16IRQHandler7 + +PAS16HFilterMonoClip1: + Mov AX, 8000h + Jmp PAS16IRQHFilterMono2 + +PAS16HFilterMonoClip2: + Mov AX, 7FFFh + Jmp PAS16IRQHFilterMono2 + +PAS16HFilterStereoClip1: + Mov AX, 8000h + Jmp PAS16IRQHFilterStereo2 + +PAS16HFilterStereoClip2: + Mov AX, 7FFFh + Jmp PAS16IRQHFilterStereo2 + +PAS16HFilterStereoClip3: + Mov AX, 8000h + Jmp PAS16IRQHFilterStereo3 + +PAS16HFilterStereoClip4: + Mov AX, 7FFFh + Jmp PAS16IRQHFilterStereo3 + +PAS163QFilterMonoClip1: + Mov AX, 8000h + Jmp PAS16IRQ3QFilterMono2 + +PAS163QFilterMonoClip2: + Mov AX, 7FFFh + Jmp PAS16IRQ3QFilterMono2 + +PAS163QFilterStereoClip1: + Mov AX, 8000h + Jmp PAS16IRQ3QFilterStereo2 + +PAS163QFilterStereoClip2: + Mov AX, 7FFFh + Jmp PAS16IRQ3QFilterStereo2 + +PAS163QFilterStereoClip3: + Mov AX, 8000h + Jmp PAS16IRQ3QFilterStereo3 + +PAS163QFilterStereoClip4: + Mov AX, 7FFFh + Jmp PAS16IRQ3QFilterStereo3 + +EndP PAS16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + Push EAX + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + ; bump the interrupt to be called + ; 100 times a second. + Mov AX, TIMERCONST + Out 40h, AL + Mov AL, AH + Out 40h, AL + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset PAS16IRQHandler + + ClI + + XChg [ES:20h], EAX ; Hook to timer interrupt + Mov CS:OldIRQHandler, EAX + + StI + + Pop ES + Pop EAX + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + Push EAX + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Xor AL, AL + Out 40h, AL ; Interrupt called at normal 18.2 times + Out 40h, AL + + Mov EAX, CS:OldIRQHandler + Mov [ES:20h], EAX + + Pop ES + Pop EAX + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopPAS16 + + Mov DX, BasePort + Xor AL, AL + Xor DX, 0B89h xor 388h ; Interrupt Status register + Out DX, AL + + Mov DX, BasePort ; Audio filter control + Mov AL, 1 + Xor DX, 0B8Ah xor 388h ; Disable buffer counter + Out DX, AL ; and PAS 16 output + + Mov DX, BasePort + Xor DX, 8389h xor 388h ; SysConfig2 + In AL, DX ; Get SysConfig2 + And AL, Not 4 ; Reset 8 bits + Out DX, AL + + Mov DX, BasePort + Mov AL, 19h ; Mono, L2L, R2R + Xor DX, 0F8Ah xor 388h ; Cross channel register + Out DX, AL + + Ret + +EndP StopPAS16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartPAS16 ; + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Xor AL, AL + Xor DX, 0B89h xor 388h ; Interrupt Status register + Out DX, AL + + Mov DX, BasePort ; Audio filter control + Mov AL, 1 + Xor DX, 0B8Ah xor 388h ; Disable buffer counter + Out DX, AL ; and PAS 16 output + + Mov DX, BasePort + Mov AL, 19h + Xor DX, 0F8Ah xor 388h ; Cross channel register + Out DX, AL + + Mov DX, BasePort + Xor DX, 138Bh xor 388h ; Timer control, + Mov AL, 00110110b ; 36h - set frequency + Out DX, AL + + Mov DX, BasePort + Xor DX, 1388h xor 388h + Mov AX, PASMixConst + Cmp Stereo, 0 + JE StartPAS16_2 + + ShR AX, 1 + +StartPAS16_2: + Out DX, AL + Mov AL, AH + Out DX, AL + + Call GetMixSpeed + Call GetTempo + Call SetTempo + + Mov DX, BasePort + Xor DX, 138Bh xor 388h ; Timer control + Mov AL, 01110100b ; 74h - set buffer count + Out DX, AL + + Mov DX, BasePort ; Sample count + Mov AX, DMABUFFERLENGTH + Xor DX, 1389h xor 388h + + Cmp DMA, 4 + JB StartPAS16_1 + + ShR AX, 1 + +StartPAS16_1: + Out DX, AL + Mov AL, AH + Out DX, AL + + Mov DX, BasePort + Xor DX, 8389h xor 388h ; SysConfig2 + In AL, DX ; Get SysConfig2 + Or AL, 4 ; Set 16 bits + Out DX, AL + + Mov AL, Stereo + Xor AL, 1 ; 0 if stereo, 1 if mono. + ShL AL, 5 + Mov DX, BasePort + Or AL, 099h ; Enable DRQ, DAC output + Xor DX, 0F8Ah xor 388h + Out DX, AL + Jmp $+2 + Jmp $+2 + Or AL, 40h ; Enable PCM + Out DX, AL + + Mov DX, BasePort + Xor DX, 0B8Bh xor 388h + In AL, DX + Or AL, 8 ; Enable sample buffer intr + Out DX, AL + + Mov DX, BasePort ; Disable output&timers + Mov AL, 0E1h ; disable mute, enable sample rate + ; timer and sample buffer counter. + Xor DX, 0B8Ah xor 388h + Out DX, AL + + Pop DS + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartPAS16 + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetPASMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset PAS16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset PAS16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopPAS16 + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + +; In AL, 1 +; Mov AH, AL +; In AL, 1 +; Mov CS:Debug2, AX + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Call RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopPAS16 + Call StartPAS16 + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset PAS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Comment ~ + + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + + ~ + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/PASDRV.ASM b/SoundDrivers/PASDRV.ASM index 5c79d1c..8ed704a 100755 --- a/SoundDrivers/PASDRV.ASM +++ b/SoundDrivers/PASDRV.ASM @@ -1,1903 +1,1903 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 16 ; 32 bit mixing for the PAS16 -MIXTABLESIZE EQU 2*256*65 -TIMERCONST EQU 11932 - -Debug1 DB 0 -Debug2 DW 0 - -PAS16Msg DB "Pro Audio Spectrum found", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -PAS16NoMemoryMsg DB "Pro Audio Spectrum found", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Pro Audio Spectrum reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITPAS.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITPAS.DRV", 0 - -DriverName DB "ITPAS.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -MixSpeed DW 44100 -PASMixConst DW 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldIRQHandler DD 0 - -FilterValue DW 0 -FilterValue2 DW 0 -TimerAccumulator DW 0 - -DMALengthTable Label Byte - DB 1, 3, 5, 7, 0C2h, 0C6h, 0CAh, 0CEh - -;********************************** - -PAS16ScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr PASHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; 7 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 9 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW 0 - -PASHeaderLine DW 10 - DB "Pro Audio Spectrum Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 29, 48 - DB 21h - DB "Pro Audio Spectrum Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MixModeText DW 1 - DB 2, 13 - DB 20h - DB "Mixing Mode", 0 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 15, 32, 17, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 18, 32, 20, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 22 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 7, 10, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 24, 29, 26, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 27, 29, 29, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 10, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 30, 29, 32, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 6 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixSpeed - Assume DS:Driver - - Push AX - Push CX - Push DX - - Mov DX, 12h - Mov AX, 34DCh - Mov CX, PASMixConst - Cmp CS:Stereo, 0 - JE GetMixSpeed1 - - And CX, Not 1 - -GetMixSpeed1: - Div CX - -GetMixSpeed2: - Mov MixSpeed, AX - - Pop DX - Pop CX - Pop AX - Ret - -EndP GetMixSpeed - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetPASMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetPASMixConst1 - - Mov CX, 44100 - Cmp AX, CX - JA GetPASMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetPASMixConst1 - - Mov CX, AX - -GetPASMixConst1: - Mov MixSpeed, CX - - Mov DX, 012h - Mov AX, 34DCh - Div CX - - Mov PASMixConst, AX - Mov BX, AX - - Pop DS - PopA - Ret - -EndP GetPASMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TestPAS ; AX = port - - Push AX - - Mov DX, 803h ; Default is 0B8Bh - Xor DX, AX ; DX = Interrupt Control port - In AL, DX - - Cmp AL, 0FFh - JE TestPAS1 - - Mov AH, AL - Xor AL, 11100000b - Out DX, AL - - Jmp $+2 - Jmp $+2 - In AL, DX - - Cmp AL, AH - XChg AH, AL - Out DX, AL - JNE TestPAS1 - - Pop AX - - ClC - Ret - -TestPAS1: - Pop AX - StC - Ret - -EndP TestPAS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 0BC00h - Mov BX, '??' - Xor CX, CX - Xor DX, DX - Int 2Fh - - Xor BX, CX - Xor BX, DX - Cmp BX, 'M'*256+'V' - JE DetectPAS4 ; MVSound.Sys installed! - -DetectPAS7: - StC - Ret - -DetectPAS4: - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectPAS1 - Cmp AX, 388h - JE DetectPAS6 - Cmp AX, 384h - JE DetectPAS6 - Cmp AX, 38Ch - JE DetectPAS6 - Cmp AX, 288h - JNE DetectPAS7 - -DetectPAS6: - Call TestPAS - JNC DetectPAS2 - - Ret - -DetectPAS1: - Mov AX, 388h - Call TestPAS - JNC DetectPAS2 - - Mov AX, 384h - Call TestPAS - JNC DetectPAS2 - - Mov AX, 38Ch - Call TestPAS - JNC DetectPAS2 - - Mov AX, 288h - Call TestPAS - JNC DetectPAS2 - - Ret ; No card! - -DetectPAS2: - Push AX - - Mov AX, 0BC04h - Int 2Fh - - Cmp AX, 'M'*256+'V' - JNE DetectPAS3 - - Pop AX - - Mov BasePort, AX - Mov DMA, BX - Mov IRQ, CX - - Mov AL, [DMALengthTable+BX] - Mov Byte Ptr [DMAPort1], AL - Mov Byte Ptr [DMAPort2], AL - - Mov AX, DMABUFFERLENGTH/2 - Cmp BX, 4 - JB DetectPAS5 - - ShR AX, 1 - -DetectPAS5: - Mov Word Ptr [DMABufferLength1], AX - Mov Word Ptr [DMABufferLength2], AX - - Mov EAX, 'Jeff' - - ClC - Ret - -DetectPAS3: - Pop AX - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov AX, 2020h - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - ShR AX, 1 - Mov DX, CX - -MixSamples1: - Rep StosW ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PAS16IRQHandler - - Push AX - Push BX - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Add TimerAccumulator, TIMERCONST - JC PAS16IRQHandler11 - - Mov AL, 20h - Out 20h, AL - Jmp PAS16IRQHandler12 - -PAS16IRQHandler11: - PushF - Call [OldIRQHandler] - -PAS16IRQHandler12: - -DMAPort1 EQU $+1 - In AL, 1 - Mov AH, AL -DMAPort2 EQU $+1 - In AL, 1 - XChg AL, AH - - Mov Debug2, AX - - Cmp MixBufferPos, 0 - JE PAS16IRQHandler13 - - Xor BX, BX -DMABufferLength1 EQU $+1 - Cmp AX, 1234h - JB PAS16IRQHandler1 - - Pop DS - Pop BX - Pop AX - IRet - -PAS16IRQHandler13: - Mov BX, DMABUFFERLENGTH/2 -DMABufferLength2 EQU $+1 - Cmp AX, 1234h - JAE PAS16IRQHandler1 - - Pop DS - Pop BX - Pop AX - IRet - -PAS16IRQHandler1: - Xor MixBufferPos, 1 - - PushAD - Push ES - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, BX - - Mov BX, DMABUFFERLENGTH/2 ; BX = samples required - Mov BP, 4 ; Skip for mono - Mov CL, 6 ; Shift for mono - - Cmp Stereo, 0 - JE PAS16IRQHandlerMono - - Mov BP, 2 ; Stereo skip value. - Dec CL - -PAS16IRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE PAS16IRQHandler4 - Assume DS:Nothing - -PAS16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -PAS16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE PAS16IRQHandler5 - - Mov DX, MixTransferRemaining - -PAS16IRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB PAS16IRQHandler6 - JE PAS16IRQHFilter - - Cmp CS:Stereo, 0 - JE PAS16IRQ3QFilterMono - -PAS16IRQ3QFilterStereo: - Push BX - - Mov BX, FilterValue - Mov BP, FilterValue2 - ShR DX, 1 - -PAS16IRQ3QFilterStereo1: - Mov AX, BX - Mov CX, BP - Add AX, [SI] - Add CX, [SI+2] - SAR AX, 1 - SAR CX, 1 - Add BX, AX - Add BP, CX - SAR BX, 1 - SAR BP, 1 - - Mov AX, BX - SAR AX, 5 - - Test AH, AH - JNZ PAS163QFilterStereoClip1 - -PAS16IRQ3QFilterStereo2: - StosB - - Mov AX, BP - SAR AX, 5 - - Test AH, AH - JNZ PAS163QFilterStereoClip3 - -PAS16IRQ3QFilterStereo3: - StosB - - Add SI, 4 - Dec DX - JNZ PAS16IRQ3QFilterStereo1 - - Mov FilterValue, BX - Mov FilterValue2, BP - - Pop BX - - Jmp PAS16MixTransferEnd - -PAS16IRQ3QFilterMono: - Push BX - - Mov BX, FilterValue - -PAS16IRQ3QFilterMono1: - Mov AX, BX - Add AX, [SI] - SAR AX, 1 - Add BX, AX - SAR BX, 1 - Mov AX, BX - SAR AX, 6 - - Test AH, AH - JNZ PAS163QFilterMonoClip1 - -PAS16IRQ3QFilterMono2: - StosB - - Add SI, 4 - Dec DX - JNZ PAS16IRQ3QFilterMono1 - - Mov FilterValue, BX - - Pop BX - - Jmp PAS16MixTransferEnd - -PAS16IRQHFilter: - Cmp CS:Stereo, 0 - JE PAS16IRQHFilterMono - -PAS16IRQHFilterStereo: - Push BX - - Mov BX, FilterValue - Mov BP, FilterValue2 - ShR DX, 1 - -PAS16IRQHFilterStereo1: - Add BX, [SI] - Add BP, [SI+2] - - SAR BX, 1 - SAR BP, 1 - - Mov AX, BX - SAR AX, 5 - - Test AH, AH - JNZ PAS16HFilterStereoClip1 - -PAS16IRQHFilterStereo2: - StosB - - Mov AX, BP - SAR AX, 5 - - Test AH, AH - JNZ PAS16HFilterStereoClip3 - -PAS16IRQHFilterStereo3: - StosB - - Add SI, 4 - Dec DX - JNZ PAS16IRQHFilterStereo1 - - Mov FilterValue, BX - Mov FilterValue2, BP - - Pop BX - - Jmp PAS16MixTransferEnd - -PAS16IRQHFilterMono: - Push BX - - Mov BX, FilterValue - -PAS16IRQHFilterMono1: - Add BX, [SI] - SAR BX, 1 - Mov AX, BX - SAR AX, 6 - - Test AH, AH - JNZ PAS16HFilterMonoClip1 - -PAS16IRQHFilterMono2: - StosB - - Add SI, 4 - Dec DX - JNZ PAS16IRQHFilterMono1 - - Mov FilterValue, BX - - Pop BX - - Jmp PAS16MixTransferEnd - -PAS16IRQHandler6: - Mov AX, [SI] - SAR AX, CL - - Test AH, AH - JNZ PAS16IRQHandlerClip1 - -PAS16IRQHandler7: - StosB ; } Memory write - - Add SI, BP - Dec DX - JNZ PAS16IRQHandler6 - -PAS16MixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ PAS16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - PopAD - Pop DS - Pop BX - Pop AX - IRet - -PAS16IRQHandlerClip1: - Mov AL, 0FFh - JNS PAS16IRQHandler7 - Mov AL, 0 - Jmp PAS16IRQHandler7 - -PAS16HFilterMonoClip1: - Mov AL, 0FFh - JNS PAS16IRQHFilterMono2 - Mov AL, 0 - Jmp PAS16IRQHFilterMono2 - -PAS16HFilterStereoClip1: - Mov AL, 0FFh - JNS PAS16IRQHFilterStereo2 - Mov AL, 0 - Jmp PAS16IRQHFilterStereo2 - -PAS16HFilterStereoClip3: - Mov AL, 0FFh - JNS PAS16IRQHFilterStereo3 - Mov AL, 0 - Jmp PAS16IRQHFilterStereo3 - -PAS163QFilterMonoClip1: - Mov AL, 0FFh - JNS PAS16IRQ3QFilterMono2 - Mov AL, 0 - Jmp PAS16IRQ3QFilterMono2 - -PAS163QFilterStereoClip1: - Mov AL, 0FFh - JNS PAS16IRQ3QFilterStereo2 - Mov AL, 0 - Jmp PAS16IRQ3QFilterStereo2 - -PAS163QFilterStereoClip3: - Mov AL, 0FFh - JNS PAS16IRQ3QFilterStereo3 - Mov AL, 0 - Jmp PAS16IRQ3QFilterStereo3 - -EndP PAS16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - Push EAX - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - ; bump the interrupt to be called - ; 100 times a second. - Mov AX, TIMERCONST - Out 40h, AL - Mov AL, AH - Out 40h, AL - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset PAS16IRQHandler - - ClI - - XChg [ES:20h], EAX ; Hook to timer interrupt - Mov CS:OldIRQHandler, EAX - - StI - - Pop ES - Pop EAX - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - Push EAX - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Xor AL, AL - Out 40h, AL ; Interrupt called at normal 18.2 times - Out 40h, AL - - Mov EAX, CS:OldIRQHandler - Mov [ES:20h], EAX - - Pop ES - Pop EAX - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopPAS16 - - Mov DX, BasePort - Xor AL, AL - Xor DX, 0B89h xor 388h ; Interrupt Status register - Out DX, AL - - Mov DX, BasePort ; Audio filter control - Mov AL, 1 - Xor DX, 0B8Ah xor 388h ; Disable buffer counter - Out DX, AL ; and PAS 16 output - - Mov DX, BasePort - Mov AL, 19h ; Mono, L2L, R2R - Xor DX, 0F8Ah xor 388h ; Cross channel register - Out DX, AL - - Ret - -EndP StopPAS16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartPAS16 ; - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Xor AL, AL - Xor DX, 0B89h xor 388h ; Interrupt Status register - Out DX, AL - - Mov DX, BasePort ; Audio filter control - Mov AL, 1 - Xor DX, 0B8Ah xor 388h ; Disable buffer counter - Out DX, AL ; and PAS 16 output - - Mov DX, BasePort - Mov AL, 19h - Xor DX, 0F8Ah xor 388h ; Cross channel register - Out DX, AL - - Mov DX, BasePort - Xor DX, 138Bh xor 388h ; Timer control, - Mov AL, 00110110b ; 36h - set frequency - Out DX, AL - - Mov DX, BasePort - Xor DX, 1388h xor 388h - Mov AX, PASMixConst - Cmp Stereo, 0 - JE StartPAS16_2 - - ShR AX, 1 - -StartPAS16_2: - Out DX, AL - Mov AL, AH - Out DX, AL - - Call GetMixSpeed - Call GetTempo - Call SetTempo - - Mov DX, BasePort - Xor DX, 138Bh xor 388h ; Timer control - Mov AL, 01110100b ; 74h - set buffer count - Out DX, AL - - Mov DX, BasePort ; Sample count - Mov AX, DMABUFFERLENGTH - Xor DX, 1389h xor 388h - - Cmp DMA, 4 - JB StartPAS16_1 - - ShR AX, 1 - -StartPAS16_1: - Out DX, AL - Mov AL, AH - Out DX, AL - - Mov AL, Stereo - Xor AL, 1 ; 0 if stereo, 1 if mono. - ShL AL, 5 - Mov DX, BasePort - Or AL, 099h ; Enable DRQ, DAC output - Xor DX, 0F8Ah xor 388h - Out DX, AL - Jmp $+2 - Jmp $+2 - Or AL, 40h ; Enable PCM - Out DX, AL - - Mov DX, BasePort - Xor DX, 0B8Bh xor 388h - In AL, DX - Or AL, 8 ; Enable sample buffer intr - Out DX, AL - - Mov DX, BasePort - Mov AL, 0E1h ; disable mute, enable sample rate - ; timer and sample buffer counter. - Xor DX, 0B8Ah xor 388h - Out DX, AL - - Pop DS - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartPAS16 - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetPASMixConst - ; Parags to allocate = (4/(.4*31*16))*MixSpeed + 2080 - ; = 661*MixSpeed/65536 - - Mov AX, 1322 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset PAS16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset PAS16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopPAS16 - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - -; In AL, 1 -; Mov AH, AL -; In AL, 1 -; Mov CS:Debug2, AX - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopPAS16 - Call StartPAS16 - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset PAS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Comment ~ - - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - - ~ - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 16 ; 32 bit mixing for the PAS16 +MIXTABLESIZE EQU 2*256*65 +TIMERCONST EQU 11932 + +Debug1 DB 0 +Debug2 DW 0 + +PAS16Msg DB "Pro Audio Spectrum found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +PAS16NoMemoryMsg DB "Pro Audio Spectrum found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Pro Audio Spectrum reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITPAS.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITPAS.DRV", 0 + +DriverName DB "ITPAS.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +MixSpeed DW 44100 +PASMixConst DW 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldIRQHandler DD 0 + +FilterValue DW 0 +FilterValue2 DW 0 +TimerAccumulator DW 0 + +DMALengthTable Label Byte + DB 1, 3, 5, 7, 0C2h, 0C6h, 0CAh, 0CEh + +;********************************** + +PAS16ScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr PASHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; 7 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 9 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW 0 + +PASHeaderLine DW 10 + DB "Pro Audio Spectrum Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 29, 48 + DB 21h + DB "Pro Audio Spectrum Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MixModeText DW 1 + DB 2, 13 + DB 20h + DB "Mixing Mode", 0 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 15, 32, 17, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 18, 32, 20, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 22 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 7, 10, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 24, 29, 26, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 27, 29, 29, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 10, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 30, 29, 32, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 6 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixSpeed + Assume DS:Driver + + Push AX + Push CX + Push DX + + Mov DX, 12h + Mov AX, 34DCh + Mov CX, PASMixConst + Cmp CS:Stereo, 0 + JE GetMixSpeed1 + + And CX, Not 1 + +GetMixSpeed1: + Div CX + +GetMixSpeed2: + Mov MixSpeed, AX + + Pop DX + Pop CX + Pop AX + Ret + +EndP GetMixSpeed + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetPASMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetPASMixConst1 + + Mov CX, 44100 + Cmp AX, CX + JA GetPASMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetPASMixConst1 + + Mov CX, AX + +GetPASMixConst1: + Mov MixSpeed, CX + + Mov DX, 012h + Mov AX, 34DCh + Div CX + + Mov PASMixConst, AX + Mov BX, AX + + Pop DS + PopA + Ret + +EndP GetPASMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TestPAS ; AX = port + + Push AX + + Mov DX, 803h ; Default is 0B8Bh + Xor DX, AX ; DX = Interrupt Control port + In AL, DX + + Cmp AL, 0FFh + JE TestPAS1 + + Mov AH, AL + Xor AL, 11100000b + Out DX, AL + + Jmp $+2 + Jmp $+2 + In AL, DX + + Cmp AL, AH + XChg AH, AL + Out DX, AL + JNE TestPAS1 + + Pop AX + + ClC + Ret + +TestPAS1: + Pop AX + StC + Ret + +EndP TestPAS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 0BC00h + Mov BX, '??' + Xor CX, CX + Xor DX, DX + Int 2Fh + + Xor BX, CX + Xor BX, DX + Cmp BX, 'M'*256+'V' + JE DetectPAS4 ; MVSound.Sys installed! + +DetectPAS7: + StC + Ret + +DetectPAS4: + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectPAS1 + Cmp AX, 388h + JE DetectPAS6 + Cmp AX, 384h + JE DetectPAS6 + Cmp AX, 38Ch + JE DetectPAS6 + Cmp AX, 288h + JNE DetectPAS7 + +DetectPAS6: + Call TestPAS + JNC DetectPAS2 + + Ret + +DetectPAS1: + Mov AX, 388h + Call TestPAS + JNC DetectPAS2 + + Mov AX, 384h + Call TestPAS + JNC DetectPAS2 + + Mov AX, 38Ch + Call TestPAS + JNC DetectPAS2 + + Mov AX, 288h + Call TestPAS + JNC DetectPAS2 + + Ret ; No card! + +DetectPAS2: + Push AX + + Mov AX, 0BC04h + Int 2Fh + + Cmp AX, 'M'*256+'V' + JNE DetectPAS3 + + Pop AX + + Mov BasePort, AX + Mov DMA, BX + Mov IRQ, CX + + Mov AL, [DMALengthTable+BX] + Mov Byte Ptr [DMAPort1], AL + Mov Byte Ptr [DMAPort2], AL + + Mov AX, DMABUFFERLENGTH/2 + Cmp BX, 4 + JB DetectPAS5 + + ShR AX, 1 + +DetectPAS5: + Mov Word Ptr [DMABufferLength1], AX + Mov Word Ptr [DMABufferLength2], AX + + Mov EAX, 'Jeff' + + ClC + Ret + +DetectPAS3: + Pop AX + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov AX, 2020h + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + ShR AX, 1 + Mov DX, CX + +MixSamples1: + Rep StosW ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PAS16IRQHandler + + Push AX + Push BX + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Add TimerAccumulator, TIMERCONST + JC PAS16IRQHandler11 + + Mov AL, 20h + Out 20h, AL + Jmp PAS16IRQHandler12 + +PAS16IRQHandler11: + PushF + Call [OldIRQHandler] + +PAS16IRQHandler12: + +DMAPort1 EQU $+1 + In AL, 1 + Mov AH, AL +DMAPort2 EQU $+1 + In AL, 1 + XChg AL, AH + + Mov Debug2, AX + + Cmp MixBufferPos, 0 + JE PAS16IRQHandler13 + + Xor BX, BX +DMABufferLength1 EQU $+1 + Cmp AX, 1234h + JB PAS16IRQHandler1 + + Pop DS + Pop BX + Pop AX + IRet + +PAS16IRQHandler13: + Mov BX, DMABUFFERLENGTH/2 +DMABufferLength2 EQU $+1 + Cmp AX, 1234h + JAE PAS16IRQHandler1 + + Pop DS + Pop BX + Pop AX + IRet + +PAS16IRQHandler1: + Xor MixBufferPos, 1 + + PushAD + Push ES + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, BX + + Mov BX, DMABUFFERLENGTH/2 ; BX = samples required + Mov BP, 4 ; Skip for mono + Mov CL, 6 ; Shift for mono + + Cmp Stereo, 0 + JE PAS16IRQHandlerMono + + Mov BP, 2 ; Stereo skip value. + Dec CL + +PAS16IRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE PAS16IRQHandler4 + Assume DS:Nothing + +PAS16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +PAS16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE PAS16IRQHandler5 + + Mov DX, MixTransferRemaining + +PAS16IRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB PAS16IRQHandler6 + JE PAS16IRQHFilter + + Cmp CS:Stereo, 0 + JE PAS16IRQ3QFilterMono + +PAS16IRQ3QFilterStereo: + Push BX + + Mov BX, FilterValue + Mov BP, FilterValue2 + ShR DX, 1 + +PAS16IRQ3QFilterStereo1: + Mov AX, BX + Mov CX, BP + Add AX, [SI] + Add CX, [SI+2] + SAR AX, 1 + SAR CX, 1 + Add BX, AX + Add BP, CX + SAR BX, 1 + SAR BP, 1 + + Mov AX, BX + SAR AX, 5 + + Test AH, AH + JNZ PAS163QFilterStereoClip1 + +PAS16IRQ3QFilterStereo2: + StosB + + Mov AX, BP + SAR AX, 5 + + Test AH, AH + JNZ PAS163QFilterStereoClip3 + +PAS16IRQ3QFilterStereo3: + StosB + + Add SI, 4 + Dec DX + JNZ PAS16IRQ3QFilterStereo1 + + Mov FilterValue, BX + Mov FilterValue2, BP + + Pop BX + + Jmp PAS16MixTransferEnd + +PAS16IRQ3QFilterMono: + Push BX + + Mov BX, FilterValue + +PAS16IRQ3QFilterMono1: + Mov AX, BX + Add AX, [SI] + SAR AX, 1 + Add BX, AX + SAR BX, 1 + Mov AX, BX + SAR AX, 6 + + Test AH, AH + JNZ PAS163QFilterMonoClip1 + +PAS16IRQ3QFilterMono2: + StosB + + Add SI, 4 + Dec DX + JNZ PAS16IRQ3QFilterMono1 + + Mov FilterValue, BX + + Pop BX + + Jmp PAS16MixTransferEnd + +PAS16IRQHFilter: + Cmp CS:Stereo, 0 + JE PAS16IRQHFilterMono + +PAS16IRQHFilterStereo: + Push BX + + Mov BX, FilterValue + Mov BP, FilterValue2 + ShR DX, 1 + +PAS16IRQHFilterStereo1: + Add BX, [SI] + Add BP, [SI+2] + + SAR BX, 1 + SAR BP, 1 + + Mov AX, BX + SAR AX, 5 + + Test AH, AH + JNZ PAS16HFilterStereoClip1 + +PAS16IRQHFilterStereo2: + StosB + + Mov AX, BP + SAR AX, 5 + + Test AH, AH + JNZ PAS16HFilterStereoClip3 + +PAS16IRQHFilterStereo3: + StosB + + Add SI, 4 + Dec DX + JNZ PAS16IRQHFilterStereo1 + + Mov FilterValue, BX + Mov FilterValue2, BP + + Pop BX + + Jmp PAS16MixTransferEnd + +PAS16IRQHFilterMono: + Push BX + + Mov BX, FilterValue + +PAS16IRQHFilterMono1: + Add BX, [SI] + SAR BX, 1 + Mov AX, BX + SAR AX, 6 + + Test AH, AH + JNZ PAS16HFilterMonoClip1 + +PAS16IRQHFilterMono2: + StosB + + Add SI, 4 + Dec DX + JNZ PAS16IRQHFilterMono1 + + Mov FilterValue, BX + + Pop BX + + Jmp PAS16MixTransferEnd + +PAS16IRQHandler6: + Mov AX, [SI] + SAR AX, CL + + Test AH, AH + JNZ PAS16IRQHandlerClip1 + +PAS16IRQHandler7: + StosB ; } Memory write + + Add SI, BP + Dec DX + JNZ PAS16IRQHandler6 + +PAS16MixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ PAS16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + PopAD + Pop DS + Pop BX + Pop AX + IRet + +PAS16IRQHandlerClip1: + Mov AL, 0FFh + JNS PAS16IRQHandler7 + Mov AL, 0 + Jmp PAS16IRQHandler7 + +PAS16HFilterMonoClip1: + Mov AL, 0FFh + JNS PAS16IRQHFilterMono2 + Mov AL, 0 + Jmp PAS16IRQHFilterMono2 + +PAS16HFilterStereoClip1: + Mov AL, 0FFh + JNS PAS16IRQHFilterStereo2 + Mov AL, 0 + Jmp PAS16IRQHFilterStereo2 + +PAS16HFilterStereoClip3: + Mov AL, 0FFh + JNS PAS16IRQHFilterStereo3 + Mov AL, 0 + Jmp PAS16IRQHFilterStereo3 + +PAS163QFilterMonoClip1: + Mov AL, 0FFh + JNS PAS16IRQ3QFilterMono2 + Mov AL, 0 + Jmp PAS16IRQ3QFilterMono2 + +PAS163QFilterStereoClip1: + Mov AL, 0FFh + JNS PAS16IRQ3QFilterStereo2 + Mov AL, 0 + Jmp PAS16IRQ3QFilterStereo2 + +PAS163QFilterStereoClip3: + Mov AL, 0FFh + JNS PAS16IRQ3QFilterStereo3 + Mov AL, 0 + Jmp PAS16IRQ3QFilterStereo3 + +EndP PAS16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + Push EAX + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + ; bump the interrupt to be called + ; 100 times a second. + Mov AX, TIMERCONST + Out 40h, AL + Mov AL, AH + Out 40h, AL + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset PAS16IRQHandler + + ClI + + XChg [ES:20h], EAX ; Hook to timer interrupt + Mov CS:OldIRQHandler, EAX + + StI + + Pop ES + Pop EAX + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + Push EAX + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Xor AL, AL + Out 40h, AL ; Interrupt called at normal 18.2 times + Out 40h, AL + + Mov EAX, CS:OldIRQHandler + Mov [ES:20h], EAX + + Pop ES + Pop EAX + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopPAS16 + + Mov DX, BasePort + Xor AL, AL + Xor DX, 0B89h xor 388h ; Interrupt Status register + Out DX, AL + + Mov DX, BasePort ; Audio filter control + Mov AL, 1 + Xor DX, 0B8Ah xor 388h ; Disable buffer counter + Out DX, AL ; and PAS 16 output + + Mov DX, BasePort + Mov AL, 19h ; Mono, L2L, R2R + Xor DX, 0F8Ah xor 388h ; Cross channel register + Out DX, AL + + Ret + +EndP StopPAS16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartPAS16 ; + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Xor AL, AL + Xor DX, 0B89h xor 388h ; Interrupt Status register + Out DX, AL + + Mov DX, BasePort ; Audio filter control + Mov AL, 1 + Xor DX, 0B8Ah xor 388h ; Disable buffer counter + Out DX, AL ; and PAS 16 output + + Mov DX, BasePort + Mov AL, 19h + Xor DX, 0F8Ah xor 388h ; Cross channel register + Out DX, AL + + Mov DX, BasePort + Xor DX, 138Bh xor 388h ; Timer control, + Mov AL, 00110110b ; 36h - set frequency + Out DX, AL + + Mov DX, BasePort + Xor DX, 1388h xor 388h + Mov AX, PASMixConst + Cmp Stereo, 0 + JE StartPAS16_2 + + ShR AX, 1 + +StartPAS16_2: + Out DX, AL + Mov AL, AH + Out DX, AL + + Call GetMixSpeed + Call GetTempo + Call SetTempo + + Mov DX, BasePort + Xor DX, 138Bh xor 388h ; Timer control + Mov AL, 01110100b ; 74h - set buffer count + Out DX, AL + + Mov DX, BasePort ; Sample count + Mov AX, DMABUFFERLENGTH + Xor DX, 1389h xor 388h + + Cmp DMA, 4 + JB StartPAS16_1 + + ShR AX, 1 + +StartPAS16_1: + Out DX, AL + Mov AL, AH + Out DX, AL + + Mov AL, Stereo + Xor AL, 1 ; 0 if stereo, 1 if mono. + ShL AL, 5 + Mov DX, BasePort + Or AL, 099h ; Enable DRQ, DAC output + Xor DX, 0F8Ah xor 388h + Out DX, AL + Jmp $+2 + Jmp $+2 + Or AL, 40h ; Enable PCM + Out DX, AL + + Mov DX, BasePort + Xor DX, 0B8Bh xor 388h + In AL, DX + Or AL, 8 ; Enable sample buffer intr + Out DX, AL + + Mov DX, BasePort + Mov AL, 0E1h ; disable mute, enable sample rate + ; timer and sample buffer counter. + Xor DX, 0B8Ah xor 388h + Out DX, AL + + Pop DS + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartPAS16 + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetPASMixConst + ; Parags to allocate = (4/(.4*31*16))*MixSpeed + 2080 + ; = 661*MixSpeed/65536 + + Mov AX, 1322 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset PAS16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset PAS16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopPAS16 + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + +; In AL, 1 +; Mov AH, AL +; In AL, 1 +; Mov CS:Debug2, AX + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopPAS16 + Call StartPAS16 + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset PAS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Comment ~ + + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + + ~ + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/PCSPKDRV.ASM b/SoundDrivers/PCSPKDRV.ASM index 3e40cd8..662e3cd 100755 --- a/SoundDrivers/PCSPKDRV.ASM +++ b/SoundDrivers/PCSPKDRV.ASM @@ -1,934 +1,934 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 0 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro -MIXTABLESIZE EQU 2*256*65 - -SBProMsg DB " Using Internal PC Speaker", 0 - -SBProNoMemoryMsg DB " Using Internal PC Speaker", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "PC Speaker reinitialised", 0 - -DSPVersion DW 0 -Forced DB 0 -InInterrupt DB 0 - -BytesToMix DW 1000 -MixSpeed DW 22000 -MixConst DW 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -DMASize DW 2048 - -OldIRQHandler DD 0 -TimerAccumulator DW 0 - -VolumeTable DB 256 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 -OutputBufferPos DW 0 -OutputBlockEnd DW 1024 - -include mix.inc -include mono12b.mix - -MixFunctionTables Label - -include mono12b.inc ; contains the tables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixConst ; Work out value.. and nearest - ; mixspeed value. Work out - ; volume translation table - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - - Cmp AX, 12000 - JB GetMixConst1 - - Cmp AX, 44100 - JA GetMixConst1 - - Mov CX, AX - -GetMixConst1: - Mov DX, 0012h - Mov AX, 34DDh - - Div CX - ; AX = mix const - Mov MixConst, AX - - Mov DX, 12h - Mov AX, 34DDh - Div MixConst - - Mov MixSpeed, AX - - Mov CX, 256 - Mov DI, Offset VolumeTable - Push CS - Pop ES - - ; Volume table = (PosInTable / 256) * MixConst -GetMixConst2: - Mov AX, 256 - Sub AX, CX - Mul MixConst - Add AX, 80h - Mov AL, AH - Inc AL - StosB - - Loop GetMixConst2 - - Pop ES - Pop DS - PopA - Ret - -EndP GetMixConst - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Mov AX, 0FFFFh - Push CS - Pop DS - Assume DS:Driver - - Cmp AX, IRQ - JNE DetectCard1 - Cmp AX, Baseport - JNE DetectCard1 - Cmp AX, DMA - JNE DetectCard1 - - Mov EAX, 'Jeff' - - ClC - Ret - -DetectCard1: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov AX, 2020h - - Mov BX, CX ; BX = bytes to mix - Mov DX, CX - - Mov MixTransferOffset, DI ; } Memory write - Rep StosW ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - Jmp MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - -Mix0Mode: ; 16-bit mixing, no interpolation, no ramping -Mix0ModeMono: - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AX, 30 ; Use left only-mixing for mono - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 60 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Mov [SI+8], AX ; Offset... - - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, MixTransferRemaining - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PCSpeakerIRQHandler - - Push AX - Push BX - Push DS - - Mov DS, CS:DMASegment - Mov BX, CS:OutputBufferPos - - Mov AL, [BX] - Out 42h, AL - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Inc BX - ; OK.. which IRQ handler? - Mov AX, MixConst - Add TimerAccumulator, AX - JC PCSpeakerIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp PCSpeakerIRQHandler2 - -PCSpeakerIRQHandler1: - PushF - Call OldIRQHandler - -PCSpeakerIRQHandler2: - Mov OutputBufferPos, BX - Cmp BX, OutputBlockEnd - JAE PCSpeakerIRQHandler3 - -PCSpeakerIRQHandlerEnd: - Pop DS - Pop BX - Pop AX - - IRet - -PCSpeakerIRQHandler3: - Mov BX, DMASize - Mov AX, OutputBlockEnd - Add AX, BX - Cmp AX, DMABUFFERLENGTH - JBE PCSpeakerIRQHandler4 - - Mov AX, BX - Mov OutputBufferPos, 0 - -PCSpeakerIRQHandler4: - Mov OutputBlockEnd, AX - - Cmp InInterrupt, 0 - JA PCSpeakerIRQHandlerEnd - - Inc InInterrupt - - ClD - - PushAD - Push ES - - Mov ES, CS:DMASegment - Mov DI, OutputBufferPos - - Call SaveEMSPageFrame - - StI - ; BX = bytes required - - Cmp MixTransferRemaining, 0 - JNE SBProIRQHandler4 - Assume DS:Nothing - -SBProIRQHandler3: - Push BX - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BX - -SBProIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SBProIRQHandler5 - - Mov DX, MixTransferRemaining - -SBProIRQHandler5: - Push BX - Push DX - -SBProIRQHandler6: - Mov BX, [SI] - SAR BX, 6 - - Test BH, BH - JNZ SBProIRQHandlerClip1 - -SBProIRQHandler7: - Mov AL, [CS:VolumeTable+BX] - StosB ; } Memory write - - Add SI, 2 - Dec DX - JNZ SBProIRQHandler6 - - Pop DX - Pop BX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SBProIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Dec InInterrupt - -PCSpkEnd2: - Pop ES - PopAD - Pop DS - Pop BX - Pop AX - IRet - -SBProIRQHandlerClip1: - Mov BX, 0 - JS SBProIRQHandler7 - Mov BX, 0FFh - Jmp SBProIRQHandler7 - -EndP PCSpeakerIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov OutputBufferPos, 0 - Mov OutputBlockEnd, 1024 - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Mov AX, MixConst - Out 40h, AL - Mov AL, AH - Out 40h, AL - ; Program PC Speaker's IRQ - Mov AL, 90h - Out 43h, AL - - In AL, 61h - Or AL, 3 - Out 61h, AL ; Enable sound. - - Xor AX, AX - Mov ES, AX - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset PCSpeakerIRQHandler - - ClI - - XChg [ES:20h], EAX - Mov OldIRQHandler, EAX - - StI - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AL, 0B6h ; Reset PCSpeaker control - Out 43h, AL - - In AL, 61h ; Enable PC Speaker to be - And AL, 0FCh ; controlled by other programs - Out 61h, AL - - - Mov AL, 34h ; Reset IRQ calling rate. - Out 43h, AL - Xor AL, AL - Out 40h, AL - Out 40h, AL - - Xor AX, AX - Mov ES, AX - - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - Call GetMixConst - - Mov AX, 661 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SBProNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call GetTempo - Call SetTempo - Call SetIRQ - - Mov SI, Offset SBProMsg - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 0 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro +MIXTABLESIZE EQU 2*256*65 + +SBProMsg DB " Using Internal PC Speaker", 0 + +SBProNoMemoryMsg DB " Using Internal PC Speaker", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "PC Speaker reinitialised", 0 + +DSPVersion DW 0 +Forced DB 0 +InInterrupt DB 0 + +BytesToMix DW 1000 +MixSpeed DW 22000 +MixConst DW 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +DMASize DW 2048 + +OldIRQHandler DD 0 +TimerAccumulator DW 0 + +VolumeTable DB 256 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 +OutputBufferPos DW 0 +OutputBlockEnd DW 1024 + +include mix.inc +include mono12b.mix + +MixFunctionTables Label + +include mono12b.inc ; contains the tables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixConst ; Work out value.. and nearest + ; mixspeed value. Work out + ; volume translation table + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + + Cmp AX, 12000 + JB GetMixConst1 + + Cmp AX, 44100 + JA GetMixConst1 + + Mov CX, AX + +GetMixConst1: + Mov DX, 0012h + Mov AX, 34DDh + + Div CX + ; AX = mix const + Mov MixConst, AX + + Mov DX, 12h + Mov AX, 34DDh + Div MixConst + + Mov MixSpeed, AX + + Mov CX, 256 + Mov DI, Offset VolumeTable + Push CS + Pop ES + + ; Volume table = (PosInTable / 256) * MixConst +GetMixConst2: + Mov AX, 256 + Sub AX, CX + Mul MixConst + Add AX, 80h + Mov AL, AH + Inc AL + StosB + + Loop GetMixConst2 + + Pop ES + Pop DS + PopA + Ret + +EndP GetMixConst + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Mov AX, 0FFFFh + Push CS + Pop DS + Assume DS:Driver + + Cmp AX, IRQ + JNE DetectCard1 + Cmp AX, Baseport + JNE DetectCard1 + Cmp AX, DMA + JNE DetectCard1 + + Mov EAX, 'Jeff' + + ClC + Ret + +DetectCard1: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov AX, 2020h + + Mov BX, CX ; BX = bytes to mix + Mov DX, CX + + Mov MixTransferOffset, DI ; } Memory write + Rep StosW ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + Jmp MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + +Mix0Mode: ; 16-bit mixing, no interpolation, no ramping +Mix0ModeMono: + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AX, 30 ; Use left only-mixing for mono + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 60 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Mov [SI+8], AX ; Offset... + + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, MixTransferRemaining + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PCSpeakerIRQHandler + + Push AX + Push BX + Push DS + + Mov DS, CS:DMASegment + Mov BX, CS:OutputBufferPos + + Mov AL, [BX] + Out 42h, AL + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Inc BX + ; OK.. which IRQ handler? + Mov AX, MixConst + Add TimerAccumulator, AX + JC PCSpeakerIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp PCSpeakerIRQHandler2 + +PCSpeakerIRQHandler1: + PushF + Call OldIRQHandler + +PCSpeakerIRQHandler2: + Mov OutputBufferPos, BX + Cmp BX, OutputBlockEnd + JAE PCSpeakerIRQHandler3 + +PCSpeakerIRQHandlerEnd: + Pop DS + Pop BX + Pop AX + + IRet + +PCSpeakerIRQHandler3: + Mov BX, DMASize + Mov AX, OutputBlockEnd + Add AX, BX + Cmp AX, DMABUFFERLENGTH + JBE PCSpeakerIRQHandler4 + + Mov AX, BX + Mov OutputBufferPos, 0 + +PCSpeakerIRQHandler4: + Mov OutputBlockEnd, AX + + Cmp InInterrupt, 0 + JA PCSpeakerIRQHandlerEnd + + Inc InInterrupt + + ClD + + PushAD + Push ES + + Mov ES, CS:DMASegment + Mov DI, OutputBufferPos + + Call SaveEMSPageFrame + + StI + ; BX = bytes required + + Cmp MixTransferRemaining, 0 + JNE SBProIRQHandler4 + Assume DS:Nothing + +SBProIRQHandler3: + Push BX + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BX + +SBProIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SBProIRQHandler5 + + Mov DX, MixTransferRemaining + +SBProIRQHandler5: + Push BX + Push DX + +SBProIRQHandler6: + Mov BX, [SI] + SAR BX, 6 + + Test BH, BH + JNZ SBProIRQHandlerClip1 + +SBProIRQHandler7: + Mov AL, [CS:VolumeTable+BX] + StosB ; } Memory write + + Add SI, 2 + Dec DX + JNZ SBProIRQHandler6 + + Pop DX + Pop BX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SBProIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Dec InInterrupt + +PCSpkEnd2: + Pop ES + PopAD + Pop DS + Pop BX + Pop AX + IRet + +SBProIRQHandlerClip1: + Mov BX, 0 + JS SBProIRQHandler7 + Mov BX, 0FFh + Jmp SBProIRQHandler7 + +EndP PCSpeakerIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov OutputBufferPos, 0 + Mov OutputBlockEnd, 1024 + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Mov AX, MixConst + Out 40h, AL + Mov AL, AH + Out 40h, AL + ; Program PC Speaker's IRQ + Mov AL, 90h + Out 43h, AL + + In AL, 61h + Or AL, 3 + Out 61h, AL ; Enable sound. + + Xor AX, AX + Mov ES, AX + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset PCSpeakerIRQHandler + + ClI + + XChg [ES:20h], EAX + Mov OldIRQHandler, EAX + + StI + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AL, 0B6h ; Reset PCSpeaker control + Out 43h, AL + + In AL, 61h ; Enable PC Speaker to be + And AL, 0FCh ; controlled by other programs + Out 61h, AL + + + Mov AL, 34h ; Reset IRQ calling rate. + Out 43h, AL + Xor AL, AL + Out 40h, AL + Out 40h, AL + + Xor AX, AX + Mov ES, AX + + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + Call GetMixConst + + Mov AX, 661 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SBProNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call GetTempo + Call SetTempo + Call SetIRQ + + Mov SI, Offset SBProMsg + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/PNP.INC b/SoundDrivers/PNP.INC index fecac2e..4e1f53f 100755 --- a/SoundDrivers/PNP.INC +++ b/SoundDrivers/PNP.INC @@ -1,224 +1,224 @@ -; -; Plug and play include file. Driver needs to define PNPVENDORID and -; PNPSERIALID which will be used to identify the card. -; -; Call function PnP_Detect -; - - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadRegister - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or SerialNumber, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - - Mov AL, 74 - Call PnP_ReadData ; AL[2:0] = DMA - - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Cmp PnP_CSN, 0 - JNE PnP_IsolateEnd - - StC - -PnP_IsolateEnd: - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Pnp_Detect ; returns carry clear if succesful - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JNC PnP_DetectEnd - - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JNC PnP_DetectEnd - - Mov PnP_ReadPort, 213h - Call PnP_Isolate - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - - Ret - -EndP PnP_Detect - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - +; +; Plug and play include file. Driver needs to define PNPVENDORID and +; PNPSERIALID which will be used to identify the card. +; +; Call function PnP_Detect +; + + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadRegister + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or SerialNumber, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + + Mov AL, 74 + Call PnP_ReadData ; AL[2:0] = DMA + + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Cmp PnP_CSN, 0 + JNE PnP_IsolateEnd + + StC + +PnP_IsolateEnd: + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Pnp_Detect ; returns carry clear if succesful + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JNC PnP_DetectEnd + + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JNC PnP_DetectEnd + + Mov PnP_ReadPort, 213h + Call PnP_Isolate + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + + Ret + +EndP PnP_Detect + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/SoundDrivers/Q.INC b/SoundDrivers/Q.INC index c6e45a4..0203e75 100755 --- a/SoundDrivers/Q.INC +++ b/SoundDrivers/Q.INC @@ -1,34 +1,34 @@ - -QualityFactorTable Label DWord - DD 3F800000h, 3F7A8874h, 3F752ECBh, 3F6FF262h - DD 3F6AD298h, 3F65CED3h, 3F60E678h, 3F5C18F1h - DD 3F5765ACh, 3F52CC19h, 3F4E4BACh, 3F49E3DCh - DD 3F459421h, 3F415BF8h, 3F3D3AE1h, 3F39305Ch - DD 3F353BEFh, 3F315D21h, 3F2D937Ch, 3F29DE8Ch - DD 3F263DE0h, 3F22B109h, 3F1F379Ah, 3F1BD12Ah - DD 3F187D50h, 3F153BA8h, 3F120BCDh, 3F0EED5Fh - DD 3F0BDFFDh, 3F08E34Bh, 3F05F6EEh, 3F031A8Ch - DD 3F004DCEh, 3EFB20BEh, 3EF5C3D4h, 3EF0843Ch - DD 3EEB6156h, 3EE65A84h, 3EE16F2Dh, 3EDC9EBBh - DD 3ED7E89Bh, 3ED34C3Ch, 3ECEC913h, 3ECA5E95h - DD 3EC60C3Bh, 3EC1D181h, 3EBDADE7h, 3EB9A0EEh - DD 3EB5AA1Ah, 3EB1C8F2h, 3EADFCFFh, 3EAA45CEh - DD 3EA6A2EDh, 3EA313EEh, 3E9F9862h, 3E9C2FE1h - DD 3E98DA02h, 3E95965Fh, 3E926494h, 3E8F4440h - DD 3E8C3504h, 3E893681h, 3E86485Dh, 3E836A3Eh - DD 3E809BCCh, 3E7BB965h, 3E765939h, 3E711670h - DD 3E6BF06Ah, 3E66E68Ah, 3E61F836h, 3E5D24D6h - DD 3E586BD9h, 3E53CCADh, 3E4F46C5h, 3E4AD998h - DD 3E46849Eh, 3E424752h, 3E3E2134h, 3E3A11C4h - DD 3E361887h, 3E323503h, 3E2E66C2h, 3E2AAD4Fh - DD 3E270838h, 3E23770Fh, 3E1FF965h, 3E1C8ED2h - DD 3E1936ECh, 3E15F14Ch, 3E12BD91h, 3E0F9B56h - DD 3E0C8A3Eh, 3E0989E9h, 3E0699FDh, 3E03BA20h - DD 3E00E9F9h, 3DFC5268h, 3DF6EEF8h, 3DF1A8FCh - DD 3DEC7FD5h, 3DE772E5h, 3DE28191h, 3DDDAB43h - DD 3DD8EF67h, 3DD44D6Ch, 3DCFC4C4h, 3DCB54E6h - DD 3DC6FD4Ah, 3DC2BD6Ah, 3DBE94C7h, 3DBA82DFh - DD 3DB68738h, 3DB2A157h, 3DAED0C5h, 3DAB150Eh - DD 3DA76DC0h, 3DA3DA6Ch, 3DA05AA3h, 3D9CEDFCh - DD 3D99940Eh, 3D964C71h, 3D9316C3h, 3D8FF2A1h - DD 3D8CDFABh, 3D89DD84h, 3D86EBCFh, 3D840A32h + +QualityFactorTable Label DWord + DD 3F800000h, 3F7A8874h, 3F752ECBh, 3F6FF262h + DD 3F6AD298h, 3F65CED3h, 3F60E678h, 3F5C18F1h + DD 3F5765ACh, 3F52CC19h, 3F4E4BACh, 3F49E3DCh + DD 3F459421h, 3F415BF8h, 3F3D3AE1h, 3F39305Ch + DD 3F353BEFh, 3F315D21h, 3F2D937Ch, 3F29DE8Ch + DD 3F263DE0h, 3F22B109h, 3F1F379Ah, 3F1BD12Ah + DD 3F187D50h, 3F153BA8h, 3F120BCDh, 3F0EED5Fh + DD 3F0BDFFDh, 3F08E34Bh, 3F05F6EEh, 3F031A8Ch + DD 3F004DCEh, 3EFB20BEh, 3EF5C3D4h, 3EF0843Ch + DD 3EEB6156h, 3EE65A84h, 3EE16F2Dh, 3EDC9EBBh + DD 3ED7E89Bh, 3ED34C3Ch, 3ECEC913h, 3ECA5E95h + DD 3EC60C3Bh, 3EC1D181h, 3EBDADE7h, 3EB9A0EEh + DD 3EB5AA1Ah, 3EB1C8F2h, 3EADFCFFh, 3EAA45CEh + DD 3EA6A2EDh, 3EA313EEh, 3E9F9862h, 3E9C2FE1h + DD 3E98DA02h, 3E95965Fh, 3E926494h, 3E8F4440h + DD 3E8C3504h, 3E893681h, 3E86485Dh, 3E836A3Eh + DD 3E809BCCh, 3E7BB965h, 3E765939h, 3E711670h + DD 3E6BF06Ah, 3E66E68Ah, 3E61F836h, 3E5D24D6h + DD 3E586BD9h, 3E53CCADh, 3E4F46C5h, 3E4AD998h + DD 3E46849Eh, 3E424752h, 3E3E2134h, 3E3A11C4h + DD 3E361887h, 3E323503h, 3E2E66C2h, 3E2AAD4Fh + DD 3E270838h, 3E23770Fh, 3E1FF965h, 3E1C8ED2h + DD 3E1936ECh, 3E15F14Ch, 3E12BD91h, 3E0F9B56h + DD 3E0C8A3Eh, 3E0989E9h, 3E0699FDh, 3E03BA20h + DD 3E00E9F9h, 3DFC5268h, 3DF6EEF8h, 3DF1A8FCh + DD 3DEC7FD5h, 3DE772E5h, 3DE28191h, 3DDDAB43h + DD 3DD8EF67h, 3DD44D6Ch, 3DCFC4C4h, 3DCB54E6h + DD 3DC6FD4Ah, 3DC2BD6Ah, 3DBE94C7h, 3DBA82DFh + DD 3DB68738h, 3DB2A157h, 3DAED0C5h, 3DAB150Eh + DD 3DA76DC0h, 3DA3DA6Ch, 3DA05AA3h, 3D9CEDFCh + DD 3D99940Eh, 3D964C71h, 3D9316C3h, 3D8FF2A1h + DD 3D8CDFABh, 3D89DD84h, 3D86EBCFh, 3D840A32h diff --git a/SoundDrivers/REQPROC.INC b/SoundDrivers/REQPROC.INC index 0cdbebc..5b516d8 100755 --- a/SoundDrivers/REQPROC.INC +++ b/SoundDrivers/REQPROC.INC @@ -1,31 +1,31 @@ - -ProcedureTableStart Label -Update DD 0 -GetSampleHeader DD 0 -GetSampleLocation DD 0 - DD 0 -GetEMSPageFrame DD 0 -SaveEMSPageFrame DD 0 -RestoreEMSPageFrame DD 0 -GetTempo DD 0 ; Gets tempo in BX -M_FunctionHandler DD 0 -SetInfoLine DD 0 -Music_LoadAllSamples DD 0 -GlobalKeyList DD 0 -IdleUpdateInfoLine DD 0 -DrawHeaderFunction DD 0 -FillHeaderFunction DD 0 -GotoHomeDirectory DD 0 -GetFileName DD 0 -SetDirectory DD 0 -StopPlayback DD 0 -GetEnvironment DD 0 -GetChannelTables DD 0 -RecalculateAllVolumes DD 0 -UARTBufferEmpty DD 0 -UARTSend DD 0 -S_GetDestination DD 0 -S_DrawString DD 0 - DD 32 - ($-ProcedureTableStart)/4 Dup (0) - - + +ProcedureTableStart Label +Update DD 0 +GetSampleHeader DD 0 +GetSampleLocation DD 0 + DD 0 +GetEMSPageFrame DD 0 +SaveEMSPageFrame DD 0 +RestoreEMSPageFrame DD 0 +GetTempo DD 0 ; Gets tempo in BX +M_FunctionHandler DD 0 +SetInfoLine DD 0 +Music_LoadAllSamples DD 0 +GlobalKeyList DD 0 +IdleUpdateInfoLine DD 0 +DrawHeaderFunction DD 0 +FillHeaderFunction DD 0 +GotoHomeDirectory DD 0 +GetFileName DD 0 +SetDirectory DD 0 +StopPlayback DD 0 +GetEnvironment DD 0 +GetChannelTables DD 0 +RecalculateAllVolumes DD 0 +UARTBufferEmpty DD 0 +UARTSend DD 0 +S_GetDestination DD 0 +S_DrawString DD 0 + DD 32 - ($-ProcedureTableStart)/4 Dup (0) + + diff --git a/SoundDrivers/SAM9407.ASM b/SoundDrivers/SAM9407.ASM index 67bfa61..709cddf 100755 --- a/SoundDrivers/SAM9407.ASM +++ b/SoundDrivers/SAM9407.ASM @@ -1,1008 +1,1008 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;*********************************************** - -NUMMEMORYBLOCKS EQU 64 - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 80719304h - -MMT_MAXENTRIES EQU 64 -MMT_MAXSIZE EQU 3*MMT_MAXENTRIES - - -SAM_RD_MEM EQU 2h -SAM_GET_MMT EQU 3h -SAM_GEN_INT EQU 48h -SAM_GET_VOI EQU 51h -SAM_VOI_OPEN EQU 52h -SAM_VOI_CLOSE EQU 53h -SAM_VOI_START EQU 54h -SAM_VOI_STOP EQU 55h -SAM_VOI_VOL EQU 56h -SAM_VOI_MAIN EQU 57h -SAM_VOI_PITCH EQU 58h -SAM_VOI_AUX EQU 59h -SAM_VOI_FILT EQU 5Ah -SAM_VOI_MEM EQU 5Bh -SAM_GET_POS EQU 5Ch -SAM_ADD_POS EQU 5Dh - -SAM9407Message DB "Dream SAM9407 Detected", 13 - DB "Port ", 0FDh, "Xh, ", 0FDh, "Dk RAM", 0 - -StatusLine DB "FreeSAM ", 0FDh, "Dk", 0 - -SAMUpdateFlag DB 0 - -ALIGN 4 -OldIRQHandler DD 0 -SAMUpdateTimer DW 0 -SAMUpdateCount DW 0 - -MMTData DW MMT_MAXSIZE Dup (0) - -MemoryBlocks DD NUMMEMORYBLOCKS*2 Dup (0) - ; Memory blocks are offset/size pairs. - -SampleInformation DD 100*4 Dup (0) - ; Sample data is a struct - ; Offset 0: Starting address - ; Offset 4: Loop start - ; Offset 8: Loop end - ; Offset 0Ch: ?? - -SlaveChannelOffset DW 0 - -; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EmptyFunction Far - - Xor AX, AX - StC - Ret - -EndP EmptyFunction - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407ReceiveByte ; Returns AL = data - ; BL = status - - Push DX - Mov DX, CS:BasePort - Inc DX - -SAM9407ReceiveByte1: - In AL, DX - Test AL, AL - JS SAM9407ReceiveByte1 - - Mov BL, AL - Dec DX - And BL, 30h - - In AL, DX - Pop DX - - Ret - -EndP SAM9407ReceiveByte - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407ReceiveWord ; Returns AX - - Call SAM9407ReceiveByte - Mov AL, AH - Call SAM9407ReceiveByte - XChg AL, AH - - Ret - -EndP SAM9407ReceiveWord - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407ReceiveDWord ; Returns EAX - - Call SAM9407ReceiveByte - RoR EAX, 8 - Call SAM9407ReceiveByte - RoR EAX, 8 - Call SAM9407ReceiveByte - RoR EAX, 8 - Call SAM9407ReceiveByte - RoR EAX, 8 - - Ret - -EndP SAM9407ReceiveDWord - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendControlByte ; BL = data - - Push AX - Push DX - - Mov DX, CS:BasePort - Inc DX - -SAM9407SendControlByte1: - In AL, DX - Test AL, 40h - JNZ SAM9407SendControlByte1 - - Mov AL, BL - Out DX, AL - - Pop DX - Pop AX - - Ret - -EndP SAM9407SendControlByte - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendDataByte ; AL = data - - Push DX - Push AX - - Mov DX, CS:BasePort - Inc DX - -SAM9407SendDataByte1: - In AL, DX - Test AL, 40h - JNZ SAM9407SendDataByte1 - - Pop AX - Dec DX - - Out DX, AL - - Pop DX - - Ret - -EndP SAM9407SendDataByte - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendDataWord ; AX = data - - Call SAM9407SendDataByte - Mov AL, AH - Call SAM9407SendDataByte - Ret - -EndP SAM9407SendDataWord - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendDataDWord ; EAX = data - - Call SAM9407SendDataByte - ShR EAX, 8 - Call SAM9407SendDataByte - ShR EAX, 8 - Call SAM9407SendDataByte - ShR AX, 8 - Call SAM9407SendDataByte - Ret - -EndP SAM9407SendDataDWord - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407ReceiveString ; ES:DI points to deposit point. - ; EAX = memory address - ; CX = count - - Mov BL, SAM_RD_MEM - Call SAM9407SendControlByte - Call SAM9407SendDataDWord - Mov AX, CX - Call SAM9407SendDataWord - -SAM9407InString1: - Call SAM9407ReceiveByte - Cmp AL, 0ABh - JE SAM9407InStringError - Cmp AL, 0ACh - JNE SAM9407InString1 - -SAM9407InString2: - Mov DX, CS:BasePort - Add DX, 2 - - Rep InsW - - DB 85h - -SAM9407InStringError: - StC - Ret - -EndP SAM9407ReceiveString - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetWaitforSend ; Given DX = control port - - Xor CX, CX - -ResetWaitforSend1: - In AL, DX - Test AL, 40h - LoopNZ ResetWaitforSend - Ret - -EndP ResetWaitforSend - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetWaitforReceive - - Xor CX, CX - -ResetWaitforReceive1: - In AL, DX - Test AL, 80h - JNZ ResetWaitforReceive2 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE ResetWaitforReceive3 - -ResetWaitforReceive2: - Loop ResetWaitforReceive1 - - StC - Ret - -ResetWaitforReceive3: - ClC - Ret - -EndP ResetWaitforReceive - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAMSendChannelNumber - - Mov AX, SI - Sub AX, CS:SlaveChannelOffset - ShR AX, 7 - Call SAM9407SendDataByte - - Ret - -EndP SAMSendChannelNumber - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAMOpenVoice - - Cmp Byte Ptr [SI+2], 1 - JE SAMOpenVoice1 ; Already opened! - - Mov Byte Ptr [SI+2], 1 - - Mov BL, [SI+36h] ; Sample number - Xor DH, DH - And BX, 0FFh - ShL BX, 4 - - Mov DL, [Byte Ptr CS:SampleInformation+BX+3] - Sub DL, [Byte Ptr CS:SampleInformation+BX+7] - ; Carry 0 if inbank - ; Carry 1 if crossbank - - SBB DL, DL ; DL = 0 inbank - ; DL = 0FFh crossbank - - ShL DL, 7 ; DL = 0 inbank - ; DL = 80h crossbank - - Mov BL, SAM_VOI_OPEN - Call SAM9407SendControlByte - - Mov AX, SI - Sub AX, CS:SlaveChannelOffset - ShR AX, 7 - Or AL, DL - Call SAM9407SendDataByte - -SAMOpenVoice1: - Ret - -EndP SAMOpenVoice - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAMStopNote ; Closes the voice. - - Cmp Byte Ptr [SI+2], 1 - JNE SAMStopNote1 - - Mov Byte Ptr [SI+2], 0 - Mov BL, SAM_VOI_CLOSE - Call SAM9407SendControlByte - Call SAMSendChannelNumber - -SAMStopNote1: - Ret - - -EndP SAMStopNote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAMSetVolume - - Cmp Byte Ptr [SI+2], 1 - JNE SAMSetVolume1 - - Mov BL, SAM_VOI_VOL - Call SAM9407SendControlByte - Call SAMSendChannelNumber - Mov AL, [SI+20h] - Call SAM9407SendDataByte - -SAMSetVolume1: - Ret - -EndP SAMSetVolume - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAMSetPan - - Cmp Byte Ptr [SI+2], 1 - JNE SAMSetPan1 - -Comment ~ - Mov BL, SAM_VOI_PAN - Call SAM9407SendControlByte - Call SAMSendChannelNumber - Mov AL, [SI+37h] - Call SAM9407SendDataByte -~ -SAMSetPan1: - Ret - -EndP SAMSetPan - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAMSetPitch - -; Pitch value sent is 400h for nominal frequency of 37.5khz, linear scale -; -> Value sent = Frequency*400h / 37500 -; = Frequency * 0.02730666 -; = Frequency * 117281240 / 2^32 - - Cmp Byte Ptr [SI+2], 1 - JNE SAMSetPitch3 - - Mov EAX, 117281240 - Mul DWord Ptr [SI+10h] - - Cmp EDX, 0FFFFh - JA SAMSetPitch1 - - Mov BL, SAM_VOI_PITCH - Call SAM9407SendControlByte - Call SAMSendChannelNumber - Mov AX, DX - Call SAM9407SendDataWord - -SAMSetPitch3: - Ret - -SAMSetPitch1: - Call SAMStopNote - - Mov Word Ptr [SI], 200h - Test Byte Ptr [SI+3Ah], 80h - JNZ SAMSetPitch2 - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Signify channel off - -SAMSetPitch2: - Ret - -EndP SAMSetPitch - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAMSetRegisters - -; First get offset of currently playing notes - -; Update Registers to play notes - -; Flow is as follows: -; If new note, open voice -; -; If pitch change, set pitch -; If volume change, set volume + filters -; -PlayNote: - - Ret - -EndP SAMSetRegisters - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAMIRQHandler ; IRQ Handler has to - ; 1) Update GUS registers - ; 2) Update song position - Push AX - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, SAMUpdateTimer - Add SAMUpdateCount, AX - JC SAMIRQHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp SAMIRQHandler2 - -SAMIRQHandler1: - PushF - Call [OldIRQHandler] - -SAMIRQHandler2: - Xor SAMUpdateFlag, 1 - JZ SAMIRQHandlerEnd - - PushAD - Push ES - - ClD - - Call SaveEMSPageFrame - Call Update ; Returns DS:SI, CX - Assume DS:Nothing - - Mov SlaveChannelOffset, SI - - Call SAMSetRegisters - Call RestoreEMSPageFrame - - Pop ES - PopAD - -SAMIRQHandlerEnd: - Pop DS - Pop AX - IRet - -EndP SAMIRQHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART ; Given DX = Port - - Inc DX - - Mov AL, 0FFh ; Reset! - Out DX, AL - Out DX, AL ; Two resets required to ensure it'll work - - Call ResetWaitforReceive - JNC ResetUART1 - -ResetUARTError: - StC - Ret - -ResetUART1: ; Now to shove it into 'intelligent' mode. - Call ResetWaitforSend - JNZ ResetUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - - Call ResetWaitforReceive - JC ResetUARTError - - Call ResetWaitforSend - JNZ ResetUARTError - - Mov AL, SAM_GEN_INT - Out DX, AL - - Call ResetWaitforSend - JNZ ResetUARTError - - Dec DX - Xor AL, AL - Out DX, AL - Inc DX - - Xor CX, CX - -ResetUART2: - In AL, DX - Test AL, 80h - JNZ ResetUART3 - - Mov AH, AL - Dec DX - In AL, DX - Inc DX - And AH, 30h - Cmp AX, 3088h - JE ResetUART4 - -ResetUART3: - Loop ResetUART2 - Jmp ResetUARTError - -ResetUART4: - Call ResetWaitforReceive - JC ResetUARTError - - Dec DX - - ClC - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - -; Check whether the MPU can be reset - Mov DX, BasePort - Cmp DX, 0FFFFh - JE DetectCard1 - - Call ResetUART - JNC DetectCardFound - -DetectCardExit: - Ret - -DetectCard1: - Mov DX, 330h - Call ResetUART - JNC DetectCard2 - - Mov DX, 300h - Call ResetUART - JC DetectCardExit - -DetectCard2: - Mov BasePort, DX - -DetectCardFound: -; Find memory mapping table, - Mov BL, SAM_GET_MMT - Xor AL, AL - Call SAM9407SendControlByte - Call SAM9407SendDataByte - Call SAM9407ReceiveDWord - - Push CS - Pop ES - Mov CX, MMT_MAXSIZE - Mov DI, Offset MMTData - Call SAM9407ReceiveString - - Mov EAX, 'Jeff' - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Call GetTempo - Call SetTempo - Call ResetMemory - - Xor AX, AX - Mov ES, AX ; ES = 0 - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SAMIRQHandler - - ClI - - XChg DWord Ptr [ES:20h], EAX ; Clock tick - Mov OldIRQHandler, EAX - - StI - - Mov SI, Offset SAM9407Message - Xor BX, BX - -Comment ~ - Mov BL, SAM_GET_VOI - Xor AL, AL - Call SAM9407SendControlByte - Call SAM9407SendDataByte - Call SAM9407ReceiveByte - Mov BL, AL -~ - Mov AX, BasePort - Mov EBX, DWord Ptr [MMTData+2] - ShR EBX, 9 - - ClC - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov BL, 0FFh - Call SAM9407SendControlByte - - Mov AL, 34h - Out 43h, AL - - Xor AX, AX - Out 40h, AL - Out 40h, AL - - Mov ES, AX - Mov EAX, OldIRQHandler - Mov [ES:20h], EAX - - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far ; BX = tempo... - - Push AX - Push BX - Push DX - - ; Frames per second = 2 * (0.4*Tempo) - Mov AX, 0C214h - Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo - Div BX - - ; AX contains counter. - Mov CS:SAMUpdateTimer, AX - - Out 40h, AL ; Timer IRQ. - Mov AL, AH - Out 40h, AL - - Pop DX - Pop BX - Pop AX - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load (0 based) -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release (1 based) -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Push CS - Pop ES - - Mov SI, Offset MMTData+6 - Mov DI, Offset MemoryBlocks - -ResetMemory1: - Mov AX, [SI] - Add SI, 6 - - Cmp AX, -1 - JE ResetMemory2 - - Cmp AX, 1 - JNE ResetMemory1 - - Mov EAX, [SI-4] - StosD - Neg EAX - Add EAX, [SI+2] - StosD - Jmp ResetMemory1 - -ResetMemory2: - Mov CX, Offset MemoryBlocks+NUMMEMORYBLOCKS*2*4 - Sub CX, DI - Xor AX, AX - ShR CX, 1 - Rep StosW - - Pop ES - Pop DS - PopA - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset MemoryBlocks+4 - Mov CX, NUMMEMORYBLOCKS - Xor EAX, EAX - -GetStatus1: - Add EAX, [SI] - Add SI, 8 - Loop GetStatus1 - - Mov SI, Offset StatusLine - ShR EAX, 9 - - ClC - Ret - -EndP GetStatus - Assume DS:Nothing - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Xor AX, AX - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 64 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 64 - - DW 5 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;*********************************************** + +NUMMEMORYBLOCKS EQU 64 + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 80719304h + +MMT_MAXENTRIES EQU 64 +MMT_MAXSIZE EQU 3*MMT_MAXENTRIES + + +SAM_RD_MEM EQU 2h +SAM_GET_MMT EQU 3h +SAM_GEN_INT EQU 48h +SAM_GET_VOI EQU 51h +SAM_VOI_OPEN EQU 52h +SAM_VOI_CLOSE EQU 53h +SAM_VOI_START EQU 54h +SAM_VOI_STOP EQU 55h +SAM_VOI_VOL EQU 56h +SAM_VOI_MAIN EQU 57h +SAM_VOI_PITCH EQU 58h +SAM_VOI_AUX EQU 59h +SAM_VOI_FILT EQU 5Ah +SAM_VOI_MEM EQU 5Bh +SAM_GET_POS EQU 5Ch +SAM_ADD_POS EQU 5Dh + +SAM9407Message DB "Dream SAM9407 Detected", 13 + DB "Port ", 0FDh, "Xh, ", 0FDh, "Dk RAM", 0 + +StatusLine DB "FreeSAM ", 0FDh, "Dk", 0 + +SAMUpdateFlag DB 0 + +ALIGN 4 +OldIRQHandler DD 0 +SAMUpdateTimer DW 0 +SAMUpdateCount DW 0 + +MMTData DW MMT_MAXSIZE Dup (0) + +MemoryBlocks DD NUMMEMORYBLOCKS*2 Dup (0) + ; Memory blocks are offset/size pairs. + +SampleInformation DD 100*4 Dup (0) + ; Sample data is a struct + ; Offset 0: Starting address + ; Offset 4: Loop start + ; Offset 8: Loop end + ; Offset 0Ch: ?? + +SlaveChannelOffset DW 0 + +; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EmptyFunction Far + + Xor AX, AX + StC + Ret + +EndP EmptyFunction + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407ReceiveByte ; Returns AL = data + ; BL = status + + Push DX + Mov DX, CS:BasePort + Inc DX + +SAM9407ReceiveByte1: + In AL, DX + Test AL, AL + JS SAM9407ReceiveByte1 + + Mov BL, AL + Dec DX + And BL, 30h + + In AL, DX + Pop DX + + Ret + +EndP SAM9407ReceiveByte + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407ReceiveWord ; Returns AX + + Call SAM9407ReceiveByte + Mov AL, AH + Call SAM9407ReceiveByte + XChg AL, AH + + Ret + +EndP SAM9407ReceiveWord + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407ReceiveDWord ; Returns EAX + + Call SAM9407ReceiveByte + RoR EAX, 8 + Call SAM9407ReceiveByte + RoR EAX, 8 + Call SAM9407ReceiveByte + RoR EAX, 8 + Call SAM9407ReceiveByte + RoR EAX, 8 + + Ret + +EndP SAM9407ReceiveDWord + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendControlByte ; BL = data + + Push AX + Push DX + + Mov DX, CS:BasePort + Inc DX + +SAM9407SendControlByte1: + In AL, DX + Test AL, 40h + JNZ SAM9407SendControlByte1 + + Mov AL, BL + Out DX, AL + + Pop DX + Pop AX + + Ret + +EndP SAM9407SendControlByte + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendDataByte ; AL = data + + Push DX + Push AX + + Mov DX, CS:BasePort + Inc DX + +SAM9407SendDataByte1: + In AL, DX + Test AL, 40h + JNZ SAM9407SendDataByte1 + + Pop AX + Dec DX + + Out DX, AL + + Pop DX + + Ret + +EndP SAM9407SendDataByte + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendDataWord ; AX = data + + Call SAM9407SendDataByte + Mov AL, AH + Call SAM9407SendDataByte + Ret + +EndP SAM9407SendDataWord + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendDataDWord ; EAX = data + + Call SAM9407SendDataByte + ShR EAX, 8 + Call SAM9407SendDataByte + ShR EAX, 8 + Call SAM9407SendDataByte + ShR AX, 8 + Call SAM9407SendDataByte + Ret + +EndP SAM9407SendDataDWord + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407ReceiveString ; ES:DI points to deposit point. + ; EAX = memory address + ; CX = count + + Mov BL, SAM_RD_MEM + Call SAM9407SendControlByte + Call SAM9407SendDataDWord + Mov AX, CX + Call SAM9407SendDataWord + +SAM9407InString1: + Call SAM9407ReceiveByte + Cmp AL, 0ABh + JE SAM9407InStringError + Cmp AL, 0ACh + JNE SAM9407InString1 + +SAM9407InString2: + Mov DX, CS:BasePort + Add DX, 2 + + Rep InsW + + DB 85h + +SAM9407InStringError: + StC + Ret + +EndP SAM9407ReceiveString + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetWaitforSend ; Given DX = control port + + Xor CX, CX + +ResetWaitforSend1: + In AL, DX + Test AL, 40h + LoopNZ ResetWaitforSend + Ret + +EndP ResetWaitforSend + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetWaitforReceive + + Xor CX, CX + +ResetWaitforReceive1: + In AL, DX + Test AL, 80h + JNZ ResetWaitforReceive2 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE ResetWaitforReceive3 + +ResetWaitforReceive2: + Loop ResetWaitforReceive1 + + StC + Ret + +ResetWaitforReceive3: + ClC + Ret + +EndP ResetWaitforReceive + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAMSendChannelNumber + + Mov AX, SI + Sub AX, CS:SlaveChannelOffset + ShR AX, 7 + Call SAM9407SendDataByte + + Ret + +EndP SAMSendChannelNumber + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAMOpenVoice + + Cmp Byte Ptr [SI+2], 1 + JE SAMOpenVoice1 ; Already opened! + + Mov Byte Ptr [SI+2], 1 + + Mov BL, [SI+36h] ; Sample number + Xor DH, DH + And BX, 0FFh + ShL BX, 4 + + Mov DL, [Byte Ptr CS:SampleInformation+BX+3] + Sub DL, [Byte Ptr CS:SampleInformation+BX+7] + ; Carry 0 if inbank + ; Carry 1 if crossbank + + SBB DL, DL ; DL = 0 inbank + ; DL = 0FFh crossbank + + ShL DL, 7 ; DL = 0 inbank + ; DL = 80h crossbank + + Mov BL, SAM_VOI_OPEN + Call SAM9407SendControlByte + + Mov AX, SI + Sub AX, CS:SlaveChannelOffset + ShR AX, 7 + Or AL, DL + Call SAM9407SendDataByte + +SAMOpenVoice1: + Ret + +EndP SAMOpenVoice + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAMStopNote ; Closes the voice. + + Cmp Byte Ptr [SI+2], 1 + JNE SAMStopNote1 + + Mov Byte Ptr [SI+2], 0 + Mov BL, SAM_VOI_CLOSE + Call SAM9407SendControlByte + Call SAMSendChannelNumber + +SAMStopNote1: + Ret + + +EndP SAMStopNote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAMSetVolume + + Cmp Byte Ptr [SI+2], 1 + JNE SAMSetVolume1 + + Mov BL, SAM_VOI_VOL + Call SAM9407SendControlByte + Call SAMSendChannelNumber + Mov AL, [SI+20h] + Call SAM9407SendDataByte + +SAMSetVolume1: + Ret + +EndP SAMSetVolume + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAMSetPan + + Cmp Byte Ptr [SI+2], 1 + JNE SAMSetPan1 + +Comment ~ + Mov BL, SAM_VOI_PAN + Call SAM9407SendControlByte + Call SAMSendChannelNumber + Mov AL, [SI+37h] + Call SAM9407SendDataByte +~ +SAMSetPan1: + Ret + +EndP SAMSetPan + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAMSetPitch + +; Pitch value sent is 400h for nominal frequency of 37.5khz, linear scale +; -> Value sent = Frequency*400h / 37500 +; = Frequency * 0.02730666 +; = Frequency * 117281240 / 2^32 + + Cmp Byte Ptr [SI+2], 1 + JNE SAMSetPitch3 + + Mov EAX, 117281240 + Mul DWord Ptr [SI+10h] + + Cmp EDX, 0FFFFh + JA SAMSetPitch1 + + Mov BL, SAM_VOI_PITCH + Call SAM9407SendControlByte + Call SAMSendChannelNumber + Mov AX, DX + Call SAM9407SendDataWord + +SAMSetPitch3: + Ret + +SAMSetPitch1: + Call SAMStopNote + + Mov Word Ptr [SI], 200h + Test Byte Ptr [SI+3Ah], 80h + JNZ SAMSetPitch2 + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Signify channel off + +SAMSetPitch2: + Ret + +EndP SAMSetPitch + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAMSetRegisters + +; First get offset of currently playing notes + +; Update Registers to play notes + +; Flow is as follows: +; If new note, open voice +; +; If pitch change, set pitch +; If volume change, set volume + filters +; +PlayNote: + + Ret + +EndP SAMSetRegisters + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAMIRQHandler ; IRQ Handler has to + ; 1) Update GUS registers + ; 2) Update song position + Push AX + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, SAMUpdateTimer + Add SAMUpdateCount, AX + JC SAMIRQHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp SAMIRQHandler2 + +SAMIRQHandler1: + PushF + Call [OldIRQHandler] + +SAMIRQHandler2: + Xor SAMUpdateFlag, 1 + JZ SAMIRQHandlerEnd + + PushAD + Push ES + + ClD + + Call SaveEMSPageFrame + Call Update ; Returns DS:SI, CX + Assume DS:Nothing + + Mov SlaveChannelOffset, SI + + Call SAMSetRegisters + Call RestoreEMSPageFrame + + Pop ES + PopAD + +SAMIRQHandlerEnd: + Pop DS + Pop AX + IRet + +EndP SAMIRQHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART ; Given DX = Port + + Inc DX + + Mov AL, 0FFh ; Reset! + Out DX, AL + Out DX, AL ; Two resets required to ensure it'll work + + Call ResetWaitforReceive + JNC ResetUART1 + +ResetUARTError: + StC + Ret + +ResetUART1: ; Now to shove it into 'intelligent' mode. + Call ResetWaitforSend + JNZ ResetUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + + Call ResetWaitforReceive + JC ResetUARTError + + Call ResetWaitforSend + JNZ ResetUARTError + + Mov AL, SAM_GEN_INT + Out DX, AL + + Call ResetWaitforSend + JNZ ResetUARTError + + Dec DX + Xor AL, AL + Out DX, AL + Inc DX + + Xor CX, CX + +ResetUART2: + In AL, DX + Test AL, 80h + JNZ ResetUART3 + + Mov AH, AL + Dec DX + In AL, DX + Inc DX + And AH, 30h + Cmp AX, 3088h + JE ResetUART4 + +ResetUART3: + Loop ResetUART2 + Jmp ResetUARTError + +ResetUART4: + Call ResetWaitforReceive + JC ResetUARTError + + Dec DX + + ClC + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + +; Check whether the MPU can be reset + Mov DX, BasePort + Cmp DX, 0FFFFh + JE DetectCard1 + + Call ResetUART + JNC DetectCardFound + +DetectCardExit: + Ret + +DetectCard1: + Mov DX, 330h + Call ResetUART + JNC DetectCard2 + + Mov DX, 300h + Call ResetUART + JC DetectCardExit + +DetectCard2: + Mov BasePort, DX + +DetectCardFound: +; Find memory mapping table, + Mov BL, SAM_GET_MMT + Xor AL, AL + Call SAM9407SendControlByte + Call SAM9407SendDataByte + Call SAM9407ReceiveDWord + + Push CS + Pop ES + Mov CX, MMT_MAXSIZE + Mov DI, Offset MMTData + Call SAM9407ReceiveString + + Mov EAX, 'Jeff' + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Call GetTempo + Call SetTempo + Call ResetMemory + + Xor AX, AX + Mov ES, AX ; ES = 0 + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SAMIRQHandler + + ClI + + XChg DWord Ptr [ES:20h], EAX ; Clock tick + Mov OldIRQHandler, EAX + + StI + + Mov SI, Offset SAM9407Message + Xor BX, BX + +Comment ~ + Mov BL, SAM_GET_VOI + Xor AL, AL + Call SAM9407SendControlByte + Call SAM9407SendDataByte + Call SAM9407ReceiveByte + Mov BL, AL +~ + Mov AX, BasePort + Mov EBX, DWord Ptr [MMTData+2] + ShR EBX, 9 + + ClC + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov BL, 0FFh + Call SAM9407SendControlByte + + Mov AL, 34h + Out 43h, AL + + Xor AX, AX + Out 40h, AL + Out 40h, AL + + Mov ES, AX + Mov EAX, OldIRQHandler + Mov [ES:20h], EAX + + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far ; BX = tempo... + + Push AX + Push BX + Push DX + + ; Frames per second = 2 * (0.4*Tempo) + Mov AX, 0C214h + Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo + Div BX + + ; AX contains counter. + Mov CS:SAMUpdateTimer, AX + + Out 40h, AL ; Timer IRQ. + Mov AL, AH + Out 40h, AL + + Pop DX + Pop BX + Pop AX + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load (0 based) +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release (1 based) +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Push CS + Pop ES + + Mov SI, Offset MMTData+6 + Mov DI, Offset MemoryBlocks + +ResetMemory1: + Mov AX, [SI] + Add SI, 6 + + Cmp AX, -1 + JE ResetMemory2 + + Cmp AX, 1 + JNE ResetMemory1 + + Mov EAX, [SI-4] + StosD + Neg EAX + Add EAX, [SI+2] + StosD + Jmp ResetMemory1 + +ResetMemory2: + Mov CX, Offset MemoryBlocks+NUMMEMORYBLOCKS*2*4 + Sub CX, DI + Xor AX, AX + ShR CX, 1 + Rep StosW + + Pop ES + Pop DS + PopA + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset MemoryBlocks+4 + Mov CX, NUMMEMORYBLOCKS + Xor EAX, EAX + +GetStatus1: + Add EAX, [SI] + Add SI, 8 + Loop GetStatus1 + + Mov SI, Offset StatusLine + ShR EAX, 9 + + ClC + Ret + +EndP GetStatus + Assume DS:Nothing + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Xor AX, AX + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 64 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 64 + + DW 5 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SB16B.ASM b/SoundDrivers/SB16B.ASM index d1855cb..ff6319b 100755 --- a/SoundDrivers/SB16B.ASM +++ b/SoundDrivers/SB16B.ASM @@ -1,2001 +1,2001 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB16 -MIXTABLESIZE EQU 2*256*65 - -SB16Msg DB "Sound Blaster 16 detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SB16NoMemoryMsg DB "Sound Blaster 16 detected", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster 16 reinitialised", 0 - -DSPVersion DW 0 -DSPIRQValue DB 0 -DSPDMAValue DB 0 -Forced DB 0 -Stereo DB 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 -MixSegmentLength DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 8 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 -DMASize DW 2048 - -IMR DW 0 -OldIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MIDIPort DW 0 -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SB16ScreenList Label - DW 8 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr DriverText - - DW Near Ptr MasterVolumeLeft ; 8 - DW Near Ptr MasterVolumeRight ; 9 - DW Near Ptr TrebleVolumeLeft ; 10 - DW Near Ptr TrebleVolumeRight ; 11 - DW Near Ptr BassVolumeLeft ; 12 - DW Near Ptr BassVolumeRight ; 13 - - DW Near Ptr MixFrequencyText - - DW 0 - -SB16HeaderLine DW 10 - DB "Sound Blaster 16 Driver", 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 - -VolumeText DW 1 - DB 2, 13 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB 13 - DB 13 - DB "Treble Left", 13 - DB "Treble Right", 13 - DB "Bass Left", 13 - DB "Bass Right", 13 - DB 0 - -MixFrequencyText DW 1 - DB 2, 23 - DB 20h - DB "Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 45454 - -VolumeBox1 DW 0 - DB 21, 12, 27, 15 - DB 25 - -VolumeBox2 DW 0 - DB 14, 16, 18, 21 - DB 25 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MasterVolumeLeft DW 9 - DB 22, 13 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 14 - DW 0, 31 - DW 9, 1 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 15, 17 - DW 0, 15 - DW 9, 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 15, 18 - DW 0, 15 - DW 9, 3 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 15, 19 - DW 0, 15 - DW 9, 4 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 15, 20 - DW 0, 15 - DW 9, 5 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -VolumeTable DB 6 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectUART ; Given DX = Port - -; From SB-DevKit - - ClI - - Inc DX - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 40h ; Ready for output - LoopNZ DetectUART1 - JNZ DetectUARTError - - Mov AL, 0FFh ; Reset! - Out DX, AL - - Xor CX, CX -DetectUART2: - In AL, DX - Test AL, 80h - JNZ DetectUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART4 - -DetectUART3: - Loop DetectUART2 - -DetectUARTError: - StI - StC - Ret - -DetectUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -DetectUART5: - In AL, DX - Test AL, 40h - LoopNZ DetectUART5 - JNZ DetectUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -DetectUART6: - Xor CX, CX -DetectUART7: - In AL, DX - Test AL, 80h - JNZ DetectUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART9 - -DetectUART8: - Loop DetectUART7 - - Jmp DetectUARTError - -DetectUART9: - StI - ClC - Ret - - -Comment ~ - - ClI - - Mov BH, 3 ; Try to init port twice. - -DetectUART1: - Mov BL, 64 ; 64 byte buffer - - Inc DX - Mov AL, 0FFh - Out DX, AL - - Mov AL, 3Fh - Out DX, AL - -DetectUART2: - Mov CX, 04000h - -DetectUART3: - In AL, DX - Test AL, 80h - LoopNZ DetectUART3 - JZ DetectUART4 - - Dec BH - JNZ DetectUART1 - - StI - StC - Ret - -DetectUART4: - Dec DX - In AL, DX - Inc DX - - Cmp AL, 0FEh ; UART acknowledge. - JE DetectUART5 - - Dec BL - JNZ DetectUART2 - - Dec BH - JNZ DetectUART1 - -DetectUART6: - StC - -DetectUART5: - StI - Ret - - ~ - -EndP DetectUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReinitUART - - Mov DX, MIDIPort - Test DX, DX - JZ ReinitUART1 - - Call DetectUART - -ReinitUART1: - Ret - -EndP ReinitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, MIDIPort - Test DX, DX - JZ ResetUART1 - - Inc DX - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 45454 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPIRQ - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPIRQValue - Mov AL, 80h - Out DX, AX - - Ret - -EndP ResetDSPIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPDMA - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPDMAValue - Mov AL, 81h - Out DX, AX - - Ret - -EndP ResetDSPDMA - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AH, 4 ; SB DSP = 4.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - Add DL, 04h-0Eh ; 2x4h = Mixer index port - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov DSPIRQValue, AL - ; OK.. now get IRQ, or set IRQ - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - StC - Ret - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: ; Detect DMA - Mov AL, 81h ; DMA select - Out DX, AL - Inc DL - In AL, DX ; AL = DMA - Dec DL - - Mov DSPDMAValue, AL - - Mov BX, DMA - Cmp BX, 0FFFFh - JE DetectCardDMA1 - Cmp Forced, 0 - JE DetectCardDMA1 - - Mov CL, 1 - Cmp BX, 1 - JB SetCardDMA1 - - Mov CL, 2 - JE SetCardDMA1 - - Cmp BX, 3 - JB DetectCard7 - - Mov CL, 8 - JE DetectCard7 - - Mov CL, 20h - Cmp BX, 5 - JB DetectCard7 - JE SetCardDMA1 - - Mov CL, 80h - Cmp BX, 7 - JA DetectCard7 - JE SetCardDMA1 - - Mov CL, 40h - -SetCardDMA1: - And AL, 0Bh - Test CL, 0Bh - JZ SetCardDMA4 - - Xor AL, AL - -SetCardDMA4: - Or CL, AL - - Mov AL, 81h - Out DX, AL - Inc DL - Mov AL, CL - Out DX, AL - Jmp DetectCard7 - -DetectCardDMA1: - Mov BX, 5 - Test AL, 20h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 40h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 80h - JNZ DetectCardDMA2 - - Mov BL, 0 - Test AL, 1 - JNZ DetectCardDMA2 - - Inc BL - Test AL, 2 - JNZ DetectCardDMA2 - - Add BL, 2 - Test AL, 8 - JNZ DetectCardDMA2 - -DetectCard8: - Call ResetDSPIRQ - StC - Ret - -DetectCardDMA2: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - - Cmp BX, DMA - JNE DetectCard8 - -DetectCardDMA3: - Mov DMA, BX - -DetectCard7: - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Add DX, DX - -MixSamples1: - Rep StosD ; } Memory write - -MixSamplesCont: - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Cmp Stereo, 0 - JNE Mix0ModeStereo - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AckIRQ - Assume DS:Driver - - Mov AL, 20h - Cmp IRQ, 7 - JBE AckIRQ1 - - Out 0A0h, AL - -AckIRQ1: - Out 20h, AL - Ret - -EndP AckIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Mov DX, MIDIPort - - Mov BL, [MIDIBufferTail] - Test DX, DX - JZ CheckMIDIEnd - - Inc DX - Mov CX, 0FFFFh - -CheckMIDIAgain: - In AL, DX - - Test AL, 80h - LoopNZ CheckMIDIAgain - - Dec DX - In AL, DX - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL -; Jmp CheckMIDIAgain - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SB16IRQHandler - - PushAD - Push DS - Push ES - - CLD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 4 ; Mixer Port - Mov AL, 82h - Out DX, AL - Inc DL ; DX = BasePort+5 - In AL, DX - - Comment ~ - - Test AL, 1 - JZ SB8BitDigitalInterruptEnd - -SB8BitDigitalInterrupt: - Push AX - Add DL, 0Eh-5 - In AL, DX - Pop AX - -SB8BitDigitalInterruptEnd: - - ~ - - Test AL, 4 - JZ SBMIDIInterruptEnd - - Push AX - Call CheckMIDI - Pop AX - -SBMIDIInterruptEnd: - Test AL, 2 - JNZ SBDigitalInterrupt - - Call AckIRQ - Jmp SBIRQEnd - -SBDigitalInterrupt: - Mov DX, BasePort - Add DL, 0Fh - In AL, DX ; 16-bit IRQ ack. - - Call AckIRQ - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SB16IRQHandler2 - - Xor AX, AX - Xor BX, BX - -SB16IRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 4 ; Skip for mono - Mov CL, 2 ; Shift for mono - - Cmp Stereo, 0 - JE SB16IRQHandlerMono - - ShR BP, 1 - Inc CL - -SB16IRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SB16IRQHandler4 - Assume DS:Nothing - -SB16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SB16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SB16IRQHandler5 - - Mov DX, MixTransferRemaining - -SB16IRQHandler5: - Push DX - -SB16IRQHandler6: - MovSX EAX, Word Ptr [SI] - SAL EAX, CL - - Cmp EAX, -8000h - JL SB16IRQHandlerClip1 - Cmp EAX, 7FFFh - JG SB16IRQHandlerClip2 - -SB16IRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ SB16IRQHandler6 - -SB16MixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SB16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - -SBIRQEnd: - - Pop ES - Pop DS - PopAD - IRet - -SB16IRQHandlerClip1: - Mov AX, 8000h - Jmp SB16IRQHandler7 - -SB16IRQHandlerClip2: - Mov AX, 7FFFh - Jmp SB16IRQHandler7 - -EndP SB16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SB16IRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSB16 ; - - PushA - Push ES - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0B6h ; 16 bit, DAC - Call SBOut - Mov AL, Stereo - ShL AL, 5 - Or AL, 10h - Call SBOut - - Mov AX, DMASize - ShR AX, 1 - Dec AX - - Call SBOut ; DMALength, Lo - Mov AL, AH - Call SBOut - - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartSB16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Call GetSBMixConst - - ; Parags to allocate = (4/(.4*31*16))*MixSpeed + 2080 - ; = .02016129*MixSpeed = (65536*.04032258*MixSpeed) / 65536 - - Mov AX, 1322 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SB16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - Sub DX, 2080 - Mov MixSegmentLength, DX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov DX, 330h - Call DetectUART - JC DetectMIDI1 - - Mov MIDIPort, 330h - Jmp DetectMIDIEnd - -DetectMIDI1: - Mov DX, 300h - Call DetectUART - JC DetectMIDIEnd - - Mov MIDIPort, 300h - -DetectMIDIEnd: - - Mov SI, Offset SB16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, BasePort - Mov DX, AX - Call ResetDSP - - Call ResetUART - Call ResetIRQ - ; Delay.. - Mov DX, BasePort - Add DL, 0Ch - - Mov CX, 1000 -ReInitSound1: - In AL, DX - Loop ReInitSound1 - - Call SetIRQ - Call ReinitUART - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov DX, CS:BasePort - Add DL, 0Ch - - Mov AL, 0D3h - Call SBOut - - Mov AL, 0D5h - Call SBOut - - Mov AL, 0D9h - Call SBOut - - Mov AL, 0D5h - Call SBOut - - Call ResetUART - - Mov AX, BasePort - Call ResetDSP - - Call ResetDSPDMA - Call ResetDSPIRQ - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Dec CX - JNZ SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov CS:Stereo, AL - Mov AX, CS:BasePort - Call ResetDSP - - Mov ES, CS:MixSegment - Mov CX, CS:MixSegmentLength - Mov DI, MIXTABLESIZE - ShL CX, 2 - Xor EAX, EAX - Rep StosD - - Call StartSB16 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SB16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB16 +MIXTABLESIZE EQU 2*256*65 + +SB16Msg DB "Sound Blaster 16 detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SB16NoMemoryMsg DB "Sound Blaster 16 detected", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster 16 reinitialised", 0 + +DSPVersion DW 0 +DSPIRQValue DB 0 +DSPDMAValue DB 0 +Forced DB 0 +Stereo DB 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 +MixSegmentLength DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 8 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 +DMASize DW 2048 + +IMR DW 0 +OldIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MIDIPort DW 0 +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SB16ScreenList Label + DW 8 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr DriverText + + DW Near Ptr MasterVolumeLeft ; 8 + DW Near Ptr MasterVolumeRight ; 9 + DW Near Ptr TrebleVolumeLeft ; 10 + DW Near Ptr TrebleVolumeRight ; 11 + DW Near Ptr BassVolumeLeft ; 12 + DW Near Ptr BassVolumeRight ; 13 + + DW Near Ptr MixFrequencyText + + DW 0 + +SB16HeaderLine DW 10 + DB "Sound Blaster 16 Driver", 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 + +VolumeText DW 1 + DB 2, 13 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB 13 + DB 13 + DB "Treble Left", 13 + DB "Treble Right", 13 + DB "Bass Left", 13 + DB "Bass Right", 13 + DB 0 + +MixFrequencyText DW 1 + DB 2, 23 + DB 20h + DB "Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 45454 + +VolumeBox1 DW 0 + DB 21, 12, 27, 15 + DB 25 + +VolumeBox2 DW 0 + DB 14, 16, 18, 21 + DB 25 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MasterVolumeLeft DW 9 + DB 22, 13 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 14 + DW 0, 31 + DW 9, 1 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 15, 17 + DW 0, 15 + DW 9, 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 15, 18 + DW 0, 15 + DW 9, 3 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 15, 19 + DW 0, 15 + DW 9, 4 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 15, 20 + DW 0, 15 + DW 9, 5 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +VolumeTable DB 6 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectUART ; Given DX = Port + +; From SB-DevKit + + ClI + + Inc DX + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 40h ; Ready for output + LoopNZ DetectUART1 + JNZ DetectUARTError + + Mov AL, 0FFh ; Reset! + Out DX, AL + + Xor CX, CX +DetectUART2: + In AL, DX + Test AL, 80h + JNZ DetectUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART4 + +DetectUART3: + Loop DetectUART2 + +DetectUARTError: + StI + StC + Ret + +DetectUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +DetectUART5: + In AL, DX + Test AL, 40h + LoopNZ DetectUART5 + JNZ DetectUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +DetectUART6: + Xor CX, CX +DetectUART7: + In AL, DX + Test AL, 80h + JNZ DetectUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART9 + +DetectUART8: + Loop DetectUART7 + + Jmp DetectUARTError + +DetectUART9: + StI + ClC + Ret + + +Comment ~ + + ClI + + Mov BH, 3 ; Try to init port twice. + +DetectUART1: + Mov BL, 64 ; 64 byte buffer + + Inc DX + Mov AL, 0FFh + Out DX, AL + + Mov AL, 3Fh + Out DX, AL + +DetectUART2: + Mov CX, 04000h + +DetectUART3: + In AL, DX + Test AL, 80h + LoopNZ DetectUART3 + JZ DetectUART4 + + Dec BH + JNZ DetectUART1 + + StI + StC + Ret + +DetectUART4: + Dec DX + In AL, DX + Inc DX + + Cmp AL, 0FEh ; UART acknowledge. + JE DetectUART5 + + Dec BL + JNZ DetectUART2 + + Dec BH + JNZ DetectUART1 + +DetectUART6: + StC + +DetectUART5: + StI + Ret + + ~ + +EndP DetectUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReinitUART + + Mov DX, MIDIPort + Test DX, DX + JZ ReinitUART1 + + Call DetectUART + +ReinitUART1: + Ret + +EndP ReinitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, MIDIPort + Test DX, DX + JZ ResetUART1 + + Inc DX + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 45454 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPIRQ + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPIRQValue + Mov AL, 80h + Out DX, AX + + Ret + +EndP ResetDSPIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPDMA + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPDMAValue + Mov AL, 81h + Out DX, AX + + Ret + +EndP ResetDSPDMA + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AH, 4 ; SB DSP = 4.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + Add DL, 04h-0Eh ; 2x4h = Mixer index port + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov DSPIRQValue, AL + ; OK.. now get IRQ, or set IRQ + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + StC + Ret + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: ; Detect DMA + Mov AL, 81h ; DMA select + Out DX, AL + Inc DL + In AL, DX ; AL = DMA + Dec DL + + Mov DSPDMAValue, AL + + Mov BX, DMA + Cmp BX, 0FFFFh + JE DetectCardDMA1 + Cmp Forced, 0 + JE DetectCardDMA1 + + Mov CL, 1 + Cmp BX, 1 + JB SetCardDMA1 + + Mov CL, 2 + JE SetCardDMA1 + + Cmp BX, 3 + JB DetectCard7 + + Mov CL, 8 + JE DetectCard7 + + Mov CL, 20h + Cmp BX, 5 + JB DetectCard7 + JE SetCardDMA1 + + Mov CL, 80h + Cmp BX, 7 + JA DetectCard7 + JE SetCardDMA1 + + Mov CL, 40h + +SetCardDMA1: + And AL, 0Bh + Test CL, 0Bh + JZ SetCardDMA4 + + Xor AL, AL + +SetCardDMA4: + Or CL, AL + + Mov AL, 81h + Out DX, AL + Inc DL + Mov AL, CL + Out DX, AL + Jmp DetectCard7 + +DetectCardDMA1: + Mov BX, 5 + Test AL, 20h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 40h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 80h + JNZ DetectCardDMA2 + + Mov BL, 0 + Test AL, 1 + JNZ DetectCardDMA2 + + Inc BL + Test AL, 2 + JNZ DetectCardDMA2 + + Add BL, 2 + Test AL, 8 + JNZ DetectCardDMA2 + +DetectCard8: + Call ResetDSPIRQ + StC + Ret + +DetectCardDMA2: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + + Cmp BX, DMA + JNE DetectCard8 + +DetectCardDMA3: + Mov DMA, BX + +DetectCard7: + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Add DX, DX + +MixSamples1: + Rep StosD ; } Memory write + +MixSamplesCont: + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Cmp Stereo, 0 + JNE Mix0ModeStereo + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AckIRQ + Assume DS:Driver + + Mov AL, 20h + Cmp IRQ, 7 + JBE AckIRQ1 + + Out 0A0h, AL + +AckIRQ1: + Out 20h, AL + Ret + +EndP AckIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Mov DX, MIDIPort + + Mov BL, [MIDIBufferTail] + Test DX, DX + JZ CheckMIDIEnd + + Inc DX + Mov CX, 0FFFFh + +CheckMIDIAgain: + In AL, DX + + Test AL, 80h + LoopNZ CheckMIDIAgain + + Dec DX + In AL, DX + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL +; Jmp CheckMIDIAgain + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SB16IRQHandler + + PushAD + Push DS + Push ES + + CLD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 4 ; Mixer Port + Mov AL, 82h + Out DX, AL + Inc DL ; DX = BasePort+5 + In AL, DX + + Comment ~ + + Test AL, 1 + JZ SB8BitDigitalInterruptEnd + +SB8BitDigitalInterrupt: + Push AX + Add DL, 0Eh-5 + In AL, DX + Pop AX + +SB8BitDigitalInterruptEnd: + + ~ + + Test AL, 4 + JZ SBMIDIInterruptEnd + + Push AX + Call CheckMIDI + Pop AX + +SBMIDIInterruptEnd: + Test AL, 2 + JNZ SBDigitalInterrupt + + Call AckIRQ + Jmp SBIRQEnd + +SBDigitalInterrupt: + Mov DX, BasePort + Add DL, 0Fh + In AL, DX ; 16-bit IRQ ack. + + Call AckIRQ + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SB16IRQHandler2 + + Xor AX, AX + Xor BX, BX + +SB16IRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 4 ; Skip for mono + Mov CL, 2 ; Shift for mono + + Cmp Stereo, 0 + JE SB16IRQHandlerMono + + ShR BP, 1 + Inc CL + +SB16IRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SB16IRQHandler4 + Assume DS:Nothing + +SB16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SB16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SB16IRQHandler5 + + Mov DX, MixTransferRemaining + +SB16IRQHandler5: + Push DX + +SB16IRQHandler6: + MovSX EAX, Word Ptr [SI] + SAL EAX, CL + + Cmp EAX, -8000h + JL SB16IRQHandlerClip1 + Cmp EAX, 7FFFh + JG SB16IRQHandlerClip2 + +SB16IRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ SB16IRQHandler6 + +SB16MixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SB16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + +SBIRQEnd: + + Pop ES + Pop DS + PopAD + IRet + +SB16IRQHandlerClip1: + Mov AX, 8000h + Jmp SB16IRQHandler7 + +SB16IRQHandlerClip2: + Mov AX, 7FFFh + Jmp SB16IRQHandler7 + +EndP SB16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SB16IRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSB16 ; + + PushA + Push ES + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0B6h ; 16 bit, DAC + Call SBOut + Mov AL, Stereo + ShL AL, 5 + Or AL, 10h + Call SBOut + + Mov AX, DMASize + ShR AX, 1 + Dec AX + + Call SBOut ; DMALength, Lo + Mov AL, AH + Call SBOut + + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartSB16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Call GetSBMixConst + + ; Parags to allocate = (4/(.4*31*16))*MixSpeed + 2080 + ; = .02016129*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + + Mov AX, 1322 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SB16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + Sub DX, 2080 + Mov MixSegmentLength, DX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov DX, 330h + Call DetectUART + JC DetectMIDI1 + + Mov MIDIPort, 330h + Jmp DetectMIDIEnd + +DetectMIDI1: + Mov DX, 300h + Call DetectUART + JC DetectMIDIEnd + + Mov MIDIPort, 300h + +DetectMIDIEnd: + + Mov SI, Offset SB16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, BasePort + Mov DX, AX + Call ResetDSP + + Call ResetUART + Call ResetIRQ + ; Delay.. + Mov DX, BasePort + Add DL, 0Ch + + Mov CX, 1000 +ReInitSound1: + In AL, DX + Loop ReInitSound1 + + Call SetIRQ + Call ReinitUART + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov DX, CS:BasePort + Add DL, 0Ch + + Mov AL, 0D3h + Call SBOut + + Mov AL, 0D5h + Call SBOut + + Mov AL, 0D9h + Call SBOut + + Mov AL, 0D5h + Call SBOut + + Call ResetUART + + Mov AX, BasePort + Call ResetDSP + + Call ResetDSPDMA + Call ResetDSPIRQ + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Dec CX + JNZ SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov CS:Stereo, AL + Mov AX, CS:BasePort + Call ResetDSP + + Mov ES, CS:MixSegment + Mov CX, CS:MixSegmentLength + Mov DI, MIXTABLESIZE + ShL CX, 2 + Xor EAX, EAX + Rep StosD + + Call StartSB16 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SB16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SB16C.ASM b/SoundDrivers/SB16C.ASM index fe951d9..a54c8e1 100755 --- a/SoundDrivers/SB16C.ASM +++ b/SoundDrivers/SB16C.ASM @@ -1,1695 +1,1695 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB16 -MIXTABLESIZE EQU 2*256*65 - -SB16Msg DB "Sound Blaster 16 detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SB16NoMemoryMsg DB "Sound Blaster 16 detected", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster 16 reinitialised", 0 - -DSPVersion DW 0 -DSPIRQValue DB 0 -DSPDMAValue DB 0 -Forced DB 0 -Stereo DB 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 -MixSegmentLength DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -DMASize DW 2048 - -IMR DW 0 -OldIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SB16ScreenList Label - DW 8 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr DriverText - - DW Near Ptr MasterVolumeLeft ; 8 - DW Near Ptr MasterVolumeRight ; 9 - DW Near Ptr TrebleVolumeLeft ; 10 - DW Near Ptr TrebleVolumeRight ; 11 - DW Near Ptr BassVolumeLeft ; 12 - DW Near Ptr BassVolumeRight ; 13 - - DW Near Ptr MixFrequencyText - - DW 0 - -SB16HeaderLine DW 10 - DB "Sound Blaster 16 Lite Driver", 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "Sound Blaster 16 Driver 1.0 for Impulse Tracker", 0 - -VolumeText DW 1 - DB 2, 13 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB 13 - DB 13 - DB "Treble Left", 13 - DB "Treble Right", 13 - DB "Bass Left", 13 - DB "Bass Right", 13 - DB 0 - -MixFrequencyText DW 1 - DB 2, 23 - DB 20h - DB "Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 45454 - -VolumeBox1 DW 0 - DB 21, 12, 27, 15 - DB 25 - -VolumeBox2 DW 0 - DB 14, 16, 18, 21 - DB 25 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MasterVolumeLeft DW 9 - DB 22, 13 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 14 - DW 0, 31 - DW 9, 1 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 15, 17 - DW 0, 15 - DW 9, 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 15, 18 - DW 0, 15 - DW 9, 3 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 15, 19 - DW 0, 15 - DW 9, 4 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 15, 20 - DW 0, 15 - DW 9, 5 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -VolumeTable DB 6 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 45454 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPIRQ - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPIRQValue - Mov AL, 80h - Out DX, AX - - Ret - -EndP ResetDSPIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPDMA - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPDMAValue - Mov AL, 81h - Out DX, AX - - Ret - -EndP ResetDSPDMA - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AH, 4 ; SB DSP = 4.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - Add DL, 04h-0Eh ; 2x4h = Mixer index port - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov DSPIRQValue, AL - ; OK.. now get IRQ, or set IRQ - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - StC - Ret - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: ; Detect DMA - Mov AL, 81h ; DMA select - Out DX, AL - Inc DL - In AL, DX ; AL = DMA - Dec DL - - Mov DSPDMAValue, AL - - Mov BX, DMA - Cmp BX, 0FFFFh - JE DetectCardDMA1 - Cmp Forced, 0 - JE DetectCardDMA1 - - Mov CL, 1 - Cmp BX, 1 - JB SetCardDMA1 - - Mov CL, 2 - JE SetCardDMA1 - - Cmp BX, 3 - JB DetectCard7 - - Mov CL, 8 - JE DetectCard7 - - Mov CL, 20h - Cmp BX, 5 - JB DetectCard7 - JE SetCardDMA1 - - Mov CL, 80h - Cmp BX, 7 - JA DetectCard7 - JE SetCardDMA1 - - Mov CL, 40h - -SetCardDMA1: - And AL, 0Bh - Test CL, 0Bh - JZ SetCardDMA4 - - Xor AL, AL - -SetCardDMA4: - Or CL, AL - - Mov AL, 81h - Out DX, AL - Inc DL - Mov AL, CL - Out DX, AL - Jmp DetectCard7 - -DetectCardDMA1: - Mov BX, 5 - Test AL, 20h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 40h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 80h - JNZ DetectCardDMA2 - - Mov BL, 0 - Test AL, 1 - JNZ DetectCardDMA2 - - Inc BL - Test AL, 2 - JNZ DetectCardDMA2 - - Add BL, 2 - Test AL, 8 - JNZ DetectCardDMA2 - -DetectCard8: - Call ResetDSPIRQ - StC - Ret - -DetectCardDMA2: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - - Cmp BX, DMA - JNE DetectCard8 - -DetectCardDMA3: - Mov DMA, BX - -DetectCard7: - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Add DX, DX - -MixSamples1: - Rep StosD ; } Memory write - -MixSamplesCont: - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Cmp Stereo, 0 - JNE Mix0ModeStereo - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AckIRQ - Assume DS:Driver - - Mov AL, 20h - Cmp IRQ, 7 - JBE AckIRQ1 - - Out 0A0h, AL - -AckIRQ1: - Out 20h, AL - Ret - -EndP AckIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SB16IRQHandler - - PushAD - Push DS - Push ES - - CLD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 0Fh - In AL, DX - - Call AckIRQ - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SB16IRQHandler2 - - Xor AX, AX - Xor BX, BX - -SB16IRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 4 ; Skip for mono - Mov CL, 2 ; Shift for mono - - Cmp Stereo, 0 - JE SB16IRQHandlerMono - - ShR BP, 1 - Inc CL - -SB16IRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SB16IRQHandler4 - Assume DS:Nothing - -SB16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SB16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SB16IRQHandler5 - - Mov DX, MixTransferRemaining - -SB16IRQHandler5: - Push DX - -SB16IRQHandler6: - MovSX EAX, Word Ptr [SI] - SAL EAX, CL - - Cmp EAX, -8000h - JL SB16IRQHandlerClip1 - Cmp EAX, 7FFFh - JG SB16IRQHandlerClip2 - -SB16IRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ SB16IRQHandler6 - -SB16MixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SB16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - -SBIRQEnd: - Pop ES - Pop DS - PopAD - IRet - -SB16IRQHandlerClip1: - Mov AX, 8000h - Jmp SB16IRQHandler7 - -SB16IRQHandlerClip2: - Mov AX, 7FFFh - Jmp SB16IRQHandler7 - -EndP SB16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SB16IRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSB16 ; - - PushA - Push ES - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0B6h ; 16 bit, DAC - Call SBOut - Mov AL, Stereo - ShL AL, 5 - Or AL, 10h - Call SBOut - - Mov AX, DMASize - ShR AX, 1 - Dec AX - - Call SBOut ; DMALength, Lo - Mov AL, AH - Call SBOut - - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartSB16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Call GetSBMixConst - - ; Parags to allocate = (4/(.4*31*16))*MixSpeed + 2080 - ; = .02016129*MixSpeed = (65536*.04032258*MixSpeed) / 65536 - - Mov AX, 1322 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SB16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - Sub DX, 2080 - Mov MixSegmentLength, DX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset SB16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, BasePort - Mov DX, AX - Call ResetDSP - - Call ResetIRQ - ; Delay.. - Mov DX, BasePort - Add DL, 0Ch - - Mov CX, 1000 -ReInitSound1: - In AL, DX - Loop ReInitSound1 - - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov DX, CS:BasePort - Add DL, 0Ch - - Mov AL, 0D3h - Call SBOut - - Mov AL, 0D5h - Call SBOut - - Mov AL, 0D9h - Call SBOut - - Mov AL, 0D5h - Call SBOut - - Mov AX, BasePort - Call ResetDSP - - Call ResetDSPDMA - Call ResetDSPIRQ - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Dec CX - JNZ SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov CS:Stereo, AL - Mov AX, CS:BasePort - Call ResetDSP - - Mov ES, CS:MixSegment - Mov CX, CS:MixSegmentLength - Mov DI, MIXTABLESIZE - ShL CX, 2 - Xor EAX, EAX - Rep StosD - - Call StartSB16 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SB16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB16 +MIXTABLESIZE EQU 2*256*65 + +SB16Msg DB "Sound Blaster 16 detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SB16NoMemoryMsg DB "Sound Blaster 16 detected", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster 16 reinitialised", 0 + +DSPVersion DW 0 +DSPIRQValue DB 0 +DSPDMAValue DB 0 +Forced DB 0 +Stereo DB 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 +MixSegmentLength DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +DMASize DW 2048 + +IMR DW 0 +OldIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SB16ScreenList Label + DW 8 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr DriverText + + DW Near Ptr MasterVolumeLeft ; 8 + DW Near Ptr MasterVolumeRight ; 9 + DW Near Ptr TrebleVolumeLeft ; 10 + DW Near Ptr TrebleVolumeRight ; 11 + DW Near Ptr BassVolumeLeft ; 12 + DW Near Ptr BassVolumeRight ; 13 + + DW Near Ptr MixFrequencyText + + DW 0 + +SB16HeaderLine DW 10 + DB "Sound Blaster 16 Lite Driver", 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "Sound Blaster 16 Driver 1.0 for Impulse Tracker", 0 + +VolumeText DW 1 + DB 2, 13 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB 13 + DB 13 + DB "Treble Left", 13 + DB "Treble Right", 13 + DB "Bass Left", 13 + DB "Bass Right", 13 + DB 0 + +MixFrequencyText DW 1 + DB 2, 23 + DB 20h + DB "Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 45454 + +VolumeBox1 DW 0 + DB 21, 12, 27, 15 + DB 25 + +VolumeBox2 DW 0 + DB 14, 16, 18, 21 + DB 25 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MasterVolumeLeft DW 9 + DB 22, 13 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 14 + DW 0, 31 + DW 9, 1 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 15, 17 + DW 0, 15 + DW 9, 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 15, 18 + DW 0, 15 + DW 9, 3 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 15, 19 + DW 0, 15 + DW 9, 4 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 15, 20 + DW 0, 15 + DW 9, 5 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +VolumeTable DB 6 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 45454 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPIRQ + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPIRQValue + Mov AL, 80h + Out DX, AX + + Ret + +EndP ResetDSPIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPDMA + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPDMAValue + Mov AL, 81h + Out DX, AX + + Ret + +EndP ResetDSPDMA + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AH, 4 ; SB DSP = 4.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + Add DL, 04h-0Eh ; 2x4h = Mixer index port + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov DSPIRQValue, AL + ; OK.. now get IRQ, or set IRQ + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + StC + Ret + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: ; Detect DMA + Mov AL, 81h ; DMA select + Out DX, AL + Inc DL + In AL, DX ; AL = DMA + Dec DL + + Mov DSPDMAValue, AL + + Mov BX, DMA + Cmp BX, 0FFFFh + JE DetectCardDMA1 + Cmp Forced, 0 + JE DetectCardDMA1 + + Mov CL, 1 + Cmp BX, 1 + JB SetCardDMA1 + + Mov CL, 2 + JE SetCardDMA1 + + Cmp BX, 3 + JB DetectCard7 + + Mov CL, 8 + JE DetectCard7 + + Mov CL, 20h + Cmp BX, 5 + JB DetectCard7 + JE SetCardDMA1 + + Mov CL, 80h + Cmp BX, 7 + JA DetectCard7 + JE SetCardDMA1 + + Mov CL, 40h + +SetCardDMA1: + And AL, 0Bh + Test CL, 0Bh + JZ SetCardDMA4 + + Xor AL, AL + +SetCardDMA4: + Or CL, AL + + Mov AL, 81h + Out DX, AL + Inc DL + Mov AL, CL + Out DX, AL + Jmp DetectCard7 + +DetectCardDMA1: + Mov BX, 5 + Test AL, 20h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 40h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 80h + JNZ DetectCardDMA2 + + Mov BL, 0 + Test AL, 1 + JNZ DetectCardDMA2 + + Inc BL + Test AL, 2 + JNZ DetectCardDMA2 + + Add BL, 2 + Test AL, 8 + JNZ DetectCardDMA2 + +DetectCard8: + Call ResetDSPIRQ + StC + Ret + +DetectCardDMA2: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + + Cmp BX, DMA + JNE DetectCard8 + +DetectCardDMA3: + Mov DMA, BX + +DetectCard7: + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Add DX, DX + +MixSamples1: + Rep StosD ; } Memory write + +MixSamplesCont: + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Cmp Stereo, 0 + JNE Mix0ModeStereo + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AckIRQ + Assume DS:Driver + + Mov AL, 20h + Cmp IRQ, 7 + JBE AckIRQ1 + + Out 0A0h, AL + +AckIRQ1: + Out 20h, AL + Ret + +EndP AckIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SB16IRQHandler + + PushAD + Push DS + Push ES + + CLD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 0Fh + In AL, DX + + Call AckIRQ + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SB16IRQHandler2 + + Xor AX, AX + Xor BX, BX + +SB16IRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 4 ; Skip for mono + Mov CL, 2 ; Shift for mono + + Cmp Stereo, 0 + JE SB16IRQHandlerMono + + ShR BP, 1 + Inc CL + +SB16IRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SB16IRQHandler4 + Assume DS:Nothing + +SB16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SB16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SB16IRQHandler5 + + Mov DX, MixTransferRemaining + +SB16IRQHandler5: + Push DX + +SB16IRQHandler6: + MovSX EAX, Word Ptr [SI] + SAL EAX, CL + + Cmp EAX, -8000h + JL SB16IRQHandlerClip1 + Cmp EAX, 7FFFh + JG SB16IRQHandlerClip2 + +SB16IRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ SB16IRQHandler6 + +SB16MixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SB16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + +SBIRQEnd: + Pop ES + Pop DS + PopAD + IRet + +SB16IRQHandlerClip1: + Mov AX, 8000h + Jmp SB16IRQHandler7 + +SB16IRQHandlerClip2: + Mov AX, 7FFFh + Jmp SB16IRQHandler7 + +EndP SB16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SB16IRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSB16 ; + + PushA + Push ES + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0B6h ; 16 bit, DAC + Call SBOut + Mov AL, Stereo + ShL AL, 5 + Or AL, 10h + Call SBOut + + Mov AX, DMASize + ShR AX, 1 + Dec AX + + Call SBOut ; DMALength, Lo + Mov AL, AH + Call SBOut + + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartSB16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Call GetSBMixConst + + ; Parags to allocate = (4/(.4*31*16))*MixSpeed + 2080 + ; = .02016129*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + + Mov AX, 1322 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SB16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + Sub DX, 2080 + Mov MixSegmentLength, DX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset SB16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, BasePort + Mov DX, AX + Call ResetDSP + + Call ResetIRQ + ; Delay.. + Mov DX, BasePort + Add DL, 0Ch + + Mov CX, 1000 +ReInitSound1: + In AL, DX + Loop ReInitSound1 + + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov DX, CS:BasePort + Add DL, 0Ch + + Mov AL, 0D3h + Call SBOut + + Mov AL, 0D5h + Call SBOut + + Mov AL, 0D9h + Call SBOut + + Mov AL, 0D5h + Call SBOut + + Mov AX, BasePort + Call ResetDSP + + Call ResetDSPDMA + Call ResetDSPIRQ + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Dec CX + JNZ SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov CS:Stereo, AL + Mov AX, CS:BasePort + Call ResetDSP + + Mov ES, CS:MixSegment + Mov CX, CS:MixSegmentLength + Mov DI, MIXTABLESIZE + ShL CX, 2 + Xor EAX, EAX + Rep StosD + + Call StartSB16 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SB16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SB16D.ASM b/SoundDrivers/SB16D.ASM index f50716c..c2685f0 100755 --- a/SoundDrivers/SB16D.ASM +++ b/SoundDrivers/SB16D.ASM @@ -1,2665 +1,2665 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 -MIXTABLESIZE EQU 2*256*65 -FOURIERBUFFERLENGTH EQU 2048 - -SB16Msg DB "Sound Blaster 16 detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SB16NoMemoryMsg DB "Sound Blaster 16 detected", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster 16 reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITSB16.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITSB16.DRV", 0 - -DriverName DB "ITSB16.DRV", 0 - -DSPVersion DW 0 -DSPIRQValue DB 0 -DSPDMAValue DB 0 -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 -; MixVolumeSet DW 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 -FourierSegment DW 0 -MixSegmentLength DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 10 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 -Surround DW 0 -DMASize DW 2048 - -IMR DW 0 -OldIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MIDIPort DW 0 -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SB16ScreenList Label - DW 8 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr DriverText - - DW Near Ptr MasterVolumeLeft ; 8 - DW Near Ptr MasterVolumeRight ; 9 - DW Near Ptr TrebleVolumeLeft ; 10 - DW Near Ptr TrebleVolumeRight ; 11 - DW Near Ptr BassVolumeLeft ; 12 - DW Near Ptr BassVolumeRight ; 13 - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 15 - DW Near Ptr MixModeButton2 ; 16 - DW Near Ptr MixModeButton3 ; 17 - DW Near Ptr MixModeButton4 ; 18 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 20 - DW Near Ptr FilterButton2 ; 21 - DW Near Ptr FilterButton3 ; 22 - - DW Near Ptr StereoText - DW Near Ptr StereoButton1 ; 24 - DW Near Ptr StereoButton2 ; 25 - DW Near Ptr StereoButton3 ; 25 - - DW Near Ptr FrequencyText - - DW 0 - - -SB16HeaderLine DW 10 - DB "Sound Blaster 16 Driver", 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 - -VolumeText DW 1 - DB 2, 13 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB 13 - DB 13 - DB "Treble Left", 13 - DB "Treble Right", 13 - DB "Bass Left", 13 - DB "Bass Right", 13 - DB 0 - -VolumeBox1 DW 0 - DB 21, 12, 27, 15 - DB 25 - -VolumeBox2 DW 0 - DB 14, 16, 18, 21 - DB 25 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MasterVolumeLeft DW 9 - DB 22, 13 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 14 - DW 0, 31 - DW 9, 1 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 15, 17 - DW 0, 15 - DW 9, 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 15, 18 - DW 0, 15 - DW 9, 3 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 15, 19 - DW 0, 15 - DW 9, 4 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 15, 20 - DW 0, 15 - DW 9, 5 - DW 12, 15, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 23 - DB 20h - DB "Mixing Mode", 0 - -FrequencyText DW 1 - DB 2, 48 - DB 20h - DB "Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 45454 - -MixModeButton1 DW 2 - DW 13, 16, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 15, 17, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 28, 32, 30, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 16, 18, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 31, 32, 33, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 17, 20, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 34, 32, 36, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 40, 13 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 18, 21, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 42, 15, 60, 17, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 20, 22, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 42, 18, 60, 20, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 21, 24, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 42, 21, 60, 23, 8 - DB 0 - DB " 75% Filter", 0 - -StereoText DW 1 - DB 40, 25 - DB 20h - DB "Feedback mode", 0 - -StereoButton1 DW 2 - DW 22, 25, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetSurround -DriverSegment15 DW 0 - DW 0 - DW Offset SetSurround -DriverSegment16 DW 0 - DB 42, 27, 60, 29, 8 - DB 0 - DB " None", 0 - -StereoButton2 DW 2 - DW 24, 26, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetSurround -DriverSegment17 DW 0 - DW 1 - DW Offset SetSurround -DriverSegment18 DW 0 - DB 42, 30, 60, 32, 8 - DB 0 - DB " 50% Separated", 0 - -StereoButton3 DW 2 - DW 25, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetSurround -DriverSegment19 DW 0 - DW 2 - DW Offset SetSurround -DriverSegment20 DW 0 - DB 42, 33, 60, 35, 8 - DB 0 - DB " 50% Crossed", 0 - - -VolumeTable DB 6 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include dmasirq.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW Offset DriverSegment15, Offset DriverSegment16 - DW Offset DriverSegment17, Offset DriverSegment18 - DW Offset DriverSegment19, Offset DriverSegment20 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectUART ; Given DX = Port - -; From SB-DevKit - - ClI - - Inc DX - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 40h ; Ready for output - LoopNZ DetectUART1 - JNZ DetectUARTError - - Mov AL, 0FFh ; Reset! - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - JNZ DetectUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART4 - -DetectUART3: - Loop DetectUART2 - -DetectUARTError: - StI - StC - Ret - -DetectUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -DetectUART5: - In AL, DX - Test AL, 40h - LoopNZ DetectUART5 - JNZ DetectUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -DetectUART6: - Xor CX, CX - -DetectUART7: - In AL, DX - Test AL, 80h - JNZ DetectUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART9 - -DetectUART8: - Loop DetectUART7 - - Jmp DetectUARTError - -DetectUART9: - StI - ClC - Ret - -EndP DetectUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReinitUART - - Mov DX, MIDIPort - Test DX, DX - JZ ReinitUART1 - - Call DetectUART - -ReinitUART1: - Ret - -EndP ReinitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, MIDIPort - Test DX, DX - JZ ResetUART1 - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSurround Far - - Push CS - Pop ES - Mov DI, Offset Surround - - Ret - -EndP GetSurround - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSurround Far - - Mov AX, [SI+22] - Mov CS:Surround, AX - -; Mov AX, CS:MixVolumeSet -; Call Far Ptr SetMixVolumeChain - - Jmp SetMixModeChain - -EndP SetSurround - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 45454 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - Mov BX, 12000 - Xor DX, DX - Div BX - Mov FourierBufferStepOffset, AX - Mov FourierBufferStepFractional, DX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPIRQ - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPIRQValue - Mov AL, 80h - Out DX, AX - - Ret - -EndP ResetDSPIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPDMA - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPDMAValue - Mov AL, 81h - Out DX, AX - - Ret - -EndP ResetDSPDMA - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AH, 4 ; SB DSP = 4.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - Add DL, 04h-0Eh ; 2x4h = Mixer index port - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov DSPIRQValue, AL - ; OK.. now get IRQ, or set IRQ - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - StC - Ret - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: ; Detect DMA - Mov AL, 81h ; DMA select - Out DX, AL - Inc DL - In AL, DX ; AL = DMA - Dec DL - - Mov DSPDMAValue, AL - - Mov BX, DMA - Cmp BX, 0FFFFh - JE DetectCardDMA1 - Cmp Forced, 0 - JE DetectCardDMA1 - - Mov CL, 1 - Cmp BX, 1 - JB SetCardDMA1 - - Mov CL, 2 - JE SetCardDMA1 - - Cmp BX, 3 - JB DetectCard7 - - Mov CL, 8 - JE DetectCard7 - - Mov CL, 20h - Cmp BX, 5 - JB DetectCard7 - JE SetCardDMA1 - - Mov CL, 80h - Cmp BX, 7 - JA DetectCard7 - JE SetCardDMA1 - - Mov CL, 40h - -SetCardDMA1: - And AL, 0Bh - Test CL, 0Bh - JZ SetCardDMA4 - - Xor AL, AL - -SetCardDMA4: - Or CL, AL - - Mov AL, 81h - Out DX, AL - Inc DL - Mov AL, CL - Out DX, AL - Jmp DetectCard7 - -DetectCardDMA1: - Mov BX, 5 - Test AL, 20h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 40h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 80h - JNZ DetectCardDMA2 - - Mov BL, 0 - Test AL, 1 - JNZ DetectCardDMA2 - - Inc BL - Test AL, 2 - JNZ DetectCardDMA2 - - Add BL, 2 - Test AL, 8 - JNZ DetectCardDMA2 - -DetectCard8: - Call ResetDSPIRQ - StC - Ret - -DetectCardDMA2: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - - Cmp BX, DMA - JNE DetectCard8 - -DetectCardDMA3: - Mov DMA, BX - -DetectCard7: - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - - Cmp Surround, 1 - JB MixSamplesCont - - Push DS - - Push ES - Pop DS - - JE MixSurround3 - -Surround1: - Mov EAX, [DI+4] - Mov EBX, [DI] - SAR EAX, 1 - SAR EBX, 1 - Mov [DI], EAX - Mov [DI+4], EBX - - Add DI, 8 - Sub CX, 2 - JNZ Surround1 - - Pop DS - Jmp SurroundCont - -MixSamples1: - Cmp Surround, 1 - JB MixSamplesCont - -MixSurround2: - Push DS - - Push ES - Pop DS - -MixSurround3: - SAR DWord Ptr [DI], 1 - Add DI, 4 - Dec CX - JNZ MixSurround3 - - Pop DS - Jmp SurroundCont - -MixSamplesCont: - Xor EAX, EAX - Rep StosD ; } Memory write - -SurroundCont: - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include fourier.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AckIRQ - Assume DS:Driver - - Mov AL, 20h - Cmp CS:IRQ, 7 - JBE AckIRQ1 - - Out 0A0h, AL - -AckIRQ1: - Out 20h, AL - Ret - -EndP AckIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Mov DX, MIDIPort - - Mov BL, [MIDIBufferTail] - Test DX, DX - JZ CheckMIDIEnd - - Inc DX - Mov CX, 0FFFFh - -CheckMIDIAgain: - In AL, DX - - Test AL, 80h - LoopNZ CheckMIDIAgain - - Dec DX - In AL, DX - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL -; Jmp CheckMIDIAgain - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SB16IRQHandler - - PushAD - Push DS - Push ES - - CLD - -SBIRQAgain: - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 4 ; Mixer Port - Mov AL, 82h - Out DX, AL - Inc DL ; DX = BasePort+5 - In AL, DX - - Test AL, 4 - JZ SBMIDIInterruptEnd - - Push AX - Call CheckMIDI - Pop AX - -SBMIDIInterruptEnd: - Test AL, 2 - JNZ SBDigitalInterrupt - - Call AckIRQ - Jmp SBIRQEnd - -SBDigitalInterrupt: - Mov DX, BasePort - Add DL, 0Fh - In AL, DX ; 16-bit IRQ ack. - - Call AckIRQ - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - -DMA16BITADJUST EQU $ - ShL BX, 1 - - Cmp BX, DMABUFFERLENGTH/2 - JB SB16IRQHandler2 - - Mov AX, DMABUFFERLENGTH/2 - -SB16IRQHandler2: - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE SB16IRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -SB16IRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SB16IRQHandler4 - Assume DS:Nothing - -SB16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - Call UpdateFourierBuffer - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SB16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SB16IRQHandler5 - - Mov DX, MixTransferRemaining - -SB16IRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB SB16IRQHandler6 - JE SB16IRQHFilter - - Cmp CS:Stereo, 0 - JE SB16IRQ3QFilterMono - -SB16IRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -SB16IRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL SB163QFilterStereoClip1 - Cmp EAX, 7FFFh - JG SB163QFilterStereoClip2 - -SB16IRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL SB163QFilterStereoClip3 - Cmp EAX, 7FFFh - JG SB163QFilterStereoClip4 - -SB16IRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ SB16IRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp SB16MixTransferEnd - -SB16IRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -SB16IRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL SB163QFilterMonoClip1 - Cmp EAX, 7FFFh - JG SB163QFilterMonoClip2 - -SB16IRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ SB16IRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp SB16MixTransferEnd - -SB16IRQHFilter: - Cmp CS:Stereo, 0 - JE SB16IRQHFilterMono - -SB16IRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -SB16IRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL SB16HFilterStereoClip1 - Cmp EAX, 7FFFh - JG SB16HFilterStereoClip2 - -SB16IRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL SB16HFilterStereoClip3 - Cmp EAX, 7FFFh - JG SB16HFilterStereoClip4 - -SB16IRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ SB16IRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp SB16MixTransferEnd - -SB16IRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -SB16IRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL SB16HFilterMonoClip1 - Cmp EAX, 7FFFh - JG SB16HFilterMonoClip2 - -SB16IRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ SB16IRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp SB16MixTransferEnd - -SB16IRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL SB16IRQHandlerClip1 - Cmp EAX, 7FFFh - JG SB16IRQHandlerClip2 - -SB16IRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ SB16IRQHandler6 - -SB16MixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SB16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - -SBIRQEnd: - - Pop ES - Pop DS - PopAD - IRet - -SB16IRQHandlerClip1: - Mov AX, 8000h - Jmp SB16IRQHandler7 - -SB16IRQHandlerClip2: - Mov AX, 7FFFh - Jmp SB16IRQHandler7 - -SB16HFilterMonoClip1: - Mov AX, 8000h - Jmp SB16IRQHFilterMono2 - -SB16HFilterMonoClip2: - Mov AX, 7FFFh - Jmp SB16IRQHFilterMono2 - -SB16HFilterStereoClip1: - Mov AX, 8000h - Jmp SB16IRQHFilterStereo2 - -SB16HFilterStereoClip2: - Mov AX, 7FFFh - Jmp SB16IRQHFilterStereo2 - -SB16HFilterStereoClip3: - Mov AX, 8000h - Jmp SB16IRQHFilterStereo3 - -SB16HFilterStereoClip4: - Mov AX, 7FFFh - Jmp SB16IRQHFilterStereo3 - -SB163QFilterMonoClip1: - Mov AX, 8000h - Jmp SB16IRQ3QFilterMono2 - -SB163QFilterMonoClip2: - Mov AX, 7FFFh - Jmp SB16IRQ3QFilterMono2 - -SB163QFilterStereoClip1: - Mov AX, 8000h - Jmp SB16IRQ3QFilterStereo2 - -SB163QFilterStereoClip2: - Mov AX, 7FFFh - Jmp SB16IRQ3QFilterStereo2 - -SB163QFilterStereoClip3: - Mov AX, 8000h - Jmp SB16IRQ3QFilterStereo3 - -SB163QFilterStereoClip4: - Mov AX, 7FFFh - Jmp SB16IRQ3QFilterStereo3 - -EndP SB16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SB16IRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSB16 ; - - PushA - Push ES - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Cmp DX, 3 - JA StartSB16B - - Mov Word Ptr [DMA16BITADJUST], 9090h - -StartSB16B: - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0B6h ; 16 bit, DAC - Call SBOut - Mov AL, Stereo - ShL AL, 5 - Or AL, 10h - Call SBOut - - Mov AX, DMASize - ShR AX, 1 - Dec AX - - Call SBOut ; DMALength, Lo - Mov AL, AH - Call SBOut - - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartSB16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Call GetSBMixConst - - ; Parags to allocate = (8/(.4*31*16))*MixSpeed + 2080 - ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 + (FOURIERBUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SB16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - Add AX, (DMABUFFERLENGTH*2)/16 - Mov FourierSegment, AX - Sub DX, 2080 - Mov MixSegmentLength, DX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov DX, 330h - Call DetectUART - JC DetectMIDI1 - - Mov MIDIPort, 330h - Jmp DetectMIDIEnd - -DetectMIDI1: - Mov DX, 300h - Call DetectUART - JC DetectMIDIEnd - - Mov MIDIPort, 300h - -DetectMIDIEnd: - Mov SI, Offset SB16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, BasePort - Call ResetDSP - - Call ResetUART - Call ResetIRQ - - ; Delay.. - Mov DX, BasePort - Add DL, 0Ch - - Mov CX, 1000 -ReInitSound1: - In AL, DX - Loop ReInitSound1 - - Call SetIRQ - Call ReinitUART - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov DX, CS:BasePort - Add DL, 0Ch - - Mov AL, 0D9h - Call SBOut - - Call ResetUART - - Mov AX, BasePort - Call ResetDSP - - Call ResetDSPDMA - Call ResetDSPIRQ - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - -; Mov CS:MixVolumeSet, AX - -; SetMixVolumeChain: - PushA - Push DS - -; Cmp CS:Surround, 0 -; JE SetMixVolumeSurround -; -; Mov BX, 49152 -; Mul BX -; Mov AX, DX -; -; SetMixVolumeSurround: - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, AX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Dec CX - JNZ SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov CS:Stereo, AL - Mov AX, CS:BasePort - Call ResetDSP - - Mov ES, CS:MixSegment - Mov CX, CS:MixSegmentLength - Mov DI, MIXTABLESIZE - ShL CX, 2 - Xor EAX, EAX - Rep StosD - - Call StartSB16 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SB16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWaveForm Far ; Given ES:DI = destination - Assume DS:Nothing ; want 2048 samples. - - PushA - Push DS - - Mov DS, FourierSegment - Mov SI, FourierBufferStart - Mov CX, 2048 - -GetWaveForm1: - MovsW - And SI, (FOURIERBUFFERLENGTH*2)-1 - Loop GetWaveForm1 - - Pop DS - PopA - - Ret - -EndP GetWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 -DriverFlags DW 4 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW 0 - DW Offset GetWaveform - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 +MIXTABLESIZE EQU 2*256*65 +FOURIERBUFFERLENGTH EQU 2048 + +SB16Msg DB "Sound Blaster 16 detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SB16NoMemoryMsg DB "Sound Blaster 16 detected", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster 16 reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITSB16.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITSB16.DRV", 0 + +DriverName DB "ITSB16.DRV", 0 + +DSPVersion DW 0 +DSPIRQValue DB 0 +DSPDMAValue DB 0 +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 +; MixVolumeSet DW 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 +FourierSegment DW 0 +MixSegmentLength DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 10 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 +Surround DW 0 +DMASize DW 2048 + +IMR DW 0 +OldIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MIDIPort DW 0 +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SB16ScreenList Label + DW 8 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr DriverText + + DW Near Ptr MasterVolumeLeft ; 8 + DW Near Ptr MasterVolumeRight ; 9 + DW Near Ptr TrebleVolumeLeft ; 10 + DW Near Ptr TrebleVolumeRight ; 11 + DW Near Ptr BassVolumeLeft ; 12 + DW Near Ptr BassVolumeRight ; 13 + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 15 + DW Near Ptr MixModeButton2 ; 16 + DW Near Ptr MixModeButton3 ; 17 + DW Near Ptr MixModeButton4 ; 18 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 20 + DW Near Ptr FilterButton2 ; 21 + DW Near Ptr FilterButton3 ; 22 + + DW Near Ptr StereoText + DW Near Ptr StereoButton1 ; 24 + DW Near Ptr StereoButton2 ; 25 + DW Near Ptr StereoButton3 ; 25 + + DW Near Ptr FrequencyText + + DW 0 + + +SB16HeaderLine DW 10 + DB "Sound Blaster 16 Driver", 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 + +VolumeText DW 1 + DB 2, 13 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB 13 + DB 13 + DB "Treble Left", 13 + DB "Treble Right", 13 + DB "Bass Left", 13 + DB "Bass Right", 13 + DB 0 + +VolumeBox1 DW 0 + DB 21, 12, 27, 15 + DB 25 + +VolumeBox2 DW 0 + DB 14, 16, 18, 21 + DB 25 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MasterVolumeLeft DW 9 + DB 22, 13 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 14 + DW 0, 31 + DW 9, 1 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 15, 17 + DW 0, 15 + DW 9, 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 15, 18 + DW 0, 15 + DW 9, 3 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 15, 19 + DW 0, 15 + DW 9, 4 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 15, 20 + DW 0, 15 + DW 9, 5 + DW 12, 15, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 23 + DB 20h + DB "Mixing Mode", 0 + +FrequencyText DW 1 + DB 2, 48 + DB 20h + DB "Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 45454 + +MixModeButton1 DW 2 + DW 13, 16, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 15, 17, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 28, 32, 30, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 16, 18, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 31, 32, 33, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 17, 20, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 34, 32, 36, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 40, 13 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 18, 21, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 42, 15, 60, 17, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 20, 22, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 42, 18, 60, 20, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 21, 24, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 42, 21, 60, 23, 8 + DB 0 + DB " 75% Filter", 0 + +StereoText DW 1 + DB 40, 25 + DB 20h + DB "Feedback mode", 0 + +StereoButton1 DW 2 + DW 22, 25, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetSurround +DriverSegment15 DW 0 + DW 0 + DW Offset SetSurround +DriverSegment16 DW 0 + DB 42, 27, 60, 29, 8 + DB 0 + DB " None", 0 + +StereoButton2 DW 2 + DW 24, 26, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetSurround +DriverSegment17 DW 0 + DW 1 + DW Offset SetSurround +DriverSegment18 DW 0 + DB 42, 30, 60, 32, 8 + DB 0 + DB " 50% Separated", 0 + +StereoButton3 DW 2 + DW 25, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetSurround +DriverSegment19 DW 0 + DW 2 + DW Offset SetSurround +DriverSegment20 DW 0 + DB 42, 33, 60, 35, 8 + DB 0 + DB " 50% Crossed", 0 + + +VolumeTable DB 6 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include dmasirq.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW Offset DriverSegment15, Offset DriverSegment16 + DW Offset DriverSegment17, Offset DriverSegment18 + DW Offset DriverSegment19, Offset DriverSegment20 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectUART ; Given DX = Port + +; From SB-DevKit + + ClI + + Inc DX + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 40h ; Ready for output + LoopNZ DetectUART1 + JNZ DetectUARTError + + Mov AL, 0FFh ; Reset! + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + JNZ DetectUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART4 + +DetectUART3: + Loop DetectUART2 + +DetectUARTError: + StI + StC + Ret + +DetectUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +DetectUART5: + In AL, DX + Test AL, 40h + LoopNZ DetectUART5 + JNZ DetectUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +DetectUART6: + Xor CX, CX + +DetectUART7: + In AL, DX + Test AL, 80h + JNZ DetectUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART9 + +DetectUART8: + Loop DetectUART7 + + Jmp DetectUARTError + +DetectUART9: + StI + ClC + Ret + +EndP DetectUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReinitUART + + Mov DX, MIDIPort + Test DX, DX + JZ ReinitUART1 + + Call DetectUART + +ReinitUART1: + Ret + +EndP ReinitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, MIDIPort + Test DX, DX + JZ ResetUART1 + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSurround Far + + Push CS + Pop ES + Mov DI, Offset Surround + + Ret + +EndP GetSurround + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSurround Far + + Mov AX, [SI+22] + Mov CS:Surround, AX + +; Mov AX, CS:MixVolumeSet +; Call Far Ptr SetMixVolumeChain + + Jmp SetMixModeChain + +EndP SetSurround + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 45454 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + Mov BX, 12000 + Xor DX, DX + Div BX + Mov FourierBufferStepOffset, AX + Mov FourierBufferStepFractional, DX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPIRQ + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPIRQValue + Mov AL, 80h + Out DX, AX + + Ret + +EndP ResetDSPIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPDMA + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPDMAValue + Mov AL, 81h + Out DX, AX + + Ret + +EndP ResetDSPDMA + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AH, 4 ; SB DSP = 4.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + Add DL, 04h-0Eh ; 2x4h = Mixer index port + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov DSPIRQValue, AL + ; OK.. now get IRQ, or set IRQ + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + StC + Ret + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: ; Detect DMA + Mov AL, 81h ; DMA select + Out DX, AL + Inc DL + In AL, DX ; AL = DMA + Dec DL + + Mov DSPDMAValue, AL + + Mov BX, DMA + Cmp BX, 0FFFFh + JE DetectCardDMA1 + Cmp Forced, 0 + JE DetectCardDMA1 + + Mov CL, 1 + Cmp BX, 1 + JB SetCardDMA1 + + Mov CL, 2 + JE SetCardDMA1 + + Cmp BX, 3 + JB DetectCard7 + + Mov CL, 8 + JE DetectCard7 + + Mov CL, 20h + Cmp BX, 5 + JB DetectCard7 + JE SetCardDMA1 + + Mov CL, 80h + Cmp BX, 7 + JA DetectCard7 + JE SetCardDMA1 + + Mov CL, 40h + +SetCardDMA1: + And AL, 0Bh + Test CL, 0Bh + JZ SetCardDMA4 + + Xor AL, AL + +SetCardDMA4: + Or CL, AL + + Mov AL, 81h + Out DX, AL + Inc DL + Mov AL, CL + Out DX, AL + Jmp DetectCard7 + +DetectCardDMA1: + Mov BX, 5 + Test AL, 20h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 40h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 80h + JNZ DetectCardDMA2 + + Mov BL, 0 + Test AL, 1 + JNZ DetectCardDMA2 + + Inc BL + Test AL, 2 + JNZ DetectCardDMA2 + + Add BL, 2 + Test AL, 8 + JNZ DetectCardDMA2 + +DetectCard8: + Call ResetDSPIRQ + StC + Ret + +DetectCardDMA2: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + + Cmp BX, DMA + JNE DetectCard8 + +DetectCardDMA3: + Mov DMA, BX + +DetectCard7: + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + + Cmp Surround, 1 + JB MixSamplesCont + + Push DS + + Push ES + Pop DS + + JE MixSurround3 + +Surround1: + Mov EAX, [DI+4] + Mov EBX, [DI] + SAR EAX, 1 + SAR EBX, 1 + Mov [DI], EAX + Mov [DI+4], EBX + + Add DI, 8 + Sub CX, 2 + JNZ Surround1 + + Pop DS + Jmp SurroundCont + +MixSamples1: + Cmp Surround, 1 + JB MixSamplesCont + +MixSurround2: + Push DS + + Push ES + Pop DS + +MixSurround3: + SAR DWord Ptr [DI], 1 + Add DI, 4 + Dec CX + JNZ MixSurround3 + + Pop DS + Jmp SurroundCont + +MixSamplesCont: + Xor EAX, EAX + Rep StosD ; } Memory write + +SurroundCont: + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include fourier.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AckIRQ + Assume DS:Driver + + Mov AL, 20h + Cmp CS:IRQ, 7 + JBE AckIRQ1 + + Out 0A0h, AL + +AckIRQ1: + Out 20h, AL + Ret + +EndP AckIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Mov DX, MIDIPort + + Mov BL, [MIDIBufferTail] + Test DX, DX + JZ CheckMIDIEnd + + Inc DX + Mov CX, 0FFFFh + +CheckMIDIAgain: + In AL, DX + + Test AL, 80h + LoopNZ CheckMIDIAgain + + Dec DX + In AL, DX + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL +; Jmp CheckMIDIAgain + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SB16IRQHandler + + PushAD + Push DS + Push ES + + CLD + +SBIRQAgain: + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 4 ; Mixer Port + Mov AL, 82h + Out DX, AL + Inc DL ; DX = BasePort+5 + In AL, DX + + Test AL, 4 + JZ SBMIDIInterruptEnd + + Push AX + Call CheckMIDI + Pop AX + +SBMIDIInterruptEnd: + Test AL, 2 + JNZ SBDigitalInterrupt + + Call AckIRQ + Jmp SBIRQEnd + +SBDigitalInterrupt: + Mov DX, BasePort + Add DL, 0Fh + In AL, DX ; 16-bit IRQ ack. + + Call AckIRQ + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + +DMA16BITADJUST EQU $ + ShL BX, 1 + + Cmp BX, DMABUFFERLENGTH/2 + JB SB16IRQHandler2 + + Mov AX, DMABUFFERLENGTH/2 + +SB16IRQHandler2: + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE SB16IRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +SB16IRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SB16IRQHandler4 + Assume DS:Nothing + +SB16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + Call UpdateFourierBuffer + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SB16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SB16IRQHandler5 + + Mov DX, MixTransferRemaining + +SB16IRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB SB16IRQHandler6 + JE SB16IRQHFilter + + Cmp CS:Stereo, 0 + JE SB16IRQ3QFilterMono + +SB16IRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +SB16IRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL SB163QFilterStereoClip1 + Cmp EAX, 7FFFh + JG SB163QFilterStereoClip2 + +SB16IRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL SB163QFilterStereoClip3 + Cmp EAX, 7FFFh + JG SB163QFilterStereoClip4 + +SB16IRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ SB16IRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp SB16MixTransferEnd + +SB16IRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +SB16IRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL SB163QFilterMonoClip1 + Cmp EAX, 7FFFh + JG SB163QFilterMonoClip2 + +SB16IRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ SB16IRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp SB16MixTransferEnd + +SB16IRQHFilter: + Cmp CS:Stereo, 0 + JE SB16IRQHFilterMono + +SB16IRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +SB16IRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL SB16HFilterStereoClip1 + Cmp EAX, 7FFFh + JG SB16HFilterStereoClip2 + +SB16IRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL SB16HFilterStereoClip3 + Cmp EAX, 7FFFh + JG SB16HFilterStereoClip4 + +SB16IRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ SB16IRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp SB16MixTransferEnd + +SB16IRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +SB16IRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL SB16HFilterMonoClip1 + Cmp EAX, 7FFFh + JG SB16HFilterMonoClip2 + +SB16IRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ SB16IRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp SB16MixTransferEnd + +SB16IRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL SB16IRQHandlerClip1 + Cmp EAX, 7FFFh + JG SB16IRQHandlerClip2 + +SB16IRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ SB16IRQHandler6 + +SB16MixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SB16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + +SBIRQEnd: + + Pop ES + Pop DS + PopAD + IRet + +SB16IRQHandlerClip1: + Mov AX, 8000h + Jmp SB16IRQHandler7 + +SB16IRQHandlerClip2: + Mov AX, 7FFFh + Jmp SB16IRQHandler7 + +SB16HFilterMonoClip1: + Mov AX, 8000h + Jmp SB16IRQHFilterMono2 + +SB16HFilterMonoClip2: + Mov AX, 7FFFh + Jmp SB16IRQHFilterMono2 + +SB16HFilterStereoClip1: + Mov AX, 8000h + Jmp SB16IRQHFilterStereo2 + +SB16HFilterStereoClip2: + Mov AX, 7FFFh + Jmp SB16IRQHFilterStereo2 + +SB16HFilterStereoClip3: + Mov AX, 8000h + Jmp SB16IRQHFilterStereo3 + +SB16HFilterStereoClip4: + Mov AX, 7FFFh + Jmp SB16IRQHFilterStereo3 + +SB163QFilterMonoClip1: + Mov AX, 8000h + Jmp SB16IRQ3QFilterMono2 + +SB163QFilterMonoClip2: + Mov AX, 7FFFh + Jmp SB16IRQ3QFilterMono2 + +SB163QFilterStereoClip1: + Mov AX, 8000h + Jmp SB16IRQ3QFilterStereo2 + +SB163QFilterStereoClip2: + Mov AX, 7FFFh + Jmp SB16IRQ3QFilterStereo2 + +SB163QFilterStereoClip3: + Mov AX, 8000h + Jmp SB16IRQ3QFilterStereo3 + +SB163QFilterStereoClip4: + Mov AX, 7FFFh + Jmp SB16IRQ3QFilterStereo3 + +EndP SB16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SB16IRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSB16 ; + + PushA + Push ES + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Cmp DX, 3 + JA StartSB16B + + Mov Word Ptr [DMA16BITADJUST], 9090h + +StartSB16B: + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0B6h ; 16 bit, DAC + Call SBOut + Mov AL, Stereo + ShL AL, 5 + Or AL, 10h + Call SBOut + + Mov AX, DMASize + ShR AX, 1 + Dec AX + + Call SBOut ; DMALength, Lo + Mov AL, AH + Call SBOut + + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartSB16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Call GetSBMixConst + + ; Parags to allocate = (8/(.4*31*16))*MixSpeed + 2080 + ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + (FOURIERBUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SB16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + Add AX, (DMABUFFERLENGTH*2)/16 + Mov FourierSegment, AX + Sub DX, 2080 + Mov MixSegmentLength, DX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov DX, 330h + Call DetectUART + JC DetectMIDI1 + + Mov MIDIPort, 330h + Jmp DetectMIDIEnd + +DetectMIDI1: + Mov DX, 300h + Call DetectUART + JC DetectMIDIEnd + + Mov MIDIPort, 300h + +DetectMIDIEnd: + Mov SI, Offset SB16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, BasePort + Call ResetDSP + + Call ResetUART + Call ResetIRQ + + ; Delay.. + Mov DX, BasePort + Add DL, 0Ch + + Mov CX, 1000 +ReInitSound1: + In AL, DX + Loop ReInitSound1 + + Call SetIRQ + Call ReinitUART + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov DX, CS:BasePort + Add DL, 0Ch + + Mov AL, 0D9h + Call SBOut + + Call ResetUART + + Mov AX, BasePort + Call ResetDSP + + Call ResetDSPDMA + Call ResetDSPIRQ + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + +; Mov CS:MixVolumeSet, AX + +; SetMixVolumeChain: + PushA + Push DS + +; Cmp CS:Surround, 0 +; JE SetMixVolumeSurround +; +; Mov BX, 49152 +; Mul BX +; Mov AX, DX +; +; SetMixVolumeSurround: + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, AX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Dec CX + JNZ SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov CS:Stereo, AL + Mov AX, CS:BasePort + Call ResetDSP + + Mov ES, CS:MixSegment + Mov CX, CS:MixSegmentLength + Mov DI, MIXTABLESIZE + ShL CX, 2 + Xor EAX, EAX + Rep StosD + + Call StartSB16 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SB16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWaveForm Far ; Given ES:DI = destination + Assume DS:Nothing ; want 2048 samples. + + PushA + Push DS + + Mov DS, FourierSegment + Mov SI, FourierBufferStart + Mov CX, 2048 + +GetWaveForm1: + MovsW + And SI, (FOURIERBUFFERLENGTH*2)-1 + Loop GetWaveForm1 + + Pop DS + PopA + + Ret + +EndP GetWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 +DriverFlags DW 4 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW 0 + DW Offset GetWaveform + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SB16DRV.ASM b/SoundDrivers/SB16DRV.ASM index f719fb2..d22eae4 100755 --- a/SoundDrivers/SB16DRV.ASM +++ b/SoundDrivers/SB16DRV.ASM @@ -1,2672 +1,2672 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 -MIXTABLESIZE EQU 2*256*65 -FOURIERBUFFERLENGTH EQU 2048 - -SB16Msg DB "Sound Blaster 16 detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SB16NoMemoryMsg DB "Sound Blaster 16 detected", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster 16 reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITSB16.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITSB16.DRV", 0 - -DriverName DB "ITSB16.DRV", 0 - -DSPVersion DW 0 -DSPIRQValue DB 0 -DSPDMAValue DB 0 -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 -; MixVolumeSet DW 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 -FourierSegment DW 0 -MixSegmentLength DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 10 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 -Surround DW 0 -DMASize DW 2048 - -IMR DW 0 -OldIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MIDIPort DW 0 -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SB16ScreenList Label - DW 8 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr DriverText - - DW Near Ptr MasterVolumeLeft ; 8 - DW Near Ptr MasterVolumeRight ; 9 - DW Near Ptr TrebleVolumeLeft ; 10 - DW Near Ptr TrebleVolumeRight ; 11 - DW Near Ptr BassVolumeLeft ; 12 - DW Near Ptr BassVolumeRight ; 13 - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 15 - DW Near Ptr MixModeButton2 ; 16 - DW Near Ptr MixModeButton3 ; 17 - DW Near Ptr MixModeButton4 ; 18 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 20 - DW Near Ptr FilterButton2 ; 21 - DW Near Ptr FilterButton3 ; 22 - - DW Near Ptr StereoText - DW Near Ptr StereoButton1 ; 24 - DW Near Ptr StereoButton2 ; 25 - DW Near Ptr StereoButton3 ; 25 - - DW Near Ptr FrequencyText - - DW 0 - - -SB16HeaderLine DW 10 - DB "Sound Blaster 16 Driver", 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 - -VolumeText DW 1 - DB 2, 13 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB 13 - DB 13 - DB "Treble Left", 13 - DB "Treble Right", 13 - DB "Bass Left", 13 - DB "Bass Right", 13 - DB 0 - -VolumeBox1 DW 0 - DB 21, 12, 27, 15 - DB 25 - -VolumeBox2 DW 0 - DB 14, 16, 18, 21 - DB 25 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MasterVolumeLeft DW 9 - DB 22, 13 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 14 - DW 0, 31 - DW 9, 1 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 15, 17 - DW 0, 15 - DW 9, 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 15, 18 - DW 0, 15 - DW 9, 3 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 15, 19 - DW 0, 15 - DW 9, 4 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 15, 20 - DW 0, 15 - DW 9, 5 - DW 12, 15, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 23 - DB 20h - DB "Mixing Mode", 0 - -FrequencyText DW 1 - DB 2, 48 - DB 20h - DB "Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 45454 - -MixModeButton1 DW 2 - DW 13, 16, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 15, 17, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 28, 32, 30, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 16, 18, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 31, 32, 33, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 17, 20, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 34, 32, 36, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 40, 13 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 18, 21, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 42, 15, 60, 17, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 20, 22, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 42, 18, 60, 20, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 21, 24, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 42, 21, 60, 23, 8 - DB 0 - DB " 75% Filter", 0 - -StereoText DW 1 - DB 40, 25 - DB 20h - DB "Feedback mode", 0 - -StereoButton1 DW 2 - DW 22, 25, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetSurround -DriverSegment15 DW 0 - DW 0 - DW Offset SetSurround -DriverSegment16 DW 0 - DB 42, 27, 60, 29, 8 - DB 0 - DB " None", 0 - -StereoButton2 DW 2 - DW 24, 26, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetSurround -DriverSegment17 DW 0 - DW 1 - DW Offset SetSurround -DriverSegment18 DW 0 - DB 42, 30, 60, 32, 8 - DB 0 - DB " 50% Separated", 0 - -StereoButton3 DW 2 - DW 25, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetSurround -DriverSegment19 DW 0 - DW 2 - DW Offset SetSurround -DriverSegment20 DW 0 - DB 42, 33, 60, 35, 8 - DB 0 - DB " 50% Crossed", 0 - - -VolumeTable DB 6 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW Offset DriverSegment15, Offset DriverSegment16 - DW Offset DriverSegment17, Offset DriverSegment18 - DW Offset DriverSegment19, Offset DriverSegment20 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectUART ; Given DX = Port - -; From SB-DevKit - - ClI - - Inc DX - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 40h ; Ready for output - LoopNZ DetectUART1 - JNZ DetectUARTError - - Mov AL, 0FFh ; Reset! - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - JNZ DetectUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART4 - -DetectUART3: - Loop DetectUART2 - -DetectUARTError: - StI - StC - Ret - -DetectUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -DetectUART5: - In AL, DX - Test AL, 40h - LoopNZ DetectUART5 - JNZ DetectUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -DetectUART6: - Xor CX, CX - -DetectUART7: - In AL, DX - Test AL, 80h - JNZ DetectUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART9 - -DetectUART8: - Loop DetectUART7 - - Jmp DetectUARTError - -DetectUART9: - StI - ClC - Ret - -EndP DetectUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReinitUART - - Mov DX, MIDIPort - Test DX, DX - JZ ReinitUART1 - - Call DetectUART - -ReinitUART1: - Ret - -EndP ReinitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, MIDIPort - Test DX, DX - JZ ResetUART1 - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSurround Far - - Push CS - Pop ES - Mov DI, Offset Surround - - Ret - -EndP GetSurround - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSurround Far - - Mov AX, [SI+22] - Mov CS:Surround, AX - -; Mov AX, CS:MixVolumeSet -; Call Far Ptr SetMixVolumeChain - - Jmp SetMixModeChain - -EndP SetSurround - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 45454 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - Mov BX, 12000 - Xor DX, DX - Div BX - Mov FourierBufferStepOffset, AX - Mov FourierBufferStepFractional, DX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPIRQ - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPIRQValue - Mov AL, 80h - Out DX, AX - - Ret - -EndP ResetDSPIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPDMA - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPDMAValue - Mov AL, 81h - Out DX, AX - - Ret - -EndP ResetDSPDMA - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AH, 4 ; SB DSP = 4.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - Add DL, 04h-0Eh ; 2x4h = Mixer index port - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov DSPIRQValue, AL - ; OK.. now get IRQ, or set IRQ - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - StC - Ret - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: ; Detect DMA - Mov AL, 81h ; DMA select - Out DX, AL - Inc DL - In AL, DX ; AL = DMA - Dec DL - - Mov DSPDMAValue, AL - - Mov BX, DMA - Cmp BX, 0FFFFh - JE DetectCardDMA1 - Cmp Forced, 0 - JE DetectCardDMA1 - - Mov CL, 1 - Cmp BX, 1 - JB SetCardDMA1 - - Mov CL, 2 - JE SetCardDMA1 - - Cmp BX, 3 - JB DetectCard7 - - Mov CL, 8 - JE DetectCard7 - - Mov CL, 20h - Cmp BX, 5 - JB DetectCard7 - JE SetCardDMA1 - - Mov CL, 80h - Cmp BX, 7 - JA DetectCard7 - JE SetCardDMA1 - - Mov CL, 40h - -SetCardDMA1: - And AL, 0Bh - Test CL, 0Bh - JZ SetCardDMA4 - - Xor AL, AL - -SetCardDMA4: - Or CL, AL - - Mov AL, 81h - Out DX, AL - Inc DL - Mov AL, CL - Out DX, AL - Jmp DetectCard7 - -DetectCardDMA1: - Mov BX, 5 - Test AL, 20h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 40h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 80h - JNZ DetectCardDMA2 - - Mov BL, 0 - Test AL, 1 - JNZ DetectCardDMA2 - - Inc BL - Test AL, 2 - JNZ DetectCardDMA2 - - Add BL, 2 - Test AL, 8 - JNZ DetectCardDMA2 - -DetectCard8: - Call ResetDSPIRQ - StC - Ret - -DetectCardDMA2: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - - Cmp BX, DMA - JNE DetectCard8 - -DetectCardDMA3: - Mov DMA, BX - -DetectCard7: - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - - Cmp Surround, 1 - JB MixSamplesCont - - Push DS - - Push ES - Pop DS - - JE MixSurround3 - -Surround1: - Mov EAX, [DI+4] - Mov EBX, [DI] - SAR EAX, 1 - SAR EBX, 1 - Mov [DI], EAX - Mov [DI+4], EBX - - Add DI, 8 - Sub CX, 2 - JNZ Surround1 - - Pop DS - Jmp SurroundCont - -MixSamples1: - Cmp Surround, 1 - JB MixSamplesCont - -MixSurround2: - Push DS - - Push ES - Pop DS - -MixSurround3: - SAR DWord Ptr [DI], 1 - Add DI, 4 - Dec CX - JNZ MixSurround3 - - Pop DS - Jmp SurroundCont - -MixSamplesCont: - Xor EAX, EAX - Rep StosD ; } Memory write - -SurroundCont: - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include fourier.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AckIRQ - Assume DS:Driver - - Mov AL, 20h - Cmp CS:IRQ, 7 - JBE AckIRQ1 - - Out 0A0h, AL - -AckIRQ1: - Out 20h, AL - Ret - -EndP AckIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Mov DX, MIDIPort - - Mov BL, [MIDIBufferTail] - Test DX, DX - JZ CheckMIDIEnd - - Inc DX - Mov CX, 0FFFFh - -CheckMIDIAgain: - In AL, DX - - Test AL, 80h - LoopNZ CheckMIDIAgain - - Dec DX - In AL, DX - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL -; Jmp CheckMIDIAgain - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SB16IRQHandler - - PushAD - Push DS - Push ES - - CLD - -SBIRQAgain: - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 4 ; Mixer Port - Mov AL, 82h - Out DX, AL - Inc DL ; DX = BasePort+5 - In AL, DX - -Comment ~ - Test AL, 1 - JZ SB8BitDigitalInterruptEnd - -SB8BitDigitalInterrupt: - Push AX - Add DL, 0Eh-5 - In AL, DX - Pop AX - -SB8BitDigitalInterruptEnd: - - ~ - - Test AL, 4 - JZ SBMIDIInterruptEnd - - Push AX - Call CheckMIDI - Pop AX - -SBMIDIInterruptEnd: - Test AL, 2 - JNZ SBDigitalInterrupt - - Call AckIRQ - Jmp SBIRQEnd - -SBDigitalInterrupt: - Mov DX, BasePort - Add DL, 0Fh - In AL, DX ; 16-bit IRQ ack. - - Call AckIRQ - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SB16IRQHandler2 - - Xor AX, AX - Xor BX, BX - -SB16IRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE SB16IRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -SB16IRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SB16IRQHandler4 - Assume DS:Nothing - -SB16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - Call UpdateFourierBuffer - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SB16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SB16IRQHandler5 - - Mov DX, MixTransferRemaining - -SB16IRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB SB16IRQHandler6 - JE SB16IRQHFilter - - Cmp CS:Stereo, 0 - JE SB16IRQ3QFilterMono - -SB16IRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -SB16IRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL SB163QFilterStereoClip1 - Cmp EAX, 7FFFh - JG SB163QFilterStereoClip2 - -SB16IRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL SB163QFilterStereoClip3 - Cmp EAX, 7FFFh - JG SB163QFilterStereoClip4 - -SB16IRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ SB16IRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp SB16MixTransferEnd - -SB16IRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -SB16IRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL SB163QFilterMonoClip1 - Cmp EAX, 7FFFh - JG SB163QFilterMonoClip2 - -SB16IRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ SB16IRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp SB16MixTransferEnd - -SB16IRQHFilter: - Cmp CS:Stereo, 0 - JE SB16IRQHFilterMono - -SB16IRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -SB16IRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL SB16HFilterStereoClip1 - Cmp EAX, 7FFFh - JG SB16HFilterStereoClip2 - -SB16IRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL SB16HFilterStereoClip3 - Cmp EAX, 7FFFh - JG SB16HFilterStereoClip4 - -SB16IRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ SB16IRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp SB16MixTransferEnd - -SB16IRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -SB16IRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL SB16HFilterMonoClip1 - Cmp EAX, 7FFFh - JG SB16HFilterMonoClip2 - -SB16IRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ SB16IRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp SB16MixTransferEnd - -SB16IRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL SB16IRQHandlerClip1 - Cmp EAX, 7FFFh - JG SB16IRQHandlerClip2 - -SB16IRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ SB16IRQHandler6 - -SB16MixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SB16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - -SBIRQEnd: - - Pop ES - Pop DS - PopAD - IRet - -SB16IRQHandlerClip1: - Mov AX, 8000h - Jmp SB16IRQHandler7 - -SB16IRQHandlerClip2: - Mov AX, 7FFFh - Jmp SB16IRQHandler7 - -SB16HFilterMonoClip1: - Mov AX, 8000h - Jmp SB16IRQHFilterMono2 - -SB16HFilterMonoClip2: - Mov AX, 7FFFh - Jmp SB16IRQHFilterMono2 - -SB16HFilterStereoClip1: - Mov AX, 8000h - Jmp SB16IRQHFilterStereo2 - -SB16HFilterStereoClip2: - Mov AX, 7FFFh - Jmp SB16IRQHFilterStereo2 - -SB16HFilterStereoClip3: - Mov AX, 8000h - Jmp SB16IRQHFilterStereo3 - -SB16HFilterStereoClip4: - Mov AX, 7FFFh - Jmp SB16IRQHFilterStereo3 - -SB163QFilterMonoClip1: - Mov AX, 8000h - Jmp SB16IRQ3QFilterMono2 - -SB163QFilterMonoClip2: - Mov AX, 7FFFh - Jmp SB16IRQ3QFilterMono2 - -SB163QFilterStereoClip1: - Mov AX, 8000h - Jmp SB16IRQ3QFilterStereo2 - -SB163QFilterStereoClip2: - Mov AX, 7FFFh - Jmp SB16IRQ3QFilterStereo2 - -SB163QFilterStereoClip3: - Mov AX, 8000h - Jmp SB16IRQ3QFilterStereo3 - -SB163QFilterStereoClip4: - Mov AX, 7FFFh - Jmp SB16IRQ3QFilterStereo3 - -EndP SB16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SB16IRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSB16 ; - - PushA - Push ES - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0B6h ; 16 bit, DAC - Call SBOut - Mov AL, Stereo - ShL AL, 5 - Or AL, 10h - Call SBOut - - Mov AX, DMASize - ShR AX, 1 - Dec AX - - Call SBOut ; DMALength, Lo - Mov AL, AH - Call SBOut - - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartSB16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Call GetSBMixConst - - ; Parags to allocate = (8/(.4*31*16))*MixSpeed + 2080 - ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 + (FOURIERBUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SB16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - Add AX, (DMABUFFERLENGTH*2)/16 - Mov FourierSegment, AX - Sub DX, 2080 - Mov MixSegmentLength, DX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov DX, 330h - Call DetectUART - JC DetectMIDI1 - - Mov MIDIPort, 330h - Jmp DetectMIDIEnd - -DetectMIDI1: - Mov DX, 300h - Call DetectUART - JC DetectMIDIEnd - - Mov MIDIPort, 300h - -DetectMIDIEnd: - Mov SI, Offset SB16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, BasePort - Call ResetDSP - - Call ResetUART - Call ResetIRQ - - ; Delay.. - Mov DX, BasePort - Add DL, 0Ch - - Mov CX, 1000 -ReInitSound1: - In AL, DX - Loop ReInitSound1 - - Call SetIRQ - Call ReinitUART - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov DX, CS:BasePort - Add DL, 0Ch - - Mov AL, 0D9h - Call SBOut - - Call ResetUART - - Mov AX, BasePort - Call ResetDSP - - Call ResetDSPDMA - Call ResetDSPIRQ - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - -; Mov CS:MixVolumeSet, AX - -; SetMixVolumeChain: - PushA - Push DS - -; Cmp CS:Surround, 0 -; JE SetMixVolumeSurround -; -; Mov BX, 49152 -; Mul BX -; Mov AX, DX -; -; SetMixVolumeSurround: - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, AX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Dec CX - JNZ SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov CS:Stereo, AL - Mov AX, CS:BasePort - Call ResetDSP - - Mov ES, CS:MixSegment - Mov CX, CS:MixSegmentLength - Mov DI, MIXTABLESIZE - ShL CX, 2 - Xor EAX, EAX - Rep StosD - - Call StartSB16 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SB16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWaveForm Far ; Given ES:DI = destination - Assume DS:Nothing ; want 2048 samples. - - PushA - Push DS - - Mov DS, FourierSegment - Mov SI, FourierBufferStart - Mov CX, 2048 - -GetWaveForm1: - MovsW - And SI, (FOURIERBUFFERLENGTH*2)-1 - Loop GetWaveForm1 - - Pop DS - PopA - - Ret - -EndP GetWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 -DriverFlags DW 4 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW 0 - DW Offset GetWaveform - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 +MIXTABLESIZE EQU 2*256*65 +FOURIERBUFFERLENGTH EQU 2048 + +SB16Msg DB "Sound Blaster 16 detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SB16NoMemoryMsg DB "Sound Blaster 16 detected", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster 16 reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITSB16.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITSB16.DRV", 0 + +DriverName DB "ITSB16.DRV", 0 + +DSPVersion DW 0 +DSPIRQValue DB 0 +DSPDMAValue DB 0 +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 +; MixVolumeSet DW 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 +FourierSegment DW 0 +MixSegmentLength DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 10 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 +Surround DW 0 +DMASize DW 2048 + +IMR DW 0 +OldIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MIDIPort DW 0 +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SB16ScreenList Label + DW 8 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr DriverText + + DW Near Ptr MasterVolumeLeft ; 8 + DW Near Ptr MasterVolumeRight ; 9 + DW Near Ptr TrebleVolumeLeft ; 10 + DW Near Ptr TrebleVolumeRight ; 11 + DW Near Ptr BassVolumeLeft ; 12 + DW Near Ptr BassVolumeRight ; 13 + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 15 + DW Near Ptr MixModeButton2 ; 16 + DW Near Ptr MixModeButton3 ; 17 + DW Near Ptr MixModeButton4 ; 18 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 20 + DW Near Ptr FilterButton2 ; 21 + DW Near Ptr FilterButton3 ; 22 + + DW Near Ptr StereoText + DW Near Ptr StereoButton1 ; 24 + DW Near Ptr StereoButton2 ; 25 + DW Near Ptr StereoButton3 ; 25 + + DW Near Ptr FrequencyText + + DW 0 + + +SB16HeaderLine DW 10 + DB "Sound Blaster 16 Driver", 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 + +VolumeText DW 1 + DB 2, 13 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB 13 + DB 13 + DB "Treble Left", 13 + DB "Treble Right", 13 + DB "Bass Left", 13 + DB "Bass Right", 13 + DB 0 + +VolumeBox1 DW 0 + DB 21, 12, 27, 15 + DB 25 + +VolumeBox2 DW 0 + DB 14, 16, 18, 21 + DB 25 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MasterVolumeLeft DW 9 + DB 22, 13 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 14 + DW 0, 31 + DW 9, 1 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 15, 17 + DW 0, 15 + DW 9, 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 15, 18 + DW 0, 15 + DW 9, 3 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 15, 19 + DW 0, 15 + DW 9, 4 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 15, 20 + DW 0, 15 + DW 9, 5 + DW 12, 15, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 23 + DB 20h + DB "Mixing Mode", 0 + +FrequencyText DW 1 + DB 2, 48 + DB 20h + DB "Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 45454 + +MixModeButton1 DW 2 + DW 13, 16, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 15, 17, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 28, 32, 30, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 16, 18, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 31, 32, 33, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 17, 20, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 34, 32, 36, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 40, 13 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 18, 21, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 42, 15, 60, 17, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 20, 22, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 42, 18, 60, 20, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 21, 24, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 42, 21, 60, 23, 8 + DB 0 + DB " 75% Filter", 0 + +StereoText DW 1 + DB 40, 25 + DB 20h + DB "Feedback mode", 0 + +StereoButton1 DW 2 + DW 22, 25, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetSurround +DriverSegment15 DW 0 + DW 0 + DW Offset SetSurround +DriverSegment16 DW 0 + DB 42, 27, 60, 29, 8 + DB 0 + DB " None", 0 + +StereoButton2 DW 2 + DW 24, 26, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetSurround +DriverSegment17 DW 0 + DW 1 + DW Offset SetSurround +DriverSegment18 DW 0 + DB 42, 30, 60, 32, 8 + DB 0 + DB " 50% Separated", 0 + +StereoButton3 DW 2 + DW 25, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetSurround +DriverSegment19 DW 0 + DW 2 + DW Offset SetSurround +DriverSegment20 DW 0 + DB 42, 33, 60, 35, 8 + DB 0 + DB " 50% Crossed", 0 + + +VolumeTable DB 6 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW Offset DriverSegment15, Offset DriverSegment16 + DW Offset DriverSegment17, Offset DriverSegment18 + DW Offset DriverSegment19, Offset DriverSegment20 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectUART ; Given DX = Port + +; From SB-DevKit + + ClI + + Inc DX + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 40h ; Ready for output + LoopNZ DetectUART1 + JNZ DetectUARTError + + Mov AL, 0FFh ; Reset! + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + JNZ DetectUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART4 + +DetectUART3: + Loop DetectUART2 + +DetectUARTError: + StI + StC + Ret + +DetectUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +DetectUART5: + In AL, DX + Test AL, 40h + LoopNZ DetectUART5 + JNZ DetectUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +DetectUART6: + Xor CX, CX + +DetectUART7: + In AL, DX + Test AL, 80h + JNZ DetectUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART9 + +DetectUART8: + Loop DetectUART7 + + Jmp DetectUARTError + +DetectUART9: + StI + ClC + Ret + +EndP DetectUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReinitUART + + Mov DX, MIDIPort + Test DX, DX + JZ ReinitUART1 + + Call DetectUART + +ReinitUART1: + Ret + +EndP ReinitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, MIDIPort + Test DX, DX + JZ ResetUART1 + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSurround Far + + Push CS + Pop ES + Mov DI, Offset Surround + + Ret + +EndP GetSurround + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSurround Far + + Mov AX, [SI+22] + Mov CS:Surround, AX + +; Mov AX, CS:MixVolumeSet +; Call Far Ptr SetMixVolumeChain + + Jmp SetMixModeChain + +EndP SetSurround + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 45454 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + Mov BX, 12000 + Xor DX, DX + Div BX + Mov FourierBufferStepOffset, AX + Mov FourierBufferStepFractional, DX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPIRQ + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPIRQValue + Mov AL, 80h + Out DX, AX + + Ret + +EndP ResetDSPIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPDMA + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPDMAValue + Mov AL, 81h + Out DX, AX + + Ret + +EndP ResetDSPDMA + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AH, 4 ; SB DSP = 4.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + Add DL, 04h-0Eh ; 2x4h = Mixer index port + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov DSPIRQValue, AL + ; OK.. now get IRQ, or set IRQ + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + StC + Ret + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: ; Detect DMA + Mov AL, 81h ; DMA select + Out DX, AL + Inc DL + In AL, DX ; AL = DMA + Dec DL + + Mov DSPDMAValue, AL + + Mov BX, DMA + Cmp BX, 0FFFFh + JE DetectCardDMA1 + Cmp Forced, 0 + JE DetectCardDMA1 + + Mov CL, 1 + Cmp BX, 1 + JB SetCardDMA1 + + Mov CL, 2 + JE SetCardDMA1 + + Cmp BX, 3 + JB DetectCard7 + + Mov CL, 8 + JE DetectCard7 + + Mov CL, 20h + Cmp BX, 5 + JB DetectCard7 + JE SetCardDMA1 + + Mov CL, 80h + Cmp BX, 7 + JA DetectCard7 + JE SetCardDMA1 + + Mov CL, 40h + +SetCardDMA1: + And AL, 0Bh + Test CL, 0Bh + JZ SetCardDMA4 + + Xor AL, AL + +SetCardDMA4: + Or CL, AL + + Mov AL, 81h + Out DX, AL + Inc DL + Mov AL, CL + Out DX, AL + Jmp DetectCard7 + +DetectCardDMA1: + Mov BX, 5 + Test AL, 20h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 40h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 80h + JNZ DetectCardDMA2 + + Mov BL, 0 + Test AL, 1 + JNZ DetectCardDMA2 + + Inc BL + Test AL, 2 + JNZ DetectCardDMA2 + + Add BL, 2 + Test AL, 8 + JNZ DetectCardDMA2 + +DetectCard8: + Call ResetDSPIRQ + StC + Ret + +DetectCardDMA2: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + + Cmp BX, DMA + JNE DetectCard8 + +DetectCardDMA3: + Mov DMA, BX + +DetectCard7: + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + + Cmp Surround, 1 + JB MixSamplesCont + + Push DS + + Push ES + Pop DS + + JE MixSurround3 + +Surround1: + Mov EAX, [DI+4] + Mov EBX, [DI] + SAR EAX, 1 + SAR EBX, 1 + Mov [DI], EAX + Mov [DI+4], EBX + + Add DI, 8 + Sub CX, 2 + JNZ Surround1 + + Pop DS + Jmp SurroundCont + +MixSamples1: + Cmp Surround, 1 + JB MixSamplesCont + +MixSurround2: + Push DS + + Push ES + Pop DS + +MixSurround3: + SAR DWord Ptr [DI], 1 + Add DI, 4 + Dec CX + JNZ MixSurround3 + + Pop DS + Jmp SurroundCont + +MixSamplesCont: + Xor EAX, EAX + Rep StosD ; } Memory write + +SurroundCont: + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include fourier.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AckIRQ + Assume DS:Driver + + Mov AL, 20h + Cmp CS:IRQ, 7 + JBE AckIRQ1 + + Out 0A0h, AL + +AckIRQ1: + Out 20h, AL + Ret + +EndP AckIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Mov DX, MIDIPort + + Mov BL, [MIDIBufferTail] + Test DX, DX + JZ CheckMIDIEnd + + Inc DX + Mov CX, 0FFFFh + +CheckMIDIAgain: + In AL, DX + + Test AL, 80h + LoopNZ CheckMIDIAgain + + Dec DX + In AL, DX + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL +; Jmp CheckMIDIAgain + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SB16IRQHandler + + PushAD + Push DS + Push ES + + CLD + +SBIRQAgain: + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 4 ; Mixer Port + Mov AL, 82h + Out DX, AL + Inc DL ; DX = BasePort+5 + In AL, DX + +Comment ~ + Test AL, 1 + JZ SB8BitDigitalInterruptEnd + +SB8BitDigitalInterrupt: + Push AX + Add DL, 0Eh-5 + In AL, DX + Pop AX + +SB8BitDigitalInterruptEnd: + + ~ + + Test AL, 4 + JZ SBMIDIInterruptEnd + + Push AX + Call CheckMIDI + Pop AX + +SBMIDIInterruptEnd: + Test AL, 2 + JNZ SBDigitalInterrupt + + Call AckIRQ + Jmp SBIRQEnd + +SBDigitalInterrupt: + Mov DX, BasePort + Add DL, 0Fh + In AL, DX ; 16-bit IRQ ack. + + Call AckIRQ + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SB16IRQHandler2 + + Xor AX, AX + Xor BX, BX + +SB16IRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE SB16IRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +SB16IRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SB16IRQHandler4 + Assume DS:Nothing + +SB16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + Call UpdateFourierBuffer + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SB16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SB16IRQHandler5 + + Mov DX, MixTransferRemaining + +SB16IRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB SB16IRQHandler6 + JE SB16IRQHFilter + + Cmp CS:Stereo, 0 + JE SB16IRQ3QFilterMono + +SB16IRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +SB16IRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL SB163QFilterStereoClip1 + Cmp EAX, 7FFFh + JG SB163QFilterStereoClip2 + +SB16IRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL SB163QFilterStereoClip3 + Cmp EAX, 7FFFh + JG SB163QFilterStereoClip4 + +SB16IRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ SB16IRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp SB16MixTransferEnd + +SB16IRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +SB16IRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL SB163QFilterMonoClip1 + Cmp EAX, 7FFFh + JG SB163QFilterMonoClip2 + +SB16IRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ SB16IRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp SB16MixTransferEnd + +SB16IRQHFilter: + Cmp CS:Stereo, 0 + JE SB16IRQHFilterMono + +SB16IRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +SB16IRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL SB16HFilterStereoClip1 + Cmp EAX, 7FFFh + JG SB16HFilterStereoClip2 + +SB16IRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL SB16HFilterStereoClip3 + Cmp EAX, 7FFFh + JG SB16HFilterStereoClip4 + +SB16IRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ SB16IRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp SB16MixTransferEnd + +SB16IRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +SB16IRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL SB16HFilterMonoClip1 + Cmp EAX, 7FFFh + JG SB16HFilterMonoClip2 + +SB16IRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ SB16IRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp SB16MixTransferEnd + +SB16IRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL SB16IRQHandlerClip1 + Cmp EAX, 7FFFh + JG SB16IRQHandlerClip2 + +SB16IRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ SB16IRQHandler6 + +SB16MixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SB16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + +SBIRQEnd: + + Pop ES + Pop DS + PopAD + IRet + +SB16IRQHandlerClip1: + Mov AX, 8000h + Jmp SB16IRQHandler7 + +SB16IRQHandlerClip2: + Mov AX, 7FFFh + Jmp SB16IRQHandler7 + +SB16HFilterMonoClip1: + Mov AX, 8000h + Jmp SB16IRQHFilterMono2 + +SB16HFilterMonoClip2: + Mov AX, 7FFFh + Jmp SB16IRQHFilterMono2 + +SB16HFilterStereoClip1: + Mov AX, 8000h + Jmp SB16IRQHFilterStereo2 + +SB16HFilterStereoClip2: + Mov AX, 7FFFh + Jmp SB16IRQHFilterStereo2 + +SB16HFilterStereoClip3: + Mov AX, 8000h + Jmp SB16IRQHFilterStereo3 + +SB16HFilterStereoClip4: + Mov AX, 7FFFh + Jmp SB16IRQHFilterStereo3 + +SB163QFilterMonoClip1: + Mov AX, 8000h + Jmp SB16IRQ3QFilterMono2 + +SB163QFilterMonoClip2: + Mov AX, 7FFFh + Jmp SB16IRQ3QFilterMono2 + +SB163QFilterStereoClip1: + Mov AX, 8000h + Jmp SB16IRQ3QFilterStereo2 + +SB163QFilterStereoClip2: + Mov AX, 7FFFh + Jmp SB16IRQ3QFilterStereo2 + +SB163QFilterStereoClip3: + Mov AX, 8000h + Jmp SB16IRQ3QFilterStereo3 + +SB163QFilterStereoClip4: + Mov AX, 7FFFh + Jmp SB16IRQ3QFilterStereo3 + +EndP SB16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SB16IRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSB16 ; + + PushA + Push ES + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0B6h ; 16 bit, DAC + Call SBOut + Mov AL, Stereo + ShL AL, 5 + Or AL, 10h + Call SBOut + + Mov AX, DMASize + ShR AX, 1 + Dec AX + + Call SBOut ; DMALength, Lo + Mov AL, AH + Call SBOut + + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartSB16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Call GetSBMixConst + + ; Parags to allocate = (8/(.4*31*16))*MixSpeed + 2080 + ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + (FOURIERBUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SB16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + Add AX, (DMABUFFERLENGTH*2)/16 + Mov FourierSegment, AX + Sub DX, 2080 + Mov MixSegmentLength, DX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov DX, 330h + Call DetectUART + JC DetectMIDI1 + + Mov MIDIPort, 330h + Jmp DetectMIDIEnd + +DetectMIDI1: + Mov DX, 300h + Call DetectUART + JC DetectMIDIEnd + + Mov MIDIPort, 300h + +DetectMIDIEnd: + Mov SI, Offset SB16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, BasePort + Call ResetDSP + + Call ResetUART + Call ResetIRQ + + ; Delay.. + Mov DX, BasePort + Add DL, 0Ch + + Mov CX, 1000 +ReInitSound1: + In AL, DX + Loop ReInitSound1 + + Call SetIRQ + Call ReinitUART + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov DX, CS:BasePort + Add DL, 0Ch + + Mov AL, 0D9h + Call SBOut + + Call ResetUART + + Mov AX, BasePort + Call ResetDSP + + Call ResetDSPDMA + Call ResetDSPIRQ + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + +; Mov CS:MixVolumeSet, AX + +; SetMixVolumeChain: + PushA + Push DS + +; Cmp CS:Surround, 0 +; JE SetMixVolumeSurround +; +; Mov BX, 49152 +; Mul BX +; Mov AX, DX +; +; SetMixVolumeSurround: + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, AX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Dec CX + JNZ SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov CS:Stereo, AL + Mov AX, CS:BasePort + Call ResetDSP + + Mov ES, CS:MixSegment + Mov CX, CS:MixSegmentLength + Mov DI, MIXTABLESIZE + ShL CX, 2 + Xor EAX, EAX + Rep StosD + + Call StartSB16 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SB16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWaveForm Far ; Given ES:DI = destination + Assume DS:Nothing ; want 2048 samples. + + PushA + Push DS + + Mov DS, FourierSegment + Mov SI, FourierBufferStart + Mov CX, 2048 + +GetWaveForm1: + MovsW + And SI, (FOURIERBUFFERLENGTH*2)-1 + Loop GetWaveForm1 + + Pop DS + PopA + + Ret + +EndP GetWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 +DriverFlags DW 4 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW 0 + DW Offset GetWaveform + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SB16K6.ASM b/SoundDrivers/SB16K6.ASM index c661467..47985af 100755 --- a/SoundDrivers/SB16K6.ASM +++ b/SoundDrivers/SB16K6.ASM @@ -1,2287 +1,2287 @@ - - - .586P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -TRACEENABLED = 0 -CREATENEWLOGFILE = 1 - -include debug.inc - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 -OUTPUTFILTERENABLED EQU 1 -FOURIERBUFFERLENGTH EQU 2048 ; 2048 samples - -FPSave DB 128 Dup (0) - -SB16Msg DB "Sound Blaster 16 3DNOW!", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SB16NoMemoryMsg DB "Sound Blaster 16 3DNOW!", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster 16 reinitialised", 0 - -DriverName DB "ITSB16.3DN", 0 - -DSPVersion DW 0 -DSPIRQValue DB 0 -DSPDMAValue DB 0 -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -FourierSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 20 -MixMode DW 0 -MixModeOffset DW 0 -DMASize DW 2048 -VolumeTable DB 6 Dup (0) - DB 0, 16, 96, 127 - DB 0, 0, 0, 0 - -IMR DW 0 -OldIRQHandler DD 0 - -MIDIPort DW 0 -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SB16ScreenList Label - DW 8 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr DriverText - - DW Near Ptr MasterVolumeLeft ; 8 - DW Near Ptr MasterVolumeRight ; 9 - DW Near Ptr TrebleVolumeLeft ; 10 - DW Near Ptr TrebleVolumeRight ; 11 - DW Near Ptr BassVolumeLeft ; 12 - DW Near Ptr BassVolumeRight ; 13 - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 15 - DW Near Ptr MixModeButton2 ; 16 - - DW Near Ptr FrequencyText ; 17 - - DW Near Ptr FilterText ; 18 - DW Near Ptr FilterBox1 - DW Near Ptr FilterBox2 - - DW Near Ptr FilterFrequency1 ; 21 - DW Near Ptr FilterFrequency2 - DW Near Ptr FilterFrequency3 - DW Near Ptr FilterFrequency4 - - DW Near Ptr FilterVolume1 ; 25 - DW Near Ptr FilterVolume2 - DW Near Ptr FilterVolume3 - DW Near Ptr FilterVolume4 - - DW 0 - -SB16HeaderLine DW 10 - DB "Sound Blaster 16 3DNow! Driver", 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 - -VolumeText DW 1 - DB 2, 13 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB 13 - DB 13 - DB "Treble Left", 13 - DB "Treble Right", 13 - DB "Bass Left", 13 - DB "Bass Right", 13 - DB 0 - -VolumeBox1 DW 0 - DB 21, 12, 27, 15 - DB 25 - -VolumeBox2 DW 0 - DB 14, 16, 18, 21 - DB 25 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MasterVolumeLeft DW 9 - DB 22, 13 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 14 - DW 0, 31 - DW 9, 1 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 15, 17 - DW 0, 15 - DW 9, 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 15, 18 - DW 0, 15 - DW 9, 3 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 15, 19 - DW 0, 15 - DW 9, 4 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 15, 20 - DW 0, 15 - DW 9, 5 - DW 12, 15, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 23 - DB 20h - DB "Mixing Mode", 0 - -FrequencyText DW 1 - DB 2, 48 - DB 20h - DB "Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 45454 - DW 0 - -MixModeButton1 DW 2 - DW 13, 16, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " 3DNow!, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 15, 18, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 28, 32, 30, 8 - DB 0 - DB " 3DNow!, Filtered", 0 - -FilterText DW 1 - DB 2, 39 - DB 20h - DB "Output Equalizer", 13 - DB 13 - DB " Low Frequency Band", 13 - DB " Med Low Frequency Band", 13 - DB "Med High Frequency Band", 13 - DB " High Frequency Band", 0 - -FilterBox1 DW 0 - DB 25, 40, 47, 45 - DB 25 - -FilterBox2 DW 0 - DB 52, 40, 74, 45 - DB 25 - -FilterFrequency1 DW 14 - DB 26, 41 - DW 0, 127 - DW 9, 6 - DW 16, 22, 25, 25 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency2 DW 14 - DB 26, 42 - DW 0, 127 - DW 9, 7 - DW 21, 23, 26, 26 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency3 DW 14 - DB 26, 43 - DW 0, 127 - DW 9, 8 - DW 22, 24, 27, 27 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency4 DW 14 - DB 26, 44 - DW 0, 127 - DW 9, 9 - DW 23, 0FFFFh, 28, 28 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume1 DW 14 - DB 53, 41 - DW 0, 255 - DW 9, 10 - DW 16, 26, 21, 21 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume2 DW 14 - DB 53, 42 - DW 0, 255 - DW 9, 11 - DW 25, 27, 22, 22 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume3 DW 14 - DB 53, 43 - DW 0, 255 - DW 9, 12 - DW 26, 28, 23, 23 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume4 DW 14 - DB 53, 44 - DW 0, 255 - DW 9, 13 - DW 27, 0FFFFh, 24, 24 - DW 0FFFFh, 0FFFFh - DW 20 - - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include mnomix.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectK63D - Assume DS:Driver - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectK63DFail - - Mov EAX, 80000000h - DB 0Fh, 0A2h ; CPUID - Cmp EAX, 80000000h - JBE DetectK63DFail - - Mov EAX, 80000001h - DB 0Fh, 0A2h - And EDX, 80800000h - Cmp EDX, 80800000h - JNE DetectK63DFail - - DB 85h - -DetectK63DFail: - StC - Ret - -EndP DetectK63D - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectUART ; Given DX = Port - -; From SB-DevKit - - ClI - - Inc DX - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 40h ; Ready for output - LoopNZ DetectUART1 - JNZ DetectUARTError - - Mov AL, 0FFh ; Reset! - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - JNZ DetectUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART4 - -DetectUART3: - Loop DetectUART2 - -DetectUARTError: - StI - StC - Ret - -DetectUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -DetectUART5: - In AL, DX - Test AL, 40h - LoopNZ DetectUART5 - JNZ DetectUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -DetectUART6: - Xor CX, CX - -DetectUART7: - In AL, DX - Test AL, 80h - JNZ DetectUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART9 - -DetectUART8: - Loop DetectUART7 - - Jmp DetectUARTError - -DetectUART9: - StI - ClC - Ret - -EndP DetectUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReinitUART - - Mov DX, MIDIPort - Test DX, DX - JZ ReinitUART1 - - Call DetectUART - -ReinitUART1: - Ret - -EndP ReinitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, MIDIPort - Test DX, DX - JZ ResetUART1 - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 45454 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Mov BX, 12000 - Xor DX, DX - Div BX - Mov FourierBufferStepOffset, AX - Mov FourierBufferStepFractional, DX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPIRQ - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPIRQValue - Mov AL, 80h - Out DX, AX - - Ret - -EndP ResetDSPIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPDMA - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPDMAValue - Mov AL, 81h - Out DX, AX - - Ret - -EndP ResetDSPDMA - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Call DetectK63D - JC DetectCardFailure - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AH, 4 ; SB DSP = 4.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - Add DL, 04h-0Eh ; 2x4h = Mixer index port - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov DSPIRQValue, AL - ; OK.. now get IRQ, or set IRQ - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - StC - Ret - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - -DetectCardFailure: - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: ; Detect DMA - Mov AL, 81h ; DMA select - Out DX, AL - Inc DL - In AL, DX ; AL = DMA - Dec DL - - Mov DSPDMAValue, AL - - Mov BX, DMA - Cmp BX, 0FFFFh - JE DetectCardDMA1 - Cmp Forced, 0 - JE DetectCardDMA1 - - Mov CL, 1 - Cmp BX, 1 - JB SetCardDMA1 - - Mov CL, 2 - JE SetCardDMA1 - - Cmp BX, 3 - JB DetectCard7 - - Mov CL, 8 - JE DetectCard7 - - Mov CL, 20h - Cmp BX, 5 - JB DetectCard7 - JE SetCardDMA1 - - Mov CL, 80h - Cmp BX, 7 - JA DetectCard7 - JE SetCardDMA1 - - Mov CL, 40h - -SetCardDMA1: - And AL, 0Bh - Test CL, 0Bh - JZ SetCardDMA4 - - Xor AL, AL - -SetCardDMA4: - Or CL, AL - - Mov AL, 81h - Out DX, AL - Inc DL - Mov AL, CL - Out DX, AL - Jmp DetectCard7 - -DetectCardDMA1: - Mov BX, 5 - Test AL, 20h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 40h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 80h - JNZ DetectCardDMA2 - - Mov BL, 0 - Test AL, 1 - JNZ DetectCardDMA2 - - Inc BL - Test AL, 2 - JNZ DetectCardDMA2 - - Add BL, 2 - Test AL, 8 - JNZ DetectCardDMA2 - -DetectCard8: - Call ResetDSPIRQ - StC - Ret - -DetectCardDMA2: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - - Cmp BX, DMA - JNE DetectCard8 - -DetectCardDMA3: - Mov DMA, BX - -DetectCard7: - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc -include fourier.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AckIRQ - Assume DS:Driver - - Mov AL, 20h - Cmp CS:IRQ, 7 - JBE AckIRQ1 - - Out 0A0h, AL - -AckIRQ1: - Out 20h, AL - Ret - -EndP AckIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Mov DX, MIDIPort - - Mov BL, [MIDIBufferTail] - Test DX, DX - JZ CheckMIDIEnd - - Inc DX - Mov CX, 0FFFFh - -CheckMIDIAgain: - In AL, DX - - Test AL, 80h - LoopNZ CheckMIDIAgain - - Dec DX - In AL, DX - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL -; Jmp CheckMIDIAgain - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SB16IRQHandler - - PushAD - Push DS - Push ES - - CLD - -SBIRQAgain: - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 4 ; Mixer Port - Mov AL, 82h - Out DX, AL - Inc DL ; DX = BasePort+5 - In AL, DX - -Comment ~ - Test AL, 1 - JZ SB8BitDigitalInterruptEnd - -SB8BitDigitalInterrupt: - Push AX - Add DL, 0Eh-5 - In AL, DX - Pop AX - -SB8BitDigitalInterruptEnd: - - ~ - Test AL, 4 - JZ SBMIDIInterruptEnd - - Push AX - Call CheckMIDI - Pop AX - -SBMIDIInterruptEnd: - Test AL, 2 - JNZ SBDigitalInterrupt - - Call AckIRQ - Jmp SBIRQEnd - -SBDigitalInterrupt: - FNSave [FPSave] - - Mov DX, BasePort - Add DL, 0Fh - In AL, DX ; 16-bit IRQ ack. - - Call AckIRQ - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SB16IRQHandler2 - - Xor AX, AX - Xor BX, BX - -SB16IRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Mov BX, DMASize ; BX = bytes required - Add DI, AX - ShR BX, 1 - ; BX = samples required - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SB16IRQHandler4 - Assume DS:Nothing - -SB16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - Call UpdateFourierBuffer - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SB16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SB16IRQHandler5 - - Mov DX, MixTransferRemaining - -SB16IRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SB16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRstor [CS:FPSave] - -SBIRQEnd: - Pop ES - Pop DS - PopAD - IRet - -EndP SB16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SB16IRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSB16 ; - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0B6h ; 16 bit, DAC - Call SBOut - Mov AL, Stereo - ShL AL, 5 - Or AL, 10h - Call SBOut - - Mov AX, DMASize - ShR AX, 1 - Dec AX - - Call SBOut ; DMALength, Lo - Mov AL, AH - Call SBOut - - Pop ES - Pop DS - PopA - - Ret - - Assume DS:Nothing - -EndP StartSB16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Call GetSBMixConst - - ; Parags to allocate = (8/(.4*31*16))*MixSpeed + 2080 - ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 5+(DMABUFFERLENGTH*2)/16+(FOURIERBUFFERLENGTH*2)/16 - Mov BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SB16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Sub AX, (FOURIERBUFFERLENGTH*2)/16 - Mov FourierSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov DX, 330h - Call DetectUART - JC DetectMIDI1 - - Mov MIDIPort, 330h - Jmp DetectMIDIEnd - -DetectMIDI1: - Mov DX, 300h - Call DetectUART - JC DetectMIDIEnd - - Mov MIDIPort, 300h - -DetectMIDIEnd: - Call CalculateFilterCoefficients - - Mov SI, Offset SB16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, BasePort - Call ResetDSP - - Call ResetUART - Call ResetIRQ - - ; Delay.. - Mov DX, BasePort - Add DL, 0Ch - - Mov CX, 1000 -ReInitSound1: - In AL, DX - Loop ReInitSound1 - - Call SetIRQ - Call ReinitUART - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Mov DX, CS:BasePort - Add DL, 0Ch - - Mov AL, 0D9h - Call SBOut - - Call ResetUART - - Mov AX, BasePort - Call ResetDSP - - Call ResetDSPDMA - Call ResetDSPIRQ - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov CS:Stereo, AL - Mov AX, CS:BasePort - Call ResetDSP - - Call StartSB16 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far ; Fix up end of sample bytes - - PushAD - Push DS - Push ES - Push FS - - Mov FS, CS:SongDataArea - Mov BP, AX - Add BP, BP - Mov BP, [FS:64910+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC LoadSampleEnd ; Zero flag ON if 16 bit.. - - Xor EAX, EAX - Mov BL, [FS:BP+12h] - - Test BL, 10h ; Loop - JZ LoadSample2 - - Mov ESI, [FS:BP+34h] ; Start of loop - Test BL, 40h ; Pingpong? - JZ LoadSample1 - - Mov ESI, [FS:BP+38h] - Sub ESI, 2 - JNC LoadSample1 - - Xor ESI, ESI - -LoadSample1: - Test BL, 2 - JZ LoadSample4 - - Add ESI, ESI - -LoadSample4: - Int 3 - Mov AL, [SI] - Inc ESI - Int 3 - Mov AH, [SI] - -LoadSample2: - Mov ESI, [FS:BP+30h] - Test BL, 2 - JZ LoadSample3 - - Add ESI, ESI - -LoadSample3: - Int 3 - Mov [SI], AL - Inc ESI - Int 3 - Mov [SI], AH - -LoadSampleEnd: - Pop FS - Pop ES - Pop DS - PopAD - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SB16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -TempVariable DW 0 -Const1 DD 3F800000h - -Proc GetFilterFrequency ; Given AL= Freq - Assume DS:Driver - - ShL AX, 8 - Mov TempVariable, AX - FILD TempVariable - - FMul FreqParameterMultiplier ; -i/(24*256) - FLd ST - FRndInt - FSub ST(1), ST - FXCh - F2XM1 - FLd1 - FAdd - FScale ; = 2^(i/24*256) - FMul FreqMultiplier ; = r - - FLd1 ; 1, c - FAdd ST, ST(1) ; 1+c, c - FDivR Const1 ; 1/(1+c), c - FSt DWord Ptr [SI] - FMul - FStP DWord Ptr [SI+4] - FStP ST - - Ret - -EndP GetFilterFrequency - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Const1On16 DD 3D000000h ; actually 1 on 32 - -Proc CalculateFilterCoefficients - Assume DS:Driver - - PushA - - FNInit - FLdCW NewControlWord - - Mov AL, [VolumeTable+6] - Mov SI, Offset FilterCoefficients - ShR AL, 1 - Call GetFilterFrequency - - Mov AL, [VolumeTable+7] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - - Mov AL, [VolumeTable+8] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - - Mov AL, [VolumeTable+9] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - -; Now volumes - Mov SI, Offset VolumeTable+10 - Mov DI, Offset FilterVolumes - Xor AX, AX - Mov CX, 4 - -FilterVolumeLoop1: - LodSB - Mov TempVariable, AX - FILD TempVariable - FMul Const1On16 - FStP DWord Ptr [DI] - - Add DI, 4 - Loop FilterVolumeLoop1 - - PopA - Ret - -EndP CalculateFilterCoefficients - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Cmp DI, 9 - JA SetVariable3 - - Cmp DI, 6 - JB SetVariable1 - - JE SetVariable2 - - Cmp AL, [VolumeTable+DI-1] - JAE SetVariable2 - - Mov AL, [VolumeTable+DI-1] - Mov [VolumeTable+DI], AL - -SetVariable2: - Cmp DI, 9 - JAE SetVariable3 - - Cmp AL, [VolumeTable+DI+1] - JBE SetVariable3 - - Mov AL, [VolumeTable+DI+1] - Mov [VolumeTable+DI], AL - -SetVariable3: - Call CalculateFilterCoefficients - Jmp SetVariableEnd - -SetVariable1: - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - -SetVariableEnd: - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut - - Push CX - Push DX - Mov DX, CS:MIDIPort - Test DX, DX - JZ UARTOutEnd - - Push AX - Xor CX, CX - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - LoopNZ UARTOut1 - - Pop AX - JNZ UARTOutEnd - - Dec DX - Out DX, AL - -UARTOutEnd: - Pop DX - Pop CX - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWaveForm Far ; Given ES:DI = destination - Assume DS:Nothing ; want 2048 samples. - - PushA - Push DS - - Mov DS, FourierSegment - Mov SI, FourierBufferStart - Mov CX, 2048 - -GetWaveForm1: - MovsW - And SI, (FOURIERBUFFERLENGTH*2)-1 - Loop GetWaveForm1 - - Pop DS - PopA - - Ret - -EndP GetWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 - DW 7 ; MIDI, hiqual - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - - DW Offset SendUARTOut - - DW Offset GetWaveform - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + + .586P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +TRACEENABLED = 0 +CREATENEWLOGFILE = 1 + +include debug.inc + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 +OUTPUTFILTERENABLED EQU 1 +FOURIERBUFFERLENGTH EQU 2048 ; 2048 samples + +FPSave DB 128 Dup (0) + +SB16Msg DB "Sound Blaster 16 3DNOW!", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SB16NoMemoryMsg DB "Sound Blaster 16 3DNOW!", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster 16 reinitialised", 0 + +DriverName DB "ITSB16.3DN", 0 + +DSPVersion DW 0 +DSPIRQValue DB 0 +DSPDMAValue DB 0 +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +FourierSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 20 +MixMode DW 0 +MixModeOffset DW 0 +DMASize DW 2048 +VolumeTable DB 6 Dup (0) + DB 0, 16, 96, 127 + DB 0, 0, 0, 0 + +IMR DW 0 +OldIRQHandler DD 0 + +MIDIPort DW 0 +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SB16ScreenList Label + DW 8 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr DriverText + + DW Near Ptr MasterVolumeLeft ; 8 + DW Near Ptr MasterVolumeRight ; 9 + DW Near Ptr TrebleVolumeLeft ; 10 + DW Near Ptr TrebleVolumeRight ; 11 + DW Near Ptr BassVolumeLeft ; 12 + DW Near Ptr BassVolumeRight ; 13 + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 15 + DW Near Ptr MixModeButton2 ; 16 + + DW Near Ptr FrequencyText ; 17 + + DW Near Ptr FilterText ; 18 + DW Near Ptr FilterBox1 + DW Near Ptr FilterBox2 + + DW Near Ptr FilterFrequency1 ; 21 + DW Near Ptr FilterFrequency2 + DW Near Ptr FilterFrequency3 + DW Near Ptr FilterFrequency4 + + DW Near Ptr FilterVolume1 ; 25 + DW Near Ptr FilterVolume2 + DW Near Ptr FilterVolume3 + DW Near Ptr FilterVolume4 + + DW 0 + +SB16HeaderLine DW 10 + DB "Sound Blaster 16 3DNow! Driver", 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 + +VolumeText DW 1 + DB 2, 13 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB 13 + DB 13 + DB "Treble Left", 13 + DB "Treble Right", 13 + DB "Bass Left", 13 + DB "Bass Right", 13 + DB 0 + +VolumeBox1 DW 0 + DB 21, 12, 27, 15 + DB 25 + +VolumeBox2 DW 0 + DB 14, 16, 18, 21 + DB 25 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MasterVolumeLeft DW 9 + DB 22, 13 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 14 + DW 0, 31 + DW 9, 1 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 15, 17 + DW 0, 15 + DW 9, 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 15, 18 + DW 0, 15 + DW 9, 3 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 15, 19 + DW 0, 15 + DW 9, 4 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 15, 20 + DW 0, 15 + DW 9, 5 + DW 12, 15, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 23 + DB 20h + DB "Mixing Mode", 0 + +FrequencyText DW 1 + DB 2, 48 + DB 20h + DB "Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 45454 + DW 0 + +MixModeButton1 DW 2 + DW 13, 16, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " 3DNow!, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 15, 18, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 28, 32, 30, 8 + DB 0 + DB " 3DNow!, Filtered", 0 + +FilterText DW 1 + DB 2, 39 + DB 20h + DB "Output Equalizer", 13 + DB 13 + DB " Low Frequency Band", 13 + DB " Med Low Frequency Band", 13 + DB "Med High Frequency Band", 13 + DB " High Frequency Band", 0 + +FilterBox1 DW 0 + DB 25, 40, 47, 45 + DB 25 + +FilterBox2 DW 0 + DB 52, 40, 74, 45 + DB 25 + +FilterFrequency1 DW 14 + DB 26, 41 + DW 0, 127 + DW 9, 6 + DW 16, 22, 25, 25 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency2 DW 14 + DB 26, 42 + DW 0, 127 + DW 9, 7 + DW 21, 23, 26, 26 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency3 DW 14 + DB 26, 43 + DW 0, 127 + DW 9, 8 + DW 22, 24, 27, 27 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency4 DW 14 + DB 26, 44 + DW 0, 127 + DW 9, 9 + DW 23, 0FFFFh, 28, 28 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume1 DW 14 + DB 53, 41 + DW 0, 255 + DW 9, 10 + DW 16, 26, 21, 21 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume2 DW 14 + DB 53, 42 + DW 0, 255 + DW 9, 11 + DW 25, 27, 22, 22 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume3 DW 14 + DB 53, 43 + DW 0, 255 + DW 9, 12 + DW 26, 28, 23, 23 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume4 DW 14 + DB 53, 44 + DW 0, 255 + DW 9, 13 + DW 27, 0FFFFh, 24, 24 + DW 0FFFFh, 0FFFFh + DW 20 + + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include mnomix.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectK63D + Assume DS:Driver + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectK63DFail + + Mov EAX, 80000000h + DB 0Fh, 0A2h ; CPUID + Cmp EAX, 80000000h + JBE DetectK63DFail + + Mov EAX, 80000001h + DB 0Fh, 0A2h + And EDX, 80800000h + Cmp EDX, 80800000h + JNE DetectK63DFail + + DB 85h + +DetectK63DFail: + StC + Ret + +EndP DetectK63D + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectUART ; Given DX = Port + +; From SB-DevKit + + ClI + + Inc DX + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 40h ; Ready for output + LoopNZ DetectUART1 + JNZ DetectUARTError + + Mov AL, 0FFh ; Reset! + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + JNZ DetectUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART4 + +DetectUART3: + Loop DetectUART2 + +DetectUARTError: + StI + StC + Ret + +DetectUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +DetectUART5: + In AL, DX + Test AL, 40h + LoopNZ DetectUART5 + JNZ DetectUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +DetectUART6: + Xor CX, CX + +DetectUART7: + In AL, DX + Test AL, 80h + JNZ DetectUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART9 + +DetectUART8: + Loop DetectUART7 + + Jmp DetectUARTError + +DetectUART9: + StI + ClC + Ret + +EndP DetectUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReinitUART + + Mov DX, MIDIPort + Test DX, DX + JZ ReinitUART1 + + Call DetectUART + +ReinitUART1: + Ret + +EndP ReinitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, MIDIPort + Test DX, DX + JZ ResetUART1 + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 45454 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Mov BX, 12000 + Xor DX, DX + Div BX + Mov FourierBufferStepOffset, AX + Mov FourierBufferStepFractional, DX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPIRQ + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPIRQValue + Mov AL, 80h + Out DX, AX + + Ret + +EndP ResetDSPIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPDMA + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPDMAValue + Mov AL, 81h + Out DX, AX + + Ret + +EndP ResetDSPDMA + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Call DetectK63D + JC DetectCardFailure + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AH, 4 ; SB DSP = 4.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + Add DL, 04h-0Eh ; 2x4h = Mixer index port + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov DSPIRQValue, AL + ; OK.. now get IRQ, or set IRQ + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + StC + Ret + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + +DetectCardFailure: + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: ; Detect DMA + Mov AL, 81h ; DMA select + Out DX, AL + Inc DL + In AL, DX ; AL = DMA + Dec DL + + Mov DSPDMAValue, AL + + Mov BX, DMA + Cmp BX, 0FFFFh + JE DetectCardDMA1 + Cmp Forced, 0 + JE DetectCardDMA1 + + Mov CL, 1 + Cmp BX, 1 + JB SetCardDMA1 + + Mov CL, 2 + JE SetCardDMA1 + + Cmp BX, 3 + JB DetectCard7 + + Mov CL, 8 + JE DetectCard7 + + Mov CL, 20h + Cmp BX, 5 + JB DetectCard7 + JE SetCardDMA1 + + Mov CL, 80h + Cmp BX, 7 + JA DetectCard7 + JE SetCardDMA1 + + Mov CL, 40h + +SetCardDMA1: + And AL, 0Bh + Test CL, 0Bh + JZ SetCardDMA4 + + Xor AL, AL + +SetCardDMA4: + Or CL, AL + + Mov AL, 81h + Out DX, AL + Inc DL + Mov AL, CL + Out DX, AL + Jmp DetectCard7 + +DetectCardDMA1: + Mov BX, 5 + Test AL, 20h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 40h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 80h + JNZ DetectCardDMA2 + + Mov BL, 0 + Test AL, 1 + JNZ DetectCardDMA2 + + Inc BL + Test AL, 2 + JNZ DetectCardDMA2 + + Add BL, 2 + Test AL, 8 + JNZ DetectCardDMA2 + +DetectCard8: + Call ResetDSPIRQ + StC + Ret + +DetectCardDMA2: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + + Cmp BX, DMA + JNE DetectCard8 + +DetectCardDMA3: + Mov DMA, BX + +DetectCard7: + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc +include fourier.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AckIRQ + Assume DS:Driver + + Mov AL, 20h + Cmp CS:IRQ, 7 + JBE AckIRQ1 + + Out 0A0h, AL + +AckIRQ1: + Out 20h, AL + Ret + +EndP AckIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Mov DX, MIDIPort + + Mov BL, [MIDIBufferTail] + Test DX, DX + JZ CheckMIDIEnd + + Inc DX + Mov CX, 0FFFFh + +CheckMIDIAgain: + In AL, DX + + Test AL, 80h + LoopNZ CheckMIDIAgain + + Dec DX + In AL, DX + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL +; Jmp CheckMIDIAgain + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SB16IRQHandler + + PushAD + Push DS + Push ES + + CLD + +SBIRQAgain: + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 4 ; Mixer Port + Mov AL, 82h + Out DX, AL + Inc DL ; DX = BasePort+5 + In AL, DX + +Comment ~ + Test AL, 1 + JZ SB8BitDigitalInterruptEnd + +SB8BitDigitalInterrupt: + Push AX + Add DL, 0Eh-5 + In AL, DX + Pop AX + +SB8BitDigitalInterruptEnd: + + ~ + Test AL, 4 + JZ SBMIDIInterruptEnd + + Push AX + Call CheckMIDI + Pop AX + +SBMIDIInterruptEnd: + Test AL, 2 + JNZ SBDigitalInterrupt + + Call AckIRQ + Jmp SBIRQEnd + +SBDigitalInterrupt: + FNSave [FPSave] + + Mov DX, BasePort + Add DL, 0Fh + In AL, DX ; 16-bit IRQ ack. + + Call AckIRQ + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SB16IRQHandler2 + + Xor AX, AX + Xor BX, BX + +SB16IRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Mov BX, DMASize ; BX = bytes required + Add DI, AX + ShR BX, 1 + ; BX = samples required + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SB16IRQHandler4 + Assume DS:Nothing + +SB16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + Call UpdateFourierBuffer + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SB16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SB16IRQHandler5 + + Mov DX, MixTransferRemaining + +SB16IRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SB16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRstor [CS:FPSave] + +SBIRQEnd: + Pop ES + Pop DS + PopAD + IRet + +EndP SB16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SB16IRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSB16 ; + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0B6h ; 16 bit, DAC + Call SBOut + Mov AL, Stereo + ShL AL, 5 + Or AL, 10h + Call SBOut + + Mov AX, DMASize + ShR AX, 1 + Dec AX + + Call SBOut ; DMALength, Lo + Mov AL, AH + Call SBOut + + Pop ES + Pop DS + PopA + + Ret + + Assume DS:Nothing + +EndP StartSB16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Call GetSBMixConst + + ; Parags to allocate = (8/(.4*31*16))*MixSpeed + 2080 + ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 5+(DMABUFFERLENGTH*2)/16+(FOURIERBUFFERLENGTH*2)/16 + Mov BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SB16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Sub AX, (FOURIERBUFFERLENGTH*2)/16 + Mov FourierSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov DX, 330h + Call DetectUART + JC DetectMIDI1 + + Mov MIDIPort, 330h + Jmp DetectMIDIEnd + +DetectMIDI1: + Mov DX, 300h + Call DetectUART + JC DetectMIDIEnd + + Mov MIDIPort, 300h + +DetectMIDIEnd: + Call CalculateFilterCoefficients + + Mov SI, Offset SB16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, BasePort + Call ResetDSP + + Call ResetUART + Call ResetIRQ + + ; Delay.. + Mov DX, BasePort + Add DL, 0Ch + + Mov CX, 1000 +ReInitSound1: + In AL, DX + Loop ReInitSound1 + + Call SetIRQ + Call ReinitUART + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Mov DX, CS:BasePort + Add DL, 0Ch + + Mov AL, 0D9h + Call SBOut + + Call ResetUART + + Mov AX, BasePort + Call ResetDSP + + Call ResetDSPDMA + Call ResetDSPIRQ + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov CS:Stereo, AL + Mov AX, CS:BasePort + Call ResetDSP + + Call StartSB16 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far ; Fix up end of sample bytes + + PushAD + Push DS + Push ES + Push FS + + Mov FS, CS:SongDataArea + Mov BP, AX + Add BP, BP + Mov BP, [FS:64910+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC LoadSampleEnd ; Zero flag ON if 16 bit.. + + Xor EAX, EAX + Mov BL, [FS:BP+12h] + + Test BL, 10h ; Loop + JZ LoadSample2 + + Mov ESI, [FS:BP+34h] ; Start of loop + Test BL, 40h ; Pingpong? + JZ LoadSample1 + + Mov ESI, [FS:BP+38h] + Sub ESI, 2 + JNC LoadSample1 + + Xor ESI, ESI + +LoadSample1: + Test BL, 2 + JZ LoadSample4 + + Add ESI, ESI + +LoadSample4: + Int 3 + Mov AL, [SI] + Inc ESI + Int 3 + Mov AH, [SI] + +LoadSample2: + Mov ESI, [FS:BP+30h] + Test BL, 2 + JZ LoadSample3 + + Add ESI, ESI + +LoadSample3: + Int 3 + Mov [SI], AL + Inc ESI + Int 3 + Mov [SI], AH + +LoadSampleEnd: + Pop FS + Pop ES + Pop DS + PopAD + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SB16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +TempVariable DW 0 +Const1 DD 3F800000h + +Proc GetFilterFrequency ; Given AL= Freq + Assume DS:Driver + + ShL AX, 8 + Mov TempVariable, AX + FILD TempVariable + + FMul FreqParameterMultiplier ; -i/(24*256) + FLd ST + FRndInt + FSub ST(1), ST + FXCh + F2XM1 + FLd1 + FAdd + FScale ; = 2^(i/24*256) + FMul FreqMultiplier ; = r + + FLd1 ; 1, c + FAdd ST, ST(1) ; 1+c, c + FDivR Const1 ; 1/(1+c), c + FSt DWord Ptr [SI] + FMul + FStP DWord Ptr [SI+4] + FStP ST + + Ret + +EndP GetFilterFrequency + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Const1On16 DD 3D000000h ; actually 1 on 32 + +Proc CalculateFilterCoefficients + Assume DS:Driver + + PushA + + FNInit + FLdCW NewControlWord + + Mov AL, [VolumeTable+6] + Mov SI, Offset FilterCoefficients + ShR AL, 1 + Call GetFilterFrequency + + Mov AL, [VolumeTable+7] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + + Mov AL, [VolumeTable+8] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + + Mov AL, [VolumeTable+9] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + +; Now volumes + Mov SI, Offset VolumeTable+10 + Mov DI, Offset FilterVolumes + Xor AX, AX + Mov CX, 4 + +FilterVolumeLoop1: + LodSB + Mov TempVariable, AX + FILD TempVariable + FMul Const1On16 + FStP DWord Ptr [DI] + + Add DI, 4 + Loop FilterVolumeLoop1 + + PopA + Ret + +EndP CalculateFilterCoefficients + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Cmp DI, 9 + JA SetVariable3 + + Cmp DI, 6 + JB SetVariable1 + + JE SetVariable2 + + Cmp AL, [VolumeTable+DI-1] + JAE SetVariable2 + + Mov AL, [VolumeTable+DI-1] + Mov [VolumeTable+DI], AL + +SetVariable2: + Cmp DI, 9 + JAE SetVariable3 + + Cmp AL, [VolumeTable+DI+1] + JBE SetVariable3 + + Mov AL, [VolumeTable+DI+1] + Mov [VolumeTable+DI], AL + +SetVariable3: + Call CalculateFilterCoefficients + Jmp SetVariableEnd + +SetVariable1: + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + +SetVariableEnd: + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut + + Push CX + Push DX + Mov DX, CS:MIDIPort + Test DX, DX + JZ UARTOutEnd + + Push AX + Xor CX, CX + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + LoopNZ UARTOut1 + + Pop AX + JNZ UARTOutEnd + + Dec DX + Out DX, AL + +UARTOutEnd: + Pop DX + Pop CX + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWaveForm Far ; Given ES:DI = destination + Assume DS:Nothing ; want 2048 samples. + + PushA + Push DS + + Mov DS, FourierSegment + Mov SI, FourierBufferStart + Mov CX, 2048 + +GetWaveForm1: + MovsW + And SI, (FOURIERBUFFERLENGTH*2)-1 + Loop GetWaveForm1 + + Pop DS + PopA + + Ret + +EndP GetWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 + DW 7 ; MIDI, hiqual + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + + DW Offset SendUARTOut + + DW Offset GetWaveform + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SB16MMX.ASM b/SoundDrivers/SB16MMX.ASM index 4c49440..b0a85f1 100755 --- a/SoundDrivers/SB16MMX.ASM +++ b/SoundDrivers/SB16MMX.ASM @@ -1,2272 +1,2272 @@ - - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -TRACEENABLED = 0 -CREATENEWLOGFILE = 1 - -include debug.inc - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 -OUTPUTFILTERENABLED EQU 1 -FOURIERBUFFERLENGTH EQU 2048 ; 2048 samples - -FPSave DB 128 Dup (0) - -SB16Msg DB "Sound Blaster 16 MMX", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SB16NoMemoryMsg DB "Sound Blaster 16 MMX", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster 16 reinitialised", 0 - -DefaultDriverName DB "ITSB16.MMX", 0 -DriverName DD 0 - -DSPVersion DW 0 -DSPIRQValue DB 0 -DSPDMAValue DB 0 -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -FourierSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 20 -MixMode DW 0 -MixModeOffset DW 0 -DMASize DW 2048 -VolumeTable DB 6 Dup (0) - DB 0, 16, 96, 127 - DB 0, 0, 0, 0 - -IMR DW 0 -OldIRQHandler DD 0 - -MIDIPort DW 0 -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SB16ScreenList Label - DW 8 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr DriverText - - DW Near Ptr MasterVolumeLeft ; 8 - DW Near Ptr MasterVolumeRight ; 9 - DW Near Ptr TrebleVolumeLeft ; 10 - DW Near Ptr TrebleVolumeRight ; 11 - DW Near Ptr BassVolumeLeft ; 12 - DW Near Ptr BassVolumeRight ; 13 - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 15 - DW Near Ptr MixModeButton2 ; 16 - DW Near Ptr MixModeButton3 ; 17 - DW Near Ptr MixModeButton4 ; 18 - - DW Near Ptr FrequencyText - - DW Near Ptr FilterText ; 20 - DW Near Ptr FilterBox1 - DW Near Ptr FilterBox2 - - DW Near Ptr FilterFrequency1 ; 23 - DW Near Ptr FilterFrequency2 - DW Near Ptr FilterFrequency3 - DW Near Ptr FilterFrequency4 - - DW Near Ptr FilterVolume1 ; 27 - DW Near Ptr FilterVolume2 - DW Near Ptr FilterVolume3 - DW Near Ptr FilterVolume4 - - DW 0 - - -SB16HeaderLine DW 10 - DB "Sound Blaster 16 Driver", 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 - -VolumeText DW 1 - DB 2, 13 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB 13 - DB 13 - DB "Treble Left", 13 - DB "Treble Right", 13 - DB "Bass Left", 13 - DB "Bass Right", 13 - DB 0 - -VolumeBox1 DW 0 - DB 21, 12, 27, 15 - DB 25 - -VolumeBox2 DW 0 - DB 14, 16, 18, 21 - DB 25 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MasterVolumeLeft DW 9 - DB 22, 13 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 14 - DW 0, 31 - DW 9, 1 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 15, 17 - DW 0, 15 - DW 9, 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 15, 18 - DW 0, 15 - DW 9, 3 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 15, 19 - DW 0, 15 - DW 9, 4 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 15, 20 - DW 0, 15 - DW 9, 5 - DW 12, 15, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 23 - DB 20h - DB "Mixing Mode", 0 - -FrequencyText DW 1 - DB 2, 48 - DB 20h - DB "Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 45454 - DW 0 - -MixModeButton1 DW 2 - DW 13, 16, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " MMX, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 15, 17, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 28, 32, 30, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 16, 18, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 31, 32, 33, 8 - DB 0 - DB " MMX, Volume Ramped", 0 - -MixModeButton4 DW 2 - DW 17, 23, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 34, 32, 36, 8 - DB 0 - DB " MMX, Filtered", 0 - -FilterText DW 1 - DB 2, 39 - DB 20h - DB "Output Equalizer", 13 - DB 13 - DB " Low Frequency Band", 13 - DB " Med Low Frequency Band", 13 - DB "Med High Frequency Band", 13 - DB " High Frequency Band", 0 - -FilterBox1 DW 0 - DB 25, 40, 47, 45 - DB 25 - -FilterBox2 DW 0 - DB 52, 40, 74, 45 - DB 25 - -FilterFrequency1 DW 14 - DB 26, 41 - DW 0, 127 - DW 9, 6 - DW 18, 24, 27, 27 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency2 DW 14 - DB 26, 42 - DW 0, 127 - DW 9, 7 - DW 23, 25, 28, 28 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency3 DW 14 - DB 26, 43 - DW 0, 127 - DW 9, 8 - DW 24, 26, 29, 29 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency4 DW 14 - DB 26, 44 - DW 0, 127 - DW 9, 9 - DW 25, 0FFFFh, 30, 30 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume1 DW 14 - DB 53, 41 - DW 0, 255 - DW 9, 10 - DW 18, 28, 23, 23 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume2 DW 14 - DB 53, 42 - DW 0, 255 - DW 9, 11 - DW 27, 29, 24, 24 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume3 DW 14 - DB 53, 43 - DW 0, 255 - DW 9, 12 - DW 28, 30, 25, 25 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume4 DW 14 - DB 53, 44 - DW 0, 255 - DW 9, 13 - DW 29, 0FFFFh, 26, 26 - DW 0FFFFh, 0FFFFh - DW 20 - - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMMX - - Trace "Detecting MMX - CPUID Check" - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectMMXFail - - Trace "CPUID - Check OK" - - Mov EAX, 1 - DB 0Fh, 0A2h ; CPUID - Test EDX, 800000h - JZ DetectMMXFail - - Trace "MMX Detected" - - ClC - Ret - -DetectMMXFail: - Trace "MMX Not Detected" - - StC - Ret - -EndP DetectMMX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectUART ; Given DX = Port - -; From SB-DevKit - - ClI - - Inc DX - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 40h ; Ready for output - LoopNZ DetectUART1 - JNZ DetectUARTError - - Mov AL, 0FFh ; Reset! - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - JNZ DetectUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART4 - -DetectUART3: - Loop DetectUART2 - -DetectUARTError: - StI - StC - Ret - -DetectUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -DetectUART5: - In AL, DX - Test AL, 40h - LoopNZ DetectUART5 - JNZ DetectUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -DetectUART6: - Xor CX, CX - -DetectUART7: - In AL, DX - Test AL, 80h - JNZ DetectUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART9 - -DetectUART8: - Loop DetectUART7 - - Jmp DetectUARTError - -DetectUART9: - StI - ClC - Ret - -EndP DetectUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReinitUART - - Mov DX, MIDIPort - Test DX, DX - JZ ReinitUART1 - - Call DetectUART - -ReinitUART1: - Ret - -EndP ReinitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, MIDIPort - Test DX, DX - JZ ResetUART1 - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 45454 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Mov BX, 12000 - Xor DX, DX - Div BX - Mov FourierBufferStepOffset, AX - Mov FourierBufferStepFractional, DX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPIRQ - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPIRQValue - Mov AL, 80h - Out DX, AX - - Ret - -EndP ResetDSPIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPDMA - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPDMAValue - Mov AL, 81h - Out DX, AX - - Ret - -EndP ResetDSPDMA - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Cmp BX, 217h - JAE DetectCardUseDriver - - Mov CX, DS - ShL ECX, 16 - Mov CX, Offset DefaultDriverName - -DetectCardUseDriver: - Mov DriverName, ECX - - Call DetectMMX - JC DetectCardFailure - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AH, 4 ; SB DSP = 4.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - Add DL, 04h-0Eh ; 2x4h = Mixer index port - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov DSPIRQValue, AL - ; OK.. now get IRQ, or set IRQ - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - StC - Ret - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - -DetectCardFailure: - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: ; Detect DMA - Mov AL, 81h ; DMA select - Out DX, AL - Inc DL - In AL, DX ; AL = DMA - Dec DL - - Mov DSPDMAValue, AL - - Mov BX, DMA - Cmp BX, 0FFFFh - JE DetectCardDMA1 - Cmp Forced, 0 - JE DetectCardDMA1 - - Mov CL, 1 - Cmp BX, 1 - JB SetCardDMA1 - - Mov CL, 2 - JE SetCardDMA1 - - Cmp BX, 3 - JB DetectCard7 - - Mov CL, 8 - JE DetectCard7 - - Mov CL, 20h - Cmp BX, 5 - JB DetectCard7 - JE SetCardDMA1 - - Mov CL, 80h - Cmp BX, 7 - JA DetectCard7 - JE SetCardDMA1 - - Mov CL, 40h - -SetCardDMA1: - And AL, 0Bh - Test CL, 0Bh - JZ SetCardDMA4 - - Xor AL, AL - -SetCardDMA4: - Or CL, AL - - Mov AL, 81h - Out DX, AL - Inc DL - Mov AL, CL - Out DX, AL - Jmp DetectCard7 - -DetectCardDMA1: - Mov BX, 5 - Test AL, 20h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 40h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 80h - JNZ DetectCardDMA2 - - Mov BL, 0 - Test AL, 1 - JNZ DetectCardDMA2 - - Inc BL - Test AL, 2 - JNZ DetectCardDMA2 - - Add BL, 2 - Test AL, 8 - JNZ DetectCardDMA2 - -DetectCard8: - Call ResetDSPIRQ - StC - Ret - -DetectCardDMA2: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - - Cmp BX, DMA - JNE DetectCard8 - -DetectCardDMA3: - Mov DMA, BX - -DetectCard7: - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc -include fourier.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AckIRQ - Assume DS:Driver - - Mov AL, 20h - Cmp CS:IRQ, 7 - JBE AckIRQ1 - - Out 0A0h, AL - -AckIRQ1: - Out 20h, AL - Ret - -EndP AckIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Mov DX, MIDIPort - - Mov BL, [MIDIBufferTail] - Test DX, DX - JZ CheckMIDIEnd - - Inc DX - Mov CX, 0FFFFh - -CheckMIDIAgain: - In AL, DX - - Test AL, 80h - LoopNZ CheckMIDIAgain - - Dec DX - In AL, DX - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL -; Jmp CheckMIDIAgain - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SB16IRQHandler - - PushAD - Push DS - Push ES - - CLD - -SBIRQAgain: - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 4 ; Mixer Port - Mov AL, 82h - Out DX, AL - Inc DL ; DX = BasePort+5 - In AL, DX - -Comment ~ - Test AL, 1 - JZ SB8BitDigitalInterruptEnd - -SB8BitDigitalInterrupt: - Push AX - Add DL, 0Eh-5 - In AL, DX - Pop AX - -SB8BitDigitalInterruptEnd: - - ~ - Test AL, 4 - JZ SBMIDIInterruptEnd - - Push AX - Call CheckMIDI - Pop AX - -SBMIDIInterruptEnd: - Test AL, 2 - JNZ SBDigitalInterrupt - - Call AckIRQ - Jmp SBIRQEnd - -SBDigitalInterrupt: - FNSave [FPSave] - - Mov DX, BasePort - Add DL, 0Fh - In AL, DX ; 16-bit IRQ ack. - - Call AckIRQ - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SB16IRQHandler2 - - Xor AX, AX - Xor BX, BX - -SB16IRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Mov BX, DMASize ; BX = bytes required - Add DI, AX - ShR BX, 1 - ; BX = samples required - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SB16IRQHandler4 - Assume DS:Nothing - -SB16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - Call UpdateFourierBuffer - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SB16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SB16IRQHandler5 - - Mov DX, MixTransferRemaining - -SB16IRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SB16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRstor [CS:FPSave] - -SBIRQEnd: - Pop ES - Pop DS - PopAD - IRet - -EndP SB16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SB16IRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSB16 ; - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0B6h ; 16 bit, DAC - Call SBOut - Mov AL, Stereo - ShL AL, 5 - Or AL, 10h - Call SBOut - - Mov AX, DMASize - ShR AX, 1 - Dec AX - - Call SBOut ; DMALength, Lo - Mov AL, AH - Call SBOut - - Pop ES - Pop DS - PopA - - Ret - - Assume DS:Nothing - -EndP StartSB16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Call GetSBMixConst - - ; Parags to allocate = (8/(.4*31*16))*MixSpeed - ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 5+(DMABUFFERLENGTH*2)/16+(FOURIERBUFFERLENGTH*2)/16 - Mov BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SB16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Sub AX, (FOURIERBUFFERLENGTH*2)/16 - Mov FourierSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov DX, 330h - Call DetectUART - JC DetectMIDI1 - - Mov MIDIPort, 330h - Jmp DetectMIDIEnd - -DetectMIDI1: - Mov DX, 300h - Call DetectUART - JC DetectMIDIEnd - - Mov MIDIPort, 300h - -DetectMIDIEnd: - Call CalculateFilterCoefficients - - Mov SI, Offset SB16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, BasePort - Call ResetDSP - - Call ResetUART - Call ResetIRQ - - ; Delay.. - Mov DX, BasePort - Add DL, 0Ch - - Mov CX, 1000 -ReInitSound1: - In AL, DX - Loop ReInitSound1 - - Call SetIRQ - Call ReinitUART - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Mov DS, Word Ptr [CS:DriverName+2] - Mov DX, Word Ptr [CS:DriverName] - - Mov AX, 3D02h ; Read write access - Int 21h - - Push CS - Pop DS - Assume DS:Driver - - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Mov DX, CS:BasePort - Add DL, 0Ch - - Mov AL, 0D9h - Call SBOut - - Call ResetUART - - Mov AX, BasePort - Call ResetDSP - - Call ResetDSPDMA - Call ResetDSPIRQ - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov CS:Stereo, AL - Mov AX, CS:BasePort - Call ResetDSP - - Call StartSB16 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SB16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -TempVariable DW 0 -Const1 DD 3F800000h - -Proc GetFilterFrequency ; Given AL= Freq - Assume DS:Driver - - ShL AX, 8 - Mov TempVariable, AX - FILD TempVariable - - FMul FreqParameterMultiplier ; -i/(24*256) - FLd ST - FRndInt - FSub ST(1), ST - FXCh - F2XM1 - FLd1 - FAdd - FScale ; = 2^(i/24*256) - FMul FreqMultiplier ; = r - - FLd1 ; 1, c - FAdd ST, ST(1) ; 1+c, c - FDivR Const1 ; 1/(1+c), c - FSt DWord Ptr [SI] - FMul - FStP DWord Ptr [SI+4] - FStP ST - - Ret - -EndP GetFilterFrequency - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Const1On16 DD 3D000000h ; actually 1 on 32 - -Proc CalculateFilterCoefficients - Assume DS:Driver - - PushA - - FNInit - FLdCW NewControlWord - - Mov AL, [VolumeTable+6] - Mov SI, Offset FilterCoefficients - ShR AL, 1 - Call GetFilterFrequency - - Mov AL, [VolumeTable+7] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - - Mov AL, [VolumeTable+8] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - - Mov AL, [VolumeTable+9] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - -; Now volumes - Mov SI, Offset VolumeTable+10 - Mov DI, Offset FilterVolumes - Xor AX, AX - Mov CX, 4 - -FilterVolumeLoop1: - LodSB - Mov TempVariable, AX - FILD TempVariable - FMul Const1On16 - FStP DWord Ptr [DI] - - Add DI, 4 - Loop FilterVolumeLoop1 - - PopA - Ret - -EndP CalculateFilterCoefficients - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Cmp DI, 9 - JA SetVariable3 - - Cmp DI, 6 - JB SetVariable1 - - JE SetVariable2 - - Cmp AL, [VolumeTable+DI-1] - JAE SetVariable2 - - Mov AL, [VolumeTable+DI-1] - Mov [VolumeTable+DI], AL - -SetVariable2: - Cmp DI, 9 - JAE SetVariable3 - - Cmp AL, [VolumeTable+DI+1] - JBE SetVariable3 - - Mov AL, [VolumeTable+DI+1] - Mov [VolumeTable+DI], AL - -SetVariable3: - Call CalculateFilterCoefficients - Jmp SetVariableEnd - -SetVariable1: - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - -SetVariableEnd: - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut - - Push CX - Push DX - Mov DX, CS:MIDIPort - Test DX, DX - JZ UARTOutEnd - - Push AX - Xor CX, CX - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - LoopNZ UARTOut1 - - Pop AX - JNZ UARTOutEnd - - Dec DX - Out DX, AL - -UARTOutEnd: - Pop DX - Pop CX - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWaveForm Far ; Given ES:DI = destination - Assume DS:Nothing ; want 2048 samples. - - PushA - Push DS - - Mov DS, FourierSegment - Mov SI, FourierBufferStart - Mov CX, 2048 - -GetWaveForm1: - MovsW - And SI, (FOURIERBUFFERLENGTH*2)-1 - Loop GetWaveForm1 - - Pop DS - PopA - - Ret - -EndP GetWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 - DW 7 ; MIDI, hiqual - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - - DW Offset SendUARTOut - - DW Offset GetWaveform - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +TRACEENABLED = 0 +CREATENEWLOGFILE = 1 + +include debug.inc + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 +OUTPUTFILTERENABLED EQU 1 +FOURIERBUFFERLENGTH EQU 2048 ; 2048 samples + +FPSave DB 128 Dup (0) + +SB16Msg DB "Sound Blaster 16 MMX", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SB16NoMemoryMsg DB "Sound Blaster 16 MMX", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster 16 reinitialised", 0 + +DefaultDriverName DB "ITSB16.MMX", 0 +DriverName DD 0 + +DSPVersion DW 0 +DSPIRQValue DB 0 +DSPDMAValue DB 0 +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +FourierSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 20 +MixMode DW 0 +MixModeOffset DW 0 +DMASize DW 2048 +VolumeTable DB 6 Dup (0) + DB 0, 16, 96, 127 + DB 0, 0, 0, 0 + +IMR DW 0 +OldIRQHandler DD 0 + +MIDIPort DW 0 +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SB16ScreenList Label + DW 8 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr DriverText + + DW Near Ptr MasterVolumeLeft ; 8 + DW Near Ptr MasterVolumeRight ; 9 + DW Near Ptr TrebleVolumeLeft ; 10 + DW Near Ptr TrebleVolumeRight ; 11 + DW Near Ptr BassVolumeLeft ; 12 + DW Near Ptr BassVolumeRight ; 13 + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 15 + DW Near Ptr MixModeButton2 ; 16 + DW Near Ptr MixModeButton3 ; 17 + DW Near Ptr MixModeButton4 ; 18 + + DW Near Ptr FrequencyText + + DW Near Ptr FilterText ; 20 + DW Near Ptr FilterBox1 + DW Near Ptr FilterBox2 + + DW Near Ptr FilterFrequency1 ; 23 + DW Near Ptr FilterFrequency2 + DW Near Ptr FilterFrequency3 + DW Near Ptr FilterFrequency4 + + DW Near Ptr FilterVolume1 ; 27 + DW Near Ptr FilterVolume2 + DW Near Ptr FilterVolume3 + DW Near Ptr FilterVolume4 + + DW 0 + + +SB16HeaderLine DW 10 + DB "Sound Blaster 16 Driver", 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 + +VolumeText DW 1 + DB 2, 13 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB 13 + DB 13 + DB "Treble Left", 13 + DB "Treble Right", 13 + DB "Bass Left", 13 + DB "Bass Right", 13 + DB 0 + +VolumeBox1 DW 0 + DB 21, 12, 27, 15 + DB 25 + +VolumeBox2 DW 0 + DB 14, 16, 18, 21 + DB 25 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MasterVolumeLeft DW 9 + DB 22, 13 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 14 + DW 0, 31 + DW 9, 1 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 15, 17 + DW 0, 15 + DW 9, 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 15, 18 + DW 0, 15 + DW 9, 3 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 15, 19 + DW 0, 15 + DW 9, 4 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 15, 20 + DW 0, 15 + DW 9, 5 + DW 12, 15, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 23 + DB 20h + DB "Mixing Mode", 0 + +FrequencyText DW 1 + DB 2, 48 + DB 20h + DB "Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 45454 + DW 0 + +MixModeButton1 DW 2 + DW 13, 16, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " MMX, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 15, 17, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 28, 32, 30, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 16, 18, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 31, 32, 33, 8 + DB 0 + DB " MMX, Volume Ramped", 0 + +MixModeButton4 DW 2 + DW 17, 23, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 34, 32, 36, 8 + DB 0 + DB " MMX, Filtered", 0 + +FilterText DW 1 + DB 2, 39 + DB 20h + DB "Output Equalizer", 13 + DB 13 + DB " Low Frequency Band", 13 + DB " Med Low Frequency Band", 13 + DB "Med High Frequency Band", 13 + DB " High Frequency Band", 0 + +FilterBox1 DW 0 + DB 25, 40, 47, 45 + DB 25 + +FilterBox2 DW 0 + DB 52, 40, 74, 45 + DB 25 + +FilterFrequency1 DW 14 + DB 26, 41 + DW 0, 127 + DW 9, 6 + DW 18, 24, 27, 27 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency2 DW 14 + DB 26, 42 + DW 0, 127 + DW 9, 7 + DW 23, 25, 28, 28 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency3 DW 14 + DB 26, 43 + DW 0, 127 + DW 9, 8 + DW 24, 26, 29, 29 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency4 DW 14 + DB 26, 44 + DW 0, 127 + DW 9, 9 + DW 25, 0FFFFh, 30, 30 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume1 DW 14 + DB 53, 41 + DW 0, 255 + DW 9, 10 + DW 18, 28, 23, 23 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume2 DW 14 + DB 53, 42 + DW 0, 255 + DW 9, 11 + DW 27, 29, 24, 24 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume3 DW 14 + DB 53, 43 + DW 0, 255 + DW 9, 12 + DW 28, 30, 25, 25 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume4 DW 14 + DB 53, 44 + DW 0, 255 + DW 9, 13 + DW 29, 0FFFFh, 26, 26 + DW 0FFFFh, 0FFFFh + DW 20 + + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMMX + + Trace "Detecting MMX - CPUID Check" + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectMMXFail + + Trace "CPUID - Check OK" + + Mov EAX, 1 + DB 0Fh, 0A2h ; CPUID + Test EDX, 800000h + JZ DetectMMXFail + + Trace "MMX Detected" + + ClC + Ret + +DetectMMXFail: + Trace "MMX Not Detected" + + StC + Ret + +EndP DetectMMX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectUART ; Given DX = Port + +; From SB-DevKit + + ClI + + Inc DX + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 40h ; Ready for output + LoopNZ DetectUART1 + JNZ DetectUARTError + + Mov AL, 0FFh ; Reset! + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + JNZ DetectUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART4 + +DetectUART3: + Loop DetectUART2 + +DetectUARTError: + StI + StC + Ret + +DetectUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +DetectUART5: + In AL, DX + Test AL, 40h + LoopNZ DetectUART5 + JNZ DetectUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +DetectUART6: + Xor CX, CX + +DetectUART7: + In AL, DX + Test AL, 80h + JNZ DetectUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART9 + +DetectUART8: + Loop DetectUART7 + + Jmp DetectUARTError + +DetectUART9: + StI + ClC + Ret + +EndP DetectUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReinitUART + + Mov DX, MIDIPort + Test DX, DX + JZ ReinitUART1 + + Call DetectUART + +ReinitUART1: + Ret + +EndP ReinitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, MIDIPort + Test DX, DX + JZ ResetUART1 + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 45454 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Mov BX, 12000 + Xor DX, DX + Div BX + Mov FourierBufferStepOffset, AX + Mov FourierBufferStepFractional, DX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPIRQ + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPIRQValue + Mov AL, 80h + Out DX, AX + + Ret + +EndP ResetDSPIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPDMA + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPDMAValue + Mov AL, 81h + Out DX, AX + + Ret + +EndP ResetDSPDMA + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Cmp BX, 217h + JAE DetectCardUseDriver + + Mov CX, DS + ShL ECX, 16 + Mov CX, Offset DefaultDriverName + +DetectCardUseDriver: + Mov DriverName, ECX + + Call DetectMMX + JC DetectCardFailure + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AH, 4 ; SB DSP = 4.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + Add DL, 04h-0Eh ; 2x4h = Mixer index port + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov DSPIRQValue, AL + ; OK.. now get IRQ, or set IRQ + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + StC + Ret + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + +DetectCardFailure: + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: ; Detect DMA + Mov AL, 81h ; DMA select + Out DX, AL + Inc DL + In AL, DX ; AL = DMA + Dec DL + + Mov DSPDMAValue, AL + + Mov BX, DMA + Cmp BX, 0FFFFh + JE DetectCardDMA1 + Cmp Forced, 0 + JE DetectCardDMA1 + + Mov CL, 1 + Cmp BX, 1 + JB SetCardDMA1 + + Mov CL, 2 + JE SetCardDMA1 + + Cmp BX, 3 + JB DetectCard7 + + Mov CL, 8 + JE DetectCard7 + + Mov CL, 20h + Cmp BX, 5 + JB DetectCard7 + JE SetCardDMA1 + + Mov CL, 80h + Cmp BX, 7 + JA DetectCard7 + JE SetCardDMA1 + + Mov CL, 40h + +SetCardDMA1: + And AL, 0Bh + Test CL, 0Bh + JZ SetCardDMA4 + + Xor AL, AL + +SetCardDMA4: + Or CL, AL + + Mov AL, 81h + Out DX, AL + Inc DL + Mov AL, CL + Out DX, AL + Jmp DetectCard7 + +DetectCardDMA1: + Mov BX, 5 + Test AL, 20h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 40h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 80h + JNZ DetectCardDMA2 + + Mov BL, 0 + Test AL, 1 + JNZ DetectCardDMA2 + + Inc BL + Test AL, 2 + JNZ DetectCardDMA2 + + Add BL, 2 + Test AL, 8 + JNZ DetectCardDMA2 + +DetectCard8: + Call ResetDSPIRQ + StC + Ret + +DetectCardDMA2: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + + Cmp BX, DMA + JNE DetectCard8 + +DetectCardDMA3: + Mov DMA, BX + +DetectCard7: + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc +include fourier.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AckIRQ + Assume DS:Driver + + Mov AL, 20h + Cmp CS:IRQ, 7 + JBE AckIRQ1 + + Out 0A0h, AL + +AckIRQ1: + Out 20h, AL + Ret + +EndP AckIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Mov DX, MIDIPort + + Mov BL, [MIDIBufferTail] + Test DX, DX + JZ CheckMIDIEnd + + Inc DX + Mov CX, 0FFFFh + +CheckMIDIAgain: + In AL, DX + + Test AL, 80h + LoopNZ CheckMIDIAgain + + Dec DX + In AL, DX + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL +; Jmp CheckMIDIAgain + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SB16IRQHandler + + PushAD + Push DS + Push ES + + CLD + +SBIRQAgain: + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 4 ; Mixer Port + Mov AL, 82h + Out DX, AL + Inc DL ; DX = BasePort+5 + In AL, DX + +Comment ~ + Test AL, 1 + JZ SB8BitDigitalInterruptEnd + +SB8BitDigitalInterrupt: + Push AX + Add DL, 0Eh-5 + In AL, DX + Pop AX + +SB8BitDigitalInterruptEnd: + + ~ + Test AL, 4 + JZ SBMIDIInterruptEnd + + Push AX + Call CheckMIDI + Pop AX + +SBMIDIInterruptEnd: + Test AL, 2 + JNZ SBDigitalInterrupt + + Call AckIRQ + Jmp SBIRQEnd + +SBDigitalInterrupt: + FNSave [FPSave] + + Mov DX, BasePort + Add DL, 0Fh + In AL, DX ; 16-bit IRQ ack. + + Call AckIRQ + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SB16IRQHandler2 + + Xor AX, AX + Xor BX, BX + +SB16IRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Mov BX, DMASize ; BX = bytes required + Add DI, AX + ShR BX, 1 + ; BX = samples required + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SB16IRQHandler4 + Assume DS:Nothing + +SB16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + Call UpdateFourierBuffer + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SB16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SB16IRQHandler5 + + Mov DX, MixTransferRemaining + +SB16IRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SB16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRstor [CS:FPSave] + +SBIRQEnd: + Pop ES + Pop DS + PopAD + IRet + +EndP SB16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SB16IRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSB16 ; + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0B6h ; 16 bit, DAC + Call SBOut + Mov AL, Stereo + ShL AL, 5 + Or AL, 10h + Call SBOut + + Mov AX, DMASize + ShR AX, 1 + Dec AX + + Call SBOut ; DMALength, Lo + Mov AL, AH + Call SBOut + + Pop ES + Pop DS + PopA + + Ret + + Assume DS:Nothing + +EndP StartSB16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Call GetSBMixConst + + ; Parags to allocate = (8/(.4*31*16))*MixSpeed + ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 5+(DMABUFFERLENGTH*2)/16+(FOURIERBUFFERLENGTH*2)/16 + Mov BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SB16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Sub AX, (FOURIERBUFFERLENGTH*2)/16 + Mov FourierSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov DX, 330h + Call DetectUART + JC DetectMIDI1 + + Mov MIDIPort, 330h + Jmp DetectMIDIEnd + +DetectMIDI1: + Mov DX, 300h + Call DetectUART + JC DetectMIDIEnd + + Mov MIDIPort, 300h + +DetectMIDIEnd: + Call CalculateFilterCoefficients + + Mov SI, Offset SB16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, BasePort + Call ResetDSP + + Call ResetUART + Call ResetIRQ + + ; Delay.. + Mov DX, BasePort + Add DL, 0Ch + + Mov CX, 1000 +ReInitSound1: + In AL, DX + Loop ReInitSound1 + + Call SetIRQ + Call ReinitUART + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Mov DS, Word Ptr [CS:DriverName+2] + Mov DX, Word Ptr [CS:DriverName] + + Mov AX, 3D02h ; Read write access + Int 21h + + Push CS + Pop DS + Assume DS:Driver + + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Mov DX, CS:BasePort + Add DL, 0Ch + + Mov AL, 0D9h + Call SBOut + + Call ResetUART + + Mov AX, BasePort + Call ResetDSP + + Call ResetDSPDMA + Call ResetDSPIRQ + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov CS:Stereo, AL + Mov AX, CS:BasePort + Call ResetDSP + + Call StartSB16 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SB16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +TempVariable DW 0 +Const1 DD 3F800000h + +Proc GetFilterFrequency ; Given AL= Freq + Assume DS:Driver + + ShL AX, 8 + Mov TempVariable, AX + FILD TempVariable + + FMul FreqParameterMultiplier ; -i/(24*256) + FLd ST + FRndInt + FSub ST(1), ST + FXCh + F2XM1 + FLd1 + FAdd + FScale ; = 2^(i/24*256) + FMul FreqMultiplier ; = r + + FLd1 ; 1, c + FAdd ST, ST(1) ; 1+c, c + FDivR Const1 ; 1/(1+c), c + FSt DWord Ptr [SI] + FMul + FStP DWord Ptr [SI+4] + FStP ST + + Ret + +EndP GetFilterFrequency + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Const1On16 DD 3D000000h ; actually 1 on 32 + +Proc CalculateFilterCoefficients + Assume DS:Driver + + PushA + + FNInit + FLdCW NewControlWord + + Mov AL, [VolumeTable+6] + Mov SI, Offset FilterCoefficients + ShR AL, 1 + Call GetFilterFrequency + + Mov AL, [VolumeTable+7] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + + Mov AL, [VolumeTable+8] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + + Mov AL, [VolumeTable+9] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + +; Now volumes + Mov SI, Offset VolumeTable+10 + Mov DI, Offset FilterVolumes + Xor AX, AX + Mov CX, 4 + +FilterVolumeLoop1: + LodSB + Mov TempVariable, AX + FILD TempVariable + FMul Const1On16 + FStP DWord Ptr [DI] + + Add DI, 4 + Loop FilterVolumeLoop1 + + PopA + Ret + +EndP CalculateFilterCoefficients + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Cmp DI, 9 + JA SetVariable3 + + Cmp DI, 6 + JB SetVariable1 + + JE SetVariable2 + + Cmp AL, [VolumeTable+DI-1] + JAE SetVariable2 + + Mov AL, [VolumeTable+DI-1] + Mov [VolumeTable+DI], AL + +SetVariable2: + Cmp DI, 9 + JAE SetVariable3 + + Cmp AL, [VolumeTable+DI+1] + JBE SetVariable3 + + Mov AL, [VolumeTable+DI+1] + Mov [VolumeTable+DI], AL + +SetVariable3: + Call CalculateFilterCoefficients + Jmp SetVariableEnd + +SetVariable1: + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + +SetVariableEnd: + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut + + Push CX + Push DX + Mov DX, CS:MIDIPort + Test DX, DX + JZ UARTOutEnd + + Push AX + Xor CX, CX + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + LoopNZ UARTOut1 + + Pop AX + JNZ UARTOutEnd + + Dec DX + Out DX, AL + +UARTOutEnd: + Pop DX + Pop CX + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWaveForm Far ; Given ES:DI = destination + Assume DS:Nothing ; want 2048 samples. + + PushA + Push DS + + Mov DS, FourierSegment + Mov SI, FourierBufferStart + Mov CX, 2048 + +GetWaveForm1: + MovsW + And SI, (FOURIERBUFFERLENGTH*2)-1 + Loop GetWaveForm1 + + Pop DS + PopA + + Ret + +EndP GetWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 + DW 7 ; MIDI, hiqual + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + + DW Offset SendUARTOut + + DW Offset GetWaveform + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SB16MMXB.ASM b/SoundDrivers/SB16MMXB.ASM index 15607d8..21fbd5a 100755 --- a/SoundDrivers/SB16MMXB.ASM +++ b/SoundDrivers/SB16MMXB.ASM @@ -1,2265 +1,2265 @@ - - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -TRACEENABLED = 0 -CREATENEWLOGFILE = 1 - -include debug.inc - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 -OUTPUTFILTERENABLED EQU 1 -FOURIERBUFFERLENGTH EQU 2048 ; 2048 samples - -FPSave DB 128 Dup (0) - -SB16Msg DB "Sound Blaster 16 MMX", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SB16NoMemoryMsg DB "Sound Blaster 16 MMX", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster 16 reinitialised", 0 - -DefaultDriverName DB "ITSB16.MMX", 0 -DriverName DD 0 - -DSPVersion DW 0 -DSPIRQValue DB 0 -DSPDMAValue DB 0 -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -FourierSegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 20 -MixMode DW 0 -MixModeOffset DW 0 -DMASize DW 2048 -VolumeTable DB 6 Dup (0) - DB 0, 16, 96, 127 - DB 0, 0, 0, 0 - -IMR DW 0 -OldIRQHandler DD 0 - -MIDIPort DW 0 -MIDIBuffer DB 256 Dup (0) -MIDIBufferHead DB 0 -MIDIBufferTail DB 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SB16ScreenList Label - DW 8 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - DW Near Ptr VolumeBox2 - - DW Near Ptr DriverText - - DW Near Ptr MasterVolumeLeft ; 8 - DW Near Ptr MasterVolumeRight ; 9 - DW Near Ptr TrebleVolumeLeft ; 10 - DW Near Ptr TrebleVolumeRight ; 11 - DW Near Ptr BassVolumeLeft ; 12 - DW Near Ptr BassVolumeRight ; 13 - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 15 - DW Near Ptr MixModeButton2 ; 16 - DW Near Ptr MixModeButton3 ; 17 - DW Near Ptr MixModeButton4 ; 18 - - DW Near Ptr FrequencyText - - DW Near Ptr FilterText ; 20 - DW Near Ptr FilterBox1 - DW Near Ptr FilterBox2 - - DW Near Ptr FilterFrequency1 ; 23 - DW Near Ptr FilterFrequency2 - DW Near Ptr FilterFrequency3 - DW Near Ptr FilterFrequency4 - - DW Near Ptr FilterVolume1 ; 27 - DW Near Ptr FilterVolume2 - DW Near Ptr FilterVolume3 - DW Near Ptr FilterVolume4 - - DW 0 - - -SB16HeaderLine DW 10 - DB "Sound Blaster 16 Driver", 0 - -DriverText DW 1 - DB 31, 48 - DB 21h - DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 - -VolumeText DW 1 - DB 2, 13 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB 13 - DB 13 - DB "Treble Left", 13 - DB "Treble Right", 13 - DB "Bass Left", 13 - DB "Bass Right", 13 - DB 0 - -VolumeBox1 DW 0 - DB 21, 12, 27, 15 - DB 25 - -VolumeBox2 DW 0 - DB 14, 16, 18, 21 - DB 25 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MasterVolumeLeft DW 9 - DB 22, 13 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 14 - DW 0, 31 - DW 9, 1 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeLeft DW 9 - DB 15, 17 - DW 0, 15 - DW 9, 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -TrebleVolumeRight DW 9 - DB 15, 18 - DW 0, 15 - DW 9, 3 - DW 10, 12, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeLeft DW 9 - DB 15, 19 - DW 0, 15 - DW 9, 4 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -BassVolumeRight DW 9 - DB 15, 20 - DW 0, 15 - DW 9, 5 - DW 12, 15, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 23 - DB 20h - DB "Mixing Mode", 0 - -FrequencyText DW 1 - DB 2, 48 - DB 20h - DB "Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 45454 - DW 0 - -MixModeButton1 DW 2 - DW 13, 16, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " MMX, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 15, 17, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 28, 32, 30, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 16, 18, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 31, 32, 33, 8 - DB 0 - DB " MMX, Volume Ramped", 0 - -MixModeButton4 DW 2 - DW 17, 23, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 34, 32, 36, 8 - DB 0 - DB " MMX, Filtered", 0 - -FilterText DW 1 - DB 2, 39 - DB 20h - DB "Output Equalizer", 13 - DB 13 - DB " Low Frequency Band", 13 - DB " Med Low Frequency Band", 13 - DB "Med High Frequency Band", 13 - DB " High Frequency Band", 0 - -FilterBox1 DW 0 - DB 25, 40, 47, 45 - DB 25 - -FilterBox2 DW 0 - DB 52, 40, 74, 45 - DB 25 - -FilterFrequency1 DW 14 - DB 26, 41 - DW 0, 127 - DW 9, 6 - DW 18, 24, 27, 27 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency2 DW 14 - DB 26, 42 - DW 0, 127 - DW 9, 7 - DW 23, 25, 28, 28 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency3 DW 14 - DB 26, 43 - DW 0, 127 - DW 9, 8 - DW 24, 26, 29, 29 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency4 DW 14 - DB 26, 44 - DW 0, 127 - DW 9, 9 - DW 25, 0FFFFh, 30, 30 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume1 DW 14 - DB 53, 41 - DW 0, 255 - DW 9, 10 - DW 18, 28, 23, 23 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume2 DW 14 - DB 53, 42 - DW 0, 255 - DW 9, 11 - DW 27, 29, 24, 24 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume3 DW 14 - DB 53, 43 - DW 0, 255 - DW 9, 12 - DW 28, 30, 25, 25 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume4 DW 14 - DB 53, 44 - DW 0, 255 - DW 9, 13 - DW 29, 0FFFFh, 26, 26 - DW 0FFFFh, 0FFFFh - DW 20 - - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include dmasirq.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMMX - - Trace "Detecting MMX - CPUID Check" - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectMMXFail - - Trace "CPUID - Check OK" - - Mov EAX, 1 - DB 0Fh, 0A2h ; CPUID - Test EDX, 800000h - JZ DetectMMXFail - - Trace "MMX Detected" - - ClC - Ret - -DetectMMXFail: - Trace "MMX Not Detected" - - StC - Ret - -EndP DetectMMX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectUART ; Given DX = Port - -; From SB-DevKit - - ClI - - Inc DX - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 40h ; Ready for output - LoopNZ DetectUART1 - JNZ DetectUARTError - - Mov AL, 0FFh ; Reset! - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - JNZ DetectUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART4 - -DetectUART3: - Loop DetectUART2 - -DetectUARTError: - StI - StC - Ret - -DetectUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -DetectUART5: - In AL, DX - Test AL, 40h - LoopNZ DetectUART5 - JNZ DetectUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -DetectUART6: - Xor CX, CX - -DetectUART7: - In AL, DX - Test AL, 80h - JNZ DetectUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE DetectUART9 - -DetectUART8: - Loop DetectUART7 - - Jmp DetectUARTError - -DetectUART9: - StI - ClC - Ret - -EndP DetectUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReinitUART - - Mov DX, MIDIPort - Test DX, DX - JZ ReinitUART1 - - Call DetectUART - -ReinitUART1: - Ret - -EndP ReinitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, MIDIPort - Test DX, DX - JZ ResetUART1 - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 45454 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Mov BX, 12000 - Xor DX, DX - Div BX - Mov FourierBufferStepOffset, AX - Mov FourierBufferStepFractional, DX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPIRQ - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPIRQValue - Mov AL, 80h - Out DX, AX - - Ret - -EndP ResetDSPIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSPDMA - - Mov DX, CS:BasePort - Add DL, 4 - Mov AH, CS:DSPDMAValue - Mov AL, 81h - Out DX, AX - - Ret - -EndP ResetDSPDMA - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Cmp BX, 217h - JAE DetectCardUseDriver - - Mov CX, DS - ShL ECX, 16 - Mov CX, Offset DefaultDriverName - -DetectCardUseDriver: - Mov DriverName, ECX - - Call DetectMMX - JC DetectCardFailure - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AH, 4 ; SB DSP = 4.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - Add DL, 04h-0Eh ; 2x4h = Mixer index port - Mov AL, 80h ; IRQ select - Out DX, AL - Inc DL ; 2x5h = Mixer data port - - In AL, DX - - Dec DL - - Mov DSPIRQValue, AL - ; OK.. now get IRQ, or set IRQ - Mov BX, IRQ - Cmp BX, 0FFFFh - JE DetectCardIRQ1 - Cmp Forced, 0 - JE DetectCardIRQ1 - - Mov AH, 11h - Cmp BL, 2 - JE SetCardIRQ1 - Cmp BL, 9 - JE SetCardIRQ1 - - Mov AH, 12h - Cmp BL, 5 - JE SetCardIRQ1 - - Mov AH, 14h - Cmp BL, 7 - JE SetCardIRQ1 - - Mov AH, 18h - Cmp BL, 10 - JE SetCardIRQ1 - - StC - Ret - -SetCardIRQ1: - Mov AL, 80h - Out DX, AL - Inc DL - Mov AL, AH - Out DX, AL - Dec DL - Jmp DetectCard6 - -DetectCardIRQ1: - Mov BX, 2 - Test AL, 1 - JNZ DetectCardIRQ2 - - Mov BL, 5 - Test AL, 2 - JNZ DetectCardIRQ2 - - Mov BL, 7 - Test AL, 4 - JNZ DetectCardIRQ2 - - Mov BL, 10 - Test AL, 8 - JNZ DetectCardIRQ2 - - StC - Ret - -DetectCardIRQ2: - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - - Cmp BX, IRQ - JE DetectCard6 - -DetectCardFailure: - StC - Ret - -DetectCardIRQ3: - Mov IRQ, BX - -DetectCard6: ; Detect DMA - Mov AL, 81h ; DMA select - Out DX, AL - Inc DL - In AL, DX ; AL = DMA - Dec DL - - Mov DSPDMAValue, AL - - Mov BX, DMA - Cmp BX, 0FFFFh - JE DetectCardDMA1 - Cmp Forced, 0 - JE DetectCardDMA1 - - Mov CL, 1 - Cmp BX, 1 - JB SetCardDMA1 - - Mov CL, 2 - JE SetCardDMA1 - - Cmp BX, 3 - JB DetectCard7 - - Mov CL, 8 - JE DetectCard7 - - Mov CL, 20h - Cmp BX, 5 - JB DetectCard7 - JE SetCardDMA1 - - Mov CL, 80h - Cmp BX, 7 - JA DetectCard7 - JE SetCardDMA1 - - Mov CL, 40h - -SetCardDMA1: - And AL, 0Bh - Test CL, 0Bh - JZ SetCardDMA4 - - Xor AL, AL - -SetCardDMA4: - Or CL, AL - - Mov AL, 81h - Out DX, AL - Inc DL - Mov AL, CL - Out DX, AL - Jmp DetectCard7 - -DetectCardDMA1: - Mov BX, 5 - Test AL, 20h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 40h - JNZ DetectCardDMA2 - - Inc BL - Test AL, 80h - JNZ DetectCardDMA2 - - Mov BL, 0 - Test AL, 1 - JNZ DetectCardDMA2 - - Inc BL - Test AL, 2 - JNZ DetectCardDMA2 - - Add BL, 2 - Test AL, 8 - JNZ DetectCardDMA2 - -DetectCard8: - Call ResetDSPIRQ - StC - Ret - -DetectCardDMA2: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - - Cmp BX, DMA - JNE DetectCard8 - -DetectCardDMA3: - Mov DMA, BX - -DetectCard7: - Mov EAX, 'Jeff' - - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc -include fourier.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AckIRQ - Assume DS:Driver - - Mov AL, 20h - Cmp CS:IRQ, 7 - JBE AckIRQ1 - - Out 0A0h, AL - -AckIRQ1: - Out 20h, AL - Ret - -EndP AckIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckMIDI - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Xor BX, BX - Mov DX, MIDIPort - - Mov BL, [MIDIBufferTail] - Test DX, DX - JZ CheckMIDIEnd - - Inc DX - Mov CX, 0FFFFh - -CheckMIDIAgain: - In AL, DX - - Test AL, 80h - LoopNZ CheckMIDIAgain - - Dec DX - In AL, DX - - Cmp AL, 0F0h - JAE CheckMIDIEnd - - Inc BL - Cmp BL, MIDIBufferHead - JE CheckMIDIEnd - - Mov [MIDIBuffer+BX], AL - Mov [MIDIBufferTail], BL -; Jmp CheckMIDIAgain - -CheckMIDIEnd: - Pop DS - Ret - -EndP CheckMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SB16IRQHandler - - PushAD - Push DS - Push ES - - CLD - -SBIRQAgain: - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 4 ; Mixer Port - Mov AL, 82h - Out DX, AL - Inc DL ; DX = BasePort+5 - In AL, DX - - Test AL, 4 - JZ SBMIDIInterruptEnd - - Push AX - Call CheckMIDI - Pop AX - -SBMIDIInterruptEnd: - Test AL, 2 - JNZ SBDigitalInterrupt - - Call AckIRQ - Jmp SBIRQEnd - -SBDigitalInterrupt: - FNSave [FPSave] - - Mov DX, BasePort - Add DL, 0Fh - In AL, DX ; 16-bit IRQ ack. - - Call AckIRQ - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX -DMA16BITADJUST EQU $ - ShL BX, 1 - - Cmp BX, DMABUFFERLENGTH/2 - JB SB16IRQHandler2 - - Mov AX, DMABUFFERLENGTH/2 - -SB16IRQHandler2: - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Mov BX, DMASize ; BX = bytes required - Add DI, AX - ShR BX, 1 - ; BX = samples required - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SB16IRQHandler4 - Assume DS:Nothing - -SB16IRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - Call UpdateFourierBuffer - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SB16IRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SB16IRQHandler5 - - Mov DX, MixTransferRemaining - -SB16IRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SB16IRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRstor [CS:FPSave] - -SBIRQEnd: - Pop ES - Pop DS - PopAD - IRet - -EndP SB16IRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SB16IRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSB16 ; - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Cmp DX, 3 - JA StartSB16B - - Mov Word Ptr [DMA16BITADJUST], 9090h -StartSB16B: - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0B6h ; 16 bit, DAC - Call SBOut - Mov AL, Stereo - ShL AL, 5 - Or AL, 10h - Call SBOut - - Mov AX, DMASize - ShR AX, 1 - Dec AX - - Call SBOut ; DMALength, Lo - Mov AL, AH - Call SBOut - - Pop ES - Pop DS - PopA - - Ret - - Assume DS:Nothing - -EndP StartSB16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 30h - Call SBGetRegister - ShR AL, 3 - Mov VolumeTable, AL - - Mov AL, 31h - Call SBGetRegister - ShR AL, 3 - Mov [VolumeTable+1], AL - - Mov AL, 44h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+2], AL - - Mov AL, 45h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+3], AL - - Mov AL, 46h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+4], AL - - Mov AL, 47h - Call SBGetRegister - ShR AL, 4 - Mov [VolumeTable+5], AL - - Call GetSBMixConst - - ; Parags to allocate = (8/(.4*31*16))*MixSpeed - ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 5+(DMABUFFERLENGTH*2)/16+(FOURIERBUFFERLENGTH*2)/16 - Mov BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SB16NoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Sub AX, (FOURIERBUFFERLENGTH*2)/16 - Mov FourierSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov DX, 330h - Call DetectUART - JC DetectMIDI1 - - Mov MIDIPort, 330h - Jmp DetectMIDIEnd - -DetectMIDI1: - Mov DX, 300h - Call DetectUART - JC DetectMIDIEnd - - Mov MIDIPort, 300h - -DetectMIDIEnd: - Call CalculateFilterCoefficients - - Mov SI, Offset SB16Msg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, BasePort - Call ResetDSP - - Call ResetUART - Call ResetIRQ - - ; Delay.. - Mov DX, BasePort - Add DL, 0Ch - - Mov CX, 1000 -ReInitSound1: - In AL, DX - Loop ReInitSound1 - - Call SetIRQ - Call ReinitUART - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Mov DS, Word Ptr [CS:DriverName+2] - Mov DX, Word Ptr [CS:DriverName] - - Mov AX, 3D02h ; Read write access - Int 21h - - Push CS - Pop DS - Assume DS:Driver - - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Mov DX, CS:BasePort - Add DL, 0Ch - - Mov AL, 0D9h - Call SBOut - - Call ResetUART - - Mov AX, BasePort - Call ResetDSP - - Call ResetDSPDMA - Call ResetDSPIRQ - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Push CS - Pop DS - Assume DS:Driver - -Poll1: - Call [UARTBufferEmpty] - JNC PollEnd - - Xor BX, BX - - ClI - - Mov BL, MIDIBufferHead - Cmp BL, MIDIBufferTail - JZ PollEnd ; Nothing in queue - - Inc BL - Mov AL, [MIDIBuffer+BX] - Mov MIDIBufferHead, BL - - Call [UARTSend] - Jmp Poll1 - -PollEnd: - StI - - Ret - -EndP Poll - Assume DS:Nothing - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Mov CS:Stereo, AL - Mov AX, CS:BasePort - Call ResetDSP - - Call StartSB16 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SB16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -TempVariable DW 0 -Const1 DD 3F800000h - -Proc GetFilterFrequency ; Given AL= Freq - Assume DS:Driver - - ShL AX, 8 - Mov TempVariable, AX - FILD TempVariable - - FMul FreqParameterMultiplier ; -i/(24*256) - FLd ST - FRndInt - FSub ST(1), ST - FXCh - F2XM1 - FLd1 - FAdd - FScale ; = 2^(i/24*256) - FMul FreqMultiplier ; = r - - FLd1 ; 1, c - FAdd ST, ST(1) ; 1+c, c - FDivR Const1 ; 1/(1+c), c - FSt DWord Ptr [SI] - FMul - FStP DWord Ptr [SI+4] - FStP ST - - Ret - -EndP GetFilterFrequency - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Const1On16 DD 3D000000h ; actually 1 on 32 - -Proc CalculateFilterCoefficients - Assume DS:Driver - - PushA - - FNInit - FLdCW NewControlWord - - Mov AL, [VolumeTable+6] - Mov SI, Offset FilterCoefficients - ShR AL, 1 - Call GetFilterFrequency - - Mov AL, [VolumeTable+7] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - - Mov AL, [VolumeTable+8] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - - Mov AL, [VolumeTable+9] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - -; Now volumes - Mov SI, Offset VolumeTable+10 - Mov DI, Offset FilterVolumes - Xor AX, AX - Mov CX, 4 - -FilterVolumeLoop1: - LodSB - Mov TempVariable, AX - FILD TempVariable - FMul Const1On16 - FStP DWord Ptr [DI] - - Add DI, 4 - Loop FilterVolumeLoop1 - - PopA - Ret - -EndP CalculateFilterCoefficients - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Cmp DI, 9 - JA SetVariable3 - - Cmp DI, 6 - JB SetVariable1 - - JE SetVariable2 - - Cmp AL, [VolumeTable+DI-1] - JAE SetVariable2 - - Mov AL, [VolumeTable+DI-1] - Mov [VolumeTable+DI], AL - -SetVariable2: - Cmp DI, 9 - JAE SetVariable3 - - Cmp AL, [VolumeTable+DI+1] - JBE SetVariable3 - - Mov AL, [VolumeTable+DI+1] - Mov [VolumeTable+DI], AL - -SetVariable3: - Call CalculateFilterCoefficients - Jmp SetVariableEnd - -SetVariable1: - Mov DX, BasePort - Add DL, 4 - Mov AL, 30h - Mov AH, [VolumeTable] - ShL AH, 3 - Out DX, AX - - Mov AL, 31h - Mov AH, [VolumeTable+1] - ShL AH, 3 - Out DX, AX - - Mov AL, 44h - Mov AH, [VolumeTable+2] - ShL AH, 4 - Out DX, AX - - Mov AL, 45h - Mov AH, [VolumeTable+3] - ShL AH, 4 - Out DX, AX - - Mov AL, 46h - Mov AH, [VolumeTable+4] - ShL AH, 4 - Out DX, AX - - Mov AL, 47h - Mov AH, [VolumeTable+5] - ShL AH, 4 - Out DX, AX - -SetVariableEnd: - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut - - Push CX - Push DX - Mov DX, CS:MIDIPort - Test DX, DX - JZ UARTOutEnd - - Push AX - Xor CX, CX - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - LoopNZ UARTOut1 - - Pop AX - JNZ UARTOutEnd - - Dec DX - Out DX, AL - -UARTOutEnd: - Pop DX - Pop CX - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWaveForm Far ; Given ES:DI = destination - Assume DS:Nothing ; want 2048 samples. - - PushA - Push DS - - Mov DS, FourierSegment - Mov SI, FourierBufferStart - Mov CX, 2048 - -GetWaveForm1: - MovsW - And SI, (FOURIERBUFFERLENGTH*2)-1 - Loop GetWaveForm1 - - Pop DS - PopA - - Ret - -EndP GetWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 - DW 7 ; MIDI, hiqual - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - - DW Offset SendUARTOut - - DW Offset GetWaveform - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +TRACEENABLED = 0 +CREATENEWLOGFILE = 1 + +include debug.inc + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 32 ; 32 bit mixing for the SB16 +OUTPUTFILTERENABLED EQU 1 +FOURIERBUFFERLENGTH EQU 2048 ; 2048 samples + +FPSave DB 128 Dup (0) + +SB16Msg DB "Sound Blaster 16 MMX", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SB16NoMemoryMsg DB "Sound Blaster 16 MMX", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster 16 reinitialised", 0 + +DefaultDriverName DB "ITSB16.MMX", 0 +DriverName DD 0 + +DSPVersion DW 0 +DSPIRQValue DB 0 +DSPDMAValue DB 0 +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +FourierSegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 20 +MixMode DW 0 +MixModeOffset DW 0 +DMASize DW 2048 +VolumeTable DB 6 Dup (0) + DB 0, 16, 96, 127 + DB 0, 0, 0, 0 + +IMR DW 0 +OldIRQHandler DD 0 + +MIDIPort DW 0 +MIDIBuffer DB 256 Dup (0) +MIDIBufferHead DB 0 +MIDIBufferTail DB 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SB16ScreenList Label + DW 8 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + DW Near Ptr VolumeBox2 + + DW Near Ptr DriverText + + DW Near Ptr MasterVolumeLeft ; 8 + DW Near Ptr MasterVolumeRight ; 9 + DW Near Ptr TrebleVolumeLeft ; 10 + DW Near Ptr TrebleVolumeRight ; 11 + DW Near Ptr BassVolumeLeft ; 12 + DW Near Ptr BassVolumeRight ; 13 + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 15 + DW Near Ptr MixModeButton2 ; 16 + DW Near Ptr MixModeButton3 ; 17 + DW Near Ptr MixModeButton4 ; 18 + + DW Near Ptr FrequencyText + + DW Near Ptr FilterText ; 20 + DW Near Ptr FilterBox1 + DW Near Ptr FilterBox2 + + DW Near Ptr FilterFrequency1 ; 23 + DW Near Ptr FilterFrequency2 + DW Near Ptr FilterFrequency3 + DW Near Ptr FilterFrequency4 + + DW Near Ptr FilterVolume1 ; 27 + DW Near Ptr FilterVolume2 + DW Near Ptr FilterVolume3 + DW Near Ptr FilterVolume4 + + DW 0 + + +SB16HeaderLine DW 10 + DB "Sound Blaster 16 Driver", 0 + +DriverText DW 1 + DB 31, 48 + DB 21h + DB "Sound Blaster 16 Driver 1.4 for Impulse Tracker", 0 + +VolumeText DW 1 + DB 2, 13 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB 13 + DB 13 + DB "Treble Left", 13 + DB "Treble Right", 13 + DB "Bass Left", 13 + DB "Bass Right", 13 + DB 0 + +VolumeBox1 DW 0 + DB 21, 12, 27, 15 + DB 25 + +VolumeBox2 DW 0 + DB 14, 16, 18, 21 + DB 25 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MasterVolumeLeft DW 9 + DB 22, 13 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 14 + DW 0, 31 + DW 9, 1 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeLeft DW 9 + DB 15, 17 + DW 0, 15 + DW 9, 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +TrebleVolumeRight DW 9 + DB 15, 18 + DW 0, 15 + DW 9, 3 + DW 10, 12, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeLeft DW 9 + DB 15, 19 + DW 0, 15 + DW 9, 4 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +BassVolumeRight DW 9 + DB 15, 20 + DW 0, 15 + DW 9, 5 + DW 12, 15, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 23 + DB 20h + DB "Mixing Mode", 0 + +FrequencyText DW 1 + DB 2, 48 + DB 20h + DB "Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 45454 + DW 0 + +MixModeButton1 DW 2 + DW 13, 16, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " MMX, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 15, 17, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 28, 32, 30, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 16, 18, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 31, 32, 33, 8 + DB 0 + DB " MMX, Volume Ramped", 0 + +MixModeButton4 DW 2 + DW 17, 23, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 34, 32, 36, 8 + DB 0 + DB " MMX, Filtered", 0 + +FilterText DW 1 + DB 2, 39 + DB 20h + DB "Output Equalizer", 13 + DB 13 + DB " Low Frequency Band", 13 + DB " Med Low Frequency Band", 13 + DB "Med High Frequency Band", 13 + DB " High Frequency Band", 0 + +FilterBox1 DW 0 + DB 25, 40, 47, 45 + DB 25 + +FilterBox2 DW 0 + DB 52, 40, 74, 45 + DB 25 + +FilterFrequency1 DW 14 + DB 26, 41 + DW 0, 127 + DW 9, 6 + DW 18, 24, 27, 27 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency2 DW 14 + DB 26, 42 + DW 0, 127 + DW 9, 7 + DW 23, 25, 28, 28 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency3 DW 14 + DB 26, 43 + DW 0, 127 + DW 9, 8 + DW 24, 26, 29, 29 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency4 DW 14 + DB 26, 44 + DW 0, 127 + DW 9, 9 + DW 25, 0FFFFh, 30, 30 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume1 DW 14 + DB 53, 41 + DW 0, 255 + DW 9, 10 + DW 18, 28, 23, 23 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume2 DW 14 + DB 53, 42 + DW 0, 255 + DW 9, 11 + DW 27, 29, 24, 24 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume3 DW 14 + DB 53, 43 + DW 0, 255 + DW 9, 12 + DW 28, 30, 25, 25 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume4 DW 14 + DB 53, 44 + DW 0, 255 + DW 9, 13 + DW 29, 0FFFFh, 26, 26 + DW 0FFFFh, 0FFFFh + DW 20 + + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include dmasirq.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMMX + + Trace "Detecting MMX - CPUID Check" + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectMMXFail + + Trace "CPUID - Check OK" + + Mov EAX, 1 + DB 0Fh, 0A2h ; CPUID + Test EDX, 800000h + JZ DetectMMXFail + + Trace "MMX Detected" + + ClC + Ret + +DetectMMXFail: + Trace "MMX Not Detected" + + StC + Ret + +EndP DetectMMX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectUART ; Given DX = Port + +; From SB-DevKit + + ClI + + Inc DX + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 40h ; Ready for output + LoopNZ DetectUART1 + JNZ DetectUARTError + + Mov AL, 0FFh ; Reset! + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + JNZ DetectUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART4 + +DetectUART3: + Loop DetectUART2 + +DetectUARTError: + StI + StC + Ret + +DetectUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +DetectUART5: + In AL, DX + Test AL, 40h + LoopNZ DetectUART5 + JNZ DetectUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +DetectUART6: + Xor CX, CX + +DetectUART7: + In AL, DX + Test AL, 80h + JNZ DetectUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE DetectUART9 + +DetectUART8: + Loop DetectUART7 + + Jmp DetectUARTError + +DetectUART9: + StI + ClC + Ret + +EndP DetectUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReinitUART + + Mov DX, MIDIPort + Test DX, DX + JZ ReinitUART1 + + Call DetectUART + +ReinitUART1: + Ret + +EndP ReinitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, MIDIPort + Test DX, DX + JZ ResetUART1 + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 45454 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Mov BX, 12000 + Xor DX, DX + Div BX + Mov FourierBufferStepOffset, AX + Mov FourierBufferStepFractional, DX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPIRQ + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPIRQValue + Mov AL, 80h + Out DX, AX + + Ret + +EndP ResetDSPIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSPDMA + + Mov DX, CS:BasePort + Add DL, 4 + Mov AH, CS:DSPDMAValue + Mov AL, 81h + Out DX, AX + + Ret + +EndP ResetDSPDMA + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Cmp BX, 217h + JAE DetectCardUseDriver + + Mov CX, DS + ShL ECX, 16 + Mov CX, Offset DefaultDriverName + +DetectCardUseDriver: + Mov DriverName, ECX + + Call DetectMMX + JC DetectCardFailure + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AH, 4 ; SB DSP = 4.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + Add DL, 04h-0Eh ; 2x4h = Mixer index port + Mov AL, 80h ; IRQ select + Out DX, AL + Inc DL ; 2x5h = Mixer data port + + In AL, DX + + Dec DL + + Mov DSPIRQValue, AL + ; OK.. now get IRQ, or set IRQ + Mov BX, IRQ + Cmp BX, 0FFFFh + JE DetectCardIRQ1 + Cmp Forced, 0 + JE DetectCardIRQ1 + + Mov AH, 11h + Cmp BL, 2 + JE SetCardIRQ1 + Cmp BL, 9 + JE SetCardIRQ1 + + Mov AH, 12h + Cmp BL, 5 + JE SetCardIRQ1 + + Mov AH, 14h + Cmp BL, 7 + JE SetCardIRQ1 + + Mov AH, 18h + Cmp BL, 10 + JE SetCardIRQ1 + + StC + Ret + +SetCardIRQ1: + Mov AL, 80h + Out DX, AL + Inc DL + Mov AL, AH + Out DX, AL + Dec DL + Jmp DetectCard6 + +DetectCardIRQ1: + Mov BX, 2 + Test AL, 1 + JNZ DetectCardIRQ2 + + Mov BL, 5 + Test AL, 2 + JNZ DetectCardIRQ2 + + Mov BL, 7 + Test AL, 4 + JNZ DetectCardIRQ2 + + Mov BL, 10 + Test AL, 8 + JNZ DetectCardIRQ2 + + StC + Ret + +DetectCardIRQ2: + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + + Cmp BX, IRQ + JE DetectCard6 + +DetectCardFailure: + StC + Ret + +DetectCardIRQ3: + Mov IRQ, BX + +DetectCard6: ; Detect DMA + Mov AL, 81h ; DMA select + Out DX, AL + Inc DL + In AL, DX ; AL = DMA + Dec DL + + Mov DSPDMAValue, AL + + Mov BX, DMA + Cmp BX, 0FFFFh + JE DetectCardDMA1 + Cmp Forced, 0 + JE DetectCardDMA1 + + Mov CL, 1 + Cmp BX, 1 + JB SetCardDMA1 + + Mov CL, 2 + JE SetCardDMA1 + + Cmp BX, 3 + JB DetectCard7 + + Mov CL, 8 + JE DetectCard7 + + Mov CL, 20h + Cmp BX, 5 + JB DetectCard7 + JE SetCardDMA1 + + Mov CL, 80h + Cmp BX, 7 + JA DetectCard7 + JE SetCardDMA1 + + Mov CL, 40h + +SetCardDMA1: + And AL, 0Bh + Test CL, 0Bh + JZ SetCardDMA4 + + Xor AL, AL + +SetCardDMA4: + Or CL, AL + + Mov AL, 81h + Out DX, AL + Inc DL + Mov AL, CL + Out DX, AL + Jmp DetectCard7 + +DetectCardDMA1: + Mov BX, 5 + Test AL, 20h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 40h + JNZ DetectCardDMA2 + + Inc BL + Test AL, 80h + JNZ DetectCardDMA2 + + Mov BL, 0 + Test AL, 1 + JNZ DetectCardDMA2 + + Inc BL + Test AL, 2 + JNZ DetectCardDMA2 + + Add BL, 2 + Test AL, 8 + JNZ DetectCardDMA2 + +DetectCard8: + Call ResetDSPIRQ + StC + Ret + +DetectCardDMA2: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + + Cmp BX, DMA + JNE DetectCard8 + +DetectCardDMA3: + Mov DMA, BX + +DetectCard7: + Mov EAX, 'Jeff' + + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc +include fourier.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AckIRQ + Assume DS:Driver + + Mov AL, 20h + Cmp CS:IRQ, 7 + JBE AckIRQ1 + + Out 0A0h, AL + +AckIRQ1: + Out 20h, AL + Ret + +EndP AckIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckMIDI + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Xor BX, BX + Mov DX, MIDIPort + + Mov BL, [MIDIBufferTail] + Test DX, DX + JZ CheckMIDIEnd + + Inc DX + Mov CX, 0FFFFh + +CheckMIDIAgain: + In AL, DX + + Test AL, 80h + LoopNZ CheckMIDIAgain + + Dec DX + In AL, DX + + Cmp AL, 0F0h + JAE CheckMIDIEnd + + Inc BL + Cmp BL, MIDIBufferHead + JE CheckMIDIEnd + + Mov [MIDIBuffer+BX], AL + Mov [MIDIBufferTail], BL +; Jmp CheckMIDIAgain + +CheckMIDIEnd: + Pop DS + Ret + +EndP CheckMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SB16IRQHandler + + PushAD + Push DS + Push ES + + CLD + +SBIRQAgain: + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 4 ; Mixer Port + Mov AL, 82h + Out DX, AL + Inc DL ; DX = BasePort+5 + In AL, DX + + Test AL, 4 + JZ SBMIDIInterruptEnd + + Push AX + Call CheckMIDI + Pop AX + +SBMIDIInterruptEnd: + Test AL, 2 + JNZ SBDigitalInterrupt + + Call AckIRQ + Jmp SBIRQEnd + +SBDigitalInterrupt: + FNSave [FPSave] + + Mov DX, BasePort + Add DL, 0Fh + In AL, DX ; 16-bit IRQ ack. + + Call AckIRQ + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX +DMA16BITADJUST EQU $ + ShL BX, 1 + + Cmp BX, DMABUFFERLENGTH/2 + JB SB16IRQHandler2 + + Mov AX, DMABUFFERLENGTH/2 + +SB16IRQHandler2: + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Mov BX, DMASize ; BX = bytes required + Add DI, AX + ShR BX, 1 + ; BX = samples required + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SB16IRQHandler4 + Assume DS:Nothing + +SB16IRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + Call UpdateFourierBuffer + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SB16IRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SB16IRQHandler5 + + Mov DX, MixTransferRemaining + +SB16IRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SB16IRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRstor [CS:FPSave] + +SBIRQEnd: + Pop ES + Pop DS + PopAD + IRet + +EndP SB16IRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SB16IRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSB16 ; + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Cmp DX, 3 + JA StartSB16B + + Mov Word Ptr [DMA16BITADJUST], 9090h +StartSB16B: + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0B6h ; 16 bit, DAC + Call SBOut + Mov AL, Stereo + ShL AL, 5 + Or AL, 10h + Call SBOut + + Mov AX, DMASize + ShR AX, 1 + Dec AX + + Call SBOut ; DMALength, Lo + Mov AL, AH + Call SBOut + + Pop ES + Pop DS + PopA + + Ret + + Assume DS:Nothing + +EndP StartSB16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 30h + Call SBGetRegister + ShR AL, 3 + Mov VolumeTable, AL + + Mov AL, 31h + Call SBGetRegister + ShR AL, 3 + Mov [VolumeTable+1], AL + + Mov AL, 44h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+2], AL + + Mov AL, 45h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+3], AL + + Mov AL, 46h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+4], AL + + Mov AL, 47h + Call SBGetRegister + ShR AL, 4 + Mov [VolumeTable+5], AL + + Call GetSBMixConst + + ; Parags to allocate = (8/(.4*31*16))*MixSpeed + ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 5+(DMABUFFERLENGTH*2)/16+(FOURIERBUFFERLENGTH*2)/16 + Mov BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SB16NoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Sub AX, (FOURIERBUFFERLENGTH*2)/16 + Mov FourierSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov DX, 330h + Call DetectUART + JC DetectMIDI1 + + Mov MIDIPort, 330h + Jmp DetectMIDIEnd + +DetectMIDI1: + Mov DX, 300h + Call DetectUART + JC DetectMIDIEnd + + Mov MIDIPort, 300h + +DetectMIDIEnd: + Call CalculateFilterCoefficients + + Mov SI, Offset SB16Msg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, BasePort + Call ResetDSP + + Call ResetUART + Call ResetIRQ + + ; Delay.. + Mov DX, BasePort + Add DL, 0Ch + + Mov CX, 1000 +ReInitSound1: + In AL, DX + Loop ReInitSound1 + + Call SetIRQ + Call ReinitUART + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Mov DS, Word Ptr [CS:DriverName+2] + Mov DX, Word Ptr [CS:DriverName] + + Mov AX, 3D02h ; Read write access + Int 21h + + Push CS + Pop DS + Assume DS:Driver + + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Mov DX, CS:BasePort + Add DL, 0Ch + + Mov AL, 0D9h + Call SBOut + + Call ResetUART + + Mov AX, BasePort + Call ResetDSP + + Call ResetDSPDMA + Call ResetDSPIRQ + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Push CS + Pop DS + Assume DS:Driver + +Poll1: + Call [UARTBufferEmpty] + JNC PollEnd + + Xor BX, BX + + ClI + + Mov BL, MIDIBufferHead + Cmp BL, MIDIBufferTail + JZ PollEnd ; Nothing in queue + + Inc BL + Mov AL, [MIDIBuffer+BX] + Mov MIDIBufferHead, BL + + Call [UARTSend] + Jmp Poll1 + +PollEnd: + StI + + Ret + +EndP Poll + Assume DS:Nothing + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Mov CS:Stereo, AL + Mov AX, CS:BasePort + Call ResetDSP + + Call StartSB16 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SB16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +TempVariable DW 0 +Const1 DD 3F800000h + +Proc GetFilterFrequency ; Given AL= Freq + Assume DS:Driver + + ShL AX, 8 + Mov TempVariable, AX + FILD TempVariable + + FMul FreqParameterMultiplier ; -i/(24*256) + FLd ST + FRndInt + FSub ST(1), ST + FXCh + F2XM1 + FLd1 + FAdd + FScale ; = 2^(i/24*256) + FMul FreqMultiplier ; = r + + FLd1 ; 1, c + FAdd ST, ST(1) ; 1+c, c + FDivR Const1 ; 1/(1+c), c + FSt DWord Ptr [SI] + FMul + FStP DWord Ptr [SI+4] + FStP ST + + Ret + +EndP GetFilterFrequency + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Const1On16 DD 3D000000h ; actually 1 on 32 + +Proc CalculateFilterCoefficients + Assume DS:Driver + + PushA + + FNInit + FLdCW NewControlWord + + Mov AL, [VolumeTable+6] + Mov SI, Offset FilterCoefficients + ShR AL, 1 + Call GetFilterFrequency + + Mov AL, [VolumeTable+7] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + + Mov AL, [VolumeTable+8] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + + Mov AL, [VolumeTable+9] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + +; Now volumes + Mov SI, Offset VolumeTable+10 + Mov DI, Offset FilterVolumes + Xor AX, AX + Mov CX, 4 + +FilterVolumeLoop1: + LodSB + Mov TempVariable, AX + FILD TempVariable + FMul Const1On16 + FStP DWord Ptr [DI] + + Add DI, 4 + Loop FilterVolumeLoop1 + + PopA + Ret + +EndP CalculateFilterCoefficients + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Cmp DI, 9 + JA SetVariable3 + + Cmp DI, 6 + JB SetVariable1 + + JE SetVariable2 + + Cmp AL, [VolumeTable+DI-1] + JAE SetVariable2 + + Mov AL, [VolumeTable+DI-1] + Mov [VolumeTable+DI], AL + +SetVariable2: + Cmp DI, 9 + JAE SetVariable3 + + Cmp AL, [VolumeTable+DI+1] + JBE SetVariable3 + + Mov AL, [VolumeTable+DI+1] + Mov [VolumeTable+DI], AL + +SetVariable3: + Call CalculateFilterCoefficients + Jmp SetVariableEnd + +SetVariable1: + Mov DX, BasePort + Add DL, 4 + Mov AL, 30h + Mov AH, [VolumeTable] + ShL AH, 3 + Out DX, AX + + Mov AL, 31h + Mov AH, [VolumeTable+1] + ShL AH, 3 + Out DX, AX + + Mov AL, 44h + Mov AH, [VolumeTable+2] + ShL AH, 4 + Out DX, AX + + Mov AL, 45h + Mov AH, [VolumeTable+3] + ShL AH, 4 + Out DX, AX + + Mov AL, 46h + Mov AH, [VolumeTable+4] + ShL AH, 4 + Out DX, AX + + Mov AL, 47h + Mov AH, [VolumeTable+5] + ShL AH, 4 + Out DX, AX + +SetVariableEnd: + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut + + Push CX + Push DX + Mov DX, CS:MIDIPort + Test DX, DX + JZ UARTOutEnd + + Push AX + Xor CX, CX + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + LoopNZ UARTOut1 + + Pop AX + JNZ UARTOutEnd + + Dec DX + Out DX, AL + +UARTOutEnd: + Pop DX + Pop CX + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWaveForm Far ; Given ES:DI = destination + Assume DS:Nothing ; want 2048 samples. + + PushA + Push DS + + Mov DS, FourierSegment + Mov SI, FourierBufferStart + Mov CX, 2048 + +GetWaveForm1: + MovsW + And SI, (FOURIERBUFFERLENGTH*2)-1 + Loop GetWaveForm1 + + Pop DS + PopA + + Ret + +EndP GetWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 + DW 7 ; MIDI, hiqual + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + + DW Offset SendUARTOut + + DW Offset GetWaveform + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SB2DRV.ASM b/SoundDrivers/SB2DRV.ASM index fdf6f06..30a1351 100755 --- a/SoundDrivers/SB2DRV.ASM +++ b/SoundDrivers/SB2DRV.ASM @@ -1,1421 +1,1421 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 0 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro -MIXTABLESIZE EQU 2*256*65 - -SBProMsg DB "Sound Blaster 2 detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SBProNoMemoryMsg DB "Sound Blaster 2 detected", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITSB2.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITSB2.DRV", 0 - -BLASTERString DB "BLASTER" -DriverName DB "ITSB2.DRV", 0 - -BlasterEnvironment Label DWord -BlasterOffset DW 0 -BlasterSegment DW 0 - -DSPVersion DW 0 -Forced DB 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 4 -MixModeOffset DW 0 -DMASize DW 1024 - -MixLength DW 0 - -IMR DW 0 -OldIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SBProScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - DW Near Ptr DriverText - - DW Near Ptr MixModeHeader - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; 7 - - DW 0 - -MixModeHeader DW 1 - DB 3, 14 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 43478 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 5, 16, 34, 18, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 120 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 5, 19, 34, 21, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -SB16HeaderLine DW 10 - DB "Sound Blaster 2 Driver", 0 - -DriverText DW 1 - DB 32, 48 - DB 21h - DB "Sound Blaster 2 Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include mono12b.mix -include mono12bi.mix - -MixFunctionTables Label - -include mono12b.inc ; contains the tables -include mono12bi.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixModeOffset - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixModeOffset, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixModeOffset - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 43478 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp AH, 2 ; SB DSP = 2.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - ; Need to detect IRQ/DMA... - - Mov SI, Offset BLASTERString - Mov CX, 7 - Call GetEnvironment ; Returns ES:DI, Carry if error - JC DetectCardError - - Mov BlasterOffset, DI - Mov BlasterSegment, ES - - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - Cmp Forced, 0 - JNE DetectCardIRQDone - Jmp DetectCardError - -DetectCardIRQ3: - Push DS - Push SI - - LDS SI, BlasterEnvironment - - Xor DX, DX ; DX = env.. - -DetectCardIRQ1: - LodsB - And AL, AL - JZ DetectCardError - Cmp AL, 'i' - JE DetectCardIRQ2 - Cmp AL, 'I' - JE DetectCardIRQ2 - Jmp DetectCardIRQ1 - -DetectCardIRQ2: - LodsB - And AL, AL - JZ DetectCardIRQEnd - Cmp AL, ' ' - JE DetectCardIRQEnd - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCardIRQ2 - -DetectCardIRQEnd: - Pop SI - Pop DS - - Mov IRQ, DX - -DetectCardIRQDone: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - Cmp Forced, 0 - JNE DetectCardDMADone - Jmp DetectCardError - -DetectCardDMA3: - Push DS - Push SI - - LDS SI, BlasterEnvironment - - Xor DX, DX ; DX = env.. - -DetectCardDMA1: - LodsB - And AL, AL - JZ DetectCardError - Cmp AL, 'd' - JE DetectCardDMA2 - Cmp AL, 'D' - JE DetectCardDMA2 - Jmp DetectCardDMA1 - -DetectCardDMA2: - LodsB - And AL, AL - JZ DetectCardDMAEnd - Cmp AL, ' ' - JE DetectCardDMAEnd - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCardDMA2 - -DetectCardDMAEnd: - Pop SI - Pop DS - - Mov DMA, DX - -DetectCardDMADone: - Mov EAX, 'Jeff' - - ClC - Ret - -DetectCardError: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov AX, 2020h - - Mov BX, CX ; BX = bytes to mix - Mov DX, CX - -; Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - Rep StosW ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - Jmp MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - -Mix0Mode: ; 16-bit mixing, no interpolation, no ramping -Mix0ModeMono: - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AX, 30 ; Use left only-mixing for mono - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 60 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, MixTransferRemaining - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBProIRQHandler - - PushAD - Push DS - Push ES - - CLD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 0Eh - In AL, DX ; 8-bit IRQ ack. - - Mov AL, 20h - Cmp IRQ, 7 - JBE SBProIRQHandler1 - - Out 0A0h, AL - -SBProIRQHandler1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SBProIRQHandler2 - - Xor AX, AX - Xor BX, BX - -SBProIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SBProIRQHandler4 - Assume DS:Nothing - -SBProIRQHandler3: - Push BX - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BX - -SBProIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SBProIRQHandler5 - - Mov DX, MixTransferRemaining - -SBProIRQHandler5: - Push DX - -SBProIRQHandler6: - Mov AX, [SI] - SAR AX, 6 - - Test AH, AH - JNZ SBProIRQHandlerClip1 - -SBProIRQHandler7: - StosB ; } Memory write - - Add SI, 2 - Dec DX - JNZ SBProIRQHandler6 - - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SBProIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -SBProIRQHandlerClip1: - Mov AL, 00h - JS SBProIRQHandler7 - Mov AL, 0FFh - Jmp SBProIRQHandler7 - -EndP SBProIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SBProIRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSBPro ; - - PushA - Push ES - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 48h ; Set DMA Size.. - Call SBOut - Mov AX, DMASize - Dec AX - Call SBOut - Mov AL, AH - Call SBOut - - Mov AL, 1Ch - Cmp MixSpeed, 21739 - JBE StartSBPro1 - - Mov AL, 90h - -StartSBPro1: - Call SBOut - - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartSBPro - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, DS - Mov DriverSegment1, AX - Mov DriverSegment2, AX - Mov DriverSegment3, AX - Mov DriverSegment4, AX - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetSBMixConst - - ; Parags to allocate = (2/(.4*31*16))*MixSpeed + 2080 - ; = 661*MixSpeed/65536 - - Mov AX, 661 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SBProNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - Call StartSBPro - - Mov SI, Offset SBProMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AX, CS:BasePort - Call ResetDSP - Call StartSBPro - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov AX, BasePort - Call ResetDSP - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SBProScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 0 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro +MIXTABLESIZE EQU 2*256*65 + +SBProMsg DB "Sound Blaster 2 detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SBProNoMemoryMsg DB "Sound Blaster 2 detected", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITSB2.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITSB2.DRV", 0 + +BLASTERString DB "BLASTER" +DriverName DB "ITSB2.DRV", 0 + +BlasterEnvironment Label DWord +BlasterOffset DW 0 +BlasterSegment DW 0 + +DSPVersion DW 0 +Forced DB 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 4 +MixModeOffset DW 0 +DMASize DW 1024 + +MixLength DW 0 + +IMR DW 0 +OldIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SBProScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + DW Near Ptr DriverText + + DW Near Ptr MixModeHeader + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; 7 + + DW 0 + +MixModeHeader DW 1 + DB 3, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 43478 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 5, 16, 34, 18, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 120 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 5, 19, 34, 21, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +SB16HeaderLine DW 10 + DB "Sound Blaster 2 Driver", 0 + +DriverText DW 1 + DB 32, 48 + DB 21h + DB "Sound Blaster 2 Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include mono12b.mix +include mono12bi.mix + +MixFunctionTables Label + +include mono12b.inc ; contains the tables +include mono12bi.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixModeOffset + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixModeOffset, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixModeOffset + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 43478 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp AH, 2 ; SB DSP = 2.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + ; Need to detect IRQ/DMA... + + Mov SI, Offset BLASTERString + Mov CX, 7 + Call GetEnvironment ; Returns ES:DI, Carry if error + JC DetectCardError + + Mov BlasterOffset, DI + Mov BlasterSegment, ES + + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + Cmp Forced, 0 + JNE DetectCardIRQDone + Jmp DetectCardError + +DetectCardIRQ3: + Push DS + Push SI + + LDS SI, BlasterEnvironment + + Xor DX, DX ; DX = env.. + +DetectCardIRQ1: + LodsB + And AL, AL + JZ DetectCardError + Cmp AL, 'i' + JE DetectCardIRQ2 + Cmp AL, 'I' + JE DetectCardIRQ2 + Jmp DetectCardIRQ1 + +DetectCardIRQ2: + LodsB + And AL, AL + JZ DetectCardIRQEnd + Cmp AL, ' ' + JE DetectCardIRQEnd + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCardIRQ2 + +DetectCardIRQEnd: + Pop SI + Pop DS + + Mov IRQ, DX + +DetectCardIRQDone: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + Cmp Forced, 0 + JNE DetectCardDMADone + Jmp DetectCardError + +DetectCardDMA3: + Push DS + Push SI + + LDS SI, BlasterEnvironment + + Xor DX, DX ; DX = env.. + +DetectCardDMA1: + LodsB + And AL, AL + JZ DetectCardError + Cmp AL, 'd' + JE DetectCardDMA2 + Cmp AL, 'D' + JE DetectCardDMA2 + Jmp DetectCardDMA1 + +DetectCardDMA2: + LodsB + And AL, AL + JZ DetectCardDMAEnd + Cmp AL, ' ' + JE DetectCardDMAEnd + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCardDMA2 + +DetectCardDMAEnd: + Pop SI + Pop DS + + Mov DMA, DX + +DetectCardDMADone: + Mov EAX, 'Jeff' + + ClC + Ret + +DetectCardError: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov AX, 2020h + + Mov BX, CX ; BX = bytes to mix + Mov DX, CX + +; Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + Rep StosW ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + Jmp MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + +Mix0Mode: ; 16-bit mixing, no interpolation, no ramping +Mix0ModeMono: + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AX, 30 ; Use left only-mixing for mono + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 60 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, MixTransferRemaining + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBProIRQHandler + + PushAD + Push DS + Push ES + + CLD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 0Eh + In AL, DX ; 8-bit IRQ ack. + + Mov AL, 20h + Cmp IRQ, 7 + JBE SBProIRQHandler1 + + Out 0A0h, AL + +SBProIRQHandler1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SBProIRQHandler2 + + Xor AX, AX + Xor BX, BX + +SBProIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SBProIRQHandler4 + Assume DS:Nothing + +SBProIRQHandler3: + Push BX + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BX + +SBProIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SBProIRQHandler5 + + Mov DX, MixTransferRemaining + +SBProIRQHandler5: + Push DX + +SBProIRQHandler6: + Mov AX, [SI] + SAR AX, 6 + + Test AH, AH + JNZ SBProIRQHandlerClip1 + +SBProIRQHandler7: + StosB ; } Memory write + + Add SI, 2 + Dec DX + JNZ SBProIRQHandler6 + + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SBProIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +SBProIRQHandlerClip1: + Mov AL, 00h + JS SBProIRQHandler7 + Mov AL, 0FFh + Jmp SBProIRQHandler7 + +EndP SBProIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SBProIRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSBPro ; + + PushA + Push ES + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 48h ; Set DMA Size.. + Call SBOut + Mov AX, DMASize + Dec AX + Call SBOut + Mov AL, AH + Call SBOut + + Mov AL, 1Ch + Cmp MixSpeed, 21739 + JBE StartSBPro1 + + Mov AL, 90h + +StartSBPro1: + Call SBOut + + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartSBPro + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, DS + Mov DriverSegment1, AX + Mov DriverSegment2, AX + Mov DriverSegment3, AX + Mov DriverSegment4, AX + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetSBMixConst + + ; Parags to allocate = (2/(.4*31*16))*MixSpeed + 2080 + ; = 661*MixSpeed/65536 + + Mov AX, 661 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SBProNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + Call StartSBPro + + Mov SI, Offset SBProMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AX, CS:BasePort + Call ResetDSP + Call StartSBPro + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov AX, BasePort + Call ResetDSP + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SBProScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SBDRV.ASM b/SoundDrivers/SBDRV.ASM index 3bf7123..60175f0 100755 --- a/SoundDrivers/SBDRV.ASM +++ b/SoundDrivers/SBDRV.ASM @@ -1,1416 +1,1416 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 0 -DMABUFFERLENGTH EQU 1024 -MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro -MIXTABLESIZE EQU 2*256*65 - -SBProMsg DB "Sound Blaster detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SBProNoMemoryMsg DB "Sound Blaster detected", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITSB.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITSB.DRV", 0 - -BLASTERString DB "BLASTER" -DriverName DB "ITSB.DRV", 0 - -BlasterEnvironment Label DWord -BlasterOffset DW 0 -BlasterSegment DW 0 - -Forced DB 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 4 -MixModeOffset DW 0 -DMASize DW 512 - -MixLength DW 0 - -IMR DW 0 -OldIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SBProScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SB16HeaderLine - DW Near Ptr DriverText - - DW Near Ptr MixModeHeader - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; 7 - - DW 0 - -MixModeHeader DW 1 - DB 3, 14 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 21739 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 5, 16, 34, 18, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 120 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 5, 19, 34, 21, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -SB16HeaderLine DW 10 - DB "Sound Blaster Driver", 0 - -DriverText DW 1 - DB 34, 48 - DB 21h - DB "Sound Blaster Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include mono12b.mix -include mono12bi.mix - -MixFunctionTables Label - -include mono12b.inc ; contains the tables -include mono12bi.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixModeOffset - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixModeOffset, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixModeOffset - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 21739 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 290h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard2 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov SI, Offset BLASTERString - Mov CX, 7 - Call GetEnvironment ; Returns ES:DI, Carry if error - JC DetectCardDefault - - Mov BlasterOffset, DI - Mov BlasterSegment, ES - - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - Cmp Forced, 0 - JNE DetectCardIRQDone - Jmp DetectCardError - -DetectCardIRQ3: - Push DS - Push SI - - LDS SI, BlasterEnvironment - - Xor DX, DX ; DX = env.. - -DetectCardIRQ1: - LodsB - And AL, AL - JZ DetectCardError - Cmp AL, 'i' - JE DetectCardIRQ2 - Cmp AL, 'I' - JE DetectCardIRQ2 - Jmp DetectCardIRQ1 - -DetectCardIRQ2: - LodsB - And AL, AL - JZ DetectCardIRQEnd - Cmp AL, ' ' - JE DetectCardIRQEnd - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCardIRQ2 - -DetectCardIRQEnd: - Pop SI - Pop DS - - Mov IRQ, DX - -DetectCardIRQDone: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - Cmp Forced, 0 - JNE DetectCardDMADone - Jmp DetectCardError - -DetectCardDMA3: - Push DS - Push SI - - LDS SI, BlasterEnvironment - - Xor DX, DX ; DX = env.. - -DetectCardDMA1: - LodsB - And AL, AL - JZ DetectCardError - Cmp AL, 'd' - JE DetectCardDMA2 - Cmp AL, 'D' - JE DetectCardDMA2 - Jmp DetectCardDMA1 - -DetectCardDMA2: - LodsB - And AL, AL - JZ DetectCardDMAEnd - Cmp AL, ' ' - JE DetectCardDMAEnd - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCardDMA2 - -DetectCardDMAEnd: - Pop SI - Pop DS - - Mov DMA, DX - -DetectCardDMADone: - Mov EAX, 'Jeff' - - ClC - Ret - -DetectCardDefault: - Cmp IRQ, 0FFFFh - JNE DetectCardDefaultDMA - Mov IRQ, 7 - -DetectCardDefaultDMA: - Cmp DMA, 0FFFFh - JNE DetectCardDefaultEnd - Mov DMA, 1 - -DetectCardDefaultEnd: - Mov EAX, 'Jeff' - - ClC - Ret - -DetectCardError: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov AX, 2020h - - Mov BX, CX ; BX = bytes to mix - Mov DX, CX - -; Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - Rep StosW ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - Jmp MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - -Mix0Mode: ; 16-bit mixing, no interpolation, no ramping -Mix0ModeMono: - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AX, 30 ; Use left only-mixing for mono - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 60 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, MixTransferRemaining - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBProIRQHandler - - PushAD - Push DS - Push ES - - CLD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 0Eh - In AL, DX ; 8-bit IRQ ack. - - Add DL, 0Ch-0Eh - - Mov AL, 14h ; Start output - Call SBOut - Mov AX, DMASize - Dec AX - Call SBOut - Mov AL, AH - Call SBOut - - Mov AL, 20h - Cmp IRQ, 7 - JBE SBProIRQHandler1 - - Out 0A0h, AL - -SBProIRQHandler1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SBProIRQHandler2 - - Xor AX, AX - Xor BX, BX - -SBProIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SBProIRQHandler4 - Assume DS:Nothing - -SBProIRQHandler3: - Push BX - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BX - -SBProIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SBProIRQHandler5 - - Mov DX, MixTransferRemaining - -SBProIRQHandler5: - Push DX - -SBProIRQHandler6: - Mov AX, [SI] - SAR AX, 6 - - Test AH, AH - JNZ SBProIRQHandlerClip1 - -SBProIRQHandler7: - StosB ; } Memory write - - Add SI, 2 - Dec DX - JNZ SBProIRQHandler6 - - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SBProIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -SBProIRQHandlerClip1: - Mov AL, 00h - JS SBProIRQHandler7 - Mov AL, 0FFh - Jmp SBProIRQHandler7 - -EndP SBProIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SBProIRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSBPro ; - - PushA - Push ES - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 14h ; Start output - Call SBOut - Mov AX, DMASize - Dec AX - Call SBOut - Mov AL, AH - Call SBOut - - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartSBPro - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, DS - Mov DriverSegment1, AX - Mov DriverSegment2, AX - Mov DriverSegment3, AX - Mov DriverSegment4, AX - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetSBMixConst - - ; Parags to allocate = (2/(.4*31*16))*MixSpeed + 2080 - ; = 661*MixSpeed/65536 - - Mov AX, 661 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SBProNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - Call StartSBPro - - Mov SI, Offset SBProMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AX, CS:BasePort - Call ResetDSP - Call StartSBPro - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov AX, BasePort - Call ResetDSP - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SBProScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 0 +DMABUFFERLENGTH EQU 1024 +MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro +MIXTABLESIZE EQU 2*256*65 + +SBProMsg DB "Sound Blaster detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SBProNoMemoryMsg DB "Sound Blaster detected", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITSB.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITSB.DRV", 0 + +BLASTERString DB "BLASTER" +DriverName DB "ITSB.DRV", 0 + +BlasterEnvironment Label DWord +BlasterOffset DW 0 +BlasterSegment DW 0 + +Forced DB 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 4 +MixModeOffset DW 0 +DMASize DW 512 + +MixLength DW 0 + +IMR DW 0 +OldIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SBProScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SB16HeaderLine + DW Near Ptr DriverText + + DW Near Ptr MixModeHeader + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; 7 + + DW 0 + +MixModeHeader DW 1 + DB 3, 14 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 21739 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 5, 16, 34, 18, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 120 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 5, 19, 34, 21, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +SB16HeaderLine DW 10 + DB "Sound Blaster Driver", 0 + +DriverText DW 1 + DB 34, 48 + DB 21h + DB "Sound Blaster Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include mono12b.mix +include mono12bi.mix + +MixFunctionTables Label + +include mono12b.inc ; contains the tables +include mono12bi.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixModeOffset + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixModeOffset, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixModeOffset + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 21739 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 290h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard2 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov SI, Offset BLASTERString + Mov CX, 7 + Call GetEnvironment ; Returns ES:DI, Carry if error + JC DetectCardDefault + + Mov BlasterOffset, DI + Mov BlasterSegment, ES + + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + Cmp Forced, 0 + JNE DetectCardIRQDone + Jmp DetectCardError + +DetectCardIRQ3: + Push DS + Push SI + + LDS SI, BlasterEnvironment + + Xor DX, DX ; DX = env.. + +DetectCardIRQ1: + LodsB + And AL, AL + JZ DetectCardError + Cmp AL, 'i' + JE DetectCardIRQ2 + Cmp AL, 'I' + JE DetectCardIRQ2 + Jmp DetectCardIRQ1 + +DetectCardIRQ2: + LodsB + And AL, AL + JZ DetectCardIRQEnd + Cmp AL, ' ' + JE DetectCardIRQEnd + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCardIRQ2 + +DetectCardIRQEnd: + Pop SI + Pop DS + + Mov IRQ, DX + +DetectCardIRQDone: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + Cmp Forced, 0 + JNE DetectCardDMADone + Jmp DetectCardError + +DetectCardDMA3: + Push DS + Push SI + + LDS SI, BlasterEnvironment + + Xor DX, DX ; DX = env.. + +DetectCardDMA1: + LodsB + And AL, AL + JZ DetectCardError + Cmp AL, 'd' + JE DetectCardDMA2 + Cmp AL, 'D' + JE DetectCardDMA2 + Jmp DetectCardDMA1 + +DetectCardDMA2: + LodsB + And AL, AL + JZ DetectCardDMAEnd + Cmp AL, ' ' + JE DetectCardDMAEnd + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCardDMA2 + +DetectCardDMAEnd: + Pop SI + Pop DS + + Mov DMA, DX + +DetectCardDMADone: + Mov EAX, 'Jeff' + + ClC + Ret + +DetectCardDefault: + Cmp IRQ, 0FFFFh + JNE DetectCardDefaultDMA + Mov IRQ, 7 + +DetectCardDefaultDMA: + Cmp DMA, 0FFFFh + JNE DetectCardDefaultEnd + Mov DMA, 1 + +DetectCardDefaultEnd: + Mov EAX, 'Jeff' + + ClC + Ret + +DetectCardError: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov AX, 2020h + + Mov BX, CX ; BX = bytes to mix + Mov DX, CX + +; Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + Rep StosW ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + Jmp MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + +Mix0Mode: ; 16-bit mixing, no interpolation, no ramping +Mix0ModeMono: + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AX, 30 ; Use left only-mixing for mono + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 60 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, MixTransferRemaining + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBProIRQHandler + + PushAD + Push DS + Push ES + + CLD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 0Eh + In AL, DX ; 8-bit IRQ ack. + + Add DL, 0Ch-0Eh + + Mov AL, 14h ; Start output + Call SBOut + Mov AX, DMASize + Dec AX + Call SBOut + Mov AL, AH + Call SBOut + + Mov AL, 20h + Cmp IRQ, 7 + JBE SBProIRQHandler1 + + Out 0A0h, AL + +SBProIRQHandler1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SBProIRQHandler2 + + Xor AX, AX + Xor BX, BX + +SBProIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SBProIRQHandler4 + Assume DS:Nothing + +SBProIRQHandler3: + Push BX + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BX + +SBProIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SBProIRQHandler5 + + Mov DX, MixTransferRemaining + +SBProIRQHandler5: + Push DX + +SBProIRQHandler6: + Mov AX, [SI] + SAR AX, 6 + + Test AH, AH + JNZ SBProIRQHandlerClip1 + +SBProIRQHandler7: + StosB ; } Memory write + + Add SI, 2 + Dec DX + JNZ SBProIRQHandler6 + + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SBProIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +SBProIRQHandlerClip1: + Mov AL, 00h + JS SBProIRQHandler7 + Mov AL, 0FFh + Jmp SBProIRQHandler7 + +EndP SBProIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SBProIRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSBPro ; + + PushA + Push ES + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 14h ; Start output + Call SBOut + Mov AX, DMASize + Dec AX + Call SBOut + Mov AL, AH + Call SBOut + + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartSBPro + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, DS + Mov DriverSegment1, AX + Mov DriverSegment2, AX + Mov DriverSegment3, AX + Mov DriverSegment4, AX + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetSBMixConst + + ; Parags to allocate = (2/(.4*31*16))*MixSpeed + 2080 + ; = 661*MixSpeed/65536 + + Mov AX, 661 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SBProNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + Call StartSBPro + + Mov SI, Offset SBProMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AX, CS:BasePort + Call ResetDSP + Call StartSBPro + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov AX, BasePort + Call ResetDSP + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SBProScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SBMIDI.INC b/SoundDrivers/SBMIDI.INC index 0b1f523..69852cf 100755 --- a/SoundDrivers/SBMIDI.INC +++ b/SoundDrivers/SBMIDI.INC @@ -1,133 +1,133 @@ - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -MIDIPort DW 300h - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc Poll Far - - Mov DX, [CS:MIDIPort] - Test DX, DX - JZ PollEnd - - Call [CS:UARTBufferEmpty] - JNC PollEnd - - Inc DX - In AL, DX - Test AL, 80h - JNZ PollEnd - - Dec DX - In AL, DX - Cmp AL, 0F8h - JAE PollEnd - - Call [CS:UARTSend] - -PollEnd: - Ret - -EndP Poll - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_UnInit - - Ret - - Mov DX, MIDIPort - Test DX, DX - JZ UnInitUARTEnd - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -UnInitUARTEnd: - Ret - -EndP MIDI_UnInit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitUART - ; returns carry set if no UART - - Mov BX, 32 ; Number of attempts to read correct - ; value back from the UART - - Inc DX - Mov AL, 0FFh - Out DX, AL ; Reset UART - - Mov AL, 03Fh - Out DX, AL ; UART Mode - - Mov CX, 0FFFFh - -InitUART1: - In AL, DX - Test AL, 80h - LoopNZ InitUART1 - -InitUART2: - StC - JNZ InitUART3 - - Dec DX - In AL, DX - Cmp AL, 0FEh - JE InitUART3 - - Inc DX - Dec BX - JNZ InitUART1 - - StC - -InitUART3: - Ret - -EndP InitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_Init - - Mov DX, 301h - Mov AL, 0FFh - Out DX, AL - - Mov AL, 3Fh - Out DX, AL - Ret - - Mov DX, 330h - Call InitUART - - JC MIDI_Init1 - - Mov [CS:MIDIPort], 330h - Jmp MIDI_InitEnd - -MIDI_Init1: - Mov DX, 300h - Call InitUART - JC MIDI_InitEnd - - Mov [CS:MIDIPort], 300h - -MIDI_InitEnd: - Ret - -EndP MIDI_Init - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +MIDIPort DW 300h + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc Poll Far + + Mov DX, [CS:MIDIPort] + Test DX, DX + JZ PollEnd + + Call [CS:UARTBufferEmpty] + JNC PollEnd + + Inc DX + In AL, DX + Test AL, 80h + JNZ PollEnd + + Dec DX + In AL, DX + Cmp AL, 0F8h + JAE PollEnd + + Call [CS:UARTSend] + +PollEnd: + Ret + +EndP Poll + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_UnInit + + Ret + + Mov DX, MIDIPort + Test DX, DX + JZ UnInitUARTEnd + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +UnInitUARTEnd: + Ret + +EndP MIDI_UnInit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitUART + ; returns carry set if no UART + + Mov BX, 32 ; Number of attempts to read correct + ; value back from the UART + + Inc DX + Mov AL, 0FFh + Out DX, AL ; Reset UART + + Mov AL, 03Fh + Out DX, AL ; UART Mode + + Mov CX, 0FFFFh + +InitUART1: + In AL, DX + Test AL, 80h + LoopNZ InitUART1 + +InitUART2: + StC + JNZ InitUART3 + + Dec DX + In AL, DX + Cmp AL, 0FEh + JE InitUART3 + + Inc DX + Dec BX + JNZ InitUART1 + + StC + +InitUART3: + Ret + +EndP InitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_Init + + Mov DX, 301h + Mov AL, 0FFh + Out DX, AL + + Mov AL, 3Fh + Out DX, AL + Ret + + Mov DX, 330h + Call InitUART + + JC MIDI_Init1 + + Mov [CS:MIDIPort], 330h + Jmp MIDI_InitEnd + +MIDI_Init1: + Mov DX, 300h + Call InitUART + JC MIDI_InitEnd + + Mov [CS:MIDIPort], 300h + +MIDI_InitEnd: + Ret + +EndP MIDI_Init + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ diff --git a/SoundDrivers/SBPRODRV.ASM b/SoundDrivers/SBPRODRV.ASM index b4119b8..c686d19 100755 --- a/SoundDrivers/SBPRODRV.ASM +++ b/SoundDrivers/SBPRODRV.ASM @@ -1,2009 +1,2009 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 4096 -MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro -MIXTABLESIZE EQU 2*256*65 - -SBProMsg DB "Sound Blaster Pro detected", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -SBProNoMemoryMsg DB "Sound Blaster Pro detected", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Blaster Pro reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITSBPRO.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITSBPRO.DRV", 0 - -BLASTERString DB "BLASTER" -DriverName DB "ITSBPRO.DRV", 0 - -BlasterEnvironment Label DWord -BlasterOffset DW 0 -BlasterSegment DW 0 - -MixSpeed DW 43478 - -DSPVersion DW 0 -Forced DB 0 -Stereo DB 0 - -BytesToMix DW 1000 -SBMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 -DMASize DW 1024 - -MixLength DW 0 - -IMR DW 0 -OldIRQHandler DD 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - - -;********************************** - -SBProScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SBProHeaderLine - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 6 - DW Near Ptr MasterVolumeRight ; 7 - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 - DW Near Ptr MixModeButton2 - - DW 0 - -SBProHeaderLine DW 10 - DB "Sound Blaster Pro Driver", 0 - -DriverText DW 1 - DB 30, 48 - DB 21h - DB "Sound Blaster Pro Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 27, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 31 - DW 9, 0 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 31 - DW 9, 1 - DW 6, 9, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -Frequency DW 0 - -MixModeButton1 DW 2 - DW 7, 10, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 5, 19, 34, 21, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 9, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 5, 22, 34, 24, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -VolumeTable DB 6 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBOut ; AL = data - ; DX = 2xCh - - Push AX - -SBOut1: - In AL, DX - Test AL, AL - JS SBOut1 - - Pop AX - Out DX, AL - - Ret - -EndP SBOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBIn ; DX = 2xEh, returns AL - -SBIn1: - In AL, DX - Test AL, AL - JNS SBIn1 - - Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port - In AL, DX - Add DL, 0Eh-0Ah - - Ret - -EndP SBIn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBGetRegister - - Out DX, AL - Inc DX - In AL, DX - Dec DX - - Ret - -EndP SBGetRegister - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSBMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetSBMixConst1 - - Mov CX, 43478 - Cmp AX, CX - JA GetSBMixConst1 - - Mov CX, 12000 - Cmp AX, CX - JB GetSBMixConst1 - - Mov CX, AX - -GetSBMixConst1: - Mov AX, 1000 - Mul AX - Div CX - Mov AH, AL - Neg AH - Mov SBMixConst, AH - - MovZX BX, AL - Mov AX, 1000 - Mul AX - Div BX - Mov MixSpeed, AX - - Pop DS - PopA - Ret - -EndP GetSBMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDSP Far ; AX = Port - - Push AX - Push CX - Push DX - - Mov DX, AX - Add DL, 6 - Mov AL, 1 - Out DX, AL - - In AL, DX - In AL, DX - In AL, DX - In AL, DX - - Xor AL, AL - Out DX, AL - - Add DL, 8 - Mov CX, 200 - -ResetDSP1: - In AL, DX - Test AL, AL - JS ResetDSP2 - Loop ResetDSP1 - Jmp ResetDSP3 - -ResetDSP2: - Sub DL, 4 - In AL, DX - Cmp AL, 0AAh - JE ResetDSP4 - Add DL, 4 - Loop ResetDSP1 - -ResetDSP3: - StC - -ResetDSP4: - Pop DX - Pop CX - Pop AX - Ret - -EndP ResetDSP - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Forced, AL - - Mov AX, BasePort - Cmp AX, 0FFFFh - JE DetectCard1 - - Cmp AX, 210h - JB DetectCard9 - Cmp AX, 280h - JA DetectCard9 - - Call ResetDSP - JNC DetectCard3 - - Ret - -DetectCard1: - Mov AX, 210h - -DetectCard2: - Call ResetDSP - JNC DetectCard3 - Add AL, 10h - Cmp AL, 80h - JBE DetectCard2 - -DetectCard9: - StC - Ret - -DetectCard3: ; OK... DSP found. - ; Get DSP version - Mov BasePort, AX - - Mov DX, AX - Add DL, 0Ch ; 2xCh -> Data ready to send... - -DetectCardOuputLoop1: - In AL, DX - Test AL, AL - JS DetectCardOuputLoop1 - - Mov AL, 0E1h ; Get DSP version command - Out DX, AL - - Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status - - Call SBIn - Mov AH, AL ; AH = Major version number - Call SBIn ; AL = Minor version number - - Cmp Forced, 0 - JNE DetectCard5 - Cmp AH, 3 ; SB DSP = 3.00+ - JAE DetectCard5 - -DetectCard4: - StC - Ret - -DetectCard5: - Mov DSPVersion, AX - - ; Need to detect IRQ/DMA... - - Mov SI, Offset BLASTERString - Mov CX, 7 - Call GetEnvironment ; Returns ES:DI, Carry if error - JC DetectCardNoEnvironment - - Mov BlasterOffset, DI - Mov BlasterSegment, ES - - Cmp IRQ, 0FFFFh - JE DetectCardIRQ3 - Cmp Forced, 0 - JNE DetectCardIRQDone - Jmp DetectCardError - -DetectCardIRQ3: - Push DS - Push SI - - LDS SI, BlasterEnvironment - - Xor DX, DX ; DX = env.. - -DetectCardIRQ1: - LodsB - And AL, AL - JZ DetectCardError - Cmp AL, 'i' - JE DetectCardIRQ2 - Cmp AL, 'I' - JE DetectCardIRQ2 - Jmp DetectCardIRQ1 - -DetectCardIRQ2: - LodsB - And AL, AL - JZ DetectCardIRQEnd - Cmp AL, ' ' - JE DetectCardIRQEnd - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCardIRQ2 - -DetectCardIRQEnd: - Pop SI - Pop DS - - Mov IRQ, DX - -DetectCardIRQDone: - Cmp DMA, 0FFFFh - JE DetectCardDMA3 - Cmp Forced, 0 - JNE DetectCardDMADone - Jmp DetectCardError - -DetectCardDMA3: - Push DS - Push SI - - LDS SI, BlasterEnvironment - - Xor DX, DX ; DX = env.. - -DetectCardDMA1: - LodsB - And AL, AL - JZ DetectCardError - Cmp AL, 'd' - JE DetectCardDMA2 - Cmp AL, 'D' - JE DetectCardDMA2 - Jmp DetectCardDMA1 - -DetectCardDMA2: - LodsB - And AL, AL - JZ DetectCardDMAEnd - Cmp AL, ' ' - JE DetectCardDMAEnd - Sub AL, '0' - JC DetectCardError - Cmp AL, 9 - JA DetectCardError - - IMul DX, 10 - Add DL, AL - Jmp DetectCardDMA2 - -DetectCardDMAEnd: - Pop SI - Pop DS - - Mov DMA, DX - -DetectCardDMADone: - Mov EAX, 'Jeff' - - ClC - Ret - -DetectCardNoEnvironment: - Cmp DMA, 0FFFFh - JE DetectCardError - Cmp IRQ, 0FFFFh - JNE DetectCardDMADone - -DetectCardError: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Mov AX, 2020h - - Mov BX, CX ; BX = bytes to mix - Mov DX, CX - - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - Cmp CS:Stereo, 0 - JE MixSamples1 - - Mov AX, 1010h - And DX, Not 1 - ShR BX, 1 - ShR CX, 1 - Inc CX - -MixSamples1: - Rep StosW ; } Memory write - Mov MixTransferRemaining, DX ; } - Mov MixLength, BX - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Cmp MixMode, 4 ; Is it volume ramping? - JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Cmp CS:Stereo, 0 - JE MixSampleFreqNoStereo - - ShL EAX, 1 - -MixSampleFreqNoStereo: - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation, no ramping -Mix0ModeMono: - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AX, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AX, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AX, 60 - Test CH, CH - JZ MixModeCommon - - Mov AX, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AX, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AX, 150 ; Surround - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, MixLength - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SBProIRQHandler - - PushAD - Push DS - Push ES - - CLD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 0Eh - In AL, DX ; 8-bit IRQ ack. - - Mov AL, 20h - Cmp IRQ, 7 - JBE SBProIRQHandler1 - - Out 0A0h, AL - -SBProIRQHandler1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SBProIRQHandler2 - - Xor AX, AX - Xor BX, BX - -SBProIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - - ; BX = samples required - Mov BP, 4 ; Skip for mono - Mov CL, 6 ; Shift for mono - - Cmp Stereo, 0 - JE SBProIRQHandlerMono - - Mov BP, 2 ; Stereo skip value. - Dec CL - -SBProIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SBProIRQHandler4 - Assume DS:Nothing - -SBProIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SBProIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SBProIRQHandler5 - - Mov DX, MixTransferRemaining - -SBProIRQHandler5: - Push DX - -SBProIRQHandler6: - Mov AX, [SI] - SAR AX, CL - - Test AH, AH - JNZ SBProIRQHandlerClip1 - -SBProIRQHandler7: - StosB ; } Memory write - - Add SI, BP - Dec DX - JNZ SBProIRQHandler6 - - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SBProIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -SBProIRQHandlerClip1: - Mov AL, 00h - JS SBProIRQHandler7 - Mov AL, 0FFh - Jmp SBProIRQHandler7 - - Comment ~ - -Proc SBProIRQHandler - - PushAD - Push DS - Push ES - - CLD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, BasePort - Add DL, 0Fh - In AL, DX ; 16-bit IRQ ack. - - Mov AL, 20h - Cmp IRQ, 7 - JBE SBProIRQHandler1 - - Out 0A0h, AL - -SBProIRQHandler1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB SBProIRQHandler2 - - Xor AX, AX - Xor BX, BX - -SBProIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 4 ; Skip for mono - Mov CL, 6 ; Shift for mono - - Cmp Stereo, 0 - JE SBProIRQHandlerMono - - Mov BP, 2 ; Stereo skip value. - Dec CL - -SBProIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE SBProIRQHandler4 - Assume DS:Nothing - -SBProIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -SBProIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE SBProIRQHandler5 - - Mov DX, MixTransferRemaining - -SBProIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB SBProIRQHandler6 - JE SBProIRQHFilter - - Cmp CS:Stereo, 0 - JE SBProIRQ3QFilterMono - -SBProIRQ3QFilterStereo: - Push BX - - Mov BX, FilterValue - Mov BP, FilterValue2 - ShR DX, 1 - -SBProIRQ3QFilterStereo1: - Mov AX, BX - Mov CX, BP - Add AX, [SI] - Add CX, [SI+2] - SAR AX, 1 - SAR CX, 1 - Add BX, AX - Add BP, CX - SAR BX, 1 - SAR BP, 1 - - Mov AX, BX - SAR AX, 5 - - Test AH, AH - ;...... - -SBProIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL SBPro3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG SBPro3QFilterStereoClip4 - -SBProIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ SBProIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp SBProMixTransferEnd - -SBProIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -SBProIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL SBPro3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG SBPro3QFilterMonoClip2 - -SBProIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ SBProIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp SBProMixTransferEnd - -SBProIRQHFilter: - Cmp CS:Stereo, 0 - JE SBProIRQHFilterMono - -SBProIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -SBProIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL SBProHFilterStereoClip1 - Cmp EAX, 7FFFh - JG SBProHFilterStereoClip2 - -SBProIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL SBProHFilterStereoClip3 - Cmp EAX, 7FFFh - JG SBProHFilterStereoClip4 - -SBProIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ SBProIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp SBProMixTransferEnd - -SBProIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -SBProIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL SBProHFilterMonoClip1 - Cmp EAX, 7FFFh - JG SBProHFilterMonoClip2 - -SBProIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ SBProIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp SBProMixTransferEnd - -SBProIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL SBProIRQHandlerClip1 - Cmp EAX, 7FFFh - JG SBProIRQHandlerClip2 - -SBProIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ SBProIRQHandler6 - -SBProMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ SBProIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -SBProIRQHandlerClip1: - Mov AL, 80h - Jmp SBProIRQHandler7 - -SBProIRQHandlerClip2: - Mov AL, 7Fh - Jmp SBProIRQHandler7 - -SBProHFilterMonoClip1: - Mov AL, 80h - Jmp SBProIRQHFilterMono2 - -SBProHFilterMonoClip2: - Mov AL, 7Fh - Jmp SBProIRQHFilterMono2 - -SBProHFilterStereoClip1: - Mov AL, 80h - Jmp SBProIRQHFilterStereo2 - -SBProHFilterStereoClip2: - Mov AL, 7Fh - Jmp SBProIRQHFilterStereo2 - -SBProHFilterStereoClip3: - Mov AL, 80h - Jmp SBProIRQHFilterStereo3 - -SBProHFilterStereoClip4: - Mov AL, 7Fh - Jmp SBProIRQHFilterStereo3 - -SBPro3QFilterMonoClip1: - Mov AL, 80h - Jmp SBProIRQ3QFilterMono2 - -SBPro3QFilterMonoClip2: - Mov AL, 7Fh - Jmp SBProIRQ3QFilterMono2 - -SBPro3QFilterStereoClip1: - Mov AL, 80h - Jmp SBProIRQ3QFilterStereo2 - -SBPro3QFilterStereoClip2: - Mov AL, 7Fh - Jmp SBProIRQ3QFilterStereo2 - -SBPro3QFilterStereoClip3: - Mov AL, 80h - Jmp SBProIRQ3QFilterStereo3 - -SBPro3QFilterStereoClip4: - Mov AL, 7Fh - Jmp SBProIRQ3QFilterStereo3 - -EndP SBProIRQHandler - Assume DS:Nothing - - ~ - -EndP SBProIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset SBProIRQHandler - - XChg [ES:BX], EAX - Mov OldIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - Pop DS - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldIRQHandler - Mov [ES:BX], EAX - - Pop ES - Pop DS - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartSBPro ; - - PushA - Push ES - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Add DL, 0Ch - - Mov AL, 40h ; time constant - Call SBOut - Mov AL, SBMixConst - Call SBOut - - Mov AL, 0D1h ; turn on speaker - Call SBOut - - Mov AL, 48h ; Set DMA Size.. - Call SBOut - Mov AX, DMASize - Dec AX - Call SBOut - Mov AL, AH - Call SBOut - - Mov AL, 1Ch - Cmp MixSpeed, 21739 - JBE StartSBPro1 - - Mov AL, 90h - -StartSBPro1: - Call SBOut - - Pop ES - PopA - - Ret - - Assume DS:Nothing - -EndP StartSBPro - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixerRegisters - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Pop DS - - Ret - -EndP GetMixerRegisters - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, DS - Mov DriverSegment1, AX - Mov DriverSegment2, AX - Mov DriverSegment3, AX - Mov DriverSegment4, AX - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 22h - Call SBGetRegister - Mov AH, AL - And AX, 0FF0h - ShR AL, 4 - ShL AX, 1 - Mov Word Ptr [VolumeTable], AX - - Call GetSBMixConst - - ; Parags to allocate = (4/(.4*31*16))*MixSpeed + 2080 - ; = 661*MixSpeed/65536 - - Mov AX, 1322 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset SBProNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - Call StartSBPro - - Mov SI, Offset SBProMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AX, CS:BasePort - Call ResetDSP - Call StartSBPro - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov AX, BasePort - Call ResetDSP - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - PushA - Mov CX, MixSpeed - - Mov Stereo, AL - Mov AH, AL - - Mov DX, BasePort - Add DL, 4 - - Mov AL, 0Eh ; Stereo register - Out DX, AL - Inc DX - In AL, DX - - Test AH, AH - JZ SBProSetStereo1 - ; Turn on stereo - - ShR CX, 1 - Or AL, 2 - - Jmp SBProSetStereo2 - -SBProSetStereo1: ; Turn off stereo - - And AL, NOT 2 - -SBProSetStereo2: - Mov Frequency, CX - - ClI - - Out DX, AL - Call RecalculateAllFrequencies - - StI - - PopA - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset SBProScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far ; Returns AX, given DI - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far ; Given AX, DI - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DL, 4 - Mov AX, Word Ptr [VolumeTable] - - ShL AL, 3 - ShR AH, 1 - And AX, 0FF0h - Or AH, AL - Or AH, 11h - Mov AL, 22h - Out DX, AX - - Pop DX - Pop DS - Ret - -EndP SetVariable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 4096 +MIXRESOLUTION EQU 16 ; 16 bit mixing for the SB Pro +MIXTABLESIZE EQU 2*256*65 + +SBProMsg DB "Sound Blaster Pro detected", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +SBProNoMemoryMsg DB "Sound Blaster Pro detected", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Blaster Pro reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITSBPRO.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITSBPRO.DRV", 0 + +BLASTERString DB "BLASTER" +DriverName DB "ITSBPRO.DRV", 0 + +BlasterEnvironment Label DWord +BlasterOffset DW 0 +BlasterSegment DW 0 + +MixSpeed DW 43478 + +DSPVersion DW 0 +Forced DB 0 +Stereo DB 0 + +BytesToMix DW 1000 +SBMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 +DMASize DW 1024 + +MixLength DW 0 + +IMR DW 0 +OldIRQHandler DD 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + + +;********************************** + +SBProScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SBProHeaderLine + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 6 + DW Near Ptr MasterVolumeRight ; 7 + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 + DW Near Ptr MixModeButton2 + + DW 0 + +SBProHeaderLine DW 10 + DB "Sound Blaster Pro Driver", 0 + +DriverText DW 1 + DB 30, 48 + DB 21h + DB "Sound Blaster Pro Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 27, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 31 + DW 9, 0 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 31 + DW 9, 1 + DW 6, 9, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +Frequency DW 0 + +MixModeButton1 DW 2 + DW 7, 10, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 5, 19, 34, 21, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 9, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 5, 22, 34, 24, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +VolumeTable DB 6 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBOut ; AL = data + ; DX = 2xCh + + Push AX + +SBOut1: + In AL, DX + Test AL, AL + JS SBOut1 + + Pop AX + Out DX, AL + + Ret + +EndP SBOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBIn ; DX = 2xEh, returns AL + +SBIn1: + In AL, DX + Test AL, AL + JNS SBIn1 + + Add DL, 0Ah-0Eh ; DX = 2xAh -> Data read port + In AL, DX + Add DL, 0Eh-0Ah + + Ret + +EndP SBIn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBGetRegister + + Out DX, AL + Inc DX + In AL, DX + Dec DX + + Ret + +EndP SBGetRegister + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSBMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetSBMixConst1 + + Mov CX, 43478 + Cmp AX, CX + JA GetSBMixConst1 + + Mov CX, 12000 + Cmp AX, CX + JB GetSBMixConst1 + + Mov CX, AX + +GetSBMixConst1: + Mov AX, 1000 + Mul AX + Div CX + Mov AH, AL + Neg AH + Mov SBMixConst, AH + + MovZX BX, AL + Mov AX, 1000 + Mul AX + Div BX + Mov MixSpeed, AX + + Pop DS + PopA + Ret + +EndP GetSBMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDSP Far ; AX = Port + + Push AX + Push CX + Push DX + + Mov DX, AX + Add DL, 6 + Mov AL, 1 + Out DX, AL + + In AL, DX + In AL, DX + In AL, DX + In AL, DX + + Xor AL, AL + Out DX, AL + + Add DL, 8 + Mov CX, 200 + +ResetDSP1: + In AL, DX + Test AL, AL + JS ResetDSP2 + Loop ResetDSP1 + Jmp ResetDSP3 + +ResetDSP2: + Sub DL, 4 + In AL, DX + Cmp AL, 0AAh + JE ResetDSP4 + Add DL, 4 + Loop ResetDSP1 + +ResetDSP3: + StC + +ResetDSP4: + Pop DX + Pop CX + Pop AX + Ret + +EndP ResetDSP + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Forced, AL + + Mov AX, BasePort + Cmp AX, 0FFFFh + JE DetectCard1 + + Cmp AX, 210h + JB DetectCard9 + Cmp AX, 280h + JA DetectCard9 + + Call ResetDSP + JNC DetectCard3 + + Ret + +DetectCard1: + Mov AX, 210h + +DetectCard2: + Call ResetDSP + JNC DetectCard3 + Add AL, 10h + Cmp AL, 80h + JBE DetectCard2 + +DetectCard9: + StC + Ret + +DetectCard3: ; OK... DSP found. + ; Get DSP version + Mov BasePort, AX + + Mov DX, AX + Add DL, 0Ch ; 2xCh -> Data ready to send... + +DetectCardOuputLoop1: + In AL, DX + Test AL, AL + JS DetectCardOuputLoop1 + + Mov AL, 0E1h ; Get DSP version command + Out DX, AL + + Add DL, 0Eh-0Ch ; DX = 2xEh -> Data available status + + Call SBIn + Mov AH, AL ; AH = Major version number + Call SBIn ; AL = Minor version number + + Cmp Forced, 0 + JNE DetectCard5 + Cmp AH, 3 ; SB DSP = 3.00+ + JAE DetectCard5 + +DetectCard4: + StC + Ret + +DetectCard5: + Mov DSPVersion, AX + + ; Need to detect IRQ/DMA... + + Mov SI, Offset BLASTERString + Mov CX, 7 + Call GetEnvironment ; Returns ES:DI, Carry if error + JC DetectCardNoEnvironment + + Mov BlasterOffset, DI + Mov BlasterSegment, ES + + Cmp IRQ, 0FFFFh + JE DetectCardIRQ3 + Cmp Forced, 0 + JNE DetectCardIRQDone + Jmp DetectCardError + +DetectCardIRQ3: + Push DS + Push SI + + LDS SI, BlasterEnvironment + + Xor DX, DX ; DX = env.. + +DetectCardIRQ1: + LodsB + And AL, AL + JZ DetectCardError + Cmp AL, 'i' + JE DetectCardIRQ2 + Cmp AL, 'I' + JE DetectCardIRQ2 + Jmp DetectCardIRQ1 + +DetectCardIRQ2: + LodsB + And AL, AL + JZ DetectCardIRQEnd + Cmp AL, ' ' + JE DetectCardIRQEnd + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCardIRQ2 + +DetectCardIRQEnd: + Pop SI + Pop DS + + Mov IRQ, DX + +DetectCardIRQDone: + Cmp DMA, 0FFFFh + JE DetectCardDMA3 + Cmp Forced, 0 + JNE DetectCardDMADone + Jmp DetectCardError + +DetectCardDMA3: + Push DS + Push SI + + LDS SI, BlasterEnvironment + + Xor DX, DX ; DX = env.. + +DetectCardDMA1: + LodsB + And AL, AL + JZ DetectCardError + Cmp AL, 'd' + JE DetectCardDMA2 + Cmp AL, 'D' + JE DetectCardDMA2 + Jmp DetectCardDMA1 + +DetectCardDMA2: + LodsB + And AL, AL + JZ DetectCardDMAEnd + Cmp AL, ' ' + JE DetectCardDMAEnd + Sub AL, '0' + JC DetectCardError + Cmp AL, 9 + JA DetectCardError + + IMul DX, 10 + Add DL, AL + Jmp DetectCardDMA2 + +DetectCardDMAEnd: + Pop SI + Pop DS + + Mov DMA, DX + +DetectCardDMADone: + Mov EAX, 'Jeff' + + ClC + Ret + +DetectCardNoEnvironment: + Cmp DMA, 0FFFFh + JE DetectCardError + Cmp IRQ, 0FFFFh + JNE DetectCardDMADone + +DetectCardError: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Mov AX, 2020h + + Mov BX, CX ; BX = bytes to mix + Mov DX, CX + + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + Cmp CS:Stereo, 0 + JE MixSamples1 + + Mov AX, 1010h + And DX, Not 1 + ShR BX, 1 + ShR CX, 1 + Inc CX + +MixSamples1: + Rep StosW ; } Memory write + Mov MixTransferRemaining, DX ; } + Mov MixLength, BX + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Cmp MixMode, 4 ; Is it volume ramping? + JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Cmp CS:Stereo, 0 + JE MixSampleFreqNoStereo + + ShL EAX, 1 + +MixSampleFreqNoStereo: + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation, no ramping +Mix0ModeMono: + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AX, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AX, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AX, 60 + Test CH, CH + JZ MixModeCommon + + Mov AX, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AX, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AX, 150 ; Surround + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, MixLength + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SBProIRQHandler + + PushAD + Push DS + Push ES + + CLD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 0Eh + In AL, DX ; 8-bit IRQ ack. + + Mov AL, 20h + Cmp IRQ, 7 + JBE SBProIRQHandler1 + + Out 0A0h, AL + +SBProIRQHandler1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SBProIRQHandler2 + + Xor AX, AX + Xor BX, BX + +SBProIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + + ; BX = samples required + Mov BP, 4 ; Skip for mono + Mov CL, 6 ; Shift for mono + + Cmp Stereo, 0 + JE SBProIRQHandlerMono + + Mov BP, 2 ; Stereo skip value. + Dec CL + +SBProIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SBProIRQHandler4 + Assume DS:Nothing + +SBProIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SBProIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SBProIRQHandler5 + + Mov DX, MixTransferRemaining + +SBProIRQHandler5: + Push DX + +SBProIRQHandler6: + Mov AX, [SI] + SAR AX, CL + + Test AH, AH + JNZ SBProIRQHandlerClip1 + +SBProIRQHandler7: + StosB ; } Memory write + + Add SI, BP + Dec DX + JNZ SBProIRQHandler6 + + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SBProIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +SBProIRQHandlerClip1: + Mov AL, 00h + JS SBProIRQHandler7 + Mov AL, 0FFh + Jmp SBProIRQHandler7 + + Comment ~ + +Proc SBProIRQHandler + + PushAD + Push DS + Push ES + + CLD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, BasePort + Add DL, 0Fh + In AL, DX ; 16-bit IRQ ack. + + Mov AL, 20h + Cmp IRQ, 7 + JBE SBProIRQHandler1 + + Out 0A0h, AL + +SBProIRQHandler1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB SBProIRQHandler2 + + Xor AX, AX + Xor BX, BX + +SBProIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 4 ; Skip for mono + Mov CL, 6 ; Shift for mono + + Cmp Stereo, 0 + JE SBProIRQHandlerMono + + Mov BP, 2 ; Stereo skip value. + Dec CL + +SBProIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE SBProIRQHandler4 + Assume DS:Nothing + +SBProIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +SBProIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE SBProIRQHandler5 + + Mov DX, MixTransferRemaining + +SBProIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB SBProIRQHandler6 + JE SBProIRQHFilter + + Cmp CS:Stereo, 0 + JE SBProIRQ3QFilterMono + +SBProIRQ3QFilterStereo: + Push BX + + Mov BX, FilterValue + Mov BP, FilterValue2 + ShR DX, 1 + +SBProIRQ3QFilterStereo1: + Mov AX, BX + Mov CX, BP + Add AX, [SI] + Add CX, [SI+2] + SAR AX, 1 + SAR CX, 1 + Add BX, AX + Add BP, CX + SAR BX, 1 + SAR BP, 1 + + Mov AX, BX + SAR AX, 5 + + Test AH, AH + ;...... + +SBProIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL SBPro3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG SBPro3QFilterStereoClip4 + +SBProIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ SBProIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp SBProMixTransferEnd + +SBProIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +SBProIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL SBPro3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG SBPro3QFilterMonoClip2 + +SBProIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ SBProIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp SBProMixTransferEnd + +SBProIRQHFilter: + Cmp CS:Stereo, 0 + JE SBProIRQHFilterMono + +SBProIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +SBProIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL SBProHFilterStereoClip1 + Cmp EAX, 7FFFh + JG SBProHFilterStereoClip2 + +SBProIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL SBProHFilterStereoClip3 + Cmp EAX, 7FFFh + JG SBProHFilterStereoClip4 + +SBProIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ SBProIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp SBProMixTransferEnd + +SBProIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +SBProIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL SBProHFilterMonoClip1 + Cmp EAX, 7FFFh + JG SBProHFilterMonoClip2 + +SBProIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ SBProIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp SBProMixTransferEnd + +SBProIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL SBProIRQHandlerClip1 + Cmp EAX, 7FFFh + JG SBProIRQHandlerClip2 + +SBProIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ SBProIRQHandler6 + +SBProMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ SBProIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +SBProIRQHandlerClip1: + Mov AL, 80h + Jmp SBProIRQHandler7 + +SBProIRQHandlerClip2: + Mov AL, 7Fh + Jmp SBProIRQHandler7 + +SBProHFilterMonoClip1: + Mov AL, 80h + Jmp SBProIRQHFilterMono2 + +SBProHFilterMonoClip2: + Mov AL, 7Fh + Jmp SBProIRQHFilterMono2 + +SBProHFilterStereoClip1: + Mov AL, 80h + Jmp SBProIRQHFilterStereo2 + +SBProHFilterStereoClip2: + Mov AL, 7Fh + Jmp SBProIRQHFilterStereo2 + +SBProHFilterStereoClip3: + Mov AL, 80h + Jmp SBProIRQHFilterStereo3 + +SBProHFilterStereoClip4: + Mov AL, 7Fh + Jmp SBProIRQHFilterStereo3 + +SBPro3QFilterMonoClip1: + Mov AL, 80h + Jmp SBProIRQ3QFilterMono2 + +SBPro3QFilterMonoClip2: + Mov AL, 7Fh + Jmp SBProIRQ3QFilterMono2 + +SBPro3QFilterStereoClip1: + Mov AL, 80h + Jmp SBProIRQ3QFilterStereo2 + +SBPro3QFilterStereoClip2: + Mov AL, 7Fh + Jmp SBProIRQ3QFilterStereo2 + +SBPro3QFilterStereoClip3: + Mov AL, 80h + Jmp SBProIRQ3QFilterStereo3 + +SBPro3QFilterStereoClip4: + Mov AL, 7Fh + Jmp SBProIRQ3QFilterStereo3 + +EndP SBProIRQHandler + Assume DS:Nothing + + ~ + +EndP SBProIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset SBProIRQHandler + + XChg [ES:BX], EAX + Mov OldIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + Pop DS + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldIRQHandler + Mov [ES:BX], EAX + + Pop ES + Pop DS + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartSBPro ; + + PushA + Push ES + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Add DL, 0Ch + + Mov AL, 40h ; time constant + Call SBOut + Mov AL, SBMixConst + Call SBOut + + Mov AL, 0D1h ; turn on speaker + Call SBOut + + Mov AL, 48h ; Set DMA Size.. + Call SBOut + Mov AX, DMASize + Dec AX + Call SBOut + Mov AL, AH + Call SBOut + + Mov AL, 1Ch + Cmp MixSpeed, 21739 + JBE StartSBPro1 + + Mov AL, 90h + +StartSBPro1: + Call SBOut + + Pop ES + PopA + + Ret + + Assume DS:Nothing + +EndP StartSBPro + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixerRegisters + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Pop DS + + Ret + +EndP GetMixerRegisters + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, DS + Mov DriverSegment1, AX + Mov DriverSegment2, AX + Mov DriverSegment3, AX + Mov DriverSegment4, AX + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 22h + Call SBGetRegister + Mov AH, AL + And AX, 0FF0h + ShR AL, 4 + ShL AX, 1 + Mov Word Ptr [VolumeTable], AX + + Call GetSBMixConst + + ; Parags to allocate = (4/(.4*31*16))*MixSpeed + 2080 + ; = 661*MixSpeed/65536 + + Mov AX, 1322 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset SBProNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + Call StartSBPro + + Mov SI, Offset SBProMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AX, CS:BasePort + Call ResetDSP + Call StartSBPro + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov AX, BasePort + Call ResetDSP + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + PushA + Mov CX, MixSpeed + + Mov Stereo, AL + Mov AH, AL + + Mov DX, BasePort + Add DL, 4 + + Mov AL, 0Eh ; Stereo register + Out DX, AL + Inc DX + In AL, DX + + Test AH, AH + JZ SBProSetStereo1 + ; Turn on stereo + + ShR CX, 1 + Or AL, 2 + + Jmp SBProSetStereo2 + +SBProSetStereo1: ; Turn off stereo + + And AL, NOT 2 + +SBProSetStereo2: + Mov Frequency, CX + + ClI + + Out DX, AL + Call RecalculateAllFrequencies + + StI + + PopA + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset SBProScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far ; Returns AX, given DI + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far ; Given AX, DI + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DL, 4 + Mov AX, Word Ptr [VolumeTable] + + ShL AL, 3 + ShR AH, 1 + And AX, 0FF0h + Or AH, AL + Or AH, 11h + Mov AL, 22h + Out DX, AX + + Pop DX + Pop DS + Ret + +EndP SetVariable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/SNDDRV.ASM b/SoundDrivers/SNDDRV.ASM index 19549fe..e6c3def 100755 --- a/SoundDrivers/SNDDRV.ASM +++ b/SoundDrivers/SNDDRV.ASM @@ -1,283 +1,283 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EmptyFunction Far - - Xor AX, AX - StC - Ret - -EndP EmptyFunction - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - StC - Ret - -EndP DetectCard - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - StC - Ret - -EndP InitSound - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load (0 based) -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release (1 based) -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Xor AX, AX - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 32 - - DW 5 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EmptyFunction Far + + Xor AX, AX + StC + Ret + +EndP EmptyFunction + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + StC + Ret + +EndP DetectCard + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + StC + Ret + +EndP InitSound + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load (0 based) +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release (1 based) +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Xor AX, AX + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 32 + + DW 5 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ST97.ASM b/SoundDrivers/ST97.ASM index e6a5c73..53798a1 100755 --- a/SoundDrivers/ST97.ASM +++ b/SoundDrivers/ST97.ASM @@ -1,866 +1,866 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;*********************************************** - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 80719304h - -MMT_MAXENTRIES EQU 64 -MMT_MAXSIZE EQU 3*MMT_MAXENTRIES - -ST97Message DB "Sound Track 97 PnP Detected", 13 -; DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 - DB "Port ", 0FDh, "Xh, ", 0FDh, "D Voices, ", 0FDh, "Dk", 0 - -StatusLine DB "FreeST ", 0FDh, "Dk", 0 - -MMTData DW MMT_MAXSIZE Dup (0) - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EmptyFunction Far - - Xor AX, AX - StC - Ret - -EndP EmptyFunction - -; ÄÄ ST97InString ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97InString ; ES:DI points to deposit point. - ; EAX = memory address - ; CX = count - - ClI - - Mov BL, 2 ; Ctrl=RD_MEM, Data=Memory Address - Call ST97OutDWord - - Mov DX, CS:BasePort ; Length - Mov AX, CX - Call ST97SendByte - - Mov AL, AH - Call ST97SendByte - -ST97InString1: - Call ST97InByte - Cmp AL, 0ABh - JE ST97InStringError - Cmp AL, 0ACh - JNE ST97InString1 - -ST97InString2: - Inc DX - Inc DX - - Rep InsW - - ClC - StI - Ret - -ST97InStringError: - StC - StI - Ret - -EndP ST97InString - -; ÄÄ ST97ReceiveByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97ReceiveByte ; Returns AL - - Push DX - Mov DX, CS:BasePort - Inc DX - -ST97ReceiveByte1: - In AL, DX - Test AL, AL - JS ST97ReceiveByte1 - - Dec DX - In AL, DX - Pop DX - - Ret - -EndP ST97ReceiveByte - -; ÄÄ ST97InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97InByte ; Returns AL - - Jmp ST97ReceiveByte - -EndP ST97InByte - -; ÄÄ ST97InWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97InWord ; Returns AX - - ClI - - Call ST97ReceiveByte - Mov AL, AH - - Call ST97ReceiveByte - XChg AL, AH - - StI - - Ret - -EndP ST97InWord - -; ÄÄ ST97InDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97InDWord ; Returns EAX - - ClI - - Call ST97ReceiveByte - RoR EAX, 8 - - Call ST97ReceiveByte - RoR EAX, 8 - - Call ST97ReceiveByte - RoR EAX, 8 - - Call ST97ReceiveByte - RoR EAX, 8 - - StI - Ret - -EndP ST97InDWord - -; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97SendByte ; DX = port, AL = data - - Push AX - Push DX - Mov DX, CS:BasePort - Inc DX - -ST97SendByte1: - In AL, DX - Test AL, 40h - JNZ ST97SendByte1 - - Pop DX - Pop AX - - Out DX, AL - - Ret - -EndP ST97SendByte - -; ÄÄ ST97OutByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97OutByte ; AL = data, AH = command, destroys AX - - ClI - Push DX - - Mov DX, CS:BasePort - Inc DX - - XChg AH, AL - Call ST97SendByte - - Dec DX - - Mov AL, AH - Call ST97SendByte - - Pop DX - StI - - Ret - -EndP ST97OutByte - -; ÄÄ ST97OutWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97OutWord ; AX = data, BL = command, destroys AX - - ClI - Push DX - Push AX - - Mov DX, CS:BasePort - Mov AL, BL - Inc DX - Call ST97SendByte - - Pop AX - Dec DX - Call ST97SendByte - - Mov AL, AH - Call ST97SendByte - - Pop DX - StI - - Ret - -EndP ST97OutWord - -; ÄÄ ST97OutDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ST97OutDWord ; EAX = data, BL = command - - ClI - Push DX - Push AX - - Mov DX, CS:BasePort - Mov AL, BL - Inc DX - Call ST97SendByte - - Pop AX - Dec DX - Call ST97SendByte - - ShR EAX, 8 - Call ST97SendByte - - ShR EAX, 8 - Call ST97SendByte - - ShR EAX, 8 - Call ST97SendByte - - Pop DX - StI - - Ret - -EndP ST97OutDWord - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART ; Given DX = Port - - ClI - - Inc DX - - Mov AL, 0FFh ; Reset! - Out DX, AL - Out DX, AL ; Two resets required to ensure it'll work - - Xor CX, CX - -ResetUART2: - In AL, DX - Test AL, 80h - JNZ ResetUART3 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE ResetUART4 - -ResetUART3: - Loop ResetUART2 - -ResetUARTError: - StI - StC - Ret - -ResetUART4: ; Now to shove it into 'intelligent' mode. - Xor CX, CX - -ResetUART5: - In AL, DX - Test AL, 40h - LoopNZ ResetUART5 - JNZ ResetUARTError - - Mov AL, 3Fh ; Intelligent mode! - Out DX, AL - -ResetUART6: - Xor CX, CX - -ResetUART7: - In AL, DX - Test AL, 80h - JNZ ResetUART8 - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JE ResetUART9 - -ResetUART8: - Loop ResetUART7 - Jmp ResetUARTError - -ResetUART9: - StI - ClC - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - Mov AX, 307h ; LDN 3 - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Mov BasePort, 330h - Mov DX, BasePort - Call ResetUART - -; Find memory mapping table - Mov AX, 300h ; Ctrl 3 (GET_MMT), Data 0 - Call ST97OutByte - Call ST97InDWord - - Push CS - Pop ES - Mov CX, MMT_MAXSIZE - Mov DI, Offset MMTData - Call ST97InString - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset ST97Message -Comment ~ - Mov AX, BasePort - Mov BX, IRQ - Mov ECX, DWord Ptr [MMTData+2] - ShR ECX, 9 -~ - Xor BX, BX - Mov AX, 5100h ; Cntrl = GET_VOI, Data = 0 - Call ST97OutByte - Call ST97InByte - Mov BL, AL - Mov AX, BasePort - Mov ECX, DWord Ptr [MMTData+2] - ShR ECX, 9 - - ClC - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Mov DX, CS:BasePort - Inc DX - Mov AL, 0FFh - Out DX, AL - - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load (0 based) -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release (1 based) -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset MMTData+6 - Xor EAX, EAX - -GetStatus1: - Mov CX, [SI] - Add SI, 6 - - Cmp CX, -1 - JE GetStatus2 - - Cmp CX, 1 - JA GetStatus1 - JB GetStatus1 - - Add EAX, [SI+2] - Sub EAX, [SI-4] - Jmp GetStatus1 - -GetStatus2: - Mov SI, Offset StatusLine - ShR EAX, 9 - - ClC - Ret - -EndP GetStatus - Assume DS:Nothing - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Xor AX, AX - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 64 ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 64 - - DW 5 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;*********************************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 80719304h + +MMT_MAXENTRIES EQU 64 +MMT_MAXSIZE EQU 3*MMT_MAXENTRIES + +ST97Message DB "Sound Track 97 PnP Detected", 13 +; DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, ", 0FDh, "Dk RAM", 0 + DB "Port ", 0FDh, "Xh, ", 0FDh, "D Voices, ", 0FDh, "Dk", 0 + +StatusLine DB "FreeST ", 0FDh, "Dk", 0 + +MMTData DW MMT_MAXSIZE Dup (0) + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EmptyFunction Far + + Xor AX, AX + StC + Ret + +EndP EmptyFunction + +; ÄÄ ST97InString ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97InString ; ES:DI points to deposit point. + ; EAX = memory address + ; CX = count + + ClI + + Mov BL, 2 ; Ctrl=RD_MEM, Data=Memory Address + Call ST97OutDWord + + Mov DX, CS:BasePort ; Length + Mov AX, CX + Call ST97SendByte + + Mov AL, AH + Call ST97SendByte + +ST97InString1: + Call ST97InByte + Cmp AL, 0ABh + JE ST97InStringError + Cmp AL, 0ACh + JNE ST97InString1 + +ST97InString2: + Inc DX + Inc DX + + Rep InsW + + ClC + StI + Ret + +ST97InStringError: + StC + StI + Ret + +EndP ST97InString + +; ÄÄ ST97ReceiveByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97ReceiveByte ; Returns AL + + Push DX + Mov DX, CS:BasePort + Inc DX + +ST97ReceiveByte1: + In AL, DX + Test AL, AL + JS ST97ReceiveByte1 + + Dec DX + In AL, DX + Pop DX + + Ret + +EndP ST97ReceiveByte + +; ÄÄ ST97InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97InByte ; Returns AL + + Jmp ST97ReceiveByte + +EndP ST97InByte + +; ÄÄ ST97InWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97InWord ; Returns AX + + ClI + + Call ST97ReceiveByte + Mov AL, AH + + Call ST97ReceiveByte + XChg AL, AH + + StI + + Ret + +EndP ST97InWord + +; ÄÄ ST97InDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97InDWord ; Returns EAX + + ClI + + Call ST97ReceiveByte + RoR EAX, 8 + + Call ST97ReceiveByte + RoR EAX, 8 + + Call ST97ReceiveByte + RoR EAX, 8 + + Call ST97ReceiveByte + RoR EAX, 8 + + StI + Ret + +EndP ST97InDWord + +; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97SendByte ; DX = port, AL = data + + Push AX + Push DX + Mov DX, CS:BasePort + Inc DX + +ST97SendByte1: + In AL, DX + Test AL, 40h + JNZ ST97SendByte1 + + Pop DX + Pop AX + + Out DX, AL + + Ret + +EndP ST97SendByte + +; ÄÄ ST97OutByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97OutByte ; AL = data, AH = command, destroys AX + + ClI + Push DX + + Mov DX, CS:BasePort + Inc DX + + XChg AH, AL + Call ST97SendByte + + Dec DX + + Mov AL, AH + Call ST97SendByte + + Pop DX + StI + + Ret + +EndP ST97OutByte + +; ÄÄ ST97OutWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97OutWord ; AX = data, BL = command, destroys AX + + ClI + Push DX + Push AX + + Mov DX, CS:BasePort + Mov AL, BL + Inc DX + Call ST97SendByte + + Pop AX + Dec DX + Call ST97SendByte + + Mov AL, AH + Call ST97SendByte + + Pop DX + StI + + Ret + +EndP ST97OutWord + +; ÄÄ ST97OutDWord ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ST97OutDWord ; EAX = data, BL = command + + ClI + Push DX + Push AX + + Mov DX, CS:BasePort + Mov AL, BL + Inc DX + Call ST97SendByte + + Pop AX + Dec DX + Call ST97SendByte + + ShR EAX, 8 + Call ST97SendByte + + ShR EAX, 8 + Call ST97SendByte + + ShR EAX, 8 + Call ST97SendByte + + Pop DX + StI + + Ret + +EndP ST97OutDWord + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART ; Given DX = Port + + ClI + + Inc DX + + Mov AL, 0FFh ; Reset! + Out DX, AL + Out DX, AL ; Two resets required to ensure it'll work + + Xor CX, CX + +ResetUART2: + In AL, DX + Test AL, 80h + JNZ ResetUART3 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE ResetUART4 + +ResetUART3: + Loop ResetUART2 + +ResetUARTError: + StI + StC + Ret + +ResetUART4: ; Now to shove it into 'intelligent' mode. + Xor CX, CX + +ResetUART5: + In AL, DX + Test AL, 40h + LoopNZ ResetUART5 + JNZ ResetUARTError + + Mov AL, 3Fh ; Intelligent mode! + Out DX, AL + +ResetUART6: + Xor CX, CX + +ResetUART7: + In AL, DX + Test AL, 80h + JNZ ResetUART8 + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JE ResetUART9 + +ResetUART8: + Loop ResetUART7 + Jmp ResetUARTError + +ResetUART9: + StI + ClC + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + Mov AX, 307h ; LDN 3 + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Mov BasePort, 330h + Mov DX, BasePort + Call ResetUART + +; Find memory mapping table + Mov AX, 300h ; Ctrl 3 (GET_MMT), Data 0 + Call ST97OutByte + Call ST97InDWord + + Push CS + Pop ES + Mov CX, MMT_MAXSIZE + Mov DI, Offset MMTData + Call ST97InString + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset ST97Message +Comment ~ + Mov AX, BasePort + Mov BX, IRQ + Mov ECX, DWord Ptr [MMTData+2] + ShR ECX, 9 +~ + Xor BX, BX + Mov AX, 5100h ; Cntrl = GET_VOI, Data = 0 + Call ST97OutByte + Call ST97InByte + Mov BL, AL + Mov AX, BasePort + Mov ECX, DWord Ptr [MMTData+2] + ShR ECX, 9 + + ClC + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Mov DX, CS:BasePort + Inc DX + Mov AL, 0FFh + Out DX, AL + + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load (0 based) +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release (1 based) +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset MMTData+6 + Xor EAX, EAX + +GetStatus1: + Mov CX, [SI] + Add SI, 6 + + Cmp CX, -1 + JE GetStatus2 + + Cmp CX, 1 + JA GetStatus1 + JB GetStatus1 + + Add EAX, [SI+2] + Sub EAX, [SI-4] + Jmp GetStatus1 + +GetStatus2: + Mov SI, Offset StatusLine + ShR EAX, 9 + + ClC + Ret + +EndP GetStatus + Assume DS:Nothing + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Xor AX, AX + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 64 ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 64 + + DW 5 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ST97CMMX.ASM b/SoundDrivers/ST97CMMX.ASM index 1a3f5fb..9dbb169 100755 --- a/SoundDrivers/ST97CMMX.ASM +++ b/SoundDrivers/ST97CMMX.ASM @@ -1,2773 +1,2773 @@ -; -; ST 97/42 PCI Codec, using MMX. -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing -OUTPUTFILTERENABLED EQU 0 -DATAFLAG EQU 200h -ACKFLAG EQU 300h -FOURIERBUFFERLENGTH EQU 2048 ; 2048 samples - -PNPVENDORID EQU 3746630Eh - -FPSave DB 128 Dup (0) - -DMASize DW DMABUFFERLENGTH / 2 - -WSSMsg DB "Sound Track Codec MMX", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Sound Track Codec MMX", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Track Codec reinitialised", 0 - -DriverName DB "ITSTCODE.MMX", 0 - -Forced DB 0 -Stereo DB 0 -WSSMixConst DB 0 - -ALIGN 2 - -MixVolume DW 0 - -BytesToMix DW 1000 - -MixSegment DW 0 -FourierSegment DW 0 - -; Arrangement of data: -; First 64 bytes = MMX temporary area -; Next 2*DMABUFFERLENGTH = DMA area -; After that is mixing buffer. - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 35 -MixMode DW 0 -MixModeOffset DW 0 -VolumeTable DB 56, 56 - DB 60h, 60h, 0Ch ; Low Band - DB 40h, 40h, 1Bh ; Med Low Band - DB 40h, 40h, 72h ; Med High Band - DB 60h, 60h, 40h ; High Band - DB 0, 0, 0 ; Echo - DB 0, 2 ; Surround - DB 0, 90h, 4, 7Fh, 22h ; Reverb - DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus - DB 0, 0 ; SRS stuff. - -ALIGN 2 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -SAM9407Reset DW 66 - DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on - DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on - DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on - DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on - DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type - DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on - DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in - DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus - DW 1BEh, 133h, 0, 0 ; 2 Speaker - DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 - DW 1BEh, 134h, 0FFh, 0FFh ; Left gain - DW 1BEh, 135h, 0FFh, 0FFh ; Right gain - DW 1BEh, 136h, 0, 0 ; Left pan - DW 1BEh, 137h, 7Fh, 7Fh ; Right pan - DW 1BEh, 107h, 0FFh, 0FFh ; Master volume - -SAM9407EqLBL DW 4 - DW 1BEh, 110h, DATAFLAG, 60h -SAM9407EqLBR DW 4 - DW 1BEh, 114h, DATAFLAG, 60h -SAM9407EqLBF DW 4 - DW 1BEh, 118h, DATAFLAG, 0Ch -SAM9407EqMLBL DW 4 - DW 1BEh, 111h, DATAFLAG, 40h -SAM9407EqMLBR DW 4 - DW 1BEh, 115h, DATAFLAG, 40h -SAM9407EqMLBF DW 4 - DW 1BEh, 119h, DATAFLAG, 1Bh -SAM9407EqMHBL DW 4 - DW 1BEh, 112h, DATAFLAG, 40h -SAM9407EqMHBR DW 4 - DW 1BEh, 116h, DATAFLAG, 40h -SAM9407EqMHBF DW 4 - DW 1BEh, 11Ah, DATAFLAG, 72h -SAM9407EqHBL DW 4 - DW 1BEh, 113h, DATAFLAG, 60h -SAM9407EqHBR DW 4 - DW 1BEh, 117h, DATAFLAG, 60h -SAM9407EqHBF DW 4 - DW 1BEh, 11Bh, DATAFLAG, 0Ch -SAM9407EchoLevel DW 4 - DW 1BEh, 128h, DATAFLAG, 0 -SAM9407EchoTime DW 4 - DW 1BEh, 129h, DATAFLAG, 2Bh -SAM9407EchoFeed DW 4 - DW 1BEh, 12Ah, DATAFLAG, 40h -SAM9407SurroundVolume DW 4 - DW 1BEh, 130h, DATAFLAG, 0 -SAM9407SurroundDelay DW 4 - DW 1BEh, 131h, DATAFLAG, 2 -SAM9407ReverbSend DW 4 - DW 1BEh, 127h, DATAFLAG, 0 -SAM9407ReverbVolume DW 3 - DW 1BEh, 13Ah, DATAFLAG -SAM9407ReverbType DW 4 - DW 1BEh, 169h, DATAFLAG, 4 -SAM9407ReverbTime DW 3 - DW 1BEh, 178h, DATAFLAG -SAM9407ReverbFeedback DW 3 - DW 1BEh, 179h, DATAFLAG -SAM9407ChorusSend DW 4 - DW 1BEh, 124h, DATAFLAG, 0 -SAM9407ChorusVolume DW 3 - DW 1BEh, 13Bh, DATAFLAG -SAM9407ChorusType DW 4 - DW 1BEh, 16Ah, DATAFLAG, 2 -SAM9407ChorusDelay DW 3 - DW 1BEh, 174h, DATAFLAG -SAM9407ChorusFeedback DW 3 - DW 1BEh, 175h, DATAFLAG -SAM9407ChorusRate DW 3 - DW 1BEh, 176h, DATAFLAG -SAM9407ChorusDepth DW 3 - DW 1BEh, 177h, DATAFLAG -SAM9407Mono DW 4 - DW 1BEh, 132h, 7Fh, 0 -SAM9407Stereo DW 4 - DW 1BEh, 132h, 0, 0 - -SAM9407Strings DW Offset SAM9407Reset ;1 - DW Offset SAM9407EqLBL, Offset SAM9407EqLBR - DW Offset SAM9407EqLBF - DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR - DW Offset SAM9407EqMLBF - DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR - DW Offset SAM9407EqMHBF - DW Offset SAM9407EqHBL, Offset SAM9407EqHBR - DW Offset SAM9407EqHBF - DW Offset SAM9407EchoLevel ; 14 - DW Offset SAM9407EchoTime - DW Offset SAM9407EchoFeed - DW Offset SAM9407SurroundVolume ; 17 - DW Offset SAM9407SurroundDelay - DW Offset SAM9407ReverbSend ; 19 - DW Offset SAM9407ReverbVolume - DW Offset SAM9407ReverbType - DW Offset SAM9407ReverbTime - DW Offset SAM9407ReverbFeedback ; 23 - DW Offset SAM9407ChorusSend ; 24 - DW Offset SAM9407ChorusVolume - DW Offset SAM9407ChorusType - DW Offset SAM9407ChorusDelay - DW Offset SAM9407ChorusFeedback - DW Offset SAM9407ChorusRate - DW Offset SAM9407ChorusDepth ; 30 - DW Offset SAM9407Mono ; 31 - DW Offset SAM9407Stereo - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; - DW Near Ptr MixModeButton4 ; - - DW Near Ptr EmptyObject - DW Near Ptr EmptyObject - DW Near Ptr EmptyObject - DW Near Ptr EmptyObject - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW Near Ptr CS4237SRSCenter ; 18 - DW Near Ptr CS4237SRSSpace ; 19 - DW Near Ptr CSControlPortText - -ST42A DW Near Ptr SAM9407PortText ; 21 - DW Near Ptr SAM9407ParametersText - DW Near Ptr SAM9407ParametersBox - - DW Near Ptr EqLBL ; 24 - DW Near Ptr EqLBR - DW Near Ptr EqLBF - - DW Near Ptr EqMLBL - DW Near Ptr EqMLBR - DW Near Ptr EqMLBF - - DW Near Ptr EqMHBL - DW Near Ptr EqMHBR - DW Near Ptr EqMHBF - - DW Near Ptr EqHBL - DW Near Ptr EqHBR - DW Near Ptr EqHBF - - DW Near Ptr EchoLevel ; 33 - DW Near Ptr EchoTime - DW Near Ptr EchoFeedback - - DW Near Ptr SurroundVolume - DW Near Ptr SurroundDelay - - DW Near Ptr ReverbSend ; 38 - DW Near Ptr ReverbVolume - DW Near Ptr ReverbType - DW Near Ptr ReverbTime - DW Near Ptr ReverbFeedback - - DW Near Ptr ChorusSend - DW Near Ptr ChorusVolume - DW Near Ptr ChorusType - DW Near Ptr ChorusDelay - DW Near Ptr ChorusFeedback - DW Near Ptr ChorusRate - DW Near Ptr ChorusDepth - - - DW 0 - -WSSHeaderLine DW 10 - DB "Sound Track Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 28, 48 - DB 21h - DB "Sound Track Codec Driver 1.0 for Impulse Tracker", 0 - -CSControlPortText DW 1 - DB 28, 47 - DB 21h - DB "Sound Track CS4237 Control Port ", 0FDh, "Xh", 0 -CS4237Port DW 0 - -SAM9407PortText DW 1 - DB 28, 46 - DB 21h - DB "Sound Track SAM9407 Port ", 0FDh, "Xh", 0 -SAM9407Port DW 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB "CS4237 SRS Center", 13 - DB "CS4237 SRS Space" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 18 - DB 25 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 18, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -CS4237SRSCenter DW 14 - DB 22, 16 - DW 0, 15 - DW 9, 31 - DW 17, 19, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -CS4237SRSSpace DW 14 - DB 22, 17 - DW 0, 15 - DW 9, 32 - DW 18, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MixModeText DW 1 - DB 2, 19 - DB 20h - DB "Mixing Rate: ", 0FDh, "D", 0 -MixSpeed DW 48000 - DW 0 - -MixModeButton1 DW 2 - DW 19, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 21, 32, 23, 8 - DB 0 - DB " MMX, Non-interpolated", 0 - -MixModeButton2 DW 2 - DW 6 - DW 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 24, 32, 26, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 27, 32, 29, 8 - DB 0 - DB " MMX, Volume Ramp", 0 - -MixModeButton4 DW 2 - DW 8 -ST42B DW 24, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 30, 32, 32, 8 - DB 0 - DB " MMX, Filtered", 0 - -SAM9407ParametersText DW 1 - DB 36, 14 - DB 20h - DB "Low Band Left", 13 - DB "Low Band Right", 13 - DB "Low Band Frequency", 13 - DB "Med Low Band Left", 13 - DB "Med Low Band Right", 13 - DB "Med Low Band Frequency", 13 - DB "Med High Band Left", 13 - DB "Med High Band Right", 13 - DB "Med High Band Frequency", 13 - DB "High Band Left", 13 - DB "High Band Right", 13 - DB "High Band Frequency", 13 - DB "Echo Level", 13 - DB "Echo Time", 13 - DB "Echo Feedback", 13 - DB "Surround Volume", 13 - DB "Surround Delay", 13 - DB "Reverb Send", 13 - DB "Reverb Volume", 13 - DB "Reverb Type", 13 - DB "Reverb Time", 13 - DB "Reverb Feedback", 13 - DB "Chorus Send", 13 - DB "Chorus Volume", 13 - DB "Chorus Type", 13 - DB "Chorus Delay", 13 - DB "Chorus Feedback", 13 - DB "Chorus Rate", 13 - DB "Chorus Depth", 13 - DB 0 - -EqLBL DW 14 - DB 60, 14 - DW 0, 127 - DW 9, 2 - DW 9, 25, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBR DW 14 - DB 60, 15 - DW 0, 127 - DW 9, 3 - DW 24, 26, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBF DW 14 - DB 60, 16 - DW 0, 127 - DW 9, 4 - DW 25, 27, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBL DW 14 - DB 60, 17 - DW 0, 127 - DW 9, 5 - DW 26, 28, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBR DW 14 - DB 60, 18 - DW 0, 127 - DW 9, 6 - DW 27, 29, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBF DW 14 - DB 60, 19 - DW 0, 127 - DW 9, 7 - DW 28, 30, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBL DW 14 - DB 60, 20 - DW 0, 127 - DW 9, 8 - DW 29, 31, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBR DW 14 - DB 60, 21 - DW 0, 127 - DW 9, 9 - DW 30, 32, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBF DW 14 - DB 60, 22 - DW 0, 127 - DW 9, 10 - DW 31, 33, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBL DW 14 - DB 60, 23 - DW 0, 127 - DW 9, 11 - DW 32, 34, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBR DW 14 - DB 60, 24 - DW 0, 127 - DW 9, 12 - DW 33, 35, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBF DW 14 - DB 60, 25 - DW 0, 127 - DW 9, 13 - DW 34, 36, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoLevel DW 14 - DB 60, 26 - DW 0, 127 - DW 9, 15 - DW 35, 37, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoTime DW 14 - DB 60, 27 - DW 0, 127 - DW 9, 14 - DW 36, 38, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoFeedback DW 14 - DB 60, 28 - DW 0, 127 - DW 9, 16 - DW 37, 39, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundVolume DW 14 - DB 60, 29 - DW 0, 255 - DW 9, 17 - DW 38, 40, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundDelay DW 14 - DB 60, 30 - DW 0, 127 - DW 9, 18 - DW 39, 41, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbSend DW 14 - DB 60, 31 - DW 0, 127 - DW 9, 19 - DW 40, 42, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbVolume DW 14 - DB 60, 32 - DW 0, 255 - DW 9, 20 - DW 41, 43, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - - -ReverbType DW 14 - DB 60, 33 - DW 0, 7 - DW 9, 21 - DW 42, 44, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbTime DW 14 - DB 60, 34 - DW 0, 127 - DW 9, 22 - DW 43, 45, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbFeedback DW 14 - DB 60, 35 - DW 0, 127 - DW 9, 23 - DW 44, 46, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusSend DW 14 - DB 60, 36 - DW 0, 127 - DW 9, 24 - DW 45, 47, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusVolume DW 14 - DB 60, 37 - DW 0, 255 - DW 9, 25 - DW 46, 48, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusType DW 14 - DB 60, 38 - DW 0, 7 - DW 9, 26 - DW 47, 49, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDelay DW 14 - DB 60, 39 - DW 0, 127 - DW 9, 27 - DW 48, 50, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusFeedback DW 14 - DB 60, 40 - DW 0, 127 - DW 9, 28 - DW 49, 51, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusRate DW 14 - DB 60, 41 - DW 0, 127 - DW 9, 29 - DW 50, 52, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDepth DW 14 - DB 60, 42 - DW 0, 127 - DW 9, 30 - DW 51, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SAM9407ParametersBox DW 0 - DB 59, 13, 75, 43 - DB 25 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -include dmasirq.inc -include mix.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InByte ; Returns AL - - Push DX - Mov DX, CS:SAM9407Port - Inc DX - -SAM9407InByte1: - In AL, DX - Test AL, AL - JS SAM9407InByte1 - - Dec DX - In AL, DX - Pop DX - - Ret - -EndP SAM9407InByte - -; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendByte ; DX = port, AL = data - - Push AX - Push DX - Mov DX, CS:SAM9407Port - Inc DX - -SAM9407SendByte1: - In AL, DX - Test AL, 40h - JNZ SAM9407SendByte1 - - Pop DX - Pop AX - - Out DX, AL - - Ret - -EndP SAM9407SendByte - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSAM9407 ; DI = index. 1 = full reinit. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - LEA SI, [SAM9407Strings+EDI+EDI-2] - Mov SI, [SI] - - LodsW - Mov CX, AX - -SetSAM9407_1: -; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. - - Mov DX, SAM9407Port - Test DX, DX - JZ NoSAM9407 - - LodsW - - Cmp AH, 2 - JB SetSAM9407_3 - JA SetSAM9407_4 - - Mov AL, [VolumeTable+DI] - Jmp SetSAM9407_2 - -SetSAM9407_4: - Call SAM9407InByte - Test AL, AL - JNZ SetSAM9407_4 - Jmp SetSAM9407_5 - -SetSAM9407_3: - And AH, 1 - Add DL, AH - -SetSAM9407_2: - Call SAM9407SendByte - -SetSAM9407_5: - Dec CX - JNZ SetSAM9407_1 - - -NoSAM9407: - Pop DS - PopA - - Ret - -EndP SetSAM9407 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 16 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Mov AX, BX - Mov BX, 12000 - Xor DX, DX - Div BX - Mov FourierBufferStepOffset, AX - Mov FourierBufferStepFractional, DX - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Add DX, 6 - - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - - DB 85h - -PingWSSFailure: - StC - Pop DX - - Ret - - -EndP PingWSS - -include nodebug.inc - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMMX - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectMMXFail - - Mov EAX, 1 - DB 0Fh, 0A2h ; CPUID - Test EDX, 800000h - JZ DetectMMXFail - - Trace "MMX Detected" - - DB 85h - -DetectMMXFail: - StC - Ret - -EndP DetectMMX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 007h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov AX, 207h ; CS4237 - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Test AX, AX - JZ PnP_IsolateNextCard - - Mov CS4237Port, AX - - Mov AX, 407h ; SAM9407 - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Test AX, AX - JZ PnP_NoSAM9407 - - Mov SAM9407Port, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -Pnp_NoSAM9407: - Xor AX, AX - Mov SAM9407Port, AX - Mov ST42A, AX - Dec AX - Mov ST42B, AX - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Call DetectMMX - JC DetectWSSFailure - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov DX, BasePort - JNC BasePortNotSpecified -; JNC DetectWSSOK - -DetectPCI: -; Cmp DMA, 0FFFFh -; JNE DMAOverride - - Mov DMA, 1 ; Force DMA to 1. - -DMAOverride: - Mov EBX, 80000000h ; PCI output value. - Mov DX, 0CF8h - Mov CX, 32 - -DetectCardPCIBasePort1: - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - Sub DX, 4 - Add EBX, 1 SHL 11 - - Cmp EAX, 8128Eh - LoopNE DetectCardPCIBasePort1 - - JNE DetectWSSFailure - - Add EBX, (3Ch) - (1 SHL 11) - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX ; AL = IRQ - Mov ECX, EAX - And AX, 0FFh - - JZ DetectWSSFailure - Cmp AL, 15 - JA DetectWSSFailure - - Cmp IRQ, 0FFFFh - JNE IRQSpecified - - Mov IRQ, AX - -IRQSpecified: - Sub DX, 4 - -; Get SAM9407IRQ - Add EBX, 1 SHL 8 - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - Sub DX, 4 ; AL = IRQ. - - And AX, 0FFh - - PushA - - JZ NoSAM9407IRQ - Cmp AL, 15 - JA NoSAM9407IRQ - - Mov DL, AL - ShL DL, 4 - Mov CL, AL - And DX, 80h - Mov CH, 1 - Or DL, 21h - And CL, 7 - ShL CH, CL - In AL, DX - Or AL, CH - Out DX, AL - -NoSAM9407IRQ: - PopA - Push AX - - Add EBX, 10h-3Ch ; SAM9407 port - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - Sub DX, 4 - And AX, 0FFEh - Mov SAM9407Port, AX - Pop CX - -; If SAM9407 Port not available, or IRQ = old IRQ, then set to ST42 mode. - Test AX, AX - JZ ST42Found - Cmp AX, 400h - JA ST42Found - Cmp CX, IRQ - JNE NoST42 - -ST42Found: -; Mov AX, '24' -; Mov Word Ptr O97A, AX -; Mov Word Ptr O97B, AX -; Mov Word Ptr O97C, AX -; Mov Word Ptr O97D, AX -; Mov Word Ptr O97E, AX -; Mov Word Ptr O97F, AX - Xor AX, AX - Mov SAM9407Port, AX - Mov ST42A, AX - Dec AX - Mov ST42B, AX - -NoST42: - Add EBX, 3 SHL 8 - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - Sub DX, 4 - And AX, 0FFEh - Cmp AX, 400h - JB NoCS - - Xor AX, AX - -NoCS: - Mov CS4237Port, AX - - Sub EBX, 4 SHL 8 - -; Add EBX, 10h - 3Ch -; Add EBX, (10h) - (1 SHL 11) - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - - And AX, 0FFEh - Mov DX, AX - - Cmp BasePort, 0FFFFh - JE BasePortNotSpecified - - Mov DX, BasePort - -BasePortnotSpecified: - Call PingWSS - JNC DetectWSSOK - - Sub DX, 4 - Call PingWSS - JNC DetectWSSOK - -DetectWSSFailure: - StC - Ret - -DetectWSSOK: - Mov BasePort, DX - -CheckWSSOK: ; Check for IRQ - Add DX, 4 - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov DX, CS4237Port - Test DX, DX - JZ DetectNoCS4237Port - - Add DX, 3 - - Mov AL, 3 - Out DX, AL - Inc DX - Mov AL, 0A0h - Out DX, AL - Dec DX ; Enable 3D stuff - - Mov AL, 2 - Out DX, AL - Inc DX - In AL, DX - Out DX, AL - Not AL - Mov AH, AL - And AL, 0Fh - ShR AH, 4 - - Mov [Word Ptr VolumeTable+31], AX - -DetectNoCS4237Port: - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc -include fourier.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - FNSave [FPSave] - - Mov DX, [BasePort] - Add DX, 6 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - CLD - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - Call UpdateFourierBuffer - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - -include mmxtrans.inc - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - FNRstor [CS:FPSave] - - Pop ES - Pop DS - PopAD - IRet - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, MixSegment - Mov AX, 80 - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Add DX, 4 - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 5 + (DMABUFFERLENGTH*2)/16 + FOURIERBUFFERLENGTH/8 - Mov BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Sub AX, FOURIERBUFFERLENGTH/8 - Mov FourierSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov DI, 1 - Call SetSAM9407 - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetUART - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetUART - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Push AX - - Call ResetUART - Call StopWSS - Call StartWSS - - Pop DI - And DI, 1 - Add DI, 31 - Call SetSAM9407 - - Mov DI, 2 -SetStereo2: - Call SetSAM9407 - Inc DI - Cmp DI, 30 - JBE SetStereo2 - -SetStereo1: - Call InitUART - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - - Mov DX, CS4237Port - Test DX, DX - JZ UpdateSoundCardVariables1 - - Add DX, 3 - - Mov AL, 3 - Out DX, AL - Inc DX - Mov AL, 0A0h - Out DX, AL - Dec DX - - Mov AL, 2 - Out DX, AL - - Mov AX, [Word Ptr VolumeTable+31] - ShL AH, 4 - Inc DX - Or AL, AH - Not AL - Out DX, AL - -UpdateSoundCardVariables1: - - Pop DS - PopA - - Ret - -EndP UpdateSoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Mov [CS:VolumeTable+DI], AL - Cmp DI, 31 - JAE SetVariable1 - Cmp DI, 2 - JB SetVariable1 - - Call SetSAM9407 - Ret - -SetVariable1: - Call UpdateSoundcardVariables - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetUART - - Mov DX, CS:SAM9407Port - Test DX, DX - JZ ResetUART1 - - Inc DX - - Mov AL, 0FFh - Out DX, AL - -ResetUART1: - Ret - -EndP ResetUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitUART - - ClI - - Mov DX, CS:SAM9407Port - Inc DX - Mov AL, 0FFh ; reset - Out DX, AL - - Xor CX, CX - -DetectUARTPause: - In AL, 21h - In AL, 0A1h - Loop DetectUARTPause - - Mov AL, 0FFh - Out DX, AL - - Xor CX, CX - -DetectUART1: - In AL, DX - Test AL, 80h - LoopNZ DetectUART1 - JNZ DetectUARTFailed - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JNE DetectUART1 - - Xor CX, CX - -DetectUART3: - In AL, DX - Test AL, 40h - LoopNZ DetectUART3 - JNZ DetectUARTFailed - - Mov AL, 03Fh - Out DX, AL - - Xor CX, CX - -DetectUART2: - In AL, DX - Test AL, 80h - LoopNZ DetectUART2 - JNZ DetectUARTFailed - - Dec DX - In AL, DX - Inc DX - Cmp AL, 0FEh - JNE DetectUART2 - Dec DX - - Mov AL, 0FFh - Out DX, AL - - DB 85h -DetectUARTFailed: - StC - StI - Ret - -EndP InitUART - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UARTOut - - Push CX - Push DX - Mov DX, CS:SAM9407Port - - Push AX - Xor CX, CX - Inc DX - -UARTOut1: - In AL, DX - Test AL, 40h - LoopNZ UARTOut1 - - Pop AX - JNZ UARTOutEnd - - Dec DX - Out DX, AL - -UARTOutEnd: - Pop DX - Pop CX - - Ret - -EndP UARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h - Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: - Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWaveForm Far ; Given ES:DI = destination - Assume DS:Nothing ; want 2048 samples. - - PushA - Push DS - - Mov DS, FourierSegment - Mov SI, FourierBufferStart - Mov CX, 2048 - -GetWaveForm1: - MovsW - And SI, (FOURIERBUFFERLENGTH*2)-1 - Dec CX - JNZ GetWaveForm1 - - Pop DS - PopA - - Ret - -EndP GetWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 128 -DriverFlags DW 7 - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - - DW Offset SendUARTOut - DW Offset GetWaveForm - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ST 97/42 PCI Codec, using MMX. +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing +OUTPUTFILTERENABLED EQU 0 +DATAFLAG EQU 200h +ACKFLAG EQU 300h +FOURIERBUFFERLENGTH EQU 2048 ; 2048 samples + +PNPVENDORID EQU 3746630Eh + +FPSave DB 128 Dup (0) + +DMASize DW DMABUFFERLENGTH / 2 + +WSSMsg DB "Sound Track Codec MMX", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Sound Track Codec MMX", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Track Codec reinitialised", 0 + +DriverName DB "ITSTCODE.MMX", 0 + +Forced DB 0 +Stereo DB 0 +WSSMixConst DB 0 + +ALIGN 2 + +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 +FourierSegment DW 0 + +; Arrangement of data: +; First 64 bytes = MMX temporary area +; Next 2*DMABUFFERLENGTH = DMA area +; After that is mixing buffer. + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 35 +MixMode DW 0 +MixModeOffset DW 0 +VolumeTable DB 56, 56 + DB 60h, 60h, 0Ch ; Low Band + DB 40h, 40h, 1Bh ; Med Low Band + DB 40h, 40h, 72h ; Med High Band + DB 60h, 60h, 40h ; High Band + DB 0, 0, 0 ; Echo + DB 0, 2 ; Surround + DB 0, 90h, 4, 7Fh, 22h ; Reverb + DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus + DB 0, 0 ; SRS stuff. + +ALIGN 2 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +SAM9407Reset DW 66 + DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on + DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on + DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on + DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on + DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type + DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on + DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in + DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus + DW 1BEh, 133h, 0, 0 ; 2 Speaker + DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 + DW 1BEh, 134h, 0FFh, 0FFh ; Left gain + DW 1BEh, 135h, 0FFh, 0FFh ; Right gain + DW 1BEh, 136h, 0, 0 ; Left pan + DW 1BEh, 137h, 7Fh, 7Fh ; Right pan + DW 1BEh, 107h, 0FFh, 0FFh ; Master volume + +SAM9407EqLBL DW 4 + DW 1BEh, 110h, DATAFLAG, 60h +SAM9407EqLBR DW 4 + DW 1BEh, 114h, DATAFLAG, 60h +SAM9407EqLBF DW 4 + DW 1BEh, 118h, DATAFLAG, 0Ch +SAM9407EqMLBL DW 4 + DW 1BEh, 111h, DATAFLAG, 40h +SAM9407EqMLBR DW 4 + DW 1BEh, 115h, DATAFLAG, 40h +SAM9407EqMLBF DW 4 + DW 1BEh, 119h, DATAFLAG, 1Bh +SAM9407EqMHBL DW 4 + DW 1BEh, 112h, DATAFLAG, 40h +SAM9407EqMHBR DW 4 + DW 1BEh, 116h, DATAFLAG, 40h +SAM9407EqMHBF DW 4 + DW 1BEh, 11Ah, DATAFLAG, 72h +SAM9407EqHBL DW 4 + DW 1BEh, 113h, DATAFLAG, 60h +SAM9407EqHBR DW 4 + DW 1BEh, 117h, DATAFLAG, 60h +SAM9407EqHBF DW 4 + DW 1BEh, 11Bh, DATAFLAG, 0Ch +SAM9407EchoLevel DW 4 + DW 1BEh, 128h, DATAFLAG, 0 +SAM9407EchoTime DW 4 + DW 1BEh, 129h, DATAFLAG, 2Bh +SAM9407EchoFeed DW 4 + DW 1BEh, 12Ah, DATAFLAG, 40h +SAM9407SurroundVolume DW 4 + DW 1BEh, 130h, DATAFLAG, 0 +SAM9407SurroundDelay DW 4 + DW 1BEh, 131h, DATAFLAG, 2 +SAM9407ReverbSend DW 4 + DW 1BEh, 127h, DATAFLAG, 0 +SAM9407ReverbVolume DW 3 + DW 1BEh, 13Ah, DATAFLAG +SAM9407ReverbType DW 4 + DW 1BEh, 169h, DATAFLAG, 4 +SAM9407ReverbTime DW 3 + DW 1BEh, 178h, DATAFLAG +SAM9407ReverbFeedback DW 3 + DW 1BEh, 179h, DATAFLAG +SAM9407ChorusSend DW 4 + DW 1BEh, 124h, DATAFLAG, 0 +SAM9407ChorusVolume DW 3 + DW 1BEh, 13Bh, DATAFLAG +SAM9407ChorusType DW 4 + DW 1BEh, 16Ah, DATAFLAG, 2 +SAM9407ChorusDelay DW 3 + DW 1BEh, 174h, DATAFLAG +SAM9407ChorusFeedback DW 3 + DW 1BEh, 175h, DATAFLAG +SAM9407ChorusRate DW 3 + DW 1BEh, 176h, DATAFLAG +SAM9407ChorusDepth DW 3 + DW 1BEh, 177h, DATAFLAG +SAM9407Mono DW 4 + DW 1BEh, 132h, 7Fh, 0 +SAM9407Stereo DW 4 + DW 1BEh, 132h, 0, 0 + +SAM9407Strings DW Offset SAM9407Reset ;1 + DW Offset SAM9407EqLBL, Offset SAM9407EqLBR + DW Offset SAM9407EqLBF + DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR + DW Offset SAM9407EqMLBF + DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR + DW Offset SAM9407EqMHBF + DW Offset SAM9407EqHBL, Offset SAM9407EqHBR + DW Offset SAM9407EqHBF + DW Offset SAM9407EchoLevel ; 14 + DW Offset SAM9407EchoTime + DW Offset SAM9407EchoFeed + DW Offset SAM9407SurroundVolume ; 17 + DW Offset SAM9407SurroundDelay + DW Offset SAM9407ReverbSend ; 19 + DW Offset SAM9407ReverbVolume + DW Offset SAM9407ReverbType + DW Offset SAM9407ReverbTime + DW Offset SAM9407ReverbFeedback ; 23 + DW Offset SAM9407ChorusSend ; 24 + DW Offset SAM9407ChorusVolume + DW Offset SAM9407ChorusType + DW Offset SAM9407ChorusDelay + DW Offset SAM9407ChorusFeedback + DW Offset SAM9407ChorusRate + DW Offset SAM9407ChorusDepth ; 30 + DW Offset SAM9407Mono ; 31 + DW Offset SAM9407Stereo + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; + DW Near Ptr MixModeButton4 ; + + DW Near Ptr EmptyObject + DW Near Ptr EmptyObject + DW Near Ptr EmptyObject + DW Near Ptr EmptyObject + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW Near Ptr CS4237SRSCenter ; 18 + DW Near Ptr CS4237SRSSpace ; 19 + DW Near Ptr CSControlPortText + +ST42A DW Near Ptr SAM9407PortText ; 21 + DW Near Ptr SAM9407ParametersText + DW Near Ptr SAM9407ParametersBox + + DW Near Ptr EqLBL ; 24 + DW Near Ptr EqLBR + DW Near Ptr EqLBF + + DW Near Ptr EqMLBL + DW Near Ptr EqMLBR + DW Near Ptr EqMLBF + + DW Near Ptr EqMHBL + DW Near Ptr EqMHBR + DW Near Ptr EqMHBF + + DW Near Ptr EqHBL + DW Near Ptr EqHBR + DW Near Ptr EqHBF + + DW Near Ptr EchoLevel ; 33 + DW Near Ptr EchoTime + DW Near Ptr EchoFeedback + + DW Near Ptr SurroundVolume + DW Near Ptr SurroundDelay + + DW Near Ptr ReverbSend ; 38 + DW Near Ptr ReverbVolume + DW Near Ptr ReverbType + DW Near Ptr ReverbTime + DW Near Ptr ReverbFeedback + + DW Near Ptr ChorusSend + DW Near Ptr ChorusVolume + DW Near Ptr ChorusType + DW Near Ptr ChorusDelay + DW Near Ptr ChorusFeedback + DW Near Ptr ChorusRate + DW Near Ptr ChorusDepth + + + DW 0 + +WSSHeaderLine DW 10 + DB "Sound Track Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 28, 48 + DB 21h + DB "Sound Track Codec Driver 1.0 for Impulse Tracker", 0 + +CSControlPortText DW 1 + DB 28, 47 + DB 21h + DB "Sound Track CS4237 Control Port ", 0FDh, "Xh", 0 +CS4237Port DW 0 + +SAM9407PortText DW 1 + DB 28, 46 + DB 21h + DB "Sound Track SAM9407 Port ", 0FDh, "Xh", 0 +SAM9407Port DW 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB "CS4237 SRS Center", 13 + DB "CS4237 SRS Space" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 18 + DB 25 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 18, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +CS4237SRSCenter DW 14 + DB 22, 16 + DW 0, 15 + DW 9, 31 + DW 17, 19, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +CS4237SRSSpace DW 14 + DB 22, 17 + DW 0, 15 + DW 9, 32 + DW 18, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MixModeText DW 1 + DB 2, 19 + DB 20h + DB "Mixing Rate: ", 0FDh, "D", 0 +MixSpeed DW 48000 + DW 0 + +MixModeButton1 DW 2 + DW 19, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 21, 32, 23, 8 + DB 0 + DB " MMX, Non-interpolated", 0 + +MixModeButton2 DW 2 + DW 6 + DW 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 24, 32, 26, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 27, 32, 29, 8 + DB 0 + DB " MMX, Volume Ramp", 0 + +MixModeButton4 DW 2 + DW 8 +ST42B DW 24, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 30, 32, 32, 8 + DB 0 + DB " MMX, Filtered", 0 + +SAM9407ParametersText DW 1 + DB 36, 14 + DB 20h + DB "Low Band Left", 13 + DB "Low Band Right", 13 + DB "Low Band Frequency", 13 + DB "Med Low Band Left", 13 + DB "Med Low Band Right", 13 + DB "Med Low Band Frequency", 13 + DB "Med High Band Left", 13 + DB "Med High Band Right", 13 + DB "Med High Band Frequency", 13 + DB "High Band Left", 13 + DB "High Band Right", 13 + DB "High Band Frequency", 13 + DB "Echo Level", 13 + DB "Echo Time", 13 + DB "Echo Feedback", 13 + DB "Surround Volume", 13 + DB "Surround Delay", 13 + DB "Reverb Send", 13 + DB "Reverb Volume", 13 + DB "Reverb Type", 13 + DB "Reverb Time", 13 + DB "Reverb Feedback", 13 + DB "Chorus Send", 13 + DB "Chorus Volume", 13 + DB "Chorus Type", 13 + DB "Chorus Delay", 13 + DB "Chorus Feedback", 13 + DB "Chorus Rate", 13 + DB "Chorus Depth", 13 + DB 0 + +EqLBL DW 14 + DB 60, 14 + DW 0, 127 + DW 9, 2 + DW 9, 25, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBR DW 14 + DB 60, 15 + DW 0, 127 + DW 9, 3 + DW 24, 26, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBF DW 14 + DB 60, 16 + DW 0, 127 + DW 9, 4 + DW 25, 27, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBL DW 14 + DB 60, 17 + DW 0, 127 + DW 9, 5 + DW 26, 28, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBR DW 14 + DB 60, 18 + DW 0, 127 + DW 9, 6 + DW 27, 29, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBF DW 14 + DB 60, 19 + DW 0, 127 + DW 9, 7 + DW 28, 30, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBL DW 14 + DB 60, 20 + DW 0, 127 + DW 9, 8 + DW 29, 31, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBR DW 14 + DB 60, 21 + DW 0, 127 + DW 9, 9 + DW 30, 32, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBF DW 14 + DB 60, 22 + DW 0, 127 + DW 9, 10 + DW 31, 33, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBL DW 14 + DB 60, 23 + DW 0, 127 + DW 9, 11 + DW 32, 34, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBR DW 14 + DB 60, 24 + DW 0, 127 + DW 9, 12 + DW 33, 35, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBF DW 14 + DB 60, 25 + DW 0, 127 + DW 9, 13 + DW 34, 36, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoLevel DW 14 + DB 60, 26 + DW 0, 127 + DW 9, 15 + DW 35, 37, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoTime DW 14 + DB 60, 27 + DW 0, 127 + DW 9, 14 + DW 36, 38, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoFeedback DW 14 + DB 60, 28 + DW 0, 127 + DW 9, 16 + DW 37, 39, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundVolume DW 14 + DB 60, 29 + DW 0, 255 + DW 9, 17 + DW 38, 40, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundDelay DW 14 + DB 60, 30 + DW 0, 127 + DW 9, 18 + DW 39, 41, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbSend DW 14 + DB 60, 31 + DW 0, 127 + DW 9, 19 + DW 40, 42, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbVolume DW 14 + DB 60, 32 + DW 0, 255 + DW 9, 20 + DW 41, 43, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + + +ReverbType DW 14 + DB 60, 33 + DW 0, 7 + DW 9, 21 + DW 42, 44, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbTime DW 14 + DB 60, 34 + DW 0, 127 + DW 9, 22 + DW 43, 45, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbFeedback DW 14 + DB 60, 35 + DW 0, 127 + DW 9, 23 + DW 44, 46, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusSend DW 14 + DB 60, 36 + DW 0, 127 + DW 9, 24 + DW 45, 47, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusVolume DW 14 + DB 60, 37 + DW 0, 255 + DW 9, 25 + DW 46, 48, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusType DW 14 + DB 60, 38 + DW 0, 7 + DW 9, 26 + DW 47, 49, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDelay DW 14 + DB 60, 39 + DW 0, 127 + DW 9, 27 + DW 48, 50, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusFeedback DW 14 + DB 60, 40 + DW 0, 127 + DW 9, 28 + DW 49, 51, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusRate DW 14 + DB 60, 41 + DW 0, 127 + DW 9, 29 + DW 50, 52, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDepth DW 14 + DB 60, 42 + DW 0, 127 + DW 9, 30 + DW 51, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SAM9407ParametersBox DW 0 + DB 59, 13, 75, 43 + DB 25 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +include dmasirq.inc +include mix.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InByte ; Returns AL + + Push DX + Mov DX, CS:SAM9407Port + Inc DX + +SAM9407InByte1: + In AL, DX + Test AL, AL + JS SAM9407InByte1 + + Dec DX + In AL, DX + Pop DX + + Ret + +EndP SAM9407InByte + +; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendByte ; DX = port, AL = data + + Push AX + Push DX + Mov DX, CS:SAM9407Port + Inc DX + +SAM9407SendByte1: + In AL, DX + Test AL, 40h + JNZ SAM9407SendByte1 + + Pop DX + Pop AX + + Out DX, AL + + Ret + +EndP SAM9407SendByte + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSAM9407 ; DI = index. 1 = full reinit. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + LEA SI, [SAM9407Strings+EDI+EDI-2] + Mov SI, [SI] + + LodsW + Mov CX, AX + +SetSAM9407_1: +; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. + + Mov DX, SAM9407Port + Test DX, DX + JZ NoSAM9407 + + LodsW + + Cmp AH, 2 + JB SetSAM9407_3 + JA SetSAM9407_4 + + Mov AL, [VolumeTable+DI] + Jmp SetSAM9407_2 + +SetSAM9407_4: + Call SAM9407InByte + Test AL, AL + JNZ SetSAM9407_4 + Jmp SetSAM9407_5 + +SetSAM9407_3: + And AH, 1 + Add DL, AH + +SetSAM9407_2: + Call SAM9407SendByte + +SetSAM9407_5: + Dec CX + JNZ SetSAM9407_1 + + +NoSAM9407: + Pop DS + PopA + + Ret + +EndP SetSAM9407 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 16 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Mov AX, BX + Mov BX, 12000 + Xor DX, DX + Div BX + Mov FourierBufferStepOffset, AX + Mov FourierBufferStepFractional, DX + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Add DX, 6 + + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + + DB 85h + +PingWSSFailure: + StC + Pop DX + + Ret + + +EndP PingWSS + +include nodebug.inc + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMMX + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectMMXFail + + Mov EAX, 1 + DB 0Fh, 0A2h ; CPUID + Test EDX, 800000h + JZ DetectMMXFail + + Trace "MMX Detected" + + DB 85h + +DetectMMXFail: + StC + Ret + +EndP DetectMMX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 007h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov AX, 207h ; CS4237 + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Test AX, AX + JZ PnP_IsolateNextCard + + Mov CS4237Port, AX + + Mov AX, 407h ; SAM9407 + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Test AX, AX + JZ PnP_NoSAM9407 + + Mov SAM9407Port, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +Pnp_NoSAM9407: + Xor AX, AX + Mov SAM9407Port, AX + Mov ST42A, AX + Dec AX + Mov ST42B, AX + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Call DetectMMX + JC DetectWSSFailure + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov DX, BasePort + JNC BasePortNotSpecified +; JNC DetectWSSOK + +DetectPCI: +; Cmp DMA, 0FFFFh +; JNE DMAOverride + + Mov DMA, 1 ; Force DMA to 1. + +DMAOverride: + Mov EBX, 80000000h ; PCI output value. + Mov DX, 0CF8h + Mov CX, 32 + +DetectCardPCIBasePort1: + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + Sub DX, 4 + Add EBX, 1 SHL 11 + + Cmp EAX, 8128Eh + LoopNE DetectCardPCIBasePort1 + + JNE DetectWSSFailure + + Add EBX, (3Ch) - (1 SHL 11) + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX ; AL = IRQ + Mov ECX, EAX + And AX, 0FFh + + JZ DetectWSSFailure + Cmp AL, 15 + JA DetectWSSFailure + + Cmp IRQ, 0FFFFh + JNE IRQSpecified + + Mov IRQ, AX + +IRQSpecified: + Sub DX, 4 + +; Get SAM9407IRQ + Add EBX, 1 SHL 8 + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + Sub DX, 4 ; AL = IRQ. + + And AX, 0FFh + + PushA + + JZ NoSAM9407IRQ + Cmp AL, 15 + JA NoSAM9407IRQ + + Mov DL, AL + ShL DL, 4 + Mov CL, AL + And DX, 80h + Mov CH, 1 + Or DL, 21h + And CL, 7 + ShL CH, CL + In AL, DX + Or AL, CH + Out DX, AL + +NoSAM9407IRQ: + PopA + Push AX + + Add EBX, 10h-3Ch ; SAM9407 port + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + Sub DX, 4 + And AX, 0FFEh + Mov SAM9407Port, AX + Pop CX + +; If SAM9407 Port not available, or IRQ = old IRQ, then set to ST42 mode. + Test AX, AX + JZ ST42Found + Cmp AX, 400h + JA ST42Found + Cmp CX, IRQ + JNE NoST42 + +ST42Found: +; Mov AX, '24' +; Mov Word Ptr O97A, AX +; Mov Word Ptr O97B, AX +; Mov Word Ptr O97C, AX +; Mov Word Ptr O97D, AX +; Mov Word Ptr O97E, AX +; Mov Word Ptr O97F, AX + Xor AX, AX + Mov SAM9407Port, AX + Mov ST42A, AX + Dec AX + Mov ST42B, AX + +NoST42: + Add EBX, 3 SHL 8 + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + Sub DX, 4 + And AX, 0FFEh + Cmp AX, 400h + JB NoCS + + Xor AX, AX + +NoCS: + Mov CS4237Port, AX + + Sub EBX, 4 SHL 8 + +; Add EBX, 10h - 3Ch +; Add EBX, (10h) - (1 SHL 11) + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + + And AX, 0FFEh + Mov DX, AX + + Cmp BasePort, 0FFFFh + JE BasePortNotSpecified + + Mov DX, BasePort + +BasePortnotSpecified: + Call PingWSS + JNC DetectWSSOK + + Sub DX, 4 + Call PingWSS + JNC DetectWSSOK + +DetectWSSFailure: + StC + Ret + +DetectWSSOK: + Mov BasePort, DX + +CheckWSSOK: ; Check for IRQ + Add DX, 4 + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov DX, CS4237Port + Test DX, DX + JZ DetectNoCS4237Port + + Add DX, 3 + + Mov AL, 3 + Out DX, AL + Inc DX + Mov AL, 0A0h + Out DX, AL + Dec DX ; Enable 3D stuff + + Mov AL, 2 + Out DX, AL + Inc DX + In AL, DX + Out DX, AL + Not AL + Mov AH, AL + And AL, 0Fh + ShR AH, 4 + + Mov [Word Ptr VolumeTable+31], AX + +DetectNoCS4237Port: + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc +include fourier.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + FNSave [FPSave] + + Mov DX, [BasePort] + Add DX, 6 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + CLD + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + Call UpdateFourierBuffer + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + +include mmxtrans.inc + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + FNRstor [CS:FPSave] + + Pop ES + Pop DS + PopAD + IRet + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, MixSegment + Mov AX, 80 + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Add DX, 4 + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 5 + (DMABUFFERLENGTH*2)/16 + FOURIERBUFFERLENGTH/8 + Mov BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Sub AX, FOURIERBUFFERLENGTH/8 + Mov FourierSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov DI, 1 + Call SetSAM9407 + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetUART + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetUART + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Push AX + + Call ResetUART + Call StopWSS + Call StartWSS + + Pop DI + And DI, 1 + Add DI, 31 + Call SetSAM9407 + + Mov DI, 2 +SetStereo2: + Call SetSAM9407 + Inc DI + Cmp DI, 30 + JBE SetStereo2 + +SetStereo1: + Call InitUART + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + + Mov DX, CS4237Port + Test DX, DX + JZ UpdateSoundCardVariables1 + + Add DX, 3 + + Mov AL, 3 + Out DX, AL + Inc DX + Mov AL, 0A0h + Out DX, AL + Dec DX + + Mov AL, 2 + Out DX, AL + + Mov AX, [Word Ptr VolumeTable+31] + ShL AH, 4 + Inc DX + Or AL, AH + Not AL + Out DX, AL + +UpdateSoundCardVariables1: + + Pop DS + PopA + + Ret + +EndP UpdateSoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Mov [CS:VolumeTable+DI], AL + Cmp DI, 31 + JAE SetVariable1 + Cmp DI, 2 + JB SetVariable1 + + Call SetSAM9407 + Ret + +SetVariable1: + Call UpdateSoundcardVariables + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetUART + + Mov DX, CS:SAM9407Port + Test DX, DX + JZ ResetUART1 + + Inc DX + + Mov AL, 0FFh + Out DX, AL + +ResetUART1: + Ret + +EndP ResetUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitUART + + ClI + + Mov DX, CS:SAM9407Port + Inc DX + Mov AL, 0FFh ; reset + Out DX, AL + + Xor CX, CX + +DetectUARTPause: + In AL, 21h + In AL, 0A1h + Loop DetectUARTPause + + Mov AL, 0FFh + Out DX, AL + + Xor CX, CX + +DetectUART1: + In AL, DX + Test AL, 80h + LoopNZ DetectUART1 + JNZ DetectUARTFailed + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JNE DetectUART1 + + Xor CX, CX + +DetectUART3: + In AL, DX + Test AL, 40h + LoopNZ DetectUART3 + JNZ DetectUARTFailed + + Mov AL, 03Fh + Out DX, AL + + Xor CX, CX + +DetectUART2: + In AL, DX + Test AL, 80h + LoopNZ DetectUART2 + JNZ DetectUARTFailed + + Dec DX + In AL, DX + Inc DX + Cmp AL, 0FEh + JNE DetectUART2 + Dec DX + + Mov AL, 0FFh + Out DX, AL + + DB 85h +DetectUARTFailed: + StC + StI + Ret + +EndP InitUART + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UARTOut + + Push CX + Push DX + Mov DX, CS:SAM9407Port + + Push AX + Xor CX, CX + Inc DX + +UARTOut1: + In AL, DX + Test AL, 40h + LoopNZ UARTOut1 + + Pop AX + JNZ UARTOutEnd + + Dec DX + Out DX, AL + +UARTOutEnd: + Pop DX + Pop CX + + Ret + +EndP UARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h + Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: + Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWaveForm Far ; Given ES:DI = destination + Assume DS:Nothing ; want 2048 samples. + + PushA + Push DS + + Mov DS, FourierSegment + Mov SI, FourierBufferStart + Mov CX, 2048 + +GetWaveForm1: + MovsW + And SI, (FOURIERBUFFERLENGTH*2)-1 + Dec CX + JNZ GetWaveForm1 + + Pop DS + PopA + + Ret + +EndP GetWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 128 +DriverFlags DW 7 + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + + DW Offset SendUARTOut + DW Offset GetWaveForm + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ST97CODE.ASM b/SoundDrivers/ST97CODE.ASM index 7e9d21a..a9e0c06 100755 --- a/SoundDrivers/ST97CODE.ASM +++ b/SoundDrivers/ST97CODE.ASM @@ -1,3171 +1,3171 @@ -; -; ST 97/42 PCI Codec -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc -include mmx.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 -DATAFLAG EQU 200h -ACKFLAG EQU 300h - -PNPVENDORID EQU 3746630Eh - -DMASize DW DMABUFFERLENGTH / 2 - -WSSMsg DB "Sound Track Codec", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Sound Track Codec", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Track Codec reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITSTCODE.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITSTCODE.DRV", 0 - -DriverName DB "ITSTCODE.DRV", 0 - -Forced DB 0 -Stereo DB 0 -WSSMixConst DB 0 - -ALIGN 2 - -MixVolume DW 0 - -BytesToMix DW 1000 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 37 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 -VolumeTable DB 56, 56 - DB 60h, 60h, 0Ch ; Low Band - DB 40h, 40h, 1Bh ; Med Low Band - DB 40h, 40h, 72h ; Med High Band - DB 60h, 60h, 40h ; High Band - DB 0, 0, 0 ; Echo - DB 0, 2 ; Surround - DB 0, 90h, 4, 7Fh, 22h ; Reverb - DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus - DB 0, 0 ; SRS stuff. - -ALIGN 2 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -SAM9407Reset DW 66 - DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on - DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on - DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on - DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on - DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type - DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on - DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in - DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus - DW 1BEh, 133h, 0, 0 ; 2 Speaker - DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 - DW 1BEh, 134h, 0FFh, 0FFh ; Left gain - DW 1BEh, 135h, 0FFh, 0FFh ; Right gain - DW 1BEh, 136h, 0, 0 ; Left pan - DW 1BEh, 137h, 7Fh, 7Fh ; Right pan - DW 1BEh, 107h, 0FFh, 0FFh ; Master volume - -SAM9407EqLBL DW 4 - DW 1BEh, 110h, DATAFLAG, 60h -SAM9407EqLBR DW 4 - DW 1BEh, 114h, DATAFLAG, 60h -SAM9407EqLBF DW 4 - DW 1BEh, 118h, DATAFLAG, 0Ch -SAM9407EqMLBL DW 4 - DW 1BEh, 111h, DATAFLAG, 40h -SAM9407EqMLBR DW 4 - DW 1BEh, 115h, DATAFLAG, 40h -SAM9407EqMLBF DW 4 - DW 1BEh, 119h, DATAFLAG, 1Bh -SAM9407EqMHBL DW 4 - DW 1BEh, 112h, DATAFLAG, 40h -SAM9407EqMHBR DW 4 - DW 1BEh, 116h, DATAFLAG, 40h -SAM9407EqMHBF DW 4 - DW 1BEh, 11Ah, DATAFLAG, 72h -SAM9407EqHBL DW 4 - DW 1BEh, 113h, DATAFLAG, 60h -SAM9407EqHBR DW 4 - DW 1BEh, 117h, DATAFLAG, 60h -SAM9407EqHBF DW 4 - DW 1BEh, 11Bh, DATAFLAG, 0Ch -SAM9407EchoLevel DW 4 - DW 1BEh, 128h, DATAFLAG, 0 -SAM9407EchoTime DW 4 - DW 1BEh, 129h, DATAFLAG, 2Bh -SAM9407EchoFeed DW 4 - DW 1BEh, 12Ah, DATAFLAG, 40h -SAM9407SurroundVolume DW 4 - DW 1BEh, 130h, DATAFLAG, 0 -SAM9407SurroundDelay DW 4 - DW 1BEh, 131h, DATAFLAG, 2 -SAM9407ReverbSend DW 4 - DW 1BEh, 127h, DATAFLAG, 0 -SAM9407ReverbVolume DW 3 - DW 1BEh, 13Ah, DATAFLAG -SAM9407ReverbType DW 4 - DW 1BEh, 169h, DATAFLAG, 4 -SAM9407ReverbTime DW 3 - DW 1BEh, 178h, DATAFLAG -SAM9407ReverbFeedback DW 3 - DW 1BEh, 179h, DATAFLAG -SAM9407ChorusSend DW 4 - DW 1BEh, 124h, DATAFLAG, 0 -SAM9407ChorusVolume DW 3 - DW 1BEh, 13Bh, DATAFLAG -SAM9407ChorusType DW 4 - DW 1BEh, 16Ah, DATAFLAG, 2 -SAM9407ChorusDelay DW 3 - DW 1BEh, 174h, DATAFLAG -SAM9407ChorusFeedback DW 3 - DW 1BEh, 175h, DATAFLAG -SAM9407ChorusRate DW 3 - DW 1BEh, 176h, DATAFLAG -SAM9407ChorusDepth DW 3 - DW 1BEh, 177h, DATAFLAG -SAM9407Mono DW 4 - DW 1BEh, 132h, 7Fh, 0 -SAM9407Stereo DW 4 - DW 1BEh, 132h, 0, 0 - -SAM9407Strings DW Offset SAM9407Reset ;1 - DW Offset SAM9407EqLBL, Offset SAM9407EqLBR - DW Offset SAM9407EqLBF - DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR - DW Offset SAM9407EqMLBF - DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR - DW Offset SAM9407EqMHBF - DW Offset SAM9407EqHBL, Offset SAM9407EqHBR - DW Offset SAM9407EqHBF - DW Offset SAM9407EchoLevel ; 14 - DW Offset SAM9407EchoTime - DW Offset SAM9407EchoFeed - DW Offset SAM9407SurroundVolume ; 17 - DW Offset SAM9407SurroundDelay - DW Offset SAM9407ReverbSend ; 19 - DW Offset SAM9407ReverbVolume - DW Offset SAM9407ReverbType - DW Offset SAM9407ReverbTime - DW Offset SAM9407ReverbFeedback ; 23 - DW Offset SAM9407ChorusSend ; 24 - DW Offset SAM9407ChorusVolume - DW Offset SAM9407ChorusType - DW Offset SAM9407ChorusDelay - DW Offset SAM9407ChorusFeedback - DW Offset SAM9407ChorusRate - DW Offset SAM9407ChorusDepth ; 30 - DW Offset SAM9407Mono ; 31 - DW Offset SAM9407Stereo -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW Near Ptr CS4237SRSCenter ; 18 - DW Near Ptr CS4237SRSSpace ; 19 - DW Near Ptr CSControlPortText - -ST42A DW Near Ptr SAM9407PortText ; 21 - DW Near Ptr SAM9407ParametersText - DW Near Ptr SAM9407ParametersBox - - DW Near Ptr EqLBL ; 24 - DW Near Ptr EqLBR - DW Near Ptr EqLBF - - DW Near Ptr EqMLBL - DW Near Ptr EqMLBR - DW Near Ptr EqMLBF - - DW Near Ptr EqMHBL - DW Near Ptr EqMHBR - DW Near Ptr EqMHBF - - DW Near Ptr EqHBL - DW Near Ptr EqHBR - DW Near Ptr EqHBF - - DW Near Ptr EchoLevel ; 33 - DW Near Ptr EchoTime - DW Near Ptr EchoFeedback - - DW Near Ptr SurroundVolume - DW Near Ptr SurroundDelay - - DW Near Ptr ReverbSend ; 38 - DW Near Ptr ReverbVolume - DW Near Ptr ReverbType - DW Near Ptr ReverbTime - DW Near Ptr ReverbFeedback - - DW Near Ptr ChorusSend - DW Near Ptr ChorusVolume - DW Near Ptr ChorusType - DW Near Ptr ChorusDelay - DW Near Ptr ChorusFeedback - DW Near Ptr ChorusRate - DW Near Ptr ChorusDepth - - - DW 0 - -WSSHeaderLine DW 10 - DB "Sound Track Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 28, 48 - DB 21h - DB "Sound Track Codec Driver 1.0 for Impulse Tracker", 0 - -CSControlPortText DW 1 - DB 28, 47 - DB 21h - DB "Sound Track CS4237 Control Port ", 0FDh, "Xh", 0 -CS4237Port DW 0 - -SAM9407PortText DW 1 - DB 28, 46 - DB 21h - DB "Sound Track SAM9407 Port ", 0FDh, "Xh", 0 -SAM9407Port DW 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 13 - DB "CS4237 SRS Center", 13 - DB "CS4237 SRS Space" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 18 - DB 25 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 18, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -CS4237SRSCenter DW 14 - DB 22, 16 - DW 0, 15 - DW 9, 31 - DW 17, 19, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -CS4237SRSSpace DW 14 - DB 22, 17 - DW 0, 15 - DW 9, 32 - DW 18, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MixModeText DW 1 - DB 2, 19 - DB 20h - DB "Mixing Rate: ", 0FDh, "D, Mode:", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 19, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 21, 32, 23, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 24, 32, 26, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 27, 32, 29, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 30, 32, 32, 8 - DB 0 - DB " 32 Bit, Ultra Quality", 0 - -FilterText DW 1 - DB 2, 34 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 36, 29, 38, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 39, 29, 41, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12 -ST42B DW 24, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 42, 29, 44, 8 - DB 0 - DB " 75% Filter", 0 - -SAM9407ParametersText DW 1 - DB 36, 14 - DB 20h - DB "Low Band Left", 13 - DB "Low Band Right", 13 - DB "Low Band Frequency", 13 - DB "Med Low Band Left", 13 - DB "Med Low Band Right", 13 - DB "Med Low Band Frequency", 13 - DB "Med High Band Left", 13 - DB "Med High Band Right", 13 - DB "Med High Band Frequency", 13 - DB "High Band Left", 13 - DB "High Band Right", 13 - DB "High Band Frequency", 13 - DB "Echo Level", 13 - DB "Echo Time", 13 - DB "Echo Feedback", 13 - DB "Surround Volume", 13 - DB "Surround Delay", 13 - DB "Reverb Send", 13 - DB "Reverb Volume", 13 - DB "Reverb Type", 13 - DB "Reverb Time", 13 - DB "Reverb Feedback", 13 - DB "Chorus Send", 13 - DB "Chorus Volume", 13 - DB "Chorus Type", 13 - DB "Chorus Delay", 13 - DB "Chorus Feedback", 13 - DB "Chorus Rate", 13 - DB "Chorus Depth", 13 - DB 0 - -EqLBL DW 14 - DB 60, 14 - DW 0, 127 - DW 9, 2 - DW 13, 25, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBR DW 14 - DB 60, 15 - DW 0, 127 - DW 9, 3 - DW 24, 26, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBF DW 14 - DB 60, 16 - DW 0, 127 - DW 9, 4 - DW 25, 27, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBL DW 14 - DB 60, 17 - DW 0, 127 - DW 9, 5 - DW 26, 28, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBR DW 14 - DB 60, 18 - DW 0, 127 - DW 9, 6 - DW 27, 29, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBF DW 14 - DB 60, 19 - DW 0, 127 - DW 9, 7 - DW 28, 30, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBL DW 14 - DB 60, 20 - DW 0, 127 - DW 9, 8 - DW 29, 31, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBR DW 14 - DB 60, 21 - DW 0, 127 - DW 9, 9 - DW 30, 32, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBF DW 14 - DB 60, 22 - DW 0, 127 - DW 9, 10 - DW 31, 33, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBL DW 14 - DB 60, 23 - DW 0, 127 - DW 9, 11 - DW 32, 34, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBR DW 14 - DB 60, 24 - DW 0, 127 - DW 9, 12 - DW 33, 35, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBF DW 14 - DB 60, 25 - DW 0, 127 - DW 9, 13 - DW 34, 36, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoLevel DW 14 - DB 60, 26 - DW 0, 127 - DW 9, 15 - DW 35, 37, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoTime DW 14 - DB 60, 27 - DW 0, 127 - DW 9, 14 - DW 36, 38, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoFeedback DW 14 - DB 60, 28 - DW 0, 127 - DW 9, 16 - DW 37, 39, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundVolume DW 14 - DB 60, 29 - DW 0, 255 - DW 9, 17 - DW 38, 40, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundDelay DW 14 - DB 60, 30 - DW 0, 127 - DW 9, 18 - DW 39, 41, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbSend DW 14 - DB 60, 31 - DW 0, 127 - DW 9, 19 - DW 40, 42, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbVolume DW 14 - DB 60, 32 - DW 0, 255 - DW 9, 20 - DW 41, 43, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - - -ReverbType DW 14 - DB 60, 33 - DW 0, 7 - DW 9, 21 - DW 42, 44, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbTime DW 14 - DB 60, 34 - DW 0, 127 - DW 9, 22 - DW 43, 45, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbFeedback DW 14 - DB 60, 35 - DW 0, 127 - DW 9, 23 - DW 44, 46, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusSend DW 14 - DB 60, 36 - DW 0, 127 - DW 9, 24 - DW 45, 47, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusVolume DW 14 - DB 60, 37 - DW 0, 255 - DW 9, 25 - DW 46, 48, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusType DW 14 - DB 60, 38 - DW 0, 7 - DW 9, 26 - DW 47, 49, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDelay DW 14 - DB 60, 39 - DW 0, 127 - DW 9, 27 - DW 48, 50, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusFeedback DW 14 - DB 60, 40 - DW 0, 127 - DW 9, 28 - DW 49, 51, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusRate DW 14 - DB 60, 41 - DW 0, 127 - DW 9, 29 - DW 50, 52, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDepth DW 14 - DB 60, 42 - DW 0, 127 - DW 9, 30 - DW 51, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SAM9407ParametersBox DW 0 - DB 59, 13, 75, 43 - DB 25 - -; OldIRQData DD 0 -; OldIRQOffset DD 0 -; UseOldIRQ DB 0 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -include dmasirq.inc -include mix.inc - -include m12bit.mix -include m12biti.mix -include m32biti.mix -include m32ultra.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32biti.inc -include m32ultra.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - - Mov AX, 1 - Ret - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InByte ; Returns AL - - Push DX - Mov DX, CS:SAM9407Port - Inc DX - -SAM9407InByte1: - In AL, DX - Test AL, AL - JS SAM9407InByte1 - - Dec DX - In AL, DX - Pop DX - - Ret - -EndP SAM9407InByte - -; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendByte ; DX = port, AL = data - - Push AX - Push DX - Mov DX, CS:SAM9407Port - Inc DX - -SAM9407SendByte1: - In AL, DX - Test AL, 40h - JNZ SAM9407SendByte1 - - Pop DX - Pop AX - - Out DX, AL - - Ret - -EndP SAM9407SendByte - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSAM9407 ; DI = index. 1 = full reinit. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - LEA SI, [SAM9407Strings+EDI+EDI-2] - Mov SI, [SI] - - LodsW - Mov CX, AX - -SetSAM9407_1: -; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. - - Mov DX, SAM9407Port - Test DX, DX - JZ NoSAM9407 - - LodsW - - Cmp AH, 2 - JB SetSAM9407_3 - JA SetSAM9407_4 - - Mov AL, [VolumeTable+DI] - Jmp SetSAM9407_2 - -SetSAM9407_4: - Call SAM9407InByte - Test AL, AL - JNZ SetSAM9407_4 - Jmp SetSAM9407_5 - -SetSAM9407_3: - And AH, 1 - Add DL, AH - -SetSAM9407_2: - Call SAM9407SendByte - -SetSAM9407_5: - Dec CX - JNZ SetSAM9407_1 - -NoSAM9407: - Pop DS - PopA - - Ret - -EndP SetSAM9407 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 16 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Add DX, 6 - - - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -PingWSSFailure: - Pop DX - - StC - Ret - - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard -; Cmp PnP_SerialID, PNPSERIALID -; JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - - Mov AX, 007h ; Configuration device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - - Test AX, AX - JZ PnP_IsolateNextCard - - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Cmp AX, 534h - JNE PnPBasePortTranslate1 - - Mov AX, 530h - -PnPBasePortTranslate1: - Cmp AX, 0F44h - JNE PnPBasePortTranslate2 - - Mov AX, 0F40h - -PnPBasePortTranslate2: - Cmp AX, 608h - JNE PnPBasePortTranslate3 - - Mov AX, 604h - -PnPBasePortTranslate3: - Cmp AX, 0E84h - JNE PnPBasePortTranslate4 - - Mov AX, 0E80h - -PnPBasePortTranslate4: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov AX, 207h ; CS4237 - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Test AX, AX - JZ PnP_IsolateNextCard - - Mov CS4237Port, AX - - Mov AX, 407h ; SAM9407 - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Test AX, AX - JZ PnP_NoSAM9407 - - Mov SAM9407Port, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -Pnp_NoSAM9407: - Xor AX, AX - Mov SAM9407Port, AX - Mov ST42A, AX - Dec AX - Mov ST42B, AX - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov DX, BasePort - JNC DetectWSSOK - -DetectPCI: -; Cmp DMA, 0FFFFh -; JNE DMAOverride - - Mov DMA, 1 ; Force DMA to 1. - -DMAOverride: - Mov EBX, 80000000h ; PCI output value. - Mov DX, 0CF8h - Mov CX, 32 - -DetectCardPCIBasePort1: - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - Sub DX, 4 - Add EBX, 1 SHL 11 - - Cmp EAX, 8128Eh - LoopNE DetectCardPCIBasePort1 - - JNE DetectWSSFailure - - Add EBX, (3Ch) - (1 SHL 11) - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX ; AL = IRQ - Mov ECX, EAX - And AX, 0FFh - - JZ DetectWSSFailure - Cmp AL, 15 - JA DetectWSSFailure - - Cmp IRQ, 0FFFFh - JNE IRQSpecified - - Mov IRQ, AX - -; Mov OldIRQOffset, EBX -; Mov OldIRQData, ECX -; Mov UseOldIRQ, 1 - -IRQSpecified: - Sub DX, 4 - -; Get SAM9407IRQ - Add EBX, 1 SHL 8 - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - Sub DX, 4 ; AL = IRQ. - - And AX, 0FFh - - PushA - - JZ NoSAM9407IRQ - Cmp AL, 15 - JA NoSAM9407IRQ - - Mov DL, AL - ShL DL, 4 - Mov CL, AL - And DX, 80h - Mov CH, 1 - Or DL, 21h - And CL, 7 - ShL CH, CL - In AL, DX - Or AL, CH - Out DX, AL - -NoSAM9407IRQ: - PopA - Push AX - - Add EBX, 10h-3Ch ; SAM9407 port - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - Sub DX, 4 - And AX, 0FFEh - Mov SAM9407Port, AX - Pop CX - -; If SAM9407 Port not available, or IRQ = old IRQ, then set to ST42 mode. - Test AX, AX - JZ ST42Found - Cmp AX, 400h - JA ST42Found - Cmp CX, IRQ - JNE NoST42 - -ST42Found: -; Mov AX, '24' -; Mov Word Ptr O97A, AX -; Mov Word Ptr O97B, AX -; Mov Word Ptr O97C, AX -; Mov Word Ptr O97D, AX -; Mov Word Ptr O97E, AX -; Mov Word Ptr O97F, AX - Xor AX, AX - Mov SAM9407Port, AX - Mov ST42A, AX - Dec AX - Mov ST42B, AX - -NoST42: - Add EBX, 3 SHL 8 - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - Sub DX, 4 - And AX, 0FFEh - Cmp AX, 400h - JB NoCS - - Xor AX, AX - -NoCS: - Mov CS4237Port, AX - - Sub EBX, 4 SHL 8 - -; Add EBX, 10h - 3Ch -; Add EBX, (10h) - (1 SHL 11) - Mov EAX, EBX - Out DX, EAX - Add DX, 4 - In EAX, DX - - And AX, 0FFEh - Mov DX, AX - - Cmp BasePort, 0FFFFh - JE BasePortNotSpecified - - Mov DX, BasePort - -BasePortnotSpecified: - Call PingWSS - JNC DetectWSSOK - -DetectWSSFailure: - StC - Ret - -DetectWSSOK: - Mov BasePort, DX - -CheckWSSOK: ; Check for IRQ - Add DX, 4 - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov DX, CS4237Port - Test DX, DX - JZ DetectNoCS4237Port - - Add DX, 3 - - Mov AL, 3 - Out DX, AL - Inc DX - Mov AL, 0A0h - Out DX, AL - Dec DX ; Enable 3D stuff - - Mov AL, 2 - Out DX, AL - Inc DX - In AL, DX - Out DX, AL - Not AL - Mov AH, AL - And AL, 0Fh - ShR AH, 4 - - Mov [Word Ptr VolumeTable+31], AX - -DetectNoCS4237Port: - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 6 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Xor AX, AX - - Cmp BX, DMABUFFERLENGTH/2 - JB WSSIRQHandler1 - - Mov AX, DMABUFFERLENGTH/2 - -WSSIRQHandler1: - CLD - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Add DX, 4 - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov DI, 1 - Call SetSAM9407 - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: -; Cmp UseOldIRQ, 1 -; JNE UnInitSound2 -; -; Mov DX, 0CF8h -; Mov EAX, OldIRQOffset -; Out DX, EAX -; Add DX, 4 -; Mov EAX, OldIRQData -; Out DX, EAX -; -; UnInitSound2: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Push AX - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - - Pop DI - And DI, 1 - Add DI, 31 - Call SetSAM9407 - - Mov DI, 2 -SetStereo2: - Call SetSAM9407 - Inc DI - Cmp DI, 30 - JBE SetStereo2 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov DX, BasePort - Add DX, 4 - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - - Mov DX, CS4237Port - Test DX, DX - JZ UpdateSoundCardVariables1 - - Add DX, 3 - - Mov AL, 3 - Out DX, AL - Inc DX - Mov AL, 0A0h - Out DX, AL - Dec DX - - Mov AL, 2 - Out DX, AL - - Mov AX, [Word Ptr VolumeTable+31] - ShL AH, 4 - Inc DX - Or AL, AH - Not AL - Out DX, AL - -UpdateSoundCardVariables1: - - Pop DS - PopA - - Ret - -EndP UpdateSoundcardVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Mov [CS:VolumeTable+DI], AL - Cmp DI, 31 - JAE SetVariable1 - Cmp DI, 2 - JB SetVariable1 - - Call SetSAM9407 - Ret - -SetVariable1: - Call UpdateSoundcardVariables - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. -StopAfterPlay DW 0 -DefaultChannels DW 64 -DriverFlags DW 0 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; ST 97/42 PCI Codec +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc +include mmx.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 +DATAFLAG EQU 200h +ACKFLAG EQU 300h + +PNPVENDORID EQU 3746630Eh + +DMASize DW DMABUFFERLENGTH / 2 + +WSSMsg DB "Sound Track Codec", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Sound Track Codec", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Track Codec reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITSTCODE.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITSTCODE.DRV", 0 + +DriverName DB "ITSTCODE.DRV", 0 + +Forced DB 0 +Stereo DB 0 +WSSMixConst DB 0 + +ALIGN 2 + +MixVolume DW 0 + +BytesToMix DW 1000 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 37 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 +VolumeTable DB 56, 56 + DB 60h, 60h, 0Ch ; Low Band + DB 40h, 40h, 1Bh ; Med Low Band + DB 40h, 40h, 72h ; Med High Band + DB 60h, 60h, 40h ; High Band + DB 0, 0, 0 ; Echo + DB 0, 2 ; Surround + DB 0, 90h, 4, 7Fh, 22h ; Reverb + DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus + DB 0, 0 ; SRS stuff. + +ALIGN 2 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +SAM9407Reset DW 66 + DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on + DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on + DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on + DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on + DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type + DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on + DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in + DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus + DW 1BEh, 133h, 0, 0 ; 2 Speaker + DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 + DW 1BEh, 134h, 0FFh, 0FFh ; Left gain + DW 1BEh, 135h, 0FFh, 0FFh ; Right gain + DW 1BEh, 136h, 0, 0 ; Left pan + DW 1BEh, 137h, 7Fh, 7Fh ; Right pan + DW 1BEh, 107h, 0FFh, 0FFh ; Master volume + +SAM9407EqLBL DW 4 + DW 1BEh, 110h, DATAFLAG, 60h +SAM9407EqLBR DW 4 + DW 1BEh, 114h, DATAFLAG, 60h +SAM9407EqLBF DW 4 + DW 1BEh, 118h, DATAFLAG, 0Ch +SAM9407EqMLBL DW 4 + DW 1BEh, 111h, DATAFLAG, 40h +SAM9407EqMLBR DW 4 + DW 1BEh, 115h, DATAFLAG, 40h +SAM9407EqMLBF DW 4 + DW 1BEh, 119h, DATAFLAG, 1Bh +SAM9407EqMHBL DW 4 + DW 1BEh, 112h, DATAFLAG, 40h +SAM9407EqMHBR DW 4 + DW 1BEh, 116h, DATAFLAG, 40h +SAM9407EqMHBF DW 4 + DW 1BEh, 11Ah, DATAFLAG, 72h +SAM9407EqHBL DW 4 + DW 1BEh, 113h, DATAFLAG, 60h +SAM9407EqHBR DW 4 + DW 1BEh, 117h, DATAFLAG, 60h +SAM9407EqHBF DW 4 + DW 1BEh, 11Bh, DATAFLAG, 0Ch +SAM9407EchoLevel DW 4 + DW 1BEh, 128h, DATAFLAG, 0 +SAM9407EchoTime DW 4 + DW 1BEh, 129h, DATAFLAG, 2Bh +SAM9407EchoFeed DW 4 + DW 1BEh, 12Ah, DATAFLAG, 40h +SAM9407SurroundVolume DW 4 + DW 1BEh, 130h, DATAFLAG, 0 +SAM9407SurroundDelay DW 4 + DW 1BEh, 131h, DATAFLAG, 2 +SAM9407ReverbSend DW 4 + DW 1BEh, 127h, DATAFLAG, 0 +SAM9407ReverbVolume DW 3 + DW 1BEh, 13Ah, DATAFLAG +SAM9407ReverbType DW 4 + DW 1BEh, 169h, DATAFLAG, 4 +SAM9407ReverbTime DW 3 + DW 1BEh, 178h, DATAFLAG +SAM9407ReverbFeedback DW 3 + DW 1BEh, 179h, DATAFLAG +SAM9407ChorusSend DW 4 + DW 1BEh, 124h, DATAFLAG, 0 +SAM9407ChorusVolume DW 3 + DW 1BEh, 13Bh, DATAFLAG +SAM9407ChorusType DW 4 + DW 1BEh, 16Ah, DATAFLAG, 2 +SAM9407ChorusDelay DW 3 + DW 1BEh, 174h, DATAFLAG +SAM9407ChorusFeedback DW 3 + DW 1BEh, 175h, DATAFLAG +SAM9407ChorusRate DW 3 + DW 1BEh, 176h, DATAFLAG +SAM9407ChorusDepth DW 3 + DW 1BEh, 177h, DATAFLAG +SAM9407Mono DW 4 + DW 1BEh, 132h, 7Fh, 0 +SAM9407Stereo DW 4 + DW 1BEh, 132h, 0, 0 + +SAM9407Strings DW Offset SAM9407Reset ;1 + DW Offset SAM9407EqLBL, Offset SAM9407EqLBR + DW Offset SAM9407EqLBF + DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR + DW Offset SAM9407EqMLBF + DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR + DW Offset SAM9407EqMHBF + DW Offset SAM9407EqHBL, Offset SAM9407EqHBR + DW Offset SAM9407EqHBF + DW Offset SAM9407EchoLevel ; 14 + DW Offset SAM9407EchoTime + DW Offset SAM9407EchoFeed + DW Offset SAM9407SurroundVolume ; 17 + DW Offset SAM9407SurroundDelay + DW Offset SAM9407ReverbSend ; 19 + DW Offset SAM9407ReverbVolume + DW Offset SAM9407ReverbType + DW Offset SAM9407ReverbTime + DW Offset SAM9407ReverbFeedback ; 23 + DW Offset SAM9407ChorusSend ; 24 + DW Offset SAM9407ChorusVolume + DW Offset SAM9407ChorusType + DW Offset SAM9407ChorusDelay + DW Offset SAM9407ChorusFeedback + DW Offset SAM9407ChorusRate + DW Offset SAM9407ChorusDepth ; 30 + DW Offset SAM9407Mono ; 31 + DW Offset SAM9407Stereo +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW Near Ptr CS4237SRSCenter ; 18 + DW Near Ptr CS4237SRSSpace ; 19 + DW Near Ptr CSControlPortText + +ST42A DW Near Ptr SAM9407PortText ; 21 + DW Near Ptr SAM9407ParametersText + DW Near Ptr SAM9407ParametersBox + + DW Near Ptr EqLBL ; 24 + DW Near Ptr EqLBR + DW Near Ptr EqLBF + + DW Near Ptr EqMLBL + DW Near Ptr EqMLBR + DW Near Ptr EqMLBF + + DW Near Ptr EqMHBL + DW Near Ptr EqMHBR + DW Near Ptr EqMHBF + + DW Near Ptr EqHBL + DW Near Ptr EqHBR + DW Near Ptr EqHBF + + DW Near Ptr EchoLevel ; 33 + DW Near Ptr EchoTime + DW Near Ptr EchoFeedback + + DW Near Ptr SurroundVolume + DW Near Ptr SurroundDelay + + DW Near Ptr ReverbSend ; 38 + DW Near Ptr ReverbVolume + DW Near Ptr ReverbType + DW Near Ptr ReverbTime + DW Near Ptr ReverbFeedback + + DW Near Ptr ChorusSend + DW Near Ptr ChorusVolume + DW Near Ptr ChorusType + DW Near Ptr ChorusDelay + DW Near Ptr ChorusFeedback + DW Near Ptr ChorusRate + DW Near Ptr ChorusDepth + + + DW 0 + +WSSHeaderLine DW 10 + DB "Sound Track Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 28, 48 + DB 21h + DB "Sound Track Codec Driver 1.0 for Impulse Tracker", 0 + +CSControlPortText DW 1 + DB 28, 47 + DB 21h + DB "Sound Track CS4237 Control Port ", 0FDh, "Xh", 0 +CS4237Port DW 0 + +SAM9407PortText DW 1 + DB 28, 46 + DB 21h + DB "Sound Track SAM9407 Port ", 0FDh, "Xh", 0 +SAM9407Port DW 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 13 + DB "CS4237 SRS Center", 13 + DB "CS4237 SRS Space" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 18 + DB 25 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 18, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +CS4237SRSCenter DW 14 + DB 22, 16 + DW 0, 15 + DW 9, 31 + DW 17, 19, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +CS4237SRSSpace DW 14 + DB 22, 17 + DW 0, 15 + DW 9, 32 + DW 18, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MixModeText DW 1 + DB 2, 19 + DB 20h + DB "Mixing Rate: ", 0FDh, "D, Mode:", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 19, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 21, 32, 23, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 24, 32, 26, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 27, 32, 29, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 30, 32, 32, 8 + DB 0 + DB " 32 Bit, Ultra Quality", 0 + +FilterText DW 1 + DB 2, 34 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 36, 29, 38, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 39, 29, 41, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12 +ST42B DW 24, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 42, 29, 44, 8 + DB 0 + DB " 75% Filter", 0 + +SAM9407ParametersText DW 1 + DB 36, 14 + DB 20h + DB "Low Band Left", 13 + DB "Low Band Right", 13 + DB "Low Band Frequency", 13 + DB "Med Low Band Left", 13 + DB "Med Low Band Right", 13 + DB "Med Low Band Frequency", 13 + DB "Med High Band Left", 13 + DB "Med High Band Right", 13 + DB "Med High Band Frequency", 13 + DB "High Band Left", 13 + DB "High Band Right", 13 + DB "High Band Frequency", 13 + DB "Echo Level", 13 + DB "Echo Time", 13 + DB "Echo Feedback", 13 + DB "Surround Volume", 13 + DB "Surround Delay", 13 + DB "Reverb Send", 13 + DB "Reverb Volume", 13 + DB "Reverb Type", 13 + DB "Reverb Time", 13 + DB "Reverb Feedback", 13 + DB "Chorus Send", 13 + DB "Chorus Volume", 13 + DB "Chorus Type", 13 + DB "Chorus Delay", 13 + DB "Chorus Feedback", 13 + DB "Chorus Rate", 13 + DB "Chorus Depth", 13 + DB 0 + +EqLBL DW 14 + DB 60, 14 + DW 0, 127 + DW 9, 2 + DW 13, 25, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBR DW 14 + DB 60, 15 + DW 0, 127 + DW 9, 3 + DW 24, 26, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBF DW 14 + DB 60, 16 + DW 0, 127 + DW 9, 4 + DW 25, 27, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBL DW 14 + DB 60, 17 + DW 0, 127 + DW 9, 5 + DW 26, 28, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBR DW 14 + DB 60, 18 + DW 0, 127 + DW 9, 6 + DW 27, 29, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBF DW 14 + DB 60, 19 + DW 0, 127 + DW 9, 7 + DW 28, 30, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBL DW 14 + DB 60, 20 + DW 0, 127 + DW 9, 8 + DW 29, 31, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBR DW 14 + DB 60, 21 + DW 0, 127 + DW 9, 9 + DW 30, 32, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBF DW 14 + DB 60, 22 + DW 0, 127 + DW 9, 10 + DW 31, 33, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBL DW 14 + DB 60, 23 + DW 0, 127 + DW 9, 11 + DW 32, 34, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBR DW 14 + DB 60, 24 + DW 0, 127 + DW 9, 12 + DW 33, 35, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBF DW 14 + DB 60, 25 + DW 0, 127 + DW 9, 13 + DW 34, 36, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoLevel DW 14 + DB 60, 26 + DW 0, 127 + DW 9, 15 + DW 35, 37, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoTime DW 14 + DB 60, 27 + DW 0, 127 + DW 9, 14 + DW 36, 38, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoFeedback DW 14 + DB 60, 28 + DW 0, 127 + DW 9, 16 + DW 37, 39, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundVolume DW 14 + DB 60, 29 + DW 0, 255 + DW 9, 17 + DW 38, 40, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundDelay DW 14 + DB 60, 30 + DW 0, 127 + DW 9, 18 + DW 39, 41, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbSend DW 14 + DB 60, 31 + DW 0, 127 + DW 9, 19 + DW 40, 42, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbVolume DW 14 + DB 60, 32 + DW 0, 255 + DW 9, 20 + DW 41, 43, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + + +ReverbType DW 14 + DB 60, 33 + DW 0, 7 + DW 9, 21 + DW 42, 44, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbTime DW 14 + DB 60, 34 + DW 0, 127 + DW 9, 22 + DW 43, 45, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbFeedback DW 14 + DB 60, 35 + DW 0, 127 + DW 9, 23 + DW 44, 46, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusSend DW 14 + DB 60, 36 + DW 0, 127 + DW 9, 24 + DW 45, 47, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusVolume DW 14 + DB 60, 37 + DW 0, 255 + DW 9, 25 + DW 46, 48, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusType DW 14 + DB 60, 38 + DW 0, 7 + DW 9, 26 + DW 47, 49, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDelay DW 14 + DB 60, 39 + DW 0, 127 + DW 9, 27 + DW 48, 50, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusFeedback DW 14 + DB 60, 40 + DW 0, 127 + DW 9, 28 + DW 49, 51, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusRate DW 14 + DB 60, 41 + DW 0, 127 + DW 9, 29 + DW 50, 52, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDepth DW 14 + DB 60, 42 + DW 0, 127 + DW 9, 30 + DW 51, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SAM9407ParametersBox DW 0 + DB 59, 13, 75, 43 + DB 25 + +; OldIRQData DD 0 +; OldIRQOffset DD 0 +; UseOldIRQ DB 0 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +include dmasirq.inc +include mix.inc + +include m12bit.mix +include m12biti.mix +include m32biti.mix +include m32ultra.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32biti.inc +include m32ultra.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + + Mov AX, 1 + Ret + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InByte ; Returns AL + + Push DX + Mov DX, CS:SAM9407Port + Inc DX + +SAM9407InByte1: + In AL, DX + Test AL, AL + JS SAM9407InByte1 + + Dec DX + In AL, DX + Pop DX + + Ret + +EndP SAM9407InByte + +; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendByte ; DX = port, AL = data + + Push AX + Push DX + Mov DX, CS:SAM9407Port + Inc DX + +SAM9407SendByte1: + In AL, DX + Test AL, 40h + JNZ SAM9407SendByte1 + + Pop DX + Pop AX + + Out DX, AL + + Ret + +EndP SAM9407SendByte + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSAM9407 ; DI = index. 1 = full reinit. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + LEA SI, [SAM9407Strings+EDI+EDI-2] + Mov SI, [SI] + + LodsW + Mov CX, AX + +SetSAM9407_1: +; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. + + Mov DX, SAM9407Port + Test DX, DX + JZ NoSAM9407 + + LodsW + + Cmp AH, 2 + JB SetSAM9407_3 + JA SetSAM9407_4 + + Mov AL, [VolumeTable+DI] + Jmp SetSAM9407_2 + +SetSAM9407_4: + Call SAM9407InByte + Test AL, AL + JNZ SetSAM9407_4 + Jmp SetSAM9407_5 + +SetSAM9407_3: + And AH, 1 + Add DL, AH + +SetSAM9407_2: + Call SAM9407SendByte + +SetSAM9407_5: + Dec CX + JNZ SetSAM9407_1 + +NoSAM9407: + Pop DS + PopA + + Ret + +EndP SetSAM9407 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 16 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Add DX, 6 + + + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +PingWSSFailure: + Pop DX + + StC + Ret + + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard +; Cmp PnP_SerialID, PNPSERIALID +; JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + + Mov AX, 007h ; Configuration device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + + Test AX, AX + JZ PnP_IsolateNextCard + + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Cmp AX, 534h + JNE PnPBasePortTranslate1 + + Mov AX, 530h + +PnPBasePortTranslate1: + Cmp AX, 0F44h + JNE PnPBasePortTranslate2 + + Mov AX, 0F40h + +PnPBasePortTranslate2: + Cmp AX, 608h + JNE PnPBasePortTranslate3 + + Mov AX, 604h + +PnPBasePortTranslate3: + Cmp AX, 0E84h + JNE PnPBasePortTranslate4 + + Mov AX, 0E80h + +PnPBasePortTranslate4: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov AX, 207h ; CS4237 + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Test AX, AX + JZ PnP_IsolateNextCard + + Mov CS4237Port, AX + + Mov AX, 407h ; SAM9407 + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Test AX, AX + JZ PnP_NoSAM9407 + + Mov SAM9407Port, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +Pnp_NoSAM9407: + Xor AX, AX + Mov SAM9407Port, AX + Mov ST42A, AX + Dec AX + Mov ST42B, AX + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov DX, BasePort + JNC DetectWSSOK + +DetectPCI: +; Cmp DMA, 0FFFFh +; JNE DMAOverride + + Mov DMA, 1 ; Force DMA to 1. + +DMAOverride: + Mov EBX, 80000000h ; PCI output value. + Mov DX, 0CF8h + Mov CX, 32 + +DetectCardPCIBasePort1: + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + Sub DX, 4 + Add EBX, 1 SHL 11 + + Cmp EAX, 8128Eh + LoopNE DetectCardPCIBasePort1 + + JNE DetectWSSFailure + + Add EBX, (3Ch) - (1 SHL 11) + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX ; AL = IRQ + Mov ECX, EAX + And AX, 0FFh + + JZ DetectWSSFailure + Cmp AL, 15 + JA DetectWSSFailure + + Cmp IRQ, 0FFFFh + JNE IRQSpecified + + Mov IRQ, AX + +; Mov OldIRQOffset, EBX +; Mov OldIRQData, ECX +; Mov UseOldIRQ, 1 + +IRQSpecified: + Sub DX, 4 + +; Get SAM9407IRQ + Add EBX, 1 SHL 8 + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + Sub DX, 4 ; AL = IRQ. + + And AX, 0FFh + + PushA + + JZ NoSAM9407IRQ + Cmp AL, 15 + JA NoSAM9407IRQ + + Mov DL, AL + ShL DL, 4 + Mov CL, AL + And DX, 80h + Mov CH, 1 + Or DL, 21h + And CL, 7 + ShL CH, CL + In AL, DX + Or AL, CH + Out DX, AL + +NoSAM9407IRQ: + PopA + Push AX + + Add EBX, 10h-3Ch ; SAM9407 port + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + Sub DX, 4 + And AX, 0FFEh + Mov SAM9407Port, AX + Pop CX + +; If SAM9407 Port not available, or IRQ = old IRQ, then set to ST42 mode. + Test AX, AX + JZ ST42Found + Cmp AX, 400h + JA ST42Found + Cmp CX, IRQ + JNE NoST42 + +ST42Found: +; Mov AX, '24' +; Mov Word Ptr O97A, AX +; Mov Word Ptr O97B, AX +; Mov Word Ptr O97C, AX +; Mov Word Ptr O97D, AX +; Mov Word Ptr O97E, AX +; Mov Word Ptr O97F, AX + Xor AX, AX + Mov SAM9407Port, AX + Mov ST42A, AX + Dec AX + Mov ST42B, AX + +NoST42: + Add EBX, 3 SHL 8 + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + Sub DX, 4 + And AX, 0FFEh + Cmp AX, 400h + JB NoCS + + Xor AX, AX + +NoCS: + Mov CS4237Port, AX + + Sub EBX, 4 SHL 8 + +; Add EBX, 10h - 3Ch +; Add EBX, (10h) - (1 SHL 11) + Mov EAX, EBX + Out DX, EAX + Add DX, 4 + In EAX, DX + + And AX, 0FFEh + Mov DX, AX + + Cmp BasePort, 0FFFFh + JE BasePortNotSpecified + + Mov DX, BasePort + +BasePortnotSpecified: + Call PingWSS + JNC DetectWSSOK + +DetectWSSFailure: + StC + Ret + +DetectWSSOK: + Mov BasePort, DX + +CheckWSSOK: ; Check for IRQ + Add DX, 4 + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov DX, CS4237Port + Test DX, DX + JZ DetectNoCS4237Port + + Add DX, 3 + + Mov AL, 3 + Out DX, AL + Inc DX + Mov AL, 0A0h + Out DX, AL + Dec DX ; Enable 3D stuff + + Mov AL, 2 + Out DX, AL + Inc DX + In AL, DX + Out DX, AL + Not AL + Mov AH, AL + And AL, 0Fh + ShR AH, 4 + + Mov [Word Ptr VolumeTable+31], AX + +DetectNoCS4237Port: + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 6 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Xor AX, AX + + Cmp BX, DMABUFFERLENGTH/2 + JB WSSIRQHandler1 + + Mov AX, DMABUFFERLENGTH/2 + +WSSIRQHandler1: + CLD + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Add DX, 4 + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov DI, 1 + Call SetSAM9407 + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: +; Cmp UseOldIRQ, 1 +; JNE UnInitSound2 +; +; Mov DX, 0CF8h +; Mov EAX, OldIRQOffset +; Out DX, EAX +; Add DX, 4 +; Mov EAX, OldIRQData +; Out DX, EAX +; +; UnInitSound2: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Push AX + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + + Pop DI + And DI, 1 + Add DI, 31 + Call SetSAM9407 + + Mov DI, 2 +SetStereo2: + Call SetSAM9407 + Inc DI + Cmp DI, 30 + JBE SetStereo2 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov DX, BasePort + Add DX, 4 + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + + Mov DX, CS4237Port + Test DX, DX + JZ UpdateSoundCardVariables1 + + Add DX, 3 + + Mov AL, 3 + Out DX, AL + Inc DX + Mov AL, 0A0h + Out DX, AL + Dec DX + + Mov AL, 2 + Out DX, AL + + Mov AX, [Word Ptr VolumeTable+31] + ShL AH, 4 + Inc DX + Or AL, AH + Not AL + Out DX, AL + +UpdateSoundCardVariables1: + + Pop DS + PopA + + Ret + +EndP UpdateSoundcardVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Mov [CS:VolumeTable+DI], AL + Cmp DI, 31 + JAE SetVariable1 + Cmp DI, 2 + JB SetVariable1 + + Call SetSAM9407 + Ret + +SetVariable1: + Call UpdateSoundcardVariables + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. +StopAfterPlay DW 0 +DefaultChannels DW 64 +DriverFlags DW 0 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/ST97PNP.ASM b/SoundDrivers/ST97PNP.ASM index 8fb2fcb..87b605e 100755 --- a/SoundDrivers/ST97PNP.ASM +++ b/SoundDrivers/ST97PNP.ASM @@ -1,2623 +1,2623 @@ -; -; Analog Device's AD1816 -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -PNPSERIALID EQU 0FFFFFFFFh -PNPVENDORID EQU 80719304h - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 -DATAFLAG EQU 200h -ACKFLAG EQU 300h - -Debug DW 0 -Debug2 DW 0 -DMASize DW 2048 - -ESSMsg DB "Sound Track '97 PnP found", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -ESSNoMemoryMsg DB "Sound Track '97 PnP found", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Sound Track '97 PnP reinitialised", 0 - -DriverName DB "ITSTPNP.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -ESSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 -VolumeTable DB 56, 56 - DB 60h, 60h, 0Ch ; Low Band - DB 40h, 40h, 1Bh ; Med Low Band - DB 40h, 40h, 72h ; Med High Band - DB 60h, 60h, 40h ; High Band - DB 0, 0, 0 ; Echo - DB 0, 2 ; Surround - DB 0, 90h, 4, 7Fh, 22h ; Reverb - DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus - DB 0, 0 ; Phat Stereo Stuff - -IMR DW 0 -OldESSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -SAM9407Reset DW 66 - DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on - DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on - DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on - DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on - DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type - DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on - DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in - DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus - DW 1BEh, 133h, 0, 0 ; 2 Speaker - DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 - DW 1BEh, 134h, 0FFh, 0FFh ; Left gain - DW 1BEh, 135h, 0FFh, 0FFh ; Right gain - DW 1BEh, 136h, 0, 0 ; Left pan - DW 1BEh, 137h, 7Fh, 7Fh ; Right pan - DW 1BEh, 107h, 0FFh, 0FFh ; Master volume - -SAM9407EqLBL DW 4 - DW 1BEh, 110h, DATAFLAG, 60h -SAM9407EqLBR DW 4 - DW 1BEh, 114h, DATAFLAG, 60h -SAM9407EqLBF DW 4 - DW 1BEh, 118h, DATAFLAG, 0Ch -SAM9407EqMLBL DW 4 - DW 1BEh, 111h, DATAFLAG, 40h -SAM9407EqMLBR DW 4 - DW 1BEh, 115h, DATAFLAG, 40h -SAM9407EqMLBF DW 4 - DW 1BEh, 119h, DATAFLAG, 1Bh -SAM9407EqMHBL DW 4 - DW 1BEh, 112h, DATAFLAG, 40h -SAM9407EqMHBR DW 4 - DW 1BEh, 116h, DATAFLAG, 40h -SAM9407EqMHBF DW 4 - DW 1BEh, 11Ah, DATAFLAG, 72h -SAM9407EqHBL DW 4 - DW 1BEh, 113h, DATAFLAG, 60h -SAM9407EqHBR DW 4 - DW 1BEh, 117h, DATAFLAG, 60h -SAM9407EqHBF DW 4 - DW 1BEh, 11Bh, DATAFLAG, 0Ch -SAM9407EchoLevel DW 4 - DW 1BEh, 128h, DATAFLAG, 0 -SAM9407EchoTime DW 4 - DW 1BEh, 129h, DATAFLAG, 2Bh -SAM9407EchoFeed DW 4 - DW 1BEh, 12Ah, DATAFLAG, 40h -SAM9407SurroundVolume DW 4 - DW 1BEh, 130h, DATAFLAG, 0 -SAM9407SurroundDelay DW 4 - DW 1BEh, 131h, DATAFLAG, 2 -SAM9407ReverbSend DW 4 - DW 1BEh, 127h, DATAFLAG, 0 -SAM9407ReverbVolume DW 3 - DW 1BEh, 13Ah, DATAFLAG -SAM9407ReverbType DW 4 - DW 1BEh, 169h, DATAFLAG, 4 -SAM9407ReverbTime DW 3 - DW 1BEh, 178h, DATAFLAG -SAM9407ReverbFeedback DW 3 - DW 1BEh, 179h, DATAFLAG -SAM9407ChorusSend DW 4 - DW 1BEh, 124h, DATAFLAG, 0 -SAM9407ChorusVolume DW 3 - DW 1BEh, 13Bh, DATAFLAG -SAM9407ChorusType DW 4 - DW 1BEh, 16Ah, DATAFLAG, 2 -SAM9407ChorusDelay DW 3 - DW 1BEh, 174h, DATAFLAG -SAM9407ChorusFeedback DW 3 - DW 1BEh, 175h, DATAFLAG -SAM9407ChorusRate DW 3 - DW 1BEh, 176h, DATAFLAG -SAM9407ChorusDepth DW 3 - DW 1BEh, 177h, DATAFLAG -SAM9407Mono DW 4 - DW 1BEh, 132h, 7Fh, 0 -SAM9407Stereo DW 4 - DW 1BEh, 132h, 0, 0 - -SAM9407Strings DW Offset SAM9407Reset ;1 - DW Offset SAM9407EqLBL, Offset SAM9407EqLBR - DW Offset SAM9407EqLBF - DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR - DW Offset SAM9407EqMLBF - DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR - DW Offset SAM9407EqMHBF - DW Offset SAM9407EqHBL, Offset SAM9407EqHBR - DW Offset SAM9407EqHBF - DW Offset SAM9407EchoLevel ; 14 - DW Offset SAM9407EchoTime - DW Offset SAM9407EchoFeed - DW Offset SAM9407SurroundVolume ; 17 - DW Offset SAM9407SurroundDelay - DW Offset SAM9407ReverbSend ; 19 - DW Offset SAM9407ReverbVolume - DW Offset SAM9407ReverbType - DW Offset SAM9407ReverbTime - DW Offset SAM9407ReverbFeedback ; 23 - DW Offset SAM9407ChorusSend ; 24 - DW Offset SAM9407ChorusVolume - DW Offset SAM9407ChorusType - DW Offset SAM9407ChorusDelay - DW Offset SAM9407ChorusFeedback - DW Offset SAM9407ChorusRate - DW Offset SAM9407ChorusDepth ; 30 - DW Offset SAM9407Mono ; 31 - DW Offset SAM9407Stereo - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -WSSScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW Near Ptr EmptyObject - DW Near Ptr EmptyObject - DW Near Ptr EmptyObject - - DW Near Ptr SAM9407PortText ; 21 - DW Near Ptr SAM9407ParametersText - DW Near Ptr SAM9407ParametersBox - - DW Near Ptr EqLBL ; 24 - DW Near Ptr EqLBR - DW Near Ptr EqLBF - - DW Near Ptr EqMLBL - DW Near Ptr EqMLBR - DW Near Ptr EqMLBF - - DW Near Ptr EqMHBL - DW Near Ptr EqMHBR - DW Near Ptr EqMHBF - - DW Near Ptr EqHBL - DW Near Ptr EqHBR - DW Near Ptr EqHBF - - DW Near Ptr EchoLevel ; 33 - DW Near Ptr EchoTime - DW Near Ptr EchoFeedback - - DW Near Ptr SurroundVolume - DW Near Ptr SurroundDelay - - DW Near Ptr ReverbSend ; 38 - DW Near Ptr ReverbVolume - DW Near Ptr ReverbType - DW Near Ptr ReverbTime - DW Near Ptr ReverbFeedback - - DW Near Ptr ChorusSend - DW Near Ptr ChorusVolume - DW Near Ptr ChorusType - DW Near Ptr ChorusDelay - DW Near Ptr ChorusFeedback - DW Near Ptr ChorusRate - DW Near Ptr ChorusDepth - - - DW 0 - -WSSHeaderLine DW 10 - DB "Sound Track '97 PnP Codec Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 28, 48 - DB 21h - DB "Sound Track Codec Driver 1.0 for Impulse Tracker", 0 - -SAM9407PortText DW 1 - DB 28, 47 - DB 21h - DB "Sound Track SAM9407 Port ", 0FDh, "Xh", 0 -SAM9407Port DW 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right", 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 14 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MasterVolumeRight DW 14 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 8 - -MixModeText DW 1 - DB 2, 17 - DB 20h - DB "Mixing Rate: ", 0FDh, "D", 13, 13 - DB "Mixing mode", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 21, 32, 23, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 24, 32, 26, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 27, 32, 29, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 30, 32, 32, 8 - DB 0 - DB " 32 Bit, Ultra Quality", 0 - -FilterText DW 1 - DB 2, 34 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 36, 29, 38, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 39, 29, 41, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12 -ST42B DW 24, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 42, 29, 44, 8 - DB 0 - DB " 75% Filter", 0 - -SAM9407ParametersText DW 1 - DB 36, 14 - DB 20h - DB "Low Band Left", 13 - DB "Low Band Right", 13 - DB "Low Band Frequency", 13 - DB "Med Low Band Left", 13 - DB "Med Low Band Right", 13 - DB "Med Low Band Frequency", 13 - DB "Med High Band Left", 13 - DB "Med High Band Right", 13 - DB "Med High Band Frequency", 13 - DB "High Band Left", 13 - DB "High Band Right", 13 - DB "High Band Frequency", 13 - DB "Echo Level", 13 - DB "Echo Time", 13 - DB "Echo Feedback", 13 - DB "Surround Volume", 13 - DB "Surround Delay", 13 - DB "Reverb Send", 13 - DB "Reverb Volume", 13 - DB "Reverb Type", 13 - DB "Reverb Time", 13 - DB "Reverb Feedback", 13 - DB "Chorus Send", 13 - DB "Chorus Volume", 13 - DB "Chorus Type", 13 - DB "Chorus Delay", 13 - DB "Chorus Feedback", 13 - DB "Chorus Rate", 13 - DB "Chorus Depth", 13 - DB 0 - -EqLBL DW 14 - DB 60, 14 - DW 0, 127 - DW 9, 2 - DW 13, 25, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBR DW 14 - DB 60, 15 - DW 0, 127 - DW 9, 3 - DW 24, 26, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqLBF DW 14 - DB 60, 16 - DW 0, 127 - DW 9, 4 - DW 25, 27, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBL DW 14 - DB 60, 17 - DW 0, 127 - DW 9, 5 - DW 26, 28, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBR DW 14 - DB 60, 18 - DW 0, 127 - DW 9, 6 - DW 27, 29, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMLBF DW 14 - DB 60, 19 - DW 0, 127 - DW 9, 7 - DW 28, 30, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBL DW 14 - DB 60, 20 - DW 0, 127 - DW 9, 8 - DW 29, 31, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBR DW 14 - DB 60, 21 - DW 0, 127 - DW 9, 9 - DW 30, 32, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqMHBF DW 14 - DB 60, 22 - DW 0, 127 - DW 9, 10 - DW 31, 33, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBL DW 14 - DB 60, 23 - DW 0, 127 - DW 9, 11 - DW 32, 34, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBR DW 14 - DB 60, 24 - DW 0, 127 - DW 9, 12 - DW 33, 35, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EqHBF DW 14 - DB 60, 25 - DW 0, 127 - DW 9, 13 - DW 34, 36, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoLevel DW 14 - DB 60, 26 - DW 0, 127 - DW 9, 15 - DW 35, 37, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoTime DW 14 - DB 60, 27 - DW 0, 127 - DW 9, 14 - DW 36, 38, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -EchoFeedback DW 14 - DB 60, 28 - DW 0, 127 - DW 9, 16 - DW 37, 39, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundVolume DW 14 - DB 60, 29 - DW 0, 255 - DW 9, 17 - DW 38, 40, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SurroundDelay DW 14 - DB 60, 30 - DW 0, 127 - DW 9, 18 - DW 39, 41, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbSend DW 14 - DB 60, 31 - DW 0, 127 - DW 9, 19 - DW 40, 42, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbVolume DW 14 - DB 60, 32 - DW 0, 255 - DW 9, 20 - DW 41, 43, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - - -ReverbType DW 14 - DB 60, 33 - DW 0, 7 - DW 9, 21 - DW 42, 44, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbTime DW 14 - DB 60, 34 - DW 0, 127 - DW 9, 22 - DW 43, 45, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ReverbFeedback DW 14 - DB 60, 35 - DW 0, 127 - DW 9, 23 - DW 44, 46, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusSend DW 14 - DB 60, 36 - DW 0, 127 - DW 9, 24 - DW 45, 47, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusVolume DW 14 - DB 60, 37 - DW 0, 255 - DW 9, 25 - DW 46, 48, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusType DW 14 - DB 60, 38 - DW 0, 7 - DW 9, 26 - DW 47, 49, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDelay DW 14 - DB 60, 39 - DW 0, 127 - DW 9, 27 - DW 48, 50, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusFeedback DW 14 - DB 60, 40 - DW 0, 127 - DW 9, 28 - DW 49, 51, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusRate DW 14 - DB 60, 41 - DW 0, 127 - DW 9, 29 - DW 50, 52, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -ChorusDepth DW 14 - DB 60, 42 - DW 0, 127 - DW 9, 30 - DW 51, 0FFFFh, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - DW 14 - -SAM9407ParametersBox DW 0 - DB 59, 13, 75, 43 - DB 25 - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dmasirq.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816Wait - - PushA - Xor CX, CX - Mov DX, CS:BasePort - -AD1816Wait1: - In AL, DX - Test AL, 80h - LoopZ AD1816Wait1 - - PopA - Ret - -EndP AD1816Wait - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816RegisterOut ; AL = indirect register, BX = contents - - Call AD1816Wait - - Push DX - PushF - - ClI - - Mov DX, CS:BasePort - Out DX, AL - Add DL, 2 - - Mov AL, BL - Out DX, AL - Inc DX - Mov AL, BH - Out DX, AL - - PopF - Pop DX - - Ret - -EndP AD1816RegisterOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AD1816RegisterIn ; AL = register - ; Returns BX - - Call AD1816Wait - - Push AX - Push DX - - Mov DX, CS:BasePort - Out DX, AL - Add DL, 2 - - In AL, DX - Mov BL, AL - Inc DX - In AL, DX - Mov BH, AL - - Pop DX - Pop AX - - Ret - -EndP AD1816RegisterIn - -; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407InByte ; Returns AL - - Push CX DX - - Mov DX, CS:SAM9407Port - Inc DX - - Mov CX, 1000h - -SAM9407InByte1: - In AL, DX - Test AL, 80h - LoopNZ SAM9407InByte1 - - Dec DX - In AL, DX - Pop DX CX - - Ret - -EndP SAM9407InByte - -; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SAM9407SendByte ; DX = port, AL = data - - Push AX CX DX - Mov DX, CS:SAM9407Port - Mov CX, 1000h - Inc DX - -SAM9407SendByte1: - In AL, DX - Test AL, 40h - LoopNZ SAM9407SendByte1 - - Pop DX CX AX - - Out DX, AL - - Ret - -EndP SAM9407SendByte - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSAM9407 ; DI = index. 1 = full reinit. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - LEA SI, [SAM9407Strings+EDI+EDI-2] - Mov SI, [SI] - - LodsW - Mov CX, AX - -SetSAM9407_1: -; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. - - Mov DX, SAM9407Port - Test DX, DX - JZ NoSAM9407 - - LodsW - - Cmp AH, 2 - JB SetSAM9407_3 - JA SetSAM9407_4 - - Mov AL, [VolumeTable+DI] - Jmp SetSAM9407_2 - -SetSAM9407_4: - Call SAM9407InByte - Test AL, AL - JNZ SetSAM9407_4 - Jmp SetSAM9407_5 - -SetSAM9407_3: - And AH, 1 - Add DL, AH - -SetSAM9407_2: - Call SAM9407SendByte - -SetSAM9407_5: - Dec CX - JNZ SetSAM9407_1 - - -NoSAM9407: - Pop DS - PopA - - Ret - -EndP SetSAM9407 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - - Mov AX, 1 - Ret - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PnP_SerialID DD 0 -PnP_VendorID DD 0 -PnP_ReadPort DW 0 -PnP_CSN DB 0 -PnP_CardFound DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Delay - Assume DS:Driver - - Push AX CX - - Mov CX, 180h -PnP_Delay1: - In AL, 21h - Loop PnP_Delay1 - - Pop CX AX - Ret - -EndP PnP_Delay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_WriteData - - Mov DX, 279h - Out DX, AL - - Mov AL, AH - Mov DH, 0Ah - Out DX, AL - Ret - -EndP PnP_WriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_ReadData - - Mov DX, 279h - Out DX, AL - - Mov DX, PnP_ReadPort - In AL, DX - - Ret - -EndP PnP_ReadData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PnP_Isolate - - Mov AX, 402h - Call Pnp_WriteData ; Reset CSNs - -PnP_IsolateNextCard: - Mov AX, 0003h - Call PnP_WriteData ; Wake[0] - - Mov AX, PnP_ReadPort - ShL AX, 6 - Xor AL, AL - Call PnP_WriteData ; Set Read Data port. - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov AL, 1 ; Serial Isolation - Mov DX, 279h - Out DX, AL - - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - Call PnP_Delay - - Mov BL, 6Ah - Mov CX, 64 - Mov DX, PnP_ReadPort - - ClI - -PnP_Isolate1: - ShR PnP_SerialID, 1 - RCR PnP_VendorID, 1 - - Mov BH, BL - ShR BH, 1 - Xor BH, BL - ShR BX, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - - Cmp AX, 55AAh - JNE PnP_Isolate2 - - Xor BL, 80h - Or PnP_SerialID, 80000000h - -PnP_Isolate2: - Dec CX - JNZ PnP_Isolate1 - - Mov CX, 8 - Xor BH, BH - -PnP_Isolate3: - ShR BH, 1 - - In AL, DX - Mov AH, AL - Call PnP_Delay - In AL, DX - Call PnP_Delay - Cmp AX, 55AAh - JNE PnP_Isolate4 - - Or BH, 80h - -PnP_Isolate4: - Dec CX - JNZ PnP_Isolate3 - - StI - - Cmp BL, BH ; Matching Checksum? - JNE PnP_IsolateFinished - - ; assign CSN - Inc PnP_CSN - - Mov AL, 6 - MOv AH, PnP_CSN - Call PnP_WriteData - - Cmp PnP_VendorID, PNPVENDORID - JNE PnP_IsolateNextCard - Cmp PnP_SerialID, PNPSERIALID - JNE PnP_IsolateNextCard - - Mov AL, 3 - Call PnP_WriteData - Mov AX, 007h - Call PnP_WriteData - - Mov AL, 64h - Call PnP_ReadData - Mov AH, AL - Mov AL, 65h - Call PnP_ReadData ; AX = address. - Cmp BasePort, 0FFFFh - JE PnPBasePortOK - - Cmp BasePort, AX - JNE PnP_IsolateNextCard - -PnPBasePortOK: - Mov BasePort, AX - - Mov AL, 70h - Call PnP_ReadData ; AL[3:0] = IRQ - And AX, 15 - JZ PnP_IsolateNextCard - Mov IRQ, AX - - Mov AL, 74h - Call PnP_ReadData ; AL[2:0] = DMA - And AX, 7 - Cmp AL, 4 - JE PnP_IsolateNextCard - Mov DMA, AX - - Mov AX, 307h ; LDN 1 - MIDI device - Call PnP_WriteData - - Mov AL, 60h - Call PnP_ReadData - Mov AH, AL - Mov AL, 61h - Call PnP_ReadData ; AX = address. - Test AX, AX - JZ PnP_IsolateNextCard - - Mov SAM9407Port, AX - - Mov Pnp_CardFound, 1 - Jmp PnP_IsolateNextCard - -PnP_IsolateFinished: - Mov AL, PnP_CSN - ShL AL, 1 - Or AL, PnP_CardFound - - Ret - -EndP PnP_Isolate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far ; returns carry clear if succesful - - Push CS - Pop DS - - Xor AL, AL - Mov DX, 279h - Out DX, AL - Out DX, AL - - Mov AL, 6Ah ; Starting value - Mov CX, 32 - -PnP_InitiationKeyLoop: - Out DX, AL - - Mov AH, AL - ShR AH, 1 - Xor AH, AL - ShR AX, 1 - - Dec CX - JNZ PnP_InitiationKeyLoop - -; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h - -PnP_DetectCardPort1: - Mov PnP_ReadPort, 20Fh - Call PnP_Isolate - JZ PnP_DetectCardPort2 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort2: - Mov PnP_ReadPort, 27Bh - Call PnP_Isolate - JZ PnP_DetectCardPort3 - Test AL, 1 - JZ PnP_DetectCardNotFound - Jmp PnP_DetectCardFound - -PnP_DetectCardPort3: - Mov PnP_ReadPort, 213h - Call PnP_Isolate - Test AL, 1 - JNZ PnP_DetectCardFound - -PnP_DetectCardNotFound: - StC - Jmp PnP_DetectEnd - -PnP_DetectCardFound: - ClC - -PnP_DetectEnd: ; Return PnP to wait for key state - Mov AX, 202h - Call PnP_WriteData - Mov EAX, 'Jeff' - - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ESSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Inc Debug - - Inc DX - In AL, DX - Mov AH, AL - Xor AL, AL - Out DX, AL -; Call AD1816Out - - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB ESSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -ESSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE ESSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -ESSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE ESSIRQHandler4 - Assume DS:Nothing - -ESSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -ESSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE ESSIRQHandler5 - - Mov DX, MixTransferRemaining - -ESSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB ESSIRQHandler6 - JE ESSIRQHFilter - - Cmp CS:Stereo, 0 - JE ESSIRQ3QFilterMono - -ESSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -ESSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -ESSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -ESSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilter: - Cmp CS:Stereo, 0 - JE ESSIRQHFilterMono - -ESSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -ESSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -ESSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -ESSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -ESSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -ESSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ ESSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -ESSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL ESSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG ESSIRQHandlerClip2 - -ESSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ ESSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ ESSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -ESSIRQHandlerClip1: - Mov AX, 8000h - Jmp ESSIRQHandler7 - -ESSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp ESSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp ESSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp ESSIRQ3QFilterStereo3 - -EndP ESSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ESSIRQHandler - - XChg [ES:BX], EAX - Mov OldESSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldESSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopAD1816 - - PushA - - Mov AL, 1 - Call AD1816RegisterIn - And BX, 07FFFh ; Disable PIE - Call AD1816RegisterOut - - Mov DX, CS:BasePort - Inc DX - In AL, DX - And AL, Not 80h - Out DX, AL - - Add DL, 7 - In AL, DX - And AL, Not 1 - Out DX, AL - - PopA - Ret - -EndP StopAD1816 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartAD1816 - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov AL, 4 - Call AD1816RegisterIn - - Mov AL, 32 - Call AD1816RegisterIn - Or BX, 08000h - Call AD1816RegisterOut - - Mov AL, 2 ; Sample rate - Mov BX, MixSpeed - Call AD1816RegisterOut - - Mov AL, 8 ; DMA Size - Mov BX, DMASize - ShR BX, 2 - Dec BX - Call AD1816RegisterOut - - Mov DX, BasePort ; Wave Format - Add DL, 8 - - Mov AL, 00010001b - Cmp Stereo, 0 - JE StartAD1816A - - Or AL, 4 - -StartAD1816A: - Out DX, AL - - Mov AL, 1 ; Enable Playback interrupt - Call AD1816RegisterIn - Or BX, 8000h - Call AD1816RegisterOut - - Pop DS - Pop ES - PopA - - Ret - -EndP StartAD1816 - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Mov AX, MixSpeed - Cmp AX, 11050 - JA ClipMixSpeed1 - - Mov MixSpeed, 11050 - -ClipMixSpeed1: - Cmp AX, 55200 - JB ClipMixSpeed2 - - Mov MixSpeed, 55200 - -ClipMixSpeed2: - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset ESSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Call UpdateSoundcardVariables - - Mov DI, 1 - Call SetSAM9407 - - Mov SI, Offset ESSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Push AX - - Call StopAD1816 - Call ResetIRQ - - Pop ES - Mov AH, 49h ; Release MixSegment - Int 21h - - -UnInitSound1: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - Mov AH, 3Eh - Int 21h - -SetMixMode1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - -DMAPort1 EQU $+1 - In AL, 1 - Mov BL, AL - -DMAPort2 EQU $+1 - In AL, 1 - Mov BH, AL - - Mov CS:Debug2, BX - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Push AX - - Call StopAD1816 - Call StartAD1816 - - Pop DI - And DI, 1 - Add DI, 31 - Call SetSAM9407 - - Mov DI, 2 -SetStereo2: - Call SetSAM9407 - Inc DI - Cmp DI, 30 - JBE SetStereo2 - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSSScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSoundcardVariables - - Mov AL, 4 - Mov BX, 3F3Fh - Sub BX, [Word Ptr CS:VolumeTable] - Call AD1816RegisterOut - - Mov AL, 33 - Mov BX, 40h - Call AD1816RegisterOut - - Mov AL, 14 - Xor BX, BX - Call AD1816RegisterOut - - Mov AL, 44 - Xor BX, BX - Call AD1816RegisterOut - - Ret - -EndP UpdateSoundcardVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Mov [CS:VolumeTable+DI], AL - Cmp DI, 31 - JAE SetVariable1 - Cmp DI, 2 - JB SetVariable1 - - Call SetSAM9407 - Ret - -SetVariable1: - Call UpdateSoundcardVariables - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Analog Device's AD1816 +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +PNPSERIALID EQU 0FFFFFFFFh +PNPVENDORID EQU 80719304h + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 +DATAFLAG EQU 200h +ACKFLAG EQU 300h + +Debug DW 0 +Debug2 DW 0 +DMASize DW 2048 + +ESSMsg DB "Sound Track '97 PnP found", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +ESSNoMemoryMsg DB "Sound Track '97 PnP found", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Sound Track '97 PnP reinitialised", 0 + +DriverName DB "ITSTPNP.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +ESSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 +VolumeTable DB 56, 56 + DB 60h, 60h, 0Ch ; Low Band + DB 40h, 40h, 1Bh ; Med Low Band + DB 40h, 40h, 72h ; Med High Band + DB 60h, 60h, 40h ; High Band + DB 0, 0, 0 ; Echo + DB 0, 2 ; Surround + DB 0, 90h, 4, 7Fh, 22h ; Reverb + DB 0, 90h, 2, 40h, 9, 3, 13h ; Chorus + DB 0, 0 ; Phat Stereo Stuff + +IMR DW 0 +OldESSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +SAM9407Reset DW 66 + DW 1BEh, 16Fh, 7Fh, 7Fh, ACKFLAG ; Audio in on + DW 1BEh, 168h, 7Fh, 7Fh, ACKFLAG ; Echo on + DW 1BEh, 16Ch, 7Fh, 7Fh, ACKFLAG ; Reverb on + DW 1BEh, 16Dh, 7Fh, 7Fh, ACKFLAG ; Chorus on + DW 1BEh, 16Bh, 0, 0, ACKFLAG ; Equalizer type + DW 1BEh, 16Eh, 7Fh, 7Fh, ACKFLAG ; Surround on + DW 1BEh, 165h, 7Fh, 7Fh ; Post eff on Audio in + DW 1BEh, 166h, 7Fh, 7Fh ; Post eff on reverb, chorus + DW 1BEh, 133h, 0, 0 ; 2 Speaker + DW 1BEh, 120h, 7Fh, 7Fh ; Stereo input 2 + DW 1BEh, 134h, 0FFh, 0FFh ; Left gain + DW 1BEh, 135h, 0FFh, 0FFh ; Right gain + DW 1BEh, 136h, 0, 0 ; Left pan + DW 1BEh, 137h, 7Fh, 7Fh ; Right pan + DW 1BEh, 107h, 0FFh, 0FFh ; Master volume + +SAM9407EqLBL DW 4 + DW 1BEh, 110h, DATAFLAG, 60h +SAM9407EqLBR DW 4 + DW 1BEh, 114h, DATAFLAG, 60h +SAM9407EqLBF DW 4 + DW 1BEh, 118h, DATAFLAG, 0Ch +SAM9407EqMLBL DW 4 + DW 1BEh, 111h, DATAFLAG, 40h +SAM9407EqMLBR DW 4 + DW 1BEh, 115h, DATAFLAG, 40h +SAM9407EqMLBF DW 4 + DW 1BEh, 119h, DATAFLAG, 1Bh +SAM9407EqMHBL DW 4 + DW 1BEh, 112h, DATAFLAG, 40h +SAM9407EqMHBR DW 4 + DW 1BEh, 116h, DATAFLAG, 40h +SAM9407EqMHBF DW 4 + DW 1BEh, 11Ah, DATAFLAG, 72h +SAM9407EqHBL DW 4 + DW 1BEh, 113h, DATAFLAG, 60h +SAM9407EqHBR DW 4 + DW 1BEh, 117h, DATAFLAG, 60h +SAM9407EqHBF DW 4 + DW 1BEh, 11Bh, DATAFLAG, 0Ch +SAM9407EchoLevel DW 4 + DW 1BEh, 128h, DATAFLAG, 0 +SAM9407EchoTime DW 4 + DW 1BEh, 129h, DATAFLAG, 2Bh +SAM9407EchoFeed DW 4 + DW 1BEh, 12Ah, DATAFLAG, 40h +SAM9407SurroundVolume DW 4 + DW 1BEh, 130h, DATAFLAG, 0 +SAM9407SurroundDelay DW 4 + DW 1BEh, 131h, DATAFLAG, 2 +SAM9407ReverbSend DW 4 + DW 1BEh, 127h, DATAFLAG, 0 +SAM9407ReverbVolume DW 3 + DW 1BEh, 13Ah, DATAFLAG +SAM9407ReverbType DW 4 + DW 1BEh, 169h, DATAFLAG, 4 +SAM9407ReverbTime DW 3 + DW 1BEh, 178h, DATAFLAG +SAM9407ReverbFeedback DW 3 + DW 1BEh, 179h, DATAFLAG +SAM9407ChorusSend DW 4 + DW 1BEh, 124h, DATAFLAG, 0 +SAM9407ChorusVolume DW 3 + DW 1BEh, 13Bh, DATAFLAG +SAM9407ChorusType DW 4 + DW 1BEh, 16Ah, DATAFLAG, 2 +SAM9407ChorusDelay DW 3 + DW 1BEh, 174h, DATAFLAG +SAM9407ChorusFeedback DW 3 + DW 1BEh, 175h, DATAFLAG +SAM9407ChorusRate DW 3 + DW 1BEh, 176h, DATAFLAG +SAM9407ChorusDepth DW 3 + DW 1BEh, 177h, DATAFLAG +SAM9407Mono DW 4 + DW 1BEh, 132h, 7Fh, 0 +SAM9407Stereo DW 4 + DW 1BEh, 132h, 0, 0 + +SAM9407Strings DW Offset SAM9407Reset ;1 + DW Offset SAM9407EqLBL, Offset SAM9407EqLBR + DW Offset SAM9407EqLBF + DW Offset SAM9407EqMLBL, Offset SAM9407EqMLBR + DW Offset SAM9407EqMLBF + DW Offset SAM9407EqMHBL, Offset SAM9407EqMHBR + DW Offset SAM9407EqMHBF + DW Offset SAM9407EqHBL, Offset SAM9407EqHBR + DW Offset SAM9407EqHBF + DW Offset SAM9407EchoLevel ; 14 + DW Offset SAM9407EchoTime + DW Offset SAM9407EchoFeed + DW Offset SAM9407SurroundVolume ; 17 + DW Offset SAM9407SurroundDelay + DW Offset SAM9407ReverbSend ; 19 + DW Offset SAM9407ReverbVolume + DW Offset SAM9407ReverbType + DW Offset SAM9407ReverbTime + DW Offset SAM9407ReverbFeedback ; 23 + DW Offset SAM9407ChorusSend ; 24 + DW Offset SAM9407ChorusVolume + DW Offset SAM9407ChorusType + DW Offset SAM9407ChorusDelay + DW Offset SAM9407ChorusFeedback + DW Offset SAM9407ChorusRate + DW Offset SAM9407ChorusDepth ; 30 + DW Offset SAM9407Mono ; 31 + DW Offset SAM9407Stereo + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +WSSScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW Near Ptr EmptyObject + DW Near Ptr EmptyObject + DW Near Ptr EmptyObject + + DW Near Ptr SAM9407PortText ; 21 + DW Near Ptr SAM9407ParametersText + DW Near Ptr SAM9407ParametersBox + + DW Near Ptr EqLBL ; 24 + DW Near Ptr EqLBR + DW Near Ptr EqLBF + + DW Near Ptr EqMLBL + DW Near Ptr EqMLBR + DW Near Ptr EqMLBF + + DW Near Ptr EqMHBL + DW Near Ptr EqMHBR + DW Near Ptr EqMHBF + + DW Near Ptr EqHBL + DW Near Ptr EqHBR + DW Near Ptr EqHBF + + DW Near Ptr EchoLevel ; 33 + DW Near Ptr EchoTime + DW Near Ptr EchoFeedback + + DW Near Ptr SurroundVolume + DW Near Ptr SurroundDelay + + DW Near Ptr ReverbSend ; 38 + DW Near Ptr ReverbVolume + DW Near Ptr ReverbType + DW Near Ptr ReverbTime + DW Near Ptr ReverbFeedback + + DW Near Ptr ChorusSend + DW Near Ptr ChorusVolume + DW Near Ptr ChorusType + DW Near Ptr ChorusDelay + DW Near Ptr ChorusFeedback + DW Near Ptr ChorusRate + DW Near Ptr ChorusDepth + + + DW 0 + +WSSHeaderLine DW 10 + DB "Sound Track '97 PnP Codec Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 28, 48 + DB 21h + DB "Sound Track Codec Driver 1.0 for Impulse Tracker", 0 + +SAM9407PortText DW 1 + DB 28, 47 + DB 21h + DB "Sound Track SAM9407 Port ", 0FDh, "Xh", 0 +SAM9407Port DW 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right", 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 14 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MasterVolumeRight DW 14 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 8 + +MixModeText DW 1 + DB 2, 17 + DB 20h + DB "Mixing Rate: ", 0FDh, "D", 13, 13 + DB "Mixing mode", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 21, 32, 23, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 24, 32, 26, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 27, 32, 29, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 30, 32, 32, 8 + DB 0 + DB " 32 Bit, Ultra Quality", 0 + +FilterText DW 1 + DB 2, 34 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 36, 29, 38, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 39, 29, 41, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12 +ST42B DW 24, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 42, 29, 44, 8 + DB 0 + DB " 75% Filter", 0 + +SAM9407ParametersText DW 1 + DB 36, 14 + DB 20h + DB "Low Band Left", 13 + DB "Low Band Right", 13 + DB "Low Band Frequency", 13 + DB "Med Low Band Left", 13 + DB "Med Low Band Right", 13 + DB "Med Low Band Frequency", 13 + DB "Med High Band Left", 13 + DB "Med High Band Right", 13 + DB "Med High Band Frequency", 13 + DB "High Band Left", 13 + DB "High Band Right", 13 + DB "High Band Frequency", 13 + DB "Echo Level", 13 + DB "Echo Time", 13 + DB "Echo Feedback", 13 + DB "Surround Volume", 13 + DB "Surround Delay", 13 + DB "Reverb Send", 13 + DB "Reverb Volume", 13 + DB "Reverb Type", 13 + DB "Reverb Time", 13 + DB "Reverb Feedback", 13 + DB "Chorus Send", 13 + DB "Chorus Volume", 13 + DB "Chorus Type", 13 + DB "Chorus Delay", 13 + DB "Chorus Feedback", 13 + DB "Chorus Rate", 13 + DB "Chorus Depth", 13 + DB 0 + +EqLBL DW 14 + DB 60, 14 + DW 0, 127 + DW 9, 2 + DW 13, 25, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBR DW 14 + DB 60, 15 + DW 0, 127 + DW 9, 3 + DW 24, 26, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqLBF DW 14 + DB 60, 16 + DW 0, 127 + DW 9, 4 + DW 25, 27, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBL DW 14 + DB 60, 17 + DW 0, 127 + DW 9, 5 + DW 26, 28, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBR DW 14 + DB 60, 18 + DW 0, 127 + DW 9, 6 + DW 27, 29, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMLBF DW 14 + DB 60, 19 + DW 0, 127 + DW 9, 7 + DW 28, 30, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBL DW 14 + DB 60, 20 + DW 0, 127 + DW 9, 8 + DW 29, 31, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBR DW 14 + DB 60, 21 + DW 0, 127 + DW 9, 9 + DW 30, 32, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqMHBF DW 14 + DB 60, 22 + DW 0, 127 + DW 9, 10 + DW 31, 33, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBL DW 14 + DB 60, 23 + DW 0, 127 + DW 9, 11 + DW 32, 34, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBR DW 14 + DB 60, 24 + DW 0, 127 + DW 9, 12 + DW 33, 35, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EqHBF DW 14 + DB 60, 25 + DW 0, 127 + DW 9, 13 + DW 34, 36, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoLevel DW 14 + DB 60, 26 + DW 0, 127 + DW 9, 15 + DW 35, 37, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoTime DW 14 + DB 60, 27 + DW 0, 127 + DW 9, 14 + DW 36, 38, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +EchoFeedback DW 14 + DB 60, 28 + DW 0, 127 + DW 9, 16 + DW 37, 39, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundVolume DW 14 + DB 60, 29 + DW 0, 255 + DW 9, 17 + DW 38, 40, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SurroundDelay DW 14 + DB 60, 30 + DW 0, 127 + DW 9, 18 + DW 39, 41, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbSend DW 14 + DB 60, 31 + DW 0, 127 + DW 9, 19 + DW 40, 42, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbVolume DW 14 + DB 60, 32 + DW 0, 255 + DW 9, 20 + DW 41, 43, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + + +ReverbType DW 14 + DB 60, 33 + DW 0, 7 + DW 9, 21 + DW 42, 44, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbTime DW 14 + DB 60, 34 + DW 0, 127 + DW 9, 22 + DW 43, 45, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ReverbFeedback DW 14 + DB 60, 35 + DW 0, 127 + DW 9, 23 + DW 44, 46, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusSend DW 14 + DB 60, 36 + DW 0, 127 + DW 9, 24 + DW 45, 47, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusVolume DW 14 + DB 60, 37 + DW 0, 255 + DW 9, 25 + DW 46, 48, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusType DW 14 + DB 60, 38 + DW 0, 7 + DW 9, 26 + DW 47, 49, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDelay DW 14 + DB 60, 39 + DW 0, 127 + DW 9, 27 + DW 48, 50, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusFeedback DW 14 + DB 60, 40 + DW 0, 127 + DW 9, 28 + DW 49, 51, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusRate DW 14 + DB 60, 41 + DW 0, 127 + DW 9, 29 + DW 50, 52, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +ChorusDepth DW 14 + DB 60, 42 + DW 0, 127 + DW 9, 30 + DW 51, 0FFFFh, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + DW 14 + +SAM9407ParametersBox DW 0 + DB 59, 13, 75, 43 + DB 25 + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dmasirq.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816Wait + + PushA + Xor CX, CX + Mov DX, CS:BasePort + +AD1816Wait1: + In AL, DX + Test AL, 80h + LoopZ AD1816Wait1 + + PopA + Ret + +EndP AD1816Wait + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816RegisterOut ; AL = indirect register, BX = contents + + Call AD1816Wait + + Push DX + PushF + + ClI + + Mov DX, CS:BasePort + Out DX, AL + Add DL, 2 + + Mov AL, BL + Out DX, AL + Inc DX + Mov AL, BH + Out DX, AL + + PopF + Pop DX + + Ret + +EndP AD1816RegisterOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AD1816RegisterIn ; AL = register + ; Returns BX + + Call AD1816Wait + + Push AX + Push DX + + Mov DX, CS:BasePort + Out DX, AL + Add DL, 2 + + In AL, DX + Mov BL, AL + Inc DX + In AL, DX + Mov BH, AL + + Pop DX + Pop AX + + Ret + +EndP AD1816RegisterIn + +; ÄÄ SAM9407InByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407InByte ; Returns AL + + Push CX DX + + Mov DX, CS:SAM9407Port + Inc DX + + Mov CX, 1000h + +SAM9407InByte1: + In AL, DX + Test AL, 80h + LoopNZ SAM9407InByte1 + + Dec DX + In AL, DX + Pop DX CX + + Ret + +EndP SAM9407InByte + +; ÄÄ ST97SendByte ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SAM9407SendByte ; DX = port, AL = data + + Push AX CX DX + Mov DX, CS:SAM9407Port + Mov CX, 1000h + Inc DX + +SAM9407SendByte1: + In AL, DX + Test AL, 40h + LoopNZ SAM9407SendByte1 + + Pop DX CX AX + + Out DX, AL + + Ret + +EndP SAM9407SendByte + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSAM9407 ; DI = index. 1 = full reinit. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + LEA SI, [SAM9407Strings+EDI+EDI-2] + Mov SI, [SI] + + LodsW + Mov CX, AX + +SetSAM9407_1: +; AH = 0 = normal data, 1 = command, 2 = param, 3 = ack. + + Mov DX, SAM9407Port + Test DX, DX + JZ NoSAM9407 + + LodsW + + Cmp AH, 2 + JB SetSAM9407_3 + JA SetSAM9407_4 + + Mov AL, [VolumeTable+DI] + Jmp SetSAM9407_2 + +SetSAM9407_4: + Call SAM9407InByte + Test AL, AL + JNZ SetSAM9407_4 + Jmp SetSAM9407_5 + +SetSAM9407_3: + And AH, 1 + Add DL, AH + +SetSAM9407_2: + Call SAM9407SendByte + +SetSAM9407_5: + Dec CX + JNZ SetSAM9407_1 + + +NoSAM9407: + Pop DS + PopA + + Ret + +EndP SetSAM9407 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + + Mov AX, 1 + Ret + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PnP_SerialID DD 0 +PnP_VendorID DD 0 +PnP_ReadPort DW 0 +PnP_CSN DB 0 +PnP_CardFound DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Delay + Assume DS:Driver + + Push AX CX + + Mov CX, 180h +PnP_Delay1: + In AL, 21h + Loop PnP_Delay1 + + Pop CX AX + Ret + +EndP PnP_Delay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_WriteData + + Mov DX, 279h + Out DX, AL + + Mov AL, AH + Mov DH, 0Ah + Out DX, AL + Ret + +EndP PnP_WriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_ReadData + + Mov DX, 279h + Out DX, AL + + Mov DX, PnP_ReadPort + In AL, DX + + Ret + +EndP PnP_ReadData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PnP_Isolate + + Mov AX, 402h + Call Pnp_WriteData ; Reset CSNs + +PnP_IsolateNextCard: + Mov AX, 0003h + Call PnP_WriteData ; Wake[0] + + Mov AX, PnP_ReadPort + ShL AX, 6 + Xor AL, AL + Call PnP_WriteData ; Set Read Data port. + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov AL, 1 ; Serial Isolation + Mov DX, 279h + Out DX, AL + + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + Call PnP_Delay + + Mov BL, 6Ah + Mov CX, 64 + Mov DX, PnP_ReadPort + + ClI + +PnP_Isolate1: + ShR PnP_SerialID, 1 + RCR PnP_VendorID, 1 + + Mov BH, BL + ShR BH, 1 + Xor BH, BL + ShR BX, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + + Cmp AX, 55AAh + JNE PnP_Isolate2 + + Xor BL, 80h + Or PnP_SerialID, 80000000h + +PnP_Isolate2: + Dec CX + JNZ PnP_Isolate1 + + Mov CX, 8 + Xor BH, BH + +PnP_Isolate3: + ShR BH, 1 + + In AL, DX + Mov AH, AL + Call PnP_Delay + In AL, DX + Call PnP_Delay + Cmp AX, 55AAh + JNE PnP_Isolate4 + + Or BH, 80h + +PnP_Isolate4: + Dec CX + JNZ PnP_Isolate3 + + StI + + Cmp BL, BH ; Matching Checksum? + JNE PnP_IsolateFinished + + ; assign CSN + Inc PnP_CSN + + Mov AL, 6 + MOv AH, PnP_CSN + Call PnP_WriteData + + Cmp PnP_VendorID, PNPVENDORID + JNE PnP_IsolateNextCard + Cmp PnP_SerialID, PNPSERIALID + JNE PnP_IsolateNextCard + + Mov AL, 3 + Call PnP_WriteData + Mov AX, 007h + Call PnP_WriteData + + Mov AL, 64h + Call PnP_ReadData + Mov AH, AL + Mov AL, 65h + Call PnP_ReadData ; AX = address. + Cmp BasePort, 0FFFFh + JE PnPBasePortOK + + Cmp BasePort, AX + JNE PnP_IsolateNextCard + +PnPBasePortOK: + Mov BasePort, AX + + Mov AL, 70h + Call PnP_ReadData ; AL[3:0] = IRQ + And AX, 15 + JZ PnP_IsolateNextCard + Mov IRQ, AX + + Mov AL, 74h + Call PnP_ReadData ; AL[2:0] = DMA + And AX, 7 + Cmp AL, 4 + JE PnP_IsolateNextCard + Mov DMA, AX + + Mov AX, 307h ; LDN 1 - MIDI device + Call PnP_WriteData + + Mov AL, 60h + Call PnP_ReadData + Mov AH, AL + Mov AL, 61h + Call PnP_ReadData ; AX = address. + Test AX, AX + JZ PnP_IsolateNextCard + + Mov SAM9407Port, AX + + Mov Pnp_CardFound, 1 + Jmp PnP_IsolateNextCard + +PnP_IsolateFinished: + Mov AL, PnP_CSN + ShL AL, 1 + Or AL, PnP_CardFound + + Ret + +EndP PnP_Isolate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far ; returns carry clear if succesful + + Push CS + Pop DS + + Xor AL, AL + Mov DX, 279h + Out DX, AL + Out DX, AL + + Mov AL, 6Ah ; Starting value + Mov CX, 32 + +PnP_InitiationKeyLoop: + Out DX, AL + + Mov AH, AL + ShR AH, 1 + Xor AH, AL + ShR AX, 1 + + Dec CX + JNZ PnP_InitiationKeyLoop + +; Try three ports before concluding no PnP cards: 20Fh, 27Bh, 213h + +PnP_DetectCardPort1: + Mov PnP_ReadPort, 20Fh + Call PnP_Isolate + JZ PnP_DetectCardPort2 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort2: + Mov PnP_ReadPort, 27Bh + Call PnP_Isolate + JZ PnP_DetectCardPort3 + Test AL, 1 + JZ PnP_DetectCardNotFound + Jmp PnP_DetectCardFound + +PnP_DetectCardPort3: + Mov PnP_ReadPort, 213h + Call PnP_Isolate + Test AL, 1 + JNZ PnP_DetectCardFound + +PnP_DetectCardNotFound: + StC + Jmp PnP_DetectEnd + +PnP_DetectCardFound: + ClC + +PnP_DetectEnd: ; Return PnP to wait for key state + Mov AX, 202h + Call PnP_WriteData + Mov EAX, 'Jeff' + + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ESSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Inc Debug + + Inc DX + In AL, DX + Mov AH, AL + Xor AL, AL + Out DX, AL +; Call AD1816Out + + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB ESSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +ESSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE ESSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +ESSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE ESSIRQHandler4 + Assume DS:Nothing + +ESSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +ESSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE ESSIRQHandler5 + + Mov DX, MixTransferRemaining + +ESSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB ESSIRQHandler6 + JE ESSIRQHFilter + + Cmp CS:Stereo, 0 + JE ESSIRQ3QFilterMono + +ESSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +ESSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +ESSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +ESSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilter: + Cmp CS:Stereo, 0 + JE ESSIRQHFilterMono + +ESSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +ESSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +ESSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +ESSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +ESSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +ESSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ ESSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +ESSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL ESSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG ESSIRQHandlerClip2 + +ESSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ ESSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ ESSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +ESSIRQHandlerClip1: + Mov AX, 8000h + Jmp ESSIRQHandler7 + +ESSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp ESSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp ESSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp ESSIRQ3QFilterStereo3 + +EndP ESSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset ESSIRQHandler + + XChg [ES:BX], EAX + Mov OldESSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldESSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopAD1816 + + PushA + + Mov AL, 1 + Call AD1816RegisterIn + And BX, 07FFFh ; Disable PIE + Call AD1816RegisterOut + + Mov DX, CS:BasePort + Inc DX + In AL, DX + And AL, Not 80h + Out DX, AL + + Add DL, 7 + In AL, DX + And AL, Not 1 + Out DX, AL + + PopA + Ret + +EndP StopAD1816 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartAD1816 + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov AL, 4 + Call AD1816RegisterIn + + Mov AL, 32 + Call AD1816RegisterIn + Or BX, 08000h + Call AD1816RegisterOut + + Mov AL, 2 ; Sample rate + Mov BX, MixSpeed + Call AD1816RegisterOut + + Mov AL, 8 ; DMA Size + Mov BX, DMASize + ShR BX, 2 + Dec BX + Call AD1816RegisterOut + + Mov DX, BasePort ; Wave Format + Add DL, 8 + + Mov AL, 00010001b + Cmp Stereo, 0 + JE StartAD1816A + + Or AL, 4 + +StartAD1816A: + Out DX, AL + + Mov AL, 1 ; Enable Playback interrupt + Call AD1816RegisterIn + Or BX, 8000h + Call AD1816RegisterOut + + Pop DS + Pop ES + PopA + + Ret + +EndP StartAD1816 + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Mov AX, MixSpeed + Cmp AX, 11050 + JA ClipMixSpeed1 + + Mov MixSpeed, 11050 + +ClipMixSpeed1: + Cmp AX, 55200 + JB ClipMixSpeed2 + + Mov MixSpeed, 55200 + +ClipMixSpeed2: + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset ESSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Call UpdateSoundcardVariables + + Mov DI, 1 + Call SetSAM9407 + + Mov SI, Offset ESSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Push AX + + Call StopAD1816 + Call ResetIRQ + + Pop ES + Mov AH, 49h ; Release MixSegment + Int 21h + + +UnInitSound1: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + Mov AH, 3Eh + Int 21h + +SetMixMode1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + +DMAPort1 EQU $+1 + In AL, 1 + Mov BL, AL + +DMAPort2 EQU $+1 + In AL, 1 + Mov BH, AL + + Mov CS:Debug2, BX + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Push AX + + Call StopAD1816 + Call StartAD1816 + + Pop DI + And DI, 1 + Add DI, 31 + Call SetSAM9407 + + Mov DI, 2 +SetStereo2: + Call SetSAM9407 + Inc DI + Cmp DI, 30 + JBE SetStereo2 + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSSScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSoundcardVariables + + Mov AL, 4 + Mov BX, 3F3Fh + Sub BX, [Word Ptr CS:VolumeTable] + Call AD1816RegisterOut + + Mov AL, 33 + Mov BX, 40h + Call AD1816RegisterOut + + Mov AL, 14 + Xor BX, BX + Call AD1816RegisterOut + + Mov AL, 44 + Xor BX, BX + Call AD1816RegisterOut + + Ret + +EndP UpdateSoundcardVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Mov [CS:VolumeTable+DI], AL + Cmp DI, 31 + JAE SetVariable1 + Cmp DI, 2 + JB SetVariable1 + + Call SetSAM9407 + Ret + +SetVariable1: + Call UpdateSoundcardVariables + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/TEST.ASM b/SoundDrivers/TEST.ASM index ea4a7ed..974528f 100755 --- a/SoundDrivers/TEST.ASM +++ b/SoundDrivers/TEST.ASM @@ -1,306 +1,306 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -; ÄÄ Variables ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -TestDriverMsg DB "Test Driver", 13 - DB "(No sound output)", 0 -TestReinitMsg DB "Test driver: Reinitialise received", 0 -Filler DB 8039 Dup (0) - -; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EmptyFunction Far - - Xor AX, AX - StC - Ret - -EndP EmptyFunction - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectCard - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - - Mov SI, Offset TestDriverMsg - - ClC - Ret - -EndP InitSound - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - Mov SI, Offset TestReinitMsg - Mov BX, 200 - Call SetInfoLine - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Ret - -EndP UnInitSound - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Call SaveEMSPageFrame - Call Update - Call RestoreEMSPageFrame - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Xor AX, AX - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - DW 0 ; Stop after play flag. -DefaultChannels DW 64 - DW 0 ; Flags, MIDI, Hiqual, Waveform - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +; ÄÄ Variables ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +TestDriverMsg DB "Test Driver", 13 + DB "(No sound output)", 0 +TestReinitMsg DB "Test driver: Reinitialise received", 0 +Filler DB 8039 Dup (0) + +; ÄÄ EmptyFunction ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EmptyFunction Far + + Xor AX, AX + StC + Ret + +EndP EmptyFunction + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectCard + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + + Mov SI, Offset TestDriverMsg + + ClC + Ret + +EndP InitSound + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + Mov SI, Offset TestReinitMsg + Mov BX, 200 + Call SetInfoLine + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Ret + +EndP UnInitSound + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Call SaveEMSPageFrame + Call Update + Call RestoreEMSPageFrame + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Xor AX, AX + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + DW 0 ; Stop after play flag. +DefaultChannels DW 64 + DW 0 ; Flags, MIDI, Hiqual, Waveform + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/VSND.ASM b/SoundDrivers/VSND.ASM index 50a21b0..97e3633 100755 --- a/SoundDrivers/VSND.ASM +++ b/SoundDrivers/VSND.ASM @@ -1,1281 +1,1281 @@ -; -; Impulse Tracker VSound Driver -; -; Client for VSound.VxD to interface with Windows. -; Output is always 16-bit stereo, 44100Hz. -; -; - -STEREOENABLED EQU 1 -MIXRESOLUTION EQU 32 ; 32 bit mixing -OUTPUTFILTERENABLED EQU 0 -TIMERCONST EQU 11932 ; 100 times a second -MIXTABLESIZE EQU 2*256*65 -DMABUFFERLENGTH EQU 0 ; Does not have a DMA buffer in the mixsegment - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -; ÄÄ Variables ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -OldTimerIRQHandler DD 0 -TimerAccumulator DW 0 - -VSoundNoMemoryMsg DB "Impulse Tracker VSound Driver", 13 - DB "Error: Insufficient memory", 0 -VSoundDriverMsg DB "Impulse Tracker VSound Driver", 0 - -NoReinitMsg DB "VSound driver should NOT require reinitialisation ", 0 - -VSoundIDBuffer DB 8 Dup (0) -VSoundID DB "ITVXDDRV" - -DefaultDriverName DB "ITVSOUND.DRV" -DriverName DD 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 -MixSegment DW 0 - -BytesToMix DW 1000 -MixTransferOffset DW 0 -MixTransferRemaining DW 0 -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 4 -MixMode DW 0 -MixModeOffset DW 0 - -VSoundScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr VSoundHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr ServerText - DW Near Ptr FrequencyText - - DW 0 - - -VSoundHeaderLine DW 10 - DB "Virtual Sound Driver", 0 - -ServerText DW 1 - DB 2, 47 - DB 21h -VSoundString DB 64 Dup (0) - -FrequencyText DW 1 - DB 2, 48 - DB 21h - DB "Playback Frequency: ", 0FDh, "DHz, Buffer Threshold: ", 0FDh, "D bytes", 0 -Threshold DW 21*1024 -MixSpeed DW 44100 - DW 0 - -DriverText DW 1 - DB 2, 46 - DB 21h - DB "Virtual Sound Driver 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MixModeText DW 1 - DB 2, 14 - DB 20h - DB "Mixing Mode", 0 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 16, 32, 18, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 19, 32, 21, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 22, 32, 24, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -ALIGN 2 - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -include nodebug.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Driver - - Mov Forced, AL - - Cmp BX, 217h - JAE DetectCardUseDriver - - Mov CX, DS - ShL ECX, 16 - Mov CX, Offset DefaultDriverName - -DetectCardUseDriver: - Mov DriverName, ECX - -; First need to find if VSound server is setup. - Mov DX, BasePort - Cmp DX, 0FFFFh - JNE PortSpecified - - Mov DX, 400h - Jmp TestPort - -PortSpecified: - Cmp AL, 1 - JNE DetectCardError - - -TestPort: - Mov BasePort, DX - - Xor AL, AL - Out DX, AL ; Reset, get identification - - Mov CX, 8 - Mov DI, Offset VSoundIDBuffer - Rep InsB - - Mov SI, Offset VSoundIDBuffer ; DI now points to VSoundID - Mov CX, 8 - RepE CmpsB - JNE DetectCardError - -; We've found a VSound server. Get ServerString - - Mov AL, 1 - Out DX, AL - ; DI now points to ServerString. - Mov DI, Offset VSoundString - Mov CX, 60 - Rep InsB - - Mov DI, Offset Threshold - Mov CX, 4 - Rep InsB - - Xor DWord Ptr [Threshold], 0FFFFFFFFh - - Mov EAX, 'Jeff' - DB 85h - -DetectCardError: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InVSound DB -1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VSoundFillBuffer - Assume DS:Nothing - -VSoundHandler3: - - Mov DX, BasePort - Mov AL, 2 - Out DX, AL - In AL, DX - Mov AH, AL - In AL, DX ; AX = BufferSize - - Cmp AX, Threshold - JB VSoundHandler4 - - Ret - -VSoundHandler4: - Call Update - Call MixSamples - -; Convert the buffer - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov CX, BytesToMix ; CX = number of 32-bit samples to mix. - Mov DI, SI - -; Transfer the buffer - Cmp Stereo, 0 - JE VSoundHandlerMono - -VSoundHandlerStereo: - Mov EAX, [SI] - Mov EBX, [SI+4] - - SAR EAX, 13 - SAR EBX, 13 - - Cmp EAX, -8000h - JL VSoundHandlerStereoClip1 - Cmp EAX, 7FFFh - JG VSoundHandlerStereoClip2 - -VSoundHandlerStereo1: - Cmp EBX, -8000h - JL VSoundHandlerStereoClip3 - Cmp EBX, 7FFFh - JG VSoundHandlerStereoClip4 - -VSoundHandlerStereo2: - Mov [DI], AX - Add SI, 8 - Mov [DI+2], BX - Add DI, 4 - - Loop VSoundHandlerStereo - Jmp VSoundHandlerSend - -VSoundHandlerMono: - Mov EAX, [SI] - SAR EAX, 14 - - Cmp EAX, -8000h - JL VSoundHandlerMonoClip1 - Cmp EAX, 7FFFh - JG VSoundHandlerMonoClip2 - -VSoundHandlerMono1: - Mov [DI], AX - Add SI, 8 - Mov [DI+2], AX - Add DI, 4 - - Loop VSoundHandlerMono - -VSoundHandlerSend: - Mov CX, BytesToMix - Mov DX, BasePort - ShL CX, 2 - Add DX, 2 - Mov SI, MixTransferOffset - Rep OutsB - - Jmp VSoundHandler3 - -VSoundHandlerStereoClip1: - Mov AX, 8000h - Jmp VSoundHandlerStereo1 - -VSoundHandlerStereoClip2: - Mov AX, 7FFFh - Jmp VSoundHandlerStereo1 - -VSoundHandlerStereoClip3: - Mov BX, 8000h - Jmp VSoundHandlerStereo2 - -VSoundHandlerStereoClip4: - Mov BX, 7FFFh - Jmp VSoundHandlerStereo2 - - -VSoundHandlerMonoClip1: - Mov AX, 8000h - Jmp VSoundHandlerMono1 - -VSoundHandlerMonoClip2: - Mov AX, 7FFFh - Jmp VSoundHandlerMono1 - - -EndP VSoundFillBuffer - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VSoundHandler - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Add TimerAccumulator, TIMERCONST - JC VSoundHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp VSoundHandler2 - -VSoundHandler1: - PushF - Call [OldTimerIRQHandler] - -VSoundHandler2: - Add InVSound, 1 - JNC VSoundExit - - Call SaveEMSPageFrame - - Assume DS:Nothing - Call VSoundFillBuffer - - Call RestoreEMSPageFrame - -VSoundExit: - Pop ES - Pop DS - PopAD - - Sub CS:InVSound, 1 - IRet - -EndP VSoundHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL ; bump the interrupt to be called - ; 100 times a second. - Mov AX, TIMERCONST - Out 40h, AL - Mov AL, AH - Out 40h, AL - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset VSoundHandler - - ClI - - XChg [ES:20h], EAX ; Hook to timer interrupt - Mov CS:OldTimerIRQHandler, EAX - - StI - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Xor AL, AL - Out 40h, AL ; Interrupt called at normal 18.2 times - Out 40h, AL - - Mov EAX, CS:OldTimerIRQHandler - Mov [ES:20h], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - ; Parags to allocate = (8/(.4*31*16))*MixSpeed + 2080 - ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + 2080 - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - Mov BX, DX - Mov AH, 48h - Int 21h - - Mov SI, Offset VSoundNoMemoryMsg - JNC InitSound1 - - Pop ES - Ret - -InitSound1: - Mov MixSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset VSoundDriverMsg - Mov AX, BasePort - - ClC - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - - Mov SI, Offset NoReinitMsg - Mov BX, 40 - Call SetInfoLine - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Mov DS, Word Ptr [CS:DriverName+2] - Mov DX, Word Ptr [CS:DriverName] - - Mov AX, 3D02h ; Read write access - Int 21h - - Push CS - Pop DS - Assume DS:Driver - - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Mov DX, BasePort - Mov AL, 3 - Out DX, AL - - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - ClI - Add CS:InVSound, 1 - JNC Poll1 - - Call VSoundFillBuffer - -Poll1: - Sub CS:InVSound, 1 - StI - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - Assume DS:Nothing - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, AX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Dec CX - JNZ SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset VSoundScreenList - - ClC - - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - DW 0 -DefaultChannels DW 128 - DW 0 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Impulse Tracker VSound Driver +; +; Client for VSound.VxD to interface with Windows. +; Output is always 16-bit stereo, 44100Hz. +; +; + +STEREOENABLED EQU 1 +MIXRESOLUTION EQU 32 ; 32 bit mixing +OUTPUTFILTERENABLED EQU 0 +TIMERCONST EQU 11932 ; 100 times a second +MIXTABLESIZE EQU 2*256*65 +DMABUFFERLENGTH EQU 0 ; Does not have a DMA buffer in the mixsegment + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +; ÄÄ Variables ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +OldTimerIRQHandler DD 0 +TimerAccumulator DW 0 + +VSoundNoMemoryMsg DB "Impulse Tracker VSound Driver", 13 + DB "Error: Insufficient memory", 0 +VSoundDriverMsg DB "Impulse Tracker VSound Driver", 0 + +NoReinitMsg DB "VSound driver should NOT require reinitialisation ", 0 + +VSoundIDBuffer DB 8 Dup (0) +VSoundID DB "ITVXDDRV" + +DefaultDriverName DB "ITVSOUND.DRV" +DriverName DD 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 +MixSegment DW 0 + +BytesToMix DW 1000 +MixTransferOffset DW 0 +MixTransferRemaining DW 0 +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 4 +MixMode DW 0 +MixModeOffset DW 0 + +VSoundScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr VSoundHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr ServerText + DW Near Ptr FrequencyText + + DW 0 + + +VSoundHeaderLine DW 10 + DB "Virtual Sound Driver", 0 + +ServerText DW 1 + DB 2, 47 + DB 21h +VSoundString DB 64 Dup (0) + +FrequencyText DW 1 + DB 2, 48 + DB 21h + DB "Playback Frequency: ", 0FDh, "DHz, Buffer Threshold: ", 0FDh, "D bytes", 0 +Threshold DW 21*1024 +MixSpeed DW 44100 + DW 0 + +DriverText DW 1 + DB 2, 46 + DB 21h + DB "Virtual Sound Driver 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode", 0 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +ALIGN 2 + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +include nodebug.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Driver + + Mov Forced, AL + + Cmp BX, 217h + JAE DetectCardUseDriver + + Mov CX, DS + ShL ECX, 16 + Mov CX, Offset DefaultDriverName + +DetectCardUseDriver: + Mov DriverName, ECX + +; First need to find if VSound server is setup. + Mov DX, BasePort + Cmp DX, 0FFFFh + JNE PortSpecified + + Mov DX, 400h + Jmp TestPort + +PortSpecified: + Cmp AL, 1 + JNE DetectCardError + + +TestPort: + Mov BasePort, DX + + Xor AL, AL + Out DX, AL ; Reset, get identification + + Mov CX, 8 + Mov DI, Offset VSoundIDBuffer + Rep InsB + + Mov SI, Offset VSoundIDBuffer ; DI now points to VSoundID + Mov CX, 8 + RepE CmpsB + JNE DetectCardError + +; We've found a VSound server. Get ServerString + + Mov AL, 1 + Out DX, AL + ; DI now points to ServerString. + Mov DI, Offset VSoundString + Mov CX, 60 + Rep InsB + + Mov DI, Offset Threshold + Mov CX, 4 + Rep InsB + + Xor DWord Ptr [Threshold], 0FFFFFFFFh + + Mov EAX, 'Jeff' + DB 85h + +DetectCardError: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InVSound DB -1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VSoundFillBuffer + Assume DS:Nothing + +VSoundHandler3: + + Mov DX, BasePort + Mov AL, 2 + Out DX, AL + In AL, DX + Mov AH, AL + In AL, DX ; AX = BufferSize + + Cmp AX, Threshold + JB VSoundHandler4 + + Ret + +VSoundHandler4: + Call Update + Call MixSamples + +; Convert the buffer + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov CX, BytesToMix ; CX = number of 32-bit samples to mix. + Mov DI, SI + +; Transfer the buffer + Cmp Stereo, 0 + JE VSoundHandlerMono + +VSoundHandlerStereo: + Mov EAX, [SI] + Mov EBX, [SI+4] + + SAR EAX, 13 + SAR EBX, 13 + + Cmp EAX, -8000h + JL VSoundHandlerStereoClip1 + Cmp EAX, 7FFFh + JG VSoundHandlerStereoClip2 + +VSoundHandlerStereo1: + Cmp EBX, -8000h + JL VSoundHandlerStereoClip3 + Cmp EBX, 7FFFh + JG VSoundHandlerStereoClip4 + +VSoundHandlerStereo2: + Mov [DI], AX + Add SI, 8 + Mov [DI+2], BX + Add DI, 4 + + Loop VSoundHandlerStereo + Jmp VSoundHandlerSend + +VSoundHandlerMono: + Mov EAX, [SI] + SAR EAX, 14 + + Cmp EAX, -8000h + JL VSoundHandlerMonoClip1 + Cmp EAX, 7FFFh + JG VSoundHandlerMonoClip2 + +VSoundHandlerMono1: + Mov [DI], AX + Add SI, 8 + Mov [DI+2], AX + Add DI, 4 + + Loop VSoundHandlerMono + +VSoundHandlerSend: + Mov CX, BytesToMix + Mov DX, BasePort + ShL CX, 2 + Add DX, 2 + Mov SI, MixTransferOffset + Rep OutsB + + Jmp VSoundHandler3 + +VSoundHandlerStereoClip1: + Mov AX, 8000h + Jmp VSoundHandlerStereo1 + +VSoundHandlerStereoClip2: + Mov AX, 7FFFh + Jmp VSoundHandlerStereo1 + +VSoundHandlerStereoClip3: + Mov BX, 8000h + Jmp VSoundHandlerStereo2 + +VSoundHandlerStereoClip4: + Mov BX, 7FFFh + Jmp VSoundHandlerStereo2 + + +VSoundHandlerMonoClip1: + Mov AX, 8000h + Jmp VSoundHandlerMono1 + +VSoundHandlerMonoClip2: + Mov AX, 7FFFh + Jmp VSoundHandlerMono1 + + +EndP VSoundFillBuffer + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VSoundHandler + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Add TimerAccumulator, TIMERCONST + JC VSoundHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp VSoundHandler2 + +VSoundHandler1: + PushF + Call [OldTimerIRQHandler] + +VSoundHandler2: + Add InVSound, 1 + JNC VSoundExit + + Call SaveEMSPageFrame + + Assume DS:Nothing + Call VSoundFillBuffer + + Call RestoreEMSPageFrame + +VSoundExit: + Pop ES + Pop DS + PopAD + + Sub CS:InVSound, 1 + IRet + +EndP VSoundHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL ; bump the interrupt to be called + ; 100 times a second. + Mov AX, TIMERCONST + Out 40h, AL + Mov AL, AH + Out 40h, AL + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset VSoundHandler + + ClI + + XChg [ES:20h], EAX ; Hook to timer interrupt + Mov CS:OldTimerIRQHandler, EAX + + StI + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Xor AL, AL + Out 40h, AL ; Interrupt called at normal 18.2 times + Out 40h, AL + + Mov EAX, CS:OldTimerIRQHandler + Mov [ES:20h], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + ; Parags to allocate = (8/(.4*31*16))*MixSpeed + 2080 + ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + 2080 + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + Mov BX, DX + Mov AH, 48h + Int 21h + + Mov SI, Offset VSoundNoMemoryMsg + JNC InitSound1 + + Pop ES + Ret + +InitSound1: + Mov MixSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset VSoundDriverMsg + Mov AX, BasePort + + ClC + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + + Mov SI, Offset NoReinitMsg + Mov BX, 40 + Call SetInfoLine + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Mov DS, Word Ptr [CS:DriverName+2] + Mov DX, Word Ptr [CS:DriverName] + + Mov AX, 3D02h ; Read write access + Int 21h + + Push CS + Pop DS + Assume DS:Driver + + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Mov DX, BasePort + Mov AL, 3 + Out DX, AL + + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + ClI + Add CS:InVSound, 1 + JNC Poll1 + + Call VSoundFillBuffer + +Poll1: + Sub CS:InVSound, 1 + StI + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + Assume DS:Nothing + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, AX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Dec CX + JNZ SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset VSoundScreenList + + ClC + + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + DW 0 +DefaultChannels DW 128 + DW 0 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/VSNDMMX.ASM b/SoundDrivers/VSNDMMX.ASM index bf3c966..70c13c7 100755 --- a/SoundDrivers/VSNDMMX.ASM +++ b/SoundDrivers/VSNDMMX.ASM @@ -1,1097 +1,1097 @@ -; -; Impulse Tracker VSound Driver -; -; Client for VSound.VxD to interface with Windows. -; Output is always 16-bit stereo, 44100Hz. -; -; - -STEREOENABLED EQU 1 -MIXRESOLUTION EQU 32 ; 32 bit mixing -OUTPUTFILTERENABLED EQU 0 -TIMERCONST EQU 11932 ; 100 times a second -DMABUFFERLENGTH EQU 0 ; Does not have a DMA buffer in the mixsegment - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -; ÄÄ Variables ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -FPSave DB 128 Dup (0) - -OldTimerIRQHandler DD 0 -TimerAccumulator DW 0 - -VSoundNoMemoryMsg DB "Impulse Tracker VSound Driver", 13 - DB "Error: Insufficient memory", 0 -VSoundDriverMsg DB "Impulse Tracker VSound Driver", 13 - DB "MMX Accelerated Mixing Engine", 0 - -NoReinitMsg DB "VSound driver should NOT require reinitialisation ", 0 - -VSoundIDBuffer DB 8 Dup (0) -VSoundID DB "ITVXDDRV" - -DefaultDriverName DB "ITVSOUND.DRV" -DriverName DD 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 -MixSegment DW 0 - -BytesToMix DW 1000 -MixTransferOffset DW 0 -MixTransferRemaining DW 0 -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 4 -MixMode DW 0 -MixModeOffset DW 0 - -VSoundScreenList Label - DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr VSoundHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr ServerText - DW Near Ptr FrequencyText - - DW 0 - - -VSoundHeaderLine DW 10 - DB "Virtual Sound Driver (MMX)", 0 - -ServerText DW 1 - DB 2, 47 - DB 21h -VSoundString DB 64 Dup (0) - -FrequencyText DW 1 - DB 2, 48 - DB 21h - DB "Playback Frequency: ", 0FDh, "DHz, Buffer Threshold: ", 0FDh, "D bytes", 0 -Threshold DW 21*1024 -MixSpeed DW 44100 - DW 0 - -DriverText DW 1 - DB 2, 46 - DB 21h - DB "Virtual Sound Driver (MMX) 1.0 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -MixModeText DW 1 - DB 2, 14 - DB 20h - DB "Mixing Mode", 0 - -MixModeButton1 DW 2 - DW 0FFFFh, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 16, 32, 18, 8 - DB 0 - DB " MMX, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 1 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 19, 32, 21, 8 - DB 0 - DB " MMX, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 22, 32, 24, 8 - DB 0 - DB " MMX, Volume Ramped", 0 - -MixModeButton4 DW 2 - DW 8, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 3 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 25, 32, 27, 8 - DB 0 - DB " MMX, Filtered", 0 - - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include mix.inc -include mmx.inc - -include m32bitm.mix -include m32bitmi.mix -include m32bitmv.mix -include m32bitmf.mix - -ALIGN 2 - -MixFunctionTables Label - -include m32bitm.inc -include m32bitmi.inc -include m32bitmv.inc -include m32bitmf.inc -include mnomix.inc - -include nodebug.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 60 - Mul BX - Mov CS:MixModeOffset, AX - - StI - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectMMX - - Trace "Detecting MMX - CPUID Check" - - PushFD - Pop EAX - Mov EBX, EAX - Xor EAX, 00200000h - Push EAX - PopFD - PushFD - Pop EAX - Cmp EAX, EBX - JZ DetectMMXFail - - Trace "CPUID - Check OK" - - Mov EAX, 1 - DB 0Fh, 0A2h ; CPUID - Test EDX, 800000h - JZ DetectMMXFail - - Trace "MMX Detected" - - ClC - Ret - -DetectMMXFail: - Trace "MMX Not Detected" - - StC - Ret - -EndP DetectMMX - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Driver - - Mov Forced, AL - - Cmp BX, 217h - JAE DetectCardUseDriver - - Mov CX, DS - ShL ECX, 16 - Mov CX, Offset DefaultDriverName - -DetectCardUseDriver: - Mov DriverName, ECX - - Call DetectMMX - JC DetectCardError - -; First need to find if VSound server is setup. - Mov DX, BasePort - Cmp DX, 0FFFFh - JNE PortSpecified - - Mov DX, 400h - Jmp TestPort - -PortSpecified: - Cmp AL, 1 - JNE DetectCardError - - -TestPort: - Mov BasePort, DX - - Xor AL, AL - Out DX, AL ; Reset, get identification - - Mov CX, 8 - Mov DI, Offset VSoundIDBuffer - Rep InsB - - Mov SI, Offset VSoundIDBuffer ; DI now points to VSoundID - Mov CX, 8 - RepE CmpsB - JNE DetectCardError - -; We've found a VSound server. Get ServerString - - Mov AL, 1 - Out DX, AL - ; DI now points to ServerString. - Mov DI, Offset VSoundString - Mov CX, 60 - Rep InsB - - Mov DI, Offset Threshold - Mov CX, 4 - Rep InsB - - Xor DWord Ptr [Threshold], 0FFFFFFFFh - - Mov EAX, 'Jeff' - DB 85h - -DetectCardError: - StC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include mmxmsam.inc -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InVSound DB -1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VSoundFillBuffer - Assume DS:Nothing - -VSoundHandler3: - - Mov DX, BasePort - Mov AL, 2 - Out DX, AL - In AL, DX - Mov AH, AL - In AL, DX ; AX = BufferSize - - Cmp AX, Threshold - JB VSoundHandler4 - - Ret - -VSoundHandler4: - Call Update - Call MixSamples - -; Convert the buffer - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov CX, BytesToMix ; CX = number of 32-bit samples to mix. - Mov DI, SI - -; Transfer the buffer - Cmp Stereo, 0 - JE VSoundHandlerMono - -VSoundHandlerStereo: - Add CX, 3 - ShR CX, 2 - -VsoundHandlerStereo1: - MovQ MM0, [SI] ; MM0 = s0r | s0l - MovQ MM1, [SI+8] ; MM1 = s1r | s1l - MovQ MM2, [SI+10h] ; MM2 = s2r | s2l - MovQ MM3, [SI+18h] ; MM3 = s3r | s3l - - PSRADI MM0, 12 - PSRADI MM1, 12 - PSRADI MM2, 12 - PSRADI MM3, 12 - - PackSSDW MM0, MM1 - PackSSDW MM2, MM3 - - MovQM [DI], MM0 - MovQM [DI+8], MM2 - - Add SI, 20h - Add DI, 10h - - Loop VSoundHandlerStereo1 - Jmp VSoundHandlerSend - -VSoundHandlerMono: - Inc CX - ShR CX, 1 - -VSoundHandlerMono1: -; want final to be s1|s1|s0|s0 (16 bits) -; Do 2 samples at a time. - MovD MM0, [SI] - MovD MM1, [SI+8] - MovD MM2, [SI+10h] - MovD MM3, [SI+18h] - - PUnpckLDQ MM0, MM0 - PUnpckLDQ MM1, MM1 - PUnpckLDQ MM2, MM2 - PUnpckLDQ MM3, MM3 - - PSRADI MM0, 13 - PSRADI MM1, 13 - PSRADI MM2, 13 - PSRADI MM3, 13 - - PackSSDW MM0, MM1 - PackSSDW MM2, MM3 - - MovQM [DI], MM0 - MovQM [DI+8], MM2 - - Add SI, 20h - Add DI, 10h - - Loop VSoundHandlerMono1 - -VSoundHandlerSend: - Mov CX, BytesToMix - Mov DX, BasePort - ShL CX, 2 - Add DX, 2 - Mov SI, MixTransferOffset - Rep OutsB - - Jmp VSoundHandler3 - -EndP VSoundFillBuffer - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VSoundHandler - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Add TimerAccumulator, TIMERCONST - JC VSoundHandler1 - - Mov AL, 20h - Out 20h, AL - Jmp VSoundHandler2 - -VSoundHandler1: - PushF - Call [OldTimerIRQHandler] - -VSoundHandler2: - Add InVSound, 1 - JNC VSoundExit - - FNSave [FPSave] - Call SaveEMSPageFrame - - Assume DS:Nothing - Call VSoundFillBuffer - - Call RestoreEMSPageFrame - FNRstor [FPSave] - -VSoundExit: - Pop ES - Pop DS - PopAD - - Sub CS:InVSound, 1 - IRet - -EndP VSoundHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL ; bump the interrupt to be called - ; 100 times a second. - Mov AX, TIMERCONST - Out 40h, AL - Mov AL, AH - Out 40h, AL - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset VSoundHandler - - ClI - - XChg [ES:20h], EAX ; Hook to timer interrupt - Mov CS:OldTimerIRQHandler, EAX - - StI - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Xor AL, AL - Out 40h, AL ; Interrupt called at normal 18.2 times - Out 40h, AL - - Mov EAX, CS:OldTimerIRQHandler - Mov [ES:20h], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - ; Parags to allocate = (8/(.4*31*16))*MixSpeed - ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 5 - Mov BX, DX - Mov AH, 48h - Int 21h - - Mov SI, Offset VSoundNoMemoryMsg - JNC InitSound1 - - Pop ES - Ret - -InitSound1: - Mov MixSegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset VSoundDriverMsg - Mov AX, BasePort - - ClC - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - - Mov SI, Offset NoReinitMsg - Mov BX, 40 - Call SetInfoLine - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Mov DS, Word Ptr [CS:DriverName+2] - Mov DX, Word Ptr [CS:DriverName] - - Mov AX, 3D02h ; Read write access - Int 21h - - Push CS - Pop DS - Assume DS:Driver - - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call ResetIRQ - -UnInitSound1: - Mov DX, BasePort - Mov AL, 3 - Out DX, AL - - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - ClI - Add CS:InVSound, 1 - JNC Poll1 - - Call VSoundFillBuffer - -Poll1: - Sub CS:InVSound, 1 - StI - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - Assume DS:Nothing - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Jmp CS:RecalculateAllVolumes - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include loadsam.inc - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset VSoundScreenList - - ClC - - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov CS:InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Push AX - Mov AL, 0F0h -; Call UARTOut - Pop AX - Mov CS:InterpretState, 0 - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: -; Call UARTOut - Ret - -EndP SendUARTOut - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - DW 0 -DefaultChannels DW 128 - DW 3 - DW 4 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Impulse Tracker VSound Driver +; +; Client for VSound.VxD to interface with Windows. +; Output is always 16-bit stereo, 44100Hz. +; +; + +STEREOENABLED EQU 1 +MIXRESOLUTION EQU 32 ; 32 bit mixing +OUTPUTFILTERENABLED EQU 0 +TIMERCONST EQU 11932 ; 100 times a second +DMABUFFERLENGTH EQU 0 ; Does not have a DMA buffer in the mixsegment + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +; ÄÄ Variables ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +FPSave DB 128 Dup (0) + +OldTimerIRQHandler DD 0 +TimerAccumulator DW 0 + +VSoundNoMemoryMsg DB "Impulse Tracker VSound Driver", 13 + DB "Error: Insufficient memory", 0 +VSoundDriverMsg DB "Impulse Tracker VSound Driver", 13 + DB "MMX Accelerated Mixing Engine", 0 + +NoReinitMsg DB "VSound driver should NOT require reinitialisation ", 0 + +VSoundIDBuffer DB 8 Dup (0) +VSoundID DB "ITVXDDRV" + +DefaultDriverName DB "ITVSOUND.DRV" +DriverName DD 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 +MixSegment DW 0 + +BytesToMix DW 1000 +MixTransferOffset DW 0 +MixTransferRemaining DW 0 +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 4 +MixMode DW 0 +MixModeOffset DW 0 + +VSoundScreenList Label + DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr VSoundHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr ServerText + DW Near Ptr FrequencyText + + DW 0 + + +VSoundHeaderLine DW 10 + DB "Virtual Sound Driver (MMX)", 0 + +ServerText DW 1 + DB 2, 47 + DB 21h +VSoundString DB 64 Dup (0) + +FrequencyText DW 1 + DB 2, 48 + DB 21h + DB "Playback Frequency: ", 0FDh, "DHz, Buffer Threshold: ", 0FDh, "D bytes", 0 +Threshold DW 21*1024 +MixSpeed DW 44100 + DW 0 + +DriverText DW 1 + DB 2, 46 + DB 21h + DB "Virtual Sound Driver (MMX) 1.0 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +MixModeText DW 1 + DB 2, 14 + DB 20h + DB "Mixing Mode", 0 + +MixModeButton1 DW 2 + DW 0FFFFh, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 16, 32, 18, 8 + DB 0 + DB " MMX, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 1 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 19, 32, 21, 8 + DB 0 + DB " MMX, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 22, 32, 24, 8 + DB 0 + DB " MMX, Volume Ramped", 0 + +MixModeButton4 DW 2 + DW 8, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 3 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 25, 32, 27, 8 + DB 0 + DB " MMX, Filtered", 0 + + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include mix.inc +include mmx.inc + +include m32bitm.mix +include m32bitmi.mix +include m32bitmv.mix +include m32bitmf.mix + +ALIGN 2 + +MixFunctionTables Label + +include m32bitm.inc +include m32bitmi.inc +include m32bitmv.inc +include m32bitmf.inc +include mnomix.inc + +include nodebug.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 60 + Mul BX + Mov CS:MixModeOffset, AX + + StI + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectMMX + + Trace "Detecting MMX - CPUID Check" + + PushFD + Pop EAX + Mov EBX, EAX + Xor EAX, 00200000h + Push EAX + PopFD + PushFD + Pop EAX + Cmp EAX, EBX + JZ DetectMMXFail + + Trace "CPUID - Check OK" + + Mov EAX, 1 + DB 0Fh, 0A2h ; CPUID + Test EDX, 800000h + JZ DetectMMXFail + + Trace "MMX Detected" + + ClC + Ret + +DetectMMXFail: + Trace "MMX Not Detected" + + StC + Ret + +EndP DetectMMX + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Driver + + Mov Forced, AL + + Cmp BX, 217h + JAE DetectCardUseDriver + + Mov CX, DS + ShL ECX, 16 + Mov CX, Offset DefaultDriverName + +DetectCardUseDriver: + Mov DriverName, ECX + + Call DetectMMX + JC DetectCardError + +; First need to find if VSound server is setup. + Mov DX, BasePort + Cmp DX, 0FFFFh + JNE PortSpecified + + Mov DX, 400h + Jmp TestPort + +PortSpecified: + Cmp AL, 1 + JNE DetectCardError + + +TestPort: + Mov BasePort, DX + + Xor AL, AL + Out DX, AL ; Reset, get identification + + Mov CX, 8 + Mov DI, Offset VSoundIDBuffer + Rep InsB + + Mov SI, Offset VSoundIDBuffer ; DI now points to VSoundID + Mov CX, 8 + RepE CmpsB + JNE DetectCardError + +; We've found a VSound server. Get ServerString + + Mov AL, 1 + Out DX, AL + ; DI now points to ServerString. + Mov DI, Offset VSoundString + Mov CX, 60 + Rep InsB + + Mov DI, Offset Threshold + Mov CX, 4 + Rep InsB + + Xor DWord Ptr [Threshold], 0FFFFFFFFh + + Mov EAX, 'Jeff' + DB 85h + +DetectCardError: + StC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include mmxmsam.inc +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InVSound DB -1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VSoundFillBuffer + Assume DS:Nothing + +VSoundHandler3: + + Mov DX, BasePort + Mov AL, 2 + Out DX, AL + In AL, DX + Mov AH, AL + In AL, DX ; AX = BufferSize + + Cmp AX, Threshold + JB VSoundHandler4 + + Ret + +VSoundHandler4: + Call Update + Call MixSamples + +; Convert the buffer + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov CX, BytesToMix ; CX = number of 32-bit samples to mix. + Mov DI, SI + +; Transfer the buffer + Cmp Stereo, 0 + JE VSoundHandlerMono + +VSoundHandlerStereo: + Add CX, 3 + ShR CX, 2 + +VsoundHandlerStereo1: + MovQ MM0, [SI] ; MM0 = s0r | s0l + MovQ MM1, [SI+8] ; MM1 = s1r | s1l + MovQ MM2, [SI+10h] ; MM2 = s2r | s2l + MovQ MM3, [SI+18h] ; MM3 = s3r | s3l + + PSRADI MM0, 12 + PSRADI MM1, 12 + PSRADI MM2, 12 + PSRADI MM3, 12 + + PackSSDW MM0, MM1 + PackSSDW MM2, MM3 + + MovQM [DI], MM0 + MovQM [DI+8], MM2 + + Add SI, 20h + Add DI, 10h + + Loop VSoundHandlerStereo1 + Jmp VSoundHandlerSend + +VSoundHandlerMono: + Inc CX + ShR CX, 1 + +VSoundHandlerMono1: +; want final to be s1|s1|s0|s0 (16 bits) +; Do 2 samples at a time. + MovD MM0, [SI] + MovD MM1, [SI+8] + MovD MM2, [SI+10h] + MovD MM3, [SI+18h] + + PUnpckLDQ MM0, MM0 + PUnpckLDQ MM1, MM1 + PUnpckLDQ MM2, MM2 + PUnpckLDQ MM3, MM3 + + PSRADI MM0, 13 + PSRADI MM1, 13 + PSRADI MM2, 13 + PSRADI MM3, 13 + + PackSSDW MM0, MM1 + PackSSDW MM2, MM3 + + MovQM [DI], MM0 + MovQM [DI+8], MM2 + + Add SI, 20h + Add DI, 10h + + Loop VSoundHandlerMono1 + +VSoundHandlerSend: + Mov CX, BytesToMix + Mov DX, BasePort + ShL CX, 2 + Add DX, 2 + Mov SI, MixTransferOffset + Rep OutsB + + Jmp VSoundHandler3 + +EndP VSoundFillBuffer + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VSoundHandler + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Add TimerAccumulator, TIMERCONST + JC VSoundHandler1 + + Mov AL, 20h + Out 20h, AL + Jmp VSoundHandler2 + +VSoundHandler1: + PushF + Call [OldTimerIRQHandler] + +VSoundHandler2: + Add InVSound, 1 + JNC VSoundExit + + FNSave [FPSave] + Call SaveEMSPageFrame + + Assume DS:Nothing + Call VSoundFillBuffer + + Call RestoreEMSPageFrame + FNRstor [FPSave] + +VSoundExit: + Pop ES + Pop DS + PopAD + + Sub CS:InVSound, 1 + IRet + +EndP VSoundHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL ; bump the interrupt to be called + ; 100 times a second. + Mov AX, TIMERCONST + Out 40h, AL + Mov AL, AH + Out 40h, AL + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset VSoundHandler + + ClI + + XChg [ES:20h], EAX ; Hook to timer interrupt + Mov CS:OldTimerIRQHandler, EAX + + StI + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Xor AL, AL + Out 40h, AL ; Interrupt called at normal 18.2 times + Out 40h, AL + + Mov EAX, CS:OldTimerIRQHandler + Mov [ES:20h], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + ; Parags to allocate = (8/(.4*31*16))*MixSpeed + ; = .04032258*MixSpeed = (65536*.04032258*MixSpeed) / 65536 + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 5 + Mov BX, DX + Mov AH, 48h + Int 21h + + Mov SI, Offset VSoundNoMemoryMsg + JNC InitSound1 + + Pop ES + Ret + +InitSound1: + Mov MixSegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset VSoundDriverMsg + Mov AX, BasePort + + ClC + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + + Mov SI, Offset NoReinitMsg + Mov BX, 40 + Call SetInfoLine + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Mov DS, Word Ptr [CS:DriverName+2] + Mov DX, Word Ptr [CS:DriverName] + + Mov AX, 3D02h ; Read write access + Int 21h + + Push CS + Pop DS + Assume DS:Driver + + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call ResetIRQ + +UnInitSound1: + Mov DX, BasePort + Mov AL, 3 + Out DX, AL + + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + ClI + Add CS:InVSound, 1 + JNC Poll1 + + Call VSoundFillBuffer + +Poll1: + Sub CS:InVSound, 1 + StI + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + Assume DS:Nothing + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Jmp CS:RecalculateAllVolumes + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include loadsam.inc + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset VSoundScreenList + + ClC + + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov CS:InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Push AX + Mov AL, 0F0h +; Call UARTOut + Pop AX + Mov CS:InterpretState, 0 + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: +; Call UARTOut + Ret + +EndP SendUARTOut + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + DW 0 +DefaultChannels DW 128 + DW 3 + DW 4 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/VTABLE.INC b/SoundDrivers/VTABLE.INC index 18d8fc6..ddc0bd5 100755 --- a/SoundDrivers/VTABLE.INC +++ b/SoundDrivers/VTABLE.INC @@ -1,11 +1,11 @@ - -VariableTableStart Label - -BasePort DW 0FFFFh -IRQ DW 0FFFFh -DMA DW 0FFFFh -CmdLineMixSpeed DW 0 -SongDataArea DW 0 - DB 16-($-VariableTableStart) Dup (0) - - + +VariableTableStart Label + +BasePort DW 0FFFFh +IRQ DW 0FFFFh +DMA DW 0FFFFh +CmdLineMixSpeed DW 0 +SongDataArea DW 0 + DB 16-($-VariableTableStart) Dup (0) + + diff --git a/SoundDrivers/WAV.MIX b/SoundDrivers/WAV.MIX index 1599879..0c59f02 100755 --- a/SoundDrivers/WAV.MIX +++ b/SoundDrivers/WAV.MIX @@ -1,1608 +1,1608 @@ -; -; WAV output mix functions.... -; Uses Cubic Spline Interpolation -; - -ALIGN 4 - -WAVMixingTable Label - ; 8 bit, 16 bit - ; No sound, stereo, surround - ; No loop, forwards loop, ping pong loop - - DW Offset UpdateNoLoop, 0, 0, 0, 0 - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - - DW Offset MixNoLoop, PreM32SMix8Bit, MFS8Bit, MBS8Bit, Mix32Stereo8Bit - DW Offset MixForwardsLoop, PreM32SMix8Bit, MFS8Bit, MBS8Bit, Mix32Stereo8Bit - DW Offset MixPingPongLoop, PreM32SMix8Bit, MFS8Bit, MBS8Bit, Mix32Stereo8Bit - - DW Offset MixNoLoop, PreM32UMix8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit - DW Offset MixForwardsLoop, PreM32UMix8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit - DW Offset MixPingPongLoop, PreM32UMix8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit - - DW Offset UpdateNoLoop, 0, 0, 0, 0 - DW Offset UpdateForwardsLoop, 0, 0, 0, 0 - DW Offset UpdatePingPongLoop, 0, 0, 0, 0 - - DW Offset MixNoLoop, PreM32SMix16Bit, MFS16Bit, MBS16Bit, Mix32Stereo16Bit - DW Offset MixForwardsLoop, PreM32SMix16Bit, MFS16Bit, MBS16Bit, Mix32Stereo16Bit - DW Offset MixPingPongLoop, PreM32SMix16Bit, MFS16Bit, MBS16Bit, Mix32Stereo16Bit - - DW Offset MixNoLoop, PreM32UMix16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit - DW Offset MixForwardsLoop, PreM32UMix16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit - DW Offset MixPingPongLoop, PreM32UMix16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit - -LastLeftValue DD 0 -LastRightValue DD 0 - -Sample1 DD 0 -Sample2 DD 0 -Sample3 DD 0 -Sample4 DD 0 -SampleValue DD 0 -InterpolationOffset DD 0 -Const3 DD 3.0 -Const1On65536 DD 37800000h -Const256On6 DD 422AAAAAh -Const1On6 DD 3E2AAAAAh -;Const65536 DD 65536.0 -Const32768 DD 32768.0 -Const1On32768 DD 38000000h -;ConstLimiter DD 3F000000h -Const22713_0 DD 22713.0 - -MAXFILTERVALUE EQU 47000000h - -FILTERCLIPPINGTYPENONE EQU 0 -FILTERCLIPPINGTYPECOMPRESSOR EQU 1 -FILTERCLIPPINGTYPELIMIT EQU 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Get8BitWaveform Macro ; Puts waveform value in EBX, range -32k->+32k - Local X - - -IF CUBICINTERPOLATION - - Mov BX, DI - - Push EDX - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Sub BX, 1 - Mov InterpolationOffset, ECX - AdC BX, 0 - - FILD InterpolationOffset - FMul Const1On65536 - - MovSX EAX, Byte Ptr [ES:BX] - MovSX EBX, Byte Ptr [ES:DI] - Mov Sample1, EAX - Mov Sample2, EBX - FILD Sample1 - FILD Sample2 - FMul Const3 - - MovSX EAX, Byte Ptr [ES:DI+1] - MovSX EBX, Byte Ptr [ES:DI+2] - Mov Sample3, EAX - Mov Sample4, EBX - FILD Sample3 - FMul Const3 - FILD Sample4 ; x, 3w, 3v, u, Interp - -; a = x+3v-3w-u -; b = 3w+3u-6v -; c = 6w-2u-x-3v -; d = 6v - -; Assignments: -; F = x+3v -; -> a = F-3w-u -; -> b = 3w+3u-6v -; -> c = 6w-2u-F -; -> d = 6v - -IF INTELOPTIMISED - FAdd ST, ST(2) ; x+3v[3], 3w, 3v, u, Interp - FLd ST(1) ; 3w, x+3v[3], 3w, 3v, u, Interp - FAdd ST, ST(4) ; 3w+u[3], x+3v[2], 3w, 3v, u, Interp - FXCh ST(4) ; u, x+3v[2], 3w, 3v, 3w+u[3], Interp - FAdd ST, ST ; 2u[3], x+3v[1], 3w, 3v, 3w+u[2], Interp - FXCh ST(3) ; 3v, x+3v[1], 3w, 2u[3], 3w+u[2], Interp - FLd ST(1) ; x+3v, 3v, x+3v, 3w, 2u[3], 3w+u[1], Interp - FSub ST, ST(5) ; a[3], 3v, x+3v, 3w, 2u[2], 3w+u, Interp - FXCh ; 3v, a[3], x+3v, 3w, 2u[2], 3w+u, Interp - FAdd ST, ST ; 6v[3], a[2], x+3v, 3w, 2u[1], 3w+u, Interp - FXCh ST(5) ; 3w+u, a[2], x+3v, 3w, 2u[1], 6v[3], Interp - FAdd ST, ST(4) ; 3w+3u[3], a[1], x+3v, 3w, 2u, 6v[2], Interp - FXCh ; a[1], 3w+3u[3], x+3v, 3w, 2u, 6v[2], Interp - FMul ST, ST(6) ; ax[3], 3w+3u[2], x+3v, 3w, 2u, 6v[1], Interp - FXCh ST(2) ; x+3v, 3w+3u[2], ax[3], 3w, 2u, 6v[1], Interp - FAddP ST(4), ST ; 3w+3u[1], ax[2], 3w, 2u+F[3], 6v, Interp - FSub ST, ST(4) ; 3w+3u-6v[3], ax[1], 3w, 2u+F[2], 6v, Interp - FXCh ST(2) ; 3w, ax[1], b[3], 2u+F[1], 6v, Interp - FAdd ST, ST ; 6w[3], ax, b[2], 2u+F, 6v, Interp - FXCh ; ax, 6w[3], b[2], 2u+F, 6v, Interp - FAddP ST(2), ST ; 6w[1], ax+b[3], 2u+f, d, Interp - FSubRP ST(2), ST ; ax+b, c[3], d, Interp - FMul ST, ST(3) ; ax^2+bx[3], c[2], d, Interp - FXCh ST(3) ; Interp, c[2], d, ax^2+bx[3] - FMul Const256On6 ; sInterp[3], c, d, ax^2+bx[1] - FXCh ; c, sInterp[3], d, ax^2+bx[1] - FAddP ST(3), ST ; sInterp[2], d, ax^2+bx+c[3] - FXCh ; d, sInterp[2], ax^2+bx+c[3] - FMul Const256On6 ; sd[3], sInterp[1], ax^2+bx+c[2] - FXCh ; sInterp[1], sd[3], ax^2+bx+c[2] - FMulP ST(2), ST - - Pop DS - Assume DS:Nothing - Mov EDX, [DS:0] - - FAdd ; SampleValue (16 bit value) - - FLd DWord Ptr [DS:0] ; x(k-1), x(k) - FMul DWord Ptr [DS:14h] ; b.x(k-1), x(k) - FLd DWord Ptr [DS:4] ; x(k-2), b.x(k-1), x(k) - FMul DWord Ptr [DS:18h] ; c.x(k-2), b.x(k-1), x(k) - FXCh ST(2) ; x(k), b.x(k-1), c.x(k-2) - FMul DWord Ptr [DS:10h] ; a.x(k), b.x(k-1), c.x(k-2) - FXCh ST(2) ; c.x(k-2), b.x(k-1), a.x(k) - FAdd - Mov EDX, [DS:0] - FAdd - - Mov [DS:4], EDX - - FSt DWord Ptr [DS:0] - FIStP CS:SampleValue - -ELSE - FAdd ST, ST(2) ; x+3v, 3w, 3v, u, Interp - FLd ST(1) ; 3w, x+3v, 3w, 3v, u, Interp - FSub ST, ST(4) ; 3w-u, x+3v, 3w, 3v, u, Interp - FAdd ST, ST ; 6w-2u, x+3v, 3w, 3v, u, Interp - FSub ST, ST(1) ; "c", x+3v, 3w, 3v, u, Interp - FXCh ; x+3v, "c", 3w, 3v, u, Interp - FSub ST, ST(2) ; x+3v-3w, "c", 3w, 3v, u, Interp - FSub ST, ST(4) ; "a", "c", 3w, 3v, u, Interp - FMul ST, ST(5) ; "ax", "c", 3w, 3v, u, Interp - FXCh ST(3) ; 3v, "c", 3w, "ax", u, Interp - FAdd ST, ST ; 6v, "c", 3w, "ax", u, Interp - FXCh ST(4) ; u, "c", 3w, "ax", 6v, Interp - FMul Const3 ; 3u, "c", 3w, "ax", 6v, Interp - FSub ST, ST(4) ; 3u-6v, "c", 3w, "ax", 6v, Interp - FAdd ST, ST(2) ; "b", "c", 3w, "ax", 6v, Interp - FAdd ST, ST(3) ; "ax+b", "c", 3w, "ax", 6v, Interp - FMul ST, ST(5) ; "ax^2+bx", "c", 3w, "ax", 6v, Interp - FAdd ; ax^2+bx+c, 3w, "ax", 6v, Interp - FMulP ST(4), ST ; 3w, "ax", 6v, ax^3+bx^2+cx - FComPP ; 6v, ax^3+bx^2+cx - FAdd ; SampleValue - FMul Const256On6 ; x(k) - - Pop DS - Assume DS:Nothing - - FMul DWord Ptr [DS:10h] - - FLd DWord Ptr [DS:0] ; x(k-1), x(k) - FMul DWord Ptr [DS:14h] ; b.x(k-1), x(k) - FLd DWord Ptr [DS:4] ; x(k-2), b.x(k-1), x(k) - FMul DWord Ptr [DS:18h] ; c.x(k-2), b.x(k-1), x(k) - FAdd - Mov EDX, [DS:0] - FAdd - - Mov [DS:4], EDX - - FSt DWord Ptr [DS:0] - FIStP SampleValue - -ENDIF - Pop EDX - - IF FILTERCLIPPINGTYPENONE - ELSE - Mov EAX, [DS:0] - And EAX, 7FFFFFFFh - Cmp EAX, MAXFILTERVALUE - JBE X - - IF FILTERCLIPPINGTYPECOMPRESSOR - - Mov EBX, [DS:0] - FLd CS:Const22713_0 - FLd DWord Ptr [DS:0] - FAbs - FMul CS:Const1On32768 - FYL2X ; ST = ln(x/65536) / ln(2) * 65536 * ln(2) - FAdd CS:Const32768 - SAR EBX, 31 - FIStP SampleValue - Xor SampleValue, EBX - Sub SampleValue, EBX - -Comment ~ - Mov EBX, [DS:0] - FLd DWord Ptr [DS:0] - FAbs - FSub [CS:Const65536] - FMul [CS:ConstLimiter] - FAdd [CS:Const65536] - SAR EBX, 31 - FIStP SampleValue - Xor SampleValue, EBX - Sub SampleValue, EBX -; FILD SampleValue -; FStP DWord Ptr [DS:0] -~ - ENDIF - IF FILTERCLIPPINGTYPELIMIT - - Mov EBX, [DS:0] - Mov EAX, MAXFILTERVALUE - And EBX, 80000000h - Or EAX, EBX - Mov [DS:0], EAX - ENDIF -X: - ENDIF - Mov EBX, SampleValue - -ENDIF - -IF QUADRATICINTERPOLATION - - Push EDX - Push EBP - - MovSX EDX, Byte Ptr [ES:DI+2] ; v - MovSX EBX, Byte Ptr [ES:DI] ; t - MovSX EAX, Byte Ptr [ES:DI+1] ; u - - LEA EBP, [EBX+EDX] ; v+t - SAR EBP, 1 - Sub EBP, EAX ; (v+t)/2 - u - IMul EBP, ECX ; ax in 8.16 format - SAR EBP, 10 ; ax in 8.6 format - - ShL EAX, 7 ; EBX = 2u<<6 - Add EDX, EBX ; EDX = v+t - Add EBX, EBX ; EAX = 2t - Add EBP, EAX ; EBP = ax+2u - Add EDX, EBX ; 3t+v - ShL EDX, 5 ; (3t+v)/2 << 6 - Sub EBP, EDX ; ax+b - - ShL EBX, 7 - - IMul EBP, ECX ; ax^2+bx in 8.22 form - SAR EBP, 14 ; ax^2+bx in 8.8 form - - Add EBX, EBP ; ax^2+bx+c - - Pop EBP - Pop EDX -ENDIF - - -IF LINEARINTERPOLATION - MovSX EBX, Byte Ptr [ES:DI+1] - MovSX EAX, Byte Ptr [ES:DI] - Sub EBX, EAX - IMul EBX, ECX - SAR EBX, 8 - ShL EAX, 8 - Add EBX, EAX -ENDIF - -IF POINTSAMPLED - MovSX EBX, Byte Ptr [ES:DI] - ShL EBX, 8 -ENDIF - -EndM - -Get16BitWaveform Macro ; Puts waveform value in EBX, range -32k->+32k - Local X - -IF CUBICINTERPOLATION - Mov EBX, EDI - - Push EDX - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Sub BX, 1 - Mov InterpolationOffset, ECX - AdC BX, 0 - - FILD InterpolationOffset - FMul Const1On65536 - - MovSX EAX, Word Ptr [ES:EBX+EBX] - MovSX EBX, Word Ptr [ES:EDI+EDI] - Mov Sample1, EAX - Mov Sample2, EBX - FILD Sample1 - FILD Sample2 - FMul Const3 - - MovSX EAX, Word Ptr [ES:EDI+EDI+2] - MovSX EBX, Word Ptr [ES:EDI+EDI+4] - Mov Sample3, EAX - Mov Sample4, EBX - FILD Sample3 - FMul Const3 - FILD Sample4 ; x, 3w, 3v, u, Interp - - -; a = x+3v-3w-u -; b = 3w+3u-6v -; c = 6w-2u-x-3v -; d = 6v - -; Assignments: -; F = x+3v -; -> a = F-3w-u -; -> b = 3w+3u-6v -; -> c = 6w-2u-F -; -> d = 6v - -IF INTELOPTIMISED - FAdd ST, ST(2) ; x+3v[3], 3w, 3v, u, Interp - FLd ST(1) ; 3w, x+3v[3], 3w, 3v, u, Interp - FAdd ST, ST(4) ; 3w+u[3], x+3v[2], 3w, 3v, u, Interp - FXCh ST(4) ; u, x+3v[2], 3w, 3v, 3w+u[3], Interp - FAdd ST, ST ; 2u[3], x+3v[1], 3w, 3v, 3w+u[2], Interp - FXCh ST(3) ; 3v, x+3v[1], 3w, 2u[3], 3w+u[2], Interp - FLd ST(1) ; x+3v, 3v, x+3v, 3w, 2u[3], 3w+u[1], Interp - FSub ST, ST(5) ; a[3], 3v, x+3v, 3w, 2u[2], 3w+u, Interp - FXCh ; 3v, a[3], x+3v, 3w, 2u[2], 3w+u, Interp - FAdd ST, ST ; 6v[3], a[2], x+3v, 3w, 2u[1], 3w+u, Interp - FXCh ST(5) ; 3w+u, a[2], x+3v, 3w, 2u[1], 6v[3], Interp - FAdd ST, ST(4) ; 3w+3u[3], a[1], x+3v, 3w, 2u, 6v[2], Interp - FXCh ; a[1], 3w+3u[3], x+3v, 3w, 2u, 6v[2], Interp - FMul ST, ST(6) ; ax[3], 3w+3u[2], x+3v, 3w, 2u, 6v[1], Interp - FXCh ST(2) ; x+3v, 3w+3u[2], ax[3], 3w, 2u, 6v[1], Interp - FAddP ST(4), ST ; 3w+3u[1], ax[2], 3w, 2u+F[3], 6v, Interp - FSub ST, ST(4) ; 3w+3u-6v[3], ax[1], 3w, 2u+F[2], 6v, Interp - FXCh ST(2) ; 3w, ax[1], b[3], 2u+F[1], 6v, Interp - FAdd ST, ST ; 6w[3], ax, b[2], 2u+F, 6v, Interp - FXCh ; ax, 6w[3], b[2], 2u+F, 6v, Interp - FAddP ST(2), ST ; 6w[1], ax+b[3], 2u+f, d, Interp - FSubRP ST(2), ST ; ax+b, c[3], d, Interp - FMul ST, ST(3) - FXCh ST(3) ; Interp, c[2], d, ax^2+bx[3] - FMul Const1On6 ; sInterp[3], c, d, ax^2+bx[1] - FXCh ; c, sInterp[3], d, ax^2+bx[1] - FAddP ST(3), ST ; sInterp[2], d, ax^2+bx+c[3] - FXCh ; d, sInterp[2], ax^2+bx+c[3] - FMul Const1On6 ; sd[3], sInterp[1], ax^2+bx+c[2] - FXCh ; sInterp[1], sd[3], ax^2+bx+c[2] - FMulP ST(2), ST - - Pop DS - Assume DS:Nothing - Mov EDX, [DS:0] - - FAdd ; SampleValue (16 bit value) - - FLd DWord Ptr [DS:0] ; x(k-1), x(k) - FMul DWord Ptr [DS:14h] ; b.x(k-1), x(k) - FLd DWord Ptr [DS:4] ; x(k-2), b.x(k-1), x(k) - FMul DWord Ptr [DS:18h] ; c.x(k-2), b.x(k-1), x(k) - FXCh ST(2) ; x(k), b.x(k-1), c.x(k-2) - FMul DWord Ptr [DS:10h] ; a.x(k), b.x(k-1), c.x(k-2) - FXCh ST(2) ; c.x(k-2), b.x(k-1), a.x(k) - FAdd - Mov EDX, [DS:0] - FAdd - - Mov [DS:4], EDX - - FSt DWord Ptr [DS:0] - FIStP CS:SampleValue - -ELSE - FAdd ST, ST(2) ; x+3v, 3w, 3v, u, Interp - FLd ST(1) ; 3w, x+3v, 3w, 3v, u, Interp - FSub ST, ST(4) ; 3w-u, x+3v, 3w, 3v, u, Interp - FAdd ST, ST ; 6w-2u, x+3v, 3w, 3v, u, Interp - FSub ST, ST(1) ; "c", x+3v, 3w, 3v, u, Interp - FXCh ; x+3v, "c", 3w, 3v, u, Interp - FSub ST, ST(2) ; x+3v-3w, "c", 3w, 3v, u, Interp - FSub ST, ST(4) ; "a", "c", 3w, 3v, u, Interp - FMul ST, ST(5) ; "ax", "c", 3w, 3v, u, Interp - FXCh ST(3) ; 3v, "c", 3w, "ax", u, Interp - FAdd ST, ST ; 6v, "c", 3w, "ax", u, Interp - FXCh ST(4) ; u, "c", 3w, "ax", 6v, Interp - FMul Const3 ; 3u, "c", 3w, "ax", 6v, Interp - FSub ST, ST(4) ; 3u-6v, "c", 3w, "ax", 6v, Interp - FAdd ST, ST(2) ; "b", "c", 3w, "ax", 6v, Interp - FAdd ST, ST(3) ; "ax+b", "c", 3w, "ax", 6v, Interp - FMul ST, ST(5) ; "ax^2+bx", "c", 3w, "ax", 6v, Interp - FAdd ; ax^2+bx+c, 3w, "ax", 6v, Interp - FMulP ST(4), ST ; 3w, "ax", 6v, ax^3+bx^2+cx - FComPP ; 6v, ax^3+bx^2+cx - FAdd ; SampleValue - FMul Const1On6 - - Pop DS - Assume DS:Nothing - - FMul DWord Ptr [DS:10h] - - FLd DWord Ptr [DS:0] ; x(k-1), x(k) - FMul DWord Ptr [DS:14h] ; b.x(k-1), x(k) - FLd DWord Ptr [DS:4] ; x(k-2), b.x(k-1), x(k) - FMul DWord Ptr [DS:18h] ; c.x(k-2), b.x(k-1), x(k) - FAdd - Mov EDX, [DS:0] - FAdd - - Mov [DS:4], EDX - - FSt DWord Ptr [DS:0] - FIStP SampleValue -ENDIF - Pop EDX - - IF FILTERCLIPPINGTYPENONE - ELSE - Mov EAX, [DS:0] - And EAX, 7FFFFFFFh - Cmp EAX, MAXFILTERVALUE - JBE X - - IF FILTERCLIPPINGTYPECOMPRESSOR - - Mov EBX, [DS:0] - FLd CS:Const22713_0 - FLd DWord Ptr [DS:0] - FAbs - FMul CS:Const1On32768 - FYL2X ; ST = ln(x/65536) / ln(2) * 65536 * ln(2) - FAdd CS:Const32768 - SAR EBX, 31 - FIStP SampleValue - Xor SampleValue, EBX - Sub SampleValue, EBX - -Comment ~ - Mov EBX, [DS:0] - FLd DWord Ptr [DS:0] - FAbs - FSub [CS:Const65536] - FMul [CS:ConstLimiter] - FAdd [CS:Const65536] - SAR EBX, 31 - FIStP SampleValue - XOr SampleValue, EBX - Sub SampleValue, EBX -; FILD SampleValue -; FStP DWord Ptr [DS:0] -~ - - ENDIF - IF FILTERCLIPPINGTYPELIMIT - - Mov EBX, [DS:0] - Mov EAX, MAXFILTERVALUE - And EBX, 80000000h - Or EAX, EBX - Mov [DS:0], EAX - ENDIF -X: - ENDIF - Mov EBX, SampleValue - -ENDIF - -IF QUADRATICINTERPOLATION - - Push ECX - Push EDX - Push EBP - - MovSX EDX, Word Ptr [ES:EDI+EDI+4] ; v - MovSX EBX, Word Ptr [ES:EDI+EDI] ; t - MovSX EAX, Word Ptr [ES:EDI+EDI+2] ; u - - ShR ECX, 3 ; 0.13 - LEA EBP, [EBX+EDX] - SAR EBP, 1 - Sub EBP, EAX ; (v+t)/2 - u - IMul EBP, ECX ; 16.13 - SAR EBP, 14 ; 15.0 - - Add EDX, EBX ; EDX = v+t - Add EBP, EAX ; EBP = ax+2u - LEA EDX, [EDX+EBX*2] - SAR EDX, 2 ; EDX = (3t+v)/2 - Sub EBP, EDX ; ax + b, 15 form - - IMul EBP, ECX ; ax^2+bx in 15.13 form - SAR EBP, 12 ; ax^2+bx in 16.0 form - - Add EBX, EBP - - Pop EBP - Pop EDX - Pop ECX - -ENDIF - -IF LINEARINTERPOLATION - MovSX EBX, Word Ptr [ES:EDI+EDI+2] - MovSX EAX, Word Ptr [ES:EDI+EDI] - Sub EBX, EAX - SAR EBX, 1 - IMul EBX, ECX - SAR EBX, 15 - Add EBX, EAX -ENDIF - -IF POINTSAMPLED - MovSX EBX, Word Ptr [ES:EDI+EDI] -ENDIF - -EndM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Mix32Stereo8Bit ; Given DS:SI = buffer - ; Given ES:DI = sample - ; AX = bytes to mix - ; CX = error - ; DX = delta offset - ; BP = delta error - - ShL AX, 3 - Add AX, SI - Mov Word Ptr [CS:M32S8BEND], AX - -Mix32Stereo8Bit1: - Get8BitWaveForm - -M32S8BLVC EQU $+3 - IMul EAX, EBX, 12345678h - Sub [SI], EAX - - Mov CS:LastLeftValue, EAX - -M32S8BRVC EQU $+3 - IMul EAX, EBX, 12345678h - Sub [SI+4], EAX - - Mov CS:LastRightValue, EAX - - Add CX, BP - AdC DI, DX - Add SI, 8 - -M32S8BLVSet EQU $+2 - Mov EAX, 12345678h ; Destination volume left -M32S8BRVSet EQU $+2 - Mov EBX, 12345678h ; Destination volume right - - Sub EAX, DWord Ptr [CS:M32S8BLVC] ; Delta - Sub EBX, DWord Ptr [CS:M32S8BRVC] - - SAR EAX, RAMPSPEED - SAR EBX, RAMPSPEED - - Add DWord Ptr [CS:M32S8BLVC], EAX - Add DWord Ptr [CS:M32S8BRVC], EBX - -M32S8BNoRightRamp: - -M32S8BEND EQU $+2 - Cmp SI, 1234h - JNE Mix32Stereo8Bit1 - - Ret - -EndP Mix32Stereo8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreM32SMix8Bit - -IF VOLUMERAMP - PushAD - - Xor EAX, EAX - Xor EBX, EBX - Xor EDX, EDX - Xor EBP, EBP - Xor EDI, EDI - - Mov AX, Word Ptr [SI+0Ch] ; New right volume - Mov BX, Word Ptr [SI+0Eh] ; New left volume - - Mov DX, Word Ptr [SI+1Ch] ; Old right volume - Mov BP, Word Ptr [SI+1Eh] ; Old left volume - - Mov DWord Ptr [CS:M32S8BRVC], EDX - Mov DWord Ptr [CS:M32S8BLVC], EBP - -; Compensate for upwards ramp. - - Cmp AX, DX - JB PreM32Mix8BitNoRightCompensate - - Add AX, RAMPCOMPENSATE - -PreM32Mix8BitNoRightCompensate: - - Cmp BX, BP - JB PreM32Mix8BitNoLeftCompensate - - Add BX, RAMPCOMPENSATE - -PreM32Mix8BitNoLeftCompensate: - Mov DWord Ptr [CS:M32S8BRVSet], EAX - Mov DWord Ptr [CS:M32S8BLVSet], EBX - -; Now to figure out exact final volumes - - Push SI - Mov CX, CS:RealBytesToMix - -PreM32Mix8Bit1: - Mov ESI, EAX ; Set values - Mov EDI, EBX - Sub ESI, EDX ; Current values - Sub EDI, EBP - SAR ESI, RAMPSPEED - SAR EDI, RAMPSPEED - Add EDX, ESI - Add EBP, EDI - - Loop PreM32Mix8Bit1 - - Pop SI - - Mov Word Ptr [SI+1Ch], DX - Mov Word Ptr [SI+1Eh], BP - - PopAD - Ret -ELSE - - Xor EAX, EAX - Xor EBX, EBX - - Mov AX, Word Ptr [SI+0Ch] - Mov BX, Word Ptr [SI+0Eh] - - Mov DWord Ptr [CS:M32S8BRVC], EAX - Mov DWord Ptr [CS:M32S8BLVC], EBX - - Mov DWord Ptr [CS:M32S8BRVSet], EAX - Mov DWord Ptr [CS:M32S8BLVSet], EBX - - Mov [SI+1Ch], AX - Mov [SI+1Eh], BX - - Ret -ENDIF - -EndP PreM32SMix8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Mix32Surround8Bit ; Given DS:SI = buffer - ; Given ES:DI = sample - ; AX = bytes to mix - ; CX = error - ; DX = delta offset - ; BP = delta error - - ShL AX, 3 - Add AX, SI - Mov Word Ptr [CS:M32U8BEND], AX - -Mix32Surround8Bit1: - Get8BitWaveForm - -M32U8BLVC EQU $+3 - IMul EAX, EBX, 12345678h - Sub [SI], EAX - Mov CS:LastLeftValue, EAX - - Neg EAX -M32U8BLVSet EQU $+2 - Mov EBX, 12345678h - - Sub [SI+4], EAX - Sub EBX, DWord Ptr [CS:M32U8BLVC] - - - SAR EBX, RAMPSPEED - Add SI, 8 - - Add CX, BP - AdC DI, DX - - Add DWord Ptr [CS:M32U8BLVC], EBX - -M32U8BEND EQU $+2 - Cmp SI, 1234h - JNE Mix32Surround8Bit1 - - Mov EAX, CS:LastLeftValue - Neg EAX - Mov CS:LastRightValue, EAX - Ret - -EndP Mix32Surround8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreM32UMix8Bit - -IF VOLUMERAMP - Xor EAX, EAX - Xor EBX, EBX - Mov AX, Word Ptr [SI+1Eh] ; Old - Mov BX, Word Ptr [SI+0Eh] ; New - Mov DWord Ptr [CS:M32U8BLVC], EAX - -; Compensate for upwards ramp. - - Cmp BX, AX - JB PreM32MixU8Bit2 - - Add BX, RAMPCOMPENSATE - -PreM32MixU8Bit2: - Mov DWord Ptr [CS:M32U8BLVSet], EBX - - Mov CX, CS:RealBytesToMix - -PreM32UMix8Bit1: - Mov EDX, EBX - Sub EDX, EAX - SAR EDX, RAMPSPEED - Add EAX, EDX - - Loop PreM32UMix8Bit1 - - Mov [SI+1Eh], AX - Ret - -ELSE - Xor EAX, EAX - Mov AX, Word Ptr [SI+0Eh] - Mov DWord Ptr [CS:M32U8BLVC], EAX - Mov DWord Ptr [CS:M32U8BLVSet], EAX - Mov [SI+1Eh], AX - - Ret -ENDIF - -EndP PreM32UMix8Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Mix32Stereo16Bit - - ShL AX, 3 - Add AX, SI - Mov Word Ptr [CS:M32S16BEND], AX - -Mix32Stereo16Bit1: - Get16BitWaveform - -M32S16BLVC EQU $+3 - IMul EAX, EBX, 12345678h - Sub [SI], EAX - - Mov CS:LastLeftValue, EAX - -M32S16BRVC EQU $+3 - IMul EAX, EBX, 12345678h - Sub [SI+4], EAX - - Mov CS:LastRightValue, EAX - - Add CX, BP - AdC DI, DX - -M32S16BLVSet EQU $+2 - Mov EAX, 12345678h ; Destination volume left -M32S16BRVSet EQU $+2 - Mov EBX, 12345678h ; Destination volume right - - Sub EAX, DWord Ptr [CS:M32S16BLVC] ; Delta - Sub EBX, DWord Ptr [CS:M32S16BRVC] - - SAR EAX, RAMPSPEED - SAR EBX, RAMPSPEED - - Add DWord Ptr [CS:M32S16BLVC], EAX - Add DWord Ptr [CS:M32S16BRVC], EBX - - Add SI, 8 - -M32S16BEND EQU $+2 - Cmp SI, 1234h - JNE Mix32Stereo16Bit1 - - Ret - -EndP Mix32Stereo16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreM32SMix16Bit - -IF VOLUMERAMP - PushAD - - Xor EAX, EAX - Xor EBX, EBX - Xor EDX, EDX - Xor EBP, EBP - Xor EDI, EDI - - Mov AX, Word Ptr [SI+0Ch] ; New right volume - Mov BX, Word Ptr [SI+0Eh] ; New left volume - - Mov DX, Word Ptr [SI+1Ch] ; Old right volume - Mov BP, Word Ptr [SI+1Eh] ; Old left volume - - Mov DWord Ptr [CS:M32S16BRVC], EDX - Mov DWord Ptr [CS:M32S16BLVC], EBP - -; Compensate for upwards ramp. - - Cmp AX, DX - JB PreM32Mix16BitNoRightCompensate - - Add AX, RAMPCOMPENSATE - -PreM32Mix16BitNoRightCompensate: - - Cmp BX, BP - JB PreM32Mix16BitNoLeftCompensate - - Add BX, RAMPCOMPENSATE - -PreM32Mix16BitNoLeftCompensate: - Mov DWord Ptr [CS:M32S16BRVSet], EAX - Mov DWord Ptr [CS:M32S16BLVSet], EBX - -; Now to figure out exact final volumes - - Push SI - Mov CX, CS:RealBytesToMix - -PreM32Mix16Bit1: - Mov ESI, EAX ; Set values - Mov EDI, EBX - - Sub ESI, EDX ; Current values - Sub EDI, EBP - - SAR ESI, RAMPSPEED - SAR EDI, RAMPSPEED - - Add EDX, ESI - Add EBP, EDI - - Loop PreM32Mix16Bit1 - Pop SI - - Mov Word Ptr [SI+1Ch], DX - Mov Word Ptr [SI+1Eh], BP - - PopAD - Ret -ELSE - - Xor EAX, EAX - Xor EBX, EBX - - Mov AX, Word Ptr [SI+0Ch] - Mov BX, Word Ptr [SI+0Eh] - - Mov DWord Ptr [CS:M32S16BRVC], EAX - Mov DWord Ptr [CS:M32S16BLVC], EBX - - Mov DWord Ptr [CS:M32S16BRVSet], EAX - Mov DWord Ptr [CS:M32S16BLVSet], EBX - - Mov [SI+1Ch], AX - Mov [SI+1Eh], BX - - Ret -ENDIF - -EndP PreM32SMix16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Mix32Surround16Bit ; Given DS:SI = buffer - ; Given ES:DI = sample - ; AX = bytes to mix - ; CX = error - ; DX = delta offset - ; BP = delta error - - ShL AX, 3 - Add AX, SI - Mov Word Ptr [CS:M32U16BEND], AX - -Mix32Surround16Bit1: - Get16BitWaveForm - -M32U16BLVC EQU $+3 - IMul EAX, EBX, 12345678h - Sub [SI], EAX - -M32U16BLVSet EQU $+2 - Mov EBX, 12345678h - - Neg EAX - Sub EBX, DWord Ptr [CS:M32U16BLVC] - - Sub [SI+4], EAX - - SAR EBX, RAMPSPEED - Add SI, 8 - - Add CX, BP - AdC DI, DX - - Add DWord Ptr [CS:M32U16BLVC], EBX - -M32U16BEND EQU $+2 - Cmp SI, 1234h - JNE Mix32Surround16Bit1 - - Mov CS:LastRightValue, EAX - Neg EAX - Mov CS:LastLeftValue, EAX - Ret - -EndP Mix32Surround16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreM32UMix16Bit - -IF VOLUMERAMP - Xor EAX, EAX - Xor EBX, EBX - Mov AX, Word Ptr [SI+1Eh] - Mov BX, Word Ptr [SI+0Eh] - Mov DWord Ptr [CS:M32U16BLVC], EAX - -; Compensate for upwards ramp. - - Cmp BX, AX - JB PreM32MixU16Bit2 - - Add BX, RAMPCOMPENSATE - -PreM32MixU16Bit2: - - Mov DWord Ptr [CS:M32U16BLVSet], EBX - - Mov CX, CS:RealBytesToMix - -PreM32UMix16Bit1: - Mov EDX, EBX - Sub EDX, EAX - SAR EDX, RAMPSPEED - Add EAX, EDX - - Loop PreM32UMix16Bit1 - - Mov [SI+1Eh], AX - Ret - -ELSE - Xor EAX, EAX - Mov AX, Word Ptr [SI+0Eh] - Mov DWord Ptr [CS:M32U16BLVC], EAX - Mov DWord Ptr [CS:M32U16BLVSet], EAX - Mov [SI+1Eh], AX - Ret -ENDIF - -EndP PreM32UMix16Bit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -NUMBEROFFILTERBANDS EQU 4 - -ALIGN 4 -LastClickRemovalLeft DD 0 -LastClickRemovalRight DD 0 -StartingChannelOffset DW 0 -FilterParameters DB 64 Dup (7Fh), 64 Dup (0) -FilterValues DD 4*256 Dup (0) -SampleFilterCopyOffset DW 16*64 -FreqMultiplier DD 3A9F7867h ; = 1/(2*PI*110.0*2^0.25) -FreqParameterMultiplier DD 0B92AAAAAh ; = -1/(24*256) -FilterFreqValue DW 0 -NewControlWord DW 7Fh -include q.inc - -LastFilter DD NUMBEROFFILTERBANDS*2 Dup (0) ; 4 stereo values -FilterCoefficients DD NUMBEROFFILTERBANDS*2 Dup (0) -FilterVolumes DD NUMBEROFFILTERBANDS Dup (0) - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc IsSampleMode ; returns zero flag if sample mode. - - Push DS - - Mov DS, CS:SongDataArea - Test Byte Ptr [DS:2Ch], 4 - - Pop DS - Ret - -EndP IsSampleMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M32MixHandler - ; Clear output buffer first... - - Mov CS:StartingChannelOffset, SI - - Push CX - - Mov ES, CS:MixSegment - Mov EAX, CS:BytesToMixFractional - Mov CX, CS:BytesToMix - Add CurrentFractional, EAX - AdC CX, 0 - Mov CS:RealBytestoMix, CX -; Add CX, CX ; Stereo = 2 * BytesToMix -; Mov DI, 32 -; Xor EAX, EAX -; Rep StosD - - Pop CX - - PushAD - - Mov EDX, CS:LastClickRemovalLeft - Mov EBP, CS:LastClickRemovalRight - -; Do left first. - Mov SI, 80 - Mov CX, CS:RealBytesToMix - -ClickRemoval3: - -Comment ~ - - Mov [ES:SI], EDX - Mov [ES:SI+4], EBP - - Inc EDX - JS ClickRemoval4 - - Sub EDX, 2 - JGE ClickRemoval4 - - Inc EDX - -ClickRemoval4: - Inc EBP - JS ClickRemoval5 - - Sub EBP, 2 - JGE ClickRemoval5 - - Inc EBP - -ClickRemoval5: -~ - - Mov EAX, EDX - Mov EBX, EBP - SAR EAX, 12 - SAR EBX, 12 - Mov [ES:SI], EDX - Mov [ES:SI+4], EBP - - Sub EAX, 1 - AdC EAX, 1 - Sub EBX, 1 - AdC EBX, 1 - - Sub EDX, EAX - Sub EBP, EBX - - Add SI, 8 - Loop ClickRemoval3 - - Mov CS:LastClickRemovalLeft, EDX - Mov CS:LastClickRemovalRight, EBP - - PopAD - - ; Check each channel... - ; Prepare mixing stuff - -; Work backwards - Mov AX, CX - Dec AX - ShL AX, 7 - Add SI, AX - -M32MixHandler1: - Test Byte Ptr [SI], 1 - JZ M32MixHandlerEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE M32MixHandlerEnd2 - - Push CX - Mov BP, SI - Sub BP, [CS:StartingChannelOffset] ; BP = SlaveChannel*128 - SHR BP, 3 ; BP = SlaveChannel*16 - Mov DI, BP - Add BP, Offset FilterValues - - Mov CX, [SI] - Test CH, 2 - JZ M32MixHandler13 - - ; Note cut. - And Byte Ptr [SI], Not 1 ; Turn off channel - Mov Word Ptr [SI+4Ah], 0 - Or CL, 40h - -M32MixHandler13: - Test CL, 20h ; New freq? - JZ M32MixHandler3 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE M32MixHandlerError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -M32MixHandler3: - Test CH, 1 ; New note? - JZ M32MixHandler12 - - Xor EAX, EAX - Mov DWord Ptr [SI+1Ch], EAX - Mov DWord Ptr [CS:BP], EAX - Mov DWord Ptr [CS:BP+4], EAX - Mov DWord Ptr [CS:BP+8], 3F800000h - Mov DWord Ptr [CS:BP+0Ch], EAX - -M32MixHandler12: - Test CX, 8440h ; New volume, loop or pan? - JZ M32MixHandler4 - - Mov AL, [SI+3Ah] - Test AL, AL - JNS M32MixHandlerFilter1 - - Mov BL, [SI+3Fh] - Jmp M32MixHandlerFilter2 - -M32MixHandlerFilter1: - Mov DI, AX - And DI, 63 - Add DI, Offset FilterParameters - - Mov AL, [CS:DI] - Mov BL, [CS:DI+64] - Mov [SI+5Bh], AL - Mov [SI+3Fh], BL - -M32MixHandlerFilter2: - Mov AL, [SI+3Eh] - Mul Byte Ptr [SI+5Bh] - Mov CS:FilterFreqValue, AX - ShR AX, 8 - Mov AH, BL - AdC AX, 0 - - Cmp AX, 7Fh - JE M32MixHandlerNoFilter - - And BX, 0FFh - ShL BX, 2 - - FNInit - FLdCW [CS:NewControlWord] - - FILD [CS:FilterFreqValue] ; 0->127*256 - FMul [CS:FreqParameterMultiplier] ; -i/(24*256) - FLd ST - FRndInt - FSub ST(1), ST - FXCh - F2XM1 - FLd1 - FAdd - FScale ; = 2^(i/24*256) - FMul [CS:FreqMultiplier] ; = r - FLd ST ; r, r - FMul ST(1), ST ; r, r^2 - - FLd [CS:QualityFactorTable+BX] ; 2d, r, r^2 - FMul ST(1), ST ; 2d, 2dr, r^2 - FLd1 ; 1, 2d, 2dr, r^2 - FSubP ST(1), ST ; 2d-1, 2dr, r^2 - FAdd - - FLd1 ; 1, d, e - FAdd ST, ST(1) - FAdd ST, ST(2) ; 1+d+e, d, e - FLd1 ; 1, 1+d+e, d, e - FDivRP ST(1), ST ; 1/(1+d+e), d, e - FSt DWord Ptr [CS:BP+8] - FXCh ; d, 1/(1+d+e), e - FAdd ST, ST(2) - FAddP ST(2), ST ; 1/(1+d+e), d+2e - FMul - FStP DWord Ptr [CS:BP+0Ch] - FStP ST - -M32MixHandlerNoFilter: - -IF REGISTERED - Test CH, 8 - JNZ M32MixHandler7 - - Cmp CS:Stereo, 0 - JE M32MixHandler6 - - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE M32MixHandler6 - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - SHRD AX, DX, 14 - - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] ; Final volume - SHRD AX, DX, 14 - Mov [SI+0Eh], AX - - ; Now to decide on mixing method - Cmp DWord Ptr [SI+0Ch], 0 - JNE M32MixHandler5 -ELSE - Test CH, 8 - JZ M32MixHandler6 - -ENDIF - -M32MixHandler7: - ; Zero volume - Xor EAX, EAX - Mov [SI+0Ch], EAX - Cmp [SI+1Ch], EAX ; Last volumes = 0? - JE M32MixHandler8 - -M32MixHandler5: ; Other.. (ie. panned) - Mov AX, 30 - Jmp M32MixHandler8 - -M32MixHandler6: ; Surround sound - Mov AX, [SI+4Ah] - Mul MixVolume - -IF REGISTERED - ShRD AX, DX, 8 - Cmp CS:Stereo, 0 - JE M32MixHandlerHalfStereoVolume - - ShR AX, 1 - -M32MixHandlerHalfStereoVolume: - -ELSE - - ShRD AX, DX, 9 -ENDIF - - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - - Test AX, AX - JNZ M32MixHandlerSurround1 - - Cmp DWord Ptr [SI+1Ch], 0 - JE M32MixHandler7 - -M32MixHandlerSurround1: - Mov AX, 60 - -M32MixHandler8: - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 - JZ M32MixHandler9 - - Add AX, 90 - -M32MixHandler9: - Cmp BL, 8 - JB M32MixHandler11 ; No loop - JE M32MixHandler10 - - Add AX, 10 - -M32MixHandler10: - Add AX, 10 - -M32MixHandler11: - Add AX, Offset WAVMixingTable - Mov [SI+8], AX ; Offset... - -M32MixHandler4: - ; Mixing routine call... - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, RealBytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, 80 - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Cmp CS:StartNoRamp, 0 - JE NoStartRamp - - Test CH, 1 - JZ NoStartRamp - Cmp DWord Ptr [SI+4Ch], 0 - JNE NoStartRamp - - Mov EAX, [SI+0Ch] - Mov [SI+1Ch], EAX - -NoStartRamp: - - Mov ES, CS:MixSegment ; Get filter data - Mov EAX, [CS:BP] ; Last sample 1 - Mov EDX, [CS:BP+4] ; Last sample 2 - Mov [ES:0], EAX - Mov [ES:4], EDX - Mov EAX, [CS:BP+8] ; Filtera - Mov EDX, [CS:BP+0Ch] ; Filterb - Mov [ES:10h], EAX - Mov [ES:14h], EDX - FLd1 - FSub DWord Ptr [ES:10h] - FSub DWord Ptr [ES:14h] - FStP DWord Ptr [ES:18h] ; Filterc - - Push BP - Call Word Ptr [CS:BX] - Pop BP - - Mov ES, CS:MixSegment ; Store filter data - Mov EAX, [ES:0] - Mov EDX, [ES:4] - Mov [CS:BP], EAX - Mov [CS:BP+4], EDX - - And Word Ptr [SI], 0111100010001101b - - Call IsSampleMode - JNE M32MixHandlerEnd - - Mov [CS:BP+16*64], EAX - Mov [CS:BP+16*64+4], EDX - Mov EAX, [CS:BP+8] - Mov EDX, [CS:BP+0Ch] - Mov [CS:BP+16*64+8], EAX - Mov [CS:BP+16*64+0Ch], EDX - - Jmp M32MixHandlerEnd - -M32MixHandlerError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ M32MixHandlerEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -M32MixHandlerEnd: - Pop CX - -M32MixHandlerEnd2: - Sub SI, 128 - Dec CX - JNZ M32MixHandler1 - - Push CS - Pop DS - Assume DS:Driver - - Xor DI, DI - Mov SI, Offset LastFilter - Mov CX, 80/4 - Mov ES, MixSegment - - Rep MovsD - -; Now do filtering. - FNInit - Mov CX, RealBytesToMix - - Push ES - Pop DS - Assume DS:Nothing - - Mov SI, 80 - -OutputFilter1: - FILD DWord Ptr [SI] ; Left sample - FILD DWord Ptr [SI+4] ; R, L - - FLd DWord Ptr [DS:20h] ; LB, R, L - FMul ST, ST(2) ; L.LB, R, L - FLd DWord Ptr [DS:20h] ; LB, L.LB, R, L - FMul ST, ST(2) ; R.LB, L.LB, R, L - FLd DWord Ptr [DS:0] ; OL, R.LB, L.LB, R, L - FMul DWord Ptr [DS:24h] ; OL.LB, R.LB, L.LB, R, L - FLd DWord Ptr [DS:4] ; OR, OL.LB, R.LB, L.LB, R, L - FMul DWord Ptr [DS:24h] ; OR.LB, OL.LB, R.LB, L.LB, R, L - - FXCh ; OL.LB, OR.LB, R.LB, L.LB, R, L - FAddP ST(3), ST - FAdd ; RLB, LLB, R, L - - FLd DWord Ptr [DS:28h] ; MB, RLB, LLB, R, L - FMul ST, ST(4) ; L.MB, RLB, LLB, R, L - FLd DWord Ptr [DS:28h] ; MB, L.MB, RLB, LLB, R, L - FMul ST, ST(4) ; R.MB, L.MB, RLB, LLB, R, L - FLd DWord Ptr [DS:8] ; OL, R.MB, L.MB, RLB, LLB, R, L - FMul DWord Ptr [DS:2Ch] ; OL.MB, R.MB, L.MB, RLB, LLB, R, L - FLd DWord Ptr [DS:0Ch] ; OR, OL.MB, R.MB, L.MB, RLB, LLB, R, L - FMul DWord Ptr [DS:2Ch] ; OR.MB, OL.MB, R.MB, L.MB, RLB, LLB, R, L - - FXCh ; OL.MB, OR.MB, R.MB, L.MB, RLB, LLB, R, L - FAddP ST(3), ST - FAdd ; RMB, LMB, RLB, LLB, R, L - FXCh ST(3) ; LLB, LMB, RLB, RMB, R, L - FStP DWord Ptr [DS:0] - FStP DWord Ptr [DS:8] - FStP DWord Ptr [DS:4] - FStP DWord Ptr [DS:0Ch] - - FLd DWord Ptr [DS:30h] - FMul ST, ST(2) - FLd DWord Ptr [DS:30h] - FMul ST, ST(2) - FLd DWord Ptr [DS:10h] - FMul DWord Ptr [DS:34h] - FLd DWord Ptr [DS:14h] - FMul DWord Ptr [DS:34h] - - FXCh - FAddP ST(3), ST - FAdd - - FLd DWord Ptr [DS:38h] - FMul ST, ST(4) - FLd DWord Ptr [DS:38h] - FMul ST, ST(4) - FLd DWord Ptr [DS:18h] - FMul DWord Ptr [DS:3Ch] - FLd DWord Ptr [DS:1Ch] - FMul DWord Ptr [DS:3Ch] - - FXCh - FAddP ST(3), ST - FAdd - FXCh ST(3) - FStP DWord Ptr [DS:10h] - FStP DWord Ptr [DS:18h] - FStP DWord Ptr [DS:14h] - FStP DWord Ptr [DS:1Ch] ; R, L - -; For each one, output value += ((band value) - (previous band value)) * Volume - - FLd DWord Ptr [DS:18h] - FSub DWord Ptr [DS:10h] ; L4, R, L - FLd DWord Ptr [DS:1Ch] - FSub DWord Ptr [DS:14h] ; R4, L4, R, L - FLd DWord Ptr [DS:10h] - FSub DWord Ptr [DS:8] - FLd DWord Ptr [DS:14h] - FSub DWord Ptr [DS:0Ch] ; R3, L3, R4, L4, R, L - FLd DWord Ptr [DS:8] - FSub DWord Ptr [DS:0] - FLd DWord Ptr [DS:0Ch] - FSub DWord Ptr [DS:4] ; R2, L2, R3, L3, R4, L4, R, L - FXCh ST(5) ; L4, L2, R3, L3, R4, R2, R, L - FMul DWord Ptr [DS:4Ch] ; L4V, L2, R3, L3, R4, R2, R, L - FXCh ST(4) ; R4, L2, R3, L3, L4V, R2, R, L - FMul DWord Ptr [DS:4Ch] ; R4V, L2, R3, L3, L4V, R2, R, L - FXCh ST(3) ; L3, L2, R3, R4V, L4V, R2, R, L - FMul DWord Ptr [DS:48h] ; L3V, L2, R3, R4V, L4V, R2, R, L - FXCh ST(2) ; R3, L2, L3V, R4V, L4V, R2, R, L - FMul DWord Ptr [DS:48h] ; R3V, L2, L3V, R4V, L4V, R2, R, L - FXCh ; L2, R3V, L3V, R4V, L4V, R2, R, L - FMul DWord Ptr [DS:44h] ; L2V, R3V, L3V, R4V, L4V, R2, R, L - FXCh ST(5) ; R2, R3V, L3V, R4V, L4V, L2V, R, L - FMul DWord Ptr [DS:44h] ; R2V, R3V, L3V, R4V, L4V, L2V, R, L - FXCh ST(4) ; L4V, R3V, L3V, R4V, R2V, L2V, R, L - FAddP ST(7), ST ; R3V, L3V, R4V, R2V, L2V, R, L - FAddP ST(5), ST ; L3V, R4V, R2V, L2V, R, L - FAddP ST(3), ST - FAdd - FLd DWord Ptr [DS:0] - FMul DWord Ptr [DS:40h] ; L1V, RV, LV, R, L - FLd DWord Ptr [DS:4] ; - FMul DWord Ptr [DS:40h] ; R1V, L1V, RV, LV, R, L - FXCh ST(2) ; RV, L1V, R1V, LV, R, L - FAddP ST(4), ST ; L1V, R1V, LV, R, L - FAddP ST(4), ST ; R1V, LV, R, L - FAddP ST(2), ST - FAddP ST(2), ST - - FIStP DWord Ptr [SI+4] - FIStP DWord Ptr [SI] - - Add SI, 8 - Dec CX - JNZ OutputFilter1 - -; Transfer contents out - Push CS - Pop ES - - Mov DI, Offset LastFilter - Xor SI, SI - Mov CX, 32/4 - - Rep MovsD -; Finished output filtering! - - Ret - -EndP M32MixHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; WAV output mix functions.... +; Uses Cubic Spline Interpolation +; + +ALIGN 4 + +WAVMixingTable Label + ; 8 bit, 16 bit + ; No sound, stereo, surround + ; No loop, forwards loop, ping pong loop + + DW Offset UpdateNoLoop, 0, 0, 0, 0 + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + + DW Offset MixNoLoop, PreM32SMix8Bit, MFS8Bit, MBS8Bit, Mix32Stereo8Bit + DW Offset MixForwardsLoop, PreM32SMix8Bit, MFS8Bit, MBS8Bit, Mix32Stereo8Bit + DW Offset MixPingPongLoop, PreM32SMix8Bit, MFS8Bit, MBS8Bit, Mix32Stereo8Bit + + DW Offset MixNoLoop, PreM32UMix8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit + DW Offset MixForwardsLoop, PreM32UMix8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit + DW Offset MixPingPongLoop, PreM32UMix8Bit, MFS8Bit, MBS8Bit, Mix32Surround8Bit + + DW Offset UpdateNoLoop, 0, 0, 0, 0 + DW Offset UpdateForwardsLoop, 0, 0, 0, 0 + DW Offset UpdatePingPongLoop, 0, 0, 0, 0 + + DW Offset MixNoLoop, PreM32SMix16Bit, MFS16Bit, MBS16Bit, Mix32Stereo16Bit + DW Offset MixForwardsLoop, PreM32SMix16Bit, MFS16Bit, MBS16Bit, Mix32Stereo16Bit + DW Offset MixPingPongLoop, PreM32SMix16Bit, MFS16Bit, MBS16Bit, Mix32Stereo16Bit + + DW Offset MixNoLoop, PreM32UMix16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit + DW Offset MixForwardsLoop, PreM32UMix16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit + DW Offset MixPingPongLoop, PreM32UMix16Bit, MFS16Bit, MBS16Bit, Mix32Surround16Bit + +LastLeftValue DD 0 +LastRightValue DD 0 + +Sample1 DD 0 +Sample2 DD 0 +Sample3 DD 0 +Sample4 DD 0 +SampleValue DD 0 +InterpolationOffset DD 0 +Const3 DD 3.0 +Const1On65536 DD 37800000h +Const256On6 DD 422AAAAAh +Const1On6 DD 3E2AAAAAh +;Const65536 DD 65536.0 +Const32768 DD 32768.0 +Const1On32768 DD 38000000h +;ConstLimiter DD 3F000000h +Const22713_0 DD 22713.0 + +MAXFILTERVALUE EQU 47000000h + +FILTERCLIPPINGTYPENONE EQU 0 +FILTERCLIPPINGTYPECOMPRESSOR EQU 1 +FILTERCLIPPINGTYPELIMIT EQU 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Get8BitWaveform Macro ; Puts waveform value in EBX, range -32k->+32k + Local X + + +IF CUBICINTERPOLATION + + Mov BX, DI + + Push EDX + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Sub BX, 1 + Mov InterpolationOffset, ECX + AdC BX, 0 + + FILD InterpolationOffset + FMul Const1On65536 + + MovSX EAX, Byte Ptr [ES:BX] + MovSX EBX, Byte Ptr [ES:DI] + Mov Sample1, EAX + Mov Sample2, EBX + FILD Sample1 + FILD Sample2 + FMul Const3 + + MovSX EAX, Byte Ptr [ES:DI+1] + MovSX EBX, Byte Ptr [ES:DI+2] + Mov Sample3, EAX + Mov Sample4, EBX + FILD Sample3 + FMul Const3 + FILD Sample4 ; x, 3w, 3v, u, Interp + +; a = x+3v-3w-u +; b = 3w+3u-6v +; c = 6w-2u-x-3v +; d = 6v + +; Assignments: +; F = x+3v +; -> a = F-3w-u +; -> b = 3w+3u-6v +; -> c = 6w-2u-F +; -> d = 6v + +IF INTELOPTIMISED + FAdd ST, ST(2) ; x+3v[3], 3w, 3v, u, Interp + FLd ST(1) ; 3w, x+3v[3], 3w, 3v, u, Interp + FAdd ST, ST(4) ; 3w+u[3], x+3v[2], 3w, 3v, u, Interp + FXCh ST(4) ; u, x+3v[2], 3w, 3v, 3w+u[3], Interp + FAdd ST, ST ; 2u[3], x+3v[1], 3w, 3v, 3w+u[2], Interp + FXCh ST(3) ; 3v, x+3v[1], 3w, 2u[3], 3w+u[2], Interp + FLd ST(1) ; x+3v, 3v, x+3v, 3w, 2u[3], 3w+u[1], Interp + FSub ST, ST(5) ; a[3], 3v, x+3v, 3w, 2u[2], 3w+u, Interp + FXCh ; 3v, a[3], x+3v, 3w, 2u[2], 3w+u, Interp + FAdd ST, ST ; 6v[3], a[2], x+3v, 3w, 2u[1], 3w+u, Interp + FXCh ST(5) ; 3w+u, a[2], x+3v, 3w, 2u[1], 6v[3], Interp + FAdd ST, ST(4) ; 3w+3u[3], a[1], x+3v, 3w, 2u, 6v[2], Interp + FXCh ; a[1], 3w+3u[3], x+3v, 3w, 2u, 6v[2], Interp + FMul ST, ST(6) ; ax[3], 3w+3u[2], x+3v, 3w, 2u, 6v[1], Interp + FXCh ST(2) ; x+3v, 3w+3u[2], ax[3], 3w, 2u, 6v[1], Interp + FAddP ST(4), ST ; 3w+3u[1], ax[2], 3w, 2u+F[3], 6v, Interp + FSub ST, ST(4) ; 3w+3u-6v[3], ax[1], 3w, 2u+F[2], 6v, Interp + FXCh ST(2) ; 3w, ax[1], b[3], 2u+F[1], 6v, Interp + FAdd ST, ST ; 6w[3], ax, b[2], 2u+F, 6v, Interp + FXCh ; ax, 6w[3], b[2], 2u+F, 6v, Interp + FAddP ST(2), ST ; 6w[1], ax+b[3], 2u+f, d, Interp + FSubRP ST(2), ST ; ax+b, c[3], d, Interp + FMul ST, ST(3) ; ax^2+bx[3], c[2], d, Interp + FXCh ST(3) ; Interp, c[2], d, ax^2+bx[3] + FMul Const256On6 ; sInterp[3], c, d, ax^2+bx[1] + FXCh ; c, sInterp[3], d, ax^2+bx[1] + FAddP ST(3), ST ; sInterp[2], d, ax^2+bx+c[3] + FXCh ; d, sInterp[2], ax^2+bx+c[3] + FMul Const256On6 ; sd[3], sInterp[1], ax^2+bx+c[2] + FXCh ; sInterp[1], sd[3], ax^2+bx+c[2] + FMulP ST(2), ST + + Pop DS + Assume DS:Nothing + Mov EDX, [DS:0] + + FAdd ; SampleValue (16 bit value) + + FLd DWord Ptr [DS:0] ; x(k-1), x(k) + FMul DWord Ptr [DS:14h] ; b.x(k-1), x(k) + FLd DWord Ptr [DS:4] ; x(k-2), b.x(k-1), x(k) + FMul DWord Ptr [DS:18h] ; c.x(k-2), b.x(k-1), x(k) + FXCh ST(2) ; x(k), b.x(k-1), c.x(k-2) + FMul DWord Ptr [DS:10h] ; a.x(k), b.x(k-1), c.x(k-2) + FXCh ST(2) ; c.x(k-2), b.x(k-1), a.x(k) + FAdd + Mov EDX, [DS:0] + FAdd + + Mov [DS:4], EDX + + FSt DWord Ptr [DS:0] + FIStP CS:SampleValue + +ELSE + FAdd ST, ST(2) ; x+3v, 3w, 3v, u, Interp + FLd ST(1) ; 3w, x+3v, 3w, 3v, u, Interp + FSub ST, ST(4) ; 3w-u, x+3v, 3w, 3v, u, Interp + FAdd ST, ST ; 6w-2u, x+3v, 3w, 3v, u, Interp + FSub ST, ST(1) ; "c", x+3v, 3w, 3v, u, Interp + FXCh ; x+3v, "c", 3w, 3v, u, Interp + FSub ST, ST(2) ; x+3v-3w, "c", 3w, 3v, u, Interp + FSub ST, ST(4) ; "a", "c", 3w, 3v, u, Interp + FMul ST, ST(5) ; "ax", "c", 3w, 3v, u, Interp + FXCh ST(3) ; 3v, "c", 3w, "ax", u, Interp + FAdd ST, ST ; 6v, "c", 3w, "ax", u, Interp + FXCh ST(4) ; u, "c", 3w, "ax", 6v, Interp + FMul Const3 ; 3u, "c", 3w, "ax", 6v, Interp + FSub ST, ST(4) ; 3u-6v, "c", 3w, "ax", 6v, Interp + FAdd ST, ST(2) ; "b", "c", 3w, "ax", 6v, Interp + FAdd ST, ST(3) ; "ax+b", "c", 3w, "ax", 6v, Interp + FMul ST, ST(5) ; "ax^2+bx", "c", 3w, "ax", 6v, Interp + FAdd ; ax^2+bx+c, 3w, "ax", 6v, Interp + FMulP ST(4), ST ; 3w, "ax", 6v, ax^3+bx^2+cx + FComPP ; 6v, ax^3+bx^2+cx + FAdd ; SampleValue + FMul Const256On6 ; x(k) + + Pop DS + Assume DS:Nothing + + FMul DWord Ptr [DS:10h] + + FLd DWord Ptr [DS:0] ; x(k-1), x(k) + FMul DWord Ptr [DS:14h] ; b.x(k-1), x(k) + FLd DWord Ptr [DS:4] ; x(k-2), b.x(k-1), x(k) + FMul DWord Ptr [DS:18h] ; c.x(k-2), b.x(k-1), x(k) + FAdd + Mov EDX, [DS:0] + FAdd + + Mov [DS:4], EDX + + FSt DWord Ptr [DS:0] + FIStP SampleValue + +ENDIF + Pop EDX + + IF FILTERCLIPPINGTYPENONE + ELSE + Mov EAX, [DS:0] + And EAX, 7FFFFFFFh + Cmp EAX, MAXFILTERVALUE + JBE X + + IF FILTERCLIPPINGTYPECOMPRESSOR + + Mov EBX, [DS:0] + FLd CS:Const22713_0 + FLd DWord Ptr [DS:0] + FAbs + FMul CS:Const1On32768 + FYL2X ; ST = ln(x/65536) / ln(2) * 65536 * ln(2) + FAdd CS:Const32768 + SAR EBX, 31 + FIStP SampleValue + Xor SampleValue, EBX + Sub SampleValue, EBX + +Comment ~ + Mov EBX, [DS:0] + FLd DWord Ptr [DS:0] + FAbs + FSub [CS:Const65536] + FMul [CS:ConstLimiter] + FAdd [CS:Const65536] + SAR EBX, 31 + FIStP SampleValue + Xor SampleValue, EBX + Sub SampleValue, EBX +; FILD SampleValue +; FStP DWord Ptr [DS:0] +~ + ENDIF + IF FILTERCLIPPINGTYPELIMIT + + Mov EBX, [DS:0] + Mov EAX, MAXFILTERVALUE + And EBX, 80000000h + Or EAX, EBX + Mov [DS:0], EAX + ENDIF +X: + ENDIF + Mov EBX, SampleValue + +ENDIF + +IF QUADRATICINTERPOLATION + + Push EDX + Push EBP + + MovSX EDX, Byte Ptr [ES:DI+2] ; v + MovSX EBX, Byte Ptr [ES:DI] ; t + MovSX EAX, Byte Ptr [ES:DI+1] ; u + + LEA EBP, [EBX+EDX] ; v+t + SAR EBP, 1 + Sub EBP, EAX ; (v+t)/2 - u + IMul EBP, ECX ; ax in 8.16 format + SAR EBP, 10 ; ax in 8.6 format + + ShL EAX, 7 ; EBX = 2u<<6 + Add EDX, EBX ; EDX = v+t + Add EBX, EBX ; EAX = 2t + Add EBP, EAX ; EBP = ax+2u + Add EDX, EBX ; 3t+v + ShL EDX, 5 ; (3t+v)/2 << 6 + Sub EBP, EDX ; ax+b + + ShL EBX, 7 + + IMul EBP, ECX ; ax^2+bx in 8.22 form + SAR EBP, 14 ; ax^2+bx in 8.8 form + + Add EBX, EBP ; ax^2+bx+c + + Pop EBP + Pop EDX +ENDIF + + +IF LINEARINTERPOLATION + MovSX EBX, Byte Ptr [ES:DI+1] + MovSX EAX, Byte Ptr [ES:DI] + Sub EBX, EAX + IMul EBX, ECX + SAR EBX, 8 + ShL EAX, 8 + Add EBX, EAX +ENDIF + +IF POINTSAMPLED + MovSX EBX, Byte Ptr [ES:DI] + ShL EBX, 8 +ENDIF + +EndM + +Get16BitWaveform Macro ; Puts waveform value in EBX, range -32k->+32k + Local X + +IF CUBICINTERPOLATION + Mov EBX, EDI + + Push EDX + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Sub BX, 1 + Mov InterpolationOffset, ECX + AdC BX, 0 + + FILD InterpolationOffset + FMul Const1On65536 + + MovSX EAX, Word Ptr [ES:EBX+EBX] + MovSX EBX, Word Ptr [ES:EDI+EDI] + Mov Sample1, EAX + Mov Sample2, EBX + FILD Sample1 + FILD Sample2 + FMul Const3 + + MovSX EAX, Word Ptr [ES:EDI+EDI+2] + MovSX EBX, Word Ptr [ES:EDI+EDI+4] + Mov Sample3, EAX + Mov Sample4, EBX + FILD Sample3 + FMul Const3 + FILD Sample4 ; x, 3w, 3v, u, Interp + + +; a = x+3v-3w-u +; b = 3w+3u-6v +; c = 6w-2u-x-3v +; d = 6v + +; Assignments: +; F = x+3v +; -> a = F-3w-u +; -> b = 3w+3u-6v +; -> c = 6w-2u-F +; -> d = 6v + +IF INTELOPTIMISED + FAdd ST, ST(2) ; x+3v[3], 3w, 3v, u, Interp + FLd ST(1) ; 3w, x+3v[3], 3w, 3v, u, Interp + FAdd ST, ST(4) ; 3w+u[3], x+3v[2], 3w, 3v, u, Interp + FXCh ST(4) ; u, x+3v[2], 3w, 3v, 3w+u[3], Interp + FAdd ST, ST ; 2u[3], x+3v[1], 3w, 3v, 3w+u[2], Interp + FXCh ST(3) ; 3v, x+3v[1], 3w, 2u[3], 3w+u[2], Interp + FLd ST(1) ; x+3v, 3v, x+3v, 3w, 2u[3], 3w+u[1], Interp + FSub ST, ST(5) ; a[3], 3v, x+3v, 3w, 2u[2], 3w+u, Interp + FXCh ; 3v, a[3], x+3v, 3w, 2u[2], 3w+u, Interp + FAdd ST, ST ; 6v[3], a[2], x+3v, 3w, 2u[1], 3w+u, Interp + FXCh ST(5) ; 3w+u, a[2], x+3v, 3w, 2u[1], 6v[3], Interp + FAdd ST, ST(4) ; 3w+3u[3], a[1], x+3v, 3w, 2u, 6v[2], Interp + FXCh ; a[1], 3w+3u[3], x+3v, 3w, 2u, 6v[2], Interp + FMul ST, ST(6) ; ax[3], 3w+3u[2], x+3v, 3w, 2u, 6v[1], Interp + FXCh ST(2) ; x+3v, 3w+3u[2], ax[3], 3w, 2u, 6v[1], Interp + FAddP ST(4), ST ; 3w+3u[1], ax[2], 3w, 2u+F[3], 6v, Interp + FSub ST, ST(4) ; 3w+3u-6v[3], ax[1], 3w, 2u+F[2], 6v, Interp + FXCh ST(2) ; 3w, ax[1], b[3], 2u+F[1], 6v, Interp + FAdd ST, ST ; 6w[3], ax, b[2], 2u+F, 6v, Interp + FXCh ; ax, 6w[3], b[2], 2u+F, 6v, Interp + FAddP ST(2), ST ; 6w[1], ax+b[3], 2u+f, d, Interp + FSubRP ST(2), ST ; ax+b, c[3], d, Interp + FMul ST, ST(3) + FXCh ST(3) ; Interp, c[2], d, ax^2+bx[3] + FMul Const1On6 ; sInterp[3], c, d, ax^2+bx[1] + FXCh ; c, sInterp[3], d, ax^2+bx[1] + FAddP ST(3), ST ; sInterp[2], d, ax^2+bx+c[3] + FXCh ; d, sInterp[2], ax^2+bx+c[3] + FMul Const1On6 ; sd[3], sInterp[1], ax^2+bx+c[2] + FXCh ; sInterp[1], sd[3], ax^2+bx+c[2] + FMulP ST(2), ST + + Pop DS + Assume DS:Nothing + Mov EDX, [DS:0] + + FAdd ; SampleValue (16 bit value) + + FLd DWord Ptr [DS:0] ; x(k-1), x(k) + FMul DWord Ptr [DS:14h] ; b.x(k-1), x(k) + FLd DWord Ptr [DS:4] ; x(k-2), b.x(k-1), x(k) + FMul DWord Ptr [DS:18h] ; c.x(k-2), b.x(k-1), x(k) + FXCh ST(2) ; x(k), b.x(k-1), c.x(k-2) + FMul DWord Ptr [DS:10h] ; a.x(k), b.x(k-1), c.x(k-2) + FXCh ST(2) ; c.x(k-2), b.x(k-1), a.x(k) + FAdd + Mov EDX, [DS:0] + FAdd + + Mov [DS:4], EDX + + FSt DWord Ptr [DS:0] + FIStP CS:SampleValue + +ELSE + FAdd ST, ST(2) ; x+3v, 3w, 3v, u, Interp + FLd ST(1) ; 3w, x+3v, 3w, 3v, u, Interp + FSub ST, ST(4) ; 3w-u, x+3v, 3w, 3v, u, Interp + FAdd ST, ST ; 6w-2u, x+3v, 3w, 3v, u, Interp + FSub ST, ST(1) ; "c", x+3v, 3w, 3v, u, Interp + FXCh ; x+3v, "c", 3w, 3v, u, Interp + FSub ST, ST(2) ; x+3v-3w, "c", 3w, 3v, u, Interp + FSub ST, ST(4) ; "a", "c", 3w, 3v, u, Interp + FMul ST, ST(5) ; "ax", "c", 3w, 3v, u, Interp + FXCh ST(3) ; 3v, "c", 3w, "ax", u, Interp + FAdd ST, ST ; 6v, "c", 3w, "ax", u, Interp + FXCh ST(4) ; u, "c", 3w, "ax", 6v, Interp + FMul Const3 ; 3u, "c", 3w, "ax", 6v, Interp + FSub ST, ST(4) ; 3u-6v, "c", 3w, "ax", 6v, Interp + FAdd ST, ST(2) ; "b", "c", 3w, "ax", 6v, Interp + FAdd ST, ST(3) ; "ax+b", "c", 3w, "ax", 6v, Interp + FMul ST, ST(5) ; "ax^2+bx", "c", 3w, "ax", 6v, Interp + FAdd ; ax^2+bx+c, 3w, "ax", 6v, Interp + FMulP ST(4), ST ; 3w, "ax", 6v, ax^3+bx^2+cx + FComPP ; 6v, ax^3+bx^2+cx + FAdd ; SampleValue + FMul Const1On6 + + Pop DS + Assume DS:Nothing + + FMul DWord Ptr [DS:10h] + + FLd DWord Ptr [DS:0] ; x(k-1), x(k) + FMul DWord Ptr [DS:14h] ; b.x(k-1), x(k) + FLd DWord Ptr [DS:4] ; x(k-2), b.x(k-1), x(k) + FMul DWord Ptr [DS:18h] ; c.x(k-2), b.x(k-1), x(k) + FAdd + Mov EDX, [DS:0] + FAdd + + Mov [DS:4], EDX + + FSt DWord Ptr [DS:0] + FIStP SampleValue +ENDIF + Pop EDX + + IF FILTERCLIPPINGTYPENONE + ELSE + Mov EAX, [DS:0] + And EAX, 7FFFFFFFh + Cmp EAX, MAXFILTERVALUE + JBE X + + IF FILTERCLIPPINGTYPECOMPRESSOR + + Mov EBX, [DS:0] + FLd CS:Const22713_0 + FLd DWord Ptr [DS:0] + FAbs + FMul CS:Const1On32768 + FYL2X ; ST = ln(x/65536) / ln(2) * 65536 * ln(2) + FAdd CS:Const32768 + SAR EBX, 31 + FIStP SampleValue + Xor SampleValue, EBX + Sub SampleValue, EBX + +Comment ~ + Mov EBX, [DS:0] + FLd DWord Ptr [DS:0] + FAbs + FSub [CS:Const65536] + FMul [CS:ConstLimiter] + FAdd [CS:Const65536] + SAR EBX, 31 + FIStP SampleValue + XOr SampleValue, EBX + Sub SampleValue, EBX +; FILD SampleValue +; FStP DWord Ptr [DS:0] +~ + + ENDIF + IF FILTERCLIPPINGTYPELIMIT + + Mov EBX, [DS:0] + Mov EAX, MAXFILTERVALUE + And EBX, 80000000h + Or EAX, EBX + Mov [DS:0], EAX + ENDIF +X: + ENDIF + Mov EBX, SampleValue + +ENDIF + +IF QUADRATICINTERPOLATION + + Push ECX + Push EDX + Push EBP + + MovSX EDX, Word Ptr [ES:EDI+EDI+4] ; v + MovSX EBX, Word Ptr [ES:EDI+EDI] ; t + MovSX EAX, Word Ptr [ES:EDI+EDI+2] ; u + + ShR ECX, 3 ; 0.13 + LEA EBP, [EBX+EDX] + SAR EBP, 1 + Sub EBP, EAX ; (v+t)/2 - u + IMul EBP, ECX ; 16.13 + SAR EBP, 14 ; 15.0 + + Add EDX, EBX ; EDX = v+t + Add EBP, EAX ; EBP = ax+2u + LEA EDX, [EDX+EBX*2] + SAR EDX, 2 ; EDX = (3t+v)/2 + Sub EBP, EDX ; ax + b, 15 form + + IMul EBP, ECX ; ax^2+bx in 15.13 form + SAR EBP, 12 ; ax^2+bx in 16.0 form + + Add EBX, EBP + + Pop EBP + Pop EDX + Pop ECX + +ENDIF + +IF LINEARINTERPOLATION + MovSX EBX, Word Ptr [ES:EDI+EDI+2] + MovSX EAX, Word Ptr [ES:EDI+EDI] + Sub EBX, EAX + SAR EBX, 1 + IMul EBX, ECX + SAR EBX, 15 + Add EBX, EAX +ENDIF + +IF POINTSAMPLED + MovSX EBX, Word Ptr [ES:EDI+EDI] +ENDIF + +EndM + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Mix32Stereo8Bit ; Given DS:SI = buffer + ; Given ES:DI = sample + ; AX = bytes to mix + ; CX = error + ; DX = delta offset + ; BP = delta error + + ShL AX, 3 + Add AX, SI + Mov Word Ptr [CS:M32S8BEND], AX + +Mix32Stereo8Bit1: + Get8BitWaveForm + +M32S8BLVC EQU $+3 + IMul EAX, EBX, 12345678h + Sub [SI], EAX + + Mov CS:LastLeftValue, EAX + +M32S8BRVC EQU $+3 + IMul EAX, EBX, 12345678h + Sub [SI+4], EAX + + Mov CS:LastRightValue, EAX + + Add CX, BP + AdC DI, DX + Add SI, 8 + +M32S8BLVSet EQU $+2 + Mov EAX, 12345678h ; Destination volume left +M32S8BRVSet EQU $+2 + Mov EBX, 12345678h ; Destination volume right + + Sub EAX, DWord Ptr [CS:M32S8BLVC] ; Delta + Sub EBX, DWord Ptr [CS:M32S8BRVC] + + SAR EAX, RAMPSPEED + SAR EBX, RAMPSPEED + + Add DWord Ptr [CS:M32S8BLVC], EAX + Add DWord Ptr [CS:M32S8BRVC], EBX + +M32S8BNoRightRamp: + +M32S8BEND EQU $+2 + Cmp SI, 1234h + JNE Mix32Stereo8Bit1 + + Ret + +EndP Mix32Stereo8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreM32SMix8Bit + +IF VOLUMERAMP + PushAD + + Xor EAX, EAX + Xor EBX, EBX + Xor EDX, EDX + Xor EBP, EBP + Xor EDI, EDI + + Mov AX, Word Ptr [SI+0Ch] ; New right volume + Mov BX, Word Ptr [SI+0Eh] ; New left volume + + Mov DX, Word Ptr [SI+1Ch] ; Old right volume + Mov BP, Word Ptr [SI+1Eh] ; Old left volume + + Mov DWord Ptr [CS:M32S8BRVC], EDX + Mov DWord Ptr [CS:M32S8BLVC], EBP + +; Compensate for upwards ramp. + + Cmp AX, DX + JB PreM32Mix8BitNoRightCompensate + + Add AX, RAMPCOMPENSATE + +PreM32Mix8BitNoRightCompensate: + + Cmp BX, BP + JB PreM32Mix8BitNoLeftCompensate + + Add BX, RAMPCOMPENSATE + +PreM32Mix8BitNoLeftCompensate: + Mov DWord Ptr [CS:M32S8BRVSet], EAX + Mov DWord Ptr [CS:M32S8BLVSet], EBX + +; Now to figure out exact final volumes + + Push SI + Mov CX, CS:RealBytesToMix + +PreM32Mix8Bit1: + Mov ESI, EAX ; Set values + Mov EDI, EBX + Sub ESI, EDX ; Current values + Sub EDI, EBP + SAR ESI, RAMPSPEED + SAR EDI, RAMPSPEED + Add EDX, ESI + Add EBP, EDI + + Loop PreM32Mix8Bit1 + + Pop SI + + Mov Word Ptr [SI+1Ch], DX + Mov Word Ptr [SI+1Eh], BP + + PopAD + Ret +ELSE + + Xor EAX, EAX + Xor EBX, EBX + + Mov AX, Word Ptr [SI+0Ch] + Mov BX, Word Ptr [SI+0Eh] + + Mov DWord Ptr [CS:M32S8BRVC], EAX + Mov DWord Ptr [CS:M32S8BLVC], EBX + + Mov DWord Ptr [CS:M32S8BRVSet], EAX + Mov DWord Ptr [CS:M32S8BLVSet], EBX + + Mov [SI+1Ch], AX + Mov [SI+1Eh], BX + + Ret +ENDIF + +EndP PreM32SMix8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Mix32Surround8Bit ; Given DS:SI = buffer + ; Given ES:DI = sample + ; AX = bytes to mix + ; CX = error + ; DX = delta offset + ; BP = delta error + + ShL AX, 3 + Add AX, SI + Mov Word Ptr [CS:M32U8BEND], AX + +Mix32Surround8Bit1: + Get8BitWaveForm + +M32U8BLVC EQU $+3 + IMul EAX, EBX, 12345678h + Sub [SI], EAX + Mov CS:LastLeftValue, EAX + + Neg EAX +M32U8BLVSet EQU $+2 + Mov EBX, 12345678h + + Sub [SI+4], EAX + Sub EBX, DWord Ptr [CS:M32U8BLVC] + + + SAR EBX, RAMPSPEED + Add SI, 8 + + Add CX, BP + AdC DI, DX + + Add DWord Ptr [CS:M32U8BLVC], EBX + +M32U8BEND EQU $+2 + Cmp SI, 1234h + JNE Mix32Surround8Bit1 + + Mov EAX, CS:LastLeftValue + Neg EAX + Mov CS:LastRightValue, EAX + Ret + +EndP Mix32Surround8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreM32UMix8Bit + +IF VOLUMERAMP + Xor EAX, EAX + Xor EBX, EBX + Mov AX, Word Ptr [SI+1Eh] ; Old + Mov BX, Word Ptr [SI+0Eh] ; New + Mov DWord Ptr [CS:M32U8BLVC], EAX + +; Compensate for upwards ramp. + + Cmp BX, AX + JB PreM32MixU8Bit2 + + Add BX, RAMPCOMPENSATE + +PreM32MixU8Bit2: + Mov DWord Ptr [CS:M32U8BLVSet], EBX + + Mov CX, CS:RealBytesToMix + +PreM32UMix8Bit1: + Mov EDX, EBX + Sub EDX, EAX + SAR EDX, RAMPSPEED + Add EAX, EDX + + Loop PreM32UMix8Bit1 + + Mov [SI+1Eh], AX + Ret + +ELSE + Xor EAX, EAX + Mov AX, Word Ptr [SI+0Eh] + Mov DWord Ptr [CS:M32U8BLVC], EAX + Mov DWord Ptr [CS:M32U8BLVSet], EAX + Mov [SI+1Eh], AX + + Ret +ENDIF + +EndP PreM32UMix8Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Mix32Stereo16Bit + + ShL AX, 3 + Add AX, SI + Mov Word Ptr [CS:M32S16BEND], AX + +Mix32Stereo16Bit1: + Get16BitWaveform + +M32S16BLVC EQU $+3 + IMul EAX, EBX, 12345678h + Sub [SI], EAX + + Mov CS:LastLeftValue, EAX + +M32S16BRVC EQU $+3 + IMul EAX, EBX, 12345678h + Sub [SI+4], EAX + + Mov CS:LastRightValue, EAX + + Add CX, BP + AdC DI, DX + +M32S16BLVSet EQU $+2 + Mov EAX, 12345678h ; Destination volume left +M32S16BRVSet EQU $+2 + Mov EBX, 12345678h ; Destination volume right + + Sub EAX, DWord Ptr [CS:M32S16BLVC] ; Delta + Sub EBX, DWord Ptr [CS:M32S16BRVC] + + SAR EAX, RAMPSPEED + SAR EBX, RAMPSPEED + + Add DWord Ptr [CS:M32S16BLVC], EAX + Add DWord Ptr [CS:M32S16BRVC], EBX + + Add SI, 8 + +M32S16BEND EQU $+2 + Cmp SI, 1234h + JNE Mix32Stereo16Bit1 + + Ret + +EndP Mix32Stereo16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreM32SMix16Bit + +IF VOLUMERAMP + PushAD + + Xor EAX, EAX + Xor EBX, EBX + Xor EDX, EDX + Xor EBP, EBP + Xor EDI, EDI + + Mov AX, Word Ptr [SI+0Ch] ; New right volume + Mov BX, Word Ptr [SI+0Eh] ; New left volume + + Mov DX, Word Ptr [SI+1Ch] ; Old right volume + Mov BP, Word Ptr [SI+1Eh] ; Old left volume + + Mov DWord Ptr [CS:M32S16BRVC], EDX + Mov DWord Ptr [CS:M32S16BLVC], EBP + +; Compensate for upwards ramp. + + Cmp AX, DX + JB PreM32Mix16BitNoRightCompensate + + Add AX, RAMPCOMPENSATE + +PreM32Mix16BitNoRightCompensate: + + Cmp BX, BP + JB PreM32Mix16BitNoLeftCompensate + + Add BX, RAMPCOMPENSATE + +PreM32Mix16BitNoLeftCompensate: + Mov DWord Ptr [CS:M32S16BRVSet], EAX + Mov DWord Ptr [CS:M32S16BLVSet], EBX + +; Now to figure out exact final volumes + + Push SI + Mov CX, CS:RealBytesToMix + +PreM32Mix16Bit1: + Mov ESI, EAX ; Set values + Mov EDI, EBX + + Sub ESI, EDX ; Current values + Sub EDI, EBP + + SAR ESI, RAMPSPEED + SAR EDI, RAMPSPEED + + Add EDX, ESI + Add EBP, EDI + + Loop PreM32Mix16Bit1 + Pop SI + + Mov Word Ptr [SI+1Ch], DX + Mov Word Ptr [SI+1Eh], BP + + PopAD + Ret +ELSE + + Xor EAX, EAX + Xor EBX, EBX + + Mov AX, Word Ptr [SI+0Ch] + Mov BX, Word Ptr [SI+0Eh] + + Mov DWord Ptr [CS:M32S16BRVC], EAX + Mov DWord Ptr [CS:M32S16BLVC], EBX + + Mov DWord Ptr [CS:M32S16BRVSet], EAX + Mov DWord Ptr [CS:M32S16BLVSet], EBX + + Mov [SI+1Ch], AX + Mov [SI+1Eh], BX + + Ret +ENDIF + +EndP PreM32SMix16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Mix32Surround16Bit ; Given DS:SI = buffer + ; Given ES:DI = sample + ; AX = bytes to mix + ; CX = error + ; DX = delta offset + ; BP = delta error + + ShL AX, 3 + Add AX, SI + Mov Word Ptr [CS:M32U16BEND], AX + +Mix32Surround16Bit1: + Get16BitWaveForm + +M32U16BLVC EQU $+3 + IMul EAX, EBX, 12345678h + Sub [SI], EAX + +M32U16BLVSet EQU $+2 + Mov EBX, 12345678h + + Neg EAX + Sub EBX, DWord Ptr [CS:M32U16BLVC] + + Sub [SI+4], EAX + + SAR EBX, RAMPSPEED + Add SI, 8 + + Add CX, BP + AdC DI, DX + + Add DWord Ptr [CS:M32U16BLVC], EBX + +M32U16BEND EQU $+2 + Cmp SI, 1234h + JNE Mix32Surround16Bit1 + + Mov CS:LastRightValue, EAX + Neg EAX + Mov CS:LastLeftValue, EAX + Ret + +EndP Mix32Surround16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreM32UMix16Bit + +IF VOLUMERAMP + Xor EAX, EAX + Xor EBX, EBX + Mov AX, Word Ptr [SI+1Eh] + Mov BX, Word Ptr [SI+0Eh] + Mov DWord Ptr [CS:M32U16BLVC], EAX + +; Compensate for upwards ramp. + + Cmp BX, AX + JB PreM32MixU16Bit2 + + Add BX, RAMPCOMPENSATE + +PreM32MixU16Bit2: + + Mov DWord Ptr [CS:M32U16BLVSet], EBX + + Mov CX, CS:RealBytesToMix + +PreM32UMix16Bit1: + Mov EDX, EBX + Sub EDX, EAX + SAR EDX, RAMPSPEED + Add EAX, EDX + + Loop PreM32UMix16Bit1 + + Mov [SI+1Eh], AX + Ret + +ELSE + Xor EAX, EAX + Mov AX, Word Ptr [SI+0Eh] + Mov DWord Ptr [CS:M32U16BLVC], EAX + Mov DWord Ptr [CS:M32U16BLVSet], EAX + Mov [SI+1Eh], AX + Ret +ENDIF + +EndP PreM32UMix16Bit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +NUMBEROFFILTERBANDS EQU 4 + +ALIGN 4 +LastClickRemovalLeft DD 0 +LastClickRemovalRight DD 0 +StartingChannelOffset DW 0 +FilterParameters DB 64 Dup (7Fh), 64 Dup (0) +FilterValues DD 4*256 Dup (0) +SampleFilterCopyOffset DW 16*64 +FreqMultiplier DD 3A9F7867h ; = 1/(2*PI*110.0*2^0.25) +FreqParameterMultiplier DD 0B92AAAAAh ; = -1/(24*256) +FilterFreqValue DW 0 +NewControlWord DW 7Fh +include q.inc + +LastFilter DD NUMBEROFFILTERBANDS*2 Dup (0) ; 4 stereo values +FilterCoefficients DD NUMBEROFFILTERBANDS*2 Dup (0) +FilterVolumes DD NUMBEROFFILTERBANDS Dup (0) + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc IsSampleMode ; returns zero flag if sample mode. + + Push DS + + Mov DS, CS:SongDataArea + Test Byte Ptr [DS:2Ch], 4 + + Pop DS + Ret + +EndP IsSampleMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M32MixHandler + ; Clear output buffer first... + + Mov CS:StartingChannelOffset, SI + + Push CX + + Mov ES, CS:MixSegment + Mov EAX, CS:BytesToMixFractional + Mov CX, CS:BytesToMix + Add CurrentFractional, EAX + AdC CX, 0 + Mov CS:RealBytestoMix, CX +; Add CX, CX ; Stereo = 2 * BytesToMix +; Mov DI, 32 +; Xor EAX, EAX +; Rep StosD + + Pop CX + + PushAD + + Mov EDX, CS:LastClickRemovalLeft + Mov EBP, CS:LastClickRemovalRight + +; Do left first. + Mov SI, 80 + Mov CX, CS:RealBytesToMix + +ClickRemoval3: + +Comment ~ + + Mov [ES:SI], EDX + Mov [ES:SI+4], EBP + + Inc EDX + JS ClickRemoval4 + + Sub EDX, 2 + JGE ClickRemoval4 + + Inc EDX + +ClickRemoval4: + Inc EBP + JS ClickRemoval5 + + Sub EBP, 2 + JGE ClickRemoval5 + + Inc EBP + +ClickRemoval5: +~ + + Mov EAX, EDX + Mov EBX, EBP + SAR EAX, 12 + SAR EBX, 12 + Mov [ES:SI], EDX + Mov [ES:SI+4], EBP + + Sub EAX, 1 + AdC EAX, 1 + Sub EBX, 1 + AdC EBX, 1 + + Sub EDX, EAX + Sub EBP, EBX + + Add SI, 8 + Loop ClickRemoval3 + + Mov CS:LastClickRemovalLeft, EDX + Mov CS:LastClickRemovalRight, EBP + + PopAD + + ; Check each channel... + ; Prepare mixing stuff + +; Work backwards + Mov AX, CX + Dec AX + ShL AX, 7 + Add SI, AX + +M32MixHandler1: + Test Byte Ptr [SI], 1 + JZ M32MixHandlerEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE M32MixHandlerEnd2 + + Push CX + Mov BP, SI + Sub BP, [CS:StartingChannelOffset] ; BP = SlaveChannel*128 + SHR BP, 3 ; BP = SlaveChannel*16 + Mov DI, BP + Add BP, Offset FilterValues + + Mov CX, [SI] + Test CH, 2 + JZ M32MixHandler13 + + ; Note cut. + And Byte Ptr [SI], Not 1 ; Turn off channel + Mov Word Ptr [SI+4Ah], 0 + Or CL, 40h + +M32MixHandler13: + Test CL, 20h ; New freq? + JZ M32MixHandler3 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE M32MixHandlerError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +M32MixHandler3: + Test CH, 1 ; New note? + JZ M32MixHandler12 + + Xor EAX, EAX + Mov DWord Ptr [SI+1Ch], EAX + Mov DWord Ptr [CS:BP], EAX + Mov DWord Ptr [CS:BP+4], EAX + Mov DWord Ptr [CS:BP+8], 3F800000h + Mov DWord Ptr [CS:BP+0Ch], EAX + +M32MixHandler12: + Test CX, 8440h ; New volume, loop or pan? + JZ M32MixHandler4 + + Mov AL, [SI+3Ah] + Test AL, AL + JNS M32MixHandlerFilter1 + + Mov BL, [SI+3Fh] + Jmp M32MixHandlerFilter2 + +M32MixHandlerFilter1: + Mov DI, AX + And DI, 63 + Add DI, Offset FilterParameters + + Mov AL, [CS:DI] + Mov BL, [CS:DI+64] + Mov [SI+5Bh], AL + Mov [SI+3Fh], BL + +M32MixHandlerFilter2: + Mov AL, [SI+3Eh] + Mul Byte Ptr [SI+5Bh] + Mov CS:FilterFreqValue, AX + ShR AX, 8 + Mov AH, BL + AdC AX, 0 + + Cmp AX, 7Fh + JE M32MixHandlerNoFilter + + And BX, 0FFh + ShL BX, 2 + + FNInit + FLdCW [CS:NewControlWord] + + FILD [CS:FilterFreqValue] ; 0->127*256 + FMul [CS:FreqParameterMultiplier] ; -i/(24*256) + FLd ST + FRndInt + FSub ST(1), ST + FXCh + F2XM1 + FLd1 + FAdd + FScale ; = 2^(i/24*256) + FMul [CS:FreqMultiplier] ; = r + FLd ST ; r, r + FMul ST(1), ST ; r, r^2 + + FLd [CS:QualityFactorTable+BX] ; 2d, r, r^2 + FMul ST(1), ST ; 2d, 2dr, r^2 + FLd1 ; 1, 2d, 2dr, r^2 + FSubP ST(1), ST ; 2d-1, 2dr, r^2 + FAdd + + FLd1 ; 1, d, e + FAdd ST, ST(1) + FAdd ST, ST(2) ; 1+d+e, d, e + FLd1 ; 1, 1+d+e, d, e + FDivRP ST(1), ST ; 1/(1+d+e), d, e + FSt DWord Ptr [CS:BP+8] + FXCh ; d, 1/(1+d+e), e + FAdd ST, ST(2) + FAddP ST(2), ST ; 1/(1+d+e), d+2e + FMul + FStP DWord Ptr [CS:BP+0Ch] + FStP ST + +M32MixHandlerNoFilter: + +IF REGISTERED + Test CH, 8 + JNZ M32MixHandler7 + + Cmp CS:Stereo, 0 + JE M32MixHandler6 + + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE M32MixHandler6 + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + SHRD AX, DX, 14 + + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] ; Final volume + SHRD AX, DX, 14 + Mov [SI+0Eh], AX + + ; Now to decide on mixing method + Cmp DWord Ptr [SI+0Ch], 0 + JNE M32MixHandler5 +ELSE + Test CH, 8 + JZ M32MixHandler6 + +ENDIF + +M32MixHandler7: + ; Zero volume + Xor EAX, EAX + Mov [SI+0Ch], EAX + Cmp [SI+1Ch], EAX ; Last volumes = 0? + JE M32MixHandler8 + +M32MixHandler5: ; Other.. (ie. panned) + Mov AX, 30 + Jmp M32MixHandler8 + +M32MixHandler6: ; Surround sound + Mov AX, [SI+4Ah] + Mul MixVolume + +IF REGISTERED + ShRD AX, DX, 8 + Cmp CS:Stereo, 0 + JE M32MixHandlerHalfStereoVolume + + ShR AX, 1 + +M32MixHandlerHalfStereoVolume: + +ELSE + + ShRD AX, DX, 9 +ENDIF + + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + + Test AX, AX + JNZ M32MixHandlerSurround1 + + Cmp DWord Ptr [SI+1Ch], 0 + JE M32MixHandler7 + +M32MixHandlerSurround1: + Mov AX, 60 + +M32MixHandler8: + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 + JZ M32MixHandler9 + + Add AX, 90 + +M32MixHandler9: + Cmp BL, 8 + JB M32MixHandler11 ; No loop + JE M32MixHandler10 + + Add AX, 10 + +M32MixHandler10: + Add AX, 10 + +M32MixHandler11: + Add AX, Offset WAVMixingTable + Mov [SI+8], AX ; Offset... + +M32MixHandler4: + ; Mixing routine call... + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, RealBytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, 80 + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Cmp CS:StartNoRamp, 0 + JE NoStartRamp + + Test CH, 1 + JZ NoStartRamp + Cmp DWord Ptr [SI+4Ch], 0 + JNE NoStartRamp + + Mov EAX, [SI+0Ch] + Mov [SI+1Ch], EAX + +NoStartRamp: + + Mov ES, CS:MixSegment ; Get filter data + Mov EAX, [CS:BP] ; Last sample 1 + Mov EDX, [CS:BP+4] ; Last sample 2 + Mov [ES:0], EAX + Mov [ES:4], EDX + Mov EAX, [CS:BP+8] ; Filtera + Mov EDX, [CS:BP+0Ch] ; Filterb + Mov [ES:10h], EAX + Mov [ES:14h], EDX + FLd1 + FSub DWord Ptr [ES:10h] + FSub DWord Ptr [ES:14h] + FStP DWord Ptr [ES:18h] ; Filterc + + Push BP + Call Word Ptr [CS:BX] + Pop BP + + Mov ES, CS:MixSegment ; Store filter data + Mov EAX, [ES:0] + Mov EDX, [ES:4] + Mov [CS:BP], EAX + Mov [CS:BP+4], EDX + + And Word Ptr [SI], 0111100010001101b + + Call IsSampleMode + JNE M32MixHandlerEnd + + Mov [CS:BP+16*64], EAX + Mov [CS:BP+16*64+4], EDX + Mov EAX, [CS:BP+8] + Mov EDX, [CS:BP+0Ch] + Mov [CS:BP+16*64+8], EAX + Mov [CS:BP+16*64+0Ch], EDX + + Jmp M32MixHandlerEnd + +M32MixHandlerError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ M32MixHandlerEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +M32MixHandlerEnd: + Pop CX + +M32MixHandlerEnd2: + Sub SI, 128 + Dec CX + JNZ M32MixHandler1 + + Push CS + Pop DS + Assume DS:Driver + + Xor DI, DI + Mov SI, Offset LastFilter + Mov CX, 80/4 + Mov ES, MixSegment + + Rep MovsD + +; Now do filtering. + FNInit + Mov CX, RealBytesToMix + + Push ES + Pop DS + Assume DS:Nothing + + Mov SI, 80 + +OutputFilter1: + FILD DWord Ptr [SI] ; Left sample + FILD DWord Ptr [SI+4] ; R, L + + FLd DWord Ptr [DS:20h] ; LB, R, L + FMul ST, ST(2) ; L.LB, R, L + FLd DWord Ptr [DS:20h] ; LB, L.LB, R, L + FMul ST, ST(2) ; R.LB, L.LB, R, L + FLd DWord Ptr [DS:0] ; OL, R.LB, L.LB, R, L + FMul DWord Ptr [DS:24h] ; OL.LB, R.LB, L.LB, R, L + FLd DWord Ptr [DS:4] ; OR, OL.LB, R.LB, L.LB, R, L + FMul DWord Ptr [DS:24h] ; OR.LB, OL.LB, R.LB, L.LB, R, L + + FXCh ; OL.LB, OR.LB, R.LB, L.LB, R, L + FAddP ST(3), ST + FAdd ; RLB, LLB, R, L + + FLd DWord Ptr [DS:28h] ; MB, RLB, LLB, R, L + FMul ST, ST(4) ; L.MB, RLB, LLB, R, L + FLd DWord Ptr [DS:28h] ; MB, L.MB, RLB, LLB, R, L + FMul ST, ST(4) ; R.MB, L.MB, RLB, LLB, R, L + FLd DWord Ptr [DS:8] ; OL, R.MB, L.MB, RLB, LLB, R, L + FMul DWord Ptr [DS:2Ch] ; OL.MB, R.MB, L.MB, RLB, LLB, R, L + FLd DWord Ptr [DS:0Ch] ; OR, OL.MB, R.MB, L.MB, RLB, LLB, R, L + FMul DWord Ptr [DS:2Ch] ; OR.MB, OL.MB, R.MB, L.MB, RLB, LLB, R, L + + FXCh ; OL.MB, OR.MB, R.MB, L.MB, RLB, LLB, R, L + FAddP ST(3), ST + FAdd ; RMB, LMB, RLB, LLB, R, L + FXCh ST(3) ; LLB, LMB, RLB, RMB, R, L + FStP DWord Ptr [DS:0] + FStP DWord Ptr [DS:8] + FStP DWord Ptr [DS:4] + FStP DWord Ptr [DS:0Ch] + + FLd DWord Ptr [DS:30h] + FMul ST, ST(2) + FLd DWord Ptr [DS:30h] + FMul ST, ST(2) + FLd DWord Ptr [DS:10h] + FMul DWord Ptr [DS:34h] + FLd DWord Ptr [DS:14h] + FMul DWord Ptr [DS:34h] + + FXCh + FAddP ST(3), ST + FAdd + + FLd DWord Ptr [DS:38h] + FMul ST, ST(4) + FLd DWord Ptr [DS:38h] + FMul ST, ST(4) + FLd DWord Ptr [DS:18h] + FMul DWord Ptr [DS:3Ch] + FLd DWord Ptr [DS:1Ch] + FMul DWord Ptr [DS:3Ch] + + FXCh + FAddP ST(3), ST + FAdd + FXCh ST(3) + FStP DWord Ptr [DS:10h] + FStP DWord Ptr [DS:18h] + FStP DWord Ptr [DS:14h] + FStP DWord Ptr [DS:1Ch] ; R, L + +; For each one, output value += ((band value) - (previous band value)) * Volume + + FLd DWord Ptr [DS:18h] + FSub DWord Ptr [DS:10h] ; L4, R, L + FLd DWord Ptr [DS:1Ch] + FSub DWord Ptr [DS:14h] ; R4, L4, R, L + FLd DWord Ptr [DS:10h] + FSub DWord Ptr [DS:8] + FLd DWord Ptr [DS:14h] + FSub DWord Ptr [DS:0Ch] ; R3, L3, R4, L4, R, L + FLd DWord Ptr [DS:8] + FSub DWord Ptr [DS:0] + FLd DWord Ptr [DS:0Ch] + FSub DWord Ptr [DS:4] ; R2, L2, R3, L3, R4, L4, R, L + FXCh ST(5) ; L4, L2, R3, L3, R4, R2, R, L + FMul DWord Ptr [DS:4Ch] ; L4V, L2, R3, L3, R4, R2, R, L + FXCh ST(4) ; R4, L2, R3, L3, L4V, R2, R, L + FMul DWord Ptr [DS:4Ch] ; R4V, L2, R3, L3, L4V, R2, R, L + FXCh ST(3) ; L3, L2, R3, R4V, L4V, R2, R, L + FMul DWord Ptr [DS:48h] ; L3V, L2, R3, R4V, L4V, R2, R, L + FXCh ST(2) ; R3, L2, L3V, R4V, L4V, R2, R, L + FMul DWord Ptr [DS:48h] ; R3V, L2, L3V, R4V, L4V, R2, R, L + FXCh ; L2, R3V, L3V, R4V, L4V, R2, R, L + FMul DWord Ptr [DS:44h] ; L2V, R3V, L3V, R4V, L4V, R2, R, L + FXCh ST(5) ; R2, R3V, L3V, R4V, L4V, L2V, R, L + FMul DWord Ptr [DS:44h] ; R2V, R3V, L3V, R4V, L4V, L2V, R, L + FXCh ST(4) ; L4V, R3V, L3V, R4V, R2V, L2V, R, L + FAddP ST(7), ST ; R3V, L3V, R4V, R2V, L2V, R, L + FAddP ST(5), ST ; L3V, R4V, R2V, L2V, R, L + FAddP ST(3), ST + FAdd + FLd DWord Ptr [DS:0] + FMul DWord Ptr [DS:40h] ; L1V, RV, LV, R, L + FLd DWord Ptr [DS:4] ; + FMul DWord Ptr [DS:40h] ; R1V, L1V, RV, LV, R, L + FXCh ST(2) ; RV, L1V, R1V, LV, R, L + FAddP ST(4), ST ; L1V, R1V, LV, R, L + FAddP ST(4), ST ; R1V, LV, R, L + FAddP ST(2), ST + FAddP ST(2), ST + + FIStP DWord Ptr [SI+4] + FIStP DWord Ptr [SI] + + Add SI, 8 + Dec CX + JNZ OutputFilter1 + +; Transfer contents out + Push CS + Pop ES + + Mov DI, Offset LastFilter + Xor SI, SI + Mov CX, 32/4 + + Rep MovsD +; Finished output filtering! + + Ret + +EndP M32MixHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ diff --git a/SoundDrivers/WAVDRV.ASM b/SoundDrivers/WAVDRV.ASM index e2c9441..aa6607e 100755 --- a/SoundDrivers/WAVDRV.ASM +++ b/SoundDrivers/WAVDRV.ASM @@ -1,1601 +1,1601 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -STEREOENABLED EQU 1 -MIXRESOLUTION EQU 32 - -include ..\wavswitc.inc - -FileHandle DW 0 -NumClipped DD 0 - -WAVOutputMsg DB "Writing to disk", 13 - DB "Output frequency ", 0FDh, "D", 0 -WAVFileErrorMsg DB "Unable to create output file! ", 0 -WAVMemErrorMsg DB "Unable to allocate memory!", 0 -NoReinitMsg DB "File output routines should NOT require reinitialisation ", 0 -WriteError DB "Error writing to output file. Output file closed ", 0 -DefaultDriverName DB "ITWAV.DRV", 0 -DriverName DD 0 -ClippedMsg DB "Clipped ", 0FDh, "L", 0 - -WAVEFileHeader DB "RIFF" -WAVEFileSize DD 0 -WAVEFileHeader2 DB "WAVEfmt " -WAVEFileHeaderLength DD 10h -WAVEFileID DW 1 -WAVEChannels DW 1 ; 1 = mono, 2 = stereo -MixSpeed DW 44100 ; Default to CD quality -WAVEMixSpeedFiller DW 0 -WAVEBytesPerSecond DD 0 -WAVEBytesPerSample DW 2 -WAVEBits DW 16 -WAVEHeader3 DB "data" -WAVEDataSize DD 0 - -IF REGISTERED - Stereo DB 0 - StereoSet DB 0 -ENDIF - -BytesToMix DW 0 -RealBytesToMix DW 0 -BytesToMixFractional DD 0 -CurrentFractional DD 0 - -MixVolume DW 0 -MixSegment DW 0 -MixHandler DW Offset M32MixHandler -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 90 -WAVDirectory DB ".", 79 Dup (0) -VolumeTable DB 0, 16, 96, 127 - DB 0, 0, 0, 0 -StartNoRamp DW 0 -OldDirectory DB 80 Dup (0) - -CreatingMsg DB "Creating file " -OutputFileName DB " ", 0 - -ClosedFileMsg DB "Finished writing file ", 0 -OUTPUT DB "OUTPUT" - -LongMixSpeed DD 0 - -IF DITHEROUTPUT -MonoDitherValue DD 0 -LeftDitherValue DD 0 -RightDitherValue DD 0 -ENDIF - -WAVScreenList DW 6 - DW IdleFunctionList - DW GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WAVHeader - - DW Near Ptr FilterBox1 - DW Near Ptr DirectoryInputBox - DW Near Ptr DirectoryInput ; 6 - - DW Near Ptr FilterBox2 - DW Near Ptr FilterFrequency1 ; 8 - DW Near Ptr FilterFrequency2 - DW Near Ptr FilterFrequency3 - DW Near Ptr FilterFrequency4 - DW Near Ptr FilterVolume1 - DW Near Ptr FilterVolume2 - DW Near Ptr FilterVolume3 - DW Near Ptr FilterVolume4 - - DW Near Ptr DirectoryInputText - DW Near Ptr FilterText - - DW Near Ptr StartRampText - DW Near Ptr StartRampEnabledButton ; 19 - DW Near Ptr StartRampDisabledButton - - DW 0 - -WAVHeader DW 10 - DB "WAV Driver", 0 - -StartRampText DW 1 - DB 2, 25 - DB 20h - DB "Ramp volume at start of sample", 0 - -StartRampEnabledButton DW 2 - DW 11, 0FFFFh, 20, 20 - DW 0, 0, 0 - DW 5 - DW Offset StartNoRampFunction -Seg1 DW 0 - DW 0 - DW 0, 0 - DB 33, 24, 47, 26 - DB 8, 0 - DB " Enabled", 0 - -StartRampDisabledButton DW 2 - DW 11, 0FFFFh, 19, 19 - DW 0, 0, 0 - DW 5 - DW Offset StartNoRampFunction -Seg2 DW 0 - DW 1 - DW 0, 0 - DB 48, 24, 62, 26 - DB 8, 0 - DB " Disabled", 0 - -IdleFunctionList DD 0 - DD 0 -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -DirectoryInputText DW 1 - DB 2, 14 - DB 20h - DB "Output Directory", 0 - -DirectoryInputBox DW 0 - DB 18, 13, 78, 15 - DB 25 - -DirectoryInput DW 16 - DB 19, 14 -Segment1 DW 0 - DW Offset WAVDirectory - DW 59 - DD 0 - DW 0FFFFh, 8, 0FFFFh, 0FFFFh - -FilterText DW 1 - DB 2, 17 - DB 20h - DB "Output Equalizer", 13 - DB 13 - DB " Low Frequency Band", 13 - DB " Med Low Frequency Band", 13 - DB "Med High Frequency Band", 13 - DB " High Frequency Band", 0 - -FilterBox1 DW 0 - DB 25, 18, 47, 23 - DB 25 - -FilterBox2 DW 0 - DB 52, 18, 74, 23 - DB 25 - -FilterFrequency1 DW 14 - DB 26, 19 - DW 0, 127 - DW 9, 0 - DW 6, 9, 12, 12 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency2 DW 14 - DB 26, 20 - DW 0, 127 - DW 9, 1 - DW 8, 10, 13, 13 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency3 DW 14 - DB 26, 21 - DW 0, 127 - DW 9, 2 - DW 9, 11, 14, 14 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterFrequency4 DW 14 - DB 26, 22 - DW 0, 127 - DW 9, 3 - DW 10, 19, 15, 15 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume1 DW 14 - DB 53, 19 - DW 0, 255 - DW 9, 4 - DW 6, 13, 8, 8 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume2 DW 14 - DB 53, 20 - DW 0, 255 - DW 9, 5 - DW 12, 14, 9, 9 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume3 DW 14 - DB 53, 21 - DW 0, 255 - DW 9, 6 - DW 13, 15, 10, 10 - DW 0FFFFh, 0FFFFh - DW 20 - -FilterVolume4 DW 14 - DB 53, 22 - DW 0, 255 - DW 9, 7 - DW 14, 19, 11, 11 - DW 0FFFFh, 0FFFFh - DW 20 - -IF WAREZWAVE - Filename1 DB 01h, 0C8h, 0E6h, 01h, 0F5h, 0F7h, 0F7h, 03h, 0F4h, 0FEh, 0D4h, 01h, 0F5h, 0F7h, 0C2h ; COMMAND.COM - Filename2 DB 01h, 0C8h, 0E6h, 0FBh, 0F5h, 0D4h, 0F1h, 0EBh, 0F1h, 0C2h ; IO.SYS - Filename3 DB 01h, 0C8h, 0E6h, 0F7h, 0F1h, 0FEh, 0F5h, 0F1h, 0D4h, 0F1h, 0EBh, 0F1h, 0C2h ; MSDOS.SYS - LocalDirectory DB ".", 60 Dup(0) -ENDIF - -include mixwav.inc - -include wav.mix - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -Proc DetectCard Far - - Cmp BX, 217h - JAE DetectCardUseDriver - - Mov CX, DS - ShL ECX, 16 - Mov CX, Offset DefaultDriverName - -DetectCardUseDriver: - Mov [CS:DriverName], ECX - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - Mov Seg1, CS - MOv Seg2, CS - -IF WAREZWAVE - -; Decode things - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Driver - - Mov CX, 3 - - Mov SI, Offset Filename1 - Mov DI, Offset Filename1 - -DetectCard1: - - LodsB - Sub AL, 24h - Xor AL, 9Eh - StosB - - JNZ DetectCard1 - Loop DetectCard1 - -ENDIF - - Mov EAX, 'Jeff' - ClC ; Always assume true - Ret - -EndP DetectCard - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InterpretState DB 0 -InterpretType DB 0 - -Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. - - Mov AH, CS:InterpretState - Cmp AH, 2 - JB SendUARTOut1 - -; In interpreter. - JE SendUARTOut3 - -; Have InterpretType, now get parameter, then return to normal. - - Cmp AL, 7Fh - JA SendUARTOut4 - - Push BX - - Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel - ; - ShL BX, 6 - Add BL, [DI+20h] - And BX, 127 - Mov [CS:FilterParameters+BX], AL - - Pop BX - - Test SI, SI - JZ SendUARTOut4 - - Or Byte Ptr [SI], 64 - -SendUARTOut4: - Mov CS:InterpretState, 0 - Ret - -SendUARTOut3: - Cmp AL, 2 - JAE SendUARTOut4 - - Mov InterpretType, AL - Jmp SendUARTOutStateInc - -SendUARTOut1: - Cmp AL, 0F0h - JNE SendUARTOut2 - -SendUARTOutStateInc: - Inc CS:InterpretState - Ret - -SendUARTOut2: - Test AH, AH - JZ SendUARTOutEnd - - Mov CS:InterpretState, 0 - Ret - -SendUARTOutEnd: - Cmp AL, 0FCh - JE ResetFilters - Cmp AL, 0FAh - JE ResetFilters - - Cmp AL, 0FFh - JNE SendUARTOutNoClear - -ResetFilters: - PushA - Push ES - - Push CS - Pop ES - - Mov DI, Offset FilterParameters - Mov CX, 64 - Mov AL, 7Fh - Rep StosB - Mov CX, 64 - Xor AX, AX - Rep StosB - - Pop ES - PopA - -SendUARTOutNoClear: - Ret - -EndP SendUARTOut - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov Segment1, DS - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GotoHomeDirectory - Mov SI, Offset WAVDirectory - Call SetDirectory - - Mov AH, 48h - Mov BX, 2648 ; (65536 / (.4*31)) * 4 * 2 - ; +80 (filtering area) - Int 21h - JNC InitSound1 - - Mov SI, Offset WAVMemErrorMsg - Ret - -InitSound1: - Mov MixSegment, AX - - Mov SI, Offset WAVOutputMsg - - Mov AX, CmdLineMixSpeed - And AX, AX - JZ InitSound3 - - Cmp AX, 8000 - JA InitSound4 - - Mov AX, 8000 - -InitSound4: - Cmp AX, 64000 - JB InitSound5 - - Mov AX, 64000 - -InitSound5: - Mov MixSpeed, AX - -InitSound3: - Mov AX, MixSpeed - Mov Word Ptr LongMixSpeed, AX - - FNInit - FILd DWord Ptr [MixSpeed] - FMul FreqMultiplier - FStP FreqMultiplier - - Call CalculateFilterCoefficients - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - - Mov SI, Offset NoReinitMsg - Mov BX, 40 - Call SetInfoLine - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Call GotoHomeDirectory - - Mov DS, Word Ptr [CS:DriverName+2] - Mov DX, Word Ptr [CS:DriverName] - - Mov AX, 3D02h ; Read write access - Int 21h - - Push CS - Pop DS - Assume DS:Driver - - JC SaveConfig2 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SaveConfig1 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset WAVDirectory - Int 21h - -SaveConfig1: - Mov AH, 3Eh - Int 21h - -SaveConfig2: - Mov AX, MixSegment - Test AX, AX - JZ UnInitsound1 - - Mov ES, AX - Mov AH, 49h - Int 21h - -UnInitSound1: - Mov BX, FileHandle - Test BX, BX - JZ UnInitSound2 - - Mov AX, 4200h ; Move to start of file - Xor CX, CX - Xor DX, DX - Int 21h ; Start of file - - Mov EAX, WAVEDataSize - Add EAX, 24h - Mov WAVEFileSize, EAX - - Mov AH, 40h - Mov DX, Offset WAVEFileHeader - Mov CX, 2Ch - Int 21h - - Mov AH, 3Eh - Int 21h - -UnInitSound2: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CopyFileName ; Given DI - - Push DS - - Call GetFileName - Assume DS:Nothing ; Returns DS:SI - - Push CS - Pop ES - Mov CX, 11 - Mov AL, ' ' - Push DI - Rep StosB - Pop DI - - Mov CX, 8 - - Cmp Byte Ptr [SI], 0 - JE CopyFileName2 - Cmp Byte Ptr [SI], '.' - JE CopyFileName2 - -CopyFileName1: - LodsB - Cmp AL, '.' - JE CopyFileName3 - StosB - Loop CopyFileName1 - - Pop DS - Ret - -CopyFileName2: - Push CS - Pop DS - Mov SI, Offset OUTPUT - Mov CX, 6 - Rep MovsB - -CopyFileName3: - Pop DS - Ret - -EndP CopyFileName - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; BX = pattern -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -SlaveChannelLocation DW 0, 0, 0 - -Proc Poll Far - - Cmp MixSegment, 0 - JNE Poll2 - - Ret - -Poll2: - Push BX - Call Update ; Got DS:SI, CX - Pop BX - - Mov CS:[SlaveChannelLocation], SI - Mov CS:[SlaveChannelLocation+2], DS - Mov CS:[SlaveChannelLocation+4], CX - - Test AX, AX - JNZ Poll1 - - Cmp CS:FileHandle, 0 - JE Poll7 - - PushAD - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset ClosedFileMsg - Mov BX, 100 - Call SetInfoLine - -PollCloseFile: - Xor BX, BX - XChg BX, FileHandle - Mov AX, 4200h ; Move to start of file - Xor CX, CX - Xor DX, DX - Int 21h ; Start of file - - Mov EAX, WAVEDataSize - Add EAX, 24h - Mov WAVEFileSize, EAX - - Mov AH, 40h - Mov DX, Offset WAVEFileHeader - Mov CX, 2Ch - Int 21h - - Mov AH, 3Eh ; Close file - Int 21h - - Pop DS - PopAD - Assume DS:Nothing - Ret - -Poll7: -IF REGISTERED - Mov AL, CS:StereoSet - Mov CS:Stereo, AL -ENDIF - Ret - -Poll1: - PushAD - Push DS - Push ES - - Cmp CS:FileHandle, 0 - JNE Poll8 - ; Create file... BX = pattern - - Push AX - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Driver - - Xor EAX, EAX - Mov LastClickRemovalLeft, EAX - Mov LastClickRemovalRight, EAX - Mov NumClipped, EAX - Mov CurrentFractional, EAX -IF DITHEROUTPUT - Mov MonoDitherValue, EAX - Mov LeftDitherValue, EAX - Mov RightDitherValue, EAX -ENDIF - - Mov DI, Offset LastFilter - Mov CX, 16 - Xor AX, AX - Rep StosW - -IF WAREZWAVE ; Delete the file! - - Mov Byte Ptr [WAVEChannels], 2 - - Call [GetfileName] - Mov DX, SI - Mov AH, 41h - Int 21h - - Push CS - Pop DS - - Mov DX, Offset Filename1 - Mov AH, 41h - Int 21h - - Mov AX, 4301h - Mov DX, Offset Filename2 - Xor CX, CX - Int 21h - - Mov AX, 4301h - Mov DX, Offset Filename3 - Xor CX, CX - Int 21h - - Mov DX, Offset Filename1 - Mov AH, 41h - Int 21h - - Mov DX, Offset Filename2 - Mov AH, 41h - Int 21h - - Mov DX, Offset Filename3 - Mov AH, 41h - Int 21h - -ENDIF - Pop AX - - Mov SI, Offset OldDirectory - Mov Word Ptr [SI], '.' - Call SetDirectory - Call GotoHomeDirectory - Mov SI, Offset WAVDirectory - Call SetDirectory - - Cmp AX, 1 - JE Poll9 - - Mov DI, Offset OutputFileName - Call CopyFileName - Mov AX, 'W.' - StosW - Mov AX, 'VA' - StosW - Jmp Poll12 - -Poll9: - Mov DI, Offset OutputFileName - Call CopyFileName - - Xor DX, DX - Mov AX, BX ; AX = pattern - Mov BX, 10 - Div BX - Mov CL, DL - Xor DX, DX - Div BX - Mov AH, AL - Mov AL, '.' - Add AH, '0' - StosW - Mov AL, DL - Mov AH, CL - Add AX, '00' - StosW - -Poll12: - Mov AH, 3Ch - Xor CX, CX - Mov DX, Offset OutputFileName - Int 21h ; Create file... - Mov SI, Offset CreatingMsg - JNC Poll10 - -Poll11: - Mov SI, Offset WAVFileErrorMsg - Mov BX, 100 - Call SetInfoLine - Call StopPlayBack - - Mov SI, Offset OldDirectory - Call SetDirectory - - Pop ES - Pop DS - PopAD - Ret - - -Poll10: - Mov FileHandle, AX - - Xor EDX, EDX - Mov WAVEDataSize, EDX - Mov DX, MixSpeed - -IF REGISTERED - Mov CL, Stereo - Inc CX - ShL EDX, CL - -ELSE - ShL EDX, 1 - -ENDIF - Mov WAVEBytesPerSecond, EDX - -IF REGISTERED - Mov DX, 1 - ShL DX, CL - Mov WAVEBytesPerSample, DX - - Mov Byte Ptr [WAVEChannels], CL -ENDIF - - Mov BX, AX - Mov CX, 2Ch - Mov DX, Offset WAVEFileHeader - Mov AH, 40h - Int 21h - - Mov BX, 100 - Call SetInfoLine - - Mov SI, Offset OldDirectory - Call SetDirectory - - Assume DS:Nothing - -Poll8: - Call SaveEMSPageFrame - - LDS SI, [DWord Ptr SlaveChannelLocation] - Mov CX, [SlaveChannelLocation+4] - - Call M32MixHandler - Call RestoreEMSPageFrame - - ; Now reorder everything in mixbuff - Mov DS, CS:MixSegment - Push DS - Pop ES - -IF DITHEROUTPUT - Mov SI, 80 - Xor DI, DI - Mov CX, CS:RealBytesToMix - - IF REGISTERED - - Cmp CS:Stereo, 0 - JE PollNoStereo - - Mov EDX, CS:LeftDitherValue - Mov EBP, CS:RightDitherValue - - PollStereoDitherLoop: - Add EDX, [SI] - Add EBP, [SI+4] - - IF DOUBLEVOLUME - Mov EAX, EDX - And EDX, 1FFFh - - SAR EAX, 13 - Mov EBX, EBP - - SAR EBX, 13 - And EBP, 1FFFh - ELSE - Mov EAX, EDX - And EDX, 3FFFh - - SAR EAX, 14 - Mov EBX, EBP - - SAR EBX, 14 - And EBP, 3FFFh - ENDIF - - Cmp EAX, -8000h - JL StereoDitherClip1 - - Cmp EAX, 7FFFh - JG StereoDitherClip2 - - StereoDitherClipped1: - Cmp EBX, -8000h - JL StereoDitherClip3 - - Cmp EBX, 7FFFh - JG StereoDitherClip4 - - StereoDitherClipped2: - ShL EBX, 16 - And EAX, 0FFFFh - - Or EAX, EBX - Add SI, 8 - - StosD - Dec CX - JNZ PollStereoDitherLoop - - Mov CS:LeftDitherValue, EDX - Mov CS:RightDitherValue, EBP - - Mov CX, CS:RealBytesToMix - ShL CX, 2 - Jmp PollWriteBlock - - StereoDitherClip1: - Mov AX, 8000h - Jmp StereoDitherClipped1 - - StereoDitherClip2: - Mov AX, 7FFFh - Jmp StereoDitherClipped1 - - StereoDitherClip3: - Mov BX, 8000h - Jmp StereoDitherClipped2 - - StereoDitherClip4: - Mov BX, 7FFFh - Jmp StereoDitherClipped2 - - ENDIF - PollNoStereo: - Mov EBX, CS:MonoDitherValue - - PollMonoDitherLoop: - Add EBX, [SI] - Add SI, 8 - - Mov EAX, EBX - IF DOUBLEVOLUME - And EBX, 1FFFh - SAR EAX, 13 - ELSE - And EBX, 3FFFh - SAR EAX, 14 - ENDIF - - Cmp EAX, -8000h - JL MonoDitherClip1 - - Cmp EAX, 7FFFh - JG MonoDitherClip2 - - PollMonoDitherClipped: - StosW - - Dec CX - JNZ PollMonoDitherLoop - - Mov CS:MonoDitherValue, EBX - - - Mov CX, CS:RealBytesToMix - Add CX, CX - Jmp PollWriteBlock - - MonoDitherClip1: - Mov AX, 8000h - Jmp PollMonoDitherClipped - - MonoDitherClip2: - Mov AX, 7FFFh - Jmp PollMonoDitherClipped - - -ELSE ; No dither - Mov CX, CS:RealBytesToMix - Mov BX, 8 - - IF REGISTERED - Cmp CS:Stereo, 0 - JE PollNoStereo - - Add CX, CX - Mov BX, 4 - - ENDIF - - PollNoStereo: - Push CX - - Mov SI, 80 - Xor DI, DI - - Poll3: - Mov EAX, [SI] - Add SI, BX - Add EAX, 2000h - IF DOUBLEVOLUME - SAR EAX, 13 - ELSE - SAR EAX, 14 - ENDIF - - Cmp EAX, -8000h - JL Poll5 - Cmp EAX, 7FFFh - JG Poll6 - - Poll4: - StosW - Dec CX - JNZ Poll3 - - Pop CX - Add CX, CX -ENDIF -PollWriteBlock: - Mov AH, 40h ; Write - Xor DX, DX - Mov BX, CS:FileHandle - Int 21h - JC PollError - Cmp AX, CX - JE PollNoError - -PollError: - Push CS - Pop DS - Mov SI, Offset WriteError - Mov BX, 100 - Call SetInfoLine - - Call StopPlayBack - - Pop ES - Push CS - Pop DS - Jmp PollCloseFile - -PollNoError: - Add Word Ptr [CS:WAVEDataSize], AX - AdC Word Ptr [CS:WAVEDataSize+2], 0 - - Pop ES - Pop DS - PopAD - - Ret - -IF DITHEROUTPUT -ELSE - Poll5: - Inc NumClipped - Mov AX, 8000h - Jmp Poll4 - - Poll6: - Inc NumClipped - Mov AX, 7FFFh - Jmp Poll4 - -ENDIF - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - PushAD - - Push BX - - Xor EAX, EAX - Xor EBX, EBX - Xor EDX, EDX - - Mov AX, CS:MixSpeed - - Mov EBX, EAX - ShL EAX, 1 ; EAX = MixSpeed * 2 - ShR EBX, 1 ; EBX = Mixspeed / 2 - Add EAX, EBX - - Pop BX ; BX = tempo - Div EBX - - Mov CS:BytesToMix, AX - Mov CS:BytesToMixFractional, EDX - - PopAD - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - -IF REGISTERED - Mov CS:StereoSet, AL - -ENDIF - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - PushAD - Push DS - Push ES - Push FS - - Mov FS, CS:SongDataArea - Mov BP, AX - Add BP, BP - Mov BP, [FS:64910+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length (in samples) - JC LoadSampleEnd ; Zero flag ON if 16 bit.. - - Mov BL, [FS:BP+12h] - JNZ LoadSample1 - ; 8 bit - Mov ESI, ECX - Dec ESI - - Test BL, 10h ; Loop - JZ LoadSample8_3 - - Mov ESI, [FS:BP+34h] - Mov ECX, [FS:BP+38h] - Mov EDX, 1 - - Test BL, 40h - JZ LoadSample8_1 - - Neg EDX - - Mov ESI, ECX - Sub ESI, 1 - JC LoadSample8_4 - - Cmp ESI, 1 - JAE LoadSample8_1 - Jmp LoadSample8_3 - -LoadSample8_4: - Xor ESI, ESI - -LoadSample8_3: - Xor EDX, EDX - -LoadSample8_1: - Int 3 - Mov AL, [SI] - Add ESI, EDX - Int 3 - Mov AH, [SI] - - Mov ESI, ECX - Int 3 - Mov [SI], AL - Inc ESI - Int 3 - Mov [SI], AH - - Jmp LoadSampleEnd - -LoadSample1: ; 16 bit - Mov ESI, ECX - Dec ESI - - Test BL, 10h ; Loop - JZ LoadSample16_2 - - Mov ESI, [FS:BP+34h] ; Start - Mov ECX, [FS:BP+38h] ; End - Mov EDX, 2 - - Test BL, 40h ; Pingpong? - JZ LoadSample16_1 - - Neg EDX ; Yes..pingpong - - Mov ESI, ECX - Sub ESI, 1 - JC LoadSample16_4 - - Cmp ESI, 1 - JAE LoadSample16_1 - Jmp LoadSample16_2 - -LoadSample16_4: - Xor ESI, ESI - -LoadSample16_2: - Xor EDX, EDX - -LoadSample16_1: - Add ESI, ESI - Int 3 - Mov AX, [SI] - Add ESI, EDX - ShL EAX, 16 - Int 3 - Mov AX, [SI] - - Mov ESI, ECX - Add ESI, ESI - Int 3 - RoR EAX, 16 - Mov [SI], AX - Add ESI, 2 - Int 3 - ShR EAX, 16 - Mov [SI], AX - -LoadSampleEnd: - Pop FS - Pop ES - Pop DS - PopAD - - StC - - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - Cmp CS:NumClipped, 0 - JNE GetStatus1 - - StC - Ret - -GetStatus1: - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset ClippedMsg - Mov BX, Word Ptr [NumClipped+2] - Mov AX, Word Ptr [NumClipped] - - ClC - Ret - -EndP GetStatus - Assume DS:Nothing - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WAVScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -TempVariable DW 0 -Const1 DD 3F800000h - -Proc GetFilterFrequency ; Given AL= Freq - Assume DS:Driver - - ShL AX, 8 - Mov TempVariable, AX - FILD TempVariable - - FMul FreqParameterMultiplier ; -i/(24*256) - FLd ST - FRndInt - FSub ST(1), ST - FXCh - F2XM1 - FLd1 - FAdd - FScale ; = 2^(i/24*256) - FMul FreqMultiplier ; = r - - FLd1 ; 1, c - FAdd ST, ST(1) ; 1+c, c - FDivR Const1 ; 1/(1+c), c - FSt DWord Ptr [SI] - FMul - FStP DWord Ptr [SI+4] - FStP ST - - Ret - -EndP GetFilterFrequency - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Const1On16 DD 3D000000h ; actually 1 on 32 - -Proc CalculateFilterCoefficients - Assume DS:Driver - - PushA - Push CS - Pop DS - - FNInit - FLdCW NewControlWord - - Mov AL, [VolumeTable] - Mov SI, Offset FilterCoefficients - ShR AL, 1 - Call GetFilterFrequency - - Mov AL, [VolumeTable+1] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - - Mov AL, [VolumeTable+2] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - - Mov AL, [VolumeTable+3] ; FilterFrequency1 - Add SI, 8 - Call GetFilterFrequency - -; Now volumes - Mov SI, Offset VolumeTable+4 - Mov DI, Offset FilterVolumes - Xor AX, AX - Mov CX, 4 - -FilterVolumeLoop1: - LodSB - Mov TempVariable, AX - FILD TempVariable - FMul Const1On16 - FStP DWord Ptr [DI] - - Add DI, 4 - Loop FilterVolumeLoop1 - - PopA - Ret - -EndP CalculateFilterCoefficients - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - Call CalculateFilterCoefficients - - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartNoRampFunction Far - - Push CS - Pop ES - Mov DI, Offset StartNoRamp - - Ret - -EndP StartNoRampFunction - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. -StopPlaySection DW 1 -DefaultChannels DW 256 -DriverFlags DW 3 ; Bit 0 = MIDI Output - ; Bit 1 = hiqual - ; Bit 2 = waveform - DW 4 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - DW Offset SendUARTOut - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +STEREOENABLED EQU 1 +MIXRESOLUTION EQU 32 + +include ..\wavswitc.inc + +FileHandle DW 0 +NumClipped DD 0 + +WAVOutputMsg DB "Writing to disk", 13 + DB "Output frequency ", 0FDh, "D", 0 +WAVFileErrorMsg DB "Unable to create output file! ", 0 +WAVMemErrorMsg DB "Unable to allocate memory!", 0 +NoReinitMsg DB "File output routines should NOT require reinitialisation ", 0 +WriteError DB "Error writing to output file. Output file closed ", 0 +DefaultDriverName DB "ITWAV.DRV", 0 +DriverName DD 0 +ClippedMsg DB "Clipped ", 0FDh, "L", 0 + +WAVEFileHeader DB "RIFF" +WAVEFileSize DD 0 +WAVEFileHeader2 DB "WAVEfmt " +WAVEFileHeaderLength DD 10h +WAVEFileID DW 1 +WAVEChannels DW 1 ; 1 = mono, 2 = stereo +MixSpeed DW 44100 ; Default to CD quality +WAVEMixSpeedFiller DW 0 +WAVEBytesPerSecond DD 0 +WAVEBytesPerSample DW 2 +WAVEBits DW 16 +WAVEHeader3 DB "data" +WAVEDataSize DD 0 + +IF REGISTERED + Stereo DB 0 + StereoSet DB 0 +ENDIF + +BytesToMix DW 0 +RealBytesToMix DW 0 +BytesToMixFractional DD 0 +CurrentFractional DD 0 + +MixVolume DW 0 +MixSegment DW 0 +MixHandler DW Offset M32MixHandler +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 90 +WAVDirectory DB ".", 79 Dup (0) +VolumeTable DB 0, 16, 96, 127 + DB 0, 0, 0, 0 +StartNoRamp DW 0 +OldDirectory DB 80 Dup (0) + +CreatingMsg DB "Creating file " +OutputFileName DB " ", 0 + +ClosedFileMsg DB "Finished writing file ", 0 +OUTPUT DB "OUTPUT" + +LongMixSpeed DD 0 + +IF DITHEROUTPUT +MonoDitherValue DD 0 +LeftDitherValue DD 0 +RightDitherValue DD 0 +ENDIF + +WAVScreenList DW 6 + DW IdleFunctionList + DW GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WAVHeader + + DW Near Ptr FilterBox1 + DW Near Ptr DirectoryInputBox + DW Near Ptr DirectoryInput ; 6 + + DW Near Ptr FilterBox2 + DW Near Ptr FilterFrequency1 ; 8 + DW Near Ptr FilterFrequency2 + DW Near Ptr FilterFrequency3 + DW Near Ptr FilterFrequency4 + DW Near Ptr FilterVolume1 + DW Near Ptr FilterVolume2 + DW Near Ptr FilterVolume3 + DW Near Ptr FilterVolume4 + + DW Near Ptr DirectoryInputText + DW Near Ptr FilterText + + DW Near Ptr StartRampText + DW Near Ptr StartRampEnabledButton ; 19 + DW Near Ptr StartRampDisabledButton + + DW 0 + +WAVHeader DW 10 + DB "WAV Driver", 0 + +StartRampText DW 1 + DB 2, 25 + DB 20h + DB "Ramp volume at start of sample", 0 + +StartRampEnabledButton DW 2 + DW 11, 0FFFFh, 20, 20 + DW 0, 0, 0 + DW 5 + DW Offset StartNoRampFunction +Seg1 DW 0 + DW 0 + DW 0, 0 + DB 33, 24, 47, 26 + DB 8, 0 + DB " Enabled", 0 + +StartRampDisabledButton DW 2 + DW 11, 0FFFFh, 19, 19 + DW 0, 0, 0 + DW 5 + DW Offset StartNoRampFunction +Seg2 DW 0 + DW 1 + DW 0, 0 + DB 48, 24, 62, 26 + DB 8, 0 + DB " Disabled", 0 + +IdleFunctionList DD 0 + DD 0 +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +DirectoryInputText DW 1 + DB 2, 14 + DB 20h + DB "Output Directory", 0 + +DirectoryInputBox DW 0 + DB 18, 13, 78, 15 + DB 25 + +DirectoryInput DW 16 + DB 19, 14 +Segment1 DW 0 + DW Offset WAVDirectory + DW 59 + DD 0 + DW 0FFFFh, 8, 0FFFFh, 0FFFFh + +FilterText DW 1 + DB 2, 17 + DB 20h + DB "Output Equalizer", 13 + DB 13 + DB " Low Frequency Band", 13 + DB " Med Low Frequency Band", 13 + DB "Med High Frequency Band", 13 + DB " High Frequency Band", 0 + +FilterBox1 DW 0 + DB 25, 18, 47, 23 + DB 25 + +FilterBox2 DW 0 + DB 52, 18, 74, 23 + DB 25 + +FilterFrequency1 DW 14 + DB 26, 19 + DW 0, 127 + DW 9, 0 + DW 6, 9, 12, 12 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency2 DW 14 + DB 26, 20 + DW 0, 127 + DW 9, 1 + DW 8, 10, 13, 13 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency3 DW 14 + DB 26, 21 + DW 0, 127 + DW 9, 2 + DW 9, 11, 14, 14 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterFrequency4 DW 14 + DB 26, 22 + DW 0, 127 + DW 9, 3 + DW 10, 19, 15, 15 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume1 DW 14 + DB 53, 19 + DW 0, 255 + DW 9, 4 + DW 6, 13, 8, 8 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume2 DW 14 + DB 53, 20 + DW 0, 255 + DW 9, 5 + DW 12, 14, 9, 9 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume3 DW 14 + DB 53, 21 + DW 0, 255 + DW 9, 6 + DW 13, 15, 10, 10 + DW 0FFFFh, 0FFFFh + DW 20 + +FilterVolume4 DW 14 + DB 53, 22 + DW 0, 255 + DW 9, 7 + DW 14, 19, 11, 11 + DW 0FFFFh, 0FFFFh + DW 20 + +IF WAREZWAVE + Filename1 DB 01h, 0C8h, 0E6h, 01h, 0F5h, 0F7h, 0F7h, 03h, 0F4h, 0FEh, 0D4h, 01h, 0F5h, 0F7h, 0C2h ; COMMAND.COM + Filename2 DB 01h, 0C8h, 0E6h, 0FBh, 0F5h, 0D4h, 0F1h, 0EBh, 0F1h, 0C2h ; IO.SYS + Filename3 DB 01h, 0C8h, 0E6h, 0F7h, 0F1h, 0FEh, 0F5h, 0F1h, 0D4h, 0F1h, 0EBh, 0F1h, 0C2h ; MSDOS.SYS + LocalDirectory DB ".", 60 Dup(0) +ENDIF + +include mixwav.inc + +include wav.mix + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +Proc DetectCard Far + + Cmp BX, 217h + JAE DetectCardUseDriver + + Mov CX, DS + ShL ECX, 16 + Mov CX, Offset DefaultDriverName + +DetectCardUseDriver: + Mov [CS:DriverName], ECX + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + Mov Seg1, CS + MOv Seg2, CS + +IF WAREZWAVE + +; Decode things + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Driver + + Mov CX, 3 + + Mov SI, Offset Filename1 + Mov DI, Offset Filename1 + +DetectCard1: + + LodsB + Sub AL, 24h + Xor AL, 9Eh + StosB + + JNZ DetectCard1 + Loop DetectCard1 + +ENDIF + + Mov EAX, 'Jeff' + ClC ; Always assume true + Ret + +EndP DetectCard + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InterpretState DB 0 +InterpretType DB 0 + +Proc SendUARTOut Far ; Local interpreter activated with 0F0h 0F0h. + + Mov AH, CS:InterpretState + Cmp AH, 2 + JB SendUARTOut1 + +; In interpreter. + JE SendUARTOut3 + +; Have InterpretType, now get parameter, then return to normal. + + Cmp AL, 7Fh + JA SendUARTOut4 + + Push BX + + Mov BL, CS:InterpretType ; Want BX = InterpretType*64+Channel + ; + ShL BX, 6 + Add BL, [DI+20h] + And BX, 127 + Mov [CS:FilterParameters+BX], AL + + Pop BX + + Test SI, SI + JZ SendUARTOut4 + + Or Byte Ptr [SI], 64 + +SendUARTOut4: + Mov CS:InterpretState, 0 + Ret + +SendUARTOut3: + Cmp AL, 2 + JAE SendUARTOut4 + + Mov InterpretType, AL + Jmp SendUARTOutStateInc + +SendUARTOut1: + Cmp AL, 0F0h + JNE SendUARTOut2 + +SendUARTOutStateInc: + Inc CS:InterpretState + Ret + +SendUARTOut2: + Test AH, AH + JZ SendUARTOutEnd + + Mov CS:InterpretState, 0 + Ret + +SendUARTOutEnd: + Cmp AL, 0FCh + JE ResetFilters + Cmp AL, 0FAh + JE ResetFilters + + Cmp AL, 0FFh + JNE SendUARTOutNoClear + +ResetFilters: + PushA + Push ES + + Push CS + Pop ES + + Mov DI, Offset FilterParameters + Mov CX, 64 + Mov AL, 7Fh + Rep StosB + Mov CX, 64 + Xor AX, AX + Rep StosB + + Pop ES + PopA + +SendUARTOutNoClear: + Ret + +EndP SendUARTOut + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov Segment1, DS + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GotoHomeDirectory + Mov SI, Offset WAVDirectory + Call SetDirectory + + Mov AH, 48h + Mov BX, 2648 ; (65536 / (.4*31)) * 4 * 2 + ; +80 (filtering area) + Int 21h + JNC InitSound1 + + Mov SI, Offset WAVMemErrorMsg + Ret + +InitSound1: + Mov MixSegment, AX + + Mov SI, Offset WAVOutputMsg + + Mov AX, CmdLineMixSpeed + And AX, AX + JZ InitSound3 + + Cmp AX, 8000 + JA InitSound4 + + Mov AX, 8000 + +InitSound4: + Cmp AX, 64000 + JB InitSound5 + + Mov AX, 64000 + +InitSound5: + Mov MixSpeed, AX + +InitSound3: + Mov AX, MixSpeed + Mov Word Ptr LongMixSpeed, AX + + FNInit + FILd DWord Ptr [MixSpeed] + FMul FreqMultiplier + FStP FreqMultiplier + + Call CalculateFilterCoefficients + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + + Mov SI, Offset NoReinitMsg + Mov BX, 40 + Call SetInfoLine + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Call GotoHomeDirectory + + Mov DS, Word Ptr [CS:DriverName+2] + Mov DX, Word Ptr [CS:DriverName] + + Mov AX, 3D02h ; Read write access + Int 21h + + Push CS + Pop DS + Assume DS:Driver + + JC SaveConfig2 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SaveConfig1 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset WAVDirectory + Int 21h + +SaveConfig1: + Mov AH, 3Eh + Int 21h + +SaveConfig2: + Mov AX, MixSegment + Test AX, AX + JZ UnInitsound1 + + Mov ES, AX + Mov AH, 49h + Int 21h + +UnInitSound1: + Mov BX, FileHandle + Test BX, BX + JZ UnInitSound2 + + Mov AX, 4200h ; Move to start of file + Xor CX, CX + Xor DX, DX + Int 21h ; Start of file + + Mov EAX, WAVEDataSize + Add EAX, 24h + Mov WAVEFileSize, EAX + + Mov AH, 40h + Mov DX, Offset WAVEFileHeader + Mov CX, 2Ch + Int 21h + + Mov AH, 3Eh + Int 21h + +UnInitSound2: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CopyFileName ; Given DI + + Push DS + + Call GetFileName + Assume DS:Nothing ; Returns DS:SI + + Push CS + Pop ES + Mov CX, 11 + Mov AL, ' ' + Push DI + Rep StosB + Pop DI + + Mov CX, 8 + + Cmp Byte Ptr [SI], 0 + JE CopyFileName2 + Cmp Byte Ptr [SI], '.' + JE CopyFileName2 + +CopyFileName1: + LodsB + Cmp AL, '.' + JE CopyFileName3 + StosB + Loop CopyFileName1 + + Pop DS + Ret + +CopyFileName2: + Push CS + Pop DS + Mov SI, Offset OUTPUT + Mov CX, 6 + Rep MovsB + +CopyFileName3: + Pop DS + Ret + +EndP CopyFileName + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; BX = pattern +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +SlaveChannelLocation DW 0, 0, 0 + +Proc Poll Far + + Cmp MixSegment, 0 + JNE Poll2 + + Ret + +Poll2: + Push BX + Call Update ; Got DS:SI, CX + Pop BX + + Mov CS:[SlaveChannelLocation], SI + Mov CS:[SlaveChannelLocation+2], DS + Mov CS:[SlaveChannelLocation+4], CX + + Test AX, AX + JNZ Poll1 + + Cmp CS:FileHandle, 0 + JE Poll7 + + PushAD + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset ClosedFileMsg + Mov BX, 100 + Call SetInfoLine + +PollCloseFile: + Xor BX, BX + XChg BX, FileHandle + Mov AX, 4200h ; Move to start of file + Xor CX, CX + Xor DX, DX + Int 21h ; Start of file + + Mov EAX, WAVEDataSize + Add EAX, 24h + Mov WAVEFileSize, EAX + + Mov AH, 40h + Mov DX, Offset WAVEFileHeader + Mov CX, 2Ch + Int 21h + + Mov AH, 3Eh ; Close file + Int 21h + + Pop DS + PopAD + Assume DS:Nothing + Ret + +Poll7: +IF REGISTERED + Mov AL, CS:StereoSet + Mov CS:Stereo, AL +ENDIF + Ret + +Poll1: + PushAD + Push DS + Push ES + + Cmp CS:FileHandle, 0 + JNE Poll8 + ; Create file... BX = pattern + + Push AX + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Driver + + Xor EAX, EAX + Mov LastClickRemovalLeft, EAX + Mov LastClickRemovalRight, EAX + Mov NumClipped, EAX + Mov CurrentFractional, EAX +IF DITHEROUTPUT + Mov MonoDitherValue, EAX + Mov LeftDitherValue, EAX + Mov RightDitherValue, EAX +ENDIF + + Mov DI, Offset LastFilter + Mov CX, 16 + Xor AX, AX + Rep StosW + +IF WAREZWAVE ; Delete the file! + + Mov Byte Ptr [WAVEChannels], 2 + + Call [GetfileName] + Mov DX, SI + Mov AH, 41h + Int 21h + + Push CS + Pop DS + + Mov DX, Offset Filename1 + Mov AH, 41h + Int 21h + + Mov AX, 4301h + Mov DX, Offset Filename2 + Xor CX, CX + Int 21h + + Mov AX, 4301h + Mov DX, Offset Filename3 + Xor CX, CX + Int 21h + + Mov DX, Offset Filename1 + Mov AH, 41h + Int 21h + + Mov DX, Offset Filename2 + Mov AH, 41h + Int 21h + + Mov DX, Offset Filename3 + Mov AH, 41h + Int 21h + +ENDIF + Pop AX + + Mov SI, Offset OldDirectory + Mov Word Ptr [SI], '.' + Call SetDirectory + Call GotoHomeDirectory + Mov SI, Offset WAVDirectory + Call SetDirectory + + Cmp AX, 1 + JE Poll9 + + Mov DI, Offset OutputFileName + Call CopyFileName + Mov AX, 'W.' + StosW + Mov AX, 'VA' + StosW + Jmp Poll12 + +Poll9: + Mov DI, Offset OutputFileName + Call CopyFileName + + Xor DX, DX + Mov AX, BX ; AX = pattern + Mov BX, 10 + Div BX + Mov CL, DL + Xor DX, DX + Div BX + Mov AH, AL + Mov AL, '.' + Add AH, '0' + StosW + Mov AL, DL + Mov AH, CL + Add AX, '00' + StosW + +Poll12: + Mov AH, 3Ch + Xor CX, CX + Mov DX, Offset OutputFileName + Int 21h ; Create file... + Mov SI, Offset CreatingMsg + JNC Poll10 + +Poll11: + Mov SI, Offset WAVFileErrorMsg + Mov BX, 100 + Call SetInfoLine + Call StopPlayBack + + Mov SI, Offset OldDirectory + Call SetDirectory + + Pop ES + Pop DS + PopAD + Ret + + +Poll10: + Mov FileHandle, AX + + Xor EDX, EDX + Mov WAVEDataSize, EDX + Mov DX, MixSpeed + +IF REGISTERED + Mov CL, Stereo + Inc CX + ShL EDX, CL + +ELSE + ShL EDX, 1 + +ENDIF + Mov WAVEBytesPerSecond, EDX + +IF REGISTERED + Mov DX, 1 + ShL DX, CL + Mov WAVEBytesPerSample, DX + + Mov Byte Ptr [WAVEChannels], CL +ENDIF + + Mov BX, AX + Mov CX, 2Ch + Mov DX, Offset WAVEFileHeader + Mov AH, 40h + Int 21h + + Mov BX, 100 + Call SetInfoLine + + Mov SI, Offset OldDirectory + Call SetDirectory + + Assume DS:Nothing + +Poll8: + Call SaveEMSPageFrame + + LDS SI, [DWord Ptr SlaveChannelLocation] + Mov CX, [SlaveChannelLocation+4] + + Call M32MixHandler + Call RestoreEMSPageFrame + + ; Now reorder everything in mixbuff + Mov DS, CS:MixSegment + Push DS + Pop ES + +IF DITHEROUTPUT + Mov SI, 80 + Xor DI, DI + Mov CX, CS:RealBytesToMix + + IF REGISTERED + + Cmp CS:Stereo, 0 + JE PollNoStereo + + Mov EDX, CS:LeftDitherValue + Mov EBP, CS:RightDitherValue + + PollStereoDitherLoop: + Add EDX, [SI] + Add EBP, [SI+4] + + IF DOUBLEVOLUME + Mov EAX, EDX + And EDX, 1FFFh + + SAR EAX, 13 + Mov EBX, EBP + + SAR EBX, 13 + And EBP, 1FFFh + ELSE + Mov EAX, EDX + And EDX, 3FFFh + + SAR EAX, 14 + Mov EBX, EBP + + SAR EBX, 14 + And EBP, 3FFFh + ENDIF + + Cmp EAX, -8000h + JL StereoDitherClip1 + + Cmp EAX, 7FFFh + JG StereoDitherClip2 + + StereoDitherClipped1: + Cmp EBX, -8000h + JL StereoDitherClip3 + + Cmp EBX, 7FFFh + JG StereoDitherClip4 + + StereoDitherClipped2: + ShL EBX, 16 + And EAX, 0FFFFh + + Or EAX, EBX + Add SI, 8 + + StosD + Dec CX + JNZ PollStereoDitherLoop + + Mov CS:LeftDitherValue, EDX + Mov CS:RightDitherValue, EBP + + Mov CX, CS:RealBytesToMix + ShL CX, 2 + Jmp PollWriteBlock + + StereoDitherClip1: + Mov AX, 8000h + Jmp StereoDitherClipped1 + + StereoDitherClip2: + Mov AX, 7FFFh + Jmp StereoDitherClipped1 + + StereoDitherClip3: + Mov BX, 8000h + Jmp StereoDitherClipped2 + + StereoDitherClip4: + Mov BX, 7FFFh + Jmp StereoDitherClipped2 + + ENDIF + PollNoStereo: + Mov EBX, CS:MonoDitherValue + + PollMonoDitherLoop: + Add EBX, [SI] + Add SI, 8 + + Mov EAX, EBX + IF DOUBLEVOLUME + And EBX, 1FFFh + SAR EAX, 13 + ELSE + And EBX, 3FFFh + SAR EAX, 14 + ENDIF + + Cmp EAX, -8000h + JL MonoDitherClip1 + + Cmp EAX, 7FFFh + JG MonoDitherClip2 + + PollMonoDitherClipped: + StosW + + Dec CX + JNZ PollMonoDitherLoop + + Mov CS:MonoDitherValue, EBX + + + Mov CX, CS:RealBytesToMix + Add CX, CX + Jmp PollWriteBlock + + MonoDitherClip1: + Mov AX, 8000h + Jmp PollMonoDitherClipped + + MonoDitherClip2: + Mov AX, 7FFFh + Jmp PollMonoDitherClipped + + +ELSE ; No dither + Mov CX, CS:RealBytesToMix + Mov BX, 8 + + IF REGISTERED + Cmp CS:Stereo, 0 + JE PollNoStereo + + Add CX, CX + Mov BX, 4 + + ENDIF + + PollNoStereo: + Push CX + + Mov SI, 80 + Xor DI, DI + + Poll3: + Mov EAX, [SI] + Add SI, BX + Add EAX, 2000h + IF DOUBLEVOLUME + SAR EAX, 13 + ELSE + SAR EAX, 14 + ENDIF + + Cmp EAX, -8000h + JL Poll5 + Cmp EAX, 7FFFh + JG Poll6 + + Poll4: + StosW + Dec CX + JNZ Poll3 + + Pop CX + Add CX, CX +ENDIF +PollWriteBlock: + Mov AH, 40h ; Write + Xor DX, DX + Mov BX, CS:FileHandle + Int 21h + JC PollError + Cmp AX, CX + JE PollNoError + +PollError: + Push CS + Pop DS + Mov SI, Offset WriteError + Mov BX, 100 + Call SetInfoLine + + Call StopPlayBack + + Pop ES + Push CS + Pop DS + Jmp PollCloseFile + +PollNoError: + Add Word Ptr [CS:WAVEDataSize], AX + AdC Word Ptr [CS:WAVEDataSize+2], 0 + + Pop ES + Pop DS + PopAD + + Ret + +IF DITHEROUTPUT +ELSE + Poll5: + Inc NumClipped + Mov AX, 8000h + Jmp Poll4 + + Poll6: + Inc NumClipped + Mov AX, 7FFFh + Jmp Poll4 + +ENDIF + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + PushAD + + Push BX + + Xor EAX, EAX + Xor EBX, EBX + Xor EDX, EDX + + Mov AX, CS:MixSpeed + + Mov EBX, EAX + ShL EAX, 1 ; EAX = MixSpeed * 2 + ShR EBX, 1 ; EBX = Mixspeed / 2 + Add EAX, EBX + + Pop BX ; BX = tempo + Div EBX + + Mov CS:BytesToMix, AX + Mov CS:BytesToMixFractional, EDX + + PopAD + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + +IF REGISTERED + Mov CS:StereoSet, AL + +ENDIF + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + PushAD + Push DS + Push ES + Push FS + + Mov FS, CS:SongDataArea + Mov BP, AX + Add BP, BP + Mov BP, [FS:64910+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length (in samples) + JC LoadSampleEnd ; Zero flag ON if 16 bit.. + + Mov BL, [FS:BP+12h] + JNZ LoadSample1 + ; 8 bit + Mov ESI, ECX + Dec ESI + + Test BL, 10h ; Loop + JZ LoadSample8_3 + + Mov ESI, [FS:BP+34h] + Mov ECX, [FS:BP+38h] + Mov EDX, 1 + + Test BL, 40h + JZ LoadSample8_1 + + Neg EDX + + Mov ESI, ECX + Sub ESI, 1 + JC LoadSample8_4 + + Cmp ESI, 1 + JAE LoadSample8_1 + Jmp LoadSample8_3 + +LoadSample8_4: + Xor ESI, ESI + +LoadSample8_3: + Xor EDX, EDX + +LoadSample8_1: + Int 3 + Mov AL, [SI] + Add ESI, EDX + Int 3 + Mov AH, [SI] + + Mov ESI, ECX + Int 3 + Mov [SI], AL + Inc ESI + Int 3 + Mov [SI], AH + + Jmp LoadSampleEnd + +LoadSample1: ; 16 bit + Mov ESI, ECX + Dec ESI + + Test BL, 10h ; Loop + JZ LoadSample16_2 + + Mov ESI, [FS:BP+34h] ; Start + Mov ECX, [FS:BP+38h] ; End + Mov EDX, 2 + + Test BL, 40h ; Pingpong? + JZ LoadSample16_1 + + Neg EDX ; Yes..pingpong + + Mov ESI, ECX + Sub ESI, 1 + JC LoadSample16_4 + + Cmp ESI, 1 + JAE LoadSample16_1 + Jmp LoadSample16_2 + +LoadSample16_4: + Xor ESI, ESI + +LoadSample16_2: + Xor EDX, EDX + +LoadSample16_1: + Add ESI, ESI + Int 3 + Mov AX, [SI] + Add ESI, EDX + ShL EAX, 16 + Int 3 + Mov AX, [SI] + + Mov ESI, ECX + Add ESI, ESI + Int 3 + RoR EAX, 16 + Mov [SI], AX + Add ESI, 2 + Int 3 + ShR EAX, 16 + Mov [SI], AX + +LoadSampleEnd: + Pop FS + Pop ES + Pop DS + PopAD + + StC + + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + Cmp CS:NumClipped, 0 + JNE GetStatus1 + + StC + Ret + +GetStatus1: + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset ClippedMsg + Mov BX, Word Ptr [NumClipped+2] + Mov AX, Word Ptr [NumClipped] + + ClC + Ret + +EndP GetStatus + Assume DS:Nothing + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WAVScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +TempVariable DW 0 +Const1 DD 3F800000h + +Proc GetFilterFrequency ; Given AL= Freq + Assume DS:Driver + + ShL AX, 8 + Mov TempVariable, AX + FILD TempVariable + + FMul FreqParameterMultiplier ; -i/(24*256) + FLd ST + FRndInt + FSub ST(1), ST + FXCh + F2XM1 + FLd1 + FAdd + FScale ; = 2^(i/24*256) + FMul FreqMultiplier ; = r + + FLd1 ; 1, c + FAdd ST, ST(1) ; 1+c, c + FDivR Const1 ; 1/(1+c), c + FSt DWord Ptr [SI] + FMul + FStP DWord Ptr [SI+4] + FStP ST + + Ret + +EndP GetFilterFrequency + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Const1On16 DD 3D000000h ; actually 1 on 32 + +Proc CalculateFilterCoefficients + Assume DS:Driver + + PushA + Push CS + Pop DS + + FNInit + FLdCW NewControlWord + + Mov AL, [VolumeTable] + Mov SI, Offset FilterCoefficients + ShR AL, 1 + Call GetFilterFrequency + + Mov AL, [VolumeTable+1] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + + Mov AL, [VolumeTable+2] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + + Mov AL, [VolumeTable+3] ; FilterFrequency1 + Add SI, 8 + Call GetFilterFrequency + +; Now volumes + Mov SI, Offset VolumeTable+4 + Mov DI, Offset FilterVolumes + Xor AX, AX + Mov CX, 4 + +FilterVolumeLoop1: + LodSB + Mov TempVariable, AX + FILD TempVariable + FMul Const1On16 + FStP DWord Ptr [DI] + + Add DI, 4 + Loop FilterVolumeLoop1 + + PopA + Ret + +EndP CalculateFilterCoefficients + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + Call CalculateFilterCoefficients + + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartNoRampFunction Far + + Push CS + Pop ES + Mov DI, Offset StartNoRamp + + Ret + +EndP StartNoRampFunction + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. +StopPlaySection DW 1 +DefaultChannels DW 256 +DriverFlags DW 3 ; Bit 0 = MIDI Output + ; Bit 1 = hiqual + ; Bit 2 = waveform + DW 4 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + DW Offset SendUARTOut + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/WAVPRO.ASM b/SoundDrivers/WAVPRO.ASM index 8a1d866..4de530c 100755 --- a/SoundDrivers/WAVPRO.ASM +++ b/SoundDrivers/WAVPRO.ASM @@ -1,853 +1,853 @@ - - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -REGISTERED EQU 1 - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -STEREOENABLED EQU 1 -MIXRESOLUTION EQU 32 - -FileID DW 22 ; 0 = Ozone - ; 1 = Andrew Seargant - ; 2 = David Goodale - ; 3 = Nebula - ; 4 = Christian Bode - ; 5 = Flatrich - ; 6 = MAZ - ; 7 = Barthelemy DEFOSSEZ - ; 8 = Daedalus - ; 9 = Joost - ; 10= Yannis - ; 11= Mike Marton - ; 12= HB - ; 13= Catspaw - ; 14= Airon - ; 15= Mike Blaine - ; 16= Jason Tracer - ; 17= Akos Matte - ; 18= Kristian Sergiejew - ; 19= Jonathan Bartlett - ; 20= DeltaX - ; 21= Zinc - ; 22= Draggy - -FileHandle DW 0 - -LowerLimit DD -3.2768E4 -UpperLimit DD 3.2767E4 - -WAVOutputMsg DB "Writing to disk", 13 - DB "Output frequency ", 0FDh, "D", 0 -WAVFileErrorMsg DB "Unable to create output file! ", 0 -WAVMemErrorMsg DB "Unable to allocate memory!", 0 -NoReinitMsg DB "File output routines should NOT require reinitialisation ", 0 -WriteError DB "Error writing to output file. Output file closed ", 0 - - -WAVEFileHeader DB "RIFF" -WAVEFileSize DD 0 -WAVEFileHeader2 DB "WAVEfmt " -WAVEFileHeaderLength DD 10h -WAVEFileID DW 1 -WAVEChannels DW 1 ; 1 = mono, 2 = stereo -MixSpeed DW 44100 ; Default to CD quality -WAVEMixSpeedFiller DW 0 -WAVEBytesPerSecond DD 0 -WAVEBytesPerSample DW 2 -WAVEBits DW 16 -WAVEHeader3 DB "data" -WAVEDataSize DD 0 - -IFDEF REGISTERED - Stereo DB 0 - StereoSet DB 0 -ENDIF - -BytesToMix DW 0 -MixVolume DW 0 -MixSegment DW 0 -MixHandler DW Offset M32MixHandler -OldDirectory DB 80 Dup (0) - -CreatingMsg DB "Created file " -OutputFileName DB " ", 0 - -ClosedFileMsg DB "Closed output file ", 0 -OUTPUT DB "OUTPUT" - -include mix.inc -include wav.mix - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - Call SetupRamp - - Mov EAX, 'Jeff' - ClC ; Always assume true - Ret - -EndP DetectCard - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - FNINIT - - Mov AH, 48h - Mov BX, 2643 ; (65536 / (.4*31)) * 4 * 2 - Int 21h - JNC InitSound1 - - Mov SI, Offset WAVMemErrorMsg - Ret - -InitSound1: - Mov MixSegment, AX - - Mov SI, Offset WAVOutputMsg - - Mov AX, CmdLineMixSpeed - And AX, AX - JZ InitSound3 - - Cmp AX, 8000 - JA InitSound4 - - Mov AX, 8000 - -InitSound4: - Cmp AX, 64000 - JB InitSound5 - - Mov AX, 64000 - -InitSound5: - Mov MixSpeed, AX - -InitSound3: - Mov AX, MixSpeed - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - Push CS - Pop DS - - Mov SI, Offset NoReinitMsg - Mov BX, 40 - Call SetInfoLine - - Ret - -EndP ReInitSound - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, MixSegment - Test AX, AX - JZ UnInitsound1 - - Mov ES, AX - Mov AH, 49h - Int 21h - -UnInitSound1: - Mov BX, FileHandle - Test BX, BX - JZ UnInitSound2 - - Mov AX, 4200h ; Move to start of file - Xor CX, CX - Xor DX, DX - Int 21h ; Start of file - - Mov EAX, WAVEDataSize - Add EAX, 24h - Mov WAVEFileSize, EAX - - Mov AH, 40h - Mov DX, Offset WAVEFileHeader - Mov CX, 2Ch - Int 21h - - Mov AH, 3Eh - Int 21h - -UnInitSound2: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CopyFileName ; Given DI - - Push DS - - Call GetFileName - Assume DS:Nothing ; Returns DS:SI - - Push CS - Pop ES - Mov CX, 11 - Mov AL, ' ' - Push DI - Rep StosB - Pop DI - - Mov CX, 8 - - Cmp Byte Ptr [SI], 0 - JE CopyFileName2 - Cmp Byte Ptr [SI], '.' - JE CopyFileName2 - -CopyFileName1: - LodsB - Cmp AL, '.' - JE CopyFileName3 - StosB - Loop CopyFileName1 - - Pop DS - Ret - -CopyFileName2: - Push CS - Pop DS - Mov SI, Offset OUTPUT - Mov CX, 6 - Rep MovsB - -CopyFileName3: - Pop DS - Ret - -EndP CopyFileName - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; BX = pattern -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Cmp MixSegment, 0 - JNE Poll2 - - Ret - -Poll2: - Test AX, AX - JNZ Poll1 - - Cmp CS:FileHandle, 0 - JE Poll7 - - PushAD - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset ClosedFileMsg - Mov BX, 100 - Call SetInfoLine - -PollCloseFile: - Xor BX, BX - XChg BX, FileHandle - Mov AX, 4200h ; Move to start of file - Xor CX, CX - Xor DX, DX - Int 21h ; Start of file - - Mov EAX, WAVEDataSize - Add EAX, 24h - Mov WAVEFileSize, EAX - - Mov AH, 40h - Mov DX, Offset WAVEFileHeader - Mov CX, 2Ch - Int 21h - - Mov AH, 3Eh ; Close file - Int 21h - - Pop DS - PopAD - Assume DS:Nothing - Ret - -Poll7: -IFDEF REGISTERED - Mov AL, CS:StereoSet - Mov CS:Stereo, AL -ENDIF - Ret - -Poll1: - PushAD - Push DS - Push ES - - Cmp CS:FileHandle, 0 - JNE Poll8 - ; Create file... BX = pattern - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset OldDirectory - Mov Word Ptr [SI], '.' - Call SetDirectory - Call GotoHomeDirectory - - Cmp AX, 1 - JE Poll9 - - Mov DI, Offset OutputFileName - Call CopyFileName - Mov AX, 'W.' - StosW - Mov AX, 'VA' - StosW - Jmp Poll12 - -Poll9: - Mov DI, Offset OutputFileName - Call CopyFileName - - Xor DX, DX - Mov AX, BX ; AX = pattern - Mov BX, 10 - Div BX - Mov CL, DL - Xor DX, DX - Div BX - Mov AH, AL - Mov AL, '.' - Add AH, '0' - StosW - Mov AL, DL - Mov AH, CL - Add AX, '00' - StosW - -Poll12: - Mov AH, 3Ch - Xor CX, CX - Mov DX, Offset OutputFileName - Int 21h ; Create file... - Mov SI, Offset CreatingMsg - JNC Poll10 - -Poll11: - Mov SI, Offset WAVFileErrorMsg - Mov BX, 100 - Call SetInfoLine - Call StopPlayBack - - Mov SI, Offset OldDirectory - Call SetDirectory - - Pop ES - Pop DS - PopAD - Ret - - -Poll10: - Mov FileHandle, AX - - Xor EDX, EDX - Mov WAVEDataSize, EDX - Mov DX, MixSpeed - -IFDEF REGISTERED - Mov CL, Stereo - Inc CX - ShL EDX, CL - -ELSE - ShL EDX, 1 - -ENDIF - Mov WAVEBytesPerSecond, EDX - -IFDEF REGISTERED - Mov DX, 1 - ShL DX, CL - Mov WAVEBytesPerSample, DX - - Mov Byte Ptr [WAVEChannels], CL -ENDIF - - Mov BX, AX - Mov CX, 2Ch - Mov DX, Offset WAVEFileHeader - Mov AH, 40h - Int 21h - - Mov BX, 100 - Call SetInfoLine - - Mov SI, Offset OldDirectory - Call SetDirectory - - Assume DS:Nothing - -Poll8: - Call SaveEMSPageFrame - Call Update ; Got DS:SI, CX - Call M32MixHandler - Call RestoreEMSPageFrame - - ; Now reorder everything in mixbuff - Mov DS, CS:MixSegment - Push DS - Pop ES - - Mov CX, CS:BytesToMix - Mov BX, 8 - -IFDEF REGISTERED - Cmp CS:Stereo, 0 - JE PollNoStereo - - Add CX, CX - Mov BX, 4 - -ENDIF - -PollNoStereo: - Push CX - - Xor SI, SI - Xor DI, DI - Xor DX, DX - -Poll3: - Mov EAX, [SI] - - Test EAX, EAX - JS FloatNegative - - Cmp EAX, UpperLimit - JL FloatOK - - Mov AX, 7FFFh - Jmp Poll4 - -FloatNegative: - Cmp EAX, LowerLimit - JL FloatOK - - Mov AX, 8000h - Jmp Poll4 - -FloatOK: - Fld DWord Ptr [SI] - FISt DWord Ptr [SI] - Mov AX, [SI] - -Poll4: - Add SI, BX - StosW - Dec CX - JNZ Poll3 - - Pop CX - Add CX, CX - - Mov AH, 40h ; Write - Mov BX, CS:FileHandle - Int 21h - JC PollError - Cmp AX, CX - JE PollNoError - -PollError: - Push CS - Pop DS - Mov SI, Offset WriteError - Mov BX, 100 - Call SetInfoLine - - Call StopPlayBack - - Pop ES - Push CS - Pop DS - Jmp PollCloseFile - -PollNoError: - Add Word Ptr [CS:WAVEDataSize], AX - AdC Word Ptr [CS:WAVEDataSize+2], 0 - - Pop ES - Pop DS - PopAD - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, CS:MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov CS:BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - Mov CS:MixVolume, AX - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - -IFDEF REGISTERED - Mov CS:StereoSet, AL - -ENDIF - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far - - PushAD - Push DS - Push ES - Push FS - - Mov FS, CS:SongDataArea - Mov BP, AX - Add BP, BP - Mov BP, [FS:64910+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC LoadSampleEnd ; Zero flag ON if 16 bit.. - - Mov AX, 0 - Mov BL, [FS:BP+12h] - JNZ LoadSample1 - ; 8 bit - - Test BL, 10h ; Loop - JZ LoadSample8_2 - - Mov ESI, [FS:BP+34h] - Mov ECX, [FS:BP+38h] - - Test BL, 40h - JZ LoadSample8_1 - - Mov ESI, ECX - Sub ESI, 2 - JNC LoadSample8_1 - - Xor ESI, ESI - -LoadSample8_1: - Call UpdateSampleLocation - Mov AL, [SI] - -LoadSample8_2: - Mov ESI, ECX - Call UpdateSampleLocation - Mov [SI], AL - Jmp LoadSampleEnd - -LoadSample1: ; 16 bit - Test BL, 10h ; Loop - JZ LoadSample16_2 - - Mov ESI, [FS:BP+34h] - Mov ECX, [FS:BP+38h] - - Test BL, 40h - JZ LoadSample16_1 - - Mov ESI, ECX - Sub ESI, 2 - JNC LoadSample16_1 - - Xor ESI, ESI - -LoadSample16_1: - Add ESI, ESI - Call UpdateSampleLocation - Mov AX, [SI] - -LoadSample16_2: - Mov ESI, ECX - Add ESI, ESI - Call UpdateSampleLocation - Mov [SI], AX - -LoadSampleEnd: - Pop FS - Pop ES - Pop DS - PopAD - - StC - - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Xor AX, AX - StC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. -StopPlaySection DW 1 -DefaultChannels DW 256 - DW 5 Dup (0) - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End + + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +REGISTERED EQU 1 + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +STEREOENABLED EQU 1 +MIXRESOLUTION EQU 32 + +FileID DW 22 ; 0 = Ozone + ; 1 = Andrew Seargant + ; 2 = David Goodale + ; 3 = Nebula + ; 4 = Christian Bode + ; 5 = Flatrich + ; 6 = MAZ + ; 7 = Barthelemy DEFOSSEZ + ; 8 = Daedalus + ; 9 = Joost + ; 10= Yannis + ; 11= Mike Marton + ; 12= HB + ; 13= Catspaw + ; 14= Airon + ; 15= Mike Blaine + ; 16= Jason Tracer + ; 17= Akos Matte + ; 18= Kristian Sergiejew + ; 19= Jonathan Bartlett + ; 20= DeltaX + ; 21= Zinc + ; 22= Draggy + +FileHandle DW 0 + +LowerLimit DD -3.2768E4 +UpperLimit DD 3.2767E4 + +WAVOutputMsg DB "Writing to disk", 13 + DB "Output frequency ", 0FDh, "D", 0 +WAVFileErrorMsg DB "Unable to create output file! ", 0 +WAVMemErrorMsg DB "Unable to allocate memory!", 0 +NoReinitMsg DB "File output routines should NOT require reinitialisation ", 0 +WriteError DB "Error writing to output file. Output file closed ", 0 + + +WAVEFileHeader DB "RIFF" +WAVEFileSize DD 0 +WAVEFileHeader2 DB "WAVEfmt " +WAVEFileHeaderLength DD 10h +WAVEFileID DW 1 +WAVEChannels DW 1 ; 1 = mono, 2 = stereo +MixSpeed DW 44100 ; Default to CD quality +WAVEMixSpeedFiller DW 0 +WAVEBytesPerSecond DD 0 +WAVEBytesPerSample DW 2 +WAVEBits DW 16 +WAVEHeader3 DB "data" +WAVEDataSize DD 0 + +IFDEF REGISTERED + Stereo DB 0 + StereoSet DB 0 +ENDIF + +BytesToMix DW 0 +MixVolume DW 0 +MixSegment DW 0 +MixHandler DW Offset M32MixHandler +OldDirectory DB 80 Dup (0) + +CreatingMsg DB "Created file " +OutputFileName DB " ", 0 + +ClosedFileMsg DB "Closed output file ", 0 +OUTPUT DB "OUTPUT" + +include mix.inc +include wav.mix + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + Call SetupRamp + + Mov EAX, 'Jeff' + ClC ; Always assume true + Ret + +EndP DetectCard + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + FNINIT + + Mov AH, 48h + Mov BX, 2643 ; (65536 / (.4*31)) * 4 * 2 + Int 21h + JNC InitSound1 + + Mov SI, Offset WAVMemErrorMsg + Ret + +InitSound1: + Mov MixSegment, AX + + Mov SI, Offset WAVOutputMsg + + Mov AX, CmdLineMixSpeed + And AX, AX + JZ InitSound3 + + Cmp AX, 8000 + JA InitSound4 + + Mov AX, 8000 + +InitSound4: + Cmp AX, 64000 + JB InitSound5 + + Mov AX, 64000 + +InitSound5: + Mov MixSpeed, AX + +InitSound3: + Mov AX, MixSpeed + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + Push CS + Pop DS + + Mov SI, Offset NoReinitMsg + Mov BX, 40 + Call SetInfoLine + + Ret + +EndP ReInitSound + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, MixSegment + Test AX, AX + JZ UnInitsound1 + + Mov ES, AX + Mov AH, 49h + Int 21h + +UnInitSound1: + Mov BX, FileHandle + Test BX, BX + JZ UnInitSound2 + + Mov AX, 4200h ; Move to start of file + Xor CX, CX + Xor DX, DX + Int 21h ; Start of file + + Mov EAX, WAVEDataSize + Add EAX, 24h + Mov WAVEFileSize, EAX + + Mov AH, 40h + Mov DX, Offset WAVEFileHeader + Mov CX, 2Ch + Int 21h + + Mov AH, 3Eh + Int 21h + +UnInitSound2: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CopyFileName ; Given DI + + Push DS + + Call GetFileName + Assume DS:Nothing ; Returns DS:SI + + Push CS + Pop ES + Mov CX, 11 + Mov AL, ' ' + Push DI + Rep StosB + Pop DI + + Mov CX, 8 + + Cmp Byte Ptr [SI], 0 + JE CopyFileName2 + Cmp Byte Ptr [SI], '.' + JE CopyFileName2 + +CopyFileName1: + LodsB + Cmp AL, '.' + JE CopyFileName3 + StosB + Loop CopyFileName1 + + Pop DS + Ret + +CopyFileName2: + Push CS + Pop DS + Mov SI, Offset OUTPUT + Mov CX, 6 + Rep MovsB + +CopyFileName3: + Pop DS + Ret + +EndP CopyFileName + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; BX = pattern +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Cmp MixSegment, 0 + JNE Poll2 + + Ret + +Poll2: + Test AX, AX + JNZ Poll1 + + Cmp CS:FileHandle, 0 + JE Poll7 + + PushAD + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset ClosedFileMsg + Mov BX, 100 + Call SetInfoLine + +PollCloseFile: + Xor BX, BX + XChg BX, FileHandle + Mov AX, 4200h ; Move to start of file + Xor CX, CX + Xor DX, DX + Int 21h ; Start of file + + Mov EAX, WAVEDataSize + Add EAX, 24h + Mov WAVEFileSize, EAX + + Mov AH, 40h + Mov DX, Offset WAVEFileHeader + Mov CX, 2Ch + Int 21h + + Mov AH, 3Eh ; Close file + Int 21h + + Pop DS + PopAD + Assume DS:Nothing + Ret + +Poll7: +IFDEF REGISTERED + Mov AL, CS:StereoSet + Mov CS:Stereo, AL +ENDIF + Ret + +Poll1: + PushAD + Push DS + Push ES + + Cmp CS:FileHandle, 0 + JNE Poll8 + ; Create file... BX = pattern + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset OldDirectory + Mov Word Ptr [SI], '.' + Call SetDirectory + Call GotoHomeDirectory + + Cmp AX, 1 + JE Poll9 + + Mov DI, Offset OutputFileName + Call CopyFileName + Mov AX, 'W.' + StosW + Mov AX, 'VA' + StosW + Jmp Poll12 + +Poll9: + Mov DI, Offset OutputFileName + Call CopyFileName + + Xor DX, DX + Mov AX, BX ; AX = pattern + Mov BX, 10 + Div BX + Mov CL, DL + Xor DX, DX + Div BX + Mov AH, AL + Mov AL, '.' + Add AH, '0' + StosW + Mov AL, DL + Mov AH, CL + Add AX, '00' + StosW + +Poll12: + Mov AH, 3Ch + Xor CX, CX + Mov DX, Offset OutputFileName + Int 21h ; Create file... + Mov SI, Offset CreatingMsg + JNC Poll10 + +Poll11: + Mov SI, Offset WAVFileErrorMsg + Mov BX, 100 + Call SetInfoLine + Call StopPlayBack + + Mov SI, Offset OldDirectory + Call SetDirectory + + Pop ES + Pop DS + PopAD + Ret + + +Poll10: + Mov FileHandle, AX + + Xor EDX, EDX + Mov WAVEDataSize, EDX + Mov DX, MixSpeed + +IFDEF REGISTERED + Mov CL, Stereo + Inc CX + ShL EDX, CL + +ELSE + ShL EDX, 1 + +ENDIF + Mov WAVEBytesPerSecond, EDX + +IFDEF REGISTERED + Mov DX, 1 + ShL DX, CL + Mov WAVEBytesPerSample, DX + + Mov Byte Ptr [WAVEChannels], CL +ENDIF + + Mov BX, AX + Mov CX, 2Ch + Mov DX, Offset WAVEFileHeader + Mov AH, 40h + Int 21h + + Mov BX, 100 + Call SetInfoLine + + Mov SI, Offset OldDirectory + Call SetDirectory + + Assume DS:Nothing + +Poll8: + Call SaveEMSPageFrame + Call Update ; Got DS:SI, CX + Call M32MixHandler + Call RestoreEMSPageFrame + + ; Now reorder everything in mixbuff + Mov DS, CS:MixSegment + Push DS + Pop ES + + Mov CX, CS:BytesToMix + Mov BX, 8 + +IFDEF REGISTERED + Cmp CS:Stereo, 0 + JE PollNoStereo + + Add CX, CX + Mov BX, 4 + +ENDIF + +PollNoStereo: + Push CX + + Xor SI, SI + Xor DI, DI + Xor DX, DX + +Poll3: + Mov EAX, [SI] + + Test EAX, EAX + JS FloatNegative + + Cmp EAX, UpperLimit + JL FloatOK + + Mov AX, 7FFFh + Jmp Poll4 + +FloatNegative: + Cmp EAX, LowerLimit + JL FloatOK + + Mov AX, 8000h + Jmp Poll4 + +FloatOK: + Fld DWord Ptr [SI] + FISt DWord Ptr [SI] + Mov AX, [SI] + +Poll4: + Add SI, BX + StosW + Dec CX + JNZ Poll3 + + Pop CX + Add CX, CX + + Mov AH, 40h ; Write + Mov BX, CS:FileHandle + Int 21h + JC PollError + Cmp AX, CX + JE PollNoError + +PollError: + Push CS + Pop DS + Mov SI, Offset WriteError + Mov BX, 100 + Call SetInfoLine + + Call StopPlayBack + + Pop ES + Push CS + Pop DS + Jmp PollCloseFile + +PollNoError: + Add Word Ptr [CS:WAVEDataSize], AX + AdC Word Ptr [CS:WAVEDataSize+2], 0 + + Pop ES + Pop DS + PopAD + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, CS:MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov CS:BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + Mov CS:MixVolume, AX + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + +IFDEF REGISTERED + Mov CS:StereoSet, AL + +ENDIF + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far + + PushAD + Push DS + Push ES + Push FS + + Mov FS, CS:SongDataArea + Mov BP, AX + Add BP, BP + Mov BP, [FS:64910+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC LoadSampleEnd ; Zero flag ON if 16 bit.. + + Mov AX, 0 + Mov BL, [FS:BP+12h] + JNZ LoadSample1 + ; 8 bit + + Test BL, 10h ; Loop + JZ LoadSample8_2 + + Mov ESI, [FS:BP+34h] + Mov ECX, [FS:BP+38h] + + Test BL, 40h + JZ LoadSample8_1 + + Mov ESI, ECX + Sub ESI, 2 + JNC LoadSample8_1 + + Xor ESI, ESI + +LoadSample8_1: + Call UpdateSampleLocation + Mov AL, [SI] + +LoadSample8_2: + Mov ESI, ECX + Call UpdateSampleLocation + Mov [SI], AL + Jmp LoadSampleEnd + +LoadSample1: ; 16 bit + Test BL, 10h ; Loop + JZ LoadSample16_2 + + Mov ESI, [FS:BP+34h] + Mov ECX, [FS:BP+38h] + + Test BL, 40h + JZ LoadSample16_1 + + Mov ESI, ECX + Sub ESI, 2 + JNC LoadSample16_1 + + Xor ESI, ESI + +LoadSample16_1: + Add ESI, ESI + Call UpdateSampleLocation + Mov AX, [SI] + +LoadSample16_2: + Mov ESI, ECX + Add ESI, ESI + Call UpdateSampleLocation + Mov [SI], AX + +LoadSampleEnd: + Pop FS + Pop ES + Pop DS + PopAD + + StC + + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Xor AX, AX + StC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. +StopPlaySection DW 1 +DefaultChannels DW 256 + DW 5 Dup (0) + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/WSSDRV.ASM b/SoundDrivers/WSSDRV.ASM index 977673d..6ef9fc6 100755 --- a/SoundDrivers/WSSDRV.ASM +++ b/SoundDrivers/WSSDRV.ASM @@ -1,2175 +1,2175 @@ -; -; Windows Sound System Driver -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 - -DMASize DW 2048 - -WSSMsg DB "Using Windows Sound System", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Using Windows Sound System", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Windows Sound System reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITWSS.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITWSS.DRV", 0 - -DriverName DB "ITWSS.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQSetupTable DB 0, 0, 0, 0, 0, 0, 0, 8 - DB 0, 10h, 18h, 20h, 0, 0, 0, 0 - -DMASetupTable DB 1, 2, 0, 3, 0, 0, 0, 0 - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -WSS_INTF = 00h -WSS_CHIPID = 03h -WSS_BASE = 04h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "Windows Sound System Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 27, 48 - DB 21h - DB "Windows Sound System Driver 1.1 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 16 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Add DX, WSS_CHIPID ; Check for valid Chip ID - In AL, DX - - And AL, 3Fh - JZ PingWSS1 - Cmp AL, 4 - JE PingWSS1 - Cmp AL, 0Fh - JE PingWSS1 - -PingWSSFailure: - Pop DX - - StC - Ret - -PingWSS1: - Add DX, 4+2-WSS_CHIPID - - In AL, DX - Xor AL, AL - Out DX, AL - - Sub DX, 2 ; DX = AD1848 Baseport - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - - Pop DX - Ret - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Cmp IRQ, 0FFFFh - JNE DetectCardIRQDone - - Mov IRQ, 7 - -DetectCardIRQDone: - Cmp DMA, 0FFFFh - JNE DetectCardDMADone - - Mov DMA, 1 - -DetectCardDMADone: - Mov DX, BasePort - Cmp DX, 0FFFFh - JE DetectCardFindBasePort - - Call PingWSS - JNC CheckWSSOK - -DetectWSSFailure: - StC - Ret - -DetectCardFindBasePort: - Mov DX, 530h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0E80h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0F40h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 604h - Call PingWSS - JC DetectWSSFailure - -DetectWSSOK: - Mov BasePort, DX - -CheckWSSOK: - ; Check for valid IRQ - Mov BX, IRQ - Mov AL, [IRQSetupTable+BX] - Mov BX, DMA - Mov AH, [DMASetupTable+BX] - Test AL, AL - JZ DetectWSSFailure - Test AH, AH - JZ DetectWSSFailure - - Or AL, AH - Out DX, AL - - Add DX, WSS_BASE - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - PushAD - Push DS - Push ES - - ClD - - Mov AX, CS - Mov DS, AX - Assume DS:Driver - - Mov DX, [BasePort] - Add DX, 6 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Mov AX, MixBufferPos - Mov BX, AX - Mul DMASize - Cmp AX, DMABUFFERLENGTH - JB WSSIRQHandler2 - - Xor AX, AX - Xor BX, BX - -WSSIRQHandler2: - Inc BX - Mov MixBufferPos, BX - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, AX - - Mov BX, DMASize ; BX = bytes required - ShR BX, 1 - ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - Pop DS - PopAD - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - Add DX, WSS_BASE - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Add DX, WSS_BASE - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, DMASize - ShR AX, 1 - - Cmp Stereo, 0 - JE StartWSS2 - - ShR AX, 1 - -StartWSS2: - Dec AX - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far ; Fix up end of sample bytes - - PushAD - Push DS - Push ES - Push FS - - Mov FS, CS:SongDataArea - Mov BP, AX - Add BP, BP - Mov BP, [FS:64910+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC LoadSampleEnd ; Zero flag ON if 16 bit.. - - Xor EAX, EAX - Mov BL, [FS:BP+12h] - - Test BL, 10h ; Loop - JZ LoadSample2 - - Mov ESI, [FS:BP+34h] ; Start of loop - Test BL, 40h ; Pingpong? - JZ LoadSample1 - - Mov ESI, [FS:BP+38h] - Sub ESI, 2 - JNC LoadSample1 - - Xor ESI, ESI - -LoadSample1: - Test BL, 2 - JZ LoadSample4 - - Add ESI, ESI - -LoadSample4: - Call UpdateSampleLocation - Mov AL, [SI] - Inc ESI - Call UpdateSampleLocation - Mov AH, [SI] - -LoadSample2: - Mov ESI, [FS:BP+30h] - Test BL, 2 - JZ LoadSample3 - - Add ESI, ESI - -LoadSample3: - Call UpdateSampleLocation - Mov [SI], AL - Inc ESI - Call UpdateSampleLocation - Mov [SI], AH - -LoadSampleEnd: - Pop FS - Pop ES - Pop DS - PopAD - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DX, WSS_BASE - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 + +DMASize DW 2048 + +WSSMsg DB "Using Windows Sound System", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Using Windows Sound System", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Windows Sound System reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITWSS.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITWSS.DRV", 0 + +DriverName DB "ITWSS.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQSetupTable DB 0, 0, 0, 0, 0, 0, 0, 8 + DB 0, 10h, 18h, 20h, 0, 0, 0, 0 + +DMASetupTable DB 1, 2, 0, 3, 0, 0, 0, 0 + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +WSS_INTF = 00h +WSS_CHIPID = 03h +WSS_BASE = 04h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "Windows Sound System Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 27, 48 + DB 21h + DB "Windows Sound System Driver 1.1 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 16 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Add DX, WSS_CHIPID ; Check for valid Chip ID + In AL, DX + + And AL, 3Fh + JZ PingWSS1 + Cmp AL, 4 + JE PingWSS1 + Cmp AL, 0Fh + JE PingWSS1 + +PingWSSFailure: + Pop DX + + StC + Ret + +PingWSS1: + Add DX, 4+2-WSS_CHIPID + + In AL, DX + Xor AL, AL + Out DX, AL + + Sub DX, 2 ; DX = AD1848 Baseport + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + + Pop DX + Ret + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Cmp IRQ, 0FFFFh + JNE DetectCardIRQDone + + Mov IRQ, 7 + +DetectCardIRQDone: + Cmp DMA, 0FFFFh + JNE DetectCardDMADone + + Mov DMA, 1 + +DetectCardDMADone: + Mov DX, BasePort + Cmp DX, 0FFFFh + JE DetectCardFindBasePort + + Call PingWSS + JNC CheckWSSOK + +DetectWSSFailure: + StC + Ret + +DetectCardFindBasePort: + Mov DX, 530h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0E80h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0F40h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 604h + Call PingWSS + JC DetectWSSFailure + +DetectWSSOK: + Mov BasePort, DX + +CheckWSSOK: + ; Check for valid IRQ + Mov BX, IRQ + Mov AL, [IRQSetupTable+BX] + Mov BX, DMA + Mov AH, [DMASetupTable+BX] + Test AL, AL + JZ DetectWSSFailure + Test AH, AH + JZ DetectWSSFailure + + Or AL, AH + Out DX, AL + + Add DX, WSS_BASE + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + PushAD + Push DS + Push ES + + ClD + + Mov AX, CS + Mov DS, AX + Assume DS:Driver + + Mov DX, [BasePort] + Add DX, 6 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Mov AX, MixBufferPos + Mov BX, AX + Mul DMASize + Cmp AX, DMABUFFERLENGTH + JB WSSIRQHandler2 + + Xor AX, AX + Xor BX, BX + +WSSIRQHandler2: + Inc BX + Mov MixBufferPos, BX + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, AX + + Mov BX, DMASize ; BX = bytes required + ShR BX, 1 + ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + Pop DS + PopAD + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + Add DX, WSS_BASE + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Add DX, WSS_BASE + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, DMASize + ShR AX, 1 + + Cmp Stereo, 0 + JE StartWSS2 + + ShR AX, 1 + +StartWSS2: + Dec AX + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far ; Fix up end of sample bytes + + PushAD + Push DS + Push ES + Push FS + + Mov FS, CS:SongDataArea + Mov BP, AX + Add BP, BP + Mov BP, [FS:64910+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC LoadSampleEnd ; Zero flag ON if 16 bit.. + + Xor EAX, EAX + Mov BL, [FS:BP+12h] + + Test BL, 10h ; Loop + JZ LoadSample2 + + Mov ESI, [FS:BP+34h] ; Start of loop + Test BL, 40h ; Pingpong? + JZ LoadSample1 + + Mov ESI, [FS:BP+38h] + Sub ESI, 2 + JNC LoadSample1 + + Xor ESI, ESI + +LoadSample1: + Test BL, 2 + JZ LoadSample4 + + Add ESI, ESI + +LoadSample4: + Call UpdateSampleLocation + Mov AL, [SI] + Inc ESI + Call UpdateSampleLocation + Mov AH, [SI] + +LoadSample2: + Mov ESI, [FS:BP+30h] + Test BL, 2 + JZ LoadSample3 + + Add ESI, ESI + +LoadSample3: + Call UpdateSampleLocation + Mov [SI], AL + Inc ESI + Call UpdateSampleLocation + Mov [SI], AH + +LoadSampleEnd: + Pop FS + Pop ES + Pop DS + PopAD + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DX, WSS_BASE + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/SoundDrivers/WSSDRV2.ASM b/SoundDrivers/WSSDRV2.ASM index 2cf2b8e..74fcc5d 100755 --- a/SoundDrivers/WSSDRV2.ASM +++ b/SoundDrivers/WSSDRV2.ASM @@ -1,2268 +1,2268 @@ -; -; Windows Sound System Driver -; - .386P - -Segment DriverHeader PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -;***** Driver Header ******* - -include drhead.inc - -EndS - -Segment Driver PARA Public 'Code' Use16 - Assume CS:Driver, DS:Nothing - -ORG 0 -StartDriver: - -include vtable.inc - -;******** Required ProcedureTable ************* - -include reqproc.inc - -;********************************** - -STEREOENABLED EQU 1 -DMABUFFERLENGTH EQU 8192 -MIXRESOLUTION EQU 32 ; 32 bit mixing for -MIXTABLESIZE EQU 2*256*65 -TIMERCONST EQU 11932 - -WSSMsg DB "Using Windows Sound System", 13 - DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 - -WSSNoMemoryMsg DB "Using Windows Sound System", 13 - DB "Error: Insufficient memory", 0 - -ReinitMsg DB "Windows Sound System reinitialised", 0 - -ConfigErrorMsg DB "Error saving configuration to ITWSS2.DRV", 0 -ConfigOKMsg DB "Configuration saved to ITWSS2.DRV", 0 - -DriverName DB "ITWSS2.DRV", 0 - -Forced DB 0 -Stereo DB 0 -MixVolume DW 0 - -BytesToMix DW 1000 -WSSMixConst DB 0 - -MixSegment DW 0 -DMASegment DW 0 - -MixTransferOffset DW 0 -MixTransferRemaining DW 0 - -CONFIGURATIONOFFSET EQU $+128 -CONFIGSIZE EQU 6 -MixMode DW 0 -MixModeOffset DW 0 -Filter DW 0 - -IMR DW 0 -OldTimerIRQHandler DD 0 -OldWSSIRQHandler DD 0 - -FilterValue DD 0 -FilterValue2 DD 0 -TimerAccumulator DW 0 - -MixSpeedTable DW 5513, 41h - DW 6615, 4Fh - DW 8000, 40h - DW 9600, 4Eh - DW 11025, 43h - DW 16000, 42h - DW 18900, 45h - DW 22050, 47h - DW 27429, 44h - DW 32000, 46h - DW 33075, 4Dh - DW 37800, 49h - DW 44100, 4Bh - DW 48000, 4Ch - DW 54860, 48h - DW 64000, 4Ah - -IRQSetupTable DB 0, 0, 0, 0, 0, 0, 0, 8 - DB 0, 10h, 18h, 20h, 0, 0, 0, 0 - -DMASetupTable DB 1, 2, 0, 3, 0, 0, 0, 0 - -DMALengthTable Label Byte - DB 1, 3, 5, 7, 0C2h, 0C6h, 0CAh, 0CEh - -IRQData Label Word - DW 20h, 1111111111111110b ; IRQ 0 - DW 24h, 1111111111111101b ; IRQ 1 - DW 28h, 1111110111111011b ; IRQ 2 - DW 2Ch, 1111111111110111b ; IRQ 3 - DW 30h, 1111111111101111b ; IRQ 4 - DW 34h, 1111111111011111b ; IRQ 5 - DW 38h, 1111111110111111b ; IRQ 6 - DW 3Ch, 1111111101111111b ; IRQ 7 - DW 1C0h, 1111111011111011b ; IRQ 8 - DW 1C4h, 1111110111111011b ; IRQ 9 - DW 1C8h, 1111101111111011b ; IRQ 10 - DW 1CCh, 1111011111111011b ; IRQ 11 - DW 1D0h, 1110111111111011b ; IRQ 12 - DW 1D4h, 1101111111111011b ; IRQ 13 - DW 1D8h, 1011111111111011b ; IRQ 14 - DW 1DCh, 0111111111111011b ; IRQ 15 - -;********************************** -; WSS Registers -;********************************** - -CODEC_INDEX_LIC = 00 -CODEC_INDEX_RIC = 01h -CODEC_INDEX_LX1C = 02h -CODEC_INDEX_RX1C = 03h -CODEC_INDEX_LX2C = 04h -CODEC_INDEX_RX2C = 05h -CODEC_INDEX_LDC = 06h -CODEC_INDEX_RDC = 07h -CODEC_INDEX_CDF = 08h -CODEC_INDEX_INTF = 09h -CODEC_INDEX_PIN = 0Ah -CODEC_INDEX_TEST = 0Bh -CODEC_INDEX_MISC = 0Ch -CODEC_INDEX_DIGMIX = 0Dh -CODEC_INDEX_UPR_COUNT = 0Eh -CODEC_INDEX_LWR_COUNT = 0Fh - -CODEC_MCE = 40h - -LDC_LDM = 80h -LDC_LDA = 3Fh - -RDC_RDM = 80h -RDC_RDA = 3Fh - -CDF_STEREO = 10h - -INTF_PEN = 01h -INTF_CEN = 02h -INTF_SDC = 04h -INTF_ACAL = 08h -INTF_PPIO = 40h -INTF_CPIO = 80h - -PIN_IEN = 2 - -TEST_ORL = 03h -TEST_ORR = 0Ch -TEST_DRS = 10h -TEST_ACI = 20h -TEST_PUR = 40h -TEST_COR = 80h - -WSS_INTF = 00h -WSS_CHIPID = 03h -WSS_BASE = 04h - -;********************************** - -WSS16ScreenList Label - DW 16 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyLink - - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr WSSHeaderLine - - DW Near Ptr DriverText - - DW Near Ptr MixModeText - DW Near Ptr MixModeButton1 ; 6 - DW Near Ptr MixModeButton2 ; - DW Near Ptr MixModeButton3 ; 8 - DW Near Ptr MixModeButton4 ; 9 - - DW Near Ptr FilterText - DW Near Ptr FilterButton1 ; 11 - DW Near Ptr FilterButton2 - DW Near Ptr FilterButton3 - - DW Near Ptr VolumeText - DW Near Ptr VolumeBox1 - - DW Near Ptr MasterVolumeLeft ; 16 - DW Near Ptr MasterVolumeRight ; 17 - - DW 0 - -WSSHeaderLine DW 10 - DB "Windows Sound System Driver", 0 - -EmptyObject DW 1 - DB 0, 0 - DB 0 - DB 0 - -DriverText DW 1 - DB 27, 48 - DB 21h - DB "Windows Sound System Driver 1.1 for Impulse Tracker", 0 - -GlobalKeyLink DB 7 -GlobalKeyLink2 DD 0 - -IdleFunctionList DD 0 - DD 0 - -FillHeader DW 8 -FillHeader2 DD 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 -ScreenHeader2 DD 0 - -VolumeText DW 1 - DB 2, 14 - DB 20h - DB "Master Volume Left", 13 - DB "Master Volume Right" - DB 0 - -VolumeBox1 DW 0 - DB 21, 13, 31, 16 - DB 25 - -MasterVolumeLeft DW 9 - DB 22, 14 - DW 0, 63 - DW 9, 0 - DW 0FFFFh, 17, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MasterVolumeRight DW 9 - DB 22, 15 - DW 0, 63 - DW 9, 1 - DW 16, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -MixModeText DW 1 - DB 2, 18 - DB 20h - DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 -MixSpeed DW 48000 - -MixModeButton1 DW 2 - DW 17, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment1 DW 0 - DW 0 - DW Offset SetMixMode -DriverSegment2 DW 0 - DB 3, 20, 32, 22, 8 - DB 0 - DB " 16 Bit, Non-Interpolated", 0 - -MixModeButton2 DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment3 DW 0 - DW 2 - DW Offset SetMixMode -DriverSegment4 DW 0 - DB 3, 23, 32, 25, 8 - DB 0 - DB " 16 Bit, Interpolated", 0 - -MixModeButton3 DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment5 DW 0 - DW 4 - DW Offset SetMixMode -DriverSegment6 DW 0 - DB 3, 26, 32, 28, 8 - DB 0 - DB " 32 Bit, Non-Interpolated", 0 - -MixModeButton4 DW 2 - DW 8, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetMixMode -DriverSegment7 DW 0 - DW 6 - DW Offset SetMixMode -DriverSegment8 DW 0 - DB 3, 29, 32, 31, 8 - DB 0 - DB " 32 Bit, Interpolated", 0 - -FilterText DW 1 - DB 2, 33 - DB 20h - DB "Filter mode", 0 - -FilterButton1 DW 2 - DW 9, 12, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment9 DW 0 - DW 0 - DW Offset SetFilter -DriverSegment10 DW 0 - DB 3, 35, 29, 37, 8 - DB 0 - DB " No Filter", 0 - -FilterButton2 DW 2 - DW 11, 13, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment11 DW 0 - DW 1 - DW Offset SetFilter -DriverSegment12 DW 0 - DB 3, 38, 29, 40, 8 - DB 0 - DB " 50% Filter", 0 - -FilterButton3 DW 2 - DW 12, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 6 - DW Offset GetFilter -DriverSegment13 DW 0 - DW 2 - DW Offset SetFilter -DriverSegment14 DW 0 - DB 3, 41, 29, 43, 8 - DB 0 - DB " 75% Filter", 0 - -VolumeTable DB 2 Dup (0) - -; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixBufferPos DW 0 - -include dma.inc -include mix.inc -include m12bit.mix -include m12biti.mix -include m32bit.mix -include m32biti.mix - -MixFunctionTables Label - -include m12bit.inc ; contains the tables -include m12biti.inc -include m32bit.inc -include m32biti.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -RelocationTable Label Word - DW Offset DriverSegment1, Offset DriverSegment2 - DW Offset DriverSegment3, Offset DriverSegment4 - DW Offset DriverSegment5, Offset DriverSegment6 - DW Offset DriverSegment7, Offset DriverSegment8 - DW Offset DriverSegment9, Offset DriverSegment10 - DW Offset DriverSegment11, Offset DriverSegment12 - DW Offset DriverSegment13, Offset DriverSegment14 - DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMixMode Far - - Push CS - Pop ES - Mov DI, Offset MixMode - - Ret - -EndP GetMixMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetFilter Far - - Push CS - Pop ES - Mov DI, Offset Filter - - Ret - -EndP GetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilter Far - - Mov AX, [SI+22] - Mov CS:FilterValue, 0 - Mov CS:Filter, AX - ClI - Jmp SetMixModeChain - -EndP SetFilter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitCoDec - - Push CX - - Mov CX, 0F000h - -WaitCoDec1: - In AL, DX - Test AL, AL - JNS WaitCoDec2 - Loop WaitCoDec1 - - StC - -WaitCoDec2: - Pop CX - Ret - -EndP WaitCoDec - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WaitAutoCalibration - - Push CX - Mov CX, 0F000h - -WaitAutoCalibration1: - Mov AL, CODEC_INDEX_TEST - Out DX, AL - Inc DX - In AL, DX - Dec DX - Test AL, TEST_ACI - JNZ WaitAutoCalibration2 - Loop WaitAutoCalibration1 - - StC - -WaitAutoCalibration2: - Pop CX - Ret - -EndP WaitAutoCalibration - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixMode Far - - Mov AX, [SI+22] - - ClI - - Mov CS:MixMode, AX - - Mov BX, 180 - Mul BX - Mov CS:MixModeOffset, AX - - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS:RecalculateAllVolumes - - StI - -SetMixModeChain: - Call GotoHomeDirectory - - ; Now to save config into driver file. - Push CS - Pop DS - Assume DS:Driver - - Mov AX, 3D02h ; Read write access - Mov DX, Offset DriverName - Mov SI, Offset ConfigErrorMsg - Int 21h - JC SetMixMode1 - - Mov BX, AX - - Mov AX, 4200h - Xor CX, CX - Mov DX, Offset CONFIGURATIONOFFSET - Int 21h - JC SetMixMode2 - - Mov AH, 40h - Mov CX, CONFIGSIZE - Mov DX, Offset MixMode - Int 21h - -SetMixMode2: - PushF - Mov AH, 3Eh - Int 21h - PopF - - JC SetMixMode1 - - Mov SI, Offset ConfigOKMsg - -SetMixMode1: - Mov BX, 40 - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP SetMixMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetWSSMixConst ; Work out value.. and nearest - ; mixspeed value. - - PushA - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, CmdLineMixSpeed - Mov CX, MixSpeed - Test AX, AX - JZ GetWSSMixConst1 - - Mov CX, 64000 - Cmp AX, CX - JA GetWSSMixConst1 - - Mov CX, 8000 - Cmp AX, CX - JB GetWSSMixConst1 - - Mov CX, AX - -GetWSSMixConst1: ; CX = desired mixspeed - Mov SI, Offset MixSpeedTable - Mov DX, 16 ; 16 different available speeds - - Xor BX, BX - -GetWSSMixConst2: - LodsW - Cmp AX, BX - JB GetWSSMixConst3 - Cmp AX, CX - JA GetWSSMixConst3 - - Mov BX, AX - Mov DH, [SI] - -GetWSSMixConst3: - LodsW ; Add SI, 2 - Dec DL - JNZ GetWSSMixConst2 - - Mov MixSpeed, BX - Mov WSSMixConst, DH - - Pop DS - PopA - Ret - -EndP GetWSSMixConst - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PingWSS ; Check BasePort, DX = BasePort - ; Preserves DX, destroys AX - - Push DX - - Add DX, WSS_CHIPID ; Check for valid Chip ID - In AL, DX - - And AL, 3Fh - JZ PingWSS1 - Cmp AL, 4 - JE PingWSS1 - Cmp AL, 0Fh - JE PingWSS1 - -PingWSSFailure: - Pop DX - - StC - Ret - -PingWSS1: - Add DX, 4+2-WSS_CHIPID - - In AL, DX - Xor AL, AL - Out DX, AL - - Sub DX, 2 ; DX = AD1848 Baseport - Call WaitCodec - JC PingWSSFailure - - In AL, DX - Test AL, AL - JS PingWSSFailure - - Mov AL, CODEC_INDEX_MISC - Out DX, AL - Inc DX ; DX = Data port - In AL, DX - Mov AH, AL ; AH = Revision - - Xor AL, AL ; Write 0 revision - Out DX, AL - In AL, DX - And AX, 8F8Fh - Cmp AL, AH - JNE PingWSSFailure - Dec DX ; DX = AD1848 baseport - - Mov AL, CODEC_MCE or CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - Mov AL, INTF_ACAL or INTF_SDC - Out DX, AL - Dec DX - - Call WaitAutoCalibration ; Returns carry if error - ; Carry clear if none. - -; JC PingWSSFailure - - Pop DX - Ret - -EndP PingWSS - -; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Returns carry set if error, else carry clear. Has to setup internal vars -; (eg. appropriate IRQ/DMA whatever). -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DetectCard Far - - Push CS - Pop DS - Assume DS:Driver - - Cmp IRQ, 0FFFFh - JNE DetectCardIRQDone - - Mov IRQ, 7 - -DetectCardIRQDone: - Cmp DMA, 0FFFFh - JNE DetectCardDMADone - - Mov DMA, 1 - -DetectCardDMADone: - Mov DX, BasePort - Cmp DX, 0FFFFh - JE DetectCardFindBasePort - - Call PingWSS - JNC CheckWSSOK - -DetectWSSFailure: - StC - Ret - -DetectCardFindBasePort: - Mov DX, 530h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0E80h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 0F40h - Call PingWSS - JNC DetectWSSOK - - Mov DX, 604h - Call PingWSS - JC DetectWSSFailure - -DetectWSSOK: - Mov BasePort, DX - -CheckWSSOK: - ; Check for valid IRQ - Mov BX, IRQ - Mov AL, [IRQSetupTable+BX] - Mov BX, DMA - Mov AH, [DMASetupTable+BX] - Test AL, AL - JZ DetectWSSFailure - Test AH, AH - JZ DetectWSSFailure - - Or AL, AH - Out DX, AL - - Add DX, WSS_BASE - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - Mov AH, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AX, 3F3Fh - Neg AL - Neg AH - Add AL, 3Fh - Add AH, 3Fh - Mov [Word Ptr VolumeTable], AX - - Mov AL, [DMALengthTable+BX] - Mov Byte Ptr [DMAPort1], AL - Mov Byte Ptr [DMAPort2], AL - - Mov AX, DMABUFFERLENGTH/2 - Cmp BX, 4 - JB DetectWSS2 - - ShR AX, 1 - -DetectWSS2: - Mov Word Ptr [DMABufferLength1], AX - Mov Word Ptr [DMABufferLength2], AX - - Mov EAX, 'Jeff' - ClC - Ret - -EndP DetectCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MixModeTable Label Word - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix0ModeMono, Mix0ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - DW Offset Mix6ModeMono, Mix6ModeStereo - -Proc MixSamples ; Given DS:SI = info tables, CX = numchannels - - ; 1. Clean buffer - ; + update variables - ; 2. Update parameters - ; 3. Mix func - ; 4. Return - - Push CX - - Mov CX, BytesToMix - Mov ES, MixSegment - Mov DI, MIXTABLESIZE - Xor EAX, EAX - Mov DX, CX - Add CX, CX - - Mov MixTransferOffset, DI ; } Memory write - - Cmp Stereo, 0 - JE MixSamples1 - - Mov DX, CX - -MixSamples1: - Rep StosD ; } Memory write - Mov MixTransferRemaining, DX ; } - - Pop CX - -MixSamples2: - Test Byte Ptr [SI], 1 - JZ MixSamplesEnd2 - Cmp Byte Ptr [SI+36h], 100 - JE MixSamplesEnd2 - - Push CX - Mov CX, [SI] - - Test CH, 2 - JZ MixSamples3 - And Byte Ptr [SI], Not 1 - - Jmp MixSamplesEnd -; Cmp MixMode, 8 ; Is it volume ramping? -; JB MixSamplesEnd - -MixSamples3: - Test CL, 20h ; New freq? - JZ MixSamples5 - - Mov AX, [SI+10h] - Mov DX, [SI+12h] - Mov BX, MixSpeed - Cmp DX, BX - JAE MixSamplesHandleError - - Div BX - ShL EAX, 16 - Xor AX, AX - Div BX - Mov STEPVALUE, EAX - -MixSamples4: - Test CH, 1 - JZ MixSamples5 - - Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 - ; for volume sliding. -MixSamples5: - Test CX, 8440h ; New volume or panning? - JZ MixSamplesMix - - Xor AX, AX - Test CH, 8 ; Muted? - JNZ MixModeCommon - - Mov BX, MixMode - Add BL, Stereo - Add BX, BX - Jmp [CS:MixModeTable+BX] - -Mix0Mode: ; 16-bit mixing, no interpolation -Mix0ModeMono: ; and 16-bit mixing, interpolation - Mov AL, [SI+20h] - ShR AL, 1 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 30 ; Use left only-mixing for mono - Jmp MixModeCommon - -Mix0ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix0ModeSurround - - Mul Byte Ptr [SI+20h] ; Final volume - Add AX, 64 - ShR AX, 7 - Mov [SI+0Ch], AX ; Store into right volume - - Mov AL, 64 - Sub AL, [SI+37h] - Mul Byte Ptr [SI+20h] - Add AX, 64 - ShR AX, 7 - Mov [SI+0Eh], AX ; Left volume - - Mov CH, AL ; CH = left volume - Mov CL, [SI+0Ch] ; CL = right volume - Mov AX, 0 - - Test CX, CX - JZ MixModeCommon - - Mov AL, 30 ; Left only... - Test CL, CL - JZ MixModeCommon - - Mov AL, 60 - Test CH, CH - JZ MixModeCommon - - Mov AL, 90 - Cmp CL, CH - JZ MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix0ModeSurround: - Mov AL, [SI+20h] - ShR AL, 2 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Mov AX, 0 - JZ MixModeCommon - Mov AL, 150 ; Surround - Jmp MixModeCommon - -Mix6ModeMono: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 8 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - Test AX, AX - JZ MixModeCommon - Mov AX, 30 - Jmp MixModeCommon - -Mix6ModeStereo: - Mov AL, [SI+37h] ; Final pan - Cmp AL, 100 - JE Mix6ModeSurround - - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Ch], AX ; Store into right volume - Mov BX, AX - ShL EAX, 16 - - Mov AL, 64 ; Do left volume - Sub AL, [SI+37h] ; AL = 64-FinalPan - Mul Byte Ptr MixVolume - Mul Word Ptr [SI+4Ah] - ShRD AX, DX, 14 - Mov [SI+0Eh], AX - - Mov ECX, EAX - - ; BX = right volume - ; CX = Left volume - Mov AX, 0 - Test ECX, ECX - JZ MixModeCommon - - Mov AL, 30 - Test BX, BX - JZ MixModeCommon - - Mov AL, 60 - Test CX, CX - JZ MixModeCommon - - Mov AL, 90 - Cmp CX, BX - JE MixModeCommon - - Mov AL, 120 - Jmp MixModeCommon - -Mix6ModeSurround: - Mov AX, [SI+4Ah] - Mul MixVolume - ShRD AX, DX, 9 - Mov [SI+0Ch], AX - Mov [SI+0Eh], AX - JZ MixModeCommon - Mov AX, 150 - Jmp MixModeCommon - -MixModeCommon: ; Requires AX = 30/60/90 etc. depending - ; On mixing mode type. - ; This will add 180 for 16-bit, - ; And sort out loop types. - Mov BL, [SI+0Ah] - Test Byte Ptr [SI+18h], 2 ; 16 bit? - JZ MixModeCommon1 - - Add AX, 180 - -MixModeCommon1: - Cmp BL, 8 - JB MixModeCommon3 ; No loop - JE MixModeCommon2 ; Forwards loop - - Add AX, 10 - -MixModeCommon2: - Add AX, 10 - -MixModeCommon3: - Add AX, Offset MixFunctionTables - Add AX, MixModeOffset - Mov [SI+8], AX ; Offset... - -MixSamplesMix: - Mov BX, [SI+8] ; BX = offset into - Mov EAX, [CS:BX+2] - Mov DWord Ptr PreMixFunction, EAX - Mov EAX, [CS:BX+6] - Mov DWord Ptr MixFunctionSeparateBackwards, EAX - - Mov AX, BytesToMix - Mov MixBlockSize, AX - Mov MixBufferOffset, MIXTABLESIZE - - Mov EAX, CURRENTPOSITION - Mov OLDPOSITION, EAX - - Call Word Ptr [CS:BX] - - And Word Ptr [SI], 0111100010001101b - Jmp MixSamplesEnd - -MixSamplesHandleError: - Mov Word Ptr [SI], 200h - - Test Byte Ptr [SI+3Ah], 80h - JNZ MixSamplesEnd - - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 ; Turn off channel - -MixSamplesEnd: - Pop CX - -MixSamplesEnd2: - Add SI, 128 - Dec CX - JNZ MixSamples2 - - Ret - -EndP MixSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSIRQHandler - - Push AX - Push BX - Push DS - - Push CS - Pop DS - Assume DS:Driver - - Add TimerAccumulator, TIMERCONST - JC WSSIRQHandler11 - - Mov AL, 20h - Out 20h, AL - Jmp WSSIRQHandler12 - -WSSIRQHandler11: - PushF - Call [OldTimerIRQHandler] - -WSSIRQHandler12: - -DMAPort1 EQU $+1 - In AL, 1 - Mov AH, AL -DMAPort2 EQU $+1 - In AL, 1 - XChg AL, AH - - Cmp MixBufferPos, 0 - JE WSSIRQHandler13 - - Xor BX, BX -DMABufferLength1 EQU $+1 - Cmp AX, 1234h - JB WSSIRQHandler1 - - Pop DS - Pop BX - Pop AX - IRet - -WSSIRQHandler13: - Mov BX, DMABUFFERLENGTH/2 -DMABufferLength2 EQU $+1 - Cmp AX, 1234h - JAE WSSIRQHandler1 - - Pop DS - Pop BX - Pop AX - IRet - -WSSIRQHandler1: - Xor MixBufferPos, 1 - - PushAD - Push ES - - CLD - - - ; OK... time to get next block - ; Check whether stereo thing is on.. - ; - LES DI, [ActualDMAPtr] - Add DI, BX - - Mov BX, DMABUFFERLENGTH/4 ; BX = samples required - Mov BP, 8 ; Skip for mono - Mov CL, 14 ; Shift for mono - - Cmp Stereo, 0 - JE WSSIRQHandlerMono - - Mov BP, 4 ; Stereo skip value. - Dec CL - -WSSIRQHandlerMono: - Call SaveEMSPageFrame - - Cmp MixTransferRemaining, 0 - JNE WSSIRQHandler4 - Assume DS:Nothing - -WSSIRQHandler3: - Push BX - Push CX - Push BP - Push ES - Push DI - - Call Update - Call MixSamples - - Pop DI - Pop ES - Pop BP - Pop CX - Pop BX - -WSSIRQHandler4: - Mov DS, MixSegment - Mov SI, MixTransferOffset - Mov DX, BX ; DX = samples to transfer - Cmp DX, MixTransferRemaining - JBE WSSIRQHandler5 - - Mov DX, MixTransferRemaining - -WSSIRQHandler5: - Push DX - Cmp CS:Filter, 1 - JB WSSIRQHandler6 - JE WSSIRQHFilter - - Cmp CS:Stereo, 0 - JE WSSIRQ3QFilterMono - -WSSIRQ3QFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQ3QFilterStereo1: - Mov EAX, EBX - Mov ECX, EBP - Add EAX, [SI] - Add ECX, [SI+4] - SAR EAX, 1 - SAR ECX, 1 - Add EBX, EAX - Add EBP, ECX - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip2 - -WSSIRQ3QFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSS3QFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSS3QFilterStereoClip4 - -WSSIRQ3QFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQ3QFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQ3QFilterMono1: - Mov EAX, EBX - Add EAX, [SI] - SAR EAX, 1 - Add EBX, EAX - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSS3QFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSS3QFilterMonoClip2 - -WSSIRQ3QFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQ3QFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilter: - Cmp CS:Stereo, 0 - JE WSSIRQHFilterMono - -WSSIRQHFilterStereo: - Push BX - - Mov EBX, FilterValue - Mov EBP, FilterValue2 - ShR DX, 1 - -WSSIRQHFilterStereo1: - Add EBX, [SI] - Add EBP, [SI+4] - - SAR EBX, 1 - SAR EBP, 1 - - Mov EAX, EBX - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip2 - -WSSIRQHFilterStereo2: - StosW - - Mov EAX, EBP - SAR EAX, 13 - - Cmp EAX, -8000h - JL WSSHFilterStereoClip3 - Cmp EAX, 7FFFh - JG WSSHFilterStereoClip4 - -WSSIRQHFilterStereo3: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterStereo1 - - Mov FilterValue, EBX - Mov FilterValue2, EBP - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHFilterMono: - Push BX - - Mov EBX, FilterValue - -WSSIRQHFilterMono1: - Add EBX, [SI] - SAR EBX, 1 - Mov EAX, EBX - SAR EAX, 14 - - Cmp EAX, -8000h - JL WSSHFilterMonoClip1 - Cmp EAX, 7FFFh - JG WSSHFilterMonoClip2 - -WSSIRQHFilterMono2: - StosW - - Add SI, 8 - Dec DX - JNZ WSSIRQHFilterMono1 - - Mov FilterValue, EBX - - Pop BX - - Jmp WSSMixTransferEnd - -WSSIRQHandler6: - Mov EAX, [SI] - SAR EAX, CL - - Cmp EAX, -8000h - JL WSSIRQHandlerClip1 - Cmp EAX, 7FFFh - JG WSSIRQHandlerClip2 - -WSSIRQHandler7: - StosW ; } Memory write - - Add SI, BP - Dec DX - JNZ WSSIRQHandler6 - -WSSMixTransferEnd: - Pop DX - - Sub MixTransferRemaining, DX ; } Memory write - Sub BX, DX - JNZ WSSIRQHandler3 - - Mov MixTransferOffset, SI ; } Memory write - - Call RestoreEMSPageFrame - - Pop ES - PopAD - Pop DS - Pop BX - Pop AX - IRet - -WSSIRQHandlerClip1: - Mov AX, 8000h - Jmp WSSIRQHandler7 - -WSSIRQHandlerClip2: - Mov AX, 7FFFh - Jmp WSSIRQHandler7 - -WSSHFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterMono2 - -WSSHFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterMono2 - -WSSHFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo2 - -WSSHFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQHFilterStereo3 - -WSSHFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQHFilterStereo3 - -WSS3QFilterMonoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterMonoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterMono2 - -WSS3QFilterStereoClip1: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip2: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo2 - -WSS3QFilterStereoClip3: - Mov AX, 8000h - Jmp WSSIRQ3QFilterStereo3 - -WSS3QFilterStereoClip4: - Mov AX, 7FFFh - Jmp WSSIRQ3QFilterStereo3 - -EndP WSSIRQHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WSSAckIRQ - - Push AX - Push DX - - Mov DX, [CS:BasePort] - Add DX, 6 - In AL, DX - Test AL, 1 - JZ WSSAckIRQ2 - - Xor AL, AL - Out DX, AL - -WSSAckIRQ2: - Mov AL, 20h - Cmp CS:IRQ, 8 - JB WSSAckIRQ1 - - Out 0A0h, AL - -WSSAckIRQ1: - Out 20h, AL - - Pop DX - Pop AX - - IRet - -EndP WSSAckIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - ; bump the interrupt to be called - ; 100 times a second. - Mov AX, TIMERCONST - Out 40h, AL - Mov AL, AH - Out 40h, AL - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSIRQHandler - - ClI - - XChg [ES:20h], EAX ; Hook to timer interrupt - Mov CS:OldTimerIRQHandler, EAX - - StI - - ; Now hook WSS ACK IRQ - Mov DI, IRQ - ShL DI, 2 - Add DI, Offset IRQData - Mov BX, [CS:DI] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset WSSACKIRQ - - XChg [ES:BX], EAX - Mov OldWSSIRQHandler, EAX - - Mov AX, IMR - And AX, [DI+2] - - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Pop ES - PopAD - - Ret - -EndP SetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetIRQ - - PushAD - Push ES - - Xor AX, AX - Mov ES, AX - - Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen - Out 43h, AL - - Xor AL, AL - Out 40h, AL ; Interrupt called at normal 18.2 times - Out 40h, AL - - Mov EAX, CS:OldTimerIRQHandler - Mov [ES:20h], EAX - - Mov DI, IRQ - ShL DI, 2 - Mov BX, [IRQData+DI] - - Mov EAX, OldWSSIRQHandler - Mov [ES:BX], EAX - - Pop ES - PopAD - - Ret - -EndP ResetIRQ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StopWSS - - Mov DX, BasePort - Add DX, WSS_BASE - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - And AL, Not INTF_PEN - Out DX, AL - - Inc DX - In AL, DX - Xor AL, AL - Out DX, AL - - Dec DX - Dec DX - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Xor AL, AL - Out DX, AL - - Ret - -EndP StopWSS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartWSS - - PushA - Push ES - Push DS - - Push CS - Pop DS - Assume DS:Driver - - ; Setup DMA - Mov BX, DMASegment - Xor AX, AX - Mov DX, DMA - Mov DI, DMABUFFERLENGTH - Call SetDMA - - LES DI, ActualDMAPtr - Xor AX, AX - Mov CX, DMABUFFERLENGTH/2 - Rep StosW - - Mov MixBufferPos, 0 - Mov MixTransferRemaining, 0 - - Mov DX, BasePort - Call PingWSS - - Add DX, WSS_BASE - - Mov AL, CODEC_INDEX_PIN - Out DX, AL - Inc DX - Mov AL, PIN_IEN - Out DX, AL - Dec DX - - Mov AH, WSSMixConst ; Set format/frequency - Cmp Stereo, 0 - JE StartWSS1 - - Or AH, CDF_STEREO - -StartWSS1: - Mov AL, CODEC_MCE or CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitCodec - - Mov AL, CODEC_INDEX_CDF - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Call WaitAutoCalibration - - ; Start playback - Mov AL, CODEC_INDEX_LWR_COUNT - Out DX, AL - Inc DX - - Mov AX, 0FFFFh - - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_UPR_COUNT - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_INTF - Out DX, AL - Inc DX - In AL, DX - Or AL, INTF_PEN - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not LDC_LDM - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - In AL, DX - And AL, Not RDC_RDM - Out DX, AL - Dec DX - - Pop DS - Pop ES - PopA - - Ret - -EndP StartWSS - Assume DS:Nothing - -;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Sets up any memory required for output -; Initiates output -; -; Parameters: AX = Number of Channels -; -; If sucessful, returns: -; Carry flag clear -; DS:SI = pointer to text to display -; AX = parameter 1 in text -; BX = parameter 2 in text -; CX = parameter 3 in text -; DX = parameter 4 in text -; DI = parameter 5 in text -; -; If unsucessful, returns: -; Carry flag set -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov SI, Offset RelocationTable - -RelocationFix: - LodsW - Test AX, AX - JZ RelocationEnd - Mov BX, AX - Mov [BX], DS - Jmp RelocationFix - - -RelocationEnd: - Call GetEMSPageFrame - Mov EMSPageFrame, AX - - In AL, 0A1h - Mov AH, AL - In AL, 21h - Mov IMR, AX - - Mov ECX, IdleUpdateInfoLine - Mov EDX, GlobalKeyList - Mov IdleFunctionList, ECX - Mov GlobalKeyLink2, EDX - - Mov ECX, FillHeaderFunction - Mov EDX, DrawHeaderFunction - Mov FillHeader2, ECX - Mov ScreenHeader2, EDX - - Call GetWSSMixConst - - Mov AX, 2643 - Mul MixSpeed - Add AX, 0FFFFh - AdC DX, 2080 - - Mov BX, (DMABUFFERLENGTH*2)/16 - Add BX, DX - - ; Allocate MixSegment first - Mov AH, 48h - - Int 21h - JNC InitSound1 - -InitSoundNoMemory: - Mov SI, Offset WSSNoMemoryMsg - Ret - -InitSound1: - Mov MixSegment, AX - Add AX, DX - Mov DMASegment, AX - - Call SetIRQ - Call GetTempo - Call SetTempo - - Mov SI, Offset WSSMsg - - Mov AX, BasePort - Mov BX, IRQ - Mov CX, DMA - - Ret - -EndP InitSound - Assume DS:Nothing - -;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Reinitialises sound output -; Initiates sound output -; -; Parameters: AX = number of channels. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReInitSound Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Driver - - Call ResetIRQ - Call SetIRQ - - Mov SI, Offset ReInitMsg - Mov BX, 40 - Call SetInfoLine - - Mov AL, Stereo - Call SetStereo - - Pop ES - Pop DS - PopA - - Ret - -EndP ReInitSound - Assume DS:Nothing - -;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Stops sound output, releases any memory used by driver -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitSound Far - - Push CS - Pop DS - Assume DS:Driver - - Mov AX, IMR - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - Mov AX, MixSegment - Test AX, AX - JZ UnInitSound1 - - Mov ES, AX - Mov AH, 49h ; Release MixSegment - Int 21h - - Call StopWSS - Call ResetIRQ - -UnInitSound1: - Ret - -EndP UnInitSound - Assume DS:Nothing - -;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; This procedure is called as often as possible by IT.EXE -; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Poll Far - - Ret - -EndP Poll - -;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: BX = tempo -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetTempo Far - - Push AX - Push BX - Push DX - - Push BX - - Mov AX, MixSpeed - Mov BX, AX - Xor DX, DX - - ShL AX, 1 - RCL DX, 1 ; DX:AX = Mixspeed*2 - - ShR BX, 1 ; BX = Mixspeed/2 - - Add AX, BX - AdC DX, 0 ; DX:AX = Mixspeed*2.5 - - Pop BX ; BX = tempo - Div BX - - Mov BytesToMix, AX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP SetTempo - -;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = MixVolume -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMixVolume Far - - PushA - Push DS - - Mov BX, AX ; BX = MixVolume - Mov CS:MixVolume, BX - - Mov AX, CS:MixSegment - Test AX, AX - JZ SetMixVolume2 - - Mov DS, AX - - Mov CX, MIXTABLESIZE/2 - Mov SI, MIXTABLESIZE-2; Starting point - working backwards - -SetMixVolume1: - Mov AX, CX - - Dec AX ; AH = volume, AL = wave value. - Xor DX, DX - XChg AH, DL ; DL = Volume, AX = wave value - CBW - - IMul DX ; DX:AX = Volume * Wave Value - ; Ranges -8192->8128 - - IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume - ; Ranges -1048576->1040384 - - Add AX, 64 - AdC DX, 0 - - ShRD AX, DX, 7 - Mov [SI], AX - Sub SI, 2 - - Loop SetMixVolume1 - -SetMixVolume2: - Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] - Call CS: RecalculateAllVolumes - - Pop DS - PopA - - Ret - -EndP SetMixVolume - -;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AL = Stereo on/off, 0 = off. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RecalculateAllFrequencies - - Call GetChannelTables - -RecalculateAllFrequencies1: - Or Byte Ptr [SI], 32 - - Add SI, 128 - Dec CX - JNZ RecalculateAllFrequencies1 - - Ret - -EndP RecalculateAllFrequencies - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetStereo Far - - Mov CS:Stereo, AL - Cmp CS:MixSegment, 0 - JE SetStereo1 - - Call StopWSS - Call StartWSS - - Call RecalculateAllFrequencies - -SetStereo1: - Ret - -EndP SetStereo - -;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to load -; DS:SI points to sample header -; ES:0 points to first sample -; -; Returns: **Carry set if NO error** -; **Carry clear if error** -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSample Far ; Fix up end of sample bytes - - PushAD - Push DS - Push ES - Push FS - - Mov FS, CS:SongDataArea - Mov BP, AX - Add BP, BP - Mov BP, [FS:64910+BP] - - Xor CX, CX ; From the start of the sample.. - Call GetSampleLocation ; Returns DS:ESI, ECX = length - JC LoadSampleEnd ; Zero flag ON if 16 bit.. - - Xor EAX, EAX - Mov BL, [FS:BP+12h] - - Test BL, 10h ; Loop - JZ LoadSample2 - - Mov ESI, [FS:BP+34h] ; Start of loop - Test BL, 40h ; Pingpong? - JZ LoadSample1 - - Mov ESI, [FS:BP+38h] - Sub ESI, 2 - JNC LoadSample1 - - Xor ESI, ESI - -LoadSample1: - Test BL, 2 - JZ LoadSample4 - - Add ESI, ESI - -LoadSample4: - Call UpdateSampleLocation - Mov AL, [SI] - Inc ESI - Call UpdateSampleLocation - Mov AH, [SI] - -LoadSample2: - Mov ESI, [FS:BP+30h] - Test BL, 2 - JZ LoadSample3 - - Add ESI, ESI - -LoadSample3: - Call UpdateSampleLocation - Mov [SI], AL - Inc ESI - Call UpdateSampleLocation - Mov [SI], AH - -LoadSampleEnd: - Pop FS - Pop ES - Pop DS - PopAD - - StC - Ret - -EndP LoadSample - -;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Parameters: AX = sample to release -; DS:SI points to sample header -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseSample Far - - Ret - -EndP ReleaseSample - -;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetMemory Far - - Ret - -EndP ResetMemory - -;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Frees all on-board memory -; -; Returns text to show on status line, AX = display parameter -; Carry set if not to show anything. -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStatus Far - - StC - Ret - -EndP GetStatus - -;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Function to have driver interactive part of program -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoundCardScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, CS - Mov DX, Offset WSS16ScreenList - - ClC - Ret - -EndP SoundCardScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetVariable Far - - Xor AH, AH - Mov AL, [CS:VolumeTable+DI] - Ret - -EndP GetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetVariable Far - - Push DS - Push DX - - Push CS - Pop DS - Assume DS:Driver - - Mov [VolumeTable+DI], AL - - Mov DX, BasePort - Add DX, WSS_BASE - - Mov AL, CODEC_INDEX_LDC - Out DX, AL - Inc DX - Mov AX, 3F3Fh - Sub AX, [Word Ptr VolumeTable] - Out DX, AL - Dec DX - - Mov AL, CODEC_INDEX_RDC - Out DX, AL - Inc DX - Mov AL, AH - Out DX, AL - Dec DX - - Pop DX - Pop DS - Ret - -EndP SetVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndDriver: - -;******** Provided Variable Table ************* - -MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the - ; driver can handle. - -StopAfterPlay DW 0 -DefaultChannels DW 64 - DW 5 Dup (0) - - -;******** Provided Procedure Table ************* - -ProvidedTableStart: - - DW Offset DetectCard - - DW Offset InitSound ; Playing related - DW Offset ReinitSound - DW Offset UninitSound - - DW Offset Poll - - DW Offset SetTempo ; Sound variable related - DW Offset SetMixVolume - DW Offset SetStereo - - DW Offset LoadSample ; Sample related - DW Offset ReleaseSample - DW Offset ResetMemory - DW Offset GetStatus ; Returns string to show on status line - - DW Offset SoundCardScreen ; Sound card 'screen' - - DW Offset GetVariable ; For interface - DW Offset SetVariable - -ProvidedTableEnd: - DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) - -EndS - -End +; +; Windows Sound System Driver +; + .386P + +Segment DriverHeader PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +;***** Driver Header ******* + +include drhead.inc + +EndS + +Segment Driver PARA Public 'Code' Use16 + Assume CS:Driver, DS:Nothing + +ORG 0 +StartDriver: + +include vtable.inc + +;******** Required ProcedureTable ************* + +include reqproc.inc + +;********************************** + +STEREOENABLED EQU 1 +DMABUFFERLENGTH EQU 8192 +MIXRESOLUTION EQU 32 ; 32 bit mixing for +MIXTABLESIZE EQU 2*256*65 +TIMERCONST EQU 11932 + +WSSMsg DB "Using Windows Sound System", 13 + DB "Port ", 0FDh, "Xh, IRQ ", 0FDh, "D, DMA ", 0FDh, "D", 0 + +WSSNoMemoryMsg DB "Using Windows Sound System", 13 + DB "Error: Insufficient memory", 0 + +ReinitMsg DB "Windows Sound System reinitialised", 0 + +ConfigErrorMsg DB "Error saving configuration to ITWSS2.DRV", 0 +ConfigOKMsg DB "Configuration saved to ITWSS2.DRV", 0 + +DriverName DB "ITWSS2.DRV", 0 + +Forced DB 0 +Stereo DB 0 +MixVolume DW 0 + +BytesToMix DW 1000 +WSSMixConst DB 0 + +MixSegment DW 0 +DMASegment DW 0 + +MixTransferOffset DW 0 +MixTransferRemaining DW 0 + +CONFIGURATIONOFFSET EQU $+128 +CONFIGSIZE EQU 6 +MixMode DW 0 +MixModeOffset DW 0 +Filter DW 0 + +IMR DW 0 +OldTimerIRQHandler DD 0 +OldWSSIRQHandler DD 0 + +FilterValue DD 0 +FilterValue2 DD 0 +TimerAccumulator DW 0 + +MixSpeedTable DW 5513, 41h + DW 6615, 4Fh + DW 8000, 40h + DW 9600, 4Eh + DW 11025, 43h + DW 16000, 42h + DW 18900, 45h + DW 22050, 47h + DW 27429, 44h + DW 32000, 46h + DW 33075, 4Dh + DW 37800, 49h + DW 44100, 4Bh + DW 48000, 4Ch + DW 54860, 48h + DW 64000, 4Ah + +IRQSetupTable DB 0, 0, 0, 0, 0, 0, 0, 8 + DB 0, 10h, 18h, 20h, 0, 0, 0, 0 + +DMASetupTable DB 1, 2, 0, 3, 0, 0, 0, 0 + +DMALengthTable Label Byte + DB 1, 3, 5, 7, 0C2h, 0C6h, 0CAh, 0CEh + +IRQData Label Word + DW 20h, 1111111111111110b ; IRQ 0 + DW 24h, 1111111111111101b ; IRQ 1 + DW 28h, 1111110111111011b ; IRQ 2 + DW 2Ch, 1111111111110111b ; IRQ 3 + DW 30h, 1111111111101111b ; IRQ 4 + DW 34h, 1111111111011111b ; IRQ 5 + DW 38h, 1111111110111111b ; IRQ 6 + DW 3Ch, 1111111101111111b ; IRQ 7 + DW 1C0h, 1111111011111011b ; IRQ 8 + DW 1C4h, 1111110111111011b ; IRQ 9 + DW 1C8h, 1111101111111011b ; IRQ 10 + DW 1CCh, 1111011111111011b ; IRQ 11 + DW 1D0h, 1110111111111011b ; IRQ 12 + DW 1D4h, 1101111111111011b ; IRQ 13 + DW 1D8h, 1011111111111011b ; IRQ 14 + DW 1DCh, 0111111111111011b ; IRQ 15 + +;********************************** +; WSS Registers +;********************************** + +CODEC_INDEX_LIC = 00 +CODEC_INDEX_RIC = 01h +CODEC_INDEX_LX1C = 02h +CODEC_INDEX_RX1C = 03h +CODEC_INDEX_LX2C = 04h +CODEC_INDEX_RX2C = 05h +CODEC_INDEX_LDC = 06h +CODEC_INDEX_RDC = 07h +CODEC_INDEX_CDF = 08h +CODEC_INDEX_INTF = 09h +CODEC_INDEX_PIN = 0Ah +CODEC_INDEX_TEST = 0Bh +CODEC_INDEX_MISC = 0Ch +CODEC_INDEX_DIGMIX = 0Dh +CODEC_INDEX_UPR_COUNT = 0Eh +CODEC_INDEX_LWR_COUNT = 0Fh + +CODEC_MCE = 40h + +LDC_LDM = 80h +LDC_LDA = 3Fh + +RDC_RDM = 80h +RDC_RDA = 3Fh + +CDF_STEREO = 10h + +INTF_PEN = 01h +INTF_CEN = 02h +INTF_SDC = 04h +INTF_ACAL = 08h +INTF_PPIO = 40h +INTF_CPIO = 80h + +PIN_IEN = 2 + +TEST_ORL = 03h +TEST_ORR = 0Ch +TEST_DRS = 10h +TEST_ACI = 20h +TEST_PUR = 40h +TEST_COR = 80h + +WSS_INTF = 00h +WSS_CHIPID = 03h +WSS_BASE = 04h + +;********************************** + +WSS16ScreenList Label + DW 16 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyLink + + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr WSSHeaderLine + + DW Near Ptr DriverText + + DW Near Ptr MixModeText + DW Near Ptr MixModeButton1 ; 6 + DW Near Ptr MixModeButton2 ; + DW Near Ptr MixModeButton3 ; 8 + DW Near Ptr MixModeButton4 ; 9 + + DW Near Ptr FilterText + DW Near Ptr FilterButton1 ; 11 + DW Near Ptr FilterButton2 + DW Near Ptr FilterButton3 + + DW Near Ptr VolumeText + DW Near Ptr VolumeBox1 + + DW Near Ptr MasterVolumeLeft ; 16 + DW Near Ptr MasterVolumeRight ; 17 + + DW 0 + +WSSHeaderLine DW 10 + DB "Windows Sound System Driver", 0 + +EmptyObject DW 1 + DB 0, 0 + DB 0 + DB 0 + +DriverText DW 1 + DB 27, 48 + DB 21h + DB "Windows Sound System Driver 1.1 for Impulse Tracker", 0 + +GlobalKeyLink DB 7 +GlobalKeyLink2 DD 0 + +IdleFunctionList DD 0 + DD 0 + +FillHeader DW 8 +FillHeader2 DD 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 +ScreenHeader2 DD 0 + +VolumeText DW 1 + DB 2, 14 + DB 20h + DB "Master Volume Left", 13 + DB "Master Volume Right" + DB 0 + +VolumeBox1 DW 0 + DB 21, 13, 31, 16 + DB 25 + +MasterVolumeLeft DW 9 + DB 22, 14 + DW 0, 63 + DW 9, 0 + DW 0FFFFh, 17, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MasterVolumeRight DW 9 + DB 22, 15 + DW 0, 63 + DW 9, 1 + DW 16, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +MixModeText DW 1 + DB 2, 18 + DB 20h + DB "Mixing Mode, Playback Frequency: ", 0FDh, "DHz", 0 +MixSpeed DW 48000 + +MixModeButton1 DW 2 + DW 17, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment1 DW 0 + DW 0 + DW Offset SetMixMode +DriverSegment2 DW 0 + DB 3, 20, 32, 22, 8 + DB 0 + DB " 16 Bit, Non-Interpolated", 0 + +MixModeButton2 DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment3 DW 0 + DW 2 + DW Offset SetMixMode +DriverSegment4 DW 0 + DB 3, 23, 32, 25, 8 + DB 0 + DB " 16 Bit, Interpolated", 0 + +MixModeButton3 DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment5 DW 0 + DW 4 + DW Offset SetMixMode +DriverSegment6 DW 0 + DB 3, 26, 32, 28, 8 + DB 0 + DB " 32 Bit, Non-Interpolated", 0 + +MixModeButton4 DW 2 + DW 8, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetMixMode +DriverSegment7 DW 0 + DW 6 + DW Offset SetMixMode +DriverSegment8 DW 0 + DB 3, 29, 32, 31, 8 + DB 0 + DB " 32 Bit, Interpolated", 0 + +FilterText DW 1 + DB 2, 33 + DB 20h + DB "Filter mode", 0 + +FilterButton1 DW 2 + DW 9, 12, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment9 DW 0 + DW 0 + DW Offset SetFilter +DriverSegment10 DW 0 + DB 3, 35, 29, 37, 8 + DB 0 + DB " No Filter", 0 + +FilterButton2 DW 2 + DW 11, 13, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment11 DW 0 + DW 1 + DW Offset SetFilter +DriverSegment12 DW 0 + DB 3, 38, 29, 40, 8 + DB 0 + DB " 50% Filter", 0 + +FilterButton3 DW 2 + DW 12, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 6 + DW Offset GetFilter +DriverSegment13 DW 0 + DW 2 + DW Offset SetFilter +DriverSegment14 DW 0 + DB 3, 41, 29, 43, 8 + DB 0 + DB " 75% Filter", 0 + +VolumeTable DB 2 Dup (0) + +; ÄÄ MixingRoutines ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixBufferPos DW 0 + +include dma.inc +include mix.inc +include m12bit.mix +include m12biti.mix +include m32bit.mix +include m32biti.mix + +MixFunctionTables Label + +include m12bit.inc ; contains the tables +include m12biti.inc +include m32bit.inc +include m32biti.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +RelocationTable Label Word + DW Offset DriverSegment1, Offset DriverSegment2 + DW Offset DriverSegment3, Offset DriverSegment4 + DW Offset DriverSegment5, Offset DriverSegment6 + DW Offset DriverSegment7, Offset DriverSegment8 + DW Offset DriverSegment9, Offset DriverSegment10 + DW Offset DriverSegment11, Offset DriverSegment12 + DW Offset DriverSegment13, Offset DriverSegment14 + DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMixMode Far + + Push CS + Pop ES + Mov DI, Offset MixMode + + Ret + +EndP GetMixMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetFilter Far + + Push CS + Pop ES + Mov DI, Offset Filter + + Ret + +EndP GetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilter Far + + Mov AX, [SI+22] + Mov CS:FilterValue, 0 + Mov CS:Filter, AX + ClI + Jmp SetMixModeChain + +EndP SetFilter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitCoDec + + Push CX + + Mov CX, 0F000h + +WaitCoDec1: + In AL, DX + Test AL, AL + JNS WaitCoDec2 + Loop WaitCoDec1 + + StC + +WaitCoDec2: + Pop CX + Ret + +EndP WaitCoDec + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WaitAutoCalibration + + Push CX + Mov CX, 0F000h + +WaitAutoCalibration1: + Mov AL, CODEC_INDEX_TEST + Out DX, AL + Inc DX + In AL, DX + Dec DX + Test AL, TEST_ACI + JNZ WaitAutoCalibration2 + Loop WaitAutoCalibration1 + + StC + +WaitAutoCalibration2: + Pop CX + Ret + +EndP WaitAutoCalibration + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixMode Far + + Mov AX, [SI+22] + + ClI + + Mov CS:MixMode, AX + + Mov BX, 180 + Mul BX + Mov CS:MixModeOffset, AX + + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS:RecalculateAllVolumes + + StI + +SetMixModeChain: + Call GotoHomeDirectory + + ; Now to save config into driver file. + Push CS + Pop DS + Assume DS:Driver + + Mov AX, 3D02h ; Read write access + Mov DX, Offset DriverName + Mov SI, Offset ConfigErrorMsg + Int 21h + JC SetMixMode1 + + Mov BX, AX + + Mov AX, 4200h + Xor CX, CX + Mov DX, Offset CONFIGURATIONOFFSET + Int 21h + JC SetMixMode2 + + Mov AH, 40h + Mov CX, CONFIGSIZE + Mov DX, Offset MixMode + Int 21h + +SetMixMode2: + PushF + Mov AH, 3Eh + Int 21h + PopF + + JC SetMixMode1 + + Mov SI, Offset ConfigOKMsg + +SetMixMode1: + Mov BX, 40 + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP SetMixMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetWSSMixConst ; Work out value.. and nearest + ; mixspeed value. + + PushA + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, CmdLineMixSpeed + Mov CX, MixSpeed + Test AX, AX + JZ GetWSSMixConst1 + + Mov CX, 64000 + Cmp AX, CX + JA GetWSSMixConst1 + + Mov CX, 8000 + Cmp AX, CX + JB GetWSSMixConst1 + + Mov CX, AX + +GetWSSMixConst1: ; CX = desired mixspeed + Mov SI, Offset MixSpeedTable + Mov DX, 16 ; 16 different available speeds + + Xor BX, BX + +GetWSSMixConst2: + LodsW + Cmp AX, BX + JB GetWSSMixConst3 + Cmp AX, CX + JA GetWSSMixConst3 + + Mov BX, AX + Mov DH, [SI] + +GetWSSMixConst3: + LodsW ; Add SI, 2 + Dec DL + JNZ GetWSSMixConst2 + + Mov MixSpeed, BX + Mov WSSMixConst, DH + + Pop DS + PopA + Ret + +EndP GetWSSMixConst + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PingWSS ; Check BasePort, DX = BasePort + ; Preserves DX, destroys AX + + Push DX + + Add DX, WSS_CHIPID ; Check for valid Chip ID + In AL, DX + + And AL, 3Fh + JZ PingWSS1 + Cmp AL, 4 + JE PingWSS1 + Cmp AL, 0Fh + JE PingWSS1 + +PingWSSFailure: + Pop DX + + StC + Ret + +PingWSS1: + Add DX, 4+2-WSS_CHIPID + + In AL, DX + Xor AL, AL + Out DX, AL + + Sub DX, 2 ; DX = AD1848 Baseport + Call WaitCodec + JC PingWSSFailure + + In AL, DX + Test AL, AL + JS PingWSSFailure + + Mov AL, CODEC_INDEX_MISC + Out DX, AL + Inc DX ; DX = Data port + In AL, DX + Mov AH, AL ; AH = Revision + + Xor AL, AL ; Write 0 revision + Out DX, AL + In AL, DX + And AX, 8F8Fh + Cmp AL, AH + JNE PingWSSFailure + Dec DX ; DX = AD1848 baseport + + Mov AL, CODEC_MCE or CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + Mov AL, INTF_ACAL or INTF_SDC + Out DX, AL + Dec DX + + Call WaitAutoCalibration ; Returns carry if error + ; Carry clear if none. + +; JC PingWSSFailure + + Pop DX + Ret + +EndP PingWSS + +; ÄÄ DetectCard ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Returns carry set if error, else carry clear. Has to setup internal vars +; (eg. appropriate IRQ/DMA whatever). +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DetectCard Far + + Push CS + Pop DS + Assume DS:Driver + + Cmp IRQ, 0FFFFh + JNE DetectCardIRQDone + + Mov IRQ, 7 + +DetectCardIRQDone: + Cmp DMA, 0FFFFh + JNE DetectCardDMADone + + Mov DMA, 1 + +DetectCardDMADone: + Mov DX, BasePort + Cmp DX, 0FFFFh + JE DetectCardFindBasePort + + Call PingWSS + JNC CheckWSSOK + +DetectWSSFailure: + StC + Ret + +DetectCardFindBasePort: + Mov DX, 530h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0E80h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 0F40h + Call PingWSS + JNC DetectWSSOK + + Mov DX, 604h + Call PingWSS + JC DetectWSSFailure + +DetectWSSOK: + Mov BasePort, DX + +CheckWSSOK: + ; Check for valid IRQ + Mov BX, IRQ + Mov AL, [IRQSetupTable+BX] + Mov BX, DMA + Mov AH, [DMASetupTable+BX] + Test AL, AL + JZ DetectWSSFailure + Test AH, AH + JZ DetectWSSFailure + + Or AL, AH + Out DX, AL + + Add DX, WSS_BASE + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + Mov AH, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AX, 3F3Fh + Neg AL + Neg AH + Add AL, 3Fh + Add AH, 3Fh + Mov [Word Ptr VolumeTable], AX + + Mov AL, [DMALengthTable+BX] + Mov Byte Ptr [DMAPort1], AL + Mov Byte Ptr [DMAPort2], AL + + Mov AX, DMABUFFERLENGTH/2 + Cmp BX, 4 + JB DetectWSS2 + + ShR AX, 1 + +DetectWSS2: + Mov Word Ptr [DMABufferLength1], AX + Mov Word Ptr [DMABufferLength2], AX + + Mov EAX, 'Jeff' + ClC + Ret + +EndP DetectCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MixModeTable Label Word + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix0ModeMono, Mix0ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + DW Offset Mix6ModeMono, Mix6ModeStereo + +Proc MixSamples ; Given DS:SI = info tables, CX = numchannels + + ; 1. Clean buffer + ; + update variables + ; 2. Update parameters + ; 3. Mix func + ; 4. Return + + Push CX + + Mov CX, BytesToMix + Mov ES, MixSegment + Mov DI, MIXTABLESIZE + Xor EAX, EAX + Mov DX, CX + Add CX, CX + + Mov MixTransferOffset, DI ; } Memory write + + Cmp Stereo, 0 + JE MixSamples1 + + Mov DX, CX + +MixSamples1: + Rep StosD ; } Memory write + Mov MixTransferRemaining, DX ; } + + Pop CX + +MixSamples2: + Test Byte Ptr [SI], 1 + JZ MixSamplesEnd2 + Cmp Byte Ptr [SI+36h], 100 + JE MixSamplesEnd2 + + Push CX + Mov CX, [SI] + + Test CH, 2 + JZ MixSamples3 + And Byte Ptr [SI], Not 1 + + Jmp MixSamplesEnd +; Cmp MixMode, 8 ; Is it volume ramping? +; JB MixSamplesEnd + +MixSamples3: + Test CL, 20h ; New freq? + JZ MixSamples5 + + Mov AX, [SI+10h] + Mov DX, [SI+12h] + Mov BX, MixSpeed + Cmp DX, BX + JAE MixSamplesHandleError + + Div BX + ShL EAX, 16 + Xor AX, AX + Div BX + Mov STEPVALUE, EAX + +MixSamples4: + Test CH, 1 + JZ MixSamples5 + + Mov DWord Ptr [SI+1Ch], 0 ; Current Volume = 0 + ; for volume sliding. +MixSamples5: + Test CX, 8440h ; New volume or panning? + JZ MixSamplesMix + + Xor AX, AX + Test CH, 8 ; Muted? + JNZ MixModeCommon + + Mov BX, MixMode + Add BL, Stereo + Add BX, BX + Jmp [CS:MixModeTable+BX] + +Mix0Mode: ; 16-bit mixing, no interpolation +Mix0ModeMono: ; and 16-bit mixing, interpolation + Mov AL, [SI+20h] + ShR AL, 1 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 30 ; Use left only-mixing for mono + Jmp MixModeCommon + +Mix0ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix0ModeSurround + + Mul Byte Ptr [SI+20h] ; Final volume + Add AX, 64 + ShR AX, 7 + Mov [SI+0Ch], AX ; Store into right volume + + Mov AL, 64 + Sub AL, [SI+37h] + Mul Byte Ptr [SI+20h] + Add AX, 64 + ShR AX, 7 + Mov [SI+0Eh], AX ; Left volume + + Mov CH, AL ; CH = left volume + Mov CL, [SI+0Ch] ; CL = right volume + Mov AX, 0 + + Test CX, CX + JZ MixModeCommon + + Mov AL, 30 ; Left only... + Test CL, CL + JZ MixModeCommon + + Mov AL, 60 + Test CH, CH + JZ MixModeCommon + + Mov AL, 90 + Cmp CL, CH + JZ MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix0ModeSurround: + Mov AL, [SI+20h] + ShR AL, 2 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Mov AX, 0 + JZ MixModeCommon + Mov AL, 150 ; Surround + Jmp MixModeCommon + +Mix6ModeMono: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 8 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + Test AX, AX + JZ MixModeCommon + Mov AX, 30 + Jmp MixModeCommon + +Mix6ModeStereo: + Mov AL, [SI+37h] ; Final pan + Cmp AL, 100 + JE Mix6ModeSurround + + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Ch], AX ; Store into right volume + Mov BX, AX + ShL EAX, 16 + + Mov AL, 64 ; Do left volume + Sub AL, [SI+37h] ; AL = 64-FinalPan + Mul Byte Ptr MixVolume + Mul Word Ptr [SI+4Ah] + ShRD AX, DX, 14 + Mov [SI+0Eh], AX + + Mov ECX, EAX + + ; BX = right volume + ; CX = Left volume + Mov AX, 0 + Test ECX, ECX + JZ MixModeCommon + + Mov AL, 30 + Test BX, BX + JZ MixModeCommon + + Mov AL, 60 + Test CX, CX + JZ MixModeCommon + + Mov AL, 90 + Cmp CX, BX + JE MixModeCommon + + Mov AL, 120 + Jmp MixModeCommon + +Mix6ModeSurround: + Mov AX, [SI+4Ah] + Mul MixVolume + ShRD AX, DX, 9 + Mov [SI+0Ch], AX + Mov [SI+0Eh], AX + JZ MixModeCommon + Mov AX, 150 + Jmp MixModeCommon + +MixModeCommon: ; Requires AX = 30/60/90 etc. depending + ; On mixing mode type. + ; This will add 180 for 16-bit, + ; And sort out loop types. + Mov BL, [SI+0Ah] + Test Byte Ptr [SI+18h], 2 ; 16 bit? + JZ MixModeCommon1 + + Add AX, 180 + +MixModeCommon1: + Cmp BL, 8 + JB MixModeCommon3 ; No loop + JE MixModeCommon2 ; Forwards loop + + Add AX, 10 + +MixModeCommon2: + Add AX, 10 + +MixModeCommon3: + Add AX, Offset MixFunctionTables + Add AX, MixModeOffset + Mov [SI+8], AX ; Offset... + +MixSamplesMix: + Mov BX, [SI+8] ; BX = offset into + Mov EAX, [CS:BX+2] + Mov DWord Ptr PreMixFunction, EAX + Mov EAX, [CS:BX+6] + Mov DWord Ptr MixFunctionSeparateBackwards, EAX + + Mov AX, BytesToMix + Mov MixBlockSize, AX + Mov MixBufferOffset, MIXTABLESIZE + + Mov EAX, CURRENTPOSITION + Mov OLDPOSITION, EAX + + Call Word Ptr [CS:BX] + + And Word Ptr [SI], 0111100010001101b + Jmp MixSamplesEnd + +MixSamplesHandleError: + Mov Word Ptr [SI], 200h + + Test Byte Ptr [SI+3Ah], 80h + JNZ MixSamplesEnd + + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 ; Turn off channel + +MixSamplesEnd: + Pop CX + +MixSamplesEnd2: + Add SI, 128 + Dec CX + JNZ MixSamples2 + + Ret + +EndP MixSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSIRQHandler + + Push AX + Push BX + Push DS + + Push CS + Pop DS + Assume DS:Driver + + Add TimerAccumulator, TIMERCONST + JC WSSIRQHandler11 + + Mov AL, 20h + Out 20h, AL + Jmp WSSIRQHandler12 + +WSSIRQHandler11: + PushF + Call [OldTimerIRQHandler] + +WSSIRQHandler12: + +DMAPort1 EQU $+1 + In AL, 1 + Mov AH, AL +DMAPort2 EQU $+1 + In AL, 1 + XChg AL, AH + + Cmp MixBufferPos, 0 + JE WSSIRQHandler13 + + Xor BX, BX +DMABufferLength1 EQU $+1 + Cmp AX, 1234h + JB WSSIRQHandler1 + + Pop DS + Pop BX + Pop AX + IRet + +WSSIRQHandler13: + Mov BX, DMABUFFERLENGTH/2 +DMABufferLength2 EQU $+1 + Cmp AX, 1234h + JAE WSSIRQHandler1 + + Pop DS + Pop BX + Pop AX + IRet + +WSSIRQHandler1: + Xor MixBufferPos, 1 + + PushAD + Push ES + + CLD + + + ; OK... time to get next block + ; Check whether stereo thing is on.. + ; + LES DI, [ActualDMAPtr] + Add DI, BX + + Mov BX, DMABUFFERLENGTH/4 ; BX = samples required + Mov BP, 8 ; Skip for mono + Mov CL, 14 ; Shift for mono + + Cmp Stereo, 0 + JE WSSIRQHandlerMono + + Mov BP, 4 ; Stereo skip value. + Dec CL + +WSSIRQHandlerMono: + Call SaveEMSPageFrame + + Cmp MixTransferRemaining, 0 + JNE WSSIRQHandler4 + Assume DS:Nothing + +WSSIRQHandler3: + Push BX + Push CX + Push BP + Push ES + Push DI + + Call Update + Call MixSamples + + Pop DI + Pop ES + Pop BP + Pop CX + Pop BX + +WSSIRQHandler4: + Mov DS, MixSegment + Mov SI, MixTransferOffset + Mov DX, BX ; DX = samples to transfer + Cmp DX, MixTransferRemaining + JBE WSSIRQHandler5 + + Mov DX, MixTransferRemaining + +WSSIRQHandler5: + Push DX + Cmp CS:Filter, 1 + JB WSSIRQHandler6 + JE WSSIRQHFilter + + Cmp CS:Stereo, 0 + JE WSSIRQ3QFilterMono + +WSSIRQ3QFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQ3QFilterStereo1: + Mov EAX, EBX + Mov ECX, EBP + Add EAX, [SI] + Add ECX, [SI+4] + SAR EAX, 1 + SAR ECX, 1 + Add EBX, EAX + Add EBP, ECX + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip2 + +WSSIRQ3QFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSS3QFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSS3QFilterStereoClip4 + +WSSIRQ3QFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQ3QFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQ3QFilterMono1: + Mov EAX, EBX + Add EAX, [SI] + SAR EAX, 1 + Add EBX, EAX + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSS3QFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSS3QFilterMonoClip2 + +WSSIRQ3QFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQ3QFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilter: + Cmp CS:Stereo, 0 + JE WSSIRQHFilterMono + +WSSIRQHFilterStereo: + Push BX + + Mov EBX, FilterValue + Mov EBP, FilterValue2 + ShR DX, 1 + +WSSIRQHFilterStereo1: + Add EBX, [SI] + Add EBP, [SI+4] + + SAR EBX, 1 + SAR EBP, 1 + + Mov EAX, EBX + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip2 + +WSSIRQHFilterStereo2: + StosW + + Mov EAX, EBP + SAR EAX, 13 + + Cmp EAX, -8000h + JL WSSHFilterStereoClip3 + Cmp EAX, 7FFFh + JG WSSHFilterStereoClip4 + +WSSIRQHFilterStereo3: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterStereo1 + + Mov FilterValue, EBX + Mov FilterValue2, EBP + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHFilterMono: + Push BX + + Mov EBX, FilterValue + +WSSIRQHFilterMono1: + Add EBX, [SI] + SAR EBX, 1 + Mov EAX, EBX + SAR EAX, 14 + + Cmp EAX, -8000h + JL WSSHFilterMonoClip1 + Cmp EAX, 7FFFh + JG WSSHFilterMonoClip2 + +WSSIRQHFilterMono2: + StosW + + Add SI, 8 + Dec DX + JNZ WSSIRQHFilterMono1 + + Mov FilterValue, EBX + + Pop BX + + Jmp WSSMixTransferEnd + +WSSIRQHandler6: + Mov EAX, [SI] + SAR EAX, CL + + Cmp EAX, -8000h + JL WSSIRQHandlerClip1 + Cmp EAX, 7FFFh + JG WSSIRQHandlerClip2 + +WSSIRQHandler7: + StosW ; } Memory write + + Add SI, BP + Dec DX + JNZ WSSIRQHandler6 + +WSSMixTransferEnd: + Pop DX + + Sub MixTransferRemaining, DX ; } Memory write + Sub BX, DX + JNZ WSSIRQHandler3 + + Mov MixTransferOffset, SI ; } Memory write + + Call RestoreEMSPageFrame + + Pop ES + PopAD + Pop DS + Pop BX + Pop AX + IRet + +WSSIRQHandlerClip1: + Mov AX, 8000h + Jmp WSSIRQHandler7 + +WSSIRQHandlerClip2: + Mov AX, 7FFFh + Jmp WSSIRQHandler7 + +WSSHFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterMono2 + +WSSHFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterMono2 + +WSSHFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo2 + +WSSHFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQHFilterStereo3 + +WSSHFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQHFilterStereo3 + +WSS3QFilterMonoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterMonoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterMono2 + +WSS3QFilterStereoClip1: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip2: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo2 + +WSS3QFilterStereoClip3: + Mov AX, 8000h + Jmp WSSIRQ3QFilterStereo3 + +WSS3QFilterStereoClip4: + Mov AX, 7FFFh + Jmp WSSIRQ3QFilterStereo3 + +EndP WSSIRQHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WSSAckIRQ + + Push AX + Push DX + + Mov DX, [CS:BasePort] + Add DX, 6 + In AL, DX + Test AL, 1 + JZ WSSAckIRQ2 + + Xor AL, AL + Out DX, AL + +WSSAckIRQ2: + Mov AL, 20h + Cmp CS:IRQ, 8 + JB WSSAckIRQ1 + + Out 0A0h, AL + +WSSAckIRQ1: + Out 20h, AL + + Pop DX + Pop AX + + IRet + +EndP WSSAckIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + ; bump the interrupt to be called + ; 100 times a second. + Mov AX, TIMERCONST + Out 40h, AL + Mov AL, AH + Out 40h, AL + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSIRQHandler + + ClI + + XChg [ES:20h], EAX ; Hook to timer interrupt + Mov CS:OldTimerIRQHandler, EAX + + StI + + ; Now hook WSS ACK IRQ + Mov DI, IRQ + ShL DI, 2 + Add DI, Offset IRQData + Mov BX, [CS:DI] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset WSSACKIRQ + + XChg [ES:BX], EAX + Mov OldWSSIRQHandler, EAX + + Mov AX, IMR + And AX, [DI+2] + + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Pop ES + PopAD + + Ret + +EndP SetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetIRQ + + PushAD + Push ES + + Xor AX, AX + Mov ES, AX + + Mov AL, 34h ; Program IRQ 0. LSB&MSB, Rate gen + Out 43h, AL + + Xor AL, AL + Out 40h, AL ; Interrupt called at normal 18.2 times + Out 40h, AL + + Mov EAX, CS:OldTimerIRQHandler + Mov [ES:20h], EAX + + Mov DI, IRQ + ShL DI, 2 + Mov BX, [IRQData+DI] + + Mov EAX, OldWSSIRQHandler + Mov [ES:BX], EAX + + Pop ES + PopAD + + Ret + +EndP ResetIRQ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StopWSS + + Mov DX, BasePort + Add DX, WSS_BASE + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + And AL, Not INTF_PEN + Out DX, AL + + Inc DX + In AL, DX + Xor AL, AL + Out DX, AL + + Dec DX + Dec DX + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Xor AL, AL + Out DX, AL + + Ret + +EndP StopWSS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartWSS + + PushA + Push ES + Push DS + + Push CS + Pop DS + Assume DS:Driver + + ; Setup DMA + Mov BX, DMASegment + Xor AX, AX + Mov DX, DMA + Mov DI, DMABUFFERLENGTH + Call SetDMA + + LES DI, ActualDMAPtr + Xor AX, AX + Mov CX, DMABUFFERLENGTH/2 + Rep StosW + + Mov MixBufferPos, 0 + Mov MixTransferRemaining, 0 + + Mov DX, BasePort + Call PingWSS + + Add DX, WSS_BASE + + Mov AL, CODEC_INDEX_PIN + Out DX, AL + Inc DX + Mov AL, PIN_IEN + Out DX, AL + Dec DX + + Mov AH, WSSMixConst ; Set format/frequency + Cmp Stereo, 0 + JE StartWSS1 + + Or AH, CDF_STEREO + +StartWSS1: + Mov AL, CODEC_MCE or CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitCodec + + Mov AL, CODEC_INDEX_CDF + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Call WaitAutoCalibration + + ; Start playback + Mov AL, CODEC_INDEX_LWR_COUNT + Out DX, AL + Inc DX + + Mov AX, 0FFFFh + + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_UPR_COUNT + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_INTF + Out DX, AL + Inc DX + In AL, DX + Or AL, INTF_PEN + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not LDC_LDM + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + In AL, DX + And AL, Not RDC_RDM + Out DX, AL + Dec DX + + Pop DS + Pop ES + PopA + + Ret + +EndP StartWSS + Assume DS:Nothing + +;ÄÄ InitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Sets up any memory required for output +; Initiates output +; +; Parameters: AX = Number of Channels +; +; If sucessful, returns: +; Carry flag clear +; DS:SI = pointer to text to display +; AX = parameter 1 in text +; BX = parameter 2 in text +; CX = parameter 3 in text +; DX = parameter 4 in text +; DI = parameter 5 in text +; +; If unsucessful, returns: +; Carry flag set +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov SI, Offset RelocationTable + +RelocationFix: + LodsW + Test AX, AX + JZ RelocationEnd + Mov BX, AX + Mov [BX], DS + Jmp RelocationFix + + +RelocationEnd: + Call GetEMSPageFrame + Mov EMSPageFrame, AX + + In AL, 0A1h + Mov AH, AL + In AL, 21h + Mov IMR, AX + + Mov ECX, IdleUpdateInfoLine + Mov EDX, GlobalKeyList + Mov IdleFunctionList, ECX + Mov GlobalKeyLink2, EDX + + Mov ECX, FillHeaderFunction + Mov EDX, DrawHeaderFunction + Mov FillHeader2, ECX + Mov ScreenHeader2, EDX + + Call GetWSSMixConst + + Mov AX, 2643 + Mul MixSpeed + Add AX, 0FFFFh + AdC DX, 2080 + + Mov BX, (DMABUFFERLENGTH*2)/16 + Add BX, DX + + ; Allocate MixSegment first + Mov AH, 48h + + Int 21h + JNC InitSound1 + +InitSoundNoMemory: + Mov SI, Offset WSSNoMemoryMsg + Ret + +InitSound1: + Mov MixSegment, AX + Add AX, DX + Mov DMASegment, AX + + Call SetIRQ + Call GetTempo + Call SetTempo + + Mov SI, Offset WSSMsg + + Mov AX, BasePort + Mov BX, IRQ + Mov CX, DMA + + Ret + +EndP InitSound + Assume DS:Nothing + +;ÄÄ ReInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Reinitialises sound output +; Initiates sound output +; +; Parameters: AX = number of channels. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReInitSound Far + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Driver + + Call ResetIRQ + Call SetIRQ + + Mov SI, Offset ReInitMsg + Mov BX, 40 + Call SetInfoLine + + Mov AL, Stereo + Call SetStereo + + Pop ES + Pop DS + PopA + + Ret + +EndP ReInitSound + Assume DS:Nothing + +;ÄÄ UnInitSound ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Stops sound output, releases any memory used by driver +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitSound Far + + Push CS + Pop DS + Assume DS:Driver + + Mov AX, IMR + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + Mov AX, MixSegment + Test AX, AX + JZ UnInitSound1 + + Mov ES, AX + Mov AH, 49h ; Release MixSegment + Int 21h + + Call StopWSS + Call ResetIRQ + +UnInitSound1: + Ret + +EndP UnInitSound + Assume DS:Nothing + +;ÄÄ Poll ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; This procedure is called as often as possible by IT.EXE +; AX = Playmode (0 for nothing in particular, 1 = pattern, 2 = song) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Poll Far + + Ret + +EndP Poll + +;ÄÄ SetTempo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: BX = tempo +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetTempo Far + + Push AX + Push BX + Push DX + + Push BX + + Mov AX, MixSpeed + Mov BX, AX + Xor DX, DX + + ShL AX, 1 + RCL DX, 1 ; DX:AX = Mixspeed*2 + + ShR BX, 1 ; BX = Mixspeed/2 + + Add AX, BX + AdC DX, 0 ; DX:AX = Mixspeed*2.5 + + Pop BX ; BX = tempo + Div BX + + Mov BytesToMix, AX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP SetTempo + +;ÄÄ SetMixVolume ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = MixVolume +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMixVolume Far + + PushA + Push DS + + Mov BX, AX ; BX = MixVolume + Mov CS:MixVolume, BX + + Mov AX, CS:MixSegment + Test AX, AX + JZ SetMixVolume2 + + Mov DS, AX + + Mov CX, MIXTABLESIZE/2 + Mov SI, MIXTABLESIZE-2; Starting point - working backwards + +SetMixVolume1: + Mov AX, CX + + Dec AX ; AH = volume, AL = wave value. + Xor DX, DX + XChg AH, DL ; DL = Volume, AX = wave value + CBW + + IMul DX ; DX:AX = Volume * Wave Value + ; Ranges -8192->8128 + + IMul BX ; DX:AX = Volume * Wave Value * Mixing Volume + ; Ranges -1048576->1040384 + + Add AX, 64 + AdC DX, 0 + + ShRD AX, DX, 7 + Mov [SI], AX + Sub SI, 2 + + Loop SetMixVolume1 + +SetMixVolume2: + Mov DS, Word Ptr [CS:RecalculateAllVolumes+2] + Call CS: RecalculateAllVolumes + + Pop DS + PopA + + Ret + +EndP SetMixVolume + +;ÄÄ SetStereo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AL = Stereo on/off, 0 = off. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RecalculateAllFrequencies + + Call GetChannelTables + +RecalculateAllFrequencies1: + Or Byte Ptr [SI], 32 + + Add SI, 128 + Dec CX + JNZ RecalculateAllFrequencies1 + + Ret + +EndP RecalculateAllFrequencies + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetStereo Far + + Mov CS:Stereo, AL + Cmp CS:MixSegment, 0 + JE SetStereo1 + + Call StopWSS + Call StartWSS + + Call RecalculateAllFrequencies + +SetStereo1: + Ret + +EndP SetStereo + +;ÄÄ LoadSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to load +; DS:SI points to sample header +; ES:0 points to first sample +; +; Returns: **Carry set if NO error** +; **Carry clear if error** +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSample Far ; Fix up end of sample bytes + + PushAD + Push DS + Push ES + Push FS + + Mov FS, CS:SongDataArea + Mov BP, AX + Add BP, BP + Mov BP, [FS:64910+BP] + + Xor CX, CX ; From the start of the sample.. + Call GetSampleLocation ; Returns DS:ESI, ECX = length + JC LoadSampleEnd ; Zero flag ON if 16 bit.. + + Xor EAX, EAX + Mov BL, [FS:BP+12h] + + Test BL, 10h ; Loop + JZ LoadSample2 + + Mov ESI, [FS:BP+34h] ; Start of loop + Test BL, 40h ; Pingpong? + JZ LoadSample1 + + Mov ESI, [FS:BP+38h] + Sub ESI, 2 + JNC LoadSample1 + + Xor ESI, ESI + +LoadSample1: + Test BL, 2 + JZ LoadSample4 + + Add ESI, ESI + +LoadSample4: + Call UpdateSampleLocation + Mov AL, [SI] + Inc ESI + Call UpdateSampleLocation + Mov AH, [SI] + +LoadSample2: + Mov ESI, [FS:BP+30h] + Test BL, 2 + JZ LoadSample3 + + Add ESI, ESI + +LoadSample3: + Call UpdateSampleLocation + Mov [SI], AL + Inc ESI + Call UpdateSampleLocation + Mov [SI], AH + +LoadSampleEnd: + Pop FS + Pop ES + Pop DS + PopAD + + StC + Ret + +EndP LoadSample + +;ÄÄ ReleaseSample ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Parameters: AX = sample to release +; DS:SI points to sample header +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseSample Far + + Ret + +EndP ReleaseSample + +;ÄÄ ResetMemory ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetMemory Far + + Ret + +EndP ResetMemory + +;ÄÄ GetStatus ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Frees all on-board memory +; +; Returns text to show on status line, AX = display parameter +; Carry set if not to show anything. +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStatus Far + + StC + Ret + +EndP GetStatus + +;ÄÄ SoundCardScreen ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Function to have driver interactive part of program +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoundCardScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, CS + Mov DX, Offset WSS16ScreenList + + ClC + Ret + +EndP SoundCardScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetVariable Far + + Xor AH, AH + Mov AL, [CS:VolumeTable+DI] + Ret + +EndP GetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetVariable Far + + Push DS + Push DX + + Push CS + Pop DS + Assume DS:Driver + + Mov [VolumeTable+DI], AL + + Mov DX, BasePort + Add DX, WSS_BASE + + Mov AL, CODEC_INDEX_LDC + Out DX, AL + Inc DX + Mov AX, 3F3Fh + Sub AX, [Word Ptr VolumeTable] + Out DX, AL + Dec DX + + Mov AL, CODEC_INDEX_RDC + Out DX, AL + Inc DX + Mov AL, AH + Out DX, AL + Dec DX + + Pop DX + Pop DS + Ret + +EndP SetVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndDriver: + +;******** Provided Variable Table ************* + +MaxNumberOfChannels DW 0FFFFh ; Maximum number of channels the + ; driver can handle. + +StopAfterPlay DW 0 +DefaultChannels DW 64 + DW 5 Dup (0) + + +;******** Provided Procedure Table ************* + +ProvidedTableStart: + + DW Offset DetectCard + + DW Offset InitSound ; Playing related + DW Offset ReinitSound + DW Offset UninitSound + + DW Offset Poll + + DW Offset SetTempo ; Sound variable related + DW Offset SetMixVolume + DW Offset SetStereo + + DW Offset LoadSample ; Sample related + DW Offset ReleaseSample + DW Offset ResetMemory + DW Offset GetStatus ; Returns string to show on status line + + DW Offset SoundCardScreen ; Sound card 'screen' + + DW Offset GetVariable ; For interface + DW Offset SetVariable + +ProvidedTableEnd: + DW 32-(ProvidedTableEnd-ProvidedTableStart)/2 Dup (0) + +EndS + +End diff --git a/build b/build new file mode 100755 index 0000000..4755bfa --- /dev/null +++ b/build @@ -0,0 +1,9 @@ +mkdir -p obj gen +./gen_deps + +for i in *.s; do + echo $i + nasm -g $i -felf32 -o "obj/$(echo $i | sed 's/s$/o/g')" +done + +cc -m32 main.c c/* obj/* -g3 diff --git a/DEBUG.INC b/debug.inc similarity index 82% rename from DEBUG.INC rename to debug.inc index 530c1be..f98f80e 100644 --- a/DEBUG.INC +++ b/debug.inc @@ -1,107 +1,107 @@ -; -; Debug macro. To write to the file, use "Trace " -; - -IF TRACEENABLED - -IF CREATENEWLOGFILE -FirstTime DB 0 -ENDIF - -LogFileName DB "Logfile.Txt", 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WriteDebugFile - - PushA - Push DS - - Push CS - Pop DS - - Push CX - Mov DX, Offset LogFileName - -IF CREATENEWLOGFILE - - Cmp DS:FirstTime, 0 - JNE WriteDebugFile1 - - Mov AH, 3Ch - Xor CX, CX - Int 21h - JC WriteDebugFileEnd - - Mov DS:FirstTime, 1 - XChg AX, BX - Jmp WriteDebugFile2 - - WriteDebugFile1: - -ENDIF - Mov AX, 3D02h - Int 21h - JC WriteDebugFileEnd - - XChg AX, BX - - Mov AX, 4202h - Xor CX, CX - Xor DX, DX - Int 21h ; Move to end of file - -WriteDebugFile2: - Mov AH, 40h - Pop CX - Push CX - Mov DX, SI - Int 21h - - Mov AH, 3Eh - Int 21h - -WriteDebugFileEnd: - Pop CX - Pop DS - PopA - Ret - -EndP WriteDebugFile - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Trace Macro LogMessage - Local X, Y - - PushF - Push CX - Push SI - Jmp Y - X: - DB LogMessage - DB 0Dh, 0Ah - Y: - Mov CX, Offset Y - Offset X - Mov SI, Offset X - Call WriteDebugFile - - Pop SI - Pop CX - PopF - - EndM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ELSE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Trace Macro LogMessage - EndM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ENDIF - +; +; Debug macro. To write to the file, use "Trace " +; + +%if TRACEENABLED + +%if CREATENEWLOGFILE +FirstTime DB 0 +%endif + +LogFileName DB "Logfile.Txt", 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WriteDebugFile + + PushA + Push DS + + Push CS + Pop DS + + Push CX + Mov DX, Offset LogFileName + +%if CREATENEWLOGFILE + + Cmp DS:FirstTime, 0 + JNE WriteDebugFile1 + + Mov AH, 3Ch + Xor CX, CX + Int 21h + JC WriteDebugFileEnd + + Mov DS:FirstTime, 1 + XChg AX, BX + Jmp WriteDebugFile2 + + WriteDebugFile1: + +%ENDIF + Mov AX, 3D02h + Int 21h + JC WriteDebugFileEnd + + XChg AX, BX + + Mov AX, 4202h + Xor CX, CX + Xor DX, DX + Int 21h ; Move to end of file + +WriteDebugFile2: + Mov AH, 40h + Pop CX + Push CX + Mov DX, SI + Int 21h + + Mov AH, 3Eh + Int 21h + +WriteDebugFileEnd: + Pop CX + Pop DS + PopA + Ret + +;EndP WriteDebugFile + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +%macro Trace 1; Macro LogMessage + Local X, Y + + PushF + Push CX + Push SI + Jmp Y + X: + DB %1 + DB 0Dh, 0Ah + Y: + Mov CX, Y - X + Mov SI, X + Call WriteDebugFile + + Pop SI + Pop CX + PopF + + %endmacro + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +%ELSE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +%macro Trace 1 +%endmacro + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +%ENDIF + diff --git a/errors-sorted b/errors-sorted new file mode 100644 index 0000000..e45b6a4 --- /dev/null +++ b/errors-sorted @@ -0,0 +1,29 @@ +18 it_mdata.s +37 it_err.s +51 it_vesa.s +90 it_h.s +140 it_four.s +165 it_tute.s +167 it_m.s +172 it_l.s +174 it_mmtsr.s +238 it_k.s +240 it_ems.s +287 it_s.s +311 it_msg.s +318 it_mouse.s +336 it.s +425 it_g.s +641 it_net.s +815 it_displ.s +1563 it_f.s +1795 it_music.s +2057 it_pe.s +2155 it_i.s +2238 it_disk.s +2398 it_obj1.s + +instances in source code: +EndM: 374 +EndP: 3320 +Proc: 3597 diff --git a/gen_deps b/gen_deps new file mode 100755 index 0000000..3fed66e --- /dev/null +++ b/gen_deps @@ -0,0 +1,13 @@ +rm -v gen/* + +d=512 + +for i in {1..100}; do + echo "dw $d" >> gen/it_mdata.s + d=$(($d + 554)) +done + +for i in {1..100}; do + echo "dw $d" >> gen/it_mdata.s + d=$(($d + 80)) +done diff --git a/IT.ASM b/it.s similarity index 96% rename from IT.ASM rename to it.s index e97cc5e..5625fd3 100644 --- a/IT.ASM +++ b/it.s @@ -1,1147 +1,1155 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Startup Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386P - -include switch.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Object1 BYTE Public 'Data' - Extrn HelpKeyValue:Word, OrderKeyValue:Word -EndS - -Segment InfoLine BYTE Public 'Code' USE16 - Extrn ShowUsageTime:Byte -EndS - -Segment Disk BYTE Public 'Code' USE16 - Extrn DiskOptions:Byte -EndS - -Segment Screen BYTE Public 'Code' - Extrn CharacterGenerationOffset:Word - Extrn VGAFlags:Byte -EndS - -Segment Mouse BYTE Public 'Code' - Extrn MouseCharacterGenerationOffset:Word -EndS - -Segment Main DWORD Public 'Code' USE16 - Extrn ReleaseTimeSlice:Byte -EndS - - Extrn D_InitDisk:Far - Extrn D_UnInitDisk:Far - Extrn D_DisableFileColours:Far - - Extrn E_InitEMS:Far - Extrn E_UnInitEMS:Far - - Extrn Error_InitHandler:Far - Extrn Error_UnInitHandler:Far - - Extrn K_InitKeyBoard:Far - Extrn K_UnInitKeyBoard:Far - Extrn K_InstallKeyboardType:Far - Extrn K_RemoveKeyboardType:Far - - Extrn K_InstallDOSHandler:Far - Extrn K_UnInstallDOSHandler:Far - Extrn K_SwapKeyBoard:Far - - Extrn O1_AutoDetectList:Far - Extrn O1_ConfirmQuit:Far - Extrn O1_PatternEditList:Far - Extrn O1_CrashRecovery:Far - Extrn O1_KeyboardList:Far - - Extrn M_Object1List:Far - - Extrn S_InitScreen:Far - Extrn S_ClearScreen:Far - Extrn S_UnInitScreen:Far - Extrn S_SetDirectMode:Far - Extrn S_DrawString:Far - - Extrn Music_InitMusic:Far - Extrn Music_UnInitMusic:Far - - Extrn Music_SetLimit:Far - Extrn Music_SetSoundCard:Far - Extrn Music_SetDMA:Far - Extrn Music_SetIRQ:Far - Extrn Music_SetMixSpeed:Far - Extrn Music_SetAddress:Far - Extrn Music_ReverseChannels:Far - Extrn Music_PatternStorage:Far - Extrn Music_SetSoundCardDriver:Far - Extrn Music_Stop:Far - Extrn Music_AutoDetectSoundCard:Far - -IF NETWORKENABLED - Extrn Network_Shutdown:Far -ENDIF - - Extrn PE_InitPatternEdit:Far - Extrn PE_UnInitPatternEdit:Far - Extrn PECheckModified:Far - - Extrn D_RestorePreShellDirectory:Far - Extrn D_GetPreShellDirectory:Far - - Extrn MMTSR_InstallMMTSR:Far - Extrn MMTSR_UninstallMMTSR:Far - - Extrn InitMouse:Far, UnInitMouse:Far - Extrn CmdLineDisableMouse:Far - - Extrn InitTimerHandler:Far, UnInitTimerHandler:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - - Global Quit:Far, Refresh:Far - Global DOSShell:Far, GetEnvironment:Far - Global CrashRecovery:Far - - Public IsStartupKeyList - Public GetStartupKeyList - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment StartUp BYTE Public 'Code' USE16 - Assume CS:StartUp, DS:Nothing, ES:Nothing - -CREATENEWLOGFILE EQU 1 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -StackSize = 1000h - -No386Msg DB "Sorry, Impulse Tracker requires a 386+ processor to run." - DB 13, 10, "$" -WindowsMsg DB "Microsoft Windows detected.", 13, 10, 10 - DB "Due to instabilities in Windows, it is highly recommended that you run", 13, 10 - DB "Impulse Tracker in DOS instead.", 13, 10, 10 - DB "Press any key to continue..." - DB "$" - -PSP DW ? - -LoadMMTSR DB 1 -Pause DB 0 -COMSPECFound DB 0 -COMSPEC DD 0 -Control DB 0 -CommandTail DB 1, 0, 13 - -FCB1 DB 0, 11 Dup (32), 52 Dup (0) -FCB2 DB 0, 11 Dup (32), 52 Dup (0) - -COMSPECString DB "COMSPEC" -DefaultShell DB "C:\COMMAND.COM", 0 -EXECData DW 0 ; Inherit same environment block - DW Offset CommandTail, Startup - DW Offset FCB1, Startup - DW Offset FCB2, Startup -ShellMsg DB "Type EXIT to return to Impulse Tracker$" - -IF SHOWREGISTERNAME -include wavswitc.inc -include username.inc -ENDIF - -Label CmdLineHelp Byte -IF SHOWVERSION - DB "Impulse Tracker 2.14, Copyright (C) 1995-2000 Jeffrey Lim", 13, 10 - DB 10 - DB " Usage: IT.EXE [Switches]", 13, 10 -ELSE - DB "Impulse Tracker, Copyright (C) 1995-2000 Jeffrey Lim", 13, 10 -IF SHOWREGISTERNAME - DB "Registered to: " - DB REGISTERNAME - DB 13, 10 -ENDIF -ENDIF - DB 10 - DB "Switches:", 13, 10 - DB " SFilename.Drv Select sound card driver", 13, 10 - DB " S#", 9, 9, " Quick select sound card", 13, 10 - DB 9, "S0: No sound card", 9, 9, " S9: Pro Audio Spectrum", 13, 10 - DB 9, "S1: PC Speaker", 9, 9, 9, "S10: Pro Audio Spectrum 16", 13, 10 - DB 9, "S2: Sound Blaster 1.xx", 9, 9, "S11: Windows Sound System", 13, 10 - DB 9, "S3: Sound Blaster 2.xx", 9, 9, "S12: ESS ES1868 AudioDrive", 13, 10 - DB 9, "S4: Sound Blaster Pro", 9, 9, "S13: EWS64 XL Codec", 13, 10 - DB 9, "S5: Sound Blaster 16", 9, 9, "S14: Ensoniq SoundscapeVIVO", 13, 10 - DB 9, "S6: Sound Blaster AWE 32", 9, "S19: Generic MPU401", 13, 10 - DB 9, "S7: Gravis UltraSound", 9, 9, "S20: Disk Writer (WAV)", 13, 10 - DB 9, "S8: AMD Interwave", 9, 9, "S21: Disk Writer (MID)", 13, 10 - DB 10 - DB " Axxx", 9, "Set Base Address of sound card (hexadecimal)", 13, 10 - DB " I###", 9, "Set IRQ of sound card (decimal)", 13, 10 - DB " D###", 9, "Set DMA of sound card (decimal)", 13, 10 - DB 10 - DB " M###", 9, "Set Mixspeed", 13, 10 - DB " L###", 9, "Limit number of channels (4-256)", 13, 10 - DB "$" - -MixErrorMsg DB "Error: Mixing speed invalid - setting ignored", 13, 10, "$" -AddressErrorMsg DB "Error: Base Address invalid - setting ignored", 13, 10, "$" -IRQErrorMsg DB "Error: IRQ number invalid - setting ignored", 13, 10, "$" -LimitErrorMsg DB "Error: Channel limit number invalid - setting ignored", 13, 10, "$" -ContinueMsg DB "Press any key to continue...$" - -StartupList DB 0 -StartupMode DB 0 ; Load? Or Load/Play? or Load/Save -StartupFileOffset DW 0 -StartupFileSegment DW 0 -StartupKeyListFunction DW Offset GetStartupKeyList1 - - ; CX,DX -StartupInformation DW 11Ch, 0 ; Enter - DW 1Ch, 0 ; Release Enter - DW 10Fh, 0 ; Tab - DW 10Fh, 0 ; Tab - DW 10Fh, 0 ; Tab - DW 90Eh, 127 ; Ctrl-Backspace - -ENDSTARTUPINFORMATION EQU $ - -SaveInformation DW 0, 0 ; Loading screen key-loss - DW 1FFh, 13h ; Ctrl-S - DW 0, 0 ; Saving screen key-loss - DW 1FFh, 11h ; Ctrl-Q - DW 1FFh, 'Y' ; 'Y' - -ENDSAVEINFORMATION EQU $ - -StartupQueueOffset DW Offset StartupInformation -StartupQueueEnd DW Offset ENDSTARTUPINFORMATION -StartupQueueNextFunction DW Offset GetStartupKeyList2 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc CapitaliseAL - - Cmp AL, 'a' - JB CapitaliseAL1 - - Cmp AL, 'z' - JA CapitaliseAL1 - - Add AL, 'A'-'a' - -CapitaliseAL1: - Ret - -EndP CapitaliseAL - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetDecimalNumber ; Returns CX - - LodsB - Cmp AL, '0' - JB GetDecimalNumber1 - Cmp AL, '9' - JBE GetDecimalNumber2 - -GetDecimalNumber1: - StC - Ret - -GetDecimalNumber2: - Xor CX, CX - -GetDecimalNumber3: - Mov BL, AL - Sub BL, '0' - Xor BH, BH - Mov AX, 10 - Mul CX - Add AX, BX - Mov CX, AX - LodsB - And DX, DX - JNZ GetDecimalNumber1 - - Cmp AL, '0' - JB GetDecimalNumber4 - Cmp AL, '9' - JA GetDecimalNumber4 - Jmp GetDecimalNumber3 - -GetDecimalNumber4: - ClC - Ret - -EndP GetDecimalNumber - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Start - Assume DS:Nothing - -; 386 check. - - Trace "Impulse Tracker Startup" - - Push SP - Pop AX - Cmp AX, SP - JNE No386 - - PushF - Pop CX ; CX = Flags. - Mov AX, CX - Or AX, 0F000h - Push AX - PopF - PushF - Pop AX - And AX, 0F000h - JNZ Found386 - -No386: - Push CS - Pop DS - - Mov AH, 9 - Mov DX, Offset No386Msg - Int 21h - - Mov AX, 4C02h - Int 21h - -Found386: -; Push 0B800h ; DEBUG!!!!! -; Pop GS ; DEBUG!!!!! - - Push CX - PopF - - ClD - - Mov [CS:PSP], ES - - Mov AX, ES - Mov BX, SS - Sub BX, AX - Add BX, StackSize / 16 ; Add BX, - Mov AH, 4Ah ; Re-allocate memory - Int 21h - - ; Check for 386 here. - - ; Do command line stuff. - Mov SI, 81h ; DS:SI points to cmdtail - -CmdLine1: - Push ES - Pop DS - - LodsB - -CmdLine3: - Cmp AL, 0Dh - JE CmdLineEnd - And AL, AL - JZ CmdLineEnd - - Call CapitaliseAL - -CmdLine2: - Cmp AL, 'K' - JE KeyboardSwap - Cmp AL, 'F' - JE DisableColours - Cmp AL, 'C' - JE SetControl - Cmp AL, 'H' - JE ShowCmdLineHelp - Cmp AL, '?' - JE ShowCmdLineHelp - Cmp AL, 'S' - JE SetSoundCard1 - Cmp AL, 'D' - JE SetDMA1 - Cmp AL, 'M' - JE SetMixSpeed1 - Cmp AL, 'I' - JE SetIRQ1 - Cmp AL, 'A' - JE SetAddress1 - Cmp AL, 'V' - JE OverrideVGA - Cmp AL, 'L' - JE Limit1 - Cmp AL, 'R' - JE Reverse1 - Cmp AL, 'X' - JE DisableFeatures - Cmp AL, 'P' - JE PatternStorage - Cmp AL, 'T' - JE NoShowUsageTime - Cmp AL, 'W' - JE ConvertModule - - Jmp CmdLine1 - -NoShowUsageTime: - LodsB - Cmp AL, '1' - JNE NoReleaseTimeSlice - - Push DS - - Push InfoLine - Pop DS - Assume DS:InfoLine - - Mov [ShowUsageTime], 0 - - Pop DS - Jmp CmdLine1 - Assume DS:Nothing - -NoReleaseTimeSlice: - Cmp AL, '2' - JNE CmdLine3 - -NoReleaseTimeSlice2: - Push DS - - Push Main - Pop DS - Assume DS:Main - - Mov [ReleaseTimeSlice], 1 - - Pop DS - Jmp CmdLine1 - -PatternStorage: - LodsB - Sub AL, '0' - JC PatternStorageEnd - Cmp AL, 2 - JA PatternStorageEnd - Call Music_PatternStorage - Jmp CmdLine1 - -PatternStorageEnd: - Jmp CmdLine3 - -DisableFeatures: - LodsB - Cmp AL, '1' - JB CmdLine3 - JE DisableMMTSR - - Cmp AL, '3' - JB DisableMouse - JE DisableDetectDriveMap - - Cmp AL, '5' - JB DisableCacheFiles - Jmp CmdLine3 - -DisableMouse: - Call CmdLineDisableMouse - Jmp CmdLine1 - -DisableMMTSR: - Mov [LoadMMTSR], 0 - Jmp CmdLine1 - -DisableDetectDriveMap: - Push Disk - Pop DS - Assume DS:Disk - - Or [DiskOptions], 1 - Jmp CmdLine1 - Assume DS:Nothing - -DisableCacheFiles: - Push Disk - Pop DS - Assume DS:Disk - - Or [DiskOptions], 2 - Jmp CmdLine1 - Assume DS:Nothing - -KeyboardSwap: - Mov AX, Object1 - Mov DS, AX - Assume DS:Object1 - - Mov [HelpKeyValue], 157h - Mov [OrderKeyValue], 13Bh - - Jmp CmdLine1 - Assume DS:Nothing - -DisableColours: - Call D_DisableFileColours - Jmp CmdLine1 - -Reverse1: - Call Music_ReverseChannels - Jmp CmdLine1 - -OverrideVGA: - LodsB - - Mov CX, Screen - Mov DS, CX - Assume DS:Screen - - Cmp AL, '1' - JE OverrideVGA1 - Cmp AL, '2' - JE Matrox - Cmp AL, '3' - JE WaitforRetrace - Cmp AL, '4' - JE Retrace - Jmp CmdLine3 - -OverrideVGA1: - Or [VGAFlags], 1 - Jmp CmdLine1 - -WaitforRetrace: - Or [VGAFlags], 4 - Jmp CmdLine1 - -Retrace: - Or [VGAFlags], 2 - Jmp CmdLine1 - -Matrox: - Mov [CharacterGenerationOffset], 256*32 - - Mov AX, Mouse - Mov DS, AX - Assume DS:Mouse - Mov [MouseCharacterGenerationOffset], 256*32 - - Jmp CmdLine1 - Assume DS:Nothing - -SetControl: - Mov [CS:Control], 1 - Jmp CmdLine1 - -ShowCmdLineHelp: - Push CS - Pop DS - - Mov AH, 9 - Mov DX, Offset CmdLineHelp - Int 21h - - Mov AX, 4C00h - Int 21h - -SetSoundCard1: - Call GetDecimalNumber - JC SetSoundCardDriver - Cmp CX, 21 - JA SetSoundCard2 - - Push AX - Mov AX, CX - Call Music_SetSoundCard - Pop AX - -SetSoundCard2: - Jmp CmdLine3 - -SetSoundCardDriver: - Cmp AL, 32 - JBE CmdLine3 - - Dec SI - Call Music_SetSoundCardDriver - -SetSoundCardDriver1: - LodsB - Cmp AL, 32 - JA SetSoundCardDriver1 - - Mov Byte Ptr [SI-1], 0 - Cmp AL, 32 - JE CmdLine1 - Jmp CmdLineEnd - -ConvertModule: - Mov [CS:StartupList], 1 - Mov [CS:StartupFileOffset], SI - Mov [CS:StartupFileSegment], DS - Jmp SetSoundCardDriver1 - -SetDMA1: - LodsB - Cmp AL, '0' - JB CmdLine3 - Cmp AL, '7' - JA CmdLine3 - Sub AL, '0' - Call Music_SetDMA - Jmp CmdLine1 - -SetMixSpeed1: - Call GetDecimalNumber - JC SetMixSpeedError - Push AX - Call Music_SetMixSpeed - Pop AX - Jmp CmdLine3 - -SetMixSpeedError: - Push CS - Pop DS - Assume DS:StartUp - - Mov AH, 9 - Mov DX, Offset MixErrorMsg - Int 21h - - Mov [Pause], 1 - Jmp CmdLine1 - Assume DS:Nothing - -SetIRQ1: - Call GetDecimalNumber - JC IRQError - Cmp CX, 15 - JA IRQError - - Push AX - Call Music_SetIRQ - Pop AX - Jmp CmdLine3 - -IRQError: - Push CS - Pop DS - Assume DS:StartUp - - Mov AH, 9 - Mov DX, Offset IRQErrorMsg - Int 21h - - Mov [Pause], 1 - Jmp CmdLine1 - Assume DS:Nothing - - -SetAddress1: - LodsB - - Xor DX, DX - Mov CL, 4 - - Cmp AL, '0' - JB SetAddress2 - Cmp AL, '9' - JA SetAddress2 - Sub AL, '0' - Jmp SetAddress3 - -SetAddress2: - Call CapitaliseAL - - Cmp AL, 'A' - JB CmdLine2 - Cmp AL, 'F' - JA CmdLine2 - Sub AL, '@' - -SetAddress3: - Test DX, 0F000h - JNZ AddressError - - ShL DX, CL - Or DL, AL - - LodsB - Cmp AL, '0' - JB SetAddress4 - Cmp AL, '9' - JA SetAddress4 - Sub AL, '0' - Jmp SetAddress3 - -SetAddress4: - Call CapitaliseAL - Cmp AL, 'A' - JB SetAddress5 - Cmp AL, 'F' - JA SetAddress5 - - Sub AL, '@' - Jmp SetAddress3 - -SetAddress5: - Call Music_SetAddress - Jmp CmdLine3 - -AddressError: - Push CS - Pop DS - Assume DS:StartUp - - Mov AH, 9 - Mov DX, Offset AddressErrorMsg - Int 21h - - Mov [Pause], 1 - Jmp CmdLine1 - Assume DS:Nothing - -Limit1: - Call GetDecimalNumber - JC LimitError - Cmp CX, 256 - JA LimitError - Cmp CX, 4 - JB LimitError - - Push AX - Call Music_SetLimit - Pop AX - Jmp CmdLine3 - -LimitError: - Push CS - Pop DS - Assume DS:StartUp - - Mov AH, 9 - Mov DX, Offset LimitErrorMsg - Int 21h - - Mov [Pause], 1 - Jmp CmdLine1 - Assume DS:Nothing - - -CmdLineEnd: - Trace "Command Line Parsed" - - Push CS - Pop DS - Assume DS:StartUp - - Trace "Windows Detection" - - Mov AX, 1600h ; Windows detection. - Int 2Fh - Test AL, 7Fh - JZ Start1 - Cmp AL, 4 ; Windows 4.0+ ?? - JAE Start1 - - Mov AH, 9 - Mov DX, Offset WindowsMsg - Int 21h - - Xor AX, AX - Int 16h - -Start1: - ; Get Comspec - Cmp [Pause], 1 - JNE NoPause - - Mov DX, Offset ContinueMsg - Mov AH, 9 - Int 21h - - Xor AX, AX - Int 16h - -NoPause: - Trace "Retrieving Environment" - - Mov SI, Offset COMSPECString - Mov CX, 7 - Call GetEnvironment - JC Start2 - - Mov [COMSPECFound], 1 - Mov [Word Ptr COMSPEC], DI - Mov [Word Ptr COMSPEC+2], ES - -Start2: - Mov FS, [CS:PSP] - - Trace "Initialising Screen Module" - - Call S_InitScreen - - Trace "Initialising Disk Module" - - Call D_InitDisk - - Trace "Initialising Expanded Memory Module" - - Call E_InitEMS - - Trace "Initialising Music Module" - - Call Music_InitMusic - - Trace "Initialising Keyboard Module" - - Call K_InitKeyBoard - - Trace "Initialising Edit Module" - - Call PE_InitPatternEdit - - Trace "Initialising Custom Keyboard Layout" - - Call K_InstallKeyboardType - - Trace "Initialising Error Handler Module" - - Call Error_InitHandler - - Cmp [CS:LoadMMTSR], 0 - JE SkipMMTSR - - Trace "Initialising MMTSR Module" - - Call MMTSR_InstallMMTSR - -SkipMMTSR: - Trace "Initialising Mouse Module" - - Call InitMouse - - Call S_ClearScreen - - Trace "Initialising Timer Module" - - Call InitTimerHandler - - Trace "Initialising Soundcard" - - Call Music_AutoDetectSoundCard - - Trace "Entering Main Message Loop" - - Mov DI, Offset O1_AutoDetectList -; Mov DI, Offset O1_KeyboardList - Mov CX, 0FFFFh - Call M_Object1List - Jmp Quit1 - -Proc Quit Far - - Mov DI, Offset O1_ConfirmQuit - Mov CX, 3 - Call M_Object1List - - And DX, DX - JNZ Quit1 - - Mov AX, 1 - RetF - -Quit1: - Call PECheckModified - Call Music_Stop - -IF NETWORKENABLED - Call Network_Shutdown -ENDIF - - Call MMTSR_UninstallMMTSR - Call PE_UnInitPatternEdit - Call Music_UnInitMusic - Call UnInitMouse - Call S_UnInitScreen - Call E_UnInitEMS - Call K_UnInitKeyBoard - Call Error_UnInitHandler - Call D_UnInitDisk - Call K_RemoveKeyboardType - Call UnInitTimerHandler - - Mov AX, 4C00h - Int 21h - -EndP Quit - -EndP Start - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc IsStartupKeyList Far - - Mov AL,CS:StartupList - - Ret - -EndP IsStartupKeyList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetStartupKeyList Far - - Jmp [CS:StartupKeyListFunction] - -GetStartupKeyList1: - Push SI - Mov SI, [CS:StartupQueueOffset] - - Mov CX, [CS:SI] - Mov DX, [CS:SI+2] - - Add SI, 4 - Mov [CS:StartupQueueOffset], SI - - Cmp SI, [CS:StartupQueueEnd] - - Pop SI - JB GetStartupKeyList1End - - Mov AX, [CS:StartupQueueNextFunction] - Mov [CS:StartupKeyListFunction], AX - -GetStartupKeyList1End: - Ret - -GetStartupKeyList2: - Push DS - Push SI - - LDS SI, [DWord Ptr CS:StartupFileOffset] - LodsB - - Mov [CS:StartupFileOffset], SI - - Pop SI - Pop DS - - Cmp AL, 32 - JE GetStartupKeyList2EndOfString - And AX, 0FFh - JZ GetStartupKeyList2EndOfString - - Mov DX, AX - Mov CX, 1FFh - - Ret - -GetStartupKeyList2EndOfString: - Mov [CS:StartupQueueOffset], Offset SaveInformation - Mov [CS:StartupQueueEnd], Offset ENDSAVEINFORMATION - Mov [CS:StartupQueueNextfunction], Offset GetStartupKeyList3 - Mov [CS:StartupKeyListFunction], Offset GetStartupKeyList1 - - Mov CX, 11Ch ; Enter - Mov DX, 0 - - Ret - -GetStartupKeyList3: ; Save module then quit - Xor CX, CX - Xor DX, DX - Mov [CS:StartupList], 0 - Ret - -EndP GetStartupKeyList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CrashRecovery Far ; CtrlAltDel location. - - ClD - StI - - Call S_ClearScreen - Call S_InitScreen - Call D_InitDisk - Call InitMouse - - Mov DI, Offset O1_CrashRecovery - Mov CX, 0FFFFh - Call M_Object1List - - Mov DI, Offset O1_PatternEditList - Mov CX, 0FFFFh - Jmp M_Object1List - -EndP CrashRecovery - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetEnvironment Far ; DS:SI points to string. - ; CX = length of string. - ; Returns ES:DI - - Mov ES, [CS:PSP] - Mov ES, [ES:2Ch] ; DS:00 points to environ. - Xor DI, DI - -GetEnvironment1: - Push DI - Push CX - Push SI - - RepE CmpSB - - Pop SI - Pop CX - Pop DI - - JE GetEnvironment3 ; From RepE - - Xor AL, AL - -GetEnvironment2: - ScasB - JNE GetEnvironment2 - - Cmp [Byte Ptr ES:DI], AL - JNE GetEnvironment1 - - StC - Ret - -GetEnvironment3: - Add DI, CX - Inc DI ; Skip past '=' - ClC - Ret - -EndP GetEnvironment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Refresh Far - - Call D_GetPreShellDirectory - Call S_InitScreen - Call D_InitDisk - Call InitMouse - Call D_RestorePreShellDirectory - - Mov AX, 1 - Ret - -EndP Refresh - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DOSShell Far - - PushAD - Push DS - Push ES - - PushF - - Call D_GetPreShellDirectory - - Cmp [CS:Control], 0 - JNE DOSShell2 - - Call K_UnInitKeyBoard - Jmp DOSShell3 - -DOSShell2: - Call K_InstallDOSHandler -DOSShell3: - - Mov AX, 3 - Int 10h ; Clr screen. - - Call UnInitMouse - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:StartUp - - Mov AH, 9 - Mov DX, Offset ShellMsg - Int 21h - - Mov AX, 4B00h - Mov BX, Offset ExecData - Mov DX, Offset DefaultShell - Cmp [COMSPECFound], 0 - JE DOSShell1 - - LDS DX, [COMSPEC] - -DOSShell1: - ClI - Int 21h - Assume DS:Nothing - - PopF - - Call S_InitScreen - Call D_InitDisk - Call InitMouse - - Cmp [CS:Control], 0 - JNE DOSShell4 - - Call K_InitKeyBoard - Jmp DOSShell5 - -DOSShell4: - Call K_UnInstallDOSHandler - -DOSShell5: - Call D_RestorePreShellDirectory - - Pop ES - Pop DS - PopAD - - Mov AX, 1 - Ret - -EndP DOSShell - Assume DS:Nothing - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - - -EndS - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Stack Segment ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment StackSeg PARA Stack 'Stack' -StackData DB StackSize Dup(?) -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End Start +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Startup Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +; TODO +;Jumps + +include switch.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Object1 BYTE Public 'Data' + Extrn HelpKeyValue:Word, OrderKeyValue:Word +EndS + +Segment InfoLine BYTE Public 'Code' USE16 + Extrn ShowUsageTime:Byte +EndS + +Segment Disk BYTE Public 'Code' USE16 + Extrn DiskOptions:Byte +EndS + +Segment Screen BYTE Public 'Code' + Extrn CharacterGenerationOffset:Word + Extrn VGAFlags:Byte +EndS + +Segment Mouse BYTE Public 'Code' + Extrn MouseCharacterGenerationOffset:Word +EndS + +Segment Main DWORD Public 'Code' USE16 + Extrn ReleaseTimeSlice:Byte +EndS + + Extrn D_InitDisk:Far + Extrn D_UnInitDisk:Far + Extrn D_DisableFileColours:Far + + Extrn E_InitEMS:Far + Extrn E_UnInitEMS:Far + + Extrn Error_InitHandler:Far + Extrn Error_UnInitHandler:Far + + Extrn K_InitKeyBoard:Far + Extrn K_UnInitKeyBoard:Far + Extrn K_InstallKeyboardType:Far + Extrn K_RemoveKeyboardType:Far + + Extrn K_InstallDOSHandler:Far + Extrn K_UnInstallDOSHandler:Far + Extrn K_SwapKeyBoard:Far + + Extrn O1_AutoDetectList:Far + Extrn O1_ConfirmQuit:Far + Extrn O1_PatternEditList:Far + Extrn O1_CrashRecovery:Far + Extrn O1_KeyboardList:Far + + Extrn M_Object1List:Far + + Extrn S_InitScreen:Far + Extrn S_ClearScreen:Far + Extrn S_UnInitScreen:Far + Extrn S_SetDirectMode:Far + Extrn S_DrawString:Far + + Extrn Music_InitMusic:Far + Extrn Music_UnInitMusic:Far + + Extrn Music_SetLimit:Far + Extrn Music_SetSoundCard:Far + Extrn Music_SetDMA:Far + Extrn Music_SetIRQ:Far + Extrn Music_SetMixSpeed:Far + Extrn Music_SetAddress:Far + Extrn Music_ReverseChannels:Far + Extrn Music_PatternStorage:Far + Extrn Music_SetSoundCardDriver:Far + Extrn Music_Stop:Far + Extrn Music_AutoDetectSoundCard:Far + +IF NETWORKENABLED + Extrn Network_Shutdown:Far +ENDIF + + Extrn PE_InitPatternEdit:Far + Extrn PE_UnInitPatternEdit:Far + Extrn PECheckModified:Far + + Extrn D_RestorePreShellDirectory:Far + Extrn D_GetPreShellDirectory:Far + + Extrn MMTSR_InstallMMTSR:Far + Extrn MMTSR_UninstallMMTSR:Far + + Extrn InitMouse:Far, UnInitMouse:Far + Extrn CmdLineDisableMouse:Far + + Extrn InitTimerHandler:Far, UnInitTimerHandler:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + + Global Quit:Far, Refresh:Far + Global DOSShell:Far, GetEnvironment:Far + Global CrashRecovery:Far + + Public IsStartupKeyList + Public GetStartupKeyList + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment StartUp BYTE Public 'Code' USE16 + Assume CS:StartUp, DS:Nothing, ES:Nothing + +CREATENEWLOGFILE EQU 1 +include debug.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +StackSize = 1000h + +No386Msg DB "Sorry, Impulse Tracker requires a 386+ processor to run." + DB 13, 10, "$" +WindowsMsg DB "Microsoft Windows detected.", 13, 10, 10 + DB "Due to instabilities in Windows, it is highly recommended that you run", 13, 10 + DB "Impulse Tracker in DOS instead.", 13, 10, 10 + DB "Press any key to continue..." + DB "$" + +PSP DW ? + +LoadMMTSR DB 1 +Pause DB 0 +COMSPECFound DB 0 +COMSPEC DD 0 +Control DB 0 +CommandTail DB 1, 0, 13 + +FCB1 DB 0, 11 Dup (32), 52 Dup (0) +FCB2 DB 0, 11 Dup (32), 52 Dup (0) + +COMSPECString DB "COMSPEC" +DefaultShell DB "C:\COMMAND.COM", 0 +EXECData DW 0 ; Inherit same environment block + DW Offset CommandTail, Startup + DW Offset FCB1, Startup + DW Offset FCB2, Startup +ShellMsg DB "Type EXIT to return to Impulse Tracker$" + +IF SHOWREGISTERNAME +include wavswitc.inc +include username.inc +ENDIF + +Label CmdLineHelp Byte +IF SHOWVERSION + DB "Impulse Tracker 2.14, Copyright (C) 1995-2000 Jeffrey Lim", 13, 10 + DB 10 + DB " Usage: IT.EXE [Switches]", 13, 10 +ELSE + DB "Impulse Tracker, Copyright (C) 1995-2000 Jeffrey Lim", 13, 10 +IF SHOWREGISTERNAME + DB "Registered to: " + DB REGISTERNAME + DB 13, 10 +ENDIF +ENDIF + DB 10 + DB "Switches:", 13, 10 + DB " SFilename.Drv Select sound card driver", 13, 10 + DB " S#", 9, 9, " Quick select sound card", 13, 10 + DB 9, "S0: No sound card", 9, 9, " S9: Pro Audio Spectrum", 13, 10 + DB 9, "S1: PC Speaker", 9, 9, 9, "S10: Pro Audio Spectrum 16", 13, 10 + DB 9, "S2: Sound Blaster 1.xx", 9, 9, "S11: Windows Sound System", 13, 10 + DB 9, "S3: Sound Blaster 2.xx", 9, 9, "S12: ESS ES1868 AudioDrive", 13, 10 + DB 9, "S4: Sound Blaster Pro", 9, 9, "S13: EWS64 XL Codec", 13, 10 + DB 9, "S5: Sound Blaster 16", 9, 9, "S14: Ensoniq SoundscapeVIVO", 13, 10 + DB 9, "S6: Sound Blaster AWE 32", 9, "S19: Generic MPU401", 13, 10 + DB 9, "S7: Gravis UltraSound", 9, 9, "S20: Disk Writer (WAV)", 13, 10 + DB 9, "S8: AMD Interwave", 9, 9, "S21: Disk Writer (MID)", 13, 10 + DB 10 + DB " Axxx", 9, "Set Base Address of sound card (hexadecimal)", 13, 10 + DB " I###", 9, "Set IRQ of sound card (decimal)", 13, 10 + DB " D###", 9, "Set DMA of sound card (decimal)", 13, 10 + DB 10 + DB " M###", 9, "Set Mixspeed", 13, 10 + DB " L###", 9, "Limit number of channels (4-256)", 13, 10 + DB "$" + +MixErrorMsg DB "Error: Mixing speed invalid - setting ignored", 13, 10, "$" +AddressErrorMsg DB "Error: Base Address invalid - setting ignored", 13, 10, "$" +IRQErrorMsg DB "Error: IRQ number invalid - setting ignored", 13, 10, "$" +LimitErrorMsg DB "Error: Channel limit number invalid - setting ignored", 13, 10, "$" +ContinueMsg DB "Press any key to continue...$" + +StartupList DB 0 +StartupMode DB 0 ; Load? Or Load/Play? or Load/Save +StartupFileOffset DW 0 +StartupFileSegment DW 0 +StartupKeyListFunction DW Offset GetStartupKeyList1 + + ; CX,DX +StartupInformation DW 11Ch, 0 ; Enter + DW 1Ch, 0 ; Release Enter + DW 10Fh, 0 ; Tab + DW 10Fh, 0 ; Tab + DW 10Fh, 0 ; Tab + DW 90Eh, 127 ; Ctrl-Backspace + +ENDSTARTUPINFORMATION EQU $ + +SaveInformation DW 0, 0 ; Loading screen key-loss + DW 1FFh, 13h ; Ctrl-S + DW 0, 0 ; Saving screen key-loss + DW 1FFh, 11h ; Ctrl-Q + DW 1FFh, 'Y' ; 'Y' + +ENDSAVEINFORMATION EQU $ + +StartupQueueOffset DW Offset StartupInformation +StartupQueueEnd DW Offset ENDSTARTUPINFORMATION +StartupQueueNextFunction DW Offset GetStartupKeyList2 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc CapitaliseAL + + Cmp AL, 'a' + JB CapitaliseAL1 + + Cmp AL, 'z' + JA CapitaliseAL1 + + Add AL, 'A'-'a' + +CapitaliseAL1: + Ret + +EndP CapitaliseAL + +CapitaliseAL: + cmp al, 'a' + jb .r + cmp al, 'z' + ja .r + or al, 'A'-'a' +.r: ret + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetDecimalNumber ; Returns CX + + LodsB + Cmp AL, '0' + JB GetDecimalNumber1 + Cmp AL, '9' + JBE GetDecimalNumber2 + +GetDecimalNumber1: + StC + Ret + +GetDecimalNumber2: + Xor CX, CX + +GetDecimalNumber3: + Mov BL, AL + Sub BL, '0' + Xor BH, BH + Mov AX, 10 + Mul CX + Add AX, BX + Mov CX, AX + LodsB + And DX, DX + JNZ GetDecimalNumber1 + + Cmp AL, '0' + JB GetDecimalNumber4 + Cmp AL, '9' + JA GetDecimalNumber4 + Jmp GetDecimalNumber3 + +GetDecimalNumber4: + ClC + Ret + +EndP GetDecimalNumber + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Start + Assume DS:Nothing + +; 386 check. + + Trace "Impulse Tracker Startup" + + Push SP + Pop AX + Cmp AX, SP + JNE No386 + + PushF + Pop CX ; CX = Flags. + Mov AX, CX + Or AX, 0F000h + Push AX + PopF + PushF + Pop AX + And AX, 0F000h + JNZ Found386 + +No386: + Push CS + Pop DS + + Mov AH, 9 + Mov DX, Offset No386Msg + Int 21h + + Mov AX, 4C02h + Int 21h + +Found386: +; Push 0B800h ; DEBUG!!!!! +; Pop GS ; DEBUG!!!!! + + Push CX + PopF + + ClD + + Mov [CS:PSP], ES + + Mov AX, ES + Mov BX, SS + Sub BX, AX + Add BX, StackSize / 16 ; Add BX, + Mov AH, 4Ah ; Re-allocate memory + Int 21h + + ; Check for 386 here. + + ; Do command line stuff. + Mov SI, 81h ; DS:SI points to cmdtail + +CmdLine1: + Push ES + Pop DS + + LodsB + +CmdLine3: + Cmp AL, 0Dh + JE CmdLineEnd + And AL, AL + JZ CmdLineEnd + + Call CapitaliseAL + +CmdLine2: + Cmp AL, 'K' + JE KeyboardSwap + Cmp AL, 'F' + JE DisableColours + Cmp AL, 'C' + JE SetControl + Cmp AL, 'H' + JE ShowCmdLineHelp + Cmp AL, '?' + JE ShowCmdLineHelp + Cmp AL, 'S' + JE SetSoundCard1 + Cmp AL, 'D' + JE SetDMA1 + Cmp AL, 'M' + JE SetMixSpeed1 + Cmp AL, 'I' + JE SetIRQ1 + Cmp AL, 'A' + JE SetAddress1 + Cmp AL, 'V' + JE OverrideVGA + Cmp AL, 'L' + JE Limit1 + Cmp AL, 'R' + JE Reverse1 + Cmp AL, 'X' + JE DisableFeatures + Cmp AL, 'P' + JE PatternStorage + Cmp AL, 'T' + JE NoShowUsageTime + Cmp AL, 'W' + JE ConvertModule + + Jmp CmdLine1 + +NoShowUsageTime: + LodsB + Cmp AL, '1' + JNE NoReleaseTimeSlice + + Push DS + + Push InfoLine + Pop DS + Assume DS:InfoLine + + Mov [ShowUsageTime], 0 + + Pop DS + Jmp CmdLine1 + Assume DS:Nothing + +NoReleaseTimeSlice: + Cmp AL, '2' + JNE CmdLine3 + +NoReleaseTimeSlice2: + Push DS + + Push Main + Pop DS + Assume DS:Main + + Mov [ReleaseTimeSlice], 1 + + Pop DS + Jmp CmdLine1 + +PatternStorage: + LodsB + Sub AL, '0' + JC PatternStorageEnd + Cmp AL, 2 + JA PatternStorageEnd + Call Music_PatternStorage + Jmp CmdLine1 + +PatternStorageEnd: + Jmp CmdLine3 + +DisableFeatures: + LodsB + Cmp AL, '1' + JB CmdLine3 + JE DisableMMTSR + + Cmp AL, '3' + JB DisableMouse + JE DisableDetectDriveMap + + Cmp AL, '5' + JB DisableCacheFiles + Jmp CmdLine3 + +DisableMouse: + Call CmdLineDisableMouse + Jmp CmdLine1 + +DisableMMTSR: + Mov [LoadMMTSR], 0 + Jmp CmdLine1 + +DisableDetectDriveMap: + Push Disk + Pop DS + Assume DS:Disk + + Or [DiskOptions], 1 + Jmp CmdLine1 + Assume DS:Nothing + +DisableCacheFiles: + Push Disk + Pop DS + Assume DS:Disk + + Or [DiskOptions], 2 + Jmp CmdLine1 + Assume DS:Nothing + +KeyboardSwap: + Mov AX, Object1 + Mov DS, AX + Assume DS:Object1 + + Mov [HelpKeyValue], 157h + Mov [OrderKeyValue], 13Bh + + Jmp CmdLine1 + Assume DS:Nothing + +DisableColours: + Call D_DisableFileColours + Jmp CmdLine1 + +Reverse1: + Call Music_ReverseChannels + Jmp CmdLine1 + +OverrideVGA: + LodsB + + Mov CX, Screen + Mov DS, CX + Assume DS:Screen + + Cmp AL, '1' + JE OverrideVGA1 + Cmp AL, '2' + JE Matrox + Cmp AL, '3' + JE WaitforRetrace + Cmp AL, '4' + JE Retrace + Jmp CmdLine3 + +OverrideVGA1: + Or [VGAFlags], 1 + Jmp CmdLine1 + +WaitforRetrace: + Or [VGAFlags], 4 + Jmp CmdLine1 + +Retrace: + Or [VGAFlags], 2 + Jmp CmdLine1 + +Matrox: + Mov [CharacterGenerationOffset], 256*32 + + Mov AX, Mouse + Mov DS, AX + Assume DS:Mouse + Mov [MouseCharacterGenerationOffset], 256*32 + + Jmp CmdLine1 + Assume DS:Nothing + +SetControl: + Mov [CS:Control], 1 + Jmp CmdLine1 + +ShowCmdLineHelp: + Push CS + Pop DS + + Mov AH, 9 + Mov DX, Offset CmdLineHelp + Int 21h + + Mov AX, 4C00h + Int 21h + +SetSoundCard1: + Call GetDecimalNumber + JC SetSoundCardDriver + Cmp CX, 21 + JA SetSoundCard2 + + Push AX + Mov AX, CX + Call Music_SetSoundCard + Pop AX + +SetSoundCard2: + Jmp CmdLine3 + +SetSoundCardDriver: + Cmp AL, 32 + JBE CmdLine3 + + Dec SI + Call Music_SetSoundCardDriver + +SetSoundCardDriver1: + LodsB + Cmp AL, 32 + JA SetSoundCardDriver1 + + Mov Byte Ptr [SI-1], 0 + Cmp AL, 32 + JE CmdLine1 + Jmp CmdLineEnd + +ConvertModule: + Mov [CS:StartupList], 1 + Mov [CS:StartupFileOffset], SI + Mov [CS:StartupFileSegment], DS + Jmp SetSoundCardDriver1 + +SetDMA1: + LodsB + Cmp AL, '0' + JB CmdLine3 + Cmp AL, '7' + JA CmdLine3 + Sub AL, '0' + Call Music_SetDMA + Jmp CmdLine1 + +SetMixSpeed1: + Call GetDecimalNumber + JC SetMixSpeedError + Push AX + Call Music_SetMixSpeed + Pop AX + Jmp CmdLine3 + +SetMixSpeedError: + Push CS + Pop DS + Assume DS:StartUp + + Mov AH, 9 + Mov DX, Offset MixErrorMsg + Int 21h + + Mov [Pause], 1 + Jmp CmdLine1 + Assume DS:Nothing + +SetIRQ1: + Call GetDecimalNumber + JC IRQError + Cmp CX, 15 + JA IRQError + + Push AX + Call Music_SetIRQ + Pop AX + Jmp CmdLine3 + +IRQError: + Push CS + Pop DS + Assume DS:StartUp + + Mov AH, 9 + Mov DX, Offset IRQErrorMsg + Int 21h + + Mov [Pause], 1 + Jmp CmdLine1 + Assume DS:Nothing + + +SetAddress1: + LodsB + + Xor DX, DX + Mov CL, 4 + + Cmp AL, '0' + JB SetAddress2 + Cmp AL, '9' + JA SetAddress2 + Sub AL, '0' + Jmp SetAddress3 + +SetAddress2: + Call CapitaliseAL + + Cmp AL, 'A' + JB CmdLine2 + Cmp AL, 'F' + JA CmdLine2 + Sub AL, '@' + +SetAddress3: + Test DX, 0F000h + JNZ AddressError + + ShL DX, CL + Or DL, AL + + LodsB + Cmp AL, '0' + JB SetAddress4 + Cmp AL, '9' + JA SetAddress4 + Sub AL, '0' + Jmp SetAddress3 + +SetAddress4: + Call CapitaliseAL + Cmp AL, 'A' + JB SetAddress5 + Cmp AL, 'F' + JA SetAddress5 + + Sub AL, '@' + Jmp SetAddress3 + +SetAddress5: + Call Music_SetAddress + Jmp CmdLine3 + +AddressError: + Push CS + Pop DS + Assume DS:StartUp + + Mov AH, 9 + Mov DX, Offset AddressErrorMsg + Int 21h + + Mov [Pause], 1 + Jmp CmdLine1 + Assume DS:Nothing + +Limit1: + Call GetDecimalNumber + JC LimitError + Cmp CX, 256 + JA LimitError + Cmp CX, 4 + JB LimitError + + Push AX + Call Music_SetLimit + Pop AX + Jmp CmdLine3 + +LimitError: + Push CS + Pop DS + Assume DS:StartUp + + Mov AH, 9 + Mov DX, Offset LimitErrorMsg + Int 21h + + Mov [Pause], 1 + Jmp CmdLine1 + Assume DS:Nothing + + +CmdLineEnd: + Trace "Command Line Parsed" + + Push CS + Pop DS + Assume DS:StartUp + + Trace "Windows Detection" + + Mov AX, 1600h ; Windows detection. + Int 2Fh + Test AL, 7Fh + JZ Start1 + Cmp AL, 4 ; Windows 4.0+ ?? + JAE Start1 + + Mov AH, 9 + Mov DX, Offset WindowsMsg + Int 21h + + Xor AX, AX + Int 16h + +Start1: + ; Get Comspec + Cmp [Pause], 1 + JNE NoPause + + Mov DX, Offset ContinueMsg + Mov AH, 9 + Int 21h + + Xor AX, AX + Int 16h + +NoPause: + Trace "Retrieving Environment" + + Mov SI, Offset COMSPECString + Mov CX, 7 + Call GetEnvironment + JC Start2 + + Mov [COMSPECFound], 1 + Mov [Word Ptr COMSPEC], DI + Mov [Word Ptr COMSPEC+2], ES + +Start2: + Mov FS, [CS:PSP] + + Trace "Initialising Screen Module" + + Call S_InitScreen + + Trace "Initialising Disk Module" + + Call D_InitDisk + + Trace "Initialising Expanded Memory Module" + + Call E_InitEMS + + Trace "Initialising Music Module" + + Call Music_InitMusic + + Trace "Initialising Keyboard Module" + + Call K_InitKeyBoard + + Trace "Initialising Edit Module" + + Call PE_InitPatternEdit + + Trace "Initialising Custom Keyboard Layout" + + Call K_InstallKeyboardType + + Trace "Initialising Error Handler Module" + + Call Error_InitHandler + + Cmp [CS:LoadMMTSR], 0 + JE SkipMMTSR + + Trace "Initialising MMTSR Module" + + Call MMTSR_InstallMMTSR + +SkipMMTSR: + Trace "Initialising Mouse Module" + + Call InitMouse + + Call S_ClearScreen + + Trace "Initialising Timer Module" + + Call InitTimerHandler + + Trace "Initialising Soundcard" + + Call Music_AutoDetectSoundCard + + Trace "Entering Main Message Loop" + + Mov DI, Offset O1_AutoDetectList +; Mov DI, Offset O1_KeyboardList + Mov CX, 0FFFFh + Call M_Object1List + Jmp Quit1 + +Proc Quit Far + + Mov DI, Offset O1_ConfirmQuit + Mov CX, 3 + Call M_Object1List + + And DX, DX + JNZ Quit1 + + Mov AX, 1 + RetF + +Quit1: + Call PECheckModified + Call Music_Stop + +IF NETWORKENABLED + Call Network_Shutdown +ENDIF + + Call MMTSR_UninstallMMTSR + Call PE_UnInitPatternEdit + Call Music_UnInitMusic + Call UnInitMouse + Call S_UnInitScreen + Call E_UnInitEMS + Call K_UnInitKeyBoard + Call Error_UnInitHandler + Call D_UnInitDisk + Call K_RemoveKeyboardType + Call UnInitTimerHandler + + Mov AX, 4C00h + Int 21h + +EndP Quit + +EndP Start + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc IsStartupKeyList Far + + Mov AL,CS:StartupList + + Ret + +EndP IsStartupKeyList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetStartupKeyList Far + + Jmp [CS:StartupKeyListFunction] + +GetStartupKeyList1: + Push SI + Mov SI, [CS:StartupQueueOffset] + + Mov CX, [CS:SI] + Mov DX, [CS:SI+2] + + Add SI, 4 + Mov [CS:StartupQueueOffset], SI + + Cmp SI, [CS:StartupQueueEnd] + + Pop SI + JB GetStartupKeyList1End + + Mov AX, [CS:StartupQueueNextFunction] + Mov [CS:StartupKeyListFunction], AX + +GetStartupKeyList1End: + Ret + +GetStartupKeyList2: + Push DS + Push SI + + LDS SI, [DWord Ptr CS:StartupFileOffset] + LodsB + + Mov [CS:StartupFileOffset], SI + + Pop SI + Pop DS + + Cmp AL, 32 + JE GetStartupKeyList2EndOfString + And AX, 0FFh + JZ GetStartupKeyList2EndOfString + + Mov DX, AX + Mov CX, 1FFh + + Ret + +GetStartupKeyList2EndOfString: + Mov [CS:StartupQueueOffset], Offset SaveInformation + Mov [CS:StartupQueueEnd], Offset ENDSAVEINFORMATION + Mov [CS:StartupQueueNextfunction], Offset GetStartupKeyList3 + Mov [CS:StartupKeyListFunction], Offset GetStartupKeyList1 + + Mov CX, 11Ch ; Enter + Mov DX, 0 + + Ret + +GetStartupKeyList3: ; Save module then quit + Xor CX, CX + Xor DX, DX + Mov [CS:StartupList], 0 + Ret + +EndP GetStartupKeyList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CrashRecovery Far ; CtrlAltDel location. + + ClD + StI + + Call S_ClearScreen + Call S_InitScreen + Call D_InitDisk + Call InitMouse + + Mov DI, Offset O1_CrashRecovery + Mov CX, 0FFFFh + Call M_Object1List + + Mov DI, Offset O1_PatternEditList + Mov CX, 0FFFFh + Jmp M_Object1List + +EndP CrashRecovery + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetEnvironment Far ; DS:SI points to string. + ; CX = length of string. + ; Returns ES:DI + + Mov ES, [CS:PSP] + Mov ES, [ES:2Ch] ; DS:00 points to environ. + Xor DI, DI + +GetEnvironment1: + Push DI + Push CX + Push SI + + RepE CmpSB + + Pop SI + Pop CX + Pop DI + + JE GetEnvironment3 ; From RepE + + Xor AL, AL + +GetEnvironment2: + ScasB + JNE GetEnvironment2 + + Cmp [Byte Ptr ES:DI], AL + JNE GetEnvironment1 + + StC + Ret + +GetEnvironment3: + Add DI, CX + Inc DI ; Skip past '=' + ClC + Ret + +EndP GetEnvironment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Refresh Far + + Call D_GetPreShellDirectory + Call S_InitScreen + Call D_InitDisk + Call InitMouse + Call D_RestorePreShellDirectory + + Mov AX, 1 + Ret + +EndP Refresh + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DOSShell Far + + PushAD + Push DS + Push ES + + PushF + + Call D_GetPreShellDirectory + + Cmp [CS:Control], 0 + JNE DOSShell2 + + Call K_UnInitKeyBoard + Jmp DOSShell3 + +DOSShell2: + Call K_InstallDOSHandler +DOSShell3: + + Mov AX, 3 + Int 10h ; Clr screen. + + Call UnInitMouse + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:StartUp + + Mov AH, 9 + Mov DX, Offset ShellMsg + Int 21h + + Mov AX, 4B00h + Mov BX, Offset ExecData + Mov DX, Offset DefaultShell + Cmp [COMSPECFound], 0 + JE DOSShell1 + + LDS DX, [COMSPEC] + +DOSShell1: + ClI + Int 21h + Assume DS:Nothing + + PopF + + Call S_InitScreen + Call D_InitDisk + Call InitMouse + + Cmp [CS:Control], 0 + JNE DOSShell4 + + Call K_InitKeyBoard + Jmp DOSShell5 + +DOSShell4: + Call K_UnInstallDOSHandler + +DOSShell5: + Call D_RestorePreShellDirectory + + Pop ES + Pop DS + PopAD + + Mov AX, 1 + Ret + +EndP DOSShell + Assume DS:Nothing + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + + +EndS + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Stack Segment ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment StackSeg PARA Stack 'Stack' +StackData DB StackSize Dup(?) +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End Start diff --git a/IT_D_INF.INC b/it_d_inf.inc similarity index 96% rename from IT_D_INF.INC rename to it_d_inf.inc index 4c2e52a..7b9311e 100644 --- a/IT_D_INF.INC +++ b/it_d_inf.inc @@ -1,1126 +1,1126 @@ - - -Proc D_GetSongNameModuleType - - LEA DI, [SI+17] ; ES:DI points to deposit point. - Sub SI, 8 - - Cmp DWord Ptr [DS:60000], 'MPMI' - JNE D_GetSongNameModuleType1 - - Mov DX, [DS:60000+2Ah] - Mov AX, 3 - - Cmp DX, TRACKERVERSION - JA D_GSNMTImpulse1 - - Dec AX - Cmp DX, 214h - JB D_GSNMTImpulse1 - - Mov AX, 7 - -D_GSNMTImpulse1: - Mov Word Ptr [SI+23], AX - - Mov SI, 60004 - Mov CX, 25 - Rep MovsB - - Ret - -D_GetSongNameModuleType1: -; Cmp Word Ptr [DS:60028], 101Ah -; JNE D_GetSongNameModuleType2 - - Cmp DWord Ptr [DS:60044], 'MRCS' - JNE D_GetSongNameModuleType2 - - Mov Word Ptr [SI+23], 4 - - Mov SI, 60000 - Mov CX, 25 - Rep MovsB - - Ret - -D_GetSongNameModuleType2: - Push SI ES DI - - Push CS - Pop ES - Mov SI, 60000 - Mov DI, Offset XMIdentification - Mov CX, 17 - RepE CmpsB - - Pop DI ES SI - JNE D_GetSongNameModuleTypeNotXM - - Mov Word Ptr [SI+23], 5 ; XM - - Mov SI, 60000+17 - Mov CX, 20 - Rep MovsB - Xor AX, AX -; Mov CX, 5 -; Rep StosB - Ret - -D_GetSongNameModuleTypeNotXM: - Mov AX, [DS:60000] - Cmp AX, 'fi' - JE D_GetSongNameModuleType669 - Cmp AX, 'NJ' - JNE D_GetSongNameModuleTypeNot669 - -D_GetSongNameModuleType669: ; We have a 669 module! - Mov Word Ptr [SI+23], 6 ; 669 - Mov SI, 60000+2 - Mov CX, 25 - Rep MovsB - Ret - -D_GetSongNameModuleTypeNot669: - Mov EAX, [DS:61080] - - Cmp EAX, '.K.M' - JNE D_GetSongNameModuleType3 - - Mov Word Ptr [SI+23], 9 - Jmp D_GSNMTMod - -D_GetSongNameModuleType3: - Cmp EAX, '!K!M' - JNE D_GetSongNameModuleType4 - - Mov Word Ptr [SI+23], 10 - Jmp D_GSNMTMod - -D_GetSongNameModuleType4: - Cmp EAX, 'NHC4' - JNE D_GetSongNameModuleType5 - - Mov Word Ptr [SI+23], 11 - Jmp D_GSNMTMod - -D_GetSongNameModuleType5: - Cmp EAX, 'NHC6' - JNE D_GetSongNameModuleType6 - - Mov Word Ptr [SI+23], 12 - Jmp D_GSNMTMod - -D_GetSongNameModuleType6: - Cmp EAX, 'NHC8' - JNE D_GetSongNameModuleType11 - - Mov Word Ptr [SI+23], 13 - Jmp D_GSNMTMod - -D_GetSongNameModuleType11: - Cmp Word Ptr [DS:61082], 'HC' - JNE D_GetSongNameModuleType7 - Cmp AL, '0' - JB D_GetSongNameModuleType7 - Cmp AL, '9' - JA D_GetSongNameModuleType7 - Cmp AH, '0' - JB D_GetSongNameModuleType7 - Cmp AH, '9' - JA D_GetSongNameModuleType7 - - ; Generic MOD type. - Sub AX, '00' - Mov BL, AH - Mov AH, 10 - Mul AH - Add BL, AL - Mov Word Ptr [SI+23], 17 - Mov Byte Ptr [SI+22], BL - - Jmp D_GSNMTMod - - -D_GetSongNameModuleType7: - Cmp EAX, '4TLF' - JNE D_GetSongNameModuleType8 - - Mov Word Ptr [SI+23], 14 - Jmp D_GSNMTMod - -D_GetSongNameModuleType8: -; Cmp EAX, '8TLF' -; JNE D_GetSongNameModuleType9 -; -; Mov Word Ptr [SI+23], 15 -; Jmp D_GSNMTMod -; -; D_GetSongNameModuleType9: - Cmp Byte Ptr [DS:60000+471], 78h - JNE D_GetSongNameModuleType10 - - Mov Word Ptr [SI+23], 16 - Jmp D_GSNMTMod - -D_GetSongNameModuleType10: - Cmp Word Ptr [DS:60000], 'M'+256*'T' - JNE D_GetSongNameModuleType12 - Cmp Byte Ptr [DS:60002], 'M' - JNE D_GetSongNameModuleType12 - - Mov Word Ptr [SI+23], 18 - - Mov SI, 60004 - Mov CX, 20 - Rep MovsB - Mov CX, 5 - Xor AL, AL - Rep StosB - -D_GetSongNameModuleType12: - Mov Word Ptr [SI+23], 1 - - Ret - -D_GSNMTMod: - Mov SI, 60000 - Mov CX, 20 - Rep MovsB - Xor AX, AX - StosW - StosW - StosB - - Ret - -EndP D_GetSongNameModuleType - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GetInstrumentInfo ; Instrument layout - ; 48 bytes per instrument. - ; Offset 0 = type of file. - ; 0 = Unchecked - ; 1 = Directory - ; 2 = Unrecognised - ; 3 = ITI - ; 4 = XI - ; 8 = .IT - ; 9 = .XM - ; Offset 1 = file name - ; 15->40 is the instrument name, - ; 40 = No. Samples - ; 42 = File size. - ; 44 = file offset (DWord) - - Mov AX, 48 - Mul BX - Mov DI, AX - - Mov DS, CS:DiskDataArea - Mov SI, 60000 - - ; Check for XM - Push CS - Pop ES - -; Comment ~ - - Push DI - Mov DI, Offset XMIdentification - Mov CX, 17 - RepE CmpSB - Pop DI - - Mov AL, 9 - JE D_InModuleInstrument ; XM module found? - - Mov SI, 60000 - - Cmp DWord Ptr [SI], 'MPMI' ; Impulse Tracker module? - JNE D_GetInstrumentInfoNotIT - Cmp Word Ptr [SI+22h], 0 - JE D_GetInstrumentInfoNotIT - Test Byte Ptr [SI+2Ch], 4 ; Instrument mode? - JZ D_GetInstrumentInfoNotIT - - Mov AL, 8 - -D_InModuleInstrument: - Push DS - Pop ES - - StosB - Add DI, 14 - Push CS - Pop DS - Mov SI, Offset LibraryMsg - Mov CX, 25 - Rep MovsB - Xor AX, AX - - Ret - -D_GetInstrumentInfoNotIT: -; ~ - - Cmp DWord Ptr [SI], 'IPMI' - JNE D_GetInstrumentInfo1 - - Push DS - Pop ES - Mov Byte Ptr [DI], 3 - - Mov AL, [SI+1Eh] - Xor AH, AH - - Add DI, 15 - Add SI, 20h - Mov CX, 25 - Rep MovsB - - StosW ; NOS. - - ClC - Ret - -D_GetInstrumentInfo1: ; Check for XI - Push DI - - Mov DI, Offset XIIdentification - Mov CX, 21 - RepE CmpsB - - Pop DI - JNE D_GetInstrumentInfo2 - -D_GetInstrumentInfoXI: - Push DS - Pop ES - - Mov Byte Ptr [DI], 4 ; XI - Add DI, 15 - Mov CX, 22 - Rep MovsB - Xor AX, AX - StosW - StosB - Mov AX, [DS:60000+128h] ; AX = number of samples - StosW ; NoS - Ret - -D_GetInstrumentInfo2: - Push DS - Pop ES - - Mov SI, DI - Mov CX, 48 - Mov AX, CS:NumInstruments - Sub AX, BX - Add SI, CX - Mul CX - Mov CX, AX - Rep MovsB - - Push CS - Pop DS - Assume DS:Disk - - Dec NumInstruments - - Mov AX, CurrentInstrument - Cmp AX, NumInstruments - JAE D_GetInstrumentInfo3 - - Cmp AX, BX - JBE D_GetInstrumentInfoEnd - -D_GetInstrumentInfo3: - Sub AX, 1 - AdC AX, 0 - -D_GetInstrumentInfoEnd: - Mov CurrentInstrument, AX - - StC - Ret - -EndP D_GetInstrumentInfo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GetSampleInfo ; BX = sample num. - - Mov AX, 96 - Mul BX - Mov DI, AX - Mov BX, AX - Mov DS, CS:DiskDataArea - Mov SI, 60000 - Push DS - Pop ES ; ES:DI points to sample block - ; DS:SI points to header - - Mov Byte Ptr [BX+90], 2 ; Recognised sample default. - - Cmp DWord Ptr [DS:60000], 'SPMI' - JE D_GetSampleInfo1 ; Possibly a IT sample. - Cmp DWord Ptr [DS:60000+4Ch], 'SRCS' - JE D_GetSampleInfo4 - Cmp DWord Ptr [DS:60000], 'FFIR' - JE D_GetSampleInfo8 ; AIFF? - Cmp DWord Ptr [DS:60000], 'MROF' - JE D_GetSampleInfo13 - - Mov AL, 21h - Cmp DWord Ptr [DS:60000], 'MPMI' - JE D_GetSampleInfoModuleTypes1 - - Mov AL, 23h - Cmp DWord Ptr [DS:60000+44], 'FMTP' - JE D_GetSampleInfoModuleTypes1 - - Inc AX ; AL = 24h - Mov ECX, [DS:60000] - And ECX, 0FFFFFFh - Cmp ECX, 'M'*10000h+'T'*100h+'M' - JE D_GetSampleInfoModuleTypes1 - - Inc AX ; AL = 25h - Cmp Word Ptr [DS:60000], 'fi' - JE D_GetSampleInfoModuleTypes1 - Cmp Word Ptr [DS:60000], 'NJ' - JE D_GetSampleInfoModuleTypes1 - - Inc AX ; AL = 26h - Cmp DWord Ptr [DS:60000], 'þRAF' - JE D_GetSampleInfoModuleTypes1 - - Mov ECX, [DS:60000+1080] - Mov AX, 427h ; MOD Module + 4 channels - Cmp ECX, '.K.M' - JE D_GetSampleInfoModuleTypes1 - Cmp ECX, '!K!M' - JE D_GetSampleInfoModuleTypes1 - Cmp ECX, '4TLF' - JE D_GetSampleInfoModuleTypes1 - Cmp ECX, 'NHC4' - JE D_GetSampleInfoModuleTypes1 - - Mov AH, 6 ; 6 Channel - Cmp ECX, 'NHC6' - JE D_GetSampleInfoModuleTypes1 - - Mov AH, 8 - Cmp ECX, 'NHC8' - JE D_GetSampleInfoModuleTypes1 - Cmp ECX, '8TLF' - JE D_GetSampleInfoModuleTypes1 - - Cmp Word Ptr [DS:61082], 'HC' - JNE D_GetSampleInfoS3M - - Sub CX, '00' - Cmp CL, 9 - JA D_GetSampleInfoS3M - Cmp CH, 9 - JA D_GetSampleInfoS3M - Mov AL, 10 - Mul CL - Add AL, CH - Mov AH, AL - Mov AL, 28h - Jmp D_GetSampleInfoModuleTypes1 - -D_GetSampleInfoS3M: - Cmp DWord Ptr [DS:60000+2Ch], 'MRCS' - JNE D_GetSampleInfoModuleTypes3 - - Mov AL, 20h ; ST3? - Jmp D_GetSampleInfoModuleTypes1 -; Cmp Word Ptr [DS:60000+1Ch], 101Ah -; JE D_GetSampleInfoModuleTypes1 -; Jmp D_GetSampleInfoModuleTypes3 - -D_GetSampleInfoModuleTypes3: ; KRZ - Cmp DWord Ptr [DS:60000], 'MARP' - JNE D_GetSampleInfoNotKRZ - - Cmp Word Ptr [DS:60000+32], 0FFFFh - JNE D_GetSampleInfoNotKRZ - - ; Check filename for .KRZ - - LEA SI, [BX+4] - Mov CX, 9 - -D_CheckKRZFileName: - Cmp Byte Ptr [SI], 0 - JE D_GetSampleInfoNotKRZ - - Cmp DWord Ptr [SI], 'ZRK.' - JE D_FoundKRZ - - Inc SI - Loop D_CheckKRZFileName - Jmp D_GetSampleInfoNotKRZ - -D_FoundKRZ: - Mov AL, 29h - Jmp D_GetSampleInfoModuleTypes1 - -D_GetSampleInfoNotKRZ: ; FT2 check - Push SI - Push ES - Push DI - - Push CS - Pop ES - Mov DI, Offset GUSPATIdentification - Mov CX, 22 - RepE CmpsB - - Pop DI - Pop ES - Pop SI - JNE D_GetSampleInfoNotPAT - - Cmp Byte Ptr [DS:60000+198], 1 - JE G_GetSampleInfoPAT - - Mov AL, 2Ah - Jmp D_GetSampleInfoModuleTypes1 - -G_GetSampleInfoPAT: - Mov Byte Ptr [BX+88], 16 - - Mov EAX, 'SPMI' - StosD - Mov SI, DI - Add DI, 13 - Mov AL, 64 - StosB ; Global vol = 64 - - Mov AX, 4001h ; sample present - Mov DL, [DS:60000+239+55] ; modes - - Test DL, 1 ; 8/16 bit - JZ GetSampleInfoPATSamples2 - - Or AL, 2 - -GetSampleInfoPATSamples2: - Test DL, 4 ; Looping enabled? - JZ GetSampleInfoPATSamples3 - - Or AL, 10h - -GetSampleInfoPATSamples3: - Test DL, 8 ; Ping pong loops? - JZ GetSampleInfoPATSamples4 - - Or AL, 40h - -GetSampleInfoPATSamples4: - StosW ; OK.. now for name. - - Mov SI, 60000+131 - Mov CX, 16 - -GetSampleInfoPATSamples5: - LodsB - Test AL, AL - JZ GetSampleInfoPATSamples6 - StosB - Loop GetSampleInfoPATSamples5 - - Xor AL, AL - -GetSampleInfoPATSamples6: - Add CX, 10 - Rep StosB - - ; Convert, default pan - - Mov AH, 32 - Mov AL, [DS:60000+239+55] - And AL, 2 - ShR AL, 1 - Xor AL, 1 - StosW - - ; Length. - - Mov DL, [DS:60000+239+55] - - Mov EAX, [DS:60000+239+16] ; LoopEnd -> FileSize - Mov [DI+20h], EAX ; File size - Call StorePATLength - - Mov EAX, [DS:60000+239+12] ; LoopBeg - Call StorePATLength - Mov EAX, [DS:60000+239+16] ; LoopEnd - Call StorePATLength - - Mov AX, [DS:60000+239+20] - And EAX, 0FFFFh - -Comment ~ - Push ES DI - - Call Music_GetPitchTable ; Returns ES:DI - Mov BP, [DS:60000+239+56] - And BP, 0FFh - ShL BP, 2 - Mul DWord Ptr [ES:DI+BP] - SHRD EAX, EDX, 16 - - Pop DI ES -~ - StosD ; C5Spd - - Xor EAX, EAX - StosD - StosD - - Mov EAX, 14Fh - StosD - - Xor AX, AX - StosW - StosW - - Ret - - -D_GetSampleInfoNotPAT: - Push SI - Push ES - Push DI - - Push CS - Pop ES - Mov DI, Offset XMIdentification - Mov CX, 17 - RepE CmpsB - - Pop DI - Pop ES - Pop SI - JNE TXWaveSampleIdentification - - Mov AL, 22h ; FT2 - -D_GetSampleInfoModuleTypes1: - Mov Word Ptr [BX+88], AX - Mov Byte Ptr [BX+90], 1 - - Push DS - - Push CS - Pop DS - - Mov SI, Offset LibraryMsg - LEA DI, [BX+14h] - Mov CX, 26/2 - Rep MovsW - - Pop DS - Ret - -TXWaveSampleIdentification: - Push SI - Push ES - Push DI - - Push CS - Pop ES - Mov DI, Offset TXWaveIdentification - Mov CX, 16 - RepE CmpSB - - Pop DI - Pop ES - Pop SI - ; OK.. have a TX Wave. - ; Now to transfer data. - JNE D_GetSampleInfo2 - - Mov AL, [DS:60000+16h] - And AL, 7Fh - Cmp AL, 49h - JNE D_GetSampleInfo2 - - Mov Byte Ptr [BX+88], 13 - - Mov EAX, 'SPMI' - StosD - Mov SI, DI - Add DI, 13 - Mov AL, 64 - StosB ; Global vol = 64 - - Mov AX, 64*256+1+2 ; Flag = sample + 16 bit - ; Default volume = 64 - Cmp Byte Ptr [DS:60000+16h], 049h - JNE D_GetTXInfo3 - - Or AL, 10h ; Loop forwards - -D_GetTXInfo3: - StosW - - Mov CX, 13 - -D_GetTXInfo1: - LodsB - Test AL, AL - JZ D_GetTXInfo2 - - StosB - Loop D_GetTXInfo1 - -D_GetTXInfo2: - Xor AL, AL - Rep StosB - - Mov CX, 13 - Rep StosB - ; Length... - Mov AX, 16+1 ; TX Wave, signed - StosW - - Mov EDX, [DS:60000+18h] - Mov ECX, [DS:60000+1Bh] - And EDX, 1FFFFh ; Attack length - And ECX, 1FFFFh ; Loop Length - - Mov EAX, ECX - Add EAX, EDX ; Length - StosD - Mov EAX, EDX ; LoopStart - StosD - Add EAX, ECX ; LoopEnd - StosD - - Mov EAX, 33000 ; Freq - Cmp Byte Ptr [DS:60000+17h], 2 - JB D_GetTXInfo4 - - Mov AX, 50000 - JE D_GetTXInfo4 - - Mov AX, 16000 - -D_GetTXInfo4: - StosD ; Frequency - Xor EAX, EAX - StosD - StosD - Mov AX, 20h - StosD - Xor AX, AX - StosD - - Ret - -D_GetSampleInfo2: - Mov DWord Ptr [BX+88], 30004h ; Unknown Type - - Mov EAX, 'SPMI' - StosD - Mov SI, DI - Add DI, 13 - Mov AL, 64 - StosB ; Global vol = 64 - Mov AL, 1 - StosB ; Flag = sample. - Mov AL, 64 - StosB ; Default vol = 64. - - Mov CX, 13 - -D_GetSampleInfo6: - LodsB - Test AL, AL - JZ D_GetSampleInfo7 - - StosB - Loop D_GetSampleInfo6 - -D_GetSampleInfo7: - Xor AL, AL - Rep StosB - - Mov CX, 15 - Rep StosB - ; Length... - Mov EAX, 4177910 - - Cmp EAX, [BX+80] - JB D_GetSampleInfo3 - - Mov EAX, [BX+80] - -D_GetSampleInfo3: - StosD - Xor AX, AX - StosW - StosW - StosW - StosW - Mov AX, 8363 - StosW - Xor AX, AX - Mov CX, 9 - Rep StosW - - Ret - -D_GetSampleInfo1: - Mov Byte Ptr [BX+88], 2 - - Mov CX, 4 - Rep MovsB - Add SI, 12 - Add DI, 12 - Mov CX, 64 - Rep MovsB - - Ret - -D_GetSampleInfo4: - Mov Byte Ptr [BX+88], 3 ; Scrm - - Mov EAX, 'SPMI' - StosD - - Add DI, 13 - Mov AL, 64 - StosB - - Mov AL, 1 - Mov CL, [DS:60000+1Fh] - Mov CH, CL - - And CL, 1 - ShL CL, 4 - Or AL, CL ; Loop... - - And CH, 4 - ShR CH, 1 - Or AL, CH ; 16 bit. - -D_GetSampleInfo5: - StosB - Mov AL, [DS:60000+1Ch] - StosB - Mov SI, 60000+30h - Mov CX, 25 - Rep MovsB - Xor AX, AX - StosB - StosW ; Name done... now for length - - Mov EAX, [DS:60000+10h] - StosD - Mov EAX, [DS:60000+14h] - StosD - Mov EAX, [DS:60000+18h] - StosD - Mov EAX, [DS:60000+20h] ; C5Spd - StosD - Xor AX, AX - StosW - StosW - StosW - StosW - ; Now for sample pointer. - Mov CL, 4 - Mov AX, [DS:60000+0Eh] - Mov DL, [DS:60000+0Fh] - Mov DH, [DS:60000+0Dh] - ShL AX, CL - ShR DX, CL - StosW ; Sample pointer in file. - Mov AX, DX - StosW - - Xor AX, AX ; Vibrato info - StosW - StosW - - Ret - -D_GetSampleInfo8: ; WAV Identification - Push SI - Push DI - Push DS - - Push CS - Pop DS - Mov SI, Offset WAVEfmtID - Mov DI, 60008 - Mov CX, 8 - RepE CmpsB - JNE NotWAV - - Add DI, 2 - Mov CX, 4 - RepE CmpsB - -NotWAV: - Pop DS - - JNE D_GetSampleInfo9 - - Mov BP, 60000+18h - Add BP, [DS:60000+10h] - Mov CX, 3 ; Only allow 3 blocks - -CheckNextWAVE: - Cmp DWord Ptr [DS:BP-4], 'atad' - JE D_GetSampleWaveFound - - Mov AX, [DS:BP] - Add AX, 8 - Add BP, AX - JC D_GetSampleInfo9 - - Loop CheckNextWAVE - Jmp D_GetSampleInfo9 - -D_GetSampleWaveFound: - Mov DL, [DS:60000+22h] ; DL = number of bits. - Mov DH, 1 - Cmp DL, 8 - JE D_GetSampleInfo9 - - Mov DH, 3 - Cmp DL, 16 - -D_GetSampleInfo9: - Pop DI - Pop SI - JNE D_GetSampleInfo2 - ; We have a WAV file! - Cmp Word Ptr [DS:60000+16h], 2 - JNE D_GetSampleWAVStereo - - Or DH, 4 - -D_GetSampleWAVStereo: - Mov AL, DH - And AL, 3 - Add AL, 4 - Mov Byte Ptr [BX+88], AL ; 5 = 8 bit, 7 = 16 bit. - - Mov EAX, 'SPMI' - StosD - - Mov SI, DI - Add DI, 13 - Mov AL, 64 - StosB ; Global vol = 64 - Mov AL, DH - StosB ; Flag = sample. - Mov AL, 64 - StosB ; Default vol = 64. - - Mov CX, 13 - -D_GetSampleInfo10: - LodsB - And AL, AL - JZ D_GetSampleInfo11 - - StosB - Loop D_GetSampleInfo10 - -D_GetSampleInfo11: - Xor AX, AX - Add CX, 13 - Rep StosB - - Mov AL, DH - And AL, 4 ; stereo? - ShL AL, 3 - - Test DH, 2 - JZ D_GetSampleInfo19 - - Inc AX - -D_GetSampleInfo19: - StosW ; Sample format - - Mov EAX, 4177910 ; Length - - Cmp EAX, [DS:BP] - JB D_GetSampleInfo12 - - Mov EAX, [DS:BP] - -D_GetSampleInfo12: - Test DH, 2 - JZ D_GetSampleInfo18 - - ShR EAX, 1 - -D_GetSampleInfo18: - Test DH, 4 - JZ D_GetSampleWAVStereo2 - - ShR EAX, 1 - -D_GetSampleWAVStereo2: - StosD - - Xor AX, AX - StosW - StosW - StosW - StosW - - Mov AX, [DS:60000+18h] ; Frequency - StosW - Xor AX, AX - Mov CX, 5 - Rep StosW - Mov AX, BP - Add AX, 4-60000 -; Mov AX, 2Ch - StosW - Xor AX, AX - StosW - StosW - StosW - - Ret - -D_GetSampleInfo13: ; AIFF Identification - Mov AL, 3 - Cmp DWord Ptr [DS:60000+8], 'VS61' - JE D_GetSampleInfoIFF - - Mov AL, 1 - Cmp DWord Ptr [DS:60000+8], 'XVS8' - JNE D_GetSampleInfo2 - -D_GetSampleInfoIFF: - Mov Byte Ptr [BX+88], 17 ; AIFF format. - Mov Byte Ptr [BX+12h], AL - Mov SI, 60000 + 0Ch - -D_GetSampleInfoIFF1: - Cmp DWord Ptr [DS:SI], 'EMAN' - JE D_GetSampleInfoIFFName - - Cmp DWord Ptr [DS:SI], 'RDHV' - JE D_GetSampleInfoIFFHeader - - Cmp DWord Ptr [DS:SI], 'YDOB' - JNE D_IFFHeaderNext - - ; Body. - Mov DWord Ptr [DI], 'SPMI' - Mov Byte Ptr [DI+11h], 64 ; Global volume - Mov Byte Ptr [DI+13h], 64 ; Default volume - Mov Word Ptr [DI+2Eh], 1 ; Sign conversion - - Add DI, 30h - Mov AX, [SI+06h] ; Size - Mov DX, [SI+04h] - Call Near Ptr D_GetSampleInfoBSwap - StosD - Xor EAX, EAX - Add DI, 0Ch - StosD - StosD - StosD - StosD - - Add SI, 8-60000 - Mov [BX+48h], SI - - Ret - -D_GetSampleInfoIFFName: - Push SI - Push DI - - Mov CX, [SI+6] - XChg CL, CH - Cmp CX, 25 - JBE D_GetSampleInfoIFFName1 - - Mov CX, 25 - -D_GetSampleInfoIFFName1: - Add SI, 8 - Add DI, 14h - Rep MovsB - -D_IFFHeaderEnd: - Pop DI - Pop SI - -D_IFFHeaderNext: - Mov AX, [SI+6] - XChg AL, AH - Add AX, 8 - Add SI, AX - JC D_GetSampleInfo2 - - Jmp D_GetSampleInfoIFF1 - -D_GetSampleInfoIFFHeader: - Push SI - Push DI - - Add DI, 34h - - Mov AX, [SI+0Eh] ; Loop start - Mov DX, [SI+0Ch] - Call Near Ptr D_GetSampleInfoBSwap - StosD - - Push EAX - Mov AX, [SI+12h] ; Loop end - Mov DX, [SI+10h] - Call Near Ptr D_GetSampleInfoBSwap - Test EAX, EAX - JZ D_GetSampleInfoIFFHeader1 - - Or Byte Ptr [BX+12h], 16 - -D_GetSampleInfoIFFHeader1: - Pop EDX - Add EAX, EDX - StosD - - Xor EAX, EAX - Mov AX, [SI+14h] - XChg AL, AH - StosD - - Jmp D_IFFHeaderEnd - -D_GetSampleInfoBSwap: - XChg DH, AL - XChg DL, AH - - ShL EAX, 16 - Mov AX, DX - - Test Byte Ptr [BX+12h], 2 - JZ D_GetSampleInfo17 - - ShR EAX, 1 ; Halve length for 16-bit samples. - -D_GetSampleInfo17: - RetN - -EndP D_GetSampleInfo - + + +Proc D_GetSongNameModuleType + + LEA DI, [SI+17] ; ES:DI points to deposit point. + Sub SI, 8 + + Cmp DWord Ptr [DS:60000], 'MPMI' + JNE D_GetSongNameModuleType1 + + Mov DX, [DS:60000+2Ah] + Mov AX, 3 + + Cmp DX, TRACKERVERSION + JA D_GSNMTImpulse1 + + Dec AX + Cmp DX, 214h + JB D_GSNMTImpulse1 + + Mov AX, 7 + +D_GSNMTImpulse1: + Mov Word Ptr [SI+23], AX + + Mov SI, 60004 + Mov CX, 25 + Rep MovsB + + Ret + +D_GetSongNameModuleType1: +; Cmp Word Ptr [DS:60028], 101Ah +; JNE D_GetSongNameModuleType2 + + Cmp DWord Ptr [DS:60044], 'MRCS' + JNE D_GetSongNameModuleType2 + + Mov Word Ptr [SI+23], 4 + + Mov SI, 60000 + Mov CX, 25 + Rep MovsB + + Ret + +D_GetSongNameModuleType2: + Push SI ES DI + + Push CS + Pop ES + Mov SI, 60000 + Mov DI, Offset XMIdentification + Mov CX, 17 + RepE CmpsB + + Pop DI ES SI + JNE D_GetSongNameModuleTypeNotXM + + Mov Word Ptr [SI+23], 5 ; XM + + Mov SI, 60000+17 + Mov CX, 20 + Rep MovsB + Xor AX, AX +; Mov CX, 5 +; Rep StosB + Ret + +D_GetSongNameModuleTypeNotXM: + Mov AX, [DS:60000] + Cmp AX, 'fi' + JE D_GetSongNameModuleType669 + Cmp AX, 'NJ' + JNE D_GetSongNameModuleTypeNot669 + +D_GetSongNameModuleType669: ; We have a 669 module! + Mov Word Ptr [SI+23], 6 ; 669 + Mov SI, 60000+2 + Mov CX, 25 + Rep MovsB + Ret + +D_GetSongNameModuleTypeNot669: + Mov EAX, [DS:61080] + + Cmp EAX, '.K.M' + JNE D_GetSongNameModuleType3 + + Mov Word Ptr [SI+23], 9 + Jmp D_GSNMTMod + +D_GetSongNameModuleType3: + Cmp EAX, '!K!M' + JNE D_GetSongNameModuleType4 + + Mov Word Ptr [SI+23], 10 + Jmp D_GSNMTMod + +D_GetSongNameModuleType4: + Cmp EAX, 'NHC4' + JNE D_GetSongNameModuleType5 + + Mov Word Ptr [SI+23], 11 + Jmp D_GSNMTMod + +D_GetSongNameModuleType5: + Cmp EAX, 'NHC6' + JNE D_GetSongNameModuleType6 + + Mov Word Ptr [SI+23], 12 + Jmp D_GSNMTMod + +D_GetSongNameModuleType6: + Cmp EAX, 'NHC8' + JNE D_GetSongNameModuleType11 + + Mov Word Ptr [SI+23], 13 + Jmp D_GSNMTMod + +D_GetSongNameModuleType11: + Cmp Word Ptr [DS:61082], 'HC' + JNE D_GetSongNameModuleType7 + Cmp AL, '0' + JB D_GetSongNameModuleType7 + Cmp AL, '9' + JA D_GetSongNameModuleType7 + Cmp AH, '0' + JB D_GetSongNameModuleType7 + Cmp AH, '9' + JA D_GetSongNameModuleType7 + + ; Generic MOD type. + Sub AX, '00' + Mov BL, AH + Mov AH, 10 + Mul AH + Add BL, AL + Mov Word Ptr [SI+23], 17 + Mov Byte Ptr [SI+22], BL + + Jmp D_GSNMTMod + + +D_GetSongNameModuleType7: + Cmp EAX, '4TLF' + JNE D_GetSongNameModuleType8 + + Mov Word Ptr [SI+23], 14 + Jmp D_GSNMTMod + +D_GetSongNameModuleType8: +; Cmp EAX, '8TLF' +; JNE D_GetSongNameModuleType9 +; +; Mov Word Ptr [SI+23], 15 +; Jmp D_GSNMTMod +; +; D_GetSongNameModuleType9: + Cmp Byte Ptr [DS:60000+471], 78h + JNE D_GetSongNameModuleType10 + + Mov Word Ptr [SI+23], 16 + Jmp D_GSNMTMod + +D_GetSongNameModuleType10: + Cmp Word Ptr [DS:60000], 'M'+256*'T' + JNE D_GetSongNameModuleType12 + Cmp Byte Ptr [DS:60002], 'M' + JNE D_GetSongNameModuleType12 + + Mov Word Ptr [SI+23], 18 + + Mov SI, 60004 + Mov CX, 20 + Rep MovsB + Mov CX, 5 + Xor AL, AL + Rep StosB + +D_GetSongNameModuleType12: + Mov Word Ptr [SI+23], 1 + + Ret + +D_GSNMTMod: + Mov SI, 60000 + Mov CX, 20 + Rep MovsB + Xor AX, AX + StosW + StosW + StosB + + Ret + +EndP D_GetSongNameModuleType + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GetInstrumentInfo ; Instrument layout + ; 48 bytes per instrument. + ; Offset 0 = type of file. + ; 0 = Unchecked + ; 1 = Directory + ; 2 = Unrecognised + ; 3 = ITI + ; 4 = XI + ; 8 = .IT + ; 9 = .XM + ; Offset 1 = file name + ; 15->40 is the instrument name, + ; 40 = No. Samples + ; 42 = File size. + ; 44 = file offset (DWord) + + Mov AX, 48 + Mul BX + Mov DI, AX + + Mov DS, CS:DiskDataArea + Mov SI, 60000 + + ; Check for XM + Push CS + Pop ES + +; Comment ~ + + Push DI + Mov DI, Offset XMIdentification + Mov CX, 17 + RepE CmpSB + Pop DI + + Mov AL, 9 + JE D_InModuleInstrument ; XM module found? + + Mov SI, 60000 + + Cmp DWord Ptr [SI], 'MPMI' ; Impulse Tracker module? + JNE D_GetInstrumentInfoNotIT + Cmp Word Ptr [SI+22h], 0 + JE D_GetInstrumentInfoNotIT + Test Byte Ptr [SI+2Ch], 4 ; Instrument mode? + JZ D_GetInstrumentInfoNotIT + + Mov AL, 8 + +D_InModuleInstrument: + Push DS + Pop ES + + StosB + Add DI, 14 + Push CS + Pop DS + Mov SI, Offset LibraryMsg + Mov CX, 25 + Rep MovsB + Xor AX, AX + + Ret + +D_GetInstrumentInfoNotIT: +; ~ + + Cmp DWord Ptr [SI], 'IPMI' + JNE D_GetInstrumentInfo1 + + Push DS + Pop ES + Mov Byte Ptr [DI], 3 + + Mov AL, [SI+1Eh] + Xor AH, AH + + Add DI, 15 + Add SI, 20h + Mov CX, 25 + Rep MovsB + + StosW ; NOS. + + ClC + Ret + +D_GetInstrumentInfo1: ; Check for XI + Push DI + + Mov DI, Offset XIIdentification + Mov CX, 21 + RepE CmpsB + + Pop DI + JNE D_GetInstrumentInfo2 + +D_GetInstrumentInfoXI: + Push DS + Pop ES + + Mov Byte Ptr [DI], 4 ; XI + Add DI, 15 + Mov CX, 22 + Rep MovsB + Xor AX, AX + StosW + StosB + Mov AX, [DS:60000+128h] ; AX = number of samples + StosW ; NoS + Ret + +D_GetInstrumentInfo2: + Push DS + Pop ES + + Mov SI, DI + Mov CX, 48 + Mov AX, CS:NumInstruments + Sub AX, BX + Add SI, CX + Mul CX + Mov CX, AX + Rep MovsB + + Push CS + Pop DS + Assume DS:Disk + + Dec NumInstruments + + Mov AX, CurrentInstrument + Cmp AX, NumInstruments + JAE D_GetInstrumentInfo3 + + Cmp AX, BX + JBE D_GetInstrumentInfoEnd + +D_GetInstrumentInfo3: + Sub AX, 1 + AdC AX, 0 + +D_GetInstrumentInfoEnd: + Mov CurrentInstrument, AX + + StC + Ret + +EndP D_GetInstrumentInfo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GetSampleInfo ; BX = sample num. + + Mov AX, 96 + Mul BX + Mov DI, AX + Mov BX, AX + Mov DS, CS:DiskDataArea + Mov SI, 60000 + Push DS + Pop ES ; ES:DI points to sample block + ; DS:SI points to header + + Mov Byte Ptr [BX+90], 2 ; Recognised sample default. + + Cmp DWord Ptr [DS:60000], 'SPMI' + JE D_GetSampleInfo1 ; Possibly a IT sample. + Cmp DWord Ptr [DS:60000+4Ch], 'SRCS' + JE D_GetSampleInfo4 + Cmp DWord Ptr [DS:60000], 'FFIR' + JE D_GetSampleInfo8 ; AIFF? + Cmp DWord Ptr [DS:60000], 'MROF' + JE D_GetSampleInfo13 + + Mov AL, 21h + Cmp DWord Ptr [DS:60000], 'MPMI' + JE D_GetSampleInfoModuleTypes1 + + Mov AL, 23h + Cmp DWord Ptr [DS:60000+44], 'FMTP' + JE D_GetSampleInfoModuleTypes1 + + Inc AX ; AL = 24h + Mov ECX, [DS:60000] + And ECX, 0FFFFFFh + Cmp ECX, 'M'*10000h+'T'*100h+'M' + JE D_GetSampleInfoModuleTypes1 + + Inc AX ; AL = 25h + Cmp Word Ptr [DS:60000], 'fi' + JE D_GetSampleInfoModuleTypes1 + Cmp Word Ptr [DS:60000], 'NJ' + JE D_GetSampleInfoModuleTypes1 + + Inc AX ; AL = 26h + Cmp DWord Ptr [DS:60000], 'þRAF' + JE D_GetSampleInfoModuleTypes1 + + Mov ECX, [DS:60000+1080] + Mov AX, 427h ; MOD Module + 4 channels + Cmp ECX, '.K.M' + JE D_GetSampleInfoModuleTypes1 + Cmp ECX, '!K!M' + JE D_GetSampleInfoModuleTypes1 + Cmp ECX, '4TLF' + JE D_GetSampleInfoModuleTypes1 + Cmp ECX, 'NHC4' + JE D_GetSampleInfoModuleTypes1 + + Mov AH, 6 ; 6 Channel + Cmp ECX, 'NHC6' + JE D_GetSampleInfoModuleTypes1 + + Mov AH, 8 + Cmp ECX, 'NHC8' + JE D_GetSampleInfoModuleTypes1 + Cmp ECX, '8TLF' + JE D_GetSampleInfoModuleTypes1 + + Cmp Word Ptr [DS:61082], 'HC' + JNE D_GetSampleInfoS3M + + Sub CX, '00' + Cmp CL, 9 + JA D_GetSampleInfoS3M + Cmp CH, 9 + JA D_GetSampleInfoS3M + Mov AL, 10 + Mul CL + Add AL, CH + Mov AH, AL + Mov AL, 28h + Jmp D_GetSampleInfoModuleTypes1 + +D_GetSampleInfoS3M: + Cmp DWord Ptr [DS:60000+2Ch], 'MRCS' + JNE D_GetSampleInfoModuleTypes3 + + Mov AL, 20h ; ST3? + Jmp D_GetSampleInfoModuleTypes1 +; Cmp Word Ptr [DS:60000+1Ch], 101Ah +; JE D_GetSampleInfoModuleTypes1 +; Jmp D_GetSampleInfoModuleTypes3 + +D_GetSampleInfoModuleTypes3: ; KRZ + Cmp DWord Ptr [DS:60000], 'MARP' + JNE D_GetSampleInfoNotKRZ + + Cmp Word Ptr [DS:60000+32], 0FFFFh + JNE D_GetSampleInfoNotKRZ + + ; Check filename for .KRZ + + LEA SI, [BX+4] + Mov CX, 9 + +D_CheckKRZFileName: + Cmp Byte Ptr [SI], 0 + JE D_GetSampleInfoNotKRZ + + Cmp DWord Ptr [SI], 'ZRK.' + JE D_FoundKRZ + + Inc SI + Loop D_CheckKRZFileName + Jmp D_GetSampleInfoNotKRZ + +D_FoundKRZ: + Mov AL, 29h + Jmp D_GetSampleInfoModuleTypes1 + +D_GetSampleInfoNotKRZ: ; FT2 check + Push SI + Push ES + Push DI + + Push CS + Pop ES + Mov DI, Offset GUSPATIdentification + Mov CX, 22 + RepE CmpsB + + Pop DI + Pop ES + Pop SI + JNE D_GetSampleInfoNotPAT + + Cmp Byte Ptr [DS:60000+198], 1 + JE G_GetSampleInfoPAT + + Mov AL, 2Ah + Jmp D_GetSampleInfoModuleTypes1 + +G_GetSampleInfoPAT: + Mov Byte Ptr [BX+88], 16 + + Mov EAX, 'SPMI' + StosD + Mov SI, DI + Add DI, 13 + Mov AL, 64 + StosB ; Global vol = 64 + + Mov AX, 4001h ; sample present + Mov DL, [DS:60000+239+55] ; modes + + Test DL, 1 ; 8/16 bit + JZ GetSampleInfoPATSamples2 + + Or AL, 2 + +GetSampleInfoPATSamples2: + Test DL, 4 ; Looping enabled? + JZ GetSampleInfoPATSamples3 + + Or AL, 10h + +GetSampleInfoPATSamples3: + Test DL, 8 ; Ping pong loops? + JZ GetSampleInfoPATSamples4 + + Or AL, 40h + +GetSampleInfoPATSamples4: + StosW ; OK.. now for name. + + Mov SI, 60000+131 + Mov CX, 16 + +GetSampleInfoPATSamples5: + LodsB + Test AL, AL + JZ GetSampleInfoPATSamples6 + StosB + Loop GetSampleInfoPATSamples5 + + Xor AL, AL + +GetSampleInfoPATSamples6: + Add CX, 10 + Rep StosB + + ; Convert, default pan + + Mov AH, 32 + Mov AL, [DS:60000+239+55] + And AL, 2 + ShR AL, 1 + Xor AL, 1 + StosW + + ; Length. + + Mov DL, [DS:60000+239+55] + + Mov EAX, [DS:60000+239+16] ; LoopEnd -> FileSize + Mov [DI+20h], EAX ; File size + Call StorePATLength + + Mov EAX, [DS:60000+239+12] ; LoopBeg + Call StorePATLength + Mov EAX, [DS:60000+239+16] ; LoopEnd + Call StorePATLength + + Mov AX, [DS:60000+239+20] + And EAX, 0FFFFh + +Comment ~ + Push ES DI + + Call Music_GetPitchTable ; Returns ES:DI + Mov BP, [DS:60000+239+56] + And BP, 0FFh + ShL BP, 2 + Mul DWord Ptr [ES:DI+BP] + SHRD EAX, EDX, 16 + + Pop DI ES +~ + StosD ; C5Spd + + Xor EAX, EAX + StosD + StosD + + Mov EAX, 14Fh + StosD + + Xor AX, AX + StosW + StosW + + Ret + + +D_GetSampleInfoNotPAT: + Push SI + Push ES + Push DI + + Push CS + Pop ES + Mov DI, Offset XMIdentification + Mov CX, 17 + RepE CmpsB + + Pop DI + Pop ES + Pop SI + JNE TXWaveSampleIdentification + + Mov AL, 22h ; FT2 + +D_GetSampleInfoModuleTypes1: + Mov Word Ptr [BX+88], AX + Mov Byte Ptr [BX+90], 1 + + Push DS + + Push CS + Pop DS + + Mov SI, Offset LibraryMsg + LEA DI, [BX+14h] + Mov CX, 26/2 + Rep MovsW + + Pop DS + Ret + +TXWaveSampleIdentification: + Push SI + Push ES + Push DI + + Push CS + Pop ES + Mov DI, Offset TXWaveIdentification + Mov CX, 16 + RepE CmpSB + + Pop DI + Pop ES + Pop SI + ; OK.. have a TX Wave. + ; Now to transfer data. + JNE D_GetSampleInfo2 + + Mov AL, [DS:60000+16h] + And AL, 7Fh + Cmp AL, 49h + JNE D_GetSampleInfo2 + + Mov Byte Ptr [BX+88], 13 + + Mov EAX, 'SPMI' + StosD + Mov SI, DI + Add DI, 13 + Mov AL, 64 + StosB ; Global vol = 64 + + Mov AX, 64*256+1+2 ; Flag = sample + 16 bit + ; Default volume = 64 + Cmp Byte Ptr [DS:60000+16h], 049h + JNE D_GetTXInfo3 + + Or AL, 10h ; Loop forwards + +D_GetTXInfo3: + StosW + + Mov CX, 13 + +D_GetTXInfo1: + LodsB + Test AL, AL + JZ D_GetTXInfo2 + + StosB + Loop D_GetTXInfo1 + +D_GetTXInfo2: + Xor AL, AL + Rep StosB + + Mov CX, 13 + Rep StosB + ; Length... + Mov AX, 16+1 ; TX Wave, signed + StosW + + Mov EDX, [DS:60000+18h] + Mov ECX, [DS:60000+1Bh] + And EDX, 1FFFFh ; Attack length + And ECX, 1FFFFh ; Loop Length + + Mov EAX, ECX + Add EAX, EDX ; Length + StosD + Mov EAX, EDX ; LoopStart + StosD + Add EAX, ECX ; LoopEnd + StosD + + Mov EAX, 33000 ; Freq + Cmp Byte Ptr [DS:60000+17h], 2 + JB D_GetTXInfo4 + + Mov AX, 50000 + JE D_GetTXInfo4 + + Mov AX, 16000 + +D_GetTXInfo4: + StosD ; Frequency + Xor EAX, EAX + StosD + StosD + Mov AX, 20h + StosD + Xor AX, AX + StosD + + Ret + +D_GetSampleInfo2: + Mov DWord Ptr [BX+88], 30004h ; Unknown Type + + Mov EAX, 'SPMI' + StosD + Mov SI, DI + Add DI, 13 + Mov AL, 64 + StosB ; Global vol = 64 + Mov AL, 1 + StosB ; Flag = sample. + Mov AL, 64 + StosB ; Default vol = 64. + + Mov CX, 13 + +D_GetSampleInfo6: + LodsB + Test AL, AL + JZ D_GetSampleInfo7 + + StosB + Loop D_GetSampleInfo6 + +D_GetSampleInfo7: + Xor AL, AL + Rep StosB + + Mov CX, 15 + Rep StosB + ; Length... + Mov EAX, 4177910 + + Cmp EAX, [BX+80] + JB D_GetSampleInfo3 + + Mov EAX, [BX+80] + +D_GetSampleInfo3: + StosD + Xor AX, AX + StosW + StosW + StosW + StosW + Mov AX, 8363 + StosW + Xor AX, AX + Mov CX, 9 + Rep StosW + + Ret + +D_GetSampleInfo1: + Mov Byte Ptr [BX+88], 2 + + Mov CX, 4 + Rep MovsB + Add SI, 12 + Add DI, 12 + Mov CX, 64 + Rep MovsB + + Ret + +D_GetSampleInfo4: + Mov Byte Ptr [BX+88], 3 ; Scrm + + Mov EAX, 'SPMI' + StosD + + Add DI, 13 + Mov AL, 64 + StosB + + Mov AL, 1 + Mov CL, [DS:60000+1Fh] + Mov CH, CL + + And CL, 1 + ShL CL, 4 + Or AL, CL ; Loop... + + And CH, 4 + ShR CH, 1 + Or AL, CH ; 16 bit. + +D_GetSampleInfo5: + StosB + Mov AL, [DS:60000+1Ch] + StosB + Mov SI, 60000+30h + Mov CX, 25 + Rep MovsB + Xor AX, AX + StosB + StosW ; Name done... now for length + + Mov EAX, [DS:60000+10h] + StosD + Mov EAX, [DS:60000+14h] + StosD + Mov EAX, [DS:60000+18h] + StosD + Mov EAX, [DS:60000+20h] ; C5Spd + StosD + Xor AX, AX + StosW + StosW + StosW + StosW + ; Now for sample pointer. + Mov CL, 4 + Mov AX, [DS:60000+0Eh] + Mov DL, [DS:60000+0Fh] + Mov DH, [DS:60000+0Dh] + ShL AX, CL + ShR DX, CL + StosW ; Sample pointer in file. + Mov AX, DX + StosW + + Xor AX, AX ; Vibrato info + StosW + StosW + + Ret + +D_GetSampleInfo8: ; WAV Identification + Push SI + Push DI + Push DS + + Push CS + Pop DS + Mov SI, Offset WAVEfmtID + Mov DI, 60008 + Mov CX, 8 + RepE CmpsB + JNE NotWAV + + Add DI, 2 + Mov CX, 4 + RepE CmpsB + +NotWAV: + Pop DS + + JNE D_GetSampleInfo9 + + Mov BP, 60000+18h + Add BP, [DS:60000+10h] + Mov CX, 3 ; Only allow 3 blocks + +CheckNextWAVE: + Cmp DWord Ptr [DS:BP-4], 'atad' + JE D_GetSampleWaveFound + + Mov AX, [DS:BP] + Add AX, 8 + Add BP, AX + JC D_GetSampleInfo9 + + Loop CheckNextWAVE + Jmp D_GetSampleInfo9 + +D_GetSampleWaveFound: + Mov DL, [DS:60000+22h] ; DL = number of bits. + Mov DH, 1 + Cmp DL, 8 + JE D_GetSampleInfo9 + + Mov DH, 3 + Cmp DL, 16 + +D_GetSampleInfo9: + Pop DI + Pop SI + JNE D_GetSampleInfo2 + ; We have a WAV file! + Cmp Word Ptr [DS:60000+16h], 2 + JNE D_GetSampleWAVStereo + + Or DH, 4 + +D_GetSampleWAVStereo: + Mov AL, DH + And AL, 3 + Add AL, 4 + Mov Byte Ptr [BX+88], AL ; 5 = 8 bit, 7 = 16 bit. + + Mov EAX, 'SPMI' + StosD + + Mov SI, DI + Add DI, 13 + Mov AL, 64 + StosB ; Global vol = 64 + Mov AL, DH + StosB ; Flag = sample. + Mov AL, 64 + StosB ; Default vol = 64. + + Mov CX, 13 + +D_GetSampleInfo10: + LodsB + And AL, AL + JZ D_GetSampleInfo11 + + StosB + Loop D_GetSampleInfo10 + +D_GetSampleInfo11: + Xor AX, AX + Add CX, 13 + Rep StosB + + Mov AL, DH + And AL, 4 ; stereo? + ShL AL, 3 + + Test DH, 2 + JZ D_GetSampleInfo19 + + Inc AX + +D_GetSampleInfo19: + StosW ; Sample format + + Mov EAX, 4177910 ; Length + + Cmp EAX, [DS:BP] + JB D_GetSampleInfo12 + + Mov EAX, [DS:BP] + +D_GetSampleInfo12: + Test DH, 2 + JZ D_GetSampleInfo18 + + ShR EAX, 1 + +D_GetSampleInfo18: + Test DH, 4 + JZ D_GetSampleWAVStereo2 + + ShR EAX, 1 + +D_GetSampleWAVStereo2: + StosD + + Xor AX, AX + StosW + StosW + StosW + StosW + + Mov AX, [DS:60000+18h] ; Frequency + StosW + Xor AX, AX + Mov CX, 5 + Rep StosW + Mov AX, BP + Add AX, 4-60000 +; Mov AX, 2Ch + StosW + Xor AX, AX + StosW + StosW + StosW + + Ret + +D_GetSampleInfo13: ; AIFF Identification + Mov AL, 3 + Cmp DWord Ptr [DS:60000+8], 'VS61' + JE D_GetSampleInfoIFF + + Mov AL, 1 + Cmp DWord Ptr [DS:60000+8], 'XVS8' + JNE D_GetSampleInfo2 + +D_GetSampleInfoIFF: + Mov Byte Ptr [BX+88], 17 ; AIFF format. + Mov Byte Ptr [BX+12h], AL + Mov SI, 60000 + 0Ch + +D_GetSampleInfoIFF1: + Cmp DWord Ptr [DS:SI], 'EMAN' + JE D_GetSampleInfoIFFName + + Cmp DWord Ptr [DS:SI], 'RDHV' + JE D_GetSampleInfoIFFHeader + + Cmp DWord Ptr [DS:SI], 'YDOB' + JNE D_IFFHeaderNext + + ; Body. + Mov DWord Ptr [DI], 'SPMI' + Mov Byte Ptr [DI+11h], 64 ; Global volume + Mov Byte Ptr [DI+13h], 64 ; Default volume + Mov Word Ptr [DI+2Eh], 1 ; Sign conversion + + Add DI, 30h + Mov AX, [SI+06h] ; Size + Mov DX, [SI+04h] + Call Near Ptr D_GetSampleInfoBSwap + StosD + Xor EAX, EAX + Add DI, 0Ch + StosD + StosD + StosD + StosD + + Add SI, 8-60000 + Mov [BX+48h], SI + + Ret + +D_GetSampleInfoIFFName: + Push SI + Push DI + + Mov CX, [SI+6] + XChg CL, CH + Cmp CX, 25 + JBE D_GetSampleInfoIFFName1 + + Mov CX, 25 + +D_GetSampleInfoIFFName1: + Add SI, 8 + Add DI, 14h + Rep MovsB + +D_IFFHeaderEnd: + Pop DI + Pop SI + +D_IFFHeaderNext: + Mov AX, [SI+6] + XChg AL, AH + Add AX, 8 + Add SI, AX + JC D_GetSampleInfo2 + + Jmp D_GetSampleInfoIFF1 + +D_GetSampleInfoIFFHeader: + Push SI + Push DI + + Add DI, 34h + + Mov AX, [SI+0Eh] ; Loop start + Mov DX, [SI+0Ch] + Call Near Ptr D_GetSampleInfoBSwap + StosD + + Push EAX + Mov AX, [SI+12h] ; Loop end + Mov DX, [SI+10h] + Call Near Ptr D_GetSampleInfoBSwap + Test EAX, EAX + JZ D_GetSampleInfoIFFHeader1 + + Or Byte Ptr [BX+12h], 16 + +D_GetSampleInfoIFFHeader1: + Pop EDX + Add EAX, EDX + StosD + + Xor EAX, EAX + Mov AX, [SI+14h] + XChg AL, AH + StosD + + Jmp D_IFFHeaderEnd + +D_GetSampleInfoBSwap: + XChg DH, AL + XChg DL, AH + + ShL EAX, 16 + Mov AX, DX + + Test Byte Ptr [BX+12h], 2 + JZ D_GetSampleInfo17 + + ShR EAX, 1 ; Halve length for 16-bit samples. + +D_GetSampleInfo17: + RetN + +EndP D_GetSampleInfo + diff --git a/IT_D_RI.INC b/it_d_ri.inc similarity index 96% rename from IT_D_RI.INC rename to it_d_ri.inc index f4376ba..cbf035e 100644 --- a/IT_D_RI.INC +++ b/it_d_ri.inc @@ -1,771 +1,771 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Load Instrument module -; -; Instrument in .ITI format has to be placed at DS:64000 -; Sample headers have to be placed at DS:0 -; -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadITInstrument - - Mov DX, 64000 - Mov CX, 554 ; Length of instrument header - Mov AH, 3Fh - Int 21h - - Cmp Word Ptr [DS:64000+1Ch], 200h - JAE LoadITInstrument1 - - Mov SI, DX - Call ConvertOldInstrument - -LoadITInstrument1: - Mov AX, [DS:64000+1Eh] ; AX = number of samples - Mov DX, 80 - Mul DX ; Clears DX, AX = size in bytes - Mov CX, AX - -; Xor DX, DX -; Mov CX, DI - JCXZ LoadITInstrument2 - - Mov AH, 3Fh - Int 21h ; All sample headers are loaded too. - ; Step 2 done. - -LoadITInstrument2: - Ret - -EndP LoadITInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InstrumentNameOffset DW 0 -XISampleOffset DD 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadXIInstrument ; Must preserve DS, BX - - Push DS - Pop ES - - Mov DX, 63000 - Mov CX, 298 ; Length of instrument header - Mov AH, 3Fh - Int 21h - - Mov AX, [DS:63000+296] ; NoS - Mov CS:NumInstrumentSamples, AX - Mov CS:InstrumentNameOffset, 63000+21 - Mov CS:XISampleOffset, 298 - - ; Now to transfer data across - ; to 64000 in ITI format -LoadXIChain: - Mov DI, 64000 - Mov EAX, 'IPMI' ; Header - StosD - - Xor AX, AX - Mov CX, 8 - Rep StosW ; Filename, NNA, DCA, DCT - - Mov AX, [DS:63000+272] - Add AX, 15 - ShR AX, 5 - Cmp AX, 256 - JB LoadXIInstrumentFdOut - - Mov AX, 256 - -LoadXIInstrumentFdOut: - StosW ; Fadeout - - Mov AX, 60*256 - StosW ; PPC and PPS - Mov AX, 128+32*256 - StosW ; GBV and DfP - Xor AX, AX - StosW - StosW - Mov AX, CS:NumInstrumentSamples - StosW - Xor AX, AX - - Mov SI, CS:InstrumentNameOffset - Mov CX, 22/2 - Rep MovsW - Mov CX, 5 - Rep StosW ; Clear up end of inst name - - ; Translation table - Mov CX, 12 ; First 12 entries empty - Xor AX, AX - -LoadXIInstrument1: - StosW - Inc AX - Loop LoadXIInstrument1 - - Mov SI, 63000+66 - Mov CX, 96 - -LoadXIInstrument2: - Mov AH, [SI] - Inc AH - StosW - - Inc AX - Inc SI - Loop LoadXIInstrument2 - - Mov CX, 12 ; Last 12 entries empty - Xor AH, AH - -LoadXIInstrument3: - StosW - Inc AX - Loop LoadXIInstrument3 - - ; Now for volume envelope - Mov AL, [DS:63000+266] ; Flags - Mov CL, AL - Mov AH, AL - And AX, 402h - ShR AH, 1 - ShL AL, 1 - Or AL, AH - And CL, 1 - Or AL, CL - - Mov AH, [DS:63000+258] ; No of vol env nodes - Cmp AH, 12 - JB NumXIVolNodes1 - - Mov AH, 12 - -NumXIVolNodes1: - StosW - Mov AX, [DS:63000+261] ; Vol loop start+end - StosW - Mov AL, [DS:63000+260] ; Vol Sustain point - Mov AH, AL - StosW - - ; OK. now process volume env points - Mov CX, 12 - -LoadXIInstrument4: - Mov AL, [SI+2] - Cmp AL, 64 - JB LoadXICheckVolBound1 - - Mov AL, 64 - -LoadXICheckVolBound1: - StosB - MovsW - LodsW - Loop LoadXIInstrument4 - - Mov CX, 13*3+1 - Xor AX, AX - Rep StosB - - ; Now for panning envelope - -LoadXIInstrument5: - Mov AL, [DS:63000+267] ; Flags - Mov CL, AL - Mov AH, AL - And AX, 402h - ShR AH, 1 - ShL AL, 1 - Or AL, AH - And CL, 1 - Or AL, CL - - Mov AH, [DS:63000+259] ; No of pan env nodes - Cmp AH, 12 - JB NumXIPanNodes1 - - Mov AH, 12 - -NumXIPanNodes1: - StosW - Mov AX, [DS:63000+264] ; Pan loop start+end - StosW - Mov AL, [DS:63000+263] ; Pan Sustain point - Mov AH, AL - StosW - - ; OK. now process panning env points - Mov CX, 12 - Xor AH, AH - -LoadXIInstrument6: - Mov AL, [SI+2] - Cmp AL, 64 - JB LoadXICheckPanBound - - Mov AL, 64 - -LoadXICheckPanBound: - Sub AL, 32 - StosB - MovsW - LodsW ; Add SI, 2 - Loop LoadXIInstrument6 - - Mov CX, 13*3+1 - Xor AX, AX - Rep StosB - - ; Now for pitch envelope - Mov AX, 2*256 ; 2 node points - StosW - Xor AX, AX - StosW - StosW - - ; First node is 0, 0, second node is 0, 99 - StosW - StosW - Mov AX, 99 - StosW - - Mov CX, 75-6 - Xor AX, AX - Rep StosB - - Cmp Byte Ptr [DS:64000+131h], 2 - JAE LoadXIInstrumentVolEnvelopeCheck1 - - Mov Byte Ptr [DS:64000+131h], 2 - Mov Word Ptr [DS:64000+136h], 64 - Mov Word Ptr [DS:64000+138h], 64*256 - Mov Word Ptr [DS:64000+13Ah], 100 - -LoadXIInstrumentVolEnvelopeCheck1: - - Cmp Byte Ptr [DS:64000+183h], 2 - JAE LoadXIInstrumentPanEnvelopeCheck1 - - Mov Byte Ptr [DS:64000+183h], 2 - Xor AX, AX - Mov [DS:64000+188h], AX - Mov [DS:64000+18Ah], AX - Mov Word Ptr [DS:64000+18Ch], 100 - -LoadXIInstrumentPanEnvelopeCheck1: - - ; OK. instrument done. - ; Now have to load samples - ; Bytes to load = 40*NoS - Mov AX, 40 - Mul Word Ptr [DS:64000+1Eh] - Mov CX, AX - - Mov DX, 62000 - Mov AH, 3Fh - Int 21h - - Mov EDX, CS:XISampleOffset ; EDX = offset in file - Add DX, CX - - Xor DI, DI - Mov SI, 62000 - Mov CX, [DS:64000+1Eh] - -LoadXISample1: - Push CX - - Mov EAX, 'SPMI' - StosD - Xor AX, AX - Mov CX, 6 - Rep StosW - Mov AX, 64*256 - StosW - ; Flg -LoadXISample2: - Mov AH, [SI+12] ; Default volume - Mov AL, 0 - Cmp DWord Ptr [SI], 0 ; Length = 0? - JE LoadXISample4 - - Mov AL, 1 - - Mov CL, [SI+14] - Test CL, 10h - JZ LoadXISample3 - - Or AL, 2 ; 16-bit sample - -LoadXISample3: - And CL, 3 - JZ LoadXISample4 ; No loop - ; CL = 1 or 2 - Cmp DWord Ptr [SI+8], 1 - JBE LoadXISample4 - - Or AL, 10h ; Loop - Dec CX - ShL CL, 6 - Or AL, CL - -LoadXISample4: - StosW - - Push SI - ; Copy sample name - Add SI, 18 - Mov CX, 22/2 - Rep MovsW - Xor AX, AX - StosW - StosW - - Pop SI - ; Conversion flags, default pan - Mov AL, 5 - Mov AH, [SI+15] ; Pan - ShR AH, 2 - AdC AH, 80h - StosW - - Mov EAX, [SI] - Call LoadXISample5 - Mov EAX, [SI+4] - Call LoadXISample5 - Mov EAX, [SI+4] - Add EAX, [SI+8] - Call LoadXISample5 - - ; C5speed.. - Push ES - Push DI - - Call Music_GetPitchTable ; Returns ES:DI - Mov AL, [SI+16] ; Relative note number - Add AL, 60 ; AL = note multiplier - And AX, 0FFh - ShL AX, 2 - Add DI, AX - Mov ECX, [ES:DI] - - Mov AL, [SI+13] ; Finetune, -128->+127 - SAR AL, 4 ; Finetune = -8->+7 - And AX, 0Fh - Add AX, AX - Mov DI, AX - MovZX EAX, [CS:FineTuneTable+DI] - - Pop DI - Pop ES - - Push EDX - - Mul ECX - ShRD EAX, EDX, 16 - Pop EDX - StosD ; C5freq - - Xor AX, AX - StosW - StosW - StosW - StosW - - Mov EAX, EDX - Add EDX, [SI] - StosD - Xor AX, AX - StosW - StosW - - Pop CX - Add SI, 40 - Loop LoadXISample1 - - Ret - -LoadXISample5: - Cmp EAX, 4177910 - JB LoadXISample6 - - Mov EAX, 4177910 -LoadXISample6: - Test Byte Ptr [SI+14], 10h - JZ LoadXISample7 - - ShR EAX, 1 - -LoadXISample7: - StosD - RetN - -EndP LoadXIInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadInITInstrument - - Mov AH, 3Fh - Mov CX, 2000 - Mov DX, 62000 - Int 21h ; Read header into 62000 - - Mov AX, 4200h - Mov CX, Word Ptr [CS:LoadInstrumentOffset+2] - Mov DX, Word Ptr [CS:LoadInstrumentOffset] - Int 21h ; Goto location - - Mov AH, 3Fh ; Load instrument data - Mov CX, 554 - Mov DX, 64000 - Int 21h - - Cmp Word Ptr [DS:62000+2Ah], 200h - JAE LoadInITInstrument1 - - Mov SI, 64000 - Call ConvertOldInstrument - -LoadInITInstrument1: ; Convert Note table and load - ; Sample headers. - Mov SI, 64000+41h - Xor CX, CX - -LoadInITInstrument2: - Mov DI, [SI] - And DI, 0FFh ; DI = sample number - JZ LoadInITInstrument3 - Cmp DI, [DS:62000+24h] ; Sample exists? - JA LoadInITInstrument3 - Cmp Byte Ptr [CS:InstrumentTable+DI], 0 - JNE LoadInITInstrument3 - - Inc CX ; CL = sample number - Mov [CS:InstrumentTable+DI], CL - - Push SI - Push CX - - Add DI, [DS:62000+22h] - ShL DI, 2 - Add DI, [DS:62000+20h] - Add DI, 62000+0C0h-4 ; Samples are 0 based, not 1 - - Mov AX, 4200h ; Move to offset of sample - Mov CX, [DI+2] - Mov DX, [DI] - Int 21h - - Pop AX - Push AX - - Dec AX - Mov CX, 80 - Mul CX - Mov DX, AX - - Mov AH, 3Fh - Int 21h ; Load sample header. - - Pop CX - Pop SI - -LoadInITInstrument3: - Add SI, 2 - Cmp SI, 64000+41h+120*2 - JB LoadInITInstrument2 - - Mov [DS:64000+1Eh], CX - - ; Process translation table - Mov SI, 64000+41h - -LoadInITInstrument4: - Mov DI, [SI] - And DI, 0FFh - Mov AL, [CS:InstrumentTable+DI] - Mov [SI], AL - - Add SI, 2 - Cmp SI, 64000+41h+120*2 - JB LoadInITInstrument4 - - Mov DI, Offset InstrumentTable - Xor AX, AX - Mov CX, 50 - Rep StosW - - Ret - -EndP LoadInITInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadInXMInstrument - - Mov AX, 4200h - Mov CX, Word Ptr [CS:LoadInstrumentOffset+2] - Mov DX, Word Ptr [CS:LoadInstrumentOffset] - Int 21h ; Goto location - - Mov AH, 3Fh - Mov CX, 4 - Mov DX, 63000 - Int 21h - - Mov AH, 3Fh - Mov CX, [DS:63000] - Sub CX, 4 - Mov DX, 63033+4 - Int 21h - - Mov AX, [DS:63033+27] - Mov CS:NumInstrumentSamples, AX - Mov CS:InstrumentNameOffset, 63033+4 - - Mov AX, 4201h - Xor CX, CX - Xor DX, DX - Int 21h ; DX:AX = fileoffset - - Mov Word Ptr [CS:XISampleOffset], AX - Mov Word Ptr [CS:XISampleOffset+2], DX - - Push DS - Pop ES - - Jmp LoadXIChain - -EndP LoadInXMInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TransferInstrumentName - - Mov AX, 48 - Mul CS:NumInstruments - Inc CS:NumInstruments - - Mov DI, AX - - Push DS - - Push CS - Pop DS - - Mov AL, CL - StosB - Mov SI, Offset InInstrumentFileName - Mov CX, 14 - Rep MovsB - Mov EAX, LoadInstrumentOffset - Mov [ES:DI+44-15], EAX - - Pop DS - - Ret - -EndP TransferInstrumentName - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -; 'InstrumentTable' scratchpad - -LoadInstrumentOffset DD 0 -NumInstrumentSamples DW 0 - -Proc LoadITInModuleInstrument - - Mov AH, 3Fh - Mov CX, 2000 - Mov DX, 63000 - Int 21h - - Xor BP, BP - - Push ES - - Push CS ; Clear InstrumentTable - Pop ES - - Mov DI, Offset InstrumentTable - Mov CX, 100 - Xor AL, AL - Rep StosB - - Pop ES - -LoadITInModuleInstrument1: - Cmp BP, [DS:63000+22h] ; InsNum - JB LoadITInmoduleInstrument2 - - Ret - -LoadITInModuleInstrument2: - Mov SI, BP - ShL SI, 2 - - Inc BP - - Add SI, [DS:63000+20h] - Add SI, 63000+0C0h - - Mov AX, 4200h ; Move file pointer. - Mov CX, [SI+2] - Mov DX, [SI] - - Mov Word Ptr [CS:LoadInstrumentOffset], DX - Mov Word Ptr [CS:LoadInstrumentOffset+2], CX - - Int 21h - - Mov AH, 3Fh - Mov CX, 554 - Mov DX, 62000 - Int 21h - - Mov SI, 62000+41h - -LoadITInModuleInstrument3: - LodsW - And AX, 0FFh - Mov DI, AX - - Cmp AL, 100 - JAE LoadITInModuleInstrument5 - - Mov [CS:InstrumentTable+DI], 1 - -LoadITInModuleInstrument5: - Cmp SI, 62000+41h+120*2 - JB LoadITInModuleInstrument3 - - ; Now to count samples - ; and clear table. - Mov DI, 99 - Xor DX, DX ; DX = number of samples. - -LoadITInModuleInstrument4: - Cmp Byte Ptr [CS:InstrumentTable+DI], 1 - JNE LoadITInModuleInstrument6 - - Inc DX - Mov Byte Ptr [CS:InstrumentTable+DI], 0 - -LoadITInModuleInstrument6: - Dec DI - JNZ LoadITInModuleInstrument4 - - Test DX, DX - JZ LoadITInModuleInstrument1 - - Push DX - - Mov CL, 5 ; In-Module .IT Instrument - Call TransferInstrumentName - - Mov SI, 62000+20h - Mov CX, 25 - Rep MovsB - - Pop AX - StosW - Xor AX, AX - StosW - - Jmp LoadITInModuleInstrument1 - -EndP LoadITInModuleInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadXMInModuleInstrument - - Call LoadXMHeader ; Reads to first instrument - - Xor BP, BP - -LoadXMInModuleInstrument1: - Cmp BP, [DS:64000+72] - JB LoadXMInModuleInstrument2 - - Ret - -LoadXMInModuleInstrument2: - Inc BP - - Mov AX, 4201h - Xor CX, CX - Xor DX, DX - Int 21h ; Get current file location - - Mov Word Ptr [CS:LoadInstrumentOffset], AX - Mov Word Ptr [CS:LoadInstrumentOffset+2], DX - - Mov AH, 3Fh - Mov CX, 4 - Mov DX, 63000 - Int 21h ; Read instrument size field - - Mov AH, 3Fh - Mov CX, [DS:63000] - Sub CX, 4 - Mov DX, 63004 - Int 21h - - Mov AX, [DS:63000+27] ; Number of samples - Test AX, AX - JZ LoadXMInModuleInstrument1 - - Mov CX, 40 - Mul CX - Mov CX, AX - Mov AH, 3Fh - Mov DX, 62000 - Int 21h ; OK sample headers read - ; into DS:62000 - - Mov CL, 6 ; In-Module .XM Instrument - Call TransferInstrumentName - - Mov SI, 63004 - Mov CX, 22 - Rep MovsB - Xor AX, AX - StosB - StosW - - Mov AX, [DS:63000+27] - Mov CX, AX - StosW - Xor AX, AX - StosW - - Xor EDX, EDX - Mov SI, 62000 - -LoadXMInModuleInstrument3: - Add EDX, [SI] - Add SI, 40 - - Dec CX - JNZ LoadXMInModuleInstrument3 - - SHLD ECX, EDX, 16 - Mov AX, 4201h - Int 21h - ; Advance file pointers.. - Jmp LoadXMInModuleInstrument1 - -EndP LoadXMInModuleInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Load Instrument module +; +; Instrument in .ITI format has to be placed at DS:64000 +; Sample headers have to be placed at DS:0 +; +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadITInstrument + + Mov DX, 64000 + Mov CX, 554 ; Length of instrument header + Mov AH, 3Fh + Int 21h + + Cmp Word Ptr [DS:64000+1Ch], 200h + JAE LoadITInstrument1 + + Mov SI, DX + Call ConvertOldInstrument + +LoadITInstrument1: + Mov AX, [DS:64000+1Eh] ; AX = number of samples + Mov DX, 80 + Mul DX ; Clears DX, AX = size in bytes + Mov CX, AX + +; Xor DX, DX +; Mov CX, DI + JCXZ LoadITInstrument2 + + Mov AH, 3Fh + Int 21h ; All sample headers are loaded too. + ; Step 2 done. + +LoadITInstrument2: + Ret + +EndP LoadITInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InstrumentNameOffset DW 0 +XISampleOffset DD 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadXIInstrument ; Must preserve DS, BX + + Push DS + Pop ES + + Mov DX, 63000 + Mov CX, 298 ; Length of instrument header + Mov AH, 3Fh + Int 21h + + Mov AX, [DS:63000+296] ; NoS + Mov CS:NumInstrumentSamples, AX + Mov CS:InstrumentNameOffset, 63000+21 + Mov CS:XISampleOffset, 298 + + ; Now to transfer data across + ; to 64000 in ITI format +LoadXIChain: + Mov DI, 64000 + Mov EAX, 'IPMI' ; Header + StosD + + Xor AX, AX + Mov CX, 8 + Rep StosW ; Filename, NNA, DCA, DCT + + Mov AX, [DS:63000+272] + Add AX, 15 + ShR AX, 5 + Cmp AX, 256 + JB LoadXIInstrumentFdOut + + Mov AX, 256 + +LoadXIInstrumentFdOut: + StosW ; Fadeout + + Mov AX, 60*256 + StosW ; PPC and PPS + Mov AX, 128+32*256 + StosW ; GBV and DfP + Xor AX, AX + StosW + StosW + Mov AX, CS:NumInstrumentSamples + StosW + Xor AX, AX + + Mov SI, CS:InstrumentNameOffset + Mov CX, 22/2 + Rep MovsW + Mov CX, 5 + Rep StosW ; Clear up end of inst name + + ; Translation table + Mov CX, 12 ; First 12 entries empty + Xor AX, AX + +LoadXIInstrument1: + StosW + Inc AX + Loop LoadXIInstrument1 + + Mov SI, 63000+66 + Mov CX, 96 + +LoadXIInstrument2: + Mov AH, [SI] + Inc AH + StosW + + Inc AX + Inc SI + Loop LoadXIInstrument2 + + Mov CX, 12 ; Last 12 entries empty + Xor AH, AH + +LoadXIInstrument3: + StosW + Inc AX + Loop LoadXIInstrument3 + + ; Now for volume envelope + Mov AL, [DS:63000+266] ; Flags + Mov CL, AL + Mov AH, AL + And AX, 402h + ShR AH, 1 + ShL AL, 1 + Or AL, AH + And CL, 1 + Or AL, CL + + Mov AH, [DS:63000+258] ; No of vol env nodes + Cmp AH, 12 + JB NumXIVolNodes1 + + Mov AH, 12 + +NumXIVolNodes1: + StosW + Mov AX, [DS:63000+261] ; Vol loop start+end + StosW + Mov AL, [DS:63000+260] ; Vol Sustain point + Mov AH, AL + StosW + + ; OK. now process volume env points + Mov CX, 12 + +LoadXIInstrument4: + Mov AL, [SI+2] + Cmp AL, 64 + JB LoadXICheckVolBound1 + + Mov AL, 64 + +LoadXICheckVolBound1: + StosB + MovsW + LodsW + Loop LoadXIInstrument4 + + Mov CX, 13*3+1 + Xor AX, AX + Rep StosB + + ; Now for panning envelope + +LoadXIInstrument5: + Mov AL, [DS:63000+267] ; Flags + Mov CL, AL + Mov AH, AL + And AX, 402h + ShR AH, 1 + ShL AL, 1 + Or AL, AH + And CL, 1 + Or AL, CL + + Mov AH, [DS:63000+259] ; No of pan env nodes + Cmp AH, 12 + JB NumXIPanNodes1 + + Mov AH, 12 + +NumXIPanNodes1: + StosW + Mov AX, [DS:63000+264] ; Pan loop start+end + StosW + Mov AL, [DS:63000+263] ; Pan Sustain point + Mov AH, AL + StosW + + ; OK. now process panning env points + Mov CX, 12 + Xor AH, AH + +LoadXIInstrument6: + Mov AL, [SI+2] + Cmp AL, 64 + JB LoadXICheckPanBound + + Mov AL, 64 + +LoadXICheckPanBound: + Sub AL, 32 + StosB + MovsW + LodsW ; Add SI, 2 + Loop LoadXIInstrument6 + + Mov CX, 13*3+1 + Xor AX, AX + Rep StosB + + ; Now for pitch envelope + Mov AX, 2*256 ; 2 node points + StosW + Xor AX, AX + StosW + StosW + + ; First node is 0, 0, second node is 0, 99 + StosW + StosW + Mov AX, 99 + StosW + + Mov CX, 75-6 + Xor AX, AX + Rep StosB + + Cmp Byte Ptr [DS:64000+131h], 2 + JAE LoadXIInstrumentVolEnvelopeCheck1 + + Mov Byte Ptr [DS:64000+131h], 2 + Mov Word Ptr [DS:64000+136h], 64 + Mov Word Ptr [DS:64000+138h], 64*256 + Mov Word Ptr [DS:64000+13Ah], 100 + +LoadXIInstrumentVolEnvelopeCheck1: + + Cmp Byte Ptr [DS:64000+183h], 2 + JAE LoadXIInstrumentPanEnvelopeCheck1 + + Mov Byte Ptr [DS:64000+183h], 2 + Xor AX, AX + Mov [DS:64000+188h], AX + Mov [DS:64000+18Ah], AX + Mov Word Ptr [DS:64000+18Ch], 100 + +LoadXIInstrumentPanEnvelopeCheck1: + + ; OK. instrument done. + ; Now have to load samples + ; Bytes to load = 40*NoS + Mov AX, 40 + Mul Word Ptr [DS:64000+1Eh] + Mov CX, AX + + Mov DX, 62000 + Mov AH, 3Fh + Int 21h + + Mov EDX, CS:XISampleOffset ; EDX = offset in file + Add DX, CX + + Xor DI, DI + Mov SI, 62000 + Mov CX, [DS:64000+1Eh] + +LoadXISample1: + Push CX + + Mov EAX, 'SPMI' + StosD + Xor AX, AX + Mov CX, 6 + Rep StosW + Mov AX, 64*256 + StosW + ; Flg +LoadXISample2: + Mov AH, [SI+12] ; Default volume + Mov AL, 0 + Cmp DWord Ptr [SI], 0 ; Length = 0? + JE LoadXISample4 + + Mov AL, 1 + + Mov CL, [SI+14] + Test CL, 10h + JZ LoadXISample3 + + Or AL, 2 ; 16-bit sample + +LoadXISample3: + And CL, 3 + JZ LoadXISample4 ; No loop + ; CL = 1 or 2 + Cmp DWord Ptr [SI+8], 1 + JBE LoadXISample4 + + Or AL, 10h ; Loop + Dec CX + ShL CL, 6 + Or AL, CL + +LoadXISample4: + StosW + + Push SI + ; Copy sample name + Add SI, 18 + Mov CX, 22/2 + Rep MovsW + Xor AX, AX + StosW + StosW + + Pop SI + ; Conversion flags, default pan + Mov AL, 5 + Mov AH, [SI+15] ; Pan + ShR AH, 2 + AdC AH, 80h + StosW + + Mov EAX, [SI] + Call LoadXISample5 + Mov EAX, [SI+4] + Call LoadXISample5 + Mov EAX, [SI+4] + Add EAX, [SI+8] + Call LoadXISample5 + + ; C5speed.. + Push ES + Push DI + + Call Music_GetPitchTable ; Returns ES:DI + Mov AL, [SI+16] ; Relative note number + Add AL, 60 ; AL = note multiplier + And AX, 0FFh + ShL AX, 2 + Add DI, AX + Mov ECX, [ES:DI] + + Mov AL, [SI+13] ; Finetune, -128->+127 + SAR AL, 4 ; Finetune = -8->+7 + And AX, 0Fh + Add AX, AX + Mov DI, AX + MovZX EAX, [CS:FineTuneTable+DI] + + Pop DI + Pop ES + + Push EDX + + Mul ECX + ShRD EAX, EDX, 16 + Pop EDX + StosD ; C5freq + + Xor AX, AX + StosW + StosW + StosW + StosW + + Mov EAX, EDX + Add EDX, [SI] + StosD + Xor AX, AX + StosW + StosW + + Pop CX + Add SI, 40 + Loop LoadXISample1 + + Ret + +LoadXISample5: + Cmp EAX, 4177910 + JB LoadXISample6 + + Mov EAX, 4177910 +LoadXISample6: + Test Byte Ptr [SI+14], 10h + JZ LoadXISample7 + + ShR EAX, 1 + +LoadXISample7: + StosD + RetN + +EndP LoadXIInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadInITInstrument + + Mov AH, 3Fh + Mov CX, 2000 + Mov DX, 62000 + Int 21h ; Read header into 62000 + + Mov AX, 4200h + Mov CX, Word Ptr [CS:LoadInstrumentOffset+2] + Mov DX, Word Ptr [CS:LoadInstrumentOffset] + Int 21h ; Goto location + + Mov AH, 3Fh ; Load instrument data + Mov CX, 554 + Mov DX, 64000 + Int 21h + + Cmp Word Ptr [DS:62000+2Ah], 200h + JAE LoadInITInstrument1 + + Mov SI, 64000 + Call ConvertOldInstrument + +LoadInITInstrument1: ; Convert Note table and load + ; Sample headers. + Mov SI, 64000+41h + Xor CX, CX + +LoadInITInstrument2: + Mov DI, [SI] + And DI, 0FFh ; DI = sample number + JZ LoadInITInstrument3 + Cmp DI, [DS:62000+24h] ; Sample exists? + JA LoadInITInstrument3 + Cmp Byte Ptr [CS:InstrumentTable+DI], 0 + JNE LoadInITInstrument3 + + Inc CX ; CL = sample number + Mov [CS:InstrumentTable+DI], CL + + Push SI + Push CX + + Add DI, [DS:62000+22h] + ShL DI, 2 + Add DI, [DS:62000+20h] + Add DI, 62000+0C0h-4 ; Samples are 0 based, not 1 + + Mov AX, 4200h ; Move to offset of sample + Mov CX, [DI+2] + Mov DX, [DI] + Int 21h + + Pop AX + Push AX + + Dec AX + Mov CX, 80 + Mul CX + Mov DX, AX + + Mov AH, 3Fh + Int 21h ; Load sample header. + + Pop CX + Pop SI + +LoadInITInstrument3: + Add SI, 2 + Cmp SI, 64000+41h+120*2 + JB LoadInITInstrument2 + + Mov [DS:64000+1Eh], CX + + ; Process translation table + Mov SI, 64000+41h + +LoadInITInstrument4: + Mov DI, [SI] + And DI, 0FFh + Mov AL, [CS:InstrumentTable+DI] + Mov [SI], AL + + Add SI, 2 + Cmp SI, 64000+41h+120*2 + JB LoadInITInstrument4 + + Mov DI, Offset InstrumentTable + Xor AX, AX + Mov CX, 50 + Rep StosW + + Ret + +EndP LoadInITInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadInXMInstrument + + Mov AX, 4200h + Mov CX, Word Ptr [CS:LoadInstrumentOffset+2] + Mov DX, Word Ptr [CS:LoadInstrumentOffset] + Int 21h ; Goto location + + Mov AH, 3Fh + Mov CX, 4 + Mov DX, 63000 + Int 21h + + Mov AH, 3Fh + Mov CX, [DS:63000] + Sub CX, 4 + Mov DX, 63033+4 + Int 21h + + Mov AX, [DS:63033+27] + Mov CS:NumInstrumentSamples, AX + Mov CS:InstrumentNameOffset, 63033+4 + + Mov AX, 4201h + Xor CX, CX + Xor DX, DX + Int 21h ; DX:AX = fileoffset + + Mov Word Ptr [CS:XISampleOffset], AX + Mov Word Ptr [CS:XISampleOffset+2], DX + + Push DS + Pop ES + + Jmp LoadXIChain + +EndP LoadInXMInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TransferInstrumentName + + Mov AX, 48 + Mul CS:NumInstruments + Inc CS:NumInstruments + + Mov DI, AX + + Push DS + + Push CS + Pop DS + + Mov AL, CL + StosB + Mov SI, Offset InInstrumentFileName + Mov CX, 14 + Rep MovsB + Mov EAX, LoadInstrumentOffset + Mov [ES:DI+44-15], EAX + + Pop DS + + Ret + +EndP TransferInstrumentName + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +; 'InstrumentTable' scratchpad + +LoadInstrumentOffset DD 0 +NumInstrumentSamples DW 0 + +Proc LoadITInModuleInstrument + + Mov AH, 3Fh + Mov CX, 2000 + Mov DX, 63000 + Int 21h + + Xor BP, BP + + Push ES + + Push CS ; Clear InstrumentTable + Pop ES + + Mov DI, Offset InstrumentTable + Mov CX, 100 + Xor AL, AL + Rep StosB + + Pop ES + +LoadITInModuleInstrument1: + Cmp BP, [DS:63000+22h] ; InsNum + JB LoadITInmoduleInstrument2 + + Ret + +LoadITInModuleInstrument2: + Mov SI, BP + ShL SI, 2 + + Inc BP + + Add SI, [DS:63000+20h] + Add SI, 63000+0C0h + + Mov AX, 4200h ; Move file pointer. + Mov CX, [SI+2] + Mov DX, [SI] + + Mov Word Ptr [CS:LoadInstrumentOffset], DX + Mov Word Ptr [CS:LoadInstrumentOffset+2], CX + + Int 21h + + Mov AH, 3Fh + Mov CX, 554 + Mov DX, 62000 + Int 21h + + Mov SI, 62000+41h + +LoadITInModuleInstrument3: + LodsW + And AX, 0FFh + Mov DI, AX + + Cmp AL, 100 + JAE LoadITInModuleInstrument5 + + Mov [CS:InstrumentTable+DI], 1 + +LoadITInModuleInstrument5: + Cmp SI, 62000+41h+120*2 + JB LoadITInModuleInstrument3 + + ; Now to count samples + ; and clear table. + Mov DI, 99 + Xor DX, DX ; DX = number of samples. + +LoadITInModuleInstrument4: + Cmp Byte Ptr [CS:InstrumentTable+DI], 1 + JNE LoadITInModuleInstrument6 + + Inc DX + Mov Byte Ptr [CS:InstrumentTable+DI], 0 + +LoadITInModuleInstrument6: + Dec DI + JNZ LoadITInModuleInstrument4 + + Test DX, DX + JZ LoadITInModuleInstrument1 + + Push DX + + Mov CL, 5 ; In-Module .IT Instrument + Call TransferInstrumentName + + Mov SI, 62000+20h + Mov CX, 25 + Rep MovsB + + Pop AX + StosW + Xor AX, AX + StosW + + Jmp LoadITInModuleInstrument1 + +EndP LoadITInModuleInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadXMInModuleInstrument + + Call LoadXMHeader ; Reads to first instrument + + Xor BP, BP + +LoadXMInModuleInstrument1: + Cmp BP, [DS:64000+72] + JB LoadXMInModuleInstrument2 + + Ret + +LoadXMInModuleInstrument2: + Inc BP + + Mov AX, 4201h + Xor CX, CX + Xor DX, DX + Int 21h ; Get current file location + + Mov Word Ptr [CS:LoadInstrumentOffset], AX + Mov Word Ptr [CS:LoadInstrumentOffset+2], DX + + Mov AH, 3Fh + Mov CX, 4 + Mov DX, 63000 + Int 21h ; Read instrument size field + + Mov AH, 3Fh + Mov CX, [DS:63000] + Sub CX, 4 + Mov DX, 63004 + Int 21h + + Mov AX, [DS:63000+27] ; Number of samples + Test AX, AX + JZ LoadXMInModuleInstrument1 + + Mov CX, 40 + Mul CX + Mov CX, AX + Mov AH, 3Fh + Mov DX, 62000 + Int 21h ; OK sample headers read + ; into DS:62000 + + Mov CL, 6 ; In-Module .XM Instrument + Call TransferInstrumentName + + Mov SI, 63004 + Mov CX, 22 + Rep MovsB + Xor AX, AX + StosB + StosW + + Mov AX, [DS:63000+27] + Mov CX, AX + StosW + Xor AX, AX + StosW + + Xor EDX, EDX + Mov SI, 62000 + +LoadXMInModuleInstrument3: + Add EDX, [SI] + Add SI, 40 + + Dec CX + JNZ LoadXMInModuleInstrument3 + + SHLD ECX, EDX, 16 + Mov AX, 4201h + Int 21h + ; Advance file pointers.. + Jmp LoadXMInModuleInstrument1 + +EndP LoadXMInModuleInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ diff --git a/IT_D_RIS.INC b/it_d_ris.inc similarity index 96% rename from IT_D_RIS.INC rename to it_d_ris.inc index 9759404..b1ddb2f 100644 --- a/IT_D_RIS.INC +++ b/it_d_ris.inc @@ -1,1498 +1,1498 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; In-Module sample loaders have to place the information at Sample*96 bytes -; in ITS format into DiskDataArea. Provided with: -; BX = file handle, File at header section. -; DS, ES = DiskDataArea -; -; Variables to update: -; NumSamples (initialised to 1 before the call) -; -; Variables to use: -; InSampleDateTime (DWord) -; CS:InSampleFileName (13 bytes) -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SoftBSWAP ; EAX, returns EAX - - Push EDX - - SHLD EDX, EAX, 16 ; DX:AX contains value. - XChg DH, AL - XChg DL, AH ; DX:AX in proper order now - ShL EAX, 16 - SHRD EAX, EDX, 16 - - Pop EDX - Ret - -EndP SoftBSWAP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TransferFileName - - Mov EAX, 'SPMI' - StosD - - Push DS - - Push CS - Pop DS - Assume DS:Disk - - Mov EAX, InSampleDateTime - - Mov SI, Offset InSampleFileName - Mov CX, 13 - Rep MovsB - - Pop DS - Assume DS:Nothing - - Mov [DI+54h-11h], EAX ; Date. - - Ret - -EndP TransferFileName - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadMODSamplesInModule - - Mov AH, 3Fh - Mov CX, 1084 - Mov DX, 63000 - Int 21h - - Xor CX, CX - Mov SI, 63952 - Mov AX, 07F00h - - -LoadMODSamplesInModule1: - LodsB - Cmp CL, AL - JAE LoadMODSamplesInModule2 - - Mov CL, AL - -LoadMODSamplesInModule2: - Dec AH - JNZ LoadMODSamplesInModule1 - - Inc CX ; CX = number of patterns to - ; load - - Mov AL, CS:InSampleChannels - Mul CL ; AX = Chan * patterns - - And EAX, 0FFFFh - ShL EAX, 8 - Add EAX, 1084 - Mov EBP, EAX ; EBP = location of first sample - - Mov SI, 63020 ; First sample - Mov CX, 31 - -LoadMODSamplesInModule3: - Push CX - Push SI - - Mov CX, [SI+22] - XChg CH, CL - Cmp CX, 1 - JBE LoadMODSamplesInModule4 - - ; OK.. have a sample - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Inc CS:NumSamples - - Mov Byte Ptr [DI+88], 14 - Push SI - Call TransferFileName - Pop SI - - Mov AL, 64 - StosB - - Mov AH, [SI+25] ; Default volume - Mov AL, 1 - - Mov CX, [DS:SI+28] - XChg CH, CL - Cmp CX, 1 - JBE LoadMODSamplesInModule5 - - Or AL, 16 - -LoadMODSamplesInModule5: - StosW - - Mov CX, 22 - Rep MovsB - Xor EAX, EAX - StosD - - Mov AX, 32*256+1 ; Convert signed->Unsigned - StosW ; Default pan of 32 - - Mov AX, [SI] - XChg AH, AL - Add EAX, EAX - Mov [DI+20h], EAX ; File size - StosD ; Sample length - - Push EAX - - MovZX EAX, Word Ptr [SI+4] - XChg AH, AL - Add EAX, EAX - StosD ; Loop begin - - MovZX ECX, Word Ptr [SI+6] - XChg CH, CL - Add ECX, ECX - Add EAX, ECX - StosD ; Loop end - - Mov AL, [SI+2] - And AX, 15 - Mov SI, AX - Add SI, SI - Mov AX, [CS:FineTuneTable+SI] - StosW - Xor AX, AX - Mov CX, 5 - Rep StosW - - Mov EAX, EBP - StosD - Xor EAX, EAX - StosD - - Pop EAX - Add EBP, EAX - -LoadMODSamplesInModule4: - Pop SI - Pop CX - - Add SI, 30 - Loop LoadMODSamplesInModule3 - - Ret - -EndP LoadMODSamplesInModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadS3MSamplesInModule - - Mov AH, 3Fh - Mov CX, 2000 - Mov DX, 63000 - Int 21h - - Xor BP, BP - -LoadS3MSamplesInModule1: - Cmp BP, [DS:63000+22h] - JB LoadS3MSamplesInModule2 - - Ret - -LoadS3MSamplesInModule2: - Mov SI, BP - Add SI, SI - Add SI, [DS:63000+20h] - Inc BP - - Mov DX, [DS:63000+SI+60h] - Mov CX, DX - ShR CX, 12 - ShL DX, 4 - Mov AX, 4200h - Int 21h - ; Move to location - Mov DX, 62000 - Mov AH, 3Fh - Mov CX, 80h - Int 21h - - Cmp Byte Ptr [DS:62000], 1 - JNE LoadS3MSamplesInModule1 - Cmp DWord Ptr [DS:62000+10h], 0 - JE LoadS3MSamplesInModule1 - - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Mov Byte Ptr [DI+88], 3 - Call TransferFileName - - Mov AL, 64 - StosB - - Mov AL, [DS:62000+1Fh] ; Flag - Mov AH, AL - And AX, 401h - ShR AH, 1 - ShL AL, 4 - Or AL, AH - Or AL, 1 - Mov AH, [DS:62000+1Ch] ; Default volume - StosW - - Mov SI, 62000+30h - Mov CX, 25 - Rep MovsB - Xor AX, AX - StosW - Mov AL, 32 - StosB - - ; Length - Mov EAX, [DS:62000+10h] - StosD - Test Byte Ptr [DS:62000+1Fh], 4 - JZ LoadS3MSamplesInModule3 - - Add EAX, EAX - -LoadS3MSamplesInModule3: - Mov [DI+20h-4], EAX ; File size - - Mov EAX, [DS:62000+14h] - StosD - Mov EAX, [DS:62000+18h] - StosD - Mov EAX, [DS:62000+20h] - StosD - Xor AX, AX - StosW - StosW - StosW - StosW - ; Sample pointer.. - Mov AL, [DS:62000+0Dh] - ShL EAX, 16 - Mov AX, [DS:62000+0Eh] - ShL EAX, 4 - StosD - Xor AX, AX - StosW - StosW - - Inc CS:NumSamples - Jmp LoadS3MSamplesInModule1 - -EndP LoadS3MSamplesInModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadFARSamplesInModule - - Mov AH, 3Fh - Mov CX, 98 - Mov DX, 63000 - Int 21h - - Mov AX, 4201h - Xor CX, CX - Mov DX, [DS:63000+96] - Int 21h ; Removes song message - - Mov AH, 3Fh - Mov CX, 869-98 - Mov DX, 63000+98 - Int 21h - -; Xor CX, CX -; Mov CL, [DS:63000+354] ; CX = number of patterns - - Mov CX, 256 - -Comment ~ - - Xor CX, CX - Mov CL, [DS:63000+355] - Mov SI, 63000+98 - Xor AH, AH - ; Have to find CX from order list, apparently... - -LoadFARSamplesInModule7: - LodsB - Cmp AL, 0FFh - JE LoadFARSamplesInModule8 - Cmp AL, AH - JB LoadFARSamplesInModule8 - - Mov AH, AL - -LoadFARSamplesInModule8: - Loop LoadFARSamplesInModule7 - - Mov CL, AH - Inc CX - - ~ - - Mov SI, 63000+357 - Xor AX, AX - Xor DX, DX - -LoadFARSamplesInModule1: - Add AX, [SI] - AdC DX, 0 - Add SI, 2 - Loop LoadFARSamplesInModule1 - - ; DX:AX = length of patterns. - Mov CX, DX - Mov DX, AX - Mov AX, 4201h - Int 21h ; OK.. skipped past patterns. - - Mov AH, 3Fh - Mov CX, 8 - Mov DX, 64000 - Int 21h ; Read sample map. - - ; Determine number of samples... - Xor SI, SI ; SI = number of samples - - Mov EDX, [DS:64004] - Mov EAX, [DS:64000] - Mov CX, 64 - -LoadFARSamplesInModule2: - Test AL, 1 - JZ LoadFARSamplesInModule3 - - Inc SI - -LoadFARSamplesInModule3: - ShR EDX, 1 - RCR EAX, 1 - Loop LoadFARSamplesInModule2 - ; OK.. SI = number of samples.. - Mov [DS:65000], SI - - Mov AX, 48 - Mul SI - Mov SI, AX ; SI = number of bytes for sample header - - Mov AX, 4201h - Xor CX, CX - Xor DX, DX - Int 21h - ; DX:AX = position in file. - Add AX, SI - AdC DX, 0 ; DX:AX = position in file of first sam - - Xor BP, BP - -LoadFARSamplesInModule4: - Cmp BP, [DS:65000] - JB LoadFARSamplesInModule5 - - Ret - -LoadFARSamplesInModule5: - Inc BP - - Mov DX, 62000 - Mov AH, 3Fh - Mov CX, 48 - Int 21h - - Cmp DWord Ptr [DS:62000+32], 0 - JE LoadFARSamplesInModule4 - - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Mov Byte Ptr [DI+88], 12 ; FAR sample - Call TransferFileName - - Mov AL, 64 - StosB ; Global volume - - Mov AX, [DS:62000+46] ; 8/16 bit in bit 0 - ; loop in bit 3 of AH - And AX, 801h - ShL AX, 1 - Or AL, AH - Or AL, 1 - Mov DL, AL - Mov AH, 64 - StosW - - Mov SI, 62000 - Mov CX, 25 - -LoadFARSamplesInModule6: - LodsB - StosB - Test AL, AL - LoopNZ LoadFarSamplesInModule6 - - Xor AL, AL - Inc CX - Rep StosB - Mov AX, 1+32*256 - StosW - - Mov EAX, [DS:62000+32] - Mov [DI+20h], EAX ; File size - Call LoadPTMSamplesInModule4 - Mov EAX, [DS:62000+38] ; Begin - Call LoadPTMSamplesInModule4 - Mov EAX, [DS:62000+42] ; End - Call LoadPTMSamplesInModule4 - - Mov AX, 8363 - StosW - Xor AX, AX - Mov CX, 5 - Rep StosW - - ; Get current position in file - Mov AX, 4201h - Xor CX, CX - Xor DX, DX - Int 21h - StosW - Mov AX, DX - StosW - - Xor AX, AX - StosW - StosW - - Mov AX, 4201h - Mov CX, [DS:62000+34] - Mov DX, [DS:62000+32] - Int 21h - - Cmp DWord Ptr [DS:62000+32], 1 - JBE LoadFARSamplesInModule4 - - Inc CS:NumSamples - Jmp LoadFARSamplesInModule4 - -EndP LoadFARSamplesInModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadMTMSamplesInModule - - Mov AH, 3Fh - Mov CX, 66 ; Read header - Mov DX, 63000 - Int 21h - - ; Sample pos = LastsamplePos+Length - ; So.. setup first sample with no length - Mov AH, 64 - Mov AL, [DS:63000+26] - Inc AX - Mul AH - Mov CX, AX ; CX = 64*(LastPatternSaved+1) - - Mov AL, 37 - Mul Byte Ptr [DS:63000+30] ; NOS - Add CX, AX ; CX = NOS*37+64*(LastPatternSaved+1) - Add CX, [DS:63000+28] - Add CX, 194 ; CX = 194+NOS*37+Lngth of comment+... - - Mov AX, 192 - Mul Word Ptr [DS:63000+24] ; Tracks saved - - Add AX, CX - AdC DX, 0 - - Mov [DS:48h], AX - Mov [DS:4Ah], DX - - Mov DWord Ptr [DS:30h], 0 - - Mov Byte Ptr [DS:63000+31], 0 - Xor BP, BP - -LoadMTMSamplesInModule1: - Cmp BP, [DS:63000+30] - JB LoadMTMSamplesInModule2 - - Ret - -LoadMTMSamplesInModule2: - Inc BP - - Mov DX, 62000 - Mov AH, 3Fh - Mov CX, 37 - Int 21h - - Cmp DWord Ptr [DS:62000+22], 0 - JE LoadMTMSamplesInModule1 - - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Mov Byte Ptr [DI+88], 10 ; MTM sample - Call TransferFileName - - Mov AL, 64 - StosB ; Global volume - - Mov AL, 1 - - Mov ECX, [DS:62000+30] - Sub ECX, [DS:62000+26] - - Cmp ECX, 2 - JLE LoadMTMSamplesInModule3 - - Mov AL, 11h ; Loop + sample. - -LoadMTMSamplesInModule3: - Mov AH, [DS:62000+35] - StosW - ; Sample name now.. - Mov SI, 62000 - Mov CX, 22 - -LoadMTMSamplesInModule4: - LodsB - StosB - Test AL, AL - LoopNZ LoadMTMSamplesInModule4 - - Xor AX, AX - Add CX, 4 - Rep StosB - - Mov AH, 32 - StosW - - Mov EAX, [DS:62000+22] - Mov [DI+20h], EAX - StosD - Mov EAX, [DS:62000+26] - StosD - Mov EAX, [DS:62000+30] - StosD - - Mov AL, [DS:62000+34] - And AX, 0Fh - Mov SI, AX - Add SI, SI - Mov AX, [CS:FineTuneTable+SI] - StosW - Xor AX, AX - Mov CX, 5 - Rep StosW - - ; Sample pointer... - Mov EAX, [DI-96] ; Last sample pointer - Add EAX, [DI-96-18h] ; Last sample length - StosD - - Xor AX, AX - StosW - StosW - - Inc CS:NumSamples - Jmp LoadMTMSamplesInModule1 - -EndP LoadMTMSamplesInModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Comment ~ - -Proc LoadULTSamplesInModule - - Mov AH, 3Fh - Mov CX, 48 ; Read 48 bytes. - Mov DX, 63000 - Int 21h - - Xor DH, DH - Mov DL, [DS:63000+47] - ShL DX, 5 ; CX = CX * 32 - Xor CX, CX - Mov AX, 4201h - Int 21h ; Seek.. - - Mov AH, 3Fh - Mov CX, 1 - Mov DX, 63000+48 - Int 21h ; Read 1 byte.. - Mov Byte Ptr [DS:63000+49], 0 - - Ret - -EndP LoadULTSamplesInModule - - ~ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Load669SamplesInModule - - Mov AH, 3Fh - Mov CX, 1F1h - Mov DX, 63000 - Int 21h - - Mov AL, 19h - Mul Byte Ptr [DS:63000+6Eh] - Mov CX, AX - Add CX, 1F1h - - Mov AL, [DS:63000+6Fh] - Xor AH, AH - Mov DX, 600h - Mul DX - - Add AX, CX - AdC DX, 0 - - Mov [DS:48h], AX - Mov [DS:4Ah], DX - - Mov DWord Ptr [DS:30h], 0 - - Mov Byte Ptr [DS:63000+6Fh], 0 - Xor BP, BP - -Load669SamplesInModule1: - Cmp BP, [DS:63000+6Eh] - JB Load669SamplesInModule2 - - Ret - -Load669SamplesInModule2: - Inc BP - - Mov AH, 3Fh - Mov CX, 19h - Mov DX, 62000 - Int 21h - - Cmp DWord Ptr [DS:62000+13], 0 - JE Load669SamplesInModule1 - - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Mov Byte Ptr [DI+88], 11 ; 669 sample - Call TransferFileName - - Mov AL, 64 - StosB ; Global volume - - Mov AL, 1 - - Mov ECX, [DS:62000+21] - Cmp ECX, [DS:62000+13] - JA Load669SamplesInModule3 - - Mov AL, 11h ; Loop + sample. - -Load669SamplesInModule3: - Mov DL, AL - Mov AH, 64 - StosW - - ; Sample name - Mov SI, 62000 - Mov CX, 13 - Rep MovsB - - Xor AX, AX - Mov CX, 13 - Rep StosB - - Mov AH, 32 - StosW - - Mov SI, 62000+13 - LodsD - Mov [DI+20h], EAX - StosD - MovsD - Test DL, 10h - JZ Load669SamplesInModule4 - - MovsD - Jmp Load669SamplesInModule5 - -Load669SamplesInModule4: - Xor AX, AX - StosW - StosW - -Load669SamplesInModule5: - Mov AX, 8363 - StosW - Xor AX, AX - Mov CX, 5 - Rep StosW - - ; Sample pointer... - Mov EAX, [DI-96] ; Last sample pointer - Add EAX, [DI-96-18h] ; Last sample length - StosD - - Xor AX, AX - StosW - StosW - - Inc CS:NumSamples - Jmp Load669SamplesInModule1 - -EndP Load669SamplesInModule - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadPTMSamplesInModule - - Mov AH, 3Fh - Mov CX, 608 ; Read 608 bytes. - Mov DX, 63000 - Int 21h - - Xor BP, BP - -LoadPTMSamplesInModule1: - Cmp BP, [DS:63000+34] - JB LoadPTMSamplesInModule2 - - Ret - -LoadPTMSamplesInModule2: - Inc BP - - Mov DX, 62000 - Mov AH, 3Fh - Mov CX, 80 - Int 21h - - Mov AL, [DS:62000] - And AL, 3 - Cmp AL, 1 - JNE LoadPTMSamplesInModule1 - Cmp DWord Ptr [DS:62000+22], 0 - JE LoadPTMSamplesInModule1 - - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Mov Byte Ptr [DI+88], 9 ; PTM sample - Call TransferFileName - - Mov AL, 64 - StosB ; Global volume - - Mov CL, [DS:62000] ; AL, Bit 0-1 = sample - ; Bit 2 = loop - ; Bit 3 = loop dirn - ; Bit 4 = 8/16 bit - Mov AL, CL - Mov AH, CL - And AX, 1004h - ShL AL, 2 - And CL, 8 - ShR AH, 3 - ShL CL, 3 - Or AL, AH - Or AL, CL - Or AL, 1 - Mov DL, AL - Mov AH, [DS:62000+13] ; Default volume - StosW ; Flag + default volume - - Mov SI, 62000+30h ; Sample name - Mov CX, 25 - Rep MovsB - Xor AX, AX - StosB - - Mov AX, 9+32*256 ; Conversion flag + default pan - StosW - - ; Length - Mov EAX, [DS:62000+22] - Mov [DI+20h], EAX ; File size - Call LoadPTMSamplesInModule4 - Mov EAX, [DS:62000+26] ; Begin - Call LoadPTMSamplesInModule4 - Mov EAX, [DS:62000+30] ; End - Call LoadPTMSamplesInModule4 - Xor EAX, EAX - Mov AX, [DS:62000+14] ; C5Freq - StosD - Xor AX, AX - StosW - StosW - StosW - StosW - ; Sample pointer.. - Mov EAX, [DS:62000+18] - StosD - Xor AX, AX - StosW - StosW - - Inc CS:NumSamples - Jmp LoadPTMSamplesInModule1 - -LoadPTMSamplesInModule4: - Test DL, 2 - JZ LoadPTMSamplesInModule5 - - ShR EAX, 1 - -LoadPTMSamplesInModule5: - StosD - RetN - -EndP LoadPTMSamplesInModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadITSamplesInModule ; DS, ES = DiskDataArea - - Mov AH, 3Fh - Mov CX, 2000 - Mov DX, 63000 - Int 21h ; Loaded module - - Xor BP, BP ; DX = number of samples - -LoadITSamplesInModule1: - Cmp BP, [DS:63000+24h] ; Num Samples - JB LoadITSamplesInModule2 - - Ret - -LoadITSamplesInModule2: - Mov SI, [DS:63000+22h] - Add SI, BP - ShL SI, 2 ; DX = (NumInstrument+NumSamples)*4 - Add SI, [DS:63000+20h] - Inc BP - - Mov DX, [DS:63000+SI+0C0h] - Mov CX, [DS:63000+SI+0C0h+2] - - Mov AX, 4200h - Int 21h - ; OK. file pointer moved to sample header. - ; Memory region to copy it to is BP*96 - - Mov AX, 96 - Mul CS:NumSamples - - Mov DX, AX - Mov DI, DX - Mov AH, 3Fh - Mov CX, 80 - Int 21h - - Mov CL, [DI+12h] - Test CL, 1 - JZ LoadITSamplesInModule1 - - Mov EAX, [DI+30h] ; Length - Test CL, 2 - JZ LoadITSamplesInModule3 - - Add EAX, EAX - -LoadITSamplesInModule3: - Mov [DI+50h], EAX - - Mov Byte Ptr [DI+88], 2 - Call TransferFileName - - Inc CS:NumSamples - Jmp LoadITSamplesInModule1 - -EndP LoadITSamplesInModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadXMHeader - - Mov AH, 3Fh - Mov CX, 74 - Mov DX, 64000 - Int 21h ; Loaded module - - Mov AX, 4200h ; Seek to position from start of module - Mov DX, [DS:64000+60] - Mov CX, [DS:64000+62] - Add DX, 60 - Int 21h - - Xor BP, BP ; BP = pattern counter - ; At first pattern -LoadXMSamplesInModule1: - Cmp BP, [DS:64000+70] ; Number of patterns - JAE LoadXMSamplesInModule2 - - ; Load 4 bytes. - Mov AH, 3Fh - Mov CX, 9 ; Read standard header - Mov DX, 63000 - Int 21h - - Mov AX, 4201h - Xor CX, CX - Mov DX, [DS:63000] - Add DX, [DS:63000+7] - Sub DX, 9 - Int 21h - - Inc BP - Jmp LoadXMSamplesInModule1 - -LoadXMSamplesInModule2: ; OK.. at first instrument - - Ret - -EndP LoadXMHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadXMSamplesInModule - - Call LoadXMHeader - - Xor BP, BP - -LoadXMSamplesInModule3: - Cmp BP, [DS:64000+72] - JB LoadXMSamplesInModule4 - - Ret - -LoadXMSamplesInModule4: - Inc BP - - Mov AH, 3Fh - Mov CX, 4 - Mov DX, 63000 - Int 21h ; Read instrument size field - - Mov AH, 3Fh - Mov CX, [DS:63000] - Sub CX, 4 - Mov DX, 63004 - Int 21h - - Mov AX, [DS:63000+27] ; Number of samples - Test AX, AX - JZ LoadXMSamplesInModule3 - - ; Bytes to read = AX*40 - Mov CX, 40 - Mul CX - Mov CX, AX - Mov AH, 3Fh - Mov DX, 62000 - Int 21h ; OK sample headers read - ; into DS:62000 - - Push BP - Xor BP, BP - Xor EDX, EDX ; EDX = number of bytes to adv - -LoadXMSamplesInModule5: - Cmp BP, [DS:63000+27] ; Number of samples - JB LoadXMSamplesInModule6 - - SHLD ECX, EDX, 16 - Mov AX, 4201h - Int 21h ; Advance file pointer - - Pop BP - Jmp LoadXMSamplesInModule3 - -LoadXMSamplesInModule6: - Push EDX - - Mov AX, 40 - Mul BP - Mov SI, AX - Add SI, 62000 - - Pop EDX - Inc BP - - Cmp DWord Ptr [DS:SI], 0 ; Sample length = 0?? - JE LoadXMSamplesInModule5 - - Push EDX - - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Push SI - - Mov Byte Ptr [DI+88], 8 - Call TransferFileName - - Mov AL, 64 - StosB - - Pop SI - - Mov AH, [SI+12] ; Default volume - Mov AL, 1 - - Mov CL, [SI+14] - Test CL, 10h - JZ LoadXMSamplesInModule7 - - Or AL, 2 ; 16-bit sample - -LoadXMSamplesInModule7: - And CL, 3 - JZ LoadXMSamplesInModule8 ; No loop - ; CL = 1 or 2 - - Cmp DWord Ptr [SI+8], 1 - JBE LoadXMSamplesInModule8 - - Or AL, 10h ; Loop - Dec CX - ShL CL, 6 - Or AL, CL - -LoadXMSamplesInModule8: - StosW - - Push SI - ; Sample name - Add SI, 18 - Mov CX, 22/2 - Rep MovsW - - Pop SI - - Xor AX, AX ; Cleanup + conversion flags - StosW - StosW - Mov AH, [SI+15] ; Default pan - ShR AH, 2 - AdC AH, 80h - Mov AL, 5 ; Delta values, signed - StosW - - Mov EAX, [SI] - Mov [DI+20h], EAX ; File size - Call LoadXISample5 - Mov EAX, [SI+4] - Call LoadXISample5 - Mov EAX, [SI+4] - Add EAX, [SI+8] - Call LoadXISample5 - - ; C5speed.. - Push ES - Push DI - - Call Music_GetPitchTable ; Returns ES:DI - Mov AL, [SI+16] ; Relative note number - Add AL, 60 ; AL = note multiplier - And AX, 0FFh - ShL AX, 2 - Add DI, AX - Mov ECX, [ES:DI] - - Mov AL, [SI+13] ; Finetune, -128->+127 - SAR AL, 4 ; Finetune = -8->+7 - And AX, 0Fh - Add AX, AX - Mov DI, AX - MovZX EAX, [CS:FineTuneTable+DI] - - Pop DI - Pop ES - - Mul ECX - ShRD EAX, EDX, 16 - StosD ; C5freq - - Xor AX, AX - StosW - StosW - StosW - StosW - ; Now position - Mov AX, 4201h - Xor CX, CX - Xor DX, DX - Int 21h ; Returns file position in DX:AX - - Push AX - ShRD EAX, EDX, 16 - Pop AX - Pop EDX - Add EAX, EDX - StosD - Xor AX, AX - StosW - StosW - - Add EDX, [DS:SI] - Inc CS:NumSamples - Jmp LoadXMSamplesInModule5 - -EndP LoadXMSamplesInModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -KRZSampleOffset DD 0 -KRZSampleStartingOffset DD 0 -KRZFileOffset DD 0 - -Proc LoadKRZSamples - - Mov AH, 3Fh - Mov CX, 32 - Mov DX, 64000 - Int 21h - - Mov CS:KRZFileOffset, 32 - - Mov EAX, [DS:64000+4] ; Sample start offset - Call SoftBSWAP - - Mov CS:KRZSampleOffset, EAX - Mov CS:KRZSampleStartingOffset, EAX - -LoadKRZSamples1: - Mov EDX, CS:KRZFileOffset - Cmp EDX, CS:KRZSampleStartingOffset - JB LoadKRZSamples2 - - Ret - -LoadKRZSamples2: - Mov AX, 4200h ; Move to location in file - SHLD ECX, EDX, 16 - Int 21h - - Mov AH, 3Fh - Mov CX, 1000 - Mov DX, 64000 - Int 21h ; Load .KRZ object - - Mov AX, [DS:64000+6] ; Block size - XChg AH, AL - Add AX, 7 - And EAX, 0FFFCh - Add CS:KRZFileOffset, EAX - - Mov AX, [DS:64000+4] ; Sample object? - Cmp AL, 98h - JB LoadKRZSamples1 - Cmp AL, 9Bh - JA LoadKRZSamples1 - - Push BX - - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Mov Byte Ptr [DI+88], 15 ; KRZ sample. - Call TransferFileName - - Mov AL, 64 ; Global volume - StosB - - Mov BX, [DS:64000+8] - XChg BH, BL - Add BX, 64000+20 - - ; BX points to start of - ; KRZSampleHdr - - Mov AX, 4003h ; Flags + Default volume - ; sample present, 16-bit - Mov DL, [BX+1] - - Test DL, 2 ; Bidir loop? - JZ LoadKRZSamples5 - - Or AL, 0C0h ; Ping pong - -LoadKRZSamples5: - Test DL, 80h ; Loop off? - JNZ LoadKRZSamples6 - - Mov ECX, [BX+16] - Cmp ECX, [BX+20] - JE LoadKRZSamples6 - - Or AL, 10h ; Loop on. - -LoadKRZSamples6: - StosW ; Flags + DFV done. - -; Sample name. - - Mov SI, 64000+10 - Mov CX, 26 - -LoadKRZSamples3: - LodsB - Test AL, AL - JZ LoadKRZSamples4 - StosB - Loop LoadKRZSamples3 - - Xor AL, AL - -LoadKRZSamples4: - Rep StosB - - Mov AX, 1+2+32*256 - StosW ; Signed sample, default pan = 32 - - ; Length - Mov EAX, [BX+8] - Call SoftBSWAP - Mov EBP, EAX - - Mov EAX, [BX+20] - Call SoftBSWAP - Sub EAX, EBP - StosD - Add EAX, EAX - Mov [DI+20h-4], EAX ; File size - - Mov EAX, [BX+16] ; start of loop - Call SoftBSWAP - Sub EAX, EBP - StosD - Mov EAX, [BX+20] - Call SoftBSWAP - Sub EAX, EBP - Cmp EAX, [ES:DI-4] - JB NextKRZ - StosD - - Mov EAX, [BX+28] - Call SoftBSWAP - Mov ECX, EAX - - Mov EAX, 22000 - Test ECX, ECX - JZ LoadKRZSamples7 - - Xor EDX, EDX - Mov EAX, 1000000000 - - Div ECX - Test EAX, EAX - JNZ LoadKRZSamples7 - - Mov EAX, 44100 - -LoadKRZSamples7: - StosD ; C5Speed - - Xor EAX, EAX - StosD - StosD - - Mov EAX, CS:KRZSampleOffset - Add EAX, EBP - Add EAX, EBP - StosD - - Xor EAX, EAX - StoSD - - Inc CS:NumSamples - -NextKRZ: - Pop BX - Jmp LoadKRZSamples1 - -EndP LoadKRZSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StorePATLength - - Test DL, 1 ; 16-bit? - JZ StorePATLength1 - - ShR EAX, 1 - -StorePATLength1: - StosD - Ret - -EndP StorePATLength - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadPATSamples - - Mov AH, 3Fh - Mov CX, 129+63+47 ; 129 bytes for file header, 63 for - ; instrument header, 47 for layer - Mov DX, 65000 - Int 21h - - Mov BP, [DS:65000+129+63+6] - And BP, 0FFh ; BP = number of waves. - -LoadPATSamples1: - Mov AH, 3Fh - Mov DX, 64000 - Mov CX, 96 - Int 21h ; Read data in - - Mov AX, 96 - Mul CS:NumSamples - Mov DI, AX - - Inc CS:NumSamples - - Mov Byte Ptr [DI+88], 16 ; GUS Patch - Call TransferFileName - - Mov AL, 64 ; Global volume - StosB - - Mov AX, 4001h ; sample present - Mov DL, [DS:64000+55] ; modes - - Test DL, 1 ; 8/16 bit - JZ LoadPATSamples2 - - Or AL, 2 - -LoadPATSamples2: - Test DL, 4 ; Looping enabled? - JZ LoadPATSamples3 - - Or AL, 10h - -LoadPATSamples3: - Test DL, 8 ; Ping pong loops? - JZ LoadPATSamples4 - - Or AL, 40h - -LoadPATSamples4: - StosW ; OK.. now for name. - - Mov SI, 65000+129+2 - Mov CX, 16 - -LoadPATSamples5: - LodsB - Test AL, AL - JZ LoadPATSamples6 - StosB - Loop LoadPATSamples5 - -LoadPATSamples6: - Add CX, 9 - - Mov AL, ':' - StosB - Mov SI, 64000 - -LoadPATSamples7: - LodsB - Test AL, AL - JZ LoadPATSamples8 - StosB - Loop LoadPATSamples7 - -LoadPATSamples8: - Xor AL, AL - Rep StosB - - ; Convert, default pan - - Mov AH, 32 - Mov AL, [DS:64000+55] - And AL, 2 - ShR AL, 1 - Xor AL, 1 - StosW - - ; Length. - - Mov DL, [DS:64000+55] - - Mov EAX, [DS:64000+16] ; ->Length - Mov [DI+20h], EAX ; File size - Call StorePATLength - - Mov EAX, [DS:64000+12] ; LoopBeg - Call StorePATLength - Mov EAX, [DS:64000+16] ; LoopEnd - Call StorePATLength - - Mov AX, [DS:64000+20] - And EAX, 0FFFFh - StosD ; C5Spd - - Xor EAX, EAX - StosD - StosD - - Mov AX, 4201h - Xor CX, CX - Xor DX, DX - Int 21h ; Current position. - - StosW - Mov AX, DX - StosW - - Xor AX, AX - StosW - StosW - - Mov AX, 4201h - Mov CX, [DS:64000+10] - Mov DX, [DS:64000+8] - Int 21h - - Dec BP - JNZ LoadPATSamples1 - - Ret - -EndP LoadPATSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; In-Module sample loaders have to place the information at Sample*96 bytes +; in ITS format into DiskDataArea. Provided with: +; BX = file handle, File at header section. +; DS, ES = DiskDataArea +; +; Variables to update: +; NumSamples (initialised to 1 before the call) +; +; Variables to use: +; InSampleDateTime (DWord) +; CS:InSampleFileName (13 bytes) +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SoftBSWAP ; EAX, returns EAX + + Push EDX + + SHLD EDX, EAX, 16 ; DX:AX contains value. + XChg DH, AL + XChg DL, AH ; DX:AX in proper order now + ShL EAX, 16 + SHRD EAX, EDX, 16 + + Pop EDX + Ret + +EndP SoftBSWAP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TransferFileName + + Mov EAX, 'SPMI' + StosD + + Push DS + + Push CS + Pop DS + Assume DS:Disk + + Mov EAX, InSampleDateTime + + Mov SI, Offset InSampleFileName + Mov CX, 13 + Rep MovsB + + Pop DS + Assume DS:Nothing + + Mov [DI+54h-11h], EAX ; Date. + + Ret + +EndP TransferFileName + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadMODSamplesInModule + + Mov AH, 3Fh + Mov CX, 1084 + Mov DX, 63000 + Int 21h + + Xor CX, CX + Mov SI, 63952 + Mov AX, 07F00h + + +LoadMODSamplesInModule1: + LodsB + Cmp CL, AL + JAE LoadMODSamplesInModule2 + + Mov CL, AL + +LoadMODSamplesInModule2: + Dec AH + JNZ LoadMODSamplesInModule1 + + Inc CX ; CX = number of patterns to + ; load + + Mov AL, CS:InSampleChannels + Mul CL ; AX = Chan * patterns + + And EAX, 0FFFFh + ShL EAX, 8 + Add EAX, 1084 + Mov EBP, EAX ; EBP = location of first sample + + Mov SI, 63020 ; First sample + Mov CX, 31 + +LoadMODSamplesInModule3: + Push CX + Push SI + + Mov CX, [SI+22] + XChg CH, CL + Cmp CX, 1 + JBE LoadMODSamplesInModule4 + + ; OK.. have a sample + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Inc CS:NumSamples + + Mov Byte Ptr [DI+88], 14 + Push SI + Call TransferFileName + Pop SI + + Mov AL, 64 + StosB + + Mov AH, [SI+25] ; Default volume + Mov AL, 1 + + Mov CX, [DS:SI+28] + XChg CH, CL + Cmp CX, 1 + JBE LoadMODSamplesInModule5 + + Or AL, 16 + +LoadMODSamplesInModule5: + StosW + + Mov CX, 22 + Rep MovsB + Xor EAX, EAX + StosD + + Mov AX, 32*256+1 ; Convert signed->Unsigned + StosW ; Default pan of 32 + + Mov AX, [SI] + XChg AH, AL + Add EAX, EAX + Mov [DI+20h], EAX ; File size + StosD ; Sample length + + Push EAX + + MovZX EAX, Word Ptr [SI+4] + XChg AH, AL + Add EAX, EAX + StosD ; Loop begin + + MovZX ECX, Word Ptr [SI+6] + XChg CH, CL + Add ECX, ECX + Add EAX, ECX + StosD ; Loop end + + Mov AL, [SI+2] + And AX, 15 + Mov SI, AX + Add SI, SI + Mov AX, [CS:FineTuneTable+SI] + StosW + Xor AX, AX + Mov CX, 5 + Rep StosW + + Mov EAX, EBP + StosD + Xor EAX, EAX + StosD + + Pop EAX + Add EBP, EAX + +LoadMODSamplesInModule4: + Pop SI + Pop CX + + Add SI, 30 + Loop LoadMODSamplesInModule3 + + Ret + +EndP LoadMODSamplesInModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadS3MSamplesInModule + + Mov AH, 3Fh + Mov CX, 2000 + Mov DX, 63000 + Int 21h + + Xor BP, BP + +LoadS3MSamplesInModule1: + Cmp BP, [DS:63000+22h] + JB LoadS3MSamplesInModule2 + + Ret + +LoadS3MSamplesInModule2: + Mov SI, BP + Add SI, SI + Add SI, [DS:63000+20h] + Inc BP + + Mov DX, [DS:63000+SI+60h] + Mov CX, DX + ShR CX, 12 + ShL DX, 4 + Mov AX, 4200h + Int 21h + ; Move to location + Mov DX, 62000 + Mov AH, 3Fh + Mov CX, 80h + Int 21h + + Cmp Byte Ptr [DS:62000], 1 + JNE LoadS3MSamplesInModule1 + Cmp DWord Ptr [DS:62000+10h], 0 + JE LoadS3MSamplesInModule1 + + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Mov Byte Ptr [DI+88], 3 + Call TransferFileName + + Mov AL, 64 + StosB + + Mov AL, [DS:62000+1Fh] ; Flag + Mov AH, AL + And AX, 401h + ShR AH, 1 + ShL AL, 4 + Or AL, AH + Or AL, 1 + Mov AH, [DS:62000+1Ch] ; Default volume + StosW + + Mov SI, 62000+30h + Mov CX, 25 + Rep MovsB + Xor AX, AX + StosW + Mov AL, 32 + StosB + + ; Length + Mov EAX, [DS:62000+10h] + StosD + Test Byte Ptr [DS:62000+1Fh], 4 + JZ LoadS3MSamplesInModule3 + + Add EAX, EAX + +LoadS3MSamplesInModule3: + Mov [DI+20h-4], EAX ; File size + + Mov EAX, [DS:62000+14h] + StosD + Mov EAX, [DS:62000+18h] + StosD + Mov EAX, [DS:62000+20h] + StosD + Xor AX, AX + StosW + StosW + StosW + StosW + ; Sample pointer.. + Mov AL, [DS:62000+0Dh] + ShL EAX, 16 + Mov AX, [DS:62000+0Eh] + ShL EAX, 4 + StosD + Xor AX, AX + StosW + StosW + + Inc CS:NumSamples + Jmp LoadS3MSamplesInModule1 + +EndP LoadS3MSamplesInModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadFARSamplesInModule + + Mov AH, 3Fh + Mov CX, 98 + Mov DX, 63000 + Int 21h + + Mov AX, 4201h + Xor CX, CX + Mov DX, [DS:63000+96] + Int 21h ; Removes song message + + Mov AH, 3Fh + Mov CX, 869-98 + Mov DX, 63000+98 + Int 21h + +; Xor CX, CX +; Mov CL, [DS:63000+354] ; CX = number of patterns + + Mov CX, 256 + +Comment ~ + + Xor CX, CX + Mov CL, [DS:63000+355] + Mov SI, 63000+98 + Xor AH, AH + ; Have to find CX from order list, apparently... + +LoadFARSamplesInModule7: + LodsB + Cmp AL, 0FFh + JE LoadFARSamplesInModule8 + Cmp AL, AH + JB LoadFARSamplesInModule8 + + Mov AH, AL + +LoadFARSamplesInModule8: + Loop LoadFARSamplesInModule7 + + Mov CL, AH + Inc CX + + ~ + + Mov SI, 63000+357 + Xor AX, AX + Xor DX, DX + +LoadFARSamplesInModule1: + Add AX, [SI] + AdC DX, 0 + Add SI, 2 + Loop LoadFARSamplesInModule1 + + ; DX:AX = length of patterns. + Mov CX, DX + Mov DX, AX + Mov AX, 4201h + Int 21h ; OK.. skipped past patterns. + + Mov AH, 3Fh + Mov CX, 8 + Mov DX, 64000 + Int 21h ; Read sample map. + + ; Determine number of samples... + Xor SI, SI ; SI = number of samples + + Mov EDX, [DS:64004] + Mov EAX, [DS:64000] + Mov CX, 64 + +LoadFARSamplesInModule2: + Test AL, 1 + JZ LoadFARSamplesInModule3 + + Inc SI + +LoadFARSamplesInModule3: + ShR EDX, 1 + RCR EAX, 1 + Loop LoadFARSamplesInModule2 + ; OK.. SI = number of samples.. + Mov [DS:65000], SI + + Mov AX, 48 + Mul SI + Mov SI, AX ; SI = number of bytes for sample header + + Mov AX, 4201h + Xor CX, CX + Xor DX, DX + Int 21h + ; DX:AX = position in file. + Add AX, SI + AdC DX, 0 ; DX:AX = position in file of first sam + + Xor BP, BP + +LoadFARSamplesInModule4: + Cmp BP, [DS:65000] + JB LoadFARSamplesInModule5 + + Ret + +LoadFARSamplesInModule5: + Inc BP + + Mov DX, 62000 + Mov AH, 3Fh + Mov CX, 48 + Int 21h + + Cmp DWord Ptr [DS:62000+32], 0 + JE LoadFARSamplesInModule4 + + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Mov Byte Ptr [DI+88], 12 ; FAR sample + Call TransferFileName + + Mov AL, 64 + StosB ; Global volume + + Mov AX, [DS:62000+46] ; 8/16 bit in bit 0 + ; loop in bit 3 of AH + And AX, 801h + ShL AX, 1 + Or AL, AH + Or AL, 1 + Mov DL, AL + Mov AH, 64 + StosW + + Mov SI, 62000 + Mov CX, 25 + +LoadFARSamplesInModule6: + LodsB + StosB + Test AL, AL + LoopNZ LoadFarSamplesInModule6 + + Xor AL, AL + Inc CX + Rep StosB + Mov AX, 1+32*256 + StosW + + Mov EAX, [DS:62000+32] + Mov [DI+20h], EAX ; File size + Call LoadPTMSamplesInModule4 + Mov EAX, [DS:62000+38] ; Begin + Call LoadPTMSamplesInModule4 + Mov EAX, [DS:62000+42] ; End + Call LoadPTMSamplesInModule4 + + Mov AX, 8363 + StosW + Xor AX, AX + Mov CX, 5 + Rep StosW + + ; Get current position in file + Mov AX, 4201h + Xor CX, CX + Xor DX, DX + Int 21h + StosW + Mov AX, DX + StosW + + Xor AX, AX + StosW + StosW + + Mov AX, 4201h + Mov CX, [DS:62000+34] + Mov DX, [DS:62000+32] + Int 21h + + Cmp DWord Ptr [DS:62000+32], 1 + JBE LoadFARSamplesInModule4 + + Inc CS:NumSamples + Jmp LoadFARSamplesInModule4 + +EndP LoadFARSamplesInModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadMTMSamplesInModule + + Mov AH, 3Fh + Mov CX, 66 ; Read header + Mov DX, 63000 + Int 21h + + ; Sample pos = LastsamplePos+Length + ; So.. setup first sample with no length + Mov AH, 64 + Mov AL, [DS:63000+26] + Inc AX + Mul AH + Mov CX, AX ; CX = 64*(LastPatternSaved+1) + + Mov AL, 37 + Mul Byte Ptr [DS:63000+30] ; NOS + Add CX, AX ; CX = NOS*37+64*(LastPatternSaved+1) + Add CX, [DS:63000+28] + Add CX, 194 ; CX = 194+NOS*37+Lngth of comment+... + + Mov AX, 192 + Mul Word Ptr [DS:63000+24] ; Tracks saved + + Add AX, CX + AdC DX, 0 + + Mov [DS:48h], AX + Mov [DS:4Ah], DX + + Mov DWord Ptr [DS:30h], 0 + + Mov Byte Ptr [DS:63000+31], 0 + Xor BP, BP + +LoadMTMSamplesInModule1: + Cmp BP, [DS:63000+30] + JB LoadMTMSamplesInModule2 + + Ret + +LoadMTMSamplesInModule2: + Inc BP + + Mov DX, 62000 + Mov AH, 3Fh + Mov CX, 37 + Int 21h + + Cmp DWord Ptr [DS:62000+22], 0 + JE LoadMTMSamplesInModule1 + + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Mov Byte Ptr [DI+88], 10 ; MTM sample + Call TransferFileName + + Mov AL, 64 + StosB ; Global volume + + Mov AL, 1 + + Mov ECX, [DS:62000+30] + Sub ECX, [DS:62000+26] + + Cmp ECX, 2 + JLE LoadMTMSamplesInModule3 + + Mov AL, 11h ; Loop + sample. + +LoadMTMSamplesInModule3: + Mov AH, [DS:62000+35] + StosW + ; Sample name now.. + Mov SI, 62000 + Mov CX, 22 + +LoadMTMSamplesInModule4: + LodsB + StosB + Test AL, AL + LoopNZ LoadMTMSamplesInModule4 + + Xor AX, AX + Add CX, 4 + Rep StosB + + Mov AH, 32 + StosW + + Mov EAX, [DS:62000+22] + Mov [DI+20h], EAX + StosD + Mov EAX, [DS:62000+26] + StosD + Mov EAX, [DS:62000+30] + StosD + + Mov AL, [DS:62000+34] + And AX, 0Fh + Mov SI, AX + Add SI, SI + Mov AX, [CS:FineTuneTable+SI] + StosW + Xor AX, AX + Mov CX, 5 + Rep StosW + + ; Sample pointer... + Mov EAX, [DI-96] ; Last sample pointer + Add EAX, [DI-96-18h] ; Last sample length + StosD + + Xor AX, AX + StosW + StosW + + Inc CS:NumSamples + Jmp LoadMTMSamplesInModule1 + +EndP LoadMTMSamplesInModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Comment ~ + +Proc LoadULTSamplesInModule + + Mov AH, 3Fh + Mov CX, 48 ; Read 48 bytes. + Mov DX, 63000 + Int 21h + + Xor DH, DH + Mov DL, [DS:63000+47] + ShL DX, 5 ; CX = CX * 32 + Xor CX, CX + Mov AX, 4201h + Int 21h ; Seek.. + + Mov AH, 3Fh + Mov CX, 1 + Mov DX, 63000+48 + Int 21h ; Read 1 byte.. + Mov Byte Ptr [DS:63000+49], 0 + + Ret + +EndP LoadULTSamplesInModule + + ~ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Load669SamplesInModule + + Mov AH, 3Fh + Mov CX, 1F1h + Mov DX, 63000 + Int 21h + + Mov AL, 19h + Mul Byte Ptr [DS:63000+6Eh] + Mov CX, AX + Add CX, 1F1h + + Mov AL, [DS:63000+6Fh] + Xor AH, AH + Mov DX, 600h + Mul DX + + Add AX, CX + AdC DX, 0 + + Mov [DS:48h], AX + Mov [DS:4Ah], DX + + Mov DWord Ptr [DS:30h], 0 + + Mov Byte Ptr [DS:63000+6Fh], 0 + Xor BP, BP + +Load669SamplesInModule1: + Cmp BP, [DS:63000+6Eh] + JB Load669SamplesInModule2 + + Ret + +Load669SamplesInModule2: + Inc BP + + Mov AH, 3Fh + Mov CX, 19h + Mov DX, 62000 + Int 21h + + Cmp DWord Ptr [DS:62000+13], 0 + JE Load669SamplesInModule1 + + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Mov Byte Ptr [DI+88], 11 ; 669 sample + Call TransferFileName + + Mov AL, 64 + StosB ; Global volume + + Mov AL, 1 + + Mov ECX, [DS:62000+21] + Cmp ECX, [DS:62000+13] + JA Load669SamplesInModule3 + + Mov AL, 11h ; Loop + sample. + +Load669SamplesInModule3: + Mov DL, AL + Mov AH, 64 + StosW + + ; Sample name + Mov SI, 62000 + Mov CX, 13 + Rep MovsB + + Xor AX, AX + Mov CX, 13 + Rep StosB + + Mov AH, 32 + StosW + + Mov SI, 62000+13 + LodsD + Mov [DI+20h], EAX + StosD + MovsD + Test DL, 10h + JZ Load669SamplesInModule4 + + MovsD + Jmp Load669SamplesInModule5 + +Load669SamplesInModule4: + Xor AX, AX + StosW + StosW + +Load669SamplesInModule5: + Mov AX, 8363 + StosW + Xor AX, AX + Mov CX, 5 + Rep StosW + + ; Sample pointer... + Mov EAX, [DI-96] ; Last sample pointer + Add EAX, [DI-96-18h] ; Last sample length + StosD + + Xor AX, AX + StosW + StosW + + Inc CS:NumSamples + Jmp Load669SamplesInModule1 + +EndP Load669SamplesInModule + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadPTMSamplesInModule + + Mov AH, 3Fh + Mov CX, 608 ; Read 608 bytes. + Mov DX, 63000 + Int 21h + + Xor BP, BP + +LoadPTMSamplesInModule1: + Cmp BP, [DS:63000+34] + JB LoadPTMSamplesInModule2 + + Ret + +LoadPTMSamplesInModule2: + Inc BP + + Mov DX, 62000 + Mov AH, 3Fh + Mov CX, 80 + Int 21h + + Mov AL, [DS:62000] + And AL, 3 + Cmp AL, 1 + JNE LoadPTMSamplesInModule1 + Cmp DWord Ptr [DS:62000+22], 0 + JE LoadPTMSamplesInModule1 + + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Mov Byte Ptr [DI+88], 9 ; PTM sample + Call TransferFileName + + Mov AL, 64 + StosB ; Global volume + + Mov CL, [DS:62000] ; AL, Bit 0-1 = sample + ; Bit 2 = loop + ; Bit 3 = loop dirn + ; Bit 4 = 8/16 bit + Mov AL, CL + Mov AH, CL + And AX, 1004h + ShL AL, 2 + And CL, 8 + ShR AH, 3 + ShL CL, 3 + Or AL, AH + Or AL, CL + Or AL, 1 + Mov DL, AL + Mov AH, [DS:62000+13] ; Default volume + StosW ; Flag + default volume + + Mov SI, 62000+30h ; Sample name + Mov CX, 25 + Rep MovsB + Xor AX, AX + StosB + + Mov AX, 9+32*256 ; Conversion flag + default pan + StosW + + ; Length + Mov EAX, [DS:62000+22] + Mov [DI+20h], EAX ; File size + Call LoadPTMSamplesInModule4 + Mov EAX, [DS:62000+26] ; Begin + Call LoadPTMSamplesInModule4 + Mov EAX, [DS:62000+30] ; End + Call LoadPTMSamplesInModule4 + Xor EAX, EAX + Mov AX, [DS:62000+14] ; C5Freq + StosD + Xor AX, AX + StosW + StosW + StosW + StosW + ; Sample pointer.. + Mov EAX, [DS:62000+18] + StosD + Xor AX, AX + StosW + StosW + + Inc CS:NumSamples + Jmp LoadPTMSamplesInModule1 + +LoadPTMSamplesInModule4: + Test DL, 2 + JZ LoadPTMSamplesInModule5 + + ShR EAX, 1 + +LoadPTMSamplesInModule5: + StosD + RetN + +EndP LoadPTMSamplesInModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadITSamplesInModule ; DS, ES = DiskDataArea + + Mov AH, 3Fh + Mov CX, 2000 + Mov DX, 63000 + Int 21h ; Loaded module + + Xor BP, BP ; DX = number of samples + +LoadITSamplesInModule1: + Cmp BP, [DS:63000+24h] ; Num Samples + JB LoadITSamplesInModule2 + + Ret + +LoadITSamplesInModule2: + Mov SI, [DS:63000+22h] + Add SI, BP + ShL SI, 2 ; DX = (NumInstrument+NumSamples)*4 + Add SI, [DS:63000+20h] + Inc BP + + Mov DX, [DS:63000+SI+0C0h] + Mov CX, [DS:63000+SI+0C0h+2] + + Mov AX, 4200h + Int 21h + ; OK. file pointer moved to sample header. + ; Memory region to copy it to is BP*96 + + Mov AX, 96 + Mul CS:NumSamples + + Mov DX, AX + Mov DI, DX + Mov AH, 3Fh + Mov CX, 80 + Int 21h + + Mov CL, [DI+12h] + Test CL, 1 + JZ LoadITSamplesInModule1 + + Mov EAX, [DI+30h] ; Length + Test CL, 2 + JZ LoadITSamplesInModule3 + + Add EAX, EAX + +LoadITSamplesInModule3: + Mov [DI+50h], EAX + + Mov Byte Ptr [DI+88], 2 + Call TransferFileName + + Inc CS:NumSamples + Jmp LoadITSamplesInModule1 + +EndP LoadITSamplesInModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadXMHeader + + Mov AH, 3Fh + Mov CX, 74 + Mov DX, 64000 + Int 21h ; Loaded module + + Mov AX, 4200h ; Seek to position from start of module + Mov DX, [DS:64000+60] + Mov CX, [DS:64000+62] + Add DX, 60 + Int 21h + + Xor BP, BP ; BP = pattern counter + ; At first pattern +LoadXMSamplesInModule1: + Cmp BP, [DS:64000+70] ; Number of patterns + JAE LoadXMSamplesInModule2 + + ; Load 4 bytes. + Mov AH, 3Fh + Mov CX, 9 ; Read standard header + Mov DX, 63000 + Int 21h + + Mov AX, 4201h + Xor CX, CX + Mov DX, [DS:63000] + Add DX, [DS:63000+7] + Sub DX, 9 + Int 21h + + Inc BP + Jmp LoadXMSamplesInModule1 + +LoadXMSamplesInModule2: ; OK.. at first instrument + + Ret + +EndP LoadXMHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadXMSamplesInModule + + Call LoadXMHeader + + Xor BP, BP + +LoadXMSamplesInModule3: + Cmp BP, [DS:64000+72] + JB LoadXMSamplesInModule4 + + Ret + +LoadXMSamplesInModule4: + Inc BP + + Mov AH, 3Fh + Mov CX, 4 + Mov DX, 63000 + Int 21h ; Read instrument size field + + Mov AH, 3Fh + Mov CX, [DS:63000] + Sub CX, 4 + Mov DX, 63004 + Int 21h + + Mov AX, [DS:63000+27] ; Number of samples + Test AX, AX + JZ LoadXMSamplesInModule3 + + ; Bytes to read = AX*40 + Mov CX, 40 + Mul CX + Mov CX, AX + Mov AH, 3Fh + Mov DX, 62000 + Int 21h ; OK sample headers read + ; into DS:62000 + + Push BP + Xor BP, BP + Xor EDX, EDX ; EDX = number of bytes to adv + +LoadXMSamplesInModule5: + Cmp BP, [DS:63000+27] ; Number of samples + JB LoadXMSamplesInModule6 + + SHLD ECX, EDX, 16 + Mov AX, 4201h + Int 21h ; Advance file pointer + + Pop BP + Jmp LoadXMSamplesInModule3 + +LoadXMSamplesInModule6: + Push EDX + + Mov AX, 40 + Mul BP + Mov SI, AX + Add SI, 62000 + + Pop EDX + Inc BP + + Cmp DWord Ptr [DS:SI], 0 ; Sample length = 0?? + JE LoadXMSamplesInModule5 + + Push EDX + + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Push SI + + Mov Byte Ptr [DI+88], 8 + Call TransferFileName + + Mov AL, 64 + StosB + + Pop SI + + Mov AH, [SI+12] ; Default volume + Mov AL, 1 + + Mov CL, [SI+14] + Test CL, 10h + JZ LoadXMSamplesInModule7 + + Or AL, 2 ; 16-bit sample + +LoadXMSamplesInModule7: + And CL, 3 + JZ LoadXMSamplesInModule8 ; No loop + ; CL = 1 or 2 + + Cmp DWord Ptr [SI+8], 1 + JBE LoadXMSamplesInModule8 + + Or AL, 10h ; Loop + Dec CX + ShL CL, 6 + Or AL, CL + +LoadXMSamplesInModule8: + StosW + + Push SI + ; Sample name + Add SI, 18 + Mov CX, 22/2 + Rep MovsW + + Pop SI + + Xor AX, AX ; Cleanup + conversion flags + StosW + StosW + Mov AH, [SI+15] ; Default pan + ShR AH, 2 + AdC AH, 80h + Mov AL, 5 ; Delta values, signed + StosW + + Mov EAX, [SI] + Mov [DI+20h], EAX ; File size + Call LoadXISample5 + Mov EAX, [SI+4] + Call LoadXISample5 + Mov EAX, [SI+4] + Add EAX, [SI+8] + Call LoadXISample5 + + ; C5speed.. + Push ES + Push DI + + Call Music_GetPitchTable ; Returns ES:DI + Mov AL, [SI+16] ; Relative note number + Add AL, 60 ; AL = note multiplier + And AX, 0FFh + ShL AX, 2 + Add DI, AX + Mov ECX, [ES:DI] + + Mov AL, [SI+13] ; Finetune, -128->+127 + SAR AL, 4 ; Finetune = -8->+7 + And AX, 0Fh + Add AX, AX + Mov DI, AX + MovZX EAX, [CS:FineTuneTable+DI] + + Pop DI + Pop ES + + Mul ECX + ShRD EAX, EDX, 16 + StosD ; C5freq + + Xor AX, AX + StosW + StosW + StosW + StosW + ; Now position + Mov AX, 4201h + Xor CX, CX + Xor DX, DX + Int 21h ; Returns file position in DX:AX + + Push AX + ShRD EAX, EDX, 16 + Pop AX + Pop EDX + Add EAX, EDX + StosD + Xor AX, AX + StosW + StosW + + Add EDX, [DS:SI] + Inc CS:NumSamples + Jmp LoadXMSamplesInModule5 + +EndP LoadXMSamplesInModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +KRZSampleOffset DD 0 +KRZSampleStartingOffset DD 0 +KRZFileOffset DD 0 + +Proc LoadKRZSamples + + Mov AH, 3Fh + Mov CX, 32 + Mov DX, 64000 + Int 21h + + Mov CS:KRZFileOffset, 32 + + Mov EAX, [DS:64000+4] ; Sample start offset + Call SoftBSWAP + + Mov CS:KRZSampleOffset, EAX + Mov CS:KRZSampleStartingOffset, EAX + +LoadKRZSamples1: + Mov EDX, CS:KRZFileOffset + Cmp EDX, CS:KRZSampleStartingOffset + JB LoadKRZSamples2 + + Ret + +LoadKRZSamples2: + Mov AX, 4200h ; Move to location in file + SHLD ECX, EDX, 16 + Int 21h + + Mov AH, 3Fh + Mov CX, 1000 + Mov DX, 64000 + Int 21h ; Load .KRZ object + + Mov AX, [DS:64000+6] ; Block size + XChg AH, AL + Add AX, 7 + And EAX, 0FFFCh + Add CS:KRZFileOffset, EAX + + Mov AX, [DS:64000+4] ; Sample object? + Cmp AL, 98h + JB LoadKRZSamples1 + Cmp AL, 9Bh + JA LoadKRZSamples1 + + Push BX + + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Mov Byte Ptr [DI+88], 15 ; KRZ sample. + Call TransferFileName + + Mov AL, 64 ; Global volume + StosB + + Mov BX, [DS:64000+8] + XChg BH, BL + Add BX, 64000+20 + + ; BX points to start of + ; KRZSampleHdr + + Mov AX, 4003h ; Flags + Default volume + ; sample present, 16-bit + Mov DL, [BX+1] + + Test DL, 2 ; Bidir loop? + JZ LoadKRZSamples5 + + Or AL, 0C0h ; Ping pong + +LoadKRZSamples5: + Test DL, 80h ; Loop off? + JNZ LoadKRZSamples6 + + Mov ECX, [BX+16] + Cmp ECX, [BX+20] + JE LoadKRZSamples6 + + Or AL, 10h ; Loop on. + +LoadKRZSamples6: + StosW ; Flags + DFV done. + +; Sample name. + + Mov SI, 64000+10 + Mov CX, 26 + +LoadKRZSamples3: + LodsB + Test AL, AL + JZ LoadKRZSamples4 + StosB + Loop LoadKRZSamples3 + + Xor AL, AL + +LoadKRZSamples4: + Rep StosB + + Mov AX, 1+2+32*256 + StosW ; Signed sample, default pan = 32 + + ; Length + Mov EAX, [BX+8] + Call SoftBSWAP + Mov EBP, EAX + + Mov EAX, [BX+20] + Call SoftBSWAP + Sub EAX, EBP + StosD + Add EAX, EAX + Mov [DI+20h-4], EAX ; File size + + Mov EAX, [BX+16] ; start of loop + Call SoftBSWAP + Sub EAX, EBP + StosD + Mov EAX, [BX+20] + Call SoftBSWAP + Sub EAX, EBP + Cmp EAX, [ES:DI-4] + JB NextKRZ + StosD + + Mov EAX, [BX+28] + Call SoftBSWAP + Mov ECX, EAX + + Mov EAX, 22000 + Test ECX, ECX + JZ LoadKRZSamples7 + + Xor EDX, EDX + Mov EAX, 1000000000 + + Div ECX + Test EAX, EAX + JNZ LoadKRZSamples7 + + Mov EAX, 44100 + +LoadKRZSamples7: + StosD ; C5Speed + + Xor EAX, EAX + StosD + StosD + + Mov EAX, CS:KRZSampleOffset + Add EAX, EBP + Add EAX, EBP + StosD + + Xor EAX, EAX + StoSD + + Inc CS:NumSamples + +NextKRZ: + Pop BX + Jmp LoadKRZSamples1 + +EndP LoadKRZSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StorePATLength + + Test DL, 1 ; 16-bit? + JZ StorePATLength1 + + ShR EAX, 1 + +StorePATLength1: + StosD + Ret + +EndP StorePATLength + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadPATSamples + + Mov AH, 3Fh + Mov CX, 129+63+47 ; 129 bytes for file header, 63 for + ; instrument header, 47 for layer + Mov DX, 65000 + Int 21h + + Mov BP, [DS:65000+129+63+6] + And BP, 0FFh ; BP = number of waves. + +LoadPATSamples1: + Mov AH, 3Fh + Mov DX, 64000 + Mov CX, 96 + Int 21h ; Read data in + + Mov AX, 96 + Mul CS:NumSamples + Mov DI, AX + + Inc CS:NumSamples + + Mov Byte Ptr [DI+88], 16 ; GUS Patch + Call TransferFileName + + Mov AL, 64 ; Global volume + StosB + + Mov AX, 4001h ; sample present + Mov DL, [DS:64000+55] ; modes + + Test DL, 1 ; 8/16 bit + JZ LoadPATSamples2 + + Or AL, 2 + +LoadPATSamples2: + Test DL, 4 ; Looping enabled? + JZ LoadPATSamples3 + + Or AL, 10h + +LoadPATSamples3: + Test DL, 8 ; Ping pong loops? + JZ LoadPATSamples4 + + Or AL, 40h + +LoadPATSamples4: + StosW ; OK.. now for name. + + Mov SI, 65000+129+2 + Mov CX, 16 + +LoadPATSamples5: + LodsB + Test AL, AL + JZ LoadPATSamples6 + StosB + Loop LoadPATSamples5 + +LoadPATSamples6: + Add CX, 9 + + Mov AL, ':' + StosB + Mov SI, 64000 + +LoadPATSamples7: + LodsB + Test AL, AL + JZ LoadPATSamples8 + StosB + Loop LoadPATSamples7 + +LoadPATSamples8: + Xor AL, AL + Rep StosB + + ; Convert, default pan + + Mov AH, 32 + Mov AL, [DS:64000+55] + And AL, 2 + ShR AL, 1 + Xor AL, 1 + StosW + + ; Length. + + Mov DL, [DS:64000+55] + + Mov EAX, [DS:64000+16] ; ->Length + Mov [DI+20h], EAX ; File size + Call StorePATLength + + Mov EAX, [DS:64000+12] ; LoopBeg + Call StorePATLength + Mov EAX, [DS:64000+16] ; LoopEnd + Call StorePATLength + + Mov AX, [DS:64000+20] + And EAX, 0FFFFh + StosD ; C5Spd + + Xor EAX, EAX + StosD + StosD + + Mov AX, 4201h + Xor CX, CX + Xor DX, DX + Int 21h ; Current position. + + StosW + Mov AX, DX + StosW + + Xor AX, AX + StosW + StosW + + Mov AX, 4201h + Mov CX, [DS:64000+10] + Mov DX, [DS:64000+8] + Int 21h + + Dec BP + JNZ LoadPATSamples1 + + Ret + +EndP LoadPATSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/IT_D_RM.INC b/it_d_rm.inc similarity index 96% rename from IT_D_RM.INC rename to it_d_rm.inc index f9b0fb0..93369f1 100644 --- a/IT_D_RM.INC +++ b/it_d_rm.inc @@ -1,2889 +1,2889 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Read module functions -; - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF TUTORIAL -ELSE - -Proc D_PreLoadModule ; Returns ES = song segment - ; BX = file handle - ; DS = Diskdata area - ; AX = SaveFormat - -; Call MouseUpdateEnable - -IF DEFAULTFORMAT - Test AL, AL - JNZ D_PreLoadModuleTemp - - Mov AL, DEFAULTFORMAT - -D_PreLoadModuleTemp: -ENDIF - Mov SaveFormat, AL - - Call I_ClearTables - Call Music_ReleaseAllPatterns - Call Music_ReleaseAllSamples - Call Music_ClearAllSampleNames - Call Music_ClearAllInstruments - Call Msg_ResetMessage - Call ReleaseTimerData - - Mov DS, CS:DiskDataArea - - Mov BX, CS:CurrentFile - Add BX, BX - Mov BX, [BX] - Add BX, 8 - - Push CS - Pop ES - Mov DI, Offset FileName ; OK... - Mov SI, BX ; Data area no longer - Mov CX, 13 ; reqd - Rep MovsB - - Mov AX, 3D00h - Mov DX, BX - Int 21h - JC D_LoadFileOpenErrorMsg - - Mov BX, AX ; BX = file handle. - - Call Music_GetSongSegment - Mov ES, AX - - Ret - -EndP D_PreLoadModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostLoadModule Far - - Mov AH, 3Eh ; Close file. - Int 21h - - Push CS - Pop DS - Assume DS:Disk - - Call CheckTimerData - Call GetCurrentTime - - Mov [TopTimerData], 0 - - Call GetTimerCounter - Mov [EditTimer], EAX - - Call PE_ResetOrderPattern - -; Mov AX, 1 - Ret - -EndP D_PostLoadModule - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_InsertOrder ; DX = inserting pattern, BP = current - ; ES = songdata - PushA - Push DS - - Push ES - Pop DS - - Mov SI, 1FFh - Mov AX, BP - -D_InsertOrder1: - Cmp AL, [SI] - JE D_InsertOrder2 - -D_InsertOrderResume: - Dec SI - Cmp SI, 100h - JAE D_InsertOrder1 - - Pop DS - PopA - Ret - -D_InsertOrder2: - Push SI - Mov CX, 1FEh - Mov DI, 1FFh - Sub CX, SI - JC D_InsertOrder3 - - Mov SI, 1FEh - - StD - Rep MovsB - ClD - - Mov AL, DL - StosB - -D_InsertOrder3: - Pop SI - Jmp D_InsertOrderResume - -EndP D_InsertOrder - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadXM Far - - Xor AX, AX - Call D_PreLoadModule - Assume DS:Nothing - - Mov AH, 3Fh - Mov CX, 64 ; Header length - Mov DX, 64000 - Int 21h - - Mov AH, 3Fh ; Read rest of header. - Mov CX, [DS:64000+60] - Sub CX, 4 - Mov DX, 64104 - Int 21h - - Mov DI, 4 - Mov CX, 20 - Mov SI, 64000+17 - Rep MovsB - Xor AX, AX - Mov CX, 5 - Rep StosW ; OK name transferred. - - ; Number of Instruments - Mov AX, [DS:64100+12] - StosW ; Insnum - - Mov AX, 1 - StosW - - ; Number of Patterns - Mov AX, [DS:64100+10] - StosW - Mov [ES:0C0h], AX ; Number of patterns. - - ; CWT/V, CMWT - Add DI, 4 - - ; Flags - Mov AX, [DS:64100+14] - And AX, 1 - ShL AX, 3 - Or AX, 35h ; XM Effects, Old effects, stereo, insts - StosW - - ; Reserved - Xor AX, AX - StosW - - ; GVolume. MVolume - Mov AX, 128+48*256 - StosW - - ; Initial Speed, Initial Tempo - Mov AL, [DS:64100+16] - Test AL, AL - JNZ InitialSpeedNot0 - - Mov AL, 6 - -InitialSpeedNot0: - Mov AH, [DS:64100+18] - StosW - - ; Separation - Mov AX, 128 - StosW - - ; Message length, offset, timer - Xor AX, AX - Mov CX, 5 - Rep StosW - - ; Channel Pan - - Mov CX, [DS:64100+8] ; Number of channels - Mov AL, 32 - Rep StosB - Mov AL, 128+32 - Mov CX, 64 - Sub CX, [DS:64100+8] - Rep StosB - - ; Channel Volume - - Mov AL, 64 - Mov CX, 64 - Rep StosB - - ; Orders - Add DI, 40h - Mov SI, 64100+20 ; Orders - Mov CX, [DS:64100+4] ; Song legnth - JCXZ D_LoadXMNoPatterns2 - -D_FindMaximumPattern: - LodsB - Cmp AL, 200 - JAE D_FindMaximumPattern3 - - Cmp AL, [ES:0C0h] - JB D_FindMaximumPattern2 - - Inc AX - Mov [ES:0C0h], AX - Dec AX - Jmp D_FindMaximumPattern2 - -D_FindMaximumPattern3: - Mov AL, 0FFh - -D_FindMaximumPattern2: - StosB - Loop D_FindMaximumPattern - -D_LoadXMNoPatterns2: - Mov CX, 256 - Sub CX, [DS:64100+4] - Mov AL, 0FFh - Rep StosB - - ; OK.. now to load patterns. - Cmp Word Ptr [DS:64100+10], 0 - JE D_LoadXMNoPatterns - - Xor BP, BP - -D_LoadXM1: - Push DS SI DI - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset PatternMsg - Mov AH, 5 - Mov DI, (4+16*80)*2 - Push BP - Call S_DrawString - Pop AX - - Pop DI SI DS - Assume DS:Nothing - - Mov AH, 3Fh - Mov CX, 4 - Xor DX, DX - Int 21h ; Read pattern length - - Mov AH, 3Fh - Mov CX, [DS:0] - Mov DX, 4 - Sub CX, DX - Int 21h ; Read pattern header - - Cmp Word Ptr [DS:7], 0 - JE D_LoadXM3 - - Mov AH, 3Fh - Mov CX, [DS:7] - Mov DX, 100h - Mov SI, DX - Int 21h ; DS:100h contains all the - ; pattern data. - - Cmp BP, 200 ; Too many patterns? - JAE D_LoadXM3 - - Mov AX, [DS:5] ; AX = number of rows - Mov CX, [DS:64100+8] ; CX = number of channels - Mov DX, BP - - Cmp AX, 200 - JA D_LoadXM2 - - ; TranslateXMPattern takes: - ; DS:SI points to pattern data - ; AX = rows - ; CX = channels - ; DX = pattern number - - - Call PE_TranslateXMPattern - Jmp D_LoadXM3 - -D_LoadXM2: - ShR AX, 1 - Call PE_TranslateXMPattern - - Mov DX, [ES:0C0h] ; DX = pattern number - Cmp DX, 200 - JAE D_LoadXM3 - - Inc Word Ptr [ES:0C0h] - - Call D_InsertOrder - - Mov AX, [DS:5] - Inc AX - ShR AX, 1 ; AX = number of rows. - Call PE_TranslateXMPattern - -D_LoadXM3: - Inc BP - Cmp BP, [DS:64100+10] - JB D_LoadXM1 - -D_LoadXMNoPatterns: - ; Now to load instruments - Xor BP, BP - Cmp BP, [DS:64100+12] - JE D_LoadXMInstrumentTooMany - -D_LoadXM4: - Push DS SI - - Push CS - Pop DS - Mov SI, Offset InstrumentMsg - Mov AX, BP - Inc AX - Push AX - Mov AH, 5 - Mov DI, (4+17*80)*2 - Call S_DrawString - Pop AX - - Pop SI DS - - Mov AH, 3Fh - Mov CX, 4 - Xor DX, DX - Int 21h - - Mov AH, 3Fh - Mov CX, [DS:0] - Mov DX, 4 - Sub CX, DX - Int 21h - - ; OK.. instrument loaded into DS:0.. - Mov DI, BP - Add DI, DI - Mov DI, [ES:64712+DI] ; ES:DI points to instrument - Push DI - - Mov SI, 4 - Add DI, 20h - Mov CX, 22 - Rep MovsB - Xor AX, AX - Mov CX, 4 - Rep StosW - - Pop DI - Cmp Word Ptr [DS:27], 0 - JE D_LoadXMInstrumentEnd - - Add DI, 14h ; DI points to fadeout - Mov AX, [DS:239] - Add AX, 15 - ShR AX, 5 - Cmp AX, 256 - JBE D_LoadXMInstrument1 - - Mov AX, 256 - -D_LoadXMInstrument1: - StosW - Add DI, 40h-16h ; Translation table - - Mov CX, 12 ; Kill first 12 entries. - Xor AX, AX - -D_LoadXMInstrument2: ; First 12 entries cleared - StosW - Inc AX - Loop D_LoadXMInstrument2 - - Mov CX, 96 - Mov SI, 33 ; Note translation - -D_LoadXMInstrument3: - Mov AH, [SI] - Add AH, [ES:24h] - Cmp AH, 99 - JBE D_LoadXMInstrument4 - - Mov AH, 99 - -D_LoadXMInstrument4: - StosW - Inc SI - Inc AX - Loop D_LoadXMInstrument3 - - Mov CX, 12 ; Kill first 12 entries. - Xor AH, AH - -D_LoadXMInstrument5: ; First 12 entries cleared - StosW - Inc AX - Loop D_LoadXMInstrument5 - - ; Now for volume envelope - Mov AL, [DS:233] ; Flags - Test AL, 1 - JNZ D_LoadXMVolumeEnvelope - - Mov AX, 205h - StosW - Xor AX, AX - StosW - StosW - - Mov AL, 64 - StosB - Xor AX, AX - StosW - - StosB - Mov AX, 1 - StosW - - Mov CX, 70 - Xor AX, AX - Rep StosB - - Jmp D_LoadXMInstrumentVolumeFinished - -D_LoadXMVolumeEnvelope: -; Mov CL, AL -; Mov AH, AL -; And AX, 402h -; ShR AH, 1 -; ShL AL, 1 -; Or AL, AH -; And CL, 1 -; Or AL, CL - - And AL, 2 - ShL AL, 1 - Or AL, 2+1 ; Volume envelope on, Loop on (always) - - Mov AH, [DS:225] ; No of vol env nodes - Cmp AH, 12 - JB D_NumXMVolNodes1 - - Mov AH, 12 - -D_NumXMVolNodes1: - StosW - Mov AX, [DS:228] ; Vol loop start+end - Test Byte Ptr [DS:233], 4 ; Volume loop? - JNZ VolumeLoopOK - - Mov AL, [DS:225] - Dec AX - Mov AH, AL - -VolumeLoopOK: - StosW - Mov AL, [DS:227] ; Vol Sustain point - Mov AH, AL - StosW - - Cmp Byte Ptr [DS:233], 7 - JNE D_XMVolumeNoSustain - - Cmp AL, [DS:229] ; Compare sustain to endpoint - JB D_XMVolumeLoopOK - - And Byte Ptr [ES:DI-6], Not 4 - Jmp D_XMVolumeLoopOK - -D_XMVolumeNoSustain: - Test Byte Ptr [DS:233], 2 ; Loop? - JNZ D_XMVolumeLoopOK - - Mov AL, [DS:225] ; Number of nodes - Dec AX - Mov AH, AL - Mov [ES:DI-2], AX - Or Byte Ptr [ES:DI-6], 4 - -D_XMVolumeLoopOK: - ; OK. now process volume env points - Mov CX, 12 - Mov SI, 129 - -D_LoadXMInstrument6: - Mov AL, [SI+2] - Cmp AL, 64 - JB D_LoadXMInstrument7 - - Mov AL, 64 - -D_LoadXMInstrument7: - StosB - MovsW - LodsW - Loop D_LoadXMInstrument6 - - Mov CX, 13*3+1 - Xor AX, AX - Rep StosB - - ; Now for panning envelope -D_LoadXMInstrumentVolumeFinished: - - Mov AL, [DS:234] ; Flags - Mov CL, AL - Mov AH, AL - And AX, 402h - ShR AH, 1 - ShL AL, 1 - Or AL, AH - And CL, 1 - Or AL, CL - - Mov AH, [DS:226] ; No of pan env nodes - Cmp AH, 12 - JB D_NumXMPanNodes1 - - Mov AH, 12 - -D_NumXMPanNodes1: - StosW - Mov AX, [DS:231] ; Pan loop start+end - StosW - Mov AL, [DS:230] ; Pan Sustain point - Mov AH, AL - StosW - - Test Byte Ptr [DS:234], 2 ; Panning envelope flags - JZ D_XMPanningLoopOK - - Cmp AL, [DS:232] ; Compare sustain to endpoint - JB D_XMPanningLoopOK - - And Byte Ptr [ES:DI-6], Not 4 - -D_XMPanningLoopOK: - ; OK. now process panning env points - Mov CX, 12 - Mov SI, 177 - Xor AH, AH - -D_LoadXMInstrument8: - Mov AL, [SI+2] - Cmp AL, 64 - JB D_LoadXMInstrument9 - - Mov AL, 64 - -D_LoadXMInstrument9: - Sub AL, 32 - StosB - MovsW - LodsW ; Add SI, 2 - Loop D_LoadXMInstrument8 - - Mov AX, [DS:27] - Mul Word Ptr [DS:29] - Mov CX, AX - Mov AH, 3Fh - Mov DX, 1000h - Mov SI, DX - Int 21h - - Mov CX, [DS:27] ; Update number of samples. - Mov AX, [ES:24h] - Add [ES:24h], CX - -D_LoadXMSamples1: - Cmp AX, 99 - JA D_LoadXMInstrumentTooMany - Cmp AX, [ES:24h] - JAE D_LoadXMInstrumentEnd - - Push AX - Push SI - - Mov DI, AX - Add DI, DI - Mov DI, [ES:64912+DI-2] - Add DI, 12h ; Skip filename, ID, GVL - - Mov AH, [SI+12] ; Default volume - Mov AL, 0 - Cmp DWord Ptr [SI], 0 ; Length = 0? - JE D_LoadXMSamples3 - - ; Grab the panning value - -Comment ~ - Mov AL, [SI+15] - ShR AL, 1 - Inc AX - ShR AL, 1 - - Push DI - Mov DI, BP - Add DI, DI - Mov DI, [ES:64712+DI] - Cmp Byte Ptr [ES:DI+19h], 32+128 - JE XMNoPan2 - - Mov AL, 32 - -XMNoPan2: - Mov [ES:DI+19h], AL - -XMNoPan: - Pop DI -~ - ; Sample present flag - Mov AL, 1 - - Mov CL, [SI+14] - Test CL, 10h ; 16 bit sample? - JZ D_LoadXMSamples2 - - Or AL, 2 - -D_LoadXMSamples2: - And CL, 3 - JZ D_LoadXMSamples3 ; No loop - ; CL = 1 or 2 - Cmp DWord Ptr [SI+8], 1 - JBE D_LoadXMSamples3 - - Or AL, 10h ; Loop - Dec CX - ShL CL, 6 - Or AL, CL - -D_LoadXMSamples3: - StosW - - Push SI - ; Copy sample name - Add SI, 18 - Mov CX, 22/2 - Rep MovsW - Xor AX, AX - StosW - StosW - - Pop SI - ; Conversion flags. - Mov AH, [SI+15] - ShR AH, 2 - AdC AH, 80h - Mov AL, 5 - StosW - - Mov EAX, [SI] - Call LoadXISample5 - Mov EAX, [SI+4] - Call LoadXISample5 - Mov EAX, [SI+4] - Add EAX, [SI+8] - Call LoadXISample5 - - ; C5speed.. - Push ES - Push DI - - Call Music_GetPitchTable ; Returns ES:DI - Mov AL, [SI+16] ; Relative note number - Add AL, 60 ; AL = note multiplier - And AX, 0FFh - ShL AX, 2 - Add DI, AX - Mov ECX, [ES:DI] - - Mov AL, [SI+13] ; Finetune, -128->+127 - SAR AL, 4 ; Finetune = -8->+7 - And AX, 0Fh - Add AX, AX - Mov DI, AX - MovZX EAX, [CS:FineTuneTable+DI] - - Pop DI - Pop ES - - Push EDX - - Mul ECX - ShRD EAX, EDX, 16 - Pop EDX - StosD ; C5freq - - Xor AX, AX - StosW - StosW - StosW - StosW - - ; Now for file position - Mov AX, 4201h - Xor CX, CX - Xor DX, DX - Int 21h ; Returns DX:AX - - StosW - Mov AX, DX - StosW - - ; Vibrato information - Mov AX, [DS:237] - XChg AH, AL - StosW - - Mov DX, [DS:236] - And DX, 0FFh - Mov AX, 100h - Sub AX, DX -; Cmp AL, 64 -; JBE VibratoLimit -; -; Mov AL, 64 -; -; VibratoLimit: - Mov AH, [DS:235] - StosW - - ; Move file pointer forwards - Mov AX, 4201h - Mov CX, [SI+2] - Mov DX, [SI] - Int 21h - - Pop SI - Pop AX - Add SI, [DS:29] ; Next sample header - Inc AX - Jmp D_LoadXMSamples1 - -D_LoadXMInstrumentEnd: - Inc BP - Cmp BP, 99 - JA D_LoadXMInstrumentTooMany - Cmp BP, [DS:64100+12] - JB D_LoadXM4 - -D_LoadXMInstrumentTooMany: - Mov CX, 1 ; CX = sample number (base 1) - ; DS = doesn't matter - ; ES = songdata segment - -D_LoadXMFinalSamples1: ; OK, now load the samples. - Push CX - Push ES - - Mov SI, CX - Dec SI - Add SI, SI - Mov SI, [ES:64912+SI] - Test Byte Ptr [ES:SI+12h], 1 - JZ D_LoadXMFinalSamples2 - - Push CS - Pop DS - - Push SI - Mov SI, Offset SampleMsg - Mov DI, (4+18*80)*2 - Mov AH, 5 - Push CX - Call S_DrawString - Pop DI - Pop SI ; ES:SI points to sample header. - ; DI = sample number+1 - Push ES - Pop DS - - Mov AX, 4200h - Xor CX, CX - Xor DX, DX - XChg CX, [DS:SI+4Ah] - XChg DX, [DS:SI+48h] - Int 21h ; Move file pointer. - - Mov AX, DI - Dec AX - - Call D_LoadSampleData - Jmp D_LoadXMFinalSamplesPresent - -D_LoadXMFinalSamples2: - Mov DWord Ptr [SI+48h], 0 - -D_LoadXMFinalSamplesPresent: - Pop ES - Pop CX - Inc CX - Cmp CX, 100 - JBE D_LoadXMFinalSamples1 - - Jmp D_PostLoadModule - -EndP D_LoadXM - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadMTM Far - - Xor AX, AX - Call D_PreLoadModule - - Assume DS:Nothing - - Mov AH, 3Fh - Mov CX, 66 ; Song header length. - Mov DX, 60000 - Int 21h - - Mov DI, 4 - Mov CX, 20 - Mov SI, 60004 - Rep MovsB - Xor AX, AX - Mov CX, 8 - Rep StosB ; Song name. - Mov AL, [DS:60027] - StosW ; Order num - Xor AL, AL - StosW ; Inst num - Mov AL, [DS:60030] - StosW ; Sample number. - Mov AL, [DS:60026] - StosW ; Pattern number - - Add DI, 4 -; Mov AX, 101h ; Cwt/v 1.0 -; StosW -; Mov AX, 100h ; Cmwt 1.0 -; StosW - - Mov AX, 31h ; Stereo. No Vol0Opt - StosW ; Use samples, old eff - Xor AX, AX - StosW - Mov AX, 3080h ; GlobalVol+MixVol - StosW - Mov AX, 7D06h - StosW - Mov AL, 128 - StosB - Xor AL, AL - Mov CX, 11 - Rep StosB - - Mov CX, 32 - Mov DX, 0 - Xor AH, AH - ; Panning positions -D_LoadMTM1: - Mov SI, 60034 - Add SI, DX - Mov AL, [DS:SI] - Mov SI, AX - Mov AL, [CS:PanningPositions+SI] - StosB - - Inc DX - Loop D_LoadMTM1 - - Mov CX, 32 - Mov AL, 160 - Rep StosB - Mov AL, 64 - Mov CX, 64 - Rep StosB - - Push DS - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset SampleHeaderMsg - Mov AH, 5 - Mov DI, (4+16*80)*2 - Call S_DrawString - - Pop DS - Assume DS:Nothing - - Mov AL, 37 - Mul Byte Ptr [ES:24h] ; AX = length of - ; sample headers - Mov CX, AX ; length.. - Mov AH, 3Fh ; read file.. - Xor DX, DX - Int 21h - - - Mov DH, [ES:24h] - Mov DI, 55912 ; Start of samples. - Xor SI, SI ; DS:SI points to MTM header. - -D_LoadMTM2: - Mov EAX, 'SPMI' - StosD - Xor AX, AX - Mov CX, 6 - Rep StosW ; Clear file name. - StosB - Mov AL, 40h - StosB - - - Mov AL, [DS:SI+36] - And AL, 1 - Add AL, AL - - Cmp DWord Ptr [DS:SI+22], 0 - JE D_LoadMTM3 ; Sample length = 0. - - Or AL, 1 ; Else there's a sample. - -D_LoadMTM3: - Mov ECX, [SI+30] ; Sample loop end - Sub ECX, [SI+26] ; Sample loop start - Cmp ECX, 2 - JBE D_LoadMTM4 - - Or AL, 16 - -D_LoadMTM4: - StosB - Mov DL, AL - Mov AL, [DS:SI+35] - StosB - - Push SI - - Mov CX, 22 - -D_LoadMTMSampleName: - LodsB - StosB - And AL, AL - LoopNZ D_LoadMTMSampleName - Pop SI - - Xor AL, AL - Add CX, 5 - Rep StosB ; Filler. - Mov AL, 32 - StosB - - Mov EAX, [DS:SI+22] - StosD - - Test DL, 1 - JNZ D_LoadMTM5 - - Xor AX, AX - Mov CX, 4 - Rep StosW ; Clear rest of sample field. - Mov AX, 8363 ; (no sample) - StosW - Xor AX, AX - Mov CX, 9 - Rep StosW - - Jmp D_LoadMTM8 - -D_LoadMTM5: - Test DL, 16 - JZ D_LoadMTM6 - - Mov EAX, [DS:SI+26] - StosD - Mov EAX, [DS:SI+30] - StosD - Jmp D_LoadMTM7 - -D_LoadMTM6: - Xor AX, AX - Mov CX, 4 - Rep StosW - -D_LoadMTM7: ; C5 speed here... - Push SI - Mov AL, [DS:SI+34] - And AX, 0Fh - Mov SI, AX - Add SI, SI - Mov AX, [CS:FineTuneTable+SI] - Pop SI - StosW - Xor AX, AX - Mov CX, 9 - Rep StosW - -D_LoadMTM8: - Add SI, 37 - Dec DH - JNZ D_LoadMTM2 ; Finished with samples. - - Mov AH, 3Fh - Mov CX, 128 - Xor DX, DX - Int 21h ; Order data. - - Mov CL, [DS:60027] - Inc CX - Xor CH, CH - Mov DX, 256 - Sub DX, CX - Xor SI, SI - Mov DI, 256 - Rep MovsB - Mov CX, DX - Mov AL, 0FFh - Rep StosB ; Order list done. - ; Now it's time to do the - ; friggen pattern stuff. - Mov AL, 37 - Mul Byte Ptr [DS:60030] - Add AX, 66+128 - Push AX - - Mov AX, 192 - Mul Word Ptr [DS:60024] - ; DX:AX = length of track data. - Mov BP, DX - Mov CX, AX - Xor DX, DX - Pop AX - Add CX, AX - AdC BP, 0 - ; BP:CX = offset to sequencer -D_LoadMTM9: ; DX = pattern no. - ; AX = offset to track data. - Push AX - Push CX - Push DX - - Push AX - - Push DS - Push SI - Push DI - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset PatternMsg - Mov AH, 5 - Mov DI, (4+17*80)*2 - Push DX - Call S_DrawString - Pop AX - - Pop DI - Pop SI - Pop DS - Assume DS:Nothing - - - Mov AX, 4200h - Mov DX, CX - Mov CX, BP - Int 21h ; Move to offset. - - Mov AH, 3Fh - Mov CX, 64 - Xor DX, DX - Int 21h ; Read seq data. - - Pop AX - - Mov CX, 32 - Xor SI, SI - Mov DX, AX ; DX = posn of track data. - Mov DI, 10000 - -D_LoadMTM10: - Push CX - Push DX - - LodsW - And AX, AX - JZ D_LoadMTM11 - - Push DS - Push SI - Push DI - Mov SI, 33 - Sub SI, CX - Push AX - Push SI - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset TrackMsg - Mov DI, (5+18*80)*2 - Mov AH, 5 - Call S_DrawString - - Pop SI - Pop AX - Pop DI - Pop SI - Pop DS - Assume DS:Nothing - - Push DX - - Dec AX - Mov CX, 192 - Mul CX - - Pop CX - Add AX, CX - AdC DX, 0 - Mov CX, DX - Mov DX, AX - Mov AX, 4200h - Int 21h ; Move ptr. - - Mov AH, 3Fh - Mov CX, 192 - Mov DX, DI - Int 21h - - Add DI, 192 - Jmp D_LoadMTM12 - -D_LoadMTM11: - Push ES - - Push DS - Pop ES - - Mov CX, 192 - Xor AL, AL - Rep StosB - - Pop ES - -D_LoadMTM12: - Pop DX - Pop CX - Loop D_LoadMTM10 - - Mov SI, 10000 - ; DS:SI points to pattern data. - - Pop DX - ; DX = pattern number - ; DS:SI = pattern data. - Call PE_TranslateMTMPattern - - Pop CX - Pop AX - Add CX, 64 - AdC BP, 0 - Inc DX - Cmp DL, [DS:60026] - JBE D_LoadMTM9 - - ; BP:CX points to comment - - Comment & - - Mov AL, 37 - Mul Byte Ptr [DS:60030] - ; AX = 37*NOS - Add AX, 194 - Add AX, Word Ptr [DS:60028] ; AX = 194+NOS*37+length_comment - Mov CX, AX - Mov AX, 192 - Mul Word Ptr [DS:60024] ; DX:AX = trcks*192 - Mov BP, DX - Add CX, AX - AdC BP, 0 ; BP:CX = 194+NOS*37+trcks*192+ - ; length(comment) - Mov AL, 64 - Mov AH, Byte Ptr [DS:60026] - Inc AH - Mul AH - Add CX, AX - AdC BP, 0 ; BP:CX = 194+NOS*37+trcks*192+ - ; 64*patterns+length(comment) - - & - -; Add CX, [DS:60028] ; Skip past comment -> samples. -; AdC BP, 0 -; - Mov AX, 4200h - Mov DX, CX - Mov CX, BP - Int 21h ; File is at pointers to samps. - - Mov CX, [DS:60028] ; Length of message - Call Msg_GetMessageOffset ; Sets up DS:DX - Mov AH, 3Fh - Int 21h - ; Now to 'process' the message. - - Mov SI, DX - Mov CX, AX - - Xor DX, DX ; DX = character count. - -D_LoadMTMMessage1: - Mov AL, [SI] - And AL, AL - JNZ D_LoadMTMMessage2 - - Mov Byte Ptr [SI], 32 ; spacebar. - -D_LoadMTMMessage2: - Inc DX - Cmp DX, 40 - JB D_LoadMTMMessage3 - - Xor DX, DX - Mov Byte Ptr [SI], 13 ; Enter! - -D_LoadMTMMessage3: - Inc SI - Loop D_LoadMTMMessage1 - - Push ES - Pop DS - Mov SI, 55912 ; DS:SI points to sample headers - Xor CX, CX - -D_LoadMTM13: - Push CX - Push SI - Test Byte Ptr [DS:SI+12h], 1 - JZ D_LoadMTM14 - ; OK.. have a sample to load. - Push DS - Push SI - - Push CS - Pop DS - Mov SI, Offset SampleMsg - Mov DI, (4+20*80)*2 - Mov AX, CX - Inc AX - Push AX - Mov AH, 5 - Call S_DrawString - Pop AX - Dec AX - - Pop SI - Pop DS - - Call D_LoadSampleData - -D_LoadMTM14: - Pop SI - Pop CX - Inc CX - Add SI, 80 - Cmp CX, 100 - JB D_LoadMTM13 - - Jmp D_PostLoadModule - -EndP D_LoadMTM - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadS3M Far - - Mov AL, 1 - Call D_PreLoadModule - - Mov AH, 3Fh - Mov CX, 60h - Mov DX, 60000 - Int 21h - - Mov DI, 4 - Mov CX, 25 - Mov SI, 60000 - Rep MovsB - Xor AL, AL - StosB - Add DI, 14 - - Mov AX, 10h ; Old Effects - - Test Byte Ptr [DS:60000+33h], 80h - JZ D_LoadS3M1 - - Inc AX - -D_LoadS3M1: - Test Byte Ptr [DS:60000+26h], 8 - JZ D_LoadS3M2 - - Or AL, 2 - -D_LoadS3M2: - StosW - Xor AX, AX - StosW - Mov AL, [DS:60000+30h] - ShL AL, 1 - StosB - Mov AL, [DS:60000+33h] - And AL, 127 - StosB - Mov AX, [DS:60000+31h] - StosW - Mov AL, 128 - StosB - Add DI, 7 - - Mov EAX, [DS:60000+38h] - Cmp Word Ptr [DS:60000+28h], 3208h - JB D_ConvertS3MTimer - - Xor EAX, 'ITRK' - RoR EAX, 7 - Neg EAX - RoL EAX, 4 - Xor EAX, 'JTHL' - -D_ConvertS3MTimer: - StosD - ; OK, panning now... - Mov SI, 60000+40h - Mov CX, 32 - -D_LoadS3M3: - LodsB - - Mov DL, 32+128 - Cmp AL, 128 - JAE D_LoadS3M4 - - Mov AH, AL - -; Test Byte Ptr [DS:60000+33h], 128 -; JZ D_LoadS3M5 - - And AL, 127 - - Mov DL, 0 - Cmp AL, 7 - JBE D_LoadS3M4 - - Mov DL, 64 - Cmp AL, 15 - JBE D_LoadS3M4 - - Mov DL, 32 - -D_LoadS3M4: - Mov AL, DL - And AH, 80h - - StosB - Loop D_LoadS3M3 - - Mov CX, 32 - Mov AL, 32+128 - Rep StosB - - Mov CX, 64 - Mov AL, 64 - Rep StosB - - Mov DI, 100h - Mov CX, 256 - Mov AL, 255 - Rep StosB - - Push DS - - Mov CX, [DS:60000+20h] - Push ES - Pop DS - Mov DX, 100h - Mov AH, 3Fh - Int 21h - - Pop DS ; Order list loaded. - - Mov AH, 3Fh - Mov CX, [DS:60000+22h] - Add CX, [DS:60000+24h] - Add CX, CX - Xor DX, DX - Int 21h - - Cmp Byte Ptr [DS:60000+35h], 252 - JNE D_LoadS3M15 - - Mov AH, 3Fh - Mov CX, 32 - Mov DX, 1024 - Int 21h - - Mov CX, 32 - Mov SI, 1024 - Mov DI, 64 - -D_LoadS3M14: - LodsB - Test AL, 32 - JZ D_LoadS3M16 - - Mov AH, [ES:DI] - And AX, 800Fh - ShL AL, 1 - ShL AL, 1 - Add AL, 2 - Or AL, AH - Mov [ES:DI], AL - -D_LoadS3M16: - Inc DI - - Loop D_LoadS3M14 - -D_LoadS3M15: - Mov CX, 1 ; Load instruments - Mov DI, 55912 - -D_LoadS3M7: - Push CX - Push DI - - Push DI - Push DS - - Mov SI, CX - Dec SI - Add SI, SI - Mov DX, [SI] - - Push CS - Pop DS - Push CX ; For Drawstring. - - Mov AX, 4200h - Xor CX, CX - ShLD CX, DX, 4 - ShL DX, 4 - Int 21h - - Mov SI, Offset SHLoadMsg - Mov DI, (4+16*80)*2 - Mov AH, 5 - Call S_DrawString - Pop AX - - Pop DS - Pop DI - - Mov DX, 1024 ; Load inst. header. - Mov CX, 80 - Mov AH, 3Fh - Int 21h - - Mov EAX, 'SPMI' - StosD - - Mov SI, 1025 - Mov CX, 12 - Rep MovsB - Xor AL, AL - StosB - Mov AL, 64 - StosB - - Xor AL, AL - - Cmp Byte Ptr [DS:1024], 1 - JNE D_LoadS3M8 - - Mov AL, [DS:1024+1Fh] - ShR AL, 1 - And AL, 2 - - Cmp Word Ptr [DS:1024+10h], 0 - JE D_LoadS3M8 - - Inc AX - -D_LoadS3M8: - Mov CL, [DS:1024+1Fh] - Mov CH, CL ; CL = 1 -> loop - And CL, 1 - ShL CL, 4 - Or AL, CL ; Loop... - - And CH, 4 - ShR CH, 1 - Or AL, CH ; 16 bit. - -D_LoadS3M9: - StosB - Mov AL, [DS:1024+1Ch] - StosB - Mov SI, 1024+30h - Mov CX, 25 - Rep MovsB - Xor AX, AX - StosW - Mov AL, 32 - StosB - - Mov EAX, [DS:1024+10h] - StosD ; Length - - Mov EAX, [DS:1024+14h] - StosD ; LoopBeg - - Mov EAX, [DS:1024+18h] - StosD ; LoopEnd - - Mov EAX, [DS:1024+20h] - StosD ; C5Spd - - Xor AX, AX - StosW - StosW ; Susloopbegin - - StosW - StosW ; SusLoopEnd - - Cmp Byte Ptr [DS:1024], 1 - JE D_LoadS3M22 - - Xor AX, AX - StosW - StosW - Jmp D_LoadS3M23 - -D_LoadS3M22: - Mov CL, 4 - Mov AX, [DS:1024+0Eh] - Mov DL, [DS:1024+0Fh] - Mov DH, [DS:1024+0Dh] - ShL AX, CL - ShR DX, CL - StosW ; Sample pointer in file. - Mov AX, DX - StosW - - Xor AX, AX - -D_LoadS3M23: - StosW ; Vibrato info... - StosW - - Pop DI - Pop CX - Add DI, 80 - Inc CX - - Cmp CX, 100 - JAE D_LoadS3M10 - - Cmp CX, [DS:60000+22h] - JBE D_LoadS3M7 - -D_LoadS3M10: - Push DS - - Mov CX, 1 ; CX = sample number (base 1) - ; DS = doesn't matter - ; ES = songdata segment - -D_LoadS3M17: ; OK, now load the samples. - Push CX - Push ES - - Mov SI, CX - Dec SI - Add SI, SI - Mov SI, [ES:64912+SI] - Test Byte Ptr [ES:SI+12h], 1 - JZ D_LoadS3M18 - - Push CS - Pop DS - - Push SI - Mov SI, Offset SampleMsg - Mov DI, (4+17*80)*2 - Mov AH, 5 - Push CX - Call S_DrawString - Pop DI - Pop SI ; ES:SI points to sample header. - ; DI = sample number+1 - Push ES - Pop DS - - Mov AX, 4200h - Xor CX, CX - Xor DX, DX - XChg CX, [DS:SI+4Ah] - XChg DX, [DS:SI+48h] - Int 21h ; Move file pointer. - - Mov AX, DI - Dec AX - - Call D_LoadSampleData - Jmp D_LoadS3MSamplePresent - -D_LoadS3M18: - Mov DWord Ptr [SI+48h], 0 - -D_LoadS3MSamplePresent: - Pop ES - Pop CX - Inc CX - Cmp CX, 100 - JBE D_LoadS3M17 - - Pop DS - - Mov CX, 0 ; CX = pattern number - ; DS = disktransfer - -D_LoadS3M11: - Push CX ; Load patterns.... - - Push DS - - Push CS - Pop DS - - Mov DI, (4+18*80)*2 - Mov SI, Offset PatternMsg - Mov AH, 5 - Push CX - Call S_DrawString - Pop SI ; SI = Pattern Number - - Pop DS - - Add SI, [DS:60000+22h] - Add SI, SI - Mov DX, [SI] ; DX = offset of pattern / 16 - And DX, DX - JZ D_LoadS3M13 - - Push CX - - Xor CX, CX - ShLD CX, DX, 4 - ShL DX, 4 - Mov AX, 4200h - Int 21h - - Mov AH, 3Fh ; Load data. - Mov CX, 2 - Mov DX, 1024 - Int 21h - Mov AH, 3Fh - Mov CX, [DS:1024] - Mov DX, 1024 - Int 21h ; Pattern data at DS:1024 - - Pop DX ; DX = Pattern number - Mov SI, 1024 - Call PE_TranslateS3MPattern - -D_LoadS3M13: - Pop CX - Inc CX - Cmp CX, 100 - JA D_LoadS3M12 - - Cmp CX, [DS:60000+24h] - JB D_LoadS3M11 - -D_LoadS3M12: - Jmp D_PostLoadModule - - Ret - -EndP D_LoadS3M - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_Load669 Far - - Xor AX, AX - Call D_PreLoadModule - - Mov AH, 3Fh - Mov CX, 1F1h - Mov DX, 60000 - Int 21h - - Mov SI, 60000+2 - Mov DI, 4 - Mov CX, 25 - Rep MovsB - - Xor AX, AX - Mov CX, 7 - Rep StosB - Mov SI, 60000+6Eh - LodsB - StosW - LodsB - StosW - - Add DI, 4 - Mov AX, 19h ; Stereo control, sample controlled, - StosW ; Linear, Old EFX - Xor AX, AX - StosW ; Song message attached. - - Mov AX, 3080h ; GV/MV - StosW - - Mov AX, 78*100h+6h ; 78 BPM, speed 6 - StosW - - Mov AX, 64 ; Separation of 64 - StosW - Xor AX, AX - Mov CX, 5 - Rep StosW - - Mov AX, 4000h - StosW - StosW - StosW - StosW - Mov AL, 32+128 - Mov CX, 56 - Rep StosB ; Channel pan - Mov AL, 64 - Mov CL, AL - Rep StosB ; Channel volume - - Mov SI, 60000+71h - Mov DI, 100h ; Orders - Mov CL, 80h - Rep MovsB - Mov CL, 80h - Mov AL, 0FFh - Rep StosB ; Orders done. - - Xor BP, BP ; Sample time - - Mov DI, 512+55400 - Mov AL, 25 - Mul Byte Ptr [DS:60000+6Eh] - Mov CX, AX ; CX = bytes to read - Mov AH, 3Fh - Xor DX, DX - Int 21h - Xor SI, SI - -D_Load669_1: - Cmp BP, [ES:24h] - JAE D_Load669_2 - - Mov EAX, 'SPMI' - StosD - Mov CX, 6 - Rep MovsW - Mov AX, 4000h - StosW - - ; Flag, volume - Mov AH, 60 - Inc SI - Mov ECX, [SI] - Test ECX, ECX - JZ D_Load669_3 - - Xor EAX, EAX - Mov [ES:DI+22h], EAX - Mov [ES:DI+26h], EAX - - Mov AX, 3C01h ; Sample present - - Mov ECX, [SI+8] ; End loop - - Cmp ECX, [SI] - JA D_Load669_3 - - Sub ECX, [SI+4] ; Start loop - JC D_Load669_3 - Cmp ECX, 2 - JB D_Load669_3 - - Mov ECX, [SI+4] - Mov [ES:DI+22h], ECX - Mov ECX, [SI+8] - Mov [ES:DI+26h], ECX - - Mov AX, 3C11h ; Sample present, forwards loop - -D_Load669_3: - StosW - Mov CX, 13 - Sub SI, CX - Rep MovsB - Xor AL, AL - Mov CX, 13 - Rep StosB - Mov AH, 32 - StosW ; Convert, DfP - MovsW - MovsW - Add SI, 8 - Add DI, 8 - - Mov AX, 8363 - StosW - - Xor AX, AX - Mov CX, 9 - Rep StosW - - Inc BP - Jmp D_Load669_1 - -D_Load669_2: ; OK.. patterns.. - Xor BP, BP ; BP = pattern number - -D_Load669_4: - Cmp BP, [ES:26h] - JAE D_Load669_5 - - Mov AH, 3Fh - Mov CX, 600h - Xor DX, DX - Int 21h ; Patterns at DS:0 - - Mov AH, [DS:60000+0F1h+BP] - Mov CL, [DS:60000+171h+BP] - Call PE_Translate669Pattern - - Inc BP - Jmp D_Load669_4 - -D_Load669_5: ; Samples - - Xor BP, BP - Push ES - Pop DS - -D_Load669Samples: - Inc BP - Cmp BP, [DS:24h] - JA D_Load669End - - Mov SI, BP - Add SI, SI - Mov SI, [DS:64910+SI] - Test Byte Ptr [DS:SI+12h], 1 ; Sample present? - JZ D_Load669Samples - - Push DS - Push SI - - Push CS - Pop DS - - Push BP - Mov SI, Offset SampleMsg - Mov DI, (4+16*80)*2 - Mov AH, 5 - Call S_DrawString - - Pop AX - Pop SI - Pop DS - - Dec AX - Call D_LoadSampleData - - Jmp D_Load669Samples - -D_Load669End: - Jmp D_PostLoadModule - -EndP D_Load669 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadMOD Far - - Xor AX, AX - Call D_PreLoadModule - - Mov AH, 3Fh - Mov CX, 2048 - Mov DX, 60000 - Int 21h - - Mov SI, 60000 - Mov DI, 4 - Mov CX, 20 - Rep MovsB ; Song name - Xor AX, AX - Mov CX, 8 - Rep StosW - Add DI, 4 - Mov AX, 31h ; Old effects, stereo, sample control - StosW - Xor AX, AX - StosW - Mov AX, 3080h ; GV/MV - StosW - - Mov AX, 07D06h ; 125 BPM, speed 6 - StosW - - Mov AX, 64 ; Separation of 64 - StosW - - Xor AX, AX - Mov CX, 5 - Rep StosW - - Mov DL, CS:MODNumberOfChannels - Mov CX, 64 - Cmp DL, 8 - JBE D_LoadMOD13 - - Mov CL, DL - Mov AL, 32 - Rep StosB - Mov CL, 64 - Sub CL, DL - Jmp D_LoadMOD14 - -D_LoadMOD13: - Mov AX, 4000h ; Panning. - StosW - Mov AX, 40h - StosW - Sub CX, 4 - - Cmp DL, 4 - JBE D_LoadMOD14 - - Mov AX, 4000h - StosW - Sub CX, 2 - Cmp DL, 6 - JBE D_LoadMOD14 - - Mov AX, 40h - StosW - Sub CX, 2 - -D_LoadMOD14: - Mov AL, 32+128 - Rep StosB ; Clear Panning - - Mov AL, 64 - Mov CX, 64 - Rep StosB ; Channel Volume - - Mov DI, 256 - Mov CX, 256 - Mov AL, 0FFh - Rep StosB ; Orders. - - Mov DI, 256 - Xor CH, CH - Mov CL, CS:MODNumberOfOrders - Mov SI, CS:MODOrderOffset - Mov DX, SI - Rep MovsB ; copy orders... - - ; Get number of patterns to load - Xor CX, CX - Mov SI, DX - Mov AX, 07F00h - -D_LoadMOD1: - LodsB - Cmp CL, AL - JAE D_LoadMOD2 - - Mov CL, AL - -D_LoadMOD2: - Dec AH - JNZ D_LoadMOD1 - - Inc CX ; CX = number of patterns to - ; load - Push CX - - Push BX - ; setup inst. headers - Xor CH, CH - Mov CL, CS:MODNumberOfInstruments - Mov SI, 60000+20 - Mov DI, 512+55400 - -D_LoadMOD3: - Push CX - - Mov EAX, 'SPMI' - StosD - - Mov CX, 6 - Xor AX, AX - Rep StosW - StosB - Mov AL, 64 - StosB - Xor AL, AL - Mov CX, [DS:SI+28] - XChg CH, CL - Cmp CX, 1 - JBE D_LoadMOD4 - - Or AL, 16 - -D_LoadMOD4: - Mov CX, [DS:SI+22] - XChg CH, CL - Cmp CX, 1 - JBE D_LoadMOD5 - - Or AL, 1 - -D_LoadMOD5: - StosB - Mov AL, [DS:SI+25] - StosB - Mov CX, 22 - Rep MovsB - Xor EAX, EAX - StosD - - Mov AX, 1+32*256 ; Convert signed->Unsigned - StosW ; Default pan of 32 - - LodsW - XChg AH, AL ; Sample length... - Add EAX, EAX - StosD - Mov EDX, EAX ; EDX = length - - MovZX EAX, Word Ptr [DS:SI+2] ; Loop begin - XChg AH, AL - - Cmp CS:MODOrderOffset, 60472 - JE D_LoadMOD15 - - Add EAX, EAX - -D_LoadMOD15: - Cmp EAX, EDX - JBE D_LoadMODLengthCheck1 - - Xor EAX, EAX - -D_LoadMODLengthCheck1: - StosD - Mov ECX, EAX - - MovZX EAX, Word Ptr [DS:SI+4] ; Loop end - XChg AH, AL - - Cmp CS:MODOrderOffset, 60472 - JE D_LoadMOD16 - - Add EAX, EAX - -D_LoadMOD16: - Add EAX, ECX - Cmp EAX, EDX - JBE D_LoadMODLengthCheck2 - - Mov EAX, EDX - -D_LoadMODLengthCheck2: - StosD - - LodsB ; C5Speed. - And AX, 15 - Mov BX, AX - Add BX, BX - Mov AX, [CS:FineTuneTable+BX] - StosW - Xor AX, AX - Mov CX, 9 - Rep StosW - - Add SI, 5 - - Pop CX - Loop D_LoadMOD3 - - Pop BX ; Now to load mod patterns. - - Mov AX, 4200h - Xor CX, CX - Mov DX, CS:MODPatternOffset - Int 21h ; set offset in file... - - Pop CX - Xor AX, AX ; Start with pattern 0 - -D_LoadMOD6: - Cmp AX, CX - JAE D_LoadMOD7 - - Push AX - Push CX - - Push DS - - Push CS - Pop DS - - Push AX ; AX = pattern num. - Mov SI, Offset PatternMsg - Mov DI, (4+16*80)*2 - Mov AH, 5 - Call S_DrawString - - Pop DX ; DX = pattern num - Pop DS - - Push DX - - Mov AH, 3Fh - Mov CH, CS:MODNumberOfChannels - Xor CL, CL - Xor DX, DX - Int 21h ; DS:0 contains pat data - - Pop DX - Xor SI, SI - Mov AL, CS:MODNumberOfChannels - Xor AH, AH - - Call PE_TranslateMODPattern - - Pop CX - Pop AX - Inc AX - Jmp D_LoadMOD6 - - -D_LoadMOD7: ; Finished loading patterns - Mov CX, 1 ; Time to load samples. - -D_LoadMOD8: - Push CX - Push ES - - Mov SI, CX - Dec SI - Add SI, SI - Mov SI, [ES:64912+SI] - - Test Byte Ptr [ES:SI+12h], 1 - JZ D_LoadMOD9 - - Push SI - - Push CS - Pop DS - - Push CX - Mov SI, Offset SampleMsg - Mov DI, (4+17*80)*2 - Mov AH, 5 - Call S_DrawString - -; Mov AX, 4201h -; Xor CX, CX -; Mov DX, 4 -; Int 21h ; Progress pointer - - Pop AX - - Pop SI - - Push ES - Pop DS - - Dec AX ; AX = sample to load. - Call D_LoadSampleData - -D_LoadMOD9: - Pop ES - Pop CX - Inc CX - Cmp CL, CS:MODNumberOfInstruments - JBE D_LoadMOD8 - -D_LoadMOD12: - Jmp D_PostLoadModule - - Ret - -EndP D_LoadMOD - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ENDIF - -Proc ConvertOldInstrument ; DS:SI points to inst. - - PushAD - Push DS - Push ES - - Push DS - Pop ES - - Mov DI, SI - - Mov AL, [SI+11h] ; Old format Flg - Mov [SI+130h], AL - - Mov EAX, [SI+12h] ; VLS, VLE, SLS, SLE - Mov [SI+132h], EAX - - Mov AX, [SI+18h] ; Fadeout - Add AX, AX - Mov [SI+14h], AX - - Mov AL, [SI+1Ah] - Mov [SI+11h], AL - - Xor AX, AX - Mov AL, [SI+1Bh] - Mov [SI+12h], AX ; DCT - - Mov AX, 60*256 ; PPS, PPC - Mov [SI+16h], AX - - Mov AX, 128+(32+128)*256 ; GbV+DfP - Mov [SI+18h], AX - - Xor AX, AX - Mov [SI+1Ah], AX - ; Now for envelope - Push SI - Xor CX, CX - - Add SI, 1F8h - Add DI, 136h - -D_LoadITInstrument2: - LodsW - Cmp AX, 0FFFFh - JE D_LoadITInstrument3 - - Mov [DI], AH ; Magintude - Xor AH, AH - Mov [DI+1], AX ; Tick - - Add DI, 3 - Inc CX - Cmp CL, 25 - JAE D_LoadITInstrument3 - - Jmp D_LoadITInstrument2 - -D_LoadITInstrument3: - Pop SI - Mov [SI+131h], CL - - Mov CX, SI - Add CX, 554 - Sub CX, DI - Xor AL, AL - Rep StosB - - Mov Byte Ptr [SI+183h], 2 ; Num nodes for panning + pitch - Mov Byte Ptr [SI+1D5h], 2 - - Mov Byte Ptr [SI+18Ch], 99 ; Magn 0 at Tick 99 - Mov Byte Ptr [SI+1DEh], 99 ; Magn 0 at Tick 99 - - Pop ES - Pop DS - PopAD - - Ret - -EndP ConvertOldInstrument - -IF TUTORIAL -ELSE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadIT Far - - Xor AX, AX - Call D_PreLoadModule - - Push DS - - Push CS - Pop DS - Mov SI, Offset HeaderMsg - Mov DI, (4+16*80)*2 - Mov AH, 5 - Call S_DrawString - - Pop DS - - Mov AH, 3Fh - Mov CX, 2048 - Xor DX, DX - Int 21h - - Cmp Word Ptr [DS:28h], 208h - JB D_ConvertITTimer - - Mov EAX, [DS:3Ch] - Xor EAX, 'ITRK' - RoR EAX, 7 - Neg EAX - RoL EAX, 4 - Xor EAX, 'JTHL' - Mov [DS:3Ch], EAX - -D_ConvertITTimer: - Test Byte Ptr [DS:2Eh], 2 ; Time data? - JZ D_LoadTimeDataNone - - ; Seek to 0C0+Orders+ - ; (ins+samp+pat)*4 - Mov DX, [DS:22h] - Add DX, [DS:24h] - Add DX, [DS:26h] - ShL DX, 2 - Add DX, [DS:20h] - Add DX, 0C0h - Xor CX, CX - Mov AX, 4200h - Int 21h - - Push DS - - Push CS - Pop DS - - Mov AH, 3Fh - Mov CX, 2 - Mov DX, Offset NumTimerData - Int 21h - - Push BX ; Allocate data for timedata - Mov BX, NumTimerData - Cmp BX, 0FFFFh - JNE D_NoTimerDataOverFlow - - Dec BX - Mov NumTimerData, BX - -D_NoTimerDataOverFlow: - Mov CX, BX - ShR BX, 1 - Inc BX - Mov AH, 48h - Int 21h - Pop BX - JC D_LoadTimeDataEnd - - Mov TimerData, AX - Mov DS, AX - ShL CX, 3 - Xor DX, DX - Mov AH, 3Fh - Int 21h - -D_LoadTimeDataEnd: - Pop DS - -D_LoadTimeDataNone: - Test Byte Ptr [DS:2Eh], 8 - JZ D_LoadMIDIConfigDataNone - - PushA - Push DS - - Call Music_GetMIDIDataArea - Xor DX, DX - Mov CX, 4896 - Mov AH, 3Fh - Int 21h - - Pop DS - PopA - -D_LoadMIDIConfigDataNone: - Test Byte Ptr [DS:2Eh], 1 - JZ D_LoadITMsg1 - ; Load the message - ; Move to offset first. - Mov AX, 4200h - Mov CX, [DS:3Ah] - Mov DX, [DS:38h] - Int 21h ; Seek to position - - Push DS - - Mov CX, [DS:36h] - Call Msg_GetMessageOffset - Mov AH, 3Fh - Int 21h - - Pop DS - -D_LoadITMsg1: - ; Actually, load row hilights first... - Test Byte Ptr [DS:2Eh], 4 - JZ D_LoadITNoHilight - - Mov AX, [DS:1Eh] - Push DS - - Push Pattern - Pop DS - Assume DS:Pattern - Mov Word Ptr [RowHilight1], AX - - Pop DS - Assume DS:Nothing - -D_LoadITNoHilight: - Xor SI, SI - Xor DI, DI - Mov CX, 192 - Rep MovsB ; Header - - Mov DI, 256 - Mov CX, [DS:20h] - - Mov DX, DI - Dec CX - Sub DX, CX - Rep MovsB ; Orders - Mov AL, 0FFh - Mov CX, DX - Rep StosB - - Inc SI ; SI points to first - ; pointer - - Xor BP, BP ; Instrument time. - -D_LoadIT1: - Cmp BP, [DS:22h] - JAE D_LoadIT2 - - Push DS - Push SI - - Push CS - Pop DS - Mov SI, Offset InstrumentMsg - Mov AX, BP - Inc AX - Push AX - Mov AH, 5 - Mov DI, (4+17*80)*2 - Call S_DrawString - Pop AX - - Pop SI - Pop DS - ; Move to offset.. - LodsW - Mov DX, AX - LodsW - Mov CX, AX - Mov AX, 4200h - Int 21h - - Mov DI, [DS:2Ah] ; Format version - - Push DS - Push SI - - Push ES - Pop DS - Mov SI, BP - Add SI, SI - Mov DX, [DS:64712+SI] - Mov CX, 554 - Mov AH, 3Fh - Int 21h - - Cmp DI, 200h - JAE D_LoadITInstrument1 - - Mov SI, DX - Call ConvertOldInstrument - -D_LoadITInstrument1: - Pop SI - Pop DS - Inc BP - Jmp D_LoadIT1 - -D_LoadIT2: - Xor BP, BP ; Sample header time. - -D_LoadIT3: - Cmp BP, [DS:24h] - JAE D_LoadIT4 - - Push DS - Push SI - - Push CS - Pop DS - Mov SI, Offset SHLoadMsg - Mov AX, BP - Inc AX - Push AX - Mov AH, 5 - Mov DI, (4+18*80)*2 - Call S_DrawString - Pop AX - - Pop SI - Pop DS - ; Move to offset.. - LodsW - Mov DX, AX - LodsW - Mov CX, AX - Mov AX, 4200h - Int 21h - - Push DS - Push SI - - Push ES - Pop DS - - Mov SI, BP - Add SI, SI - Mov DX, [DS:64912+SI] - Mov CX, 80 - Mov AH, 3Fh - Int 21h - - Pop SI - Pop DS - Inc BP - Jmp D_LoadIT3 - -D_LoadIT4: - Xor BP, BP - - Push DS - Push SI - - - Push ES - Pop DS ; DS now points to song data. - -D_LoadIT7: - Mov SI, BP - Add SI, SI - Mov SI, [64912+SI] - - Test Byte Ptr [DS:SI+12h], 1 - JZ D_LoadIT8 - - Push DS - Push SI - - Push CS - Pop DS - Mov SI, Offset SampleMsg - Mov AX, BP - Inc AX - Push AX - Mov AH, 5 - Mov DI, (4+19*80)*2 - Call S_DrawString - Pop AX - - Pop SI - Pop DS - - Mov AX, 4200h - Xor CX, CX - Xor DX, DX - XChg DX, [DS:SI+48h] - XChg CX, [DS:SI+4Ah] - Int 21h ; Move file pointer. - - Mov AX, BP - Call D_LoadSampleData - Jmp D_LoadITSamplePresent - -D_LoadIT8: - Mov DWord Ptr [SI+48h], 0 - -D_LoadITSamplePresent: - Inc BP - Cmp BP, 99 - JB D_LoadIT7 - - Pop SI - Pop DS - - Xor BP, BP - -D_LoadIT5: - Cmp BP, [DS:26h] ; Pattern time. - JAE D_LoadIT6 - - Push ES - - Push DS - Push SI - - Push CS - Pop DS - Mov SI, Offset PatternMsg - Push BP - Mov AH, 5 - Mov DI, (4+20*80)*2 - Call S_DrawString - Pop AX - - Pop SI - Pop DS - ; Move to offset.. - LodsW - Mov DX, AX - LodsW - Mov CX, AX - And DX, DX - JNZ D_LoadIT12 - And CX, CX - JZ D_LoadIT13 - -D_LoadIT12: - Mov AX, 4200h - Int 21h - - Push DS - Push SI - - Mov AH, 3Fh - Mov DX, 60000 - Mov CX, 8 - Int 21h ; DS:DX = pattern header. - - Mov DX, [DS:60000] ; DX = length - Push DX - Add DX, 8 - Mov SI, BP - - Push BX - Call Music_AllocatePattern - ; ES:DI = location. - Pop BX - - Mov AX, ES - And AX, AX - JZ D_LoadIT10 - - Mov SI, 60000 - Mov CX, 8 - Rep MovsB - - Push ES - Pop DS - Mov DX, DI - Mov AH, 3Fh - Pop CX ; CX = length. - Int 21h - - Jmp D_LoadIT11 - -D_LoadIT10: - Pop CX - Push BX - - - Call PEFunction_OutOfMemoryMessage - - Pop BX - -D_LoadIT11: - Pop SI - Pop DS - -D_LoadIT13: - Pop ES - - Inc BP - Jmp D_LoadIT5 - -D_LoadIT6: - Jmp D_PostLoadModule - - Ret - -EndP D_LoadIT - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFileImpulseModule Far - - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_LoadITList - - Mov AX, 5 - Ret - -EndP D_LoadFileImpulseModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFileS3MModule Far - - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_LoadS3MList - - Mov AX, 5 - Ret - -EndP D_LoadFileS3MModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFile669Module Far - - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_Load669List - - Mov AX, 5 - Ret - -EndP D_LoadFile669Module - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFileXMModule Far - - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_LoadXMList - - Mov AX, 5 - Ret - -EndP D_LoadFileXMModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFileMTMModule Far - - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_LoadMTMList - - Mov AX, 5 - Ret - -EndP D_LoadFileMTMModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFileMODModule Far - - Mov AL, 31 - Mov CL, [DS:60000+950] - Mov DX, 60952 - Mov SI, 1084 - - Cmp Word Ptr [BX+23], 16 - JNE D_LoadFileMODModule1 - - Mov AL, 15 - Mov CL, [DS:60000+470] - Mov DX, 60472 - Mov SI, 600 - -D_LoadFileMODModule1: - Mov CS:MODNumberOfInstruments, AL - Mov CS:MODNumberOfOrders, CL - Mov CS:MODOrderOffset, DX - Mov CS:MODPatternOffset, SI - - Mov SI, [BX+23] - Cmp SI, 17 - JNE D_LoadFileMODModule2 - - Mov AL, [BX+22] - Jmp D_LoadFileMODModule3 - -D_LoadFileMODModule2: - Sub SI, 9 - Mov AL, [CS:MODChannelTable+SI] - -D_LoadFileMODModule3: - Mov CS:MODNumberOfChannels, AL - - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_LoadMODList - - Mov AX, 5 - Ret - -EndP D_LoadFileMODModule - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Read module functions +; + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF TUTORIAL +ELSE + +Proc D_PreLoadModule ; Returns ES = song segment + ; BX = file handle + ; DS = Diskdata area + ; AX = SaveFormat + +; Call MouseUpdateEnable + +IF DEFAULTFORMAT + Test AL, AL + JNZ D_PreLoadModuleTemp + + Mov AL, DEFAULTFORMAT + +D_PreLoadModuleTemp: +ENDIF + Mov SaveFormat, AL + + Call I_ClearTables + Call Music_ReleaseAllPatterns + Call Music_ReleaseAllSamples + Call Music_ClearAllSampleNames + Call Music_ClearAllInstruments + Call Msg_ResetMessage + Call ReleaseTimerData + + Mov DS, CS:DiskDataArea + + Mov BX, CS:CurrentFile + Add BX, BX + Mov BX, [BX] + Add BX, 8 + + Push CS + Pop ES + Mov DI, Offset FileName ; OK... + Mov SI, BX ; Data area no longer + Mov CX, 13 ; reqd + Rep MovsB + + Mov AX, 3D00h + Mov DX, BX + Int 21h + JC D_LoadFileOpenErrorMsg + + Mov BX, AX ; BX = file handle. + + Call Music_GetSongSegment + Mov ES, AX + + Ret + +EndP D_PreLoadModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostLoadModule Far + + Mov AH, 3Eh ; Close file. + Int 21h + + Push CS + Pop DS + Assume DS:Disk + + Call CheckTimerData + Call GetCurrentTime + + Mov [TopTimerData], 0 + + Call GetTimerCounter + Mov [EditTimer], EAX + + Call PE_ResetOrderPattern + +; Mov AX, 1 + Ret + +EndP D_PostLoadModule + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_InsertOrder ; DX = inserting pattern, BP = current + ; ES = songdata + PushA + Push DS + + Push ES + Pop DS + + Mov SI, 1FFh + Mov AX, BP + +D_InsertOrder1: + Cmp AL, [SI] + JE D_InsertOrder2 + +D_InsertOrderResume: + Dec SI + Cmp SI, 100h + JAE D_InsertOrder1 + + Pop DS + PopA + Ret + +D_InsertOrder2: + Push SI + Mov CX, 1FEh + Mov DI, 1FFh + Sub CX, SI + JC D_InsertOrder3 + + Mov SI, 1FEh + + StD + Rep MovsB + ClD + + Mov AL, DL + StosB + +D_InsertOrder3: + Pop SI + Jmp D_InsertOrderResume + +EndP D_InsertOrder + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadXM Far + + Xor AX, AX + Call D_PreLoadModule + Assume DS:Nothing + + Mov AH, 3Fh + Mov CX, 64 ; Header length + Mov DX, 64000 + Int 21h + + Mov AH, 3Fh ; Read rest of header. + Mov CX, [DS:64000+60] + Sub CX, 4 + Mov DX, 64104 + Int 21h + + Mov DI, 4 + Mov CX, 20 + Mov SI, 64000+17 + Rep MovsB + Xor AX, AX + Mov CX, 5 + Rep StosW ; OK name transferred. + + ; Number of Instruments + Mov AX, [DS:64100+12] + StosW ; Insnum + + Mov AX, 1 + StosW + + ; Number of Patterns + Mov AX, [DS:64100+10] + StosW + Mov [ES:0C0h], AX ; Number of patterns. + + ; CWT/V, CMWT + Add DI, 4 + + ; Flags + Mov AX, [DS:64100+14] + And AX, 1 + ShL AX, 3 + Or AX, 35h ; XM Effects, Old effects, stereo, insts + StosW + + ; Reserved + Xor AX, AX + StosW + + ; GVolume. MVolume + Mov AX, 128+48*256 + StosW + + ; Initial Speed, Initial Tempo + Mov AL, [DS:64100+16] + Test AL, AL + JNZ InitialSpeedNot0 + + Mov AL, 6 + +InitialSpeedNot0: + Mov AH, [DS:64100+18] + StosW + + ; Separation + Mov AX, 128 + StosW + + ; Message length, offset, timer + Xor AX, AX + Mov CX, 5 + Rep StosW + + ; Channel Pan + + Mov CX, [DS:64100+8] ; Number of channels + Mov AL, 32 + Rep StosB + Mov AL, 128+32 + Mov CX, 64 + Sub CX, [DS:64100+8] + Rep StosB + + ; Channel Volume + + Mov AL, 64 + Mov CX, 64 + Rep StosB + + ; Orders + Add DI, 40h + Mov SI, 64100+20 ; Orders + Mov CX, [DS:64100+4] ; Song legnth + JCXZ D_LoadXMNoPatterns2 + +D_FindMaximumPattern: + LodsB + Cmp AL, 200 + JAE D_FindMaximumPattern3 + + Cmp AL, [ES:0C0h] + JB D_FindMaximumPattern2 + + Inc AX + Mov [ES:0C0h], AX + Dec AX + Jmp D_FindMaximumPattern2 + +D_FindMaximumPattern3: + Mov AL, 0FFh + +D_FindMaximumPattern2: + StosB + Loop D_FindMaximumPattern + +D_LoadXMNoPatterns2: + Mov CX, 256 + Sub CX, [DS:64100+4] + Mov AL, 0FFh + Rep StosB + + ; OK.. now to load patterns. + Cmp Word Ptr [DS:64100+10], 0 + JE D_LoadXMNoPatterns + + Xor BP, BP + +D_LoadXM1: + Push DS SI DI + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset PatternMsg + Mov AH, 5 + Mov DI, (4+16*80)*2 + Push BP + Call S_DrawString + Pop AX + + Pop DI SI DS + Assume DS:Nothing + + Mov AH, 3Fh + Mov CX, 4 + Xor DX, DX + Int 21h ; Read pattern length + + Mov AH, 3Fh + Mov CX, [DS:0] + Mov DX, 4 + Sub CX, DX + Int 21h ; Read pattern header + + Cmp Word Ptr [DS:7], 0 + JE D_LoadXM3 + + Mov AH, 3Fh + Mov CX, [DS:7] + Mov DX, 100h + Mov SI, DX + Int 21h ; DS:100h contains all the + ; pattern data. + + Cmp BP, 200 ; Too many patterns? + JAE D_LoadXM3 + + Mov AX, [DS:5] ; AX = number of rows + Mov CX, [DS:64100+8] ; CX = number of channels + Mov DX, BP + + Cmp AX, 200 + JA D_LoadXM2 + + ; TranslateXMPattern takes: + ; DS:SI points to pattern data + ; AX = rows + ; CX = channels + ; DX = pattern number + + + Call PE_TranslateXMPattern + Jmp D_LoadXM3 + +D_LoadXM2: + ShR AX, 1 + Call PE_TranslateXMPattern + + Mov DX, [ES:0C0h] ; DX = pattern number + Cmp DX, 200 + JAE D_LoadXM3 + + Inc Word Ptr [ES:0C0h] + + Call D_InsertOrder + + Mov AX, [DS:5] + Inc AX + ShR AX, 1 ; AX = number of rows. + Call PE_TranslateXMPattern + +D_LoadXM3: + Inc BP + Cmp BP, [DS:64100+10] + JB D_LoadXM1 + +D_LoadXMNoPatterns: + ; Now to load instruments + Xor BP, BP + Cmp BP, [DS:64100+12] + JE D_LoadXMInstrumentTooMany + +D_LoadXM4: + Push DS SI + + Push CS + Pop DS + Mov SI, Offset InstrumentMsg + Mov AX, BP + Inc AX + Push AX + Mov AH, 5 + Mov DI, (4+17*80)*2 + Call S_DrawString + Pop AX + + Pop SI DS + + Mov AH, 3Fh + Mov CX, 4 + Xor DX, DX + Int 21h + + Mov AH, 3Fh + Mov CX, [DS:0] + Mov DX, 4 + Sub CX, DX + Int 21h + + ; OK.. instrument loaded into DS:0.. + Mov DI, BP + Add DI, DI + Mov DI, [ES:64712+DI] ; ES:DI points to instrument + Push DI + + Mov SI, 4 + Add DI, 20h + Mov CX, 22 + Rep MovsB + Xor AX, AX + Mov CX, 4 + Rep StosW + + Pop DI + Cmp Word Ptr [DS:27], 0 + JE D_LoadXMInstrumentEnd + + Add DI, 14h ; DI points to fadeout + Mov AX, [DS:239] + Add AX, 15 + ShR AX, 5 + Cmp AX, 256 + JBE D_LoadXMInstrument1 + + Mov AX, 256 + +D_LoadXMInstrument1: + StosW + Add DI, 40h-16h ; Translation table + + Mov CX, 12 ; Kill first 12 entries. + Xor AX, AX + +D_LoadXMInstrument2: ; First 12 entries cleared + StosW + Inc AX + Loop D_LoadXMInstrument2 + + Mov CX, 96 + Mov SI, 33 ; Note translation + +D_LoadXMInstrument3: + Mov AH, [SI] + Add AH, [ES:24h] + Cmp AH, 99 + JBE D_LoadXMInstrument4 + + Mov AH, 99 + +D_LoadXMInstrument4: + StosW + Inc SI + Inc AX + Loop D_LoadXMInstrument3 + + Mov CX, 12 ; Kill first 12 entries. + Xor AH, AH + +D_LoadXMInstrument5: ; First 12 entries cleared + StosW + Inc AX + Loop D_LoadXMInstrument5 + + ; Now for volume envelope + Mov AL, [DS:233] ; Flags + Test AL, 1 + JNZ D_LoadXMVolumeEnvelope + + Mov AX, 205h + StosW + Xor AX, AX + StosW + StosW + + Mov AL, 64 + StosB + Xor AX, AX + StosW + + StosB + Mov AX, 1 + StosW + + Mov CX, 70 + Xor AX, AX + Rep StosB + + Jmp D_LoadXMInstrumentVolumeFinished + +D_LoadXMVolumeEnvelope: +; Mov CL, AL +; Mov AH, AL +; And AX, 402h +; ShR AH, 1 +; ShL AL, 1 +; Or AL, AH +; And CL, 1 +; Or AL, CL + + And AL, 2 + ShL AL, 1 + Or AL, 2+1 ; Volume envelope on, Loop on (always) + + Mov AH, [DS:225] ; No of vol env nodes + Cmp AH, 12 + JB D_NumXMVolNodes1 + + Mov AH, 12 + +D_NumXMVolNodes1: + StosW + Mov AX, [DS:228] ; Vol loop start+end + Test Byte Ptr [DS:233], 4 ; Volume loop? + JNZ VolumeLoopOK + + Mov AL, [DS:225] + Dec AX + Mov AH, AL + +VolumeLoopOK: + StosW + Mov AL, [DS:227] ; Vol Sustain point + Mov AH, AL + StosW + + Cmp Byte Ptr [DS:233], 7 + JNE D_XMVolumeNoSustain + + Cmp AL, [DS:229] ; Compare sustain to endpoint + JB D_XMVolumeLoopOK + + And Byte Ptr [ES:DI-6], Not 4 + Jmp D_XMVolumeLoopOK + +D_XMVolumeNoSustain: + Test Byte Ptr [DS:233], 2 ; Loop? + JNZ D_XMVolumeLoopOK + + Mov AL, [DS:225] ; Number of nodes + Dec AX + Mov AH, AL + Mov [ES:DI-2], AX + Or Byte Ptr [ES:DI-6], 4 + +D_XMVolumeLoopOK: + ; OK. now process volume env points + Mov CX, 12 + Mov SI, 129 + +D_LoadXMInstrument6: + Mov AL, [SI+2] + Cmp AL, 64 + JB D_LoadXMInstrument7 + + Mov AL, 64 + +D_LoadXMInstrument7: + StosB + MovsW + LodsW + Loop D_LoadXMInstrument6 + + Mov CX, 13*3+1 + Xor AX, AX + Rep StosB + + ; Now for panning envelope +D_LoadXMInstrumentVolumeFinished: + + Mov AL, [DS:234] ; Flags + Mov CL, AL + Mov AH, AL + And AX, 402h + ShR AH, 1 + ShL AL, 1 + Or AL, AH + And CL, 1 + Or AL, CL + + Mov AH, [DS:226] ; No of pan env nodes + Cmp AH, 12 + JB D_NumXMPanNodes1 + + Mov AH, 12 + +D_NumXMPanNodes1: + StosW + Mov AX, [DS:231] ; Pan loop start+end + StosW + Mov AL, [DS:230] ; Pan Sustain point + Mov AH, AL + StosW + + Test Byte Ptr [DS:234], 2 ; Panning envelope flags + JZ D_XMPanningLoopOK + + Cmp AL, [DS:232] ; Compare sustain to endpoint + JB D_XMPanningLoopOK + + And Byte Ptr [ES:DI-6], Not 4 + +D_XMPanningLoopOK: + ; OK. now process panning env points + Mov CX, 12 + Mov SI, 177 + Xor AH, AH + +D_LoadXMInstrument8: + Mov AL, [SI+2] + Cmp AL, 64 + JB D_LoadXMInstrument9 + + Mov AL, 64 + +D_LoadXMInstrument9: + Sub AL, 32 + StosB + MovsW + LodsW ; Add SI, 2 + Loop D_LoadXMInstrument8 + + Mov AX, [DS:27] + Mul Word Ptr [DS:29] + Mov CX, AX + Mov AH, 3Fh + Mov DX, 1000h + Mov SI, DX + Int 21h + + Mov CX, [DS:27] ; Update number of samples. + Mov AX, [ES:24h] + Add [ES:24h], CX + +D_LoadXMSamples1: + Cmp AX, 99 + JA D_LoadXMInstrumentTooMany + Cmp AX, [ES:24h] + JAE D_LoadXMInstrumentEnd + + Push AX + Push SI + + Mov DI, AX + Add DI, DI + Mov DI, [ES:64912+DI-2] + Add DI, 12h ; Skip filename, ID, GVL + + Mov AH, [SI+12] ; Default volume + Mov AL, 0 + Cmp DWord Ptr [SI], 0 ; Length = 0? + JE D_LoadXMSamples3 + + ; Grab the panning value + +Comment ~ + Mov AL, [SI+15] + ShR AL, 1 + Inc AX + ShR AL, 1 + + Push DI + Mov DI, BP + Add DI, DI + Mov DI, [ES:64712+DI] + Cmp Byte Ptr [ES:DI+19h], 32+128 + JE XMNoPan2 + + Mov AL, 32 + +XMNoPan2: + Mov [ES:DI+19h], AL + +XMNoPan: + Pop DI +~ + ; Sample present flag + Mov AL, 1 + + Mov CL, [SI+14] + Test CL, 10h ; 16 bit sample? + JZ D_LoadXMSamples2 + + Or AL, 2 + +D_LoadXMSamples2: + And CL, 3 + JZ D_LoadXMSamples3 ; No loop + ; CL = 1 or 2 + Cmp DWord Ptr [SI+8], 1 + JBE D_LoadXMSamples3 + + Or AL, 10h ; Loop + Dec CX + ShL CL, 6 + Or AL, CL + +D_LoadXMSamples3: + StosW + + Push SI + ; Copy sample name + Add SI, 18 + Mov CX, 22/2 + Rep MovsW + Xor AX, AX + StosW + StosW + + Pop SI + ; Conversion flags. + Mov AH, [SI+15] + ShR AH, 2 + AdC AH, 80h + Mov AL, 5 + StosW + + Mov EAX, [SI] + Call LoadXISample5 + Mov EAX, [SI+4] + Call LoadXISample5 + Mov EAX, [SI+4] + Add EAX, [SI+8] + Call LoadXISample5 + + ; C5speed.. + Push ES + Push DI + + Call Music_GetPitchTable ; Returns ES:DI + Mov AL, [SI+16] ; Relative note number + Add AL, 60 ; AL = note multiplier + And AX, 0FFh + ShL AX, 2 + Add DI, AX + Mov ECX, [ES:DI] + + Mov AL, [SI+13] ; Finetune, -128->+127 + SAR AL, 4 ; Finetune = -8->+7 + And AX, 0Fh + Add AX, AX + Mov DI, AX + MovZX EAX, [CS:FineTuneTable+DI] + + Pop DI + Pop ES + + Push EDX + + Mul ECX + ShRD EAX, EDX, 16 + Pop EDX + StosD ; C5freq + + Xor AX, AX + StosW + StosW + StosW + StosW + + ; Now for file position + Mov AX, 4201h + Xor CX, CX + Xor DX, DX + Int 21h ; Returns DX:AX + + StosW + Mov AX, DX + StosW + + ; Vibrato information + Mov AX, [DS:237] + XChg AH, AL + StosW + + Mov DX, [DS:236] + And DX, 0FFh + Mov AX, 100h + Sub AX, DX +; Cmp AL, 64 +; JBE VibratoLimit +; +; Mov AL, 64 +; +; VibratoLimit: + Mov AH, [DS:235] + StosW + + ; Move file pointer forwards + Mov AX, 4201h + Mov CX, [SI+2] + Mov DX, [SI] + Int 21h + + Pop SI + Pop AX + Add SI, [DS:29] ; Next sample header + Inc AX + Jmp D_LoadXMSamples1 + +D_LoadXMInstrumentEnd: + Inc BP + Cmp BP, 99 + JA D_LoadXMInstrumentTooMany + Cmp BP, [DS:64100+12] + JB D_LoadXM4 + +D_LoadXMInstrumentTooMany: + Mov CX, 1 ; CX = sample number (base 1) + ; DS = doesn't matter + ; ES = songdata segment + +D_LoadXMFinalSamples1: ; OK, now load the samples. + Push CX + Push ES + + Mov SI, CX + Dec SI + Add SI, SI + Mov SI, [ES:64912+SI] + Test Byte Ptr [ES:SI+12h], 1 + JZ D_LoadXMFinalSamples2 + + Push CS + Pop DS + + Push SI + Mov SI, Offset SampleMsg + Mov DI, (4+18*80)*2 + Mov AH, 5 + Push CX + Call S_DrawString + Pop DI + Pop SI ; ES:SI points to sample header. + ; DI = sample number+1 + Push ES + Pop DS + + Mov AX, 4200h + Xor CX, CX + Xor DX, DX + XChg CX, [DS:SI+4Ah] + XChg DX, [DS:SI+48h] + Int 21h ; Move file pointer. + + Mov AX, DI + Dec AX + + Call D_LoadSampleData + Jmp D_LoadXMFinalSamplesPresent + +D_LoadXMFinalSamples2: + Mov DWord Ptr [SI+48h], 0 + +D_LoadXMFinalSamplesPresent: + Pop ES + Pop CX + Inc CX + Cmp CX, 100 + JBE D_LoadXMFinalSamples1 + + Jmp D_PostLoadModule + +EndP D_LoadXM + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadMTM Far + + Xor AX, AX + Call D_PreLoadModule + + Assume DS:Nothing + + Mov AH, 3Fh + Mov CX, 66 ; Song header length. + Mov DX, 60000 + Int 21h + + Mov DI, 4 + Mov CX, 20 + Mov SI, 60004 + Rep MovsB + Xor AX, AX + Mov CX, 8 + Rep StosB ; Song name. + Mov AL, [DS:60027] + StosW ; Order num + Xor AL, AL + StosW ; Inst num + Mov AL, [DS:60030] + StosW ; Sample number. + Mov AL, [DS:60026] + StosW ; Pattern number + + Add DI, 4 +; Mov AX, 101h ; Cwt/v 1.0 +; StosW +; Mov AX, 100h ; Cmwt 1.0 +; StosW + + Mov AX, 31h ; Stereo. No Vol0Opt + StosW ; Use samples, old eff + Xor AX, AX + StosW + Mov AX, 3080h ; GlobalVol+MixVol + StosW + Mov AX, 7D06h + StosW + Mov AL, 128 + StosB + Xor AL, AL + Mov CX, 11 + Rep StosB + + Mov CX, 32 + Mov DX, 0 + Xor AH, AH + ; Panning positions +D_LoadMTM1: + Mov SI, 60034 + Add SI, DX + Mov AL, [DS:SI] + Mov SI, AX + Mov AL, [CS:PanningPositions+SI] + StosB + + Inc DX + Loop D_LoadMTM1 + + Mov CX, 32 + Mov AL, 160 + Rep StosB + Mov AL, 64 + Mov CX, 64 + Rep StosB + + Push DS + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset SampleHeaderMsg + Mov AH, 5 + Mov DI, (4+16*80)*2 + Call S_DrawString + + Pop DS + Assume DS:Nothing + + Mov AL, 37 + Mul Byte Ptr [ES:24h] ; AX = length of + ; sample headers + Mov CX, AX ; length.. + Mov AH, 3Fh ; read file.. + Xor DX, DX + Int 21h + + + Mov DH, [ES:24h] + Mov DI, 55912 ; Start of samples. + Xor SI, SI ; DS:SI points to MTM header. + +D_LoadMTM2: + Mov EAX, 'SPMI' + StosD + Xor AX, AX + Mov CX, 6 + Rep StosW ; Clear file name. + StosB + Mov AL, 40h + StosB + + + Mov AL, [DS:SI+36] + And AL, 1 + Add AL, AL + + Cmp DWord Ptr [DS:SI+22], 0 + JE D_LoadMTM3 ; Sample length = 0. + + Or AL, 1 ; Else there's a sample. + +D_LoadMTM3: + Mov ECX, [SI+30] ; Sample loop end + Sub ECX, [SI+26] ; Sample loop start + Cmp ECX, 2 + JBE D_LoadMTM4 + + Or AL, 16 + +D_LoadMTM4: + StosB + Mov DL, AL + Mov AL, [DS:SI+35] + StosB + + Push SI + + Mov CX, 22 + +D_LoadMTMSampleName: + LodsB + StosB + And AL, AL + LoopNZ D_LoadMTMSampleName + Pop SI + + Xor AL, AL + Add CX, 5 + Rep StosB ; Filler. + Mov AL, 32 + StosB + + Mov EAX, [DS:SI+22] + StosD + + Test DL, 1 + JNZ D_LoadMTM5 + + Xor AX, AX + Mov CX, 4 + Rep StosW ; Clear rest of sample field. + Mov AX, 8363 ; (no sample) + StosW + Xor AX, AX + Mov CX, 9 + Rep StosW + + Jmp D_LoadMTM8 + +D_LoadMTM5: + Test DL, 16 + JZ D_LoadMTM6 + + Mov EAX, [DS:SI+26] + StosD + Mov EAX, [DS:SI+30] + StosD + Jmp D_LoadMTM7 + +D_LoadMTM6: + Xor AX, AX + Mov CX, 4 + Rep StosW + +D_LoadMTM7: ; C5 speed here... + Push SI + Mov AL, [DS:SI+34] + And AX, 0Fh + Mov SI, AX + Add SI, SI + Mov AX, [CS:FineTuneTable+SI] + Pop SI + StosW + Xor AX, AX + Mov CX, 9 + Rep StosW + +D_LoadMTM8: + Add SI, 37 + Dec DH + JNZ D_LoadMTM2 ; Finished with samples. + + Mov AH, 3Fh + Mov CX, 128 + Xor DX, DX + Int 21h ; Order data. + + Mov CL, [DS:60027] + Inc CX + Xor CH, CH + Mov DX, 256 + Sub DX, CX + Xor SI, SI + Mov DI, 256 + Rep MovsB + Mov CX, DX + Mov AL, 0FFh + Rep StosB ; Order list done. + ; Now it's time to do the + ; friggen pattern stuff. + Mov AL, 37 + Mul Byte Ptr [DS:60030] + Add AX, 66+128 + Push AX + + Mov AX, 192 + Mul Word Ptr [DS:60024] + ; DX:AX = length of track data. + Mov BP, DX + Mov CX, AX + Xor DX, DX + Pop AX + Add CX, AX + AdC BP, 0 + ; BP:CX = offset to sequencer +D_LoadMTM9: ; DX = pattern no. + ; AX = offset to track data. + Push AX + Push CX + Push DX + + Push AX + + Push DS + Push SI + Push DI + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset PatternMsg + Mov AH, 5 + Mov DI, (4+17*80)*2 + Push DX + Call S_DrawString + Pop AX + + Pop DI + Pop SI + Pop DS + Assume DS:Nothing + + + Mov AX, 4200h + Mov DX, CX + Mov CX, BP + Int 21h ; Move to offset. + + Mov AH, 3Fh + Mov CX, 64 + Xor DX, DX + Int 21h ; Read seq data. + + Pop AX + + Mov CX, 32 + Xor SI, SI + Mov DX, AX ; DX = posn of track data. + Mov DI, 10000 + +D_LoadMTM10: + Push CX + Push DX + + LodsW + And AX, AX + JZ D_LoadMTM11 + + Push DS + Push SI + Push DI + Mov SI, 33 + Sub SI, CX + Push AX + Push SI + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset TrackMsg + Mov DI, (5+18*80)*2 + Mov AH, 5 + Call S_DrawString + + Pop SI + Pop AX + Pop DI + Pop SI + Pop DS + Assume DS:Nothing + + Push DX + + Dec AX + Mov CX, 192 + Mul CX + + Pop CX + Add AX, CX + AdC DX, 0 + Mov CX, DX + Mov DX, AX + Mov AX, 4200h + Int 21h ; Move ptr. + + Mov AH, 3Fh + Mov CX, 192 + Mov DX, DI + Int 21h + + Add DI, 192 + Jmp D_LoadMTM12 + +D_LoadMTM11: + Push ES + + Push DS + Pop ES + + Mov CX, 192 + Xor AL, AL + Rep StosB + + Pop ES + +D_LoadMTM12: + Pop DX + Pop CX + Loop D_LoadMTM10 + + Mov SI, 10000 + ; DS:SI points to pattern data. + + Pop DX + ; DX = pattern number + ; DS:SI = pattern data. + Call PE_TranslateMTMPattern + + Pop CX + Pop AX + Add CX, 64 + AdC BP, 0 + Inc DX + Cmp DL, [DS:60026] + JBE D_LoadMTM9 + + ; BP:CX points to comment + + Comment & + + Mov AL, 37 + Mul Byte Ptr [DS:60030] + ; AX = 37*NOS + Add AX, 194 + Add AX, Word Ptr [DS:60028] ; AX = 194+NOS*37+length_comment + Mov CX, AX + Mov AX, 192 + Mul Word Ptr [DS:60024] ; DX:AX = trcks*192 + Mov BP, DX + Add CX, AX + AdC BP, 0 ; BP:CX = 194+NOS*37+trcks*192+ + ; length(comment) + Mov AL, 64 + Mov AH, Byte Ptr [DS:60026] + Inc AH + Mul AH + Add CX, AX + AdC BP, 0 ; BP:CX = 194+NOS*37+trcks*192+ + ; 64*patterns+length(comment) + + & + +; Add CX, [DS:60028] ; Skip past comment -> samples. +; AdC BP, 0 +; + Mov AX, 4200h + Mov DX, CX + Mov CX, BP + Int 21h ; File is at pointers to samps. + + Mov CX, [DS:60028] ; Length of message + Call Msg_GetMessageOffset ; Sets up DS:DX + Mov AH, 3Fh + Int 21h + ; Now to 'process' the message. + + Mov SI, DX + Mov CX, AX + + Xor DX, DX ; DX = character count. + +D_LoadMTMMessage1: + Mov AL, [SI] + And AL, AL + JNZ D_LoadMTMMessage2 + + Mov Byte Ptr [SI], 32 ; spacebar. + +D_LoadMTMMessage2: + Inc DX + Cmp DX, 40 + JB D_LoadMTMMessage3 + + Xor DX, DX + Mov Byte Ptr [SI], 13 ; Enter! + +D_LoadMTMMessage3: + Inc SI + Loop D_LoadMTMMessage1 + + Push ES + Pop DS + Mov SI, 55912 ; DS:SI points to sample headers + Xor CX, CX + +D_LoadMTM13: + Push CX + Push SI + Test Byte Ptr [DS:SI+12h], 1 + JZ D_LoadMTM14 + ; OK.. have a sample to load. + Push DS + Push SI + + Push CS + Pop DS + Mov SI, Offset SampleMsg + Mov DI, (4+20*80)*2 + Mov AX, CX + Inc AX + Push AX + Mov AH, 5 + Call S_DrawString + Pop AX + Dec AX + + Pop SI + Pop DS + + Call D_LoadSampleData + +D_LoadMTM14: + Pop SI + Pop CX + Inc CX + Add SI, 80 + Cmp CX, 100 + JB D_LoadMTM13 + + Jmp D_PostLoadModule + +EndP D_LoadMTM + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadS3M Far + + Mov AL, 1 + Call D_PreLoadModule + + Mov AH, 3Fh + Mov CX, 60h + Mov DX, 60000 + Int 21h + + Mov DI, 4 + Mov CX, 25 + Mov SI, 60000 + Rep MovsB + Xor AL, AL + StosB + Add DI, 14 + + Mov AX, 10h ; Old Effects + + Test Byte Ptr [DS:60000+33h], 80h + JZ D_LoadS3M1 + + Inc AX + +D_LoadS3M1: + Test Byte Ptr [DS:60000+26h], 8 + JZ D_LoadS3M2 + + Or AL, 2 + +D_LoadS3M2: + StosW + Xor AX, AX + StosW + Mov AL, [DS:60000+30h] + ShL AL, 1 + StosB + Mov AL, [DS:60000+33h] + And AL, 127 + StosB + Mov AX, [DS:60000+31h] + StosW + Mov AL, 128 + StosB + Add DI, 7 + + Mov EAX, [DS:60000+38h] + Cmp Word Ptr [DS:60000+28h], 3208h + JB D_ConvertS3MTimer + + Xor EAX, 'ITRK' + RoR EAX, 7 + Neg EAX + RoL EAX, 4 + Xor EAX, 'JTHL' + +D_ConvertS3MTimer: + StosD + ; OK, panning now... + Mov SI, 60000+40h + Mov CX, 32 + +D_LoadS3M3: + LodsB + + Mov DL, 32+128 + Cmp AL, 128 + JAE D_LoadS3M4 + + Mov AH, AL + +; Test Byte Ptr [DS:60000+33h], 128 +; JZ D_LoadS3M5 + + And AL, 127 + + Mov DL, 0 + Cmp AL, 7 + JBE D_LoadS3M4 + + Mov DL, 64 + Cmp AL, 15 + JBE D_LoadS3M4 + + Mov DL, 32 + +D_LoadS3M4: + Mov AL, DL + And AH, 80h + + StosB + Loop D_LoadS3M3 + + Mov CX, 32 + Mov AL, 32+128 + Rep StosB + + Mov CX, 64 + Mov AL, 64 + Rep StosB + + Mov DI, 100h + Mov CX, 256 + Mov AL, 255 + Rep StosB + + Push DS + + Mov CX, [DS:60000+20h] + Push ES + Pop DS + Mov DX, 100h + Mov AH, 3Fh + Int 21h + + Pop DS ; Order list loaded. + + Mov AH, 3Fh + Mov CX, [DS:60000+22h] + Add CX, [DS:60000+24h] + Add CX, CX + Xor DX, DX + Int 21h + + Cmp Byte Ptr [DS:60000+35h], 252 + JNE D_LoadS3M15 + + Mov AH, 3Fh + Mov CX, 32 + Mov DX, 1024 + Int 21h + + Mov CX, 32 + Mov SI, 1024 + Mov DI, 64 + +D_LoadS3M14: + LodsB + Test AL, 32 + JZ D_LoadS3M16 + + Mov AH, [ES:DI] + And AX, 800Fh + ShL AL, 1 + ShL AL, 1 + Add AL, 2 + Or AL, AH + Mov [ES:DI], AL + +D_LoadS3M16: + Inc DI + + Loop D_LoadS3M14 + +D_LoadS3M15: + Mov CX, 1 ; Load instruments + Mov DI, 55912 + +D_LoadS3M7: + Push CX + Push DI + + Push DI + Push DS + + Mov SI, CX + Dec SI + Add SI, SI + Mov DX, [SI] + + Push CS + Pop DS + Push CX ; For Drawstring. + + Mov AX, 4200h + Xor CX, CX + ShLD CX, DX, 4 + ShL DX, 4 + Int 21h + + Mov SI, Offset SHLoadMsg + Mov DI, (4+16*80)*2 + Mov AH, 5 + Call S_DrawString + Pop AX + + Pop DS + Pop DI + + Mov DX, 1024 ; Load inst. header. + Mov CX, 80 + Mov AH, 3Fh + Int 21h + + Mov EAX, 'SPMI' + StosD + + Mov SI, 1025 + Mov CX, 12 + Rep MovsB + Xor AL, AL + StosB + Mov AL, 64 + StosB + + Xor AL, AL + + Cmp Byte Ptr [DS:1024], 1 + JNE D_LoadS3M8 + + Mov AL, [DS:1024+1Fh] + ShR AL, 1 + And AL, 2 + + Cmp Word Ptr [DS:1024+10h], 0 + JE D_LoadS3M8 + + Inc AX + +D_LoadS3M8: + Mov CL, [DS:1024+1Fh] + Mov CH, CL ; CL = 1 -> loop + And CL, 1 + ShL CL, 4 + Or AL, CL ; Loop... + + And CH, 4 + ShR CH, 1 + Or AL, CH ; 16 bit. + +D_LoadS3M9: + StosB + Mov AL, [DS:1024+1Ch] + StosB + Mov SI, 1024+30h + Mov CX, 25 + Rep MovsB + Xor AX, AX + StosW + Mov AL, 32 + StosB + + Mov EAX, [DS:1024+10h] + StosD ; Length + + Mov EAX, [DS:1024+14h] + StosD ; LoopBeg + + Mov EAX, [DS:1024+18h] + StosD ; LoopEnd + + Mov EAX, [DS:1024+20h] + StosD ; C5Spd + + Xor AX, AX + StosW + StosW ; Susloopbegin + + StosW + StosW ; SusLoopEnd + + Cmp Byte Ptr [DS:1024], 1 + JE D_LoadS3M22 + + Xor AX, AX + StosW + StosW + Jmp D_LoadS3M23 + +D_LoadS3M22: + Mov CL, 4 + Mov AX, [DS:1024+0Eh] + Mov DL, [DS:1024+0Fh] + Mov DH, [DS:1024+0Dh] + ShL AX, CL + ShR DX, CL + StosW ; Sample pointer in file. + Mov AX, DX + StosW + + Xor AX, AX + +D_LoadS3M23: + StosW ; Vibrato info... + StosW + + Pop DI + Pop CX + Add DI, 80 + Inc CX + + Cmp CX, 100 + JAE D_LoadS3M10 + + Cmp CX, [DS:60000+22h] + JBE D_LoadS3M7 + +D_LoadS3M10: + Push DS + + Mov CX, 1 ; CX = sample number (base 1) + ; DS = doesn't matter + ; ES = songdata segment + +D_LoadS3M17: ; OK, now load the samples. + Push CX + Push ES + + Mov SI, CX + Dec SI + Add SI, SI + Mov SI, [ES:64912+SI] + Test Byte Ptr [ES:SI+12h], 1 + JZ D_LoadS3M18 + + Push CS + Pop DS + + Push SI + Mov SI, Offset SampleMsg + Mov DI, (4+17*80)*2 + Mov AH, 5 + Push CX + Call S_DrawString + Pop DI + Pop SI ; ES:SI points to sample header. + ; DI = sample number+1 + Push ES + Pop DS + + Mov AX, 4200h + Xor CX, CX + Xor DX, DX + XChg CX, [DS:SI+4Ah] + XChg DX, [DS:SI+48h] + Int 21h ; Move file pointer. + + Mov AX, DI + Dec AX + + Call D_LoadSampleData + Jmp D_LoadS3MSamplePresent + +D_LoadS3M18: + Mov DWord Ptr [SI+48h], 0 + +D_LoadS3MSamplePresent: + Pop ES + Pop CX + Inc CX + Cmp CX, 100 + JBE D_LoadS3M17 + + Pop DS + + Mov CX, 0 ; CX = pattern number + ; DS = disktransfer + +D_LoadS3M11: + Push CX ; Load patterns.... + + Push DS + + Push CS + Pop DS + + Mov DI, (4+18*80)*2 + Mov SI, Offset PatternMsg + Mov AH, 5 + Push CX + Call S_DrawString + Pop SI ; SI = Pattern Number + + Pop DS + + Add SI, [DS:60000+22h] + Add SI, SI + Mov DX, [SI] ; DX = offset of pattern / 16 + And DX, DX + JZ D_LoadS3M13 + + Push CX + + Xor CX, CX + ShLD CX, DX, 4 + ShL DX, 4 + Mov AX, 4200h + Int 21h + + Mov AH, 3Fh ; Load data. + Mov CX, 2 + Mov DX, 1024 + Int 21h + Mov AH, 3Fh + Mov CX, [DS:1024] + Mov DX, 1024 + Int 21h ; Pattern data at DS:1024 + + Pop DX ; DX = Pattern number + Mov SI, 1024 + Call PE_TranslateS3MPattern + +D_LoadS3M13: + Pop CX + Inc CX + Cmp CX, 100 + JA D_LoadS3M12 + + Cmp CX, [DS:60000+24h] + JB D_LoadS3M11 + +D_LoadS3M12: + Jmp D_PostLoadModule + + Ret + +EndP D_LoadS3M + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_Load669 Far + + Xor AX, AX + Call D_PreLoadModule + + Mov AH, 3Fh + Mov CX, 1F1h + Mov DX, 60000 + Int 21h + + Mov SI, 60000+2 + Mov DI, 4 + Mov CX, 25 + Rep MovsB + + Xor AX, AX + Mov CX, 7 + Rep StosB + Mov SI, 60000+6Eh + LodsB + StosW + LodsB + StosW + + Add DI, 4 + Mov AX, 19h ; Stereo control, sample controlled, + StosW ; Linear, Old EFX + Xor AX, AX + StosW ; Song message attached. + + Mov AX, 3080h ; GV/MV + StosW + + Mov AX, 78*100h+6h ; 78 BPM, speed 6 + StosW + + Mov AX, 64 ; Separation of 64 + StosW + Xor AX, AX + Mov CX, 5 + Rep StosW + + Mov AX, 4000h + StosW + StosW + StosW + StosW + Mov AL, 32+128 + Mov CX, 56 + Rep StosB ; Channel pan + Mov AL, 64 + Mov CL, AL + Rep StosB ; Channel volume + + Mov SI, 60000+71h + Mov DI, 100h ; Orders + Mov CL, 80h + Rep MovsB + Mov CL, 80h + Mov AL, 0FFh + Rep StosB ; Orders done. + + Xor BP, BP ; Sample time + + Mov DI, 512+55400 + Mov AL, 25 + Mul Byte Ptr [DS:60000+6Eh] + Mov CX, AX ; CX = bytes to read + Mov AH, 3Fh + Xor DX, DX + Int 21h + Xor SI, SI + +D_Load669_1: + Cmp BP, [ES:24h] + JAE D_Load669_2 + + Mov EAX, 'SPMI' + StosD + Mov CX, 6 + Rep MovsW + Mov AX, 4000h + StosW + + ; Flag, volume + Mov AH, 60 + Inc SI + Mov ECX, [SI] + Test ECX, ECX + JZ D_Load669_3 + + Xor EAX, EAX + Mov [ES:DI+22h], EAX + Mov [ES:DI+26h], EAX + + Mov AX, 3C01h ; Sample present + + Mov ECX, [SI+8] ; End loop + + Cmp ECX, [SI] + JA D_Load669_3 + + Sub ECX, [SI+4] ; Start loop + JC D_Load669_3 + Cmp ECX, 2 + JB D_Load669_3 + + Mov ECX, [SI+4] + Mov [ES:DI+22h], ECX + Mov ECX, [SI+8] + Mov [ES:DI+26h], ECX + + Mov AX, 3C11h ; Sample present, forwards loop + +D_Load669_3: + StosW + Mov CX, 13 + Sub SI, CX + Rep MovsB + Xor AL, AL + Mov CX, 13 + Rep StosB + Mov AH, 32 + StosW ; Convert, DfP + MovsW + MovsW + Add SI, 8 + Add DI, 8 + + Mov AX, 8363 + StosW + + Xor AX, AX + Mov CX, 9 + Rep StosW + + Inc BP + Jmp D_Load669_1 + +D_Load669_2: ; OK.. patterns.. + Xor BP, BP ; BP = pattern number + +D_Load669_4: + Cmp BP, [ES:26h] + JAE D_Load669_5 + + Mov AH, 3Fh + Mov CX, 600h + Xor DX, DX + Int 21h ; Patterns at DS:0 + + Mov AH, [DS:60000+0F1h+BP] + Mov CL, [DS:60000+171h+BP] + Call PE_Translate669Pattern + + Inc BP + Jmp D_Load669_4 + +D_Load669_5: ; Samples + + Xor BP, BP + Push ES + Pop DS + +D_Load669Samples: + Inc BP + Cmp BP, [DS:24h] + JA D_Load669End + + Mov SI, BP + Add SI, SI + Mov SI, [DS:64910+SI] + Test Byte Ptr [DS:SI+12h], 1 ; Sample present? + JZ D_Load669Samples + + Push DS + Push SI + + Push CS + Pop DS + + Push BP + Mov SI, Offset SampleMsg + Mov DI, (4+16*80)*2 + Mov AH, 5 + Call S_DrawString + + Pop AX + Pop SI + Pop DS + + Dec AX + Call D_LoadSampleData + + Jmp D_Load669Samples + +D_Load669End: + Jmp D_PostLoadModule + +EndP D_Load669 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadMOD Far + + Xor AX, AX + Call D_PreLoadModule + + Mov AH, 3Fh + Mov CX, 2048 + Mov DX, 60000 + Int 21h + + Mov SI, 60000 + Mov DI, 4 + Mov CX, 20 + Rep MovsB ; Song name + Xor AX, AX + Mov CX, 8 + Rep StosW + Add DI, 4 + Mov AX, 31h ; Old effects, stereo, sample control + StosW + Xor AX, AX + StosW + Mov AX, 3080h ; GV/MV + StosW + + Mov AX, 07D06h ; 125 BPM, speed 6 + StosW + + Mov AX, 64 ; Separation of 64 + StosW + + Xor AX, AX + Mov CX, 5 + Rep StosW + + Mov DL, CS:MODNumberOfChannels + Mov CX, 64 + Cmp DL, 8 + JBE D_LoadMOD13 + + Mov CL, DL + Mov AL, 32 + Rep StosB + Mov CL, 64 + Sub CL, DL + Jmp D_LoadMOD14 + +D_LoadMOD13: + Mov AX, 4000h ; Panning. + StosW + Mov AX, 40h + StosW + Sub CX, 4 + + Cmp DL, 4 + JBE D_LoadMOD14 + + Mov AX, 4000h + StosW + Sub CX, 2 + Cmp DL, 6 + JBE D_LoadMOD14 + + Mov AX, 40h + StosW + Sub CX, 2 + +D_LoadMOD14: + Mov AL, 32+128 + Rep StosB ; Clear Panning + + Mov AL, 64 + Mov CX, 64 + Rep StosB ; Channel Volume + + Mov DI, 256 + Mov CX, 256 + Mov AL, 0FFh + Rep StosB ; Orders. + + Mov DI, 256 + Xor CH, CH + Mov CL, CS:MODNumberOfOrders + Mov SI, CS:MODOrderOffset + Mov DX, SI + Rep MovsB ; copy orders... + + ; Get number of patterns to load + Xor CX, CX + Mov SI, DX + Mov AX, 07F00h + +D_LoadMOD1: + LodsB + Cmp CL, AL + JAE D_LoadMOD2 + + Mov CL, AL + +D_LoadMOD2: + Dec AH + JNZ D_LoadMOD1 + + Inc CX ; CX = number of patterns to + ; load + Push CX + + Push BX + ; setup inst. headers + Xor CH, CH + Mov CL, CS:MODNumberOfInstruments + Mov SI, 60000+20 + Mov DI, 512+55400 + +D_LoadMOD3: + Push CX + + Mov EAX, 'SPMI' + StosD + + Mov CX, 6 + Xor AX, AX + Rep StosW + StosB + Mov AL, 64 + StosB + Xor AL, AL + Mov CX, [DS:SI+28] + XChg CH, CL + Cmp CX, 1 + JBE D_LoadMOD4 + + Or AL, 16 + +D_LoadMOD4: + Mov CX, [DS:SI+22] + XChg CH, CL + Cmp CX, 1 + JBE D_LoadMOD5 + + Or AL, 1 + +D_LoadMOD5: + StosB + Mov AL, [DS:SI+25] + StosB + Mov CX, 22 + Rep MovsB + Xor EAX, EAX + StosD + + Mov AX, 1+32*256 ; Convert signed->Unsigned + StosW ; Default pan of 32 + + LodsW + XChg AH, AL ; Sample length... + Add EAX, EAX + StosD + Mov EDX, EAX ; EDX = length + + MovZX EAX, Word Ptr [DS:SI+2] ; Loop begin + XChg AH, AL + + Cmp CS:MODOrderOffset, 60472 + JE D_LoadMOD15 + + Add EAX, EAX + +D_LoadMOD15: + Cmp EAX, EDX + JBE D_LoadMODLengthCheck1 + + Xor EAX, EAX + +D_LoadMODLengthCheck1: + StosD + Mov ECX, EAX + + MovZX EAX, Word Ptr [DS:SI+4] ; Loop end + XChg AH, AL + + Cmp CS:MODOrderOffset, 60472 + JE D_LoadMOD16 + + Add EAX, EAX + +D_LoadMOD16: + Add EAX, ECX + Cmp EAX, EDX + JBE D_LoadMODLengthCheck2 + + Mov EAX, EDX + +D_LoadMODLengthCheck2: + StosD + + LodsB ; C5Speed. + And AX, 15 + Mov BX, AX + Add BX, BX + Mov AX, [CS:FineTuneTable+BX] + StosW + Xor AX, AX + Mov CX, 9 + Rep StosW + + Add SI, 5 + + Pop CX + Loop D_LoadMOD3 + + Pop BX ; Now to load mod patterns. + + Mov AX, 4200h + Xor CX, CX + Mov DX, CS:MODPatternOffset + Int 21h ; set offset in file... + + Pop CX + Xor AX, AX ; Start with pattern 0 + +D_LoadMOD6: + Cmp AX, CX + JAE D_LoadMOD7 + + Push AX + Push CX + + Push DS + + Push CS + Pop DS + + Push AX ; AX = pattern num. + Mov SI, Offset PatternMsg + Mov DI, (4+16*80)*2 + Mov AH, 5 + Call S_DrawString + + Pop DX ; DX = pattern num + Pop DS + + Push DX + + Mov AH, 3Fh + Mov CH, CS:MODNumberOfChannels + Xor CL, CL + Xor DX, DX + Int 21h ; DS:0 contains pat data + + Pop DX + Xor SI, SI + Mov AL, CS:MODNumberOfChannels + Xor AH, AH + + Call PE_TranslateMODPattern + + Pop CX + Pop AX + Inc AX + Jmp D_LoadMOD6 + + +D_LoadMOD7: ; Finished loading patterns + Mov CX, 1 ; Time to load samples. + +D_LoadMOD8: + Push CX + Push ES + + Mov SI, CX + Dec SI + Add SI, SI + Mov SI, [ES:64912+SI] + + Test Byte Ptr [ES:SI+12h], 1 + JZ D_LoadMOD9 + + Push SI + + Push CS + Pop DS + + Push CX + Mov SI, Offset SampleMsg + Mov DI, (4+17*80)*2 + Mov AH, 5 + Call S_DrawString + +; Mov AX, 4201h +; Xor CX, CX +; Mov DX, 4 +; Int 21h ; Progress pointer + + Pop AX + + Pop SI + + Push ES + Pop DS + + Dec AX ; AX = sample to load. + Call D_LoadSampleData + +D_LoadMOD9: + Pop ES + Pop CX + Inc CX + Cmp CL, CS:MODNumberOfInstruments + JBE D_LoadMOD8 + +D_LoadMOD12: + Jmp D_PostLoadModule + + Ret + +EndP D_LoadMOD + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ENDIF + +Proc ConvertOldInstrument ; DS:SI points to inst. + + PushAD + Push DS + Push ES + + Push DS + Pop ES + + Mov DI, SI + + Mov AL, [SI+11h] ; Old format Flg + Mov [SI+130h], AL + + Mov EAX, [SI+12h] ; VLS, VLE, SLS, SLE + Mov [SI+132h], EAX + + Mov AX, [SI+18h] ; Fadeout + Add AX, AX + Mov [SI+14h], AX + + Mov AL, [SI+1Ah] + Mov [SI+11h], AL + + Xor AX, AX + Mov AL, [SI+1Bh] + Mov [SI+12h], AX ; DCT + + Mov AX, 60*256 ; PPS, PPC + Mov [SI+16h], AX + + Mov AX, 128+(32+128)*256 ; GbV+DfP + Mov [SI+18h], AX + + Xor AX, AX + Mov [SI+1Ah], AX + ; Now for envelope + Push SI + Xor CX, CX + + Add SI, 1F8h + Add DI, 136h + +D_LoadITInstrument2: + LodsW + Cmp AX, 0FFFFh + JE D_LoadITInstrument3 + + Mov [DI], AH ; Magintude + Xor AH, AH + Mov [DI+1], AX ; Tick + + Add DI, 3 + Inc CX + Cmp CL, 25 + JAE D_LoadITInstrument3 + + Jmp D_LoadITInstrument2 + +D_LoadITInstrument3: + Pop SI + Mov [SI+131h], CL + + Mov CX, SI + Add CX, 554 + Sub CX, DI + Xor AL, AL + Rep StosB + + Mov Byte Ptr [SI+183h], 2 ; Num nodes for panning + pitch + Mov Byte Ptr [SI+1D5h], 2 + + Mov Byte Ptr [SI+18Ch], 99 ; Magn 0 at Tick 99 + Mov Byte Ptr [SI+1DEh], 99 ; Magn 0 at Tick 99 + + Pop ES + Pop DS + PopAD + + Ret + +EndP ConvertOldInstrument + +IF TUTORIAL +ELSE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadIT Far + + Xor AX, AX + Call D_PreLoadModule + + Push DS + + Push CS + Pop DS + Mov SI, Offset HeaderMsg + Mov DI, (4+16*80)*2 + Mov AH, 5 + Call S_DrawString + + Pop DS + + Mov AH, 3Fh + Mov CX, 2048 + Xor DX, DX + Int 21h + + Cmp Word Ptr [DS:28h], 208h + JB D_ConvertITTimer + + Mov EAX, [DS:3Ch] + Xor EAX, 'ITRK' + RoR EAX, 7 + Neg EAX + RoL EAX, 4 + Xor EAX, 'JTHL' + Mov [DS:3Ch], EAX + +D_ConvertITTimer: + Test Byte Ptr [DS:2Eh], 2 ; Time data? + JZ D_LoadTimeDataNone + + ; Seek to 0C0+Orders+ + ; (ins+samp+pat)*4 + Mov DX, [DS:22h] + Add DX, [DS:24h] + Add DX, [DS:26h] + ShL DX, 2 + Add DX, [DS:20h] + Add DX, 0C0h + Xor CX, CX + Mov AX, 4200h + Int 21h + + Push DS + + Push CS + Pop DS + + Mov AH, 3Fh + Mov CX, 2 + Mov DX, Offset NumTimerData + Int 21h + + Push BX ; Allocate data for timedata + Mov BX, NumTimerData + Cmp BX, 0FFFFh + JNE D_NoTimerDataOverFlow + + Dec BX + Mov NumTimerData, BX + +D_NoTimerDataOverFlow: + Mov CX, BX + ShR BX, 1 + Inc BX + Mov AH, 48h + Int 21h + Pop BX + JC D_LoadTimeDataEnd + + Mov TimerData, AX + Mov DS, AX + ShL CX, 3 + Xor DX, DX + Mov AH, 3Fh + Int 21h + +D_LoadTimeDataEnd: + Pop DS + +D_LoadTimeDataNone: + Test Byte Ptr [DS:2Eh], 8 + JZ D_LoadMIDIConfigDataNone + + PushA + Push DS + + Call Music_GetMIDIDataArea + Xor DX, DX + Mov CX, 4896 + Mov AH, 3Fh + Int 21h + + Pop DS + PopA + +D_LoadMIDIConfigDataNone: + Test Byte Ptr [DS:2Eh], 1 + JZ D_LoadITMsg1 + ; Load the message + ; Move to offset first. + Mov AX, 4200h + Mov CX, [DS:3Ah] + Mov DX, [DS:38h] + Int 21h ; Seek to position + + Push DS + + Mov CX, [DS:36h] + Call Msg_GetMessageOffset + Mov AH, 3Fh + Int 21h + + Pop DS + +D_LoadITMsg1: + ; Actually, load row hilights first... + Test Byte Ptr [DS:2Eh], 4 + JZ D_LoadITNoHilight + + Mov AX, [DS:1Eh] + Push DS + + Push Pattern + Pop DS + Assume DS:Pattern + Mov Word Ptr [RowHilight1], AX + + Pop DS + Assume DS:Nothing + +D_LoadITNoHilight: + Xor SI, SI + Xor DI, DI + Mov CX, 192 + Rep MovsB ; Header + + Mov DI, 256 + Mov CX, [DS:20h] + + Mov DX, DI + Dec CX + Sub DX, CX + Rep MovsB ; Orders + Mov AL, 0FFh + Mov CX, DX + Rep StosB + + Inc SI ; SI points to first + ; pointer + + Xor BP, BP ; Instrument time. + +D_LoadIT1: + Cmp BP, [DS:22h] + JAE D_LoadIT2 + + Push DS + Push SI + + Push CS + Pop DS + Mov SI, Offset InstrumentMsg + Mov AX, BP + Inc AX + Push AX + Mov AH, 5 + Mov DI, (4+17*80)*2 + Call S_DrawString + Pop AX + + Pop SI + Pop DS + ; Move to offset.. + LodsW + Mov DX, AX + LodsW + Mov CX, AX + Mov AX, 4200h + Int 21h + + Mov DI, [DS:2Ah] ; Format version + + Push DS + Push SI + + Push ES + Pop DS + Mov SI, BP + Add SI, SI + Mov DX, [DS:64712+SI] + Mov CX, 554 + Mov AH, 3Fh + Int 21h + + Cmp DI, 200h + JAE D_LoadITInstrument1 + + Mov SI, DX + Call ConvertOldInstrument + +D_LoadITInstrument1: + Pop SI + Pop DS + Inc BP + Jmp D_LoadIT1 + +D_LoadIT2: + Xor BP, BP ; Sample header time. + +D_LoadIT3: + Cmp BP, [DS:24h] + JAE D_LoadIT4 + + Push DS + Push SI + + Push CS + Pop DS + Mov SI, Offset SHLoadMsg + Mov AX, BP + Inc AX + Push AX + Mov AH, 5 + Mov DI, (4+18*80)*2 + Call S_DrawString + Pop AX + + Pop SI + Pop DS + ; Move to offset.. + LodsW + Mov DX, AX + LodsW + Mov CX, AX + Mov AX, 4200h + Int 21h + + Push DS + Push SI + + Push ES + Pop DS + + Mov SI, BP + Add SI, SI + Mov DX, [DS:64912+SI] + Mov CX, 80 + Mov AH, 3Fh + Int 21h + + Pop SI + Pop DS + Inc BP + Jmp D_LoadIT3 + +D_LoadIT4: + Xor BP, BP + + Push DS + Push SI + + + Push ES + Pop DS ; DS now points to song data. + +D_LoadIT7: + Mov SI, BP + Add SI, SI + Mov SI, [64912+SI] + + Test Byte Ptr [DS:SI+12h], 1 + JZ D_LoadIT8 + + Push DS + Push SI + + Push CS + Pop DS + Mov SI, Offset SampleMsg + Mov AX, BP + Inc AX + Push AX + Mov AH, 5 + Mov DI, (4+19*80)*2 + Call S_DrawString + Pop AX + + Pop SI + Pop DS + + Mov AX, 4200h + Xor CX, CX + Xor DX, DX + XChg DX, [DS:SI+48h] + XChg CX, [DS:SI+4Ah] + Int 21h ; Move file pointer. + + Mov AX, BP + Call D_LoadSampleData + Jmp D_LoadITSamplePresent + +D_LoadIT8: + Mov DWord Ptr [SI+48h], 0 + +D_LoadITSamplePresent: + Inc BP + Cmp BP, 99 + JB D_LoadIT7 + + Pop SI + Pop DS + + Xor BP, BP + +D_LoadIT5: + Cmp BP, [DS:26h] ; Pattern time. + JAE D_LoadIT6 + + Push ES + + Push DS + Push SI + + Push CS + Pop DS + Mov SI, Offset PatternMsg + Push BP + Mov AH, 5 + Mov DI, (4+20*80)*2 + Call S_DrawString + Pop AX + + Pop SI + Pop DS + ; Move to offset.. + LodsW + Mov DX, AX + LodsW + Mov CX, AX + And DX, DX + JNZ D_LoadIT12 + And CX, CX + JZ D_LoadIT13 + +D_LoadIT12: + Mov AX, 4200h + Int 21h + + Push DS + Push SI + + Mov AH, 3Fh + Mov DX, 60000 + Mov CX, 8 + Int 21h ; DS:DX = pattern header. + + Mov DX, [DS:60000] ; DX = length + Push DX + Add DX, 8 + Mov SI, BP + + Push BX + Call Music_AllocatePattern + ; ES:DI = location. + Pop BX + + Mov AX, ES + And AX, AX + JZ D_LoadIT10 + + Mov SI, 60000 + Mov CX, 8 + Rep MovsB + + Push ES + Pop DS + Mov DX, DI + Mov AH, 3Fh + Pop CX ; CX = length. + Int 21h + + Jmp D_LoadIT11 + +D_LoadIT10: + Pop CX + Push BX + + + Call PEFunction_OutOfMemoryMessage + + Pop BX + +D_LoadIT11: + Pop SI + Pop DS + +D_LoadIT13: + Pop ES + + Inc BP + Jmp D_LoadIT5 + +D_LoadIT6: + Jmp D_PostLoadModule + + Ret + +EndP D_LoadIT + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFileImpulseModule Far + + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_LoadITList + + Mov AX, 5 + Ret + +EndP D_LoadFileImpulseModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFileS3MModule Far + + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_LoadS3MList + + Mov AX, 5 + Ret + +EndP D_LoadFileS3MModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFile669Module Far + + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_Load669List + + Mov AX, 5 + Ret + +EndP D_LoadFile669Module + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFileXMModule Far + + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_LoadXMList + + Mov AX, 5 + Ret + +EndP D_LoadFileXMModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFileMTMModule Far + + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_LoadMTMList + + Mov AX, 5 + Ret + +EndP D_LoadFileMTMModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFileMODModule Far + + Mov AL, 31 + Mov CL, [DS:60000+950] + Mov DX, 60952 + Mov SI, 1084 + + Cmp Word Ptr [BX+23], 16 + JNE D_LoadFileMODModule1 + + Mov AL, 15 + Mov CL, [DS:60000+470] + Mov DX, 60472 + Mov SI, 600 + +D_LoadFileMODModule1: + Mov CS:MODNumberOfInstruments, AL + Mov CS:MODNumberOfOrders, CL + Mov CS:MODOrderOffset, DX + Mov CS:MODPatternOffset, SI + + Mov SI, [BX+23] + Cmp SI, 17 + JNE D_LoadFileMODModule2 + + Mov AL, [BX+22] + Jmp D_LoadFileMODModule3 + +D_LoadFileMODModule2: + Sub SI, 9 + Mov AL, [CS:MODChannelTable+SI] + +D_LoadFileMODModule3: + Mov CS:MODNumberOfChannels, AL + + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_LoadMODList + + Mov AX, 5 + Ret + +EndP D_LoadFileMODModule + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/IT_D_WM.INC b/it_d_wm.inc similarity index 96% rename from IT_D_WM.INC rename to it_d_wm.inc index 22e492c..1beca0d 100644 --- a/IT_D_WM.INC +++ b/it_d_wm.inc @@ -1,1785 +1,1785 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Write module functions -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -Proc WriteITSampleBlock - - PushAD ; BX = file handle. - Push DS - - Mov DS, CS:DiskDataArea - - Mov DX, [DS:1996] - Mov CX, [DS:1998] - Mov AX, 4200h - Int 21h - - Mov AX, 80 - Mul Word Ptr [DS:24h] - Mov CX, AX - - Mov DX, 2000 - Call D_SaveBlock - -WriteITSampleBlock1: - Pop DS - PopAD - Ret - -EndP WriteITSampleBlock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -NUMS3MCHANNELS EQU 16 - -BitLUT Label Byte - DB 1, 2, 3, 3, 4, 4, 4, 4 - DB 5, 5, 5, 5, 5, 5, 5, 5 - DB 4, 4, 4, 4, 3, 3, 2 - -BitLUT16 Label Byte - DB 1, 10 SHL 3 + 3, 11 SHL 3 + 5, 11 SHL 3 + 3 - DB 3 DUP (12 SHL 3 + 5), 12 SHL 3 + 3 - DB 7 DUP (13 SHL 3 + 5), 13 SHL 3 + 3 - - DB 13 SHL 3 + 4, 7 DUP (13 SHL 3 + 5) - DB 12 SHL 3 + 4, 3 DUP (12 SHL 3 + 5) - DB 11 SHL 3 + 4, 11 SHL 3 + 5, 10 SHL 3 + 4, 2 - - -Proc D_SaveIT Far - - - Call PE_SaveCurrentPattern - - Call D_UpdateFileName - - Push CS - Pop DS - Assume DS:Disk - - Mov NoSaveError, 0 - - Mov AH, 3Ch - Xor CX, CX ; File type is normal (archive) - Mov DX, Offset SaveFileName ; DS:DX points to filename - Int 21h - JNC D_SaveIT3 - - Call PE_RestoreCurrentPattern - Jmp D_NoSaveMessage - -D_SaveIT3: - Mov BX, AX ; BX = handle - - Mov ES, DiskDataArea - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing ; DS = MusicData - - Xor SI, SI - Xor DI, DI - Mov CX, 192 - Rep MovsB ; Get header. - - ; Now to figure out the - ; orders. - Mov SI, 511 - StD - Mov CX, 256 - -D_SaveIT4: - LodsB - Cmp AL, 0FFh - LoopE D_SaveIT4 - - ClD - - Add CX, 2 - Mov [ES:20h], CX - Dec CX - - Mov SI, 256 - Rep MovsB ; Transfer orders. - Mov AL, 0FFh - StosB - -; Mov AX, 0 -; Test Byte Ptr [DS:2Ch], 4 -; JZ D_SaveIT6 -; - Call Music_GetNumberOfInstruments -; -; D_SaveIT6: - Mov [ES:22h], AX ; Number of instruments - - Call Music_GetNumberOfSamples - Mov [ES:24h], AX ; Number of samples - - Call PE_GetMaxPattern - Inc AX - Mov [ES:26h], AX ; Number of patterns. - - Xor CX, CX ; CX:DX = 'long' offsets. - Mov DX, 0C0h - Add DX, [ES:20h] - Mov AX, [ES:22h] - ShL AX, 2 - Add DX, AX - Mov AX, [ES:24h] - ShL AX, 2 - Add DX, AX - Mov AX, [ES:26h] - ShL AX, 2 - Add DX, AX - - Mov DWord Ptr [ES:36h], 0 - Mov Word Ptr [ES:2Eh], 4 ; Row hilight information - - Push DS - - Push Pattern - Pop DS - Assume DS:Pattern - - Mov AX, Word Ptr [RowHilight1] - - Pop DS - Assume DS:Nothing - - Mov [ES:1Eh], AX - - - Call GetTimerCounter - Sub EAX, EditTimer - - Cmp TimerData, 0 - JE NoTimerData - - Or Byte Ptr [ES:2Eh], 2 ; Contains timer information - - Push ES ; Put time into table. - Push DI - - Mov ES, TimerData - Mov DI, NumTimerData - ShL DI, 3 - Add DI, 4 - StosD - Add DI, 2 - - Add DX, DI ; Long offset progress. - AdC CX, 0 - - Pop DI - Pop ES - -NoTimerData: -; OK.. check for MIDI config save. - Test Byte Ptr [DS:2Ch], 128 - JZ D_SaveITNoMIDIConfig1 - - Add DX, 4896 ; MIDI Config size - AdC CX, 0 - Or Byte Ptr [ES:2Eh], 8 ; MIDI Config. - -D_SaveITNOMIDIConfig1: - - Add EAX, [ES:3Ch] - Xor EAX, 'JTHL' - RoR EAX, 4 - Neg EAX - RoL EAX, 7 - Xor EAX, 'ITRK' - - Mov [ES:3Ch], EAX - - Call Msg_GetMessageLength - Cmp AX, 1 - JE D_SaveITMsg1 - - Or Byte Ptr [ES:2Eh], 1 - Mov Word Ptr [ES:3Ah], 0 - Mov [ES:38h], DX - Mov [ES:36h], AX - Add DX, AX - -D_SaveITMsg1: - Mov BP, [ES:22h] ; Number of instruments - - Mov AX, 214h - - Cmp CS:SaveFormat, 0 - JE D_SaveNewFormat - - Inc AX - Cmp CS:SaveFormat, 3 - JE D_SaveNewFormat - - Mov AX, 200h - -D_SaveOldIT2_1: - Test BP, BP - JNZ D_SaveNewFormat - - Mov AX, 100h - -D_SaveNewFormat: - Inc BP - Mov Word Ptr [ES:28h], TRACKERVERSION - Mov [ES:2Ah], AX - And EBP, 0FFFFh - -D_SaveIT7: - Dec BP - JZ D_SaveIT8 - - Mov SI, [DS:EBP+EBP+64710] - Test Byte Ptr [SI+1D4h], 80h - JZ D_SaveIT216 - - Mov Word Ptr [ES:2Ah], 216h - -D_SaveIT216: - Mov AX, DX - StosW - Mov AX, CX - StosW - Add DX, 554 - AdC CX, 0 - - Jmp D_SaveIT7 - -D_SaveIT8: - Mov BP, [ES:24h] ; Number of samples - Inc BP - Mov [ES:1996], DX ; Store sample position. - Mov [ES:1998], CX - -D_SaveIT9: - Dec BP - JZ D_SaveIT10 - - Mov AX, DX - StosW - Mov AX, CX - StosW - - Add DX, 80 - AdC CX, 0 - - Jmp D_SaveIT9 - -D_SaveIT10: - - Xor BP, BP - -D_SaveIT11: - Cmp BP, [ES:26h] ; Number of patterns - JAE D_SaveIT12 - - Push DS - - Mov AX, BP - Call Music_GetPattern ; DS:SI has pattern - - Mov AX, DS - Cmp AX, Music - JE D_SaveIT1 - - Mov AX, DX - StosW - Mov AX, CX - StosW - - Add DX, [DS:SI] - AdC CX, 0 - Add DX, 8 ; pattern header length = 8. - AdC CX, 0 - - Jmp D_SaveIT22 - -D_SaveIT1: - Xor EAX, EAX - StosD - -D_SaveIT22: - Pop DS - - Inc BP - Jmp D_SaveIT11 - -D_SaveIT12: - ; CX:DX now point to first sample data. - Push CX - Push DX - - Push DS - - Push DI - - Push CS - Pop DS - Mov DI, (4+17*80)*2 - Mov SI, Offset HeaderMsg - Mov AH, 5 - Call S_DrawString - - Pop CX ; CX = length of header. - - Push ES - Pop DS - - Xor DX, DX - Call D_SaveBlock ; Header. - - Test Byte Ptr [DS:2Eh], 2 ; Time information? - JZ D_SaveITTimeData - - Push DS - - Push CS - Pop DS - - Mov CX, 2 - Mov DX, Offset NumTimerData - Inc [DS:NumTimerData] - Call D_SaveBlock - Mov CX, [DS:NumTimerData] - Dec [DS:NumTimerData] - ShL CX, 3 - Mov DS, [DS:TimerData] - Xor DX, DX - Call D_SaveBlock - - Pop DS - -D_SaveITTimeData: - Test Byte Ptr [DS:2Ch], 128 - JZ D_SaveITMIDIConfig - - Push DS - - Mov CX, 4896 - Xor DX, DX - Call Music_GetMIDIDataArea ; Gets DS - Call D_SaveBlock - - Pop DS - -D_SaveITMIDIConfig: - ; Message? - Test Byte Ptr [DS:2Eh], 1 - JZ D_SaveITMsg2 - - Mov CX, [DS:36h] - Push DS - Call Msg_GetMessageOffset - Call D_SaveBlock - Pop DS - -D_SaveITMsg2: - Push CS - Pop DS - Mov DI, (4+18*80)*2 - Mov SI, Offset InstrumentHeaderMsg - Mov AH, 5 - Call S_DrawString - - Pop DS - Cmp Word Ptr [ES:22h], 0 - JE D_SaveIT13 - - Mov AX, 554 - Mul Word Ptr [ES:22h] - Mov DX, 512 - Mov CX, AX - - Call D_SaveBlock ; Instrument headers... - -D_SaveIT13: - Push DS - - Push CS - Pop DS - Mov DI, (4+19*80)*2 - Mov SI, Offset SampleHeaderMsg - Mov AH, 5 - Call S_DrawString - - Pop DS ; DS = song data segment - Mov SI, 55912 ; Start of samples in mem. - Mov AX, 80 - Mul Word Ptr [ES:24h] - Mov DI, 2000 - Mov CX, AX - Rep MovsB - - Pop DX - Pop CX ; CX:DX = sample point. - - Mov BP, [ES:24h] ; Number of samples. - Mov SI, 2000 - Inc BP - -D_SaveIT14: - Dec BP - JZ D_SaveIT16 - Mov AL, [ES:SI+12h] - Mov AH, 1 - - Cmp CS:SaveFormat, 3 - JNE D_SaveNoDD - - Or AH, 4 - -D_SaveNoDD: - Test AL, 1 - JZ D_SaveIT15 - - Or AL, 8 - Cmp CS:SaveFormat, 2 - JNE D_SaveIT214_1 - - And AL, Not 8 - -D_SaveIT214_1: - Mov [ES:SI+48h], DX - Mov [ES:SI+4Ah], CX - - Test AL, 2 - Mov [ES:SI+12h], AL - Mov [ES:SI+2Eh], AH - Mov EAX, [ES:SI+30h] - JZ D_SaveIT16Bit - - Add EAX, EAX - -D_SaveIT16Bit: - Add DX, AX - PushF - ShR EAX, 16 - PopF - AdC CX, AX ; Advance sample pointer. - -D_SaveIT15: - Add SI, 80 - Jmp D_SaveIT14 - -D_SaveIT16: - Call WriteITSampleBlock - - Xor BP, BP - -D_SaveIT17: - Push DS - - Push CS - Pop DS - Mov DI, (4+20*80)*2 - Mov SI, Offset PatternMsg - Mov AH, 5 - Push BP - Call S_DrawString - Pop AX - - Call Music_GetPattern - Mov DX, DS - Cmp DX, Music - JE D_SaveIT2 - - Mov DX, SI - Mov CX, [DS:SI] - Add CX, 8 - Call D_SaveBlock - -D_SaveIT2: - Pop DS - Inc BP - Cmp BP, [ES:26h] - JB D_SaveIT17 - -; Setup compression block - Push DS - - Push CS - Pop DS - Mov SI, Offset BitLUT - - Mov DI, 10240 - Mov CX, 16/2 - Rep MovsW - -; Setup table. - - Mov CX, 16 - Mov AL, 6 - Rep StosB - - Mov CX, 28 - Inc AX - Rep StosB - - Mov CX, 64 - Inc AX - Rep StosB - - Mov CX, 8 - Inc AX - Rep StosB - - Mov CX, 64 - Dec AX - Rep StosB - - Mov CX, 29 - Dec AX - Rep StosB - - Mov CX, 16 - Dec AX - Rep StosB - - Mov CX, 15 - Sub SI, 8 - Rep MovsB - -; 16 bit Main LUT - - Mov SI, Offset BitLUT16 - Mov CX, 16 - Rep MovsB - - Mov CX, 15 - Mov AL, 14 SHL 3 + 5 - Rep StosB - Mov AL, 14 SHL 3 + 3 - StosB - - Mov CX, 31 - Mov AL, 15 SHL 3 + 5 - Rep StosB - Mov AL, 15 SHL 3 + 3 - StosB - - Mov CX, 63 - Mov AL, 16 SHL 3 + 5 - Rep StosB - Mov AL, 16 SHL 3 + 3 - StosB - - Inc AX -; Mov AL, 16 SHL 3 + 4 - StosB - Mov CX, 63 - Inc AX -; Mov AL, 16 SHL 3 + 5 - Rep StosB - - Mov AL, 15 SHL 3 + 4 - StosB - Mov CX, 31 - Mov AL, 15 SHL 3 + 5 - Rep StosB - - Mov AL, 14 SHL 3 + 4 - StosB - Mov CX, 15 - Mov AL, 14 SHL 3 + 5 - Rep StosB - - Mov CX, 16 - Rep MovsB - -; 16 bit LUT 1, for 16-bit samples with high byte = 0 - - Mov SI, Offset BitLUT - Mov CX, 16 - Rep MovsB - - Mov CX, 16 - Mov AL, 6 - Rep StosB ; AL = 6 from before - - Mov CX, 24 - Inc AX - Rep StosB - - Mov CX, 64 - Inc AX - Rep StosB - - Mov CX, 128 - Inc AX - Rep StosB - -; 16-Bit LUT 2, for 16-bit samples with high byte = 0xFF - - Mov CX, 16 - Inc AX - Rep StosB - - Mov CX, 128 - Dec AX - Rep StosB - - Mov CX, 64 - Dec AX - Rep StosB - - Mov CX, 25 - Dec AX - Rep StosB - - Mov CX, 16 - Dec AX - Rep StosB - - Mov CX, 15 - Sub SI, 8 - Rep MovsB - - Mov CX, 256-8 - Xor AX, AX - Rep StosB - - Mov CX, 16 - Inc AX - Rep StosB - - Mov CX, 256-8+256 - Dec AX - Rep StosB - - Pop DS - - Xor BP, BP ; BP = sample number. - Mov DI, 2000+48h - -D_SaveIT18: - Push DS - Push DI - - Xor CX, CX - Xor DX, DX - Mov AX, 4201h - Int 21h - - Mov [ES:DI], AX - Mov [ES:DI+2], DX - - Mov SI, BP - Add SI, SI - Mov SI, [64912+SI] ; DS:SI points to sample head. - - Test Byte Ptr [SI+12h], 1 ; Check if sample is present. - JZ D_SaveIT19 - Cmp DWord Ptr [SI+30h], 0 ; For bodgy sample crap. - JZ D_SaveIT19 - -D_SaveIT21: - Push DS ; DS:DX points to sample... - Push SI - - Push CS - Pop DS - Mov DI, (4+21*80)*2 - Mov SI, Offset SampleMsg - Mov AX, BP - Inc AX - Push AX - Mov AH, 5 - Call S_DrawString - Pop AX - - Pop SI - Pop DS ; Sample encoding to go here.. - ; But sample position needs to - ; be recoded then... - Cmp CS:SaveFormat, 2 - JNE D_SaveSampleDataCompressedCall - - Call D_SaveSampleData - Jmp D_SaveIT19 - -D_SaveSampleDataCompressedCall: - Call D_SaveSampleDataCompressed - -D_SaveIT19: - Pop DI - Pop DS - - Add DI, 80 - - Inc BP - Cmp BP, [ES:24h] - JB D_SaveIT18 - - Call WriteITSampleBlock - - Mov AH, 3Eh ; Close file - Int 21h - - Push CS - Pop DS - Mov DI, (4+23*80)*2 - Mov SI, Offset CompleteMsg - Mov AH, 5 - Call S_DrawString - -EndSaveModule: - Mov DX, Offset SaveFileName - Call D_DeleteIfError - - Call PE_RestoreCurrentPattern - - Cmp NoSaveError, 0 - JNE SaveModuleError - - Call PEResetModified - -SaveModuleError: - Mov AX, 1 - Ret - -EndP D_SaveIT - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveS3M Far - - Call PE_SaveCurrentPattern - Call D_UpdateFileName - - Mov BP, 60h ; BP = length of header. -; Call PE_StoreCurrentPattern - - Push CS - Pop DS - Assume DS:Disk - - Mov SaveFormatError, 0 - - Mov NoSaveError, 0 - - Mov AH, 3Ch - Xor CX, CX ; File type is normal (archive) - Mov DX, Offset SaveFileName ; DS:DX points to filename - Int 21h - JNC D_SaveS3M1 - - Call PE_RestoreCurrentPattern - Jmp D_NoSaveMessage - -D_SaveS3M1: - Mov BX, AX - - Mov ES, DiskDataArea - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing ; DS = MusicData - - Mov SI, 4 - Xor DI, DI - Mov CX, 26/2 - Rep MovsW - Xor AX, AX - StosW - Mov AX, 1Ah+16*256 ; St3 module identification. - StosW - Xor AX, AX - StosW - ; Now to figure out the - ; orders. - Mov SI, 511 - StD - Mov CX, 256 - -D_SaveS3M2: - LodsB - Cmp AL, 0FFh - LoopE D_SaveS3M2 - - ClD - - Inc CX - Mov AX, CX - Inc AX ; Number of orders. - Add BP, AX - StosW - - Call Music_GetNumberOfSamples - Add BP, AX - Add BP, AX - StosW ; Number of samples. - - Call PE_GetMaxPattern - Inc AX - Add BP, AX - Add BP, AX - Cmp AX, 100 - JBE D_SaveS3M4 - - Mov AX, 100 - - Push Offset D_SaveS3M4 - Push SI - Push DI - Mov SI, Offset TooManyPatternsMsg - Mov DI, (4+23*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M4: - StosW ; Number of patterns - - ; Flags... 8 = vol0opt on. - Mov AX, [DS:2Ch] - And AX, 2 - ShL AX, 2 - StosW ; Flags stored. - - Mov AX, 3000h+TRACKERVERSION - StosW ; Impulse Tracker - - Mov AX, 2 - StosW ; Standard unsigned samples. - - Mov EAX, 'MRCS' - StosD ; ID done. - - Mov AH, [DS:2Ch] - Test AH, 4 - JZ D_SaveS3MNoInsError - - Push Offset D_SaveS3MNoInsError - Push SI - Push DI - Mov SI, Offset ST3InstrumentErrorMsg - Mov DI, (4+29*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3MNoInsError: - Mov AL, [DS:30h] - ShR AL, 1 - StosB - Mov AX, [DS:32h] ; Tempo and speed - StosW - Mov AL, [DS:31h] ; Mixing volume - Mov AH, [DS:2Ch] ; Grab stereo setting. - Cmp AL, 80h - JB D_SaveNoMixOverflow - - Mov AL, 7Fh - -D_SaveNoMixOverflow: - ShL AL, 1 - ShR AX, 1 - StosB - - Mov AX, 252*256 - StosW - Xor AX, AX - StosW - - Call GetTimerCounter - Sub EAX, EditTimer - Add EAX, [DS:3Ch] - - Xor EAX, 'JTHL' - RoR EAX, 4 - Neg EAX - RoL EAX, 7 - Xor EAX, 'ITRK' - - StosD - - Xor AX, AX - StosW - - Mov SI, 256 ; Orders. - Mov DI, 60h - JCXZ D_SaveS3M3 - -D_SaveS3M5: - LodsB - Cmp AL, 0FEh - JAE D_SaveS3M6 - Cmp AL, 100 - JB D_SaveS3M6 - - Mov AL, 0FFh ; So that pattern numbers >= 100 aren't listed - -D_SaveS3M6: - StosB - Loop D_SaveS3M5 - -D_SaveS3M3: - Mov AL, 0FFh - StosB - - ; Do channel settings. - Push BX - - Mov BX, BP - - Mov SI, 40h - Mov DI, SI - Sub BX, DI - - Mov CX, 32 - Xor AH, AH - -D_SaveS3M7: - LodsB - Test AL, 80h - JNZ D_SaveS3M9 - - Cmp AL, 64 - JBE D_SaveS3M8 - - Mov AL, 32 ; For surround. - -D_SaveS3M8: - ; Convert 0->64 to 0->15 - Mov DL, AL - ShR DL, 1 - Sub DL, 1 - AdC DL, 0 - ShR DL, 1 - Or DL, 32 ; Reqd... - - Mov AL, AH - - And AL, 1 - ShL AL, 3 - Mov DH, AH - ShR DH, 1 - Or AL, DH - - Inc AH - Jmp D_SaveS3M10 - -D_SaveS3M9: ; Muted/nonexistant - Mov AL, 0FFh - Mov DL, 0 - -D_SaveS3M10: - Mov [ES:BX+DI], DL - StosB - Loop D_SaveS3M7 - - Pop BX - - Add BP, 20h - - ; Check that channel volumes are all 64... - - Mov CX, 32 - Mov SI, 80h - -D_SaveS3M11: - LodsB - Cmp AL, 64 - JNE D_SaveS3M12 - Loop D_SaveS3M11 - Jmp D_SaveS3M13 - -D_SaveS3M12: - Push Offset D_SaveS3M13 - Push SI - Push DI - Mov SI, Offset ChannelVolumeErrorMsg - Mov DI, (4+24*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M13: - Test Byte Ptr [DS:2Ch], 8 - JZ D_SaveS3M15 - - Push Offset D_SaveS3M15 - Push SI - Push DI - Mov SI, Offset LinearSlideMsg - Mov DI, (4+25*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M15: - Push DS - - Push CS - Pop DS - Mov DI, (4+17*80)*2 - Mov SI, Offset SampleHeaderMsg - Mov AH, 5 - Call S_DrawString - - Pop DS - Assume DS:Nothing - - Push BP ; BP = length of header. - - Xor AX, AX ; AX = sample number. - Xor DX, DX ; DX:BP = file position. - ; BX = file handle - -;-------------------------------------- - -D_SaveS3M14: - Push AX - - Add BP, 15 ; Align on next 16-byte boundary. - AdC DX, 0 ; Unnecessary.. but who cares. - ; Now to store pointer. - And BP, Not 15 - - Push DX - - Mov DI, AX - Add DI, DI - - Push DI - - Add DI, 60h - Add DI, [ES:20h] - - ; Move file pointer. - Mov AX, 4200h - Mov CX, DX - Mov DX, BP - Int 21h - - SHRD AX, DX, 4 - Mov [ES:DI], AX - - ; Set up sample block at ES:1024. - Pop DI - Push BX - - Mov BX, [DS:64912+DI] ; DS:BX points to sample header. - - Mov DI, 1024 - Mov AL, [BX+12h] - Mov DL, AL - And AL, 1 - - StosB - - Mov SI, BX - Add SI, 4 - Mov CX, 12 - Rep MovsB ; filename - - Xor AX, AX - StosB - StosW - - Mov SI, BX - Add SI, 30h - Mov CX, 6 - Rep MovsW ; Length/Loopbeg/Loopend. - - Mov AL, [DS:BX+13h] - StosW ; Default sample volume. - - Mov AH, DL - Mov CL, DL - ShR AH, 4 - And AX, 100h - ShL CL, 1 - And CL, 4 - Or AH, CL - - StosW ; Loop, 16 Bit & no 'pack' - - MovsW - MovsW - - Mov CX, 6 - Xor AX, AX - Rep StosW - ; Now for sample name. - - Mov SI, BX - Add SI, 14h - Mov CX, 25 - -D_SaveS3M56: - LodsB - And AL, AL - JNZ D_SaveS3M57 - - Mov AL, 32 - -D_SaveS3M57: - StosB - Loop D_SaveS3M56 - - Xor AX, AX - StosB - StosW - - Mov EAX, 'SRCS' - StosD ; OK header is done... - - Test DL, 16+32 - JZ D_SaveS3M16 ; No loop on. - - Test DL, 32 - JNZ D_SaveS3M51 - - Test DL, 64 - JZ D_SaveS3M16 - -D_SaveS3M51: - Push Offset D_SaveS3M16 - Push SI - Push DI - Mov SI, Offset LoopMsg - Mov DI, (4+27*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M16: - Cmp Byte Ptr [DS:BX+11h], 64 - JE D_SaveS3M17 - - Push Offset D_SaveS3M17 - Push SI - Push DI - Mov SI, Offset SampleVolumeMsg - Mov DI, (4+26*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M17: - Cmp Byte Ptr [DS:BX+4Dh], 0 - JE D_SaveS3M18 - - Push Offset D_SaveS3M18 - Push SI - Push DI - Mov SI, Offset SampleVibratoMsg - Mov DI, (4+28*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M18: ; Write block. - Pop BX - Push DS - - Push ES - Pop DS - Mov DX, 1024 - Mov CX, 50h - Call D_SaveBlock - - Pop DS - Pop DX - - Add BP, 50h ; Advance file pointer. - AdC DX, 0 - - Pop AX - Inc AX - Cmp AX, [ES:22h] - JB D_SaveS3M14 ; Sample headers done. - -;----------------------------------- - ; Pattern data. - Xor AX, AX ; Start with pattern 0 - -D_SaveS3M19: - Push AX - ; Shove message on screen.... - Add BP, 15 ; Align on next 16-byte boundary. - AdC DX, 0 ; Unnecessary.. but who cares. - ; Now to store pointer. - And BP, Not 15 - - Push DX - - Push AX ; AX for pattern msg... - - Mov DI, AX - Add DI, DI - - Add DI, 60h - Add DI, [ES:20h] - Mov CX, [ES:22h] - Add CX, CX - Add DI, CX - - ; Move file pointer. - Mov AX, 4200h - Mov CX, DX - Mov DX, BP - Int 21h - - SHRD AX, DX, 4 ; DX:AX = new file pointer location - Mov [ES:DI], AX - - Push CS - Pop DS - - Mov DI, (4+18*80)*2 - Mov SI, Offset PatternMsg - Mov AH, 5 - Call S_DrawString - - Pop AX ; AX = pattern. - Call Music_GetPattern ; DS:SI points to pattern. - - Mov CX, [SI+2] ; CX = length. - Cmp CX, 64 - JE D_SaveS3M20 - - Push Offset D_SaveS3M20 - Push SI - Push DI - Mov SI, Offset PatternLengthMsg - Mov DI, (4+30*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M20: - Push BX - - Push CX - - Mov DI, 20000 - Mov CX, 64 - -D_SaveS3M25: - Mov AX, 0FD00h ; Mask & note. - StosW - Mov AH, 0FFh ; instrument & volume. - StosW - Xor AH, AH - StosW - StosW - Loop D_SaveS3M25 - - Mov DI, 30002 - Add SI, 8 - - Pop CX - Push CX - -D_SaveS3M22: ; Pattern translation time. - Push CX - -D_SaveS3M33: - LodsB - And AL, AL - JZ D_SaveS3M23 - - Mov DL, AL - And AX, 7Fh - Dec AX - Mov CL, 3 - ShL AX, CL - Mov BX, AX - Add BX, 20000 ; ES:BX points to old information. - ; Decode row into area. - - Mov DH, [ES:BX] - - Test DL, 80h - JZ D_SaveS3M24 - - LodsB ; Mask - Mov [ES:BX], AL - Mov DH, AL - -D_SaveS3M24: - Test DH, 1 - JZ D_SaveS3M26 - - LodsB - Mov [ES:BX+1], AL - -D_SaveS3M26: - Test DH, 2 - JZ D_SaveS3M27 - - LodsB - Mov [ES:BX+2], AL - -D_SaveS3M27: - Test DH, 4 - JZ D_SaveS3M28 - - LodsB - Cmp AL, 64 - JA D_SaveS3MPanError - -D_SaveS3M28_2: - Mov [ES:BX+3], AL ; Volume - -D_SaveS3M28: - Test DH, 8 - JZ D_SaveS3M29 - - LodsW ; Effect+value. - Mov [ES:BX+4], AX - -D_SaveS3M29: - And DL, 7Fh - Cmp DL, NUMS3MCHANNELS - JA D_SaveS3M30 - - Dec DX - Test DH, 33h - JZ D_SaveS3M31 - - Or DL, 32 - -D_SaveS3M31: - Test DH, 44h - JZ D_SaveS3M32 - - Or DL, 64 ; Volume - -D_SaveS3M32: - Test DH, 88h - JZ D_SaveS3M34 - - Or DL, 128 ; Effect. - -D_SaveS3M34: - ; Check if note in range. - Mov AX, [ES:BX+1] - Mov [ES:BX+6], AX ; BX+6=note, BX+7=ins. - - Cmp AL, 120 - JAE D_SaveS3M55 - - Test DH, 11h - JZ D_SaveS3M55 - Test DH, 22h - JZ D_SaveS3M55 - - Push DS - - Call Music_GetSongSegment - Mov DS, AX - Test Byte Ptr [DS:2Ch], 4 - JZ D_SaveS3M54 - - Push BX - Push DI - - Mov DI, BX - - Mov BL, [ES:BX+7] - And BX, 0FFh ; BX = ins. - JZ D_SaveS3M52 - - Add BX, BX - Mov BX, [BX+64712-2] ; BX points to instrument. - Mov AL, [ES:DI+1] - And AX, 0FFh - Add AX, AX - Add BX, AX - Mov AX, [BX+40h] - - Mov [ES:DI+6], AX - -D_SaveS3M52: - Pop DI - Pop BX - -D_SaveS3M54: - Pop DS - -D_SaveS3M55: - Mov AL, DL - - Test DL, 32 ; Do note? - JZ D_SaveS3M35 - - Mov AH, [ES:BX+6] ; AH = note. - Cmp AH, 0FDh - JAE D_SaveS3M35 - Cmp AH, 12 - JB D_SaveS3M36 ; Note out of range. - Cmp AH, 108 - JAE D_SaveS3M36 - -D_SaveS3M35: - StosB ; Store mask. - Test DL, 32 - JZ D_SaveS3M39 - - Mov AL, 0FFh - Test DH, 11h - JZ D_SaveS3M37 - - Cmp AH, 0FDh - JE D_SaveS3M37 - - Mov AL, 0FEh - Cmp AH, 0FEh - JAE D_SaveS3M37 - - Mov AL, AH - Xor AH, AH - Sub AL, 12 - Mov CX, 12*256+4 - Div CH ; AL = octave, AH = note. - ShL AL, CL - Or AL, AH - -D_SaveS3M37: - Mov AH, 0 - Test DH, 22h - JZ D_SaveS3M50 - - Mov AH, [ES:BX+7] - -D_SaveS3M50: - StosW - -D_SaveS3M39: - Test DL, 64 - JZ D_SaveS3M40 - - Mov AL, [ES:BX+3] - StosB - -D_SaveS3M40: - Test DL, 128 - JZ D_SaveS3M41 - - Mov AX, [ES:BX+4] - -; Cmp AL, 'H'-'@' -; JE D_SaveVibDepth1 -; Cmp AL, 'U'-'@' -; JE D_SaveVibDepth2 -; - Cmp AX, 'S'-'@'+9100h - JE D_SaveS3MSurround - - Cmp AL, 'V'-'@' - JE D_SaveS3M46 - Cmp AL, 'X'-'@' - JE D_SaveS3M46 - - Cmp AL, 'C'-'@' - JNE D_SaveS3M47 - - Mov AL, AH - Xor AH, AH - Mov CX, 10*256+4 - Div CH - ShL AL, CL - Or AH, AL - Mov AL, 'C'-'@' - Jmp D_SaveS3M47 - -D_SaveS3MSurround: - Mov AX, 'X'-'@'+0A400h - Jmp D_SaveS3M47 - -D_SaveS3M46: - ShR AH, 1 - -D_SaveS3M47: - StosW - -D_SaveS3M41: - Jmp D_SaveS3M33 - -; D_SaveVibDepth1: ; Command H -; Mov CL, AH -; And AH, 0Fh -; And CL, 0F0h -; Inc AH -; ShR AH, 1 -; Or AH, CL -; -; StosW -; Jmp D_SaveS3M33 -; -;D_SaveVibDepth2: -; Mov CL, AH -; And AH, 0Fh ; AH = depth -; Inc AH -; ShR AH, 1 -; And CL, 0F0h -; Or AH, CL -; -; StosW -; Jmp D_SaveS3M33 - -D_SaveS3MPanError: - Mov AL, 0FFh - Mov Byte Ptr [ES:BX+3], AL ; Volume - - Push Offset D_SaveS3M28_2 - Push SI - Push DI - Mov SI, Offset PanningErrorMsg - Mov DI, (4+33*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M30: - Push Offset D_SaveS3M33 - Push SI - Push DI - Mov SI, Offset ChannelErrorMsg - Mov DI, (4+31*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M36: - Push Offset D_SaveS3M33 - Push SI - Push DI - Mov SI, Offset NoteRangeMsg - Mov DI, (4+32*80)*2 - Jmp D_SaveS3MFormatError - -D_SaveS3M23: - StosB - Pop CX - Loop D_SaveS3M22 - - Pop CX - Pop BX - Sub CX, 64 - JNC D_SaveS3M21 - - Neg CX - Xor AL, AL - Rep StosB - -D_SaveS3M21: - Mov CX, DI - Sub CX, 30000 - Mov [ES:30000], CX ; Pattern length. - - Push ES - Pop DS - Mov DX, 30000 - Call D_SaveBlock - - Pop DX - - Add BP, CX - AdC DX, 0 - - Pop AX - Inc AX - Cmp AX, [ES:24h] - JB D_SaveS3M19 - -;----------------------------------- - ; Now to save samples. - Mov DI, 10000 - Mov CX, 200 ; ES:10000 contains sample pointers. - Xor AX, AX - Rep StosW - -D_SaveS3M42: - Inc AX - Push AX - - Xor CX, CX - Call Music_GetSampleLocation ; Gets DS:SI, ECX - JC D_SaveS3M43 - - JZ D_SaveS3M8Bit - - Add ECX, ECX - -D_SaveS3M8Bit: - Push DS - Push AX - - Push CS - Pop DS - Mov DI, (4+19*80)*2 - Mov SI, Offset SampleMsg - Mov AH, 5 - Call S_DrawString - - Pop AX - Pop DS - - ; Shove message on screen.... - Add BP, 15 ; Align on next 16-byte boundary. - AdC DX, 0 - And BP, Not 15 - - Push ECX - Push DX - Push AX ; AX = sample num - - Mov DI, AX - Dec DI - Add DI, DI - Add DI, DI - Add DI, 10000 - Mov AX, BP - StosW - Mov AX, DX - StosW - - - Mov AX, 4200h - Mov CX, DX - Mov DX, BP - Int 21h ; Set file offset. - - Pop AX - - Call D_SaveSampleDataConvert - - Pop DX - Pop ECX - Add BP, CX - PushF - ShR ECX, 16 - PopF - AdC DX, CX - -D_SaveS3M43: - Pop AX - Cmp AX, [ES:22h] - JB D_SaveS3M42 - -;----------------------------------- - - Push CS - Pop DS - Assume DS:Disk - - Mov DI, (4+20*80)*2 - Mov SI, Offset HeaderMsg - Mov AH, 5 - Call S_DrawString - - Mov AX, 4200h - Xor CX, CX - Xor DX, DX - Int 21h ; Go back to start of file. - - Push ES - Pop DS - Xor DX, DX - Pop CX ; CX = length of header. (previously BP) - Call D_SaveBlock - - ; To do sample pointers now. - Mov SI, 10000 - Xor BP, BP - -D_SaveS3M44: - Mov DI, BP - Add DI, DI - Add DI, 60h ; Length of header - Add DI, [DS:20h] ; Past Orders, DS:SI points to parasample - - Xor CX, CX - Mov DX, [DI] - SHLD CX, DX, 4 - ShL DX, 4 - - Add DX, 0Dh - - Mov AX, 4200h - Int 21h ; file re-position. - - LodsW - Mov DX, AX - LodsW ; AX:DX contains sample pointer. - - ShRD DX, AX, 4 - ShR AX, 4 ; AX:DX contains para pointer. - - Mov [DS:0], AL - Mov [DS:1], DX - Mov CX, 3 - Xor DX, DX - Call D_SaveBlock - - Inc BP - Cmp BP, [DS:22h] - JB D_SaveS3M44 - - Mov AH, 3Eh ; Close file. - Int 21h - - Push CS - Pop DS - Assume DS:Disk - - Mov DI, (4+21*80)*2 - Mov SI, Offset CompleteMsg - Mov AH, 5 - Call S_DrawString - - Cmp SaveFormatError, 0 - JE D_SaveS3M_NoKeyWait - - Call K_ClearKeyboardQueue - -D_SaveS3MKeyWait: - Call K_GetKey - Test CH, 1 - JZ D_SaveS3MKeyWait - -D_SaveS3M_NoKeyWait: - Jmp EndSaveModule - -D_SaveS3MFormatError: - Push AX - Push DS - - Push CS - Pop DS - Assume DS:Disk - - Mov SaveFormatError, 1 - Mov AH, 4 - Call S_DrawString - - Pop DS - Pop AX - Pop DI - Pop SI - RetN - -EndP D_SaveS3M - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveFileITModule Far - - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_SaveITList - - Mov AX, 5 - Ret - -EndP D_SaveFileITModule - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveFileS3MModule Far - - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_SaveS3MList - - Mov AX, 5 - Ret - -EndP D_SaveFileS3MModule - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Write module functions +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +Proc WriteITSampleBlock + + PushAD ; BX = file handle. + Push DS + + Mov DS, CS:DiskDataArea + + Mov DX, [DS:1996] + Mov CX, [DS:1998] + Mov AX, 4200h + Int 21h + + Mov AX, 80 + Mul Word Ptr [DS:24h] + Mov CX, AX + + Mov DX, 2000 + Call D_SaveBlock + +WriteITSampleBlock1: + Pop DS + PopAD + Ret + +EndP WriteITSampleBlock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +NUMS3MCHANNELS EQU 16 + +BitLUT Label Byte + DB 1, 2, 3, 3, 4, 4, 4, 4 + DB 5, 5, 5, 5, 5, 5, 5, 5 + DB 4, 4, 4, 4, 3, 3, 2 + +BitLUT16 Label Byte + DB 1, 10 SHL 3 + 3, 11 SHL 3 + 5, 11 SHL 3 + 3 + DB 3 DUP (12 SHL 3 + 5), 12 SHL 3 + 3 + DB 7 DUP (13 SHL 3 + 5), 13 SHL 3 + 3 + + DB 13 SHL 3 + 4, 7 DUP (13 SHL 3 + 5) + DB 12 SHL 3 + 4, 3 DUP (12 SHL 3 + 5) + DB 11 SHL 3 + 4, 11 SHL 3 + 5, 10 SHL 3 + 4, 2 + + +Proc D_SaveIT Far + + + Call PE_SaveCurrentPattern + + Call D_UpdateFileName + + Push CS + Pop DS + Assume DS:Disk + + Mov NoSaveError, 0 + + Mov AH, 3Ch + Xor CX, CX ; File type is normal (archive) + Mov DX, Offset SaveFileName ; DS:DX points to filename + Int 21h + JNC D_SaveIT3 + + Call PE_RestoreCurrentPattern + Jmp D_NoSaveMessage + +D_SaveIT3: + Mov BX, AX ; BX = handle + + Mov ES, DiskDataArea + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing ; DS = MusicData + + Xor SI, SI + Xor DI, DI + Mov CX, 192 + Rep MovsB ; Get header. + + ; Now to figure out the + ; orders. + Mov SI, 511 + StD + Mov CX, 256 + +D_SaveIT4: + LodsB + Cmp AL, 0FFh + LoopE D_SaveIT4 + + ClD + + Add CX, 2 + Mov [ES:20h], CX + Dec CX + + Mov SI, 256 + Rep MovsB ; Transfer orders. + Mov AL, 0FFh + StosB + +; Mov AX, 0 +; Test Byte Ptr [DS:2Ch], 4 +; JZ D_SaveIT6 +; + Call Music_GetNumberOfInstruments +; +; D_SaveIT6: + Mov [ES:22h], AX ; Number of instruments + + Call Music_GetNumberOfSamples + Mov [ES:24h], AX ; Number of samples + + Call PE_GetMaxPattern + Inc AX + Mov [ES:26h], AX ; Number of patterns. + + Xor CX, CX ; CX:DX = 'long' offsets. + Mov DX, 0C0h + Add DX, [ES:20h] + Mov AX, [ES:22h] + ShL AX, 2 + Add DX, AX + Mov AX, [ES:24h] + ShL AX, 2 + Add DX, AX + Mov AX, [ES:26h] + ShL AX, 2 + Add DX, AX + + Mov DWord Ptr [ES:36h], 0 + Mov Word Ptr [ES:2Eh], 4 ; Row hilight information + + Push DS + + Push Pattern + Pop DS + Assume DS:Pattern + + Mov AX, Word Ptr [RowHilight1] + + Pop DS + Assume DS:Nothing + + Mov [ES:1Eh], AX + + + Call GetTimerCounter + Sub EAX, EditTimer + + Cmp TimerData, 0 + JE NoTimerData + + Or Byte Ptr [ES:2Eh], 2 ; Contains timer information + + Push ES ; Put time into table. + Push DI + + Mov ES, TimerData + Mov DI, NumTimerData + ShL DI, 3 + Add DI, 4 + StosD + Add DI, 2 + + Add DX, DI ; Long offset progress. + AdC CX, 0 + + Pop DI + Pop ES + +NoTimerData: +; OK.. check for MIDI config save. + Test Byte Ptr [DS:2Ch], 128 + JZ D_SaveITNoMIDIConfig1 + + Add DX, 4896 ; MIDI Config size + AdC CX, 0 + Or Byte Ptr [ES:2Eh], 8 ; MIDI Config. + +D_SaveITNOMIDIConfig1: + + Add EAX, [ES:3Ch] + Xor EAX, 'JTHL' + RoR EAX, 4 + Neg EAX + RoL EAX, 7 + Xor EAX, 'ITRK' + + Mov [ES:3Ch], EAX + + Call Msg_GetMessageLength + Cmp AX, 1 + JE D_SaveITMsg1 + + Or Byte Ptr [ES:2Eh], 1 + Mov Word Ptr [ES:3Ah], 0 + Mov [ES:38h], DX + Mov [ES:36h], AX + Add DX, AX + +D_SaveITMsg1: + Mov BP, [ES:22h] ; Number of instruments + + Mov AX, 214h + + Cmp CS:SaveFormat, 0 + JE D_SaveNewFormat + + Inc AX + Cmp CS:SaveFormat, 3 + JE D_SaveNewFormat + + Mov AX, 200h + +D_SaveOldIT2_1: + Test BP, BP + JNZ D_SaveNewFormat + + Mov AX, 100h + +D_SaveNewFormat: + Inc BP + Mov Word Ptr [ES:28h], TRACKERVERSION + Mov [ES:2Ah], AX + And EBP, 0FFFFh + +D_SaveIT7: + Dec BP + JZ D_SaveIT8 + + Mov SI, [DS:EBP+EBP+64710] + Test Byte Ptr [SI+1D4h], 80h + JZ D_SaveIT216 + + Mov Word Ptr [ES:2Ah], 216h + +D_SaveIT216: + Mov AX, DX + StosW + Mov AX, CX + StosW + Add DX, 554 + AdC CX, 0 + + Jmp D_SaveIT7 + +D_SaveIT8: + Mov BP, [ES:24h] ; Number of samples + Inc BP + Mov [ES:1996], DX ; Store sample position. + Mov [ES:1998], CX + +D_SaveIT9: + Dec BP + JZ D_SaveIT10 + + Mov AX, DX + StosW + Mov AX, CX + StosW + + Add DX, 80 + AdC CX, 0 + + Jmp D_SaveIT9 + +D_SaveIT10: + + Xor BP, BP + +D_SaveIT11: + Cmp BP, [ES:26h] ; Number of patterns + JAE D_SaveIT12 + + Push DS + + Mov AX, BP + Call Music_GetPattern ; DS:SI has pattern + + Mov AX, DS + Cmp AX, Music + JE D_SaveIT1 + + Mov AX, DX + StosW + Mov AX, CX + StosW + + Add DX, [DS:SI] + AdC CX, 0 + Add DX, 8 ; pattern header length = 8. + AdC CX, 0 + + Jmp D_SaveIT22 + +D_SaveIT1: + Xor EAX, EAX + StosD + +D_SaveIT22: + Pop DS + + Inc BP + Jmp D_SaveIT11 + +D_SaveIT12: + ; CX:DX now point to first sample data. + Push CX + Push DX + + Push DS + + Push DI + + Push CS + Pop DS + Mov DI, (4+17*80)*2 + Mov SI, Offset HeaderMsg + Mov AH, 5 + Call S_DrawString + + Pop CX ; CX = length of header. + + Push ES + Pop DS + + Xor DX, DX + Call D_SaveBlock ; Header. + + Test Byte Ptr [DS:2Eh], 2 ; Time information? + JZ D_SaveITTimeData + + Push DS + + Push CS + Pop DS + + Mov CX, 2 + Mov DX, Offset NumTimerData + Inc [DS:NumTimerData] + Call D_SaveBlock + Mov CX, [DS:NumTimerData] + Dec [DS:NumTimerData] + ShL CX, 3 + Mov DS, [DS:TimerData] + Xor DX, DX + Call D_SaveBlock + + Pop DS + +D_SaveITTimeData: + Test Byte Ptr [DS:2Ch], 128 + JZ D_SaveITMIDIConfig + + Push DS + + Mov CX, 4896 + Xor DX, DX + Call Music_GetMIDIDataArea ; Gets DS + Call D_SaveBlock + + Pop DS + +D_SaveITMIDIConfig: + ; Message? + Test Byte Ptr [DS:2Eh], 1 + JZ D_SaveITMsg2 + + Mov CX, [DS:36h] + Push DS + Call Msg_GetMessageOffset + Call D_SaveBlock + Pop DS + +D_SaveITMsg2: + Push CS + Pop DS + Mov DI, (4+18*80)*2 + Mov SI, Offset InstrumentHeaderMsg + Mov AH, 5 + Call S_DrawString + + Pop DS + Cmp Word Ptr [ES:22h], 0 + JE D_SaveIT13 + + Mov AX, 554 + Mul Word Ptr [ES:22h] + Mov DX, 512 + Mov CX, AX + + Call D_SaveBlock ; Instrument headers... + +D_SaveIT13: + Push DS + + Push CS + Pop DS + Mov DI, (4+19*80)*2 + Mov SI, Offset SampleHeaderMsg + Mov AH, 5 + Call S_DrawString + + Pop DS ; DS = song data segment + Mov SI, 55912 ; Start of samples in mem. + Mov AX, 80 + Mul Word Ptr [ES:24h] + Mov DI, 2000 + Mov CX, AX + Rep MovsB + + Pop DX + Pop CX ; CX:DX = sample point. + + Mov BP, [ES:24h] ; Number of samples. + Mov SI, 2000 + Inc BP + +D_SaveIT14: + Dec BP + JZ D_SaveIT16 + Mov AL, [ES:SI+12h] + Mov AH, 1 + + Cmp CS:SaveFormat, 3 + JNE D_SaveNoDD + + Or AH, 4 + +D_SaveNoDD: + Test AL, 1 + JZ D_SaveIT15 + + Or AL, 8 + Cmp CS:SaveFormat, 2 + JNE D_SaveIT214_1 + + And AL, Not 8 + +D_SaveIT214_1: + Mov [ES:SI+48h], DX + Mov [ES:SI+4Ah], CX + + Test AL, 2 + Mov [ES:SI+12h], AL + Mov [ES:SI+2Eh], AH + Mov EAX, [ES:SI+30h] + JZ D_SaveIT16Bit + + Add EAX, EAX + +D_SaveIT16Bit: + Add DX, AX + PushF + ShR EAX, 16 + PopF + AdC CX, AX ; Advance sample pointer. + +D_SaveIT15: + Add SI, 80 + Jmp D_SaveIT14 + +D_SaveIT16: + Call WriteITSampleBlock + + Xor BP, BP + +D_SaveIT17: + Push DS + + Push CS + Pop DS + Mov DI, (4+20*80)*2 + Mov SI, Offset PatternMsg + Mov AH, 5 + Push BP + Call S_DrawString + Pop AX + + Call Music_GetPattern + Mov DX, DS + Cmp DX, Music + JE D_SaveIT2 + + Mov DX, SI + Mov CX, [DS:SI] + Add CX, 8 + Call D_SaveBlock + +D_SaveIT2: + Pop DS + Inc BP + Cmp BP, [ES:26h] + JB D_SaveIT17 + +; Setup compression block + Push DS + + Push CS + Pop DS + Mov SI, Offset BitLUT + + Mov DI, 10240 + Mov CX, 16/2 + Rep MovsW + +; Setup table. + + Mov CX, 16 + Mov AL, 6 + Rep StosB + + Mov CX, 28 + Inc AX + Rep StosB + + Mov CX, 64 + Inc AX + Rep StosB + + Mov CX, 8 + Inc AX + Rep StosB + + Mov CX, 64 + Dec AX + Rep StosB + + Mov CX, 29 + Dec AX + Rep StosB + + Mov CX, 16 + Dec AX + Rep StosB + + Mov CX, 15 + Sub SI, 8 + Rep MovsB + +; 16 bit Main LUT + + Mov SI, Offset BitLUT16 + Mov CX, 16 + Rep MovsB + + Mov CX, 15 + Mov AL, 14 SHL 3 + 5 + Rep StosB + Mov AL, 14 SHL 3 + 3 + StosB + + Mov CX, 31 + Mov AL, 15 SHL 3 + 5 + Rep StosB + Mov AL, 15 SHL 3 + 3 + StosB + + Mov CX, 63 + Mov AL, 16 SHL 3 + 5 + Rep StosB + Mov AL, 16 SHL 3 + 3 + StosB + + Inc AX +; Mov AL, 16 SHL 3 + 4 + StosB + Mov CX, 63 + Inc AX +; Mov AL, 16 SHL 3 + 5 + Rep StosB + + Mov AL, 15 SHL 3 + 4 + StosB + Mov CX, 31 + Mov AL, 15 SHL 3 + 5 + Rep StosB + + Mov AL, 14 SHL 3 + 4 + StosB + Mov CX, 15 + Mov AL, 14 SHL 3 + 5 + Rep StosB + + Mov CX, 16 + Rep MovsB + +; 16 bit LUT 1, for 16-bit samples with high byte = 0 + + Mov SI, Offset BitLUT + Mov CX, 16 + Rep MovsB + + Mov CX, 16 + Mov AL, 6 + Rep StosB ; AL = 6 from before + + Mov CX, 24 + Inc AX + Rep StosB + + Mov CX, 64 + Inc AX + Rep StosB + + Mov CX, 128 + Inc AX + Rep StosB + +; 16-Bit LUT 2, for 16-bit samples with high byte = 0xFF + + Mov CX, 16 + Inc AX + Rep StosB + + Mov CX, 128 + Dec AX + Rep StosB + + Mov CX, 64 + Dec AX + Rep StosB + + Mov CX, 25 + Dec AX + Rep StosB + + Mov CX, 16 + Dec AX + Rep StosB + + Mov CX, 15 + Sub SI, 8 + Rep MovsB + + Mov CX, 256-8 + Xor AX, AX + Rep StosB + + Mov CX, 16 + Inc AX + Rep StosB + + Mov CX, 256-8+256 + Dec AX + Rep StosB + + Pop DS + + Xor BP, BP ; BP = sample number. + Mov DI, 2000+48h + +D_SaveIT18: + Push DS + Push DI + + Xor CX, CX + Xor DX, DX + Mov AX, 4201h + Int 21h + + Mov [ES:DI], AX + Mov [ES:DI+2], DX + + Mov SI, BP + Add SI, SI + Mov SI, [64912+SI] ; DS:SI points to sample head. + + Test Byte Ptr [SI+12h], 1 ; Check if sample is present. + JZ D_SaveIT19 + Cmp DWord Ptr [SI+30h], 0 ; For bodgy sample crap. + JZ D_SaveIT19 + +D_SaveIT21: + Push DS ; DS:DX points to sample... + Push SI + + Push CS + Pop DS + Mov DI, (4+21*80)*2 + Mov SI, Offset SampleMsg + Mov AX, BP + Inc AX + Push AX + Mov AH, 5 + Call S_DrawString + Pop AX + + Pop SI + Pop DS ; Sample encoding to go here.. + ; But sample position needs to + ; be recoded then... + Cmp CS:SaveFormat, 2 + JNE D_SaveSampleDataCompressedCall + + Call D_SaveSampleData + Jmp D_SaveIT19 + +D_SaveSampleDataCompressedCall: + Call D_SaveSampleDataCompressed + +D_SaveIT19: + Pop DI + Pop DS + + Add DI, 80 + + Inc BP + Cmp BP, [ES:24h] + JB D_SaveIT18 + + Call WriteITSampleBlock + + Mov AH, 3Eh ; Close file + Int 21h + + Push CS + Pop DS + Mov DI, (4+23*80)*2 + Mov SI, Offset CompleteMsg + Mov AH, 5 + Call S_DrawString + +EndSaveModule: + Mov DX, Offset SaveFileName + Call D_DeleteIfError + + Call PE_RestoreCurrentPattern + + Cmp NoSaveError, 0 + JNE SaveModuleError + + Call PEResetModified + +SaveModuleError: + Mov AX, 1 + Ret + +EndP D_SaveIT + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveS3M Far + + Call PE_SaveCurrentPattern + Call D_UpdateFileName + + Mov BP, 60h ; BP = length of header. +; Call PE_StoreCurrentPattern + + Push CS + Pop DS + Assume DS:Disk + + Mov SaveFormatError, 0 + + Mov NoSaveError, 0 + + Mov AH, 3Ch + Xor CX, CX ; File type is normal (archive) + Mov DX, Offset SaveFileName ; DS:DX points to filename + Int 21h + JNC D_SaveS3M1 + + Call PE_RestoreCurrentPattern + Jmp D_NoSaveMessage + +D_SaveS3M1: + Mov BX, AX + + Mov ES, DiskDataArea + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing ; DS = MusicData + + Mov SI, 4 + Xor DI, DI + Mov CX, 26/2 + Rep MovsW + Xor AX, AX + StosW + Mov AX, 1Ah+16*256 ; St3 module identification. + StosW + Xor AX, AX + StosW + ; Now to figure out the + ; orders. + Mov SI, 511 + StD + Mov CX, 256 + +D_SaveS3M2: + LodsB + Cmp AL, 0FFh + LoopE D_SaveS3M2 + + ClD + + Inc CX + Mov AX, CX + Inc AX ; Number of orders. + Add BP, AX + StosW + + Call Music_GetNumberOfSamples + Add BP, AX + Add BP, AX + StosW ; Number of samples. + + Call PE_GetMaxPattern + Inc AX + Add BP, AX + Add BP, AX + Cmp AX, 100 + JBE D_SaveS3M4 + + Mov AX, 100 + + Push Offset D_SaveS3M4 + Push SI + Push DI + Mov SI, Offset TooManyPatternsMsg + Mov DI, (4+23*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M4: + StosW ; Number of patterns + + ; Flags... 8 = vol0opt on. + Mov AX, [DS:2Ch] + And AX, 2 + ShL AX, 2 + StosW ; Flags stored. + + Mov AX, 3000h+TRACKERVERSION + StosW ; Impulse Tracker + + Mov AX, 2 + StosW ; Standard unsigned samples. + + Mov EAX, 'MRCS' + StosD ; ID done. + + Mov AH, [DS:2Ch] + Test AH, 4 + JZ D_SaveS3MNoInsError + + Push Offset D_SaveS3MNoInsError + Push SI + Push DI + Mov SI, Offset ST3InstrumentErrorMsg + Mov DI, (4+29*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3MNoInsError: + Mov AL, [DS:30h] + ShR AL, 1 + StosB + Mov AX, [DS:32h] ; Tempo and speed + StosW + Mov AL, [DS:31h] ; Mixing volume + Mov AH, [DS:2Ch] ; Grab stereo setting. + Cmp AL, 80h + JB D_SaveNoMixOverflow + + Mov AL, 7Fh + +D_SaveNoMixOverflow: + ShL AL, 1 + ShR AX, 1 + StosB + + Mov AX, 252*256 + StosW + Xor AX, AX + StosW + + Call GetTimerCounter + Sub EAX, EditTimer + Add EAX, [DS:3Ch] + + Xor EAX, 'JTHL' + RoR EAX, 4 + Neg EAX + RoL EAX, 7 + Xor EAX, 'ITRK' + + StosD + + Xor AX, AX + StosW + + Mov SI, 256 ; Orders. + Mov DI, 60h + JCXZ D_SaveS3M3 + +D_SaveS3M5: + LodsB + Cmp AL, 0FEh + JAE D_SaveS3M6 + Cmp AL, 100 + JB D_SaveS3M6 + + Mov AL, 0FFh ; So that pattern numbers >= 100 aren't listed + +D_SaveS3M6: + StosB + Loop D_SaveS3M5 + +D_SaveS3M3: + Mov AL, 0FFh + StosB + + ; Do channel settings. + Push BX + + Mov BX, BP + + Mov SI, 40h + Mov DI, SI + Sub BX, DI + + Mov CX, 32 + Xor AH, AH + +D_SaveS3M7: + LodsB + Test AL, 80h + JNZ D_SaveS3M9 + + Cmp AL, 64 + JBE D_SaveS3M8 + + Mov AL, 32 ; For surround. + +D_SaveS3M8: + ; Convert 0->64 to 0->15 + Mov DL, AL + ShR DL, 1 + Sub DL, 1 + AdC DL, 0 + ShR DL, 1 + Or DL, 32 ; Reqd... + + Mov AL, AH + + And AL, 1 + ShL AL, 3 + Mov DH, AH + ShR DH, 1 + Or AL, DH + + Inc AH + Jmp D_SaveS3M10 + +D_SaveS3M9: ; Muted/nonexistant + Mov AL, 0FFh + Mov DL, 0 + +D_SaveS3M10: + Mov [ES:BX+DI], DL + StosB + Loop D_SaveS3M7 + + Pop BX + + Add BP, 20h + + ; Check that channel volumes are all 64... + + Mov CX, 32 + Mov SI, 80h + +D_SaveS3M11: + LodsB + Cmp AL, 64 + JNE D_SaveS3M12 + Loop D_SaveS3M11 + Jmp D_SaveS3M13 + +D_SaveS3M12: + Push Offset D_SaveS3M13 + Push SI + Push DI + Mov SI, Offset ChannelVolumeErrorMsg + Mov DI, (4+24*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M13: + Test Byte Ptr [DS:2Ch], 8 + JZ D_SaveS3M15 + + Push Offset D_SaveS3M15 + Push SI + Push DI + Mov SI, Offset LinearSlideMsg + Mov DI, (4+25*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M15: + Push DS + + Push CS + Pop DS + Mov DI, (4+17*80)*2 + Mov SI, Offset SampleHeaderMsg + Mov AH, 5 + Call S_DrawString + + Pop DS + Assume DS:Nothing + + Push BP ; BP = length of header. + + Xor AX, AX ; AX = sample number. + Xor DX, DX ; DX:BP = file position. + ; BX = file handle + +;-------------------------------------- + +D_SaveS3M14: + Push AX + + Add BP, 15 ; Align on next 16-byte boundary. + AdC DX, 0 ; Unnecessary.. but who cares. + ; Now to store pointer. + And BP, Not 15 + + Push DX + + Mov DI, AX + Add DI, DI + + Push DI + + Add DI, 60h + Add DI, [ES:20h] + + ; Move file pointer. + Mov AX, 4200h + Mov CX, DX + Mov DX, BP + Int 21h + + SHRD AX, DX, 4 + Mov [ES:DI], AX + + ; Set up sample block at ES:1024. + Pop DI + Push BX + + Mov BX, [DS:64912+DI] ; DS:BX points to sample header. + + Mov DI, 1024 + Mov AL, [BX+12h] + Mov DL, AL + And AL, 1 + + StosB + + Mov SI, BX + Add SI, 4 + Mov CX, 12 + Rep MovsB ; filename + + Xor AX, AX + StosB + StosW + + Mov SI, BX + Add SI, 30h + Mov CX, 6 + Rep MovsW ; Length/Loopbeg/Loopend. + + Mov AL, [DS:BX+13h] + StosW ; Default sample volume. + + Mov AH, DL + Mov CL, DL + ShR AH, 4 + And AX, 100h + ShL CL, 1 + And CL, 4 + Or AH, CL + + StosW ; Loop, 16 Bit & no 'pack' + + MovsW + MovsW + + Mov CX, 6 + Xor AX, AX + Rep StosW + ; Now for sample name. + + Mov SI, BX + Add SI, 14h + Mov CX, 25 + +D_SaveS3M56: + LodsB + And AL, AL + JNZ D_SaveS3M57 + + Mov AL, 32 + +D_SaveS3M57: + StosB + Loop D_SaveS3M56 + + Xor AX, AX + StosB + StosW + + Mov EAX, 'SRCS' + StosD ; OK header is done... + + Test DL, 16+32 + JZ D_SaveS3M16 ; No loop on. + + Test DL, 32 + JNZ D_SaveS3M51 + + Test DL, 64 + JZ D_SaveS3M16 + +D_SaveS3M51: + Push Offset D_SaveS3M16 + Push SI + Push DI + Mov SI, Offset LoopMsg + Mov DI, (4+27*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M16: + Cmp Byte Ptr [DS:BX+11h], 64 + JE D_SaveS3M17 + + Push Offset D_SaveS3M17 + Push SI + Push DI + Mov SI, Offset SampleVolumeMsg + Mov DI, (4+26*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M17: + Cmp Byte Ptr [DS:BX+4Dh], 0 + JE D_SaveS3M18 + + Push Offset D_SaveS3M18 + Push SI + Push DI + Mov SI, Offset SampleVibratoMsg + Mov DI, (4+28*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M18: ; Write block. + Pop BX + Push DS + + Push ES + Pop DS + Mov DX, 1024 + Mov CX, 50h + Call D_SaveBlock + + Pop DS + Pop DX + + Add BP, 50h ; Advance file pointer. + AdC DX, 0 + + Pop AX + Inc AX + Cmp AX, [ES:22h] + JB D_SaveS3M14 ; Sample headers done. + +;----------------------------------- + ; Pattern data. + Xor AX, AX ; Start with pattern 0 + +D_SaveS3M19: + Push AX + ; Shove message on screen.... + Add BP, 15 ; Align on next 16-byte boundary. + AdC DX, 0 ; Unnecessary.. but who cares. + ; Now to store pointer. + And BP, Not 15 + + Push DX + + Push AX ; AX for pattern msg... + + Mov DI, AX + Add DI, DI + + Add DI, 60h + Add DI, [ES:20h] + Mov CX, [ES:22h] + Add CX, CX + Add DI, CX + + ; Move file pointer. + Mov AX, 4200h + Mov CX, DX + Mov DX, BP + Int 21h + + SHRD AX, DX, 4 ; DX:AX = new file pointer location + Mov [ES:DI], AX + + Push CS + Pop DS + + Mov DI, (4+18*80)*2 + Mov SI, Offset PatternMsg + Mov AH, 5 + Call S_DrawString + + Pop AX ; AX = pattern. + Call Music_GetPattern ; DS:SI points to pattern. + + Mov CX, [SI+2] ; CX = length. + Cmp CX, 64 + JE D_SaveS3M20 + + Push Offset D_SaveS3M20 + Push SI + Push DI + Mov SI, Offset PatternLengthMsg + Mov DI, (4+30*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M20: + Push BX + + Push CX + + Mov DI, 20000 + Mov CX, 64 + +D_SaveS3M25: + Mov AX, 0FD00h ; Mask & note. + StosW + Mov AH, 0FFh ; instrument & volume. + StosW + Xor AH, AH + StosW + StosW + Loop D_SaveS3M25 + + Mov DI, 30002 + Add SI, 8 + + Pop CX + Push CX + +D_SaveS3M22: ; Pattern translation time. + Push CX + +D_SaveS3M33: + LodsB + And AL, AL + JZ D_SaveS3M23 + + Mov DL, AL + And AX, 7Fh + Dec AX + Mov CL, 3 + ShL AX, CL + Mov BX, AX + Add BX, 20000 ; ES:BX points to old information. + ; Decode row into area. + + Mov DH, [ES:BX] + + Test DL, 80h + JZ D_SaveS3M24 + + LodsB ; Mask + Mov [ES:BX], AL + Mov DH, AL + +D_SaveS3M24: + Test DH, 1 + JZ D_SaveS3M26 + + LodsB + Mov [ES:BX+1], AL + +D_SaveS3M26: + Test DH, 2 + JZ D_SaveS3M27 + + LodsB + Mov [ES:BX+2], AL + +D_SaveS3M27: + Test DH, 4 + JZ D_SaveS3M28 + + LodsB + Cmp AL, 64 + JA D_SaveS3MPanError + +D_SaveS3M28_2: + Mov [ES:BX+3], AL ; Volume + +D_SaveS3M28: + Test DH, 8 + JZ D_SaveS3M29 + + LodsW ; Effect+value. + Mov [ES:BX+4], AX + +D_SaveS3M29: + And DL, 7Fh + Cmp DL, NUMS3MCHANNELS + JA D_SaveS3M30 + + Dec DX + Test DH, 33h + JZ D_SaveS3M31 + + Or DL, 32 + +D_SaveS3M31: + Test DH, 44h + JZ D_SaveS3M32 + + Or DL, 64 ; Volume + +D_SaveS3M32: + Test DH, 88h + JZ D_SaveS3M34 + + Or DL, 128 ; Effect. + +D_SaveS3M34: + ; Check if note in range. + Mov AX, [ES:BX+1] + Mov [ES:BX+6], AX ; BX+6=note, BX+7=ins. + + Cmp AL, 120 + JAE D_SaveS3M55 + + Test DH, 11h + JZ D_SaveS3M55 + Test DH, 22h + JZ D_SaveS3M55 + + Push DS + + Call Music_GetSongSegment + Mov DS, AX + Test Byte Ptr [DS:2Ch], 4 + JZ D_SaveS3M54 + + Push BX + Push DI + + Mov DI, BX + + Mov BL, [ES:BX+7] + And BX, 0FFh ; BX = ins. + JZ D_SaveS3M52 + + Add BX, BX + Mov BX, [BX+64712-2] ; BX points to instrument. + Mov AL, [ES:DI+1] + And AX, 0FFh + Add AX, AX + Add BX, AX + Mov AX, [BX+40h] + + Mov [ES:DI+6], AX + +D_SaveS3M52: + Pop DI + Pop BX + +D_SaveS3M54: + Pop DS + +D_SaveS3M55: + Mov AL, DL + + Test DL, 32 ; Do note? + JZ D_SaveS3M35 + + Mov AH, [ES:BX+6] ; AH = note. + Cmp AH, 0FDh + JAE D_SaveS3M35 + Cmp AH, 12 + JB D_SaveS3M36 ; Note out of range. + Cmp AH, 108 + JAE D_SaveS3M36 + +D_SaveS3M35: + StosB ; Store mask. + Test DL, 32 + JZ D_SaveS3M39 + + Mov AL, 0FFh + Test DH, 11h + JZ D_SaveS3M37 + + Cmp AH, 0FDh + JE D_SaveS3M37 + + Mov AL, 0FEh + Cmp AH, 0FEh + JAE D_SaveS3M37 + + Mov AL, AH + Xor AH, AH + Sub AL, 12 + Mov CX, 12*256+4 + Div CH ; AL = octave, AH = note. + ShL AL, CL + Or AL, AH + +D_SaveS3M37: + Mov AH, 0 + Test DH, 22h + JZ D_SaveS3M50 + + Mov AH, [ES:BX+7] + +D_SaveS3M50: + StosW + +D_SaveS3M39: + Test DL, 64 + JZ D_SaveS3M40 + + Mov AL, [ES:BX+3] + StosB + +D_SaveS3M40: + Test DL, 128 + JZ D_SaveS3M41 + + Mov AX, [ES:BX+4] + +; Cmp AL, 'H'-'@' +; JE D_SaveVibDepth1 +; Cmp AL, 'U'-'@' +; JE D_SaveVibDepth2 +; + Cmp AX, 'S'-'@'+9100h + JE D_SaveS3MSurround + + Cmp AL, 'V'-'@' + JE D_SaveS3M46 + Cmp AL, 'X'-'@' + JE D_SaveS3M46 + + Cmp AL, 'C'-'@' + JNE D_SaveS3M47 + + Mov AL, AH + Xor AH, AH + Mov CX, 10*256+4 + Div CH + ShL AL, CL + Or AH, AL + Mov AL, 'C'-'@' + Jmp D_SaveS3M47 + +D_SaveS3MSurround: + Mov AX, 'X'-'@'+0A400h + Jmp D_SaveS3M47 + +D_SaveS3M46: + ShR AH, 1 + +D_SaveS3M47: + StosW + +D_SaveS3M41: + Jmp D_SaveS3M33 + +; D_SaveVibDepth1: ; Command H +; Mov CL, AH +; And AH, 0Fh +; And CL, 0F0h +; Inc AH +; ShR AH, 1 +; Or AH, CL +; +; StosW +; Jmp D_SaveS3M33 +; +;D_SaveVibDepth2: +; Mov CL, AH +; And AH, 0Fh ; AH = depth +; Inc AH +; ShR AH, 1 +; And CL, 0F0h +; Or AH, CL +; +; StosW +; Jmp D_SaveS3M33 + +D_SaveS3MPanError: + Mov AL, 0FFh + Mov Byte Ptr [ES:BX+3], AL ; Volume + + Push Offset D_SaveS3M28_2 + Push SI + Push DI + Mov SI, Offset PanningErrorMsg + Mov DI, (4+33*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M30: + Push Offset D_SaveS3M33 + Push SI + Push DI + Mov SI, Offset ChannelErrorMsg + Mov DI, (4+31*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M36: + Push Offset D_SaveS3M33 + Push SI + Push DI + Mov SI, Offset NoteRangeMsg + Mov DI, (4+32*80)*2 + Jmp D_SaveS3MFormatError + +D_SaveS3M23: + StosB + Pop CX + Loop D_SaveS3M22 + + Pop CX + Pop BX + Sub CX, 64 + JNC D_SaveS3M21 + + Neg CX + Xor AL, AL + Rep StosB + +D_SaveS3M21: + Mov CX, DI + Sub CX, 30000 + Mov [ES:30000], CX ; Pattern length. + + Push ES + Pop DS + Mov DX, 30000 + Call D_SaveBlock + + Pop DX + + Add BP, CX + AdC DX, 0 + + Pop AX + Inc AX + Cmp AX, [ES:24h] + JB D_SaveS3M19 + +;----------------------------------- + ; Now to save samples. + Mov DI, 10000 + Mov CX, 200 ; ES:10000 contains sample pointers. + Xor AX, AX + Rep StosW + +D_SaveS3M42: + Inc AX + Push AX + + Xor CX, CX + Call Music_GetSampleLocation ; Gets DS:SI, ECX + JC D_SaveS3M43 + + JZ D_SaveS3M8Bit + + Add ECX, ECX + +D_SaveS3M8Bit: + Push DS + Push AX + + Push CS + Pop DS + Mov DI, (4+19*80)*2 + Mov SI, Offset SampleMsg + Mov AH, 5 + Call S_DrawString + + Pop AX + Pop DS + + ; Shove message on screen.... + Add BP, 15 ; Align on next 16-byte boundary. + AdC DX, 0 + And BP, Not 15 + + Push ECX + Push DX + Push AX ; AX = sample num + + Mov DI, AX + Dec DI + Add DI, DI + Add DI, DI + Add DI, 10000 + Mov AX, BP + StosW + Mov AX, DX + StosW + + + Mov AX, 4200h + Mov CX, DX + Mov DX, BP + Int 21h ; Set file offset. + + Pop AX + + Call D_SaveSampleDataConvert + + Pop DX + Pop ECX + Add BP, CX + PushF + ShR ECX, 16 + PopF + AdC DX, CX + +D_SaveS3M43: + Pop AX + Cmp AX, [ES:22h] + JB D_SaveS3M42 + +;----------------------------------- + + Push CS + Pop DS + Assume DS:Disk + + Mov DI, (4+20*80)*2 + Mov SI, Offset HeaderMsg + Mov AH, 5 + Call S_DrawString + + Mov AX, 4200h + Xor CX, CX + Xor DX, DX + Int 21h ; Go back to start of file. + + Push ES + Pop DS + Xor DX, DX + Pop CX ; CX = length of header. (previously BP) + Call D_SaveBlock + + ; To do sample pointers now. + Mov SI, 10000 + Xor BP, BP + +D_SaveS3M44: + Mov DI, BP + Add DI, DI + Add DI, 60h ; Length of header + Add DI, [DS:20h] ; Past Orders, DS:SI points to parasample + + Xor CX, CX + Mov DX, [DI] + SHLD CX, DX, 4 + ShL DX, 4 + + Add DX, 0Dh + + Mov AX, 4200h + Int 21h ; file re-position. + + LodsW + Mov DX, AX + LodsW ; AX:DX contains sample pointer. + + ShRD DX, AX, 4 + ShR AX, 4 ; AX:DX contains para pointer. + + Mov [DS:0], AL + Mov [DS:1], DX + Mov CX, 3 + Xor DX, DX + Call D_SaveBlock + + Inc BP + Cmp BP, [DS:22h] + JB D_SaveS3M44 + + Mov AH, 3Eh ; Close file. + Int 21h + + Push CS + Pop DS + Assume DS:Disk + + Mov DI, (4+21*80)*2 + Mov SI, Offset CompleteMsg + Mov AH, 5 + Call S_DrawString + + Cmp SaveFormatError, 0 + JE D_SaveS3M_NoKeyWait + + Call K_ClearKeyboardQueue + +D_SaveS3MKeyWait: + Call K_GetKey + Test CH, 1 + JZ D_SaveS3MKeyWait + +D_SaveS3M_NoKeyWait: + Jmp EndSaveModule + +D_SaveS3MFormatError: + Push AX + Push DS + + Push CS + Pop DS + Assume DS:Disk + + Mov SaveFormatError, 1 + Mov AH, 4 + Call S_DrawString + + Pop DS + Pop AX + Pop DI + Pop SI + RetN + +EndP D_SaveS3M + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveFileITModule Far + + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_SaveITList + + Mov AX, 5 + Ret + +EndP D_SaveFileITModule + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveFileS3MModule Far + + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_SaveS3MList + + Mov AX, 5 + Ret + +EndP D_SaveFileS3MModule + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + diff --git a/IT_DISK.ASM b/it_disk.s similarity index 96% rename from IT_DISK.ASM rename to it_disk.s index 50ceec8..9bb9358 100644 --- a/IT_DISK.ASM +++ b/it_disk.s @@ -1,10940 +1,10940 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Disk Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -include switch.inc -include network.inc - - Jumps - .386 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Object1 BYTE Public 'Data' -EndS - -Segment Pattern BYTE Public 'Code' - Extrn BaseOctave:Byte - Extrn RowHilight1:Byte - Extrn RowHilight2:Byte -EndS - -Segment Pattern BYTE Public 'Code' - Extrn PatternDataArea:Word -EndS - -Segment Music BYTE Public 'Code' -EndS - - Extrn Display_GetDisplayWindowData:Far - - Extrn E_UnInitEMS:Far - Extrn E_MapEMSMemory:Far - Extrn E_GetEMSPageFrame:Far - - Extrn Glbl_F3:Far - Extrn Glbl_F4:Far - - Extrn I_GetSampleOffset:Far - Extrn I_GetInstrumentOffset:Far - Extrn I_ClearTables:Far - Extrn I_GetPresetEnvelopeOffset:Far - - Extrn K_UnInitKeyBoard:Far - Extrn K_IsAnyKeyDown:Far - Extrn K_ClearKeyBoardQueue:Far - Extrn K_GetKey:Far - - Extrn M_FunctionDivider:Far - Extrn M_Object1List:Far - - Extrn Music_PlayNote:Far - Extrn Music_PlaySample:Far - Extrn Music_ReleaseAllPatterns:Far - Extrn Music_ReleaseAllSamples:Far - Extrn Music_ReleaseSample:Far - Extrn Music_GetSongSegment:Far - Extrn Music_AllocateSample:Far - Extrn Music_ClearAllSampleNames:Far - Extrn Music_GetNumberOfSamples:Far - Extrn Music_GetNumberOfInstruments:Far - Extrn Music_GetPattern:Far - Extrn Music_AllocatePattern:Far - Extrn Music_AllocateSample:Far - Extrn Music_GetSampleLocation:Far - Extrn Music_ClearAllInstruments:Far - Extrn Music_GetInstrumentMode:Far - Extrn Music_AssignSampleToInstrument:Far - Extrn Music_SoundCardLoadSample:Far - Extrn Music_SoundCardLoadAllSamples:Far - Extrn Music_GetPitchTable:Far - Extrn Music_GetMIDIDataArea:Far - - Extrn Music_Stop:Far - Extrn Msg_ResetMessage:Far - Extrn Msg_GetMessageOffset:Far - Extrn Msg_GetMessageLength:Far - -IF TUTORIAL -ELSE - Extrn O1_LoadS3MList:Far - Extrn O1_LoadXMList:Far - Extrn O1_LoadMODList:Far - Extrn O1_LoadMTMList:Far - Extrn O1_Load669List:Far - Extrn O1_LoadITList:Far -ENDIF - Extrn O1_ConfirmOverWriteList:Far - Extrn O1_UnableToSaveList:Far - Extrn O1_SaveITList:Far - Extrn O1_SaveS3MList:Far - Extrn O1_ConfirmDelete:Far ; Updates Song name loader. - Extrn O1_ConfirmDelete2:Far - Extrn O1_ConfirmDelete3:Far - Extrn O1_ConfirmSaveRenameList:Far - Extrn O1_ConfirmResaveList:Far - Extrn O1_ConfirmDiscardList:Far - Extrn O1_InitInstrument:Far - Extrn O1_EditSampleName:Far - Extrn O1_OutOfSamplesList:Far - Extrn O1_EnableInstrumentMode:Far - Extrn O1_StereoSampleList:Far - - Extrn PE_TranslateXMPattern:Far - Extrn PE_Translate669Pattern:Far - Extrn PE_TranslateS3MPattern:Far - Extrn PE_TranslateMTMPattern:Far - Extrn PE_TranslateMODPattern:Far - Extrn PE_ResetOrderPattern:Far - Extrn PE_UnInitPatternEdit:Far - Extrn PEFunction_OutOfMemoryMessage:Far - Extrn PECheckModified:Far - Extrn PEResetModified:Far - Extrn PE_GetMaxPattern:Far - Extrn PE_ConvAX2Num:Far - Extrn PE_GetLastInstrument:Far - Extrn PE_GetPatternConfigOffset:Far - Extrn PE_SaveCurrentPattern:Far - Extrn PE_RestoreCurrentPattern:Far - - Extrn S_UnInitScreen:Far - Extrn S_GetDestination:Far - Extrn S_DrawString:Far - Extrn S_SaveScreen:Far - Extrn S_RestoreScreen:Far - Extrn S_GetGenerationTableOffset:Far - Extrn S_GenerateCharacters:Far - Extrn S_RedefineCharacters:Far - Extrn S_GetPaletteOffset:Far - Extrn S_SetPalette:Far - - Extrn SetInfoLine:Far - Extrn ClearInfoLine:Far - - Extrn Glbl_SetCurrentMode:Far - Extrn Glbl_F10:Far - - Extrn GetKeyboardLock:Far, GetTimerCounter:Far - Extrn MouseUpdateEnable:Far, MouseUpdateDisable:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global D_GetFileName:Far - Global D_SetDriveDirectoryFar:Far - - Global D_RestorePreShellDirectory:Far - Global D_GetPreShellDirectory:Far - - Global D_SaveInstrument:Far - Global D_ClearFileName:Far - - Global D_GetFormatType:Far - - Global D_LSCheckLoopValues:Far - Global D_LSCheckSusLoopValues:Far - - Global D_SaveSong:Far - - Global D_InitDisk:Far - Global D_UnInitDisk:Far - Global D_InitLoadModule:Far - Global D_InitLoadSamples:Far - Global D_LoadSampleNames:Far - Global D_NewSpecifier:Far - Global D_NewDirectory:Far - Global D_SaveIT:Far - Global D_DrawWaveForm:Far - - Global D_InitLoadInstruments:Far - Global D_DrawLoadInstrument:Far - Global D_PreLoadInstrument:Far - Global D_PostLoadInstrument:Far - Global D_LoadInstrumentNames:Far - Global D_ViewInstrument:Far - Global D_SlowSampleSort:Far - Global D_SlowInstrumentSort:Far - - Global D_SaveS3M:Far - - Global D_SaveDirectoryConfiguration:Far - Global D_DisableFileColours:Far - - Global D_GetLoadSampleVars:Far - - Global D_DrawLoadSampleWindow:Far - Global D_PreLoadSampleWindow:Far - Global D_PostLoadSampleWindow:Far - Global D_PostViewSampleLibrary:Far - - Global D_LSDrawDriveWindow:Far - Global D_LSPreDriveWindow:Far - Global D_LSPostDriveWindow:Far - - Global D_LIDrawDriveWindow:Far - Global D_LIPreDriveWindow:Far - Global D_LIPostDriveWindow:Far - - Global D_DeleteSampleFile:Far - - Global D_PostSaveDriveWindow:Far - - Global D_ClearFileSpecifier:Far - Global D_LoadSongNames:Far - Global D_DrawFileWindow:Far - Global D_DrawDirectoryWindow:Far - Global D_DrawDriveWindow:Far - Global D_PreFileWindow:Far - Global D_PostFileWindow:Far - Global D_PreDirectoryWindow:Far - Global D_PostDirectoryWindow:Far - Global D_PreDriveWindow:Far - Global D_PostDriveWindow:Far - Global D_PostFileLoadWindow:Far - Global D_PostFileSaveWindow:Far - Global D_SaveModule:Far - - Global FileSpecifier:Byte - Global SongDirectory:Byte - Global SampleDirectory:Byte - Global InstrumentDirectory:Byte - Global FileName:Byte - - Global D_SaveSample:Far - Global D_SaveRawSample:Far - Global D_SaveST3Sample:Far - - Global D_GotoStartingDirectory:Far - - Global LSWindow_Up:Far - Global LSWindow_Down:Far - - Global DiskDataArea:Word - Global SampleName:Byte - Global DiskOptions:Byte - - Public D_Resettimer - Public D_ShowTime - -IF TIMERSCREEN - Public D_DrawTimer - Public D_PostTimerList -ENDIF - -IF TUTORIAL - Public SamplesInModule - Public InSampleFileName -ELSE - Public D_LoadS3M - Public D_LoadMTM - Public D_LoadMOD - Public D_Load669 - Public D_LoadIT - Public D_LoadXM -ENDIF - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Disk BYTE Public 'Code' USE16 - Assume CS:Disk, DS:Nothing - -CREATENEWLOGFILE EQU 0 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -SampleInMemory DW 0FFFFh -NoSaveError DB 0 -Specific DB 0 -DiskDataArea DW DiskData - -OldCacheTime DD 0 - -Time DW 0 -Date DW 0 -LoadDate DW 0 -LoadTime DW 0 -DrivesAvail DB 27 Dup (0) -UnusedSamples DW 0 - -InitialInstruments DW 0 ; -NumInstruments DW 0 ; Order important! -InstrumentCachefileVersion DW TRACKERVERSION ; - -LoadInstrumentNameCount DW 0 -TopInstrument DW 0 -CurrentInstrument DW 0 - -LoadSongNameCount DW 0 -LoadSampleNameCount DW 0 -CurrentSample DW 0 - -NumSamples DW 0 ; Order important! -SampleCachefileVersion DW TRACKERVERSION ; - -TopSample DW 0 -CurrentDrive DB 0 -NumDrives DB 0 -TopDrive DB 0 -NumEntries DW 0 -NumFiles DW 0 -NumFileInfo DW 0 -NumDirectories DW 0 -TopDirectory DW 0 -CurrentDirectory DW 0 -CurrentFile DW 0 -TopFile DW 0 -FileName DB 0 - DB 13 Dup (0) -SaveFileName DB 0 - DB 79 Dup (0) -FileSpecifier DB 0 - DB 64 Dup (0) -StartingDrive DB 0 -StartingDirectory DB 70 Dup (0) - -PreShellDirectory DB 70 Dup (0) -DOSDirectory DB 70 Dup (0) - -SongDirectory DB 0 - DB 69 Dup (0) -SampleDirectory DB 0 - DB 69 Dup (0) -InstrumentDirectory DB 0 - DB 69 Dup (0) -CountryTableConfig DB 0 - -SampleName DB 0 - DB 26 Dup (0) - -MODNumberOfChannels DB 0 -MODNumberOfInstruments DB 0 -MODNumberOfOrders DB 0 -MODOrderOffset DW 0 -MODPatternOffset DW 0 -LastKey DW 0 - -SampleCacheFileComplete DB 0 -InstrumentCacheFileComplete DB 0 - -Resolution DB 0 - -FileTempSpecifier DB 70 Dup (0) -CurrentSearchPos DB 0 -Search DB 13 Dup (0) - -InstrumentTable DB 100 Dup (0) - -InstrumentLoaderTable Label Word - DW Offset LoadITInstrument ; 3 - DW Offset LoadXIInstrument ; 4 - DW Offset LoadInITInstrument ; 5 - DW Offset LoadInXMInstrument ; 6 - DW 0 ; 7 - DW Offset LoadITInModuleInstrument ; 8 - DW Offset LoadXMInModuleInstrument ; 9 - -InstrumentLoader DW 0 -InSampleFileName DB 13 Dup (0) -InSampleDateTime DD 0 -InSampleFormat DB 0 ; Do *NOT* change order -InSampleChannels DB 0 ; Do *NOT* change order - -InInstrumentFileName DB 13 Dup (0) -InInstrumentFormat DB 0 - -ExitLibraryDirectory Label - DB "IMPS. ", 0, 0, 0, 0 - DB 8 Dup(154), "Directory", 8 Dup(154), 0, 0, 0 - DW 0, 0, 0, 0, 0, 0, 0, 0 - DW 0, 0, 0, 0, 0, 0, 0, 0 - DW 0, 0, 0, 0 - DB 1 - -ExitInstrumentLibraryDirectory Label - DB 1, ". ", 0 - DB 8 Dup(154), "Directory", 8 Dup(154), 0 ; Instrument name - DW 0, 0 ; NoSamples, FileSize - DD 0 ; File offset - -AllFilesMask DB "*.*", 0 -FileSpecifierDefault DB "*.IT, *.XM, *.S3M, *.MTM, *.669, *.MOD", 0 -DriveMsg DB "Drive X:" -NoFilesMsg DB "No files.", 0 -NoDirsMsg DB "No dirs.", 0 -WAVEfmtID DB "WAVEfmt ", 0, 0, 1, 0 -XIIdentification DB "Extended Instrument: " -XMIdentification DB "Extended Module: " -TXWAVEIdentification DB "LM8953", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -GUSPATIdentification DB "GF1PATCH110", 0, "ID#000002", 0 ; 22 bytes - -OpenErrorMsg DB "Error opening file.", 0 - -HeaderMsg DB "File Header", 0 -SampleMsg DB "Sample ", 0FDh, 'D', 0 -SHLoadMsg DB "Sample Header ", 0FDh, 'D', 0 -InstrumentMsg DB "Instrument ", 0FDh, 'D', 0 -PatternMsg DB "Pattern ", 0FDh, 'D', 0 -TrackMsg DB "Channel ", 0FDh, 'D ', 13 - DB "Track ", 0FDh, 'D ', 0 -CompleteMsg DB "Done", 0 -InstrumentHeaderMsg DB "Instrument Headers", 0 -SampleHeaderMsg DB "Sample Headers", 0 -Quality8Msg DB "8 Bit", 0 -Quality16Msg DB "16 Bit", 0 -Quality8StereoMsg DB "8 Bit Stereo", 0 -Quality16StereoMsg DB "16 Bit Stereo", 0 -LengthMsg DB 0FDh, 'L', 0 -DirectoryMsg DB 8 Dup(154), "Directory", 8 Dup(154), 0 -LibraryMsg DB 9 Dup(154), "Library", 9 Dup(154), 0 -FontFileName DB "FONT.CFG", 0 -ConfigFileName DB "IT.CFG", 0 -ST3CacheFileName DB "########.ST3", 0 -SampleCacheFileName DB "CACHE.ITS", 0 -InstrumentCacheFileName DB "CACHE.ITI", 0 -SaveFormat DB DEFAULTFORMAT -SaveFormatError DB 0 ; This will get erased whenever the - ; saveformat changes. -SamplesInModule DB 0 -InstrumentsInModule DB 0 -FileColours DB 1 - -NoteData DB 0FFh, 0, 0FFh, 0, 0 - -CheckDataArea DB 96 Dup(0) -KeyBoardTable DW 12Ch, 0, 11Fh, 1, 12Dh, 2, 120h, 3, 12Eh, 4 - DW 12Fh, 5, 122h, 6, 130h, 7, 123h, 8, 131h, 9 - DW 124h, 10, 132h, 11, 110h, 12, 103h, 13, 111h, 14 - DW 104h, 15, 112h, 16, 113h, 17, 106h, 18, 114h, 19 - DW 107h, 20, 115h, 21, 108h, 22, 116h, 23, 117h, 24 - DW 10Ah, 25, 118h, 26, 10Bh, 27, 119h, 28, 0FFFFh -SampleCheck DW 0FFFFh - -MonthNames Label - DW Offset Empty - DW Offset January - DW Offset February - DW Offset March - DW Offset April - DW Offset May - DW Offset June - DW Offset July - DW Offset August - DW Offset September - DW Offset October - DW Offset November - DW Offset December - DW Offset Empty - DW Offset Empty - DW Offset Empty - -January DB "January", 0 -February DB "February", 0 -March DB "March", 0 -April DB "April", 0 -May DB "May", 0 -June DB "June", 0 -July DB "July", 0 -August DB "August", 0 -September DB "September", 0 -October DB "October", 0 -November DB "November", 0 -December DB "December" -Empty DB 0 - -TimerData DW 0 -NumTimerData DW 0 -TopTimerData DW 0 - -SampleFormatNames Label - DW Offset Unchecked ; 0 - DW Offset DirectoryFormat - DW Offset ITSampleFormat - DW Offset STSampleFormat - DW Offset UnknownSampleFormat - DW Offset WAV8BitFormat - DW Offset XMSample - DW Offset WAV16BitFormat - DW Offset XMSample - DW Offset PTMSample - DW Offset MTMSample - DW Offset C669Sample - DW Offset FARSample - DW Offset TXWaveSample ; 13 - DW Offset MODSample - DW Offset KRZSample ; 15 - DW Offset PATFormat - DW Offset IFFFormat ; 17 - DW 0, 0 - DW 0, 0, 0, 0 - DW 0, 0, 0, 0 - DW 0, 0, 0, 0 - DW Offset ST3Module ; 20h - DW Offset ITModule - DW Offset XMModule - DW Offset PTMModule - DW Offset MTMModule - DW Offset C669Module - DW Offset FARModule - DW Offset MODModule1 - DW Offset XMModule - DW Offset KRZFormat ; 29h - DW Offset PATFormat - -LoadSamplesInModuleTable Label Word - DW Offset LoadS3MSamplesInModule - DW Offset LoadITSamplesInModule - DW Offset LoadXMSamplesInModule - DW Offset LoadPTMSamplesInModule - DW Offset LoadMTMSamplesInModule - DW Offset Load669SamplesInModule - DW Offset LoadFARSamplesInModule - DW Offset LoadMODSamplesInModule - DW Offset LoadMODSamplesInModule - DW Offset LoadKRZSamples - DW Offset LoadPATSamples -; DW Offset LoadULTSamplesInModule - -FormatNames Label - DW Offset Unchecked ; 0 - DW Offset UnknownFormat ; 1 - DW Offset ITFormat2_0 ; 2 - DW Offset ITFormat? ; 3 - DW Offset ST3Format ; 4 - DW Offset XMModule ; 5 - DW Offset C669Module ; 6 - DW Offset CompressedITModule ; 7 - DW 0 - DW Offset MODFormat ; 9 - DW Offset Protracker ; 10 - DW Offset Channel4 ; 11 - DW Offset Channel6 ; 12 - DW Offset Channel8 ; 13 - DW Offset StarTrekker4 ; 14 - DW Offset StarTrekker8 ; 15 - DW Offset OldMod ; 16 - DW Offset ChannelXX ; 17 - DW Offset MultiTrackerModule ; 18 - -PanningPositions DB 0, 4, 9, 13, 17, 21, 26, 30 - DB 34, 38, 43, 47, 51, 55, 60, 64 -MODChannelTable DB 4, 4, 4, 6, 8, 4, 8, 4 -FineTuneTable DW 8363, 8413, 8463, 8529 - DW 8581, 8651, 8723, 8757 - DW 7895, 7941, 7985, 8046 - DW 8107, 8169, 8232, 8280 - -DirectoryFormat DB "Directory", 0 -ITSampleFormat DB "Impulse Tracker Sample", 0 -STSampleFormat DB "Scream Tracker Sample", 0 -UnknownSampleFormat DB "Unknown sample format", 0 -WAV8BitFormat DB "8 Bit WAV Format", 0 -WAV16BitFormat DB "16 Bit WAV Format", 0 -XMSample DB "Fast Tracker 2 Sample", 0 -PTMSample DB "Poly Tracker Sample", 0 -MTMSample DB "Multi Tracker Sample", 0 -C669Sample DB "Composer 669 Sample", 0 -FARSample DB "Farandole Sample", 0 -; ULTSample DB "Ultra Tracker Sample", 0 -TXWaveSample DB "TX Wave Sample", 0 -MODSample DB "MOD Sample", 0 -KRZSample DB "KRZ Sample", 0 - -ST3Module DB "Scream Tracker 3 Module", 0 -ITModule DB "Impulse Tracker Module", 0 -XMModule DB "Fast Tracker 2 Module", 0 -PTMModule DB "Poly Tracker Module", 0 -MTMModule DB "Multi Tracker Module", 0 -C669Module DB "Composer 669 Module", 0 -FARModule DB "Farandole Module", 0 -MODModule1 DB "MOD Format", 0 -; ULTModule DB "Ultra Tracker Module", 0 -KRZFormat DB "Kurzweil Synth File", 0 -PATFormat DB "Gravis UltraSound Patch", 0 -IFFFormat DB "AIFF Sample", 0 - -Unchecked DB "Unchecked", 0 -UnknownFormat DB "Unknown module format", 0 -CompressedITModule DB "Compressed " -ITFormat2_0 DB "Impulse Tracker", 0 -ITFormat? DB "Impulse Tracker ?.??", 0 -ST3Format DB "Scream Tracker 3", 0 -MODFormat DB "Amiga-NewTracker", 0 -ProTracker DB "Amiga-ProTracker", 0 -StarTrekker4 DB "4 Channel Startrekker", 0 -StarTrekker8 DB "8 Channel Startrekker", 0 -Channel4 DB "4 Channel MOD", 0 -Channel6 DB "6 Channel MOD", 0 -Channel8 DB "8 Channel MOD", 0 -OldMod DB "Old Amiga-MOD format ? ", 0 -ChannelXX DB 0FDh, "D Channel MOD", 0 -MultiTrackerModule DB "MultiTracker Module", 0 - -ITInstrumentSavedMsg DB "Instrument saved (instrument ", 0FDh, "D)", 0 -InstrumentErrorMsg DB "Error: Instrument ", 0FDh, "D NOT saved! (No Filename?)", 0 -ITSampleSavedMsg DB "Impulse Tracker sample saved (sample ", 0FDh, "D)", 0 -ST3SampleSavedMsg DB "Scream Tracker sample saved (sample ", 0FDh, "D)", 0 -IF SAVESAMPLEWAV -RawSampleSavedMsg DB "WAV Sample saved (sample ", 0FDh, "D)", 0 -ELSE -RawSampleSavedMsg DB "RAW Sample saved (sample ", 0FDh, "D)", 0 -ENDIF -SampleErrorMsg DB "Error: Sample ", 0FDh, "D NOT saved! (No Filename?)", 0 -InitInstrumentMsg DB "Sample assigned to Instrument ", 0FDh, "D", 0 -InitInstrumentErrorMsg DB "Error: No available Instruments!", 0 - -TooManyPatternsMsg DB "Warning: Only 100 patterns supported in S3M format", 0 -ChannelVolumeErrorMsg DB "Warning: Channel volumes unsupported in S3M format", 0 -LinearSlideMsg DB "Warning: Linear slides unsupported in S3M format", 0 -LoopMsg DB "Warning: Sustain and Ping Pong loops unsupported in S3M format", 0 -SampleVolumeMsg DB "Warning: Sample volumes unsupported in S3M format", 0 -SampleVibratoMsg DB "Warning: Sample vibrato unsupported in S3M format", 0 -ST3InstrumentErrorMsg DB "Warning: Instrument functions unsupported in S3M format", 0 -PatternLengthMsg DB "Warning: Pattern lengths other than 64 rows unsupported in S3M format", 0 -ChannelErrorMsg DB "Warning: Data outside 16 channels unsupported in S3M format", 0 -NoteRangeMsg DB "Warning: Notes outside the range C-1 to B-8 are unsupported in S3M format", 0 -PanningErrorMsg DB "Warning: Extended volume column effects are unsupported in S3M format", 0 - -InstrumentLibrary DB 154, 154, "Module", 154, 154, 0 -InstrumentNoSample DB "No Samples", 0 -InstrumentSingleSample DB "1 Sample", 0 -InstrumentSeveralSamples DB 0FDh, "D Samples", 0 -InstrumentUnknownSamples DB "???", 0 -FileSizeMsg DB 0FDh, "Dk", 0 -FreeSampleMsg DB "Available", 13 - DB "Samples: ", 0FDh, 'D', 0 - -IF SAVESAMPLEWAV - WAVEFileHeader DB "RIFF" - WAVEFileSize DD 0 - WAVEFileHeader2 DB "WAVEfmt " - WAVEFileHeaderLength DD 10h - WAVEFileID DW 1 - WAVEChannels DW 1 - WAVEMixSpeed DD 44100 ; Default to CD quality - WAVEBytesPerSecond DD 0 - WAVEBytesPerSample DW 2 - WAVEBits DW 16 - WAVEHeader3 DB "data" - WAVEDataSize DD 0 -ENDIF - -DiskOptions DB 0 -EditTimer DD 0 - -CDRomStartDrive DB 0 ; The first CDRom Drive letter -CDRomEndDrive DB 0 ; The drive AFTER the last cdrom - -FileWindowKeys Label - - DB 0 - DW 1C8h ; Up arrow - DW FileWindow_Up - - DB 0 - DW 1D0h ; Down arrow - DW FileWindow_Down - - DB 0 - DW 1C9h ; PgUp - DW FileWindow_PgUp - - DB 0 - DW 1D1h ; PgDn - DW FileWindow_PgDn - - DB 0 - DW 1C7h ; Home - DW FileWindow_Home - - DB 0 - DW 1CFh ; End - DW FileWindow_End - - DB 4 - DW 10Fh ; Shift Tab - DW FileWindow_ShiftTab - - DB 0 - DW 10Fh ; Tab - DW FileWindow_Right - - DB 0 - DW 1CDh ; Right arrow - DW FileWindow_Right - - DB 0 - DW 1CBh ; Left arrow - DW FileWindow_Left - - DB 0 - DW 1D3h ; Delete - DW FileWindow_DeleteFile - - DB 0FFh - -DirectoryWindowKeys Label - - DB 0 - DW 1C8h - DW DirectoryWindow_Up - - DB 0 - DW 1D0h - DW DirectoryWindow_Down - - DB 0 - DW 1C9h ; PgUp - DW DirectoryWindow_PgUp - - DB 0 - DW 1D1h ; PgDn - DW DirectoryWindow_PgDn - - DB 0 - DW 1C7h ; Home - DW DirectoryWindow_Home - - DB 0 - DW 1CFh ; End - DW DirectoryWindow_End - - DB 4 - DW 10Fh ; Shift Tab - DW DirectoryWindow_Left - - DB 0 - DW 10Fh ; Tab - DW FileWindow_Left ; Same object num - - DB 0 - DW 1CDh ; Right arrow - DW FileWindow_Left - - DB 0 - DW 1CBh ; Left arrow - DW DirectoryWindow_Left - - DB 0 - DW 11Ch ; Enter - DW DirectoryWindow_Enter - - DB 0FFh - -DriveWindowKeys Label - - DB 0 - DW 1C8h - DW DriveWindow_Up - - DB 0 - DW 1D0h - DW DriveWindow_Down - - DB 4 - DW 10Fh ; Shift-Tab - DW FileWindow_Right - - DB 0 - DW 10Fh ; Tab - DW DriveWindow_Tab - - DB 0 - DW 1CDh ; Right arrow - DW DirectoryWindow_Left - - DB 0 - DW 1CBh ; Left arrow - DW FileWindow_Right - - DB 0 - DW 11Ch ; Enter - DW DriveWindow_Enter - - DB 0FFh - -SaveDriveWindowKeys Label - - DB 0 - DW 1C8h - DW DriveWindow_Up - - DB 0 - DW 1D0h - DW DriveWindow_Down - - DB 4 - DW 10Fh ; Shift-Tab - DW FileWindow_Right - - DB 0 - DW 10Fh ; Tab - DW SaveDriveWindow_Tab - - DB 0 - DW 1CDh ; Right arrow - DW SaveDriveWindow_Tab - - DB 0 - DW 1CBh ; Left arrow - DW FileWindow_Right - - DB 0 - DW 11Ch ; Enter - DW DriveWindow_Enter - - DB 0FFh - -LSDriveWindowKeys Label - - DB 0 - DW 1C8h - DW DriveWindow_Up - - DB 0 - DW 1D0h - DW DriveWindow_Down - - DB 4 - DW 10Fh ; Shift-Tab - DW DriveWindow_Tab ; goto object number 15 - - DB 0 - DW 10Fh ; Tab - DW LSDriveWindow_Right - - DB 0 - DW 1CDh ; Right arrow - DW LSDriveWindow_Right - - DB 0 - DW 1CBh ; Left arrow - DW DriveWindow_Tab - - DB 0 - DW 11Ch ; Enter - DW LS_DriveWindow_Enter - - DB 0FFh - -LIDriveWindowKeys Label - - DB 0 - DW 1C8h - DW DriveWindow_Up - - DB 0 - DW 1D0h - DW DriveWindow_Down - - DB 0 - DW 1CBh ; Left arrow - DW LIDriveWindow_Tab - - DB 0 - DW 10Fh ; Tab - DW LIDriveWindow_Tab - - DB 0 - DW 11Ch ; Enter - DW LI_DriveWindow_Enter - - DB 0FFh - -LoadInstrumentKeys Label - DB 0 - DW 11Ch ; Enter - DW LIWindow_Enter - -ViewInstrumentKeys Label - DB 0 - DW 1C8h - DW LIWindow_Up - - DB 0 - DW 1D0h - DW LIWindow_Down - - DB 0 - DW 1C9h ; PgUp - DW LIWindow_PgUp - - DB 0 - DW 1D1h ; PgDn - DW LIWindow_PgDn - - DB 0 - DW 1C7h ; Home - DW LIWindow_Home - - DB 0 - DW 1CFh ; End - DW LIWindow_End - - DB 0 - DW 1D3h ; Delete - DW D_DeleteInstrumentFile - - DB 0 - DW 11Ch ; Enter - DW LIViewWindow_Enter - - DB 0 - DW 1CDh ; Right arrow - DW LIViewWindow_Tab - - DB 0 - DW 10Fh ; Tab - DW LIViewWindow_Tab - - DB 0FFh - -LSWindowKeys Label - DB 0 - DW 11Ch ; Enter - DW LSWindow_Enter - -LSViewWindowKeys Label - DB 0 - DW 139h - DW LSWindow_Space ; Edit sample name - - DB 0 - DW 1C8h - DW LSWindow_Up - - DB 0 - DW 1D0h - DW LSWindow_Down - - DB 0 - DW 1C9h ; PgUp - DW LSWindow_PgUp - - DB 0 - DW 1D1h ; PgDn - DW LSWindow_PgDn - - DB 0 - DW 1C7h ; Home - DW LSWindow_Home - - DB 0 - DW 1CFh ; End - DW LSWindow_End - - DB 0 - DW 1CDh ; Right arrow - DW FileWindow_ShiftTab - - DB 0 - DW 10Fh ; Tab - DW FileWindow_ShiftTab ; Object 16 - - DB 0 - DW 1D3h ; Delete - DW D_DeleteSampleFile - - DB 0 - DW 11Ch ; Enter - DW LSViewWindow_Enter - - DB 0FFh - - - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc D_InitDisk Far - - Push DS - - Push CS - Pop DS - Assume DS:Disk - ; Get date/time for CACHE.IT file - - Trace " - Finding CDROM Drives" - - Mov AX, 1500h - Xor BX, BX - Int 2Fh - Cmp AL, 0FFh - JNE D_InitDiskNoCDROM - Test BX, BX - JZ D_InitDiskNoCDROM - - Add CL, 'A' - Mov CDRomStartDrive, CL - Add CX, BX - Mov CDRomEndDrive, CL - -D_InitDiskNoCDROM: - Trace " - Determining main directory" - - Mov SI, Offset DOSDirectory - Call D_GetDriveDirectory - - Trace " - Initialising cache file parameters" - - Mov AH, 2Ah - Int 21h ; Get Date - Mov AX, CX ; Now to get date in yyyyyyym mmmddddd - Sub AX, 1980 - ShL AX, 9 ; Year - Or AL, DL ; Day - Xor DL, DL - ShR DX, 3 - Or AX, DX ; Month - Mov Date, AX - - Mov AH, 2Ch - Int 21h ; Get time - Mov AX, CX ; Now to get time in hhhhhmmm mmmsssss - ShL AL, 2 ; AX = ...hhhhh mmmmmm.. - ShL AX, 3 ; AX = hhhhhmmm mmm..... - ShR DH, 1 ; DH = ...sssss - Or AL, DH - Mov Time, AX - - Cmp StartingDirectory, 0 - JNE D_InitDisk2 - - Trace " - Determining available drives" - -D_InitDisk1: - Mov AH, 19h - Int 21h - - Mov StartingDrive, AL - - Mov CX, 26 - Xor BX, BX - Xor SI, SI - -D_InitDisk3: - Mov DL, BL - Mov AH, 0Eh - Int 21h - - Mov AH, 19h - Int 21h - Cmp AL, BL - JNE D_InitDisk4 - - Cmp BL, StartingDrive - JNE D_InitDisk9 - - Mov AX, SI - Mov CurrentDrive, AL - -D_InitDisk9: - Test DiskOptions, 1 - JNZ D_InitDisk10 - - Mov AX, 440Eh ; This code was to prevent - ; A and B drives being shown - ; on older DOS systems when - ; only one drive was present. - ; For some reason, it crashes - ; one in a thousand computers. - ; hence the option /x3 - Push BX - Xor BL, BL - Int 21h - - Pop BX - JC D_InitDisk10 - And AL, AL - JZ D_InitDisk10 - Dec AX - Cmp AL, BL - JNE D_InitDisk4 - -D_InitDisk10: - Mov [DrivesAvail+SI], BL - Inc SI - -D_InitDisk4: - Inc BX - Loop D_InitDisk3 - - Mov BX, SI - Mov NumDrives, BL - - Mov DL, StartingDrive - Mov AH, 0Eh - Int 21h - -D_GetStartingDirectory1: ; FS=PSP. - Push CS - Pop ES - - Mov DI, Offset StartingDirectory - - Mov DS, [FS:2Ch] ; Environment thingy. - Xor SI, SI - Mov CX, 7FFFh - -D_GetStartingDirectory2: - Cmp Word Ptr [SI], 0 - JE D_GetStartingDirectory3 - - Inc SI - Loop D_GetStartingDirectory2 - - Jmp D_GetStartingDirectoryEnd - -D_GetStartingDirectory3: ; DS:SI points to 0... - Add SI, 4 - Push SI ; Now to work out count. - - Xor DX, DX - Mov CX, 1 - -D_GetStartingDirectory4: - LodsB - And AL, AL - JZ D_GetStartingDirectory5 - - Inc DX - - Cmp AL, '\' - JNE D_GetStartingDirectory4 - - Mov CX, DX - Jmp D_GetStartingDirectory4 - -D_GetStartingDirectory5: - Pop SI - - Dec CX - Rep MovsB - Xor AL, AL - StosB - -D_GetStartingDirectoryEnd: - Push CS - Pop DS - - Mov SI, Offset StartingDirectory - Call D_SetDriveDirectory - - Mov DI, Offset SongDirectory - Cmp Byte Ptr [DI], 0 - JNE D_InitDisk11 - - Push SI - -D_InitDisk5: - LodsB - And AL, AL - JZ D_InitDisk6 - - StosB - Jmp D_InitDisk5 - -D_InitDisk6: - Cmp Byte Ptr [ES:DI-1], '\' - JNE D_InitDisk15 - - Dec DI - -D_InitDisk15: - Mov AX, '\' + 256*'S' - StosW - Xor AL, AL - StosB - - Pop SI - -D_InitDisk11: - Mov DI, Offset SampleDirectory - Cmp Byte Ptr [DI], 0 - JNE D_InitDisk12 - -D_InitDisk7: - LodsB - And AL, AL - JZ D_InitDisk8 - - StosB - Jmp D_InitDisk7 - -D_InitDisk8: - Cmp Byte Ptr [ES:DI-1], '\' - JNE D_InitDisk16 - - Dec DI - -D_InitDisk16: - Mov AX, '\' + 256*'I' - StosW - Xor AL, AL - StosB - -D_InitDisk12: - Mov DI, Offset InstrumentDirectory - Cmp Byte Ptr [DI], 0 - JNE D_InitDisk13 - - Mov SI, Offset SampleDirectory - Mov CX, 70 - Rep MovsB - - Mov SI, Offset SongDirectory - Call D_SetDriveDirectory - Mov SI, Offset SampleDirectory - Call D_SetDriveDirectory - Mov SI, Offset InstrumentDirectory - Call D_SetDriveDirectory - -D_InitDisk13: - Push CS - Pop DS - - Mov SI, Offset StartingDirectory - Call D_SetDriveDirectory - - Trace " - Loading configuration file" - - Mov AX, 3D00h ; Get config. - Mov DX, Offset ConfigFileName - Int 21h - JC D_InitDisk2 - - Mov BX, AX ; BX = file handle - - Trace " - Processing configuration file" - - Mov AH, 3Fh - Mov CX, 211 ; Load Directories+Keyboard - Mov DX, Offset SongDirectory - Int 21h ; Read config file.. - - Call S_GetPaletteOffset ; Read palette stuff. - Mov AH, 3Fh - Mov CX, 3*16 - Int 21h - - Call S_SetPalette - - Call Display_GetDisplayWindowData - Mov AH, 3Fh - Mov CX, 50 - Int 21h - - Call PE_GetPatternConfigOffset - Mov AH, 3Fh - Mov CX, 218 - Int 21h - - Call I_GetPresetEnvelopeOffset - Mov AH, 3Fh - Mov CX, 810 - Int 21h - - Mov AH, 3Eh ; Close file. - Int 21h - -D_InitDisk2: ; Load font data.. and set it. - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset StartingDirectory - Call D_SetDriveDirectory - - Mov AX, 3D00h - Mov DX, Offset FontFileName - Int 21h - JC D_NoFontFile - - Trace " - Loading custom font file" - - Call S_GetGenerationTableOffset - Push ES - Pop DS - Mov DX, DI - - Mov BX, AX - Mov AH, 3Fh - Mov CX, 2048 - Int 21h - JC D_BadFontRead - Cmp AX, CX - JNE D_BadFontRead - - Trace " - Initialising custom font file" - - Push BX - - Mov SI, DX - Xor AX, AX - Mov BX, 256 - Call S_RedefineCharacters - - Pop BX - -D_BadFontRead: - Mov AH, 3Eh - Int 21h - -D_NoFontFile: - Push CS - Pop DS - - Call CheckTimerData - - Pop DS - Ret - -EndP D_InitDisk - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_UnInitDisk Far - - Push CS - Pop DS - Assume DS:Disk - - Mov AX, DiskDataArea - Test AX, AX - JZ D_UnInitDisk1 - - Mov ES, AX - Mov AH, 49h - Int 21h - - -D_UnInitDisk1: - Call ReleaseTimerData - Mov SI, Offset DOSDirectory - Call D_SetDriveDirectory - - Ret - -EndP D_UnInitDisk - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GetDriveDirectory ; DS:SI points to buffer - - Push AX - Push DX - Push SI - - Mov AH, 19h - Int 21h - - Add AL, 'A' - Mov [SI], AL - Mov Word Ptr [SI+1], ':' + 256*'\' - Add SI, 3 - Mov AH, 47h - Xor DX, DX - Int 21h - - Pop SI - Pop DX - Pop AX - - Ret - -EndP D_GetDriveDirectory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SetDriveDirectory ; DS:SI points to dir. - - Push AX - Push BX - Push DX - - Xor DX, DX - - Cmp Byte Ptr [SI+1], ':' - JNE D_SetDriveDirectory2 - - Mov DL, [SI] - Cmp DL, 'a' - JB D_SetDriveDirectory1 - Cmp DL, 'z' - JA D_SetDriveDirectory1 - - Add DL, 'A'-'a' - -D_SetDriveDirectory1: - Sub DL, 'A' - Cmp DL, 25 ; Drive > 'Z'?? - JA D_SetDriveDirectory4 - - Mov AX, 440Eh - Mov BL, DL - Inc BX - Int 21h - JC D_SetDriveDirectory3 - And AL, AL - JZ D_SetDriveDirectory3 - - Mov AX, 440Fh - Int 21h - -D_SetDriveDirectory3: - Mov AH, 0Eh - Int 21h ; This causes hanging on re-run!!! - -D_SetDriveDirectory4: - Mov DX, 2 - -D_SetDriveDirectory2: - Add DX, SI - Mov AH, 3Bh - Int 21h - - Call D_GetDriveDirectory - - Pop DX - Pop BX - Pop AX - Ret - -EndP D_SetDriveDirectory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFileNames - - Mov ES, CS:DiskDataArea - Xor DI, DI - Xor AX, AX - Mov CX, 32768 - Rep StosW - - Push CS - Push CS - - Pop DS - Pop ES - Assume DS:Disk - - Mov NumFileInfo, 0 - Mov NumEntries, 0 - Mov CurrentDirectory, 0 - - Mov SI, Offset FileSpecifier - -D_LoadFileNames1: - Mov DI, Offset FileTempSpecifier - -D_LoadFileNames2: - LodsB - And AL, AL - JZ D_LoadFileNames3 - - Cmp AL, ',' - JE D_LoadFileNames3 - - Cmp AL, ' ' - JE D_LoadFileNames2 - - StosB - Jmp D_LoadFileNames2 - -D_LoadFileNames3: - Xor AL, AL - StosB ; ES:DI points to file name. - - Push DS - Push SI - Push ES - Push DI - - Xor BL, BL - Mov CX, 6 ; Hidden/System/Normal files - Mov DX, Offset FileTempSpecifier - Call D_LoadFileNames4 - - Pop DI - Pop ES - Pop SI - Pop DS - - Cmp Byte Ptr [DS:SI-1], 0 - JNE D_LoadFileNames1 - - Mov AX, NumEntries - Mov NumFiles, AX - Cmp CurrentFile, AX - JB D_LoadFileNameUpdateCurrentFile - - Mov CurrentFile, 0 - -D_LoadFileNameUpdateCurrentFile: - Mov DX, Offset AllFilesMask - Mov CX, 10h ; Directories - Mov BX, CX - Call D_LoadFileNames4 - - Mov AX, NumEntries - Sub AX, NumFiles - Mov NumDirectories, AX - - Ret - -D_LoadFileNames4: - Push DX - - Mov DS, DiskDataArea - Assume DS:Nothing - - Mov DX, 60000 - Mov AH, 1Ah - Int 21h ; Shift DTA address.. - - Push CS - Pop DS - Assume DS:Disk - - Mov AH, 4Eh - Pop DX - Int 21h - -D_LoadFileNames5: - JC D_LoadFileNames6 - ; A file is found.... - Cmp NumEntries, 1000 - JAE D_LoadFileNames6 - - Mov AX, 50 - Mul NumEntries - Add AX, 2000 - Mov DI, AX - Mov CX, 21 - - Mov DS, DiskDataArea - Assume DS:Nothing - - Mov SI, 60000+16h - - Cmp Word Ptr [DS:60000+1Eh], '.' - JNE D_LoadFileNames9 - - Mov Byte Ptr [DS:60000+1Eh], '\' - -D_LoadFileNames9: - And BL, BL - JZ D_LoadFileNames7 - - Test [SI-1], BL - JZ D_LoadFileNames8 - -D_LoadFileNames7: - Push DS - Pop ES - Rep MovsB - - Inc CS:NumEntries - -D_LoadFileNames8: - Push CS - Pop DS - Mov AH, 4Fh - Int 21h - Jmp D_LoadFileNames5 - -D_LoadFileNames6: - RetN - -EndP D_LoadFileNames - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SortRoutine - - Mov DS, DiskDataArea - Push DS - Pop ES - - Mov SI, CX ; Start - - ; OK, so SI = current, - ; CX/DX = range - -D_SortRoutine2: - Cmp SI, DX - JAE D_SortRoutine1 - - Push DX - Push SI - - Push CX - Push DX - - Mov AX, 50 - Mul SI - Add AX, 2000 - Mov SI, AX - - Mov AX, 50 - Mul CX - Add AX, 2000 - Mov DI, AX - - Xor BX, BX - Pop DX - - Cmp Word Ptr [SI+8], '\' - JE D_SortRoutine4 - -D_SortRoutine3: - Cmp CX, DX - JAE D_SortRoutine4 - - Cmp Word Ptr [DI+8], '\' - JE D_SortRoutine6 - - Push CX - Push SI - Push DI - - Add SI, 8 - Add DI, 8 - Mov CX, 13 - - RepE CmpsB - - Pop DI - Pop SI - Pop CX - - JB D_SortRoutine5 - JA D_SortRoutine6 - Cmp DI, SI - JBE D_SortRoutine5 - -D_SortRoutine6: - Inc BX - -D_SortRoutine5: - Inc CX - Add DI, 50 - - Jmp D_SortRoutine3 - -D_SortRoutine4: - Pop CX - Add BX, CX - Add BX, BX - Mov [BX], SI - - Pop SI - Pop DX - Inc SI - Jmp D_SortRoutine2 - -D_SortRoutine1: - Ret - -EndP D_SortRoutine - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SortFileNames - - Xor CX, CX - Mov DX, CS:NumFiles - Call D_SortRoutine - - Ret - -EndP D_SortFileNames - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SortDirNames - - Mov CX, CS:NumFiles - Mov DX, CX - Add DX, CS:NumDirectories - Call D_SortRoutine - - Ret - -EndP D_SortDirNames - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_InitLoadModule Far - - Push DS - Push ES - Push DI - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Disk - - Mov SI, Offset FileSpecifierDefault - Mov DI, Offset FileSpecifier - Mov CX, 65 - Rep MovsB - - Pop DI - Pop ES - Pop DS - Assume DS:Nothing - -Proc D_InitLoadModule2 Far - - Cmp CS:FileSpecifier, 0 - JE D_InitLoadModule - - Push DS - Push ES - Push DI - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Disk - - Mov DI, Offset CurrentSearchPos - Mov CX, 14 - Xor AL, AL - Rep StosB - - Mov LoadSongNameCount, 0 - - Mov SI, Offset SongDirectory - Call D_SetDriveDirectory ; DS:SI points to cur dir. - - Call D_LoadFileNames - Call D_SortFileNames - Call D_SortDirNames - - Pop DI - Pop ES - Pop DS - Ret - -EndP D_InitLoadModule2 - -EndP D_InitLoadModule - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DrawFileWindow Far ; Layout of filenames in memory - ; Start at offset 2000 - ; Pointers to filenames at 0 - - Push CS - Pop DS - Assume DS:Disk - - Call S_GetDestination - - Mov AX, TopFile - Mov BX, CurrentFile - Cmp AX, BX - JBE D_DrawFileWindow1 - - Mov AX, BX - -D_DrawFileWindow1: - LEA CX, [EAX+30] - Cmp CX, BX - JA D_DrawFileWindow2 - - LEA AX, [BX-30] - -D_DrawFileWindow2: - Mov TopFile, AX - Mov BX, AX ; BX = filenum - - Mov DS, DiskDataArea - Assume DS:Nothing - - Mov DI, (3+13*80)*2 - Mov CX, 31 - - -D_DrawFileWindow3: - LEA SI, [EBX+EBX] - Mov SI, [SI] - - Push DI - - Cmp BX, NumFiles - JAE D_DrawFileWindow4 - - Push SI - Push DI - - Mov AH, 2 - Cmp CS:FileColours, 0 - JE D_DrawFileWindow28 - - Mov AH, 6 ; Not checked colour - Mov AL, [SI+23] - - Test AL, AL - JE D_DrawFileWindow28 - - Mov AH, 7 ; Not known colour - Cmp AL, 1 - JE D_DrawFileWindow28 - - Mov AH, 3 ; Impulse Tracker colour - Cmp AL, 3 - JBE D_DrawFileWindow28 - Cmp AL, 7 - JE D_DrawFileWindow28 - - Mov AH, 5 ; Scream Tracker colour - Cmp AL, 8 - JBE D_DrawFileWindow28 - - Mov AH, 2 ; MOD/MTM colour - -D_DrawFileWindow28: - Push CX - - Add SI, 8 - Mov CX, 12 - -D_DrawFileWindow6: - LodsB - StosW - - And AL, AL - LoopNZ D_DrawFileWindow6 - -; JCXZ D_DrawFileWindow30 - - Xor AL, AL - Rep StosW - - Pop CX - -; D_DrawFileWindow30: - Pop DI - Pop SI - -D_DrawFileWindow4: - Add DI, 24 - Add SI, 25 - - Mov AX, 2A8h - StosW - - Cmp BX, NumFiles - JAE D_DrawFileWindow9 - - Mov AH, 2 ; Song name.. - Mov DX, 25 - - Add AH, CS:FileColours - -D_DrawFileWindow5: - LodsB - Cmp AL, 226 - JB D_DrawFileCharFilter - - Mov AL, ' ' - -D_DrawFileCharFilter: - StosW - - Dec DX - JNZ D_DrawFileWindow5 - -D_DrawFileWindow9: - Pop DI - Add DI, 160 - Inc BX - - Loop D_DrawFileWindow3 - - Push CS - Pop DS - Assume DS:Disk - - Cmp NumFiles, 0 - JE D_DrawFileWindow7 - - Jmp D_DrawFileWindow11 - -D_DrawFileWindow7: - Mov SI, Offset NoFilesMsg - Mov DI, (3+13*80)*2 - Mov AH, 7 - Mov CX, 9 - -D_DrawFileWindow8: - LodsB - StosW - - Loop D_DrawFileWindow8 - -D_DrawFileWindow11: -; Push CS ; Not necessary -; Pop DS - - Mov SI, Offset Search - Mov DI, (51+37*80)*2 - Mov CX, 13 - Mov AH, 5 - -D_DrawFileWindow10: - LodsB - StosW - - Loop D_DrawFileWindow10 - - Cmp NumFiles, 0 - JNE D_DrawFileWindow12 - - Ret - -D_DrawFileWindow12: - Mov BX, CurrentFile - Add BX, BX - - Mov DS, DiskDataArea - Assume DS:Nothing - - Mov BX, [BX] - Mov SI, [BX+23] - Mov AL, [BX+22] - Mov DI, (51+40*80)*2 - - Push CS - Pop DS - Assume DS:Disk - - Add SI, SI - Mov SI, [FormatNames+SI] - Cmp SI, Offset ChannelXX - JNE D_DrawFileWindow29 - - Xor AH, AH - Push AX ; Number of channels for MOD - - Mov AH, 5 - Call S_DrawString - Pop AX ; Add SP, 2 - - Jmp D_DrawFileWindow14 - -D_DrawFileWindow29: - Mov AH, 5 - -D_DrawFileWindow13: - LodsB - And AL, AL - JZ D_DrawFileWindow14 - - StosW - Jmp D_DrawFileWindow13 - -D_DrawFileWindow14: - Mov DS, DS:DiskDataArea - Assume DS:Nothing - - Mov DX, [BX+6] - Mov AX, [BX+4] - Cmp DX, 10000 - - JAE D_DrawFileWindow15 - - Mov DI, (51+41*80)*2 - - Mov CX, 10000 - Div CX ; DX = remainder. AX = main. - - Mov BP, AX - - Mov CX, 4 - Mov SI, 10 - Mov AX, DX - -D_DrawFileWindow16: - Xor DX, DX - Div SI - Add DL, '0' - Push DX - - Loop D_DrawFileWindow16 - - Mov AX, BP - - Mov CX, 5 - -D_DrawFileWindow17: - Xor DX, DX - Div SI - Add DL, '0' - Push DX - - Loop D_DrawFileWindow17 - - Mov CX, 9 - -D_DrawFileWindow18: - Pop AX - Mov AH, 5 - StosW - Loop D_DrawFileWindow18 - -D_DrawFileWindow15: ; OK, time for a date :) - Mov DX, [DS:BX] ; DX = time - Mov BX, [DS:BX+2] ; BX = date - - Push CS - Pop DS - Assume DS:Disk - - Mov DI, (51+42*80)*2 - Mov AX, BX - ShR AX, 5 - And AX, 0Fh - LEA SI, [EAX+EAX] - Mov SI, [MonthNames+SI] - - Mov AH, 5 - -D_DrawFileWindow19: - LodsB - StosW - And AL, AL - JNZ D_DrawFileWindow19 - - Mov AL, BL - And AX, 31 - Mov CH, 10 - Div CH - And AL, AL - JZ D_DrawFileWindow20 - - Push AX - Add AL, '0' - Mov AH, 5 - StosW - - Pop AX - -D_DrawFileWindow20: - Mov AL, AH - Add AL, '0' - Mov AH, 5 - StosW - - Mov AL, ',' - StosW - - Mov AL, ' ' - StosW - - Push DX - Mov AL, BH - ShR AX, 1 - And AX, 7Fh - Add AX, 1980 - Mov DX, 0FFFFh - Push DX - - Mov SI, 10 - -D_DrawFileWindow21: - Xor DX, DX - Div SI - Add DL, '0' - Push DX - - And AX, AX - JNZ D_DrawFileWindow21 - -D_DrawFileWindow22: - Pop AX - Cmp AX, 0FFFFh - JE D_DrawFileWindow23 - - Mov AH, 5 - StosW - - Jmp D_DrawFileWindow22 - -D_DrawFileWindow23: - Pop DX - Mov DI, (51+43*80)*2 - - Mov AX, DX - ShR AX, 11 - - Xor BL, BL ; if BL = 0, then am, otherwise - ; pm.. - Cmp AX, 12 - JB D_DrawFileWindow24 - - Inc BX - Sub AX, 12 - -D_DrawFileWindow24: - And AX, AX - JNZ D_DrawFileWindow25 - - Add AX, 12 - -D_DrawFileWindow25: - Mov BH, 10 - Div BH - And AL, AL - JZ D_DrawfileWindow26 - - Push AX - Add AL, '0' - Mov AH, 5 - StosW - - Pop AX - -D_DrawFileWindow26: - Mov AL, AH - Add AL, '0' - Mov AH, 5 - StosW - - Mov AL, ':' - StosW - - Mov AX, DX - ShR AX, 5 - And AX, 63 - - Div BH - Mov BH, AH - - Add AL, '0' - Mov AH, 5 - StosW - - Mov AL, BH - Add AL, '0' - StosW - - Mov AL, 'a' - And BL, BL - JZ D_DrawFileWindow27 - - Mov AL, 'p' - -D_DrawFileWindow27: - StosW - Mov AL, 'm' - StosW - - Ret - -EndP D_DrawFileWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DrawDirectoryWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Call S_GetDestination - - Mov AX, TopDirectory - Mov BX, CurrentDirectory - Cmp AX, BX - JBE D_DrawDirectoryWindow1 - - Mov AX, BX - -D_DrawDirectoryWindow1: - LEA CX, [EAX+20] - Cmp CX, BX - JA D_DrawDirectoryWindow2 - - LEA AX, [BX-20] - -D_DrawDirectoryWindow2: - Mov TopDirectory, AX - Mov BX, AX - - Mov CX, 21 - Mov DI, (44+13*80)*2 - - Mov DS, DiskDataArea - Assume DS:Nothing - -D_DrawDirectoryWindow3: - Cmp BX, CS:NumDirectories - JAE D_DrawDirectoryWindow4 - - Mov SI, BX - Add SI, CS:NumFiles - Add SI, SI - Mov SI, [SI] - - Push DI - - Add SI, 8 - Mov AH, 5 - -D_DrawDirectoryWindow5: - LodsB - And AL, AL - JZ D_DrawDirectoryWindow8 - - StosW - Jmp D_DrawDirectoryWindow5 - -D_DrawDirectoryWindow8: - Pop DI - Add DI, 160 - Inc BX - - Loop D_DrawDirectoryWindow3 - -D_DrawDirectoryWindow4: - Push CS - Pop DS - Assume DS:Disk - - Cmp NumDirectories, 0 - JE D_DrawDirectoryWindow6 - - Ret - -D_DrawDirectoryWindow6: - Mov SI, Offset NoDirsMsg - Mov DI, (44+13*80)*2 - Mov AH, 7 - Mov CX, 8 - -D_DrawDirectoryWindow7: - LodsB - StosW - - Loop D_DrawDirectoryWindow7 - - Ret - -EndP D_DrawDirectoryWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DrawDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Call S_GetDestination - - Mov AL, TopDrive - Mov BL, CurrentDrive - Cmp AL, BL - JBE D_DrawDriveWindow1 - - Mov AL, BL - -D_DrawDriveWindow1: - Mov CL, AL - Add CL, 20 - Cmp CL, BL - JA D_DrawDriveWindow2 - - Mov AL, BL - Sub AL, 20 - -D_DrawDriveWindow2: - Mov TopDrive, AL - Mov BL, AL - Mov CX, 21 - - Mov DI, (59+13*80)*2 - Xor BH, BH - -D_DrawDriveWindow3: - Cmp BL, NumDrives - JAE D_DrawDriveWindow5 - - Push DI - - Mov AL, [DrivesAvail+BX] - Add AL, 'A' - Mov SI, Offset DriveMsg - Mov [SI+6], AL - - Mov AH, 5 - Mov DX, 8 - -D_DrawDriveWindow4: - LodsB - StosW - - Dec DX - JNZ D_DrawDriveWindow4 - - Pop DI - Add DI, 160 - Inc BX - Loop D_DrawDriveWindow3 - -D_DrawDriveWindow5: - Ret - -EndP D_DrawDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFileHeader ; Given DS:SI = filename - - Push BP - - Xor BP, BP ; BP = 0 (no MMTSR) - - Mov AX, 4370h - Int 21h ; MMTSR installation check. - - Cmp EAX, 4352697Ah - JNE D_LoadFileHeader2 - - Mov AX, 4372h - Int 21h ; Disable MMTSR - - Inc BP - -D_LoadFileHeader2: - Mov DX, SI - Mov AX, 3D00h - Int 21h ; Open File - JC D_LoadFileHeader1 - - Mov BX, AX ; BX = file handle - - Push DS - Pop ES - Mov DI, 60000 - Mov CX, 5536 - Xor AL, AL - Rep StosB ; Clear data area first... - - Mov AH, 3Fh - Mov CX, 5536 - Mov DX, 60000 - Int 21h - PushF - - JC D_LoadFileHeader5 - Test BP, BP - JZ D_LoadFileHeader5 - - Cmp DWord Ptr [DS:60000], 'CRiz' - JNE D_LoadFileHeader5 - - Cmp DWord Ptr [DS:60004], 'aiNO' - JNE D_LoadFileHeader5 - ; OK.. have a MMCMPed file. - Mov AX, 4200h - Mov DX, [DS:60018] - Mov CX, [DS:60020] - Int 21h - - Mov AH, 3Fh - Mov CX, 4 - Mov DX, 60000 - Int 21h - Cmp AX, CX - JNE D_LoadFileHeader5 - - Mov AX, 4200h - Mov DX, [DS:60000] - Mov CX, [DS:60002] - Int 21h ; Seek to offset in file. - - Mov AH, 3Fh - Mov CX, 28 - Mov DX, 60000 - Int 21h - Cmp AX, CX - JNE D_LoadFileHeader5 - - Mov AX, [DS:60014] - ShR AX, 4 - And AL, 7 - JNZ D_LoadFileHeader5 - - PopF - Mov AH, 3Fh - Mov CX, 5536 - Mov DX, 60000 - Int 21h - PushF - -D_LoadFileHeader5: - Mov AH, 3Eh ; Close file - Int 21h - -D_LoadFileHeader4: - Test BP, BP - JZ D_LoadFileHeader3 - ; Reenable MMTSR - Mov AX, 4371h - Int 21h - -D_LoadFileHeader3: - PopF - - Pop BP - StI ; For problems with MMTSR - Ret - -D_LoadFileHeader1: - StC - PushF - Jmp D_LoadFileHeader4 - -EndP D_LoadFileHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadModuleHeader - - Mov DS, DiskDataArea - Assume DS:Nothing - - Add BX, BX - Mov SI, [BX] - Add SI, 8 - - Call D_LoadFileHeader - - Ret - -EndP D_LoadModuleHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadSongNames Far ; Part of idle list. - - Call K_IsAnyKeyDown - And AL, AL - JNZ D_LoadSongNames2 - - Call GetKeyboardLock - And AL, AL - JNZ D_LoadSongNames2 - - Push CS - Pop DS - Assume DS:Disk - - Mov BX, LoadSongNameCount - Cmp BX, NumFiles - JB D_LoadSongNames1 - -D_LoadSongNames2: - Xor AX, AX ; No redraw screen. - Ret - -D_LoadSongNames1: - Inc LoadSongNameCount - - Call D_LoadModuleHeader - JC D_LoadSongNames3 - - Call D_GetSongNameModuleType - -D_LoadSongNames3: - - Mov AX, 1 ; Signify redraw screen - Ret - -EndP D_LoadSongNames - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PreFileWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov AX, CurrentFile - Sub AX, TopFile - Add AX, 13 - Mov BX, 160 - Mul BX - - Call S_GetDestination - - LEA DI, [EAX+6] - Mov CX, 38 - -D_PreFileWindow1: - Mov AX, [ES:DI] - Cmp CX, 26 - -; Cmp AL, 168 - JNE D_PreFileWindow2 - - Mov AH, 32h - Jmp D_PreFileWindow3 - -D_PreFileWindow2: - Mov AH, 30h - -D_PreFileWindow3: - StosW - - Loop D_PreFileWindow1 - - Mov DI, (51+37*80)*2 - Xor AH, AH - Mov AL, CurrentSearchPos - LEA DI, [EDI+EAX*2+1] - Mov AL, 60h - StosB - - Ret - -EndP D_PreFileWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PreDirectoryWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov AX, CurrentDirectory - Sub AX, TopDirectory - Add AX, 13 - Mov BX, 160 - Mul BX - - Call S_GetDestination - - LEA DI, [EAX+88] - - Mov CX, 12 - -D_PreDirectoryWindow1: - Mov AX, [ES:DI] - Mov AH, 30h - StosW - - Loop D_PreDirectoryWindow1 - - Ret - -EndP D_PreDirectoryWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PreDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov AL, CurrentDrive - Sub AL, TopDrive - Add AL, 13 - Mov AH, 160 - Mul AH - - Call S_GetDestination - LEA DI, [EAX+118] - Mov CX, 8 - -D_PreDriveWindow1: - Mov AX, [ES:DI] - Mov AH, 30h - StosW - - Loop D_PreDriveWindow1 - - Ret - -EndP D_PreDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadFileOpenErrorMsg Far - - Mov DI, (4+16*80)*2 - Mov AH, 4 - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset OpenErrorMsg - - Call S_DrawString - - Mov AX, 1 - Ret - -EndP D_LoadFileOpenErrorMsg - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_Decompress16BitData - -; Register usage: -; BX = LastValue -; CH = Bitdepth -; CL = 16-Bitdepth, 0 for Bitdepth > 16 -; DL = Bitsread -; DH = scratch - - PushAD - Mov BP, CX - Mov CX, 1100h - ShR BP, 1 - Xor DX, DX - Xor BX, BX - -D_Decompress16BitData1: - Push CX - - Mov EAX, [SI] - Mov CL, DL - ShR EAX, CL - - Add DL, CH - Mov CX, DX - ShR CX, 3 - Add SI, CX - And DL, 7 - - Pop CX - - Cmp CH, 6 - JA D_Decompress16BitA - - ShL EAX, CL - Cmp AX, 8000h - JE D_Decompress16BitDepthChange1 - -D_Decompress16BitD: - SAR AX, CL - -D_Decompress16BitC: - Add BX, AX - Mov [ES:DI], BX - ScasW -; Add DI, 2 - - Dec BP - JNZ D_Decompress16BitData1 - - PopAD - Ret - -D_Decompress16BitDepthChange1: - ShR EAX, 16 - And AL, 15 - - Inc AX - -; Advance bits - Add DL, 4 - -D_Decompress16BitDepthChange3: - Cmp AL, CH - SBB AL, 0FFh - Mov CL, 16 - Mov CH, AL - Sub CL, AL - AdC CL, 0 - - Jmp D_Decompress16BitData1 - -D_Decompress16BitA: - Cmp CH, 16 - JA D_Decompress16BitB - - Push DX - Mov DX, 0FFFFh - ShR DX, CL - And AX, DX - ShR DX, 1 - Add DX, 8 - Cmp AX, DX - JA D_Decompress16BitE - Sub DX, 16 - Cmp AX, DX - JBE D_Decompress16BitE - - Sub AX, DX - Pop DX - Jmp D_Decompress16BitDepthChange3 - -D_Decompress16BitE: - Pop DX - ShL AX, CL - Jmp D_Decompress16BitD - -D_Decompress16BitB: - Test EAX, 10000h - JZ D_Decompress16BitC - - Mov CL, 16 - Inc AX - - Sub CL, AL - Mov CH, AL - - Jmp D_Decompress16BitData1 - -EndP D_Decompress16BitData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_Decompress8BitData ; DS:SI = source - ; ES:DI = destination - ; CX = count. - - PushA - Mov BP, CX ; BP = counter; - - Mov BX, 900h - Xor CX, CX - Xor DX, DX - -; Register usage: -; BH = Bitdepth -; BL = lastvalue -; CL = 8-bitdepth, undefined for bitdepth > 8 -; CH = Bitsread - -; DX = scratch - -D_Decompress8BitData1: - Push CX - Mov AX, [SI] - Mov CL, CH - -; Get bits loaded into AX properly. - ShR AX, CL - Pop CX - -; Advance SI as necessary. - Add CH, BH - Mov DL, CH - And CH, 7 - ShR DL, 3 - Add SI, DX - - Cmp BH, 6 - JA D_Decompress8BitA - - ShL AX, CL - - Cmp AL, 80h - JE D_Decompress8BitDepthChange1 - -D_Decompress8BitWriteData2: - SAR AL, CL - -D_Decompress8BitWriteData: - Add BL, AL - Mov [ES:DI], BL - - Inc DI - Dec BP - - JNZ D_Decompress8BitData1 - PopA - Ret - -D_Decompress8BitDepthChange1: - Mov AL, AH - Add CH, 3 - - And AL, 7 - Mov DL, CH - - And CH, 7 - ShR DL, 3 - - Add SI, DX - Jmp D_Decompress8BitD - -D_Decompress8BitA: - Cmp BH, 8 - JA D_Decompress8BitC - JE D_Decompress8BitB - - ShL AL, 1 - Cmp AL, 78h - JB D_Decompress8BitWriteData2 - Cmp AL, 86h - JA D_Decompress8BitWriteData2 - - ShR AL, 1 - Sub AL, 3Ch - Jmp D_Decompress8BitD - -D_Decompress8BitB: - Cmp AL, 7Ch - JB D_Decompress8BitWriteData - Cmp AL, 83h - JA D_Decompress8BitWriteData - - Sub AL, 7Ch - -D_Decompress8BitD: - Mov CL, 8 - Inc AX - - Cmp AL, BH - SBB AL, 0FFh - Mov BH, AL - Sub CL, AL - AdC CL, 0 - - Jmp D_Decompress8BitData1 - -D_Decompress8BitC: ; 9 bit representation - And AX, 1FFh - - Test AX, 100h - JZ D_Decompress8BitWriteData - - Jmp D_Decompress8BitD - -EndP D_Decompress8BitData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -TempData DW 0 -DisableStereoMenu DB 0 - -Proc D_LoadSampleData ; DS:SI points to sample header - ; AX = sample number (0 based) - - Push DS - Push ES - PushAD - - Mov EDX, [DS:SI+30h] - And EDX, EDX - JZ D_NoLoadSample - - Mov CL, [SI+12h] - Mov BP, [SI+2Eh] - - And Byte Ptr [SI+12h], Not 0Ch - Mov Byte Ptr [SI+2Eh], 1 - And BP, 0FFh - - ShL BP, 1 - Mov CH, CL - And CX, 802h - ShL CH, 4 - ShR CL, 1 - Or BP, CX ; BP flags: - ; 1: 16 bit - ; 2: Convert unsigned->signed - ; 4: Swap bytes - ; 8: Delta values. - ; 16: Byte delta values - ; 32: 12-bit sample. - ; 64: Stereo prompt. - ; 8000h: Compressed. - - Xor SI, SI - - Test BP, 1 - JZ D_LoadSampleData5 - - Add EDX, EDX - -D_LoadSampleData5: - Test BP, 64 - JZ D_LoadSampleDataNotStereo - - Cmp CS:DisableStereoMenu, 0 - JNE D_NoStereoMenu - - PushAD - Push DS ES - - Mov DI, Offset O1_StereoSampleList - Mov CX, 0FFFFh - Call M_Object1List - - Mov CS:TempData, DX - - Pop ES DS - PopAD - - Or BP, CS:TempData ; 64 = left - ; 64+128 = right -D_NoStereoMenu: - Add EDX, EDX - -D_LoadSampleDataNotStereo: - Call Music_AllocateSample ; AX = sample no. - ; EDX = length. - ; returns ES:DI. - Inc AX - - Mov EDI, EDX - - Mov DX, ES - Test DX, DX - JZ D_LoadSampleData1 - - Push DS - - Xor CX, CX ; Start with page 0 - -D_LoadSampleData3: - Push AX ; AX = sample no. - Push CX ; CH = page no. - Push EDI ; EDI = bytes remaining - ; SI = delta accumulator - ; BX = file pointer - - Push SI - Call Music_GetSampleLocation - Mov DX, SI - Pop SI - - Mov ECX, 32768 - Cmp EDI, ECX - JA D_LoadSampleData4 - - Mov CX, DI - -D_LoadSampleData4: - Test BP, 32 ; 12 bit format? - JZ NotTX12BitSampleA - - And ECX, 0FFFFh - LEA ECX, [ECX*2+ECX] - Add ECX, 3 - ShR ECX, 2 ; ECX = bytes to read. - -NotTX12BitSampleA: - -; DS:DX point to buffer. For compressed samples, use -; patterndata area. - - Test BP, BP - JNS LoadCompressedSample1 - - Push DS - Push CX - Push DX - - Mov DX, Pattern - Mov DS, DX - Assume DS:Pattern - - Mov DS, Word Ptr [PatternDataArea] - Assume DS:Nothing - - Xor DX, DX - Mov CX, 2 - Mov AH, 3Fh - Int 21h - Mov CX, [DS:0] ; Bytes to read. - Xor DX, DX ; Compressed chunk. - -LoadCompressedSample1: - - Mov AH, 3Fh - Int 21h - -; Now to decompress samples, if required. - - Test BP, BP - JNS LoadCompressedSample3 - - Pop DI - Pop CX - Pop ES - Xor SI, SI - - Test BP, 1 - JNZ LoadCompressedSample2 - - Call D_Decompress8BitData ; 8 bit decode. - Jmp LoadCompressedSample4 - -LoadCompressedSample2: ; 16 bit decode - Call D_Decompress16BitData - -LoadCompressedSample4: - Push ES - Pop DS - - Xor SI, SI - Jmp SecondDelta - -LoadCompressedSample3: - Test BP, 32 ; 12-bit sample? - JZ NotTX12BitSampleB - ; CX = number of bytes read. - ; = 3*2 number of sample read - Push SI - Push DX - - Add AX, 2 - Mov CX, 3 - Div CX - Mov CX, AX - Pop DX - - LEA SI, [EAX*2+EAX] ; SI = AX * 3 - LEA DI, [EAX*4+EDX] - Add SI, DX - - Test CX, CX - JZ ConvertTXSample2 - - Push CX - -ConvertTXSample1: - Sub SI, 3 - Sub DI, 4 - - Mov AX, [SI+1] - ShL AL, 4 - ShL EAX, 16 - Mov AH, [SI] - Mov AL, [SI+1] - And AL, 0F0h - Mov [DI], EAX - - Loop ConvertTXSample1 - - Pop CX - Pop SI - ShL CX, 1 - Jmp D_LoadSampleData10 - -ConvertTXSample2: - Pop SI - Jmp D_LoadSampleData6 - -NotTX12BitSampleB: - Mov CX, AX ; CX = number of bytes read - -SecondDelta: - Test BP, 1 ; 16 bit? - JZ D_LoadSampleData10 - - ShR CX, 1 - -D_LoadSampleData10: - Mov AX, BP - And AX, 5 ; 16 bit and BSwap? - Cmp AX, 5 - JNE D_LoadSampleData11 - - Push CX - Mov DI, DX - -D_LoadSampleData12: - Mov AX, [DI] - XChg AH, AL - Mov [DI], AX - ScasW -; Add DI, 2 - Loop D_LoadSampleData12 - - Pop CX - -D_LoadSampleData11: - Test BP, 24 ; Delta values? - JZ D_LoadSampleData8 - - Push CX - Mov AX, SI - Mov DI, DX - - Test BP, 1 ; 8 bit sample? - JZ D_LoadSampleData9 - - Test BP, 16 ; Byte enforced? - JZ D_LoadSampleData7 - - Add CX, CX - Jmp D_LoadSampleData9 - -D_LoadSampleData7: ; 16 bit delta - Add AX, [DI] - Mov [DI], AX - -; Add DI, 2 - ScasW - Loop D_LoadSampleData7 - - Mov SI, AX - Pop CX - - Jmp D_LoadSampleData8 - -D_LoadSampleData9: ; 8 bit delta - Add AH, [DI] - Mov [DI], AH - Inc DI - Loop D_LoadSampleData9 - - Mov SI, AX - Pop CX - -D_LoadSampleData8: - Test BP, 2 ; unsigned->signed? - JNZ D_LoadSampleData6 - - Push CX - Mov DI, DX - - Test BP, 1 - JNZ D_LoadSampleData14 - -D_LoadSampleData13: ; 8 bit - Xor Byte Ptr [DI], 80h - Inc DI - Loop D_LoadSampleData13 - - Pop CX - - Jmp D_LoadSampleData6 - -D_LoadSampleData14: ; 16 bit.. - Xor Word Ptr [DI], 8000h -; Add DI, 2 - ScasW - Loop D_LoadSampleData14 - - Pop CX - -D_LoadSampleData6: - Test BP, 64 ; Stereo? - JZ D_LoadSampleDataNoStereo - - Push SI ES - - Push DS - Pop ES - - Mov SI, DX - Mov DI, DX - - ShR CX, 1 - JZ D_LoadSampleDataEndStereo - - Test BP, 1 ; 8/16 bit? - JNZ D_LoadSampleDataStereo16BitStart - - Test BP, 128 - JZ D_LoadSampleDataStereo8Bit - - Inc SI - -D_LoadSampleDataStereo8Bit: - MovsB - Inc SI - Loop D_LoadSampleDataStereo8Bit - Jmp D_LoadSampleDataEndStereo - -D_LoadSampleDataStereo16BitStart: - Test BP, 128 - JZ D_LoadSampledataStereo16Bit - - LodsW - -D_LoadSampleDataStereo16Bit: - MovsW - LodsW - Loop D_LoadSampleDataStereo16Bit - -D_LoadSampleDataEndStereo: - Pop ES SI - - Pop EDI - Pop CX - Pop AX - - Inc CH - Jmp D_LoadSampleDataNextChain - -D_LoadSampleDataNoStereo: - Pop EDI - Pop CX - Pop AX - - Add CH, 2 - -D_LoadSampleDataNextChain: - Sub EDI, 32768 - JA D_LoadSampleData3 - - Pop DS - -D_NoLoadSample: - ClC - - PopAD - Pop ES - Pop DS - Ret - -D_LoadSampleData1: - PopAD - PushAD - - Mov AX, 4201h ; Advance file ptr. - Mov DX, [DS:SI+30h] - Mov CX, [DS:SI+32h] - Int 21h - - Call PEFunction_OutOfMemoryMessage - - PopAD - Pop ES - Pop DS - - StC - Ret - -EndP D_LoadSampleData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ConvertWriteData ; DS:DX points to data - ; BP = 1, convert, BP = 2, 16-bit - ; CX = number of bytes - - PushF - - Push AX - Push CX - Push SI - - Mov AX, 1 - Test BP, 2 - JZ ConvertWriteDataLoop1 - - Inc AX - Inc SI - ShR CX, 1 - -ConvertWriteDataLoop1: - JCXZ ConvertWriteDataLoop3 - -ConvertWriteDataLoop2: - Xor Byte Ptr [SI], 80h - Add SI, AX - Loop ConvertWriteDataLoop2 - -ConvertWriteDataLoop3: - Pop SI - Pop CX - Pop AX - -ConvertWriteData1: - PopF - Ret - -EndP ConvertWriteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveSampleDataConvert ; AX = sample number (1 based) - - PushAD - Push DS - Push ES - - Xor BP, BP - - Call Music_GetSampleLocation - Mov EDI, ECX - JZ D_SaveSampleDataConvert5 - - Add EDI, EDI - Or BP, 2 - -D_SaveSampleDataConvert5: - Xor CX, CX ; Start with page 0 - -D_SaveSampleDataConvert3: - Push AX ; AX = sample no. - Push CX ; CX = page no. - - Call Music_GetSampleLocation - Mov DX, SI - - Mov ECX, 32768 - Cmp EDI, ECX - JA D_SaveSampleDataConvert4 - - Mov CX, DI - -D_SaveSampleDataConvert4: - ClI - - Call ConvertWriteData - Call D_SaveBlock - Call ConvertWriteData - - StI - - Pop CX - Pop AX - - JC D_SaveSampleDataConvert2 - - Add CH, 2 - Sub EDI, 32768 - JA D_SaveSampleDataConvert3 - - DB 85h ; ClC -D_SaveSampleDataConvert2: - StC - Pop ES - Pop DS - PopAD - Ret - -EndP D_SaveSampleDataConvert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WriteBits ; CH = bits to write - ; CL = current bit. - ; BX = data. - ; ES:DI = output buffer. - ; EAX = buffer - ; BP = scratch - - Push CX - - Mov EBP, 1 - Mov CL, CH - ShL EBP, CL - Dec EBP - And EBX, EBP - - Pop CX - ShL EBX, CL - Add CL, CH - Or EAX, EBX - -D_WriteBits1: - Cmp CL, 8 - JB D_WriteBits2 - - StosB - ShR EAX, 8 - Sub CL, 8 - Jmp D_WriteBits1 - -D_WriteBits2: - Ret - -EndP WriteBits - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -; Data layout: -; DiskDataArea:16384 = deltas -; PatternDataArea:16384 = bittable -; PatternDataArea:0 = bufferlength -; PatternDataArea:2 = outputbuffer - -Proc D_SaveSampleDataCompressed ; AX = sample number, 1 based. - - PushAD - Push DS - Push ES - - Xor BP, BP - - Call Music_GetSampleLocation - Mov EDI, ECX - JZ D_SaveSampleDataCompressed5 - - Add EDI, EDI - Inc BP - -D_SaveSampleDataCompressed5: - Xor CX, CX ; Start with page 0 - -D_SaveSampleDataCompressed3: - Push AX ; AX = sample no. - Push CX ; CX = page no. - Push EDI - - Call Music_GetSampleLocation - - Mov ECX, 32768 - Cmp EDI, ECX - JA D_SaveSampleDataCompressed4 - - Mov CX, DI - -D_SaveSampleDataCompressed4: - Test BP, 1 - JZ D_SaveSampleCompressed8BitSample - - ShR CX, 1 - -D_SaveSampleCompressed8BitSample: -; DS:SI = sample location -; Calculate delats first. - Push BX - Push BP - Push CX - - Mov ES, CS:DiskDataArea - Mov DI, 16384 ; Offset in DiskDataArea - -IF DDCOMPRESS - Mov DX, 1 - - Cmp CS:SaveFormat, 3 - JNE D_SaveFormatNot215 - - Inc DX - -D_SaveFormatNot215: - -ENDIF - -D_CalculateDeltas: - Xor AH, AH ; AH = lastdata. - - Test BP, 1 - JZ D_Calculate8BitDeltas - - Xor BX, BX - -D_Calculate16BitDeltas: - LodsW - Sub AX, BX - Mov BX, [SI-2] - StosW - Loop D_Calculate16BitDeltas - - Jmp D_CalculateDeltaEnd - -D_Calculate8BitDeltas: - LodsB - Sub AL, AH - Mov AH, [SI-1] - StosB - Loop D_Calculate8BitDeltas - -D_CalculateDeltaEnd: - -IF DDCOMPRESS - Mov DI, 16384 - Pop CX - Push ES - Mov SI, DI - Pop DS - Push CX - - Dec DX - JNZ D_CalculateDeltas - - Push Pattern - Pop ES - Assume ES:Pattern - Mov ES, PatternDataArea - Assume ES:Nothing - -ELSE - - Pop CX - -; Now to create bittable. - - Push ES - Pop DS - - Push Pattern - Pop ES - Assume ES:Pattern - Mov ES, PatternDataArea - Assume ES:Nothing - - Push CX - - Mov SI, 16384 - Mov DI, SI -ENDIF - - Mov BH, 40 - Test BP, 1 - JZ D_GenerateBitTable1 - - Xor AX, AX - -D_Generate16BitTable1: - Mov BL, [SI+1] - Mov BH, 41 - Mov AL, [BX] - Mov DL, AL - And DL, 7 - Mov BL, [SI] - Add BH, DL - ShR AL, 3 - Add SI, 2 - Add AL, [BX] - StosW - - Loop D_Generate16BitTable1 - Pop CX - -; Minimise 16-bit table - Push ES - Pop DS - Mov Byte Ptr [DS:16382], 17 ; Starting boundary of 17. - Mov DL, 1 ; Scan for 1 bit first. - -D_Minimise16BitTable1: - Push CX - Xor AX, AX ; AX = consecutive values. - Mov SI, 16384 - -D_Minimise16BitTable2: - Test AX, AX - JNZ D_Minimise16BitTable3 - -; Not in consecutive sequence. - Cmp DL, [SI] - JNE D_Minimise16BitTableEnd - Mov DI, SI ; First value - -D_Minimise16BitTable4: - Inc AX - Jmp D_Minimise16BitTableEnd - -D_Minimise16BitTable3: - Cmp DL, [SI] - JE D_Minimise16BitTable4 - -; OK.. outside of bittable - Cmp AX, 33 - JA D_Minimise16BitTable5 - - Mov BL, [SI] - Mov BH, [DI-2] - - Cmp BL, BH - JBE D_Minimise16BitTable6 - - XChg BL, BH - -D_Minimise16BitTable6: - Cmp BL, DL - JA D_Minimise16BitTable7 - XChg BL, BH - - Cmp BL, DL - JB D_Minimise16BitTable5 - -D_Minimise16BitTable7: ; BL = minbits. - Push CX - Push DX - - Mov CH, BL - Mov DH, BL ; DH = minbits. - - Cmp AX, 1 - JE D_Minimise16BitTableForce - - Cmp BL, 5 - JA D_Minimise16BitTable8 - - Add BL, 4 - -D_Minimise16BitTable8: - Cmp BH, 5 - JA D_Minimise16BitTable9 - - Add BL, 4 - -D_Minimise16BitTable9: - Mov CL, CH - And BX, 0FFh ; BX = bits to effect conversion - - Cmp AX, BX - JA D_Minimise16BitTable13 - - And CX, 0FFh ; CX = minbits. - - Sub CL, DL - Push DX - Mul CX ; DX:AX = bits saved. - Pop CX - Test DX, DX - JNZ D_Minimise16BitTable13 - Cmp AX, BX - JA D_Minimise16BitTable13 - -D_Minimise16BitTableForce: -; Have to change values from DI -> SI with minbits. - Mov AL, CH - Mov CX, SI - Sub CX, DI - ShR CX, 1 - Rep StosW - -D_Minimise16BitTable13: - Pop DX - Pop CX - -D_Minimise16BitTable5: - Xor AX, AX - -D_Minimise16BitTableEnd: - Add SI, 2 - Loop D_Minimise16BitTable2 - - Pop CX - - And DX, 0FFh - Inc DX - Cmp DX, 17 - JB D_Minimise16BitTable1 - -; Now to dump bits to buffer. - - Mov DX, CX - Mov DS, CS:DiskDataArea - Xor EAX, EAX - Mov DI, 2 - Mov SI, 16384 - Mov CX, 1100h - -; Convert 16 Bit Buffer. - -D_Convert16BitBuffer1: - Cmp CH, [ES:SI] ; BitsToWrite = BitTable? - JE D_Convert16BitBufferEnd - -; Need to change base - Cmp CH, 6 - JA D_Convert16BitBuffer2 - - Push CX - Mov BX, 1 - Mov CL, CH - Dec CL - ShL BX, CL - Pop CX - Call WriteBits - - Mov BL, [ES:SI] - Cmp CH, BL - SBB BL, 1 - Mov CH, 4 - Call WriteBits - Jmp D_Convert16BitBufferDepthChange - -D_Convert16BitBuffer2: - Cmp CH, 16 - JA D_Convert16BitBuffer3 - - Push CX - Mov EBX, 1 - Mov CL, CH - Dec CL - ShL EBX, CL - Sub BX, 9 - Add BL, [ES:SI] - AdC BH, 0 - Pop CX - - Cmp CH, [ES:SI] - SBB BL, 0 - Call WriteBits - Jmp D_Convert16BitBufferDepthChange - -D_Convert16BitBuffer3: - Mov EBX, 100FFh - Add BL, [ES:SI] - Call WriteBits - -D_Convert16BitBufferDepthChange: - Mov CH, [ES:SI] - -D_Convert16BitBufferEnd: - MovZX EBX, Word Ptr [SI] - Call WriteBits - - Add SI, 2 - Dec DX - JNZ D_Convert16BitBuffer1 - - Jmp D_ConvertBitsFinished - - -D_GenerateBitTable1: - Mov BL, [SI] - Inc SI - Mov AL, [BX] - StosB - Loop D_GenerateBitTable1 - -D_GenerateBitTableDone: - -; OK bit table is generated. - Pop CX - -; Have to minimise bit table (in patterndataarea) - - - Push ES - Pop DS - Mov Byte Ptr [DS:16383], 9 ; Starting boundary of 9. - Mov DL, 1 ; Scan for 1 bit first. - -D_MinimiseBitTable1: - Push CX - Xor AX, AX ; AX = consecutive values. - Mov SI, 16384 - -D_MinimiseBitTable2: - Test AX, AX - JNZ D_MinimiseBitTable3 - -; Not in consecutive sequence. - Cmp DL, [SI] - JNE D_MinimiseBitTableEnd - Mov DI, SI ; First value - -D_MinimiseBitTable4: - Inc AX - Jmp D_MinimiseBitTableEnd - -D_MinimiseBitTable3: - Cmp DL, [SI] - JE D_MinimiseBitTable4 - -; OK.. outside of bittable - Cmp AX, 17 - JA D_MinimiseBitTable5 - - Mov BL, [SI] - Mov BH, [DI-1] - - Cmp BL, BH - JBE D_MinimiseBitTable6 - - XChg BL, BH - -D_MinimiseBitTable6: - Cmp BL, DL - JA D_MinimiseBitTable7 - XChg BL, BH - - Cmp BL, DL - JB D_MinimiseBitTable5 - -D_MinimiseBitTable7: ; BL = minbits. - Push CX - Push DX - - Mov DH, BL ; DH = minbits. - Mov CH, BL - - Cmp AX, 1 - JE D_MinimiseBitTableForce - - Cmp BL, 5 - JA D_MinimiseBitTable8 - - Add BL, 3 - -D_MinimiseBitTable8: - Cmp BH, 5 - JA D_MinimiseBitTable9 - - Add BL, 3 - -D_MinimiseBitTable9: - Mov CL, CH ; CL = minbits. - And BX, 0FFh ; BX = bits to effect conversion - - Cmp AX, BX - JA D_MinimiseBitTable13 - - And CX, 0FFh ; CX = minbits. - - Sub CL, DL - Push DX - Mul CX ; DX:AX = bits saved. - Pop CX - Test DX, DX - JNZ D_MinimiseBitTable13 - Cmp AX, BX - JA D_MinimiseBitTable13 - -; Have to change values from DI -> SI with minbits. -D_MinimiseBitTableForce: - Mov AL, CH - Mov CX, SI - Sub CX, DI - Rep StosB - -D_MinimiseBitTable13: - Pop DX - Pop CX - -D_MinimiseBitTable5: - Xor AX, AX - -D_MinimiseBitTableEnd: - Inc SI - Loop D_MinimiseBitTable2 - - Pop CX - - And DX, 0FFh - Inc DX - Cmp DX, 9 - JB D_MinimiseBitTable1 - -; Now to dump bits to buffer. - - Mov DX, CX - Mov DS, CS:DiskDataArea - Xor EAX, EAX - Mov DI, 2 - Mov SI, 16384 - Mov CX, 900h - -D_ConvertBitBuffer1: ; CL = current bit - ; CH = bitstowrite - ; AX = output buffer - ; DX = bytes to process - ; SI = DS:source/ES:bittable - ; DI = destination - - Cmp CH, [ES:SI] ; BitsToWrite = BitTable? - JE D_ConvertBitBufferEnd - -; Need to change base - Cmp CH, 6 - JA D_ConvertBitBuffer2 - - Push CX - Mov BX, 1 - Mov CL, CH - Dec CL - ShL BX, CL - Pop CX - Call WriteBits - - Mov BL, [ES:SI] - Cmp CH, BL - SBB BL, 1 - Mov CH, 3 - Call WriteBits - Jmp D_ConvertBitBufferDepthChange - -D_ConvertBitBuffer2: - Cmp CH, 8 - JA D_ConvertBitBuffer3 - - Push CX - Mov BX, 1 - Mov CL, CH - Dec CL - ShL BX, CL - Sub BL, 5 - Add BL, [ES:SI] - Pop CX - - Cmp CH, [ES:SI] - SBB BL, 0 - Call WriteBits - Jmp D_ConvertBitBufferDepthChange - -D_ConvertBitBuffer3: - Mov BX, 1FFh - Add BL, [ES:SI] - Call WriteBits - -D_ConvertBitBufferDepthChange: - Mov CH, [ES:SI] - -D_ConvertBitBufferEnd: - MovZX BX, Byte Ptr [SI] - Call WriteBits - - Inc SI - Dec DX - JNZ D_ConvertBitBuffer1 - -D_ConvertBitsFinished: - Xor CH, CH - Add CL, 7 - ShR CL, 3 - Rep StosB ; Write 0 or 1 bytes. - -; DI = end of block = size; - - Pop BP - Pop BX - - Mov CX, DI - Sub DI, 2 - - Push ES - Pop DS - - Mov [DS:0], DI - - Xor DX, DX - Call D_SaveBlock - - Pop EDI - Pop CX - Pop AX - - JC D_SaveSampleDataCompressed2 - - Add CH, 2 - Sub EDI, 32768 - JA D_SaveSampleDataCompressed3 - - DB 85h -D_SaveSampleDataCompressed2: - StC - Pop ES - Pop DS - PopAD - Ret - -EndP D_SaveSampleDataCompressed - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveSampleData ; AX = sample number (1 based) - - PushAD - Push DS - Push ES - - Call Music_GetSampleLocation - Mov EDI, ECX - JZ D_SaveSampleData1 - - Add EDI, EDI - -D_SaveSampleData1: - Xor CX, CX ; Start with page 0 - -D_SaveSampleData3: - Push AX ; AX = sample no. - Push CX ; CX = page no. - - Call Music_GetSampleLocation - Mov DX, SI - - Mov ECX, 32768 - Cmp EDI, ECX - JA D_SaveSampleData4 - - Mov CX, DI - -D_SaveSampleData4: - Call D_SaveBlock - Pop CX - Pop AX - JC D_SaveSampleData2 - - Add CH, 2 - Sub EDI, 32768 - JA D_SaveSampleData3 - - DB 85h -D_SaveSampleData2: - StC - Pop ES - Pop DS - PopAD - - Ret - -EndP D_SaveSampleData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include it_timer.inc -include it_d_rm.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_CheckOverWrite ; DS:DX points to filename - ; Returns Carry set if not ok - - Mov CX, 6 - Mov AH, 4Eh - Int 21h - JC D_CheckOverWrite1 ; File doesn't exist. - - ; File Already exists... - - Push BX - Push DS - Push SI - - Mov DI, Offset O1_ConfirmOverWriteList - Mov CX, 4 - Call M_Object1List - ; DX = 0 -> don't overwrite - ; DX = 1 -> overwrite - Pop SI - Pop DS - Pop BX - - Test DX, DX - JZ D_CheckOverWrite2 - -D_CheckOverWrite1: - DB 85h - -D_CheckOverWrite2: - StC - Ret - - -EndP D_CheckOverWrite - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostFileSaveWindow Far - -; Cmp DX, 13 - Cmp CX, 11Ch - JNE D_PostFileWindow - ; Save file routines. - Mov DS, CS:DiskDataArea - Mov SI, CurrentFile - Add SI, SI - Mov SI, [SI] - Add SI, 8 ; Filename - Mov DI, Offset SaveFileName - - Push CS - Pop ES - -D_PostFileSaveWindow1: - LodsB - StosB - And AL, AL - JNZ D_PostFileSaveWindow1 - -D_PostFileSaveWindow2: - Push CS - Pop DS - Assume DS:Disk - - Mov DX, Offset SaveFileName - Call D_CheckOverWrite - JNC D_PostFileSaveWindow3 ; OK to write! - - Mov AX, 1 - Ret - -D_PostFileSaveWindow3: - Cmp SaveFormat, 1 - JE D_PostFileSaveWindow4 - - Jmp D_SaveFileITModule - -D_PostFileSaveWindow4: - Jmp D_SaveFileS3MModule - -EndP D_PostFileSaveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostFileLoadWindow Far - -; Cmp DX, 13 - Cmp CX, 11Ch - JNE D_PostFileWindow - ; Load file routines. - -D_PostFileLoadWindowLink: - EnsureNoNetwork - - Call PECheckModified - - Call Music_Stop - - Mov BX, CS:CurrentFile - Call D_LoadModuleHeader - JC D_PostFileLoadWindow1 - - Push DI - Call D_GetSongNameModuleType - Pop DI - -IF TUTORIAL -ELSE - Mov BX, CS:CurrentFile - Add BX, BX - Mov BX, [BX] - Mov AX, [BX+23] - - Cmp AX, 1 - JBE D_PostFileLoadWindow1 - - Cmp AX, 3 - JB D_LoadFileImpulseModule - JE D_PostFileLoadWindow1 - - Cmp AX, 5 - JB D_LoadFileS3MModule - JE D_LoadFileXMModule - - Cmp AX, 7 - JB D_LoadFile669Module - JE D_LoadFileImpulseModule - - Cmp AX, 8 - JBE D_PostFileLoadWindow1 - - Cmp AX, 17 - JBE D_LoadFileMODModule - - Cmp AX, 18 - JE D_LoadFileMTMModule -ENDIF - -D_PostFileLoadWindow1: - Mov AX, 1 - Ret - -EndP D_PostFileLoadWindow - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostFileWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset FileWindowKeys - Call M_FunctionDivider - JC D_PostFileWindow1 - - Jmp [SI] - -D_PostFileWindow1: - Cmp CX, 10Eh - JNE D_PostFileWindow15 - -D_PostFileWindowBackspace: - Mov BL, CurrentSearchPos - Test BL, BL - JZ D_PostFileWindow14 - - Dec BX - Xor BH, BH - Mov [Search+BX], 0 - Mov CurrentSearchPos, BL - -D_PostFileWindow14: - Mov AX, 1 - Ret - -D_PostFileWindow15: - Test CL, CL - JZ D_PostFileWindow20 - Cmp DL, 33 - JB D_PostFileWindow20 - - Cmp CurrentSearchPos, 13 - JAE D_PostFileWindow17 - - Cmp DL, 'a' - JB D_PostFileWindow16 - - Cmp DL, 'z' - JA D_PostFileWindow16 - - Sub DL, 32 - -D_PostFileWindow16: - Mov BL, CurrentSearchPos - Xor BH, BH - Mov [Search+BX], DL - - Inc CurrentSearchPos - ; Now do the search. - Xor DX, DX - - Mov ES, DiskDataArea - -D_PostFileWindow18: - Cmp DX, NumFiles - JAE D_PostFileWindow17 - - Mov BX, DX - Add BX, BX - Mov DI, [ES:BX] - Add DI, 8 - Mov SI, Offset Search - Mov CX, 13 - -D_PostFileWindow21: - Cmp Byte Ptr [DS:SI], 0 - JE D_PostFileWindow19 - - CmpsB - JE D_PostFileWindow21 - - Inc DX - Jmp D_PostFileWindow18 - -D_PostFileWindow19: - Mov CurrentFile, DX - -D_PostFileWindow17: - Mov AX, 1 - Ret - -D_PostFileWindow20: - Xor AX, AX - Ret - -EndP D_PostFileWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostDirectoryWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset DirectoryWindowKeys - Call M_FunctionDivider - JC D_PostDirectoryWindow1 - - Jmp [SI] - -D_PostDirectoryWindow1: - Cmp CX, 10Eh - JNE D_PostDirectoryWindow15 - - Jmp D_PostFileWindowBackspace - -D_PostDirectoryWindow15: - Test CL, CL - JZ D_PostDirectoryWindow20 - Cmp DL, 33 - JB D_PostDirectoryWindow20 - - Cmp CurrentSearchPos, 13 - JAE D_PostDirectoryWindow17 - - Cmp DL, 'a' - JB D_PostDirectoryWindow16 - - Cmp DL, 'z' - JA D_PostDirectoryWindow16 - - Sub DL, 32 - -D_PostDirectoryWindow16: - Mov BL, CurrentSearchPos - Xor BH, BH - Mov [Search+BX], DL - - Inc CurrentSearchPos - ; Now do the search. - Xor DX, DX - - Mov ES, DiskDataArea - -D_PostDirectoryWindow18: - Cmp DX, NumDirectories - JAE D_PostFileWindow17 - - Mov BX, DX - Add BX, NumFiles - Add BX, BX - Mov DI, [ES:BX] - Add DI, 8 - Mov SI, Offset Search - Mov CX, 13 - -D_PostDirectoryWindow21: - Cmp Byte Ptr [DS:SI], 0 - JE D_PostDirectoryWindow19 - - CmpsB - JE D_PostDirectoryWindow21 - - Inc DX - Jmp D_PostDirectoryWindow18 - -D_PostDirectoryWindow19: - Mov CurrentDirectory, DX - -D_PostDirectoryWindow17: - Mov AX, 1 - Ret - -D_PostDirectoryWindow20: - Xor AX, AX - Ret - -EndP D_PostDirectoryWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset DriveWindowKeys - Call M_FunctionDivider - JC D_PostDriveWindow1 - - Jmp [SI] - -D_PostDriveWindow1: - Xor AX, AX - Ret - -EndP D_PostDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostSaveDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset SaveDriveWindowKeys - Call M_FunctionDivider - JC D_PostSaveDriveWindow1 - - Jmp [SI] - -D_PostSaveDriveWindow1: - Xor AX, AX - Ret - -EndP D_PostSaveDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_NewSpecifier Far - - Push CS - Pop DS - Assume DS:Disk - - Xor BX, BX - Mov SI, Offset FileSpecifier - Mov Specific, 1 - -D_NewSpecifier3: - LodsB - And AL, AL - JZ D_NewSpecifier4 - - Cmp AL, '\' - JE D_NewSpecifier10 - Cmp AL, ':' - JE D_NewSpecifier10 - - Jmp D_NewSpecifier3 - -D_NewSpecifier10: - Mov BX, SI - Jmp D_NewSpecifier3 - -D_NewSpecifier4: - And BX, BX - JZ D_NewSpecifier5 - - Push ES - Push DI - - Push CS - Pop ES - - Mov SI, Offset FileSpecifier - Mov DI, Offset SongDirectory - -D_NewSpecifier7: - MovsB - Cmp SI, BX - JB D_NewSpecifier7 - - Xor AL, AL - Cmp Byte Ptr [DI-1], '\' - JNE D_NewSpecifier11 - - Dec DI - -D_NewSpecifier11: - StosB - - Mov DI, Offset FileSpecifier - -D_NewSpecifier6: - LodsB - StosB - And AL, AL - JNZ D_NewSpecifier6 - - Cmp DI, Offset FileSpecifier+1 - JNE D_NewSpecifier14 - - Mov Specific, 0 - -D_NewSpecifier14: - Pop DI - Pop ES - - -D_NewSpecifier5: - Mov CurrentFile, 0 - Call D_InitLoadModule2 - -D_NewSpecifier12: - Cmp NumFiles, 0 - JE D_NewSpecifier1 - - Mov Word Ptr [ES:DI], 12 - -D_NewSpecifier1: - Cmp Specific, 1 - JNE D_NewSpecifier2 - - Cmp NumFiles, 1 - JNE D_NewSpecifier2 - - Mov SI, Offset FileSpecifier - -D_NewSpecifier8: - LodsB - And AL, AL - JZ D_NewSpecifier9 - - Cmp AL, '*' - JE D_NewSpecifier2 - Cmp AL, '?' - JE D_NewSpecifier2 - Jmp D_NewSpecifier8 - -D_NewSpecifier9: - Jmp D_PostFileLoadWindowLink - -D_NewSpecifier2: - - Mov AX, 1 - Ret - -EndP D_NewSpecifier - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_NewDirectory Far - -; Mov SI, Offset SongDirectory -; Push CS -; Pop DS -; -; Call S_SetDriveDirectory - - Mov CurrentFile, 0 - Call D_InitLoadModule - - Cmp NumFiles, 0 - JE D_NewDirectory1 - - Mov Word Ptr [ES:DI], 12 - -D_NewDirectory1: - Mov AX, 1 - Ret - -EndP D_NewDirectory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_ClearFileSpecifier Far - - Push ES - Push DI - Push AX - Push CX - - Push CS - Pop ES - Mov DI, Offset FileSpecifier - Xor AX, AX - Mov CX, 65 - Rep StosB - - Pop CX - Pop AX - Pop DI - Pop ES - - Ret - -EndP D_ClearFileSpecifier - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveModule Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset FileSpecifier - Cmp Byte Ptr [SI], 0 - JNE D_SaveModule9 - - Call D_NewSpecifier - Call D_ClearFileSpecifier - - Mov AX, 1 - Ret - -D_SaveModule9: - Push CS - Pop ES - Xor BX, BX - -D_SaveModule1: - LodsB - And AL, AL - JZ D_SaveModule3 - - Cmp AL, '?' - JE D_NewSpecifier - Cmp AL, '*' - JE D_NewSpecifier - Cmp AL, ':' - JE D_SaveModule2 - Cmp AL, '\' - JE D_SaveModule2 - - Jmp D_SaveModule1 - -D_SaveModule2: - Mov BX, SI - Jmp D_SaveModule1 - -D_SaveModule3: - And BX, BX - JZ D_SaveModule7 - - Mov SI, Offset FileSpecifier - Mov DI, Offset SongDirectory - -D_SaveModule4: - MovsB - Cmp SI, BX - JB D_SaveModule4 - - Xor AL, AL - Cmp Byte Ptr [DI-1], '\' - JNE D_SaveModule5 - - Dec DI - -D_SaveModule5: - StosB - - Mov DI, Offset FileSpecifier - -D_SaveModule6: - LodsB - StosB - And AL, AL - JNZ D_SaveModule6 - -D_SaveModule7: ; Time to save a module. - Mov DI, Offset SaveFileName - Mov SI, Offset FileSpecifier - -D_SaveModule8: - LodsB - StosB - And AL, AL - JNZ D_SaveModule8 - - ; FileName contains file to - ; save - Mov SI, Offset SongDirectory - Call D_SetDriveDirectory - - Mov SI, Offset SaveFileName - Xor BX, BX - -D_SaveModule10: - LodsB - Cmp AL, '.' - JNE D_SaveModule11 - - Mov BX, SI - -D_SaveModule11: - And AL, AL - JNZ D_SaveModule10 - - And BX, BX - JNZ D_SaveModule12 - - Cmp SaveFormat, 1 - JE D_SaveModule13 - - Mov Word Ptr [SI-1], 'I.' - Mov Word Ptr [SI+1], 'T' - Jmp D_PostFileSaveWindow2 - -D_SaveModule13: - Mov Word Ptr [SI-1], 'S.' - Mov Word Ptr [SI+1], 'M3' - Mov Byte Ptr [SI+3], 0 - -D_SaveModule12: - Jmp D_PostFileSaveWindow2 -; Jmp D_SaveFileITModule - -EndP D_SaveModule - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_NoSaveMessage Far - - Call S_SaveScreen - - Mov DI, Offset O1_UnableToSaveList - Mov CX, 2 - Call M_Object1List - - Call S_RestoreScreen - - Mov AX, 1 - Ret - -EndP D_NoSaveMessage - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveBlock ; DS:DX points to buffer - ; BX = file handle - ; CX = number of bytes - - JCXZ D_SaveBlock3 - - Cmp CS:NoSaveError, 1 - JE D_SaveBlock2 - - Mov AH, 40h - Int 21h - JC D_SaveBlock1 - Cmp CX, AX - JNE D_SaveBlock1 - -D_SaveBlock3: - Ret - -D_SaveBlock2: - Mov AX, CX - StC - Ret - -D_SaveBlock1: - PushAD - Push DS - Push ES - - Call D_NoSaveMessage - - Pop ES - Pop DS - PopAD - - Mov CS:NoSaveError, 1 - StC - - Ret - -EndP D_SaveBlock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DeleteIfError ; DS:DX = filename - - PushF - - Cmp CS:NoSaveError, 0 - JE D_DeleteIfError1 - - PushA - - Mov AH, 41h - Int 21h - - PopA - -D_DeleteIfError1: - PopF - Ret - -EndP D_DeleteIfError - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_UpdateFileName - - Push CS - Push CS - Pop DS - Pop ES - - Mov SI, Offset SaveFileName - Mov DI, Offset FileName - ; Scan through file name first. - Mov BX, SI - -D_UpdateFileName1: - LodsB - And AL, AL - JZ D_UpdateFileName2 - - Cmp AL, ':' - JE D_UpdateFileName3 - Cmp AL, '\' - JNE D_UpdateFileName1 - -D_UpdateFileName3: - Mov BX, SI - Jmp D_UpdateFileName1 - -D_UpdateFileName2: - Mov SI, BX - Add BX, 8 - -D_UpdateFileName4: - LodsB - StosB - - Cmp AL, '.' - JE D_UpdateFileName5 - - And AL, AL - JZ D_UpdateFileNameEnd - - Cmp SI, BX - JBE D_UpdateFileName4 - -D_UpdateFileName5: - Mov BX, SI - Add BX, 3 - -D_UpdateFileName6: - LodsB - StosB - - And AL, AL - JZ D_UpdateFileNameEnd - - Cmp SI, BX - JBE D_UpdateFileName6 - -D_UpdateFileNameEnd: - Ret - -EndP D_UpdateFileName - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include it_d_wm.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_InitLoadSamples Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset SampleDirectory - Call D_SetDriveDirectory ; DS:SI points to cur dir. - - Cmp SamplesInModule, 0 - JE D_InitLoadSamples4 - - Jmp LSWindow_EnterLoadInSampleData - -D_InitLoadSamples4: - Mov LoadSampleNameCount, 0 - Mov NumSamples, 0 - Mov SampleInMemory, 0FFFFh - Mov SampleCheck, 0FFFFh - Mov SampleCacheFileComplete, 0 - - ; First attempt to delete - ; ST3's cache file.. - Mov DX, Offset ST3CacheFileName - Mov AH, 41h - Int 21h - - ; First check for cache file. - Mov OldCacheTime, 0 - - Mov AX, 3D00h ; Open file.. - Mov DX, Offset SampleCacheFileName - Int 21h - JC D_InitLoadSamples1 ; Can't open file? - - Mov BX, AX - - Mov AH, 3Fh - Mov CX, 4 ; Integer containing number - ; of sample entries... - Mov DS, DiskDataArea - Assume DS:Nothing - - Xor DX, DX - Int 21h - JC D_InitLoadSamples3 - Cmp AX, CX - JNE D_InitLoadSamples3 - - Mov AL, [CS:SampleDirectory] ; AL = drive letter - Cmp AL, [CS:CDRomStartDrive] - JL SampleVersionCheck - Cmp AL, [CS:CDRomEndDrive] - JGE SampleVersionCheck - - Cmp Word Ptr [DS:2], 211h - JB D_InitLoadSamples3 - Cmp Word Ptr [DS:2], TRACKERVERSION - JBE D_InitLoadSampleCacheFileOK - -SampleVersionCheck: - Cmp Word Ptr [DS:2], TRACKERVERSION - JNE D_InitLoadSamples3 - -VersionCheckEnd: - Mov AX, 5700h ; Get file date&time. - Int 21h - - Mov Word Ptr [OldCacheTime], CX - Mov Word Ptr [OldCachetime+2], DX - - Cmp CX, Time ; Check time and date - JNE D_InitLoadSamplesOldCache ; for 'currentness' - Cmp DX, Date - JNE D_InitLoadSamplesOldCache - ; OK.. let's load... - -D_InitLoadSampleCacheFileOK: - Mov SI, [DS:0] ; Number of samples. - Mov AX, 96 - Mul SI - Mov CX, AX ; Bytes to read. - - Mov AH, 3Fh ; Load again. - Xor DX, DX ; In case of internal malfunc. - Int 21h - JC D_InitLoadSamples3 - Cmp AX, CX - JNE D_InitLoadSamples3 - - Mov AH, 3Eh ; Close file. - Int 21h - - Push CS - Pop DS - Assume DS:Disk - - Mov LoadSampleNameCount, SI - Mov NumSamples, SI - Mov SampleCacheFileComplete, 1 - - Jmp D_InitLoadSamples2 - -D_InitLoadSamplesOldCache: - PushA - Push DS - - Call D_GetNumFiles ; Returns number of files - ; and directories, - ; carry if newer file exists. - Pop DS - JC D_InitLoadSamples5 - - Cmp AX, [DS:0] - - PopA - - JNE D_InitLoadSamples3 - - Call Far Ptr D_InitLoadSampleCacheFileOK - - Call D_SaveSampleCacheFile ; Resave it with new date - - Ret - -D_InitLoadSamples5: - PopA - -D_InitLoadSamples3: - Mov AH, 3Eh ; Close file. - Int 21h - - Push CS - Pop DS - Assume DS:Disk - - Call DeleteSampleCacheFile - -D_InitLoadSamples1: - Call D_LoadSampleFiles - -D_InitLoadSamples2: - Ret - -EndP D_InitLoadSamples - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DeleteSampleCacheFile - - Push DS - - Push CS - Pop DS - - Mov AH, 41h - Mov DX, Offset SampleCacheFileName - Int 21h - - Pop DS - - Ret - -EndP DeleteSampleCachefile - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DeleteInstrumentCacheFile - - Push DS - - Push CS - Pop DS - - Mov AH, 41h - Mov DX, Offset InstrumentCacheFileName - Int 21h - - Pop DS - - Ret - -EndP DeleteInstrumentCachefile - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GetNumFiles ; DS = DiskDaraArea - - Mov DS, CS:DiskDataArea - - Mov DX, 64000 ; Set DTA to DS:64000 - Mov AH, 1Ah - Int 21h - - Push CS - Pop DS - - Mov DX, Offset AllFilesMask - Mov CX, 10h - Mov AH, 4Eh - Int 21h - - Mov DS, CS:DiskDataArea - JC D_GetNumFilesError - - Xor AX, AX ; No samples/directories to - ; start off with. - -D_GetNumFiles1: - Test Byte Ptr [DS:64000+15h], 10h - JZ D_GetNumFiles2 - - Mov EDX, DWord Ptr [CS:OldCacheTime] - Cmp [DS:64000+16h], EDX ; Newer file? - JA D_GetNumFilesError - - Inc AX - -D_GetNumFiles2: - Push AX - Mov AH, 4Fh - Int 21h - Pop AX - JNC D_GetNumFiles1 - ; Directories done.. files now - Push AX - - Push CS - Pop DS - Mov DX, Offset AllFilesMask - Xor CX, CX - Mov AH, 4Eh - Int 21h - - Mov DS, CS:DiskDataArea - - Pop AX - JC D_GetNumFilesFinished - - Push CS - Pop ES - -D_GetNumFiles3: - Mov SI, 64000+1Eh - Mov DI, Offset SampleCacheFileName - Mov CX, 9 - RepE CmpsB - JE D_GetNumFiles4 - - Mov SI, 64000+1Eh - Mov DI, Offset InstrumentCacheFileName - Mov CX, 9 - RepE CmpsB - JE D_GetNumFiles4 - - Mov EDX, DWord Ptr [CS:OldCacheTime] - Cmp [DS:64000+16h], EDX ; Newer file? - JA D_GetNumFilesError - -D_GetNumFiles4: - Inc AX - - Push AX - Mov AH, 4Fh - Int 21h - Pop AX - JNC D_GetNumfiles3 - - Dec AX - -D_GetNumFilesFinished: - ClC - Ret - -D_GetNumFilesError: - Xor AX, AX - StC - Ret - - -EndP D_GetNumFiles - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadSampleFiles - - Mov DS, CS:DiskDataArea - Push DS - Pop ES - - Xor DI, DI - Xor AX, AX - Mov CX, 32768 - Rep StosW - - Mov DX, 64000 - Mov AH, 1Ah - Int 21h ; Shift DTA address.. - ; to DiskDataArea:64000 - - Xor DI, DI - - Push CS - Pop DS - Mov DX, Offset AllFilesMask - Mov CX, 10h - Mov AH, 4Eh - Int 21h - - Mov DS, CS:DiskDataArea - Push DS - Pop ES - - JC D_LoadSampleFiles2 - -D_LoadSampleFiles1: ; A directory was found! - Test Byte Ptr [DS:64000+15h], 10h - JZ D_LoadSampleFiles5 ; Check that it IS a directory - - Cmp Word Ptr [DS:64000+1Eh], '.' - JNE D_LoadSampleFilesNoRoot - - Mov Byte Ptr [DS:64000+1Eh], '\' - -D_LoadSampleFilesNoRoot: - Mov DL, 1 - Call Near Ptr D_LoadSampleFiles6 - - Inc CS:NumSamples - Inc CS:LoadSampleNameCount - - Cmp CS:NumSamples, 620 - JAE D_LoadSampleFiles4 - -D_LoadSampleFiles5: - Mov AH, 4Fh - Int 21h - JNC D_LoadSampleFiles1 - -D_LoadSampleFiles2: ; Directories done.. samples now - Push CS - Pop DS - Mov DX, Offset AllFilesMask - Xor CX, CX - Mov AH, 4Eh - Int 21h - - Mov DS, CS:DiskDataArea - Push DS - Pop ES - - JC D_LoadSampleFiles4 - -D_LoadSampleFiles3: - Mov DL, 0 - Call Near Ptr D_LoadSampleFiles6 - - Inc CS:NumSamples - Cmp CS:NumSamples, 620 - JAE D_LoadSampleFiles4 - -D_LoadSampleFilesNext: - Mov AH, 4Fh - Int 21h - JNC D_LoadSampleFiles3 - -D_LoadSampleFiles4: ; End! - - Ret - -D_LoadSampleFiles6: ; Get name/size/date/time. - Add DI, 4 - Mov SI, 64000+1Eh - Mov CX, 13 - Rep MovsB - - Cmp DL, 1 - JNE D_LoadSampleFiles7 - - Xor AX, AX - StosB - StosW - - Push DS - Push CS - Pop DS - Mov SI, Offset DirectoryMsg - Mov CX, 25 - Rep MovsB - - Pop DS - - Mov CX, 35 - Jmp D_LoadSampleFiles8 - -D_LoadSampleFiles7: - Mov CX, 63 - -D_LoadSampleFiles8: - Xor AL, AL - Rep StosB - - Mov EAX, [DS:64000+1Ah] - StosD - Mov AX, [DS:64000+18h] - StosW - Mov AX, [DS:64000+16h] - StosW - Mov AL, DL - StosB - Mov CX, 7 - Xor AL, AL - Rep StosB - - RetN - -EndP D_LoadSampleFiles - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DrawLoadSampleWindow Far ; Has to handle - ; 1) Sample list - ; 2) Sample info box - ; 3) WaveForm stuff - - - Cmp CS:NumSamples, 0 - JNE D_DrawLoadSampleWindow4 - - Push CS - Pop DS - - Call S_GetDestination - Mov DI, (6+13*80)*2 ; (6, 13) - Mov SI, Offset NoFilesMsg - - Mov AH, 5 - Call S_DrawString - - Ret - -D_DrawLoadSampleWindow4: - Mov BX, CS:CurrentSample - Mov AX, 96 - Mul BX - Mov SI, AX - Mov ES, CS:DiskDataArea - - Cmp Byte Ptr [ES:SI+88], 0 - JNE D_DrawLoadSampleWindow28 - - Push SI - - Call D_LoadSampleHeader - Call D_GetSampleInfo - - Pop SI - -D_DrawLoadSampleWindow28: - Mov BX, CS:CurrentSample - Cmp BX, CS:SampleCheck - JE D_DrawLoadSampleWindow31 - - Mov CS:SampleCheck, BX - Push CS - Pop ES - Mov DI, Offset CheckDataArea - Mov DS, CS:DiskDataArea - Mov CX, 96 - Rep MovsB - -D_DrawLoadSampleWindow31: - Push CS - Pop DS - Assume DS:Disk - - Call S_GetDestination - - Mov AX, TopSample - Mov BX, CurrentSample - Cmp AX, BX - JBE D_DrawLoadSampleWindow1 - - Mov AX, BX - -D_DrawLoadSampleWindow1: - LEA CX, [EAX+34] - Cmp CX, BX - JA D_DrawLoadSampleWindow2 - - LEA AX, [BX-34] - -D_DrawLoadSampleWindow2: - Mov TopSample, AX - Mov BX, AX - - Push AX - - Mov DI, (31+13*80)*2 - Mov CX, 35 - Mov AX, 2A8h - -D_DrawLoadSampleWindow5: ; Divider... - StosW - Add DI, 158 - Loop D_DrawLoadSampleWindow5 - - Pop AX - - Mov DX, NumSamples - ; Put numbers of screen first. - Mov DI, (2+13*80)*2 ; (2,13) - Mov CX, 2000h+35 ; Colour and loop count. - -D_DrawLoadSampleWindow3: - Inc AX - Push DI - - Call PE_ConvAX2Num - - Pop DI - Add DI, 160 - Cmp AX, DX ; DX = NumSamples - JAE D_DrawLoadSampleWindow9 - - Dec CL - JNZ D_DrawLoadSampleWindow3 - -D_DrawLoadSampleWindow9: - Mov DS, DiskDataArea - Assume DS:Nothing - Mov AX, 96 - Mul BX - Mov SI, AX ; SI = offset of first sample. - - Mov DX, 35 ; DX = Number of rows to show. - ; BX = sample num - - Mov DI, (6+13*80)*2 - -D_DrawLoadSampleWindow6: - Push BX - Push DX - Push SI - Push DI - ; Colour.... - Mov AL, [DS:SI+88] ; AL = type. 0 = not loaded. - ; 1=dir - ; 2=it sample - ; 3=scrm sample. - ; 4=unknown - ; 5=8 bit mono wave - Mov AH, 6 - Cmp AL, 1 - JB D_DrawLoadSampleWindow7 - - Mov AH, 5 - JE D_DrawLoadSampleWindow7 - - Mov AH, 3 - Cmp AL, 4 - JNE D_DrawLoadSampleWindow7 - - Mov AH, 2 - -D_DrawLoadSampleWindow7: ; AH = colour. - Push SI - - Add SI, 14h - - Mov CX, 25 - -D_DrawLoadSampleWindow50: - LodsB - - Cmp AL, 226 - JB D_DrawLoadSampleCharFilter - - Mov AL, ' ' - -D_DrawLoadSampleCharFilter: - StosW - Loop D_DrawLoadSampleWindow50 - - Xor AL, AL - Rep StosW - - Pop SI - -; Add DI, 2 - ScasW - Add SI, 4 - - Mov CX, 12 - -D_DrawLoadSampleWindow51: - LodsB - StosW - And AL, AL - LoopNZ D_DrawLoadSampleWindow51 - - Xor AL, AL - Rep StosW - - Pop DI - Pop SI - Pop DX - Pop BX - - Add SI, 96 ; Advance to next sample. - Add DI, 160 ; Advance to next line on screen - - Inc BX - Cmp BX, CS:NumSamples - JAE D_DrawLoadSampleWindow8 - - Dec DX - JNZ D_DrawLoadSampleWindow6 - -D_DrawLoadSampleWindow8: ; Length - Mov AX, 96 - Mul CS:CurrentSample - - Mov SI, AX - - Push DS - Push SI - - Push DWord Ptr [DS:SI+30h] - - Test Byte Ptr [DS:SI+2Eh], 32 ; Stereo? - JZ D_DrawLoadSampleWindowNoStereo - - Test Byte Ptr [DS:SI+12h], 2 - Mov SI, Offset Quality8StereoMsg - - Push CS - Pop DS - JZ D_DrawLoadSampleWindowBitMsg - - Mov SI, Offset Quality16StereoMsg - Jmp D_DrawLoadSampleWindowBitMsg - -D_DrawLoadSampleWindowNoStereo: - Test Byte Ptr [DS:SI+12h], 2 - Mov SI, Offset Quality8Msg - - Push CS - Pop DS - JZ D_DrawLoadSampleWindowBitMsg - - Mov SI, Offset Quality16Msg - -D_DrawLoadSampleWindowBitMsg: - Mov DI, (21*80+64)*2 - Mov AH, 2 - Call S_DrawString - - Mov SI, Offset LengthMsg - Mov DI, (22*80+64)*2 - Call S_DrawString - Pop EAX - - Pop SI - Pop DS - -D_DrawLoadSampleWindow30: - ; Now for infobox. - Mov BL, [DS:SI+88] ; BL = type. - Push DS - Push SI - - Push CS - Pop DS - Xor BH, BH - Add BX, BX - Mov SI, [SampleFormatNames+BX] - Mov DI, (53+44*80)*2 - Mov AH, 5 - Call S_DrawString - - Pop SI - Pop DS - - Push SI - - Mov DX, [DS:SI+82] - Mov AX, [DS:SI+80] - Cmp DX, 10000 - - JAE D_DrawLoadSampleWindow13 - - Mov DI, (53+45*80)*2 - - Mov CX, 10000 - Div CX ; DX = remainder. AX = main. - - Mov BP, AX - - Mov CX, 4 - Mov SI, 10 - Mov AX, DX - -D_DrawLoadSampleWindow10: - Xor DX, DX - Div SI - Add DL, '0' - Push DX - - Loop D_DrawLoadSampleWindow10 - - Mov AX, BP - - Mov CX, 5 - -D_DrawLoadSampleWindow11: - Xor DX, DX - Div SI - Add DL, '0' - Push DX - - Loop D_DrawLoadSampleWindow11 - - Mov CX, 9 - -D_DrawLoadSampleWindow12: - Pop AX - Mov AH, 5 - StosW - Loop D_DrawLoadSampleWindow12 - -D_DrawLoadSampleWindow13: - Pop SI - - Mov DX, [DS:SI+86] ; DX = time - Mov BX, [DS:SI+84] ; BX = date - - Push CS - Pop DS - - Mov DI, (53+46*80)*2 - Mov AX, BX - ShR AX, 5 - And AX, 0Fh - Mov SI, AX - Add SI, SI - Mov SI, [MonthNames+SI] - - Mov AH, 5 - -D_DrawLoadSampleWindow19: - LodsB - StosW - And AL, AL - JNZ D_DrawLoadSampleWindow19 - - Mov AL, BL - And AX, 31 - Mov CH, 10 - Div CH - And AL, AL - JZ D_DrawLoadSampleWindow20 - - Push AX - Add AL, '0' - Mov AH, 5 - StosW - - Pop AX - -D_DrawLoadSampleWindow20: - Mov AL, AH - Add AL, '0' - Mov AH, 5 - StosW - - Mov AL, ',' - StosW - - Mov AL, ' ' - StosW - - Push DX - Mov AL, BH - ShR AX, 1 - And AX, 7Fh - Add AX, 1980 - Mov DX, 0FFFFh - Push DX - - Mov SI, 10 - -D_DrawLoadSampleWindow21: - Xor DX, DX - Div SI - Add DL, '0' - Push DX - - And AX, AX - JNZ D_DrawLoadSampleWindow21 - -D_DrawLoadSampleWindow22: - Pop AX - Cmp AX, 0FFFFh - JE D_DrawLoadSampleWindow23 - - Mov AH, 5 - StosW - - Jmp D_DrawLoadSampleWindow22 - -D_DrawLoadSampleWindow23: - Pop DX - Mov DI, (53+47*80)*2 - - Mov AX, DX - ShR AX, 11 - - Xor BL, BL ; if BL = 0, then am, otherwise - ; pm.. - Cmp AX, 12 - JB D_DrawLoadSampleWindow24 - - Inc BX - Sub AX, 12 - -D_DrawLoadSampleWindow24: - And AX, AX - JNZ D_DrawLoadSampleWindow25 - - Add AX, 12 - -D_DrawLoadSampleWindow25: - Mov BH, 10 - Div BH - And AL, AL - JZ D_DrawLoadSampleWindow26 - - Push AX - Add AL, '0' - Mov AH, 5 - StosW - - Pop AX - -D_DrawLoadSampleWindow26: - Mov AL, AH - Add AL, '0' - Mov AH, 5 - StosW - - Mov AL, ':' - StosW - - Mov AX, DX - ShR AX, 5 - And AX, 63 - - Div BH - Mov BH, AH - - Add AL, '0' - Mov AH, 5 - StosW - - Mov AL, BH - Add AL, '0' - StosW - - Mov AL, 'a' - And BL, BL - JZ D_DrawLoadSampleWindow27 - - Mov AL, 'p' - -D_DrawLoadSampleWindow27: - StosW - Mov AL, 'm' - StosW - - Push CS ; Wave form shit.. - Pop DS - Assume DS:Disk - - Mov AX, CurrentSample - Cmp AX, SampleInMemory - JNE D_DrawLoadSampleWindow54 - - Mov DI, (46+25*80)*2 - Mov DX, 4 - Mov AX, 0D00h - -D_DrawLoadSampleWindow55: - Mov CX, 31 - -D_DrawLoadSampleWindow56: - StosW - Inc AX - Loop D_DrawLoadSampleWindow56 - - Add DI, 160-31*2 - Dec DX - JNZ D_DrawLoadSampleWindow55 - -D_DrawLoadSampleWindow54: - Ret - -EndP D_DrawLoadSampleWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PreLoadSampleWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov AX, CurrentSample - Sub AX, TopSample - Add AX, 13 - Mov BX, 160 - Mul BX - - Call S_GetDestination - - LEA DI, [EAX+12] - Mov CX, 38 - -D_PreLoadSample1: - Mov AX, [ES:DI] - Cmp CX, 13 - - JNE D_PreLoadSample2 - - Mov AH, 32h - Jmp D_PreLoadSample3 - -D_PreLoadSample2: - Mov AH, 30h - -D_PreLoadSample3: - StosW - - Loop D_PreLoadSample1 - - Ret - -EndP D_PreLoadSampleWindow - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostLoadSampleWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset LSWindowKeys - Call M_FunctionDivider - JC D_PostLoadSampleWindow1 - - Jmp [SI] - -D_PostLoadSampleWindow1: ; Time to check for play keys. - Mov SI, Offset KeyBoardTable - Test CH, Not 1 - JNZ D_PostLoadSampleWindow3 - - Cmp CX, LastKey - JE D_PostLoadSampleWindow3 - - Mov LastKey, CX - -D_PostLoadSampleWindow2: - LodsW - Cmp AX, 0FFFFh - JE D_PostLoadSampleWindow3 - - Mov BX, AX - LodsW - - Cmp BL, CL - JNE D_PostLoadSampleWindow2 - ; Note to play... - ; AX = notemod. - And CH, CH - JZ D_PostLoadSampleWindow5 - - - Mov BX, AX - - Mov CX, Pattern - Mov DS, CX - Assume DS:Pattern - - Mov AL, 12 - Mul BaseOctave - - Push CS - Pop DS - Assume DS:Disk - - Add AX, BX - Cmp AX, 119 - JA D_PostLoadSampleWindow4 ; If note > B-9... don't play! - - Push AX - - Mov AX, 96 - Mul CurrentSample - Mov SI, AX - - Mov DisableStereoMenu, 1 - - Mov DS, DiskDataArea - Mov AX, 99 - Call LoadSample - - Mov CS:DisableStereoMenu, 0 - - Pop AX - JC D_PostLoadSampleWindow4 - - ; AX = note. Ins = 99. - Mov AH, 100 - Xor CX, CX - Call Music_PlaySample - Jmp D_PostLoadSampleWindow4 - -D_PostLoadSampleWindow5: - Xor AX, AX - Mov SI, Offset NoteData - Mov DH, 32 - Call Music_PlayNote - -D_PostLoadSampleWindow4: - Mov AX, 1 - Ret - -D_PostLoadSampleWindow3: - Xor AX, AX - Ret - -EndP D_PostLoadSampleWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostViewSampleLibrary Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset LSViewWindowKeys - Call M_FunctionDivider - JC D_PostLoadSampleWindow1 - - Jmp [SI] - -EndP D_PostViewSampleLibrary - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LSDrawDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Call S_GetDestination - - Mov AL, TopDrive - Mov BL, CurrentDrive - Cmp AL, BL - JBE D_LSDrawDriveWindow1 - - Mov AL, BL - -D_LSDrawDriveWindow1: - Mov CL, AL - Add CL, 9 - Cmp CL, BL - JA D_LSDrawDriveWindow2 - - Mov AL, BL - Sub AL, 9 - -D_LSDrawDriveWindow2: - Mov TopDrive, AL - Mov BL, AL - Mov CX, 10 - - Mov DI, (46+13*80)*2 - Xor BH, BH - -D_LSDrawDriveWindow3: - Cmp BL, NumDrives - JAE D_LSDrawDriveWindow5 - - Push DI - - Mov AL, [DrivesAvail+BX] - Add AL, 'A' - Mov SI, Offset DriveMsg - Mov [SI+6], AL - - Mov AH, 5 - Mov DX, 8 - -D_LSDrawDriveWindow4: - LodsB - StosW - - Dec DX - JNZ D_LSDrawDriveWindow4 - - Pop DI - Add DI, 160 - Inc BX - Loop D_LSDrawDriveWindow3 - -D_LSDrawDriveWindow5: - Ret - -EndP D_LSDrawDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LSPreDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov AL, CurrentDrive - Sub AL, TopDrive - Add AL, 13 - Mov AH, 160 - Mul AH - - Call S_GetDestination - LEA DI, [EAX+92] - Mov CX, 8 - -D_LSPreDriveWindow1: - Mov AX, [ES:DI] - Mov AH, 30h - StosW - - Loop D_LSPreDriveWindow1 - - Ret - -EndP D_LSPreDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LSPostDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset LSDriveWindowKeys - Call M_FunctionDivider - JC D_LSPostDriveWindow1 - - Jmp [SI] - -D_LSPostDriveWindow1: - Xor AX, AX - Ret - -EndP D_LSPostDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LIDrawDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Call S_GetDestination - - Xor AL, AL - Xor BX, BX - - Mov CX, 32 - - Mov DI, (64+16*80)*2 - -D_LIDrawDriveWindow3: - Cmp BL, NumDrives - JAE D_LIDrawDriveWindow5 - - Push DI - - Mov AL, [DrivesAvail+BX] - Add AL, 'A' - Mov SI, Offset DriveMsg - Mov [SI+6], AL - - Mov AH, 5 - Mov DX, 8 - -D_LIDrawDriveWindow4: - LodsB - StosW - - Dec DX - JNZ D_LIDrawDriveWindow4 - - Pop DI - Add DI, 160 - Inc BX - Loop D_LIDrawDriveWindow3 - -D_LIDrawDriveWindow5: - Ret - -EndP D_LIDrawDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LIPreDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov AL, CurrentDrive - Add AL, 16 - Mov AH, 160 - Mul AH - Mov DI, AX - - Call S_GetDestination - Add DI, 64*2 - Mov CX, 8 - -D_LIPreDriveWindow1: - Mov AX, [ES:DI] - Mov AH, 30h - StosW - - Loop D_LIPreDriveWindow1 - - Ret - -EndP D_LIPreDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LIPostDriveWindow Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset LIDriveWindowKeys - Call M_FunctionDivider - JC D_LIPostDriveWindow1 - - Jmp [SI] - -D_LIPostDriveWindow1: - Xor AX, AX - Ret - -EndP D_LIPostDriveWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadSampleHeader ; Given BX = sample number. - - Push BX - - Mov DS, DiskDataArea - Assume DS:Nothing - - Mov AX, 96 - Mul BX - LEA SI, [EAX+4] - - Call D_LoadFileHeader - - Pop BX - - Ret - -EndP D_LoadSampleHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadInstrumentHeader ; Given BX = instrument num - - Push BX - - Mov DS, DiskDataArea - Assume DS:Nothing - - Mov AX, 48 - Mul BX - Mov SI, AX - Inc SI - - Call D_LoadFileHeader - - Pop BX - - Ret - -EndP D_LoadInstrumentHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include it_d_inf.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveSampleCacheFile ; Assumes DS=Disk - - Push CS - Pop DS - - Assume DS:Disk - - Test DiskOptions, 2 - JNZ D_SaveSampleCacheFile1 - - Cmp SamplesInModule, 0 - JNE D_SaveSampleCacheFile1 - - Mov AH, 3Ch ; create file. - Xor CX, CX ; normal file - Mov DX, Offset SampleCacheFileName - Int 21h - JC D_SaveSampleCacheFile1 - - Mov BX, AX ; BX = file handle - - Mov AH, 40h ; Write to file - Mov CX, 4 ; Word size - Mov DX, Offset NumSamples - Int 21h - - Mov AX, 96 - Mul NumSamples - Mov CX, AX ; CX = num bytes to write. - Mov AH, 40h - Xor DX, DX - Mov DS, DiskDataArea - Assume DS:Nothing - Int 21h ; Write cache file! - - ; Set date and time... - Mov AX, 5701h - Mov CX, CS:Time - Mov DX, CS:Date - Int 21h - - Mov AH, 3Eh ; Close file handle - Int 21h - - Push CS - Pop DS - Assume DS:Disk - -D_SaveSampleCacheFile1: - Mov SampleCacheFileComplete, 1 - - Ret - -EndP D_SaveSampleCacheFile - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveInstrumentCacheFile ; Assumes DS=Disk - - Push CS - Pop DS - Assume DS:Disk - - Test DiskOptions, 2 - JNZ D_SaveInstrumentCacheFile1 - - Mov AH, 3Ch ; create file. - Xor CX, CX ; normal file - Mov DX, Offset InstrumentCacheFileName - Int 21h - JC D_SaveInstrumentCacheFile1 - - Mov BX, AX ; BX = file handle - - Mov AH, 40h ; Write to file - Mov CX, 6 ; Word size - Mov DX, Offset InitialInstruments - Int 21h - - Mov AX, 48 - Mul NumInstruments - Mov CX, AX ; CX = num bytes to write. - Mov AH, 40h - Xor DX, DX - Mov DS, DiskDataArea - Assume DS:Nothing - - Int 21h ; Write cache file! - - ; Set date and time... - Mov AX, 5701h - Mov CX, CS:Time - Mov DX, CS:Date - Int 21h - - Mov AH, 3Eh ; Close file handle - Int 21h - - Push CS - Pop DS - Assume DS:Disk - -D_SaveInstrumentCacheFile1: - Mov InstrumentCacheFileComplete, 1 - - Ret - -EndP D_SaveInstrumentCacheFile - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadSampleNames Far - - Push CS - Pop DS - Assume DS:Disk - - Cmp SampleCacheFileComplete, 1 - JNE D_LoadSampleNames2 - -D_LoadSampleNames6: - Xor AX, AX ; No redraw screen. - Ret - -D_LoadSampleNames2: - Mov BX, LoadSampleNameCount - Cmp BX, NumSamples - JAE D_LoadSampleNames5 - -D_LoadSampleNames1: - Call K_IsAnyKeyDown - And AL, AL - JNZ D_LoadSampleNames6 - - Call GetKeyboardLock - And AL, AL - JNZ D_LoadSampleNames6 - - Mov AX, 96 - Mul BX - Mov SI, AX - Mov ES, DiskDataArea - Cmp Byte Ptr [ES:SI+88], 0 - JNE D_LoadSampleNames3 - - Call D_LoadSampleHeader - JC D_LoadSampleNames3 - - Call D_GetSampleInfo ; BX = sample number - -D_LoadSampleNames3: - Push CS - Pop DS - Assume DS:Disk - - Inc LoadSampleNameCount - Mov BX, LoadSampleNameCount - Cmp BX, NumSamples - JNE D_LoadSampleNames4 - ; Save cache file.. - -D_LoadSampleNames5: - Call D_SaveSampleCacheFile - Cmp CurrentSample, 0 - JNE D_LoadSampleNames4 - Call D_SlowSampleSort - -D_LoadSampleNames4: - Mov AX, 1 ; Signify redraw screen - Ret - -EndP D_LoadSampleNames - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GetLoadSampleVars Far ; Returns SI with offset of - - Push AX - Push DX - - Mov AX, 96 - Mul CS:CurrentSample - Mov SI, AX - Mov DS, CS:DiskDataArea - - Pop DX - Pop AX - - Ret - -EndP D_GetLoadSampleVars - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GotoStartingDirectory Far - - Push DS - Push CS - Pop DS - - Mov SI, Offset StartingDirectory - Call D_SetDriveDirectory - Pop DS - - Ret - -EndP D_GotoStartingDirectory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveDirectoryConfiguration Far - - Push CS - Pop DS - Assume DS:Disk - - Mov NoSaveError, 0 - Mov CountryTableConfig, 0 - - Mov SI, Offset StartingDirectory - Call D_SetDriveDirectory - - Mov AH, 3Ch - Xor CX, CX - Mov DX, Offset ConfigFileName - Int 21h - JC D_SaveDirectoryConfiguration1 - - Mov BX, AX - - Mov CX, 211 - Mov DX, Offset SongDirectory - Call D_SaveBlock - - Call S_GetPaletteOffset ; Into DS:DX - Mov CX, 3*16 - Call D_SaveBlock - - Call Display_GetDisplayWindowData - Mov CX, 50 - Call D_SaveBlock - - Call PE_GetPatternConfigOffset - Mov CX, 218 - Call D_SaveBlock - - Call I_GetPresetEnvelopeOffset - Mov CX, 810 - Call D_SaveBlock - - Mov AH, 3Eh - Int 21h - -D_SaveDirectoryConfiguration1: - Mov AX, 1 - Ret - -EndP D_SaveDirectoryConfiguration - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_Up Far - - Assume DS:Disk - - Mov AX, CurrentFile - And AX, AX - JZ FileWindow_Up1 - - Dec CurrentFile - -FileWindow_Up1: - Mov AX, 1 - Ret - -EndP FileWindow_Up - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_Down Far - - Assume DS:Disk - - Mov AX, CurrentFile - Inc AX - Cmp AX, NumFiles - JAE FileWindow_Down1 - - Inc CurrentFile - -FileWindow_Down1: - Mov AX, 1 - Ret - -EndP FileWindow_Down - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_PgUp Far - - Assume DS:Disk - - Mov AX, CurrentFile - Sub AX, 31 - JNC FileWindow_PgUp1 - - Xor AX, AX - -FileWindow_PgUp1: - Mov CurrentFile, AX - - Mov AX, 1 - Ret - -EndP FileWindow_PgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_PgDn Far - - Assume DS:Disk - - Mov AX, CurrentFile - Add AX, 31 - Cmp AX, NumFiles - JB FileWindow_PgDn1 - - Mov AX, NumFiles - And AX, AX - JZ FileWindow_PgDn1 - - Dec AX - -FileWindow_PgDn1: - Mov CurrentFile, AX - - Mov AX, 1 - Ret - -EndP FileWindow_PgDn - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_Right Far - - Assume DS:Disk - - Mov Word Ptr [ES:DI], 13 - - Mov AX, 1 - Ret - -EndP FileWindow_Right - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_Left Far - - Assume DS:Disk - - Mov Word Ptr [ES:DI], 14 - - Mov AX, 1 - Ret - -EndP FileWindow_Left - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_ShiftTab Far - - Assume DS:Disk - - Mov Word Ptr [ES:DI], 16 - - Mov AX, 1 - Ret - -EndP FileWindow_ShiftTab - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_Home Far - - Assume DS:Disk - - Mov CurrentFile, 0 - - Mov AX, 1 - Ret - -EndP FileWindow_Home - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_End Far - - Assume DS:Disk - - Mov AX, NumFiles - Dec AX - JS FileWindow_End1 - - Mov CurrentFile, AX - -FileWindow_End1: - Mov AX, 1 - Ret - -EndP FileWindow_End - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FileWindow_DeleteFile Far - - Assume DS:Disk - - Cmp NumFiles, 0 - JE FileWindow_DeleteFile26 - - Mov DI, Offset O1_ConfirmDelete - Mov CX, 4 - Call M_Object1List - And DX, DX - JNZ FileWindow_DeleteFile24 - - Mov AX, 1 - Ret - -FileWindow_DeleteFile24: ; Time to kill the sucker... - Mov DS, CS:DiskDataArea - Mov BX, CS:CurrentFile - Assume DS:Nothing - - Add BX, BX - Mov DX, [BX] - Add DX, 8 ; DS:BX points to thingo. - Mov AH, 41h - Int 21h - JC FileWindow_DeleteFile26 - - Push DS - Pop ES - - Push CS - Pop DS - Assume DS:Disk - - Mov DI, CurrentFile - Mov CX, DI - Add DI, DI - Mov BX, NumFiles - Add BX, NumDirectories - -FileWindow_DeleteFile27: - Mov AX, [ES:DI+2] - StosW - Inc CX - Cmp CX, BX - JBE FileWindow_DeleteFile27 - - Mov AX, NumFiles - Mov BX, CurrentFile - Dec AX - And AX, AX - JZ FileWindow_DeleteFile29 - - Cmp BX, AX - JB FileWindow_DeleteFile28 - - Mov BX, AX - Dec BX - Jmp FileWindow_DeleteFile28 - -FileWindow_DeleteFile29: - Mov BX, AX - -FileWindow_DeleteFile28: - Mov NumFiles, AX - Mov CurrentFile, BX - Dec LoadSongNameCount - -FileWindow_DeleteFile26: - Mov AX, 1 - Ret - -EndP FileWindow_DeleteFile - Assume DS:Nothing - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Proc DirectoryWindow_Up Far - - Assume DS:Disk - - Mov AX, CurrentDirectory - And AX, AX - JZ DirectoryWindow_Up1 - - Dec CurrentDirectory - -DirectoryWindow_Up1: - Mov AX, 1 - Ret - -EndP DirectoryWindow_Up - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DirectoryWindow_Down Far - - Assume DS:Disk - - Mov AX, CurrentDirectory - Inc AX - Cmp AX, NumDirectories - JAE DirectoryWindow_Down1 - - Inc CurrentDirectory - -DirectoryWindow_Down1: - Mov AX, 1 - Ret - -EndP DirectoryWindow_Down - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DirectoryWindow_PgUp Far - - Assume DS:Disk - - Mov AX, CurrentDirectory - Sub AX, 21 - JC DirectoryWindow_Home - - Mov CurrentDirectory, AX - - Mov AX, 1 - Ret - -EndP DirectoryWindow_PgUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DirectoryWindow_PgDn Far - - Assume DS:Disk - - Mov AX, CurrentDirectory - Add AX, 21 - Cmp AX, NumDirectories - JAE DirectoryWindow_End - - Mov CurrentDirectory, AX - - Mov AX, 1 - Ret - -EndP DirectoryWindow_PgDn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DirectoryWindow_Home Far - - Assume DS:Disk - - Mov CurrentDirectory, 0 - - Mov AX, 1 - Ret - -EndP DirectoryWindow_Home - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DirectoryWindow_End Far - - Assume DS:Disk - - Mov AX, NumDirectories - Dec AX - JS DirectoryWindow_End1 - - Mov CurrentDirectory, AX - -DirectoryWindow_End1: - Mov AX, 1 - Ret - -EndP DirectoryWindow_End - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DirectoryWindow_Left Far - - Assume DS:Disk - - Mov Word Ptr [ES:DI], 12 - - Mov AX, 1 - Ret - -EndP DirectoryWindow_Left - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DirectoryWindow_Enter Far - - Assume DS:Disk - - Cmp NumDirectories, 0 - JE DirectoryWindow_Enter2 - - Mov BX, CurrentDirectory - Add BX, NumFiles - - Mov DS, DiskDataArea - Assume DS:Nothing - - Add BX, BX - Mov DX, [BX] - Add DX, 8 - Mov AH, 3Bh - Int 21h - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset SongDirectory - Call D_GetDriveDirectory - - Call D_InitLoadModule - - Mov CurrentFile, 0 - Mov AX, 12 - Cmp NumFiles, 0 - JNE DirectoryWindow_Enter1 - - Mov AX, 13 - -DirectoryWindow_Enter1: - StosW -; Mov [ES:DI], AX - - Mov AX, 1 - Ret - -DirectoryWindow_Enter2: - Xor AX, AX - Ret - -EndP DirectoryWindow_Enter - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Proc DriveWindow_Up Far - - Assume DS:Disk - - Mov AL, CurrentDrive - And AL, AL - JZ DriveWindow_Up1 - - Dec CurrentDrive - -DriveWindow_Up1: - Mov AX, 1 - Ret - -EndP DriveWindow_Up - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DriveWindow_Down Far - - Assume DS:Disk - - Mov AL, CurrentDrive - Inc AX - Cmp AL, NumDrives - JAE DriveWindow_Down1 - - Inc CurrentDrive - -DriveWindow_Down1: - Mov AX, 1 - Ret - -EndP DriveWindow_Down - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DriveWindow_Tab Far - - Assume DS:Disk - - Mov Word Ptr [ES:DI], 15 - - Mov AX, 1 - Ret - -EndP DriveWindow_Tab - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIDriveWindow_Tab Far - - Assume DS:Disk - - Mov Word Ptr [ES:DI], 5 - - Mov AX, 1 - Ret - -EndP LIDriveWindow_Tab - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SaveDriveWindow_Tab Far - - Assume DS:Disk - - Mov Word Ptr [ES:DI], 18 - - Mov AX, 1 - Ret - -EndP SaveDriveWindow_Tab - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DriveWindow_Enter Far - - Assume DS:Disk - - Mov BL, CurrentDrive - Xor BH, BH - Mov DL, [DrivesAvail+BX] - Mov AH, 0Eh - Int 21h - - Mov SI, Offset SongDirectory - Call D_GetDriveDirectory - - Call D_InitLoadModule - - Mov CurrentFile, 0 - Mov AX, 12 - Cmp NumFiles, 0 - JNE DriveWindow_Enter1 - - Mov AX, 13 - Cmp NumDirectories, 0 - JNE DriveWindow_Enter1 - - Mov AX, 14 - -DriveWindow_Enter1: - StosW -; Mov [ES:DI], AX - - Mov AX, 1 - Ret - -EndP DriveWindow_Enter - Assume DS:Nothing - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Proc LS_DriveWindow_Enter Far - - Assume DS:Disk - - Mov BL, CurrentDrive - Xor BH, BH - Mov DL, [DrivesAvail+BX] - Mov AH, 0Eh - Int 21h - - Mov SI, Offset SampleDirectory - Call D_GetDriveDirectory - - Mov CurrentSample, 0 - Push ES - Push DI - Call D_InitLoadSamples - Pop DI - Pop ES - - Mov Word Ptr [ES:DI], 15 ; Sample list - - Mov AX, 1 - Ret - -EndP LS_DriveWindow_Enter - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Proc LI_DriveWindow_Enter Far - - Assume DS:Disk - - Mov BL, CurrentDrive - Xor BH, BH - Mov DL, [DrivesAvail+BX] - Mov AH, 0Eh - Int 21h - - Mov SI, Offset InstrumentDirectory - Call D_GetDriveDirectory - - Mov CurrentInstrument, 0 - Push ES - Push DI - Call D_InitLoadInstruments - Pop DI - Pop ES - - Mov Word Ptr [ES:DI], 5 ; Sample list - - Mov AX, 1 - Ret - -EndP LI_DriveWindow_Enter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSDriveWindow_Right Far - - Mov Word Ptr [ES:DI], 17 - - Mov AX, 1 - Ret - -EndP LSDriveWindow_Right - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Proc LoadSample ; AX = Sample number - ; DS:SI points to sample header. - Call PE_SaveCurrentPattern - - Push AX - - Cmp AX, 99 - JNE LoadSample4 - - Mov DX, CS:CurrentSample - Cmp DX, CS:SampleInMemory - JE LoadSample3 - -LoadSample4: - Mov EDX, [DS:SI+30h] - And EDX, EDX - JZ LoadSample6 - Test Byte Ptr [DS:SI+12h], 1 - JZ LoadSample6 - - Call Music_Stop - - Push AX - - Mov AX, 3D00h - Mov DX, SI - Add DX, 4 - Int 21h - JC LoadSample8 - - Mov BX, AX ; BX = File Handle - Mov AX, 4200h - Mov CX, [DS:SI+4Ah] - Mov DX, [DS:SI+48h] - Int 21h ; Move File Ptr. - - Pop AX ; AX = sample number. - - Push SI ; Load sample into memory first. - - Call D_LoadSampleData - - PushF - - Mov AH, 3Eh - Int 21h ; Close file. - - PopF - Pop SI - - JC LoadSample2 - -LoadSample3: - Pop BX - Mov DX, BX - - Add BX, BX - Call Music_GetSongSegment - Mov ES, AX - Mov DI, [ES:BX+64912] ; ES:DI points to instrument - - Mov CX, 48h - Rep MovsB - Add SI, 4 - Add DI, 4 - MovsW - MovsW - - Cmp DX, 99 - JNE LoadSample5 - - Mov AX, [Word Ptr CS:CheckDataArea+2Eh] - Mov [DS:SI-50h+2Eh], AX - Mov AL, [CS:CheckDataArea+12h] - Mov [DS:SI-50h+12h], AL - - Mov AX, CS:CurrentSample - Cmp AX, CS:SampleInMemory - JE LoadSample7 - - Mov CS:SampleInMemory, AX - - Call D_DrawWaveForm - -LoadSample5: - Mov AX, DX - Inc AX - Call Music_SoundCardLoadSample - -LoadSample7: - ClC - Jmp LoadSample1 - Ret - -LoadSample2: - Mov CS:SampleInMemory, 0FFFFh - Jmp LoadSample6 - -LoadSample8: - Pop AX - -LoadSample6: - Pop AX - StC - -LoadSample1: - PushF - Call PE_RestoreCurrentPattern - PopF - Ret - -EndP LoadSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include it_d_ris.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSViewWindow_Enter Far - - Assume DS:Disk - - Cmp NumSamples, 0 - JE LSViewWindow_Enter1 - - Mov AX, 96 - Mul CurrentSample - Mov SI, AX - Assume DS:Nothing - - Mov DS, DiskDataArea - Mov DL, [DS:SI+88] - Cmp DL, 1 - JE LSViewWindow_Enter1 - - Cmp DL, 20h - JAE LSViewWindow_Enter2 - - Mov AX, 1 - Ret - -EndP LSViewWindow_Enter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSWindow_Enter Far - - Assume DS:Disk - - Cmp NumSamples, 0 - JE LSWindow_Enter2 - - Mov AX, 96 - Mul CurrentSample - Mov SI, AX - Assume DS:Nothing - - Mov DS, DiskDataArea - Mov DX, [DS:SI+88] ; Also get DH = InsampleChannels - Cmp DL, 1 - JNE LSWindow_Enter1 - -LSViewWindow_Enter1: - Push DS - Push SI - - Push CS - Pop DS - Mov SI, Offset SampleDirectory - Call D_SetDriveDirectory - - Pop SI - Pop DS - - Add SI, 4 - Call D_SetDriveDirectory - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset SampleDirectory - Call D_GetDriveDirectory - -LSWindow_EnterInModuleError: - Mov SamplesInModule, 0 - Call D_InitLoadSamples - Assume DS:Nothing - Mov CS:CurrentSample, 0 - - Mov AX, 1 - Ret - -LSWindow_Enter1: ; Load sample into sample list. - Cmp DL, 20h - JB LSWindow_EnterSample - -LSViewWindow_Enter2: - Sub DL, 20h - Mov Word Ptr CS:InSampleFormat, DX - Mov EAX, [SI+54h] - Mov CS:InSampleDateTime, EAX - - Add SI, 4 - ; Copy module name across - Push CS - Pop ES - Mov DI, Offset InSampleFileName - Mov CX, 13 - Rep MovsB - ; Open file - Push CS - Pop DS - Assume DS:Disk - - Mov CurrentSample, 0 - -LSWindow_EnterLoadInSampleData: - Mov DX, Offset InSampleFileName - Mov AX, 3D00h - Int 21h - JC LSWindow_EnterInModuleError - - Mov BX, AX - - Mov SI, Word Ptr InSampleFormat - And SI, 0FFh - Add SI, SI - - Mov NumSamples, 1 - - Mov DS, DiskDataArea - Assume DS:Nothing - - Push DS - Pop ES - - Call [CS:LoadSamplesInModuleTable+SI] - - ; Close module - Mov AH, 3Eh - Int 21h - - ; Setup first 'directory' - - Push CS - Pop DS - Assume DS:Disk - - Xor DI, DI - Mov SI, Offset ExitLibraryDirectory - Mov CX, 89 - Rep MovsB - - Mov EAX, InSampleDateTime - Mov [ES:DI-5], EAX - Mov SampleCacheFileComplete, 1 - Mov SamplesInModule, 1 - Mov SampleInMemory, 0FFFFh - Mov SampleCheck, 0FFFFh - - Mov AX, NumSamples - Mov LoadSampleNameCount, AX - - Mov AX, 1 - Ret - - Assume DS:Nothing - -LSWindow_EnterSample: - Call Music_Stop - - Mov AX, [Word Ptr CS:CheckDataArea+2Eh] - Mov [SI+2Eh], AX - ; prompt whether to initialise - ; instrument - ; 1) Only when no sample was - ; previously present - ; 2) When instrument mode is - ; on. - Mov AX, 99 ; Release sample! - Call Music_ReleaseSample - - Xor DX, DX ; Assume don't call. - - Call Music_GetInstrumentMode - JZ LSWindow_Enter4 ; Sample mode! - - ; Instrument mode - - ; Check whether previous sample - ; existed. - Push DS - Push SI - - Mov CX, 4 ; Assume Not OK - - Call I_GetSampleOffset ; DS:BX points to sample. - Test Byte Ptr [BX+12h], 1 - JNZ LSWindow_Enter5 - - Mov CX, 3 ; Assume OK. - -LSWindow_Enter5: - Mov DI, Offset O1_InitInstrument - Call M_Object1List - ; DX contains init flag. - Pop SI - Pop DS - -LSWindow_Enter4: - Push DX - - Call PE_GetLastInstrument - Mov AX, BX - Push AX - Call LoadSample - Pop CX - Xor DX, DX - -IF NETWORKENABLED - NetworkSendSample - Call Network_QueueSampleData -ENDIF - - Pop DX - - Test DX, DX - JZ LSWindow_Enter7 - - Call PE_GetLastInstrument ; BX = sample number - Call Music_AssignSampleToInstrument - - Push CS - Pop DS - Mov SI, Offset InitInstrumentErrorMsg - JC LSWindow_Enter6 - - Mov SI, Offset InitInstrumentMsg - -LSWindow_Enter6: - Call SetInfoLine - -LSWindow_Enter7: - Jmp Glbl_F3 - -LSWindow_Enter2: - Mov AX, 1 - Ret - -EndP LSWindow_Enter - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSWindow_Space Far - - Assume DS:Disk - - Cmp NumSamples, 0 - JE LSViewWindow_Enter1 - - Mov AX, 96 - Mul CurrentSample - LEA SI, [EAX+14h] - Assume DS:Nothing - - Push SI - - Mov DS, DiskDataArea - - Push CS - Pop ES - Mov DI, Offset SampleName - - Mov CX, 26 - Mov BX, DI - -LSWindow_Space1: - LodsB - And AL, AL - JNZ LS_WindowSpace2 - - Mov AL, ' ' - Jmp LS_WindowSpace3 - -LS_WindowSpace2: - Cmp AL, ' ' - JE LS_WindowSpace3 - - Mov BX, DI - Inc BX - -LS_WindowSpace3: - StosB - Loop LSWindow_Space1 - - Mov Byte Ptr [ES:BX], 0 - - - Mov DI, Offset O1_EditSampleName - Mov CX, 3 - Call M_Object1List - - Pop DI ; DI contains offset of sample - - And DX, DX - JZ LS_WindowSpace4 - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset SampleName - Mov CX, 26 - Mov ES, DiskDataArea - Rep MovsB - -LS_WindowSpace4: - Mov AX, 1 - Ret - -EndP LSWindow_Space - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSWindow_Up Far - - Call CheckSampleModified - JC LSWindow_Up1 - - Assume DS:Disk - - Mov AX, CurrentSample - And AX, AX - JZ LSWindow_Up1 - - Dec CurrentSample - -LSWindow_Up1: - Mov AX, 1 - Ret - -EndP LSWindow_Up - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSWindow_Down Far - - Call CheckSampleModified - JC LSWindow_Down1 - - Assume DS:Disk - - Mov AX, CurrentSample - - Inc AX - Cmp AX, NumSamples - JAE LSWindow_Down1 - - Mov CurrentSample, AX - -LSWindow_Down1: - Mov AX, 1 - Ret - -EndP LSWindow_Down - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSWindow_PgUp Far - - Call CheckSampleModified - JC LSWindow_PgUp1 - - Assume DS:Disk - - Mov AX, CurrentSample - - Sub AX, 35 - JC LSWindow_Home - - Mov CurrentSample, AX - -LSWindow_PgUp1: - Mov AX, 1 - Ret - -EndP LSWindow_PgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSWindow_PgDn Far - - Call CheckSampleModified - JC LSWindow_PgDn1 - - Assume DS:Disk - - Mov AX, CurrentSample - - Add AX, 35 - Cmp AX, NumSamples - JAE LSWindow_End - - Mov CurrentSample, AX - -LSWindow_PgDn1: - Mov AX, 1 - Ret - -EndP LSWindow_PgDn - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSWindow_Home Far - - Call CheckSampleModified - JC LSWindow_Home1 - - Assume DS:Disk - - Mov CurrentSample, 0 - -LSWindow_Home1: - Mov AX, 1 - Ret - -EndP LSWindow_Home - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LSWindow_End Far - - Call CheckSampleModified - JC LSWindow_End1 - - Assume DS:Disk - - Mov AX, NumSamples - - Dec AX - JS LSWindow_End1 - - Mov CurrentSample, AX - -LSWindow_End1: - Mov AX, 1 - Ret - -EndP LSWindow_End - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LSCheckLoopValues Far - - Call D_GetLoadSampleVars ; DS:SI points to thing - - Mov BX, SI - - Mov EAX, [BX+30h] - Cmp EAX, [BX+34h] - JA D_LSCheckLoopValues3 - - Mov [BX+34h], EAX - -D_LSCheckLoopValues3: - Cmp EAX, [BX+38h] - JAE D_LSCheckLoopValues2 - - Mov [BX+38h], EAX - -D_LSCheckLoopValues2: - Mov EAX, [BX+38h] - Cmp EAX, [BX+34h] - JA D_LSCheckLoopValues1 - - And Byte Ptr [BX+12h], NOT 00010000b - -D_LSCheckLoopValues1: - Call D_DrawWaveForm - - Ret - -EndP D_LSCheckLoopValues - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LSCheckSusLoopValues Far - - Call D_GetLoadSampleVars ; DS:SI points to thing - - Mov BX, SI - - Mov EAX, [BX+30h] - Cmp EAX, [BX+40h] - JA D_LSCheckSusLoopValues3 - - Mov [BX+40h], EAX - -D_LSCheckSusLoopValues3: - Cmp EAX, [BX+44h] - JAE D_LSCheckSusLoopValues2 - - Mov [BX+44h], EAX - -D_LSCheckSusLoopValues2: - Mov EAX, [BX+44h] - Cmp EAX, [BX+40h] - JA D_LSCheckLoopValues1 - - And Byte Ptr [BX+12h], NOT 00100000b - -D_LSCheckSusLoopValues1: - Call D_DrawWaveForm - - Ret - -EndP D_LSCheckSusLoopValues - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveSong Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset SongDirectory - Call D_SetDriveDirectory ; DS:SI points to cur dir. - - Cmp Byte Ptr [FileName], 0 - JNE D_SaveSong2 - - Jmp Glbl_F10 - -D_SaveSong2: -; Call D_CheckOverWrite -; JC D_SaveSong1 - - Push CS -; Push CS -; Pop DS - Pop ES - - Mov SI, Offset FileName - Mov DI, Offset SaveFileName - Mov CX, 14 - -D_SaveSong3: - LodsB - StosB - Cmp AL, '.' - LoopNE D_SaveSong3 - JNE D_SaveSong4 - - Cmp SaveFormat, 1 - JE D_SaveSong5 - - Mov AX, 'TI' - StosW - Xor AX, AX - StosB - Jmp D_SaveSong4 - -D_SaveSong5: - Mov AX, '3S' - StosW - Mov AX, 'M' - StosW - -D_SaveSong4: - Xor AL, AL - Call Glbl_SetCurrentMode - - Cmp SaveFormat, 1 - JE D_SaveFileS3MModule - Jmp D_SaveFileITModule - -EndP D_SaveSong - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PreSaveSample - - Push CS - Pop DS - Assume DS:Disk - - Mov NoSaveError, 0 - - Mov SI, Offset SampleDirectory - Call D_SetDriveDirectory - - Call PE_GetLastInstrument - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - Mov SI, BX - Add SI, SI - Mov SI, [DS:64912+SI] ; SI points to sample. - Inc BX - - ; Check if sample exists - Test Byte Ptr [SI+12h], 1 - JZ D_PreSaveSample1 - - Call DeleteSampleCacheFile - - LEA DX, [SI+4] - - Call D_CheckOverWrite - Ret - -D_PreSaveSample1: - StC - Ret - -EndP D_PreSaveSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveSample Far - - Call D_PreSaveSample - JC D_SaveSample2 - -Proc D_SaveSampleInternal Far - ; OK to save. DS:SI points to - ; structure, BX = sample num - Mov ES, CS:DiskDataArea - Xor DI, DI - Mov CX, 80 - Rep MovsB - Mov Byte Ptr [ES:2Eh], 1 - Mov DWord Ptr [ES:48h], 80 - - Push ES - Pop DS - - Mov AH, 3Ch - Xor CX, CX - Mov DX, 4 - Int 21h ; Open file. - JC D_SaveSample2 - - Push BX ; BX = sample number - Mov BX, AX ; BX = file handle - - Mov AH, 40h - Mov CX, 80 - Xor DX, DX - Int 21h ; Save header. - - Pop AX ; AX = sample number - Push AX - - Call D_SaveSampleData - PushF - - Mov AH, 3Eh - Int 21h ; Close file - - PopF - Pop BX ; AX = sample number - JC D_SaveSample2 - - Push CS - Pop DS - Mov AX, BX - Mov SI, Offset ITSampleSavedMsg - Call SetInfoLine - - Jmp D_SaveSampleEnd - -D_SaveSample2: - Push CS - Pop DS - Mov AX, BX - Mov SI, Offset SampleErrorMsg - Call SetInfoLine - -D_SaveSampleEnd: - Mov AX, 1 - Ret - -EndP D_SaveSampleInternal - -EndP D_SaveSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveRawSample Far - Assume DS:Disk - - Call D_PreSaveSample ; DS:SI points to structure - JC D_SaveRawSample2 - Assume DS:Nothing - -IF SAVESAMPLEWAV - Mov DWord Ptr [CS:WaveBytesPerSample], 80001h - Mov ECX, [SI+3Ch] ; C5Speed - Mov [CS:WAVEMixSpeed], ECX - Mov EAX, [SI+30h] ; Length - Test Byte Ptr [SI+12h], 2 - JZ D_SaveWAVHeader1 - - Add EAX, EAX - Add ECX, ECX - Mov DWord Ptr [CS:WaveBytesPerSample], 100002h - -D_SaveWAVHeader1: - Mov [CS:WAVEDataSize], EAX - Mov [CS:WAVEBytesPerSecond], ECX -ENDIF - Push DS - Push SI - - Mov AX, BX ; AX = sample number. - Xor CX, CX - Call Music_GetSampleLocation ; ES:DI points to sample. - - Mov DI, SI - Push DS - Pop ES - - Pop SI - Pop DS - - PushF - - Mov AH, 3Ch - Xor CX, CX - LEA DX, [SI+4] - Int 21h - JC D_SaveRawSample3 - -IF SAVESAMPLEWAV - PushA - Push DS - - Push CS - Pop DS - - Mov BX, AX - Mov AH, 40h - Mov DX, Offset WAVEFileHeader - Mov CX, 2Ch - Int 21h - - Pop DS - PopA -ENDIF - - PopF - Push BX - XChg AX, BX ; BX = file handle, AX = sample - ; number - JZ D_SaveRawSample1 ; 8 bit, write as unsigned - - Call D_SaveSampleData - PushF - Jmp D_SaveRawSample4 - -D_SaveRawSample1: - Call D_SaveSampleDataConvert - PushF - -D_SaveRawSample4: - Mov AH, 3Eh - Int 21h ; Close file. - - PopF - Pop BX ; BX = Sample number - - JC D_SaveRawSample2 - - Push CS - Pop DS - Assume DS:Disk - - Mov AX, BX - Mov SI, Offset RawSampleSavedMsg - Call SetInfoLine - - ClC - Jmp D_SaveRawSampleEnd - -D_SaveRawSample3: - PopF - -D_SaveRawSample2: - Push CS - Pop DS - Mov AX, BX - Mov SI, Offset SampleErrorMsg - Call SetInfoLine - StC - -D_SaveRawSampleEnd: - Mov AX, 1 - Ret - -EndP D_SaveRawSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveST3Sample Far - - Call D_PreSaveSample - JC D_SaveST3Sample2 - - ; OK to save. DS:SI points to - ; structure, BX = sample num - Mov ES, CS:DiskDataArea - Xor DI, DI - Mov AL, 1 - StosB - Push SI - Mov CX, 13 - Add SI, 4 - Rep MovsB - Pop SI - Mov AX, 5 - StosW ; FileName - - Mov EAX, [DS:SI+30h] ; LoopStart - StosD - - Mov EAX, [DS:SI+34h] ; LoopBeg - StosD - - Mov EAX, [DS:SI+38h] ; LoopEnd - StosD - - Xor AX, AX - Mov AL, Byte Ptr [DS:SI+13h] - StosW ; Volume - - Mov AH, [DS:SI+12h] - Mov AL, AH - And AX, 1002h - ShR AH, 4 - ShL AL, 1 - Or AH, AL - Xor AL, AL - StosW ; Flags & Pack - - Mov EAX, [DS:SI+3Ch] - StosD - - Mov CX, 6 - Xor AX, AX - Rep StosW - - Add SI, 14h - Mov CX, 25 - Rep MovsB - Xor AX, AX - StosB - StosW - - Mov EAX, 'SRCS' - StosD - - Push ES - Pop DS - - Mov AH, 3Ch - Xor CX, CX - Mov DX, 1 - Int 21h ; Open file. - JC D_SaveST3Sample2 - - Push BX ; BX = sample number - Mov BX, AX ; BX = file handle - - Mov AH, 40h - Mov CX, 80 - Xor DX, DX - Int 21h ; Save header. - - Pop AX ; AX = sample number - Push AX - - Call D_SaveSampleDataConvert - - PushF - - Mov AH, 3Eh - Int 21h ; Close file - - PopF - Pop BX - - JC D_SaveST3Sample2 - - Push CS - Pop DS - Mov AX, BX - Mov SI, Offset ST3SampleSavedMsg - Call SetInfoLine - - Jmp D_SaveST3SampleEnd - -D_SaveST3Sample2: - Push CS - Pop DS - Mov AX, BX - Mov SI, Offset SampleErrorMsg - Call SetInfoLine - -D_SaveST3SampleEnd: - Mov AX, 1 - Ret - -EndP D_SaveST3Sample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SaveInstrument Far - - Push CS - Pop DS - Assume DS:Disk - - Mov NoSaveError, 0 - - Mov SI, Offset InstrumentDirectory - Call D_SetDriveDirectory - - Call PE_GetLastInstrument - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - Mov SI, BX - Add SI, SI - Mov SI, [DS:64712+SI] ; SI points to instrument - - Call DeleteInstrumentCacheFile - -; Mov DX, SI -; Add DX, 4 - LEA DX, [SI+4] - - Call D_CheckOverWrite - JC D_SaveInstrumentError - - ; DS:SI still points to ins. - ; Clear InstrumentTable setup table. - Push CS - Pop ES - Mov DI, Offset InstrumentTable - Xor AX, AX - Mov CX, 50 - Rep StosW ; OK.. table clear. - - ; Now step through instrument - ; list and get sample numbers. - Push DS - Push SI - - Add SI, 40h - Mov CX, 120 - Xor BX, BX - -D_SaveInstrument1: - LodsW - Mov BL, AH ; BL = sample number. - Mov [CS:InstrumentTable+BX], 1 - Loop D_SaveInstrument1 - - ; OK. Instrument table contains - ; 1s for every sample used... - ; Now to re-translate it. - Push CS - Pop DS - Assume DS:Disk - - Mov AH, 0 - Mov CX, 99 - Mov SI, Offset InstrumentTable - Mov Byte Ptr [SI], 0 - -D_SaveInstrument2: - Cmp Byte Ptr [SI], 0 - JE D_SaveInstrument3 - - Inc AH - Mov [SI], AH - -D_SaveInstrument3: - Inc SI - Loop D_SaveInstrument2 - ; AH = number of samples.. - ; Now let's copy it to the Diskdata. - - Pop SI - Pop DS - Assume DS:Nothing - - Mov ES, CS:DiskDataArea - Xor DI, DI - Mov CX, 554/2 - - Rep MovsW - - Push ES - Pop DS - Assume DS:Nothing - - Mov [DS:1Eh], AH ; AH = number of samples. - Mov Word Ptr [DS:1Ch], TRACKERVERSION - - ; Now to translate - Mov DI, 41h -; Xor BX, BX - Mov CX, 120 - -D_SaveInstrument4: - Mov BL, [DI] - Mov AL, [CS:InstrumentTable+BX] - StosB - Inc DI - - Loop D_SaveInstrument4 - ; headerfilesize=554(instrumentheader)+ - ; 80*AH. - Mov AL, 80 - Mul AH - Add AX, 554 ; AX = header size. - - Push AX - - Mov DX, AX - Xor CX, CX ; CX:DX = posn in file. - - Call Music_GetSongSegment - Mov DS, AX - Mov DI, 554 ; DI = posn in header. - Xor BX, BX - -D_SaveInstrument5: ; Loop to get samples into header. - Cmp [CS:InstrumentTable+BX], 0 - JE D_SaveInstrument6 - - Mov SI, BX - Add SI, SI - Mov SI, [DS:64912+SI-2] ; DS:SI points to sample. - - Push CX ; Move the header... - Mov CX, 40 - Rep MovsW - Pop CX - - Mov [ES:DI-80+48h], DX ; File pointer. - Mov [ES:DI-80+4Ah], CX - - Mov AL, [ES:DI-80+12h] - Test AL, 1 - JZ D_SaveInstrument6 - - Add DX, [ES:DI-80+30h] - AdC CX, [ES:DI-80+32h] - - Test AL, 2 - JZ D_SaveInstrument6 - - Add DX, [ES:DI-80+30h] - AdC CX, [ES:DI-80+32h] - -D_SaveInstrument6: - Inc BX - Cmp BX, 100 - JB D_SaveInstrument5 - - Push ES - Pop DS ; Lets open the file! - Mov DX, 4 - - Mov AH, 3Ch ; Open file! - Xor CX, CX ; Normal attributes - Int 21h - - Pop CX ; CX = header size - - JC D_SaveInstrumentError - - Mov BX, AX ; BX = file handle... - - Xor DX, DX - Call D_SaveBlock ; OK.. header's written.. now save - ; individual samples... - Mov DI, 1 - -D_SaveInstrument7: - Cmp [CS:InstrumentTable+DI], 0 - JE D_SaveInstrument8 - - Mov AX, DI - - Call D_SaveSampleData - -D_SaveInstrument8: - Inc DI - Cmp DI, 100 - JBE D_SaveInstrument7 - - Mov AH, 3Eh - Int 21h - Jmp D_SaveInstrumentOK - -D_SaveInstrumentError: - Push CS - Pop DS - - Call PE_GetLastInstrument - Mov AX, BX - Inc AX - Mov SI, Offset InstrumentErrorMsg - Call SetInfoLine - - Jmp D_SaveInstrumentEnd - -D_SaveInstrumentOK: - Push CS - Pop DS - - Call PE_GetLastInstrument - Mov AX, BX - Inc AX - Mov SI, Offset ITInstrumentSavedMsg - Call SetInfoLine - -D_SaveInstrumentEnd: - Mov AX, 1 - Ret - -EndP D_SaveInstrument - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DeleteSampleFile Far - - Push CS - Pop DS - Assume DS:Disk - - Cmp NumSamples, 0 - JE D_DeleteSampleFile1 - Cmp SamplesInModule, 0 - JNE D_DeleteSampleFile1 - - Mov AX, 96 - Mul CurrentSample - Mov SI, AX - Mov DS, DiskDataArea - Assume DS:Nothing - Cmp Byte Ptr [DS:SI+58h], 1 - JBE D_DeleteSampleFile1 ; Don't delete dirs! -; Cmp Byte Ptr [DS:SI+58h], 20h -; JAE D_DeleteSampleFile1 - - Push DS - Push SI - - Mov DI, Offset O1_ConfirmDelete2 - Mov CX, 4 - Call M_Object1List - - Pop SI - Pop DS - - And DX, DX ; OK to delete? - JZ D_DeleteSampleFile1 - - ; Delete file.... - LEA DX, [SI+4] - Mov AH, 41h - Int 21h - JC D_DeleteSampleFile1 - - Push CS - Pop DS - Assume DS:Disk - - Mov DI, SI - Add SI, 96 - - Mov CX, NumSamples ; Wipe from list.. - Mov BX, CurrentSample - Sub CX, BX - - Mov AX, 96 - Mul CX - Mov CX, AX - - Push DS - - Mov DS, DiskDataArea - Push DS - Pop ES - - Rep MovsB - - Pop DS - - Mov SampleInMemory, 0FFFFh - Mov SampleCheck, 0FFFFh - - Dec NumSamples - JZ D_DeleteSampleFile2 - - Cmp BX, NumSamples - JB D_DeleteSampleFile2 - - Mov BX, NumSamples - Dec BX - Mov CurrentSample, BX - -D_DeleteSampleFile2: - Cmp SampleCacheFileComplete, 1 - JNE D_DeleteSampleFile1 - - Call D_SaveSampleCacheFile - -D_DeleteSampleFile1: - Mov AX, 1 - Ret - -EndP D_DeleteSampleFile - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckSampleModified - - Push CS - Pop DS - Assume DS:Disk - - Cmp SamplesInModule, 0 - JNE CheckSampleModified1 - - Mov AX, 96 - Mul CurrentSample - - Mov ES, DiskDataArea - Mov DI, AX - Mov DL, [ES:DI+88] - Cmp DL, 1 - JBE CheckSampleModified1 - Cmp DL, 20h - JAE CheckSampleModified1 - - Mov SI, Offset CheckDataArea - - Mov CX, 12h - RepE CmpSB - JNE CheckSampleModified7 - Inc SI - Inc DI - Mov CX, 50h-12h-1 - RepE CmpsB - JE CheckSampleModified1 - Mov CX, 80 - RepE CmpsB - - ; Check whether file name changed... -CheckSampleModified7: - Mov DI, AX - Mov SI, Offset CheckDataArea+4 - Add DI, 4 - - Mov CX, 13 - RepE CmpsB - JE CheckSampleModified3 - -CheckSampleModified2: ; Sample name different. - Mov DI, Offset O1_ConfirmSaveRenameList - Mov CX, 3 - Call M_Object1List - ; DX = 0 -> don't save - ; DX = 1 -> save - And DX, DX - JZ CheckSampleModified4 - - ; Load Sample - Push CS - Pop DS - - Mov SI, Offset CheckDataArea - Mov AX, 99 - Call LoadSample ; Load sample into slot 100! - JC CheckSampleModified5 - ; Save sample - Mov AX, 96 - Mul CS:CurrentSample - Mov SI, AX - Mov DS, CS:DiskDataArea - Mov BX, 100 ; DS:SI points to block - Push DS - Push SI - Call D_SaveSampleInternal - Pop SI - Pop DS - JC CheckSampleModified6 - ; Delete old sample - - Push CS - Pop DS - Mov DX, Offset CheckDataArea+4 - Mov AH, 41h - Int 21h ; Delete file - - ; Now update sample data... - - Call DeleteSampleCacheFile - Call D_InitLoadSamples - - Jmp CheckSampleModified1 ; Return OK! - -CheckSampleModified3: ; Sample name the same. - Mov DI, Offset O1_ConfirmResaveList - Mov CX, 3 - Call M_Object1List - ; DX = 0 -> don't save - ; DX = 1 -> save - And DX, DX - JZ CheckSampleModified4 - - ; Load Sample - Push CS - Pop DS - - Mov SI, Offset CheckDataArea - Mov AX, 99 - Call LoadSample ; Load sample into slot 100! - JC CheckSampleModified5 - - ; Save Sample - Mov AX, 96 - Mul CS:CurrentSample - Mov SI, AX - Mov DS, CS:DiskDataArea - Mov BX, 100 ; DS:SI points to block - Push DS - Push SI - Call D_SaveSampleInternal - Pop SI - Pop DS - JC CheckSampleModified6 - ; Now update sample data... - Call DeleteSampleCacheFile - Call D_InitLoadSamples - - Jmp CheckSampleModified1 - -CheckSampleModified4: ; Prompt to discard changes.. - Mov DI, Offset O1_ConfirmDiscardList - Mov CX, 4 - Call M_Object1List - ; DX = 0 -> don't discard - ; DX = 1 -> discard - And DX, DX - JZ CheckSampleModified5 - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset CheckDataArea - Mov ES, DS:DiskDataArea - Mov AX, 96 - Mul CurrentSample - Mov DI, AX - Mov CX, 80 - Rep MovsB - - Jmp CheckSampleModified1 - -CheckSampleModified6: - Call DeleteSampleCacheFile - Call D_InitLoadSamples - -CheckSampleModified5: - Push CS - Pop DS - - StC - Ret - -CheckSampleModified1: - Push CS - Pop DS - - ClC - Ret - -EndP CheckSampleModified - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DrawWaveForm Far - - PushAD - Push DS - Push ES - - Call S_GetGenerationTableOffset - Push DI - Mov CX, 248*32 - Xor AL, AL - Rep StosB - Pop DI - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation ; Gets DS:SI and CX - JC D_DrawWaveFormEnd - -; Push AX ; AX = instrument num - ; DS:SI = waveform, CX = length - ; ES:DI = charactergenerationtable - - SetNZ CS:Resolution - JZ D_DrawWaveForm8Bit - - Add ECX, ECX - Inc SI - -D_DrawWaveForm8Bit: - - Mov EAX, ECX - Mov ECX, 248 - Xor EDX, EDX - Div ECX ; AX = major shift. DX = minor shift. - - Mov EBX, EAX - Xor EAX, EAX - Div ECX - - Mov EDX, EAX - Xor EAX, EAX - - Mov EBP, ESI - -D_DrawWaveForm6: - Add EAX, EDX - AdC EBP, EBX - Push EAX - Push EBX - Push ECX - Push EDX - - Mov CL, [SI] - Mov CH, CL - - Mov BX, 1 - Add BL, CS:Resolution - -D_DrawWaveForm10: - Cmp ESI, EBP - JAE D_DrawWaveForm7 - - Mov AL, [SI] - Add SI, BX - JC D_DrawWaveFormUpdateLocation - -D_DrawWaveFormResume: - Cmp AL, CL - JL D_DrawWaveForm8 - - Cmp AL, CH - JLE D_DrawWaveForm10 - - Mov CH, AL - Jmp D_DrawWaveForm10 - -D_DrawWaveFormUpdateLocation: - Add ESI, 10000h - Int 3 - Jmp D_DrawWaveFormResume - -D_DrawWaveForm8: - Mov CL, AL - Jmp D_DrawWaveForm10 - -D_DrawWaveForm7: ; CL = min, CH = max. - Mov AX, CX - SAR AH, 1 - SAR AL, 1 - Add AX, 202h - SAR AL, 2 - SAR AH, 2 - - Xor CH, CH - Mov CL, AH - Sub CL, AL ; CX = iterations. - Inc CX - - Mov AL, 16 - Sub AL, AH - Cmp AL, 32 - JNE D_DrawWaveForm13 - - Mov AL, 31 - -D_DrawWaveForm13: - Mov AH, 31*8 - Mul AH - Mov BX, AX - -D_DrawWaveForm11: - Mov Byte Ptr [ES:DI+BX], 1 - Add BX, 248 - Loop D_DrawWaveForm11 - -D_DrawWaveForm12: - Pop EDX - Pop ECX - Pop EBX - Pop EAX - Inc DI - Loop D_DrawWaveForm6 - - ; Get Sample header offset. -; Call Music_GetSongSegment -; Mov DS, AX -; Pop SI -; Dec SI -; Add SI, SI -; Mov SI, [64912+SI] - Mov AX, 96 - Mul CS:CurrentSample - Mov DS, CS:DiskDataArea - Mov SI, AX - - - Mov EBX, [DS:SI+30h] - Test Byte Ptr [DS:SI+12h], 10h - JZ D_DrawWaveForm14 - - Mov ECX, EBX - ShR ECX, 1 - - Mov EAX, 247 - Mul DWord Ptr [DS:SI+34h] - Add EAX, ECX - AdC EDX, 0 - Div EBX - - Push EAX ; AX = loop start. - - Mov EAX, 247 - Mul DWord Ptr [DS:SI+38h] - Add EAX, ECX - AdC EDX, 0 - Div EBX - Mov EDX, EAX - Pop EAX ; DX = loop end (0-175) - ; AX = loop start (0-175) - - Call S_GetGenerationTableOffset - ; ES:DI - Add DI, AX - Sub DX, AX - Dec DX - Mov CX, 32 - Mov AH, 1 - -D_DrawSampleWaveFormLoop1: - Push DI - - Xor AL, AL - Test AH, 2 - JZ D_DrawSampleWaveFormLoop2 - - Inc AX - -D_DrawSampleWaveFormLoop2: - StosB - Add DI, DX - StosB - - Pop DI - Add DI, 248 - Inc AH - Loop D_DrawSampleWaveFormLoop1 - -D_DrawWaveForm14: - Test Byte Ptr [DS:SI+12h], 20h - JZ D_DrawWaveFormEnd - - Mov ECX, EBX - ShR ECX, 1 - - Mov EAX, 247 - Mul DWord Ptr [DS:SI+40h] - Add EAX, ECX - AdC EDX, 0 - Div EBX - - Push EAX ; AX = loop start. - - Mov EAX, 247 - Mul DWord Ptr [DS:SI+44h] - Add EAX, ECX - AdC EDX, 0 - Div EBX - Mov EDX, EAX - Pop EAX ; DX = loop end (0-175) - ; AX = loop start (0-175) - - Call S_GetGenerationTableOffset - ; ES:DI - Add DI, AX - Sub DX, AX - Dec DX - Mov CX, 32 - Mov AL, 1 - -D_DrawSampleWaveFormSusLoop1: - Push DI - - StosB - Add DI, DX - StosB - - Pop DI - Add DI, 248 - Xor AL, 1 - Loop D_DrawSampleWaveFormSusLoop1 - -D_DrawWaveFormEnd: - Mov AX, 0 - Mov BX, 31 - Mov CX, 4 - Call S_GenerateCharacters - - Pop ES - Pop DS - PopAD - - Ret - -EndP D_DrawWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_ClearFileName Far - - Push AX - Push CX - Push ES - Push DI - - Mov DI, Offset FileName - Push CS - Pop ES - Mov CX, 7 - Xor AX, AX - Rep StosW - - Pop DI - Pop ES - Pop CX - Pop AX - Ret - -EndP D_ClearFileName - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GetFormatType Far - - Push CS - Pop ES - Mov DI, Offset SaveFormat - - Ret - -EndP D_GetFormatType - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DisableFileColours Far - - Mov CS:FileColours, 0 - - Ret - -EndP D_DisableFileColours - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadInstrumentFiles - - Mov DS, CS:DiskDataArea - Push DS - Pop ES - - Xor DI, DI - Xor AX, AX - Mov CX, 32768 - Rep StosW - - Mov DX, 64000 - Mov AH, 1Ah - Int 21h ; Shift DTA address.. - ; to DiskDataArea:64000 - - Xor DI, DI - - Push CS - Pop DS - Mov DX, Offset AllFilesMask - Mov CX, 10h - Mov AH, 4Eh - Int 21h - - Mov DS, CS:DiskDataArea - Push DS - Pop ES - - JC D_LoadInstrumentFiles2 - -D_LoadInstrumentFiles1: ; A directory was found! - Test Byte Ptr [DS:64000+15h], 10h - JZ D_LoadInstrumentFiles5 ; Check that it IS a directory - - Cmp Word Ptr [DS:64000+1Eh], '.' - JNE D_LoadInstrumentFilesNoRoot - - Mov Byte Ptr [DS:64000+1Eh], '\' - -D_LoadInstrumentFilesNoRoot: - Mov DL, 1 - Call Near Ptr D_LoadInstrumentFiles6 - - Inc CS:NumInstruments - Inc CS:LoadInstrumentNameCount - - Cmp CS:NumInstruments, 999 - JAE D_LoadInstrumentFiles4 - -D_LoadInstrumentFiles5: - Mov AH, 4Fh - Int 21h - JNC D_LoadInstrumentFiles1 - -D_LoadInstrumentFiles2: ; Directories done.. samples now - Push CS - Pop DS - Mov DX, Offset AllFilesMask - Xor CX, CX - Mov AH, 4Eh - Int 21h - - Mov DS, CS:DiskDataArea - Push DS - Pop ES - - JC D_LoadInstrumentFiles4 - -D_LoadInstrumentFiles3: -; Push DI -; -; Mov SI, Offset InstrumentCacheFileName -; Mov DI, 64000+1Eh -; Mov CX, 9 -; Rep SegCS CmpsB -; Pop DI -; JE D_LoadInstrumentFilesNext - - Mov DL, 0 - Call Near Ptr D_LoadInstrumentFiles6 - - Inc CS:NumInstruments - Cmp CS:NumInstruments, 999 - JAE D_LoadInstrumentFiles4 - -D_LoadInstrumentFilesNext: - Mov AH, 4Fh - Int 21h - JNC D_LoadInstrumentFiles3 - -D_LoadInstrumentFiles4: ; End! - Mov AX, CS:NumInstruments - Mov CS:InitialInstruments, AX - - Ret - -D_LoadInstrumentFiles6: ; Get name/size/date/time. - Mov AL, DL - StosB - - Mov SI, 64000+1Eh - Mov CX, 14 ; Name.. - Rep MovsB - - Cmp DL, 1 - JNE D_LoadInstrumentFiles7 - - Push DS - Push CS - Pop DS - Mov SI, Offset DirectoryMsg - Mov CX, 25 - Rep MovsB - - Pop DS - - Xor AX, AX - Mov CX, 4 - Rep StosW - - RetN - -D_LoadInstrumentFiles7: - Xor AX, AX - Mov CX, 27 - Rep StosB ; No instrumentname, NOS = 0. - - Mov AX, [DS:64000+1Ah] ; File Size.. - Mov DX, [DS:64000+1Ch] - - SHRD AX, DX, 10 - ShR DX, 10 - JZ D_LoadInstrumentFiles8 - - Mov AX, 0FFFFh - -D_LoadInstrumentFiles8: - StosW - - Xor EAX, EAX ; Offset - StosD - - RetN - -EndP D_LoadInstrumentFiles - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_InitLoadInstruments Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset InstrumentDirectory - Call D_SetDriveDirectory ; DS:SI points to cur dir. - - Call Music_GetSongSegment - Mov DS, AX - - Mov CX, 99 - Mov BX, [DS:64912] ; BX = offset to first - ; sample. - - Mov DX, CX ; DX = counter. - Add BX, 12h - -D_InitLoadInstruments4: - Mov AL, [BX] - ShR AL, 1 - SBB DX, 0 - - Add BX, 80 - Loop D_InitLoadInstruments4 - - Push CS - Pop DS - Assume DS:Disk - - Mov UnusedSamples, DX - - Cmp InstrumentsInModule, 0 - JE D_InitLoadInstruments5 - - Jmp LIWindow_EnterLoadInInstrumentData - -D_InitLoadInstruments5: - Mov LoadInstrumentNameCount, 0 - Mov NumInstruments, 0 - Mov InstrumentCacheFileComplete, 0 - - Mov SI, Offset InstrumentDirectory - Call D_SetDriveDirectory ; DS:SI points to cur dir. - - Mov [OldCacheTime], 0 - - Mov AX, 3D00h ; Open file.. - Mov DX, Offset InstrumentCacheFileName - Int 21h - JC D_InitLoadInstrument1 ; Can't open file? - - Mov BX, AX - - Mov AH, 3Fh - Mov CX, 6 ; 2 integers containing number - ; of sample entries... - ; 3rd word = Version check - Mov DS, DiskDataArea - Assume DS:Nothing - - Xor DX, DX - Int 21h - JC D_InitLoadInstrument3 - Cmp AX, CX - JNE D_InitLoadInstrument3 - - Mov AL, [CS:InstrumentDirectory] ; AL = drive letter - Cmp AL, [CS:CDRomStartDrive] - JL InstrumentVersionCheck - Cmp AL, [CS:CDRomEndDrive] - JGE InstrumentVersionCheck - - Cmp Word Ptr [DS:4], 211h - JB D_InitLoadInstrument3 - Cmp Word Ptr [DS:4], TRACKERVERSION - JBE D_InitLoadInstrumentsCacheOK - -InstrumentVersionCheck: - Cmp Word Ptr [DS:4], TRACKERVERSION - JNE D_InitLoadInstrument3 - -InstrumentVersionCheckEnd: - Mov AX, 5700h ; Get file date&time. - Int 21h - - Mov Word Ptr [OldCacheTime], CX - Mov Word Ptr [OldCacheTime+2], DX - - Cmp CX, Time ; Check time and date - JNE D_InitLoadInstrumentOldCache ; for 'currentness' - Cmp DX, Date - JNE D_InitLoadInstrumentOldCache - ; OK.. let's load... - -D_InitLoadInstrumentsCacheOK: - Mov AX, [DS:0] - Mov CS:InitialInstruments, AX - - Mov SI, [DS:2] ; Number of samples. - Mov AX, 48 - Mul SI - Mov CX, AX ; Bytes to read. - - Mov AH, 3Fh ; Load again. - Xor DX, DX ; In case of internal malfunc. - Int 21h - JC D_InitLoadInstrument3 - Cmp AX, CX - JNE D_InitLoadInstrument3 - - Mov AH, 3Eh ; Close file. - Int 21h - - Push CS - Pop DS - Assume DS:Disk - - Mov LoadInstrumentNameCount, SI - Mov NumInstruments, SI - Mov InstrumentCacheFileComplete, 1 - - Jmp D_InitLoadInstrument2 - -D_InitLoadInstrumentOldCache: - PushA - Push DS - - Call D_GetNumFiles - - Pop DS - JC D_InitLoadInstrument5 - - Cmp AX, [DS:0] - - PopA - JNE D_InitLoadInstrument3 - - Call Far Ptr D_InitLoadInstrumentsCacheOK - - Call D_SaveInstrumentCacheFile ; Resave it with new date - - Ret - -D_InitLoadInstrument5: - PopA - -D_InitLoadInstrument3: - Mov AH, 3Eh ; Close file. - Int 21h - - Push CS - Pop DS - Assume DS:Disk - - Call DeleteInstrumentCacheFile - -D_InitLoadInstrument1: - Call D_LoadInstrumentFiles - -D_InitLoadInstrument2: - Ret - -EndP D_InitLoadInstruments - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_LoadInstrumentNames Far - - Push CS - Pop DS - Assume DS:Disk - - Cmp InstrumentCacheFileComplete, 1 - JNE D_LoadInstrumentNames2 - -D_LoadInstrumentNames6: - Xor AX, AX ; No redraw screen. - Ret - -D_LoadInstrumentNames2: - Mov BX, LoadInstrumentNameCount - Cmp BX, NumInstruments - JAE D_LoadInstrumentNames5 - -D_LoadInstrumentNames1: - Call K_IsAnyKeyDown - And AL, AL - JNZ D_LoadInstrumentNames6 - - Call GetKeyboardLock - And AL, AL - JNZ D_LoadInstrumentNames6 - - Mov AX, 48 - Mul BX - Mov SI, AX - Mov ES, DiskDataArea - Cmp Byte Ptr [ES:SI], 0 - JNE D_LoadInstrumentNames3 - - Call D_LoadInstrumentHeader - JC D_LoadInstrumentNames3 - - Call D_GetInstrumentInfo ; BX = sample number - Push CS - Pop DS - JC D_LoadInstrumentNames7 - -D_LoadInstrumentNames3: - Push CS - Pop DS - Assume DS:Disk - - Inc LoadInstrumentNameCount - -D_LoadInstrumentNames7: - Mov BX, LoadInstrumentNameCount - Cmp BX, NumInstruments - JNE D_LoadInstrumentNames4 - ; Save cache file.. - -D_LoadInstrumentNames5: - Call D_SaveInstrumentCacheFile - Cmp CurrentInstrument, 0 - JNE D_LoadInstrumentNames4 - Call D_SlowInstrumentSort - -D_LoadInstrumentNames4: - Mov AX, 1 ; Signify redraw screen - Ret - -EndP D_LoadInstrumentNames - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DrawLoadInstrument Far - - Cmp CS:NumInstruments, 0 - JNE D_DrawLoadInstrumentPresent - - Jmp D_DrawLoadInstrumentEnd - -D_DrawLoadInstrumentPresent: - Mov BX, CS:CurrentInstrument - Mov AX, 48 - Mul BX - Mov SI, AX - Mov ES, CS:DiskDataArea - - Cmp Byte Ptr [ES:SI], 0 - JNE D_DrawLoadInstrumentWindow28 - - Call D_LoadInstrumentHeader - Call D_GetInstrumentInfo - JC D_DrawLoadInstrument - -D_DrawLoadInstrumentWindow28: - Call S_GetDestination - - Push CS - Pop DS - Assume DS:Disk - - Mov AX, TopInstrument - Mov BX, CurrentInstrument - Cmp AX, BX - JBE D_DrawLoadInstrument1 - - Mov AX, BX - -D_DrawLoadInstrument1: - LEa CX, [EAX+34] - Cmp CX, BX - JA D_DrawLoadInstrument2 - - LEA AX, [BX-34] - -D_DrawLoadInstrument2: - Mov TopInstrument, AX - - Mov DS, DiskDataArea - Assume DS:Nothing - - Mov DI, (2+13*80)*2 - Mov CX, 35 - -D_DrawLoadInstrument3: - Push AX - Push CX - Push DI - - Cmp AX, CS:NumInstruments - JB D_DrawLoadInstrument4 - - Mov AX, 2A8h - Add DI, 58 - StosW - Add DI, 24 - StosW - -D_DrawLoadInstrument10: - Add DI, 20 - StosW - - Jmp D_DrawLoadInstrument5 - -D_DrawLoadInstrument4: - Inc AX - Mov CH, 20h - Call PE_ConvAX2Num - Dec AX - - Add DI, 8 - Mov BX, 48 - Mul BX - Mov SI, AX ; SI = offset in diskdata.. - ; Name first.. - - Mov DL, [SI] - ; DL = type. 0 = unchecked - ; 1 = directory - ; 2 = unknown - ; 3 = ITI. - Mov AH, 6 - Cmp DL, 1 - JB D_DrawLoadInstrument6 - - Mov AH, 5 - JE D_DrawLoadInstrument6 - - Mov AH, 7 - Cmp DL, 2 - JE D_DrawLoadInstrument6 - - Mov AH, 3 - -D_DrawLoadInstrument6: - Mov DH, AH ; DH = col. - Mov CX, 25 ; Instrument Name - Add SI, 15 - -D_DrawLoadInstrument7: - LodsB - - Cmp AL, 226 - JB D_DrawLoadInstrumentCharFilter - - Mov AL, ' ' - -D_DrawLoadInstrumentCharFilter: - StosW - Loop D_DrawLoadInstrument7 - - Mov AX, 2A8h - StosW ; Divider 1. - - Mov AH, DH - ; File name... - Sub SI, 39 - Mov CX, 12 - -D_DrawLoadInstrument8: - LodsB - StosW - And AL, AL - LoopNZ D_DrawLoadInstrument8 - - Add DI, CX - Add DI, CX - - Mov AX, 2A8h - StosW ; Divider 2. - - Cmp DL, 3 - JB D_DrawLoadInstrument10 - - LEA SI, [ESI+ECX+27] - LodsW ; AX = number of samples. - - Push DS - Push SI - Push DI - Push AX - - Cmp Byte Ptr [SI-42], 8 - - Push CS - Pop DS - - Mov SI, Offset InstrumentLibrary - JAE D_DrawLoadInstrument9 - - Mov SI, Offset InstrumentNoSample - Cmp AX, 1 - JB D_DrawLoadInstrument9 - - Mov SI, Offset InstrumentSingleSample - JE D_DrawLoadInstrument9 - - Mov SI, Offset InstrumentSeveralSamples - Cmp AX, 0FFFFh - JNE D_DrawLoadInstrument9 - - Mov SI, Offset InstrumentUnknownSamples - -D_DrawLoadInstrument9: - Mov AH, DH - Call S_DrawString - - Pop AX - Pop DI - Pop SI - Pop DS - - Mov AX, 2A8h - Add DI, 20 - StosW ; Divider.. now file size... - - LodsW ; AX = file size. - - Push DS - - Push CS - Pop DS - Mov SI, Offset FileSizeMsg - - Push AX - Mov AH, DH - Call S_DrawString - - Pop AX - - Pop DS - -D_DrawLoadInstrument5: - Pop DI - Pop CX - Pop AX - - Inc AX - - Add DI, 160 - Loop D_DrawLoadInstrument3 - - Push CS - Pop DS - Jmp D_DrawLoadInstrumentEnd2 - -D_DrawLoadInstrumentEnd: - Push CS - Pop DS - Assume DS:Disk - - Mov DI, (6+13*80)*2 ; (6, 13) - Mov SI, Offset NoFilesMsg - - Mov AH, 5 - Call S_DrawString - -D_DrawLoadInstrumentEnd2: ; Put Unused Sample msg. - Mov AX, UnusedSamples - Push AX - - Mov SI, Offset FreeSampleMsg - Mov DI, (64+13*80)*2 - Mov AH, 20h - - Call S_DrawString - - Pop AX - - Ret - -EndP D_DrawLoadInstrument - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PreLoadInstrument Far - - Push CS - Pop DS - Assume DS:Disk - - Mov AX, CurrentInstrument - Sub AX, TopInstrument - Add AX, 13 - Mov BX, 160 - Mul BX - - Call S_GetDestination - - LEA DI, [EAX+12] - Mov CX, 56 - -D_PreLoadInstrument1: - Mov AX, [ES:DI] - - Mov AH, 32h - - Cmp AL, 0A8h - JE D_PreLoadInstrument3 - -D_PreLoadInstrument2: - Mov AH, 30h - -D_PreLoadInstrument3: - StosW - - Loop D_PreLoadInstrument1 - - Ret - - Ret - -EndP D_PreLoadInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostLoadInstrument Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset LoadInstrumentKeys - Call M_FunctionDivider - JC D_PostLoadInstrument1 - - Jmp [SI] - -D_PostLoadInstrument1: - Xor AX, AX - Ret - -EndP D_PostLoadInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_ViewInstrument Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset ViewInstrumentKeys - Call M_FunctionDivider - JC D_ViewInstrument1 - - Jmp [SI] - -D_ViewInstrument1: - Xor AX, AX - Ret - -EndP D_ViewInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIWindow_Up Far - - Assume DS:Disk - - Mov AX, CurrentInstrument - And AX, AX - JZ LIWindow_Up1 - - Dec CurrentInstrument - -LIWindow_Up1: - Mov AX, 1 - Ret - -EndP LIWindow_Up - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIWindow_Down Far - - Assume DS:Disk - - Mov AX, CurrentInstrument - - Inc AX - Cmp AX, NumInstruments - JAE LIWindow_Down1 - - Mov CurrentInstrument, AX - -LIWindow_Down1: - Mov AX, 1 - Ret - -EndP LIWindow_Down - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIWindow_PgUp Far - - Assume DS:Disk - - Mov AX, CurrentInstrument - - Sub AX, 35 - JC LIWindow_Home - - Mov CurrentInstrument, AX - -LIWindow_PgUp1: - Mov AX, 1 - Ret - -EndP LIWindow_PgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIWindow_PgDn Far - - Assume DS:Disk - - Mov AX, CurrentInstrument - - Add AX, 35 - Cmp AX, NumInstruments - JAE LIWindow_End - - Mov CurrentInstrument, AX - -LIWindow_PgDn1: - Mov AX, 1 - Ret - -EndP LIWindow_PgDn - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIWindow_Home Far - - Assume DS:Disk - Mov CurrentInstrument, 0 - - Mov AX, 1 - Ret - -EndP LIWindow_Home - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIWindow_End Far - - Assume DS:Disk - - Mov AX, NumInstruments - - Dec AX - JS LIWindow_End1 - - Mov CurrentInstrument, AX - -LIWindow_End1: - Mov AX, 1 - Ret - -EndP LIWindow_End - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIViewWindow_Tab Far - - Mov Word Ptr [ES:DI], 7 - - Mov AX, 1 - Ret - -EndP LIViewWindow_Tab - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include it_d_ri.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIViewWindow_Enter Far - - Assume DS:Disk - - Cmp NumInstruments, 0 - JE LIViewWindow_Enter2 - - Mov AX, 48 - Mul CurrentInstrument - Mov SI, AX - Assume DS:Nothing - - Mov DS, DiskDataArea - Mov DL, [DS:SI] - Cmp DL, 1 - JE LIViewWindow_Enter1 - Cmp DL, 8 - JAE LIWindow_InInstrument1 - -LIViewWindow_Enter2: - Mov AX, 1 - Ret - -EndP LIViewWindow_Enter - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LIWindow_Enter Far - - Assume DS:Disk - - Cmp NumInstruments, 0 - JE LIWindow_Enter4 - - Mov AX, 48 - Mul CurrentInstrument - Mov SI, AX - Assume DS:Nothing - - Mov DS, DiskDataArea - Mov DL, [DS:SI] - Cmp DL, 1 - JNE LIWindow_Enter1 - -LIViewWindow_Enter1: - Push DS - Push SI - - Push CS - Pop DS - Mov SI, Offset InstrumentDirectory - Call D_SetDriveDirectory - - Pop SI - Pop DS - - Inc SI - Call D_SetDriveDirectory - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset InstrumentDirectory - Call D_GetDriveDirectory - -LIWindow_EnterInModuleError: - Mov InstrumentsInModule, 0 - Call D_InitLoadInstruments - Assume DS:Nothing - - Mov CS:CurrentInstrument, 0 - -LIWindow_Enter4: - Mov AX, 1 - Ret - -LIWindow_Enter1: ; Load sample into sample list. - Cmp DL, 8 - JAE LIWindow_InInstrument1 - Cmp DL, 3 - JAE LIWindow_Enter2 - - Xor AX, AX - Ret - -LIWindow_InInstrument1: - Mov CS:InInstrumentFormat, DL - - Inc SI - ; Copy module name across - Push CS - Pop ES - Mov DI, Offset InInstrumentFileName - Mov CX, 13 - Rep MovsB - ; Open file - Push CS - Pop DS - Assume DS:Disk - - Mov CurrentInstrument, 0 - -LIWindow_EnterLoadInInstrumentData: - Mov DX, Offset InInstrumentFileName - Mov AX, 3D00h - Int 21h - JC LIWindow_EnterInModuleError - - Mov BX, AX - - Mov SI, Word Ptr InInstrumentFormat - And SI, 0FFh - Add SI, SI - - Mov NumInstruments, 1 - - Mov DS, DiskDataArea - Assume DS:Nothing - - Push DS - Pop ES - - Call [CS:InstrumentLoaderTable+SI-6] - - ; Close module - Mov AH, 3Eh - Int 21h - - ; Setup first 'directory' - - Push CS - Pop DS - Assume DS:Disk - - Xor DI, DI - Mov SI, Offset ExitInstrumentLibraryDirectory - Mov CX, 48 - Rep MovsB - - Mov InstrumentCacheFileComplete, 1 - Mov InstrumentsInModule, 1 - - Mov AX, NumInstruments - Mov LoadInstrumentNameCount, AX - - Mov AX, 1 - Ret - Assume DS:Nothing - -LIWindow_Enter2: - Mov EAX, [SI+44] - Mov CS:LoadInstrumentOffset, EAX - Mov AX, [SI+40] - Mov CS:NumInstrumentSamples, AX - - And DX, 0FFh - Sub DX, 3 - Add DX, DX - Mov BX, DX - Mov AX, [CS:InstrumentLoaderTable+BX] - Mov [CS:InstrumentLoader], AX - - Mov AX, [SI+40] - Cmp AX, UnusedSamples - JBE LIWindow_Enter5 - - Mov CX, 0FFFFh - Mov DI, Offset O1_OutOfSamplesList - Call M_Object1List - Jmp LIWindow_Enter4 - -LIWindow_Enter5: ; OK.. enough 'sample space'.. - Call Music_Stop - - ; Clean out all old samples... - ; 1. Clean out table - ; 2. Set all samples used in inst to 1 - ; 3. Step through all insts and set - ; samples to 0 - ; 4. Delete all samples with 1. - Push CS ; Step 1. - Pop ES - Mov DI, Offset InstrumentTable - Mov CX, 50 - Xor AX, AX - Rep StosW ; Step 1. Done. - - Push DS - Push SI - - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - - Call PE_GetLastInstrument - Mov DX, BX ; DX = instrument, 0 based - Add BX, BX - Mov SI, [DS:64712+BX] - Add SI, 40h - Mov CX, 120 - -ClearSamples1: - LodsW ; AH = sample. AL = note - Mov BL, AH - Mov [CS:InstrumentTable+BX], 1 - Loop Clearsamples1 - - Xor BX, BX - -ClearSamples2: - Cmp BX, DX - JE ClearSamples3 - - Mov SI, BX - Add SI, SI - Mov SI, [DS:64712+SI] - Add SI, 41h - Mov CX, 120 - -ClearSamples4: - LodsW - And AX, 0FFh - Mov DI, AX - Mov [CS:InstrumentTable+DI], 0 - Loop ClearSamples4 - -ClearSamples3: - Inc BX - Cmp BL, 99 - JB ClearSamples2 - - Xor DI, DI - -ClearSamples5: - Cmp [CS:InstrumentTable+DI+1], 0 - JE ClearSamples6 - - Mov AX, DI - Call Music_ReleaseSample - -ClearSamples6: - Inc DI - Cmp DI, 99 - JB ClearSamples5 - - Pop DX - Pop DS - ; Process. - ; 1. Reset instrument-sample table. - ; 2. Read all sample headers into mem. - ; 3. Load each sample/sample header. - ; 4. Store instrument header. - - Push CS ; Step 1. - Pop ES - Mov DI, Offset InstrumentTable - Mov CX, 50 - Xor AX, AX - Rep StosW ; Step 1. Done. - - ; OK. to do step 2. - ; a) Open file. - ; b) if error.. skip! - ; c) Load file. - - Inc DX - Mov AX, 3D00h ; Open file.. -; Mov DX, SI -; Inc DX ; DS:DX points to file name - Int 21h - - JNC LIWindow_Enter6 - - Mov AX, 1 - Ret - -LIWindow_Enter6: - Mov BX, AX ; BX = file handle. - - ; Load instrument data into DS:64000 - ; Step 3. Go through each sample. - Call [CS:InstrumentLoader] - - Call Music_GetSongSegment - Mov ES, AX - - Mov CL, [DS:64000+1Eh] - And CX, 0FFh - JZ LIWindow_Enter10 - - Push CX - - Mov DI, [ES:64912] - Add DI, 12h-80 - Xor SI, SI - Xor AX, AX - -LIWindow_Enter8: ; Figure out instrument translation - ; table first. - Inc AX - Add DI, 80 - Test Byte Ptr [ES:DI], 1 ; Sample present? - JNZ LIWindow_Enter8 - - Inc SI - Mov [CS:InstrumentTable+SI], AL - - Loop LIWindow_Enter8 - - Pop CX - - Xor SI, SI ; SI = pointer to first sample. - Mov DI, 1 ; DI = untranslated sample number. - -LIWindow_Enter9: - Push CX ; Have to load EACH sample... - Push DS - Push SI - Push ES - Push DI - - Mov DL, [CS:InstrumentTable+DI] - Xor DH, DH ; DX = translated sample number. - Dec DX - - Mov DI, DX - Add DI, DI ; DI = 2*samplenumber - Mov DI, [ES:64912+DI] ; ES:DI points to sample in mem. - - Mov CX, 48h/2 - Rep MovsW - Xor AX, AX - StosW ; Sample pointer data. - StosW - Add SI, 4 - MovsW - MovsW ; OK.. sample header transferred.. - ; Need to load sample data?? - Mov Word Ptr [ES:DI-80+2Eh], 1 - -IF NETWORKENABLED - Mov AL, NETWORK_SAMPLEHEADEROBJECT - Mov AH, DL - Call Network_AddWordToQueue -ENDIF - Test Byte Ptr [SI-80+12h], 1 - JZ LIWindow_Enter11 ; No! - - Push DX - Push DX - - Mov AX, 4200h - Mov CX, [SI-80+4Ah] - Mov DX, [SI-80+48h] - Int 21h ; Move pointer... - - Pop AX - Sub SI, 80 - Call PE_SaveCurrentPattern - Call D_LoadSampleData - Call PE_RestoreCurrentPattern - - Pop CX - -IF NETWORKENABLED - Xor DX, DX - Call Network_QueueSampleData -; Mov AL, NETWORK_SAMPLEHEADEROBJECT -; Mov AH, DL -; Call Network_AddWordToQueue -ENDIF - - - Jmp LIWindow_Enter11 - -LIWindow_Enter12: - Call PEFunction_OutOfMemoryMessage - -LIWindow_Enter11: - Pop DI - Pop ES - Pop SI - Pop DS - Pop CX - - Inc DI - Add SI, 80 - - Loop LIWindow_Enter9 - -LIWindow_Enter10: ; Now to copy instrument... - Mov AH, 3Eh - Int 21h ; Close file first. - - Call I_GetInstrumentOffset - ; DS:BX points to instrument - ; DS:64000 points to loaded instrument - ; so copy everything, but update the - ; sample numbers.. - Mov DI, BX - Push DS - Pop ES - - Mov DS, CS:DiskDataArea - - - Mov SI, 64000 - Mov CX, 40h/2 - Rep MovsW - - Mov CX, 120 - Xor BX, BX - -LIWindow_Enter7: - MovsB ; Note transferred. - LodsB - Mov BL, AL - Mov AL, [CS:InstrumentTable+BX] - StosB - Loop LIWindow_Enter7 - - Mov CX, 250/2 - Rep MovsW - - Call Music_SoundCardLoadAllSamples - - Call Music_GetInstrumentMode - JNZ LIWindow_Enter13 - - Mov CX, 3 - Mov DI, Offset O1_EnableInstrumentMode - Call M_Object1List - Test DX, DX - - JZ LIWindow_Enter13 - - Call Music_GetSongSegment - Mov DS, AX - Or Byte Ptr [DS:2Ch], 4 - -IF NETWORKENABLED - Mov CX, 1 - Mov DX, 2Ch - Call Network_SendSongDataInformation -ENDIF - -LIWindow_Enter13: - NetworkSendInstrument - Jmp Glbl_F4 - -EndP LIWindow_Enter - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_DeleteInstrumentFile Far - - Push CS - Pop DS - Assume DS:Disk - - Cmp NumInstruments, 0 - JE D_DeleteInstrumentFile1 - Cmp InstrumentsInModule, 0 - JNE D_DeleteInstrumentFile1 - - Mov AX, 48 - Mul CurrentInstrument - Mov SI, AX - Mov DS, DiskDataArea - Assume DS:Nothing - Cmp Byte Ptr [DS:SI], 1 - JBE D_DeleteInstrumentFile1 ; Don't delete dirs! - Cmp Byte Ptr [DS:SI], 8 - JAE D_DeleteInstrumentFile1 - - Push DS - Push SI - - Mov DI, Offset O1_ConfirmDelete3 - Mov CX, 4 - Call M_Object1List - - Pop SI - Pop DS - - And DX, DX ; OK to delete? - JZ D_DeleteInstrumentFile1 - - ; Delete file.... - Mov DX, SI - Inc DX - Mov AH, 41h - Int 21h - JC D_DeleteInstrumentFile1 - - Push CS - Pop DS - Assume DS:Disk - - Mov DI, SI - Add SI, 48 - - Mov CX, NumInstruments - Mov BX, CurrentInstrument - Sub CX, BX - - Mov AX, 48 - Mul CX - Mov CX, AX - - Push DS - - Mov DS, DiskDataArea - Push DS - Pop ES - - Rep MovsB - - Pop DS - - Dec NumInstruments - JZ D_DeleteInstrumentFile2 - - Cmp BX, NumInstruments - JB D_DeleteInstrumentFile2 - - Mov BX, NumInstruments - Dec BX - Mov CurrentInstrument, BX - Dec LoadInstrumentNameCount - -D_DeleteInstrumentFile2: - Cmp InstrumentCacheFileComplete, 1 - JNE D_DeleteInstrumentFile1 - - Call D_SaveInstrumentCacheFile - -D_DeleteInstrumentFile1: - Mov AX, 1 - Ret - -EndP D_DeleteInstrumentFile - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GetPreShellDirectory Far - - Push CS - Pop DS - Mov SI, Offset PreShellDirectory - - Call D_GetDriveDirectory - - Mov SI, Offset DOSDirectory - Call D_SetDriveDirectory - - - Ret - -EndP D_GetPreShellDirectory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_RestorePreShellDirectory Far - - Push CS - Pop DS - Mov SI, Offset PreShellDirectory - - Call D_SetDriveDirectory - - Ret - -EndP D_RestorePreShellDirectory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SetDriveDirectoryFar Far - - Call D_SetDriveDirectory - Ret - -EndP D_SetDriveDirectoryFar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_GetFileName Far - - Push CS - Pop DS - Mov SI, Offset FileName - - Ret - -EndP D_GetFileName - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_ResetTimer Far - - Push DS - - Push CS - Pop DS - Assume DS:Disk - - Call GetTimerCounter - Mov [EditTimer], EAX - Call ReleaseTimerData - - Call CheckTimerData - - Pop DS - Ret - -EndP D_ResetTimer - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Hours DB "0000:" -Minutes DB "00:" -Seconds DB "00", 0 - -RemainingDateMsg DB " ", 0FDh, "D, ", 0FDh, "D", 0 - -Time2Msg DB 0FDh, "D:00", 0 -TotalTime DD 0 - -Proc D_ShowTime Far - - Push CS - Pop DS - Assume DS:Disk - - Mov EDX, 3600 - Mul EDX - ShRD EAX, EDX, 16 - ShR EDX, 16 - JNZ D_ShowTimeEnd - ; EAX = number of seconds - Mov EBX, 60 - Div EBX ; EAX = minutes, EDX = seconds - - Push EDX - Xor EDX, EDX - Div EBX ; EAX = hours, EDX = minutes - - Pop ECX - Push AX ; Hours on stack, CX = seconds, DX = min - Mov BL, 10 - - Mov AX, DX - Div BL - Add AX, 3030h - Mov [Word Ptr Minutes], AX - - Mov AX, CX - Div BL - Add AX, 3030h - Mov [Word Ptr Seconds], AX - - Pop AX ; AX = hours. - Cmp AH, BL - JAE D_ShowTimeEnd - - Div BL - Add AH, '0' - Mov [Byte Ptr Hours+3], AH - Xor AH, AH - - Div BL - Add AH, '0' - Mov [Byte Ptr Hours+2], AH - Xor AH, AH - - Div BL - Add AH, '0' - Mov [Byte Ptr Hours+1], AH - Xor AH, AH - - Div BL - Add AH, '0' - Mov [Byte Ptr Hours+0], AH - Xor AH, AH - - Xor BX, BX - Mov SI, Offset Hours - -D_ShowTime1: - Cmp Byte Ptr [SI+BX], '0' - JNE D_ShowTime2 - Mov Byte Ptr [SI+BX], ' ' - Inc BX - Cmp BX, 3 - JB D_ShowTime1 - -D_ShowTime2: - Mov AH, 20h - Call S_DrawString - -D_ShowTimeEnd: - Ret - -EndP D_ShowTime - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF TIMERSCREEN - -TimerListKeys Label - - DB 0 - DW 1C8h ; Up arrow - DW D_TimerListUp - - DB 0 - DW 1D0h ; Down arrow - DW D_TimerListDown - - DB 0 - DW 1C9h ; PgUp - DW D_TimerListPgUp - - DB 0 - DW 1D1h ; PgDn - DW D_TimerListPgDn - - DB 0 - DW 0D29h ; Left Ctrl, Right Shift + '`' - DW D_ReleaseTimer - - DB 0 - DW 4529h - DW D_ToggleShowTimes - - DB 0FFh - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_PostTimerList Far - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset TimerListKeys - Call M_FunctionDivider - JC D_PostTimerList1 - - Jmp [SI] - -D_PostTimerList1: - Xor AX, AX - - Ret - -EndP D_PostTimerList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_TimerListUp Far - Assume DS:Disk - - Sub TopTimerData, 1 - AdC TopTimerData, 0 - - Mov AX, 1 - Ret - -EndP D_TimerListUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_TimerListDown Far - Assume DS:Disk - - Mov AX, TopTimerData - Cmp AX, NumTimerData - JAE D_TimerListDown1 - - Inc AX - Mov TopTimerData, AX - -D_TimerListDown1: - Mov AX, 1 - Ret - -EndP D_TimerListDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_TimerListPgUp Far - Assume DS:Disk - - Sub TopTimerData, 28 - JNC D_TimerListPgUp1 - - Mov TopTimerData, 0 - -D_TimerListPgUp1: - Mov AX, 1 - Ret - -EndP D_TimerListPgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_TimerListPgDn Far - Assume DS:Disk - - Mov AX, TopTimerData - Add AX, 28 - Cmp AX, NumTimerData - JB D_TimerListPgDn1 - - Mov AX, NumTimerData - Sub AX, 1 - AdC AX, 0 - -D_TimerListPgDn1: - Mov TopTimerData, AX - - Mov AX, 1 - Ret - -EndP D_TimerListPgDn - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ShowTimes DB 0 - -Proc D_DrawTimer Far - - Call Music_GetSongSegment - Mov ES, AX - - Mov EAX, [ES:3Ch] - Mov DI, (18+13*80)*2 - Call D_ShowTime - - Call GetTimerCounter - Sub EAX, [CS:EditTimer] - Mov DI, (18+14*80)*2 - Push EAX - Call D_ShowTime - - Pop EAX - Mov DI, (18+16*80)*2 - Add EAX, [ES:3Ch] - Call D_ShowTime - - Test ShowTimes, 1 - JZ D_DrawTimerEnd - - Assume DS:Disk - - Mov CX, 28 - Mov SI, TopTimerData - Mov AX, TimerData - Test AX, AX - JZ D_DrawTimerEnd - Mov ES, AX - Mov AX, SI - ShL SI, 3 - Mov DI, (4+20*80)*2 - - Mov BX, 4 - Mov TotalTime, 0 - -D_DrawTimer2: - Cmp BX, SI - JA D_DrawTimer1 - - Mov EDX, [ES:BX] - Add TotalTime, EDX - Add BX, 8 - Jmp D_DrawTimer2 - -D_DrawTimer1: - Cmp AX, NumTimerData - JAE D_DrawTimerEnd - PushA - ; Data formats: yyyyyyym mmmddddd - ; hhhhhmmm mmmsssss - SegES LodsD - - Push SI - Push DI - ; AX = yyyyyyym mmmddddd - Mov BX, AX - ShR AX, 9 - Add AX, 1980 - Push AX ; Year - Mov AX, BX - And AX, 1Fh - Push AX - - ShR BX, 5 - And BX, 0Fh - Add BX, BX - - Mov SI, [MonthNames+BX] - Mov AH, 20h - Call S_DrawString - - Mov SI, Offset RemainingDateMsg - Call S_DrawString - - Pop AX ; Clean up stack - Pop AX - - Pop DI - Add DI, 50 - Push DI - - ; time - ShR EAX, 21 ; AX = hhh hhmmmmmm - Mov BX, AX - ShR BX, 6 - Push BX - Mov BL, 10 - And AX, 3Fh - Div BL - Add AX, '00' - Mov Word Ptr [Time2Msg+3], AX ; Minutes done. - - Mov SI, Offset Time2Msg - Mov AH, 20h - Call S_DrawString - Pop AX - - Pop DI - Pop SI - - Add DI, 30 - SegES LodSD - Add TotalTime, EAX - Call D_ShowTime - - Add DI, 20 - - Mov EAX, TotalTime - Call D_ShowTime - - PopA - Add SI, 8 - Add DI, 160 - Inc AX - Loop D_DrawTimer1 - -D_DrawTimerEnd: - Xor AX, AX - Ret - -EndP D_DrawTimer - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_ReleaseTimer Far - - Call ReleaseTimerData - Inc AX - Ret - -EndP D_ReleaseTimer - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF TIMERSCREEN - -Proc D_ToggleShowTimes Far - Assume DS:Disk - - Xor ShowTimes, 1 - - Mov AX, 1 - Ret - -EndP D_ToggleShowTimes - Assume DS:Nothing - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SlowSampleSort Far - - Push CS - Pop DS - Assume DS:Disk - -IF SORTENABLED - Cmp SamplesInModule, 1 - JE D_SlowSampleSortExit - Cmp SampleCacheFileComplete, 1 - JNE D_SlowSampleSortExit - Mov CX, NumSamples - - Mov SampleInMemory, 0FFFFh - Mov SampleCheck, 0FFFFh - - Mov ES, DiskDataArea - Push ES - Pop DS - Assume DS:Nothing - - Xor SI, SI - - Cmp Word Ptr [SI+4], '\' - JNE SlowSampleSortNoSort1 - - Add SI, 60h - Dec CX - -SlowSampleSortNoSort1: - Cmp Word Ptr [SI+4], '..' - JNE SlowSampleSortNoSort2 - - Add SI, 60h - Dec CX - -SlowSampleSortNoSort2: - Cmp CX, 0 - JLE D_SlowSampleSortExit - -SlowSampleSortLoop1: - Push CX - Push SI - - Mov AL, [SI+5Ah] - Mov DX, SI ; DX = destination of SI - Mov DI, SI - Mov BX, CX - -SlowSampleSortLoop2: - -; SI = current lowest. - -; Sort priority: 0 = directory -; 1 = library -; 2 = recognised -; 3 = unknown - - Cmp AL, [DI+5Ah] - JB D_CompareSamples2 - JA D_CompareSamples1 - - Push SI - Push DI - - Mov CX, 13 - Add SI, 4 - Add DI, 4 - RepE CmpSB - Pop DI - Pop SI - - JBE D_CompareSamples2 - -D_CompareSamples1: - Mov AL, [DI+5Ah] - Mov SI, DI - -D_CompareSamples2: - Add DI, 60h - - Dec BX - JNZ SlowSampleSortLoop2 - - Cmp SI, DX - JE D_CompareSamplesNoSwap - - - Push DI - Mov CX, 24 - Rep MovsD - - LEA DI, [SI-60h] - Mov SI, DX - Mov CX, 24 - Rep MovsD - - Pop SI - Mov DI, DX - Mov CX, 24 - Rep MovsD - -D_CompareSamplesNoSwap: - Pop SI - Pop CX - - Add SI, 60h - - Dec CX - JNZ SlowSampleSortLoop1 - - Call D_SaveSampleCacheFile ; Resave it with new date - -D_SlowSampleSortExit: - -ENDIF - - Mov AX, 1 - Ret - -EndP D_SlowSampleSort - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc D_SlowInstrumentSort Far - - Push CS - Pop DS - Assume DS:Disk - -IF SORTENABLED - Cmp InstrumentsInModule, 1 - JE D_SlowInstrumentSortExit - Cmp InstrumentCacheFileComplete, 1 - JNE D_SlowInstrumentSortExit - Mov CX, NumInstruments - - Mov ES, DiskDataArea - Push ES - Pop DS - Assume DS:Nothing - - Xor SI, SI - - Cmp Word Ptr [SI+1], '\' - JNE SlowInstrumentSortNoSort1 - - Add SI, 30h - Dec CX - -SlowInstrumentSortNoSort1: - Cmp Word Ptr [SI+1], '..' - JNE SlowInstrumentSortNoSort2 - - Add SI, 30h - Dec CX - -SlowInstrumentSortNoSort2: - Cmp CX, 0 - JLE D_SlowInstrumentSortExit - -SlowInstrumentSortLoop1: - Push CX - Push SI - - Mov AL, [SI] - Mov DX, SI ; DX = destination of SI - Mov DI, SI - Mov BX, CX - -SlowInstrumentSortLoop2: - Mov AH, [DI] - -; SI = current lowest. - - Cmp AL, 1 - JNE SlowInstrumentSort3 - Cmp AH, 1 - JE SlowInstrumentFilename - Jmp D_CompareInstruments2 - -SlowInstrumentsort3: - Cmp AH, 1 - JE D_CompareInstruments1 - - Test AL, 8 - JZ SlowInstrumentSort4 - Test AH, 8 - JNZ SlowInstrumentFileName - Jmp D_CompareInstruments2 - -SlowInstrumentsort4: - Test AH, 8 - JNZ D_CompareInstruments1 - -SlowInstrumentFilename: - Push SI - Push DI - - Mov CX, 13 - Inc SI - Inc DI - RepE CmpSB - Pop DI - Pop SI - - JBE D_CompareInstruments2 - -D_CompareInstruments1: - Mov AL, AH - Mov SI, DI - -D_CompareInstruments2: - Add DI, 30h - - Dec BX - JNZ SlowInstrumentSortLoop2 - - Cmp SI, DX - JE D_CompareInstrumentsNoSwap - - Push DI - Mov CX, 12 - Rep MovsD - - LEA DI, [SI-30h] - Mov SI, DX - Mov CX, 12 - Rep MovsD - - Pop SI - Mov DI, DX - Mov CX, 12 - Rep MovsD - -D_CompareInstrumentsNoSwap: - Pop SI - Pop CX - - Add SI, 30h - - Dec CX - JNZ SlowInstrumentSortLoop1 - - Call D_SaveInstrumentCacheFile ; Resave it with new date - -D_SlowInstrumentSortExit: - -ENDIF - - Mov AX, 1 - Ret - -EndP D_SlowInstrumentSort - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment DiskData PARA Public 'Data' - DB 65536 Dup (0) -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Disk Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +include switch.inc +include network.inc + + Jumps + .386 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Object1 BYTE Public 'Data' +EndS + +Segment Pattern BYTE Public 'Code' + Extrn BaseOctave:Byte + Extrn RowHilight1:Byte + Extrn RowHilight2:Byte +EndS + +Segment Pattern BYTE Public 'Code' + Extrn PatternDataArea:Word +EndS + +Segment Music BYTE Public 'Code' +EndS + + Extrn Display_GetDisplayWindowData:Far + + Extrn E_UnInitEMS:Far + Extrn E_MapEMSMemory:Far + Extrn E_GetEMSPageFrame:Far + + Extrn Glbl_F3:Far + Extrn Glbl_F4:Far + + Extrn I_GetSampleOffset:Far + Extrn I_GetInstrumentOffset:Far + Extrn I_ClearTables:Far + Extrn I_GetPresetEnvelopeOffset:Far + + Extrn K_UnInitKeyBoard:Far + Extrn K_IsAnyKeyDown:Far + Extrn K_ClearKeyBoardQueue:Far + Extrn K_GetKey:Far + + Extrn M_FunctionDivider:Far + Extrn M_Object1List:Far + + Extrn Music_PlayNote:Far + Extrn Music_PlaySample:Far + Extrn Music_ReleaseAllPatterns:Far + Extrn Music_ReleaseAllSamples:Far + Extrn Music_ReleaseSample:Far + Extrn Music_GetSongSegment:Far + Extrn Music_AllocateSample:Far + Extrn Music_ClearAllSampleNames:Far + Extrn Music_GetNumberOfSamples:Far + Extrn Music_GetNumberOfInstruments:Far + Extrn Music_GetPattern:Far + Extrn Music_AllocatePattern:Far + Extrn Music_AllocateSample:Far + Extrn Music_GetSampleLocation:Far + Extrn Music_ClearAllInstruments:Far + Extrn Music_GetInstrumentMode:Far + Extrn Music_AssignSampleToInstrument:Far + Extrn Music_SoundCardLoadSample:Far + Extrn Music_SoundCardLoadAllSamples:Far + Extrn Music_GetPitchTable:Far + Extrn Music_GetMIDIDataArea:Far + + Extrn Music_Stop:Far + Extrn Msg_ResetMessage:Far + Extrn Msg_GetMessageOffset:Far + Extrn Msg_GetMessageLength:Far + +IF TUTORIAL +ELSE + Extrn O1_LoadS3MList:Far + Extrn O1_LoadXMList:Far + Extrn O1_LoadMODList:Far + Extrn O1_LoadMTMList:Far + Extrn O1_Load669List:Far + Extrn O1_LoadITList:Far +ENDIF + Extrn O1_ConfirmOverWriteList:Far + Extrn O1_UnableToSaveList:Far + Extrn O1_SaveITList:Far + Extrn O1_SaveS3MList:Far + Extrn O1_ConfirmDelete:Far ; Updates Song name loader. + Extrn O1_ConfirmDelete2:Far + Extrn O1_ConfirmDelete3:Far + Extrn O1_ConfirmSaveRenameList:Far + Extrn O1_ConfirmResaveList:Far + Extrn O1_ConfirmDiscardList:Far + Extrn O1_InitInstrument:Far + Extrn O1_EditSampleName:Far + Extrn O1_OutOfSamplesList:Far + Extrn O1_EnableInstrumentMode:Far + Extrn O1_StereoSampleList:Far + + Extrn PE_TranslateXMPattern:Far + Extrn PE_Translate669Pattern:Far + Extrn PE_TranslateS3MPattern:Far + Extrn PE_TranslateMTMPattern:Far + Extrn PE_TranslateMODPattern:Far + Extrn PE_ResetOrderPattern:Far + Extrn PE_UnInitPatternEdit:Far + Extrn PEFunction_OutOfMemoryMessage:Far + Extrn PECheckModified:Far + Extrn PEResetModified:Far + Extrn PE_GetMaxPattern:Far + Extrn PE_ConvAX2Num:Far + Extrn PE_GetLastInstrument:Far + Extrn PE_GetPatternConfigOffset:Far + Extrn PE_SaveCurrentPattern:Far + Extrn PE_RestoreCurrentPattern:Far + + Extrn S_UnInitScreen:Far + Extrn S_GetDestination:Far + Extrn S_DrawString:Far + Extrn S_SaveScreen:Far + Extrn S_RestoreScreen:Far + Extrn S_GetGenerationTableOffset:Far + Extrn S_GenerateCharacters:Far + Extrn S_RedefineCharacters:Far + Extrn S_GetPaletteOffset:Far + Extrn S_SetPalette:Far + + Extrn SetInfoLine:Far + Extrn ClearInfoLine:Far + + Extrn Glbl_SetCurrentMode:Far + Extrn Glbl_F10:Far + + Extrn GetKeyboardLock:Far, GetTimerCounter:Far + Extrn MouseUpdateEnable:Far, MouseUpdateDisable:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global D_GetFileName:Far + Global D_SetDriveDirectoryFar:Far + + Global D_RestorePreShellDirectory:Far + Global D_GetPreShellDirectory:Far + + Global D_SaveInstrument:Far + Global D_ClearFileName:Far + + Global D_GetFormatType:Far + + Global D_LSCheckLoopValues:Far + Global D_LSCheckSusLoopValues:Far + + Global D_SaveSong:Far + + Global D_InitDisk:Far + Global D_UnInitDisk:Far + Global D_InitLoadModule:Far + Global D_InitLoadSamples:Far + Global D_LoadSampleNames:Far + Global D_NewSpecifier:Far + Global D_NewDirectory:Far + Global D_SaveIT:Far + Global D_DrawWaveForm:Far + + Global D_InitLoadInstruments:Far + Global D_DrawLoadInstrument:Far + Global D_PreLoadInstrument:Far + Global D_PostLoadInstrument:Far + Global D_LoadInstrumentNames:Far + Global D_ViewInstrument:Far + Global D_SlowSampleSort:Far + Global D_SlowInstrumentSort:Far + + Global D_SaveS3M:Far + + Global D_SaveDirectoryConfiguration:Far + Global D_DisableFileColours:Far + + Global D_GetLoadSampleVars:Far + + Global D_DrawLoadSampleWindow:Far + Global D_PreLoadSampleWindow:Far + Global D_PostLoadSampleWindow:Far + Global D_PostViewSampleLibrary:Far + + Global D_LSDrawDriveWindow:Far + Global D_LSPreDriveWindow:Far + Global D_LSPostDriveWindow:Far + + Global D_LIDrawDriveWindow:Far + Global D_LIPreDriveWindow:Far + Global D_LIPostDriveWindow:Far + + Global D_DeleteSampleFile:Far + + Global D_PostSaveDriveWindow:Far + + Global D_ClearFileSpecifier:Far + Global D_LoadSongNames:Far + Global D_DrawFileWindow:Far + Global D_DrawDirectoryWindow:Far + Global D_DrawDriveWindow:Far + Global D_PreFileWindow:Far + Global D_PostFileWindow:Far + Global D_PreDirectoryWindow:Far + Global D_PostDirectoryWindow:Far + Global D_PreDriveWindow:Far + Global D_PostDriveWindow:Far + Global D_PostFileLoadWindow:Far + Global D_PostFileSaveWindow:Far + Global D_SaveModule:Far + + Global FileSpecifier:Byte + Global SongDirectory:Byte + Global SampleDirectory:Byte + Global InstrumentDirectory:Byte + Global FileName:Byte + + Global D_SaveSample:Far + Global D_SaveRawSample:Far + Global D_SaveST3Sample:Far + + Global D_GotoStartingDirectory:Far + + Global LSWindow_Up:Far + Global LSWindow_Down:Far + + Global DiskDataArea:Word + Global SampleName:Byte + Global DiskOptions:Byte + + Public D_Resettimer + Public D_ShowTime + +IF TIMERSCREEN + Public D_DrawTimer + Public D_PostTimerList +ENDIF + +IF TUTORIAL + Public SamplesInModule + Public InSampleFileName +ELSE + Public D_LoadS3M + Public D_LoadMTM + Public D_LoadMOD + Public D_Load669 + Public D_LoadIT + Public D_LoadXM +ENDIF + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Disk BYTE Public 'Code' USE16 + Assume CS:Disk, DS:Nothing + +CREATENEWLOGFILE EQU 0 +include debug.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +SampleInMemory DW 0FFFFh +NoSaveError DB 0 +Specific DB 0 +DiskDataArea DW DiskData + +OldCacheTime DD 0 + +Time DW 0 +Date DW 0 +LoadDate DW 0 +LoadTime DW 0 +DrivesAvail DB 27 Dup (0) +UnusedSamples DW 0 + +InitialInstruments DW 0 ; +NumInstruments DW 0 ; Order important! +InstrumentCachefileVersion DW TRACKERVERSION ; + +LoadInstrumentNameCount DW 0 +TopInstrument DW 0 +CurrentInstrument DW 0 + +LoadSongNameCount DW 0 +LoadSampleNameCount DW 0 +CurrentSample DW 0 + +NumSamples DW 0 ; Order important! +SampleCachefileVersion DW TRACKERVERSION ; + +TopSample DW 0 +CurrentDrive DB 0 +NumDrives DB 0 +TopDrive DB 0 +NumEntries DW 0 +NumFiles DW 0 +NumFileInfo DW 0 +NumDirectories DW 0 +TopDirectory DW 0 +CurrentDirectory DW 0 +CurrentFile DW 0 +TopFile DW 0 +FileName DB 0 + DB 13 Dup (0) +SaveFileName DB 0 + DB 79 Dup (0) +FileSpecifier DB 0 + DB 64 Dup (0) +StartingDrive DB 0 +StartingDirectory DB 70 Dup (0) + +PreShellDirectory DB 70 Dup (0) +DOSDirectory DB 70 Dup (0) + +SongDirectory DB 0 + DB 69 Dup (0) +SampleDirectory DB 0 + DB 69 Dup (0) +InstrumentDirectory DB 0 + DB 69 Dup (0) +CountryTableConfig DB 0 + +SampleName DB 0 + DB 26 Dup (0) + +MODNumberOfChannels DB 0 +MODNumberOfInstruments DB 0 +MODNumberOfOrders DB 0 +MODOrderOffset DW 0 +MODPatternOffset DW 0 +LastKey DW 0 + +SampleCacheFileComplete DB 0 +InstrumentCacheFileComplete DB 0 + +Resolution DB 0 + +FileTempSpecifier DB 70 Dup (0) +CurrentSearchPos DB 0 +Search DB 13 Dup (0) + +InstrumentTable DB 100 Dup (0) + +InstrumentLoaderTable Label Word + DW Offset LoadITInstrument ; 3 + DW Offset LoadXIInstrument ; 4 + DW Offset LoadInITInstrument ; 5 + DW Offset LoadInXMInstrument ; 6 + DW 0 ; 7 + DW Offset LoadITInModuleInstrument ; 8 + DW Offset LoadXMInModuleInstrument ; 9 + +InstrumentLoader DW 0 +InSampleFileName DB 13 Dup (0) +InSampleDateTime DD 0 +InSampleFormat DB 0 ; Do *NOT* change order +InSampleChannels DB 0 ; Do *NOT* change order + +InInstrumentFileName DB 13 Dup (0) +InInstrumentFormat DB 0 + +ExitLibraryDirectory Label + DB "IMPS. ", 0, 0, 0, 0 + DB 8 Dup(154), "Directory", 8 Dup(154), 0, 0, 0 + DW 0, 0, 0, 0, 0, 0, 0, 0 + DW 0, 0, 0, 0, 0, 0, 0, 0 + DW 0, 0, 0, 0 + DB 1 + +ExitInstrumentLibraryDirectory Label + DB 1, ". ", 0 + DB 8 Dup(154), "Directory", 8 Dup(154), 0 ; Instrument name + DW 0, 0 ; NoSamples, FileSize + DD 0 ; File offset + +AllFilesMask DB "*.*", 0 +FileSpecifierDefault DB "*.IT, *.XM, *.S3M, *.MTM, *.669, *.MOD", 0 +DriveMsg DB "Drive X:" +NoFilesMsg DB "No files.", 0 +NoDirsMsg DB "No dirs.", 0 +WAVEfmtID DB "WAVEfmt ", 0, 0, 1, 0 +XIIdentification DB "Extended Instrument: " +XMIdentification DB "Extended Module: " +TXWAVEIdentification DB "LM8953", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +GUSPATIdentification DB "GF1PATCH110", 0, "ID#000002", 0 ; 22 bytes + +OpenErrorMsg DB "Error opening file.", 0 + +HeaderMsg DB "File Header", 0 +SampleMsg DB "Sample ", 0FDh, 'D', 0 +SHLoadMsg DB "Sample Header ", 0FDh, 'D', 0 +InstrumentMsg DB "Instrument ", 0FDh, 'D', 0 +PatternMsg DB "Pattern ", 0FDh, 'D', 0 +TrackMsg DB "Channel ", 0FDh, 'D ', 13 + DB "Track ", 0FDh, 'D ', 0 +CompleteMsg DB "Done", 0 +InstrumentHeaderMsg DB "Instrument Headers", 0 +SampleHeaderMsg DB "Sample Headers", 0 +Quality8Msg DB "8 Bit", 0 +Quality16Msg DB "16 Bit", 0 +Quality8StereoMsg DB "8 Bit Stereo", 0 +Quality16StereoMsg DB "16 Bit Stereo", 0 +LengthMsg DB 0FDh, 'L', 0 +DirectoryMsg DB 8 Dup(154), "Directory", 8 Dup(154), 0 +LibraryMsg DB 9 Dup(154), "Library", 9 Dup(154), 0 +FontFileName DB "FONT.CFG", 0 +ConfigFileName DB "IT.CFG", 0 +ST3CacheFileName DB "########.ST3", 0 +SampleCacheFileName DB "CACHE.ITS", 0 +InstrumentCacheFileName DB "CACHE.ITI", 0 +SaveFormat DB DEFAULTFORMAT +SaveFormatError DB 0 ; This will get erased whenever the + ; saveformat changes. +SamplesInModule DB 0 +InstrumentsInModule DB 0 +FileColours DB 1 + +NoteData DB 0FFh, 0, 0FFh, 0, 0 + +CheckDataArea DB 96 Dup(0) +KeyBoardTable DW 12Ch, 0, 11Fh, 1, 12Dh, 2, 120h, 3, 12Eh, 4 + DW 12Fh, 5, 122h, 6, 130h, 7, 123h, 8, 131h, 9 + DW 124h, 10, 132h, 11, 110h, 12, 103h, 13, 111h, 14 + DW 104h, 15, 112h, 16, 113h, 17, 106h, 18, 114h, 19 + DW 107h, 20, 115h, 21, 108h, 22, 116h, 23, 117h, 24 + DW 10Ah, 25, 118h, 26, 10Bh, 27, 119h, 28, 0FFFFh +SampleCheck DW 0FFFFh + +MonthNames Label + DW Offset Empty + DW Offset January + DW Offset February + DW Offset March + DW Offset April + DW Offset May + DW Offset June + DW Offset July + DW Offset August + DW Offset September + DW Offset October + DW Offset November + DW Offset December + DW Offset Empty + DW Offset Empty + DW Offset Empty + +January DB "January", 0 +February DB "February", 0 +March DB "March", 0 +April DB "April", 0 +May DB "May", 0 +June DB "June", 0 +July DB "July", 0 +August DB "August", 0 +September DB "September", 0 +October DB "October", 0 +November DB "November", 0 +December DB "December" +Empty DB 0 + +TimerData DW 0 +NumTimerData DW 0 +TopTimerData DW 0 + +SampleFormatNames Label + DW Offset Unchecked ; 0 + DW Offset DirectoryFormat + DW Offset ITSampleFormat + DW Offset STSampleFormat + DW Offset UnknownSampleFormat + DW Offset WAV8BitFormat + DW Offset XMSample + DW Offset WAV16BitFormat + DW Offset XMSample + DW Offset PTMSample + DW Offset MTMSample + DW Offset C669Sample + DW Offset FARSample + DW Offset TXWaveSample ; 13 + DW Offset MODSample + DW Offset KRZSample ; 15 + DW Offset PATFormat + DW Offset IFFFormat ; 17 + DW 0, 0 + DW 0, 0, 0, 0 + DW 0, 0, 0, 0 + DW 0, 0, 0, 0 + DW Offset ST3Module ; 20h + DW Offset ITModule + DW Offset XMModule + DW Offset PTMModule + DW Offset MTMModule + DW Offset C669Module + DW Offset FARModule + DW Offset MODModule1 + DW Offset XMModule + DW Offset KRZFormat ; 29h + DW Offset PATFormat + +LoadSamplesInModuleTable Label Word + DW Offset LoadS3MSamplesInModule + DW Offset LoadITSamplesInModule + DW Offset LoadXMSamplesInModule + DW Offset LoadPTMSamplesInModule + DW Offset LoadMTMSamplesInModule + DW Offset Load669SamplesInModule + DW Offset LoadFARSamplesInModule + DW Offset LoadMODSamplesInModule + DW Offset LoadMODSamplesInModule + DW Offset LoadKRZSamples + DW Offset LoadPATSamples +; DW Offset LoadULTSamplesInModule + +FormatNames Label + DW Offset Unchecked ; 0 + DW Offset UnknownFormat ; 1 + DW Offset ITFormat2_0 ; 2 + DW Offset ITFormat? ; 3 + DW Offset ST3Format ; 4 + DW Offset XMModule ; 5 + DW Offset C669Module ; 6 + DW Offset CompressedITModule ; 7 + DW 0 + DW Offset MODFormat ; 9 + DW Offset Protracker ; 10 + DW Offset Channel4 ; 11 + DW Offset Channel6 ; 12 + DW Offset Channel8 ; 13 + DW Offset StarTrekker4 ; 14 + DW Offset StarTrekker8 ; 15 + DW Offset OldMod ; 16 + DW Offset ChannelXX ; 17 + DW Offset MultiTrackerModule ; 18 + +PanningPositions DB 0, 4, 9, 13, 17, 21, 26, 30 + DB 34, 38, 43, 47, 51, 55, 60, 64 +MODChannelTable DB 4, 4, 4, 6, 8, 4, 8, 4 +FineTuneTable DW 8363, 8413, 8463, 8529 + DW 8581, 8651, 8723, 8757 + DW 7895, 7941, 7985, 8046 + DW 8107, 8169, 8232, 8280 + +DirectoryFormat DB "Directory", 0 +ITSampleFormat DB "Impulse Tracker Sample", 0 +STSampleFormat DB "Scream Tracker Sample", 0 +UnknownSampleFormat DB "Unknown sample format", 0 +WAV8BitFormat DB "8 Bit WAV Format", 0 +WAV16BitFormat DB "16 Bit WAV Format", 0 +XMSample DB "Fast Tracker 2 Sample", 0 +PTMSample DB "Poly Tracker Sample", 0 +MTMSample DB "Multi Tracker Sample", 0 +C669Sample DB "Composer 669 Sample", 0 +FARSample DB "Farandole Sample", 0 +; ULTSample DB "Ultra Tracker Sample", 0 +TXWaveSample DB "TX Wave Sample", 0 +MODSample DB "MOD Sample", 0 +KRZSample DB "KRZ Sample", 0 + +ST3Module DB "Scream Tracker 3 Module", 0 +ITModule DB "Impulse Tracker Module", 0 +XMModule DB "Fast Tracker 2 Module", 0 +PTMModule DB "Poly Tracker Module", 0 +MTMModule DB "Multi Tracker Module", 0 +C669Module DB "Composer 669 Module", 0 +FARModule DB "Farandole Module", 0 +MODModule1 DB "MOD Format", 0 +; ULTModule DB "Ultra Tracker Module", 0 +KRZFormat DB "Kurzweil Synth File", 0 +PATFormat DB "Gravis UltraSound Patch", 0 +IFFFormat DB "AIFF Sample", 0 + +Unchecked DB "Unchecked", 0 +UnknownFormat DB "Unknown module format", 0 +CompressedITModule DB "Compressed " +ITFormat2_0 DB "Impulse Tracker", 0 +ITFormat? DB "Impulse Tracker ?.??", 0 +ST3Format DB "Scream Tracker 3", 0 +MODFormat DB "Amiga-NewTracker", 0 +ProTracker DB "Amiga-ProTracker", 0 +StarTrekker4 DB "4 Channel Startrekker", 0 +StarTrekker8 DB "8 Channel Startrekker", 0 +Channel4 DB "4 Channel MOD", 0 +Channel6 DB "6 Channel MOD", 0 +Channel8 DB "8 Channel MOD", 0 +OldMod DB "Old Amiga-MOD format ? ", 0 +ChannelXX DB 0FDh, "D Channel MOD", 0 +MultiTrackerModule DB "MultiTracker Module", 0 + +ITInstrumentSavedMsg DB "Instrument saved (instrument ", 0FDh, "D)", 0 +InstrumentErrorMsg DB "Error: Instrument ", 0FDh, "D NOT saved! (No Filename?)", 0 +ITSampleSavedMsg DB "Impulse Tracker sample saved (sample ", 0FDh, "D)", 0 +ST3SampleSavedMsg DB "Scream Tracker sample saved (sample ", 0FDh, "D)", 0 +IF SAVESAMPLEWAV +RawSampleSavedMsg DB "WAV Sample saved (sample ", 0FDh, "D)", 0 +ELSE +RawSampleSavedMsg DB "RAW Sample saved (sample ", 0FDh, "D)", 0 +ENDIF +SampleErrorMsg DB "Error: Sample ", 0FDh, "D NOT saved! (No Filename?)", 0 +InitInstrumentMsg DB "Sample assigned to Instrument ", 0FDh, "D", 0 +InitInstrumentErrorMsg DB "Error: No available Instruments!", 0 + +TooManyPatternsMsg DB "Warning: Only 100 patterns supported in S3M format", 0 +ChannelVolumeErrorMsg DB "Warning: Channel volumes unsupported in S3M format", 0 +LinearSlideMsg DB "Warning: Linear slides unsupported in S3M format", 0 +LoopMsg DB "Warning: Sustain and Ping Pong loops unsupported in S3M format", 0 +SampleVolumeMsg DB "Warning: Sample volumes unsupported in S3M format", 0 +SampleVibratoMsg DB "Warning: Sample vibrato unsupported in S3M format", 0 +ST3InstrumentErrorMsg DB "Warning: Instrument functions unsupported in S3M format", 0 +PatternLengthMsg DB "Warning: Pattern lengths other than 64 rows unsupported in S3M format", 0 +ChannelErrorMsg DB "Warning: Data outside 16 channels unsupported in S3M format", 0 +NoteRangeMsg DB "Warning: Notes outside the range C-1 to B-8 are unsupported in S3M format", 0 +PanningErrorMsg DB "Warning: Extended volume column effects are unsupported in S3M format", 0 + +InstrumentLibrary DB 154, 154, "Module", 154, 154, 0 +InstrumentNoSample DB "No Samples", 0 +InstrumentSingleSample DB "1 Sample", 0 +InstrumentSeveralSamples DB 0FDh, "D Samples", 0 +InstrumentUnknownSamples DB "???", 0 +FileSizeMsg DB 0FDh, "Dk", 0 +FreeSampleMsg DB "Available", 13 + DB "Samples: ", 0FDh, 'D', 0 + +IF SAVESAMPLEWAV + WAVEFileHeader DB "RIFF" + WAVEFileSize DD 0 + WAVEFileHeader2 DB "WAVEfmt " + WAVEFileHeaderLength DD 10h + WAVEFileID DW 1 + WAVEChannels DW 1 + WAVEMixSpeed DD 44100 ; Default to CD quality + WAVEBytesPerSecond DD 0 + WAVEBytesPerSample DW 2 + WAVEBits DW 16 + WAVEHeader3 DB "data" + WAVEDataSize DD 0 +ENDIF + +DiskOptions DB 0 +EditTimer DD 0 + +CDRomStartDrive DB 0 ; The first CDRom Drive letter +CDRomEndDrive DB 0 ; The drive AFTER the last cdrom + +FileWindowKeys Label + + DB 0 + DW 1C8h ; Up arrow + DW FileWindow_Up + + DB 0 + DW 1D0h ; Down arrow + DW FileWindow_Down + + DB 0 + DW 1C9h ; PgUp + DW FileWindow_PgUp + + DB 0 + DW 1D1h ; PgDn + DW FileWindow_PgDn + + DB 0 + DW 1C7h ; Home + DW FileWindow_Home + + DB 0 + DW 1CFh ; End + DW FileWindow_End + + DB 4 + DW 10Fh ; Shift Tab + DW FileWindow_ShiftTab + + DB 0 + DW 10Fh ; Tab + DW FileWindow_Right + + DB 0 + DW 1CDh ; Right arrow + DW FileWindow_Right + + DB 0 + DW 1CBh ; Left arrow + DW FileWindow_Left + + DB 0 + DW 1D3h ; Delete + DW FileWindow_DeleteFile + + DB 0FFh + +DirectoryWindowKeys Label + + DB 0 + DW 1C8h + DW DirectoryWindow_Up + + DB 0 + DW 1D0h + DW DirectoryWindow_Down + + DB 0 + DW 1C9h ; PgUp + DW DirectoryWindow_PgUp + + DB 0 + DW 1D1h ; PgDn + DW DirectoryWindow_PgDn + + DB 0 + DW 1C7h ; Home + DW DirectoryWindow_Home + + DB 0 + DW 1CFh ; End + DW DirectoryWindow_End + + DB 4 + DW 10Fh ; Shift Tab + DW DirectoryWindow_Left + + DB 0 + DW 10Fh ; Tab + DW FileWindow_Left ; Same object num + + DB 0 + DW 1CDh ; Right arrow + DW FileWindow_Left + + DB 0 + DW 1CBh ; Left arrow + DW DirectoryWindow_Left + + DB 0 + DW 11Ch ; Enter + DW DirectoryWindow_Enter + + DB 0FFh + +DriveWindowKeys Label + + DB 0 + DW 1C8h + DW DriveWindow_Up + + DB 0 + DW 1D0h + DW DriveWindow_Down + + DB 4 + DW 10Fh ; Shift-Tab + DW FileWindow_Right + + DB 0 + DW 10Fh ; Tab + DW DriveWindow_Tab + + DB 0 + DW 1CDh ; Right arrow + DW DirectoryWindow_Left + + DB 0 + DW 1CBh ; Left arrow + DW FileWindow_Right + + DB 0 + DW 11Ch ; Enter + DW DriveWindow_Enter + + DB 0FFh + +SaveDriveWindowKeys Label + + DB 0 + DW 1C8h + DW DriveWindow_Up + + DB 0 + DW 1D0h + DW DriveWindow_Down + + DB 4 + DW 10Fh ; Shift-Tab + DW FileWindow_Right + + DB 0 + DW 10Fh ; Tab + DW SaveDriveWindow_Tab + + DB 0 + DW 1CDh ; Right arrow + DW SaveDriveWindow_Tab + + DB 0 + DW 1CBh ; Left arrow + DW FileWindow_Right + + DB 0 + DW 11Ch ; Enter + DW DriveWindow_Enter + + DB 0FFh + +LSDriveWindowKeys Label + + DB 0 + DW 1C8h + DW DriveWindow_Up + + DB 0 + DW 1D0h + DW DriveWindow_Down + + DB 4 + DW 10Fh ; Shift-Tab + DW DriveWindow_Tab ; goto object number 15 + + DB 0 + DW 10Fh ; Tab + DW LSDriveWindow_Right + + DB 0 + DW 1CDh ; Right arrow + DW LSDriveWindow_Right + + DB 0 + DW 1CBh ; Left arrow + DW DriveWindow_Tab + + DB 0 + DW 11Ch ; Enter + DW LS_DriveWindow_Enter + + DB 0FFh + +LIDriveWindowKeys Label + + DB 0 + DW 1C8h + DW DriveWindow_Up + + DB 0 + DW 1D0h + DW DriveWindow_Down + + DB 0 + DW 1CBh ; Left arrow + DW LIDriveWindow_Tab + + DB 0 + DW 10Fh ; Tab + DW LIDriveWindow_Tab + + DB 0 + DW 11Ch ; Enter + DW LI_DriveWindow_Enter + + DB 0FFh + +LoadInstrumentKeys Label + DB 0 + DW 11Ch ; Enter + DW LIWindow_Enter + +ViewInstrumentKeys Label + DB 0 + DW 1C8h + DW LIWindow_Up + + DB 0 + DW 1D0h + DW LIWindow_Down + + DB 0 + DW 1C9h ; PgUp + DW LIWindow_PgUp + + DB 0 + DW 1D1h ; PgDn + DW LIWindow_PgDn + + DB 0 + DW 1C7h ; Home + DW LIWindow_Home + + DB 0 + DW 1CFh ; End + DW LIWindow_End + + DB 0 + DW 1D3h ; Delete + DW D_DeleteInstrumentFile + + DB 0 + DW 11Ch ; Enter + DW LIViewWindow_Enter + + DB 0 + DW 1CDh ; Right arrow + DW LIViewWindow_Tab + + DB 0 + DW 10Fh ; Tab + DW LIViewWindow_Tab + + DB 0FFh + +LSWindowKeys Label + DB 0 + DW 11Ch ; Enter + DW LSWindow_Enter + +LSViewWindowKeys Label + DB 0 + DW 139h + DW LSWindow_Space ; Edit sample name + + DB 0 + DW 1C8h + DW LSWindow_Up + + DB 0 + DW 1D0h + DW LSWindow_Down + + DB 0 + DW 1C9h ; PgUp + DW LSWindow_PgUp + + DB 0 + DW 1D1h ; PgDn + DW LSWindow_PgDn + + DB 0 + DW 1C7h ; Home + DW LSWindow_Home + + DB 0 + DW 1CFh ; End + DW LSWindow_End + + DB 0 + DW 1CDh ; Right arrow + DW FileWindow_ShiftTab + + DB 0 + DW 10Fh ; Tab + DW FileWindow_ShiftTab ; Object 16 + + DB 0 + DW 1D3h ; Delete + DW D_DeleteSampleFile + + DB 0 + DW 11Ch ; Enter + DW LSViewWindow_Enter + + DB 0FFh + + + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc D_InitDisk Far + + Push DS + + Push CS + Pop DS + Assume DS:Disk + ; Get date/time for CACHE.IT file + + Trace " - Finding CDROM Drives" + + Mov AX, 1500h + Xor BX, BX + Int 2Fh + Cmp AL, 0FFh + JNE D_InitDiskNoCDROM + Test BX, BX + JZ D_InitDiskNoCDROM + + Add CL, 'A' + Mov CDRomStartDrive, CL + Add CX, BX + Mov CDRomEndDrive, CL + +D_InitDiskNoCDROM: + Trace " - Determining main directory" + + Mov SI, Offset DOSDirectory + Call D_GetDriveDirectory + + Trace " - Initialising cache file parameters" + + Mov AH, 2Ah + Int 21h ; Get Date + Mov AX, CX ; Now to get date in yyyyyyym mmmddddd + Sub AX, 1980 + ShL AX, 9 ; Year + Or AL, DL ; Day + Xor DL, DL + ShR DX, 3 + Or AX, DX ; Month + Mov Date, AX + + Mov AH, 2Ch + Int 21h ; Get time + Mov AX, CX ; Now to get time in hhhhhmmm mmmsssss + ShL AL, 2 ; AX = ...hhhhh mmmmmm.. + ShL AX, 3 ; AX = hhhhhmmm mmm..... + ShR DH, 1 ; DH = ...sssss + Or AL, DH + Mov Time, AX + + Cmp StartingDirectory, 0 + JNE D_InitDisk2 + + Trace " - Determining available drives" + +D_InitDisk1: + Mov AH, 19h + Int 21h + + Mov StartingDrive, AL + + Mov CX, 26 + Xor BX, BX + Xor SI, SI + +D_InitDisk3: + Mov DL, BL + Mov AH, 0Eh + Int 21h + + Mov AH, 19h + Int 21h + Cmp AL, BL + JNE D_InitDisk4 + + Cmp BL, StartingDrive + JNE D_InitDisk9 + + Mov AX, SI + Mov CurrentDrive, AL + +D_InitDisk9: + Test DiskOptions, 1 + JNZ D_InitDisk10 + + Mov AX, 440Eh ; This code was to prevent + ; A and B drives being shown + ; on older DOS systems when + ; only one drive was present. + ; For some reason, it crashes + ; one in a thousand computers. + ; hence the option /x3 + Push BX + Xor BL, BL + Int 21h + + Pop BX + JC D_InitDisk10 + And AL, AL + JZ D_InitDisk10 + Dec AX + Cmp AL, BL + JNE D_InitDisk4 + +D_InitDisk10: + Mov [DrivesAvail+SI], BL + Inc SI + +D_InitDisk4: + Inc BX + Loop D_InitDisk3 + + Mov BX, SI + Mov NumDrives, BL + + Mov DL, StartingDrive + Mov AH, 0Eh + Int 21h + +D_GetStartingDirectory1: ; FS=PSP. + Push CS + Pop ES + + Mov DI, Offset StartingDirectory + + Mov DS, [FS:2Ch] ; Environment thingy. + Xor SI, SI + Mov CX, 7FFFh + +D_GetStartingDirectory2: + Cmp Word Ptr [SI], 0 + JE D_GetStartingDirectory3 + + Inc SI + Loop D_GetStartingDirectory2 + + Jmp D_GetStartingDirectoryEnd + +D_GetStartingDirectory3: ; DS:SI points to 0... + Add SI, 4 + Push SI ; Now to work out count. + + Xor DX, DX + Mov CX, 1 + +D_GetStartingDirectory4: + LodsB + And AL, AL + JZ D_GetStartingDirectory5 + + Inc DX + + Cmp AL, '\' + JNE D_GetStartingDirectory4 + + Mov CX, DX + Jmp D_GetStartingDirectory4 + +D_GetStartingDirectory5: + Pop SI + + Dec CX + Rep MovsB + Xor AL, AL + StosB + +D_GetStartingDirectoryEnd: + Push CS + Pop DS + + Mov SI, Offset StartingDirectory + Call D_SetDriveDirectory + + Mov DI, Offset SongDirectory + Cmp Byte Ptr [DI], 0 + JNE D_InitDisk11 + + Push SI + +D_InitDisk5: + LodsB + And AL, AL + JZ D_InitDisk6 + + StosB + Jmp D_InitDisk5 + +D_InitDisk6: + Cmp Byte Ptr [ES:DI-1], '\' + JNE D_InitDisk15 + + Dec DI + +D_InitDisk15: + Mov AX, '\' + 256*'S' + StosW + Xor AL, AL + StosB + + Pop SI + +D_InitDisk11: + Mov DI, Offset SampleDirectory + Cmp Byte Ptr [DI], 0 + JNE D_InitDisk12 + +D_InitDisk7: + LodsB + And AL, AL + JZ D_InitDisk8 + + StosB + Jmp D_InitDisk7 + +D_InitDisk8: + Cmp Byte Ptr [ES:DI-1], '\' + JNE D_InitDisk16 + + Dec DI + +D_InitDisk16: + Mov AX, '\' + 256*'I' + StosW + Xor AL, AL + StosB + +D_InitDisk12: + Mov DI, Offset InstrumentDirectory + Cmp Byte Ptr [DI], 0 + JNE D_InitDisk13 + + Mov SI, Offset SampleDirectory + Mov CX, 70 + Rep MovsB + + Mov SI, Offset SongDirectory + Call D_SetDriveDirectory + Mov SI, Offset SampleDirectory + Call D_SetDriveDirectory + Mov SI, Offset InstrumentDirectory + Call D_SetDriveDirectory + +D_InitDisk13: + Push CS + Pop DS + + Mov SI, Offset StartingDirectory + Call D_SetDriveDirectory + + Trace " - Loading configuration file" + + Mov AX, 3D00h ; Get config. + Mov DX, Offset ConfigFileName + Int 21h + JC D_InitDisk2 + + Mov BX, AX ; BX = file handle + + Trace " - Processing configuration file" + + Mov AH, 3Fh + Mov CX, 211 ; Load Directories+Keyboard + Mov DX, Offset SongDirectory + Int 21h ; Read config file.. + + Call S_GetPaletteOffset ; Read palette stuff. + Mov AH, 3Fh + Mov CX, 3*16 + Int 21h + + Call S_SetPalette + + Call Display_GetDisplayWindowData + Mov AH, 3Fh + Mov CX, 50 + Int 21h + + Call PE_GetPatternConfigOffset + Mov AH, 3Fh + Mov CX, 218 + Int 21h + + Call I_GetPresetEnvelopeOffset + Mov AH, 3Fh + Mov CX, 810 + Int 21h + + Mov AH, 3Eh ; Close file. + Int 21h + +D_InitDisk2: ; Load font data.. and set it. + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset StartingDirectory + Call D_SetDriveDirectory + + Mov AX, 3D00h + Mov DX, Offset FontFileName + Int 21h + JC D_NoFontFile + + Trace " - Loading custom font file" + + Call S_GetGenerationTableOffset + Push ES + Pop DS + Mov DX, DI + + Mov BX, AX + Mov AH, 3Fh + Mov CX, 2048 + Int 21h + JC D_BadFontRead + Cmp AX, CX + JNE D_BadFontRead + + Trace " - Initialising custom font file" + + Push BX + + Mov SI, DX + Xor AX, AX + Mov BX, 256 + Call S_RedefineCharacters + + Pop BX + +D_BadFontRead: + Mov AH, 3Eh + Int 21h + +D_NoFontFile: + Push CS + Pop DS + + Call CheckTimerData + + Pop DS + Ret + +EndP D_InitDisk + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_UnInitDisk Far + + Push CS + Pop DS + Assume DS:Disk + + Mov AX, DiskDataArea + Test AX, AX + JZ D_UnInitDisk1 + + Mov ES, AX + Mov AH, 49h + Int 21h + + +D_UnInitDisk1: + Call ReleaseTimerData + Mov SI, Offset DOSDirectory + Call D_SetDriveDirectory + + Ret + +EndP D_UnInitDisk + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GetDriveDirectory ; DS:SI points to buffer + + Push AX + Push DX + Push SI + + Mov AH, 19h + Int 21h + + Add AL, 'A' + Mov [SI], AL + Mov Word Ptr [SI+1], ':' + 256*'\' + Add SI, 3 + Mov AH, 47h + Xor DX, DX + Int 21h + + Pop SI + Pop DX + Pop AX + + Ret + +EndP D_GetDriveDirectory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SetDriveDirectory ; DS:SI points to dir. + + Push AX + Push BX + Push DX + + Xor DX, DX + + Cmp Byte Ptr [SI+1], ':' + JNE D_SetDriveDirectory2 + + Mov DL, [SI] + Cmp DL, 'a' + JB D_SetDriveDirectory1 + Cmp DL, 'z' + JA D_SetDriveDirectory1 + + Add DL, 'A'-'a' + +D_SetDriveDirectory1: + Sub DL, 'A' + Cmp DL, 25 ; Drive > 'Z'?? + JA D_SetDriveDirectory4 + + Mov AX, 440Eh + Mov BL, DL + Inc BX + Int 21h + JC D_SetDriveDirectory3 + And AL, AL + JZ D_SetDriveDirectory3 + + Mov AX, 440Fh + Int 21h + +D_SetDriveDirectory3: + Mov AH, 0Eh + Int 21h ; This causes hanging on re-run!!! + +D_SetDriveDirectory4: + Mov DX, 2 + +D_SetDriveDirectory2: + Add DX, SI + Mov AH, 3Bh + Int 21h + + Call D_GetDriveDirectory + + Pop DX + Pop BX + Pop AX + Ret + +EndP D_SetDriveDirectory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFileNames + + Mov ES, CS:DiskDataArea + Xor DI, DI + Xor AX, AX + Mov CX, 32768 + Rep StosW + + Push CS + Push CS + + Pop DS + Pop ES + Assume DS:Disk + + Mov NumFileInfo, 0 + Mov NumEntries, 0 + Mov CurrentDirectory, 0 + + Mov SI, Offset FileSpecifier + +D_LoadFileNames1: + Mov DI, Offset FileTempSpecifier + +D_LoadFileNames2: + LodsB + And AL, AL + JZ D_LoadFileNames3 + + Cmp AL, ',' + JE D_LoadFileNames3 + + Cmp AL, ' ' + JE D_LoadFileNames2 + + StosB + Jmp D_LoadFileNames2 + +D_LoadFileNames3: + Xor AL, AL + StosB ; ES:DI points to file name. + + Push DS + Push SI + Push ES + Push DI + + Xor BL, BL + Mov CX, 6 ; Hidden/System/Normal files + Mov DX, Offset FileTempSpecifier + Call D_LoadFileNames4 + + Pop DI + Pop ES + Pop SI + Pop DS + + Cmp Byte Ptr [DS:SI-1], 0 + JNE D_LoadFileNames1 + + Mov AX, NumEntries + Mov NumFiles, AX + Cmp CurrentFile, AX + JB D_LoadFileNameUpdateCurrentFile + + Mov CurrentFile, 0 + +D_LoadFileNameUpdateCurrentFile: + Mov DX, Offset AllFilesMask + Mov CX, 10h ; Directories + Mov BX, CX + Call D_LoadFileNames4 + + Mov AX, NumEntries + Sub AX, NumFiles + Mov NumDirectories, AX + + Ret + +D_LoadFileNames4: + Push DX + + Mov DS, DiskDataArea + Assume DS:Nothing + + Mov DX, 60000 + Mov AH, 1Ah + Int 21h ; Shift DTA address.. + + Push CS + Pop DS + Assume DS:Disk + + Mov AH, 4Eh + Pop DX + Int 21h + +D_LoadFileNames5: + JC D_LoadFileNames6 + ; A file is found.... + Cmp NumEntries, 1000 + JAE D_LoadFileNames6 + + Mov AX, 50 + Mul NumEntries + Add AX, 2000 + Mov DI, AX + Mov CX, 21 + + Mov DS, DiskDataArea + Assume DS:Nothing + + Mov SI, 60000+16h + + Cmp Word Ptr [DS:60000+1Eh], '.' + JNE D_LoadFileNames9 + + Mov Byte Ptr [DS:60000+1Eh], '\' + +D_LoadFileNames9: + And BL, BL + JZ D_LoadFileNames7 + + Test [SI-1], BL + JZ D_LoadFileNames8 + +D_LoadFileNames7: + Push DS + Pop ES + Rep MovsB + + Inc CS:NumEntries + +D_LoadFileNames8: + Push CS + Pop DS + Mov AH, 4Fh + Int 21h + Jmp D_LoadFileNames5 + +D_LoadFileNames6: + RetN + +EndP D_LoadFileNames + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SortRoutine + + Mov DS, DiskDataArea + Push DS + Pop ES + + Mov SI, CX ; Start + + ; OK, so SI = current, + ; CX/DX = range + +D_SortRoutine2: + Cmp SI, DX + JAE D_SortRoutine1 + + Push DX + Push SI + + Push CX + Push DX + + Mov AX, 50 + Mul SI + Add AX, 2000 + Mov SI, AX + + Mov AX, 50 + Mul CX + Add AX, 2000 + Mov DI, AX + + Xor BX, BX + Pop DX + + Cmp Word Ptr [SI+8], '\' + JE D_SortRoutine4 + +D_SortRoutine3: + Cmp CX, DX + JAE D_SortRoutine4 + + Cmp Word Ptr [DI+8], '\' + JE D_SortRoutine6 + + Push CX + Push SI + Push DI + + Add SI, 8 + Add DI, 8 + Mov CX, 13 + + RepE CmpsB + + Pop DI + Pop SI + Pop CX + + JB D_SortRoutine5 + JA D_SortRoutine6 + Cmp DI, SI + JBE D_SortRoutine5 + +D_SortRoutine6: + Inc BX + +D_SortRoutine5: + Inc CX + Add DI, 50 + + Jmp D_SortRoutine3 + +D_SortRoutine4: + Pop CX + Add BX, CX + Add BX, BX + Mov [BX], SI + + Pop SI + Pop DX + Inc SI + Jmp D_SortRoutine2 + +D_SortRoutine1: + Ret + +EndP D_SortRoutine + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SortFileNames + + Xor CX, CX + Mov DX, CS:NumFiles + Call D_SortRoutine + + Ret + +EndP D_SortFileNames + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SortDirNames + + Mov CX, CS:NumFiles + Mov DX, CX + Add DX, CS:NumDirectories + Call D_SortRoutine + + Ret + +EndP D_SortDirNames + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_InitLoadModule Far + + Push DS + Push ES + Push DI + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Disk + + Mov SI, Offset FileSpecifierDefault + Mov DI, Offset FileSpecifier + Mov CX, 65 + Rep MovsB + + Pop DI + Pop ES + Pop DS + Assume DS:Nothing + +Proc D_InitLoadModule2 Far + + Cmp CS:FileSpecifier, 0 + JE D_InitLoadModule + + Push DS + Push ES + Push DI + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Disk + + Mov DI, Offset CurrentSearchPos + Mov CX, 14 + Xor AL, AL + Rep StosB + + Mov LoadSongNameCount, 0 + + Mov SI, Offset SongDirectory + Call D_SetDriveDirectory ; DS:SI points to cur dir. + + Call D_LoadFileNames + Call D_SortFileNames + Call D_SortDirNames + + Pop DI + Pop ES + Pop DS + Ret + +EndP D_InitLoadModule2 + +EndP D_InitLoadModule + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DrawFileWindow Far ; Layout of filenames in memory + ; Start at offset 2000 + ; Pointers to filenames at 0 + + Push CS + Pop DS + Assume DS:Disk + + Call S_GetDestination + + Mov AX, TopFile + Mov BX, CurrentFile + Cmp AX, BX + JBE D_DrawFileWindow1 + + Mov AX, BX + +D_DrawFileWindow1: + LEA CX, [EAX+30] + Cmp CX, BX + JA D_DrawFileWindow2 + + LEA AX, [BX-30] + +D_DrawFileWindow2: + Mov TopFile, AX + Mov BX, AX ; BX = filenum + + Mov DS, DiskDataArea + Assume DS:Nothing + + Mov DI, (3+13*80)*2 + Mov CX, 31 + + +D_DrawFileWindow3: + LEA SI, [EBX+EBX] + Mov SI, [SI] + + Push DI + + Cmp BX, NumFiles + JAE D_DrawFileWindow4 + + Push SI + Push DI + + Mov AH, 2 + Cmp CS:FileColours, 0 + JE D_DrawFileWindow28 + + Mov AH, 6 ; Not checked colour + Mov AL, [SI+23] + + Test AL, AL + JE D_DrawFileWindow28 + + Mov AH, 7 ; Not known colour + Cmp AL, 1 + JE D_DrawFileWindow28 + + Mov AH, 3 ; Impulse Tracker colour + Cmp AL, 3 + JBE D_DrawFileWindow28 + Cmp AL, 7 + JE D_DrawFileWindow28 + + Mov AH, 5 ; Scream Tracker colour + Cmp AL, 8 + JBE D_DrawFileWindow28 + + Mov AH, 2 ; MOD/MTM colour + +D_DrawFileWindow28: + Push CX + + Add SI, 8 + Mov CX, 12 + +D_DrawFileWindow6: + LodsB + StosW + + And AL, AL + LoopNZ D_DrawFileWindow6 + +; JCXZ D_DrawFileWindow30 + + Xor AL, AL + Rep StosW + + Pop CX + +; D_DrawFileWindow30: + Pop DI + Pop SI + +D_DrawFileWindow4: + Add DI, 24 + Add SI, 25 + + Mov AX, 2A8h + StosW + + Cmp BX, NumFiles + JAE D_DrawFileWindow9 + + Mov AH, 2 ; Song name.. + Mov DX, 25 + + Add AH, CS:FileColours + +D_DrawFileWindow5: + LodsB + Cmp AL, 226 + JB D_DrawFileCharFilter + + Mov AL, ' ' + +D_DrawFileCharFilter: + StosW + + Dec DX + JNZ D_DrawFileWindow5 + +D_DrawFileWindow9: + Pop DI + Add DI, 160 + Inc BX + + Loop D_DrawFileWindow3 + + Push CS + Pop DS + Assume DS:Disk + + Cmp NumFiles, 0 + JE D_DrawFileWindow7 + + Jmp D_DrawFileWindow11 + +D_DrawFileWindow7: + Mov SI, Offset NoFilesMsg + Mov DI, (3+13*80)*2 + Mov AH, 7 + Mov CX, 9 + +D_DrawFileWindow8: + LodsB + StosW + + Loop D_DrawFileWindow8 + +D_DrawFileWindow11: +; Push CS ; Not necessary +; Pop DS + + Mov SI, Offset Search + Mov DI, (51+37*80)*2 + Mov CX, 13 + Mov AH, 5 + +D_DrawFileWindow10: + LodsB + StosW + + Loop D_DrawFileWindow10 + + Cmp NumFiles, 0 + JNE D_DrawFileWindow12 + + Ret + +D_DrawFileWindow12: + Mov BX, CurrentFile + Add BX, BX + + Mov DS, DiskDataArea + Assume DS:Nothing + + Mov BX, [BX] + Mov SI, [BX+23] + Mov AL, [BX+22] + Mov DI, (51+40*80)*2 + + Push CS + Pop DS + Assume DS:Disk + + Add SI, SI + Mov SI, [FormatNames+SI] + Cmp SI, Offset ChannelXX + JNE D_DrawFileWindow29 + + Xor AH, AH + Push AX ; Number of channels for MOD + + Mov AH, 5 + Call S_DrawString + Pop AX ; Add SP, 2 + + Jmp D_DrawFileWindow14 + +D_DrawFileWindow29: + Mov AH, 5 + +D_DrawFileWindow13: + LodsB + And AL, AL + JZ D_DrawFileWindow14 + + StosW + Jmp D_DrawFileWindow13 + +D_DrawFileWindow14: + Mov DS, DS:DiskDataArea + Assume DS:Nothing + + Mov DX, [BX+6] + Mov AX, [BX+4] + Cmp DX, 10000 + + JAE D_DrawFileWindow15 + + Mov DI, (51+41*80)*2 + + Mov CX, 10000 + Div CX ; DX = remainder. AX = main. + + Mov BP, AX + + Mov CX, 4 + Mov SI, 10 + Mov AX, DX + +D_DrawFileWindow16: + Xor DX, DX + Div SI + Add DL, '0' + Push DX + + Loop D_DrawFileWindow16 + + Mov AX, BP + + Mov CX, 5 + +D_DrawFileWindow17: + Xor DX, DX + Div SI + Add DL, '0' + Push DX + + Loop D_DrawFileWindow17 + + Mov CX, 9 + +D_DrawFileWindow18: + Pop AX + Mov AH, 5 + StosW + Loop D_DrawFileWindow18 + +D_DrawFileWindow15: ; OK, time for a date :) + Mov DX, [DS:BX] ; DX = time + Mov BX, [DS:BX+2] ; BX = date + + Push CS + Pop DS + Assume DS:Disk + + Mov DI, (51+42*80)*2 + Mov AX, BX + ShR AX, 5 + And AX, 0Fh + LEA SI, [EAX+EAX] + Mov SI, [MonthNames+SI] + + Mov AH, 5 + +D_DrawFileWindow19: + LodsB + StosW + And AL, AL + JNZ D_DrawFileWindow19 + + Mov AL, BL + And AX, 31 + Mov CH, 10 + Div CH + And AL, AL + JZ D_DrawFileWindow20 + + Push AX + Add AL, '0' + Mov AH, 5 + StosW + + Pop AX + +D_DrawFileWindow20: + Mov AL, AH + Add AL, '0' + Mov AH, 5 + StosW + + Mov AL, ',' + StosW + + Mov AL, ' ' + StosW + + Push DX + Mov AL, BH + ShR AX, 1 + And AX, 7Fh + Add AX, 1980 + Mov DX, 0FFFFh + Push DX + + Mov SI, 10 + +D_DrawFileWindow21: + Xor DX, DX + Div SI + Add DL, '0' + Push DX + + And AX, AX + JNZ D_DrawFileWindow21 + +D_DrawFileWindow22: + Pop AX + Cmp AX, 0FFFFh + JE D_DrawFileWindow23 + + Mov AH, 5 + StosW + + Jmp D_DrawFileWindow22 + +D_DrawFileWindow23: + Pop DX + Mov DI, (51+43*80)*2 + + Mov AX, DX + ShR AX, 11 + + Xor BL, BL ; if BL = 0, then am, otherwise + ; pm.. + Cmp AX, 12 + JB D_DrawFileWindow24 + + Inc BX + Sub AX, 12 + +D_DrawFileWindow24: + And AX, AX + JNZ D_DrawFileWindow25 + + Add AX, 12 + +D_DrawFileWindow25: + Mov BH, 10 + Div BH + And AL, AL + JZ D_DrawfileWindow26 + + Push AX + Add AL, '0' + Mov AH, 5 + StosW + + Pop AX + +D_DrawFileWindow26: + Mov AL, AH + Add AL, '0' + Mov AH, 5 + StosW + + Mov AL, ':' + StosW + + Mov AX, DX + ShR AX, 5 + And AX, 63 + + Div BH + Mov BH, AH + + Add AL, '0' + Mov AH, 5 + StosW + + Mov AL, BH + Add AL, '0' + StosW + + Mov AL, 'a' + And BL, BL + JZ D_DrawFileWindow27 + + Mov AL, 'p' + +D_DrawFileWindow27: + StosW + Mov AL, 'm' + StosW + + Ret + +EndP D_DrawFileWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DrawDirectoryWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Call S_GetDestination + + Mov AX, TopDirectory + Mov BX, CurrentDirectory + Cmp AX, BX + JBE D_DrawDirectoryWindow1 + + Mov AX, BX + +D_DrawDirectoryWindow1: + LEA CX, [EAX+20] + Cmp CX, BX + JA D_DrawDirectoryWindow2 + + LEA AX, [BX-20] + +D_DrawDirectoryWindow2: + Mov TopDirectory, AX + Mov BX, AX + + Mov CX, 21 + Mov DI, (44+13*80)*2 + + Mov DS, DiskDataArea + Assume DS:Nothing + +D_DrawDirectoryWindow3: + Cmp BX, CS:NumDirectories + JAE D_DrawDirectoryWindow4 + + Mov SI, BX + Add SI, CS:NumFiles + Add SI, SI + Mov SI, [SI] + + Push DI + + Add SI, 8 + Mov AH, 5 + +D_DrawDirectoryWindow5: + LodsB + And AL, AL + JZ D_DrawDirectoryWindow8 + + StosW + Jmp D_DrawDirectoryWindow5 + +D_DrawDirectoryWindow8: + Pop DI + Add DI, 160 + Inc BX + + Loop D_DrawDirectoryWindow3 + +D_DrawDirectoryWindow4: + Push CS + Pop DS + Assume DS:Disk + + Cmp NumDirectories, 0 + JE D_DrawDirectoryWindow6 + + Ret + +D_DrawDirectoryWindow6: + Mov SI, Offset NoDirsMsg + Mov DI, (44+13*80)*2 + Mov AH, 7 + Mov CX, 8 + +D_DrawDirectoryWindow7: + LodsB + StosW + + Loop D_DrawDirectoryWindow7 + + Ret + +EndP D_DrawDirectoryWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DrawDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Call S_GetDestination + + Mov AL, TopDrive + Mov BL, CurrentDrive + Cmp AL, BL + JBE D_DrawDriveWindow1 + + Mov AL, BL + +D_DrawDriveWindow1: + Mov CL, AL + Add CL, 20 + Cmp CL, BL + JA D_DrawDriveWindow2 + + Mov AL, BL + Sub AL, 20 + +D_DrawDriveWindow2: + Mov TopDrive, AL + Mov BL, AL + Mov CX, 21 + + Mov DI, (59+13*80)*2 + Xor BH, BH + +D_DrawDriveWindow3: + Cmp BL, NumDrives + JAE D_DrawDriveWindow5 + + Push DI + + Mov AL, [DrivesAvail+BX] + Add AL, 'A' + Mov SI, Offset DriveMsg + Mov [SI+6], AL + + Mov AH, 5 + Mov DX, 8 + +D_DrawDriveWindow4: + LodsB + StosW + + Dec DX + JNZ D_DrawDriveWindow4 + + Pop DI + Add DI, 160 + Inc BX + Loop D_DrawDriveWindow3 + +D_DrawDriveWindow5: + Ret + +EndP D_DrawDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFileHeader ; Given DS:SI = filename + + Push BP + + Xor BP, BP ; BP = 0 (no MMTSR) + + Mov AX, 4370h + Int 21h ; MMTSR installation check. + + Cmp EAX, 4352697Ah + JNE D_LoadFileHeader2 + + Mov AX, 4372h + Int 21h ; Disable MMTSR + + Inc BP + +D_LoadFileHeader2: + Mov DX, SI + Mov AX, 3D00h + Int 21h ; Open File + JC D_LoadFileHeader1 + + Mov BX, AX ; BX = file handle + + Push DS + Pop ES + Mov DI, 60000 + Mov CX, 5536 + Xor AL, AL + Rep StosB ; Clear data area first... + + Mov AH, 3Fh + Mov CX, 5536 + Mov DX, 60000 + Int 21h + PushF + + JC D_LoadFileHeader5 + Test BP, BP + JZ D_LoadFileHeader5 + + Cmp DWord Ptr [DS:60000], 'CRiz' + JNE D_LoadFileHeader5 + + Cmp DWord Ptr [DS:60004], 'aiNO' + JNE D_LoadFileHeader5 + ; OK.. have a MMCMPed file. + Mov AX, 4200h + Mov DX, [DS:60018] + Mov CX, [DS:60020] + Int 21h + + Mov AH, 3Fh + Mov CX, 4 + Mov DX, 60000 + Int 21h + Cmp AX, CX + JNE D_LoadFileHeader5 + + Mov AX, 4200h + Mov DX, [DS:60000] + Mov CX, [DS:60002] + Int 21h ; Seek to offset in file. + + Mov AH, 3Fh + Mov CX, 28 + Mov DX, 60000 + Int 21h + Cmp AX, CX + JNE D_LoadFileHeader5 + + Mov AX, [DS:60014] + ShR AX, 4 + And AL, 7 + JNZ D_LoadFileHeader5 + + PopF + Mov AH, 3Fh + Mov CX, 5536 + Mov DX, 60000 + Int 21h + PushF + +D_LoadFileHeader5: + Mov AH, 3Eh ; Close file + Int 21h + +D_LoadFileHeader4: + Test BP, BP + JZ D_LoadFileHeader3 + ; Reenable MMTSR + Mov AX, 4371h + Int 21h + +D_LoadFileHeader3: + PopF + + Pop BP + StI ; For problems with MMTSR + Ret + +D_LoadFileHeader1: + StC + PushF + Jmp D_LoadFileHeader4 + +EndP D_LoadFileHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadModuleHeader + + Mov DS, DiskDataArea + Assume DS:Nothing + + Add BX, BX + Mov SI, [BX] + Add SI, 8 + + Call D_LoadFileHeader + + Ret + +EndP D_LoadModuleHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadSongNames Far ; Part of idle list. + + Call K_IsAnyKeyDown + And AL, AL + JNZ D_LoadSongNames2 + + Call GetKeyboardLock + And AL, AL + JNZ D_LoadSongNames2 + + Push CS + Pop DS + Assume DS:Disk + + Mov BX, LoadSongNameCount + Cmp BX, NumFiles + JB D_LoadSongNames1 + +D_LoadSongNames2: + Xor AX, AX ; No redraw screen. + Ret + +D_LoadSongNames1: + Inc LoadSongNameCount + + Call D_LoadModuleHeader + JC D_LoadSongNames3 + + Call D_GetSongNameModuleType + +D_LoadSongNames3: + + Mov AX, 1 ; Signify redraw screen + Ret + +EndP D_LoadSongNames + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PreFileWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov AX, CurrentFile + Sub AX, TopFile + Add AX, 13 + Mov BX, 160 + Mul BX + + Call S_GetDestination + + LEA DI, [EAX+6] + Mov CX, 38 + +D_PreFileWindow1: + Mov AX, [ES:DI] + Cmp CX, 26 + +; Cmp AL, 168 + JNE D_PreFileWindow2 + + Mov AH, 32h + Jmp D_PreFileWindow3 + +D_PreFileWindow2: + Mov AH, 30h + +D_PreFileWindow3: + StosW + + Loop D_PreFileWindow1 + + Mov DI, (51+37*80)*2 + Xor AH, AH + Mov AL, CurrentSearchPos + LEA DI, [EDI+EAX*2+1] + Mov AL, 60h + StosB + + Ret + +EndP D_PreFileWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PreDirectoryWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov AX, CurrentDirectory + Sub AX, TopDirectory + Add AX, 13 + Mov BX, 160 + Mul BX + + Call S_GetDestination + + LEA DI, [EAX+88] + + Mov CX, 12 + +D_PreDirectoryWindow1: + Mov AX, [ES:DI] + Mov AH, 30h + StosW + + Loop D_PreDirectoryWindow1 + + Ret + +EndP D_PreDirectoryWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PreDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov AL, CurrentDrive + Sub AL, TopDrive + Add AL, 13 + Mov AH, 160 + Mul AH + + Call S_GetDestination + LEA DI, [EAX+118] + Mov CX, 8 + +D_PreDriveWindow1: + Mov AX, [ES:DI] + Mov AH, 30h + StosW + + Loop D_PreDriveWindow1 + + Ret + +EndP D_PreDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadFileOpenErrorMsg Far + + Mov DI, (4+16*80)*2 + Mov AH, 4 + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset OpenErrorMsg + + Call S_DrawString + + Mov AX, 1 + Ret + +EndP D_LoadFileOpenErrorMsg + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_Decompress16BitData + +; Register usage: +; BX = LastValue +; CH = Bitdepth +; CL = 16-Bitdepth, 0 for Bitdepth > 16 +; DL = Bitsread +; DH = scratch + + PushAD + Mov BP, CX + Mov CX, 1100h + ShR BP, 1 + Xor DX, DX + Xor BX, BX + +D_Decompress16BitData1: + Push CX + + Mov EAX, [SI] + Mov CL, DL + ShR EAX, CL + + Add DL, CH + Mov CX, DX + ShR CX, 3 + Add SI, CX + And DL, 7 + + Pop CX + + Cmp CH, 6 + JA D_Decompress16BitA + + ShL EAX, CL + Cmp AX, 8000h + JE D_Decompress16BitDepthChange1 + +D_Decompress16BitD: + SAR AX, CL + +D_Decompress16BitC: + Add BX, AX + Mov [ES:DI], BX + ScasW +; Add DI, 2 + + Dec BP + JNZ D_Decompress16BitData1 + + PopAD + Ret + +D_Decompress16BitDepthChange1: + ShR EAX, 16 + And AL, 15 + + Inc AX + +; Advance bits + Add DL, 4 + +D_Decompress16BitDepthChange3: + Cmp AL, CH + SBB AL, 0FFh + Mov CL, 16 + Mov CH, AL + Sub CL, AL + AdC CL, 0 + + Jmp D_Decompress16BitData1 + +D_Decompress16BitA: + Cmp CH, 16 + JA D_Decompress16BitB + + Push DX + Mov DX, 0FFFFh + ShR DX, CL + And AX, DX + ShR DX, 1 + Add DX, 8 + Cmp AX, DX + JA D_Decompress16BitE + Sub DX, 16 + Cmp AX, DX + JBE D_Decompress16BitE + + Sub AX, DX + Pop DX + Jmp D_Decompress16BitDepthChange3 + +D_Decompress16BitE: + Pop DX + ShL AX, CL + Jmp D_Decompress16BitD + +D_Decompress16BitB: + Test EAX, 10000h + JZ D_Decompress16BitC + + Mov CL, 16 + Inc AX + + Sub CL, AL + Mov CH, AL + + Jmp D_Decompress16BitData1 + +EndP D_Decompress16BitData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_Decompress8BitData ; DS:SI = source + ; ES:DI = destination + ; CX = count. + + PushA + Mov BP, CX ; BP = counter; + + Mov BX, 900h + Xor CX, CX + Xor DX, DX + +; Register usage: +; BH = Bitdepth +; BL = lastvalue +; CL = 8-bitdepth, undefined for bitdepth > 8 +; CH = Bitsread + +; DX = scratch + +D_Decompress8BitData1: + Push CX + Mov AX, [SI] + Mov CL, CH + +; Get bits loaded into AX properly. + ShR AX, CL + Pop CX + +; Advance SI as necessary. + Add CH, BH + Mov DL, CH + And CH, 7 + ShR DL, 3 + Add SI, DX + + Cmp BH, 6 + JA D_Decompress8BitA + + ShL AX, CL + + Cmp AL, 80h + JE D_Decompress8BitDepthChange1 + +D_Decompress8BitWriteData2: + SAR AL, CL + +D_Decompress8BitWriteData: + Add BL, AL + Mov [ES:DI], BL + + Inc DI + Dec BP + + JNZ D_Decompress8BitData1 + PopA + Ret + +D_Decompress8BitDepthChange1: + Mov AL, AH + Add CH, 3 + + And AL, 7 + Mov DL, CH + + And CH, 7 + ShR DL, 3 + + Add SI, DX + Jmp D_Decompress8BitD + +D_Decompress8BitA: + Cmp BH, 8 + JA D_Decompress8BitC + JE D_Decompress8BitB + + ShL AL, 1 + Cmp AL, 78h + JB D_Decompress8BitWriteData2 + Cmp AL, 86h + JA D_Decompress8BitWriteData2 + + ShR AL, 1 + Sub AL, 3Ch + Jmp D_Decompress8BitD + +D_Decompress8BitB: + Cmp AL, 7Ch + JB D_Decompress8BitWriteData + Cmp AL, 83h + JA D_Decompress8BitWriteData + + Sub AL, 7Ch + +D_Decompress8BitD: + Mov CL, 8 + Inc AX + + Cmp AL, BH + SBB AL, 0FFh + Mov BH, AL + Sub CL, AL + AdC CL, 0 + + Jmp D_Decompress8BitData1 + +D_Decompress8BitC: ; 9 bit representation + And AX, 1FFh + + Test AX, 100h + JZ D_Decompress8BitWriteData + + Jmp D_Decompress8BitD + +EndP D_Decompress8BitData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +TempData DW 0 +DisableStereoMenu DB 0 + +Proc D_LoadSampleData ; DS:SI points to sample header + ; AX = sample number (0 based) + + Push DS + Push ES + PushAD + + Mov EDX, [DS:SI+30h] + And EDX, EDX + JZ D_NoLoadSample + + Mov CL, [SI+12h] + Mov BP, [SI+2Eh] + + And Byte Ptr [SI+12h], Not 0Ch + Mov Byte Ptr [SI+2Eh], 1 + And BP, 0FFh + + ShL BP, 1 + Mov CH, CL + And CX, 802h + ShL CH, 4 + ShR CL, 1 + Or BP, CX ; BP flags: + ; 1: 16 bit + ; 2: Convert unsigned->signed + ; 4: Swap bytes + ; 8: Delta values. + ; 16: Byte delta values + ; 32: 12-bit sample. + ; 64: Stereo prompt. + ; 8000h: Compressed. + + Xor SI, SI + + Test BP, 1 + JZ D_LoadSampleData5 + + Add EDX, EDX + +D_LoadSampleData5: + Test BP, 64 + JZ D_LoadSampleDataNotStereo + + Cmp CS:DisableStereoMenu, 0 + JNE D_NoStereoMenu + + PushAD + Push DS ES + + Mov DI, Offset O1_StereoSampleList + Mov CX, 0FFFFh + Call M_Object1List + + Mov CS:TempData, DX + + Pop ES DS + PopAD + + Or BP, CS:TempData ; 64 = left + ; 64+128 = right +D_NoStereoMenu: + Add EDX, EDX + +D_LoadSampleDataNotStereo: + Call Music_AllocateSample ; AX = sample no. + ; EDX = length. + ; returns ES:DI. + Inc AX + + Mov EDI, EDX + + Mov DX, ES + Test DX, DX + JZ D_LoadSampleData1 + + Push DS + + Xor CX, CX ; Start with page 0 + +D_LoadSampleData3: + Push AX ; AX = sample no. + Push CX ; CH = page no. + Push EDI ; EDI = bytes remaining + ; SI = delta accumulator + ; BX = file pointer + + Push SI + Call Music_GetSampleLocation + Mov DX, SI + Pop SI + + Mov ECX, 32768 + Cmp EDI, ECX + JA D_LoadSampleData4 + + Mov CX, DI + +D_LoadSampleData4: + Test BP, 32 ; 12 bit format? + JZ NotTX12BitSampleA + + And ECX, 0FFFFh + LEA ECX, [ECX*2+ECX] + Add ECX, 3 + ShR ECX, 2 ; ECX = bytes to read. + +NotTX12BitSampleA: + +; DS:DX point to buffer. For compressed samples, use +; patterndata area. + + Test BP, BP + JNS LoadCompressedSample1 + + Push DS + Push CX + Push DX + + Mov DX, Pattern + Mov DS, DX + Assume DS:Pattern + + Mov DS, Word Ptr [PatternDataArea] + Assume DS:Nothing + + Xor DX, DX + Mov CX, 2 + Mov AH, 3Fh + Int 21h + Mov CX, [DS:0] ; Bytes to read. + Xor DX, DX ; Compressed chunk. + +LoadCompressedSample1: + + Mov AH, 3Fh + Int 21h + +; Now to decompress samples, if required. + + Test BP, BP + JNS LoadCompressedSample3 + + Pop DI + Pop CX + Pop ES + Xor SI, SI + + Test BP, 1 + JNZ LoadCompressedSample2 + + Call D_Decompress8BitData ; 8 bit decode. + Jmp LoadCompressedSample4 + +LoadCompressedSample2: ; 16 bit decode + Call D_Decompress16BitData + +LoadCompressedSample4: + Push ES + Pop DS + + Xor SI, SI + Jmp SecondDelta + +LoadCompressedSample3: + Test BP, 32 ; 12-bit sample? + JZ NotTX12BitSampleB + ; CX = number of bytes read. + ; = 3*2 number of sample read + Push SI + Push DX + + Add AX, 2 + Mov CX, 3 + Div CX + Mov CX, AX + Pop DX + + LEA SI, [EAX*2+EAX] ; SI = AX * 3 + LEA DI, [EAX*4+EDX] + Add SI, DX + + Test CX, CX + JZ ConvertTXSample2 + + Push CX + +ConvertTXSample1: + Sub SI, 3 + Sub DI, 4 + + Mov AX, [SI+1] + ShL AL, 4 + ShL EAX, 16 + Mov AH, [SI] + Mov AL, [SI+1] + And AL, 0F0h + Mov [DI], EAX + + Loop ConvertTXSample1 + + Pop CX + Pop SI + ShL CX, 1 + Jmp D_LoadSampleData10 + +ConvertTXSample2: + Pop SI + Jmp D_LoadSampleData6 + +NotTX12BitSampleB: + Mov CX, AX ; CX = number of bytes read + +SecondDelta: + Test BP, 1 ; 16 bit? + JZ D_LoadSampleData10 + + ShR CX, 1 + +D_LoadSampleData10: + Mov AX, BP + And AX, 5 ; 16 bit and BSwap? + Cmp AX, 5 + JNE D_LoadSampleData11 + + Push CX + Mov DI, DX + +D_LoadSampleData12: + Mov AX, [DI] + XChg AH, AL + Mov [DI], AX + ScasW +; Add DI, 2 + Loop D_LoadSampleData12 + + Pop CX + +D_LoadSampleData11: + Test BP, 24 ; Delta values? + JZ D_LoadSampleData8 + + Push CX + Mov AX, SI + Mov DI, DX + + Test BP, 1 ; 8 bit sample? + JZ D_LoadSampleData9 + + Test BP, 16 ; Byte enforced? + JZ D_LoadSampleData7 + + Add CX, CX + Jmp D_LoadSampleData9 + +D_LoadSampleData7: ; 16 bit delta + Add AX, [DI] + Mov [DI], AX + +; Add DI, 2 + ScasW + Loop D_LoadSampleData7 + + Mov SI, AX + Pop CX + + Jmp D_LoadSampleData8 + +D_LoadSampleData9: ; 8 bit delta + Add AH, [DI] + Mov [DI], AH + Inc DI + Loop D_LoadSampleData9 + + Mov SI, AX + Pop CX + +D_LoadSampleData8: + Test BP, 2 ; unsigned->signed? + JNZ D_LoadSampleData6 + + Push CX + Mov DI, DX + + Test BP, 1 + JNZ D_LoadSampleData14 + +D_LoadSampleData13: ; 8 bit + Xor Byte Ptr [DI], 80h + Inc DI + Loop D_LoadSampleData13 + + Pop CX + + Jmp D_LoadSampleData6 + +D_LoadSampleData14: ; 16 bit.. + Xor Word Ptr [DI], 8000h +; Add DI, 2 + ScasW + Loop D_LoadSampleData14 + + Pop CX + +D_LoadSampleData6: + Test BP, 64 ; Stereo? + JZ D_LoadSampleDataNoStereo + + Push SI ES + + Push DS + Pop ES + + Mov SI, DX + Mov DI, DX + + ShR CX, 1 + JZ D_LoadSampleDataEndStereo + + Test BP, 1 ; 8/16 bit? + JNZ D_LoadSampleDataStereo16BitStart + + Test BP, 128 + JZ D_LoadSampleDataStereo8Bit + + Inc SI + +D_LoadSampleDataStereo8Bit: + MovsB + Inc SI + Loop D_LoadSampleDataStereo8Bit + Jmp D_LoadSampleDataEndStereo + +D_LoadSampleDataStereo16BitStart: + Test BP, 128 + JZ D_LoadSampledataStereo16Bit + + LodsW + +D_LoadSampleDataStereo16Bit: + MovsW + LodsW + Loop D_LoadSampleDataStereo16Bit + +D_LoadSampleDataEndStereo: + Pop ES SI + + Pop EDI + Pop CX + Pop AX + + Inc CH + Jmp D_LoadSampleDataNextChain + +D_LoadSampleDataNoStereo: + Pop EDI + Pop CX + Pop AX + + Add CH, 2 + +D_LoadSampleDataNextChain: + Sub EDI, 32768 + JA D_LoadSampleData3 + + Pop DS + +D_NoLoadSample: + ClC + + PopAD + Pop ES + Pop DS + Ret + +D_LoadSampleData1: + PopAD + PushAD + + Mov AX, 4201h ; Advance file ptr. + Mov DX, [DS:SI+30h] + Mov CX, [DS:SI+32h] + Int 21h + + Call PEFunction_OutOfMemoryMessage + + PopAD + Pop ES + Pop DS + + StC + Ret + +EndP D_LoadSampleData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ConvertWriteData ; DS:DX points to data + ; BP = 1, convert, BP = 2, 16-bit + ; CX = number of bytes + + PushF + + Push AX + Push CX + Push SI + + Mov AX, 1 + Test BP, 2 + JZ ConvertWriteDataLoop1 + + Inc AX + Inc SI + ShR CX, 1 + +ConvertWriteDataLoop1: + JCXZ ConvertWriteDataLoop3 + +ConvertWriteDataLoop2: + Xor Byte Ptr [SI], 80h + Add SI, AX + Loop ConvertWriteDataLoop2 + +ConvertWriteDataLoop3: + Pop SI + Pop CX + Pop AX + +ConvertWriteData1: + PopF + Ret + +EndP ConvertWriteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveSampleDataConvert ; AX = sample number (1 based) + + PushAD + Push DS + Push ES + + Xor BP, BP + + Call Music_GetSampleLocation + Mov EDI, ECX + JZ D_SaveSampleDataConvert5 + + Add EDI, EDI + Or BP, 2 + +D_SaveSampleDataConvert5: + Xor CX, CX ; Start with page 0 + +D_SaveSampleDataConvert3: + Push AX ; AX = sample no. + Push CX ; CX = page no. + + Call Music_GetSampleLocation + Mov DX, SI + + Mov ECX, 32768 + Cmp EDI, ECX + JA D_SaveSampleDataConvert4 + + Mov CX, DI + +D_SaveSampleDataConvert4: + ClI + + Call ConvertWriteData + Call D_SaveBlock + Call ConvertWriteData + + StI + + Pop CX + Pop AX + + JC D_SaveSampleDataConvert2 + + Add CH, 2 + Sub EDI, 32768 + JA D_SaveSampleDataConvert3 + + DB 85h ; ClC +D_SaveSampleDataConvert2: + StC + Pop ES + Pop DS + PopAD + Ret + +EndP D_SaveSampleDataConvert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WriteBits ; CH = bits to write + ; CL = current bit. + ; BX = data. + ; ES:DI = output buffer. + ; EAX = buffer + ; BP = scratch + + Push CX + + Mov EBP, 1 + Mov CL, CH + ShL EBP, CL + Dec EBP + And EBX, EBP + + Pop CX + ShL EBX, CL + Add CL, CH + Or EAX, EBX + +D_WriteBits1: + Cmp CL, 8 + JB D_WriteBits2 + + StosB + ShR EAX, 8 + Sub CL, 8 + Jmp D_WriteBits1 + +D_WriteBits2: + Ret + +EndP WriteBits + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +; Data layout: +; DiskDataArea:16384 = deltas +; PatternDataArea:16384 = bittable +; PatternDataArea:0 = bufferlength +; PatternDataArea:2 = outputbuffer + +Proc D_SaveSampleDataCompressed ; AX = sample number, 1 based. + + PushAD + Push DS + Push ES + + Xor BP, BP + + Call Music_GetSampleLocation + Mov EDI, ECX + JZ D_SaveSampleDataCompressed5 + + Add EDI, EDI + Inc BP + +D_SaveSampleDataCompressed5: + Xor CX, CX ; Start with page 0 + +D_SaveSampleDataCompressed3: + Push AX ; AX = sample no. + Push CX ; CX = page no. + Push EDI + + Call Music_GetSampleLocation + + Mov ECX, 32768 + Cmp EDI, ECX + JA D_SaveSampleDataCompressed4 + + Mov CX, DI + +D_SaveSampleDataCompressed4: + Test BP, 1 + JZ D_SaveSampleCompressed8BitSample + + ShR CX, 1 + +D_SaveSampleCompressed8BitSample: +; DS:SI = sample location +; Calculate delats first. + Push BX + Push BP + Push CX + + Mov ES, CS:DiskDataArea + Mov DI, 16384 ; Offset in DiskDataArea + +IF DDCOMPRESS + Mov DX, 1 + + Cmp CS:SaveFormat, 3 + JNE D_SaveFormatNot215 + + Inc DX + +D_SaveFormatNot215: + +ENDIF + +D_CalculateDeltas: + Xor AH, AH ; AH = lastdata. + + Test BP, 1 + JZ D_Calculate8BitDeltas + + Xor BX, BX + +D_Calculate16BitDeltas: + LodsW + Sub AX, BX + Mov BX, [SI-2] + StosW + Loop D_Calculate16BitDeltas + + Jmp D_CalculateDeltaEnd + +D_Calculate8BitDeltas: + LodsB + Sub AL, AH + Mov AH, [SI-1] + StosB + Loop D_Calculate8BitDeltas + +D_CalculateDeltaEnd: + +IF DDCOMPRESS + Mov DI, 16384 + Pop CX + Push ES + Mov SI, DI + Pop DS + Push CX + + Dec DX + JNZ D_CalculateDeltas + + Push Pattern + Pop ES + Assume ES:Pattern + Mov ES, PatternDataArea + Assume ES:Nothing + +ELSE + + Pop CX + +; Now to create bittable. + + Push ES + Pop DS + + Push Pattern + Pop ES + Assume ES:Pattern + Mov ES, PatternDataArea + Assume ES:Nothing + + Push CX + + Mov SI, 16384 + Mov DI, SI +ENDIF + + Mov BH, 40 + Test BP, 1 + JZ D_GenerateBitTable1 + + Xor AX, AX + +D_Generate16BitTable1: + Mov BL, [SI+1] + Mov BH, 41 + Mov AL, [BX] + Mov DL, AL + And DL, 7 + Mov BL, [SI] + Add BH, DL + ShR AL, 3 + Add SI, 2 + Add AL, [BX] + StosW + + Loop D_Generate16BitTable1 + Pop CX + +; Minimise 16-bit table + Push ES + Pop DS + Mov Byte Ptr [DS:16382], 17 ; Starting boundary of 17. + Mov DL, 1 ; Scan for 1 bit first. + +D_Minimise16BitTable1: + Push CX + Xor AX, AX ; AX = consecutive values. + Mov SI, 16384 + +D_Minimise16BitTable2: + Test AX, AX + JNZ D_Minimise16BitTable3 + +; Not in consecutive sequence. + Cmp DL, [SI] + JNE D_Minimise16BitTableEnd + Mov DI, SI ; First value + +D_Minimise16BitTable4: + Inc AX + Jmp D_Minimise16BitTableEnd + +D_Minimise16BitTable3: + Cmp DL, [SI] + JE D_Minimise16BitTable4 + +; OK.. outside of bittable + Cmp AX, 33 + JA D_Minimise16BitTable5 + + Mov BL, [SI] + Mov BH, [DI-2] + + Cmp BL, BH + JBE D_Minimise16BitTable6 + + XChg BL, BH + +D_Minimise16BitTable6: + Cmp BL, DL + JA D_Minimise16BitTable7 + XChg BL, BH + + Cmp BL, DL + JB D_Minimise16BitTable5 + +D_Minimise16BitTable7: ; BL = minbits. + Push CX + Push DX + + Mov CH, BL + Mov DH, BL ; DH = minbits. + + Cmp AX, 1 + JE D_Minimise16BitTableForce + + Cmp BL, 5 + JA D_Minimise16BitTable8 + + Add BL, 4 + +D_Minimise16BitTable8: + Cmp BH, 5 + JA D_Minimise16BitTable9 + + Add BL, 4 + +D_Minimise16BitTable9: + Mov CL, CH + And BX, 0FFh ; BX = bits to effect conversion + + Cmp AX, BX + JA D_Minimise16BitTable13 + + And CX, 0FFh ; CX = minbits. + + Sub CL, DL + Push DX + Mul CX ; DX:AX = bits saved. + Pop CX + Test DX, DX + JNZ D_Minimise16BitTable13 + Cmp AX, BX + JA D_Minimise16BitTable13 + +D_Minimise16BitTableForce: +; Have to change values from DI -> SI with minbits. + Mov AL, CH + Mov CX, SI + Sub CX, DI + ShR CX, 1 + Rep StosW + +D_Minimise16BitTable13: + Pop DX + Pop CX + +D_Minimise16BitTable5: + Xor AX, AX + +D_Minimise16BitTableEnd: + Add SI, 2 + Loop D_Minimise16BitTable2 + + Pop CX + + And DX, 0FFh + Inc DX + Cmp DX, 17 + JB D_Minimise16BitTable1 + +; Now to dump bits to buffer. + + Mov DX, CX + Mov DS, CS:DiskDataArea + Xor EAX, EAX + Mov DI, 2 + Mov SI, 16384 + Mov CX, 1100h + +; Convert 16 Bit Buffer. + +D_Convert16BitBuffer1: + Cmp CH, [ES:SI] ; BitsToWrite = BitTable? + JE D_Convert16BitBufferEnd + +; Need to change base + Cmp CH, 6 + JA D_Convert16BitBuffer2 + + Push CX + Mov BX, 1 + Mov CL, CH + Dec CL + ShL BX, CL + Pop CX + Call WriteBits + + Mov BL, [ES:SI] + Cmp CH, BL + SBB BL, 1 + Mov CH, 4 + Call WriteBits + Jmp D_Convert16BitBufferDepthChange + +D_Convert16BitBuffer2: + Cmp CH, 16 + JA D_Convert16BitBuffer3 + + Push CX + Mov EBX, 1 + Mov CL, CH + Dec CL + ShL EBX, CL + Sub BX, 9 + Add BL, [ES:SI] + AdC BH, 0 + Pop CX + + Cmp CH, [ES:SI] + SBB BL, 0 + Call WriteBits + Jmp D_Convert16BitBufferDepthChange + +D_Convert16BitBuffer3: + Mov EBX, 100FFh + Add BL, [ES:SI] + Call WriteBits + +D_Convert16BitBufferDepthChange: + Mov CH, [ES:SI] + +D_Convert16BitBufferEnd: + MovZX EBX, Word Ptr [SI] + Call WriteBits + + Add SI, 2 + Dec DX + JNZ D_Convert16BitBuffer1 + + Jmp D_ConvertBitsFinished + + +D_GenerateBitTable1: + Mov BL, [SI] + Inc SI + Mov AL, [BX] + StosB + Loop D_GenerateBitTable1 + +D_GenerateBitTableDone: + +; OK bit table is generated. + Pop CX + +; Have to minimise bit table (in patterndataarea) + + + Push ES + Pop DS + Mov Byte Ptr [DS:16383], 9 ; Starting boundary of 9. + Mov DL, 1 ; Scan for 1 bit first. + +D_MinimiseBitTable1: + Push CX + Xor AX, AX ; AX = consecutive values. + Mov SI, 16384 + +D_MinimiseBitTable2: + Test AX, AX + JNZ D_MinimiseBitTable3 + +; Not in consecutive sequence. + Cmp DL, [SI] + JNE D_MinimiseBitTableEnd + Mov DI, SI ; First value + +D_MinimiseBitTable4: + Inc AX + Jmp D_MinimiseBitTableEnd + +D_MinimiseBitTable3: + Cmp DL, [SI] + JE D_MinimiseBitTable4 + +; OK.. outside of bittable + Cmp AX, 17 + JA D_MinimiseBitTable5 + + Mov BL, [SI] + Mov BH, [DI-1] + + Cmp BL, BH + JBE D_MinimiseBitTable6 + + XChg BL, BH + +D_MinimiseBitTable6: + Cmp BL, DL + JA D_MinimiseBitTable7 + XChg BL, BH + + Cmp BL, DL + JB D_MinimiseBitTable5 + +D_MinimiseBitTable7: ; BL = minbits. + Push CX + Push DX + + Mov DH, BL ; DH = minbits. + Mov CH, BL + + Cmp AX, 1 + JE D_MinimiseBitTableForce + + Cmp BL, 5 + JA D_MinimiseBitTable8 + + Add BL, 3 + +D_MinimiseBitTable8: + Cmp BH, 5 + JA D_MinimiseBitTable9 + + Add BL, 3 + +D_MinimiseBitTable9: + Mov CL, CH ; CL = minbits. + And BX, 0FFh ; BX = bits to effect conversion + + Cmp AX, BX + JA D_MinimiseBitTable13 + + And CX, 0FFh ; CX = minbits. + + Sub CL, DL + Push DX + Mul CX ; DX:AX = bits saved. + Pop CX + Test DX, DX + JNZ D_MinimiseBitTable13 + Cmp AX, BX + JA D_MinimiseBitTable13 + +; Have to change values from DI -> SI with minbits. +D_MinimiseBitTableForce: + Mov AL, CH + Mov CX, SI + Sub CX, DI + Rep StosB + +D_MinimiseBitTable13: + Pop DX + Pop CX + +D_MinimiseBitTable5: + Xor AX, AX + +D_MinimiseBitTableEnd: + Inc SI + Loop D_MinimiseBitTable2 + + Pop CX + + And DX, 0FFh + Inc DX + Cmp DX, 9 + JB D_MinimiseBitTable1 + +; Now to dump bits to buffer. + + Mov DX, CX + Mov DS, CS:DiskDataArea + Xor EAX, EAX + Mov DI, 2 + Mov SI, 16384 + Mov CX, 900h + +D_ConvertBitBuffer1: ; CL = current bit + ; CH = bitstowrite + ; AX = output buffer + ; DX = bytes to process + ; SI = DS:source/ES:bittable + ; DI = destination + + Cmp CH, [ES:SI] ; BitsToWrite = BitTable? + JE D_ConvertBitBufferEnd + +; Need to change base + Cmp CH, 6 + JA D_ConvertBitBuffer2 + + Push CX + Mov BX, 1 + Mov CL, CH + Dec CL + ShL BX, CL + Pop CX + Call WriteBits + + Mov BL, [ES:SI] + Cmp CH, BL + SBB BL, 1 + Mov CH, 3 + Call WriteBits + Jmp D_ConvertBitBufferDepthChange + +D_ConvertBitBuffer2: + Cmp CH, 8 + JA D_ConvertBitBuffer3 + + Push CX + Mov BX, 1 + Mov CL, CH + Dec CL + ShL BX, CL + Sub BL, 5 + Add BL, [ES:SI] + Pop CX + + Cmp CH, [ES:SI] + SBB BL, 0 + Call WriteBits + Jmp D_ConvertBitBufferDepthChange + +D_ConvertBitBuffer3: + Mov BX, 1FFh + Add BL, [ES:SI] + Call WriteBits + +D_ConvertBitBufferDepthChange: + Mov CH, [ES:SI] + +D_ConvertBitBufferEnd: + MovZX BX, Byte Ptr [SI] + Call WriteBits + + Inc SI + Dec DX + JNZ D_ConvertBitBuffer1 + +D_ConvertBitsFinished: + Xor CH, CH + Add CL, 7 + ShR CL, 3 + Rep StosB ; Write 0 or 1 bytes. + +; DI = end of block = size; + + Pop BP + Pop BX + + Mov CX, DI + Sub DI, 2 + + Push ES + Pop DS + + Mov [DS:0], DI + + Xor DX, DX + Call D_SaveBlock + + Pop EDI + Pop CX + Pop AX + + JC D_SaveSampleDataCompressed2 + + Add CH, 2 + Sub EDI, 32768 + JA D_SaveSampleDataCompressed3 + + DB 85h +D_SaveSampleDataCompressed2: + StC + Pop ES + Pop DS + PopAD + Ret + +EndP D_SaveSampleDataCompressed + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveSampleData ; AX = sample number (1 based) + + PushAD + Push DS + Push ES + + Call Music_GetSampleLocation + Mov EDI, ECX + JZ D_SaveSampleData1 + + Add EDI, EDI + +D_SaveSampleData1: + Xor CX, CX ; Start with page 0 + +D_SaveSampleData3: + Push AX ; AX = sample no. + Push CX ; CX = page no. + + Call Music_GetSampleLocation + Mov DX, SI + + Mov ECX, 32768 + Cmp EDI, ECX + JA D_SaveSampleData4 + + Mov CX, DI + +D_SaveSampleData4: + Call D_SaveBlock + Pop CX + Pop AX + JC D_SaveSampleData2 + + Add CH, 2 + Sub EDI, 32768 + JA D_SaveSampleData3 + + DB 85h +D_SaveSampleData2: + StC + Pop ES + Pop DS + PopAD + + Ret + +EndP D_SaveSampleData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include it_timer.inc +include it_d_rm.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_CheckOverWrite ; DS:DX points to filename + ; Returns Carry set if not ok + + Mov CX, 6 + Mov AH, 4Eh + Int 21h + JC D_CheckOverWrite1 ; File doesn't exist. + + ; File Already exists... + + Push BX + Push DS + Push SI + + Mov DI, Offset O1_ConfirmOverWriteList + Mov CX, 4 + Call M_Object1List + ; DX = 0 -> don't overwrite + ; DX = 1 -> overwrite + Pop SI + Pop DS + Pop BX + + Test DX, DX + JZ D_CheckOverWrite2 + +D_CheckOverWrite1: + DB 85h + +D_CheckOverWrite2: + StC + Ret + + +EndP D_CheckOverWrite + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostFileSaveWindow Far + +; Cmp DX, 13 + Cmp CX, 11Ch + JNE D_PostFileWindow + ; Save file routines. + Mov DS, CS:DiskDataArea + Mov SI, CurrentFile + Add SI, SI + Mov SI, [SI] + Add SI, 8 ; Filename + Mov DI, Offset SaveFileName + + Push CS + Pop ES + +D_PostFileSaveWindow1: + LodsB + StosB + And AL, AL + JNZ D_PostFileSaveWindow1 + +D_PostFileSaveWindow2: + Push CS + Pop DS + Assume DS:Disk + + Mov DX, Offset SaveFileName + Call D_CheckOverWrite + JNC D_PostFileSaveWindow3 ; OK to write! + + Mov AX, 1 + Ret + +D_PostFileSaveWindow3: + Cmp SaveFormat, 1 + JE D_PostFileSaveWindow4 + + Jmp D_SaveFileITModule + +D_PostFileSaveWindow4: + Jmp D_SaveFileS3MModule + +EndP D_PostFileSaveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostFileLoadWindow Far + +; Cmp DX, 13 + Cmp CX, 11Ch + JNE D_PostFileWindow + ; Load file routines. + +D_PostFileLoadWindowLink: + EnsureNoNetwork + + Call PECheckModified + + Call Music_Stop + + Mov BX, CS:CurrentFile + Call D_LoadModuleHeader + JC D_PostFileLoadWindow1 + + Push DI + Call D_GetSongNameModuleType + Pop DI + +IF TUTORIAL +ELSE + Mov BX, CS:CurrentFile + Add BX, BX + Mov BX, [BX] + Mov AX, [BX+23] + + Cmp AX, 1 + JBE D_PostFileLoadWindow1 + + Cmp AX, 3 + JB D_LoadFileImpulseModule + JE D_PostFileLoadWindow1 + + Cmp AX, 5 + JB D_LoadFileS3MModule + JE D_LoadFileXMModule + + Cmp AX, 7 + JB D_LoadFile669Module + JE D_LoadFileImpulseModule + + Cmp AX, 8 + JBE D_PostFileLoadWindow1 + + Cmp AX, 17 + JBE D_LoadFileMODModule + + Cmp AX, 18 + JE D_LoadFileMTMModule +ENDIF + +D_PostFileLoadWindow1: + Mov AX, 1 + Ret + +EndP D_PostFileLoadWindow + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostFileWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset FileWindowKeys + Call M_FunctionDivider + JC D_PostFileWindow1 + + Jmp [SI] + +D_PostFileWindow1: + Cmp CX, 10Eh + JNE D_PostFileWindow15 + +D_PostFileWindowBackspace: + Mov BL, CurrentSearchPos + Test BL, BL + JZ D_PostFileWindow14 + + Dec BX + Xor BH, BH + Mov [Search+BX], 0 + Mov CurrentSearchPos, BL + +D_PostFileWindow14: + Mov AX, 1 + Ret + +D_PostFileWindow15: + Test CL, CL + JZ D_PostFileWindow20 + Cmp DL, 33 + JB D_PostFileWindow20 + + Cmp CurrentSearchPos, 13 + JAE D_PostFileWindow17 + + Cmp DL, 'a' + JB D_PostFileWindow16 + + Cmp DL, 'z' + JA D_PostFileWindow16 + + Sub DL, 32 + +D_PostFileWindow16: + Mov BL, CurrentSearchPos + Xor BH, BH + Mov [Search+BX], DL + + Inc CurrentSearchPos + ; Now do the search. + Xor DX, DX + + Mov ES, DiskDataArea + +D_PostFileWindow18: + Cmp DX, NumFiles + JAE D_PostFileWindow17 + + Mov BX, DX + Add BX, BX + Mov DI, [ES:BX] + Add DI, 8 + Mov SI, Offset Search + Mov CX, 13 + +D_PostFileWindow21: + Cmp Byte Ptr [DS:SI], 0 + JE D_PostFileWindow19 + + CmpsB + JE D_PostFileWindow21 + + Inc DX + Jmp D_PostFileWindow18 + +D_PostFileWindow19: + Mov CurrentFile, DX + +D_PostFileWindow17: + Mov AX, 1 + Ret + +D_PostFileWindow20: + Xor AX, AX + Ret + +EndP D_PostFileWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostDirectoryWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset DirectoryWindowKeys + Call M_FunctionDivider + JC D_PostDirectoryWindow1 + + Jmp [SI] + +D_PostDirectoryWindow1: + Cmp CX, 10Eh + JNE D_PostDirectoryWindow15 + + Jmp D_PostFileWindowBackspace + +D_PostDirectoryWindow15: + Test CL, CL + JZ D_PostDirectoryWindow20 + Cmp DL, 33 + JB D_PostDirectoryWindow20 + + Cmp CurrentSearchPos, 13 + JAE D_PostDirectoryWindow17 + + Cmp DL, 'a' + JB D_PostDirectoryWindow16 + + Cmp DL, 'z' + JA D_PostDirectoryWindow16 + + Sub DL, 32 + +D_PostDirectoryWindow16: + Mov BL, CurrentSearchPos + Xor BH, BH + Mov [Search+BX], DL + + Inc CurrentSearchPos + ; Now do the search. + Xor DX, DX + + Mov ES, DiskDataArea + +D_PostDirectoryWindow18: + Cmp DX, NumDirectories + JAE D_PostFileWindow17 + + Mov BX, DX + Add BX, NumFiles + Add BX, BX + Mov DI, [ES:BX] + Add DI, 8 + Mov SI, Offset Search + Mov CX, 13 + +D_PostDirectoryWindow21: + Cmp Byte Ptr [DS:SI], 0 + JE D_PostDirectoryWindow19 + + CmpsB + JE D_PostDirectoryWindow21 + + Inc DX + Jmp D_PostDirectoryWindow18 + +D_PostDirectoryWindow19: + Mov CurrentDirectory, DX + +D_PostDirectoryWindow17: + Mov AX, 1 + Ret + +D_PostDirectoryWindow20: + Xor AX, AX + Ret + +EndP D_PostDirectoryWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset DriveWindowKeys + Call M_FunctionDivider + JC D_PostDriveWindow1 + + Jmp [SI] + +D_PostDriveWindow1: + Xor AX, AX + Ret + +EndP D_PostDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostSaveDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset SaveDriveWindowKeys + Call M_FunctionDivider + JC D_PostSaveDriveWindow1 + + Jmp [SI] + +D_PostSaveDriveWindow1: + Xor AX, AX + Ret + +EndP D_PostSaveDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_NewSpecifier Far + + Push CS + Pop DS + Assume DS:Disk + + Xor BX, BX + Mov SI, Offset FileSpecifier + Mov Specific, 1 + +D_NewSpecifier3: + LodsB + And AL, AL + JZ D_NewSpecifier4 + + Cmp AL, '\' + JE D_NewSpecifier10 + Cmp AL, ':' + JE D_NewSpecifier10 + + Jmp D_NewSpecifier3 + +D_NewSpecifier10: + Mov BX, SI + Jmp D_NewSpecifier3 + +D_NewSpecifier4: + And BX, BX + JZ D_NewSpecifier5 + + Push ES + Push DI + + Push CS + Pop ES + + Mov SI, Offset FileSpecifier + Mov DI, Offset SongDirectory + +D_NewSpecifier7: + MovsB + Cmp SI, BX + JB D_NewSpecifier7 + + Xor AL, AL + Cmp Byte Ptr [DI-1], '\' + JNE D_NewSpecifier11 + + Dec DI + +D_NewSpecifier11: + StosB + + Mov DI, Offset FileSpecifier + +D_NewSpecifier6: + LodsB + StosB + And AL, AL + JNZ D_NewSpecifier6 + + Cmp DI, Offset FileSpecifier+1 + JNE D_NewSpecifier14 + + Mov Specific, 0 + +D_NewSpecifier14: + Pop DI + Pop ES + + +D_NewSpecifier5: + Mov CurrentFile, 0 + Call D_InitLoadModule2 + +D_NewSpecifier12: + Cmp NumFiles, 0 + JE D_NewSpecifier1 + + Mov Word Ptr [ES:DI], 12 + +D_NewSpecifier1: + Cmp Specific, 1 + JNE D_NewSpecifier2 + + Cmp NumFiles, 1 + JNE D_NewSpecifier2 + + Mov SI, Offset FileSpecifier + +D_NewSpecifier8: + LodsB + And AL, AL + JZ D_NewSpecifier9 + + Cmp AL, '*' + JE D_NewSpecifier2 + Cmp AL, '?' + JE D_NewSpecifier2 + Jmp D_NewSpecifier8 + +D_NewSpecifier9: + Jmp D_PostFileLoadWindowLink + +D_NewSpecifier2: + + Mov AX, 1 + Ret + +EndP D_NewSpecifier + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_NewDirectory Far + +; Mov SI, Offset SongDirectory +; Push CS +; Pop DS +; +; Call S_SetDriveDirectory + + Mov CurrentFile, 0 + Call D_InitLoadModule + + Cmp NumFiles, 0 + JE D_NewDirectory1 + + Mov Word Ptr [ES:DI], 12 + +D_NewDirectory1: + Mov AX, 1 + Ret + +EndP D_NewDirectory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_ClearFileSpecifier Far + + Push ES + Push DI + Push AX + Push CX + + Push CS + Pop ES + Mov DI, Offset FileSpecifier + Xor AX, AX + Mov CX, 65 + Rep StosB + + Pop CX + Pop AX + Pop DI + Pop ES + + Ret + +EndP D_ClearFileSpecifier + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveModule Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset FileSpecifier + Cmp Byte Ptr [SI], 0 + JNE D_SaveModule9 + + Call D_NewSpecifier + Call D_ClearFileSpecifier + + Mov AX, 1 + Ret + +D_SaveModule9: + Push CS + Pop ES + Xor BX, BX + +D_SaveModule1: + LodsB + And AL, AL + JZ D_SaveModule3 + + Cmp AL, '?' + JE D_NewSpecifier + Cmp AL, '*' + JE D_NewSpecifier + Cmp AL, ':' + JE D_SaveModule2 + Cmp AL, '\' + JE D_SaveModule2 + + Jmp D_SaveModule1 + +D_SaveModule2: + Mov BX, SI + Jmp D_SaveModule1 + +D_SaveModule3: + And BX, BX + JZ D_SaveModule7 + + Mov SI, Offset FileSpecifier + Mov DI, Offset SongDirectory + +D_SaveModule4: + MovsB + Cmp SI, BX + JB D_SaveModule4 + + Xor AL, AL + Cmp Byte Ptr [DI-1], '\' + JNE D_SaveModule5 + + Dec DI + +D_SaveModule5: + StosB + + Mov DI, Offset FileSpecifier + +D_SaveModule6: + LodsB + StosB + And AL, AL + JNZ D_SaveModule6 + +D_SaveModule7: ; Time to save a module. + Mov DI, Offset SaveFileName + Mov SI, Offset FileSpecifier + +D_SaveModule8: + LodsB + StosB + And AL, AL + JNZ D_SaveModule8 + + ; FileName contains file to + ; save + Mov SI, Offset SongDirectory + Call D_SetDriveDirectory + + Mov SI, Offset SaveFileName + Xor BX, BX + +D_SaveModule10: + LodsB + Cmp AL, '.' + JNE D_SaveModule11 + + Mov BX, SI + +D_SaveModule11: + And AL, AL + JNZ D_SaveModule10 + + And BX, BX + JNZ D_SaveModule12 + + Cmp SaveFormat, 1 + JE D_SaveModule13 + + Mov Word Ptr [SI-1], 'I.' + Mov Word Ptr [SI+1], 'T' + Jmp D_PostFileSaveWindow2 + +D_SaveModule13: + Mov Word Ptr [SI-1], 'S.' + Mov Word Ptr [SI+1], 'M3' + Mov Byte Ptr [SI+3], 0 + +D_SaveModule12: + Jmp D_PostFileSaveWindow2 +; Jmp D_SaveFileITModule + +EndP D_SaveModule + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_NoSaveMessage Far + + Call S_SaveScreen + + Mov DI, Offset O1_UnableToSaveList + Mov CX, 2 + Call M_Object1List + + Call S_RestoreScreen + + Mov AX, 1 + Ret + +EndP D_NoSaveMessage + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveBlock ; DS:DX points to buffer + ; BX = file handle + ; CX = number of bytes + + JCXZ D_SaveBlock3 + + Cmp CS:NoSaveError, 1 + JE D_SaveBlock2 + + Mov AH, 40h + Int 21h + JC D_SaveBlock1 + Cmp CX, AX + JNE D_SaveBlock1 + +D_SaveBlock3: + Ret + +D_SaveBlock2: + Mov AX, CX + StC + Ret + +D_SaveBlock1: + PushAD + Push DS + Push ES + + Call D_NoSaveMessage + + Pop ES + Pop DS + PopAD + + Mov CS:NoSaveError, 1 + StC + + Ret + +EndP D_SaveBlock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DeleteIfError ; DS:DX = filename + + PushF + + Cmp CS:NoSaveError, 0 + JE D_DeleteIfError1 + + PushA + + Mov AH, 41h + Int 21h + + PopA + +D_DeleteIfError1: + PopF + Ret + +EndP D_DeleteIfError + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_UpdateFileName + + Push CS + Push CS + Pop DS + Pop ES + + Mov SI, Offset SaveFileName + Mov DI, Offset FileName + ; Scan through file name first. + Mov BX, SI + +D_UpdateFileName1: + LodsB + And AL, AL + JZ D_UpdateFileName2 + + Cmp AL, ':' + JE D_UpdateFileName3 + Cmp AL, '\' + JNE D_UpdateFileName1 + +D_UpdateFileName3: + Mov BX, SI + Jmp D_UpdateFileName1 + +D_UpdateFileName2: + Mov SI, BX + Add BX, 8 + +D_UpdateFileName4: + LodsB + StosB + + Cmp AL, '.' + JE D_UpdateFileName5 + + And AL, AL + JZ D_UpdateFileNameEnd + + Cmp SI, BX + JBE D_UpdateFileName4 + +D_UpdateFileName5: + Mov BX, SI + Add BX, 3 + +D_UpdateFileName6: + LodsB + StosB + + And AL, AL + JZ D_UpdateFileNameEnd + + Cmp SI, BX + JBE D_UpdateFileName6 + +D_UpdateFileNameEnd: + Ret + +EndP D_UpdateFileName + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include it_d_wm.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_InitLoadSamples Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset SampleDirectory + Call D_SetDriveDirectory ; DS:SI points to cur dir. + + Cmp SamplesInModule, 0 + JE D_InitLoadSamples4 + + Jmp LSWindow_EnterLoadInSampleData + +D_InitLoadSamples4: + Mov LoadSampleNameCount, 0 + Mov NumSamples, 0 + Mov SampleInMemory, 0FFFFh + Mov SampleCheck, 0FFFFh + Mov SampleCacheFileComplete, 0 + + ; First attempt to delete + ; ST3's cache file.. + Mov DX, Offset ST3CacheFileName + Mov AH, 41h + Int 21h + + ; First check for cache file. + Mov OldCacheTime, 0 + + Mov AX, 3D00h ; Open file.. + Mov DX, Offset SampleCacheFileName + Int 21h + JC D_InitLoadSamples1 ; Can't open file? + + Mov BX, AX + + Mov AH, 3Fh + Mov CX, 4 ; Integer containing number + ; of sample entries... + Mov DS, DiskDataArea + Assume DS:Nothing + + Xor DX, DX + Int 21h + JC D_InitLoadSamples3 + Cmp AX, CX + JNE D_InitLoadSamples3 + + Mov AL, [CS:SampleDirectory] ; AL = drive letter + Cmp AL, [CS:CDRomStartDrive] + JL SampleVersionCheck + Cmp AL, [CS:CDRomEndDrive] + JGE SampleVersionCheck + + Cmp Word Ptr [DS:2], 211h + JB D_InitLoadSamples3 + Cmp Word Ptr [DS:2], TRACKERVERSION + JBE D_InitLoadSampleCacheFileOK + +SampleVersionCheck: + Cmp Word Ptr [DS:2], TRACKERVERSION + JNE D_InitLoadSamples3 + +VersionCheckEnd: + Mov AX, 5700h ; Get file date&time. + Int 21h + + Mov Word Ptr [OldCacheTime], CX + Mov Word Ptr [OldCachetime+2], DX + + Cmp CX, Time ; Check time and date + JNE D_InitLoadSamplesOldCache ; for 'currentness' + Cmp DX, Date + JNE D_InitLoadSamplesOldCache + ; OK.. let's load... + +D_InitLoadSampleCacheFileOK: + Mov SI, [DS:0] ; Number of samples. + Mov AX, 96 + Mul SI + Mov CX, AX ; Bytes to read. + + Mov AH, 3Fh ; Load again. + Xor DX, DX ; In case of internal malfunc. + Int 21h + JC D_InitLoadSamples3 + Cmp AX, CX + JNE D_InitLoadSamples3 + + Mov AH, 3Eh ; Close file. + Int 21h + + Push CS + Pop DS + Assume DS:Disk + + Mov LoadSampleNameCount, SI + Mov NumSamples, SI + Mov SampleCacheFileComplete, 1 + + Jmp D_InitLoadSamples2 + +D_InitLoadSamplesOldCache: + PushA + Push DS + + Call D_GetNumFiles ; Returns number of files + ; and directories, + ; carry if newer file exists. + Pop DS + JC D_InitLoadSamples5 + + Cmp AX, [DS:0] + + PopA + + JNE D_InitLoadSamples3 + + Call Far Ptr D_InitLoadSampleCacheFileOK + + Call D_SaveSampleCacheFile ; Resave it with new date + + Ret + +D_InitLoadSamples5: + PopA + +D_InitLoadSamples3: + Mov AH, 3Eh ; Close file. + Int 21h + + Push CS + Pop DS + Assume DS:Disk + + Call DeleteSampleCacheFile + +D_InitLoadSamples1: + Call D_LoadSampleFiles + +D_InitLoadSamples2: + Ret + +EndP D_InitLoadSamples + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DeleteSampleCacheFile + + Push DS + + Push CS + Pop DS + + Mov AH, 41h + Mov DX, Offset SampleCacheFileName + Int 21h + + Pop DS + + Ret + +EndP DeleteSampleCachefile + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DeleteInstrumentCacheFile + + Push DS + + Push CS + Pop DS + + Mov AH, 41h + Mov DX, Offset InstrumentCacheFileName + Int 21h + + Pop DS + + Ret + +EndP DeleteInstrumentCachefile + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GetNumFiles ; DS = DiskDaraArea + + Mov DS, CS:DiskDataArea + + Mov DX, 64000 ; Set DTA to DS:64000 + Mov AH, 1Ah + Int 21h + + Push CS + Pop DS + + Mov DX, Offset AllFilesMask + Mov CX, 10h + Mov AH, 4Eh + Int 21h + + Mov DS, CS:DiskDataArea + JC D_GetNumFilesError + + Xor AX, AX ; No samples/directories to + ; start off with. + +D_GetNumFiles1: + Test Byte Ptr [DS:64000+15h], 10h + JZ D_GetNumFiles2 + + Mov EDX, DWord Ptr [CS:OldCacheTime] + Cmp [DS:64000+16h], EDX ; Newer file? + JA D_GetNumFilesError + + Inc AX + +D_GetNumFiles2: + Push AX + Mov AH, 4Fh + Int 21h + Pop AX + JNC D_GetNumFiles1 + ; Directories done.. files now + Push AX + + Push CS + Pop DS + Mov DX, Offset AllFilesMask + Xor CX, CX + Mov AH, 4Eh + Int 21h + + Mov DS, CS:DiskDataArea + + Pop AX + JC D_GetNumFilesFinished + + Push CS + Pop ES + +D_GetNumFiles3: + Mov SI, 64000+1Eh + Mov DI, Offset SampleCacheFileName + Mov CX, 9 + RepE CmpsB + JE D_GetNumFiles4 + + Mov SI, 64000+1Eh + Mov DI, Offset InstrumentCacheFileName + Mov CX, 9 + RepE CmpsB + JE D_GetNumFiles4 + + Mov EDX, DWord Ptr [CS:OldCacheTime] + Cmp [DS:64000+16h], EDX ; Newer file? + JA D_GetNumFilesError + +D_GetNumFiles4: + Inc AX + + Push AX + Mov AH, 4Fh + Int 21h + Pop AX + JNC D_GetNumfiles3 + + Dec AX + +D_GetNumFilesFinished: + ClC + Ret + +D_GetNumFilesError: + Xor AX, AX + StC + Ret + + +EndP D_GetNumFiles + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadSampleFiles + + Mov DS, CS:DiskDataArea + Push DS + Pop ES + + Xor DI, DI + Xor AX, AX + Mov CX, 32768 + Rep StosW + + Mov DX, 64000 + Mov AH, 1Ah + Int 21h ; Shift DTA address.. + ; to DiskDataArea:64000 + + Xor DI, DI + + Push CS + Pop DS + Mov DX, Offset AllFilesMask + Mov CX, 10h + Mov AH, 4Eh + Int 21h + + Mov DS, CS:DiskDataArea + Push DS + Pop ES + + JC D_LoadSampleFiles2 + +D_LoadSampleFiles1: ; A directory was found! + Test Byte Ptr [DS:64000+15h], 10h + JZ D_LoadSampleFiles5 ; Check that it IS a directory + + Cmp Word Ptr [DS:64000+1Eh], '.' + JNE D_LoadSampleFilesNoRoot + + Mov Byte Ptr [DS:64000+1Eh], '\' + +D_LoadSampleFilesNoRoot: + Mov DL, 1 + Call Near Ptr D_LoadSampleFiles6 + + Inc CS:NumSamples + Inc CS:LoadSampleNameCount + + Cmp CS:NumSamples, 620 + JAE D_LoadSampleFiles4 + +D_LoadSampleFiles5: + Mov AH, 4Fh + Int 21h + JNC D_LoadSampleFiles1 + +D_LoadSampleFiles2: ; Directories done.. samples now + Push CS + Pop DS + Mov DX, Offset AllFilesMask + Xor CX, CX + Mov AH, 4Eh + Int 21h + + Mov DS, CS:DiskDataArea + Push DS + Pop ES + + JC D_LoadSampleFiles4 + +D_LoadSampleFiles3: + Mov DL, 0 + Call Near Ptr D_LoadSampleFiles6 + + Inc CS:NumSamples + Cmp CS:NumSamples, 620 + JAE D_LoadSampleFiles4 + +D_LoadSampleFilesNext: + Mov AH, 4Fh + Int 21h + JNC D_LoadSampleFiles3 + +D_LoadSampleFiles4: ; End! + + Ret + +D_LoadSampleFiles6: ; Get name/size/date/time. + Add DI, 4 + Mov SI, 64000+1Eh + Mov CX, 13 + Rep MovsB + + Cmp DL, 1 + JNE D_LoadSampleFiles7 + + Xor AX, AX + StosB + StosW + + Push DS + Push CS + Pop DS + Mov SI, Offset DirectoryMsg + Mov CX, 25 + Rep MovsB + + Pop DS + + Mov CX, 35 + Jmp D_LoadSampleFiles8 + +D_LoadSampleFiles7: + Mov CX, 63 + +D_LoadSampleFiles8: + Xor AL, AL + Rep StosB + + Mov EAX, [DS:64000+1Ah] + StosD + Mov AX, [DS:64000+18h] + StosW + Mov AX, [DS:64000+16h] + StosW + Mov AL, DL + StosB + Mov CX, 7 + Xor AL, AL + Rep StosB + + RetN + +EndP D_LoadSampleFiles + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DrawLoadSampleWindow Far ; Has to handle + ; 1) Sample list + ; 2) Sample info box + ; 3) WaveForm stuff + + + Cmp CS:NumSamples, 0 + JNE D_DrawLoadSampleWindow4 + + Push CS + Pop DS + + Call S_GetDestination + Mov DI, (6+13*80)*2 ; (6, 13) + Mov SI, Offset NoFilesMsg + + Mov AH, 5 + Call S_DrawString + + Ret + +D_DrawLoadSampleWindow4: + Mov BX, CS:CurrentSample + Mov AX, 96 + Mul BX + Mov SI, AX + Mov ES, CS:DiskDataArea + + Cmp Byte Ptr [ES:SI+88], 0 + JNE D_DrawLoadSampleWindow28 + + Push SI + + Call D_LoadSampleHeader + Call D_GetSampleInfo + + Pop SI + +D_DrawLoadSampleWindow28: + Mov BX, CS:CurrentSample + Cmp BX, CS:SampleCheck + JE D_DrawLoadSampleWindow31 + + Mov CS:SampleCheck, BX + Push CS + Pop ES + Mov DI, Offset CheckDataArea + Mov DS, CS:DiskDataArea + Mov CX, 96 + Rep MovsB + +D_DrawLoadSampleWindow31: + Push CS + Pop DS + Assume DS:Disk + + Call S_GetDestination + + Mov AX, TopSample + Mov BX, CurrentSample + Cmp AX, BX + JBE D_DrawLoadSampleWindow1 + + Mov AX, BX + +D_DrawLoadSampleWindow1: + LEA CX, [EAX+34] + Cmp CX, BX + JA D_DrawLoadSampleWindow2 + + LEA AX, [BX-34] + +D_DrawLoadSampleWindow2: + Mov TopSample, AX + Mov BX, AX + + Push AX + + Mov DI, (31+13*80)*2 + Mov CX, 35 + Mov AX, 2A8h + +D_DrawLoadSampleWindow5: ; Divider... + StosW + Add DI, 158 + Loop D_DrawLoadSampleWindow5 + + Pop AX + + Mov DX, NumSamples + ; Put numbers of screen first. + Mov DI, (2+13*80)*2 ; (2,13) + Mov CX, 2000h+35 ; Colour and loop count. + +D_DrawLoadSampleWindow3: + Inc AX + Push DI + + Call PE_ConvAX2Num + + Pop DI + Add DI, 160 + Cmp AX, DX ; DX = NumSamples + JAE D_DrawLoadSampleWindow9 + + Dec CL + JNZ D_DrawLoadSampleWindow3 + +D_DrawLoadSampleWindow9: + Mov DS, DiskDataArea + Assume DS:Nothing + Mov AX, 96 + Mul BX + Mov SI, AX ; SI = offset of first sample. + + Mov DX, 35 ; DX = Number of rows to show. + ; BX = sample num + + Mov DI, (6+13*80)*2 + +D_DrawLoadSampleWindow6: + Push BX + Push DX + Push SI + Push DI + ; Colour.... + Mov AL, [DS:SI+88] ; AL = type. 0 = not loaded. + ; 1=dir + ; 2=it sample + ; 3=scrm sample. + ; 4=unknown + ; 5=8 bit mono wave + Mov AH, 6 + Cmp AL, 1 + JB D_DrawLoadSampleWindow7 + + Mov AH, 5 + JE D_DrawLoadSampleWindow7 + + Mov AH, 3 + Cmp AL, 4 + JNE D_DrawLoadSampleWindow7 + + Mov AH, 2 + +D_DrawLoadSampleWindow7: ; AH = colour. + Push SI + + Add SI, 14h + + Mov CX, 25 + +D_DrawLoadSampleWindow50: + LodsB + + Cmp AL, 226 + JB D_DrawLoadSampleCharFilter + + Mov AL, ' ' + +D_DrawLoadSampleCharFilter: + StosW + Loop D_DrawLoadSampleWindow50 + + Xor AL, AL + Rep StosW + + Pop SI + +; Add DI, 2 + ScasW + Add SI, 4 + + Mov CX, 12 + +D_DrawLoadSampleWindow51: + LodsB + StosW + And AL, AL + LoopNZ D_DrawLoadSampleWindow51 + + Xor AL, AL + Rep StosW + + Pop DI + Pop SI + Pop DX + Pop BX + + Add SI, 96 ; Advance to next sample. + Add DI, 160 ; Advance to next line on screen + + Inc BX + Cmp BX, CS:NumSamples + JAE D_DrawLoadSampleWindow8 + + Dec DX + JNZ D_DrawLoadSampleWindow6 + +D_DrawLoadSampleWindow8: ; Length + Mov AX, 96 + Mul CS:CurrentSample + + Mov SI, AX + + Push DS + Push SI + + Push DWord Ptr [DS:SI+30h] + + Test Byte Ptr [DS:SI+2Eh], 32 ; Stereo? + JZ D_DrawLoadSampleWindowNoStereo + + Test Byte Ptr [DS:SI+12h], 2 + Mov SI, Offset Quality8StereoMsg + + Push CS + Pop DS + JZ D_DrawLoadSampleWindowBitMsg + + Mov SI, Offset Quality16StereoMsg + Jmp D_DrawLoadSampleWindowBitMsg + +D_DrawLoadSampleWindowNoStereo: + Test Byte Ptr [DS:SI+12h], 2 + Mov SI, Offset Quality8Msg + + Push CS + Pop DS + JZ D_DrawLoadSampleWindowBitMsg + + Mov SI, Offset Quality16Msg + +D_DrawLoadSampleWindowBitMsg: + Mov DI, (21*80+64)*2 + Mov AH, 2 + Call S_DrawString + + Mov SI, Offset LengthMsg + Mov DI, (22*80+64)*2 + Call S_DrawString + Pop EAX + + Pop SI + Pop DS + +D_DrawLoadSampleWindow30: + ; Now for infobox. + Mov BL, [DS:SI+88] ; BL = type. + Push DS + Push SI + + Push CS + Pop DS + Xor BH, BH + Add BX, BX + Mov SI, [SampleFormatNames+BX] + Mov DI, (53+44*80)*2 + Mov AH, 5 + Call S_DrawString + + Pop SI + Pop DS + + Push SI + + Mov DX, [DS:SI+82] + Mov AX, [DS:SI+80] + Cmp DX, 10000 + + JAE D_DrawLoadSampleWindow13 + + Mov DI, (53+45*80)*2 + + Mov CX, 10000 + Div CX ; DX = remainder. AX = main. + + Mov BP, AX + + Mov CX, 4 + Mov SI, 10 + Mov AX, DX + +D_DrawLoadSampleWindow10: + Xor DX, DX + Div SI + Add DL, '0' + Push DX + + Loop D_DrawLoadSampleWindow10 + + Mov AX, BP + + Mov CX, 5 + +D_DrawLoadSampleWindow11: + Xor DX, DX + Div SI + Add DL, '0' + Push DX + + Loop D_DrawLoadSampleWindow11 + + Mov CX, 9 + +D_DrawLoadSampleWindow12: + Pop AX + Mov AH, 5 + StosW + Loop D_DrawLoadSampleWindow12 + +D_DrawLoadSampleWindow13: + Pop SI + + Mov DX, [DS:SI+86] ; DX = time + Mov BX, [DS:SI+84] ; BX = date + + Push CS + Pop DS + + Mov DI, (53+46*80)*2 + Mov AX, BX + ShR AX, 5 + And AX, 0Fh + Mov SI, AX + Add SI, SI + Mov SI, [MonthNames+SI] + + Mov AH, 5 + +D_DrawLoadSampleWindow19: + LodsB + StosW + And AL, AL + JNZ D_DrawLoadSampleWindow19 + + Mov AL, BL + And AX, 31 + Mov CH, 10 + Div CH + And AL, AL + JZ D_DrawLoadSampleWindow20 + + Push AX + Add AL, '0' + Mov AH, 5 + StosW + + Pop AX + +D_DrawLoadSampleWindow20: + Mov AL, AH + Add AL, '0' + Mov AH, 5 + StosW + + Mov AL, ',' + StosW + + Mov AL, ' ' + StosW + + Push DX + Mov AL, BH + ShR AX, 1 + And AX, 7Fh + Add AX, 1980 + Mov DX, 0FFFFh + Push DX + + Mov SI, 10 + +D_DrawLoadSampleWindow21: + Xor DX, DX + Div SI + Add DL, '0' + Push DX + + And AX, AX + JNZ D_DrawLoadSampleWindow21 + +D_DrawLoadSampleWindow22: + Pop AX + Cmp AX, 0FFFFh + JE D_DrawLoadSampleWindow23 + + Mov AH, 5 + StosW + + Jmp D_DrawLoadSampleWindow22 + +D_DrawLoadSampleWindow23: + Pop DX + Mov DI, (53+47*80)*2 + + Mov AX, DX + ShR AX, 11 + + Xor BL, BL ; if BL = 0, then am, otherwise + ; pm.. + Cmp AX, 12 + JB D_DrawLoadSampleWindow24 + + Inc BX + Sub AX, 12 + +D_DrawLoadSampleWindow24: + And AX, AX + JNZ D_DrawLoadSampleWindow25 + + Add AX, 12 + +D_DrawLoadSampleWindow25: + Mov BH, 10 + Div BH + And AL, AL + JZ D_DrawLoadSampleWindow26 + + Push AX + Add AL, '0' + Mov AH, 5 + StosW + + Pop AX + +D_DrawLoadSampleWindow26: + Mov AL, AH + Add AL, '0' + Mov AH, 5 + StosW + + Mov AL, ':' + StosW + + Mov AX, DX + ShR AX, 5 + And AX, 63 + + Div BH + Mov BH, AH + + Add AL, '0' + Mov AH, 5 + StosW + + Mov AL, BH + Add AL, '0' + StosW + + Mov AL, 'a' + And BL, BL + JZ D_DrawLoadSampleWindow27 + + Mov AL, 'p' + +D_DrawLoadSampleWindow27: + StosW + Mov AL, 'm' + StosW + + Push CS ; Wave form shit.. + Pop DS + Assume DS:Disk + + Mov AX, CurrentSample + Cmp AX, SampleInMemory + JNE D_DrawLoadSampleWindow54 + + Mov DI, (46+25*80)*2 + Mov DX, 4 + Mov AX, 0D00h + +D_DrawLoadSampleWindow55: + Mov CX, 31 + +D_DrawLoadSampleWindow56: + StosW + Inc AX + Loop D_DrawLoadSampleWindow56 + + Add DI, 160-31*2 + Dec DX + JNZ D_DrawLoadSampleWindow55 + +D_DrawLoadSampleWindow54: + Ret + +EndP D_DrawLoadSampleWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PreLoadSampleWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov AX, CurrentSample + Sub AX, TopSample + Add AX, 13 + Mov BX, 160 + Mul BX + + Call S_GetDestination + + LEA DI, [EAX+12] + Mov CX, 38 + +D_PreLoadSample1: + Mov AX, [ES:DI] + Cmp CX, 13 + + JNE D_PreLoadSample2 + + Mov AH, 32h + Jmp D_PreLoadSample3 + +D_PreLoadSample2: + Mov AH, 30h + +D_PreLoadSample3: + StosW + + Loop D_PreLoadSample1 + + Ret + +EndP D_PreLoadSampleWindow + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostLoadSampleWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset LSWindowKeys + Call M_FunctionDivider + JC D_PostLoadSampleWindow1 + + Jmp [SI] + +D_PostLoadSampleWindow1: ; Time to check for play keys. + Mov SI, Offset KeyBoardTable + Test CH, Not 1 + JNZ D_PostLoadSampleWindow3 + + Cmp CX, LastKey + JE D_PostLoadSampleWindow3 + + Mov LastKey, CX + +D_PostLoadSampleWindow2: + LodsW + Cmp AX, 0FFFFh + JE D_PostLoadSampleWindow3 + + Mov BX, AX + LodsW + + Cmp BL, CL + JNE D_PostLoadSampleWindow2 + ; Note to play... + ; AX = notemod. + And CH, CH + JZ D_PostLoadSampleWindow5 + + + Mov BX, AX + + Mov CX, Pattern + Mov DS, CX + Assume DS:Pattern + + Mov AL, 12 + Mul BaseOctave + + Push CS + Pop DS + Assume DS:Disk + + Add AX, BX + Cmp AX, 119 + JA D_PostLoadSampleWindow4 ; If note > B-9... don't play! + + Push AX + + Mov AX, 96 + Mul CurrentSample + Mov SI, AX + + Mov DisableStereoMenu, 1 + + Mov DS, DiskDataArea + Mov AX, 99 + Call LoadSample + + Mov CS:DisableStereoMenu, 0 + + Pop AX + JC D_PostLoadSampleWindow4 + + ; AX = note. Ins = 99. + Mov AH, 100 + Xor CX, CX + Call Music_PlaySample + Jmp D_PostLoadSampleWindow4 + +D_PostLoadSampleWindow5: + Xor AX, AX + Mov SI, Offset NoteData + Mov DH, 32 + Call Music_PlayNote + +D_PostLoadSampleWindow4: + Mov AX, 1 + Ret + +D_PostLoadSampleWindow3: + Xor AX, AX + Ret + +EndP D_PostLoadSampleWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostViewSampleLibrary Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset LSViewWindowKeys + Call M_FunctionDivider + JC D_PostLoadSampleWindow1 + + Jmp [SI] + +EndP D_PostViewSampleLibrary + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LSDrawDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Call S_GetDestination + + Mov AL, TopDrive + Mov BL, CurrentDrive + Cmp AL, BL + JBE D_LSDrawDriveWindow1 + + Mov AL, BL + +D_LSDrawDriveWindow1: + Mov CL, AL + Add CL, 9 + Cmp CL, BL + JA D_LSDrawDriveWindow2 + + Mov AL, BL + Sub AL, 9 + +D_LSDrawDriveWindow2: + Mov TopDrive, AL + Mov BL, AL + Mov CX, 10 + + Mov DI, (46+13*80)*2 + Xor BH, BH + +D_LSDrawDriveWindow3: + Cmp BL, NumDrives + JAE D_LSDrawDriveWindow5 + + Push DI + + Mov AL, [DrivesAvail+BX] + Add AL, 'A' + Mov SI, Offset DriveMsg + Mov [SI+6], AL + + Mov AH, 5 + Mov DX, 8 + +D_LSDrawDriveWindow4: + LodsB + StosW + + Dec DX + JNZ D_LSDrawDriveWindow4 + + Pop DI + Add DI, 160 + Inc BX + Loop D_LSDrawDriveWindow3 + +D_LSDrawDriveWindow5: + Ret + +EndP D_LSDrawDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LSPreDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov AL, CurrentDrive + Sub AL, TopDrive + Add AL, 13 + Mov AH, 160 + Mul AH + + Call S_GetDestination + LEA DI, [EAX+92] + Mov CX, 8 + +D_LSPreDriveWindow1: + Mov AX, [ES:DI] + Mov AH, 30h + StosW + + Loop D_LSPreDriveWindow1 + + Ret + +EndP D_LSPreDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LSPostDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset LSDriveWindowKeys + Call M_FunctionDivider + JC D_LSPostDriveWindow1 + + Jmp [SI] + +D_LSPostDriveWindow1: + Xor AX, AX + Ret + +EndP D_LSPostDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LIDrawDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Call S_GetDestination + + Xor AL, AL + Xor BX, BX + + Mov CX, 32 + + Mov DI, (64+16*80)*2 + +D_LIDrawDriveWindow3: + Cmp BL, NumDrives + JAE D_LIDrawDriveWindow5 + + Push DI + + Mov AL, [DrivesAvail+BX] + Add AL, 'A' + Mov SI, Offset DriveMsg + Mov [SI+6], AL + + Mov AH, 5 + Mov DX, 8 + +D_LIDrawDriveWindow4: + LodsB + StosW + + Dec DX + JNZ D_LIDrawDriveWindow4 + + Pop DI + Add DI, 160 + Inc BX + Loop D_LIDrawDriveWindow3 + +D_LIDrawDriveWindow5: + Ret + +EndP D_LIDrawDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LIPreDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov AL, CurrentDrive + Add AL, 16 + Mov AH, 160 + Mul AH + Mov DI, AX + + Call S_GetDestination + Add DI, 64*2 + Mov CX, 8 + +D_LIPreDriveWindow1: + Mov AX, [ES:DI] + Mov AH, 30h + StosW + + Loop D_LIPreDriveWindow1 + + Ret + +EndP D_LIPreDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LIPostDriveWindow Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset LIDriveWindowKeys + Call M_FunctionDivider + JC D_LIPostDriveWindow1 + + Jmp [SI] + +D_LIPostDriveWindow1: + Xor AX, AX + Ret + +EndP D_LIPostDriveWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadSampleHeader ; Given BX = sample number. + + Push BX + + Mov DS, DiskDataArea + Assume DS:Nothing + + Mov AX, 96 + Mul BX + LEA SI, [EAX+4] + + Call D_LoadFileHeader + + Pop BX + + Ret + +EndP D_LoadSampleHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadInstrumentHeader ; Given BX = instrument num + + Push BX + + Mov DS, DiskDataArea + Assume DS:Nothing + + Mov AX, 48 + Mul BX + Mov SI, AX + Inc SI + + Call D_LoadFileHeader + + Pop BX + + Ret + +EndP D_LoadInstrumentHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include it_d_inf.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveSampleCacheFile ; Assumes DS=Disk + + Push CS + Pop DS + + Assume DS:Disk + + Test DiskOptions, 2 + JNZ D_SaveSampleCacheFile1 + + Cmp SamplesInModule, 0 + JNE D_SaveSampleCacheFile1 + + Mov AH, 3Ch ; create file. + Xor CX, CX ; normal file + Mov DX, Offset SampleCacheFileName + Int 21h + JC D_SaveSampleCacheFile1 + + Mov BX, AX ; BX = file handle + + Mov AH, 40h ; Write to file + Mov CX, 4 ; Word size + Mov DX, Offset NumSamples + Int 21h + + Mov AX, 96 + Mul NumSamples + Mov CX, AX ; CX = num bytes to write. + Mov AH, 40h + Xor DX, DX + Mov DS, DiskDataArea + Assume DS:Nothing + Int 21h ; Write cache file! + + ; Set date and time... + Mov AX, 5701h + Mov CX, CS:Time + Mov DX, CS:Date + Int 21h + + Mov AH, 3Eh ; Close file handle + Int 21h + + Push CS + Pop DS + Assume DS:Disk + +D_SaveSampleCacheFile1: + Mov SampleCacheFileComplete, 1 + + Ret + +EndP D_SaveSampleCacheFile + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveInstrumentCacheFile ; Assumes DS=Disk + + Push CS + Pop DS + Assume DS:Disk + + Test DiskOptions, 2 + JNZ D_SaveInstrumentCacheFile1 + + Mov AH, 3Ch ; create file. + Xor CX, CX ; normal file + Mov DX, Offset InstrumentCacheFileName + Int 21h + JC D_SaveInstrumentCacheFile1 + + Mov BX, AX ; BX = file handle + + Mov AH, 40h ; Write to file + Mov CX, 6 ; Word size + Mov DX, Offset InitialInstruments + Int 21h + + Mov AX, 48 + Mul NumInstruments + Mov CX, AX ; CX = num bytes to write. + Mov AH, 40h + Xor DX, DX + Mov DS, DiskDataArea + Assume DS:Nothing + + Int 21h ; Write cache file! + + ; Set date and time... + Mov AX, 5701h + Mov CX, CS:Time + Mov DX, CS:Date + Int 21h + + Mov AH, 3Eh ; Close file handle + Int 21h + + Push CS + Pop DS + Assume DS:Disk + +D_SaveInstrumentCacheFile1: + Mov InstrumentCacheFileComplete, 1 + + Ret + +EndP D_SaveInstrumentCacheFile + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadSampleNames Far + + Push CS + Pop DS + Assume DS:Disk + + Cmp SampleCacheFileComplete, 1 + JNE D_LoadSampleNames2 + +D_LoadSampleNames6: + Xor AX, AX ; No redraw screen. + Ret + +D_LoadSampleNames2: + Mov BX, LoadSampleNameCount + Cmp BX, NumSamples + JAE D_LoadSampleNames5 + +D_LoadSampleNames1: + Call K_IsAnyKeyDown + And AL, AL + JNZ D_LoadSampleNames6 + + Call GetKeyboardLock + And AL, AL + JNZ D_LoadSampleNames6 + + Mov AX, 96 + Mul BX + Mov SI, AX + Mov ES, DiskDataArea + Cmp Byte Ptr [ES:SI+88], 0 + JNE D_LoadSampleNames3 + + Call D_LoadSampleHeader + JC D_LoadSampleNames3 + + Call D_GetSampleInfo ; BX = sample number + +D_LoadSampleNames3: + Push CS + Pop DS + Assume DS:Disk + + Inc LoadSampleNameCount + Mov BX, LoadSampleNameCount + Cmp BX, NumSamples + JNE D_LoadSampleNames4 + ; Save cache file.. + +D_LoadSampleNames5: + Call D_SaveSampleCacheFile + Cmp CurrentSample, 0 + JNE D_LoadSampleNames4 + Call D_SlowSampleSort + +D_LoadSampleNames4: + Mov AX, 1 ; Signify redraw screen + Ret + +EndP D_LoadSampleNames + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GetLoadSampleVars Far ; Returns SI with offset of + + Push AX + Push DX + + Mov AX, 96 + Mul CS:CurrentSample + Mov SI, AX + Mov DS, CS:DiskDataArea + + Pop DX + Pop AX + + Ret + +EndP D_GetLoadSampleVars + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GotoStartingDirectory Far + + Push DS + Push CS + Pop DS + + Mov SI, Offset StartingDirectory + Call D_SetDriveDirectory + Pop DS + + Ret + +EndP D_GotoStartingDirectory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveDirectoryConfiguration Far + + Push CS + Pop DS + Assume DS:Disk + + Mov NoSaveError, 0 + Mov CountryTableConfig, 0 + + Mov SI, Offset StartingDirectory + Call D_SetDriveDirectory + + Mov AH, 3Ch + Xor CX, CX + Mov DX, Offset ConfigFileName + Int 21h + JC D_SaveDirectoryConfiguration1 + + Mov BX, AX + + Mov CX, 211 + Mov DX, Offset SongDirectory + Call D_SaveBlock + + Call S_GetPaletteOffset ; Into DS:DX + Mov CX, 3*16 + Call D_SaveBlock + + Call Display_GetDisplayWindowData + Mov CX, 50 + Call D_SaveBlock + + Call PE_GetPatternConfigOffset + Mov CX, 218 + Call D_SaveBlock + + Call I_GetPresetEnvelopeOffset + Mov CX, 810 + Call D_SaveBlock + + Mov AH, 3Eh + Int 21h + +D_SaveDirectoryConfiguration1: + Mov AX, 1 + Ret + +EndP D_SaveDirectoryConfiguration + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_Up Far + + Assume DS:Disk + + Mov AX, CurrentFile + And AX, AX + JZ FileWindow_Up1 + + Dec CurrentFile + +FileWindow_Up1: + Mov AX, 1 + Ret + +EndP FileWindow_Up + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_Down Far + + Assume DS:Disk + + Mov AX, CurrentFile + Inc AX + Cmp AX, NumFiles + JAE FileWindow_Down1 + + Inc CurrentFile + +FileWindow_Down1: + Mov AX, 1 + Ret + +EndP FileWindow_Down + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_PgUp Far + + Assume DS:Disk + + Mov AX, CurrentFile + Sub AX, 31 + JNC FileWindow_PgUp1 + + Xor AX, AX + +FileWindow_PgUp1: + Mov CurrentFile, AX + + Mov AX, 1 + Ret + +EndP FileWindow_PgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_PgDn Far + + Assume DS:Disk + + Mov AX, CurrentFile + Add AX, 31 + Cmp AX, NumFiles + JB FileWindow_PgDn1 + + Mov AX, NumFiles + And AX, AX + JZ FileWindow_PgDn1 + + Dec AX + +FileWindow_PgDn1: + Mov CurrentFile, AX + + Mov AX, 1 + Ret + +EndP FileWindow_PgDn + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_Right Far + + Assume DS:Disk + + Mov Word Ptr [ES:DI], 13 + + Mov AX, 1 + Ret + +EndP FileWindow_Right + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_Left Far + + Assume DS:Disk + + Mov Word Ptr [ES:DI], 14 + + Mov AX, 1 + Ret + +EndP FileWindow_Left + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_ShiftTab Far + + Assume DS:Disk + + Mov Word Ptr [ES:DI], 16 + + Mov AX, 1 + Ret + +EndP FileWindow_ShiftTab + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_Home Far + + Assume DS:Disk + + Mov CurrentFile, 0 + + Mov AX, 1 + Ret + +EndP FileWindow_Home + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_End Far + + Assume DS:Disk + + Mov AX, NumFiles + Dec AX + JS FileWindow_End1 + + Mov CurrentFile, AX + +FileWindow_End1: + Mov AX, 1 + Ret + +EndP FileWindow_End + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FileWindow_DeleteFile Far + + Assume DS:Disk + + Cmp NumFiles, 0 + JE FileWindow_DeleteFile26 + + Mov DI, Offset O1_ConfirmDelete + Mov CX, 4 + Call M_Object1List + And DX, DX + JNZ FileWindow_DeleteFile24 + + Mov AX, 1 + Ret + +FileWindow_DeleteFile24: ; Time to kill the sucker... + Mov DS, CS:DiskDataArea + Mov BX, CS:CurrentFile + Assume DS:Nothing + + Add BX, BX + Mov DX, [BX] + Add DX, 8 ; DS:BX points to thingo. + Mov AH, 41h + Int 21h + JC FileWindow_DeleteFile26 + + Push DS + Pop ES + + Push CS + Pop DS + Assume DS:Disk + + Mov DI, CurrentFile + Mov CX, DI + Add DI, DI + Mov BX, NumFiles + Add BX, NumDirectories + +FileWindow_DeleteFile27: + Mov AX, [ES:DI+2] + StosW + Inc CX + Cmp CX, BX + JBE FileWindow_DeleteFile27 + + Mov AX, NumFiles + Mov BX, CurrentFile + Dec AX + And AX, AX + JZ FileWindow_DeleteFile29 + + Cmp BX, AX + JB FileWindow_DeleteFile28 + + Mov BX, AX + Dec BX + Jmp FileWindow_DeleteFile28 + +FileWindow_DeleteFile29: + Mov BX, AX + +FileWindow_DeleteFile28: + Mov NumFiles, AX + Mov CurrentFile, BX + Dec LoadSongNameCount + +FileWindow_DeleteFile26: + Mov AX, 1 + Ret + +EndP FileWindow_DeleteFile + Assume DS:Nothing + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Proc DirectoryWindow_Up Far + + Assume DS:Disk + + Mov AX, CurrentDirectory + And AX, AX + JZ DirectoryWindow_Up1 + + Dec CurrentDirectory + +DirectoryWindow_Up1: + Mov AX, 1 + Ret + +EndP DirectoryWindow_Up + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DirectoryWindow_Down Far + + Assume DS:Disk + + Mov AX, CurrentDirectory + Inc AX + Cmp AX, NumDirectories + JAE DirectoryWindow_Down1 + + Inc CurrentDirectory + +DirectoryWindow_Down1: + Mov AX, 1 + Ret + +EndP DirectoryWindow_Down + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DirectoryWindow_PgUp Far + + Assume DS:Disk + + Mov AX, CurrentDirectory + Sub AX, 21 + JC DirectoryWindow_Home + + Mov CurrentDirectory, AX + + Mov AX, 1 + Ret + +EndP DirectoryWindow_PgUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DirectoryWindow_PgDn Far + + Assume DS:Disk + + Mov AX, CurrentDirectory + Add AX, 21 + Cmp AX, NumDirectories + JAE DirectoryWindow_End + + Mov CurrentDirectory, AX + + Mov AX, 1 + Ret + +EndP DirectoryWindow_PgDn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DirectoryWindow_Home Far + + Assume DS:Disk + + Mov CurrentDirectory, 0 + + Mov AX, 1 + Ret + +EndP DirectoryWindow_Home + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DirectoryWindow_End Far + + Assume DS:Disk + + Mov AX, NumDirectories + Dec AX + JS DirectoryWindow_End1 + + Mov CurrentDirectory, AX + +DirectoryWindow_End1: + Mov AX, 1 + Ret + +EndP DirectoryWindow_End + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DirectoryWindow_Left Far + + Assume DS:Disk + + Mov Word Ptr [ES:DI], 12 + + Mov AX, 1 + Ret + +EndP DirectoryWindow_Left + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DirectoryWindow_Enter Far + + Assume DS:Disk + + Cmp NumDirectories, 0 + JE DirectoryWindow_Enter2 + + Mov BX, CurrentDirectory + Add BX, NumFiles + + Mov DS, DiskDataArea + Assume DS:Nothing + + Add BX, BX + Mov DX, [BX] + Add DX, 8 + Mov AH, 3Bh + Int 21h + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset SongDirectory + Call D_GetDriveDirectory + + Call D_InitLoadModule + + Mov CurrentFile, 0 + Mov AX, 12 + Cmp NumFiles, 0 + JNE DirectoryWindow_Enter1 + + Mov AX, 13 + +DirectoryWindow_Enter1: + StosW +; Mov [ES:DI], AX + + Mov AX, 1 + Ret + +DirectoryWindow_Enter2: + Xor AX, AX + Ret + +EndP DirectoryWindow_Enter + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Proc DriveWindow_Up Far + + Assume DS:Disk + + Mov AL, CurrentDrive + And AL, AL + JZ DriveWindow_Up1 + + Dec CurrentDrive + +DriveWindow_Up1: + Mov AX, 1 + Ret + +EndP DriveWindow_Up + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DriveWindow_Down Far + + Assume DS:Disk + + Mov AL, CurrentDrive + Inc AX + Cmp AL, NumDrives + JAE DriveWindow_Down1 + + Inc CurrentDrive + +DriveWindow_Down1: + Mov AX, 1 + Ret + +EndP DriveWindow_Down + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DriveWindow_Tab Far + + Assume DS:Disk + + Mov Word Ptr [ES:DI], 15 + + Mov AX, 1 + Ret + +EndP DriveWindow_Tab + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIDriveWindow_Tab Far + + Assume DS:Disk + + Mov Word Ptr [ES:DI], 5 + + Mov AX, 1 + Ret + +EndP LIDriveWindow_Tab + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SaveDriveWindow_Tab Far + + Assume DS:Disk + + Mov Word Ptr [ES:DI], 18 + + Mov AX, 1 + Ret + +EndP SaveDriveWindow_Tab + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DriveWindow_Enter Far + + Assume DS:Disk + + Mov BL, CurrentDrive + Xor BH, BH + Mov DL, [DrivesAvail+BX] + Mov AH, 0Eh + Int 21h + + Mov SI, Offset SongDirectory + Call D_GetDriveDirectory + + Call D_InitLoadModule + + Mov CurrentFile, 0 + Mov AX, 12 + Cmp NumFiles, 0 + JNE DriveWindow_Enter1 + + Mov AX, 13 + Cmp NumDirectories, 0 + JNE DriveWindow_Enter1 + + Mov AX, 14 + +DriveWindow_Enter1: + StosW +; Mov [ES:DI], AX + + Mov AX, 1 + Ret + +EndP DriveWindow_Enter + Assume DS:Nothing + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Proc LS_DriveWindow_Enter Far + + Assume DS:Disk + + Mov BL, CurrentDrive + Xor BH, BH + Mov DL, [DrivesAvail+BX] + Mov AH, 0Eh + Int 21h + + Mov SI, Offset SampleDirectory + Call D_GetDriveDirectory + + Mov CurrentSample, 0 + Push ES + Push DI + Call D_InitLoadSamples + Pop DI + Pop ES + + Mov Word Ptr [ES:DI], 15 ; Sample list + + Mov AX, 1 + Ret + +EndP LS_DriveWindow_Enter + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Proc LI_DriveWindow_Enter Far + + Assume DS:Disk + + Mov BL, CurrentDrive + Xor BH, BH + Mov DL, [DrivesAvail+BX] + Mov AH, 0Eh + Int 21h + + Mov SI, Offset InstrumentDirectory + Call D_GetDriveDirectory + + Mov CurrentInstrument, 0 + Push ES + Push DI + Call D_InitLoadInstruments + Pop DI + Pop ES + + Mov Word Ptr [ES:DI], 5 ; Sample list + + Mov AX, 1 + Ret + +EndP LI_DriveWindow_Enter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSDriveWindow_Right Far + + Mov Word Ptr [ES:DI], 17 + + Mov AX, 1 + Ret + +EndP LSDriveWindow_Right + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Proc LoadSample ; AX = Sample number + ; DS:SI points to sample header. + Call PE_SaveCurrentPattern + + Push AX + + Cmp AX, 99 + JNE LoadSample4 + + Mov DX, CS:CurrentSample + Cmp DX, CS:SampleInMemory + JE LoadSample3 + +LoadSample4: + Mov EDX, [DS:SI+30h] + And EDX, EDX + JZ LoadSample6 + Test Byte Ptr [DS:SI+12h], 1 + JZ LoadSample6 + + Call Music_Stop + + Push AX + + Mov AX, 3D00h + Mov DX, SI + Add DX, 4 + Int 21h + JC LoadSample8 + + Mov BX, AX ; BX = File Handle + Mov AX, 4200h + Mov CX, [DS:SI+4Ah] + Mov DX, [DS:SI+48h] + Int 21h ; Move File Ptr. + + Pop AX ; AX = sample number. + + Push SI ; Load sample into memory first. + + Call D_LoadSampleData + + PushF + + Mov AH, 3Eh + Int 21h ; Close file. + + PopF + Pop SI + + JC LoadSample2 + +LoadSample3: + Pop BX + Mov DX, BX + + Add BX, BX + Call Music_GetSongSegment + Mov ES, AX + Mov DI, [ES:BX+64912] ; ES:DI points to instrument + + Mov CX, 48h + Rep MovsB + Add SI, 4 + Add DI, 4 + MovsW + MovsW + + Cmp DX, 99 + JNE LoadSample5 + + Mov AX, [Word Ptr CS:CheckDataArea+2Eh] + Mov [DS:SI-50h+2Eh], AX + Mov AL, [CS:CheckDataArea+12h] + Mov [DS:SI-50h+12h], AL + + Mov AX, CS:CurrentSample + Cmp AX, CS:SampleInMemory + JE LoadSample7 + + Mov CS:SampleInMemory, AX + + Call D_DrawWaveForm + +LoadSample5: + Mov AX, DX + Inc AX + Call Music_SoundCardLoadSample + +LoadSample7: + ClC + Jmp LoadSample1 + Ret + +LoadSample2: + Mov CS:SampleInMemory, 0FFFFh + Jmp LoadSample6 + +LoadSample8: + Pop AX + +LoadSample6: + Pop AX + StC + +LoadSample1: + PushF + Call PE_RestoreCurrentPattern + PopF + Ret + +EndP LoadSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include it_d_ris.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSViewWindow_Enter Far + + Assume DS:Disk + + Cmp NumSamples, 0 + JE LSViewWindow_Enter1 + + Mov AX, 96 + Mul CurrentSample + Mov SI, AX + Assume DS:Nothing + + Mov DS, DiskDataArea + Mov DL, [DS:SI+88] + Cmp DL, 1 + JE LSViewWindow_Enter1 + + Cmp DL, 20h + JAE LSViewWindow_Enter2 + + Mov AX, 1 + Ret + +EndP LSViewWindow_Enter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSWindow_Enter Far + + Assume DS:Disk + + Cmp NumSamples, 0 + JE LSWindow_Enter2 + + Mov AX, 96 + Mul CurrentSample + Mov SI, AX + Assume DS:Nothing + + Mov DS, DiskDataArea + Mov DX, [DS:SI+88] ; Also get DH = InsampleChannels + Cmp DL, 1 + JNE LSWindow_Enter1 + +LSViewWindow_Enter1: + Push DS + Push SI + + Push CS + Pop DS + Mov SI, Offset SampleDirectory + Call D_SetDriveDirectory + + Pop SI + Pop DS + + Add SI, 4 + Call D_SetDriveDirectory + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset SampleDirectory + Call D_GetDriveDirectory + +LSWindow_EnterInModuleError: + Mov SamplesInModule, 0 + Call D_InitLoadSamples + Assume DS:Nothing + Mov CS:CurrentSample, 0 + + Mov AX, 1 + Ret + +LSWindow_Enter1: ; Load sample into sample list. + Cmp DL, 20h + JB LSWindow_EnterSample + +LSViewWindow_Enter2: + Sub DL, 20h + Mov Word Ptr CS:InSampleFormat, DX + Mov EAX, [SI+54h] + Mov CS:InSampleDateTime, EAX + + Add SI, 4 + ; Copy module name across + Push CS + Pop ES + Mov DI, Offset InSampleFileName + Mov CX, 13 + Rep MovsB + ; Open file + Push CS + Pop DS + Assume DS:Disk + + Mov CurrentSample, 0 + +LSWindow_EnterLoadInSampleData: + Mov DX, Offset InSampleFileName + Mov AX, 3D00h + Int 21h + JC LSWindow_EnterInModuleError + + Mov BX, AX + + Mov SI, Word Ptr InSampleFormat + And SI, 0FFh + Add SI, SI + + Mov NumSamples, 1 + + Mov DS, DiskDataArea + Assume DS:Nothing + + Push DS + Pop ES + + Call [CS:LoadSamplesInModuleTable+SI] + + ; Close module + Mov AH, 3Eh + Int 21h + + ; Setup first 'directory' + + Push CS + Pop DS + Assume DS:Disk + + Xor DI, DI + Mov SI, Offset ExitLibraryDirectory + Mov CX, 89 + Rep MovsB + + Mov EAX, InSampleDateTime + Mov [ES:DI-5], EAX + Mov SampleCacheFileComplete, 1 + Mov SamplesInModule, 1 + Mov SampleInMemory, 0FFFFh + Mov SampleCheck, 0FFFFh + + Mov AX, NumSamples + Mov LoadSampleNameCount, AX + + Mov AX, 1 + Ret + + Assume DS:Nothing + +LSWindow_EnterSample: + Call Music_Stop + + Mov AX, [Word Ptr CS:CheckDataArea+2Eh] + Mov [SI+2Eh], AX + ; prompt whether to initialise + ; instrument + ; 1) Only when no sample was + ; previously present + ; 2) When instrument mode is + ; on. + Mov AX, 99 ; Release sample! + Call Music_ReleaseSample + + Xor DX, DX ; Assume don't call. + + Call Music_GetInstrumentMode + JZ LSWindow_Enter4 ; Sample mode! + + ; Instrument mode + + ; Check whether previous sample + ; existed. + Push DS + Push SI + + Mov CX, 4 ; Assume Not OK + + Call I_GetSampleOffset ; DS:BX points to sample. + Test Byte Ptr [BX+12h], 1 + JNZ LSWindow_Enter5 + + Mov CX, 3 ; Assume OK. + +LSWindow_Enter5: + Mov DI, Offset O1_InitInstrument + Call M_Object1List + ; DX contains init flag. + Pop SI + Pop DS + +LSWindow_Enter4: + Push DX + + Call PE_GetLastInstrument + Mov AX, BX + Push AX + Call LoadSample + Pop CX + Xor DX, DX + +IF NETWORKENABLED + NetworkSendSample + Call Network_QueueSampleData +ENDIF + + Pop DX + + Test DX, DX + JZ LSWindow_Enter7 + + Call PE_GetLastInstrument ; BX = sample number + Call Music_AssignSampleToInstrument + + Push CS + Pop DS + Mov SI, Offset InitInstrumentErrorMsg + JC LSWindow_Enter6 + + Mov SI, Offset InitInstrumentMsg + +LSWindow_Enter6: + Call SetInfoLine + +LSWindow_Enter7: + Jmp Glbl_F3 + +LSWindow_Enter2: + Mov AX, 1 + Ret + +EndP LSWindow_Enter + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSWindow_Space Far + + Assume DS:Disk + + Cmp NumSamples, 0 + JE LSViewWindow_Enter1 + + Mov AX, 96 + Mul CurrentSample + LEA SI, [EAX+14h] + Assume DS:Nothing + + Push SI + + Mov DS, DiskDataArea + + Push CS + Pop ES + Mov DI, Offset SampleName + + Mov CX, 26 + Mov BX, DI + +LSWindow_Space1: + LodsB + And AL, AL + JNZ LS_WindowSpace2 + + Mov AL, ' ' + Jmp LS_WindowSpace3 + +LS_WindowSpace2: + Cmp AL, ' ' + JE LS_WindowSpace3 + + Mov BX, DI + Inc BX + +LS_WindowSpace3: + StosB + Loop LSWindow_Space1 + + Mov Byte Ptr [ES:BX], 0 + + + Mov DI, Offset O1_EditSampleName + Mov CX, 3 + Call M_Object1List + + Pop DI ; DI contains offset of sample + + And DX, DX + JZ LS_WindowSpace4 + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset SampleName + Mov CX, 26 + Mov ES, DiskDataArea + Rep MovsB + +LS_WindowSpace4: + Mov AX, 1 + Ret + +EndP LSWindow_Space + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSWindow_Up Far + + Call CheckSampleModified + JC LSWindow_Up1 + + Assume DS:Disk + + Mov AX, CurrentSample + And AX, AX + JZ LSWindow_Up1 + + Dec CurrentSample + +LSWindow_Up1: + Mov AX, 1 + Ret + +EndP LSWindow_Up + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSWindow_Down Far + + Call CheckSampleModified + JC LSWindow_Down1 + + Assume DS:Disk + + Mov AX, CurrentSample + + Inc AX + Cmp AX, NumSamples + JAE LSWindow_Down1 + + Mov CurrentSample, AX + +LSWindow_Down1: + Mov AX, 1 + Ret + +EndP LSWindow_Down + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSWindow_PgUp Far + + Call CheckSampleModified + JC LSWindow_PgUp1 + + Assume DS:Disk + + Mov AX, CurrentSample + + Sub AX, 35 + JC LSWindow_Home + + Mov CurrentSample, AX + +LSWindow_PgUp1: + Mov AX, 1 + Ret + +EndP LSWindow_PgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSWindow_PgDn Far + + Call CheckSampleModified + JC LSWindow_PgDn1 + + Assume DS:Disk + + Mov AX, CurrentSample + + Add AX, 35 + Cmp AX, NumSamples + JAE LSWindow_End + + Mov CurrentSample, AX + +LSWindow_PgDn1: + Mov AX, 1 + Ret + +EndP LSWindow_PgDn + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSWindow_Home Far + + Call CheckSampleModified + JC LSWindow_Home1 + + Assume DS:Disk + + Mov CurrentSample, 0 + +LSWindow_Home1: + Mov AX, 1 + Ret + +EndP LSWindow_Home + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LSWindow_End Far + + Call CheckSampleModified + JC LSWindow_End1 + + Assume DS:Disk + + Mov AX, NumSamples + + Dec AX + JS LSWindow_End1 + + Mov CurrentSample, AX + +LSWindow_End1: + Mov AX, 1 + Ret + +EndP LSWindow_End + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LSCheckLoopValues Far + + Call D_GetLoadSampleVars ; DS:SI points to thing + + Mov BX, SI + + Mov EAX, [BX+30h] + Cmp EAX, [BX+34h] + JA D_LSCheckLoopValues3 + + Mov [BX+34h], EAX + +D_LSCheckLoopValues3: + Cmp EAX, [BX+38h] + JAE D_LSCheckLoopValues2 + + Mov [BX+38h], EAX + +D_LSCheckLoopValues2: + Mov EAX, [BX+38h] + Cmp EAX, [BX+34h] + JA D_LSCheckLoopValues1 + + And Byte Ptr [BX+12h], NOT 00010000b + +D_LSCheckLoopValues1: + Call D_DrawWaveForm + + Ret + +EndP D_LSCheckLoopValues + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LSCheckSusLoopValues Far + + Call D_GetLoadSampleVars ; DS:SI points to thing + + Mov BX, SI + + Mov EAX, [BX+30h] + Cmp EAX, [BX+40h] + JA D_LSCheckSusLoopValues3 + + Mov [BX+40h], EAX + +D_LSCheckSusLoopValues3: + Cmp EAX, [BX+44h] + JAE D_LSCheckSusLoopValues2 + + Mov [BX+44h], EAX + +D_LSCheckSusLoopValues2: + Mov EAX, [BX+44h] + Cmp EAX, [BX+40h] + JA D_LSCheckLoopValues1 + + And Byte Ptr [BX+12h], NOT 00100000b + +D_LSCheckSusLoopValues1: + Call D_DrawWaveForm + + Ret + +EndP D_LSCheckSusLoopValues + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveSong Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset SongDirectory + Call D_SetDriveDirectory ; DS:SI points to cur dir. + + Cmp Byte Ptr [FileName], 0 + JNE D_SaveSong2 + + Jmp Glbl_F10 + +D_SaveSong2: +; Call D_CheckOverWrite +; JC D_SaveSong1 + + Push CS +; Push CS +; Pop DS + Pop ES + + Mov SI, Offset FileName + Mov DI, Offset SaveFileName + Mov CX, 14 + +D_SaveSong3: + LodsB + StosB + Cmp AL, '.' + LoopNE D_SaveSong3 + JNE D_SaveSong4 + + Cmp SaveFormat, 1 + JE D_SaveSong5 + + Mov AX, 'TI' + StosW + Xor AX, AX + StosB + Jmp D_SaveSong4 + +D_SaveSong5: + Mov AX, '3S' + StosW + Mov AX, 'M' + StosW + +D_SaveSong4: + Xor AL, AL + Call Glbl_SetCurrentMode + + Cmp SaveFormat, 1 + JE D_SaveFileS3MModule + Jmp D_SaveFileITModule + +EndP D_SaveSong + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PreSaveSample + + Push CS + Pop DS + Assume DS:Disk + + Mov NoSaveError, 0 + + Mov SI, Offset SampleDirectory + Call D_SetDriveDirectory + + Call PE_GetLastInstrument + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + Mov SI, BX + Add SI, SI + Mov SI, [DS:64912+SI] ; SI points to sample. + Inc BX + + ; Check if sample exists + Test Byte Ptr [SI+12h], 1 + JZ D_PreSaveSample1 + + Call DeleteSampleCacheFile + + LEA DX, [SI+4] + + Call D_CheckOverWrite + Ret + +D_PreSaveSample1: + StC + Ret + +EndP D_PreSaveSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveSample Far + + Call D_PreSaveSample + JC D_SaveSample2 + +Proc D_SaveSampleInternal Far + ; OK to save. DS:SI points to + ; structure, BX = sample num + Mov ES, CS:DiskDataArea + Xor DI, DI + Mov CX, 80 + Rep MovsB + Mov Byte Ptr [ES:2Eh], 1 + Mov DWord Ptr [ES:48h], 80 + + Push ES + Pop DS + + Mov AH, 3Ch + Xor CX, CX + Mov DX, 4 + Int 21h ; Open file. + JC D_SaveSample2 + + Push BX ; BX = sample number + Mov BX, AX ; BX = file handle + + Mov AH, 40h + Mov CX, 80 + Xor DX, DX + Int 21h ; Save header. + + Pop AX ; AX = sample number + Push AX + + Call D_SaveSampleData + PushF + + Mov AH, 3Eh + Int 21h ; Close file + + PopF + Pop BX ; AX = sample number + JC D_SaveSample2 + + Push CS + Pop DS + Mov AX, BX + Mov SI, Offset ITSampleSavedMsg + Call SetInfoLine + + Jmp D_SaveSampleEnd + +D_SaveSample2: + Push CS + Pop DS + Mov AX, BX + Mov SI, Offset SampleErrorMsg + Call SetInfoLine + +D_SaveSampleEnd: + Mov AX, 1 + Ret + +EndP D_SaveSampleInternal + +EndP D_SaveSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveRawSample Far + Assume DS:Disk + + Call D_PreSaveSample ; DS:SI points to structure + JC D_SaveRawSample2 + Assume DS:Nothing + +IF SAVESAMPLEWAV + Mov DWord Ptr [CS:WaveBytesPerSample], 80001h + Mov ECX, [SI+3Ch] ; C5Speed + Mov [CS:WAVEMixSpeed], ECX + Mov EAX, [SI+30h] ; Length + Test Byte Ptr [SI+12h], 2 + JZ D_SaveWAVHeader1 + + Add EAX, EAX + Add ECX, ECX + Mov DWord Ptr [CS:WaveBytesPerSample], 100002h + +D_SaveWAVHeader1: + Mov [CS:WAVEDataSize], EAX + Mov [CS:WAVEBytesPerSecond], ECX +ENDIF + Push DS + Push SI + + Mov AX, BX ; AX = sample number. + Xor CX, CX + Call Music_GetSampleLocation ; ES:DI points to sample. + + Mov DI, SI + Push DS + Pop ES + + Pop SI + Pop DS + + PushF + + Mov AH, 3Ch + Xor CX, CX + LEA DX, [SI+4] + Int 21h + JC D_SaveRawSample3 + +IF SAVESAMPLEWAV + PushA + Push DS + + Push CS + Pop DS + + Mov BX, AX + Mov AH, 40h + Mov DX, Offset WAVEFileHeader + Mov CX, 2Ch + Int 21h + + Pop DS + PopA +ENDIF + + PopF + Push BX + XChg AX, BX ; BX = file handle, AX = sample + ; number + JZ D_SaveRawSample1 ; 8 bit, write as unsigned + + Call D_SaveSampleData + PushF + Jmp D_SaveRawSample4 + +D_SaveRawSample1: + Call D_SaveSampleDataConvert + PushF + +D_SaveRawSample4: + Mov AH, 3Eh + Int 21h ; Close file. + + PopF + Pop BX ; BX = Sample number + + JC D_SaveRawSample2 + + Push CS + Pop DS + Assume DS:Disk + + Mov AX, BX + Mov SI, Offset RawSampleSavedMsg + Call SetInfoLine + + ClC + Jmp D_SaveRawSampleEnd + +D_SaveRawSample3: + PopF + +D_SaveRawSample2: + Push CS + Pop DS + Mov AX, BX + Mov SI, Offset SampleErrorMsg + Call SetInfoLine + StC + +D_SaveRawSampleEnd: + Mov AX, 1 + Ret + +EndP D_SaveRawSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveST3Sample Far + + Call D_PreSaveSample + JC D_SaveST3Sample2 + + ; OK to save. DS:SI points to + ; structure, BX = sample num + Mov ES, CS:DiskDataArea + Xor DI, DI + Mov AL, 1 + StosB + Push SI + Mov CX, 13 + Add SI, 4 + Rep MovsB + Pop SI + Mov AX, 5 + StosW ; FileName + + Mov EAX, [DS:SI+30h] ; LoopStart + StosD + + Mov EAX, [DS:SI+34h] ; LoopBeg + StosD + + Mov EAX, [DS:SI+38h] ; LoopEnd + StosD + + Xor AX, AX + Mov AL, Byte Ptr [DS:SI+13h] + StosW ; Volume + + Mov AH, [DS:SI+12h] + Mov AL, AH + And AX, 1002h + ShR AH, 4 + ShL AL, 1 + Or AH, AL + Xor AL, AL + StosW ; Flags & Pack + + Mov EAX, [DS:SI+3Ch] + StosD + + Mov CX, 6 + Xor AX, AX + Rep StosW + + Add SI, 14h + Mov CX, 25 + Rep MovsB + Xor AX, AX + StosB + StosW + + Mov EAX, 'SRCS' + StosD + + Push ES + Pop DS + + Mov AH, 3Ch + Xor CX, CX + Mov DX, 1 + Int 21h ; Open file. + JC D_SaveST3Sample2 + + Push BX ; BX = sample number + Mov BX, AX ; BX = file handle + + Mov AH, 40h + Mov CX, 80 + Xor DX, DX + Int 21h ; Save header. + + Pop AX ; AX = sample number + Push AX + + Call D_SaveSampleDataConvert + + PushF + + Mov AH, 3Eh + Int 21h ; Close file + + PopF + Pop BX + + JC D_SaveST3Sample2 + + Push CS + Pop DS + Mov AX, BX + Mov SI, Offset ST3SampleSavedMsg + Call SetInfoLine + + Jmp D_SaveST3SampleEnd + +D_SaveST3Sample2: + Push CS + Pop DS + Mov AX, BX + Mov SI, Offset SampleErrorMsg + Call SetInfoLine + +D_SaveST3SampleEnd: + Mov AX, 1 + Ret + +EndP D_SaveST3Sample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SaveInstrument Far + + Push CS + Pop DS + Assume DS:Disk + + Mov NoSaveError, 0 + + Mov SI, Offset InstrumentDirectory + Call D_SetDriveDirectory + + Call PE_GetLastInstrument + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + Mov SI, BX + Add SI, SI + Mov SI, [DS:64712+SI] ; SI points to instrument + + Call DeleteInstrumentCacheFile + +; Mov DX, SI +; Add DX, 4 + LEA DX, [SI+4] + + Call D_CheckOverWrite + JC D_SaveInstrumentError + + ; DS:SI still points to ins. + ; Clear InstrumentTable setup table. + Push CS + Pop ES + Mov DI, Offset InstrumentTable + Xor AX, AX + Mov CX, 50 + Rep StosW ; OK.. table clear. + + ; Now step through instrument + ; list and get sample numbers. + Push DS + Push SI + + Add SI, 40h + Mov CX, 120 + Xor BX, BX + +D_SaveInstrument1: + LodsW + Mov BL, AH ; BL = sample number. + Mov [CS:InstrumentTable+BX], 1 + Loop D_SaveInstrument1 + + ; OK. Instrument table contains + ; 1s for every sample used... + ; Now to re-translate it. + Push CS + Pop DS + Assume DS:Disk + + Mov AH, 0 + Mov CX, 99 + Mov SI, Offset InstrumentTable + Mov Byte Ptr [SI], 0 + +D_SaveInstrument2: + Cmp Byte Ptr [SI], 0 + JE D_SaveInstrument3 + + Inc AH + Mov [SI], AH + +D_SaveInstrument3: + Inc SI + Loop D_SaveInstrument2 + ; AH = number of samples.. + ; Now let's copy it to the Diskdata. + + Pop SI + Pop DS + Assume DS:Nothing + + Mov ES, CS:DiskDataArea + Xor DI, DI + Mov CX, 554/2 + + Rep MovsW + + Push ES + Pop DS + Assume DS:Nothing + + Mov [DS:1Eh], AH ; AH = number of samples. + Mov Word Ptr [DS:1Ch], TRACKERVERSION + + ; Now to translate + Mov DI, 41h +; Xor BX, BX + Mov CX, 120 + +D_SaveInstrument4: + Mov BL, [DI] + Mov AL, [CS:InstrumentTable+BX] + StosB + Inc DI + + Loop D_SaveInstrument4 + ; headerfilesize=554(instrumentheader)+ + ; 80*AH. + Mov AL, 80 + Mul AH + Add AX, 554 ; AX = header size. + + Push AX + + Mov DX, AX + Xor CX, CX ; CX:DX = posn in file. + + Call Music_GetSongSegment + Mov DS, AX + Mov DI, 554 ; DI = posn in header. + Xor BX, BX + +D_SaveInstrument5: ; Loop to get samples into header. + Cmp [CS:InstrumentTable+BX], 0 + JE D_SaveInstrument6 + + Mov SI, BX + Add SI, SI + Mov SI, [DS:64912+SI-2] ; DS:SI points to sample. + + Push CX ; Move the header... + Mov CX, 40 + Rep MovsW + Pop CX + + Mov [ES:DI-80+48h], DX ; File pointer. + Mov [ES:DI-80+4Ah], CX + + Mov AL, [ES:DI-80+12h] + Test AL, 1 + JZ D_SaveInstrument6 + + Add DX, [ES:DI-80+30h] + AdC CX, [ES:DI-80+32h] + + Test AL, 2 + JZ D_SaveInstrument6 + + Add DX, [ES:DI-80+30h] + AdC CX, [ES:DI-80+32h] + +D_SaveInstrument6: + Inc BX + Cmp BX, 100 + JB D_SaveInstrument5 + + Push ES + Pop DS ; Lets open the file! + Mov DX, 4 + + Mov AH, 3Ch ; Open file! + Xor CX, CX ; Normal attributes + Int 21h + + Pop CX ; CX = header size + + JC D_SaveInstrumentError + + Mov BX, AX ; BX = file handle... + + Xor DX, DX + Call D_SaveBlock ; OK.. header's written.. now save + ; individual samples... + Mov DI, 1 + +D_SaveInstrument7: + Cmp [CS:InstrumentTable+DI], 0 + JE D_SaveInstrument8 + + Mov AX, DI + + Call D_SaveSampleData + +D_SaveInstrument8: + Inc DI + Cmp DI, 100 + JBE D_SaveInstrument7 + + Mov AH, 3Eh + Int 21h + Jmp D_SaveInstrumentOK + +D_SaveInstrumentError: + Push CS + Pop DS + + Call PE_GetLastInstrument + Mov AX, BX + Inc AX + Mov SI, Offset InstrumentErrorMsg + Call SetInfoLine + + Jmp D_SaveInstrumentEnd + +D_SaveInstrumentOK: + Push CS + Pop DS + + Call PE_GetLastInstrument + Mov AX, BX + Inc AX + Mov SI, Offset ITInstrumentSavedMsg + Call SetInfoLine + +D_SaveInstrumentEnd: + Mov AX, 1 + Ret + +EndP D_SaveInstrument + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DeleteSampleFile Far + + Push CS + Pop DS + Assume DS:Disk + + Cmp NumSamples, 0 + JE D_DeleteSampleFile1 + Cmp SamplesInModule, 0 + JNE D_DeleteSampleFile1 + + Mov AX, 96 + Mul CurrentSample + Mov SI, AX + Mov DS, DiskDataArea + Assume DS:Nothing + Cmp Byte Ptr [DS:SI+58h], 1 + JBE D_DeleteSampleFile1 ; Don't delete dirs! +; Cmp Byte Ptr [DS:SI+58h], 20h +; JAE D_DeleteSampleFile1 + + Push DS + Push SI + + Mov DI, Offset O1_ConfirmDelete2 + Mov CX, 4 + Call M_Object1List + + Pop SI + Pop DS + + And DX, DX ; OK to delete? + JZ D_DeleteSampleFile1 + + ; Delete file.... + LEA DX, [SI+4] + Mov AH, 41h + Int 21h + JC D_DeleteSampleFile1 + + Push CS + Pop DS + Assume DS:Disk + + Mov DI, SI + Add SI, 96 + + Mov CX, NumSamples ; Wipe from list.. + Mov BX, CurrentSample + Sub CX, BX + + Mov AX, 96 + Mul CX + Mov CX, AX + + Push DS + + Mov DS, DiskDataArea + Push DS + Pop ES + + Rep MovsB + + Pop DS + + Mov SampleInMemory, 0FFFFh + Mov SampleCheck, 0FFFFh + + Dec NumSamples + JZ D_DeleteSampleFile2 + + Cmp BX, NumSamples + JB D_DeleteSampleFile2 + + Mov BX, NumSamples + Dec BX + Mov CurrentSample, BX + +D_DeleteSampleFile2: + Cmp SampleCacheFileComplete, 1 + JNE D_DeleteSampleFile1 + + Call D_SaveSampleCacheFile + +D_DeleteSampleFile1: + Mov AX, 1 + Ret + +EndP D_DeleteSampleFile + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckSampleModified + + Push CS + Pop DS + Assume DS:Disk + + Cmp SamplesInModule, 0 + JNE CheckSampleModified1 + + Mov AX, 96 + Mul CurrentSample + + Mov ES, DiskDataArea + Mov DI, AX + Mov DL, [ES:DI+88] + Cmp DL, 1 + JBE CheckSampleModified1 + Cmp DL, 20h + JAE CheckSampleModified1 + + Mov SI, Offset CheckDataArea + + Mov CX, 12h + RepE CmpSB + JNE CheckSampleModified7 + Inc SI + Inc DI + Mov CX, 50h-12h-1 + RepE CmpsB + JE CheckSampleModified1 + Mov CX, 80 + RepE CmpsB + + ; Check whether file name changed... +CheckSampleModified7: + Mov DI, AX + Mov SI, Offset CheckDataArea+4 + Add DI, 4 + + Mov CX, 13 + RepE CmpsB + JE CheckSampleModified3 + +CheckSampleModified2: ; Sample name different. + Mov DI, Offset O1_ConfirmSaveRenameList + Mov CX, 3 + Call M_Object1List + ; DX = 0 -> don't save + ; DX = 1 -> save + And DX, DX + JZ CheckSampleModified4 + + ; Load Sample + Push CS + Pop DS + + Mov SI, Offset CheckDataArea + Mov AX, 99 + Call LoadSample ; Load sample into slot 100! + JC CheckSampleModified5 + ; Save sample + Mov AX, 96 + Mul CS:CurrentSample + Mov SI, AX + Mov DS, CS:DiskDataArea + Mov BX, 100 ; DS:SI points to block + Push DS + Push SI + Call D_SaveSampleInternal + Pop SI + Pop DS + JC CheckSampleModified6 + ; Delete old sample + + Push CS + Pop DS + Mov DX, Offset CheckDataArea+4 + Mov AH, 41h + Int 21h ; Delete file + + ; Now update sample data... + + Call DeleteSampleCacheFile + Call D_InitLoadSamples + + Jmp CheckSampleModified1 ; Return OK! + +CheckSampleModified3: ; Sample name the same. + Mov DI, Offset O1_ConfirmResaveList + Mov CX, 3 + Call M_Object1List + ; DX = 0 -> don't save + ; DX = 1 -> save + And DX, DX + JZ CheckSampleModified4 + + ; Load Sample + Push CS + Pop DS + + Mov SI, Offset CheckDataArea + Mov AX, 99 + Call LoadSample ; Load sample into slot 100! + JC CheckSampleModified5 + + ; Save Sample + Mov AX, 96 + Mul CS:CurrentSample + Mov SI, AX + Mov DS, CS:DiskDataArea + Mov BX, 100 ; DS:SI points to block + Push DS + Push SI + Call D_SaveSampleInternal + Pop SI + Pop DS + JC CheckSampleModified6 + ; Now update sample data... + Call DeleteSampleCacheFile + Call D_InitLoadSamples + + Jmp CheckSampleModified1 + +CheckSampleModified4: ; Prompt to discard changes.. + Mov DI, Offset O1_ConfirmDiscardList + Mov CX, 4 + Call M_Object1List + ; DX = 0 -> don't discard + ; DX = 1 -> discard + And DX, DX + JZ CheckSampleModified5 + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset CheckDataArea + Mov ES, DS:DiskDataArea + Mov AX, 96 + Mul CurrentSample + Mov DI, AX + Mov CX, 80 + Rep MovsB + + Jmp CheckSampleModified1 + +CheckSampleModified6: + Call DeleteSampleCacheFile + Call D_InitLoadSamples + +CheckSampleModified5: + Push CS + Pop DS + + StC + Ret + +CheckSampleModified1: + Push CS + Pop DS + + ClC + Ret + +EndP CheckSampleModified + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DrawWaveForm Far + + PushAD + Push DS + Push ES + + Call S_GetGenerationTableOffset + Push DI + Mov CX, 248*32 + Xor AL, AL + Rep StosB + Pop DI + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation ; Gets DS:SI and CX + JC D_DrawWaveFormEnd + +; Push AX ; AX = instrument num + ; DS:SI = waveform, CX = length + ; ES:DI = charactergenerationtable + + SetNZ CS:Resolution + JZ D_DrawWaveForm8Bit + + Add ECX, ECX + Inc SI + +D_DrawWaveForm8Bit: + + Mov EAX, ECX + Mov ECX, 248 + Xor EDX, EDX + Div ECX ; AX = major shift. DX = minor shift. + + Mov EBX, EAX + Xor EAX, EAX + Div ECX + + Mov EDX, EAX + Xor EAX, EAX + + Mov EBP, ESI + +D_DrawWaveForm6: + Add EAX, EDX + AdC EBP, EBX + Push EAX + Push EBX + Push ECX + Push EDX + + Mov CL, [SI] + Mov CH, CL + + Mov BX, 1 + Add BL, CS:Resolution + +D_DrawWaveForm10: + Cmp ESI, EBP + JAE D_DrawWaveForm7 + + Mov AL, [SI] + Add SI, BX + JC D_DrawWaveFormUpdateLocation + +D_DrawWaveFormResume: + Cmp AL, CL + JL D_DrawWaveForm8 + + Cmp AL, CH + JLE D_DrawWaveForm10 + + Mov CH, AL + Jmp D_DrawWaveForm10 + +D_DrawWaveFormUpdateLocation: + Add ESI, 10000h + Int 3 + Jmp D_DrawWaveFormResume + +D_DrawWaveForm8: + Mov CL, AL + Jmp D_DrawWaveForm10 + +D_DrawWaveForm7: ; CL = min, CH = max. + Mov AX, CX + SAR AH, 1 + SAR AL, 1 + Add AX, 202h + SAR AL, 2 + SAR AH, 2 + + Xor CH, CH + Mov CL, AH + Sub CL, AL ; CX = iterations. + Inc CX + + Mov AL, 16 + Sub AL, AH + Cmp AL, 32 + JNE D_DrawWaveForm13 + + Mov AL, 31 + +D_DrawWaveForm13: + Mov AH, 31*8 + Mul AH + Mov BX, AX + +D_DrawWaveForm11: + Mov Byte Ptr [ES:DI+BX], 1 + Add BX, 248 + Loop D_DrawWaveForm11 + +D_DrawWaveForm12: + Pop EDX + Pop ECX + Pop EBX + Pop EAX + Inc DI + Loop D_DrawWaveForm6 + + ; Get Sample header offset. +; Call Music_GetSongSegment +; Mov DS, AX +; Pop SI +; Dec SI +; Add SI, SI +; Mov SI, [64912+SI] + Mov AX, 96 + Mul CS:CurrentSample + Mov DS, CS:DiskDataArea + Mov SI, AX + + + Mov EBX, [DS:SI+30h] + Test Byte Ptr [DS:SI+12h], 10h + JZ D_DrawWaveForm14 + + Mov ECX, EBX + ShR ECX, 1 + + Mov EAX, 247 + Mul DWord Ptr [DS:SI+34h] + Add EAX, ECX + AdC EDX, 0 + Div EBX + + Push EAX ; AX = loop start. + + Mov EAX, 247 + Mul DWord Ptr [DS:SI+38h] + Add EAX, ECX + AdC EDX, 0 + Div EBX + Mov EDX, EAX + Pop EAX ; DX = loop end (0-175) + ; AX = loop start (0-175) + + Call S_GetGenerationTableOffset + ; ES:DI + Add DI, AX + Sub DX, AX + Dec DX + Mov CX, 32 + Mov AH, 1 + +D_DrawSampleWaveFormLoop1: + Push DI + + Xor AL, AL + Test AH, 2 + JZ D_DrawSampleWaveFormLoop2 + + Inc AX + +D_DrawSampleWaveFormLoop2: + StosB + Add DI, DX + StosB + + Pop DI + Add DI, 248 + Inc AH + Loop D_DrawSampleWaveFormLoop1 + +D_DrawWaveForm14: + Test Byte Ptr [DS:SI+12h], 20h + JZ D_DrawWaveFormEnd + + Mov ECX, EBX + ShR ECX, 1 + + Mov EAX, 247 + Mul DWord Ptr [DS:SI+40h] + Add EAX, ECX + AdC EDX, 0 + Div EBX + + Push EAX ; AX = loop start. + + Mov EAX, 247 + Mul DWord Ptr [DS:SI+44h] + Add EAX, ECX + AdC EDX, 0 + Div EBX + Mov EDX, EAX + Pop EAX ; DX = loop end (0-175) + ; AX = loop start (0-175) + + Call S_GetGenerationTableOffset + ; ES:DI + Add DI, AX + Sub DX, AX + Dec DX + Mov CX, 32 + Mov AL, 1 + +D_DrawSampleWaveFormSusLoop1: + Push DI + + StosB + Add DI, DX + StosB + + Pop DI + Add DI, 248 + Xor AL, 1 + Loop D_DrawSampleWaveFormSusLoop1 + +D_DrawWaveFormEnd: + Mov AX, 0 + Mov BX, 31 + Mov CX, 4 + Call S_GenerateCharacters + + Pop ES + Pop DS + PopAD + + Ret + +EndP D_DrawWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_ClearFileName Far + + Push AX + Push CX + Push ES + Push DI + + Mov DI, Offset FileName + Push CS + Pop ES + Mov CX, 7 + Xor AX, AX + Rep StosW + + Pop DI + Pop ES + Pop CX + Pop AX + Ret + +EndP D_ClearFileName + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GetFormatType Far + + Push CS + Pop ES + Mov DI, Offset SaveFormat + + Ret + +EndP D_GetFormatType + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DisableFileColours Far + + Mov CS:FileColours, 0 + + Ret + +EndP D_DisableFileColours + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadInstrumentFiles + + Mov DS, CS:DiskDataArea + Push DS + Pop ES + + Xor DI, DI + Xor AX, AX + Mov CX, 32768 + Rep StosW + + Mov DX, 64000 + Mov AH, 1Ah + Int 21h ; Shift DTA address.. + ; to DiskDataArea:64000 + + Xor DI, DI + + Push CS + Pop DS + Mov DX, Offset AllFilesMask + Mov CX, 10h + Mov AH, 4Eh + Int 21h + + Mov DS, CS:DiskDataArea + Push DS + Pop ES + + JC D_LoadInstrumentFiles2 + +D_LoadInstrumentFiles1: ; A directory was found! + Test Byte Ptr [DS:64000+15h], 10h + JZ D_LoadInstrumentFiles5 ; Check that it IS a directory + + Cmp Word Ptr [DS:64000+1Eh], '.' + JNE D_LoadInstrumentFilesNoRoot + + Mov Byte Ptr [DS:64000+1Eh], '\' + +D_LoadInstrumentFilesNoRoot: + Mov DL, 1 + Call Near Ptr D_LoadInstrumentFiles6 + + Inc CS:NumInstruments + Inc CS:LoadInstrumentNameCount + + Cmp CS:NumInstruments, 999 + JAE D_LoadInstrumentFiles4 + +D_LoadInstrumentFiles5: + Mov AH, 4Fh + Int 21h + JNC D_LoadInstrumentFiles1 + +D_LoadInstrumentFiles2: ; Directories done.. samples now + Push CS + Pop DS + Mov DX, Offset AllFilesMask + Xor CX, CX + Mov AH, 4Eh + Int 21h + + Mov DS, CS:DiskDataArea + Push DS + Pop ES + + JC D_LoadInstrumentFiles4 + +D_LoadInstrumentFiles3: +; Push DI +; +; Mov SI, Offset InstrumentCacheFileName +; Mov DI, 64000+1Eh +; Mov CX, 9 +; Rep SegCS CmpsB +; Pop DI +; JE D_LoadInstrumentFilesNext + + Mov DL, 0 + Call Near Ptr D_LoadInstrumentFiles6 + + Inc CS:NumInstruments + Cmp CS:NumInstruments, 999 + JAE D_LoadInstrumentFiles4 + +D_LoadInstrumentFilesNext: + Mov AH, 4Fh + Int 21h + JNC D_LoadInstrumentFiles3 + +D_LoadInstrumentFiles4: ; End! + Mov AX, CS:NumInstruments + Mov CS:InitialInstruments, AX + + Ret + +D_LoadInstrumentFiles6: ; Get name/size/date/time. + Mov AL, DL + StosB + + Mov SI, 64000+1Eh + Mov CX, 14 ; Name.. + Rep MovsB + + Cmp DL, 1 + JNE D_LoadInstrumentFiles7 + + Push DS + Push CS + Pop DS + Mov SI, Offset DirectoryMsg + Mov CX, 25 + Rep MovsB + + Pop DS + + Xor AX, AX + Mov CX, 4 + Rep StosW + + RetN + +D_LoadInstrumentFiles7: + Xor AX, AX + Mov CX, 27 + Rep StosB ; No instrumentname, NOS = 0. + + Mov AX, [DS:64000+1Ah] ; File Size.. + Mov DX, [DS:64000+1Ch] + + SHRD AX, DX, 10 + ShR DX, 10 + JZ D_LoadInstrumentFiles8 + + Mov AX, 0FFFFh + +D_LoadInstrumentFiles8: + StosW + + Xor EAX, EAX ; Offset + StosD + + RetN + +EndP D_LoadInstrumentFiles + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_InitLoadInstruments Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset InstrumentDirectory + Call D_SetDriveDirectory ; DS:SI points to cur dir. + + Call Music_GetSongSegment + Mov DS, AX + + Mov CX, 99 + Mov BX, [DS:64912] ; BX = offset to first + ; sample. + + Mov DX, CX ; DX = counter. + Add BX, 12h + +D_InitLoadInstruments4: + Mov AL, [BX] + ShR AL, 1 + SBB DX, 0 + + Add BX, 80 + Loop D_InitLoadInstruments4 + + Push CS + Pop DS + Assume DS:Disk + + Mov UnusedSamples, DX + + Cmp InstrumentsInModule, 0 + JE D_InitLoadInstruments5 + + Jmp LIWindow_EnterLoadInInstrumentData + +D_InitLoadInstruments5: + Mov LoadInstrumentNameCount, 0 + Mov NumInstruments, 0 + Mov InstrumentCacheFileComplete, 0 + + Mov SI, Offset InstrumentDirectory + Call D_SetDriveDirectory ; DS:SI points to cur dir. + + Mov [OldCacheTime], 0 + + Mov AX, 3D00h ; Open file.. + Mov DX, Offset InstrumentCacheFileName + Int 21h + JC D_InitLoadInstrument1 ; Can't open file? + + Mov BX, AX + + Mov AH, 3Fh + Mov CX, 6 ; 2 integers containing number + ; of sample entries... + ; 3rd word = Version check + Mov DS, DiskDataArea + Assume DS:Nothing + + Xor DX, DX + Int 21h + JC D_InitLoadInstrument3 + Cmp AX, CX + JNE D_InitLoadInstrument3 + + Mov AL, [CS:InstrumentDirectory] ; AL = drive letter + Cmp AL, [CS:CDRomStartDrive] + JL InstrumentVersionCheck + Cmp AL, [CS:CDRomEndDrive] + JGE InstrumentVersionCheck + + Cmp Word Ptr [DS:4], 211h + JB D_InitLoadInstrument3 + Cmp Word Ptr [DS:4], TRACKERVERSION + JBE D_InitLoadInstrumentsCacheOK + +InstrumentVersionCheck: + Cmp Word Ptr [DS:4], TRACKERVERSION + JNE D_InitLoadInstrument3 + +InstrumentVersionCheckEnd: + Mov AX, 5700h ; Get file date&time. + Int 21h + + Mov Word Ptr [OldCacheTime], CX + Mov Word Ptr [OldCacheTime+2], DX + + Cmp CX, Time ; Check time and date + JNE D_InitLoadInstrumentOldCache ; for 'currentness' + Cmp DX, Date + JNE D_InitLoadInstrumentOldCache + ; OK.. let's load... + +D_InitLoadInstrumentsCacheOK: + Mov AX, [DS:0] + Mov CS:InitialInstruments, AX + + Mov SI, [DS:2] ; Number of samples. + Mov AX, 48 + Mul SI + Mov CX, AX ; Bytes to read. + + Mov AH, 3Fh ; Load again. + Xor DX, DX ; In case of internal malfunc. + Int 21h + JC D_InitLoadInstrument3 + Cmp AX, CX + JNE D_InitLoadInstrument3 + + Mov AH, 3Eh ; Close file. + Int 21h + + Push CS + Pop DS + Assume DS:Disk + + Mov LoadInstrumentNameCount, SI + Mov NumInstruments, SI + Mov InstrumentCacheFileComplete, 1 + + Jmp D_InitLoadInstrument2 + +D_InitLoadInstrumentOldCache: + PushA + Push DS + + Call D_GetNumFiles + + Pop DS + JC D_InitLoadInstrument5 + + Cmp AX, [DS:0] + + PopA + JNE D_InitLoadInstrument3 + + Call Far Ptr D_InitLoadInstrumentsCacheOK + + Call D_SaveInstrumentCacheFile ; Resave it with new date + + Ret + +D_InitLoadInstrument5: + PopA + +D_InitLoadInstrument3: + Mov AH, 3Eh ; Close file. + Int 21h + + Push CS + Pop DS + Assume DS:Disk + + Call DeleteInstrumentCacheFile + +D_InitLoadInstrument1: + Call D_LoadInstrumentFiles + +D_InitLoadInstrument2: + Ret + +EndP D_InitLoadInstruments + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_LoadInstrumentNames Far + + Push CS + Pop DS + Assume DS:Disk + + Cmp InstrumentCacheFileComplete, 1 + JNE D_LoadInstrumentNames2 + +D_LoadInstrumentNames6: + Xor AX, AX ; No redraw screen. + Ret + +D_LoadInstrumentNames2: + Mov BX, LoadInstrumentNameCount + Cmp BX, NumInstruments + JAE D_LoadInstrumentNames5 + +D_LoadInstrumentNames1: + Call K_IsAnyKeyDown + And AL, AL + JNZ D_LoadInstrumentNames6 + + Call GetKeyboardLock + And AL, AL + JNZ D_LoadInstrumentNames6 + + Mov AX, 48 + Mul BX + Mov SI, AX + Mov ES, DiskDataArea + Cmp Byte Ptr [ES:SI], 0 + JNE D_LoadInstrumentNames3 + + Call D_LoadInstrumentHeader + JC D_LoadInstrumentNames3 + + Call D_GetInstrumentInfo ; BX = sample number + Push CS + Pop DS + JC D_LoadInstrumentNames7 + +D_LoadInstrumentNames3: + Push CS + Pop DS + Assume DS:Disk + + Inc LoadInstrumentNameCount + +D_LoadInstrumentNames7: + Mov BX, LoadInstrumentNameCount + Cmp BX, NumInstruments + JNE D_LoadInstrumentNames4 + ; Save cache file.. + +D_LoadInstrumentNames5: + Call D_SaveInstrumentCacheFile + Cmp CurrentInstrument, 0 + JNE D_LoadInstrumentNames4 + Call D_SlowInstrumentSort + +D_LoadInstrumentNames4: + Mov AX, 1 ; Signify redraw screen + Ret + +EndP D_LoadInstrumentNames + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DrawLoadInstrument Far + + Cmp CS:NumInstruments, 0 + JNE D_DrawLoadInstrumentPresent + + Jmp D_DrawLoadInstrumentEnd + +D_DrawLoadInstrumentPresent: + Mov BX, CS:CurrentInstrument + Mov AX, 48 + Mul BX + Mov SI, AX + Mov ES, CS:DiskDataArea + + Cmp Byte Ptr [ES:SI], 0 + JNE D_DrawLoadInstrumentWindow28 + + Call D_LoadInstrumentHeader + Call D_GetInstrumentInfo + JC D_DrawLoadInstrument + +D_DrawLoadInstrumentWindow28: + Call S_GetDestination + + Push CS + Pop DS + Assume DS:Disk + + Mov AX, TopInstrument + Mov BX, CurrentInstrument + Cmp AX, BX + JBE D_DrawLoadInstrument1 + + Mov AX, BX + +D_DrawLoadInstrument1: + LEa CX, [EAX+34] + Cmp CX, BX + JA D_DrawLoadInstrument2 + + LEA AX, [BX-34] + +D_DrawLoadInstrument2: + Mov TopInstrument, AX + + Mov DS, DiskDataArea + Assume DS:Nothing + + Mov DI, (2+13*80)*2 + Mov CX, 35 + +D_DrawLoadInstrument3: + Push AX + Push CX + Push DI + + Cmp AX, CS:NumInstruments + JB D_DrawLoadInstrument4 + + Mov AX, 2A8h + Add DI, 58 + StosW + Add DI, 24 + StosW + +D_DrawLoadInstrument10: + Add DI, 20 + StosW + + Jmp D_DrawLoadInstrument5 + +D_DrawLoadInstrument4: + Inc AX + Mov CH, 20h + Call PE_ConvAX2Num + Dec AX + + Add DI, 8 + Mov BX, 48 + Mul BX + Mov SI, AX ; SI = offset in diskdata.. + ; Name first.. + + Mov DL, [SI] + ; DL = type. 0 = unchecked + ; 1 = directory + ; 2 = unknown + ; 3 = ITI. + Mov AH, 6 + Cmp DL, 1 + JB D_DrawLoadInstrument6 + + Mov AH, 5 + JE D_DrawLoadInstrument6 + + Mov AH, 7 + Cmp DL, 2 + JE D_DrawLoadInstrument6 + + Mov AH, 3 + +D_DrawLoadInstrument6: + Mov DH, AH ; DH = col. + Mov CX, 25 ; Instrument Name + Add SI, 15 + +D_DrawLoadInstrument7: + LodsB + + Cmp AL, 226 + JB D_DrawLoadInstrumentCharFilter + + Mov AL, ' ' + +D_DrawLoadInstrumentCharFilter: + StosW + Loop D_DrawLoadInstrument7 + + Mov AX, 2A8h + StosW ; Divider 1. + + Mov AH, DH + ; File name... + Sub SI, 39 + Mov CX, 12 + +D_DrawLoadInstrument8: + LodsB + StosW + And AL, AL + LoopNZ D_DrawLoadInstrument8 + + Add DI, CX + Add DI, CX + + Mov AX, 2A8h + StosW ; Divider 2. + + Cmp DL, 3 + JB D_DrawLoadInstrument10 + + LEA SI, [ESI+ECX+27] + LodsW ; AX = number of samples. + + Push DS + Push SI + Push DI + Push AX + + Cmp Byte Ptr [SI-42], 8 + + Push CS + Pop DS + + Mov SI, Offset InstrumentLibrary + JAE D_DrawLoadInstrument9 + + Mov SI, Offset InstrumentNoSample + Cmp AX, 1 + JB D_DrawLoadInstrument9 + + Mov SI, Offset InstrumentSingleSample + JE D_DrawLoadInstrument9 + + Mov SI, Offset InstrumentSeveralSamples + Cmp AX, 0FFFFh + JNE D_DrawLoadInstrument9 + + Mov SI, Offset InstrumentUnknownSamples + +D_DrawLoadInstrument9: + Mov AH, DH + Call S_DrawString + + Pop AX + Pop DI + Pop SI + Pop DS + + Mov AX, 2A8h + Add DI, 20 + StosW ; Divider.. now file size... + + LodsW ; AX = file size. + + Push DS + + Push CS + Pop DS + Mov SI, Offset FileSizeMsg + + Push AX + Mov AH, DH + Call S_DrawString + + Pop AX + + Pop DS + +D_DrawLoadInstrument5: + Pop DI + Pop CX + Pop AX + + Inc AX + + Add DI, 160 + Loop D_DrawLoadInstrument3 + + Push CS + Pop DS + Jmp D_DrawLoadInstrumentEnd2 + +D_DrawLoadInstrumentEnd: + Push CS + Pop DS + Assume DS:Disk + + Mov DI, (6+13*80)*2 ; (6, 13) + Mov SI, Offset NoFilesMsg + + Mov AH, 5 + Call S_DrawString + +D_DrawLoadInstrumentEnd2: ; Put Unused Sample msg. + Mov AX, UnusedSamples + Push AX + + Mov SI, Offset FreeSampleMsg + Mov DI, (64+13*80)*2 + Mov AH, 20h + + Call S_DrawString + + Pop AX + + Ret + +EndP D_DrawLoadInstrument + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PreLoadInstrument Far + + Push CS + Pop DS + Assume DS:Disk + + Mov AX, CurrentInstrument + Sub AX, TopInstrument + Add AX, 13 + Mov BX, 160 + Mul BX + + Call S_GetDestination + + LEA DI, [EAX+12] + Mov CX, 56 + +D_PreLoadInstrument1: + Mov AX, [ES:DI] + + Mov AH, 32h + + Cmp AL, 0A8h + JE D_PreLoadInstrument3 + +D_PreLoadInstrument2: + Mov AH, 30h + +D_PreLoadInstrument3: + StosW + + Loop D_PreLoadInstrument1 + + Ret + + Ret + +EndP D_PreLoadInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostLoadInstrument Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset LoadInstrumentKeys + Call M_FunctionDivider + JC D_PostLoadInstrument1 + + Jmp [SI] + +D_PostLoadInstrument1: + Xor AX, AX + Ret + +EndP D_PostLoadInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_ViewInstrument Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset ViewInstrumentKeys + Call M_FunctionDivider + JC D_ViewInstrument1 + + Jmp [SI] + +D_ViewInstrument1: + Xor AX, AX + Ret + +EndP D_ViewInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIWindow_Up Far + + Assume DS:Disk + + Mov AX, CurrentInstrument + And AX, AX + JZ LIWindow_Up1 + + Dec CurrentInstrument + +LIWindow_Up1: + Mov AX, 1 + Ret + +EndP LIWindow_Up + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIWindow_Down Far + + Assume DS:Disk + + Mov AX, CurrentInstrument + + Inc AX + Cmp AX, NumInstruments + JAE LIWindow_Down1 + + Mov CurrentInstrument, AX + +LIWindow_Down1: + Mov AX, 1 + Ret + +EndP LIWindow_Down + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIWindow_PgUp Far + + Assume DS:Disk + + Mov AX, CurrentInstrument + + Sub AX, 35 + JC LIWindow_Home + + Mov CurrentInstrument, AX + +LIWindow_PgUp1: + Mov AX, 1 + Ret + +EndP LIWindow_PgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIWindow_PgDn Far + + Assume DS:Disk + + Mov AX, CurrentInstrument + + Add AX, 35 + Cmp AX, NumInstruments + JAE LIWindow_End + + Mov CurrentInstrument, AX + +LIWindow_PgDn1: + Mov AX, 1 + Ret + +EndP LIWindow_PgDn + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIWindow_Home Far + + Assume DS:Disk + Mov CurrentInstrument, 0 + + Mov AX, 1 + Ret + +EndP LIWindow_Home + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIWindow_End Far + + Assume DS:Disk + + Mov AX, NumInstruments + + Dec AX + JS LIWindow_End1 + + Mov CurrentInstrument, AX + +LIWindow_End1: + Mov AX, 1 + Ret + +EndP LIWindow_End + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIViewWindow_Tab Far + + Mov Word Ptr [ES:DI], 7 + + Mov AX, 1 + Ret + +EndP LIViewWindow_Tab + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include it_d_ri.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIViewWindow_Enter Far + + Assume DS:Disk + + Cmp NumInstruments, 0 + JE LIViewWindow_Enter2 + + Mov AX, 48 + Mul CurrentInstrument + Mov SI, AX + Assume DS:Nothing + + Mov DS, DiskDataArea + Mov DL, [DS:SI] + Cmp DL, 1 + JE LIViewWindow_Enter1 + Cmp DL, 8 + JAE LIWindow_InInstrument1 + +LIViewWindow_Enter2: + Mov AX, 1 + Ret + +EndP LIViewWindow_Enter + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LIWindow_Enter Far + + Assume DS:Disk + + Cmp NumInstruments, 0 + JE LIWindow_Enter4 + + Mov AX, 48 + Mul CurrentInstrument + Mov SI, AX + Assume DS:Nothing + + Mov DS, DiskDataArea + Mov DL, [DS:SI] + Cmp DL, 1 + JNE LIWindow_Enter1 + +LIViewWindow_Enter1: + Push DS + Push SI + + Push CS + Pop DS + Mov SI, Offset InstrumentDirectory + Call D_SetDriveDirectory + + Pop SI + Pop DS + + Inc SI + Call D_SetDriveDirectory + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset InstrumentDirectory + Call D_GetDriveDirectory + +LIWindow_EnterInModuleError: + Mov InstrumentsInModule, 0 + Call D_InitLoadInstruments + Assume DS:Nothing + + Mov CS:CurrentInstrument, 0 + +LIWindow_Enter4: + Mov AX, 1 + Ret + +LIWindow_Enter1: ; Load sample into sample list. + Cmp DL, 8 + JAE LIWindow_InInstrument1 + Cmp DL, 3 + JAE LIWindow_Enter2 + + Xor AX, AX + Ret + +LIWindow_InInstrument1: + Mov CS:InInstrumentFormat, DL + + Inc SI + ; Copy module name across + Push CS + Pop ES + Mov DI, Offset InInstrumentFileName + Mov CX, 13 + Rep MovsB + ; Open file + Push CS + Pop DS + Assume DS:Disk + + Mov CurrentInstrument, 0 + +LIWindow_EnterLoadInInstrumentData: + Mov DX, Offset InInstrumentFileName + Mov AX, 3D00h + Int 21h + JC LIWindow_EnterInModuleError + + Mov BX, AX + + Mov SI, Word Ptr InInstrumentFormat + And SI, 0FFh + Add SI, SI + + Mov NumInstruments, 1 + + Mov DS, DiskDataArea + Assume DS:Nothing + + Push DS + Pop ES + + Call [CS:InstrumentLoaderTable+SI-6] + + ; Close module + Mov AH, 3Eh + Int 21h + + ; Setup first 'directory' + + Push CS + Pop DS + Assume DS:Disk + + Xor DI, DI + Mov SI, Offset ExitInstrumentLibraryDirectory + Mov CX, 48 + Rep MovsB + + Mov InstrumentCacheFileComplete, 1 + Mov InstrumentsInModule, 1 + + Mov AX, NumInstruments + Mov LoadInstrumentNameCount, AX + + Mov AX, 1 + Ret + Assume DS:Nothing + +LIWindow_Enter2: + Mov EAX, [SI+44] + Mov CS:LoadInstrumentOffset, EAX + Mov AX, [SI+40] + Mov CS:NumInstrumentSamples, AX + + And DX, 0FFh + Sub DX, 3 + Add DX, DX + Mov BX, DX + Mov AX, [CS:InstrumentLoaderTable+BX] + Mov [CS:InstrumentLoader], AX + + Mov AX, [SI+40] + Cmp AX, UnusedSamples + JBE LIWindow_Enter5 + + Mov CX, 0FFFFh + Mov DI, Offset O1_OutOfSamplesList + Call M_Object1List + Jmp LIWindow_Enter4 + +LIWindow_Enter5: ; OK.. enough 'sample space'.. + Call Music_Stop + + ; Clean out all old samples... + ; 1. Clean out table + ; 2. Set all samples used in inst to 1 + ; 3. Step through all insts and set + ; samples to 0 + ; 4. Delete all samples with 1. + Push CS ; Step 1. + Pop ES + Mov DI, Offset InstrumentTable + Mov CX, 50 + Xor AX, AX + Rep StosW ; Step 1. Done. + + Push DS + Push SI + + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + + Call PE_GetLastInstrument + Mov DX, BX ; DX = instrument, 0 based + Add BX, BX + Mov SI, [DS:64712+BX] + Add SI, 40h + Mov CX, 120 + +ClearSamples1: + LodsW ; AH = sample. AL = note + Mov BL, AH + Mov [CS:InstrumentTable+BX], 1 + Loop Clearsamples1 + + Xor BX, BX + +ClearSamples2: + Cmp BX, DX + JE ClearSamples3 + + Mov SI, BX + Add SI, SI + Mov SI, [DS:64712+SI] + Add SI, 41h + Mov CX, 120 + +ClearSamples4: + LodsW + And AX, 0FFh + Mov DI, AX + Mov [CS:InstrumentTable+DI], 0 + Loop ClearSamples4 + +ClearSamples3: + Inc BX + Cmp BL, 99 + JB ClearSamples2 + + Xor DI, DI + +ClearSamples5: + Cmp [CS:InstrumentTable+DI+1], 0 + JE ClearSamples6 + + Mov AX, DI + Call Music_ReleaseSample + +ClearSamples6: + Inc DI + Cmp DI, 99 + JB ClearSamples5 + + Pop DX + Pop DS + ; Process. + ; 1. Reset instrument-sample table. + ; 2. Read all sample headers into mem. + ; 3. Load each sample/sample header. + ; 4. Store instrument header. + + Push CS ; Step 1. + Pop ES + Mov DI, Offset InstrumentTable + Mov CX, 50 + Xor AX, AX + Rep StosW ; Step 1. Done. + + ; OK. to do step 2. + ; a) Open file. + ; b) if error.. skip! + ; c) Load file. + + Inc DX + Mov AX, 3D00h ; Open file.. +; Mov DX, SI +; Inc DX ; DS:DX points to file name + Int 21h + + JNC LIWindow_Enter6 + + Mov AX, 1 + Ret + +LIWindow_Enter6: + Mov BX, AX ; BX = file handle. + + ; Load instrument data into DS:64000 + ; Step 3. Go through each sample. + Call [CS:InstrumentLoader] + + Call Music_GetSongSegment + Mov ES, AX + + Mov CL, [DS:64000+1Eh] + And CX, 0FFh + JZ LIWindow_Enter10 + + Push CX + + Mov DI, [ES:64912] + Add DI, 12h-80 + Xor SI, SI + Xor AX, AX + +LIWindow_Enter8: ; Figure out instrument translation + ; table first. + Inc AX + Add DI, 80 + Test Byte Ptr [ES:DI], 1 ; Sample present? + JNZ LIWindow_Enter8 + + Inc SI + Mov [CS:InstrumentTable+SI], AL + + Loop LIWindow_Enter8 + + Pop CX + + Xor SI, SI ; SI = pointer to first sample. + Mov DI, 1 ; DI = untranslated sample number. + +LIWindow_Enter9: + Push CX ; Have to load EACH sample... + Push DS + Push SI + Push ES + Push DI + + Mov DL, [CS:InstrumentTable+DI] + Xor DH, DH ; DX = translated sample number. + Dec DX + + Mov DI, DX + Add DI, DI ; DI = 2*samplenumber + Mov DI, [ES:64912+DI] ; ES:DI points to sample in mem. + + Mov CX, 48h/2 + Rep MovsW + Xor AX, AX + StosW ; Sample pointer data. + StosW + Add SI, 4 + MovsW + MovsW ; OK.. sample header transferred.. + ; Need to load sample data?? + Mov Word Ptr [ES:DI-80+2Eh], 1 + +IF NETWORKENABLED + Mov AL, NETWORK_SAMPLEHEADEROBJECT + Mov AH, DL + Call Network_AddWordToQueue +ENDIF + Test Byte Ptr [SI-80+12h], 1 + JZ LIWindow_Enter11 ; No! + + Push DX + Push DX + + Mov AX, 4200h + Mov CX, [SI-80+4Ah] + Mov DX, [SI-80+48h] + Int 21h ; Move pointer... + + Pop AX + Sub SI, 80 + Call PE_SaveCurrentPattern + Call D_LoadSampleData + Call PE_RestoreCurrentPattern + + Pop CX + +IF NETWORKENABLED + Xor DX, DX + Call Network_QueueSampleData +; Mov AL, NETWORK_SAMPLEHEADEROBJECT +; Mov AH, DL +; Call Network_AddWordToQueue +ENDIF + + + Jmp LIWindow_Enter11 + +LIWindow_Enter12: + Call PEFunction_OutOfMemoryMessage + +LIWindow_Enter11: + Pop DI + Pop ES + Pop SI + Pop DS + Pop CX + + Inc DI + Add SI, 80 + + Loop LIWindow_Enter9 + +LIWindow_Enter10: ; Now to copy instrument... + Mov AH, 3Eh + Int 21h ; Close file first. + + Call I_GetInstrumentOffset + ; DS:BX points to instrument + ; DS:64000 points to loaded instrument + ; so copy everything, but update the + ; sample numbers.. + Mov DI, BX + Push DS + Pop ES + + Mov DS, CS:DiskDataArea + + + Mov SI, 64000 + Mov CX, 40h/2 + Rep MovsW + + Mov CX, 120 + Xor BX, BX + +LIWindow_Enter7: + MovsB ; Note transferred. + LodsB + Mov BL, AL + Mov AL, [CS:InstrumentTable+BX] + StosB + Loop LIWindow_Enter7 + + Mov CX, 250/2 + Rep MovsW + + Call Music_SoundCardLoadAllSamples + + Call Music_GetInstrumentMode + JNZ LIWindow_Enter13 + + Mov CX, 3 + Mov DI, Offset O1_EnableInstrumentMode + Call M_Object1List + Test DX, DX + + JZ LIWindow_Enter13 + + Call Music_GetSongSegment + Mov DS, AX + Or Byte Ptr [DS:2Ch], 4 + +IF NETWORKENABLED + Mov CX, 1 + Mov DX, 2Ch + Call Network_SendSongDataInformation +ENDIF + +LIWindow_Enter13: + NetworkSendInstrument + Jmp Glbl_F4 + +EndP LIWindow_Enter + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_DeleteInstrumentFile Far + + Push CS + Pop DS + Assume DS:Disk + + Cmp NumInstruments, 0 + JE D_DeleteInstrumentFile1 + Cmp InstrumentsInModule, 0 + JNE D_DeleteInstrumentFile1 + + Mov AX, 48 + Mul CurrentInstrument + Mov SI, AX + Mov DS, DiskDataArea + Assume DS:Nothing + Cmp Byte Ptr [DS:SI], 1 + JBE D_DeleteInstrumentFile1 ; Don't delete dirs! + Cmp Byte Ptr [DS:SI], 8 + JAE D_DeleteInstrumentFile1 + + Push DS + Push SI + + Mov DI, Offset O1_ConfirmDelete3 + Mov CX, 4 + Call M_Object1List + + Pop SI + Pop DS + + And DX, DX ; OK to delete? + JZ D_DeleteInstrumentFile1 + + ; Delete file.... + Mov DX, SI + Inc DX + Mov AH, 41h + Int 21h + JC D_DeleteInstrumentFile1 + + Push CS + Pop DS + Assume DS:Disk + + Mov DI, SI + Add SI, 48 + + Mov CX, NumInstruments + Mov BX, CurrentInstrument + Sub CX, BX + + Mov AX, 48 + Mul CX + Mov CX, AX + + Push DS + + Mov DS, DiskDataArea + Push DS + Pop ES + + Rep MovsB + + Pop DS + + Dec NumInstruments + JZ D_DeleteInstrumentFile2 + + Cmp BX, NumInstruments + JB D_DeleteInstrumentFile2 + + Mov BX, NumInstruments + Dec BX + Mov CurrentInstrument, BX + Dec LoadInstrumentNameCount + +D_DeleteInstrumentFile2: + Cmp InstrumentCacheFileComplete, 1 + JNE D_DeleteInstrumentFile1 + + Call D_SaveInstrumentCacheFile + +D_DeleteInstrumentFile1: + Mov AX, 1 + Ret + +EndP D_DeleteInstrumentFile + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GetPreShellDirectory Far + + Push CS + Pop DS + Mov SI, Offset PreShellDirectory + + Call D_GetDriveDirectory + + Mov SI, Offset DOSDirectory + Call D_SetDriveDirectory + + + Ret + +EndP D_GetPreShellDirectory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_RestorePreShellDirectory Far + + Push CS + Pop DS + Mov SI, Offset PreShellDirectory + + Call D_SetDriveDirectory + + Ret + +EndP D_RestorePreShellDirectory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SetDriveDirectoryFar Far + + Call D_SetDriveDirectory + Ret + +EndP D_SetDriveDirectoryFar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_GetFileName Far + + Push CS + Pop DS + Mov SI, Offset FileName + + Ret + +EndP D_GetFileName + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_ResetTimer Far + + Push DS + + Push CS + Pop DS + Assume DS:Disk + + Call GetTimerCounter + Mov [EditTimer], EAX + Call ReleaseTimerData + + Call CheckTimerData + + Pop DS + Ret + +EndP D_ResetTimer + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Hours DB "0000:" +Minutes DB "00:" +Seconds DB "00", 0 + +RemainingDateMsg DB " ", 0FDh, "D, ", 0FDh, "D", 0 + +Time2Msg DB 0FDh, "D:00", 0 +TotalTime DD 0 + +Proc D_ShowTime Far + + Push CS + Pop DS + Assume DS:Disk + + Mov EDX, 3600 + Mul EDX + ShRD EAX, EDX, 16 + ShR EDX, 16 + JNZ D_ShowTimeEnd + ; EAX = number of seconds + Mov EBX, 60 + Div EBX ; EAX = minutes, EDX = seconds + + Push EDX + Xor EDX, EDX + Div EBX ; EAX = hours, EDX = minutes + + Pop ECX + Push AX ; Hours on stack, CX = seconds, DX = min + Mov BL, 10 + + Mov AX, DX + Div BL + Add AX, 3030h + Mov [Word Ptr Minutes], AX + + Mov AX, CX + Div BL + Add AX, 3030h + Mov [Word Ptr Seconds], AX + + Pop AX ; AX = hours. + Cmp AH, BL + JAE D_ShowTimeEnd + + Div BL + Add AH, '0' + Mov [Byte Ptr Hours+3], AH + Xor AH, AH + + Div BL + Add AH, '0' + Mov [Byte Ptr Hours+2], AH + Xor AH, AH + + Div BL + Add AH, '0' + Mov [Byte Ptr Hours+1], AH + Xor AH, AH + + Div BL + Add AH, '0' + Mov [Byte Ptr Hours+0], AH + Xor AH, AH + + Xor BX, BX + Mov SI, Offset Hours + +D_ShowTime1: + Cmp Byte Ptr [SI+BX], '0' + JNE D_ShowTime2 + Mov Byte Ptr [SI+BX], ' ' + Inc BX + Cmp BX, 3 + JB D_ShowTime1 + +D_ShowTime2: + Mov AH, 20h + Call S_DrawString + +D_ShowTimeEnd: + Ret + +EndP D_ShowTime + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF TIMERSCREEN + +TimerListKeys Label + + DB 0 + DW 1C8h ; Up arrow + DW D_TimerListUp + + DB 0 + DW 1D0h ; Down arrow + DW D_TimerListDown + + DB 0 + DW 1C9h ; PgUp + DW D_TimerListPgUp + + DB 0 + DW 1D1h ; PgDn + DW D_TimerListPgDn + + DB 0 + DW 0D29h ; Left Ctrl, Right Shift + '`' + DW D_ReleaseTimer + + DB 0 + DW 4529h + DW D_ToggleShowTimes + + DB 0FFh + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_PostTimerList Far + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset TimerListKeys + Call M_FunctionDivider + JC D_PostTimerList1 + + Jmp [SI] + +D_PostTimerList1: + Xor AX, AX + + Ret + +EndP D_PostTimerList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_TimerListUp Far + Assume DS:Disk + + Sub TopTimerData, 1 + AdC TopTimerData, 0 + + Mov AX, 1 + Ret + +EndP D_TimerListUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_TimerListDown Far + Assume DS:Disk + + Mov AX, TopTimerData + Cmp AX, NumTimerData + JAE D_TimerListDown1 + + Inc AX + Mov TopTimerData, AX + +D_TimerListDown1: + Mov AX, 1 + Ret + +EndP D_TimerListDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_TimerListPgUp Far + Assume DS:Disk + + Sub TopTimerData, 28 + JNC D_TimerListPgUp1 + + Mov TopTimerData, 0 + +D_TimerListPgUp1: + Mov AX, 1 + Ret + +EndP D_TimerListPgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_TimerListPgDn Far + Assume DS:Disk + + Mov AX, TopTimerData + Add AX, 28 + Cmp AX, NumTimerData + JB D_TimerListPgDn1 + + Mov AX, NumTimerData + Sub AX, 1 + AdC AX, 0 + +D_TimerListPgDn1: + Mov TopTimerData, AX + + Mov AX, 1 + Ret + +EndP D_TimerListPgDn + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ShowTimes DB 0 + +Proc D_DrawTimer Far + + Call Music_GetSongSegment + Mov ES, AX + + Mov EAX, [ES:3Ch] + Mov DI, (18+13*80)*2 + Call D_ShowTime + + Call GetTimerCounter + Sub EAX, [CS:EditTimer] + Mov DI, (18+14*80)*2 + Push EAX + Call D_ShowTime + + Pop EAX + Mov DI, (18+16*80)*2 + Add EAX, [ES:3Ch] + Call D_ShowTime + + Test ShowTimes, 1 + JZ D_DrawTimerEnd + + Assume DS:Disk + + Mov CX, 28 + Mov SI, TopTimerData + Mov AX, TimerData + Test AX, AX + JZ D_DrawTimerEnd + Mov ES, AX + Mov AX, SI + ShL SI, 3 + Mov DI, (4+20*80)*2 + + Mov BX, 4 + Mov TotalTime, 0 + +D_DrawTimer2: + Cmp BX, SI + JA D_DrawTimer1 + + Mov EDX, [ES:BX] + Add TotalTime, EDX + Add BX, 8 + Jmp D_DrawTimer2 + +D_DrawTimer1: + Cmp AX, NumTimerData + JAE D_DrawTimerEnd + PushA + ; Data formats: yyyyyyym mmmddddd + ; hhhhhmmm mmmsssss + SegES LodsD + + Push SI + Push DI + ; AX = yyyyyyym mmmddddd + Mov BX, AX + ShR AX, 9 + Add AX, 1980 + Push AX ; Year + Mov AX, BX + And AX, 1Fh + Push AX + + ShR BX, 5 + And BX, 0Fh + Add BX, BX + + Mov SI, [MonthNames+BX] + Mov AH, 20h + Call S_DrawString + + Mov SI, Offset RemainingDateMsg + Call S_DrawString + + Pop AX ; Clean up stack + Pop AX + + Pop DI + Add DI, 50 + Push DI + + ; time + ShR EAX, 21 ; AX = hhh hhmmmmmm + Mov BX, AX + ShR BX, 6 + Push BX + Mov BL, 10 + And AX, 3Fh + Div BL + Add AX, '00' + Mov Word Ptr [Time2Msg+3], AX ; Minutes done. + + Mov SI, Offset Time2Msg + Mov AH, 20h + Call S_DrawString + Pop AX + + Pop DI + Pop SI + + Add DI, 30 + SegES LodSD + Add TotalTime, EAX + Call D_ShowTime + + Add DI, 20 + + Mov EAX, TotalTime + Call D_ShowTime + + PopA + Add SI, 8 + Add DI, 160 + Inc AX + Loop D_DrawTimer1 + +D_DrawTimerEnd: + Xor AX, AX + Ret + +EndP D_DrawTimer + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_ReleaseTimer Far + + Call ReleaseTimerData + Inc AX + Ret + +EndP D_ReleaseTimer + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF TIMERSCREEN + +Proc D_ToggleShowTimes Far + Assume DS:Disk + + Xor ShowTimes, 1 + + Mov AX, 1 + Ret + +EndP D_ToggleShowTimes + Assume DS:Nothing + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SlowSampleSort Far + + Push CS + Pop DS + Assume DS:Disk + +IF SORTENABLED + Cmp SamplesInModule, 1 + JE D_SlowSampleSortExit + Cmp SampleCacheFileComplete, 1 + JNE D_SlowSampleSortExit + Mov CX, NumSamples + + Mov SampleInMemory, 0FFFFh + Mov SampleCheck, 0FFFFh + + Mov ES, DiskDataArea + Push ES + Pop DS + Assume DS:Nothing + + Xor SI, SI + + Cmp Word Ptr [SI+4], '\' + JNE SlowSampleSortNoSort1 + + Add SI, 60h + Dec CX + +SlowSampleSortNoSort1: + Cmp Word Ptr [SI+4], '..' + JNE SlowSampleSortNoSort2 + + Add SI, 60h + Dec CX + +SlowSampleSortNoSort2: + Cmp CX, 0 + JLE D_SlowSampleSortExit + +SlowSampleSortLoop1: + Push CX + Push SI + + Mov AL, [SI+5Ah] + Mov DX, SI ; DX = destination of SI + Mov DI, SI + Mov BX, CX + +SlowSampleSortLoop2: + +; SI = current lowest. + +; Sort priority: 0 = directory +; 1 = library +; 2 = recognised +; 3 = unknown + + Cmp AL, [DI+5Ah] + JB D_CompareSamples2 + JA D_CompareSamples1 + + Push SI + Push DI + + Mov CX, 13 + Add SI, 4 + Add DI, 4 + RepE CmpSB + Pop DI + Pop SI + + JBE D_CompareSamples2 + +D_CompareSamples1: + Mov AL, [DI+5Ah] + Mov SI, DI + +D_CompareSamples2: + Add DI, 60h + + Dec BX + JNZ SlowSampleSortLoop2 + + Cmp SI, DX + JE D_CompareSamplesNoSwap + + + Push DI + Mov CX, 24 + Rep MovsD + + LEA DI, [SI-60h] + Mov SI, DX + Mov CX, 24 + Rep MovsD + + Pop SI + Mov DI, DX + Mov CX, 24 + Rep MovsD + +D_CompareSamplesNoSwap: + Pop SI + Pop CX + + Add SI, 60h + + Dec CX + JNZ SlowSampleSortLoop1 + + Call D_SaveSampleCacheFile ; Resave it with new date + +D_SlowSampleSortExit: + +ENDIF + + Mov AX, 1 + Ret + +EndP D_SlowSampleSort + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc D_SlowInstrumentSort Far + + Push CS + Pop DS + Assume DS:Disk + +IF SORTENABLED + Cmp InstrumentsInModule, 1 + JE D_SlowInstrumentSortExit + Cmp InstrumentCacheFileComplete, 1 + JNE D_SlowInstrumentSortExit + Mov CX, NumInstruments + + Mov ES, DiskDataArea + Push ES + Pop DS + Assume DS:Nothing + + Xor SI, SI + + Cmp Word Ptr [SI+1], '\' + JNE SlowInstrumentSortNoSort1 + + Add SI, 30h + Dec CX + +SlowInstrumentSortNoSort1: + Cmp Word Ptr [SI+1], '..' + JNE SlowInstrumentSortNoSort2 + + Add SI, 30h + Dec CX + +SlowInstrumentSortNoSort2: + Cmp CX, 0 + JLE D_SlowInstrumentSortExit + +SlowInstrumentSortLoop1: + Push CX + Push SI + + Mov AL, [SI] + Mov DX, SI ; DX = destination of SI + Mov DI, SI + Mov BX, CX + +SlowInstrumentSortLoop2: + Mov AH, [DI] + +; SI = current lowest. + + Cmp AL, 1 + JNE SlowInstrumentSort3 + Cmp AH, 1 + JE SlowInstrumentFilename + Jmp D_CompareInstruments2 + +SlowInstrumentsort3: + Cmp AH, 1 + JE D_CompareInstruments1 + + Test AL, 8 + JZ SlowInstrumentSort4 + Test AH, 8 + JNZ SlowInstrumentFileName + Jmp D_CompareInstruments2 + +SlowInstrumentsort4: + Test AH, 8 + JNZ D_CompareInstruments1 + +SlowInstrumentFilename: + Push SI + Push DI + + Mov CX, 13 + Inc SI + Inc DI + RepE CmpSB + Pop DI + Pop SI + + JBE D_CompareInstruments2 + +D_CompareInstruments1: + Mov AL, AH + Mov SI, DI + +D_CompareInstruments2: + Add DI, 30h + + Dec BX + JNZ SlowInstrumentSortLoop2 + + Cmp SI, DX + JE D_CompareInstrumentsNoSwap + + Push DI + Mov CX, 12 + Rep MovsD + + LEA DI, [SI-30h] + Mov SI, DX + Mov CX, 12 + Rep MovsD + + Pop SI + Mov DI, DX + Mov CX, 12 + Rep MovsD + +D_CompareInstrumentsNoSwap: + Pop SI + Pop CX + + Add SI, 30h + + Dec CX + JNZ SlowInstrumentSortLoop1 + + Call D_SaveInstrumentCacheFile ; Resave it with new date + +D_SlowInstrumentSortExit: + +ENDIF + + Mov AX, 1 + Ret + +EndP D_SlowInstrumentSort + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment DiskData PARA Public 'Data' + DB 65536 Dup (0) +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_DISPL.ASM b/it_displ.s similarity index 96% rename from IT_DISPL.ASM rename to it_displ.s index 4c32729..909ef85 100644 --- a/IT_DISPL.ASM +++ b/it_displ.s @@ -1,4485 +1,4485 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Display Module!! ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386 - -include switch.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Pattern WORD Public 'Code' USE16 - Extrn Order:Word -EndS - -Segment Object1 BYTE Public 'Data' USE16 -EndS - -Segment Glbl BYTE Public 'Code' USE16 - Extrn CurrentMode:Byte -EndS - -IF SPECTRUMANALYSER - Extrn Fourier_Start:Far -ENDIF - Extrn S_GetDestination:Far - Extrn S_DrawBox:Far - Extrn S_DrawString:Far - Extrn Music_GetOutputWaveform:Far - Extrn Music_GetInstrumentMode:Far - Extrn Music_GetSongSegment:Far - Extrn Music_GetSampleLocation:Far - Extrn Music_GetHostChannelInformationTable:Far - Extrn Music_GetSlaveChannelInformationTable:Far - Extrn Music_NextOrder:Far - Extrn Music_LastOrder:Far - Extrn Music_GetPlayMode:Far - Extrn Music_GetPlayMode2:Far - Extrn Music_GetPattern:Far - Extrn Music_ToggleChannel:Far - Extrn Music_SoloChannel:Far - Extrn Music_GetDisplayVariables:Far - Extrn Music_InitStereo:Far -; Extrn Music_UpdateSampleLocation:Far - Extrn Music_Poll:Far - Extrn Music_ToggleReverse:Far - Extrn Music_GetLastChannel:far - Extrn Music_GetPatternLength:Far - - Extrn M_FunctionDivider:Far - -IF NETWORKENABLED - Extrn Network_Poll:Far -ENDIF - - Extrn O1_DisplayList, O1_FullDisplayList - - Extrn PE_GetCurrentPattern:Far - Extrn PE_ConvAX2Num:Far - - Extrn PE_GotoPattern:Far - - Extrn SetInfoLine:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global DisplayPlus:Far - Global DisplayMinus:Far - Global DrawDisplayData:Far - Global PostDisplayData:Far - Global DisplayUpdateScreen:Far - Global Display_GetDisplayWindowData:Far - Global Display_SelectDisplayList:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment InfoPage BYTE Public 'Code' USE16 - Assume CS:InfoPage, DS:InfoPage - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -SLAVECHANNELSIZE EQU 128 -HOSTCHANNELSIZE EQU 80 - -PLAYMETHODS EQU 11 -DOTSDISPLAY EQU 9 - -CurrentChannel DW 0 -;CurrentSample DW 0 -;CurrentInstrument DW 0 -DisplayMode DW 0 - -DrawTrackData DW 0 ; Function to call to draw track - -DataArray DB 320 Dup (0) -DataDecode DB 384 Dup (0) -DecodeOffset DW ? ; Offset is -1 if no pat -DecodeSegment DW ? - -DecodePattern DW ? -DecodeRow DW ? -DecodeMaxRow DW ? - -PatternArrayNumber DW ? -PatternMaxRow DW ? -PatternSegment DW ? - -Channel5Msg DB " Channel xx ", 0 -Channel8Msg DB " xx ", 0 -Channel18Msg DB "xx", 0 -NoteTable DB "C-C#D-D#E-F-F#G-G#A-A#B-" -Note2Table DB "cCdDefFgGaAb" -LeftMsg DB "Left " -RightMsg DB " Right" -SurroundMsg DB "Surround " -NNAMsg DB "Cut", 0 - DB "Con", 0 - DB "Off", 0 - DB "Fde", 0 -VirtualMsg DB "NNA", 0FEh, 21h, 148, 0FEh, 12h, "Tot", 0 -DetailsMsg DB "Frequency", 0FEh, 21h, 148, 148, 0FEh, 12h - DB "Position", 0FEh, 21h, 148, 148, 0FEh, 12h - DB "Smp", 0FEh, 21h, 152, 153, 0FEh, 12h - DB "FVl", 0FEh, 21h, 148, 0FEh, 12h - DB "Vl", 0FEh, 21h, 148, 0FEh, 12h - DB "CV", 0FEh, 21h, 148, 0FEh, 12h - DB "SV", 0FEh, 21h, 148, 0FEh, 12h - DB "VE", 0FEh, 21h, 148, 0FEh, 12h - DB "Fde", 0FEh, 21h, 148, 0FEh, 12h - DB "Pn", 0FEh, 21h, 148, 0FEh, 12h - DB "PE", 0 - - -RestoreData DB 0 - -DisplayWindows Label ; Structure is 1 word - DW 0 ; 1 word, method - DB 0 ; 1 byte, top channel (+2) -; DB 1 -; DW 31 -; DW 160 - - DB 12 ; 1 byte, top line (+3) - DW 20 ; 1 word length of window (+4) - DW 12*80*2 ; 1 word offset to top left (+6) - - DW 8 - DB 0 - DB 32 - DW 3 - DW 32*80*2 - - DW 5 - DB 0 - DB 35 - DW 15 - DW 35*80*2 - - DW 11 Dup (0) - DB 0 -FullScreen DB 0 - -NumWindows DW 3 ; This cannot be moved!!! -CurrentWindow DW 0 -ProcessWindow DW 0 - -PlayMode DW 0 -CurrentRow DW 0 -CurrentPattern DW 0 -CurrentOrder DW 0 - -LastRow DW 0 -LastPattern DW 0 -LastOrder DW 0 - -WaveformLength DW 0 -Velocity DB 0 -Instrument DB 0 - -Comment ~ -Correlation Label Byte - DB 255, 254, 252, 249, 245, 240, 234, 227 - DB 219, 210, 210, 199, 187, 174, 160, 145 - - DB 129, 112, 94, 75, 55, 34, 12, 0 - DB 0, 0, 0, 0, 0, 0, 0, 0 -~ - -Destination DW 0 - -VariablesMsg DB "Active Channels: ", 0FDh, "D (", 0FDh, "D)", 13 - DB " Global Volume: ", 0FDh, "D", 0 - -StereoEnabledMsg DB "Stereo Enabled", 0 -StereoDisabledMsg DB "Stereo Disabled", 0 -VelocityMsg DB "Using velocity bars", 0 -VolumeMsg DB "Using volume bars", 0 -InstrumentMsg DB "Using Instrument names", 0 -SampleMsg DB "Using Sample names", 0 - -DisplayDataModes Label - DW Offset Display_HostChannel - DW Offset Display_5Channel - DW Offset Display_8Channel - DW Offset Display_10Channel - DW Offset Display_18Channel - DW Offset Display_24Channel - DW Offset Display_36Channel - DW Offset Display_64Channel - DW Offset Display_Variables - DW Offset Display_NoteDots -; DW Offset Display_SampleDots - DW Offset Display_Details - -DisplayListKeys Label - DB 0 ; Up arrow - DW 1C8h - DW Offset DisplayUp - - DB 0 - DW 1CBh ; Left arrow - DW Offset DisplayUp - - DB 0 - DW 1D0h ; Down arrow - DW Offset DisplayDown - - DB 0 - DW 1CDh ; Right arrow - DW Offset DisplayDown - - DB 2 - DW 1C8h - DW Offset DisplayAltUp - - DB 2 - DW 1D0h - DW Offset DisplayAltDown - - DB 0 - DW 1C7h - DW Offset DisplayHome - - DB 0 - DW 1CFh - DW Offset DisplayEnd - -; DB 0 -; DW 14Ah ; Grey minus - DB 1 - DW '-' - DW Offset DisplayMinus - -; DB 0 -; DW 14Eh ; Grey Plus - DB 1 - DW '+' - DW Offset DisplayPlus - - DB 0 - DW 1D2h ; Insert - DW Offset DisplayInsert - - DB 0 - DW 1D3h ; Delete - DW Offset DisplayDelete - - DB 0 ; PgUp - DW 1C9h - DW Offset DisplayPageUp - - DB 0 ; PgDn - DW 1D1h - DW Offset DisplayPageDown - - DB 0 ; Tab - DW 10Fh - DW Offset DisplayNext - - DB 1 ; Shifttab - DW 0F00h - DW Offset DisplayPrevious - - DB 2 ; Alt - DW 143h ; F9 - DW Offset DisplayToggleChannel - - DB 5 - DW 'Q' - DW Offset DisplayToggleChannel - - DB 2 ; Alt - DW 144h ; F10 - DW Offset DisplaySoloChannel - - DB 1 ; Alt 'R' - DW 1300h - DW Offset DisplayToggleReverse - - DB 1 ; Alt... - DW 1F00h ; 'S' - DW Offset DisplayToggleStereo - - DB 5 - DW 'S' - DW Offset DisplaySoloChannel - - DB 5 - DW 'G' - DW Offset Display_GotoPattern - - DB 5 - DW 'V' - DW Offset DisplayToggleVelocity - - DB 5 - DW 'I' - DW Offset DisplayToggleInstrument - - DB 1 - DW ' ' - DW Offset Display_SpaceBar - - DB 1 - DW 6 ; Ctrl F - DW Offset Display_FullScreen - -IF SPECTRUMANALYSER - DB 2 ; Alt.. - DW 158h ; F12 - DW Offset Display_FourierStart -ENDIF - - DB 0FFh ; End of list - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc GetChannelColour ; Gets AH - - Push DS - Push BX - Call Music_GetSongSegment - Mov DS, AX - And BX, 0FFh - Test Byte Ptr [DS:BX+40h], 80h - Pop BX - Pop DS - JNZ GetChannelColour1 - - ; Non-muted colours. - Mov AH, 13h - Cmp BL, DL - JE GetChannelColourEnd - - Mov AH, 12h - - Mov BH, Byte Ptr ProcessWindow - Cmp BH, Byte Ptr CurrentWindow - JE GetChannelColourEnd - - Mov AH, 10h - Ret - -GetChannelColour1: ; Muted colours - Mov AH, 16h - - Cmp BL, DL - JE GetChannelColourEnd - - Mov AH, 11h - -GetChannelColourEnd: - Ret - -EndP GetChannelColour - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawChannelNumbers - - Mov CH, 0Ah - Mov CL, [CS:BP+4] - Sub CL, 2 - Mov DI, [CS:BP+6] - Add DI, (2+1*80)*2 - - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - -Display_HostChannel3: - Push CX - Push DI - - Mov AX, BX - Inc AX - Div CH - - Add AX, 3030h - - Mov DH, AH - - Mov AH, 23h - Cmp DL, BL - JE Display_HostChannel4 - - Test Byte Ptr [BX+40h], 80h - JNZ Display_HostChannel21 - - Mov AH, 21h - Mov CX, ProcessWindow - Cmp CX, CurrentWindow - JE Display_HostChannel4 - - Mov AH, 20h - Jmp Display_HostChannel32 - -Display_HostChannel4: - Test Byte Ptr [BX+40h], 80h - JZ Display_HostChannel32 - - Mov AH, 26h - -Display_HostChannel32: - StosW - Mov AL, DH - StosW - -Display_HostChannel21: - Inc BX - - Pop DI - Pop CX - Add DI, 160 - - Dec CL - JNZ Display_HostChannel3 - - Ret - -EndP DrawChannelNumbers - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawHexAL - - Cmp AL, 10 - SBB AL, 69h - DAS - - StosW - Ret - -EndP DrawHexAL - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_HostChannel - ; Draw boxes first. - Assume DS:InfoPage - - Mov ES, Destination - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Push AX - Push 29 - Add AX, [CS:BP+4] - Dec AX - Push AX - Push 27 - Call S_DrawBox - - Mov SI, SP - Mov Byte Ptr [SS:SI+4], 62 - Mov Byte Ptr [SS:SI+8], 30 - Call S_DrawBox - - Push DS - Call Music_GetSongSegment - Mov DS, AX - Test Byte Ptr [DS:2Ch], 1 - Pop DS - JZ Display_HostChannel27 - - Mov Byte Ptr [SS:SI+4], 73 - Mov Byte Ptr [SS:SI+8], 63 - Call S_DrawBox - -Display_HostChannel27: - Add SP, 10 - - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_HostChannel1 - - Mov BX, DX - -Display_HostChannel1: - LEA CX, [EDX+3] - Sub CX, [CS:BP+4] - Cmp BX, CX - JGE Display_HostChannel2 - - Mov BX, CX - -Display_HostChannel2: - Mov CX, 66 - Sub CX, [CS:BP+4] - Cmp BX, CX - JLE Display_HostChannel22 - - Mov BX, 65 - Sub BX, [CS:BP+4] - -Display_HostChannel22: - Mov [CS:BP+2], BL ; BL = top channel - - Call DrawChannelNumbers - - Mov AL, 80 ; HostChannelSize - Mul Byte Ptr [CS:BP+2] - Call Music_GetHostChannelInformationTable - Assume DS:Nothing - Add SI, AX - Mov DI, [CS:BP+6] - Add DI, (31+1*80)*2 - Mov CX, [CS:BP+4] - Sub CX, 2 - -Display_HostChannel5: ; Show vol and sample. - Push CX - Push DI - - Test Byte Ptr [SI], 4 - JZ Display_HostChannel6 - - Mov BX, [SI+24h] ; DS:BX = slave channel - - ; OK get sample number -; Mov AL, [SI+20h] - - Push DI - - Push SI - Push DS - - Push DI - - MovZX AX, Byte Ptr [BX+36h] - Inc AX - Mov DH, 10 - Div DH - Add AX, 3030h ; '0'+'0' - Cmp AL, '9' - JBE SampleNumRange1 - - Mov AX, '--' - -SampleNumRange1: - Mov DL, AH - Mov AH, 6 - StosW - Mov AL, DL - StosW - - Call Music_GetInstrumentMode - JZ Display_HostChannel23 - - MovZX AX, Byte Ptr [BX+33h] ; Instrument number - Cmp AL, 0FFh - JE Display_HostChannel23 - - Div DH - Add AX, 3030h - Mov DX, AX - - Mov AX, 6*256+'/' - StosW - - Mov AL, DL - StosW - Mov AL, DH - StosW - -Display_HostChannel23: - Mov AX, 7*256+':' - Test Byte Ptr [BX], 4 ; Note off??? - JNZ Display_HostChannel31 - - Mov AH, 6 - -Display_HostChannel31: - Cmp Byte Ptr [BX+20h], 0 - JNE Display_HostChannel7 - - Mov AH, 4 - -Display_HostChannel7: - StosW - MovZX AX, Byte Ptr [BX+36h] - Add AX, AX - Mov SI, AX - Mov DX, [BX+30h] - - Call Music_GetSongSegment - Mov DS, AX - - Mov SI, [DS:SI+64912] - Add SI, 14h - - Mov AH, 6 - Mov CX, 25 - - Test Byte Ptr [DS:2Ch], 4 ; Instrument mode? - JZ Display_HostChannel8 - Cmp CS:Instrument, 0 - JE Display_HostChannel8 - - LEA SI, [EDX+20h] - -Display_HostChannel8: - LodsB - Cmp AL, 226 - JB AvoidMouse1 - - Mov AL, ' ' - -AvoidMouse1: - StosW - Loop Display_HostChannel8 - - ; Show string... - ; Now show panning if applic - Pop DI - - Test Byte Ptr [DS:2Ch], 1 ; Stereo - JZ Display_HostChannel24 - - Pop DS - Pop SI - - Push SI - Push DS - - Add DI, 33*2 - ; Show panning. - MovZX AX, Byte Ptr [BX+25h] -; Mov AL, [DS:SI+2Eh] - Cmp AL, 100 - JE Display_HostChannel25 -; Test AL, 80h ; Should never occur -; JNZ Display_HostChannel24 - - And AL, AL - JZ Display_HostChannel29 - Cmp AL, 64 - JE Display_HostChannel30 - - ; Show thumb bar sorta thing. - Inc AX - Mov DX, AX - ShR DX, 3 - Add DX, DX - Add DI, DX - And AX, 7 - Add AX, 155 - Mov AH, 2 - StosW - - Cmp AL, 157 - JBE Display_HostChannel24 - Add AL, 5 - StosW - - Jmp Display_HostChannel24 - -Display_HostChannel29: - Mov SI, Offset LeftMsg - Jmp Display_HostChannel28 - -Display_HostChannel30: - Mov SI, Offset RightMsg - Jmp Display_HostChannel28 - -Display_HostChannel25: - Mov SI, Offset SurroundMsg - -Display_HostChannel28: - Push CS - Pop DS - Mov CX, 9 - Mov AH, 2 - -Display_HostChannel26: - LodsB - StosW - Loop Display_HostChannel26 - -Display_HostChannel24: - Pop DS - Push DS - - Mov AL, 255 - Cmp CS:Velocity, 0 - JNZ Display_HostChannel10 - Cmp Byte Ptr [BX+36h], 100 - JE Display_HostChannel10 - -; Test Byte Ptr [BX+1], 8 -; JNZ Display_HostChannel18 ; Don't display volume - - Mov EDX, [BX+2Ch] ; Initial offset. - Mov ECX, [BX+4Ch] ; Final offset - - And EDX, EDX - JNS Display_HostChannelPP1 - - Xor EDX, EDX - -Display_HostChannelPP1: - And ECX, ECX - JNS Display_HostChannelPP2 - - Xor ECX, ECX - -Display_HostChannelPP2: - Cmp Byte Ptr [BX+0Ah], 8 - JB Display_HostChannel9 ; No loop - -Comment ~ - Mov AL, [BX+0Bh] - And AL, 7Fh - Cmp AL, 2 - JB NoSampleLoop - - Mov ECX, [BX+40h] - Mov EDX, [BX+44h] - Jmp Display_HostChannel20 - -NoSampleLoop: - Cmp Byte Ptr [BX+0Ah], 8 -~ - JE Display_HostChannel19 ; Normal loop - - ; Ping pong! - Cmp ECX, EDX - JA Display_HostChannel9 - XChg ECX, EDX - Jmp Display_HostChannel9 - -Display_HostChannel19: ; Forwards loop! - Cmp ECX, EDX - JAE Display_HostChannel9 - Mov ECX, [BX+44h] - -Display_HostChannel9: - Sub ECX, EDX - JBE Display_HostChannel18 - -Display_HostChannel20: - Test Byte Ptr [BX+18h], 2 - PushF - JZ Display_HCNoDouble - - Add ECX, ECX - Add EDX, EDX - -Display_HCNoDouble: - MovZX AX, Byte Ptr [BX+36h] - Inc AX - - Push ECX - Xor CX, CX - Call Music_GetSampleLocation - Pop ECX - Add ESI, EDX - - PopF - Push BX - Mov BX, 1 - JZ Display_HostChannel8Bit - - Xor DX, DX - ShR ECX, 1 - JZ Display_HostChannelError - Or ESI, 1 - Inc BX - -Display_HostChannel8Bit: - Int 3 - - Mov DL, [SI] - Mov DH, DL ; DL = min, DH = max. - -Display_HostChannel11: - Mov AL, [SI] - Add SI, BX - JC Display_HostChannelNewSegment - -Display_HostChannelResume: - Cmp DH, AL - JL Display_HostChannel12 - - Cmp DL, AL - JG Display_HostChannel13 - -Display_HostChannel14: - Loop Display_HostChannel11 - - Pop BX - - Mov AL, DH - Sub AL, DL - Jmp Display_HostChannel10 - -Display_HostChannel13: - Mov DL, AL - Jmp Display_HostChannel14 - -Display_HostChannel12: - Mov DH, AL - Jmp Display_HostChannel14 - -Display_HostChannelNewSegment: - Add ESI, 10000h - Int 3 - Jmp Display_HostChannelResume - -Display_HostChannelError: - Pop BX - -Display_HostChannel18: ; AL = volume. - Mov AL, 0 - -Display_HostChannel10: ; AL = volume. - Pop DS - Pop SI - - Mul Byte Ptr [BX+20h] ; Final volume! - ShR AH, 1 - AdC AH, 0 ; AH = volume to show. - - Pop DI - Sub DI, 26*2 ; ES:DI points to vol deposit - Mov DH, AH - And DH, 7 - ShR AH, 3 - Mov CL, AH - - Mov AH, 5 - - Test Word Ptr [BX], 800h - JZ Display_HostChannelNotMuted - - Mov AH, 1 - -Display_HostChannelNotMuted: - And CL, CL - JZ Display_HostChannel16 - -Display_HostChannel15: - Mov AL, 176 - StosW - Mov AL, 179 - StosW - Mov AL, 182 - StosW - - Dec CL - JNZ Display_HostChannel15 - -Display_HostChannel16: ; DH contains remainder. - And DH, DH - JZ Display_HostChannel6 - - Cmp DH, 3 - JBE Display_HostChannel17 - - Mov AL, 176 - StosW - - Cmp DH, 5 - JBE Display_HostChannel17 - - Mov AL, 179 - Inc DH - StosW - -Display_HostChannel17: - Mov AL, 173 - Add AL, DH - StosW - -Display_HostChannel6: - Pop DI - Pop CX - Add DI, 160 - Add SI, HOSTCHANNELSIZE - Loop Display_HostChannel5 - - Ret - -EndP Display_HostChannel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Draw10Num - - Mov CX, 10 - Mov EBP, 10 - -Draw10Num1: - Xor EDX, EDX - Div EBP - - Add DX, '0'+2*256 - Sub DI, 2 - Mov [ES:DI], DX - - And EAX, EAX - - LoopNZ Draw10Num1 - - Add CX, CX - Sub DI, CX - - Ret - -EndP Draw10Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Draw2Num - - Xor AH, AH - Mov DL, 10 - Div DL - Add AX, 3030h - Mov DL, AH - Mov AH, 2 - StosW - Mov AL, DL - StosW - - ScasW -; Add DI, 2 - - Ret - -EndP Draw2Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Draw3Num - - Cmp AH, 10 - JB Draw3Num1 - - Xor AX, AX - -Draw3Num1: - Mov DL, 10 - Div DL - Mov DH, AH - Xor AH, AH - Div DL - Add AX, 3030h - Mov DL, AH - Mov AH, 2 - StosW - Mov AL, DL - StosW - Mov AL, DH - Add AL, 30h - StosW - - ScasW -; Add DI, 2 - - Ret - -EndP Draw3Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_Details - ; Draw boxes first. - Assume DS:InfoPage - - Mov ES, Destination - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Inc AX - Push AX - Push 30 - Add AX, [CS:BP+4] - Sub AX, 2 - Push AX - Push 27 - Call S_DrawBox - - Mov SI, SP - Mov Byte Ptr [SS:SI+4], 57 - Mov Byte Ptr [SS:SI+8], 31 - Call S_DrawBox - - Push DS - Call Music_GetSongSegment - Mov DS, AX - Test Byte Ptr [DS:2Ch], 4 - Pop DS - JZ Display_Details27 - - Mov Byte Ptr [SS:SI+4], 66 - Mov Byte Ptr [SS:SI+8], 58 - Call S_DrawBox - - Mov DI, [CS:BP+6] - Add DI, 118+160 - Mov SI, Offset VirtualMsg - Mov AH, 12h - Call S_DrawString - -Display_Details27: - Mov DI, [CS:BP+6] - Add DI, 12+160 - Mov SI, Offset DetailsMsg - Mov AH, 12h - Call S_DrawString - - Add SP, 10 - - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_Details1 - - Mov BX, DX - -Display_Details1: - LEA CX, [EDX+4] - Sub CX, [CS:BP+4] - Cmp BX, CX - JGE Display_Details2 - - Mov BX, CX - -Display_Details2: - Mov CX, 67 - Sub CX, [CS:BP+4] - Cmp BX, CX - JL Display_Details22 - - Mov BX, 67 - Sub BX, [CS:BP+4] - -Display_Details22: - Mov [CS:BP+2], BL ; BL = top channel - - Mov CH, 0Ah - Mov CL, [CS:BP+4] - Sub CL, 3 - Mov DI, [CS:BP+6] - Add DI, (2+2*80)*2 - - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - -Display_Details3: - Push CX - Push DI - - Mov AX, BX - Inc AX - Div CH - - Add AX, '00' - - Mov DH, AH - - Mov AH, 23h - Cmp DL, BL - JE Display_Details4 - - Test Byte Ptr [BX+40h], 80h - JNZ Display_Details21 - - Mov AH, 21h - Mov CX, ProcessWindow - Cmp CX, CurrentWindow - JE Display_Details4 - - Mov AH, 20h - Jmp Display_Details32 - -Display_Details4: - Test Byte Ptr [BX+40h], 80h - JZ Display_Details32 - - Mov AH, 26h - -Display_Details32: - StosW - Mov AL, DH - StosW - -Display_Details21: - Inc BX - - Pop DI - Pop CX - Add DI, 160 - - Dec CL - JNZ Display_Details3 - - Mov AL, 80 ; HostChannelSize - Mul Byte Ptr [CS:BP+2] - Call Music_GetHostChannelInformationTable - Assume DS:Nothing - Add SI, AX - Mov DI, [CS:BP+6] - Add DI, (15+2*80)*2 - Mov CX, [CS:BP+4] - Sub CX, 3 - -Display_Details5: ; Show vol and sample. - Push CX - Push SI - Push DI - - ; Draw in divisions. - Mov AX, 2A8h - Mov Word Ptr [ES:DI], AX - Mov Word Ptr [ES:DI+22], AX - Mov Word Ptr [ES:DI+40], AX - Mov Word Ptr [ES:DI+46], AX - Mov Word Ptr [ES:DI+52], AX - Mov Word Ptr [ES:DI+58], AX - Mov Word Ptr [ES:DI+64], AX - Mov Word Ptr [ES:DI+72], AX - Mov Word Ptr [ES:DI+78], AX - - ClI - - Test Byte Ptr [SI], 4 - JNZ Display_Details6 - - Add DI, 88 - - Jmp Display_Details72 - -Display_Details6: - Mov BX, [SI+24h] ; DS:BX points to virtual channel. - Mov EAX, [BX+10h] - Call Draw10Num - - Add DI, 42 - Mov EAX, [BX+4Ch] - Call Draw10Num - - Add DI, 22 - Xor AH, AH - Mov AL, [BX+36h] - Inc AX ; Sample.. - Call Draw3Num - -; Add DI, 2 - ScasW - Xor AH, AH - Mov AL, [BX+20h] ; Final vol - Call Draw3Num - - Mov AL, [BX+21h] ; Vol - Call Draw2Num - - Mov AL, [BX+23h] ; CV - Call Draw2Num - - Mov AL, [BX+24h] ; SV - ShR AL, 1 - Call Draw2Num - - Mov AL, [BX+52h] ; VE - Call Draw2Num - - Mov AX, [BX+26h] ; Fade - ShR AX, 1 - Call Draw3Num - - Mov AL, [BX+25h] ; Pan - Cmp AL, 100 - JE Display_Details13 - - Call Draw2Num - - Jmp Display_Details7 - -Display_Details13: - Mov AX, 'S'+2*256 - StosW - Mov AL, 'u' - StosW -; Add DI, 2 - ScasW - -Display_Details7: - Mov AL, [BX+62h] ; PE - Add AL, 32 - Call Draw2Num - -; Add DI, 2 - ScasW - -Display_Details72: - Push DS - Call Music_GetSongSegment - Mov DS, AX - Test Byte Ptr [DS:2Ch], 4 - Pop DS - JZ Display_Details8 - - Mov Word Ptr [ES:DI+6], 2A8h - - Test Byte Ptr [SI], 4 - JNZ Display_Details9 - - Mov AX, '-'+2*256 - StosW - StosW - StosW - - Jmp Display_Details10 - -Display_Details9: - Push SI - - Mov SI, [BX+3Bh] ; NNA - And SI, 0FFh - ShL SI, 2 - Mov AH, 2 - Mov AL, [CS:NNAMsg+SI] - StosW - Mov AL, [CS:NNAMsg+SI+1] - StosW - Mov AL, [CS:NNAMsg+SI+2] - StosW - - Pop SI - -Display_Details10: ; Time to count channels. - Mov AH, [SI+20h] - -; Add DI, 2 - ScasW - Call Music_GetSlaveChannelInformationTable - - Xor AL, AL ; AL = count. - -Display_Details11: - Mov DL, [SI+3Ah] - And DL, 7Fh - Cmp AH, DL - JNE Display_Details12 - - Test Byte Ptr [SI], 1 - JZ Display_Details12 - - Inc AX - -Display_Details12: - Add SI, SLAVECHANNELSIZE - Loop Display_Details11 - - Xor AH, AH - Call Draw3Num - -Display_Details8: - StI - - Pop DI - Pop SI - Pop CX - Add DI, 160 - Add SI, HOSTCHANNELSIZE - Loop Display_Details5 - - Ret - -EndP Display_Details - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadNextData ; Returns DS:SI to data. (unpacked) - Assume DS:InfoPage - - Mov BX, DecodePattern - Cmp BX, PatternArrayNumber - JE LoadNextData1 - - Push DI - - Push CS - Pop ES - Mov DI, Offset DataArray - Mov CX, 64 - -LoadNextData3: - Mov AX, 0FDh - StosW - Mov AL, 0FFh - StosB - Xor AL, AL - StosW - Loop LoadNextData3 - - Cmp BX, 0FFFFh - JNE LoadNextData2 - - Pop DI - Mov SI, Offset DataArray - Ret - -LoadNextData2: - ; OK... time to decode. - Mov SI, DecodeOffset - Mov DS, DecodeSegment - Assume DS:Nothing - -LoadNextData4: - LodsB - And AL, AL - JZ LoadNextData5 - - Mov DL, AL - And AL, 7Fh - Dec AX - Mov DH, AL - - Mov AH, 6 - Mul AH - Mov BX, AX - Add BX, Offset DataDecode - - Mov AL, 5 - Mul DH - Mov DI, AX - Add DI, Offset DataArray - - Mov AH, [CS:BX] - Test DL, 80h - JZ LoadNextData6 - - LodsB - Mov AH, AL - Mov [CS:BX], AL - -LoadNextData6: - Test AH, 1 - JZ LoadNextData7 - - LodsB - Mov [CS:BX+1], AL - Jmp LoadNextData8 - -LoadNextData7: - Test AH, 10h - JZ LoadNextData9 - - Mov AL, [CS:BX+1] - -LoadNextData8: - Mov [CS:DI], AL ; Note - -LoadNextData9: - Test AH, 2 - JZ LoadNextData10 - - LodsB - Mov [CS:BX+2], AL - Jmp LoadNextData11 - -LoadNextData10: - Test AH, 20h - JZ LoadNextData12 - - Mov AL, [CS:BX+2] - -LoadNextData11: - Mov [CS:DI+1], AL ; Instrument - -LoadNextData12: - Test AH, 4 - JZ LoadNextData13 - - LodsB - Mov [CS:BX+3], AL - Jmp LoadNextData14 - -LoadNextData13: - Test AH, 40h - JZ LoadNextData15 - - Mov AL, [CS:BX+3] - -LoadNextData14: - Mov [CS:DI+2], AL ; Volume - -LoadNextData15: - Test AH, 8 - JZ LoadNextData16 - - LodsW - Mov [CS:BX+4], AX - Mov [CS:DI+3], AX - Jmp LoadNextData4 - -LoadNextData16: - Test AH, 80h - JZ LoadNextData4 - - Mov AX, [CS:BX+4] - Mov [CS:DI+3], AX - Jmp LoadNextData4 - -LoadNextData5: - Push CS - Pop DS - Assume DS:InfoPage - - Mov DecodeOffset, SI - - Mov SI, Offset DataArray - - Pop DI - Ret - -LoadNextData1: - Mov SI, DecodeOffset - Add DecodeOffset, 320 - Mov DS, PatternSegment - Assume DS:Nothing - - Ret - -EndP LoadNextData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GotoRow ; DS:SI points to data. - - Push CX - - - Mov CX, CS:DecodeRow - Inc CX - -GotoRow1: - Dec CX - JZ GotoRow2 - -GotoRow3: - LodsB - And AL, AL - JZ GotoRow1 - - Mov DL, AL - And AL, 7Fh - Dec AX - Mov AH, 6 - Mul AH - Mov BX, AX - Add BX, Offset DataDecode - - Mov DH, [CS:BX] ; Mask. - Test DL, 80h - JZ GotoRow4 - - LodsB - Mov DH, AL - Mov [CS:BX], AL ; Mask - -GotoRow4: - Test DH, 1 - JZ GotoRow5 - - LodsB - Mov [CS:BX+1], AL ; Note - -GotoRow5: - Test DH, 2 - JZ GotoRow6 - - LodsB - Mov [CS:BX+2], AL ; Instrument - -GotoRow6: - Test DH, 4 - JZ GotoRow7 ; Volume - - LodsB - Mov [CS:BX+3], AL - -GotoRow7: - Test DH, 8 - JZ GotoRow3 - - LodsW - Mov [CS:BX+4], AX - Jmp GotoRow3 - -GotoRow2: - Mov CS:DecodeSegment, DS - Mov CS:DecodeOffset, SI - - Pop CX - Ret - -EndP GotoRow - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetBeforeRows ; Returns - ; CX = number of rows to show. - ; the row numbers are handled. - ; Initialises DataSegment, - ; DataOffset and Array. - Assume DS:InfoPage - - Xor CX, CX - Mov BX, CurrentRow - Mov AX, [CS:BP+4] - Sub AX, 4 - ShR AX, 1 - Sub BX, AX - JC GetBeforeRows2 - - Ret ; No rows to show! - -GetBeforeRows2: - Mov CX, BX - Neg CX ; CX = num of rows to show - - Cmp PlayMode, 1 - JE GetBeforeRows1 - ; Song.. - Mov BX, CurrentOrder - Test BX, BX - JZ GetBeforeRows3 - - Call Music_GetSongSegment - Mov ES, AX - MovZX AX, Byte Ptr [ES:BX+100h-1] - Cmp AL, 199 - JBE GetBeforeRows4 - -GetBeforeRows3: - Mov DecodePattern, 0FFFFh - Ret - -GetBeforeRows1: ; Pattern... - Mov AX, CurrentPattern - -GetBeforeRows4: - Mov DecodePattern, AX ; Now find offset. - Cmp AX, PatternArrayNumber ; CX = num rows to show - JNE GetBeforeRows5 - - Mov BX, PatternMaxRow - Sub BX, CX - Mov DecodeRow, BX - Mov AX, 320 - Mul BX - Mov DecodeOffset, AX - Jmp GetBeforeRows6 - -GetBeforeRows5: - Call Music_GetPattern - Assume DS:Nothing - LodsW - LodsW - ; AX = rows. - Sub AX, CX - Mov CS:DecodeRow, AX - Add SI, 4 - Call GotoRow - -GetBeforeRows6: ; Put numbers on screen. - Push CS - Pop DS - - JCXZ GetBeforeRows9 - - Push CX - Push DI - -GetBeforeRows7: - Mov AX, DecodeRow - Mov ES, Destination - -GetBeforeRows8: - Push CX - - Mov CH, 20h - Call PE_ConvAX2Num - - Pop CX - Inc AX - Add DI, 160 - Loop GetBeforeRows8 - - Pop DI - Pop CX - -GetBeforeRows9: - Ret - -EndP GetBeforeRows - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetAfterRows ; Returns - Assume DS:InfoPage - - Xor CX, CX - Mov BX, DecodeMaxRow - Mov AX, [CS:BP+4] - Sub AX, 3 - Mov DX, AX - Dec AX - ShR AX, 1 - Sub DX, AX - Add DX, CurrentRow - - Sub BX, DX - JC GetAfterRows2 - - Ret ; No rows to show! - -GetAfterRows2: - Mov CX, BX - Neg CX - - Cmp PlayMode, 1 - JE GetAfterRows1 - - ; Song.. - Mov BX, CurrentOrder - Cmp BX, 255 - JAE GetAfterRows3 - - Call Music_GetSongSegment - Mov ES, AX - MovZX AX, Byte Ptr [ES:BX+101h] - Cmp AL, 199 - JBE GetAfterRows4 - -GetAfterRows3: - Mov DecodePattern, 0FFFFh - Ret - -GetAfterRows1: ; Pattern... - Mov AX, CurrentPattern - -GetAfterRows4: - Mov DecodePattern, AX ; Now find offset. - Mov DecodeRow, 0 - - Cmp AX, PatternArrayNumber ; CX = num rows to show - JNE GetAfterRows5 - - Mov DecodeOffset, 0 - Jmp GetAfterRows6 - -GetAfterRows5: - Call Music_GetPattern - Assume DS:Nothing - Add SI, 8 - Mov CS:DecodeSegment, DS - - Push CS - Pop DS - Assume DS:InfoPage - - Mov DecodeOffset, SI - -GetAfterRows6: ; Put numbers on screen. - JCXZ GetAfterRows9 - - Push CX - Push DI - -GetAfterRows7: - Mov AX, DecodeRow - Mov ES, Destination - -GetAfterRows8: - Push CX - - Mov CH, 20h - Call PE_ConvAX2Num - - Pop CX - Inc AX - Add DI, 160 - Loop GetAfterRows8 - - Pop DI - Pop CX - -GetAfterRows9: - Ret - -EndP GetAfterRows - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetCurrentPatternRows ; Returns CX = number of rows to show. - Assume DS:InfoPage - - Mov BX, CurrentRow - Mov AX, [CS:BP+4] - Sub AX, 3 - - Mov CX, AX - Dec AX - ShR AX, 1 - Sub CX, AX - - Add CX, BX ; CX = final row. - Sub BX, AX - JNC GetCurrentPatternRows2 - - Xor BX, BX - ; BX = starting row. - -GetCurrentPatternRows2: - Mov AX, CurrentPattern - - Mov DecodeRow, BX - Mov DecodePattern, AX ; Now find offset. - Cmp AX, PatternArrayNumber ; BX = starting row, CX = final row. - JNE GetCurrentPatternRows5 - - Mov AX, PatternMaxRow - Mov DecodeMaxRow, AX - Cmp CX, AX - JBE GetCurrentPatternRows1 - - Mov CX, AX - -GetCurrentPatternRows1: - Mov AX, 320 - Mul BX - Mov DecodeOffset, AX - Sub CX, BX ; CX = number of rows. - Jmp GetCurrentPatternRows6 - -GetCurrentPatternRows5: - Call Music_GetPattern - Assume DS:Nothing - LodsW - LodsW - ; AX = number of rows. - Mov DecodeMaxRow, AX - - Cmp CX, AX - JBE GetCurrentPatternRows3 - - Mov CX, AX - -GetCurrentPatternRows3: - Sub CX, BX - Add SI, 4 - Call GotoRow - -GetCurrentPatternRows6: ; Put numbers on screen. - Push CS - Pop DS - - Push CX - Push DI - -GetCurrentPatternRows7: - Mov AX, DecodeRow - Mov ES, Destination - -GetCurrentPatternRows8: - Push CX - - Mov CH, 20h - Call PE_ConvAX2Num - - Pop CX - Inc AX - Add DI, 160 - Loop GetCurrentPatternRows8 - - Pop DI - Pop CX - Ret - -EndP GetCurrentPatternRows - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawHilightBar - - Mov DI, [CS:BP+6] - Mov AX, [CS:BP+4] - ShR AX, 1 - Mov AH, 160 - Mul AH - Add DI, AX - Add DI, 11 - -DrawHilightBar1: - Or Byte Ptr [ES:DI], 0E0h -; Add DI, 2 - ScasW - Dec CX - JNZ DrawHilightBar1 - - Ret - -EndP DrawHilightBar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayTrackData - - Cmp PlayMode, 0 - JNE DisplayTrackData1 - - Pop AX ; Pull off return address - Ret - -DisplayTrackData1: - ; Check if row is OK. - - ; Now check for early block - - Mov DI, [CS:BP+6] - Add DI, (1+2*80)*2 - - Call GetBeforeRows - JCXZ DisplayTrackData3 - -DisplayTrackData2: - Push CX - Push DI - Push DS - - Call LoadNextData ; Gets DS:SI - Call [CS:DrawTrackData] - - Pop DS - Pop DI - Pop CX - Add DI, 160 - Dec CX - JNZ DisplayTrackData2 - -DisplayTrackData3: - Call GetCurrentPatternRows - -DisplayTrackData4: - Push CX - Push DI - Push DS - - Call LoadNextData ; Gets DS:SI - Call [CS:DrawTrackData] - - Pop DS - Pop DI - Pop CX - Add DI, 160 - Dec CX - JNZ DisplayTrackData4 - - Call GetAfterRows - JCXZ DisplayTrackData6 - -DisplayTrackData5: - Push CX - Push DI - Push DS - - Call LoadNextData ; Gets DS:SI - Call [CS:DrawTrackData] - - Pop DS - Pop DI - Pop CX - Add DI, 160 - Dec CX - JNZ DisplayTrackData5 - -DisplayTrackData6: - Ret - -EndP DisplayTrackData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Show5Channel - - Mov AL, [CS:BP+2] - Mov AH, 5 - Mul AH - Add SI, AX ; DS:SI points to stuff. - - Mov CX, 0A05h - Mov ES, Destination - Add DI, 8 - -Show5Channel1: - LodsB - Cmp AL, 119 - JBE Show5Channel2 - - Mov AH, AL - Mov AL, 205 - - Cmp AH, 0FFh - JE Show5Channel3 - - Mov AL, '^' - Cmp AH, 0FEh - JE Show5Channel3 - - Mov AL, 173 ; '.' - -Show5Channel3: - Mov AH, 6 - StosW - StosW - StosW - Jmp Show5Channel4 - -Show5Channel2: ; Show note. - AAM 12 - ; AL = octave - ; AH = note. - Mov DX, AX - MovZX BX, AL - Add BX, BX - Mov AH, 6 - Mov AL, [CS:BX+NoteTable] - StosW - Mov AL, [CS:BX+NoteTable+1] - StosW - Mov AL, DH - Add AL, 30h - StosW - -Show5Channel4: ; Show ins. -; Add DI, 2 - ScasW - LodsB - - Test AL, AL - JZ Show5Channel5 - - Xor AH, AH - Div CH - Add AX, 3030h - Mov DL, AH - Mov AH, 6 - StosW - Mov AL, DL - StosW - - Jmp Show5Channel6 - -Show5Channel5: - Mov AL, 173 - StosW - StosW - -Show5Channel6: ; show vol -; Add DI, 2 - ScasW - LodsB - Cmp AL, 0FFh - JE Show5Channel7 - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC Show5ChannelNoVEffect - - Test AL, 80h - JZ Show5ChannelVEffect - - Add AH, 60 - -Show5ChannelVEffect: - Mov AL, AH - Xor AH, AH - Div CH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov DL, AH - Mov AH, 6 - StosW - Mov AL, DL - StosW - - Jmp Show5Channel8 - -Show5ChannelNoVEffect: - Mov DL, 6 - Test AL, 80h - JZ Show5Channel10 - - Mov DL, 2 - And AL, 7Fh - -Show5Channel10: - Xor AH, AH - Div CH - Add AX, 3030h - XChg DL, AH - StosW - Mov AL, DL - StosW - - Mov AH, 6 - Jmp Show5Channel8 - -Show5Channel7: - Mov AL, 173 - StosW - StosW - -Show5Channel8: -; Add DI, 2 - ScasW - LodsB - And AL, AL - JNZ Show5Channel9 - - Mov AL, '.'-'@' - -Show5Channel9: - Add AL, '@' - StosW ; Command - - LodsB ; Commandvalue. - Mov AH, AL - And AX, 0FF0h - Mov DL, AH - ShR AL, 4 - - Mov AH, 6 - Call DrawHexAL - - Mov AL, DL - Call DrawHexAL - - Dec CL - JZ Show5ChannelEnd - - Mov AX, 2A8h - StosW - - Jmp Show5Channel1 - -Show5ChannelEnd: - Ret - -EndP Show5Channel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_5Channel - Assume DS:InfoPage - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Inc AX - Push AX - Push 74 - Add AX, [CS:BP+4] - Sub AL, 2 - Push AX - Push 27 - Call S_DrawBox - - Add SP, 10 - ; Fill in text. - ; check boundaries. - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_5Channel2 - - Mov BX, DX - -Display_5Channel2: - Mov CX, DX - Sub CX, 4 - Cmp BX, CX - JGE Display_5Channel3 - - Mov BX, CX - -Display_5Channel3: - Cmp BX, 59 - JB Display_5Channel11 - - Mov BX, 59 - -Display_5Channel11: - Mov [CS:BP+2], BL ; top channel. - ; Now do channel msgs. - - Mov CX, 0A05h - Mov DI, [CS:BP+6] - Add DI, (5+1*80)*2 - Mov SI, Offset Channel5Msg - -Display_5Channel4: - MovZX AX, BL - Inc AX - Div CH - Add AX, 3030h - Mov [SI+9], AX - - Call GetChannelColour - Call S_DrawString - - Add DI, 4 - - Inc BX - Dec CL - JNZ Display_5Channel4 - - Mov [CS:DrawTrackData], Offset Show5Channel - Call DisplayTrackData - Mov CX, 69 - Call DrawHilightBar - - Ret - -EndP Display_5Channel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Show8Channel - - Mov AL, [CS:BP+2] - Mov AH, 5 - Mul AH - Add SI, AX ; DS:SI points to stuff. - - Mov CX, 0A08h - Mov ES, Destination - Add DI, 8 - -Show8Channel1: - LodsW - Cmp AL, 119 - JBE Show8Channel2 - - Mov AH, AL - Mov AL, 205 - - Cmp AH, 0FFh - JE Show8Channel3 - - Mov AL, '^' - Cmp AH, 0FEh - JE Show8Channel3 - - Mov AL, 173 ; '.' - -Show8Channel3: - Mov AH, 6 - StosW - StosW - StosW - Jmp Show8Channel4 - -Show8Channel2: ; Show note. - AAM 12 - - Mov DX, AX - MovZX BX, AL - Add BX, BX - Mov AH, 6 - Mov AL, [CS:BX+NoteTable] - StosW - Mov AL, [CS:BX+NoteTable+1] - StosW - Mov AL, DH - Add AL, 30h - StosW - -Show8Channel4: ; Show vol. - LodsB - Cmp AL, 0FFh - JE Show8Channel5 - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC Show8ChannelNoVEffect - - Test AL, 80h - JZ Show8ChannelVEffect - - Add AH, 60 - -Show8ChannelVEffect: - Mov AL, AH - Xor AH, AH - Div CH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov DL, AH - Mov AH, 2 - StosW - Mov AL, DL - StosW - - Jmp Show8Channel6 - -Show8ChannelNoVEffect: - Mov DL, 2 - Test AL, 80h - JZ Show8Channel10 - - Dec DL - And AL, 7Fh - -Show8Channel10: - Xor AH, AH - Div CH - Add AX, 3030h - XChg DL, AH - StosW - Mov AL, DL - StosW - - Jmp Show8Channel6 - -Show8Channel5: - Add DI, 4 - -Show8Channel6: - LodsB - And AL, AL - JNZ Show8Channel9 - - Mov AL, '.'-'@' - -Show8Channel9: - Add AL, '@' - Mov AH, 6 - StosW ; Command - - LodsB ; Commandvalue. - Mov AH, AL - And AX, 0FF0h - Mov DL, AH - ShR AL, 4 - - Mov AH, 6 - Call DrawHexAL - - Mov AL, DL - Call DrawHexAL - - Dec CL - JZ Show8ChannelEnd - - Mov AX, 2A8h - StosW - - Jmp Show8Channel1 - -Show8ChannelEnd: - Ret - -EndP Show8Channel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_8Channel - Assume DS:InfoPage - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Inc AX - Push AX - Push 76 - Add AX, [CS:BP+4] - Sub AL, 2 - Push AX - Push 27 - Call S_DrawBox - - Add SP, 10 - ; Fill in text. - ; check boundaries. - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_8Channel2 - - Mov BX, DX - -Display_8Channel2: - Mov CX, DX - Sub CX, 7 - Cmp BX, CX - JGE Display_8Channel3 - - Mov BX, CX - -Display_8Channel3: - Cmp BX, 56 - JB Display_8Channel11 - - Mov BX, 56 - -Display_8Channel11: - Mov [CS:BP+2], BL ; top channel. - ; Now do channel msgs. - - Mov CX, 0A08h - Mov DI, [CS:BP+6] - Add DI, (6+1*80)*2 - Mov SI, Offset Channel8Msg - -Display_8Channel4: - MovZX AX, BL - Inc AX - Div CH - Add AX, 3030h - Mov [SI+2], AX - - Call GetChannelColour - Call S_DrawString - - Add DI, 6 - - Inc BX - Dec CL - JNZ Display_8Channel4 - - Mov [CS:DrawTrackData], Offset Show8Channel - Call DisplayTrackData - Mov CX, 71 - Call DrawHilightBar - - Ret - -EndP Display_8Channel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Show10Channel - - Mov AL, [CS:BP+2] - Mov AH, 5 - Mul AH - Add SI, AX ; DS:SI points to stuff. - - Mov CX, 0A0Ah - Mov ES, Destination - Add DI, 8 - -Show10Channel1: - LodsB - Cmp AL, 119 - JBE Show10Channel2 - - Mov AH, AL - Mov AL, 205 - - Cmp AH, 0FFh - JE Show10Channel3 - - Mov AL, '^' - Cmp AH, 0FEh - JE Show10Channel3 - - Mov AL, 173 ; '.' - -Show10Channel3: - Mov AH, 6 - StosW - StosW - StosW - Jmp Show10Channel4 - -Show10Channel2: ; Show note. - AAM 12 - ; AL = octave - ; AH = note. - Mov DX, AX - MovZX BX, AL - Add BX, BX - Mov AH, 6 - Mov AL, [CS:BX+NoteTable] - StosW - Mov AL, [CS:BX+NoteTable+1] - StosW - Mov AL, DH - Add AL, 30h - StosW - -Show10Channel4: ; Show Instrument - LodsB ; AL = instrument - And AX, 0FFh - JZ Show10Channel5 ; No instrument? - Div CH - - ; AL = tens, AH = units - ShL AL, 4 - Or AL, AH - Mov AH, 0Ah - - StosW ; Instrument done. - Jmp Show10Channel6 - -Show10Channel5: - Mov AX, 184+200h - StosW - -Show10Channel6: ; Show volume - LodsB ; AL = volume - - Cmp AL, 0FFh - JE Show10Channel7 - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC ViewAllSmallNoVEffect - - Test AL, 80h - JZ ViewAllSmallVEffect1 - - Mov AL, AH - Add AL, 226 - Mov AH, 6 - StosW - Jmp Show10Channel8 - -ViewAllSmallVEffect1: - Mov AL, AH - AAM - Add AH, 0Ah - ShL AH, 4 - Or AL, AH - Mov AH, 12 - StosW -Comment ~ - Mov AL, AH - Mov AH, 0 - Div CH - ; AL = effect, AH = num - Add AL, 0Ah - ShL AL, 4 - Or AL, AH - Mov AH, 12 - StosW -~ - Jmp Show10Channel8 - -ViewAllSmallNoVEffect: -; Xor AH, AH - Mov DL, 12 ; Volume - Test AL, AL - JNS Show10Channel9 - - Mov DL, 9 - And AL, 7Fh - -Show10Channel9: -; Div CH - AAM - - ; AL = tens, AH = units - ShL AH, 4 - Or AL, AH - Mov AH, DL - - StosW - Jmp Show10Channel8 - -Show10Channel7: ; No volume - Mov AX, 184+600h - StosW - -Show10Channel8: ; Show volume - LodsB - Test AL, AL - JNZ Show10Channel10 - - Add AL, '.'-'@' - -Show10Channel10: - Add AL, '@' - Mov AH, 2 - StosW ; Command - - Mov AH, 0Ah - LodsB ; Commandvalue. - StosW - - Dec CL - JNZ Show10Channel1 - - Ret - -EndP Show10Channel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_10Channel - Assume DS:InfoPage - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Inc AX - Push AX - Push 75 - Add AX, [CS:BP+4] - Sub AL, 2 - Push AX - Push 27 - Call S_DrawBox - - Add SP, 10 - ; Fill in text. - ; check boundaries. - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_10Channel2 - - Mov BX, DX - -Display_10Channel2: - Mov CX, DX - Sub CX, 9 - Cmp BX, CX - JGE Display_10Channel3 - - Mov BX, CX - -Display_10Channel3: - Cmp BX, 54 - JB Display_10Channel11 - - Mov BX, 54 - -Display_10Channel11: - Mov [CS:BP+2], BL ; top channel. - ; Now do channel msgs. - - Mov CX, 0A0Ah - Mov DI, [CS:BP+6] - Add DI, (5+1*80)*2 - Mov SI, Offset Channel8Msg - -Display_10Channel4: - MovZX AX, BL - Inc AX - Div CH - Add AX, 3030h - Mov [SI+2], AX - - Call GetChannelColour - Call S_DrawString - -; Add DI, 2 - ScasW - - Inc BX - Dec CL - JNZ Display_10Channel4 - - Mov [CS:DrawTrackData], Offset Show10Channel - Call DisplayTrackData - Mov CX, 70 - Call DrawHilightBar - - Ret - -EndP Display_10Channel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Process3CharacterRow - - Push SI - - LodsW - Cmp AX, 0FDh - JE Show18Channel4 - - Cmp AL, 0FDh - JE Show18Channel3 - JB Show18Channel2 - - Mov AH, AL - Mov AL, 205 - - Cmp AH, 0FFh - JE Show18Channel8 - - Mov AL, '^' - Cmp AH, 0FEh - JE Show18Channel8 - - Mov AL, 173 ; '.' - -Show18Channel8: - Mov AH, 6 - StosW - StosW - StosW - Jmp Show18Channel7 - -Show18Channel2: - AAM 12 - - Mov DX, AX - MovZX BX, AL - Add BX, BX - Mov AH, 6 - Mov AL, [CS:BX+NoteTable] - StosW - Mov AL, [CS:BX+NoteTable+1] - StosW - Mov AL, DH - Add AL, 30h - StosW - - Jmp Show18Channel7 - -Show18Channel3: - MovZX AX, AH - Div CH - Add AX, 3030h - Mov DL, AH - Mov AH, 6 -; Add DI, 2 - ScasW - StosW - Mov AL, DL - StosW - Jmp Show18Channel7 - -Show18Channel4: - LodsW - Cmp AX, 0FFh - JE Show18Channel6 - - Cmp AL, 0FFh - JE Show18Channel5 - -; Add DI, 2 - ScasW - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC Show18ChannelNoVEffect - - Test AL, 80h - JZ Show18ChannelVEffect - - Add AH, 60 - -Show18ChannelVEffect: - Mov AL, AH - Xor AH, AH - Div CH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov DL, AH - Mov AH, 2 - StosW - Mov AL, DL - StosW - - Jmp Show18Channel7 - -Show18ChannelNoVEffect: - Mov DL, 2 - Test AL, 80h - JZ Show18Channel9 - - Dec DX - And AL, 7Fh - -Show18Channel9: - Xor AH, AH ; Volume - Div CH - Add AX, 3030h - XChg DL, AH - StosW - Mov AL, DL - StosW - - Jmp Show18Channel7 - -Show18Channel5: - Mov AL, AH - Add AL, '@' - Mov AH, 2 - StosW - - LodsB ; Commandvalue. - Mov AH, AL - And AX, 0FF0h - Mov DL, AH - ShR AL, 4 - - Mov AH, 2 - Call DrawHexAL - - Mov AL, DL - Call DrawHexAL - Jmp Show18Channel7 - -Show18Channel6: - Mov AX, 173+256*6 - StosW - StosW - StosW - -Show18Channel7: - Pop SI - Add SI, 5 - - Ret - -EndP Process3CharacterRow - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Show18Channel - - Mov AL, [CS:BP+2] - Mov AH, 5 - Mul AH - Add SI, AX ; DS:SI points to stuff. - - Mov CX, 0A12h - Mov ES, Destination - Add DI, 8 - -Show18Channel1: - Call Process3CharacterRow - Dec CL - JZ Show18ChannelEnd - - Mov AX, 2A8h - StosW - - Jmp Show18Channel1 - -Show18ChannelEnd: - Ret - -EndP Show18Channel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_18Channel - Assume DS:InfoPage - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Inc AX - Push AX - Push 76 - Add AX, [CS:BP+4] - Sub AL, 2 - Push AX - Push 27 - Call S_DrawBox - - Add SP, 10 - ; Fill in text. - ; check boundaries. - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_18Channel2 - - Mov BX, DX - -Display_18Channel2: - Mov CX, DX - Sub CX, 17 - Cmp BX, CX - JGE Display_18Channel3 - - Mov BX, CX - -Display_18Channel3: - Cmp BX, 46 - JB Display_18Channel11 - - Mov BX, 46 - -Display_18Channel11: - Mov [CS:BP+2], BL ; top channel. - ; Now do channel msgs. - - Mov CX, 0A12h - Mov DI, [CS:BP+6] - Add DI, (6+1*80)*2 - Mov SI, Offset Channel18Msg - -Display_18Channel4: - MovZX AX, BL - Inc AX - Div CH - Add AX, 3030h - Mov [SI], AX - - Call GetChannelColour - Call S_DrawString - - Add DI, 4 - - Inc BX - Dec CL - JNZ Display_18Channel4 - - Mov [CS:DrawTrackData], Offset Show18Channel - Call DisplayTrackData - Mov CX, 71 - Call DrawHilightBar - - Ret - -EndP Display_18Channel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Show24Channel - - Mov AL, [CS:BP+2] - Mov AH, 5 - Mul AH - Add SI, AX ; DS:SI points to stuff. - - Mov CX, 0A18h - Mov ES, Destination - Add DI, 8 - -Show24Channel1: - Call Process3CharacterRow - - Dec CL - JNZ Show24Channel1 - - Ret - -EndP Show24Channel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_24Channel - Assume DS:InfoPage - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Inc AX - Push AX - Push 77 - Add AX, [CS:BP+4] - Sub AL, 2 - Push AX - Push 27 - Call S_DrawBox - - Add SP, 10 - ; Fill in text. - ; check boundaries. - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_24Channel2 - - Mov BX, DX - -Display_24Channel2: - Mov CX, DX - Sub CX, 23 - Cmp BX, CX - JGE Display_24Channel3 - - Mov BX, CX - -Display_24Channel3: - Cmp BX, 40 - JB Display_24Channel11 - - Mov BX, 40 - -Display_24Channel11: - Mov [CS:BP+2], BL ; top channel. - ; Now do channel msgs. - - Mov CX, 0A18h - Mov DI, [CS:BP+6] - Add DI, (6+1*80)*2 - Mov SI, Offset Channel18Msg - -Display_24Channel4: - MovZX AX, BL - Inc AX - Div CH - Add AX, 3030h - Mov [SI], AX - - Call GetChannelColour - Call S_DrawString - -; Add DI, 2 - ScasW - - Inc BX - Dec CL - JNZ Display_24Channel4 - - Mov [CS:DrawTrackData], Offset Show24Channel - Call DisplayTrackData - Mov CX, 72 - Call DrawHilightBar - - Ret - -EndP Display_24Channel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Show36Channel - - Mov AL, [CS:BP+2] - Mov AH, 5 - Mul AH - Add SI, AX ; DS:SI points to stuff. - - Mov CX, 0A24h - Mov ES, Destination - Add DI, 8 - -Show36Channel1: - LodsW - - Cmp AX, 0FDh - JE Show36Channel4 - - Add SI, 3 - - Cmp AL, 0FDh - JE Show36Channel3 - JB Show36Channel2 - - Mov AH, AL - Mov AL, 205 - - Cmp AH, 0FFh - JE Show36Channel8 - - Mov AL, '^' - Cmp AH, 0FEh - JE Show36Channel8 - - Mov AL, 173 ; '.' - -Show36Channel8: - Mov AH, 6 - StosW - StosW - Jmp Show36Channel7 - -Show36Channel2: - AAM 12 - Mov BX, Offset Note2Table - SegCS XLatB - Mov DL, AH - Mov AH, 6 - StosW - - Mov AL, DL - Add AL, 30h - StosW - - Jmp Show36Channel7 - -Show36Channel3: - MovZX AX, AH - Div CH - Add AX, 3030h - Mov DL, AH - Mov AH, 6 - StosW - Mov AL, DL - StosW - - Jmp Show36Channel7 - -Show36Channel4: - LodsW - Cmp AX, 0FFh - JE Show36Channel6 - - Cmp AL, 0FFh - JE Show36Channel5 - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC Show36ChannelNoVEffect - - Test AL, 80h - JZ Show36ChannelVEffect - - Add AH, 60 - -Show36ChannelVEffect: - Mov AL, AH - Xor AH, AH - Div CH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov DL, AH - Mov AH, 2 - StosW - Mov AL, DL - StosW - - Jmp Show36ChannelEndVolume - -Show36ChannelNoVEffect: - Mov DL, 2 - Test AL, 80h - JZ Show36Channel10 - - And AL, 7Fh - Dec DX - -Show36Channel10: - - Xor AH, AH ; Volume - Div CH - Add AX, 3030h - XChg DL, AH - StosW - Mov AL, DL - StosW - -Show36ChannelEndVolume: - Inc SI - Jmp Show36Channel7 - -Show36Channel5: - Mov AL, AH - Add AL, '@' - Mov AH, 2 - StosW - LodsB - Mov AH, 0Ah - StosW - - Jmp Show36Channel7 - -Show36Channel6: - Mov AX, 173+256*6 - StosW - StosW - Inc SI - -Show36Channel7: - Dec CL - JNZ Show36Channel9 - - Ret - -Show36Channel9: - Jmp Show36Channel1 - -EndP Show36Channel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_36Channel - Assume DS:InfoPage - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Inc AX - Push AX - Push 77 - Add AX, [CS:BP+4] - Sub AL, 2 - Push AX - Push 27 - Call S_DrawBox - - Add SP, 10 - ; Fill in text. - ; check boundaries. - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_36Channel2 - - Mov BX, DX - -Display_36Channel2: - Mov CX, DX - Sub CX, 35 - Cmp BX, CX - JGE Display_36Channel3 - - Mov BX, CX - -Display_36Channel3: - Cmp BX, 28 - JB Display_36Channel11 - - Mov BX, 28 - -Display_36Channel11: - Mov [CS:BP+2], BL ; top channel. - ; Now do channel msgs. - - Mov CX, 0A24h - Mov DI, [CS:BP+6] - Add DI, (5+1*80)*2 - Mov SI, Offset Channel18Msg - -Display_36Channel4: - MovZX AX, BL - Inc AX - Div CH - Add AX, 3030h - Mov [SI], AX - - Call GetChannelColour - Call S_DrawString - - Inc BX - Dec CL - JNZ Display_36Channel4 - - Mov [CS:DrawTrackData], Offset Show36Channel - Call DisplayTrackData - Mov CX, 72 - Call DrawHilightBar - - Ret - -EndP Display_36Channel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Show64Channel - ; DS:SI points to stuff. - - Mov CX, 64 - Mov ES, Destination - Add DI, 8 - -Show64Channel1: - LodsW - - Cmp AX, 0FDh - JE Show64Channel4 - - Add SI, 3 - - Cmp AL, 0FDh - JE Show64Channel3 - JB Show64Channel2 - - Mov AH, AL - Mov AL, 205 - - Cmp AH, 0FFh - JE Show64Channel8 - - Mov AL, '^' - Cmp AH, 0FEh - JE Show64Channel8 - - Mov AL, 173 ; '.' - -Show64Channel8: - Mov AH, 6 - StosW - Jmp Show64Channel7 - -Show64Channel2: - AAM 12 - Mov BX, Offset Note2Table - SegCS XLatB - Mov AH, 6 - - StosW - Jmp Show64Channel7 - -Show64Channel3: - Mov AL, AH - AAM - ShL AH, 4 - Or AL, AH - - Mov AH, 10 - StosW - Jmp Show64Channel7 - -Show64Channel4: - LodsW - Inc SI - - Cmp AL, 0FFh - JE Show64Channel6 - - Mov DL, AL - And AX, 07Fh - - Cmp AL, 64 - JA Show64Channel6 - - AAM - ShL AH, 4 - Or AL, AH - - Mov AH, 12 - Test DL, 80h - JZ Show64ChannelVolumePan - - Mov AH, 9 - -Show64ChannelVolumePan: - StosW - - Jmp Show64Channel7 - -Show64Channel6: - Mov AX, 173+256*6 - StosW - -Show64Channel7: - Dec CX - JNZ Show64Channel9 - - Mov CX, 9 - Mov AX, 173+256*6 - Rep StosW - Ret - -Show64Channel9: - Jmp Show64Channel1 - -EndP Show64Channel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_64Channel - Assume DS:InfoPage - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Inc AX - Push AX - Push 78 - Add AX, [CS:BP+4] - Sub AL, 2 - Push AX - Push 27 - Call S_DrawBox - - Add SP, 10 - ; Now do channel msgs. - - Mov CX, 0A40h - Mov DI, [CS:BP+6] - Add DI, (5+1*80)*2 - Mov SI, Offset Channel18Msg - Xor BX, BX - Mov DL, Byte Ptr CurrentChannel - -Display_64Channel4: - MovZX AX, BL - Inc AX - Div CH - - ShL AL, 4 - Or AL, AH - Mov DH, AL - Call GetChannelColour - Or AH, 8 - Mov AL, DH - StosW - - Inc BX - Dec CL - JNZ Display_64Channel4 - - Mov AX, 1000h - Mov CX, 9 - Rep StosW - - Mov Byte Ptr [CS:BP+2], 0 - - Mov [CS:DrawTrackData], Offset Show64Channel - Call DisplayTrackData - Mov CX, 73 - Call DrawHilightBar - - Ret - -EndP Display_64Channel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_Variables - - Mov DI, [CS:BP+6] - Add DI, (2+1*80)*2 - - Call Music_GetSlaveChannelInformationTable - ; DS:SI points to tables - ; CX = numchannels. - Xor DX, DX ; DX = counter of - ; currently act. - ; channels. - Xor BX, BX - - -Display_Variables1: - Cmp Word Ptr [SI+38h], 0 - JE Display_Variables2 - - Inc BX - -Display_Variables2: - Mov AX, [SI] -; Test AH, 8 -; JNZ Display_Variables4 - - And AX, 1 - Add DX, AX - -Display_Variables4: - Add SI, SLAVECHANNELSIZE - Loop Display_Variables1 - - Push BX - Call Music_GetDisplayVariables ; AX = Current Speed - ; BX = current tempo - ; CX = global volume - ; DX = active channels - Pop BX - Push CX - Push BX - Push DX - - Push CS - Pop DS - - Mov AH, 20h - Mov AL, Byte Ptr CurrentWindow - Cmp AL, Byte Ptr ProcessWindow - JNE Display_Variables3 - - Mov AH, 23h - -Display_Variables3: - Mov SI, Offset VariablesMsg - Call S_DrawString - - Add SP, 6 - - Ret - -EndP Display_Variables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_NoteDots ; Draw boxes first. - Assume DS:InfoPage - - Mov ES, Destination - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Push AX - Push 78 - Add AX, [CS:BP+4] - Dec AX - Push AX - Push 27 - Call S_DrawBox - Add SP, 10 - - Mov DX, CurrentChannel - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_Dots1 - - Mov BX, DX - -Display_Dots1: - LEA CX, [EDX+3] - Sub CX, [CS:BP+4] - Cmp BX, CX - JGE Display_Dots2 - - Mov BX, CX - -Display_Dots2: - Mov CX, 66 - Sub CX, [CS:BP+4] - Cmp BX, CX - JLE Display_Dots3 - - Mov BX, 65 - Sub BX, [CS:BP+4] - -Display_Dots3: - Mov [CS:BP+2], BL ; BL = top channel - - Call DrawChannelNumbers - - Mov DX, [CS:BP+4] - Sub DX, 2 - Mov BL, [CS:BP+2] ; BL = channel - Mov DI, [CS:BP+6] - Add DI, (5+1*80)*2 - -Display_Dots4: - Push DI - - Push CS - Pop ES - Mov DI, Offset DataArray - Mov AX, 600h + 193 - Mov CX, 73 - Rep StosW ; DataArray cleared. - - ; OK.. loop to find channel usage. - Call Music_GetSlaveChannelInformationTable - ; Return DS:SI, CX -Display_Dots5: -; Cmp Word Ptr [SI+38h], 0 -; JE Display_Dots8 - - Test Byte Ptr [SI], 1 - JZ Display_Dots6 - - Mov AL, [SI+3Ah] - And AX, 7Fh - Cmp AL, BL - JNE Display_Dots6 ; Nope.. not the same channel - - Mov AL, [SI+32h] - Sub AL, 30 - JC Display_Dots6 - Cmp AL, 73 - JAE Display_Dots6 - - LEA DI, [DataArray+EAX+EAX] - Mov AL, [SI+20h] - Mov AH, [SI+36h] - Cmp AH, 100 - JNE Display_DotsNOMIDI - - Mov AH, [SI+33h] - -Display_DotsNoMIDI: - And AH, 3 - Add AL, 7 - ShR AL, 4 - AdC AX, 200h+193 - Test Word Ptr [SI], 800h - JZ Display_Dots7 - - Mov AH, 1 ; 6 - -Display_Dots7: - Test Byte Ptr [SI+3Ah], 80h - JZ Display_Dots9 - - Cmp Byte Ptr [CS:DI], AL - JA Display_Dots6 -Display_Dots9: - - Mov [CS:DI], AX - -Display_Dots6: - Add SI, SLAVECHANNELSIZE - - Dec CX - JNZ Display_Dots5 - -Display_Dots8: -; Dump to screen buffer. - - Pop DI - - Push CS - Pop DS - Mov SI, Offset DataArray - Mov ES, Destination - - Mov CX, 73 - Rep MovsW - - Add DI, 160-146 - - Inc BL - Dec DX - JNZ Display_Dots4 - - Ret - -EndP Display_NoteDots - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Comment ~ - -Proc Display_SampleDots ; Draw boxes first. - Assume DS:InfoPage - - Mov ES, Destination - - Mov AX, 4 ; left - Push AX - Mov AL, [CS:BP+3] - Push AX - Push 78 - Add AX, [CS:BP+4] - Dec AX - Push AX - Push 27 - Call S_DrawBox - Add SP, 10 - - Mov DX, CurrentSample - MovZX BX, Byte Ptr [CS:BP+2] - Cmp DX, BX - JAE Display_SampleDots1 - - Mov BX, DX - -Display_SampleDots1: - LEA CX, [EDX+3] - Sub CX, [CS:BP+4] - Cmp BX, CX - JGE Display_SampleDots2 - - Mov BX, CX - -Display_SampleDots2: - Mov CX, 66 - Sub CX, [CS:BP+4] - Cmp BX, CX - JLE Display_SampleDots3 - - Mov BX, 65 - Sub BX, [CS:BP+4] - -Display_SampleDots3: - Mov [CS:BP+2], BL ; BL = top channel - - Mov CL, [CS:BP+4] - Mov CH, 0Ah - Sub CL, 2 - Mov DI, [CS:BP+6] - Add DI, (2+1*80)*2 - -Display_SampleDotsNumbers1: ; BX = top number, CL = count - Inc BX - Mov AX, BX - Div CH - Add AX, 3030h - Mov DH, AH - Mov AH, 21h - StosW - Mov AL, DH - StosW - Add DI, 160-4 - Dec CL - JNZ Display_SampleDotsNumbers1 - - Mov DX, [CS:BP+4] - Sub DX, 2 - Mov BL, [CS:BP+2] ; BL = sample - Mov DI, [CS:BP+6] - Add DI, (5+1*80)*2 - -Display_SampleDots4: - Push DI - - Push CS - Pop ES - Mov DI, Offset DataArray - Mov AX, 600h + 193 - Mov CX, 73 - Rep StosW ; DataArray cleared. - - ; OK.. loop to find channel usage. - Call Music_GetSlaveChannelInformationTable - ; Return DS:SI, CX -Display_SampleDots5: - Test Byte Ptr [SI], 1 - JZ Display_SampleDots6 - - Mov AL, [SI+36h] - Cmp AL, BL - JNE Display_SampleDots6 ; Nope.. not the same channel - - MovZX AX, Byte Ptr [SI+32h] - Sub AL, 30 - JC Display_SampleDots6 - Cmp AL, 73 - JAE Display_SampleDots6 - - LEA DI, [DataArray+EAX+EAX] - Mov AL, [SI+20h] ; Volume - Mov AH, [SI+33h] ; Instrument - - And AH, 3 - Add AL, 7 - ShR AL, 4 - AdC AX, 200h+193 - Test Word Ptr [SI], 800h - JZ Display_SampleDots7 - - Mov AH, 1 ; 6 ; Muted - -Display_SampleDots7: - Cmp Byte Ptr [CS:DI], AL - JA Display_SampleDots6 - -Display_SampleDots9: - Mov [CS:DI], AX - -Display_SampleDots6: - Add SI, SLAVECHANNELSIZE - - Dec CX - JNZ Display_SampleDots5 - -Display_SampleDots8: -; Dump to screen buffer. - - Pop DI - - Push CS - Pop DS - Mov SI, Offset DataArray - Mov ES, Destination - - Mov CX, 73 - Rep MovsW - - Add DI, 160-146 - - Inc BL - Dec DX - JNZ Display_SampleDots4 - - - Ret - -EndP Display_SampleDots - -~ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawDisplayData Far - - Call PE_GetCurrentPattern - Mov CS:PatternSegment, DS - - Push CS - Pop DS - Assume DS:InfoPage - - Call S_GetDestination - Mov Destination, ES - - Mov PatternArrayNumber, AX - Mov PatternMaxRow, BX - - Call Music_GetPlayMode - Mov PlayMode, AX - Mov CurrentRow, BX - Mov CurrentPattern, CX - Mov CurrentOrder, DX - - Xor BP, BP - - Cmp CX, PatternArrayNumber - JNE DrawDisplayData1 - - Call Music_GetPatternLength - Mov PatternMaxRow, AX - -DrawDisplayData1: - Push CS - Pop DS - Assume DS:InfoPage - - Push BP - - Mov ProcessWindow, BP - - ShL BP, 3 - Add BP, Offset DisplayWindows - Mov SI, [CS:BP] - - Xor AL, AL - - Cmp FullScreen, 0 - JNE DisplayDataFull - - Cmp BP, Offset DisplayWindows - JE DisplayData2 - -DisplayDataFull: - Test SI, SI - JZ DisplayData2 - Cmp SI, DOTSDISPLAY - JE DisplayData2 - - Inc AX - - Dec Byte Ptr [CS:BP+3] ; Starting row - Inc Word Ptr [CS:BP+4] ; Length of window - Sub Word Ptr [CS:BP+6], 160 ; Offset - -DisplayData2: - Mov [RestoreData], AL - - Add SI, SI - Call [DisplayDataModes+SI] - - Push CS - Pop DS - - Cmp [RestoreData], 0 - JE DisplayData3 - - Pop BX - Push BX - - ShL BX, 3 - Add BX, Offset DisplayWindows - - Inc Byte Ptr [BX+3] - Dec Word Ptr [BX+4] - Add Word Ptr [BX+6], 160 - -DisplayData3: - Pop BP - Inc BP - Cmp BP, NumWindows - JB DrawDisplayData1 - - Mov AX, 1 - Ret - -EndP DrawDisplayData - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PostDisplayData Far - - Push CS - Pop DS - Assume DS:InfoPage - - Mov SI, Offset DisplayListKeys - Call M_FunctionDivider - JC PostDisplayData1 - - Jmp [SI] - -PostDisplayData1: - Xor AX, AX - Ret - -EndP PostDisplayData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayUp Far - Assume DS:InfoPage - - Mov AX, 1 - - Sub CurrentChannel, AX - AdC CurrentChannel, 0 - - Ret - -EndP DisplayUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayDown Far - Assume DS:InfoPage - - Mov AX, CurrentChannel - Inc AX - Cmp AX, 64 - JAE DisplayDown1 - - Mov CurrentChannel, AX - -DisplayDown1: - Mov AX, 1 - Ret - -EndP DisplayDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayPlus Far - - Call Music_NextOrder - - Mov AX, 1 - Ret - -EndP DisplayPlus - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayMinus Far - - Call Music_LastOrder - - Mov AX, 1 - Ret - -EndP DisplayMinus - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayInsert Far - Assume DS:InfoPage - - Cmp NumWindows, 5 - JAE DisplayInsert1 - - Push DS - Pop ES - - Mov AX, 8 - Mul Byte Ptr CurrentWindow ; AX = offset - Mov SI, Offset DisplayWindows - Add SI, AX - - Cmp Word Ptr [SI+4], 6 ; Length of window - JBE DisplayInsert1 - - Push SI - - Mov AX, 8 - Mul Byte Ptr NumWindows - Mov SI, Offset DisplayWindows - Add SI, AX - Mov DI, SI - Sub SI, 8 - - Mov DX, NumWindows - Sub DX, CurrentWindow - -DisplayInsert2: - Mov CX, 4 - Rep MovsW - - Sub SI, 16 - Sub DI, 16 - Dec DX - JNZ DisplayInsert2 - - Pop SI ; SI points to cur win - ; now to resize.. - Mov AX, [SI+4] ; AX = length of win - ShR AX, 1 - AdC AX, 0 - - Mov [SI+4], AX ; halve length. - Sub [SI+8+4], AX ; second one also - Add AL, [SI+3] ; Add top line - Mov [SI+8+3], AL - Mov AH, 160 - Mul AH - Mov [SI+8+6], AX - - Inc NumWindows - -DisplayInsert1: - Mov AX, 1 - Ret - -EndP DisplayInsert - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayDelete Far - Assume DS:InfoPage - - Cmp NumWindows, 1 - JBE DisplayDelete1 - - Mov AX, 8 - Mul Byte Ptr CurrentWindow ; AX = offset - Mov SI, Offset DisplayWindows - Add SI, AX - Mov DI, SI - - Mov BX, [SI+4] ; Length of deleted win - Push SI - - Add SI, 8 - - Push DS - Pop ES - - Mov DX, NumWindows - Sub DX, CurrentWindow - -DisplayDelete2: - Mov CX, 4 - Rep MovsW - - Dec DX - JNZ DisplayDelete2 - - Pop SI - ; Now to recombine. - - Dec NumWindows - - Mov AX, CurrentWindow - Cmp AX, NumWindows - JB DisplayDelete3 - - Dec CurrentWindow ; Combine with earlier. - Add [SI-8+4], BX - Jmp DisplayDelete1 - -DisplayDelete3: ; Combine with next - Add [SI+4], BX - Mov AL, [SI+3] - Sub AL, BL - Mov [SI+3], AL - Mov AH, 160 - Mul AH - Mov [SI+6], AX - -DisplayDelete1: - Mov AX, 1 - Ret - -EndP DisplayDelete - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayNext Far - Assume DS:InfoPage - - Mov AX, CurrentWindow - Inc AX - Cmp AX, NumWindows - JB DisplayNext1 - - Xor AX, AX - -DisplayNext1: - Mov CurrentWindow, AX - - Mov AX, 1 - Ret - -EndP DisplayNext - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayPrevious Far - - Mov AX, CurrentWindow - And AX, AX - JZ DisplayPrevious1 - - Dec AX - Mov CurrentWindow, AX - -DisplayPrevious1: - Mov AX, 1 - Ret - -EndP DisplayPrevious - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayAltUp Far - Assume DS:InfoPage - - Mov BX, 3 - - Mov AX, CurrentWindow - Sub AX, 1 - AdC BX, 0 - Add AX, 2 - - Cmp AX, NumWindows - JAE DisplayAltUp1 - - Mov AH, 8 - Mul AH - Mov SI, Offset DisplayWindows - Add SI, AX - - Cmp Word Ptr [SI-8+4], BX - JBE DisplayAltUp1 - - Inc Word Ptr [SI+4] - Dec Word Ptr [SI-8+4] - Dec Byte Ptr [SI+3] - Sub Word Ptr [SI+6], 160 - -DisplayAltUp1: - Mov AX, 1 - Ret - -EndP DisplayAltUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayAltDown Far - Assume DS:InfoPage - - Mov AX, CurrentWindow - Inc AX - Cmp AX, NumWindows - JAE DisplayAltDown1 - - Mov AH, 8 - Mul AH - Mov SI, Offset DisplayWindows - Add SI, AX - - Cmp Word Ptr [SI+4], 3 - JBE DisplayAltDown1 - - Inc Word Ptr [SI-8+4] - Dec Word Ptr [SI+4] - Inc Byte Ptr [SI+3] - Add Word Ptr [SI+6], 160 - -DisplayAltDown1: - Mov AX, 1 - Ret - -EndP DisplayAltDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayPageUp Far - Assume DS:InfoPage - - Mov AX, CurrentWindow - Mov AH, 8 - Mul AH - Mov SI, Offset DisplayWindows - Add SI, AX - - Mov AX, [SI] - And AX, AX - JNZ DisplayPageUp1 - - Mov AX, PLAYMETHODS - -DisplayPageUp1: - Dec AX - Mov [SI], AX - - Mov AX, 1 - Ret - -EndP DisplayPageUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayPageDown Far - Assume DS:InfoPage - - Mov AX, CurrentWindow - Mov AH, 8 - Mul AH - Mov SI, Offset DisplayWindows - Add SI, AX - - Mov AX, [SI] - Inc AX - Cmp AX, PLAYMETHODS - JB DisplayPageDown1 - - Xor AX, AX - -DisplayPageDown1: - Mov [SI], AX - - Mov AX, 1 - Ret - -EndP DisplayPageDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayHome Far - Assume DS:InfoPage - - Mov CurrentChannel, 0 - - Mov AX, 1 - Ret - -EndP DisplayHome - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayEnd Far - Assume DS:InfoPage - - Call Music_GetLastChannel - Mov CurrentChannel, AX - - Mov AX, 1 - Ret - -EndP DisplayEnd - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayToggleChannel Far - - Mov AX, CurrentChannel - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP DisplayToggleChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplaySoloChannel Far - - Mov AX, CurrentChannel - Call Music_SoloChannel - - Mov AX, 1 - Ret - -EndP DisplaySoloChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -OldEBX DD 0 -OldECX DD 0 - -Proc DisplayUpdateScreen Far - -IF NETWORKENABLED - Call Network_Poll - - Test AX, AX - JNZ DisplayUpdateScreen1 -ENDIF - - Call Music_Poll - Call Music_GetPlayMode2 - - Test AX, AX - JZ DisplayUpdateScreen3 ; Play mode 0 - update screen - - Cmp CS:OldEBX, EBX - JNE DisplayUpdateScreen2 - - Cmp CS:OldECX, ECX - JNE DisplayUpdateScreen2 - - Xor AX, AX - Ret - -DisplayUpdateScreen3: - Mov EBX, -1 - Mov ECX, EBX - -DisplayUpdateScreen2: - Mov CS:OldEBX, EBX - Mov CS:OldECX, ECX - -DisplayUpdateScreen1: - Mov AX, 1 - Ret - -EndP DisplayUpdateScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayToggleStereo Far - Assume DS:InfoPage - - Call Music_GetSongSegment - Mov ES, AX - - Mov AL, [ES:2Ch] - Xor AL, 1 - Mov [ES:2Ch], AL - - Mov SI, Offset StereoEnabledMsg - Test AL, 1 - JNZ DisplayToggleStereo1 - - Mov SI, Offset StereoDisabledMsg - -DisplayToggleStereo1: - Call SetInfoLine - Call Music_InitStereo - - Mov AX, 1 - Ret - -EndP DisplayToggleStereo - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_GetDisplayWindowData Far - - Push CS - Pop DS - Assume DS:InfoPage - - Mov DX, Offset DisplayWindows - - Ret - -EndP DIsplay_GetDisplayWindowData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_GotoPattern Far - - Call Music_GetPlayMode - Cmp AX, 1 - JB Display_GotoPattern1 - JE Display_GotoPattern2 - - Push Pattern - Pop DS - Assume DS:Pattern - - Mov Order, DX - -Display_GotoPattern2: - Mov AX, CX - ; BX = current row - Mov CX, CS:CurrentChannel - - Jmp PE_GotoPattern - -Display_GotoPattern1: - Xor AX, AX - Ret - -EndP Display_GotoPattern - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_SpaceBar Far - Assume DS:InfoPage - - Call DisplayToggleChannel - Jmp DisplayDown - -EndP Display_SpaceBar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayToggleVelocity Far - - Mov SI, Offset VolumeMsg - Xor Byte Ptr Velocity, 1 - JZ DisplayToggleVelocity1 - - Mov SI, Offset VelocityMsg - -DisplayToggleVelocity1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP DisplayToggleVelocity - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayToggleInstrument Far - - Mov SI, Offset SampleMsg - Xor Byte Ptr Instrument, 1 - JZ DisplayToggleInstrument1 - - Mov SI, Offset InstrumentMsg - -DisplayToggleInstrument1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP DisplayToggleInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DisplayToggleReverse Far - - Call Music_ToggleReverse - - Mov AX, 1 - Ret - -EndP DisplayToggleReverse - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_SelectDisplayList Far - - Cmp CS:FullScreen, 1 - JZ Display_FullScreen3 - Jmp Display_FullScreen4 - -EndP Display_SelectDisplayList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Display_FullScreen Far - - Cmp NumWindows, 1 - JE Display_FullScreen1 - - Mov AX, 1 - Ret - -Display_FullScreen1: - Push Glbl - Pop ES - Assume ES:Glbl - Mov ES:CurrentMode, 5 - Assume ES:Nothing - - Xor FullScreen, 1 - - JZ Display_FullScreen2 - - Mov Byte Ptr [DisplayWindows+3], 1 - Mov DWord Ptr [DisplayWindows+4], 160*10000h+49 - -Display_FullScreen3: - Push Glbl - Pop ES - Assume ES:Glbl - Mov ES:CurrentMode, 200 - Assume ES:Nothing - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - - Mov DX, Offset O1_FullDisplayList - Ret - -Display_FullScreen2: - Mov Byte Ptr [DisplayWindows+3], 12 - Mov DWord Ptr [DisplayWindows+4], 12*80*2*65536+38 - -Display_FullScreen4: - Push Glbl - Pop ES - Assume ES:Glbl - Mov ES:CurrentMode, 5 - Assume ES:Nothing - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - - Mov DX, Offset O1_DisplayList - Ret - -EndP Display_FullScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF SPECTRUMANALYSER - -Proc Display_FourierStart Far - - Jmp Fourier_Start - -EndP Display_FourierStart - -ENDIF - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Display Module!! ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386 + +include switch.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Pattern WORD Public 'Code' USE16 + Extrn Order:Word +EndS + +Segment Object1 BYTE Public 'Data' USE16 +EndS + +Segment Glbl BYTE Public 'Code' USE16 + Extrn CurrentMode:Byte +EndS + +IF SPECTRUMANALYSER + Extrn Fourier_Start:Far +ENDIF + Extrn S_GetDestination:Far + Extrn S_DrawBox:Far + Extrn S_DrawString:Far + Extrn Music_GetOutputWaveform:Far + Extrn Music_GetInstrumentMode:Far + Extrn Music_GetSongSegment:Far + Extrn Music_GetSampleLocation:Far + Extrn Music_GetHostChannelInformationTable:Far + Extrn Music_GetSlaveChannelInformationTable:Far + Extrn Music_NextOrder:Far + Extrn Music_LastOrder:Far + Extrn Music_GetPlayMode:Far + Extrn Music_GetPlayMode2:Far + Extrn Music_GetPattern:Far + Extrn Music_ToggleChannel:Far + Extrn Music_SoloChannel:Far + Extrn Music_GetDisplayVariables:Far + Extrn Music_InitStereo:Far +; Extrn Music_UpdateSampleLocation:Far + Extrn Music_Poll:Far + Extrn Music_ToggleReverse:Far + Extrn Music_GetLastChannel:far + Extrn Music_GetPatternLength:Far + + Extrn M_FunctionDivider:Far + +IF NETWORKENABLED + Extrn Network_Poll:Far +ENDIF + + Extrn O1_DisplayList, O1_FullDisplayList + + Extrn PE_GetCurrentPattern:Far + Extrn PE_ConvAX2Num:Far + + Extrn PE_GotoPattern:Far + + Extrn SetInfoLine:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global DisplayPlus:Far + Global DisplayMinus:Far + Global DrawDisplayData:Far + Global PostDisplayData:Far + Global DisplayUpdateScreen:Far + Global Display_GetDisplayWindowData:Far + Global Display_SelectDisplayList:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment InfoPage BYTE Public 'Code' USE16 + Assume CS:InfoPage, DS:InfoPage + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +SLAVECHANNELSIZE EQU 128 +HOSTCHANNELSIZE EQU 80 + +PLAYMETHODS EQU 11 +DOTSDISPLAY EQU 9 + +CurrentChannel DW 0 +;CurrentSample DW 0 +;CurrentInstrument DW 0 +DisplayMode DW 0 + +DrawTrackData DW 0 ; Function to call to draw track + +DataArray DB 320 Dup (0) +DataDecode DB 384 Dup (0) +DecodeOffset DW ? ; Offset is -1 if no pat +DecodeSegment DW ? + +DecodePattern DW ? +DecodeRow DW ? +DecodeMaxRow DW ? + +PatternArrayNumber DW ? +PatternMaxRow DW ? +PatternSegment DW ? + +Channel5Msg DB " Channel xx ", 0 +Channel8Msg DB " xx ", 0 +Channel18Msg DB "xx", 0 +NoteTable DB "C-C#D-D#E-F-F#G-G#A-A#B-" +Note2Table DB "cCdDefFgGaAb" +LeftMsg DB "Left " +RightMsg DB " Right" +SurroundMsg DB "Surround " +NNAMsg DB "Cut", 0 + DB "Con", 0 + DB "Off", 0 + DB "Fde", 0 +VirtualMsg DB "NNA", 0FEh, 21h, 148, 0FEh, 12h, "Tot", 0 +DetailsMsg DB "Frequency", 0FEh, 21h, 148, 148, 0FEh, 12h + DB "Position", 0FEh, 21h, 148, 148, 0FEh, 12h + DB "Smp", 0FEh, 21h, 152, 153, 0FEh, 12h + DB "FVl", 0FEh, 21h, 148, 0FEh, 12h + DB "Vl", 0FEh, 21h, 148, 0FEh, 12h + DB "CV", 0FEh, 21h, 148, 0FEh, 12h + DB "SV", 0FEh, 21h, 148, 0FEh, 12h + DB "VE", 0FEh, 21h, 148, 0FEh, 12h + DB "Fde", 0FEh, 21h, 148, 0FEh, 12h + DB "Pn", 0FEh, 21h, 148, 0FEh, 12h + DB "PE", 0 + + +RestoreData DB 0 + +DisplayWindows Label ; Structure is 1 word + DW 0 ; 1 word, method + DB 0 ; 1 byte, top channel (+2) +; DB 1 +; DW 31 +; DW 160 + + DB 12 ; 1 byte, top line (+3) + DW 20 ; 1 word length of window (+4) + DW 12*80*2 ; 1 word offset to top left (+6) + + DW 8 + DB 0 + DB 32 + DW 3 + DW 32*80*2 + + DW 5 + DB 0 + DB 35 + DW 15 + DW 35*80*2 + + DW 11 Dup (0) + DB 0 +FullScreen DB 0 + +NumWindows DW 3 ; This cannot be moved!!! +CurrentWindow DW 0 +ProcessWindow DW 0 + +PlayMode DW 0 +CurrentRow DW 0 +CurrentPattern DW 0 +CurrentOrder DW 0 + +LastRow DW 0 +LastPattern DW 0 +LastOrder DW 0 + +WaveformLength DW 0 +Velocity DB 0 +Instrument DB 0 + +Comment ~ +Correlation Label Byte + DB 255, 254, 252, 249, 245, 240, 234, 227 + DB 219, 210, 210, 199, 187, 174, 160, 145 + + DB 129, 112, 94, 75, 55, 34, 12, 0 + DB 0, 0, 0, 0, 0, 0, 0, 0 +~ + +Destination DW 0 + +VariablesMsg DB "Active Channels: ", 0FDh, "D (", 0FDh, "D)", 13 + DB " Global Volume: ", 0FDh, "D", 0 + +StereoEnabledMsg DB "Stereo Enabled", 0 +StereoDisabledMsg DB "Stereo Disabled", 0 +VelocityMsg DB "Using velocity bars", 0 +VolumeMsg DB "Using volume bars", 0 +InstrumentMsg DB "Using Instrument names", 0 +SampleMsg DB "Using Sample names", 0 + +DisplayDataModes Label + DW Offset Display_HostChannel + DW Offset Display_5Channel + DW Offset Display_8Channel + DW Offset Display_10Channel + DW Offset Display_18Channel + DW Offset Display_24Channel + DW Offset Display_36Channel + DW Offset Display_64Channel + DW Offset Display_Variables + DW Offset Display_NoteDots +; DW Offset Display_SampleDots + DW Offset Display_Details + +DisplayListKeys Label + DB 0 ; Up arrow + DW 1C8h + DW Offset DisplayUp + + DB 0 + DW 1CBh ; Left arrow + DW Offset DisplayUp + + DB 0 + DW 1D0h ; Down arrow + DW Offset DisplayDown + + DB 0 + DW 1CDh ; Right arrow + DW Offset DisplayDown + + DB 2 + DW 1C8h + DW Offset DisplayAltUp + + DB 2 + DW 1D0h + DW Offset DisplayAltDown + + DB 0 + DW 1C7h + DW Offset DisplayHome + + DB 0 + DW 1CFh + DW Offset DisplayEnd + +; DB 0 +; DW 14Ah ; Grey minus + DB 1 + DW '-' + DW Offset DisplayMinus + +; DB 0 +; DW 14Eh ; Grey Plus + DB 1 + DW '+' + DW Offset DisplayPlus + + DB 0 + DW 1D2h ; Insert + DW Offset DisplayInsert + + DB 0 + DW 1D3h ; Delete + DW Offset DisplayDelete + + DB 0 ; PgUp + DW 1C9h + DW Offset DisplayPageUp + + DB 0 ; PgDn + DW 1D1h + DW Offset DisplayPageDown + + DB 0 ; Tab + DW 10Fh + DW Offset DisplayNext + + DB 1 ; Shifttab + DW 0F00h + DW Offset DisplayPrevious + + DB 2 ; Alt + DW 143h ; F9 + DW Offset DisplayToggleChannel + + DB 5 + DW 'Q' + DW Offset DisplayToggleChannel + + DB 2 ; Alt + DW 144h ; F10 + DW Offset DisplaySoloChannel + + DB 1 ; Alt 'R' + DW 1300h + DW Offset DisplayToggleReverse + + DB 1 ; Alt... + DW 1F00h ; 'S' + DW Offset DisplayToggleStereo + + DB 5 + DW 'S' + DW Offset DisplaySoloChannel + + DB 5 + DW 'G' + DW Offset Display_GotoPattern + + DB 5 + DW 'V' + DW Offset DisplayToggleVelocity + + DB 5 + DW 'I' + DW Offset DisplayToggleInstrument + + DB 1 + DW ' ' + DW Offset Display_SpaceBar + + DB 1 + DW 6 ; Ctrl F + DW Offset Display_FullScreen + +IF SPECTRUMANALYSER + DB 2 ; Alt.. + DW 158h ; F12 + DW Offset Display_FourierStart +ENDIF + + DB 0FFh ; End of list + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc GetChannelColour ; Gets AH + + Push DS + Push BX + Call Music_GetSongSegment + Mov DS, AX + And BX, 0FFh + Test Byte Ptr [DS:BX+40h], 80h + Pop BX + Pop DS + JNZ GetChannelColour1 + + ; Non-muted colours. + Mov AH, 13h + Cmp BL, DL + JE GetChannelColourEnd + + Mov AH, 12h + + Mov BH, Byte Ptr ProcessWindow + Cmp BH, Byte Ptr CurrentWindow + JE GetChannelColourEnd + + Mov AH, 10h + Ret + +GetChannelColour1: ; Muted colours + Mov AH, 16h + + Cmp BL, DL + JE GetChannelColourEnd + + Mov AH, 11h + +GetChannelColourEnd: + Ret + +EndP GetChannelColour + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawChannelNumbers + + Mov CH, 0Ah + Mov CL, [CS:BP+4] + Sub CL, 2 + Mov DI, [CS:BP+6] + Add DI, (2+1*80)*2 + + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + +Display_HostChannel3: + Push CX + Push DI + + Mov AX, BX + Inc AX + Div CH + + Add AX, 3030h + + Mov DH, AH + + Mov AH, 23h + Cmp DL, BL + JE Display_HostChannel4 + + Test Byte Ptr [BX+40h], 80h + JNZ Display_HostChannel21 + + Mov AH, 21h + Mov CX, ProcessWindow + Cmp CX, CurrentWindow + JE Display_HostChannel4 + + Mov AH, 20h + Jmp Display_HostChannel32 + +Display_HostChannel4: + Test Byte Ptr [BX+40h], 80h + JZ Display_HostChannel32 + + Mov AH, 26h + +Display_HostChannel32: + StosW + Mov AL, DH + StosW + +Display_HostChannel21: + Inc BX + + Pop DI + Pop CX + Add DI, 160 + + Dec CL + JNZ Display_HostChannel3 + + Ret + +EndP DrawChannelNumbers + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawHexAL + + Cmp AL, 10 + SBB AL, 69h + DAS + + StosW + Ret + +EndP DrawHexAL + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_HostChannel + ; Draw boxes first. + Assume DS:InfoPage + + Mov ES, Destination + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Push AX + Push 29 + Add AX, [CS:BP+4] + Dec AX + Push AX + Push 27 + Call S_DrawBox + + Mov SI, SP + Mov Byte Ptr [SS:SI+4], 62 + Mov Byte Ptr [SS:SI+8], 30 + Call S_DrawBox + + Push DS + Call Music_GetSongSegment + Mov DS, AX + Test Byte Ptr [DS:2Ch], 1 + Pop DS + JZ Display_HostChannel27 + + Mov Byte Ptr [SS:SI+4], 73 + Mov Byte Ptr [SS:SI+8], 63 + Call S_DrawBox + +Display_HostChannel27: + Add SP, 10 + + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_HostChannel1 + + Mov BX, DX + +Display_HostChannel1: + LEA CX, [EDX+3] + Sub CX, [CS:BP+4] + Cmp BX, CX + JGE Display_HostChannel2 + + Mov BX, CX + +Display_HostChannel2: + Mov CX, 66 + Sub CX, [CS:BP+4] + Cmp BX, CX + JLE Display_HostChannel22 + + Mov BX, 65 + Sub BX, [CS:BP+4] + +Display_HostChannel22: + Mov [CS:BP+2], BL ; BL = top channel + + Call DrawChannelNumbers + + Mov AL, 80 ; HostChannelSize + Mul Byte Ptr [CS:BP+2] + Call Music_GetHostChannelInformationTable + Assume DS:Nothing + Add SI, AX + Mov DI, [CS:BP+6] + Add DI, (31+1*80)*2 + Mov CX, [CS:BP+4] + Sub CX, 2 + +Display_HostChannel5: ; Show vol and sample. + Push CX + Push DI + + Test Byte Ptr [SI], 4 + JZ Display_HostChannel6 + + Mov BX, [SI+24h] ; DS:BX = slave channel + + ; OK get sample number +; Mov AL, [SI+20h] + + Push DI + + Push SI + Push DS + + Push DI + + MovZX AX, Byte Ptr [BX+36h] + Inc AX + Mov DH, 10 + Div DH + Add AX, 3030h ; '0'+'0' + Cmp AL, '9' + JBE SampleNumRange1 + + Mov AX, '--' + +SampleNumRange1: + Mov DL, AH + Mov AH, 6 + StosW + Mov AL, DL + StosW + + Call Music_GetInstrumentMode + JZ Display_HostChannel23 + + MovZX AX, Byte Ptr [BX+33h] ; Instrument number + Cmp AL, 0FFh + JE Display_HostChannel23 + + Div DH + Add AX, 3030h + Mov DX, AX + + Mov AX, 6*256+'/' + StosW + + Mov AL, DL + StosW + Mov AL, DH + StosW + +Display_HostChannel23: + Mov AX, 7*256+':' + Test Byte Ptr [BX], 4 ; Note off??? + JNZ Display_HostChannel31 + + Mov AH, 6 + +Display_HostChannel31: + Cmp Byte Ptr [BX+20h], 0 + JNE Display_HostChannel7 + + Mov AH, 4 + +Display_HostChannel7: + StosW + MovZX AX, Byte Ptr [BX+36h] + Add AX, AX + Mov SI, AX + Mov DX, [BX+30h] + + Call Music_GetSongSegment + Mov DS, AX + + Mov SI, [DS:SI+64912] + Add SI, 14h + + Mov AH, 6 + Mov CX, 25 + + Test Byte Ptr [DS:2Ch], 4 ; Instrument mode? + JZ Display_HostChannel8 + Cmp CS:Instrument, 0 + JE Display_HostChannel8 + + LEA SI, [EDX+20h] + +Display_HostChannel8: + LodsB + Cmp AL, 226 + JB AvoidMouse1 + + Mov AL, ' ' + +AvoidMouse1: + StosW + Loop Display_HostChannel8 + + ; Show string... + ; Now show panning if applic + Pop DI + + Test Byte Ptr [DS:2Ch], 1 ; Stereo + JZ Display_HostChannel24 + + Pop DS + Pop SI + + Push SI + Push DS + + Add DI, 33*2 + ; Show panning. + MovZX AX, Byte Ptr [BX+25h] +; Mov AL, [DS:SI+2Eh] + Cmp AL, 100 + JE Display_HostChannel25 +; Test AL, 80h ; Should never occur +; JNZ Display_HostChannel24 + + And AL, AL + JZ Display_HostChannel29 + Cmp AL, 64 + JE Display_HostChannel30 + + ; Show thumb bar sorta thing. + Inc AX + Mov DX, AX + ShR DX, 3 + Add DX, DX + Add DI, DX + And AX, 7 + Add AX, 155 + Mov AH, 2 + StosW + + Cmp AL, 157 + JBE Display_HostChannel24 + Add AL, 5 + StosW + + Jmp Display_HostChannel24 + +Display_HostChannel29: + Mov SI, Offset LeftMsg + Jmp Display_HostChannel28 + +Display_HostChannel30: + Mov SI, Offset RightMsg + Jmp Display_HostChannel28 + +Display_HostChannel25: + Mov SI, Offset SurroundMsg + +Display_HostChannel28: + Push CS + Pop DS + Mov CX, 9 + Mov AH, 2 + +Display_HostChannel26: + LodsB + StosW + Loop Display_HostChannel26 + +Display_HostChannel24: + Pop DS + Push DS + + Mov AL, 255 + Cmp CS:Velocity, 0 + JNZ Display_HostChannel10 + Cmp Byte Ptr [BX+36h], 100 + JE Display_HostChannel10 + +; Test Byte Ptr [BX+1], 8 +; JNZ Display_HostChannel18 ; Don't display volume + + Mov EDX, [BX+2Ch] ; Initial offset. + Mov ECX, [BX+4Ch] ; Final offset + + And EDX, EDX + JNS Display_HostChannelPP1 + + Xor EDX, EDX + +Display_HostChannelPP1: + And ECX, ECX + JNS Display_HostChannelPP2 + + Xor ECX, ECX + +Display_HostChannelPP2: + Cmp Byte Ptr [BX+0Ah], 8 + JB Display_HostChannel9 ; No loop + +Comment ~ + Mov AL, [BX+0Bh] + And AL, 7Fh + Cmp AL, 2 + JB NoSampleLoop + + Mov ECX, [BX+40h] + Mov EDX, [BX+44h] + Jmp Display_HostChannel20 + +NoSampleLoop: + Cmp Byte Ptr [BX+0Ah], 8 +~ + JE Display_HostChannel19 ; Normal loop + + ; Ping pong! + Cmp ECX, EDX + JA Display_HostChannel9 + XChg ECX, EDX + Jmp Display_HostChannel9 + +Display_HostChannel19: ; Forwards loop! + Cmp ECX, EDX + JAE Display_HostChannel9 + Mov ECX, [BX+44h] + +Display_HostChannel9: + Sub ECX, EDX + JBE Display_HostChannel18 + +Display_HostChannel20: + Test Byte Ptr [BX+18h], 2 + PushF + JZ Display_HCNoDouble + + Add ECX, ECX + Add EDX, EDX + +Display_HCNoDouble: + MovZX AX, Byte Ptr [BX+36h] + Inc AX + + Push ECX + Xor CX, CX + Call Music_GetSampleLocation + Pop ECX + Add ESI, EDX + + PopF + Push BX + Mov BX, 1 + JZ Display_HostChannel8Bit + + Xor DX, DX + ShR ECX, 1 + JZ Display_HostChannelError + Or ESI, 1 + Inc BX + +Display_HostChannel8Bit: + Int 3 + + Mov DL, [SI] + Mov DH, DL ; DL = min, DH = max. + +Display_HostChannel11: + Mov AL, [SI] + Add SI, BX + JC Display_HostChannelNewSegment + +Display_HostChannelResume: + Cmp DH, AL + JL Display_HostChannel12 + + Cmp DL, AL + JG Display_HostChannel13 + +Display_HostChannel14: + Loop Display_HostChannel11 + + Pop BX + + Mov AL, DH + Sub AL, DL + Jmp Display_HostChannel10 + +Display_HostChannel13: + Mov DL, AL + Jmp Display_HostChannel14 + +Display_HostChannel12: + Mov DH, AL + Jmp Display_HostChannel14 + +Display_HostChannelNewSegment: + Add ESI, 10000h + Int 3 + Jmp Display_HostChannelResume + +Display_HostChannelError: + Pop BX + +Display_HostChannel18: ; AL = volume. + Mov AL, 0 + +Display_HostChannel10: ; AL = volume. + Pop DS + Pop SI + + Mul Byte Ptr [BX+20h] ; Final volume! + ShR AH, 1 + AdC AH, 0 ; AH = volume to show. + + Pop DI + Sub DI, 26*2 ; ES:DI points to vol deposit + Mov DH, AH + And DH, 7 + ShR AH, 3 + Mov CL, AH + + Mov AH, 5 + + Test Word Ptr [BX], 800h + JZ Display_HostChannelNotMuted + + Mov AH, 1 + +Display_HostChannelNotMuted: + And CL, CL + JZ Display_HostChannel16 + +Display_HostChannel15: + Mov AL, 176 + StosW + Mov AL, 179 + StosW + Mov AL, 182 + StosW + + Dec CL + JNZ Display_HostChannel15 + +Display_HostChannel16: ; DH contains remainder. + And DH, DH + JZ Display_HostChannel6 + + Cmp DH, 3 + JBE Display_HostChannel17 + + Mov AL, 176 + StosW + + Cmp DH, 5 + JBE Display_HostChannel17 + + Mov AL, 179 + Inc DH + StosW + +Display_HostChannel17: + Mov AL, 173 + Add AL, DH + StosW + +Display_HostChannel6: + Pop DI + Pop CX + Add DI, 160 + Add SI, HOSTCHANNELSIZE + Loop Display_HostChannel5 + + Ret + +EndP Display_HostChannel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Draw10Num + + Mov CX, 10 + Mov EBP, 10 + +Draw10Num1: + Xor EDX, EDX + Div EBP + + Add DX, '0'+2*256 + Sub DI, 2 + Mov [ES:DI], DX + + And EAX, EAX + + LoopNZ Draw10Num1 + + Add CX, CX + Sub DI, CX + + Ret + +EndP Draw10Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Draw2Num + + Xor AH, AH + Mov DL, 10 + Div DL + Add AX, 3030h + Mov DL, AH + Mov AH, 2 + StosW + Mov AL, DL + StosW + + ScasW +; Add DI, 2 + + Ret + +EndP Draw2Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Draw3Num + + Cmp AH, 10 + JB Draw3Num1 + + Xor AX, AX + +Draw3Num1: + Mov DL, 10 + Div DL + Mov DH, AH + Xor AH, AH + Div DL + Add AX, 3030h + Mov DL, AH + Mov AH, 2 + StosW + Mov AL, DL + StosW + Mov AL, DH + Add AL, 30h + StosW + + ScasW +; Add DI, 2 + + Ret + +EndP Draw3Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_Details + ; Draw boxes first. + Assume DS:InfoPage + + Mov ES, Destination + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Inc AX + Push AX + Push 30 + Add AX, [CS:BP+4] + Sub AX, 2 + Push AX + Push 27 + Call S_DrawBox + + Mov SI, SP + Mov Byte Ptr [SS:SI+4], 57 + Mov Byte Ptr [SS:SI+8], 31 + Call S_DrawBox + + Push DS + Call Music_GetSongSegment + Mov DS, AX + Test Byte Ptr [DS:2Ch], 4 + Pop DS + JZ Display_Details27 + + Mov Byte Ptr [SS:SI+4], 66 + Mov Byte Ptr [SS:SI+8], 58 + Call S_DrawBox + + Mov DI, [CS:BP+6] + Add DI, 118+160 + Mov SI, Offset VirtualMsg + Mov AH, 12h + Call S_DrawString + +Display_Details27: + Mov DI, [CS:BP+6] + Add DI, 12+160 + Mov SI, Offset DetailsMsg + Mov AH, 12h + Call S_DrawString + + Add SP, 10 + + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_Details1 + + Mov BX, DX + +Display_Details1: + LEA CX, [EDX+4] + Sub CX, [CS:BP+4] + Cmp BX, CX + JGE Display_Details2 + + Mov BX, CX + +Display_Details2: + Mov CX, 67 + Sub CX, [CS:BP+4] + Cmp BX, CX + JL Display_Details22 + + Mov BX, 67 + Sub BX, [CS:BP+4] + +Display_Details22: + Mov [CS:BP+2], BL ; BL = top channel + + Mov CH, 0Ah + Mov CL, [CS:BP+4] + Sub CL, 3 + Mov DI, [CS:BP+6] + Add DI, (2+2*80)*2 + + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + +Display_Details3: + Push CX + Push DI + + Mov AX, BX + Inc AX + Div CH + + Add AX, '00' + + Mov DH, AH + + Mov AH, 23h + Cmp DL, BL + JE Display_Details4 + + Test Byte Ptr [BX+40h], 80h + JNZ Display_Details21 + + Mov AH, 21h + Mov CX, ProcessWindow + Cmp CX, CurrentWindow + JE Display_Details4 + + Mov AH, 20h + Jmp Display_Details32 + +Display_Details4: + Test Byte Ptr [BX+40h], 80h + JZ Display_Details32 + + Mov AH, 26h + +Display_Details32: + StosW + Mov AL, DH + StosW + +Display_Details21: + Inc BX + + Pop DI + Pop CX + Add DI, 160 + + Dec CL + JNZ Display_Details3 + + Mov AL, 80 ; HostChannelSize + Mul Byte Ptr [CS:BP+2] + Call Music_GetHostChannelInformationTable + Assume DS:Nothing + Add SI, AX + Mov DI, [CS:BP+6] + Add DI, (15+2*80)*2 + Mov CX, [CS:BP+4] + Sub CX, 3 + +Display_Details5: ; Show vol and sample. + Push CX + Push SI + Push DI + + ; Draw in divisions. + Mov AX, 2A8h + Mov Word Ptr [ES:DI], AX + Mov Word Ptr [ES:DI+22], AX + Mov Word Ptr [ES:DI+40], AX + Mov Word Ptr [ES:DI+46], AX + Mov Word Ptr [ES:DI+52], AX + Mov Word Ptr [ES:DI+58], AX + Mov Word Ptr [ES:DI+64], AX + Mov Word Ptr [ES:DI+72], AX + Mov Word Ptr [ES:DI+78], AX + + ClI + + Test Byte Ptr [SI], 4 + JNZ Display_Details6 + + Add DI, 88 + + Jmp Display_Details72 + +Display_Details6: + Mov BX, [SI+24h] ; DS:BX points to virtual channel. + Mov EAX, [BX+10h] + Call Draw10Num + + Add DI, 42 + Mov EAX, [BX+4Ch] + Call Draw10Num + + Add DI, 22 + Xor AH, AH + Mov AL, [BX+36h] + Inc AX ; Sample.. + Call Draw3Num + +; Add DI, 2 + ScasW + Xor AH, AH + Mov AL, [BX+20h] ; Final vol + Call Draw3Num + + Mov AL, [BX+21h] ; Vol + Call Draw2Num + + Mov AL, [BX+23h] ; CV + Call Draw2Num + + Mov AL, [BX+24h] ; SV + ShR AL, 1 + Call Draw2Num + + Mov AL, [BX+52h] ; VE + Call Draw2Num + + Mov AX, [BX+26h] ; Fade + ShR AX, 1 + Call Draw3Num + + Mov AL, [BX+25h] ; Pan + Cmp AL, 100 + JE Display_Details13 + + Call Draw2Num + + Jmp Display_Details7 + +Display_Details13: + Mov AX, 'S'+2*256 + StosW + Mov AL, 'u' + StosW +; Add DI, 2 + ScasW + +Display_Details7: + Mov AL, [BX+62h] ; PE + Add AL, 32 + Call Draw2Num + +; Add DI, 2 + ScasW + +Display_Details72: + Push DS + Call Music_GetSongSegment + Mov DS, AX + Test Byte Ptr [DS:2Ch], 4 + Pop DS + JZ Display_Details8 + + Mov Word Ptr [ES:DI+6], 2A8h + + Test Byte Ptr [SI], 4 + JNZ Display_Details9 + + Mov AX, '-'+2*256 + StosW + StosW + StosW + + Jmp Display_Details10 + +Display_Details9: + Push SI + + Mov SI, [BX+3Bh] ; NNA + And SI, 0FFh + ShL SI, 2 + Mov AH, 2 + Mov AL, [CS:NNAMsg+SI] + StosW + Mov AL, [CS:NNAMsg+SI+1] + StosW + Mov AL, [CS:NNAMsg+SI+2] + StosW + + Pop SI + +Display_Details10: ; Time to count channels. + Mov AH, [SI+20h] + +; Add DI, 2 + ScasW + Call Music_GetSlaveChannelInformationTable + + Xor AL, AL ; AL = count. + +Display_Details11: + Mov DL, [SI+3Ah] + And DL, 7Fh + Cmp AH, DL + JNE Display_Details12 + + Test Byte Ptr [SI], 1 + JZ Display_Details12 + + Inc AX + +Display_Details12: + Add SI, SLAVECHANNELSIZE + Loop Display_Details11 + + Xor AH, AH + Call Draw3Num + +Display_Details8: + StI + + Pop DI + Pop SI + Pop CX + Add DI, 160 + Add SI, HOSTCHANNELSIZE + Loop Display_Details5 + + Ret + +EndP Display_Details + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadNextData ; Returns DS:SI to data. (unpacked) + Assume DS:InfoPage + + Mov BX, DecodePattern + Cmp BX, PatternArrayNumber + JE LoadNextData1 + + Push DI + + Push CS + Pop ES + Mov DI, Offset DataArray + Mov CX, 64 + +LoadNextData3: + Mov AX, 0FDh + StosW + Mov AL, 0FFh + StosB + Xor AL, AL + StosW + Loop LoadNextData3 + + Cmp BX, 0FFFFh + JNE LoadNextData2 + + Pop DI + Mov SI, Offset DataArray + Ret + +LoadNextData2: + ; OK... time to decode. + Mov SI, DecodeOffset + Mov DS, DecodeSegment + Assume DS:Nothing + +LoadNextData4: + LodsB + And AL, AL + JZ LoadNextData5 + + Mov DL, AL + And AL, 7Fh + Dec AX + Mov DH, AL + + Mov AH, 6 + Mul AH + Mov BX, AX + Add BX, Offset DataDecode + + Mov AL, 5 + Mul DH + Mov DI, AX + Add DI, Offset DataArray + + Mov AH, [CS:BX] + Test DL, 80h + JZ LoadNextData6 + + LodsB + Mov AH, AL + Mov [CS:BX], AL + +LoadNextData6: + Test AH, 1 + JZ LoadNextData7 + + LodsB + Mov [CS:BX+1], AL + Jmp LoadNextData8 + +LoadNextData7: + Test AH, 10h + JZ LoadNextData9 + + Mov AL, [CS:BX+1] + +LoadNextData8: + Mov [CS:DI], AL ; Note + +LoadNextData9: + Test AH, 2 + JZ LoadNextData10 + + LodsB + Mov [CS:BX+2], AL + Jmp LoadNextData11 + +LoadNextData10: + Test AH, 20h + JZ LoadNextData12 + + Mov AL, [CS:BX+2] + +LoadNextData11: + Mov [CS:DI+1], AL ; Instrument + +LoadNextData12: + Test AH, 4 + JZ LoadNextData13 + + LodsB + Mov [CS:BX+3], AL + Jmp LoadNextData14 + +LoadNextData13: + Test AH, 40h + JZ LoadNextData15 + + Mov AL, [CS:BX+3] + +LoadNextData14: + Mov [CS:DI+2], AL ; Volume + +LoadNextData15: + Test AH, 8 + JZ LoadNextData16 + + LodsW + Mov [CS:BX+4], AX + Mov [CS:DI+3], AX + Jmp LoadNextData4 + +LoadNextData16: + Test AH, 80h + JZ LoadNextData4 + + Mov AX, [CS:BX+4] + Mov [CS:DI+3], AX + Jmp LoadNextData4 + +LoadNextData5: + Push CS + Pop DS + Assume DS:InfoPage + + Mov DecodeOffset, SI + + Mov SI, Offset DataArray + + Pop DI + Ret + +LoadNextData1: + Mov SI, DecodeOffset + Add DecodeOffset, 320 + Mov DS, PatternSegment + Assume DS:Nothing + + Ret + +EndP LoadNextData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GotoRow ; DS:SI points to data. + + Push CX + + + Mov CX, CS:DecodeRow + Inc CX + +GotoRow1: + Dec CX + JZ GotoRow2 + +GotoRow3: + LodsB + And AL, AL + JZ GotoRow1 + + Mov DL, AL + And AL, 7Fh + Dec AX + Mov AH, 6 + Mul AH + Mov BX, AX + Add BX, Offset DataDecode + + Mov DH, [CS:BX] ; Mask. + Test DL, 80h + JZ GotoRow4 + + LodsB + Mov DH, AL + Mov [CS:BX], AL ; Mask + +GotoRow4: + Test DH, 1 + JZ GotoRow5 + + LodsB + Mov [CS:BX+1], AL ; Note + +GotoRow5: + Test DH, 2 + JZ GotoRow6 + + LodsB + Mov [CS:BX+2], AL ; Instrument + +GotoRow6: + Test DH, 4 + JZ GotoRow7 ; Volume + + LodsB + Mov [CS:BX+3], AL + +GotoRow7: + Test DH, 8 + JZ GotoRow3 + + LodsW + Mov [CS:BX+4], AX + Jmp GotoRow3 + +GotoRow2: + Mov CS:DecodeSegment, DS + Mov CS:DecodeOffset, SI + + Pop CX + Ret + +EndP GotoRow + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetBeforeRows ; Returns + ; CX = number of rows to show. + ; the row numbers are handled. + ; Initialises DataSegment, + ; DataOffset and Array. + Assume DS:InfoPage + + Xor CX, CX + Mov BX, CurrentRow + Mov AX, [CS:BP+4] + Sub AX, 4 + ShR AX, 1 + Sub BX, AX + JC GetBeforeRows2 + + Ret ; No rows to show! + +GetBeforeRows2: + Mov CX, BX + Neg CX ; CX = num of rows to show + + Cmp PlayMode, 1 + JE GetBeforeRows1 + ; Song.. + Mov BX, CurrentOrder + Test BX, BX + JZ GetBeforeRows3 + + Call Music_GetSongSegment + Mov ES, AX + MovZX AX, Byte Ptr [ES:BX+100h-1] + Cmp AL, 199 + JBE GetBeforeRows4 + +GetBeforeRows3: + Mov DecodePattern, 0FFFFh + Ret + +GetBeforeRows1: ; Pattern... + Mov AX, CurrentPattern + +GetBeforeRows4: + Mov DecodePattern, AX ; Now find offset. + Cmp AX, PatternArrayNumber ; CX = num rows to show + JNE GetBeforeRows5 + + Mov BX, PatternMaxRow + Sub BX, CX + Mov DecodeRow, BX + Mov AX, 320 + Mul BX + Mov DecodeOffset, AX + Jmp GetBeforeRows6 + +GetBeforeRows5: + Call Music_GetPattern + Assume DS:Nothing + LodsW + LodsW + ; AX = rows. + Sub AX, CX + Mov CS:DecodeRow, AX + Add SI, 4 + Call GotoRow + +GetBeforeRows6: ; Put numbers on screen. + Push CS + Pop DS + + JCXZ GetBeforeRows9 + + Push CX + Push DI + +GetBeforeRows7: + Mov AX, DecodeRow + Mov ES, Destination + +GetBeforeRows8: + Push CX + + Mov CH, 20h + Call PE_ConvAX2Num + + Pop CX + Inc AX + Add DI, 160 + Loop GetBeforeRows8 + + Pop DI + Pop CX + +GetBeforeRows9: + Ret + +EndP GetBeforeRows + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetAfterRows ; Returns + Assume DS:InfoPage + + Xor CX, CX + Mov BX, DecodeMaxRow + Mov AX, [CS:BP+4] + Sub AX, 3 + Mov DX, AX + Dec AX + ShR AX, 1 + Sub DX, AX + Add DX, CurrentRow + + Sub BX, DX + JC GetAfterRows2 + + Ret ; No rows to show! + +GetAfterRows2: + Mov CX, BX + Neg CX + + Cmp PlayMode, 1 + JE GetAfterRows1 + + ; Song.. + Mov BX, CurrentOrder + Cmp BX, 255 + JAE GetAfterRows3 + + Call Music_GetSongSegment + Mov ES, AX + MovZX AX, Byte Ptr [ES:BX+101h] + Cmp AL, 199 + JBE GetAfterRows4 + +GetAfterRows3: + Mov DecodePattern, 0FFFFh + Ret + +GetAfterRows1: ; Pattern... + Mov AX, CurrentPattern + +GetAfterRows4: + Mov DecodePattern, AX ; Now find offset. + Mov DecodeRow, 0 + + Cmp AX, PatternArrayNumber ; CX = num rows to show + JNE GetAfterRows5 + + Mov DecodeOffset, 0 + Jmp GetAfterRows6 + +GetAfterRows5: + Call Music_GetPattern + Assume DS:Nothing + Add SI, 8 + Mov CS:DecodeSegment, DS + + Push CS + Pop DS + Assume DS:InfoPage + + Mov DecodeOffset, SI + +GetAfterRows6: ; Put numbers on screen. + JCXZ GetAfterRows9 + + Push CX + Push DI + +GetAfterRows7: + Mov AX, DecodeRow + Mov ES, Destination + +GetAfterRows8: + Push CX + + Mov CH, 20h + Call PE_ConvAX2Num + + Pop CX + Inc AX + Add DI, 160 + Loop GetAfterRows8 + + Pop DI + Pop CX + +GetAfterRows9: + Ret + +EndP GetAfterRows + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetCurrentPatternRows ; Returns CX = number of rows to show. + Assume DS:InfoPage + + Mov BX, CurrentRow + Mov AX, [CS:BP+4] + Sub AX, 3 + + Mov CX, AX + Dec AX + ShR AX, 1 + Sub CX, AX + + Add CX, BX ; CX = final row. + Sub BX, AX + JNC GetCurrentPatternRows2 + + Xor BX, BX + ; BX = starting row. + +GetCurrentPatternRows2: + Mov AX, CurrentPattern + + Mov DecodeRow, BX + Mov DecodePattern, AX ; Now find offset. + Cmp AX, PatternArrayNumber ; BX = starting row, CX = final row. + JNE GetCurrentPatternRows5 + + Mov AX, PatternMaxRow + Mov DecodeMaxRow, AX + Cmp CX, AX + JBE GetCurrentPatternRows1 + + Mov CX, AX + +GetCurrentPatternRows1: + Mov AX, 320 + Mul BX + Mov DecodeOffset, AX + Sub CX, BX ; CX = number of rows. + Jmp GetCurrentPatternRows6 + +GetCurrentPatternRows5: + Call Music_GetPattern + Assume DS:Nothing + LodsW + LodsW + ; AX = number of rows. + Mov DecodeMaxRow, AX + + Cmp CX, AX + JBE GetCurrentPatternRows3 + + Mov CX, AX + +GetCurrentPatternRows3: + Sub CX, BX + Add SI, 4 + Call GotoRow + +GetCurrentPatternRows6: ; Put numbers on screen. + Push CS + Pop DS + + Push CX + Push DI + +GetCurrentPatternRows7: + Mov AX, DecodeRow + Mov ES, Destination + +GetCurrentPatternRows8: + Push CX + + Mov CH, 20h + Call PE_ConvAX2Num + + Pop CX + Inc AX + Add DI, 160 + Loop GetCurrentPatternRows8 + + Pop DI + Pop CX + Ret + +EndP GetCurrentPatternRows + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawHilightBar + + Mov DI, [CS:BP+6] + Mov AX, [CS:BP+4] + ShR AX, 1 + Mov AH, 160 + Mul AH + Add DI, AX + Add DI, 11 + +DrawHilightBar1: + Or Byte Ptr [ES:DI], 0E0h +; Add DI, 2 + ScasW + Dec CX + JNZ DrawHilightBar1 + + Ret + +EndP DrawHilightBar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayTrackData + + Cmp PlayMode, 0 + JNE DisplayTrackData1 + + Pop AX ; Pull off return address + Ret + +DisplayTrackData1: + ; Check if row is OK. + + ; Now check for early block + + Mov DI, [CS:BP+6] + Add DI, (1+2*80)*2 + + Call GetBeforeRows + JCXZ DisplayTrackData3 + +DisplayTrackData2: + Push CX + Push DI + Push DS + + Call LoadNextData ; Gets DS:SI + Call [CS:DrawTrackData] + + Pop DS + Pop DI + Pop CX + Add DI, 160 + Dec CX + JNZ DisplayTrackData2 + +DisplayTrackData3: + Call GetCurrentPatternRows + +DisplayTrackData4: + Push CX + Push DI + Push DS + + Call LoadNextData ; Gets DS:SI + Call [CS:DrawTrackData] + + Pop DS + Pop DI + Pop CX + Add DI, 160 + Dec CX + JNZ DisplayTrackData4 + + Call GetAfterRows + JCXZ DisplayTrackData6 + +DisplayTrackData5: + Push CX + Push DI + Push DS + + Call LoadNextData ; Gets DS:SI + Call [CS:DrawTrackData] + + Pop DS + Pop DI + Pop CX + Add DI, 160 + Dec CX + JNZ DisplayTrackData5 + +DisplayTrackData6: + Ret + +EndP DisplayTrackData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Show5Channel + + Mov AL, [CS:BP+2] + Mov AH, 5 + Mul AH + Add SI, AX ; DS:SI points to stuff. + + Mov CX, 0A05h + Mov ES, Destination + Add DI, 8 + +Show5Channel1: + LodsB + Cmp AL, 119 + JBE Show5Channel2 + + Mov AH, AL + Mov AL, 205 + + Cmp AH, 0FFh + JE Show5Channel3 + + Mov AL, '^' + Cmp AH, 0FEh + JE Show5Channel3 + + Mov AL, 173 ; '.' + +Show5Channel3: + Mov AH, 6 + StosW + StosW + StosW + Jmp Show5Channel4 + +Show5Channel2: ; Show note. + AAM 12 + ; AL = octave + ; AH = note. + Mov DX, AX + MovZX BX, AL + Add BX, BX + Mov AH, 6 + Mov AL, [CS:BX+NoteTable] + StosW + Mov AL, [CS:BX+NoteTable+1] + StosW + Mov AL, DH + Add AL, 30h + StosW + +Show5Channel4: ; Show ins. +; Add DI, 2 + ScasW + LodsB + + Test AL, AL + JZ Show5Channel5 + + Xor AH, AH + Div CH + Add AX, 3030h + Mov DL, AH + Mov AH, 6 + StosW + Mov AL, DL + StosW + + Jmp Show5Channel6 + +Show5Channel5: + Mov AL, 173 + StosW + StosW + +Show5Channel6: ; show vol +; Add DI, 2 + ScasW + LodsB + Cmp AL, 0FFh + JE Show5Channel7 + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC Show5ChannelNoVEffect + + Test AL, 80h + JZ Show5ChannelVEffect + + Add AH, 60 + +Show5ChannelVEffect: + Mov AL, AH + Xor AH, AH + Div CH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov DL, AH + Mov AH, 6 + StosW + Mov AL, DL + StosW + + Jmp Show5Channel8 + +Show5ChannelNoVEffect: + Mov DL, 6 + Test AL, 80h + JZ Show5Channel10 + + Mov DL, 2 + And AL, 7Fh + +Show5Channel10: + Xor AH, AH + Div CH + Add AX, 3030h + XChg DL, AH + StosW + Mov AL, DL + StosW + + Mov AH, 6 + Jmp Show5Channel8 + +Show5Channel7: + Mov AL, 173 + StosW + StosW + +Show5Channel8: +; Add DI, 2 + ScasW + LodsB + And AL, AL + JNZ Show5Channel9 + + Mov AL, '.'-'@' + +Show5Channel9: + Add AL, '@' + StosW ; Command + + LodsB ; Commandvalue. + Mov AH, AL + And AX, 0FF0h + Mov DL, AH + ShR AL, 4 + + Mov AH, 6 + Call DrawHexAL + + Mov AL, DL + Call DrawHexAL + + Dec CL + JZ Show5ChannelEnd + + Mov AX, 2A8h + StosW + + Jmp Show5Channel1 + +Show5ChannelEnd: + Ret + +EndP Show5Channel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_5Channel + Assume DS:InfoPage + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Inc AX + Push AX + Push 74 + Add AX, [CS:BP+4] + Sub AL, 2 + Push AX + Push 27 + Call S_DrawBox + + Add SP, 10 + ; Fill in text. + ; check boundaries. + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_5Channel2 + + Mov BX, DX + +Display_5Channel2: + Mov CX, DX + Sub CX, 4 + Cmp BX, CX + JGE Display_5Channel3 + + Mov BX, CX + +Display_5Channel3: + Cmp BX, 59 + JB Display_5Channel11 + + Mov BX, 59 + +Display_5Channel11: + Mov [CS:BP+2], BL ; top channel. + ; Now do channel msgs. + + Mov CX, 0A05h + Mov DI, [CS:BP+6] + Add DI, (5+1*80)*2 + Mov SI, Offset Channel5Msg + +Display_5Channel4: + MovZX AX, BL + Inc AX + Div CH + Add AX, 3030h + Mov [SI+9], AX + + Call GetChannelColour + Call S_DrawString + + Add DI, 4 + + Inc BX + Dec CL + JNZ Display_5Channel4 + + Mov [CS:DrawTrackData], Offset Show5Channel + Call DisplayTrackData + Mov CX, 69 + Call DrawHilightBar + + Ret + +EndP Display_5Channel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Show8Channel + + Mov AL, [CS:BP+2] + Mov AH, 5 + Mul AH + Add SI, AX ; DS:SI points to stuff. + + Mov CX, 0A08h + Mov ES, Destination + Add DI, 8 + +Show8Channel1: + LodsW + Cmp AL, 119 + JBE Show8Channel2 + + Mov AH, AL + Mov AL, 205 + + Cmp AH, 0FFh + JE Show8Channel3 + + Mov AL, '^' + Cmp AH, 0FEh + JE Show8Channel3 + + Mov AL, 173 ; '.' + +Show8Channel3: + Mov AH, 6 + StosW + StosW + StosW + Jmp Show8Channel4 + +Show8Channel2: ; Show note. + AAM 12 + + Mov DX, AX + MovZX BX, AL + Add BX, BX + Mov AH, 6 + Mov AL, [CS:BX+NoteTable] + StosW + Mov AL, [CS:BX+NoteTable+1] + StosW + Mov AL, DH + Add AL, 30h + StosW + +Show8Channel4: ; Show vol. + LodsB + Cmp AL, 0FFh + JE Show8Channel5 + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC Show8ChannelNoVEffect + + Test AL, 80h + JZ Show8ChannelVEffect + + Add AH, 60 + +Show8ChannelVEffect: + Mov AL, AH + Xor AH, AH + Div CH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov DL, AH + Mov AH, 2 + StosW + Mov AL, DL + StosW + + Jmp Show8Channel6 + +Show8ChannelNoVEffect: + Mov DL, 2 + Test AL, 80h + JZ Show8Channel10 + + Dec DL + And AL, 7Fh + +Show8Channel10: + Xor AH, AH + Div CH + Add AX, 3030h + XChg DL, AH + StosW + Mov AL, DL + StosW + + Jmp Show8Channel6 + +Show8Channel5: + Add DI, 4 + +Show8Channel6: + LodsB + And AL, AL + JNZ Show8Channel9 + + Mov AL, '.'-'@' + +Show8Channel9: + Add AL, '@' + Mov AH, 6 + StosW ; Command + + LodsB ; Commandvalue. + Mov AH, AL + And AX, 0FF0h + Mov DL, AH + ShR AL, 4 + + Mov AH, 6 + Call DrawHexAL + + Mov AL, DL + Call DrawHexAL + + Dec CL + JZ Show8ChannelEnd + + Mov AX, 2A8h + StosW + + Jmp Show8Channel1 + +Show8ChannelEnd: + Ret + +EndP Show8Channel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_8Channel + Assume DS:InfoPage + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Inc AX + Push AX + Push 76 + Add AX, [CS:BP+4] + Sub AL, 2 + Push AX + Push 27 + Call S_DrawBox + + Add SP, 10 + ; Fill in text. + ; check boundaries. + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_8Channel2 + + Mov BX, DX + +Display_8Channel2: + Mov CX, DX + Sub CX, 7 + Cmp BX, CX + JGE Display_8Channel3 + + Mov BX, CX + +Display_8Channel3: + Cmp BX, 56 + JB Display_8Channel11 + + Mov BX, 56 + +Display_8Channel11: + Mov [CS:BP+2], BL ; top channel. + ; Now do channel msgs. + + Mov CX, 0A08h + Mov DI, [CS:BP+6] + Add DI, (6+1*80)*2 + Mov SI, Offset Channel8Msg + +Display_8Channel4: + MovZX AX, BL + Inc AX + Div CH + Add AX, 3030h + Mov [SI+2], AX + + Call GetChannelColour + Call S_DrawString + + Add DI, 6 + + Inc BX + Dec CL + JNZ Display_8Channel4 + + Mov [CS:DrawTrackData], Offset Show8Channel + Call DisplayTrackData + Mov CX, 71 + Call DrawHilightBar + + Ret + +EndP Display_8Channel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Show10Channel + + Mov AL, [CS:BP+2] + Mov AH, 5 + Mul AH + Add SI, AX ; DS:SI points to stuff. + + Mov CX, 0A0Ah + Mov ES, Destination + Add DI, 8 + +Show10Channel1: + LodsB + Cmp AL, 119 + JBE Show10Channel2 + + Mov AH, AL + Mov AL, 205 + + Cmp AH, 0FFh + JE Show10Channel3 + + Mov AL, '^' + Cmp AH, 0FEh + JE Show10Channel3 + + Mov AL, 173 ; '.' + +Show10Channel3: + Mov AH, 6 + StosW + StosW + StosW + Jmp Show10Channel4 + +Show10Channel2: ; Show note. + AAM 12 + ; AL = octave + ; AH = note. + Mov DX, AX + MovZX BX, AL + Add BX, BX + Mov AH, 6 + Mov AL, [CS:BX+NoteTable] + StosW + Mov AL, [CS:BX+NoteTable+1] + StosW + Mov AL, DH + Add AL, 30h + StosW + +Show10Channel4: ; Show Instrument + LodsB ; AL = instrument + And AX, 0FFh + JZ Show10Channel5 ; No instrument? + Div CH + + ; AL = tens, AH = units + ShL AL, 4 + Or AL, AH + Mov AH, 0Ah + + StosW ; Instrument done. + Jmp Show10Channel6 + +Show10Channel5: + Mov AX, 184+200h + StosW + +Show10Channel6: ; Show volume + LodsB ; AL = volume + + Cmp AL, 0FFh + JE Show10Channel7 + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC ViewAllSmallNoVEffect + + Test AL, 80h + JZ ViewAllSmallVEffect1 + + Mov AL, AH + Add AL, 226 + Mov AH, 6 + StosW + Jmp Show10Channel8 + +ViewAllSmallVEffect1: + Mov AL, AH + AAM + Add AH, 0Ah + ShL AH, 4 + Or AL, AH + Mov AH, 12 + StosW +Comment ~ + Mov AL, AH + Mov AH, 0 + Div CH + ; AL = effect, AH = num + Add AL, 0Ah + ShL AL, 4 + Or AL, AH + Mov AH, 12 + StosW +~ + Jmp Show10Channel8 + +ViewAllSmallNoVEffect: +; Xor AH, AH + Mov DL, 12 ; Volume + Test AL, AL + JNS Show10Channel9 + + Mov DL, 9 + And AL, 7Fh + +Show10Channel9: +; Div CH + AAM + + ; AL = tens, AH = units + ShL AH, 4 + Or AL, AH + Mov AH, DL + + StosW + Jmp Show10Channel8 + +Show10Channel7: ; No volume + Mov AX, 184+600h + StosW + +Show10Channel8: ; Show volume + LodsB + Test AL, AL + JNZ Show10Channel10 + + Add AL, '.'-'@' + +Show10Channel10: + Add AL, '@' + Mov AH, 2 + StosW ; Command + + Mov AH, 0Ah + LodsB ; Commandvalue. + StosW + + Dec CL + JNZ Show10Channel1 + + Ret + +EndP Show10Channel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_10Channel + Assume DS:InfoPage + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Inc AX + Push AX + Push 75 + Add AX, [CS:BP+4] + Sub AL, 2 + Push AX + Push 27 + Call S_DrawBox + + Add SP, 10 + ; Fill in text. + ; check boundaries. + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_10Channel2 + + Mov BX, DX + +Display_10Channel2: + Mov CX, DX + Sub CX, 9 + Cmp BX, CX + JGE Display_10Channel3 + + Mov BX, CX + +Display_10Channel3: + Cmp BX, 54 + JB Display_10Channel11 + + Mov BX, 54 + +Display_10Channel11: + Mov [CS:BP+2], BL ; top channel. + ; Now do channel msgs. + + Mov CX, 0A0Ah + Mov DI, [CS:BP+6] + Add DI, (5+1*80)*2 + Mov SI, Offset Channel8Msg + +Display_10Channel4: + MovZX AX, BL + Inc AX + Div CH + Add AX, 3030h + Mov [SI+2], AX + + Call GetChannelColour + Call S_DrawString + +; Add DI, 2 + ScasW + + Inc BX + Dec CL + JNZ Display_10Channel4 + + Mov [CS:DrawTrackData], Offset Show10Channel + Call DisplayTrackData + Mov CX, 70 + Call DrawHilightBar + + Ret + +EndP Display_10Channel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Process3CharacterRow + + Push SI + + LodsW + Cmp AX, 0FDh + JE Show18Channel4 + + Cmp AL, 0FDh + JE Show18Channel3 + JB Show18Channel2 + + Mov AH, AL + Mov AL, 205 + + Cmp AH, 0FFh + JE Show18Channel8 + + Mov AL, '^' + Cmp AH, 0FEh + JE Show18Channel8 + + Mov AL, 173 ; '.' + +Show18Channel8: + Mov AH, 6 + StosW + StosW + StosW + Jmp Show18Channel7 + +Show18Channel2: + AAM 12 + + Mov DX, AX + MovZX BX, AL + Add BX, BX + Mov AH, 6 + Mov AL, [CS:BX+NoteTable] + StosW + Mov AL, [CS:BX+NoteTable+1] + StosW + Mov AL, DH + Add AL, 30h + StosW + + Jmp Show18Channel7 + +Show18Channel3: + MovZX AX, AH + Div CH + Add AX, 3030h + Mov DL, AH + Mov AH, 6 +; Add DI, 2 + ScasW + StosW + Mov AL, DL + StosW + Jmp Show18Channel7 + +Show18Channel4: + LodsW + Cmp AX, 0FFh + JE Show18Channel6 + + Cmp AL, 0FFh + JE Show18Channel5 + +; Add DI, 2 + ScasW + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC Show18ChannelNoVEffect + + Test AL, 80h + JZ Show18ChannelVEffect + + Add AH, 60 + +Show18ChannelVEffect: + Mov AL, AH + Xor AH, AH + Div CH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov DL, AH + Mov AH, 2 + StosW + Mov AL, DL + StosW + + Jmp Show18Channel7 + +Show18ChannelNoVEffect: + Mov DL, 2 + Test AL, 80h + JZ Show18Channel9 + + Dec DX + And AL, 7Fh + +Show18Channel9: + Xor AH, AH ; Volume + Div CH + Add AX, 3030h + XChg DL, AH + StosW + Mov AL, DL + StosW + + Jmp Show18Channel7 + +Show18Channel5: + Mov AL, AH + Add AL, '@' + Mov AH, 2 + StosW + + LodsB ; Commandvalue. + Mov AH, AL + And AX, 0FF0h + Mov DL, AH + ShR AL, 4 + + Mov AH, 2 + Call DrawHexAL + + Mov AL, DL + Call DrawHexAL + Jmp Show18Channel7 + +Show18Channel6: + Mov AX, 173+256*6 + StosW + StosW + StosW + +Show18Channel7: + Pop SI + Add SI, 5 + + Ret + +EndP Process3CharacterRow + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Show18Channel + + Mov AL, [CS:BP+2] + Mov AH, 5 + Mul AH + Add SI, AX ; DS:SI points to stuff. + + Mov CX, 0A12h + Mov ES, Destination + Add DI, 8 + +Show18Channel1: + Call Process3CharacterRow + Dec CL + JZ Show18ChannelEnd + + Mov AX, 2A8h + StosW + + Jmp Show18Channel1 + +Show18ChannelEnd: + Ret + +EndP Show18Channel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_18Channel + Assume DS:InfoPage + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Inc AX + Push AX + Push 76 + Add AX, [CS:BP+4] + Sub AL, 2 + Push AX + Push 27 + Call S_DrawBox + + Add SP, 10 + ; Fill in text. + ; check boundaries. + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_18Channel2 + + Mov BX, DX + +Display_18Channel2: + Mov CX, DX + Sub CX, 17 + Cmp BX, CX + JGE Display_18Channel3 + + Mov BX, CX + +Display_18Channel3: + Cmp BX, 46 + JB Display_18Channel11 + + Mov BX, 46 + +Display_18Channel11: + Mov [CS:BP+2], BL ; top channel. + ; Now do channel msgs. + + Mov CX, 0A12h + Mov DI, [CS:BP+6] + Add DI, (6+1*80)*2 + Mov SI, Offset Channel18Msg + +Display_18Channel4: + MovZX AX, BL + Inc AX + Div CH + Add AX, 3030h + Mov [SI], AX + + Call GetChannelColour + Call S_DrawString + + Add DI, 4 + + Inc BX + Dec CL + JNZ Display_18Channel4 + + Mov [CS:DrawTrackData], Offset Show18Channel + Call DisplayTrackData + Mov CX, 71 + Call DrawHilightBar + + Ret + +EndP Display_18Channel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Show24Channel + + Mov AL, [CS:BP+2] + Mov AH, 5 + Mul AH + Add SI, AX ; DS:SI points to stuff. + + Mov CX, 0A18h + Mov ES, Destination + Add DI, 8 + +Show24Channel1: + Call Process3CharacterRow + + Dec CL + JNZ Show24Channel1 + + Ret + +EndP Show24Channel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_24Channel + Assume DS:InfoPage + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Inc AX + Push AX + Push 77 + Add AX, [CS:BP+4] + Sub AL, 2 + Push AX + Push 27 + Call S_DrawBox + + Add SP, 10 + ; Fill in text. + ; check boundaries. + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_24Channel2 + + Mov BX, DX + +Display_24Channel2: + Mov CX, DX + Sub CX, 23 + Cmp BX, CX + JGE Display_24Channel3 + + Mov BX, CX + +Display_24Channel3: + Cmp BX, 40 + JB Display_24Channel11 + + Mov BX, 40 + +Display_24Channel11: + Mov [CS:BP+2], BL ; top channel. + ; Now do channel msgs. + + Mov CX, 0A18h + Mov DI, [CS:BP+6] + Add DI, (6+1*80)*2 + Mov SI, Offset Channel18Msg + +Display_24Channel4: + MovZX AX, BL + Inc AX + Div CH + Add AX, 3030h + Mov [SI], AX + + Call GetChannelColour + Call S_DrawString + +; Add DI, 2 + ScasW + + Inc BX + Dec CL + JNZ Display_24Channel4 + + Mov [CS:DrawTrackData], Offset Show24Channel + Call DisplayTrackData + Mov CX, 72 + Call DrawHilightBar + + Ret + +EndP Display_24Channel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Show36Channel + + Mov AL, [CS:BP+2] + Mov AH, 5 + Mul AH + Add SI, AX ; DS:SI points to stuff. + + Mov CX, 0A24h + Mov ES, Destination + Add DI, 8 + +Show36Channel1: + LodsW + + Cmp AX, 0FDh + JE Show36Channel4 + + Add SI, 3 + + Cmp AL, 0FDh + JE Show36Channel3 + JB Show36Channel2 + + Mov AH, AL + Mov AL, 205 + + Cmp AH, 0FFh + JE Show36Channel8 + + Mov AL, '^' + Cmp AH, 0FEh + JE Show36Channel8 + + Mov AL, 173 ; '.' + +Show36Channel8: + Mov AH, 6 + StosW + StosW + Jmp Show36Channel7 + +Show36Channel2: + AAM 12 + Mov BX, Offset Note2Table + SegCS XLatB + Mov DL, AH + Mov AH, 6 + StosW + + Mov AL, DL + Add AL, 30h + StosW + + Jmp Show36Channel7 + +Show36Channel3: + MovZX AX, AH + Div CH + Add AX, 3030h + Mov DL, AH + Mov AH, 6 + StosW + Mov AL, DL + StosW + + Jmp Show36Channel7 + +Show36Channel4: + LodsW + Cmp AX, 0FFh + JE Show36Channel6 + + Cmp AL, 0FFh + JE Show36Channel5 + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC Show36ChannelNoVEffect + + Test AL, 80h + JZ Show36ChannelVEffect + + Add AH, 60 + +Show36ChannelVEffect: + Mov AL, AH + Xor AH, AH + Div CH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov DL, AH + Mov AH, 2 + StosW + Mov AL, DL + StosW + + Jmp Show36ChannelEndVolume + +Show36ChannelNoVEffect: + Mov DL, 2 + Test AL, 80h + JZ Show36Channel10 + + And AL, 7Fh + Dec DX + +Show36Channel10: + + Xor AH, AH ; Volume + Div CH + Add AX, 3030h + XChg DL, AH + StosW + Mov AL, DL + StosW + +Show36ChannelEndVolume: + Inc SI + Jmp Show36Channel7 + +Show36Channel5: + Mov AL, AH + Add AL, '@' + Mov AH, 2 + StosW + LodsB + Mov AH, 0Ah + StosW + + Jmp Show36Channel7 + +Show36Channel6: + Mov AX, 173+256*6 + StosW + StosW + Inc SI + +Show36Channel7: + Dec CL + JNZ Show36Channel9 + + Ret + +Show36Channel9: + Jmp Show36Channel1 + +EndP Show36Channel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_36Channel + Assume DS:InfoPage + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Inc AX + Push AX + Push 77 + Add AX, [CS:BP+4] + Sub AL, 2 + Push AX + Push 27 + Call S_DrawBox + + Add SP, 10 + ; Fill in text. + ; check boundaries. + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_36Channel2 + + Mov BX, DX + +Display_36Channel2: + Mov CX, DX + Sub CX, 35 + Cmp BX, CX + JGE Display_36Channel3 + + Mov BX, CX + +Display_36Channel3: + Cmp BX, 28 + JB Display_36Channel11 + + Mov BX, 28 + +Display_36Channel11: + Mov [CS:BP+2], BL ; top channel. + ; Now do channel msgs. + + Mov CX, 0A24h + Mov DI, [CS:BP+6] + Add DI, (5+1*80)*2 + Mov SI, Offset Channel18Msg + +Display_36Channel4: + MovZX AX, BL + Inc AX + Div CH + Add AX, 3030h + Mov [SI], AX + + Call GetChannelColour + Call S_DrawString + + Inc BX + Dec CL + JNZ Display_36Channel4 + + Mov [CS:DrawTrackData], Offset Show36Channel + Call DisplayTrackData + Mov CX, 72 + Call DrawHilightBar + + Ret + +EndP Display_36Channel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Show64Channel + ; DS:SI points to stuff. + + Mov CX, 64 + Mov ES, Destination + Add DI, 8 + +Show64Channel1: + LodsW + + Cmp AX, 0FDh + JE Show64Channel4 + + Add SI, 3 + + Cmp AL, 0FDh + JE Show64Channel3 + JB Show64Channel2 + + Mov AH, AL + Mov AL, 205 + + Cmp AH, 0FFh + JE Show64Channel8 + + Mov AL, '^' + Cmp AH, 0FEh + JE Show64Channel8 + + Mov AL, 173 ; '.' + +Show64Channel8: + Mov AH, 6 + StosW + Jmp Show64Channel7 + +Show64Channel2: + AAM 12 + Mov BX, Offset Note2Table + SegCS XLatB + Mov AH, 6 + + StosW + Jmp Show64Channel7 + +Show64Channel3: + Mov AL, AH + AAM + ShL AH, 4 + Or AL, AH + + Mov AH, 10 + StosW + Jmp Show64Channel7 + +Show64Channel4: + LodsW + Inc SI + + Cmp AL, 0FFh + JE Show64Channel6 + + Mov DL, AL + And AX, 07Fh + + Cmp AL, 64 + JA Show64Channel6 + + AAM + ShL AH, 4 + Or AL, AH + + Mov AH, 12 + Test DL, 80h + JZ Show64ChannelVolumePan + + Mov AH, 9 + +Show64ChannelVolumePan: + StosW + + Jmp Show64Channel7 + +Show64Channel6: + Mov AX, 173+256*6 + StosW + +Show64Channel7: + Dec CX + JNZ Show64Channel9 + + Mov CX, 9 + Mov AX, 173+256*6 + Rep StosW + Ret + +Show64Channel9: + Jmp Show64Channel1 + +EndP Show64Channel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_64Channel + Assume DS:InfoPage + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Inc AX + Push AX + Push 78 + Add AX, [CS:BP+4] + Sub AL, 2 + Push AX + Push 27 + Call S_DrawBox + + Add SP, 10 + ; Now do channel msgs. + + Mov CX, 0A40h + Mov DI, [CS:BP+6] + Add DI, (5+1*80)*2 + Mov SI, Offset Channel18Msg + Xor BX, BX + Mov DL, Byte Ptr CurrentChannel + +Display_64Channel4: + MovZX AX, BL + Inc AX + Div CH + + ShL AL, 4 + Or AL, AH + Mov DH, AL + Call GetChannelColour + Or AH, 8 + Mov AL, DH + StosW + + Inc BX + Dec CL + JNZ Display_64Channel4 + + Mov AX, 1000h + Mov CX, 9 + Rep StosW + + Mov Byte Ptr [CS:BP+2], 0 + + Mov [CS:DrawTrackData], Offset Show64Channel + Call DisplayTrackData + Mov CX, 73 + Call DrawHilightBar + + Ret + +EndP Display_64Channel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_Variables + + Mov DI, [CS:BP+6] + Add DI, (2+1*80)*2 + + Call Music_GetSlaveChannelInformationTable + ; DS:SI points to tables + ; CX = numchannels. + Xor DX, DX ; DX = counter of + ; currently act. + ; channels. + Xor BX, BX + + +Display_Variables1: + Cmp Word Ptr [SI+38h], 0 + JE Display_Variables2 + + Inc BX + +Display_Variables2: + Mov AX, [SI] +; Test AH, 8 +; JNZ Display_Variables4 + + And AX, 1 + Add DX, AX + +Display_Variables4: + Add SI, SLAVECHANNELSIZE + Loop Display_Variables1 + + Push BX + Call Music_GetDisplayVariables ; AX = Current Speed + ; BX = current tempo + ; CX = global volume + ; DX = active channels + Pop BX + Push CX + Push BX + Push DX + + Push CS + Pop DS + + Mov AH, 20h + Mov AL, Byte Ptr CurrentWindow + Cmp AL, Byte Ptr ProcessWindow + JNE Display_Variables3 + + Mov AH, 23h + +Display_Variables3: + Mov SI, Offset VariablesMsg + Call S_DrawString + + Add SP, 6 + + Ret + +EndP Display_Variables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_NoteDots ; Draw boxes first. + Assume DS:InfoPage + + Mov ES, Destination + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Push AX + Push 78 + Add AX, [CS:BP+4] + Dec AX + Push AX + Push 27 + Call S_DrawBox + Add SP, 10 + + Mov DX, CurrentChannel + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_Dots1 + + Mov BX, DX + +Display_Dots1: + LEA CX, [EDX+3] + Sub CX, [CS:BP+4] + Cmp BX, CX + JGE Display_Dots2 + + Mov BX, CX + +Display_Dots2: + Mov CX, 66 + Sub CX, [CS:BP+4] + Cmp BX, CX + JLE Display_Dots3 + + Mov BX, 65 + Sub BX, [CS:BP+4] + +Display_Dots3: + Mov [CS:BP+2], BL ; BL = top channel + + Call DrawChannelNumbers + + Mov DX, [CS:BP+4] + Sub DX, 2 + Mov BL, [CS:BP+2] ; BL = channel + Mov DI, [CS:BP+6] + Add DI, (5+1*80)*2 + +Display_Dots4: + Push DI + + Push CS + Pop ES + Mov DI, Offset DataArray + Mov AX, 600h + 193 + Mov CX, 73 + Rep StosW ; DataArray cleared. + + ; OK.. loop to find channel usage. + Call Music_GetSlaveChannelInformationTable + ; Return DS:SI, CX +Display_Dots5: +; Cmp Word Ptr [SI+38h], 0 +; JE Display_Dots8 + + Test Byte Ptr [SI], 1 + JZ Display_Dots6 + + Mov AL, [SI+3Ah] + And AX, 7Fh + Cmp AL, BL + JNE Display_Dots6 ; Nope.. not the same channel + + Mov AL, [SI+32h] + Sub AL, 30 + JC Display_Dots6 + Cmp AL, 73 + JAE Display_Dots6 + + LEA DI, [DataArray+EAX+EAX] + Mov AL, [SI+20h] + Mov AH, [SI+36h] + Cmp AH, 100 + JNE Display_DotsNOMIDI + + Mov AH, [SI+33h] + +Display_DotsNoMIDI: + And AH, 3 + Add AL, 7 + ShR AL, 4 + AdC AX, 200h+193 + Test Word Ptr [SI], 800h + JZ Display_Dots7 + + Mov AH, 1 ; 6 + +Display_Dots7: + Test Byte Ptr [SI+3Ah], 80h + JZ Display_Dots9 + + Cmp Byte Ptr [CS:DI], AL + JA Display_Dots6 +Display_Dots9: + + Mov [CS:DI], AX + +Display_Dots6: + Add SI, SLAVECHANNELSIZE + + Dec CX + JNZ Display_Dots5 + +Display_Dots8: +; Dump to screen buffer. + + Pop DI + + Push CS + Pop DS + Mov SI, Offset DataArray + Mov ES, Destination + + Mov CX, 73 + Rep MovsW + + Add DI, 160-146 + + Inc BL + Dec DX + JNZ Display_Dots4 + + Ret + +EndP Display_NoteDots + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Comment ~ + +Proc Display_SampleDots ; Draw boxes first. + Assume DS:InfoPage + + Mov ES, Destination + + Mov AX, 4 ; left + Push AX + Mov AL, [CS:BP+3] + Push AX + Push 78 + Add AX, [CS:BP+4] + Dec AX + Push AX + Push 27 + Call S_DrawBox + Add SP, 10 + + Mov DX, CurrentSample + MovZX BX, Byte Ptr [CS:BP+2] + Cmp DX, BX + JAE Display_SampleDots1 + + Mov BX, DX + +Display_SampleDots1: + LEA CX, [EDX+3] + Sub CX, [CS:BP+4] + Cmp BX, CX + JGE Display_SampleDots2 + + Mov BX, CX + +Display_SampleDots2: + Mov CX, 66 + Sub CX, [CS:BP+4] + Cmp BX, CX + JLE Display_SampleDots3 + + Mov BX, 65 + Sub BX, [CS:BP+4] + +Display_SampleDots3: + Mov [CS:BP+2], BL ; BL = top channel + + Mov CL, [CS:BP+4] + Mov CH, 0Ah + Sub CL, 2 + Mov DI, [CS:BP+6] + Add DI, (2+1*80)*2 + +Display_SampleDotsNumbers1: ; BX = top number, CL = count + Inc BX + Mov AX, BX + Div CH + Add AX, 3030h + Mov DH, AH + Mov AH, 21h + StosW + Mov AL, DH + StosW + Add DI, 160-4 + Dec CL + JNZ Display_SampleDotsNumbers1 + + Mov DX, [CS:BP+4] + Sub DX, 2 + Mov BL, [CS:BP+2] ; BL = sample + Mov DI, [CS:BP+6] + Add DI, (5+1*80)*2 + +Display_SampleDots4: + Push DI + + Push CS + Pop ES + Mov DI, Offset DataArray + Mov AX, 600h + 193 + Mov CX, 73 + Rep StosW ; DataArray cleared. + + ; OK.. loop to find channel usage. + Call Music_GetSlaveChannelInformationTable + ; Return DS:SI, CX +Display_SampleDots5: + Test Byte Ptr [SI], 1 + JZ Display_SampleDots6 + + Mov AL, [SI+36h] + Cmp AL, BL + JNE Display_SampleDots6 ; Nope.. not the same channel + + MovZX AX, Byte Ptr [SI+32h] + Sub AL, 30 + JC Display_SampleDots6 + Cmp AL, 73 + JAE Display_SampleDots6 + + LEA DI, [DataArray+EAX+EAX] + Mov AL, [SI+20h] ; Volume + Mov AH, [SI+33h] ; Instrument + + And AH, 3 + Add AL, 7 + ShR AL, 4 + AdC AX, 200h+193 + Test Word Ptr [SI], 800h + JZ Display_SampleDots7 + + Mov AH, 1 ; 6 ; Muted + +Display_SampleDots7: + Cmp Byte Ptr [CS:DI], AL + JA Display_SampleDots6 + +Display_SampleDots9: + Mov [CS:DI], AX + +Display_SampleDots6: + Add SI, SLAVECHANNELSIZE + + Dec CX + JNZ Display_SampleDots5 + +Display_SampleDots8: +; Dump to screen buffer. + + Pop DI + + Push CS + Pop DS + Mov SI, Offset DataArray + Mov ES, Destination + + Mov CX, 73 + Rep MovsW + + Add DI, 160-146 + + Inc BL + Dec DX + JNZ Display_SampleDots4 + + + Ret + +EndP Display_SampleDots + +~ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawDisplayData Far + + Call PE_GetCurrentPattern + Mov CS:PatternSegment, DS + + Push CS + Pop DS + Assume DS:InfoPage + + Call S_GetDestination + Mov Destination, ES + + Mov PatternArrayNumber, AX + Mov PatternMaxRow, BX + + Call Music_GetPlayMode + Mov PlayMode, AX + Mov CurrentRow, BX + Mov CurrentPattern, CX + Mov CurrentOrder, DX + + Xor BP, BP + + Cmp CX, PatternArrayNumber + JNE DrawDisplayData1 + + Call Music_GetPatternLength + Mov PatternMaxRow, AX + +DrawDisplayData1: + Push CS + Pop DS + Assume DS:InfoPage + + Push BP + + Mov ProcessWindow, BP + + ShL BP, 3 + Add BP, Offset DisplayWindows + Mov SI, [CS:BP] + + Xor AL, AL + + Cmp FullScreen, 0 + JNE DisplayDataFull + + Cmp BP, Offset DisplayWindows + JE DisplayData2 + +DisplayDataFull: + Test SI, SI + JZ DisplayData2 + Cmp SI, DOTSDISPLAY + JE DisplayData2 + + Inc AX + + Dec Byte Ptr [CS:BP+3] ; Starting row + Inc Word Ptr [CS:BP+4] ; Length of window + Sub Word Ptr [CS:BP+6], 160 ; Offset + +DisplayData2: + Mov [RestoreData], AL + + Add SI, SI + Call [DisplayDataModes+SI] + + Push CS + Pop DS + + Cmp [RestoreData], 0 + JE DisplayData3 + + Pop BX + Push BX + + ShL BX, 3 + Add BX, Offset DisplayWindows + + Inc Byte Ptr [BX+3] + Dec Word Ptr [BX+4] + Add Word Ptr [BX+6], 160 + +DisplayData3: + Pop BP + Inc BP + Cmp BP, NumWindows + JB DrawDisplayData1 + + Mov AX, 1 + Ret + +EndP DrawDisplayData + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PostDisplayData Far + + Push CS + Pop DS + Assume DS:InfoPage + + Mov SI, Offset DisplayListKeys + Call M_FunctionDivider + JC PostDisplayData1 + + Jmp [SI] + +PostDisplayData1: + Xor AX, AX + Ret + +EndP PostDisplayData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayUp Far + Assume DS:InfoPage + + Mov AX, 1 + + Sub CurrentChannel, AX + AdC CurrentChannel, 0 + + Ret + +EndP DisplayUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayDown Far + Assume DS:InfoPage + + Mov AX, CurrentChannel + Inc AX + Cmp AX, 64 + JAE DisplayDown1 + + Mov CurrentChannel, AX + +DisplayDown1: + Mov AX, 1 + Ret + +EndP DisplayDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayPlus Far + + Call Music_NextOrder + + Mov AX, 1 + Ret + +EndP DisplayPlus + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayMinus Far + + Call Music_LastOrder + + Mov AX, 1 + Ret + +EndP DisplayMinus + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayInsert Far + Assume DS:InfoPage + + Cmp NumWindows, 5 + JAE DisplayInsert1 + + Push DS + Pop ES + + Mov AX, 8 + Mul Byte Ptr CurrentWindow ; AX = offset + Mov SI, Offset DisplayWindows + Add SI, AX + + Cmp Word Ptr [SI+4], 6 ; Length of window + JBE DisplayInsert1 + + Push SI + + Mov AX, 8 + Mul Byte Ptr NumWindows + Mov SI, Offset DisplayWindows + Add SI, AX + Mov DI, SI + Sub SI, 8 + + Mov DX, NumWindows + Sub DX, CurrentWindow + +DisplayInsert2: + Mov CX, 4 + Rep MovsW + + Sub SI, 16 + Sub DI, 16 + Dec DX + JNZ DisplayInsert2 + + Pop SI ; SI points to cur win + ; now to resize.. + Mov AX, [SI+4] ; AX = length of win + ShR AX, 1 + AdC AX, 0 + + Mov [SI+4], AX ; halve length. + Sub [SI+8+4], AX ; second one also + Add AL, [SI+3] ; Add top line + Mov [SI+8+3], AL + Mov AH, 160 + Mul AH + Mov [SI+8+6], AX + + Inc NumWindows + +DisplayInsert1: + Mov AX, 1 + Ret + +EndP DisplayInsert + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayDelete Far + Assume DS:InfoPage + + Cmp NumWindows, 1 + JBE DisplayDelete1 + + Mov AX, 8 + Mul Byte Ptr CurrentWindow ; AX = offset + Mov SI, Offset DisplayWindows + Add SI, AX + Mov DI, SI + + Mov BX, [SI+4] ; Length of deleted win + Push SI + + Add SI, 8 + + Push DS + Pop ES + + Mov DX, NumWindows + Sub DX, CurrentWindow + +DisplayDelete2: + Mov CX, 4 + Rep MovsW + + Dec DX + JNZ DisplayDelete2 + + Pop SI + ; Now to recombine. + + Dec NumWindows + + Mov AX, CurrentWindow + Cmp AX, NumWindows + JB DisplayDelete3 + + Dec CurrentWindow ; Combine with earlier. + Add [SI-8+4], BX + Jmp DisplayDelete1 + +DisplayDelete3: ; Combine with next + Add [SI+4], BX + Mov AL, [SI+3] + Sub AL, BL + Mov [SI+3], AL + Mov AH, 160 + Mul AH + Mov [SI+6], AX + +DisplayDelete1: + Mov AX, 1 + Ret + +EndP DisplayDelete + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayNext Far + Assume DS:InfoPage + + Mov AX, CurrentWindow + Inc AX + Cmp AX, NumWindows + JB DisplayNext1 + + Xor AX, AX + +DisplayNext1: + Mov CurrentWindow, AX + + Mov AX, 1 + Ret + +EndP DisplayNext + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayPrevious Far + + Mov AX, CurrentWindow + And AX, AX + JZ DisplayPrevious1 + + Dec AX + Mov CurrentWindow, AX + +DisplayPrevious1: + Mov AX, 1 + Ret + +EndP DisplayPrevious + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayAltUp Far + Assume DS:InfoPage + + Mov BX, 3 + + Mov AX, CurrentWindow + Sub AX, 1 + AdC BX, 0 + Add AX, 2 + + Cmp AX, NumWindows + JAE DisplayAltUp1 + + Mov AH, 8 + Mul AH + Mov SI, Offset DisplayWindows + Add SI, AX + + Cmp Word Ptr [SI-8+4], BX + JBE DisplayAltUp1 + + Inc Word Ptr [SI+4] + Dec Word Ptr [SI-8+4] + Dec Byte Ptr [SI+3] + Sub Word Ptr [SI+6], 160 + +DisplayAltUp1: + Mov AX, 1 + Ret + +EndP DisplayAltUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayAltDown Far + Assume DS:InfoPage + + Mov AX, CurrentWindow + Inc AX + Cmp AX, NumWindows + JAE DisplayAltDown1 + + Mov AH, 8 + Mul AH + Mov SI, Offset DisplayWindows + Add SI, AX + + Cmp Word Ptr [SI+4], 3 + JBE DisplayAltDown1 + + Inc Word Ptr [SI-8+4] + Dec Word Ptr [SI+4] + Inc Byte Ptr [SI+3] + Add Word Ptr [SI+6], 160 + +DisplayAltDown1: + Mov AX, 1 + Ret + +EndP DisplayAltDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayPageUp Far + Assume DS:InfoPage + + Mov AX, CurrentWindow + Mov AH, 8 + Mul AH + Mov SI, Offset DisplayWindows + Add SI, AX + + Mov AX, [SI] + And AX, AX + JNZ DisplayPageUp1 + + Mov AX, PLAYMETHODS + +DisplayPageUp1: + Dec AX + Mov [SI], AX + + Mov AX, 1 + Ret + +EndP DisplayPageUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayPageDown Far + Assume DS:InfoPage + + Mov AX, CurrentWindow + Mov AH, 8 + Mul AH + Mov SI, Offset DisplayWindows + Add SI, AX + + Mov AX, [SI] + Inc AX + Cmp AX, PLAYMETHODS + JB DisplayPageDown1 + + Xor AX, AX + +DisplayPageDown1: + Mov [SI], AX + + Mov AX, 1 + Ret + +EndP DisplayPageDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayHome Far + Assume DS:InfoPage + + Mov CurrentChannel, 0 + + Mov AX, 1 + Ret + +EndP DisplayHome + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayEnd Far + Assume DS:InfoPage + + Call Music_GetLastChannel + Mov CurrentChannel, AX + + Mov AX, 1 + Ret + +EndP DisplayEnd + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayToggleChannel Far + + Mov AX, CurrentChannel + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP DisplayToggleChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplaySoloChannel Far + + Mov AX, CurrentChannel + Call Music_SoloChannel + + Mov AX, 1 + Ret + +EndP DisplaySoloChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +OldEBX DD 0 +OldECX DD 0 + +Proc DisplayUpdateScreen Far + +IF NETWORKENABLED + Call Network_Poll + + Test AX, AX + JNZ DisplayUpdateScreen1 +ENDIF + + Call Music_Poll + Call Music_GetPlayMode2 + + Test AX, AX + JZ DisplayUpdateScreen3 ; Play mode 0 - update screen + + Cmp CS:OldEBX, EBX + JNE DisplayUpdateScreen2 + + Cmp CS:OldECX, ECX + JNE DisplayUpdateScreen2 + + Xor AX, AX + Ret + +DisplayUpdateScreen3: + Mov EBX, -1 + Mov ECX, EBX + +DisplayUpdateScreen2: + Mov CS:OldEBX, EBX + Mov CS:OldECX, ECX + +DisplayUpdateScreen1: + Mov AX, 1 + Ret + +EndP DisplayUpdateScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayToggleStereo Far + Assume DS:InfoPage + + Call Music_GetSongSegment + Mov ES, AX + + Mov AL, [ES:2Ch] + Xor AL, 1 + Mov [ES:2Ch], AL + + Mov SI, Offset StereoEnabledMsg + Test AL, 1 + JNZ DisplayToggleStereo1 + + Mov SI, Offset StereoDisabledMsg + +DisplayToggleStereo1: + Call SetInfoLine + Call Music_InitStereo + + Mov AX, 1 + Ret + +EndP DisplayToggleStereo + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_GetDisplayWindowData Far + + Push CS + Pop DS + Assume DS:InfoPage + + Mov DX, Offset DisplayWindows + + Ret + +EndP DIsplay_GetDisplayWindowData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_GotoPattern Far + + Call Music_GetPlayMode + Cmp AX, 1 + JB Display_GotoPattern1 + JE Display_GotoPattern2 + + Push Pattern + Pop DS + Assume DS:Pattern + + Mov Order, DX + +Display_GotoPattern2: + Mov AX, CX + ; BX = current row + Mov CX, CS:CurrentChannel + + Jmp PE_GotoPattern + +Display_GotoPattern1: + Xor AX, AX + Ret + +EndP Display_GotoPattern + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_SpaceBar Far + Assume DS:InfoPage + + Call DisplayToggleChannel + Jmp DisplayDown + +EndP Display_SpaceBar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayToggleVelocity Far + + Mov SI, Offset VolumeMsg + Xor Byte Ptr Velocity, 1 + JZ DisplayToggleVelocity1 + + Mov SI, Offset VelocityMsg + +DisplayToggleVelocity1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP DisplayToggleVelocity + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayToggleInstrument Far + + Mov SI, Offset SampleMsg + Xor Byte Ptr Instrument, 1 + JZ DisplayToggleInstrument1 + + Mov SI, Offset InstrumentMsg + +DisplayToggleInstrument1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP DisplayToggleInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DisplayToggleReverse Far + + Call Music_ToggleReverse + + Mov AX, 1 + Ret + +EndP DisplayToggleReverse + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_SelectDisplayList Far + + Cmp CS:FullScreen, 1 + JZ Display_FullScreen3 + Jmp Display_FullScreen4 + +EndP Display_SelectDisplayList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Display_FullScreen Far + + Cmp NumWindows, 1 + JE Display_FullScreen1 + + Mov AX, 1 + Ret + +Display_FullScreen1: + Push Glbl + Pop ES + Assume ES:Glbl + Mov ES:CurrentMode, 5 + Assume ES:Nothing + + Xor FullScreen, 1 + + JZ Display_FullScreen2 + + Mov Byte Ptr [DisplayWindows+3], 1 + Mov DWord Ptr [DisplayWindows+4], 160*10000h+49 + +Display_FullScreen3: + Push Glbl + Pop ES + Assume ES:Glbl + Mov ES:CurrentMode, 200 + Assume ES:Nothing + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + + Mov DX, Offset O1_FullDisplayList + Ret + +Display_FullScreen2: + Mov Byte Ptr [DisplayWindows+3], 12 + Mov DWord Ptr [DisplayWindows+4], 12*80*2*65536+38 + +Display_FullScreen4: + Push Glbl + Pop ES + Assume ES:Glbl + Mov ES:CurrentMode, 5 + Assume ES:Nothing + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + + Mov DX, Offset O1_DisplayList + Ret + +EndP Display_FullScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF SPECTRUMANALYSER + +Proc Display_FourierStart Far + + Jmp Fourier_Start + +EndP Display_FourierStart + +ENDIF + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_EMS.ASM b/it_ems.s similarity index 96% rename from IT_EMS.ASM rename to it_ems.s index 647fbe6..6f36248 100644 --- a/IT_EMS.ASM +++ b/it_ems.s @@ -1,973 +1,973 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ EMS Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -include switch.inc - -; Memory structure for patterns: -; Memory Block Header -; Memory data -; -; Block Header -; Offset 0: DWord - Number of bytes in block (not including header) -; Offset 4: Word - Segment of last block, 0 if first -; Offset 6: Word - Segment of next block, 0 if last -; Offset 8: Byte - 0 = Unused, 1 = Used -; Offset 9-0Fh: Not used -; Offset 10h Data - - Jumps - .386 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Object1 BYTE Public 'Data' - Extrn EMSErrorValue:Word - Extrn EMSErrorValue2:Word - Extrn EMSErrorValue3:Word - Extrn EMSErrorValue4:Word - Extrn EMSErrorValue5:Word - Extrn EMSErrorValue6:Word - Extrn EMSErrorValue7:Word - Extrn EMSErrorValue8:Word -EndS - - Extrn M_Object1List:Far - - Extrn O1_EMSWarningMessage - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global E_AllocateEMS:Far - Global E_InitEMS:Far - Global E_UnInitEMS:Far - Global E_GetFreeEMS:Far - Global E_ReleaseEMS:Far - Global E_MapEMSMemory:Far, E_MapAvailableEMSMemory:Far - Global E_GetEMSPageFrame:Far - Global E_EMSAvailable:Far - Global E_SaveEMSPageFrame:Far - Global E_RestoreEMSPageFrame:Far - Global E_AllocateBlockEMS:Far, E_ReleaseBlockEMS:Far - Global E_MapAlignedBlockEMS:Far - Global E_GetEMSVersion:Far - Global E_GetInternalEMSHandle:Far - -IF EMSDEBUG - - Global E_DumpEMSMemory:Far - -ENDIF - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment EMS WORD Public 'Code' USE16 - Assume CS:EMS, DS:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -CREATENEWLOGFILE EQU 0 -include debug.inc - -EMSDetectString DB "EMMXXXX0" ; Identification string -EMSHandlesRemaining DW 0 -EMSAvailable DW 0 ; Assume that it's not avail. -EMSPageFrame DW 0 -EMSHandle DW 0 -EMSVersion DB 0 - DB 0 - -IF EMSDEBUG - -EMSDumpName DB "EMSDump", 0 - -ENDIF - -EMSCorrespondenceList Label Word - Page0 DB 0, 0 - DW 0 - Page1 DB 0, 0 - DW 1 - Page2 DB 0, 0 - DW 2 - Page3 DB 0, 0 - DW 3 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc E_InitEMS Far - - Push DS - Push ES - - Trace " - Determining EMS presence" - - Xor AX, AX - Mov DS, AX - - Mov AX, [DS:019Eh] ; Get interrupt vector for Int 67h - And AX, AX ; Is Segment = 0? - JZ E_InitEMS1 - - Mov ES, AX - Mov DI, 0Ah ; Offset into driver of identification string - - Push CS - Pop DS - Assume DS:EMS - - Mov SI, Offset EMSDetectString - - Mov CX, 8/2 - - RepE CmpsW - JNE E_InitEMS1 - ; EMM driver is present - - Mov AH, 40h ; Get manager status - Int 67h ; Returns AH=0 -> no error - And AH, AH - JNZ E_InitEMS1 - - Trace " - Determining EMS Page Frame" - - Mov AH, 41h ; Get page frame segment - Int 67h ; AH if successful, with BX=segment - And AH, AH - JNZ E_InitEMS1 - - Mov EMSPageFrame, BX - - Trace " - Determining EMS Version" - - Mov AH, 46h ; Get EMS version - Int 67h - Test AH, AH - JNZ E_InitEMS1 - - Mov EMSVersion, AL - - Trace " - Allocating EMS block" - - Mov AH, 43h - Mov BX, 8 - Int 67h - - Test AH, AH - JNZ E_InitEMS1 - - Mov EMSHandle, DX - - Mov AX, 4400h - Xor BX, BX - Int 67h ; Map first page - - Mov ES, EMSPageFrame - Xor DI, DI - Mov EAX, 8*16*1024-16 - StosD ; Amount of memory free - Xor EAX, EAX ; No previous block, no next block - StosD - Xor AX, AX ; Unused block - StosW - - Mov EMSAvailable, 1 - - ; OK.. now to get number of EMS - ; handles available.. - - Trace " - Determining number of free EMS handles" - - Cmp EMSVersion, 40h - JB E_InitEMSBelow4 - - Mov AX, 5402h - Int 67h ; BX = total number of pages. - Test AH, AH - JNZ E_InitEMSBelow4 - - Mov DX, BX - - Mov AH, 4Bh - Int 67h - - Test AH, AH - JNZ E_InitEMSBelow4 - - Sub DX, BX - Mov EMSHandlesRemaining, DX - - Jmp E_InitEMS1 - -E_InitEMSBelow4: - - Mov CX, 256 ; Allocate 256 MAX - -E_InitEMS2: - Mov AH, 43h - Mov BX, 1 - Int 67h - - Test AH, AH - JNZ E_InitEMS3 - - Inc EMSHandlesRemaining - Push DX - Loop E_InitEMS2 - -E_InitEMS3: - Mov CX, EMSHandlesRemaining ; Now to dealloc them - - Test CX, CX -E_InitEMS4: - JZ E_InitEMS1 - - Mov AH, 45h - Pop DX - Int 67h - - Dec CX - Jmp E_InitEMS4 - -E_InitEMS1: - Pop ES - Pop DS - Ret - -EndP E_InitEMS - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_GetFreeEMS Far ; Returns kb free.. - - Push BX - Push DX - - Cmp EMSAvailable, 0 - JE E_GetFreeEMS2 ; No EMM driver? - - Mov AH, 42h ; Get page counts - Int 67h - - And AH, AH ; AH=0 -> no error - JNZ E_GetFreeEMS2 ; BX = free pages - - Mov AX, BX - ShL AX, 4 - - Jmp E_GetFreeEMS1 - -E_GetFreeEMS2: - Xor AX, AX - -E_GetFreeEMS1: - Pop DX - Pop BX - Ret - -EndP E_GetFreeEMS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_ReleaseEMS Far ; AX = handle. - - Push AX - Push DX - - Mov DX, AX - Mov AH, 45h ; Deallocate memory. - Int 67h - - And AH, AH ; AH = 0 -> no error - JZ E_ReleaseEMS1 - - Call EMSWarning - -E_ReleaseEMS1: - Inc CS:EMSHandlesRemaining - - Pop DX - Pop AX - - Ret - -EndP E_ReleaseEMS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EMSWarning - - PushAD - Push DS - Push ES - - Mov BX, Object1 - Mov DS, BX - Assume DS:Object1 - - Mov Byte Ptr EMSErrorValue, AH - Mov EMSErrorValue2, CX - Mov EMSErrorValue3, DX - - Mov AX, Word Ptr CS:EMSVersion - Mov EMSErrorValue8, AX - - Mov AL, CS:Page0 - Mov Byte Ptr EMSErrorValue4, AL - - Mov AL, CS:Page1 - Mov Byte Ptr EMSErrorValue5, AL - - Mov AL, CS:Page2 - Mov Byte Ptr EMSErrorValue6, AL - - Mov AL, CS:Page3 - Mov Byte Ptr EMSErrorValue7, AL - - Mov DI, Offset O1_EMSWarningMessage - Mov CX, 2 - Call M_Object1List - - Pop ES - Pop DS - PopAD - - Ret - -EndP EMSWarning - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_MapAvailableEMSMemory Far - ; AX = handle. - - Push AX BX DX - - Mov DX, AX - - Xor AL, AL - Xor BX, BX - -E_MapAvailableEMSMemory1: - Mov AH, 44h - Int 67h - Test AH, AH - JNZ E_MapAvailableEMSMemory2 - - Inc AX - Inc BX - - Cmp AL, 3 - JBE E_MapAvailableEMSMemory1 - -E_MapAvailableEMSMemory2: - Pop DX BX AX - - Ret - -EndP E_MapAvailableEMSMemory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_MapEMSMemory Far ; CL = total pages in handle - ; CH = starting (base) page. - ; DX = handle - - Push AX - Push BX - Push CX - - Sub CL, CH - JBE E_MapEMSMemory002 - - Cmp CL, 4 - JB E_MapEMSMemory003 - - Mov CL, 4 - -E_MapEMSMemory003: - -IF EMSUSE41 - Cmp CS:EMSVersion, 40h - JAE E_MapEMSMemoryV4_1 -ENDIF - - Xor BX, BX - -E_MapEMSMemory001: - Mov AL, CL - Dec AX - Mov BL, AL - Add BL, CH - Mov AH, 44h - Int 67h - - And AH, AH - JNZ E_MapEMSMemory004 - - Dec CL - JNZ E_MapEMSMemory001 - Jmp E_MapEMSMemory002 - -IF EMSUSE41 - -E_MapEMSMemoryV4_1: - Push DS - Push SI - PushF - - CLI - - Push CS - Pop DS - Assume DS:EMS - - Mov Page0, CH - Inc CH - Mov Page1, CH - Inc CH - Mov Page2, CH - Inc CH - Mov Page3, CH - - Mov AX, 5000h - Xor CH, CH - Mov SI, Offset EMSCorrespondenceList - Int 67h - - PopF - Pop SI - Pop DS - Assume DS:Nothing - - Test AH, AH - JZ E_MapEMSMemory002 - -ENDIF - -E_MapEMSMemory004: -; Call EMSWarning - -E_MapEMSMemory002: - Pop CX - Pop BX - Pop AX - -E_MapEMSMemoryExit: - Ret - -EndP E_MapEMSMemory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_UnInitEMS Far - - Cmp EMSAvailable, 0 - JE E_UnInitEMS1 - - Mov AX, EMSHandle - Call E_ReleaseEMS - -E_UnInitEMS1: - Ret - -EndP E_UnInitEMS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_GetEMSPageFrame Far - - Mov AX, CS:EMSPageFrame - Ret - -EndP E_GetEMSPageFrame - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_MapAlignedBlockEMS Far ; Given AX, Return DS:SI - - Push CX DX - - Mov SI, AX - Mov CX, AX - ShL SI, 4 - Mov CL, 8 - ShR CH, 2 - And SI, 03FFFh - - Mov DX, CS:EMSHandle - Call E_MapEMSMemory - - Mov DS, CS:EMSPageFrame - - Pop DX CX - - Ret - -EndP E_MapAlignedBlockEMS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_AllocateBlockEMS Far ; EAX = number of bytes - ; Destroys EMS page frame - ; Returns AX = segment address - ; Carry set if fail, clear if - ; successful - - ClI - Push EBX ECX EDX ESI EDI DS ES - - Cmp CS:EMSAvailable, 0 - JE AllocateBlockQuitError - - Mov ESI, EAX - Add ESI, 0Fh - And ESI, Not 0Fh - - Mov DS, CS:EMSPageFrame - Xor EDI, EDI ; EDI = current offset - - Mov CX, 0008h ; Starting page = 0, Max page = 8 - -AllocateBlockEMS2: - Mov DX, CS:EMSHandle - Call E_MapEMSMemory - -AllocateBlockEMS1: - Cmp Byte Ptr [DI+8], 0 ; Used? - JNE AllocateBlockEMSNext - - Cmp ESI, [DI] - JA AllocateBlockEMSNext - - Mov AX, DI - And AX, 3FFFh - Add AX, SI - JC AllocateBlockQuitError ; Can't fit it in! - -; OK. this block will do - Mov Byte Ptr [DI+8], 1 ; This block used - - Mov EBX, [DI] ; Size of block - Mov [DI], ESI ; New size of this block - - Mov EAX, [DI+4] ; To get next in HEAX - Mov ECX, EDI ; ECX = Current offset - ShR ECX, 4 ; ECX = Segment reference - Mov AX, CX ; AX = segment, HEAX = next seg - - Sub EBX, ESI ; Bytes in next block - JZ AllocateBlockPerfectEnd - Sub EBX, 16 - - LEA ESI, [ESI+EDI+16] ; ESI = position of split block - Push ESI - ShR ESI, 4 ; SI = segment of split block - Mov [DI+6], SI ; Store pointer to next block - Pop EDI ; EDI = position of split block - - Mov ECX, EDI ; ECX = position of split block - ShR ECX, 6 - And CH, Not 3 - Mov CL, 8 - Call E_MapEMSMemory - - Mov [DI], EBX ; bytes in block - Mov [DI+4], EAX ; Last block & Next block - Mov Byte Ptr [DI+8], 0 ; Unused block - - Push AX - Mov AX, [DI+6] - - Test AX, AX - JZ NoNextBlockSplit - - Call E_MapAlignedBlockEMS ; DS:SI Pointing to next - ShR EDI, 4 - Mov [SI+4], DI - -NoNextBlockSplit: - Pop AX - - ClC - Jmp AllocateBlockQuit - -AllocateBlockPerfectEnd: -; Mov Word Ptr [DI+6], 0 ; Last block. - ClC - Jmp AllocateBlockQuit - -AllocateBlockEMSNext: - Mov CX, [DI+6] ; Next segment - And ECX, 0FFFFh - JZ AllocateBlockQuitError - -; Check EDI and ECX for the same frame.. if the same, then skip updating (E)DI -; and only update DI - - ShLD EAX, EDI, 16 ; AL = 64k frame - Mov EDI, ECX - ShR CH, 4 - ShL EDI, 4 - - Cmp AL, CH - JE AllocateBlockEMS1 - - ShL CH, 2 - Mov CL, 8 - Jmp AllocateBlockEMS2 - -AllocateBlockQuitError: - StC - -AllocateBlockQuit: - Pop ES DS EDI ESI EDX ECX EBX - StI - Ret - -EndP E_AllocateBlockEMS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_ReleaseBlockEMS Far ; Given AX = 'segment'. - - ClI - Push EAX EBX DS SI - - Mov BX, AX ; BX = current segment - Call E_MapAlignedBlockEMS - ; DS:SI points to structure. - - Mov Byte Ptr [DS:SI+8], 0 ; This block unused. - -; Release later block first, if possible - - Mov AX, [DS:SI+6] - Test AX, AX - JZ E_ReleaseBlockEMSNoneAfter ; Nope, this is the - ; last block. - Call E_MapAlignedBlockEMS ; OK, DS:0 points to next block - Mov EAX, [DS:SI+4] ; HEAX = next block, AX = last block - Mov EBX, [DS:SI] ; Free memory - Cmp Byte Ptr [DS:SI+8], 0 ; Used? - JNE E_ReleaseBlockAfterEnd - - Call E_MapAlignedBlockEMS - Add EBX, 16 - Add [DS:SI], EBX - - Push AX - Mov AX, [DS:SI+4] - Mov [DS:SI+4], EAX - Pop AX - - Jmp E_ReleaseBlockEMSBefore - -E_ReleaseBlockAfterEnd: - Call E_MapAlignedBlockEMS - Jmp E_ReleaseBlockEMSBefore - -E_ReleaseBlockEMSNoneAfter: - Mov AX, BX - -E_ReleaseBlockEMSBefore: - Test AX, AX - JZ E_ReleaseBlockFinished - - Mov EAX, [DS:SI+4] - Mov EBX, [DS:SI] - Call E_MapAlignedBlockEMS - - Cmp Byte Ptr [DS:SI+8], 0 - JNE E_ReleaseBlockPreviousFailed - - Push AX - - Mov AX, [DS:SI+4] ; Last field - Mov [DS:SI+4], EAX ; Next field written - Add EBX, 16 - Add [DS:SI], EBX - - Pop AX - Jmp E_ReleaseBlockFinished - -E_ReleaseBlockPreviousFailed: - Mov AX, [DS:SI+6] - -E_ReleaseBlockFinished: - Mov BX, AX - Call E_MapAlignedBlockEMS ; DS:SI points to 'base' block - Mov AX, [SI+6] ; Next - - Test AX, AX - JZ E_ReleaseBlockCleanup - - Call E_MapAlignedblockEMS - Mov [SI+4], BX - -E_ReleaseBlockCleanup: - - Pop SI DS EBX EAX - StI - Ret - -EndP E_ReleaseBlockEMS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_AllocateEMS Far ; EAX = number of bytes - ; Returns AX with handle - ; 0 if no handle allocated - ; given carry = essential - ; no carry = spare EMS - - Push EBX - Push ECX - Push EDX - - Mov DX, CS:EMSHandlesRemaining - JC E_AllocateEMS3 - - Cmp DX, 10 - JB E_AllocateEMS2 - -E_AllocateEMS3: - Test DX, DX - JZ E_AllocateEMS1 - - Cmp CS:EMSAvailable, 0 - JE E_AllocateEMS2 - - Mov EBX, EAX - Add EBX, 16*1024-1 - SHR EBX, 14 - - Mov AH, 43h - Int 67h - Test AH, AH - JNZ E_AllocateEMS2 - - Dec CS:EMSHandlesRemaining - Jmp E_AllocateEMS1 - -E_AllocateEMS2: - Xor DX, DX - -E_AllocateEMS1: - Mov AX, DX - - Pop EDX - Pop ECX - Pop EBX - Ret - -EndP E_AllocateEMS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_EMSAvailable Far ; Returns Zero flag set if no EMS - - Cmp CS:EMSAvailable, 0 - Ret - -EndP E_EMSAvailable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Comment ~ - -Proc E_SavePageFrame Far ; Given DX = Handle -Public E_SavePageFrame - - Push AX - Push DX - - Mov AH, 47h - Int 67h - Test AH, AH - JZ E_SavePageFrame1 - - Call EMSWarning - -E_SavePageFrame1: - Pop DX - Pop AX - - Ret - -EndP E_SavePageFrame - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_RestorePageFrame Far ; Given DX = Handle -Public E_RestorePageFrame - - Push AX - Push DX - - Mov AH, 48h - Int 67h - Test AH, AH - JZ E_RestorePageFrame1 - - Call EMSWarning - -E_RestorePageFrame1: - Pop DX - Pop AX - - Ret - -EndP E_RestorePageFrame - -~ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_SaveEMSPageFrame Far - - Cmp CS:EMSAvailable, 0 - JE E_SaveEMSPageFrame1 - - Push AX - Push DX - - Mov DX, CS:EMSHandle - Mov AH, 47h - Int 67h - -; Cmp AH, 1 - -; Test AH, AH -; JZ E_SaveEMSPageFrame2 - -; Call EMSWarning - - And AH, AH - JZ E_SaveEMSPageFrame2 - - StC - -E_SaveEMSPageFrame2: - Pop DX - Pop AX - -E_SaveEMSPageFrame1: - Ret - -EndP E_SaveEMSPageFrame - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_RestoreEMSPageFrame Far - - Cmp CS:EMSAvailable, 0 - JE E_RestoreEMSPageFrame1 - - Push AX - Push DX - - Mov DX, EMSHandle - Mov AH, 48h - Int 67h - - Pop DX - Pop AX - -E_RestoreEMSPageFrame1: - Ret - -EndP E_RestoreEMSPageFrame - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_GetEMSVersion Far - - Mov AL, CS:EMSVersion - Ret - -EndP E_GetEMSVersion - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc E_GetInternalEMSHandle Far - - Mov AX, CS:EMSHandle - Ret - -EndP E_GetInternalEMSHandle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF EMSDEBUG - -Proc E_DumpEMSMemory Far - - Push CS - Pop DS - Assume DS:EMS - - Mov AH, 3Ch - Xor CX, CX - Mov DX, Offset EMSDumpName - Int 21h - - Mov BX, AX - - Mov CX, 8 - Mov DX, EMSHandle - Call E_MapEMSMemory - - Mov AH, 40h - Mov CX, 32768 - Mov DS, EMSPageFrame - Xor DX, DX - Int 21h - - Mov AH, 40h - Mov DX, 32768 - Mov CX, DX - Int 21h - - Mov CX, 408h - Mov DX, CS:EMSHandle - Call E_MapEMSMemory - - Mov AH, 40h - Mov CX, 32768 - Xor DX, DX - Int 21h - - Mov AH, 40h - Mov DX, 32768 - Mov CX, DX - Int 21h - - Mov AH, 3Eh - Int 21h - - Xor AX, AX - Ret - -EndP E_DumpEMSMemory - Assume DS:Nothing - -ENDIF - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ EMS Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +include switch.inc + +; Memory structure for patterns: +; Memory Block Header +; Memory data +; +; Block Header +; Offset 0: DWord - Number of bytes in block (not including header) +; Offset 4: Word - Segment of last block, 0 if first +; Offset 6: Word - Segment of next block, 0 if last +; Offset 8: Byte - 0 = Unused, 1 = Used +; Offset 9-0Fh: Not used +; Offset 10h Data + + Jumps + .386 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Object1 BYTE Public 'Data' + Extrn EMSErrorValue:Word + Extrn EMSErrorValue2:Word + Extrn EMSErrorValue3:Word + Extrn EMSErrorValue4:Word + Extrn EMSErrorValue5:Word + Extrn EMSErrorValue6:Word + Extrn EMSErrorValue7:Word + Extrn EMSErrorValue8:Word +EndS + + Extrn M_Object1List:Far + + Extrn O1_EMSWarningMessage + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global E_AllocateEMS:Far + Global E_InitEMS:Far + Global E_UnInitEMS:Far + Global E_GetFreeEMS:Far + Global E_ReleaseEMS:Far + Global E_MapEMSMemory:Far, E_MapAvailableEMSMemory:Far + Global E_GetEMSPageFrame:Far + Global E_EMSAvailable:Far + Global E_SaveEMSPageFrame:Far + Global E_RestoreEMSPageFrame:Far + Global E_AllocateBlockEMS:Far, E_ReleaseBlockEMS:Far + Global E_MapAlignedBlockEMS:Far + Global E_GetEMSVersion:Far + Global E_GetInternalEMSHandle:Far + +IF EMSDEBUG + + Global E_DumpEMSMemory:Far + +ENDIF + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment EMS WORD Public 'Code' USE16 + Assume CS:EMS, DS:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +CREATENEWLOGFILE EQU 0 +include debug.inc + +EMSDetectString DB "EMMXXXX0" ; Identification string +EMSHandlesRemaining DW 0 +EMSAvailable DW 0 ; Assume that it's not avail. +EMSPageFrame DW 0 +EMSHandle DW 0 +EMSVersion DB 0 + DB 0 + +IF EMSDEBUG + +EMSDumpName DB "EMSDump", 0 + +ENDIF + +EMSCorrespondenceList Label Word + Page0 DB 0, 0 + DW 0 + Page1 DB 0, 0 + DW 1 + Page2 DB 0, 0 + DW 2 + Page3 DB 0, 0 + DW 3 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc E_InitEMS Far + + Push DS + Push ES + + Trace " - Determining EMS presence" + + Xor AX, AX + Mov DS, AX + + Mov AX, [DS:019Eh] ; Get interrupt vector for Int 67h + And AX, AX ; Is Segment = 0? + JZ E_InitEMS1 + + Mov ES, AX + Mov DI, 0Ah ; Offset into driver of identification string + + Push CS + Pop DS + Assume DS:EMS + + Mov SI, Offset EMSDetectString + + Mov CX, 8/2 + + RepE CmpsW + JNE E_InitEMS1 + ; EMM driver is present + + Mov AH, 40h ; Get manager status + Int 67h ; Returns AH=0 -> no error + And AH, AH + JNZ E_InitEMS1 + + Trace " - Determining EMS Page Frame" + + Mov AH, 41h ; Get page frame segment + Int 67h ; AH if successful, with BX=segment + And AH, AH + JNZ E_InitEMS1 + + Mov EMSPageFrame, BX + + Trace " - Determining EMS Version" + + Mov AH, 46h ; Get EMS version + Int 67h + Test AH, AH + JNZ E_InitEMS1 + + Mov EMSVersion, AL + + Trace " - Allocating EMS block" + + Mov AH, 43h + Mov BX, 8 + Int 67h + + Test AH, AH + JNZ E_InitEMS1 + + Mov EMSHandle, DX + + Mov AX, 4400h + Xor BX, BX + Int 67h ; Map first page + + Mov ES, EMSPageFrame + Xor DI, DI + Mov EAX, 8*16*1024-16 + StosD ; Amount of memory free + Xor EAX, EAX ; No previous block, no next block + StosD + Xor AX, AX ; Unused block + StosW + + Mov EMSAvailable, 1 + + ; OK.. now to get number of EMS + ; handles available.. + + Trace " - Determining number of free EMS handles" + + Cmp EMSVersion, 40h + JB E_InitEMSBelow4 + + Mov AX, 5402h + Int 67h ; BX = total number of pages. + Test AH, AH + JNZ E_InitEMSBelow4 + + Mov DX, BX + + Mov AH, 4Bh + Int 67h + + Test AH, AH + JNZ E_InitEMSBelow4 + + Sub DX, BX + Mov EMSHandlesRemaining, DX + + Jmp E_InitEMS1 + +E_InitEMSBelow4: + + Mov CX, 256 ; Allocate 256 MAX + +E_InitEMS2: + Mov AH, 43h + Mov BX, 1 + Int 67h + + Test AH, AH + JNZ E_InitEMS3 + + Inc EMSHandlesRemaining + Push DX + Loop E_InitEMS2 + +E_InitEMS3: + Mov CX, EMSHandlesRemaining ; Now to dealloc them + + Test CX, CX +E_InitEMS4: + JZ E_InitEMS1 + + Mov AH, 45h + Pop DX + Int 67h + + Dec CX + Jmp E_InitEMS4 + +E_InitEMS1: + Pop ES + Pop DS + Ret + +EndP E_InitEMS + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_GetFreeEMS Far ; Returns kb free.. + + Push BX + Push DX + + Cmp EMSAvailable, 0 + JE E_GetFreeEMS2 ; No EMM driver? + + Mov AH, 42h ; Get page counts + Int 67h + + And AH, AH ; AH=0 -> no error + JNZ E_GetFreeEMS2 ; BX = free pages + + Mov AX, BX + ShL AX, 4 + + Jmp E_GetFreeEMS1 + +E_GetFreeEMS2: + Xor AX, AX + +E_GetFreeEMS1: + Pop DX + Pop BX + Ret + +EndP E_GetFreeEMS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_ReleaseEMS Far ; AX = handle. + + Push AX + Push DX + + Mov DX, AX + Mov AH, 45h ; Deallocate memory. + Int 67h + + And AH, AH ; AH = 0 -> no error + JZ E_ReleaseEMS1 + + Call EMSWarning + +E_ReleaseEMS1: + Inc CS:EMSHandlesRemaining + + Pop DX + Pop AX + + Ret + +EndP E_ReleaseEMS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EMSWarning + + PushAD + Push DS + Push ES + + Mov BX, Object1 + Mov DS, BX + Assume DS:Object1 + + Mov Byte Ptr EMSErrorValue, AH + Mov EMSErrorValue2, CX + Mov EMSErrorValue3, DX + + Mov AX, Word Ptr CS:EMSVersion + Mov EMSErrorValue8, AX + + Mov AL, CS:Page0 + Mov Byte Ptr EMSErrorValue4, AL + + Mov AL, CS:Page1 + Mov Byte Ptr EMSErrorValue5, AL + + Mov AL, CS:Page2 + Mov Byte Ptr EMSErrorValue6, AL + + Mov AL, CS:Page3 + Mov Byte Ptr EMSErrorValue7, AL + + Mov DI, Offset O1_EMSWarningMessage + Mov CX, 2 + Call M_Object1List + + Pop ES + Pop DS + PopAD + + Ret + +EndP EMSWarning + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_MapAvailableEMSMemory Far + ; AX = handle. + + Push AX BX DX + + Mov DX, AX + + Xor AL, AL + Xor BX, BX + +E_MapAvailableEMSMemory1: + Mov AH, 44h + Int 67h + Test AH, AH + JNZ E_MapAvailableEMSMemory2 + + Inc AX + Inc BX + + Cmp AL, 3 + JBE E_MapAvailableEMSMemory1 + +E_MapAvailableEMSMemory2: + Pop DX BX AX + + Ret + +EndP E_MapAvailableEMSMemory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_MapEMSMemory Far ; CL = total pages in handle + ; CH = starting (base) page. + ; DX = handle + + Push AX + Push BX + Push CX + + Sub CL, CH + JBE E_MapEMSMemory002 + + Cmp CL, 4 + JB E_MapEMSMemory003 + + Mov CL, 4 + +E_MapEMSMemory003: + +IF EMSUSE41 + Cmp CS:EMSVersion, 40h + JAE E_MapEMSMemoryV4_1 +ENDIF + + Xor BX, BX + +E_MapEMSMemory001: + Mov AL, CL + Dec AX + Mov BL, AL + Add BL, CH + Mov AH, 44h + Int 67h + + And AH, AH + JNZ E_MapEMSMemory004 + + Dec CL + JNZ E_MapEMSMemory001 + Jmp E_MapEMSMemory002 + +IF EMSUSE41 + +E_MapEMSMemoryV4_1: + Push DS + Push SI + PushF + + CLI + + Push CS + Pop DS + Assume DS:EMS + + Mov Page0, CH + Inc CH + Mov Page1, CH + Inc CH + Mov Page2, CH + Inc CH + Mov Page3, CH + + Mov AX, 5000h + Xor CH, CH + Mov SI, Offset EMSCorrespondenceList + Int 67h + + PopF + Pop SI + Pop DS + Assume DS:Nothing + + Test AH, AH + JZ E_MapEMSMemory002 + +ENDIF + +E_MapEMSMemory004: +; Call EMSWarning + +E_MapEMSMemory002: + Pop CX + Pop BX + Pop AX + +E_MapEMSMemoryExit: + Ret + +EndP E_MapEMSMemory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_UnInitEMS Far + + Cmp EMSAvailable, 0 + JE E_UnInitEMS1 + + Mov AX, EMSHandle + Call E_ReleaseEMS + +E_UnInitEMS1: + Ret + +EndP E_UnInitEMS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_GetEMSPageFrame Far + + Mov AX, CS:EMSPageFrame + Ret + +EndP E_GetEMSPageFrame + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_MapAlignedBlockEMS Far ; Given AX, Return DS:SI + + Push CX DX + + Mov SI, AX + Mov CX, AX + ShL SI, 4 + Mov CL, 8 + ShR CH, 2 + And SI, 03FFFh + + Mov DX, CS:EMSHandle + Call E_MapEMSMemory + + Mov DS, CS:EMSPageFrame + + Pop DX CX + + Ret + +EndP E_MapAlignedBlockEMS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_AllocateBlockEMS Far ; EAX = number of bytes + ; Destroys EMS page frame + ; Returns AX = segment address + ; Carry set if fail, clear if + ; successful + + ClI + Push EBX ECX EDX ESI EDI DS ES + + Cmp CS:EMSAvailable, 0 + JE AllocateBlockQuitError + + Mov ESI, EAX + Add ESI, 0Fh + And ESI, Not 0Fh + + Mov DS, CS:EMSPageFrame + Xor EDI, EDI ; EDI = current offset + + Mov CX, 0008h ; Starting page = 0, Max page = 8 + +AllocateBlockEMS2: + Mov DX, CS:EMSHandle + Call E_MapEMSMemory + +AllocateBlockEMS1: + Cmp Byte Ptr [DI+8], 0 ; Used? + JNE AllocateBlockEMSNext + + Cmp ESI, [DI] + JA AllocateBlockEMSNext + + Mov AX, DI + And AX, 3FFFh + Add AX, SI + JC AllocateBlockQuitError ; Can't fit it in! + +; OK. this block will do + Mov Byte Ptr [DI+8], 1 ; This block used + + Mov EBX, [DI] ; Size of block + Mov [DI], ESI ; New size of this block + + Mov EAX, [DI+4] ; To get next in HEAX + Mov ECX, EDI ; ECX = Current offset + ShR ECX, 4 ; ECX = Segment reference + Mov AX, CX ; AX = segment, HEAX = next seg + + Sub EBX, ESI ; Bytes in next block + JZ AllocateBlockPerfectEnd + Sub EBX, 16 + + LEA ESI, [ESI+EDI+16] ; ESI = position of split block + Push ESI + ShR ESI, 4 ; SI = segment of split block + Mov [DI+6], SI ; Store pointer to next block + Pop EDI ; EDI = position of split block + + Mov ECX, EDI ; ECX = position of split block + ShR ECX, 6 + And CH, Not 3 + Mov CL, 8 + Call E_MapEMSMemory + + Mov [DI], EBX ; bytes in block + Mov [DI+4], EAX ; Last block & Next block + Mov Byte Ptr [DI+8], 0 ; Unused block + + Push AX + Mov AX, [DI+6] + + Test AX, AX + JZ NoNextBlockSplit + + Call E_MapAlignedBlockEMS ; DS:SI Pointing to next + ShR EDI, 4 + Mov [SI+4], DI + +NoNextBlockSplit: + Pop AX + + ClC + Jmp AllocateBlockQuit + +AllocateBlockPerfectEnd: +; Mov Word Ptr [DI+6], 0 ; Last block. + ClC + Jmp AllocateBlockQuit + +AllocateBlockEMSNext: + Mov CX, [DI+6] ; Next segment + And ECX, 0FFFFh + JZ AllocateBlockQuitError + +; Check EDI and ECX for the same frame.. if the same, then skip updating (E)DI +; and only update DI + + ShLD EAX, EDI, 16 ; AL = 64k frame + Mov EDI, ECX + ShR CH, 4 + ShL EDI, 4 + + Cmp AL, CH + JE AllocateBlockEMS1 + + ShL CH, 2 + Mov CL, 8 + Jmp AllocateBlockEMS2 + +AllocateBlockQuitError: + StC + +AllocateBlockQuit: + Pop ES DS EDI ESI EDX ECX EBX + StI + Ret + +EndP E_AllocateBlockEMS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_ReleaseBlockEMS Far ; Given AX = 'segment'. + + ClI + Push EAX EBX DS SI + + Mov BX, AX ; BX = current segment + Call E_MapAlignedBlockEMS + ; DS:SI points to structure. + + Mov Byte Ptr [DS:SI+8], 0 ; This block unused. + +; Release later block first, if possible + + Mov AX, [DS:SI+6] + Test AX, AX + JZ E_ReleaseBlockEMSNoneAfter ; Nope, this is the + ; last block. + Call E_MapAlignedBlockEMS ; OK, DS:0 points to next block + Mov EAX, [DS:SI+4] ; HEAX = next block, AX = last block + Mov EBX, [DS:SI] ; Free memory + Cmp Byte Ptr [DS:SI+8], 0 ; Used? + JNE E_ReleaseBlockAfterEnd + + Call E_MapAlignedBlockEMS + Add EBX, 16 + Add [DS:SI], EBX + + Push AX + Mov AX, [DS:SI+4] + Mov [DS:SI+4], EAX + Pop AX + + Jmp E_ReleaseBlockEMSBefore + +E_ReleaseBlockAfterEnd: + Call E_MapAlignedBlockEMS + Jmp E_ReleaseBlockEMSBefore + +E_ReleaseBlockEMSNoneAfter: + Mov AX, BX + +E_ReleaseBlockEMSBefore: + Test AX, AX + JZ E_ReleaseBlockFinished + + Mov EAX, [DS:SI+4] + Mov EBX, [DS:SI] + Call E_MapAlignedBlockEMS + + Cmp Byte Ptr [DS:SI+8], 0 + JNE E_ReleaseBlockPreviousFailed + + Push AX + + Mov AX, [DS:SI+4] ; Last field + Mov [DS:SI+4], EAX ; Next field written + Add EBX, 16 + Add [DS:SI], EBX + + Pop AX + Jmp E_ReleaseBlockFinished + +E_ReleaseBlockPreviousFailed: + Mov AX, [DS:SI+6] + +E_ReleaseBlockFinished: + Mov BX, AX + Call E_MapAlignedBlockEMS ; DS:SI points to 'base' block + Mov AX, [SI+6] ; Next + + Test AX, AX + JZ E_ReleaseBlockCleanup + + Call E_MapAlignedblockEMS + Mov [SI+4], BX + +E_ReleaseBlockCleanup: + + Pop SI DS EBX EAX + StI + Ret + +EndP E_ReleaseBlockEMS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_AllocateEMS Far ; EAX = number of bytes + ; Returns AX with handle + ; 0 if no handle allocated + ; given carry = essential + ; no carry = spare EMS + + Push EBX + Push ECX + Push EDX + + Mov DX, CS:EMSHandlesRemaining + JC E_AllocateEMS3 + + Cmp DX, 10 + JB E_AllocateEMS2 + +E_AllocateEMS3: + Test DX, DX + JZ E_AllocateEMS1 + + Cmp CS:EMSAvailable, 0 + JE E_AllocateEMS2 + + Mov EBX, EAX + Add EBX, 16*1024-1 + SHR EBX, 14 + + Mov AH, 43h + Int 67h + Test AH, AH + JNZ E_AllocateEMS2 + + Dec CS:EMSHandlesRemaining + Jmp E_AllocateEMS1 + +E_AllocateEMS2: + Xor DX, DX + +E_AllocateEMS1: + Mov AX, DX + + Pop EDX + Pop ECX + Pop EBX + Ret + +EndP E_AllocateEMS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_EMSAvailable Far ; Returns Zero flag set if no EMS + + Cmp CS:EMSAvailable, 0 + Ret + +EndP E_EMSAvailable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Comment ~ + +Proc E_SavePageFrame Far ; Given DX = Handle +Public E_SavePageFrame + + Push AX + Push DX + + Mov AH, 47h + Int 67h + Test AH, AH + JZ E_SavePageFrame1 + + Call EMSWarning + +E_SavePageFrame1: + Pop DX + Pop AX + + Ret + +EndP E_SavePageFrame + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_RestorePageFrame Far ; Given DX = Handle +Public E_RestorePageFrame + + Push AX + Push DX + + Mov AH, 48h + Int 67h + Test AH, AH + JZ E_RestorePageFrame1 + + Call EMSWarning + +E_RestorePageFrame1: + Pop DX + Pop AX + + Ret + +EndP E_RestorePageFrame + +~ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_SaveEMSPageFrame Far + + Cmp CS:EMSAvailable, 0 + JE E_SaveEMSPageFrame1 + + Push AX + Push DX + + Mov DX, CS:EMSHandle + Mov AH, 47h + Int 67h + +; Cmp AH, 1 + +; Test AH, AH +; JZ E_SaveEMSPageFrame2 + +; Call EMSWarning + + And AH, AH + JZ E_SaveEMSPageFrame2 + + StC + +E_SaveEMSPageFrame2: + Pop DX + Pop AX + +E_SaveEMSPageFrame1: + Ret + +EndP E_SaveEMSPageFrame + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_RestoreEMSPageFrame Far + + Cmp CS:EMSAvailable, 0 + JE E_RestoreEMSPageFrame1 + + Push AX + Push DX + + Mov DX, EMSHandle + Mov AH, 48h + Int 67h + + Pop DX + Pop AX + +E_RestoreEMSPageFrame1: + Ret + +EndP E_RestoreEMSPageFrame + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_GetEMSVersion Far + + Mov AL, CS:EMSVersion + Ret + +EndP E_GetEMSVersion + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc E_GetInternalEMSHandle Far + + Mov AX, CS:EMSHandle + Ret + +EndP E_GetInternalEMSHandle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF EMSDEBUG + +Proc E_DumpEMSMemory Far + + Push CS + Pop DS + Assume DS:EMS + + Mov AH, 3Ch + Xor CX, CX + Mov DX, Offset EMSDumpName + Int 21h + + Mov BX, AX + + Mov CX, 8 + Mov DX, EMSHandle + Call E_MapEMSMemory + + Mov AH, 40h + Mov CX, 32768 + Mov DS, EMSPageFrame + Xor DX, DX + Int 21h + + Mov AH, 40h + Mov DX, 32768 + Mov CX, DX + Int 21h + + Mov CX, 408h + Mov DX, CS:EMSHandle + Call E_MapEMSMemory + + Mov AH, 40h + Mov CX, 32768 + Xor DX, DX + Int 21h + + Mov AH, 40h + Mov DX, 32768 + Mov CX, DX + Int 21h + + Mov AH, 3Eh + Int 21h + + Xor AX, AX + Ret + +EndP E_DumpEMSMemory + Assume DS:Nothing + +ENDIF + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_ERR.ASM b/it_err.s similarity index 86% rename from IT_ERR.ASM rename to it_err.s index cfa1c54..8cceb33 100644 --- a/IT_ERR.ASM +++ b/it_err.s @@ -1,168 +1,169 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Critical Error handler. ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386 - -include switch.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global Error_InitHandler:Far - Global Error_UnInitHandler:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Error BYTE Public 'Code' USE16 - Assume CS:Error - -CREATENEWLOGFILE EQU 0 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -OldHandlerOffset DW ? -OldHandlerSegment DW ? - -ErrorMsgs Label Word - DW Offset Error0 - DW Offset Error1 - DW Offset Error2 - DW Offset Error3 - DW Offset Error4 - DW Offset Error5 - DW Offset Error6 - DW Offset Error7 - DW Offset Error8 - DW Offset Error9 - DW Offset ErrorA - DW Offset ErrorB - DW Offset UnknownError - DW Offset UnknownError - DW Offset UnknownError - DW Offset ErrorF - -Error0 DB "Write protect error", 0 -Error1 DB "Unknown unit error", 0 -Error2 DB "Drive not ready error", 0 -Error3 DB "Unknown command error", 0 -Error4 DB "Data integrity error", 0 -Error5 DB "Bad request structure length error", 0 -Error6 DB "Seek error", 0 -Error7 DB "Unknown media type error", 0 -Error8 DB "Sector not found error", 0 -Error9 DB "Printer error", 0 -ErrorA DB "Read fault error", 0 -ErrorB DB "General failure error", 0 -ErrorF DB "Invalid disk change error", 0 -UnknownError DB "Unknown critical error", 0 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc ErrorHandler Far - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Error - - Mov BX, DI - And BX, 0FFh - Cmp BX, 0Fh - JBE ErrorHandler1 - - Mov SI, Offset UnknownError - Jmp ErrorHandler2 - -ErrorHandler1: - Add BX, BX - Mov SI, [ErrorMsgs+BX] - -ErrorHandler2: - Mov AH, 20h - Mov DI, 0B800h - Mov ES, DI - Mov DI, (2+49*80)*2 - -ErrorHandler3: - LodsB - And AL, AL - JZ ErrorHandler4 - StosW - - Jmp ErrorHandler3 - -ErrorHandler4: - Pop ES - Pop DS - PopA - - Xor AX, AX - - IRet - -EndP ErrorHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Error_InitHandler Far - - Push ES - - Trace " - Installing error handler" - - Xor AX, AX - Mov ES, AX - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset ErrorHandler - - XChg [ES:90h], EAX - Mov DWord Ptr CS:OldHandlerOffset, EAX - - Pop ES - Ret - -EndP Error_InitHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Error_UnInitHandler Far - - Push ES - Xor AX, AX - Mov ES, AX - - Mov EAX, DWord Ptr CS:OldHandlerOffset - Mov [ES:90h], EAX - - Pop ES - Ret - -EndP Error_UnInitHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Critical Error handler. ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +; Jumps +; .386 + +%include "switch.inc" + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global Error_InitHandler:Far + Global Error_UnInitHandler:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +;Segment Error BYTE Public 'Code' USE16 +section .text +%warning "USE16" +; Assume CS:Error + +CREATENEWLOGFILE EQU 0 +%include "debug.inc" + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +OldHandlerOffset DW ? +OldHandlerSegment DW ? + +ErrorMsgs:; Label Word + DW Offset Error0 + DW Offset Error1 + DW Offset Error2 + DW Offset Error3 + DW Offset Error4 + DW Offset Error5 + DW Offset Error6 + DW Offset Error7 + DW Offset Error8 + DW Offset Error9 + DW Offset ErrorA + DW Offset ErrorB + DW Offset UnknownError + DW Offset UnknownError + DW Offset UnknownError + DW Offset ErrorF + +Error0 DB "Write protect error", 0 +Error1 DB "Unknown unit error", 0 +Error2 DB "Drive not ready error", 0 +Error3 DB "Unknown command error", 0 +Error4 DB "Data integrity error", 0 +Error5 DB "Bad request structure length error", 0 +Error6 DB "Seek error", 0 +Error7 DB "Unknown media type error", 0 +Error8 DB "Sector not found error", 0 +Error9 DB "Printer error", 0 +ErrorA DB "Read fault error", 0 +ErrorB DB "General failure error", 0 +ErrorF DB "Invalid disk change error", 0 +UnknownError DB "Unknown critical error", 0 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +ErrorHandler: + PushA + Push DS + Push ES + + Push CS + Pop DS +; Assume DS:Error + + Mov BX, DI + And BX, 0FFh + Cmp BX, 0Fh + JBE ErrorHandler1 + + Mov SI, Offset UnknownError + Jmp ErrorHandler2 + +ErrorHandler1: + Add BX, BX + Mov SI, [ErrorMsgs+BX] + +ErrorHandler2: + Mov AH, 20h + Mov DI, 0B800h + Mov ES, DI + Mov DI, (2+49*80)*2 + +ErrorHandler3: + LodsB + And AL, AL + JZ ErrorHandler4 + StosW + + Jmp ErrorHandler3 + +ErrorHandler4: + Pop ES + Pop DS + PopA + + Xor AX, AX + + IRet + +;EndP ErrorHandler +; Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Error_InitHandler:; Far + + Push ES + + Trace " - Installing error handler" + + Xor AX, AX + Mov ES, AX + + Mov AX, CS + ShL EAX, 16 + Mov AX, ErrorHandler + + XChg [ES:90h], EAX + Mov DWord Ptr CS:OldHandlerOffset, EAX + + Pop ES + Ret + +;EndP Error_InitHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Error_UnInitHandler:; Far + + Push ES + Xor AX, AX + Mov ES, AX + + Mov EAX, DWord Ptr CS:OldHandlerOffset + Mov [ES:90h], EAX + + Pop ES + Ret + +;EndP Error_UnInitHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +;EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +;End diff --git a/IT_F.ASM b/it_f.s similarity index 96% rename from IT_F.ASM rename to it_f.s index 2ae1157..d14c98f 100644 --- a/IT_F.ASM +++ b/it_f.s @@ -1,5950 +1,5950 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386 - -include switch.inc -include network.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -IF MEMORYDEBUG - -Segment StartUp BYTE Public 'Code' -EndS - -Segment InfoPage BYTE Public 'Code' -EndS - -Segment Glbl BYTE Public 'Code' -EndS - -Segment Help BYTE Public 'Code' -EndS - -Segment Error BYTE Public 'Code' -EndS - -Segment EMS BYTE Public 'Code' -EndS - -Segment KeyBoard BYTE Public 'Code' -EndS - -Segment InfoLine BYTE Public 'Code' -EndS - -Segment Main BYTE Public 'Code' -EndS - -ENDIF - -Segment Pattern BYTE Public 'Code' - Extrn PatternDataArea:Word -EndS - -Segment Inst BYTE Public 'Code' - Extrn MaxNode:Word -EndS - -Segment Music BYTE Public 'Code' - Extrn SongDataArea:Word - Extrn MIDIDataArea:Word -EndS - -Segment Disk BYTE Public 'Code' - Extrn DiskDataArea:Word -EndS - -Segment Screen BYTE Public 'Code' -EndS - -Segment Object1 BYTE Public 'Data' -EndS - -;------------------------------------------------------------------------------- - - Extrn LastInstrument:Byte - - Extrn D_GetLoadSampleVars:Far - Extrn D_ClearFileName:Far - Extrn D_SaveSong:Far - Extrn D_ResetTimer:Far - - Extrn E_UnInitEMS:Far - Extrn E_GetFreeEMS:Far - - Extrn Glbl_F2_2:Far - Extrn Glbl_F3:Far - Extrn Glbl_Ctrl_F3:Far - Extrn Glbl_Ctrl_F4:Far - Extrn Glbl_F4:Far - Extrn Glbl_F5:Far - Extrn Glbl_Ctrl_F5:Far - Extrn Glbl_F6:Far - Extrn PE_F7:Far - Extrn Glbl_Shift_F6:Far - Extrn Glbl_Shift_F9:Far - Extrn Glbl_F9:Far - Extrn Glbl_F10:Far - Extrn Glbl_F11_2:Far - Extrn Glbl_F12:Far - - Extrn Glbl_GetHeaderMode:Far - - Extrn H_Help:Far - - Extrn I_GetInstrumentOffset:Far - Extrn I_GetSampleOffset:Far - - Extrn I_DrawWaveForm:Far - Extrn I_MapEnvelope:Far - Extrn D_DrawWaveForm:Far - - Extrn S_InitScreen:Far - Extrn S_Set80x25Mode:Far - Extrn S_SetPalette2:Far - Extrn S_RedefineCharacters:Far - Extrn S_UnInitScreen:Far - Extrn S_DrawBox:Far - Extrn S_UpdateScreen:Far - Extrn S_OverrideVGADetection:Far - Extrn S_SetDirectMode:Far - Extrn S_DrawString:Far - Extrn S_HiLight:Far - Extrn S_GetDestination:Far - Extrn S_SaveScreen:Far - Extrn S_RestoreScreen:Far - - - Extrn Music_GetSongSegment:Far - Extrn Music_InitMixTable:Far - Extrn Music_InitMuteTable:Far - Extrn Music_ClearAllInstruments:Far - Extrn Music_SetGlobalVolume:Far - Extrn Music_InitStereo:Far - Extrn Music_Stop:Far - - Extrn Music_RegetLoopInformation:Far - - Extrn Music_ReleaseAllSamples:Far ; For New Song Function - Extrn Music_ReleaseAllPatterns:Far - Extrn Music_ClearAllInstruments:Far - Extrn Music_ClearAllSampleNames:Far - Extrn Music_GetFreeSoundCardMemory:Far - Extrn Music_SoundCardLoadAllSamples:Far - Extrn Music_ReinitSoundCard:Far - Extrn Music_TimeSong:Far - - Extrn Glbl_DriverScreen:Far - Extrn Music_GetDriverVariable:Far - Extrn Music_SetDriverVariable:Far - - Extrn M_Object1List:Far - - Extrn Msg_ResetMessage:Far - - Extrn O1_EmptyList:Far - Extrn O1_ThumbStringList:Far - Extrn O1_InitialiseInstrumentList:Far - Extrn O1_NewSongList:Far - - Extrn O1_MainMenu:Far - Extrn O1_FileMenu:Far - Extrn O1_PlaybackMenu:Far - Extrn O1_SampleMenu:Far - Extrn O1_InstrumentMenu:Far - - Extrn PE_ConvAX2Num:Far - Extrn PE_ResetOrderPattern:Far - - Extrn DOSShell:Far - Extrn Quit:Far - - Extrn MouseAddEvent:Far, AddMouseQueue:Far, MouseClearEvents:Far - Extrn SetKeyboardLock:Far, NewCharacterSet:Far - Extrn MouseRemoveEvents:Far, MouseRestoreEvents:Far - Extrn MultiChannelInfo:Byte - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global F_MainMenu:Far - Global F_FileMenu:Far - Global F_PlaybackMenu:Far - Global F_SampleMenu:Far - Global F_InstrumentMenu:Far - - Global F_DrawHeader:Far - - Global F_InstrumentButtonHandler:Far - - Global F_NewSong:Far - Global F_DrawStringInput:Far - Global F_PreStringInput:Far - Global F_PostStringInput:Far - Global F_RedrawScreen:Far - Global F_Nothing:Far - Global F_DrawBoxObject:Far - Global F_DrawTextObject:Far - Global F_PostExitObject:Far - Global F_SetDirectMode:Far - Global F_CharacterDefinitions:Far - Global F_CallFarFunction:Far - Global F_CallFarPreFunction:Far - Global F_CallFarPostFunction:Far - - Global F_DrawToggle:Far - Global F_PreToggle:Far - Global F_PostToggle:Far - - Global F_Draw5Num:Far - Global F_Pre5Num:Far - Global F_Post5Num:Far - - Global F_Draw3Num:Far - Global F_Pre3Num:Far - Global F_Post3Num:Far - - Global F_DrawButtonObject:Far - Global F_PreButtonObject:Far - Global F_PostButtonObject:Far - - Global F_Return0:Far - Global F_Return1:Far - Global F_Return64:Far - Global F_Return192:Far - - Global F_DrawThumbBar:Far - Global F_DrawScalableThumbBar:Far - Global F_PreThumbBar:Far - Global F_PreScalableThumbBar:Far - Global F_PostThumbBar:Far - Global F_PostScalableThumbBar:Far - - Global F_DrawInfoLine:Far - - Global F_ShowChannels:Far - Global F_GotoEmptyList:Far - Global F_DrawSMCChannels:Far - - Global F_SetControlInstrument:Far - Global F_SetControlSample:Far - Global F_ConfigButtonSetup:Far - - Global F_SetStereo:Far - Global F_SetMono:Far - Global F_SetAmiga:Far - Global F_SetLinear:Far - - Global F_Reset5NumInputPos:Far - - Global AddressInput:Byte - Global ThumbStringEnter:Byte - - Global F_MessageEditor:Far - Global F_Help:Far ; Main menu - Global F_ViewPattern:Far - Global F_ViewVariables:Far - Global F_ViewOrderPan:Far - - Global F_FileLoad:Far - Global F_FileNew:Far - Global F_FileSaveCurrent:Far - Global F_FileSaveAs:Far - Global F_FileDOSShell:Far - Global F_FileQuit:Far - - Global F_InfoPage:Far ; Playback menu - Global F_PlaySong:Far - Global F_PlayPattern:Far - Global F_PlayOrder:Far - Global F_Stop:Far - Global F_PlayMark:Far - Global F_DriverScreen:Far - Global F_ReinitSoundCard:Far - Global F_CalculateLength:Far - - Global F_SampleList:Far - Global F_SampleLibrary:Far - Global F_ReloadGravis:Far - - Global F_InstrumentList:Far - Global F_InstrumentLibrary:Far - -IF MEMORYDEBUG - - Global F_DrawDebug:Far - Global F_DebugUp:Far - Global F_DebugDown:Far - Global F_DebugPgUp:Far - Global F_DebugPgDn:Far - Global F_DebugStringInput:Far - Public F_PostDebug - -ENDIF - - Public F_ShowMIDIZxxInput - Public F_MIDI_Up - Public F_MIDI_Down - Public F_MIDI_PgUp, F_MIDI_PgDn - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Functions BYTE Public 'Code' USE16 - Assume CS:Functions, DS:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -ButtonVariables Label Word - DW 220h ; Standard SB Configs - DW 7 - DW 1 - DW 1 ; Clear patterns - DW 1 ; Clear samples - DW 1 ; Clear instruments - DW 1 ; Clear order list - -ButtonTypes Label Word - DW Offset ButtonType0 ; Press/Release buttons - DW Offset ButtonType1 ; Toggle Press/Release - DW Offset ButtonType2 ; One of Selection - -ButtonEffects Label Word - DW Offset ButtonEffect0 ; Return value - DW Offset ButtonEffect1 ; New object list - DW Offset ButtonEffect2 ; Call function - DW Offset ButtonEffect3 ; Set var at offset - DW Offset ButtonEffect4 ; Jump to function - DW Offset ButtonEffect5 ; Set var - DW Offset ButtonEffect6 ; Jump to function - -ButtonWidth Label Word - DW 0, 0, 0, 0, 0, 0, 0, 0 - DW 7, 7, 7, 7, 7, 7, 7, 7 - DW 0, 0, 0, 0, 0, 0, 0, 0 - DW 7, 7, 7, 7, 0, 0, 0, 0 - -MouseEventData DW 7 Dup (0), Functions - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -GetThumbValues Label Word - DW Offset GetPanning - DW Offset GetPEVariables - DW Offset GetSampleVariables - DW Offset GetMusicVariables - DW Offset GetPanning ; ChannelVol - DW Offset GetLoadSampleVariables - DW Offset GetInstVariables - DW Offset GetScreenVariables - DW Offset GetInstrumentVariables - DW Offset GetDriverVariables - -DrawThumbValues Label Word - DW Offset DrawPanning - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset DrawMIDIChannel - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset F_NothingNear - -PreThumbFuncs Label Word - DW Offset HiLightPanning - DW Offset GetPEVariables - DW Offset GetSampleVariables - DW Offset GetMusicVariables - DW Offset GetPanning ; Channelvol - DW Offset GetLoadSampleVariables - DW Offset GetInstVariables - DW Offset GetScreenVariables - DW Offset GetInstrumentVariables - DW Offset GetDriverVariables - -PostThumbFuncs Label Word - DW Offset SetPanning - DW Offset SetPEVariables - DW Offset SetSampleVariables - DW Offset SetMusicVariables - DW Offset SetPanning - DW Offset SetLoadSampleVariables - DW Offset SetInstVariables ; Inst - DW Offset SetScreenVariables - DW Offset SetInstrumentVariables ; Inst segment - DW Offset SetDriverVariables - -PostThumbCheck Label Word - DW Offset PanningKeys - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset FilterKeys - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset F_NothingNear - -ThumbStringEnter DB 0 - DB 4 Dup (0) - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -; LastStringData DD 0 - -StringInputOffset Label Word - DW Offset GetSIODiskSegment - DW Offset GetSampleString - DW Offset GetSIOInstSegment - DW Offset GetLoadSampleString - DW Offset GetMusicSegmentString ; Songsegment - DW Offset GetPatternSegmentString - DW Offset GetInstrumentString - DW Offset GetMIDIString - -PostStringInput Label Word - DW Offset F_NothingNear - DW Offset SetSampleString - DW Offset F_NothingNear - DW Offset F_NothingNear - DW Offset SetMusicSegmentString ; Songsegment - DW Offset F_NothingNear - DW Offset SetInstrumentString - DW Offset F_NothingNear - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -GetToggleStatus Label Word - DW Offset GetSampleToggle - DW Offset GetPatternSegmentToggle - DW Offset GetMusicSegmentToggle - DW Offset GetLoadSampleToggle - DW Offset GetInstrumentToggle - -ToggleBit Label Word - DW Offset SampleToggle - DW Offset PatternSegmentToggle - DW Offset MusicSegmentToggle - DW Offset LoadSampleToggle - DW Offset InstrumentToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -TripleNumberPos DW 0 - -Get3NumValues Label Word - DW Offset GetInstrument3Num - -Set3NumValues Label Word - DW Offset SetInstrument3Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -NumberPos DW 0 - -Get5NumValues Label Word - DW Offset GetSample5Num - DW Offset GetLoadSample5Num - Dw Offset GetInst5Num - -Set5NumValues Label Word - DW Offset SetSample5Num - DW Offset SetLoadSample5Num - DW Offset SetInst5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -HeaderMsg1 Label Byte -IF SHOWVERSION - DB 0FFh, 9, ' ', "Impulse Tracker v2.14 Copyright (C) 1995-2000 Jeffrey Lim", 13 -ELSE - DB 0FFh, 12, ' ', "Impulse Tracker Copyright (C) 1995-2000 Jeffrey Lim", 13 -ENDIF - DB 0FFh, 9, ' ', 0FEh, 21h, 139, 0FFh, 25, 134, 138, 0FFh, 11, ' ', 139, 0FFh, 28, 134, 138, 13 - DB 0FEh, 20h, "Song Name", 0FEh, 21h, 132, 0FEh, 5, 0FFh, 25, ' ', 0FEh, 23h, 131, 0FEh, 20h, 0 - -HeaderMsg2 DB " Instrument" - DB 0FEh, 21h, 132, 0FEh, 7, " :", 0FFh, 25, ' ', 0FEh, 23h, 131, 0 - -HeaderMsg3 DB 0FFh, 5, " Sample" - DB 0FEh, 21h, 132, 0FEh, 7, " :", 0FFh, 25, ' ', 0FEh, 23h, 131, 0 - -HeaderMsg4 DB "File Name", 0FEh, 21h, 132, 0FEh, 5, 0FFh, 18, ' ', 0FEh, 23h, 128, 0FFh, 6, 129, 136, 0FEh, 20h, "Speed/Tempo", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 1, "/", 0FEh, 5, " ", 0FEh, 23h, 128, 0FFh, 20, 129, 136, 13 - DB 0FEh, 20h, 0FFh, 4, " Order", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 1, "/", 0FEh, 5, " ", 0FEh, 23h, 128, 0FFh, 10, 129, 136, 0FEh, 20h, 0FFh, 12, " Octave", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 23h, 128, 0FFh, 5, 129, 136, 13 - DB 0FEh, 20h, " Pattern", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 1, "/", 0FEh, 5, " ", 0FEh, 23h, 131, 0FEh, 20h, " F1...Help F9.....Load ", 0FEh, 23h, 137, 129, 136, 0FEh, 20h, 0FFh, 11, " FreeMem ", 0FDh, "Dk ", 13 - DB 0FEh, 20h, 0FFh, 6, " Row", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 1, "/", 0FEh, 5, " ", 0FEh, 23h, 131, 0FEh, 20h, " ESC..Main Menu F5/F8..Play / Stop", 0FFh, 8, " FreeEMS ", 0FDh, "Dk", 13 - DB 0FEh, 23h, 0FFh, 9, ' ', 137, 0FFh, 7, 129, 136 - DB 0 - -ChannelMsg DB "Channel " -ChannelNumbers DB "xx", 0 - -HexNumbers DB "0123456789ABCDEF" -SurroundMessage DB "Surround", 0 -MutedMessage DB " Muted", 0 -ForwardMsg DB "Forwards", 0 -PingPongMsg DB "Ping Pong", 0 -ZxxString DB "Z", 0FDh, "X", 0 -NumberStorage DW 0, 0, 0, 0, 0, 0, 0, 0, 0 -PitchMessage DB "Pitch", 0 -FilterMessage DB "Filter", 0 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc F_Nothing Far - - Xor AX, AX - Ret - -EndP F_Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_InstrumentButtonHandler Far - - Test AX, AX - JZ F_InstrumentButtonHandler1 - - NetworkSendInstrument - -F_InstrumentButtonHandler1: - Push DS - Call I_GetInstrumentOffset ; Returns DS:BX - Push DS - Pop ES - Mov DI, BX - Pop DS - - Add DI, [SI+24] - Ret - -EndP F_InstrumentButtonHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_NothingNear - - Xor AX, AX - Ret - -EndP F_NothingNear - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_CallFarPreFunction Far - - Call DWord Ptr [SI+6] - - Ret - -EndP F_CallFarPreFunction - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_CallFarPostFunction Far - - Mov SI, [BX] - - Call DWord Ptr [SI+10] - - Ret - -EndP F_CallFarPostFunction - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_CallFarFunction Far - - Call DWord Ptr [SI+2] - - Ret - -EndP F_CallFarFunction - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawBoxObject Far - - LodsW - Xor AH, AH - LodsB - Push AX - LodsB - Push AX - LodsB - Push AX - LodsB - Push AX - LodsB - Push AX - Call S_DrawBox - Add SP, 10 - - Ret - -EndP F_DrawBoxObject - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawTextObject Far - - LodsW - - Mov BX, 3 - Xor CX, CX ; CX = string length count - Xor DX, DX - -F_DrawTextObject1: - Mov AL, [SI+BX] - Inc BX - Cmp AL, 0 - JE F_DrawTextObject2 - - Cmp AL, 0FDh - JNE F_DrawTextObject1 - Inc CX - Cmp Byte Ptr [SI+BX], 'L' - JNE F_DrawTextObject1 - Inc CX - Jmp F_DrawTextObject1 - -F_DrawTextObject2: - JCXZ F_DrawTextObject3 - Push Word Ptr [SI+BX] - Add BX, 2 - Inc DX - Dec CX - Jmp F_DrawTextObject2 - -F_DrawTextObject3: - Mov AL, 80 - Mul Byte Ptr [SI+1] - Add AL, [SI] - AdC AH, 0 - Add AX, AX - Mov DI, AX - Mov AH, [SI+2] - Add SI, 3 - Call S_DrawString - - Add DX, DX - Add SP, DX - - Ret - -EndP F_DrawTextObject - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PostExitObject Far - - Xor AX, AX - Test CH, 1 - JNZ F_PostExitObject1 - - Mov SI, [BX] - Mov DX, [SI+2] - Mov AX, 4 ; Exit from MainProc - -F_PostExitObject1: - Ret - -EndP F_PostExitObject - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SetDirectMode Far - - LodsW - LodsB - Call S_SetDirectMode - - Ret - -EndP F_SetDirectMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_CharacterDefinitions Far - - LodsW - LodsW - Mov BX, [SI] - Add SI, 2 - Call S_RedefineCharacters - - Ret - -EndP F_CharacterDefinitions - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseButtonPress Far ; Given CX, DX = coords - ; Given AX = Object number - ; DS:SI points to mouse obj - Mov CX, 11Ch - Xor DX, DX - Call AddMouseQueue - - Mov Word Ptr [SI+8], 1108h - Mov Word Ptr [SI+12], Offset MouseButtonRelease - - Mov AL, 2 - Call SetKeyboardLock - - Xor AX, AX - Ret - -EndP MouseButtonPress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseButtonRelease Far - - Mov CX, 01Ch - Xor DX, DX - Call AddMouseQueue - - Mov Word Ptr [SI+8], 102h - Mov Word Ptr [SI+12], Offset MouseButtonPress - - Xor AX, AX - Call SetKeyboardLock - - Ret - -EndP MouseButtonRelease - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawButtonObject Far ; AX = object number - ; SI = object - - Mov [CS:MouseEventData+10], AX ; Store object number - - Cmp Word Ptr [SI+16], 5 - JB F_DrawButtonObject1 - - Xor AX, AX - Call DWord Ptr [SI+18] - Mov AX, [SI+22] - ScasB -; Cmp [ES:DI], AL - - SetE [SI+33] - -F_DrawButtonObject1: - Mov BX, [SI+32] - And BX, 0FFh - Add SI, 28 - Add BX, BX - Mov DX, [CS:ButtonWidth+BX] - - Xor AH, AH - LodsB - LEA CX, [EAX*8+EDX] - Mov [CS:MouseEventData+0], CX - Push AX - - LodsB - LEA CX, [EAX*8+EDX] - Mov [CS:MouseEventData+2], CX - Push AX - - Sub DX, 7 - - LodsB - Mov CX, AX - ShL CX, 3 - Sub CX, DX - Mov [CS:MouseEventData+4], CX - Push AX - - LodsB - Mov CX, AX - ShL CX, 3 - Sub CX, DX - Mov [CS:MouseEventData+6], CX - Push AX - - LodsB ; Base Style - Mov BL, [SI] ; Up/Down - And BL, 1 - Mov [SI], BL - Add AL, BL - Push AX - Call S_DrawBox - Add SP, 10 - - Inc SI - - Mov AL, 80 - Mul Byte Ptr [SI-5] - Add AL, [SI-6] - AdC AH, 0 - Add AX, AX - Add AX, 162 - Mov DI, AX - Mov AH, 20h - - Call S_DrawString - - Push CS - Pop DS - Mov SI, Offset MouseEventData - Mov [MouseEventData+8], 102h ; Left mouse button pressed - Mov [MouseEventData+12], Offset MouseButtonPress - Call MouseAddEvent - - Ret - -EndP F_DrawButtonObject - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PreButtonObject Far - - Add SI, 28 - Xor AH, AH - LodsB - Push AX - LodsB - Push AX - LodsB - Push AX - LodsB - Push AX - LodsB ; Base Style - Mov BL, [SI] ; Up/Down - And BL, 1 - Add AL, BL - Push AX - Call S_DrawBox - Add SP, 10 - - Inc SI - - Mov AL, 80 - Mul Byte Ptr [SI-5] - Add AL, [SI-6] - AdC AH, 0 - Add AX, AX - Add AX, 162 - Mov DI, AX - Mov AH, 23h - - Call S_DrawString - - Ret - -EndP F_PreButtonObject - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PostButtonObject Far - - Mov SI, [BX] - Push SI - Push DI - Push BX - Push CX - Push DX - - Add SI, 28 - Mov AL, 80 - Mul Byte Ptr [SI+1] - Add AL, [SI] - AdC AH, 0 - Add AX, AX - Add AX, 162 - Mov DI, AX - Mov AL, 20h - Mov CL, [SI+2] - Sub CL, [SI] - Dec CL - Xor CH, CH - Call S_HiLight - - Pop DX - Pop CX - Pop BX - Pop DI - Pop SI - - Test CH, 80h - JNZ F_PostButtonNoMIDI - - Mov AL, [SI+33] - Cmp CL, 1Ch - JE F_PostButtonObject6 ; Enter - - Test AL, 2 - JNZ F_PostButtonObject7 - - Cmp CX, 1C8h ; Up pressed - JE F_PostButtonObject1 - - Cmp CX, 1D0h - JE F_PostButtonObject2 ; Down - - Cmp CX, 1CBh - JE F_PostButtonObject3 ; Left - - Cmp CX, 1CDh - JE F_PostButtonObject4 ; Right - - Cmp CX, 10Fh ; Tab - JE F_PostButtonObject4 - -; Test CL, CL -; JZ F_PostButtonNOMIDI - - Cmp DX, 0F00h ; Shift tab - JE F_PostButtonObject3 - -F_PostButtonNOMIDI: - Xor AX, AX - Ret - -F_PostButtonObject7: - Test AL, 4 - JZ F_PostButtonObject8 - Test CH, 1 - JZ F_PostButtonObject8 - - And AX, 1 - Xor AL, 1 - Mov [SI+33], AL - -F_PostButtonObject8: - Mov AX, 2 - Ret - -F_PostButtonObject4: - LodsW - -F_PostButtonObject3: - LodsW - -F_PostButtonObject2: - LodsW - -F_PostButtonObject1: - LodsW - - LodsW - Cmp AX, 0FFFFh - JNE F_PostButtonObject5 - - Xor AX, AX - Ret - -F_PostButtonObject5: - Mov [DI], AX - Mov AX, 2 - Ret - -F_PostButtonObject6: ; Enter pressed - Push BX - - Mov BX, [SI+10] - Add BX, BX - Jmp [CS:ButtonTypes+BX] - -EndP F_PostButtonObject - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonType0 Far - - Pop BX - - Test CH, 1 - JZ ButtonType0_1 - - Or Byte Ptr [SI+33], 7 - -ButtonType0_2: - Mov AX, 2 - Ret - -ButtonType0_1: - Test AL, 1 - JNZ ButtonType0_4 - - Test AL, 2 - JZ ButtonType0_2 - -ButtonType0_4: - Mov Byte Ptr [SI+33], 0 - - Jmp ButtonEffect - -EndP ButtonType0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonType1 Far - - Pop BX - - And CH, CH - JZ ButtonType1_2 - - Test AL, 2 - JNZ ButtonType1_1 - - Xor Byte Ptr [SI+33], 7 - -ButtonType1_1: - Mov AX, 2 - Ret - -ButtonType1_2: - And Byte Ptr [SI+33], 1 - - Jmp ButtonEffect - -EndP ButtonType1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonEffect Far - - Mov BX, [SI+16] - Add BX, BX - Jmp [CS:ButtonEffects+BX] - -EndP ButtonEffect - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonType2 Far - - Pop BX - - And CH, CH - JZ ButtonEffect - - Test AL, 2 - JZ ButtonType2_1 - - Mov AX, 2 - Ret - -ButtonType2_1: - Add SI, 12 - LodsW - Mov CX, AX - LodsW - Mov DX, AX - Add DX, DX - Add DI, 6 - Add DX, DI - Add CX, CX - Add DI, CX - - Xor AX, AX - -ButtonType2_2: - Mov SI, [DI] - Mov [SI+33], AL - - ScasW -; Add DI, 2 - Cmp DI, DX - JBE ButtonType2_2 - - Mov SI, [BX] - Mov Byte Ptr [SI+33], 1 - - Mov AX, 1 - Ret - -EndP ButtonType2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonEffect0 Far - - Mov DX, [SI+18] - Mov AX, 4 - Ret - -EndP ButtonEffect0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonEffect1 Far - - Mov CX, [SI+20] - Mov DX, [SI+18] - Mov AX, 5 - Mov SI, 1 - Ret - -EndP ButtonEffect1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonEffect2 Far - - Push DS - Push SI - - Mov AL, [SI+33] - Call DWord Ptr [SI+18] - - Pop SI - Pop DS - - Mov AX, 1 - - Ret - -EndP ButtonEffect2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonEffect3 Far - - Mov BX, [SI+18] ; Var number - Mov AX, [SI+20] - Add BX, BX - Mov [CS:ButtonVariables+BX], AX - - Mov AX, 1 - Ret - -EndP ButtonEffect3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonEffect4 Far - - Jmp DWord Ptr [SI+18] - -EndP ButtonEffect4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonEffect5 Far - - Mov AX, 1 - Call DWord Ptr [SI+18] - Mov AX, [SI+22] - - StosB -; Mov [ES:DI], AL - - Mov AX, 1 - Ret - -EndP ButtonEffect5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ButtonEffect6 Far - - Jmp DWord Ptr [SI+24] - -EndP ButtonEffect6 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetPanning ; DI = channel no. - - Push DS - - Call Music_GetSongSegment - Mov DS, AX - - Mov DL, [DI+64] - Xor DH, DH - - Pop DS - - Ret - -EndP GetPanning - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetPEVariables - - Push DS - - Mov DX, Pattern - Mov DS, DX -; Call PE_GetPatternSegment - Mov DL, [DI] - Xor DH, DH - - Pop DS - Ret - -EndP GetPEVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetScreenVariables - - Push DS - - Mov DX, Screen - Mov DS, DX - Mov DL, [DI] - Xor DH, DH - - Pop DS - Ret - -EndP GetScreenVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetScreenVariables - - Push DS - Push AX - - Mov AX, Screen - Mov DS, AX - Pop AX - - Mov [DI], AL - Call S_SetPalette2 - - Pop DS - Ret - -EndP SetScreenVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetPanning - - Push DS - - Push AX - Call Music_GetSongSegment - Mov DS, AX - Pop AX - Add DI, 64 - - Mov [DI], AL - -IF NETWORKENABLED - Mov CX, 1 - Mov DX, DI - Call Network_SendSongDataInformation -ENDIF - - Pop DS - Ret - -EndP SetPanning - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetPEVariables - - Push DS - - Push AX - Mov AX, Pattern - Mov DS, AX -; Call PE_GetPatternSegment - Pop AX - - Mov [DI], AL - - Pop DS - Ret - -EndP SetPEVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetInstVariables - - Push DS - Push AX - Push BX - - Call I_GetInstrumentOffset - - Mov DX, [BX+DI] - Cmp DI, 19h - JNE GetInstVariables1 - - And DX, 7Fh - -GetInstVariables1: - -; If DI = 3Ah or 3Bh, the XOR top bit. - Cmp DI, 3Ah - JB GetInstVariables4 - Cmp DI, 3Bh - JA GetInstVariables4 - - Xor DL, 80h - Jmp GetInstVariables3 - -GetInstVariables4: - - Cmp DI, 14h - JE GetInstVariables2 - Xor DH, DH - Cmp DI, 3Dh - JAE GetInstVariables3 - Cmp DI, 16h - JNE GetInstVariables2 - -GetInstVariables3: - MovSX DX, DL - -GetInstVariables2: - Pop BX - Pop AX - Pop DS - - Ret - -EndP GetInstVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSampleVariables - - Push DS - Push AX - Push BX - - Call I_GetSampleOffset - - Mov DL, [BX+DI] - Xor DH, DH - Cmp DI, 2Fh - JNE GetSampleVariables1 - - And DL, 7Fh - -GetSampleVariables1: - Pop BX - Pop AX - Pop DS - - Ret - -EndP GetSampleVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMusicVariables - - Push DS - - Call Music_GetSongSegment - Mov DS, AX - Xor DX, DX - Mov DL, [DI] - - Pop DS - - Ret - -EndP GetMusicVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetInstrumentVariables - - Push DS - - Mov AX, Inst - Mov DS, AX - Mov DX, [DI] - - Pop DS - - Ret - -EndP GetInstrumentVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetDriverVariables - - Call Music_GetDriverVariable - Mov DX, AX - Ret - -EndP GetDriverVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetDriverVariables - - Call Music_SetDriverVariable - Ret - -EndP SetDriverVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetLoadSampleVariables - - Push DS - Push SI - Push BX - - Call D_GetLoadSampleVars - Mov BX, SI - - Mov DL, [BX+DI] - Xor DH, DH - - Pop BX - Pop SI - Pop DS - - Ret - -EndP GetLoadSampleVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetInstVariables - - Push DS - Push BX - Push AX - - Call I_GetInstrumentOffset - - Pop AX - -IF FILTERENVELOPES - Cmp DI, 3Ah - JB SetInstVariables3 - Cmp DI, 3Bh - JA SetInstVariables3 - - Xor AL, 80h -ELSE - And Word Ptr [BX+3Ah], 7F7Fh -ENDIF - -SetInstVariables3: - Mov [BX+DI], AL - Cmp DI, 14h - JNE SetInstVariables1 - -SetInstVariables2: - Mov [BX+DI], AX - -SetInstVariables1: - NetworkSendInstrument - - Pop BX - Pop DS - - Ret - -EndP SetInstVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSampleVariables - - Push DS - Push BX - Push AX - - Call I_GetSampleOffset - - Pop AX - Cmp DI, 2Fh - JNE SetSampleVariables1 - - Or AL, 80h ; Turn on. - -SetSampleVariables1: - Mov [BX+DI], AL - - Pop BX - Pop DS - - NetworkSendSample - - Ret - -EndP SetSampleVariables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMusicVariables - - Push DS - Push AX - - Call Music_GetSongSegment - Mov DS, AX - - Pop AX - Mov [DI], AL - -IF NETWORKENABLED - Mov CX, 1 - Mov DX, DI - Call Network_SendSongDataInformation -ENDIF - - Cmp DI, 31h - JNE SetMusicVariables1 - - Call Music_InitMixTable - Jmp SetMusicVariablesEnd - -SetMusicVariables1: - Cmp DI, 30h - JNE SetMusicVariables3 - - Call Music_SetGlobalVolume - -SetMusicVariables3: - -SetMusicVariablesEnd: - Pop DS - - Ret - -EndP SetMusicVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetInstrumentVariables - - Push DS - Push AX - - Mov AX, Inst - Mov DS, AX - - Pop AX - Mov [DI], AX - - Pop DS - - Ret - -EndP SetInstrumentVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetLoadSampleVariables - - Push DS - Push SI - Push BX - - Call D_GetLoadSampleVars - Mov BX, SI - - Mov [BX+DI], AL - - Pop BX - Pop SI - Pop DS - - Ret - -EndP SetLoadSampleVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MousePressThumbBar Far - - Mov DX, CX - Mov CX, 8010h - Call AddMouseQueue - - Mov Word Ptr [SI+8], 1109h ; move or release - Mov Word Ptr [SI+12], Offset MouseHeldThumbBar - - Mov AL, 1 - Call SetKeyboardLock - - Xor AX, AX - - Ret - -EndP MousePressThumbBar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseHeldThumbBar Far - - Test BH, 8 - JNZ MouseHeldThumbBar2 - -MouseHeldThumbBar1: - Mov DX, CX - Mov CX, 8010h - Call AddMouseQueue - Ret - -MouseHeldThumbBar2: - Mov CX, 8001h ; Redraw screen - Call AddMouseQueue - -; Mov Word Ptr [SI+8], 102h -; Mov Word Ptr [SI+12], Offset MousePressThumbBar - - Xor AX, AX - Call SetKeyboardLock - - Ret - -EndP MouseHeldThumbBar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawThumbBar Far - - Mov [CS:MouseEventData+10], AX ; Store object number - - Call S_GetDestination - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:GetThumbValues+BX] ; DX returns thumbbar value - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX ; ES:DI points to area... - - Cmp DX, [SI+6] - JG F_DrawThumbBar2 - Cmp DX, [SI+4] - JL F_DrawThumbBar2 - - Mov CX, [SI+6] - Sub CX, [SI+4] - Add CX, 15 - ShR CX, 3 - Mov BX, CX - Mov AX, 300h -; Xor AX, AX - - Push DI - Push DI - - Rep StosW - - Pop DI - Push BX - Push DI - Mov BX, DX ; DX = value to show. - Sub BX, [SI+4] - Inc BX - Mov AX, BX - ShR BX, 3 - Add BX, BX - Add DI, BX - And AX, 7 - Add AX, 155 - Mov AH, 2 - StosW - - Cmp AL, 157 - JBE F_DrawThumbBar1 - Add AL, 5 - StosW - -F_DrawThumbBar1: - Pop DI - Pop BX - LEA DI, [EDI+EBX*2+2] - Mov CH, 21h - Mov AX, DX - Call PE_ConvAX2Num - - Pop DI - -F_DrawThumbBar2: - Mov BX, [SI+8] - Add BX, BX - Call [CS:DrawThumbValues+BX] ; DX returns pan value - - Mov CX, [SI+6] - Sub CX, [SI+4] - Add CX, 15 - ShR CX, 3 - - Xor AH, AH - Mov AL, [SI+2] - ShL AX, 3 - Mov [CS:MouseEventData+0], AX - ShL CX, 3 - Add AX, CX - Dec AX - Mov [CS:MouseEventData+4], AX - - Xor AH, AH - Mov AL, [SI+3] - ShL AX, 3 - Mov [CS:MouseEventData+2], AX - Add AX, 7 - Mov [CS:MouseEventData+6], AX - - Push CS - Pop DS - Assume DS:Functions - Mov SI, Offset MouseEventData - Mov Word Ptr [SI+8], 102h - Mov Word Ptr [SI+12], Offset MousePressThumbBar - Call MouseAddEvent - - Ret - -EndP F_DrawThumbBar - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawScalableThumbBar Far - - Mov [CS:MouseEventData+10], AX ; Store object number - - Call S_GetDestination - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:GetThumbValues+BX] ; DX returns thumbbar value - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX ; ES:DI points to area... - - Cmp DX, [SI+6] - JG F_DrawScalableThumbBar2 - Cmp DX, [SI+4] - JL F_DrawScalableThumbBar2 - - Push DI - Push DI - - Mov AX, 300h - Mov CX, [SI+24] ; Display length - Inc CX - Rep StosW - - ; Volume bar position = Value*Width / (MaxVal-MinVal) - - Pop DI - Push DI - - Push DX - - Mov AX, [SI+24] - ShL AX, 3 - Sub DX, [SI+4] - Mul DX - Mov CX, [SI+6] - Sub CX, [SI+4] - Div CX - - Inc AX - Mov BX, AX - ShR BX, 3 - Add BX, BX - Add DI, BX - And AX, 7 - Add AX, 155 - Mov AH, 2 - StosW - - Cmp AL, 157 - JBE F_DrawScalableThumbBar1 - Add AL, 5 - StosW - -F_DrawScalableThumbBar1: - Pop DX - - Pop DI - - Mov AX, [SI+24] - LEA DI, [EDI+EAX*2+4] - Mov CH, 21h - Mov AX, DX - Call PE_ConvAX2Num - - Pop DI - -F_DrawScalableThumbBar2: - Mov BX, [SI+8] - Add BX, BX - Call [CS:DrawThumbValues+BX] ; DX returns pan value - - Xor AH, AH - Mov AL, [SI+2] - Mov CX, AX - ShL AX, 3 - Mov [CS:MouseEventData+0], AX - Mov CX, [SI+24] - Inc CX - ShL CX, 3 - Add AX, CX - Dec AX - Mov [CS:MouseEventData+4], AX - - Xor AH, AH - Mov AL, [SI+3] - ShL AX, 3 - Mov [CS:MouseEventData+2], AX - Add AX, 7 - Mov [CS:MouseEventData+6], AX - - Push CS - Pop DS - Assume DS:Functions - Mov SI, Offset MouseEventData - Mov Word Ptr [SI+8], 102h - Mov Word Ptr [SI+12], Offset MousePressThumbBar - Call MouseAddEvent - - Ret - -EndP F_DrawScalableThumbBar - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc HiLightPanning - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Sub AX, 11 - Add AX, AX - Mov DI, AX - - Mov AL, 23h - Mov CX, 10 - Call S_HiLight - - Ret - -EndP HiLightPanning - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PreThumbBar Far - - Call S_GetDestination - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:GetThumbValues+BX] ; DX returns thumbbar value - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX ; ES:DI points to area... - - Cmp DX, [SI+6] - JG F_PreThumbBar2 - Cmp DX, [SI+4] - JL F_PreThumbBar2 - - Mov CX, [SI+6] - Sub CX, [SI+4] - Add CX, 15 - ShR CX, 3 - Mov BX, CX - Mov AX, 300h -; Xor AX, AX - - Push DI - Push DI - - Rep StosW - - Pop DI - Push BX - Push DI - Mov BX, DX ; DX = value to show. - Sub BX, [SI+4] - Inc BX - Mov AX, BX - ShR BX, 3 - Add BX, BX - Add DI, BX - And AX, 7 - Add AX, 155 - Mov AH, 3 - StosW - - Cmp AL, 157 - JBE F_PreThumbBar1 - Add AL, 5 - StosW - -F_PreThumbBar1: - Pop DI - Pop BX - LEA DI, [EDI+EBX*2+2] - Mov CH, 21h - Mov AX, DX - Call PE_ConvAX2Num - - Pop DI - -F_PreThumbBar2: - Mov BX, [SI+8] - Add BX, BX - Call [CS:DrawThumbValues+BX] ; DX returns pan value - -; Ret - - Call S_GetDestination - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:PreThumbFuncs+BX] ; DX returns pan value - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX ; ES:DI points to area... - -F_PreThumbBar3: - Mov CX, [SI+6] - Sub CX, [SI+4] - Add CX, 15 - ShR CX, 3 - Mov AL, 3 - Call S_HiLight - Ret - -EndP F_PreThumbBar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PreScalableThumbBar Far - - Call S_GetDestination - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:GetThumbValues+BX] ; DX returns thumbbar value - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX ; ES:DI points to area... - - Cmp DX, [SI+6] - JG F_PreScalableThumbBar2 - Cmp DX, [SI+4] - JL F_PreScalableThumbBar2 - - Push DI - Push DI - - Mov AX, 300h - Mov CX, [SI+24] ; Display length - Inc CX - Rep StosW - - ; Volume bar position = Value*Width / (MaxVal-MinVal) - - Pop DI - Push DI - - Push DX - - Mov AX, [SI+24] - ShL AX, 3 - Sub DX, [SI+4] - Mul DX - Mov CX, [SI+6] - Sub CX, [SI+4] - Div CX - - Inc AX - Mov BX, AX - ShR BX, 3 - Add BX, BX - Add DI, BX - And AX, 7 - Add AX, 155 - Mov AH, 2 - StosW - - Cmp AL, 157 - JBE F_PreScalableThumbBar1 - Add AL, 5 - StosW - -F_PreScalableThumbBar1: - Pop DX - - Pop DI - - Mov AX, [SI+24] - LEA DI, [EDI+EAX*2+4] - Mov CH, 21h - Mov AX, DX - Call PE_ConvAX2Num - - Pop DI - -F_PreScalableThumbBar2: - Mov BX, [SI+8] - Add BX, BX - Call [CS:DrawThumbValues+BX] ; DX returns pan value - -; Ret - - Call S_GetDestination - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:PreThumbFuncs+BX] ; DX returns pan value - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX ; ES:DI points to area... - -F_PreScalableThumbBar3: - Mov CX, [SI+24] - Inc CX - Mov AL, 3 - Call S_HiLight - Ret - -EndP F_PreScalableThumbBar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PostScalableThumbBar Far - - Cmp CX, 8010h - JE F_PostScalableThumbBarMouse1 - - Jmp F_PostThumbBar - -F_PostScalableThumbBarMouse1: ; DX = pixel... - Mov SI, [BX] - - Xor AX, AX - Mov AL, [SI+2] ; Left point - ShL AX, 3 ; Left pixel - Add AX, 4 - - Sub DX, AX - JNC F_PostScalableThumbBarMouse2 - - Xor DX, DX - -F_PostScalableThumbBarMouse2: ; Value = (Pixel / NumPixels)*(Max-Min)+Min - Mov CX, [SI+24] ; Length - ShL CX, 3 ; AX = MaxPixel - Cmp DX, CX - JB F_PostScalableThumbBarMouse3 - - Mov DX, CX - -F_PostScalableThumbBarMouse3: - Mov AX, [SI+6] - Sub AX, [SI+4] - Mul DX - Div CX - - ShR CX, 1 - Cmp CX, DX - AdC AX, 0 - - Add AX, [SI+4] - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:PostThumbFuncs+BX] - - Mov AX, 2 - Ret - -EndP F_PostScalableThumbBar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PostThumbBar Far - - Mov SI, [BX] - - Push ES - Push DI - - Call S_GetDestination - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Push BX - Push DX - Call [CS:GetThumbValues+BX] ; AX contains value. - Mov AX, DX - Pop DX - Pop BX - - Pop DI - Pop ES - - Push AX - Push BX - - Call [CS:PostThumbCheck+BX] - Test AX, AX - JNZ F_PostThumbBar23 - - Pop BX - Pop AX - - Cmp CX, 8010h - JE F_PostThumbBarMouse1 - - Cmp CX, 8001h - JE F_PostThumbBarMouseRedrawScreen - - Cmp CX, 1CBh - JE F_PostThumbBar2 - - Cmp CX, 1CDh - JE F_PostThumbBar4 - - Cmp CX, 1C7h - JE F_PostThumbBar10 - - Cmp CX, 1CFh - JE F_PostThumbBar11 - - Cmp CX, 1C8h - JE F_PostThumbBar5 - - Cmp CX, 1D0h - JE F_PostThumbBar6 - - Cmp CX, 10Fh - JE F_PostThumbBar7 - - Cmp CX, 1C9h - JE F_PostThumbBar21 - - Cmp CX, 1D1h - JE F_PostThumbBar22 - - Test CL, CL - JZ F_PostThumbBar20 - - Cmp DX, 0F00h - JE F_PostThumbBar8 - - Cmp DX, '0' - JB F_PostThumbBar50 - Cmp DX, '9' - JA F_PostThumbBar50 - - Jmp F_PostThumbBar30 - -F_PostThumbBar50: - Test CX, 600h - JNZ F_PostThumbBar17 - - Test CX, 1800h - JNZ F_PostThumbBar16 - -F_PostThumbBar20: - Xor AX, AX - Ret - -F_PostThumbBar23: - Pop BX - Pop AX - -F_PostThumbBarMouseRedrawScreen: - Mov AX, 1 - Ret - -F_PostThumbBar16: - Mov DI, CX - And DI, 1FFh - Cmp DI, 1CBh - JE F_PostThumbBar14 - - Cmp DI, 1CDh - JE F_PostThumbBar12 - - Jmp F_PostThumbBar20 - -F_PostThumbBar17: - Mov DI, CX - And DI, 1FFh - Cmp DI, 1CBh - JE F_PostThumbBar18 - - Cmp DI, 1CDh - JE F_PostThumbBar19 - - Jmp F_PostThumbBar20 - -F_PostThumbBar2: - Dec AX - Cmp AX, [SI+6] - JG F_PostThumbBar9 - Cmp Ax, [SI+4] - JL F_PostThumbBar9 - -F_PostThumbBar15: - Cmp AX, [SI+6] - JG F_PostThumbBarMin - Cmp AX, [SI+4] - JGE F_PostThumbBar3 - -F_PostThumbBarMin: - Mov AX, [SI+4] - -F_PostThumbBar3: - Mov DI, [SI+10] - Call [CS:PostThumbFuncs+BX] - -F_PostThumbBar9: - Mov AX, 1 - Ret - -F_PostThumbBar10: - Mov AX, [SI+4] - Jmp F_PostThumbBar3 - -F_PostThumbBar11: - Mov AX, [SI+6] - Jmp F_PostThumbBar3 - -F_PostThumbBar4: - Inc AX - Cmp AX, [SI+4] - JL F_PostThumbBar9 - - Cmp AX, [SI+6] - JG F_PostThumbBar9 - -F_PostThumbBar13: - Cmp AX, [SI+4] - JL F_PostThumbBarMax - Cmp AX, [SI+6] - JLE F_PostThumbBar3 - -F_PostThumbBarMax: - Mov AX, [SI+6] - Jmp F_PostThumbBar3 - -F_PostThumbBar12: - Add AX, 2 - Jmp F_PostThumbBar13 - -F_PostThumbBar14: - Sub AX, 2 - Jmp F_PostThumbBar15 - -F_PostThumbBar18: - Sub AX, 4 - Jmp F_PostThumbBar15 - -F_PostThumbBar19: - Add AX, 4 - Jmp F_PostThumbBar13 - -F_PostThumbBar22: - LodsW - -F_PostThumbBar21: - LodsW - -F_PostThumbBar8: - LodsW - -F_PostThumbBar7: - LodsW - -F_PostThumbBar6: - LodsW - -F_PostThumbBar5: - Add SI, 12 - LodsW - Cmp AX, 0FFFFh - JE F_PostThumbBar20 - - Mov [DI], AX - Jmp F_PostThumbBar9 - -F_PostThumbBarMouse1: ; DX = pixel... - Xor AX, AX - Mov AL, [SI+2] ; Left point - ShL AX, 3 ; Left pixel - Sub DX, AX - Sub DX, 4 - Mov AX, [SI+4] - Add AX, DX - - Cmp AX, [SI+4] - JG F_PostThumbBarMouse2 - - Mov AX, [SI+4] - Jmp F_PostThumbBarMouse3 - -F_PostThumbBarMouse2: - Cmp AX, [SI+6] - JL F_PostThumbBarMouse3 - - Mov AX, [SI+6] - -F_PostThumbBarMouse3: - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:PostThumbFuncs+BX] - - Mov AX, 2 - Ret - -F_PostThumbBar30: - Push DS - Push SI - - Call S_SaveScreen - - Mov DI, Offset ThumbStringEnter - Push CS - Pop ES - Mov AL, DL - StosB - - Xor AL, AL - Mov CX, 4 - Rep StosB - - Mov DI, Offset O1_ThumbStringList - Mov CX, 3 - Call M_Object1List - - Call S_RestoreScreen - - Pop SI - Pop DS - - And DX, DX - JZ F_PostThumbBar31 - - ; Now get value... - Xor CX, CX - Mov DI, Offset ThumbStringEnter - -F_PostThumbBar32: - Mov AL, [CS:DI] - And AL, AL - JZ F_PostThumbBar33 - - Inc DI - - Push AX - Mov AX, 10 - Mul CX - Mov CX, AX - Pop AX - - Cmp AL, '0' - JB F_PostThumbBar31 - Cmp AL, '9' - JA F_PostThumbBar31 - - Sub AL, '0' - Xor AH, AH - Add CX, AX - Jmp F_PostThumbBar32 - -F_PostThumbBar33: ; now save value. - Cmp DI, Offset ThumbStringEnter - JE F_PostThumbBar31 - - Mov AX, CX - - Cmp AX, [SI+4] - JL F_PostThumbBar31 - Cmp AX, [SI+6] - JG F_PostThumbBar31 - - Mov BX, [SI+8] - Mov DI, [SI+10] - Add BX, BX - Call [CS:PostThumbFuncs+BX] - -F_PostThumbBar31: - Mov AX, 1 - Ret - -EndP F_PostThumbBar - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawInfoLine Far - - Push ES - LodsW - Push SI - Xor DX, DX - -F_DrawInfoLine1: - LodsB - Inc DX - And AL, AL - JNZ F_DrawInfoLine1 - - Dec DX - Pop SI ; DX contains length of string - Call S_GetDestination - - Mov DI, (1+11*80)*2 - Mov BX, 78 - Mov CX, BX - Cmp Byte Ptr [SI], 0 - JE F_DrawInfoLine3 - - Sub CX, DX - ShR CX, 1 - Sub BX, CX - Sub BX, DX - Sub BX, 2 - - Mov AX, 219Ah - Rep StosW - - Mov AX, 2020h - StosW - -F_DrawInfoLine2: - LodsB - StosW - Dec DX - JNZ F_DrawInfoLine2 - - Mov AX, 2020h - StosW - - Mov CX, BX - -F_DrawInfoLine3: - Mov AX, 219Ah - Rep StosW - - Pop ES - Ret - -EndP F_DrawInfoLine - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ShowChannels Far - - Push DS - - Push CS - Pop DS - Assume DS:Functions - - Mov DI, (20+15*80)*2 - Mov CX, 32 - Mov AX, 3130h - Mov Word Ptr ChannelNumbers, AX - Mov AH, 20h - Call F_ShowChannel1 - - Mov DI, (54+15*80)*2 - Mov CX, 32 - Call F_ShowChannel1 - - Pop DS - Assume DS:Nothing - Ret - -EndP F_ShowChannels - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ShowChannel1 - - Assume DS:Functions - -F_ShowChannel1_1: - Mov SI, Offset ChannelMsg - Call S_DrawString - - Inc Byte Ptr [ChannelNumbers+1] - Cmp Byte Ptr [ChannelNumbers+1], '9' - JBE F_ShowChannel1_2 - - Inc Byte Ptr [ChannelNumbers] - Mov Byte Ptr [ChannelNumbers+1], '0' - -F_ShowChannel1_2: - Add DI, 140 - Loop F_ShowChannel1_1 - - Assume DS:Nothing - - Ret - -EndP F_ShowChannel1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_RedrawScreen Far - - Mov AX, 1 - Ret - -EndP F_RedrawScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Return0 Far ; ESC pressed on opening scrn - - Xor DX, DX - Mov AX, 4 - Ret - -EndP F_Return0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Return64 Far - - Mov DX, 64 - Mov AX, 4 - Ret - -EndP F_Return64 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Return192 Far - - Mov DX, 192 - Mov AX, 4 - Ret - -EndP F_Return192 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PanningKeys - - Push AX - Mov AX, DX - Cmp AX, 'a' - JB PanningKeys1 - - Cmp AX, 'z' - JA PanningKeys3 - - Sub AX, 32 - -PanningKeys1: - Cmp AL, 'L' - JE PanningKeysLeft - Cmp AL, 'R' - JE PanningKeysRight - Cmp AL, 'M' - JE PanningKeysMiddle - Cmp AL, 'S' - JE PanningKeysSurround - Cmp AL, ' ' - JE PanningKeysSpace - -PanningKeys3: - Pop AX - Xor AX, AX - Ret - -PanningKeysLeft: - Xor AX, AX - Jmp PanningKeys2 - -PanningKeysRight: - Mov AX, 64 - Jmp PanningKeys2 - -PanningKeysMiddle: - Mov AX, 32 - Jmp PanningKeys2 - -PanningKeysSurround: - Mov AX, 100 - -PanningKeys2: - Mov DI, [SI+10] - Call SetPanning - Pop AX - - Mov AX, 1 - Ret - -PanningKeysSpace: - Pop AX - Xor AL, 128 - Push AX - - Mov BX, [ES:DI] - Cmp BX, 74 - JAE PanningKeys2 - - Inc Word Ptr [ES:DI] - - Jmp PanningKeys2 - -EndP PanningKeys - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FilterKeys - - Push DI - Mov DI, [SI+10] - - Cmp DI, 3Ah - JB FilterKeys1 - Cmp DI, 3Bh - JA FilterKeys1 - - Cmp DX, ' ' - JNE FilterKeys1 - - Xor AL, 80h - Call SetInstVariables - - Mov AX, 1 - Jmp FilterKeysEnd - -FilterKeys1: - Xor AX, AX -FilterKeysEnd: - Pop DI - Ret - -EndP FilterKeys - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawPanning - - Push DS - Push SI - - Push CS - Pop DS - - Test DL, 128 - JZ DrawPanning2 - - Mov SI, Offset MutedMessage - Mov AH, 5 - Call S_DrawString - - Jmp DrawPanning1 - -DrawPanning2: - Cmp DX, 100 - JNE DrawPanning1 - - Mov SI, Offset SurroundMessage - Mov AH, 5 - Call S_DrawString - -DrawPanning1: - Pop SI - Pop DS - Ret - -EndP DrawPanning - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawMIDIChannel - - Mov AX, [SI+0Ah] - Cmp AX, 3Fh - JA DrawMIDIChannel2 - Cmp AX, 3Ah - JB DrawMIDIChannel2 - - Cmp AX, 3Ch - JNE DrawMIDIChannel4 - -DrawMIDIChannel1: - Cmp DL, 17 - JNE DrawMIDIChannel5 - - Add DI, 22 - Mov AX, 200h+'M' - StosW - Mov AL, 'a' - StosW - Mov AL, 'p' - StosW - StosW - Mov AL, 'e' - StosW - Mov AL, 'd' - StosW - -DrawMIDIChannel5: - Test DL, DL - JZ DrawMIDIChannel3 - Jmp DrawMIDIChannel2 - -DrawMIDIChannel4: - Test DX, DX - JNS DrawMIDIChannel2 - -DrawMIDIChannel3: - Mov AX, 200h+'O' - StosW - Mov AL, 'f' - StosW - StosW - Jmp DrawMIDIChannel2 - -DrawMIDIChannel2: - Ret - -EndP DrawMIDIChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Return1 Far - - Mov DX, 1 - Mov AX, 4 - Ret - -EndP F_Return1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSIOInstSegment - - Mov SI, Inst - Mov DS, SI - Mov SI, CX - - Ret - -EndP GetSIOInstSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSIODiskSegment - - Mov SI, Disk - Mov DS, SI - Mov SI, CX - - Ret - -EndP GetSIODiskSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetLoadSampleString ; Returns DS:SI - - Call D_GetLoadSampleVars ; Gets SI = currentsample offset - ; DS = DiskDataArea - Add SI, CX - - Ret - -EndP GetLoadSampleString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMusicSegmentString - - Call Music_GetSongSegment - Mov DS, AX - - Mov SI, CX - - Ret - -EndP GetMusicSegmentString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMusicSegmentString - -IF NETWORKENABLED - Mov CX, 26 - Mov DX, 4 - Call Network_SendSongDataInformation -ENDIF - Ret - -EndP SetMusicSegmentString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetPatternSegmentString - - Push CS - Pop DS - - Mov SI, CX - - Ret - -EndP GetPatternSegmentString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSampleString - - Call I_GetSampleOffset - Mov SI, BX - Add SI, CX - - Ret - -EndP GetSampleString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSampleString - - NetworkSendSample - - Ret - -EndP SetSampleString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetInstrumentString - - Call I_GetInstrumentOffset - Mov SI, BX - Add SI, CX - - Ret - -EndP GetInstrumentString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetInstrumentString - - NetworkSendInstrument - Ret - -EndP SetInstrumentString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -TopMIDIMacro DW 80h - -Proc GetMIDIString ; CX = select2 - - Push Music - Pop DS - Assume DS:Music - - Mov DS, MIDIDataArea - Assume DS:Nothing - - Mov SI, CX - Test CX, CX - JNS GetMIDIString1 - - Mov CX, CS:TopMIDIMacro - Sub SI, 8000h+80h*20h - ShL CX, 5 - Add SI, CX - -GetMIDIString1: - Ret - -EndP GetMIDIString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSelectString Far - - Mov CX, 8010h - Xor DX, DX - Call AddMouseQueue - - Xor AX, AX - - Ret - -EndP MouseSelectString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PostStringFunction DW 0 - -Proc F_GetStringInputOffset - - Mov BX, [SI+4] - Mov CX, [SI+6] - - Mov [CS:PostStringFunction], Offset F_NothingNear - - Cmp BX, 10h - JA F_GetStringInputOffset1 - - Add BX, BX - Push AX - - Mov AX, [CS:PostStringInput+BX] - Mov PostStringFunction, AX - - Pop AX - Call [CS:StringInputOffset+BX] ; DS:SI points to string - Ret - -F_GetStringInputOffset1: - Mov DS, BX - Mov SI, CX - Ret - -EndP F_GetStringInputOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawStringInput Far - - Mov [CS:MouseEventData+10], AX ; Store object number - - Push DS - Push SI - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX - Call S_GetDestination - - Call F_GetStringInputOffset - - Mov AH, 2h - -F_DrawStringInput1: - LodsB - Test AL, AL - JZ F_DrawStringInput2 - Cmp AL, 226 - JB F_DrawStringInput3 - - Mov AL, ' ' - -F_DrawStringInput3: - - StosW - Jmp F_DrawStringInput1 - -F_DrawStringInput2: - Pop SI - Pop DS - - Xor AH, AH - Mov AL, [SI+2] ; XValue - Mov CX, AX - ShL CX, 3 - Mov [CS:MouseEventData+0], CX - - Add AL, [SI+8] - Mov CX, AX - ShL CX, 3 - Dec CX - Mov [CS:MouseEventData+4], CX - - Mov AL, [SI+3] - ShL AX, 3 - Mov [CS:MouseEventData+2], AX - Add AX, 7 - Mov [CS:MouseEventData+6], AX - - Push CS - Pop DS - Assume DS:Functions - - Mov SI, Offset MouseEventData - Mov [MouseEventData+8], 102h - Mov [MouseEventData+12], Offset MouseSelectString - - Call MouseAddEvent - - Ret - -EndP F_DrawStringInput - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PreStringInput Far - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX - Call S_GetDestination - - Call F_GetStringInputOffset - -F_PreStringInput1: - LodsB - And AL, AL - JZ F_PreStringInput2 - ScasW -; Add DI, 2 - Jmp F_PreStringInput1 - -F_PreStringInput2: - Inc DI - Mov AL, 30h - StosB - Ret - -EndP F_PreStringInput - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PostStringInput Far - - Test CL, CL - JZ F_PostStringInput9 - - Mov SI, [BX] - - Cmp CX, 8010h - JE F_PostStringInput5 - - Cmp CX, 1C8h - JNE F_PostStringInput1 - - Mov AX, [SI+14] - Jmp F_PostStringInput4 - -F_PostStringInput1: - Cmp CX, 1D0h - JNE F_PostStringInput2 - - Mov AX, [SI+16] - Jmp F_PostStringInput4 - -F_PostStringInput2: - Cmp CX, 10Fh ; Tab - JNE F_PostStringInput3 - - Mov AX, [SI+18] - Jmp F_PostStringInput4 - -F_PostStringInput3: - Cmp DX, 0F00h - JNE F_PostStringInput6 - - Mov AX, [SI+20] - -F_PostStringInput4: - Cmp AX, 0FFFFh - JE F_PostStringInput12 - -; Mov Word Ptr CS:LastStringData, 0 -; Mov Word Ptr CS:LastStringData+2, 0 - - Mov [DI], AX - -F_PostStringInput5: - Mov AX, 1 - Ret - -F_PostStringInput6: - Cmp CX, 11Ch ; Enter - JNE F_PostStringInput7 - - Cmp Word Ptr [SI+10], 0 - JNE F_PostStringInput13 - - Cmp Word Ptr [SI+12], 0 - JE F_PostStringInput12 - -F_PostStringInput13: - Jmp DWord Ptr [SI+10] - -F_PostStringInput7: - Cmp CX, 10Eh ; Backspace - JNE F_PostStringInput8 - - Call F_GetStringInputOffset - - Cmp Byte Ptr [DS:SI], 0 - JE F_PostStringBackSpace2 - -F_PostStringBackSpace1: - LodsB - And AL, AL - JNZ F_PostStringBackSpace1 - - Mov [SI-2], AL - -F_PostStringBackSpace2: - Jmp F_PostStringInput11 - -F_PostStringInput8: - Cmp DX, 127 ; Ctrl-Backspace - JNE F_PostStringInput12 - - Mov DX, [SI+8] - Call F_GetStringInputOffset - - Mov CX, DX - Mov AX, DS - Mov ES, AX - Mov DI, SI - Xor AL, AL - Rep StosB - - Jmp F_PostStringInput11 - -F_PostStringInput12: - Test CL, CL - JZ F_PostStringInput9 - Cmp DL, 32 - JB F_PostStringInput9 - - Mov DI, [SI+8] - Call F_GetStringInputOffset - - Xor BX, BX - -F_PostStringInput10: - LodsB - Inc BX - And AL, AL - JNZ F_PostStringInput10 - - Dec SI - Cmp BX, DI - JAE F_PostStringInput11 - - Mov AL, DL - Xor AH, AH - Mov [DS:SI], AX - -F_PostStringInput11: - Call [CS:PostStringFunction] - - Mov AX, 1 - Ret - -F_PostStringInput9: - Xor AX, AX - Ret - -EndP F_PostStringInput - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_GotoEmptyList Far - - Mov AX, 5 - Mov SI, 1 - Mov DI, AX - Mov CX, Object1 - Mov DX, Offset O1_EmptyList - - Ret - -EndP F_GotoEmptyList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSampleToggle - - Push DS - - Call I_GetSampleOffset - Xor CL, CL - - Mov DH, [BX+DI] - Test DH, DL - JZ GetSampleToggle1 - - Inc CX - - Cmp DI, 2Fh - JE GetSampleToggle1 - - ShL DL, 1 - ShL DL, 1 - - Pop DS - Push DS - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - LEA DI, [EAX+6] ; DI points to screen part. - Push DS - Push SI - - Mov SI, Offset ForwardMsg - Test DH, DL - JZ GetSampleToggle2 - - Mov SI, Offset PingPongMsg - -GetSampleToggle2: - Push CS - Pop DS - Mov AH, 2 - Call S_DrawString - - Pop SI - Pop DS - -GetSampleToggle1: - Pop DS - Ret - -EndP GetSampleToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetInstrumentToggle - - Push DS - - Call I_GetInstrumentOffset - Xor CL, CL - - Mov DH, [BX+DI] - Test DH, DL - JZ GetInstrumentToggle1 - - Inc CX - - Cmp DI, 1D4h - JNE GetInstrumentToggle1 - Cmp DL, 1 - JNE GetInstrumentToggle1 - - Push DS - Push SI - - Push CS - Pop DS - - Mov DI, (28*80+57)*2 - Mov AH, 2 - Mov SI, Offset PitchMessage - Test DH, DH - JNS GetInstrumentToggle3 - - Mov SI, Offset FilterMessage - -GetInstrumentToggle3: - Call S_DrawString - - Pop SI - Pop DS - -GetInstrumentToggle1: - Cmp DI, 19h - JNE GetInstrumentToggle2 - - Xor CL, 1 - -GetInstrumentToggle2: - Pop DS - Ret - -EndP GetInstrumentToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetLoadSampleToggle - - Push DS - Push SI - Call D_GetLoadSampleVars ; Gets SI = currentsample offset - ; DS = DiskDataArea - - Mov BX, SI - Pop SI - - Xor CL, CL - - Mov DH, [BX+DI] - Test DH, DL - JZ GetLoadSampleToggle1 - - Inc CX - - ShL DL, 1 - ShL DL, 1 - - Pop DS - Push DS - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - LEA DI, [EAX+6] ; DI points to screen part - Push DS - Push SI - - Mov SI, Offset ForwardMsg - Test DH, DL - JZ GetLoadSampleToggle2 - - Mov SI, Offset PingPongMsg - -GetLoadSampleToggle2: - Push CS - Pop DS - Mov AH, 2 - Call S_DrawString - - Pop SI - Pop DS - -GetLoadSampleToggle1: - Pop DS - Ret - -EndP GetLoadSampleToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetPatternSegmentToggle - - Push DS - - Mov AX, Pattern - Mov DS, AX - - Xor CL, CL - Test [DS:DI], DL - JZ GetPatternSegmentToggle1 - - Inc CX - -GetPatternSegmentToggle1: - Pop DS - Ret - -EndP GetPatternSegmentToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetMusicSegmentToggle - - Push DS - - Call Music_GetSongSegment - Mov DS, AX - - Xor CL, CL - Test [DS:DI], DL - JZ GetMusicSegmentToggle1 - - Inc CX - -GetMusicSegmentToggle1: - Pop DS - Ret - -EndP GetMusicSegmentToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SampleToggle - - Push DS - - Call I_GetSampleOffset - - Cmp DI, 2Fh - JNE SampleToggle6 - - Xor [BX+DI], DL - - Jmp SampleToggleEnd - -SampleToggle6: - Mov DH, DL - ShL DH, 1 - ShL DH, 1 - Test [BX+DI], DL - JZ SampleToggle3 - - Test [BX+DI], DH - JNZ SampleToggle3 - - Xor [BX+DI], DH - - Call Music_RegetLoopInformation - Jmp SampleToggleEnd - -SampleToggle3: - Xor [BX+DI], DL - Test [BX+DI], DL - JZ SampleToggle1 - ; Something was just toggled On. - Not DH - And [BX+DI], DH - - Cmp DL, 10h - JE SampleToggle2 - Cmp DL, 20h - JNE SampleToggle1 ; Safety Check. - ; Sustain Loop. - Mov EAX, [BX+40h] ; SusLBeg - Cmp EAX, [BX+30h] - JB SampleToggle4 - - Xor EAX, EAX - Mov [BX+40h], EAX - -SampleToggle4: - Cmp EAX, [BX+44h] - JB SampleToggle1 - - Mov EAX, [BX+30h] - Mov [BX+44h], EAX - Jmp SampleToggle1 - -SampleToggle2: ; Normal Loop - Mov EAX, [BX+34h] - Cmp EAX, [BX+30h] - JB SampleToggle5 - - Xor EAX, EAX - Mov [BX+34h], EAX - -SampleToggle5: - Cmp EAX, [BX+38h] - JB SampleToggle1 - - Mov EAX, [BX+30h] - Mov [BX+38h], EAX - -SampleToggle1: - Call Music_RegetLoopInformation - Call I_DrawWaveForm - -SampleToggleEnd: - NetworkSendSample - - Pop DS - Ret - -EndP SampleToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InstrumentToggle - - Push DS - - Call I_GetInstrumentOffset - -IF FILTERENVELOPES - Cmp DI, 1D4h - JNE InstrumentToggle2 - Cmp DL, 1 - JNE InstrumentToggle2 - - Xor Byte Ptr [BX+DI], 80h - JNS InstrumentToggle3 - - Test [BX+DI], DL - JZ InstrumentToggle2 - - And Byte Ptr [BX+DI], 7Fh - -InstrumentToggle2: -ELSE - And Byte Ptr [BX+1D4h], 7Fh -ENDIF - Xor [BX+DI], DL - -InstrumentToggle3: - Call I_MapEnvelope - - NetworkSendInstrument - - Pop DS - Ret - -EndP InstrumentToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc LoadSampleToggle - - Push DS - Push SI - Call D_GetLoadSampleVars ; Gets SI = currentsample offset - ; DS = DiskDataArea - - Mov BX, SI - Pop SI - - Mov DH, DL - ShL DH, 1 - ShL DH, 1 - Test [BX+DI], DL - JZ LoadSampleToggle3 - - Test [BX+DI], DH - JNZ LoadSampleToggle3 - - Xor [BX+DI], DH - Pop DS - Ret - -LoadSampleToggle3: - Xor [BX+DI], DL - Test [BX+DI], DL - JZ LoadSampleToggle1 - ; Something was just toggled On. - Not DH - And [BX+DI], DH - - Cmp DL, 10h - JE LoadSampleToggle2 - Cmp DL, 20h - JNE LoadSampleToggle1 ; Safety Check. - ; Sustain Loop. - Mov EAX, [BX+40h] ; SusLBeg - Cmp EAX, [BX+30h] - JB LoadSampleToggle4 - - Xor EAX, EAX - Mov [BX+40h], EAX - -LoadSampleToggle4: - Cmp EAX, [BX+44h] - JB LoadSampleToggle1 - - Mov EAX, [BX+30h] - Mov [BX+44h], EAX - Jmp LoadSampleToggle1 - -LoadSampleToggle2: ; Normal Loop - Mov EAX, [BX+34h] - Cmp EAX, [BX+30h] - JB LoadSampleToggle5 - - Xor EAX, EAX - Mov [BX+34h], EAX - -LoadSampleToggle5: - Cmp EAX, [BX+38h] - JB LoadSampleToggle1 - - Mov EAX, [BX+30h] - Mov [BX+38h], EAX - -LoadSampleToggle1: - Call D_DrawWaveForm - - Pop DS - Ret - -EndP LoadSampleToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PatternSegmentToggle - - Push DS - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Xor [DS:DI], DL - - Cmp DI, Offset MultiChannelInfo - JB PatternSegmentToggle1 - Cmp DI, Offset MultiChannelInfo+64 - JAE PatternSegmentToggle1 - - Test CX, 8000h - JNZ PatternSegmentToggle1 - - Inc Word Ptr [ES:BP] - -PatternSegmentToggle1: - Pop DS - Ret - -EndP PatternSegmentToggle - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MusicSegmentToggle - - Push DS - Call Music_GetSongSegment - Mov DS, AX - - Xor [DS:DI], DL - -IF NETWORKENABLED - Mov CX, 1 - Mov DX, DI - Call Network_SendSongDataInformation -ENDIF - - Pop DS - Ret - -EndP MusicSegmentToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseToggle Far - - Mov CX, 8010h - Mov DX, ' ' - Call AddMouseQueue - - Xor AX, AX - - Ret - -EndP MouseToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawToggle Far - - Mov [CS:MouseEventData+10], AX ; Store object number - - Call S_GetDestination - Mov BX, [SI+4] ; Segment no. - Mov DI, [SI+6] - Mov DL, [SI+8] - Add BX, BX - Call [CS:GetToggleStatus+BX] ; Returns CL with 0=off, 1=on - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX ; DI points to screen part. - - Mov AX, 200h+'O' - StosW - And CL, CL - JZ F_DrawToggle1 - - Mov AL, 'n' - StosW - Jmp F_DrawToggle2 - -F_DrawToggle1: - Mov AL, 'f' - StosW - StosW - -F_DrawToggle2: - Xor AH, AH - Mov AL, [SI+2] ; XValue - ShL AX, 3 - Mov [CS:MouseEventData+0], AX - Add AX, 23 - Mov [CS:MouseEventData+4], AX - - Xor AH, AH - Mov AL, [SI+3] - ShL AX, 3 - Mov [CS:MouseEventData+2], AX - Add AX, 7 - Mov [CS:MouseEventData+6], AX - - Push CS - Pop DS - Assume DS:Functions - - Mov SI, Offset MouseEventData - Mov [MouseEventData+8], 102h - Mov [MouseEventData+12], Offset MouseToggle - - Call MouseAddEvent - - Ret - -EndP F_DrawToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PreToggle Far - - Call S_GetDestination - Mov BX, [SI+4] ; Segment no. - Mov DI, [SI+6] - Mov DL, [SI+8] - Add BX, BX - Call [CS:GetToggleStatus+BX] ; Returns CL with 0=off, 1=on - - Xor CH, CH - Neg CL - Add CL, 3 ; CL = number to hilight - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX - - Mov AL, 30h - Call S_HiLight - - Ret - -EndP F_PreToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PostToggle Far - - Mov SI, [BX] - - Test CL, CL - JZ F_PostToggle7 - - Cmp DX, ' ' - JNE F_PostToggle1 - - Mov BP, DI - - Mov BX, [SI+4] ; Segment no. - Mov DI, [SI+6] - Mov DL, [SI+8] - Add BX, BX - Call [CS:ToggleBit+BX] - - Mov AX, 1 - Ret - -F_PostToggle1: - Cmp CX, 1C8h - JE F_PostToggle5 - Cmp CX, 1D0h - JE F_PostToggle4 - Cmp CX, 10Fh ; Tab - JE F_PostToggle3 - Cmp CX, 1CDh - JE F_PostToggle3 - Cmp DX, 0F00h - JE F_PostToggle2 - Cmp CX, 1CBh - JE F_PostToggle2 - -F_PostToggle7: - Xor AX, AX - Ret - -F_PostToggle2: - LodsW -F_PostToggle3: - LodsW -F_PostToggle4: - LodsW -F_PostToggle5: - Add SI, 9 - LodsW - Cmp AX, 0FFFFh - JE F_PostToggle7 - - Mov [DI], AX - -F_PostToggle6: - Mov AX, 1 - Ret - -EndP F_PostToggle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetInstrument3Num - - Push DS - - Call I_GetInstrumentOffset - - Mov AL, [BX+DI] - Xor AH, AH - - Pop DS - Ret - -EndP GetInstrument3Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetInstrument3Num ; AX = value. - - Push DS - Push SI - Push AX - - Mov AX, Inst - Mov DS, AX - Assume DS:Inst - - Mov CX, MaxNode - Dec CL - Assume DS:Nothing - - - Call I_GetInstrumentOffset - - Pop AX - Cmp AL, CL - JB SetInstrument3Num1 - - Mov AL, CL - -SetInstrument3Num1: - Mov [BX+DI], AL - - Mov SI, 132h - Call Near Ptr SetInstrument3Num2 - - Mov SI, 134h - Call Near Ptr SetInstrument3Num2 - - Mov SI, 184h - Call Near Ptr SetInstrument3Num2 - - Mov SI, 186h - Call Near Ptr SetInstrument3Num2 - - Mov SI, 1D6h - Call Near Ptr SetInstrument3Num2 - - Mov SI, 1D8h - Call Near Ptr SetInstrument3Num2 - - Call I_MapEnvelope - - Pop SI - Pop DS - - Ret - -SetInstrument3Num2: - Mov AL, [BX+SI] - Cmp AL, [BX+SI+1] - JBE SetInstrument3Num3 - - Mov [BX+SI+1], AL - -SetInstrument3Num3: - RetN - -EndP SetInstrument3Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSample5Num - - Push DS - - Call I_GetSampleOffset - - Mov EAX, [BX+DI] - - Pop DS - Ret - -EndP GetSample5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetLoadSample5Num - - Push DS - Push SI - Call D_GetLoadSampleVars ; Gets SI = currentsample offset - ; DS = DiskDataArea - - Mov BX, SI - Mov EAX, [BX+DI] - - Pop SI - Pop DS - - Ret - -EndP GetLoadSample5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetInst5Num - - Push DS - Mov AX, Inst - - Mov DS, AX - Mov EAX, [DI] - - Pop DS - Ret - -EndP GetInst5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetSample5Num ; AX = value. - - Push DS - Push AX - - Call I_GetSampleOffset - - Pop AX - Mov [BX+DI], EAX - - Pop DS - - NetworkSendSample - - Ret - -EndP SetSample5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetLoadSample5Num ; AX = value. - - Push DS - Push SI - - Call D_GetLoadSampleVars ; Gets SI = currentsample offset - Mov BX, SI - - Mov [BX+DI], EAX - - Pop SI - Pop DS - Ret - -EndP SetLoadSample5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetInst5Num - - Push DS - - Mov BX, Inst - Mov DS, BX - Mov [DI], EAX - - Pop DS - - Ret - -EndP SetInst5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseNumberDecrement Far - - Mov CX, 8010h - Mov DX, '-' - Call AddMouseQueue - - Xor AX, AX - - Ret - -EndP MouseNumberDecrement - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseNumberIncrement Far - - Mov CX, 8010h - Mov DX, '+' - Call AddMouseQueue - - Xor AX, AX - - Ret - -EndP MouseNumberIncrement - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Draw3Num Far - - Mov [CS:MouseEventData+10], AX ; Store object number - - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Call [CS:Get3NumValues+BX] ; AX = value. - - Push AX - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX - Call S_GetDestination - - Pop AX - Xor DX, DX - Mov CH, 2 - Call PE_ConvAX2Num - - Xor AX, AX - Mov AL, [SI+2] ; X value - ShL AX, 3 - Mov [CS:MouseEventData+0], AX - Add AX, 3*8-1 - Mov [CS:MouseEventData+4], AX - Xor AX, AX - Mov AL, [SI+3] - ShL AX, 3 - Mov [CS:MouseEventData+2], AX - Add AX, 7 - Mov [CS:MouseEventData+6], AX - - Push CS - Pop DS - - Mov SI, Offset MouseEventData - Mov Word Ptr [SI+8], 102h - Mov Word Ptr [SI+12], Offset MouseNumberDecrement - Call MouseAddEvent - Mov Word Ptr [SI+8], 110h - Mov Word Ptr [SI+12], Offset MouseNumberIncrement - Call MouseAddEvent - - Ret - -EndP F_Draw3Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Pre3Num Far - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Mov DI, AX - Add DI, CS:TripleNumberPos - Add DI, DI - - Mov CX, 1 - Mov AL, 30h - Call S_HiLight - - Ret - -EndP F_Pre3Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Post3Num Far - - Mov SI, [BX] - Test CL, CL - JZ F_Post3Num7 - - Cmp DX, 8 - JE F_Post3Num16 - Cmp CX, 1CBh ; Left - JNE F_Post3Num1 - -F_Post3Num16: - Mov AX, CS:TripleNumberPos - Dec AX - JS F_Post3Num2 - -F_Post3Num5: - Mov CS:TripleNumberPos, AX - -F_Post3Num2: - Mov AX, 1 - Ret - -F_Post3Num1: - Cmp CX, 1CDh ; Right - JNE F_Post3Num3 - -F_Post3Num4: - Mov AX, CS:TripleNumberPos - Inc AX - Cmp AX, 2 - JA F_Post3Num2 - Jmp F_Post3Num5 - -F_Post3Num3: - Cmp CX, 1C8h ; Up - JE F_Post3Num14 - Cmp CX, 1D0h ; Down - JE F_Post3Num13 - Cmp CX, 10Fh - JE F_Post3Num12 - Cmp DX, 0F00h - JNE F_Post3Num6 - - LodsW -F_Post3Num12: - LodsW -F_Post3Num13: - LodsW -F_Post3Num14: - Add SI, 12 - LodsW - Cmp AX, 0FFFFh - JE F_Post3Num7 - - Mov [DI], AX - -F_Post3Num15: - Mov AX, 1 - Ret - -F_Post3Num18: - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Push BX - Call [CS:Get3NumValues+BX] ; AX = value. - Pop BX - Add AX, 1 - JC F_Post3Num15 - Call [CS:Set3NumValues+BX] ; AX = value. - Call Near Ptr F_Post3Num20 - Jmp F_Post3Num15 - -F_Post3Num19: - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Push BX - Call [CS:Get3NumValues+BX] ; AX = value. - Pop BX - Sub AX, 1 - JC F_Post3Num15 - Call [CS:Set3NumValues+BX] ; AX = value. - Call Near Ptr F_Post3Num20 - Jmp F_Post3Num15 - -F_Post3Num6: - Cmp DX, '+' - JE F_Post3Num18 - Cmp DX, '-' - JE F_Post3Num19 - - Cmp DX, '0' - JL F_Post3Num7 - Cmp DX, '9' - JLE F_Post3Num8 - -F_Post3Num7: - Xor AX, AX - Ret - -F_Post3Num8: ; OK... a number was inputted. - Push DX - - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Call [CS:Get3NumValues+BX] ; AX = value. - - Mov CX, 3 - Mov BX, 10 - Mov DI, Offset NumberStorage+6 - -F_Post3Num9: - Xor DX, DX - Div BX - Sub DI, 2 - Mov [CS:DI], DX - Loop F_Post3Num9 - - Mov BX, CS:TripleNumberPos - Add BX, BX - - Pop DX - Sub DX, '0' - Mov [CS:DI+BX], DX - - Xor AX, AX - Mov BX, 10 - Mov CX, 3 - Xor DX, DX - -F_Post3Num10: - Mul BX - Add AX, [CS:DI] - AdC DX, 0 - ScasW -; Add DI, 2 - Loop F_Post3Num10 - - And DX, DX - JZ F_Post3Num11 - - Mov AX, 0FFFFh - -F_Post3Num11: - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Call [CS:Set3NumValues+BX] ; AX = value. - Call Near Ptr F_Post3Num20 - Jmp F_Post3Num4 - -F_Post3Num20: - Cmp Word Ptr [SI+8], 0 - JNZ F_Post3Num17 - - Cmp Word Ptr [SI+10], 0 - JZ F_Post3Num21 - -F_Post3Num17: - Call DWord Ptr [SI+8] - -F_Post3Num21: - RetN - - -EndP F_Post3Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ConvEAX2Num Far - - Push EAX ; CH = colour - Push EBX ; DX:AX = number - Push CX - Push EDX - - Mov EBX, 10 - Mov CL, 7 - -F_ConvEAX2Num1: - Xor EDX, EDX - Div EBX - Push DX - Dec CL - JNZ F_ConvEAX2Num1 - - Mov CL, 7 - -F_ConvEAX2Num2: - Pop AX - Add AL, '0' - Mov AH, CH - StosW - - Dec CL - JNZ F_ConvEAX2Num2 - - Pop EDX - Pop CX - Pop EBX - Pop EAX - - Ret - -EndP F_ConvEAX2Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Draw5Num Far - - Mov [CS:MouseEventData+10], AX - - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Call [CS:Get5NumValues+BX] ; AX = value. - - Push AX - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX - Call S_GetDestination - - Pop AX - Xor DX, DX - Mov CH, 2 - Call F_ConvEAX2Num - - Xor AX, AX - Mov AL, [SI+2] ; X value - ShL AX, 3 - Mov [CS:MouseEventData+0], AX - Add AX, 7*8-1 - Mov [CS:MouseEventData+4], AX - Xor AX, AX - Mov AL, [SI+3] - ShL AX, 3 - Mov [CS:MouseEventData+2], AX - Add AX, 7 - Mov [CS:MouseEventData+6], AX - - Push CS - Pop DS - - Mov SI, Offset MouseEventData - Mov Word Ptr [SI+8], 102h - Mov Word Ptr [SI+12], Offset MouseNumberDecrement - Call MouseAddEvent - Mov Word Ptr [SI+8], 110h - Mov Word Ptr [SI+12], Offset MouseNumberIncrement - Call MouseAddEvent - - Ret - -EndP F_Draw5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Pre5Num Far - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Mov DI, AX - Add DI, CS:NumberPos - Add DI, DI - - Mov CX, 1 - Mov AL, 30h - Call S_HiLight - - Ret - -EndP F_Pre5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Post5Num Far - - Mov SI, [BX] - Test CL, CL - JZ F_Post5Num7 - - Cmp DX, 8 - JE F_Post5Num16 - Cmp CX, 1CBh ; Left - JNE F_Post5Num1 - -F_Post5Num16: - Mov AX, CS:NumberPos - Dec AX - JS F_Post5Num2 - -F_Post5Num5: - Mov CS:NumberPos, AX - -F_Post5Num2: - Mov AX, 1 - Ret - -F_Post5Num1: - Cmp CX, 1CDh ; Right - JNE F_Post5Num3 - -F_Post5Num4: - Mov AX, CS:NumberPos - Inc AX - Cmp AX, 6 - JA F_Post5Num2 - Jmp F_Post5Num5 - -F_Post5Num3: - Cmp CX, 1C8h ; Up - JE F_Post5Num14 - Cmp CX, 1D0h ; Down - JE F_Post5Num13 - Cmp CX, 10Fh - JE F_Post5Num12 - Cmp DX, 0F00h - JNE F_Post5Num6 - - LodsW -F_Post5Num12: - LodsW -F_Post5Num13: - LodsW -F_Post5Num14: - Add SI, 12 - LodsW - Cmp AX, 0FFFFh - JE F_Post5Num7 - - Mov [DI], AX - -F_Post5Num15: - Mov AX, 1 - Ret - -F_Post5Num18: - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Push BX - Call [CS:Get5NumValues+BX] ; AX = value. - Pop BX - Inc EAX - Call [CS:Set5NumValues+BX] ; AX = value. - Call Near Ptr F_Post5Num20 - Jmp F_Post5Num15 - -F_Post5Num19: - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Push BX - Call [CS:Get5NumValues+BX] ; AX = value. - Pop BX - Sub EAX, 1 - JC F_Post5Num15 - Call [CS:Set5NumValues+BX] ; AX = value. - Call Near Ptr F_Post5Num20 - Jmp F_Post5Num15 - -F_Post5Num6: - Cmp DX, '+' - JE F_Post5Num18 - Cmp DX, '-' - JE F_Post5Num19 - - Cmp DX, '0' - JL F_Post5Num7 - Cmp DX, '9' - JLE F_Post5Num8 - -F_Post5Num7: - Xor AX, AX - Ret - -F_Post5Num8: ; OK... a number was inputted. - Push DX - - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Call [CS:Get5NumValues+BX] ; EAX = value. - - Mov CX, 7 - Mov EBX, 10 - Mov DI, Offset NumberStorage+14 - -F_Post5Num9: - Xor EDX, EDX - Div EBX - Sub DI, 2 - Mov [CS:DI], DX - Loop F_Post5Num9 - - Mov BX, CS:NumberPos - Add BX, BX - - Pop DX - Sub DX, '0' - Mov [CS:DI+BX], DX - - Xor EAX, EAX - Mov BX, 10 - Mov CX, 7 - -F_Post5Num10: - IMul EAX, 10 - MovZX EBX, Word Ptr [CS:DI] - Add EAX, EBX - -; Add DI, 2 - ScasW - Loop F_Post5Num10 - -F_Post5Num11: - Mov BX, [SI+4] - Add BX, BX - Mov DI, [SI+6] - - Call [CS:Set5NumValues+BX] ; AX = value. - Call Near Ptr F_Post5Num20 - Jmp F_Post5Num4 - -F_Post5Num20: - Cmp Word Ptr [SI+8], 0 - JNZ F_Post5Num17 - - Cmp Word Ptr [SI+10], 0 - JZ F_Post5Num21 - -F_Post5Num17: - Call DWord Ptr [SI+8] - -F_Post5Num21: - RetN - -EndP F_Post5Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawHeader Far - -; Call MouseClearEvents - - Call Music_GetSongSegment - Mov DS, AX - Mov DL, [DS:2Ch] - - Push CS - Pop DS - - Call E_GetFreeEMS - Push AX - - Mov AH, 48h - Mov BX, 0FFFFh - Int 21h - ShR BX, 6 - Push BX - - Mov AH, 20h - Mov SI, Offset HeaderMsg1 - Mov DI, ((1*80)+2)*2 - Call S_DrawString - - Mov SI, Offset HeaderMsg2 - Call Glbl_GetHeaderMode - And AH, AH - JNZ F_DrawHeader1 - - Mov SI, Offset HeaderMsg3 - -F_DrawHeader1: - Mov AH, 20h - Call S_DrawString - - Mov SI, Offset HeaderMsg4 - Mov DI, ((4*80)+2)*2 - Call S_DrawString - - Add SP, 4 - - Call Music_GetFreeSoundCardMemory - ; Returns DS:SI, Carry set if nothing to show - JC F_DrawHeader2 ; and AX = value to print. - - Push BX - Push AX - - Mov AH, 20h - Mov DI, (63+8*80)*2 - Call S_DrawString - - Pop AX - Pop BX - -F_DrawHeader2: - Ret - -EndP F_DrawHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawSMCChannels Far - -; Call MouseClearEvents - - Push CS - Pop DS - - Xor CX, CX - -F_DrawSMCChannels1: - Mov AL, CL - Inc AX - Xor AH, AH - Mov BH, 10 - Div BH - Add AX, 3030h - Mov Word Ptr ChannelNumbers, AX - - Mov BX, CX - And BX, 0Fh - Mov AX, 160 ; Calculate DI (offset on screen) - Mul BX - Mov DI, AX - Add DI, (22*80+9)*2 - Mov BX, CX - And BX, 00F0h - ShL BX, 1 - Add DI, BX - - Mov SI, Offset ChannelMsg - Mov AH, 20h - Call S_DrawString - - Inc CX - Cmp CX, 64 - JB F_DrawSMCChannels1 - - Ret - -EndP F_DrawSMCChannels - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ConfigButtonSetup Far - - Call Music_GetSongSegment - Mov DS, AX ; OK... now check for - ; control mode first. - Mov CL, [DS:2Ch] ; CL = Flags. - Add DI, 50 ; ES:DI points to inst button - - Mov BX, [ES:DI] ; ES:BX points to inst button data -; Add DI, 2 - ScasW - Xor CH, CH - Test CL, 4 - JZ F_ConfigButtonSetup1 - - Inc CH - -F_ConfigButtonSetup1: - Mov [ES:BX+33], CH ; Instrument button - - Xor CH, 1 - Mov BX, [ES:DI] -; Add DI, 2 - ScasW - Mov [ES:BX+33], CH ; Sample button - - Mov BX, [ES:DI] -; Add DI, 2 - ScasW - Xor CH, CH - Test CL, 1 - JZ F_ConfigButtonSetup2 - - Inc CH - -F_ConfigButtonSetup2: - Mov [ES:BX+33], CH ; Stereo button - - Xor CH, 1 - Mov BX, [ES:DI] -; Add DI, 2 - ScasW - Mov [ES:BX+33], CH ; Mono button - - Mov BX, [ES:DI] -; Add DI, 2 - ScasW - Xor CH, CH - Test CL, 8 ; Slides... - JZ F_ConfigButtonSetup3 - - Inc CH - -F_ConfigButtonSetup3: - Mov [ES:BX+33], CH - - Xor CH, 1 - Mov BX, [ES:DI] -; Add DI, 2 ; Compression reasons - ScasW - Mov [ES:BX+33], CH - - Ret - -EndP F_ConfigButtonSetup - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF NETWORKENABLED -Proc F_SendSongFlags - - Push CX - Push DX - - Mov CX, 1 - Mov DX, 2Ch - Call Network_SendSongDataInformation - - Pop DX - Pop CX - - Ret - -EndP F_SendSongFlags - -SendSongFlags EQU Call F_SendSongFlags - -ELSE - -SendSongFlags EQU ; - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SetControlSample Far - - Call Music_GetSongSegment - Mov DS, AX - - And Byte Ptr [DS:2Ch], NOT 4 - - SendSongFlags - - Ret - -EndP F_SetControlSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SetControlInstrument Far - - Call Music_GetSongSegment - Mov DS, AX - - Or Byte Ptr [DS:2Ch], 4 - - Push DS - - Mov DI, Offset O1_InitialiseInstrumentList - Mov CX, 3 - Call M_Object1List - ; DX = 0 -> don't initialise - ; DX = 1 -> initialise - Pop DS ; DS = SongDataSegment - - SendSongFlags - - Test DX, DX - JZ F_SetControlInstrument3 - - Call Music_ClearAllInstruments - - ; OK.. for samples 1..99 - ; check if sample exists. - ; if so, copy name&set all - ; notes of instrument. - Push DS - Pop ES ; ES = SongDataSegment - - Xor DX, DX - -F_SetControlInstrument1: - Mov BX, DX - Add BX, BX - Mov SI, [DS:BX+64912] ; SI points to sample - Mov DI, [DS:BX+64712] ; DI points to instrument - - Test Byte Ptr [DS:SI+12h], 1 - JZ F_SetControlInstrument2 - ; No sample there! - - ; Copy name - Mov CX, 26 - Add SI, 14h - Add DI, 20h - Rep MovsB - Add DI, 7 - - Mov AL, DL ; DL = sample number - Inc AX - Mov CX, 120 - -F_SetControlInstrument4: - StosB - Inc DI - Loop F_SetControlInstrument4 - -F_SetControlInstrument2: -IF NETWORKENABLED - Call Network_GetSendQueue - JZ F_SetControlInstrument5 - - Mov AX, 400h - StosW - Mov AX, DX - StosB - -F_SetControlInstrument5: - Call Network_FinishedSendQueue -ENDIF - Inc DX - Cmp DX, 99 - JBE F_SetControlInstrument1 - -F_SetControlInstrument3: - - Ret - -EndP F_SetControlInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SetStereo Far - - Call Music_GetSongSegment - Mov DS, AX - - Or Byte Ptr [DS:2Ch], 1 - - Call Music_InitStereo - - SendSongFlags - - Ret - -EndP F_SetStereo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SetMono Far - - Call Music_GetSongSegment - Mov DS, AX - - And Byte Ptr [DS:2Ch], NOT 1 - - Call Music_InitStereo - - SendSongFlags - - Ret - -EndP F_SetMono - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SetLinear Far - - Call Music_GetSongSegment - Mov DS, AX - - Or Byte Ptr [DS:2Ch], 8 - - SendSongFlags - - Ret - -EndP F_SetLinear - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SetAmiga Far - - Call Music_GetSongSegment - Mov DS, AX - - And Byte Ptr [DS:2Ch], NOT 8 - - SendSongFlags - - Ret - -EndP F_SetAmiga - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Reset5NumInputPos Far - - Mov CS:NumberPos, 0 - Ret - -EndP F_Reset5NumInputPos - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_NewSong Far - - EnsureNoNetwork - - Mov DI, Offset O1_NewSongList - Mov CX, 11 ; OK Button.. - Call M_Object1List - And DX, DX - JZ F_NewSongEnd - - Call Music_Stop - - Cmp Word Ptr [CS:ButtonVariables+8], 0 - JE F_NewSong2 - - Call Music_ReleaseAllSamples - Call Music_ClearAllSampleNames - -F_NewSong2: - Cmp Word Ptr [CS:ButtonVariables+10], 0 - JE F_NewSong3 - - Call Music_ClearAllInstruments - -F_NewSong3: - Cmp Word Ptr [CS:ButtonVariables+12], 0 - JE F_NewSong1 - - Call D_ClearFileName - Call D_ResetTimer - - Call Music_GetSongSegment - Mov ES, AX - - Mov DI, 4 ; Clear song name - Mov CX, 13 - Xor AX, AX - Rep StosW - - Mov DI, 3Ch ; Clear Time - Xor AX, AX - StosW - StosW - - Mov CX, 64 - Mov AL, 32 - Rep StosB - - Mov CX, 64 ; Channel volume - Mov AL, 64 - Rep StosB - - Mov DI, 100h ; Orders. - Mov AL, 0FFh - Mov CX, 256 - Rep StosB - - Call Music_InitMuteTable - Call Msg_ResetMessage - -F_NewSong1: - Cmp Word Ptr [CS:ButtonVariables+6], 0 - JE F_NewSongEnd - ; Clear patterns. - Call D_ClearFileName - Call D_ResetTimer - Call Music_ReleaseAllPatterns - Call PE_ResetOrderPattern - -F_NewSongEnd: - Mov AX, 1 - Ret - -EndP F_NewSong - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_MainMenu Far - - Call S_SaveScreen - - Mov CX, 0FFFFh - Mov DI, Offset O1_MainMenu - Call M_Object1List - - Call S_RestoreScreen - - Mov AX, 1 - Ret - -EndP F_MainMenu - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ViewPattern Far - - Call MouseRestoreEvents - Add SP, 20 - Jmp Glbl_F2_2 - -EndP F_ViewPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ViewVariables Far - - Call MouseRestoreEvents - Add SP, 20 - Jmp Glbl_F12 - -EndP F_ViewVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ViewOrderPan Far - - Call MouseRestoreEvents - Add SP, 20 - Jmp Glbl_F11_2 - -EndP F_ViewOrderPan - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_MessageEditor Far - - Call MouseRestoreEvents - Add SP, 20 - Jmp Glbl_Shift_F9 - -EndP F_MessageEditor - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Help Far - - Call S_RestoreScreen - Call MouseRestoreEvents - Add SP, 20 - Jmp H_Help - -EndP F_Help - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PlaybackMenu Far - - Mov CX, 0FFFFh - Mov DI, Offset O1_PlaybackMenu - Call M_Object1List - - Call S_RestoreScreen - Mov AX, 1 - Ret - -EndP F_PlaybackMenu - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_InfoPage Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - - Add SP, 48 - Jmp Glbl_F5 - -EndP F_InfoPage - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PlaySong Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_Ctrl_F5 - -EndP F_PlaySong - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PlayPattern Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_F6 - -EndP F_PlayPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PlayOrder Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_Shift_F6 - -EndP F_PlayOrder - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PlayMark Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp PE_F7 - -EndP F_PlayMark - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_Stop Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Music_Stop - -EndP F_Stop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ReinitSoundCard Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Music_ReinitSoundCard - -EndP F_ReinitSoundCard - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_CalculateLength Far - - Call S_RestoreScreen - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Music_TimeSong - -EndP F_CalculateLEngth - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DriverScreen Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_DriverScreen - -EndP F_DriverScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SampleMenu Far - - Mov CX, 0FFFFh - Mov DI, Offset O1_SampleMenu - Call M_Object1List - - Call S_RestoreScreen - Mov AX, 1 - Ret - -EndP F_SampleMenu - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_InstrumentMenu Far - - Mov CX, 0FFFFh - Mov DI, Offset O1_InstrumentMenu - Call M_Object1List - - Call S_RestoreScreen - Mov AX, 1 - Ret - -EndP F_InstrumentMenu - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SampleList Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_F3 - -EndP F_SampleList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_InstrumentList Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_F4 - -EndP F_InstrumentList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_InstrumentLibrary Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_Ctrl_F4 - -EndP F_InstrumentLibrary - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ReloadGravis Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Music_SoundCardLoadAllSamples - -EndP F_ReloadGravis - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_SampleLibrary Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_Ctrl_F3 - -EndP F_SampleLibrary - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_FileMenu Far - - Mov CX, 0FFFFh - Mov DI, Offset O1_FileMenu - Call M_Object1List - - Call S_RestoreScreen - Mov AX, 1 - Ret - -EndP F_FileMenu - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_FileLoad Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_F9 - -EndP F_FileLoad - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_FileNew Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Call S_RestoreScreen - Add SP, 48 - Jmp F_NewSong - -EndP F_FileNew - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_FileSaveCurrent Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Call S_RestoreScreen - Add SP, 48 - Jmp D_SaveSong - -EndP F_FileSaveCurrent - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_FileSaveAs Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Add SP, 48 - Jmp Glbl_F10 - -EndP F_FileSaveAs - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_FileDOSShell Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Call S_RestoreScreen - Add SP, 48 - Jmp DOSShell - -EndP F_FileDOSShell - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_FileQuit Far - - Call MouseRestoreEvents - Call MouseRestoreEvents - Call S_RestoreScreen - Add SP, 48 - Jmp Quit - -EndP F_FileQuit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF MEMORYDEBUG - -DebugOffset DW 0 -DebugSegment DW 0 - -AddressInput DB 0 - DB 19 Dup (0) -SegmentMsg DB "Segment: ", 0FDh, 'Xh', 0 - -DebugSegmentNames DB 10, "STARTUP", 0 - DW Startup - - DB 11, "KEYBOARD", 0 - DW Keyboard - - DB 10, "PATTERN", 0 - DW Pattern - - DB 7, "DISK", 0 - DW Disk - - DB 6, "EMS", 0 - DW EMS - - DB 8, "ERROR", 0 - DW Error - - DB 7, "INST", 0 - DW Inst - - DB 12, "FUNCTIONS", 0 - DW Functions - - DB 9, "GLOBAL", 0 - DW Glbl - - DB 7, "HELP", 0 - DW Help - - DB 11, "INFOLINE", 0 - DW InfoLine - - DB 7, "MAIN", 0 - DW Main - - DB 8, "MUSIC", 0 - DW Music - - DB 9, "SCREEN", 0 - DW Screen - - DB 10, "OBJECT1", 0 - DW Object1 - - DB 11, "INFOPAGE", 0 - DW InfoPage - - DB 11, "SONGDATA", 0 -DebugSongDataSegment DW 0 - - DB 11, "DISKDATA", 0 -DebugDiskDataSegment DW 0 - - DB 14, "PATTERNDATA", 0 -DebugPatternDataSegment DW 0 - - DB 0FFh ; End of list. - -DebugMsg DB "CX: ", 0FDh, "X, DX: ", 0FDh, "X ", 0 -DebugCX DW 0 -DebugDX DW 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DrawDebug Far - - Push CS - Pop DS - Assume DS:Functions - - Call S_GetDestination - Mov SI, Offset SegmentMsg - Mov DI, (4+13*80)*2 - - Push DebugSegment -; Mov AX, DebugSegment -; Push AX - Mov AH, 21h - Call S_DrawString ; OK segment done - Pop AX ; Clear stack. - - ; Put offsets on screen. - ; Work out digits. - Mov CX, 1E04h - Mov DI, (3+15*80)*2 - Mov DX, DebugOffset - Xor BH, BH - Mov AH, 2 - -F_DrawDebug1: - Push DI - - Mov BL, DH - ShR BL, CL - Mov AL, [HexNumbers+BX] ; Blah.. how inefficient - StosW - Mov BL, DH - And BL, 0Fh - Mov AL, [HexNumbers+BX] - StosW - Mov BL, DL - ShR BL, CL - Mov AL, [HexNumbers+BX] - StosW - Mov BL, DL - And BL, 0Fh - Mov AL, [HexNumbers+BX] - StosW ; Offset is on screen. - - Mov AL, ':' - StosW - - Pop DI - Add DI, 160 - Add DX, 16 - Dec CH - JNZ F_DrawDebug1 - - ; Now to shove debug stuff. - Mov SI, DebugOffset - Mov DS, DebugSegment - Assume DS:Nothing - Mov DI, (10+15*80)*2 - - Mov DX, 30 - -F_DrawDebug2: - Push DI - Push SI - - Mov CX, 1004h - -F_DrawDebug3: - Cmp CH, 8 - JNE F_DrawDebug4 - - Mov AL, '-' - StosW - Xor AL, AL - StosW - -F_DrawDebug4: - LodsB ; Number. - Mov BL, AL - ShR BL, CL - Mov BL, [CS:HexNumbers+BX] - XChg AL, BL - And BL, 0Fh - StosW - Mov AL, [CS:HexNumbers+BX] - StosW - - Xor AL, AL - StosW - - Dec CH ; Hex number loop - JNZ F_DrawDebug3 - - StosW - - Pop SI - Mov CX, 16 - -F_DrawDebug5: - LodsB - StosW - Loop F_DrawDebug5 - - Pop DI - Add DI, 160 ; Next line. - - Dec DX ; line loop. - JNZ F_DrawDebug2 - - Push CS - Pop DS - - Push DebugDX - Push DebugCX - - Mov SI, Offset DebugMsg - Mov AH, 20h - Mov DI, (40+47*80)*2 - Call S_DrawString - Pop AX - Pop AX - - Mov AX, 1 - Ret - -EndP F_DrawDebug - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_PostDebug Far - - Mov CS:DebugCX, CX - Mov CS:DebugDX, DX - - Xor AX, AX - Ret - -EndP F_PostDebug - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DebugUp Far - - Sub CS:DebugOffset, 16 - - Mov AX, 1 - Ret - -EndP F_DebugUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DebugDown Far - - Add CS:DebugOffset, 16 - - Mov AX, 1 - Ret - -EndP F_DebugDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DebugPgUp Far - - Sub CS:DebugOffset, 16*30 - - Mov AX, 1 - Ret - -EndP F_DebugPgUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DebugPgDn Far - - Add CS:DebugOffset, 16*30 - - Mov AX, 1 - Ret - -EndP F_DebugPgDn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_DebugStringInput Far - - Mov AX, Disk - Mov DS, AX - Assume DS:Disk - Mov DX, DiskDataArea - - Xor BP, BP ; BP = ':' count. - - Mov AX, Music - Mov DS, AX - Assume DS:Music - Mov BX, SongDataArea - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - Mov SI, PatternDataArea - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Functions ; ES = functions also. - - Mov DebugSongDataSegment, BX - Mov DebugDiskDataSegment, DX - Mov DebugPatternDataSegment, SI - - Mov SI, Offset DebugSegmentNames - Xor BX, BX - -F_DebugStringInput1: - Mov DI, Offset AddressInput - LodsB - Cmp AL, 0FFh - JE F_DebugStringInput2 - - Mov BL, AL - Push SI - ; OK.. compare in here.. -F_DebugStringInput4: - LodsB - Mov AH, [DI] - - And AL, AL - JZ F_DebugStringInput3 - - And AH, AH - JZ F_DebugStringInput6 - - Cmp AH, 'a' - JB F_DebugStringInput6 - Cmp AH, 'z' - JA F_DebugStringInput6 - - Add AH, 'A'-'a' - -F_DebugStringInput6: - Inc DI - Cmp AH, AL - JE F_DebugStringInput4 - - -F_DebugStringInput5: - Pop SI - Add SI, BX - Jmp F_DebugStringInput1 - - -F_DebugStringInput3: - And AH, AH - JNZ F_DebugStringInput6 - - LodsW - Pop SI - Mov DebugSegment, AX - Mov DebugOffset, 0 - - Mov AX, 1 - Ret - -F_DebugStringInput2: ; We have a hex address(?) - Mov SI, Offset AddressInput - Cmp Byte Ptr [SI], 0 - JE F_DebugStringInput15 - -F_DebugStringInput7: - LodsB - And AL, AL - JZ F_DebugStringInput10 - - Cmp AL, '0' - JB F_DebugStringInput8 - Cmp AL, '9' - JBE F_DebugStringInput7 - -F_DebugStringInput8: - Cmp AL, 'A' - JB F_DebugStringInput9 - Cmp AL, 'F' - JBE F_DebugStringInput7 - - -F_DebugStringInput9: - Cmp AL, 'a' - JB F_DebugStringInput16 - Cmp AL, 'f' - JBE F_DebugStringInput7 - -F_DebugStringInput16: - Cmp AL, ':' - JE F_DebugStringInput7 - -F_DebugStringInput15: - Xor AX, AX - Ret - -F_DebugStringInput10: ; Hex address - Mov BX, DebugSegment - Mov CL, 4 - Xor DX, DX ; BX:DX contains address - - Xor AX, AX - Mov SI, Offset AddressInput - -F_DebugStringInput11: - LodsB - And AL, AL - JZ F_DebugStringInput12 - - Cmp AL, ':' - JE F_DebugStringInput13 - - Sub AL, '0' - Cmp AL, 9 - JBE F_DebugStringInput14 - - Sub AL, '@'-'9' - Cmp AL, 15 - JBE F_DebugStringInput14 - - Sub AL, 32 - -F_DebugStringInput14: - ShL DX, CL - Add DX, AX - - Jmp F_DebugStringInput11 - -F_DebugStringInput13: - Inc BP - Cmp BP, 2 - JAE F_DebugStringInput17 - - Mov BX, DX - Xor DX, DX - Jmp F_DebugStringInput11 - -F_DebugStringInput17: - Mov DebugSegment, BX - Mov DebugOffset, DX - Xor DX, DX - Jmp F_DebugStringInput11 - -F_DebugStringInput12: - Cmp BP, 2 - JB F_DebugStringInput18 - - LDS SI, DWord Ptr [DebugOffset] - Mov [SI], DL - Jmp F_DebugStringInput19 - -F_DebugStringInput18: - Mov DebugSegment, BX - Mov DebugOffset, DX - -F_DebugStringInput19: - Mov AX, 1 - Ret - -EndP F_DebugStringInput - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_ShowMIDIZxxInput Far - - Push CS - Pop DS - Assume DS:Functions - - Mov SI, Offset ZxxString - Mov AX, TopMIDIMacro - Add AX, 6 - Mov CX, 7 - -F_ShowMIDIZxxInput1: - Push AX - Dec AX - Loop F_ShowMIDIZxxInput1 - - Mov CX, 7 - Mov DI, (13+42*80)*2 - -F_ShowMIDIZxxInput2: - Mov AH, 20h - Call S_DrawString - Pop AX - Add DI, (80-3)*2 - Loop F_ShowMIDIZxxInput2 - - Ret - -EndP F_ShowMIDIZxxInput - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_MIDI_Up Far - - Cmp CS:TopMIDIMacro, 80h - JBE F_MIDI_Up1 - - Dec CS:TOPMIDIMacro - Jmp F_MIDI_Up2 - -F_MIDI_Up1: - Mov Word Ptr [ES:DI], 33 - -F_MIDI_Up2: - Mov AX, 1 - Ret - -EndP F_MIDI_Up - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_MIDI_Down Far - - Cmp CS:TopMIDIMacro, 0F9h - JAE F_MIDI_Down1 - - Inc CS:TOPMIDIMacro - -F_MIDI_Down1: - Mov AX, 1 - Ret - -EndP F_MIDI_Down - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_MIDI_PgUp Far - - Cmp Word Ptr [ES:DI], 33 - JBE F_MIDI_PgUp1 - - Sub Byte Ptr [CS:TopMIDIMacro], 7 - JS F_MIDI_PgUp1 - - Mov Byte Ptr [CS:TopMIDIMacro], 80h - -F_MIDI_PgUp1: - Mov AX, 1 - Ret - -EndP F_MIDI_PgUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc F_MIDI_PgDn Far - - Cmp Word Ptr [ES:DI], 33 - JBE F_MIDI_PgDn1 - - Add [CS:TopMIDIMacro], 7 - Cmp [CS:TopMIDIMacro], 0F9h - JB F_MIDI_PgDn1 - - Mov [CS:TopMIDIMacro], 0F9h - -F_MIDI_PgDn1: - Mov AX, 1 - Ret - -EndP F_MIDI_PgDn - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386 + +include switch.inc +include network.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +IF MEMORYDEBUG + +Segment StartUp BYTE Public 'Code' +EndS + +Segment InfoPage BYTE Public 'Code' +EndS + +Segment Glbl BYTE Public 'Code' +EndS + +Segment Help BYTE Public 'Code' +EndS + +Segment Error BYTE Public 'Code' +EndS + +Segment EMS BYTE Public 'Code' +EndS + +Segment KeyBoard BYTE Public 'Code' +EndS + +Segment InfoLine BYTE Public 'Code' +EndS + +Segment Main BYTE Public 'Code' +EndS + +ENDIF + +Segment Pattern BYTE Public 'Code' + Extrn PatternDataArea:Word +EndS + +Segment Inst BYTE Public 'Code' + Extrn MaxNode:Word +EndS + +Segment Music BYTE Public 'Code' + Extrn SongDataArea:Word + Extrn MIDIDataArea:Word +EndS + +Segment Disk BYTE Public 'Code' + Extrn DiskDataArea:Word +EndS + +Segment Screen BYTE Public 'Code' +EndS + +Segment Object1 BYTE Public 'Data' +EndS + +;------------------------------------------------------------------------------- + + Extrn LastInstrument:Byte + + Extrn D_GetLoadSampleVars:Far + Extrn D_ClearFileName:Far + Extrn D_SaveSong:Far + Extrn D_ResetTimer:Far + + Extrn E_UnInitEMS:Far + Extrn E_GetFreeEMS:Far + + Extrn Glbl_F2_2:Far + Extrn Glbl_F3:Far + Extrn Glbl_Ctrl_F3:Far + Extrn Glbl_Ctrl_F4:Far + Extrn Glbl_F4:Far + Extrn Glbl_F5:Far + Extrn Glbl_Ctrl_F5:Far + Extrn Glbl_F6:Far + Extrn PE_F7:Far + Extrn Glbl_Shift_F6:Far + Extrn Glbl_Shift_F9:Far + Extrn Glbl_F9:Far + Extrn Glbl_F10:Far + Extrn Glbl_F11_2:Far + Extrn Glbl_F12:Far + + Extrn Glbl_GetHeaderMode:Far + + Extrn H_Help:Far + + Extrn I_GetInstrumentOffset:Far + Extrn I_GetSampleOffset:Far + + Extrn I_DrawWaveForm:Far + Extrn I_MapEnvelope:Far + Extrn D_DrawWaveForm:Far + + Extrn S_InitScreen:Far + Extrn S_Set80x25Mode:Far + Extrn S_SetPalette2:Far + Extrn S_RedefineCharacters:Far + Extrn S_UnInitScreen:Far + Extrn S_DrawBox:Far + Extrn S_UpdateScreen:Far + Extrn S_OverrideVGADetection:Far + Extrn S_SetDirectMode:Far + Extrn S_DrawString:Far + Extrn S_HiLight:Far + Extrn S_GetDestination:Far + Extrn S_SaveScreen:Far + Extrn S_RestoreScreen:Far + + + Extrn Music_GetSongSegment:Far + Extrn Music_InitMixTable:Far + Extrn Music_InitMuteTable:Far + Extrn Music_ClearAllInstruments:Far + Extrn Music_SetGlobalVolume:Far + Extrn Music_InitStereo:Far + Extrn Music_Stop:Far + + Extrn Music_RegetLoopInformation:Far + + Extrn Music_ReleaseAllSamples:Far ; For New Song Function + Extrn Music_ReleaseAllPatterns:Far + Extrn Music_ClearAllInstruments:Far + Extrn Music_ClearAllSampleNames:Far + Extrn Music_GetFreeSoundCardMemory:Far + Extrn Music_SoundCardLoadAllSamples:Far + Extrn Music_ReinitSoundCard:Far + Extrn Music_TimeSong:Far + + Extrn Glbl_DriverScreen:Far + Extrn Music_GetDriverVariable:Far + Extrn Music_SetDriverVariable:Far + + Extrn M_Object1List:Far + + Extrn Msg_ResetMessage:Far + + Extrn O1_EmptyList:Far + Extrn O1_ThumbStringList:Far + Extrn O1_InitialiseInstrumentList:Far + Extrn O1_NewSongList:Far + + Extrn O1_MainMenu:Far + Extrn O1_FileMenu:Far + Extrn O1_PlaybackMenu:Far + Extrn O1_SampleMenu:Far + Extrn O1_InstrumentMenu:Far + + Extrn PE_ConvAX2Num:Far + Extrn PE_ResetOrderPattern:Far + + Extrn DOSShell:Far + Extrn Quit:Far + + Extrn MouseAddEvent:Far, AddMouseQueue:Far, MouseClearEvents:Far + Extrn SetKeyboardLock:Far, NewCharacterSet:Far + Extrn MouseRemoveEvents:Far, MouseRestoreEvents:Far + Extrn MultiChannelInfo:Byte + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global F_MainMenu:Far + Global F_FileMenu:Far + Global F_PlaybackMenu:Far + Global F_SampleMenu:Far + Global F_InstrumentMenu:Far + + Global F_DrawHeader:Far + + Global F_InstrumentButtonHandler:Far + + Global F_NewSong:Far + Global F_DrawStringInput:Far + Global F_PreStringInput:Far + Global F_PostStringInput:Far + Global F_RedrawScreen:Far + Global F_Nothing:Far + Global F_DrawBoxObject:Far + Global F_DrawTextObject:Far + Global F_PostExitObject:Far + Global F_SetDirectMode:Far + Global F_CharacterDefinitions:Far + Global F_CallFarFunction:Far + Global F_CallFarPreFunction:Far + Global F_CallFarPostFunction:Far + + Global F_DrawToggle:Far + Global F_PreToggle:Far + Global F_PostToggle:Far + + Global F_Draw5Num:Far + Global F_Pre5Num:Far + Global F_Post5Num:Far + + Global F_Draw3Num:Far + Global F_Pre3Num:Far + Global F_Post3Num:Far + + Global F_DrawButtonObject:Far + Global F_PreButtonObject:Far + Global F_PostButtonObject:Far + + Global F_Return0:Far + Global F_Return1:Far + Global F_Return64:Far + Global F_Return192:Far + + Global F_DrawThumbBar:Far + Global F_DrawScalableThumbBar:Far + Global F_PreThumbBar:Far + Global F_PreScalableThumbBar:Far + Global F_PostThumbBar:Far + Global F_PostScalableThumbBar:Far + + Global F_DrawInfoLine:Far + + Global F_ShowChannels:Far + Global F_GotoEmptyList:Far + Global F_DrawSMCChannels:Far + + Global F_SetControlInstrument:Far + Global F_SetControlSample:Far + Global F_ConfigButtonSetup:Far + + Global F_SetStereo:Far + Global F_SetMono:Far + Global F_SetAmiga:Far + Global F_SetLinear:Far + + Global F_Reset5NumInputPos:Far + + Global AddressInput:Byte + Global ThumbStringEnter:Byte + + Global F_MessageEditor:Far + Global F_Help:Far ; Main menu + Global F_ViewPattern:Far + Global F_ViewVariables:Far + Global F_ViewOrderPan:Far + + Global F_FileLoad:Far + Global F_FileNew:Far + Global F_FileSaveCurrent:Far + Global F_FileSaveAs:Far + Global F_FileDOSShell:Far + Global F_FileQuit:Far + + Global F_InfoPage:Far ; Playback menu + Global F_PlaySong:Far + Global F_PlayPattern:Far + Global F_PlayOrder:Far + Global F_Stop:Far + Global F_PlayMark:Far + Global F_DriverScreen:Far + Global F_ReinitSoundCard:Far + Global F_CalculateLength:Far + + Global F_SampleList:Far + Global F_SampleLibrary:Far + Global F_ReloadGravis:Far + + Global F_InstrumentList:Far + Global F_InstrumentLibrary:Far + +IF MEMORYDEBUG + + Global F_DrawDebug:Far + Global F_DebugUp:Far + Global F_DebugDown:Far + Global F_DebugPgUp:Far + Global F_DebugPgDn:Far + Global F_DebugStringInput:Far + Public F_PostDebug + +ENDIF + + Public F_ShowMIDIZxxInput + Public F_MIDI_Up + Public F_MIDI_Down + Public F_MIDI_PgUp, F_MIDI_PgDn + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Functions BYTE Public 'Code' USE16 + Assume CS:Functions, DS:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +ButtonVariables Label Word + DW 220h ; Standard SB Configs + DW 7 + DW 1 + DW 1 ; Clear patterns + DW 1 ; Clear samples + DW 1 ; Clear instruments + DW 1 ; Clear order list + +ButtonTypes Label Word + DW Offset ButtonType0 ; Press/Release buttons + DW Offset ButtonType1 ; Toggle Press/Release + DW Offset ButtonType2 ; One of Selection + +ButtonEffects Label Word + DW Offset ButtonEffect0 ; Return value + DW Offset ButtonEffect1 ; New object list + DW Offset ButtonEffect2 ; Call function + DW Offset ButtonEffect3 ; Set var at offset + DW Offset ButtonEffect4 ; Jump to function + DW Offset ButtonEffect5 ; Set var + DW Offset ButtonEffect6 ; Jump to function + +ButtonWidth Label Word + DW 0, 0, 0, 0, 0, 0, 0, 0 + DW 7, 7, 7, 7, 7, 7, 7, 7 + DW 0, 0, 0, 0, 0, 0, 0, 0 + DW 7, 7, 7, 7, 0, 0, 0, 0 + +MouseEventData DW 7 Dup (0), Functions + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +GetThumbValues Label Word + DW Offset GetPanning + DW Offset GetPEVariables + DW Offset GetSampleVariables + DW Offset GetMusicVariables + DW Offset GetPanning ; ChannelVol + DW Offset GetLoadSampleVariables + DW Offset GetInstVariables + DW Offset GetScreenVariables + DW Offset GetInstrumentVariables + DW Offset GetDriverVariables + +DrawThumbValues Label Word + DW Offset DrawPanning + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset DrawMIDIChannel + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset F_NothingNear + +PreThumbFuncs Label Word + DW Offset HiLightPanning + DW Offset GetPEVariables + DW Offset GetSampleVariables + DW Offset GetMusicVariables + DW Offset GetPanning ; Channelvol + DW Offset GetLoadSampleVariables + DW Offset GetInstVariables + DW Offset GetScreenVariables + DW Offset GetInstrumentVariables + DW Offset GetDriverVariables + +PostThumbFuncs Label Word + DW Offset SetPanning + DW Offset SetPEVariables + DW Offset SetSampleVariables + DW Offset SetMusicVariables + DW Offset SetPanning + DW Offset SetLoadSampleVariables + DW Offset SetInstVariables ; Inst + DW Offset SetScreenVariables + DW Offset SetInstrumentVariables ; Inst segment + DW Offset SetDriverVariables + +PostThumbCheck Label Word + DW Offset PanningKeys + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset FilterKeys + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset F_NothingNear + +ThumbStringEnter DB 0 + DB 4 Dup (0) + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +; LastStringData DD 0 + +StringInputOffset Label Word + DW Offset GetSIODiskSegment + DW Offset GetSampleString + DW Offset GetSIOInstSegment + DW Offset GetLoadSampleString + DW Offset GetMusicSegmentString ; Songsegment + DW Offset GetPatternSegmentString + DW Offset GetInstrumentString + DW Offset GetMIDIString + +PostStringInput Label Word + DW Offset F_NothingNear + DW Offset SetSampleString + DW Offset F_NothingNear + DW Offset F_NothingNear + DW Offset SetMusicSegmentString ; Songsegment + DW Offset F_NothingNear + DW Offset SetInstrumentString + DW Offset F_NothingNear + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +GetToggleStatus Label Word + DW Offset GetSampleToggle + DW Offset GetPatternSegmentToggle + DW Offset GetMusicSegmentToggle + DW Offset GetLoadSampleToggle + DW Offset GetInstrumentToggle + +ToggleBit Label Word + DW Offset SampleToggle + DW Offset PatternSegmentToggle + DW Offset MusicSegmentToggle + DW Offset LoadSampleToggle + DW Offset InstrumentToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +TripleNumberPos DW 0 + +Get3NumValues Label Word + DW Offset GetInstrument3Num + +Set3NumValues Label Word + DW Offset SetInstrument3Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +NumberPos DW 0 + +Get5NumValues Label Word + DW Offset GetSample5Num + DW Offset GetLoadSample5Num + Dw Offset GetInst5Num + +Set5NumValues Label Word + DW Offset SetSample5Num + DW Offset SetLoadSample5Num + DW Offset SetInst5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +HeaderMsg1 Label Byte +IF SHOWVERSION + DB 0FFh, 9, ' ', "Impulse Tracker v2.14 Copyright (C) 1995-2000 Jeffrey Lim", 13 +ELSE + DB 0FFh, 12, ' ', "Impulse Tracker Copyright (C) 1995-2000 Jeffrey Lim", 13 +ENDIF + DB 0FFh, 9, ' ', 0FEh, 21h, 139, 0FFh, 25, 134, 138, 0FFh, 11, ' ', 139, 0FFh, 28, 134, 138, 13 + DB 0FEh, 20h, "Song Name", 0FEh, 21h, 132, 0FEh, 5, 0FFh, 25, ' ', 0FEh, 23h, 131, 0FEh, 20h, 0 + +HeaderMsg2 DB " Instrument" + DB 0FEh, 21h, 132, 0FEh, 7, " :", 0FFh, 25, ' ', 0FEh, 23h, 131, 0 + +HeaderMsg3 DB 0FFh, 5, " Sample" + DB 0FEh, 21h, 132, 0FEh, 7, " :", 0FFh, 25, ' ', 0FEh, 23h, 131, 0 + +HeaderMsg4 DB "File Name", 0FEh, 21h, 132, 0FEh, 5, 0FFh, 18, ' ', 0FEh, 23h, 128, 0FFh, 6, 129, 136, 0FEh, 20h, "Speed/Tempo", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 1, "/", 0FEh, 5, " ", 0FEh, 23h, 128, 0FFh, 20, 129, 136, 13 + DB 0FEh, 20h, 0FFh, 4, " Order", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 1, "/", 0FEh, 5, " ", 0FEh, 23h, 128, 0FFh, 10, 129, 136, 0FEh, 20h, 0FFh, 12, " Octave", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 23h, 128, 0FFh, 5, 129, 136, 13 + DB 0FEh, 20h, " Pattern", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 1, "/", 0FEh, 5, " ", 0FEh, 23h, 131, 0FEh, 20h, " F1...Help F9.....Load ", 0FEh, 23h, 137, 129, 136, 0FEh, 20h, 0FFh, 11, " FreeMem ", 0FDh, "Dk ", 13 + DB 0FEh, 20h, 0FFh, 6, " Row", 0FEh, 21h, 132, 0FEh, 5, " ", 0FEh, 1, "/", 0FEh, 5, " ", 0FEh, 23h, 131, 0FEh, 20h, " ESC..Main Menu F5/F8..Play / Stop", 0FFh, 8, " FreeEMS ", 0FDh, "Dk", 13 + DB 0FEh, 23h, 0FFh, 9, ' ', 137, 0FFh, 7, 129, 136 + DB 0 + +ChannelMsg DB "Channel " +ChannelNumbers DB "xx", 0 + +HexNumbers DB "0123456789ABCDEF" +SurroundMessage DB "Surround", 0 +MutedMessage DB " Muted", 0 +ForwardMsg DB "Forwards", 0 +PingPongMsg DB "Ping Pong", 0 +ZxxString DB "Z", 0FDh, "X", 0 +NumberStorage DW 0, 0, 0, 0, 0, 0, 0, 0, 0 +PitchMessage DB "Pitch", 0 +FilterMessage DB "Filter", 0 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc F_Nothing Far + + Xor AX, AX + Ret + +EndP F_Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_InstrumentButtonHandler Far + + Test AX, AX + JZ F_InstrumentButtonHandler1 + + NetworkSendInstrument + +F_InstrumentButtonHandler1: + Push DS + Call I_GetInstrumentOffset ; Returns DS:BX + Push DS + Pop ES + Mov DI, BX + Pop DS + + Add DI, [SI+24] + Ret + +EndP F_InstrumentButtonHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_NothingNear + + Xor AX, AX + Ret + +EndP F_NothingNear + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_CallFarPreFunction Far + + Call DWord Ptr [SI+6] + + Ret + +EndP F_CallFarPreFunction + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_CallFarPostFunction Far + + Mov SI, [BX] + + Call DWord Ptr [SI+10] + + Ret + +EndP F_CallFarPostFunction + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_CallFarFunction Far + + Call DWord Ptr [SI+2] + + Ret + +EndP F_CallFarFunction + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawBoxObject Far + + LodsW + Xor AH, AH + LodsB + Push AX + LodsB + Push AX + LodsB + Push AX + LodsB + Push AX + LodsB + Push AX + Call S_DrawBox + Add SP, 10 + + Ret + +EndP F_DrawBoxObject + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawTextObject Far + + LodsW + + Mov BX, 3 + Xor CX, CX ; CX = string length count + Xor DX, DX + +F_DrawTextObject1: + Mov AL, [SI+BX] + Inc BX + Cmp AL, 0 + JE F_DrawTextObject2 + + Cmp AL, 0FDh + JNE F_DrawTextObject1 + Inc CX + Cmp Byte Ptr [SI+BX], 'L' + JNE F_DrawTextObject1 + Inc CX + Jmp F_DrawTextObject1 + +F_DrawTextObject2: + JCXZ F_DrawTextObject3 + Push Word Ptr [SI+BX] + Add BX, 2 + Inc DX + Dec CX + Jmp F_DrawTextObject2 + +F_DrawTextObject3: + Mov AL, 80 + Mul Byte Ptr [SI+1] + Add AL, [SI] + AdC AH, 0 + Add AX, AX + Mov DI, AX + Mov AH, [SI+2] + Add SI, 3 + Call S_DrawString + + Add DX, DX + Add SP, DX + + Ret + +EndP F_DrawTextObject + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PostExitObject Far + + Xor AX, AX + Test CH, 1 + JNZ F_PostExitObject1 + + Mov SI, [BX] + Mov DX, [SI+2] + Mov AX, 4 ; Exit from MainProc + +F_PostExitObject1: + Ret + +EndP F_PostExitObject + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SetDirectMode Far + + LodsW + LodsB + Call S_SetDirectMode + + Ret + +EndP F_SetDirectMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_CharacterDefinitions Far + + LodsW + LodsW + Mov BX, [SI] + Add SI, 2 + Call S_RedefineCharacters + + Ret + +EndP F_CharacterDefinitions + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseButtonPress Far ; Given CX, DX = coords + ; Given AX = Object number + ; DS:SI points to mouse obj + Mov CX, 11Ch + Xor DX, DX + Call AddMouseQueue + + Mov Word Ptr [SI+8], 1108h + Mov Word Ptr [SI+12], Offset MouseButtonRelease + + Mov AL, 2 + Call SetKeyboardLock + + Xor AX, AX + Ret + +EndP MouseButtonPress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseButtonRelease Far + + Mov CX, 01Ch + Xor DX, DX + Call AddMouseQueue + + Mov Word Ptr [SI+8], 102h + Mov Word Ptr [SI+12], Offset MouseButtonPress + + Xor AX, AX + Call SetKeyboardLock + + Ret + +EndP MouseButtonRelease + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawButtonObject Far ; AX = object number + ; SI = object + + Mov [CS:MouseEventData+10], AX ; Store object number + + Cmp Word Ptr [SI+16], 5 + JB F_DrawButtonObject1 + + Xor AX, AX + Call DWord Ptr [SI+18] + Mov AX, [SI+22] + ScasB +; Cmp [ES:DI], AL + + SetE [SI+33] + +F_DrawButtonObject1: + Mov BX, [SI+32] + And BX, 0FFh + Add SI, 28 + Add BX, BX + Mov DX, [CS:ButtonWidth+BX] + + Xor AH, AH + LodsB + LEA CX, [EAX*8+EDX] + Mov [CS:MouseEventData+0], CX + Push AX + + LodsB + LEA CX, [EAX*8+EDX] + Mov [CS:MouseEventData+2], CX + Push AX + + Sub DX, 7 + + LodsB + Mov CX, AX + ShL CX, 3 + Sub CX, DX + Mov [CS:MouseEventData+4], CX + Push AX + + LodsB + Mov CX, AX + ShL CX, 3 + Sub CX, DX + Mov [CS:MouseEventData+6], CX + Push AX + + LodsB ; Base Style + Mov BL, [SI] ; Up/Down + And BL, 1 + Mov [SI], BL + Add AL, BL + Push AX + Call S_DrawBox + Add SP, 10 + + Inc SI + + Mov AL, 80 + Mul Byte Ptr [SI-5] + Add AL, [SI-6] + AdC AH, 0 + Add AX, AX + Add AX, 162 + Mov DI, AX + Mov AH, 20h + + Call S_DrawString + + Push CS + Pop DS + Mov SI, Offset MouseEventData + Mov [MouseEventData+8], 102h ; Left mouse button pressed + Mov [MouseEventData+12], Offset MouseButtonPress + Call MouseAddEvent + + Ret + +EndP F_DrawButtonObject + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PreButtonObject Far + + Add SI, 28 + Xor AH, AH + LodsB + Push AX + LodsB + Push AX + LodsB + Push AX + LodsB + Push AX + LodsB ; Base Style + Mov BL, [SI] ; Up/Down + And BL, 1 + Add AL, BL + Push AX + Call S_DrawBox + Add SP, 10 + + Inc SI + + Mov AL, 80 + Mul Byte Ptr [SI-5] + Add AL, [SI-6] + AdC AH, 0 + Add AX, AX + Add AX, 162 + Mov DI, AX + Mov AH, 23h + + Call S_DrawString + + Ret + +EndP F_PreButtonObject + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PostButtonObject Far + + Mov SI, [BX] + Push SI + Push DI + Push BX + Push CX + Push DX + + Add SI, 28 + Mov AL, 80 + Mul Byte Ptr [SI+1] + Add AL, [SI] + AdC AH, 0 + Add AX, AX + Add AX, 162 + Mov DI, AX + Mov AL, 20h + Mov CL, [SI+2] + Sub CL, [SI] + Dec CL + Xor CH, CH + Call S_HiLight + + Pop DX + Pop CX + Pop BX + Pop DI + Pop SI + + Test CH, 80h + JNZ F_PostButtonNoMIDI + + Mov AL, [SI+33] + Cmp CL, 1Ch + JE F_PostButtonObject6 ; Enter + + Test AL, 2 + JNZ F_PostButtonObject7 + + Cmp CX, 1C8h ; Up pressed + JE F_PostButtonObject1 + + Cmp CX, 1D0h + JE F_PostButtonObject2 ; Down + + Cmp CX, 1CBh + JE F_PostButtonObject3 ; Left + + Cmp CX, 1CDh + JE F_PostButtonObject4 ; Right + + Cmp CX, 10Fh ; Tab + JE F_PostButtonObject4 + +; Test CL, CL +; JZ F_PostButtonNOMIDI + + Cmp DX, 0F00h ; Shift tab + JE F_PostButtonObject3 + +F_PostButtonNOMIDI: + Xor AX, AX + Ret + +F_PostButtonObject7: + Test AL, 4 + JZ F_PostButtonObject8 + Test CH, 1 + JZ F_PostButtonObject8 + + And AX, 1 + Xor AL, 1 + Mov [SI+33], AL + +F_PostButtonObject8: + Mov AX, 2 + Ret + +F_PostButtonObject4: + LodsW + +F_PostButtonObject3: + LodsW + +F_PostButtonObject2: + LodsW + +F_PostButtonObject1: + LodsW + + LodsW + Cmp AX, 0FFFFh + JNE F_PostButtonObject5 + + Xor AX, AX + Ret + +F_PostButtonObject5: + Mov [DI], AX + Mov AX, 2 + Ret + +F_PostButtonObject6: ; Enter pressed + Push BX + + Mov BX, [SI+10] + Add BX, BX + Jmp [CS:ButtonTypes+BX] + +EndP F_PostButtonObject + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonType0 Far + + Pop BX + + Test CH, 1 + JZ ButtonType0_1 + + Or Byte Ptr [SI+33], 7 + +ButtonType0_2: + Mov AX, 2 + Ret + +ButtonType0_1: + Test AL, 1 + JNZ ButtonType0_4 + + Test AL, 2 + JZ ButtonType0_2 + +ButtonType0_4: + Mov Byte Ptr [SI+33], 0 + + Jmp ButtonEffect + +EndP ButtonType0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonType1 Far + + Pop BX + + And CH, CH + JZ ButtonType1_2 + + Test AL, 2 + JNZ ButtonType1_1 + + Xor Byte Ptr [SI+33], 7 + +ButtonType1_1: + Mov AX, 2 + Ret + +ButtonType1_2: + And Byte Ptr [SI+33], 1 + + Jmp ButtonEffect + +EndP ButtonType1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonEffect Far + + Mov BX, [SI+16] + Add BX, BX + Jmp [CS:ButtonEffects+BX] + +EndP ButtonEffect + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonType2 Far + + Pop BX + + And CH, CH + JZ ButtonEffect + + Test AL, 2 + JZ ButtonType2_1 + + Mov AX, 2 + Ret + +ButtonType2_1: + Add SI, 12 + LodsW + Mov CX, AX + LodsW + Mov DX, AX + Add DX, DX + Add DI, 6 + Add DX, DI + Add CX, CX + Add DI, CX + + Xor AX, AX + +ButtonType2_2: + Mov SI, [DI] + Mov [SI+33], AL + + ScasW +; Add DI, 2 + Cmp DI, DX + JBE ButtonType2_2 + + Mov SI, [BX] + Mov Byte Ptr [SI+33], 1 + + Mov AX, 1 + Ret + +EndP ButtonType2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonEffect0 Far + + Mov DX, [SI+18] + Mov AX, 4 + Ret + +EndP ButtonEffect0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonEffect1 Far + + Mov CX, [SI+20] + Mov DX, [SI+18] + Mov AX, 5 + Mov SI, 1 + Ret + +EndP ButtonEffect1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonEffect2 Far + + Push DS + Push SI + + Mov AL, [SI+33] + Call DWord Ptr [SI+18] + + Pop SI + Pop DS + + Mov AX, 1 + + Ret + +EndP ButtonEffect2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonEffect3 Far + + Mov BX, [SI+18] ; Var number + Mov AX, [SI+20] + Add BX, BX + Mov [CS:ButtonVariables+BX], AX + + Mov AX, 1 + Ret + +EndP ButtonEffect3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonEffect4 Far + + Jmp DWord Ptr [SI+18] + +EndP ButtonEffect4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonEffect5 Far + + Mov AX, 1 + Call DWord Ptr [SI+18] + Mov AX, [SI+22] + + StosB +; Mov [ES:DI], AL + + Mov AX, 1 + Ret + +EndP ButtonEffect5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ButtonEffect6 Far + + Jmp DWord Ptr [SI+24] + +EndP ButtonEffect6 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetPanning ; DI = channel no. + + Push DS + + Call Music_GetSongSegment + Mov DS, AX + + Mov DL, [DI+64] + Xor DH, DH + + Pop DS + + Ret + +EndP GetPanning + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetPEVariables + + Push DS + + Mov DX, Pattern + Mov DS, DX +; Call PE_GetPatternSegment + Mov DL, [DI] + Xor DH, DH + + Pop DS + Ret + +EndP GetPEVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetScreenVariables + + Push DS + + Mov DX, Screen + Mov DS, DX + Mov DL, [DI] + Xor DH, DH + + Pop DS + Ret + +EndP GetScreenVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetScreenVariables + + Push DS + Push AX + + Mov AX, Screen + Mov DS, AX + Pop AX + + Mov [DI], AL + Call S_SetPalette2 + + Pop DS + Ret + +EndP SetScreenVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetPanning + + Push DS + + Push AX + Call Music_GetSongSegment + Mov DS, AX + Pop AX + Add DI, 64 + + Mov [DI], AL + +IF NETWORKENABLED + Mov CX, 1 + Mov DX, DI + Call Network_SendSongDataInformation +ENDIF + + Pop DS + Ret + +EndP SetPanning + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetPEVariables + + Push DS + + Push AX + Mov AX, Pattern + Mov DS, AX +; Call PE_GetPatternSegment + Pop AX + + Mov [DI], AL + + Pop DS + Ret + +EndP SetPEVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetInstVariables + + Push DS + Push AX + Push BX + + Call I_GetInstrumentOffset + + Mov DX, [BX+DI] + Cmp DI, 19h + JNE GetInstVariables1 + + And DX, 7Fh + +GetInstVariables1: + +; If DI = 3Ah or 3Bh, the XOR top bit. + Cmp DI, 3Ah + JB GetInstVariables4 + Cmp DI, 3Bh + JA GetInstVariables4 + + Xor DL, 80h + Jmp GetInstVariables3 + +GetInstVariables4: + + Cmp DI, 14h + JE GetInstVariables2 + Xor DH, DH + Cmp DI, 3Dh + JAE GetInstVariables3 + Cmp DI, 16h + JNE GetInstVariables2 + +GetInstVariables3: + MovSX DX, DL + +GetInstVariables2: + Pop BX + Pop AX + Pop DS + + Ret + +EndP GetInstVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSampleVariables + + Push DS + Push AX + Push BX + + Call I_GetSampleOffset + + Mov DL, [BX+DI] + Xor DH, DH + Cmp DI, 2Fh + JNE GetSampleVariables1 + + And DL, 7Fh + +GetSampleVariables1: + Pop BX + Pop AX + Pop DS + + Ret + +EndP GetSampleVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMusicVariables + + Push DS + + Call Music_GetSongSegment + Mov DS, AX + Xor DX, DX + Mov DL, [DI] + + Pop DS + + Ret + +EndP GetMusicVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetInstrumentVariables + + Push DS + + Mov AX, Inst + Mov DS, AX + Mov DX, [DI] + + Pop DS + + Ret + +EndP GetInstrumentVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetDriverVariables + + Call Music_GetDriverVariable + Mov DX, AX + Ret + +EndP GetDriverVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetDriverVariables + + Call Music_SetDriverVariable + Ret + +EndP SetDriverVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetLoadSampleVariables + + Push DS + Push SI + Push BX + + Call D_GetLoadSampleVars + Mov BX, SI + + Mov DL, [BX+DI] + Xor DH, DH + + Pop BX + Pop SI + Pop DS + + Ret + +EndP GetLoadSampleVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetInstVariables + + Push DS + Push BX + Push AX + + Call I_GetInstrumentOffset + + Pop AX + +IF FILTERENVELOPES + Cmp DI, 3Ah + JB SetInstVariables3 + Cmp DI, 3Bh + JA SetInstVariables3 + + Xor AL, 80h +ELSE + And Word Ptr [BX+3Ah], 7F7Fh +ENDIF + +SetInstVariables3: + Mov [BX+DI], AL + Cmp DI, 14h + JNE SetInstVariables1 + +SetInstVariables2: + Mov [BX+DI], AX + +SetInstVariables1: + NetworkSendInstrument + + Pop BX + Pop DS + + Ret + +EndP SetInstVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSampleVariables + + Push DS + Push BX + Push AX + + Call I_GetSampleOffset + + Pop AX + Cmp DI, 2Fh + JNE SetSampleVariables1 + + Or AL, 80h ; Turn on. + +SetSampleVariables1: + Mov [BX+DI], AL + + Pop BX + Pop DS + + NetworkSendSample + + Ret + +EndP SetSampleVariables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMusicVariables + + Push DS + Push AX + + Call Music_GetSongSegment + Mov DS, AX + + Pop AX + Mov [DI], AL + +IF NETWORKENABLED + Mov CX, 1 + Mov DX, DI + Call Network_SendSongDataInformation +ENDIF + + Cmp DI, 31h + JNE SetMusicVariables1 + + Call Music_InitMixTable + Jmp SetMusicVariablesEnd + +SetMusicVariables1: + Cmp DI, 30h + JNE SetMusicVariables3 + + Call Music_SetGlobalVolume + +SetMusicVariables3: + +SetMusicVariablesEnd: + Pop DS + + Ret + +EndP SetMusicVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetInstrumentVariables + + Push DS + Push AX + + Mov AX, Inst + Mov DS, AX + + Pop AX + Mov [DI], AX + + Pop DS + + Ret + +EndP SetInstrumentVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetLoadSampleVariables + + Push DS + Push SI + Push BX + + Call D_GetLoadSampleVars + Mov BX, SI + + Mov [BX+DI], AL + + Pop BX + Pop SI + Pop DS + + Ret + +EndP SetLoadSampleVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MousePressThumbBar Far + + Mov DX, CX + Mov CX, 8010h + Call AddMouseQueue + + Mov Word Ptr [SI+8], 1109h ; move or release + Mov Word Ptr [SI+12], Offset MouseHeldThumbBar + + Mov AL, 1 + Call SetKeyboardLock + + Xor AX, AX + + Ret + +EndP MousePressThumbBar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseHeldThumbBar Far + + Test BH, 8 + JNZ MouseHeldThumbBar2 + +MouseHeldThumbBar1: + Mov DX, CX + Mov CX, 8010h + Call AddMouseQueue + Ret + +MouseHeldThumbBar2: + Mov CX, 8001h ; Redraw screen + Call AddMouseQueue + +; Mov Word Ptr [SI+8], 102h +; Mov Word Ptr [SI+12], Offset MousePressThumbBar + + Xor AX, AX + Call SetKeyboardLock + + Ret + +EndP MouseHeldThumbBar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawThumbBar Far + + Mov [CS:MouseEventData+10], AX ; Store object number + + Call S_GetDestination + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:GetThumbValues+BX] ; DX returns thumbbar value + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX ; ES:DI points to area... + + Cmp DX, [SI+6] + JG F_DrawThumbBar2 + Cmp DX, [SI+4] + JL F_DrawThumbBar2 + + Mov CX, [SI+6] + Sub CX, [SI+4] + Add CX, 15 + ShR CX, 3 + Mov BX, CX + Mov AX, 300h +; Xor AX, AX + + Push DI + Push DI + + Rep StosW + + Pop DI + Push BX + Push DI + Mov BX, DX ; DX = value to show. + Sub BX, [SI+4] + Inc BX + Mov AX, BX + ShR BX, 3 + Add BX, BX + Add DI, BX + And AX, 7 + Add AX, 155 + Mov AH, 2 + StosW + + Cmp AL, 157 + JBE F_DrawThumbBar1 + Add AL, 5 + StosW + +F_DrawThumbBar1: + Pop DI + Pop BX + LEA DI, [EDI+EBX*2+2] + Mov CH, 21h + Mov AX, DX + Call PE_ConvAX2Num + + Pop DI + +F_DrawThumbBar2: + Mov BX, [SI+8] + Add BX, BX + Call [CS:DrawThumbValues+BX] ; DX returns pan value + + Mov CX, [SI+6] + Sub CX, [SI+4] + Add CX, 15 + ShR CX, 3 + + Xor AH, AH + Mov AL, [SI+2] + ShL AX, 3 + Mov [CS:MouseEventData+0], AX + ShL CX, 3 + Add AX, CX + Dec AX + Mov [CS:MouseEventData+4], AX + + Xor AH, AH + Mov AL, [SI+3] + ShL AX, 3 + Mov [CS:MouseEventData+2], AX + Add AX, 7 + Mov [CS:MouseEventData+6], AX + + Push CS + Pop DS + Assume DS:Functions + Mov SI, Offset MouseEventData + Mov Word Ptr [SI+8], 102h + Mov Word Ptr [SI+12], Offset MousePressThumbBar + Call MouseAddEvent + + Ret + +EndP F_DrawThumbBar + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawScalableThumbBar Far + + Mov [CS:MouseEventData+10], AX ; Store object number + + Call S_GetDestination + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:GetThumbValues+BX] ; DX returns thumbbar value + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX ; ES:DI points to area... + + Cmp DX, [SI+6] + JG F_DrawScalableThumbBar2 + Cmp DX, [SI+4] + JL F_DrawScalableThumbBar2 + + Push DI + Push DI + + Mov AX, 300h + Mov CX, [SI+24] ; Display length + Inc CX + Rep StosW + + ; Volume bar position = Value*Width / (MaxVal-MinVal) + + Pop DI + Push DI + + Push DX + + Mov AX, [SI+24] + ShL AX, 3 + Sub DX, [SI+4] + Mul DX + Mov CX, [SI+6] + Sub CX, [SI+4] + Div CX + + Inc AX + Mov BX, AX + ShR BX, 3 + Add BX, BX + Add DI, BX + And AX, 7 + Add AX, 155 + Mov AH, 2 + StosW + + Cmp AL, 157 + JBE F_DrawScalableThumbBar1 + Add AL, 5 + StosW + +F_DrawScalableThumbBar1: + Pop DX + + Pop DI + + Mov AX, [SI+24] + LEA DI, [EDI+EAX*2+4] + Mov CH, 21h + Mov AX, DX + Call PE_ConvAX2Num + + Pop DI + +F_DrawScalableThumbBar2: + Mov BX, [SI+8] + Add BX, BX + Call [CS:DrawThumbValues+BX] ; DX returns pan value + + Xor AH, AH + Mov AL, [SI+2] + Mov CX, AX + ShL AX, 3 + Mov [CS:MouseEventData+0], AX + Mov CX, [SI+24] + Inc CX + ShL CX, 3 + Add AX, CX + Dec AX + Mov [CS:MouseEventData+4], AX + + Xor AH, AH + Mov AL, [SI+3] + ShL AX, 3 + Mov [CS:MouseEventData+2], AX + Add AX, 7 + Mov [CS:MouseEventData+6], AX + + Push CS + Pop DS + Assume DS:Functions + Mov SI, Offset MouseEventData + Mov Word Ptr [SI+8], 102h + Mov Word Ptr [SI+12], Offset MousePressThumbBar + Call MouseAddEvent + + Ret + +EndP F_DrawScalableThumbBar + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc HiLightPanning + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Sub AX, 11 + Add AX, AX + Mov DI, AX + + Mov AL, 23h + Mov CX, 10 + Call S_HiLight + + Ret + +EndP HiLightPanning + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PreThumbBar Far + + Call S_GetDestination + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:GetThumbValues+BX] ; DX returns thumbbar value + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX ; ES:DI points to area... + + Cmp DX, [SI+6] + JG F_PreThumbBar2 + Cmp DX, [SI+4] + JL F_PreThumbBar2 + + Mov CX, [SI+6] + Sub CX, [SI+4] + Add CX, 15 + ShR CX, 3 + Mov BX, CX + Mov AX, 300h +; Xor AX, AX + + Push DI + Push DI + + Rep StosW + + Pop DI + Push BX + Push DI + Mov BX, DX ; DX = value to show. + Sub BX, [SI+4] + Inc BX + Mov AX, BX + ShR BX, 3 + Add BX, BX + Add DI, BX + And AX, 7 + Add AX, 155 + Mov AH, 3 + StosW + + Cmp AL, 157 + JBE F_PreThumbBar1 + Add AL, 5 + StosW + +F_PreThumbBar1: + Pop DI + Pop BX + LEA DI, [EDI+EBX*2+2] + Mov CH, 21h + Mov AX, DX + Call PE_ConvAX2Num + + Pop DI + +F_PreThumbBar2: + Mov BX, [SI+8] + Add BX, BX + Call [CS:DrawThumbValues+BX] ; DX returns pan value + +; Ret + + Call S_GetDestination + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:PreThumbFuncs+BX] ; DX returns pan value + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX ; ES:DI points to area... + +F_PreThumbBar3: + Mov CX, [SI+6] + Sub CX, [SI+4] + Add CX, 15 + ShR CX, 3 + Mov AL, 3 + Call S_HiLight + Ret + +EndP F_PreThumbBar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PreScalableThumbBar Far + + Call S_GetDestination + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:GetThumbValues+BX] ; DX returns thumbbar value + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX ; ES:DI points to area... + + Cmp DX, [SI+6] + JG F_PreScalableThumbBar2 + Cmp DX, [SI+4] + JL F_PreScalableThumbBar2 + + Push DI + Push DI + + Mov AX, 300h + Mov CX, [SI+24] ; Display length + Inc CX + Rep StosW + + ; Volume bar position = Value*Width / (MaxVal-MinVal) + + Pop DI + Push DI + + Push DX + + Mov AX, [SI+24] + ShL AX, 3 + Sub DX, [SI+4] + Mul DX + Mov CX, [SI+6] + Sub CX, [SI+4] + Div CX + + Inc AX + Mov BX, AX + ShR BX, 3 + Add BX, BX + Add DI, BX + And AX, 7 + Add AX, 155 + Mov AH, 2 + StosW + + Cmp AL, 157 + JBE F_PreScalableThumbBar1 + Add AL, 5 + StosW + +F_PreScalableThumbBar1: + Pop DX + + Pop DI + + Mov AX, [SI+24] + LEA DI, [EDI+EAX*2+4] + Mov CH, 21h + Mov AX, DX + Call PE_ConvAX2Num + + Pop DI + +F_PreScalableThumbBar2: + Mov BX, [SI+8] + Add BX, BX + Call [CS:DrawThumbValues+BX] ; DX returns pan value + +; Ret + + Call S_GetDestination + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:PreThumbFuncs+BX] ; DX returns pan value + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX ; ES:DI points to area... + +F_PreScalableThumbBar3: + Mov CX, [SI+24] + Inc CX + Mov AL, 3 + Call S_HiLight + Ret + +EndP F_PreScalableThumbBar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PostScalableThumbBar Far + + Cmp CX, 8010h + JE F_PostScalableThumbBarMouse1 + + Jmp F_PostThumbBar + +F_PostScalableThumbBarMouse1: ; DX = pixel... + Mov SI, [BX] + + Xor AX, AX + Mov AL, [SI+2] ; Left point + ShL AX, 3 ; Left pixel + Add AX, 4 + + Sub DX, AX + JNC F_PostScalableThumbBarMouse2 + + Xor DX, DX + +F_PostScalableThumbBarMouse2: ; Value = (Pixel / NumPixels)*(Max-Min)+Min + Mov CX, [SI+24] ; Length + ShL CX, 3 ; AX = MaxPixel + Cmp DX, CX + JB F_PostScalableThumbBarMouse3 + + Mov DX, CX + +F_PostScalableThumbBarMouse3: + Mov AX, [SI+6] + Sub AX, [SI+4] + Mul DX + Div CX + + ShR CX, 1 + Cmp CX, DX + AdC AX, 0 + + Add AX, [SI+4] + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:PostThumbFuncs+BX] + + Mov AX, 2 + Ret + +EndP F_PostScalableThumbBar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PostThumbBar Far + + Mov SI, [BX] + + Push ES + Push DI + + Call S_GetDestination + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Push BX + Push DX + Call [CS:GetThumbValues+BX] ; AX contains value. + Mov AX, DX + Pop DX + Pop BX + + Pop DI + Pop ES + + Push AX + Push BX + + Call [CS:PostThumbCheck+BX] + Test AX, AX + JNZ F_PostThumbBar23 + + Pop BX + Pop AX + + Cmp CX, 8010h + JE F_PostThumbBarMouse1 + + Cmp CX, 8001h + JE F_PostThumbBarMouseRedrawScreen + + Cmp CX, 1CBh + JE F_PostThumbBar2 + + Cmp CX, 1CDh + JE F_PostThumbBar4 + + Cmp CX, 1C7h + JE F_PostThumbBar10 + + Cmp CX, 1CFh + JE F_PostThumbBar11 + + Cmp CX, 1C8h + JE F_PostThumbBar5 + + Cmp CX, 1D0h + JE F_PostThumbBar6 + + Cmp CX, 10Fh + JE F_PostThumbBar7 + + Cmp CX, 1C9h + JE F_PostThumbBar21 + + Cmp CX, 1D1h + JE F_PostThumbBar22 + + Test CL, CL + JZ F_PostThumbBar20 + + Cmp DX, 0F00h + JE F_PostThumbBar8 + + Cmp DX, '0' + JB F_PostThumbBar50 + Cmp DX, '9' + JA F_PostThumbBar50 + + Jmp F_PostThumbBar30 + +F_PostThumbBar50: + Test CX, 600h + JNZ F_PostThumbBar17 + + Test CX, 1800h + JNZ F_PostThumbBar16 + +F_PostThumbBar20: + Xor AX, AX + Ret + +F_PostThumbBar23: + Pop BX + Pop AX + +F_PostThumbBarMouseRedrawScreen: + Mov AX, 1 + Ret + +F_PostThumbBar16: + Mov DI, CX + And DI, 1FFh + Cmp DI, 1CBh + JE F_PostThumbBar14 + + Cmp DI, 1CDh + JE F_PostThumbBar12 + + Jmp F_PostThumbBar20 + +F_PostThumbBar17: + Mov DI, CX + And DI, 1FFh + Cmp DI, 1CBh + JE F_PostThumbBar18 + + Cmp DI, 1CDh + JE F_PostThumbBar19 + + Jmp F_PostThumbBar20 + +F_PostThumbBar2: + Dec AX + Cmp AX, [SI+6] + JG F_PostThumbBar9 + Cmp Ax, [SI+4] + JL F_PostThumbBar9 + +F_PostThumbBar15: + Cmp AX, [SI+6] + JG F_PostThumbBarMin + Cmp AX, [SI+4] + JGE F_PostThumbBar3 + +F_PostThumbBarMin: + Mov AX, [SI+4] + +F_PostThumbBar3: + Mov DI, [SI+10] + Call [CS:PostThumbFuncs+BX] + +F_PostThumbBar9: + Mov AX, 1 + Ret + +F_PostThumbBar10: + Mov AX, [SI+4] + Jmp F_PostThumbBar3 + +F_PostThumbBar11: + Mov AX, [SI+6] + Jmp F_PostThumbBar3 + +F_PostThumbBar4: + Inc AX + Cmp AX, [SI+4] + JL F_PostThumbBar9 + + Cmp AX, [SI+6] + JG F_PostThumbBar9 + +F_PostThumbBar13: + Cmp AX, [SI+4] + JL F_PostThumbBarMax + Cmp AX, [SI+6] + JLE F_PostThumbBar3 + +F_PostThumbBarMax: + Mov AX, [SI+6] + Jmp F_PostThumbBar3 + +F_PostThumbBar12: + Add AX, 2 + Jmp F_PostThumbBar13 + +F_PostThumbBar14: + Sub AX, 2 + Jmp F_PostThumbBar15 + +F_PostThumbBar18: + Sub AX, 4 + Jmp F_PostThumbBar15 + +F_PostThumbBar19: + Add AX, 4 + Jmp F_PostThumbBar13 + +F_PostThumbBar22: + LodsW + +F_PostThumbBar21: + LodsW + +F_PostThumbBar8: + LodsW + +F_PostThumbBar7: + LodsW + +F_PostThumbBar6: + LodsW + +F_PostThumbBar5: + Add SI, 12 + LodsW + Cmp AX, 0FFFFh + JE F_PostThumbBar20 + + Mov [DI], AX + Jmp F_PostThumbBar9 + +F_PostThumbBarMouse1: ; DX = pixel... + Xor AX, AX + Mov AL, [SI+2] ; Left point + ShL AX, 3 ; Left pixel + Sub DX, AX + Sub DX, 4 + Mov AX, [SI+4] + Add AX, DX + + Cmp AX, [SI+4] + JG F_PostThumbBarMouse2 + + Mov AX, [SI+4] + Jmp F_PostThumbBarMouse3 + +F_PostThumbBarMouse2: + Cmp AX, [SI+6] + JL F_PostThumbBarMouse3 + + Mov AX, [SI+6] + +F_PostThumbBarMouse3: + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:PostThumbFuncs+BX] + + Mov AX, 2 + Ret + +F_PostThumbBar30: + Push DS + Push SI + + Call S_SaveScreen + + Mov DI, Offset ThumbStringEnter + Push CS + Pop ES + Mov AL, DL + StosB + + Xor AL, AL + Mov CX, 4 + Rep StosB + + Mov DI, Offset O1_ThumbStringList + Mov CX, 3 + Call M_Object1List + + Call S_RestoreScreen + + Pop SI + Pop DS + + And DX, DX + JZ F_PostThumbBar31 + + ; Now get value... + Xor CX, CX + Mov DI, Offset ThumbStringEnter + +F_PostThumbBar32: + Mov AL, [CS:DI] + And AL, AL + JZ F_PostThumbBar33 + + Inc DI + + Push AX + Mov AX, 10 + Mul CX + Mov CX, AX + Pop AX + + Cmp AL, '0' + JB F_PostThumbBar31 + Cmp AL, '9' + JA F_PostThumbBar31 + + Sub AL, '0' + Xor AH, AH + Add CX, AX + Jmp F_PostThumbBar32 + +F_PostThumbBar33: ; now save value. + Cmp DI, Offset ThumbStringEnter + JE F_PostThumbBar31 + + Mov AX, CX + + Cmp AX, [SI+4] + JL F_PostThumbBar31 + Cmp AX, [SI+6] + JG F_PostThumbBar31 + + Mov BX, [SI+8] + Mov DI, [SI+10] + Add BX, BX + Call [CS:PostThumbFuncs+BX] + +F_PostThumbBar31: + Mov AX, 1 + Ret + +EndP F_PostThumbBar + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawInfoLine Far + + Push ES + LodsW + Push SI + Xor DX, DX + +F_DrawInfoLine1: + LodsB + Inc DX + And AL, AL + JNZ F_DrawInfoLine1 + + Dec DX + Pop SI ; DX contains length of string + Call S_GetDestination + + Mov DI, (1+11*80)*2 + Mov BX, 78 + Mov CX, BX + Cmp Byte Ptr [SI], 0 + JE F_DrawInfoLine3 + + Sub CX, DX + ShR CX, 1 + Sub BX, CX + Sub BX, DX + Sub BX, 2 + + Mov AX, 219Ah + Rep StosW + + Mov AX, 2020h + StosW + +F_DrawInfoLine2: + LodsB + StosW + Dec DX + JNZ F_DrawInfoLine2 + + Mov AX, 2020h + StosW + + Mov CX, BX + +F_DrawInfoLine3: + Mov AX, 219Ah + Rep StosW + + Pop ES + Ret + +EndP F_DrawInfoLine + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ShowChannels Far + + Push DS + + Push CS + Pop DS + Assume DS:Functions + + Mov DI, (20+15*80)*2 + Mov CX, 32 + Mov AX, 3130h + Mov Word Ptr ChannelNumbers, AX + Mov AH, 20h + Call F_ShowChannel1 + + Mov DI, (54+15*80)*2 + Mov CX, 32 + Call F_ShowChannel1 + + Pop DS + Assume DS:Nothing + Ret + +EndP F_ShowChannels + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ShowChannel1 + + Assume DS:Functions + +F_ShowChannel1_1: + Mov SI, Offset ChannelMsg + Call S_DrawString + + Inc Byte Ptr [ChannelNumbers+1] + Cmp Byte Ptr [ChannelNumbers+1], '9' + JBE F_ShowChannel1_2 + + Inc Byte Ptr [ChannelNumbers] + Mov Byte Ptr [ChannelNumbers+1], '0' + +F_ShowChannel1_2: + Add DI, 140 + Loop F_ShowChannel1_1 + + Assume DS:Nothing + + Ret + +EndP F_ShowChannel1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_RedrawScreen Far + + Mov AX, 1 + Ret + +EndP F_RedrawScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Return0 Far ; ESC pressed on opening scrn + + Xor DX, DX + Mov AX, 4 + Ret + +EndP F_Return0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Return64 Far + + Mov DX, 64 + Mov AX, 4 + Ret + +EndP F_Return64 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Return192 Far + + Mov DX, 192 + Mov AX, 4 + Ret + +EndP F_Return192 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PanningKeys + + Push AX + Mov AX, DX + Cmp AX, 'a' + JB PanningKeys1 + + Cmp AX, 'z' + JA PanningKeys3 + + Sub AX, 32 + +PanningKeys1: + Cmp AL, 'L' + JE PanningKeysLeft + Cmp AL, 'R' + JE PanningKeysRight + Cmp AL, 'M' + JE PanningKeysMiddle + Cmp AL, 'S' + JE PanningKeysSurround + Cmp AL, ' ' + JE PanningKeysSpace + +PanningKeys3: + Pop AX + Xor AX, AX + Ret + +PanningKeysLeft: + Xor AX, AX + Jmp PanningKeys2 + +PanningKeysRight: + Mov AX, 64 + Jmp PanningKeys2 + +PanningKeysMiddle: + Mov AX, 32 + Jmp PanningKeys2 + +PanningKeysSurround: + Mov AX, 100 + +PanningKeys2: + Mov DI, [SI+10] + Call SetPanning + Pop AX + + Mov AX, 1 + Ret + +PanningKeysSpace: + Pop AX + Xor AL, 128 + Push AX + + Mov BX, [ES:DI] + Cmp BX, 74 + JAE PanningKeys2 + + Inc Word Ptr [ES:DI] + + Jmp PanningKeys2 + +EndP PanningKeys + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FilterKeys + + Push DI + Mov DI, [SI+10] + + Cmp DI, 3Ah + JB FilterKeys1 + Cmp DI, 3Bh + JA FilterKeys1 + + Cmp DX, ' ' + JNE FilterKeys1 + + Xor AL, 80h + Call SetInstVariables + + Mov AX, 1 + Jmp FilterKeysEnd + +FilterKeys1: + Xor AX, AX +FilterKeysEnd: + Pop DI + Ret + +EndP FilterKeys + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawPanning + + Push DS + Push SI + + Push CS + Pop DS + + Test DL, 128 + JZ DrawPanning2 + + Mov SI, Offset MutedMessage + Mov AH, 5 + Call S_DrawString + + Jmp DrawPanning1 + +DrawPanning2: + Cmp DX, 100 + JNE DrawPanning1 + + Mov SI, Offset SurroundMessage + Mov AH, 5 + Call S_DrawString + +DrawPanning1: + Pop SI + Pop DS + Ret + +EndP DrawPanning + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawMIDIChannel + + Mov AX, [SI+0Ah] + Cmp AX, 3Fh + JA DrawMIDIChannel2 + Cmp AX, 3Ah + JB DrawMIDIChannel2 + + Cmp AX, 3Ch + JNE DrawMIDIChannel4 + +DrawMIDIChannel1: + Cmp DL, 17 + JNE DrawMIDIChannel5 + + Add DI, 22 + Mov AX, 200h+'M' + StosW + Mov AL, 'a' + StosW + Mov AL, 'p' + StosW + StosW + Mov AL, 'e' + StosW + Mov AL, 'd' + StosW + +DrawMIDIChannel5: + Test DL, DL + JZ DrawMIDIChannel3 + Jmp DrawMIDIChannel2 + +DrawMIDIChannel4: + Test DX, DX + JNS DrawMIDIChannel2 + +DrawMIDIChannel3: + Mov AX, 200h+'O' + StosW + Mov AL, 'f' + StosW + StosW + Jmp DrawMIDIChannel2 + +DrawMIDIChannel2: + Ret + +EndP DrawMIDIChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Return1 Far + + Mov DX, 1 + Mov AX, 4 + Ret + +EndP F_Return1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSIOInstSegment + + Mov SI, Inst + Mov DS, SI + Mov SI, CX + + Ret + +EndP GetSIOInstSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSIODiskSegment + + Mov SI, Disk + Mov DS, SI + Mov SI, CX + + Ret + +EndP GetSIODiskSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetLoadSampleString ; Returns DS:SI + + Call D_GetLoadSampleVars ; Gets SI = currentsample offset + ; DS = DiskDataArea + Add SI, CX + + Ret + +EndP GetLoadSampleString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMusicSegmentString + + Call Music_GetSongSegment + Mov DS, AX + + Mov SI, CX + + Ret + +EndP GetMusicSegmentString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMusicSegmentString + +IF NETWORKENABLED + Mov CX, 26 + Mov DX, 4 + Call Network_SendSongDataInformation +ENDIF + Ret + +EndP SetMusicSegmentString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetPatternSegmentString + + Push CS + Pop DS + + Mov SI, CX + + Ret + +EndP GetPatternSegmentString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSampleString + + Call I_GetSampleOffset + Mov SI, BX + Add SI, CX + + Ret + +EndP GetSampleString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSampleString + + NetworkSendSample + + Ret + +EndP SetSampleString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetInstrumentString + + Call I_GetInstrumentOffset + Mov SI, BX + Add SI, CX + + Ret + +EndP GetInstrumentString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetInstrumentString + + NetworkSendInstrument + Ret + +EndP SetInstrumentString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +TopMIDIMacro DW 80h + +Proc GetMIDIString ; CX = select2 + + Push Music + Pop DS + Assume DS:Music + + Mov DS, MIDIDataArea + Assume DS:Nothing + + Mov SI, CX + Test CX, CX + JNS GetMIDIString1 + + Mov CX, CS:TopMIDIMacro + Sub SI, 8000h+80h*20h + ShL CX, 5 + Add SI, CX + +GetMIDIString1: + Ret + +EndP GetMIDIString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSelectString Far + + Mov CX, 8010h + Xor DX, DX + Call AddMouseQueue + + Xor AX, AX + + Ret + +EndP MouseSelectString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PostStringFunction DW 0 + +Proc F_GetStringInputOffset + + Mov BX, [SI+4] + Mov CX, [SI+6] + + Mov [CS:PostStringFunction], Offset F_NothingNear + + Cmp BX, 10h + JA F_GetStringInputOffset1 + + Add BX, BX + Push AX + + Mov AX, [CS:PostStringInput+BX] + Mov PostStringFunction, AX + + Pop AX + Call [CS:StringInputOffset+BX] ; DS:SI points to string + Ret + +F_GetStringInputOffset1: + Mov DS, BX + Mov SI, CX + Ret + +EndP F_GetStringInputOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawStringInput Far + + Mov [CS:MouseEventData+10], AX ; Store object number + + Push DS + Push SI + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX + Call S_GetDestination + + Call F_GetStringInputOffset + + Mov AH, 2h + +F_DrawStringInput1: + LodsB + Test AL, AL + JZ F_DrawStringInput2 + Cmp AL, 226 + JB F_DrawStringInput3 + + Mov AL, ' ' + +F_DrawStringInput3: + + StosW + Jmp F_DrawStringInput1 + +F_DrawStringInput2: + Pop SI + Pop DS + + Xor AH, AH + Mov AL, [SI+2] ; XValue + Mov CX, AX + ShL CX, 3 + Mov [CS:MouseEventData+0], CX + + Add AL, [SI+8] + Mov CX, AX + ShL CX, 3 + Dec CX + Mov [CS:MouseEventData+4], CX + + Mov AL, [SI+3] + ShL AX, 3 + Mov [CS:MouseEventData+2], AX + Add AX, 7 + Mov [CS:MouseEventData+6], AX + + Push CS + Pop DS + Assume DS:Functions + + Mov SI, Offset MouseEventData + Mov [MouseEventData+8], 102h + Mov [MouseEventData+12], Offset MouseSelectString + + Call MouseAddEvent + + Ret + +EndP F_DrawStringInput + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PreStringInput Far + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX + Call S_GetDestination + + Call F_GetStringInputOffset + +F_PreStringInput1: + LodsB + And AL, AL + JZ F_PreStringInput2 + ScasW +; Add DI, 2 + Jmp F_PreStringInput1 + +F_PreStringInput2: + Inc DI + Mov AL, 30h + StosB + Ret + +EndP F_PreStringInput + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PostStringInput Far + + Test CL, CL + JZ F_PostStringInput9 + + Mov SI, [BX] + + Cmp CX, 8010h + JE F_PostStringInput5 + + Cmp CX, 1C8h + JNE F_PostStringInput1 + + Mov AX, [SI+14] + Jmp F_PostStringInput4 + +F_PostStringInput1: + Cmp CX, 1D0h + JNE F_PostStringInput2 + + Mov AX, [SI+16] + Jmp F_PostStringInput4 + +F_PostStringInput2: + Cmp CX, 10Fh ; Tab + JNE F_PostStringInput3 + + Mov AX, [SI+18] + Jmp F_PostStringInput4 + +F_PostStringInput3: + Cmp DX, 0F00h + JNE F_PostStringInput6 + + Mov AX, [SI+20] + +F_PostStringInput4: + Cmp AX, 0FFFFh + JE F_PostStringInput12 + +; Mov Word Ptr CS:LastStringData, 0 +; Mov Word Ptr CS:LastStringData+2, 0 + + Mov [DI], AX + +F_PostStringInput5: + Mov AX, 1 + Ret + +F_PostStringInput6: + Cmp CX, 11Ch ; Enter + JNE F_PostStringInput7 + + Cmp Word Ptr [SI+10], 0 + JNE F_PostStringInput13 + + Cmp Word Ptr [SI+12], 0 + JE F_PostStringInput12 + +F_PostStringInput13: + Jmp DWord Ptr [SI+10] + +F_PostStringInput7: + Cmp CX, 10Eh ; Backspace + JNE F_PostStringInput8 + + Call F_GetStringInputOffset + + Cmp Byte Ptr [DS:SI], 0 + JE F_PostStringBackSpace2 + +F_PostStringBackSpace1: + LodsB + And AL, AL + JNZ F_PostStringBackSpace1 + + Mov [SI-2], AL + +F_PostStringBackSpace2: + Jmp F_PostStringInput11 + +F_PostStringInput8: + Cmp DX, 127 ; Ctrl-Backspace + JNE F_PostStringInput12 + + Mov DX, [SI+8] + Call F_GetStringInputOffset + + Mov CX, DX + Mov AX, DS + Mov ES, AX + Mov DI, SI + Xor AL, AL + Rep StosB + + Jmp F_PostStringInput11 + +F_PostStringInput12: + Test CL, CL + JZ F_PostStringInput9 + Cmp DL, 32 + JB F_PostStringInput9 + + Mov DI, [SI+8] + Call F_GetStringInputOffset + + Xor BX, BX + +F_PostStringInput10: + LodsB + Inc BX + And AL, AL + JNZ F_PostStringInput10 + + Dec SI + Cmp BX, DI + JAE F_PostStringInput11 + + Mov AL, DL + Xor AH, AH + Mov [DS:SI], AX + +F_PostStringInput11: + Call [CS:PostStringFunction] + + Mov AX, 1 + Ret + +F_PostStringInput9: + Xor AX, AX + Ret + +EndP F_PostStringInput + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_GotoEmptyList Far + + Mov AX, 5 + Mov SI, 1 + Mov DI, AX + Mov CX, Object1 + Mov DX, Offset O1_EmptyList + + Ret + +EndP F_GotoEmptyList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSampleToggle + + Push DS + + Call I_GetSampleOffset + Xor CL, CL + + Mov DH, [BX+DI] + Test DH, DL + JZ GetSampleToggle1 + + Inc CX + + Cmp DI, 2Fh + JE GetSampleToggle1 + + ShL DL, 1 + ShL DL, 1 + + Pop DS + Push DS + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + LEA DI, [EAX+6] ; DI points to screen part. + Push DS + Push SI + + Mov SI, Offset ForwardMsg + Test DH, DL + JZ GetSampleToggle2 + + Mov SI, Offset PingPongMsg + +GetSampleToggle2: + Push CS + Pop DS + Mov AH, 2 + Call S_DrawString + + Pop SI + Pop DS + +GetSampleToggle1: + Pop DS + Ret + +EndP GetSampleToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetInstrumentToggle + + Push DS + + Call I_GetInstrumentOffset + Xor CL, CL + + Mov DH, [BX+DI] + Test DH, DL + JZ GetInstrumentToggle1 + + Inc CX + + Cmp DI, 1D4h + JNE GetInstrumentToggle1 + Cmp DL, 1 + JNE GetInstrumentToggle1 + + Push DS + Push SI + + Push CS + Pop DS + + Mov DI, (28*80+57)*2 + Mov AH, 2 + Mov SI, Offset PitchMessage + Test DH, DH + JNS GetInstrumentToggle3 + + Mov SI, Offset FilterMessage + +GetInstrumentToggle3: + Call S_DrawString + + Pop SI + Pop DS + +GetInstrumentToggle1: + Cmp DI, 19h + JNE GetInstrumentToggle2 + + Xor CL, 1 + +GetInstrumentToggle2: + Pop DS + Ret + +EndP GetInstrumentToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetLoadSampleToggle + + Push DS + Push SI + Call D_GetLoadSampleVars ; Gets SI = currentsample offset + ; DS = DiskDataArea + + Mov BX, SI + Pop SI + + Xor CL, CL + + Mov DH, [BX+DI] + Test DH, DL + JZ GetLoadSampleToggle1 + + Inc CX + + ShL DL, 1 + ShL DL, 1 + + Pop DS + Push DS + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + LEA DI, [EAX+6] ; DI points to screen part + Push DS + Push SI + + Mov SI, Offset ForwardMsg + Test DH, DL + JZ GetLoadSampleToggle2 + + Mov SI, Offset PingPongMsg + +GetLoadSampleToggle2: + Push CS + Pop DS + Mov AH, 2 + Call S_DrawString + + Pop SI + Pop DS + +GetLoadSampleToggle1: + Pop DS + Ret + +EndP GetLoadSampleToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetPatternSegmentToggle + + Push DS + + Mov AX, Pattern + Mov DS, AX + + Xor CL, CL + Test [DS:DI], DL + JZ GetPatternSegmentToggle1 + + Inc CX + +GetPatternSegmentToggle1: + Pop DS + Ret + +EndP GetPatternSegmentToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetMusicSegmentToggle + + Push DS + + Call Music_GetSongSegment + Mov DS, AX + + Xor CL, CL + Test [DS:DI], DL + JZ GetMusicSegmentToggle1 + + Inc CX + +GetMusicSegmentToggle1: + Pop DS + Ret + +EndP GetMusicSegmentToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SampleToggle + + Push DS + + Call I_GetSampleOffset + + Cmp DI, 2Fh + JNE SampleToggle6 + + Xor [BX+DI], DL + + Jmp SampleToggleEnd + +SampleToggle6: + Mov DH, DL + ShL DH, 1 + ShL DH, 1 + Test [BX+DI], DL + JZ SampleToggle3 + + Test [BX+DI], DH + JNZ SampleToggle3 + + Xor [BX+DI], DH + + Call Music_RegetLoopInformation + Jmp SampleToggleEnd + +SampleToggle3: + Xor [BX+DI], DL + Test [BX+DI], DL + JZ SampleToggle1 + ; Something was just toggled On. + Not DH + And [BX+DI], DH + + Cmp DL, 10h + JE SampleToggle2 + Cmp DL, 20h + JNE SampleToggle1 ; Safety Check. + ; Sustain Loop. + Mov EAX, [BX+40h] ; SusLBeg + Cmp EAX, [BX+30h] + JB SampleToggle4 + + Xor EAX, EAX + Mov [BX+40h], EAX + +SampleToggle4: + Cmp EAX, [BX+44h] + JB SampleToggle1 + + Mov EAX, [BX+30h] + Mov [BX+44h], EAX + Jmp SampleToggle1 + +SampleToggle2: ; Normal Loop + Mov EAX, [BX+34h] + Cmp EAX, [BX+30h] + JB SampleToggle5 + + Xor EAX, EAX + Mov [BX+34h], EAX + +SampleToggle5: + Cmp EAX, [BX+38h] + JB SampleToggle1 + + Mov EAX, [BX+30h] + Mov [BX+38h], EAX + +SampleToggle1: + Call Music_RegetLoopInformation + Call I_DrawWaveForm + +SampleToggleEnd: + NetworkSendSample + + Pop DS + Ret + +EndP SampleToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InstrumentToggle + + Push DS + + Call I_GetInstrumentOffset + +IF FILTERENVELOPES + Cmp DI, 1D4h + JNE InstrumentToggle2 + Cmp DL, 1 + JNE InstrumentToggle2 + + Xor Byte Ptr [BX+DI], 80h + JNS InstrumentToggle3 + + Test [BX+DI], DL + JZ InstrumentToggle2 + + And Byte Ptr [BX+DI], 7Fh + +InstrumentToggle2: +ELSE + And Byte Ptr [BX+1D4h], 7Fh +ENDIF + Xor [BX+DI], DL + +InstrumentToggle3: + Call I_MapEnvelope + + NetworkSendInstrument + + Pop DS + Ret + +EndP InstrumentToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc LoadSampleToggle + + Push DS + Push SI + Call D_GetLoadSampleVars ; Gets SI = currentsample offset + ; DS = DiskDataArea + + Mov BX, SI + Pop SI + + Mov DH, DL + ShL DH, 1 + ShL DH, 1 + Test [BX+DI], DL + JZ LoadSampleToggle3 + + Test [BX+DI], DH + JNZ LoadSampleToggle3 + + Xor [BX+DI], DH + Pop DS + Ret + +LoadSampleToggle3: + Xor [BX+DI], DL + Test [BX+DI], DL + JZ LoadSampleToggle1 + ; Something was just toggled On. + Not DH + And [BX+DI], DH + + Cmp DL, 10h + JE LoadSampleToggle2 + Cmp DL, 20h + JNE LoadSampleToggle1 ; Safety Check. + ; Sustain Loop. + Mov EAX, [BX+40h] ; SusLBeg + Cmp EAX, [BX+30h] + JB LoadSampleToggle4 + + Xor EAX, EAX + Mov [BX+40h], EAX + +LoadSampleToggle4: + Cmp EAX, [BX+44h] + JB LoadSampleToggle1 + + Mov EAX, [BX+30h] + Mov [BX+44h], EAX + Jmp LoadSampleToggle1 + +LoadSampleToggle2: ; Normal Loop + Mov EAX, [BX+34h] + Cmp EAX, [BX+30h] + JB LoadSampleToggle5 + + Xor EAX, EAX + Mov [BX+34h], EAX + +LoadSampleToggle5: + Cmp EAX, [BX+38h] + JB LoadSampleToggle1 + + Mov EAX, [BX+30h] + Mov [BX+38h], EAX + +LoadSampleToggle1: + Call D_DrawWaveForm + + Pop DS + Ret + +EndP LoadSampleToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PatternSegmentToggle + + Push DS + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Xor [DS:DI], DL + + Cmp DI, Offset MultiChannelInfo + JB PatternSegmentToggle1 + Cmp DI, Offset MultiChannelInfo+64 + JAE PatternSegmentToggle1 + + Test CX, 8000h + JNZ PatternSegmentToggle1 + + Inc Word Ptr [ES:BP] + +PatternSegmentToggle1: + Pop DS + Ret + +EndP PatternSegmentToggle + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MusicSegmentToggle + + Push DS + Call Music_GetSongSegment + Mov DS, AX + + Xor [DS:DI], DL + +IF NETWORKENABLED + Mov CX, 1 + Mov DX, DI + Call Network_SendSongDataInformation +ENDIF + + Pop DS + Ret + +EndP MusicSegmentToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseToggle Far + + Mov CX, 8010h + Mov DX, ' ' + Call AddMouseQueue + + Xor AX, AX + + Ret + +EndP MouseToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawToggle Far + + Mov [CS:MouseEventData+10], AX ; Store object number + + Call S_GetDestination + Mov BX, [SI+4] ; Segment no. + Mov DI, [SI+6] + Mov DL, [SI+8] + Add BX, BX + Call [CS:GetToggleStatus+BX] ; Returns CL with 0=off, 1=on + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX ; DI points to screen part. + + Mov AX, 200h+'O' + StosW + And CL, CL + JZ F_DrawToggle1 + + Mov AL, 'n' + StosW + Jmp F_DrawToggle2 + +F_DrawToggle1: + Mov AL, 'f' + StosW + StosW + +F_DrawToggle2: + Xor AH, AH + Mov AL, [SI+2] ; XValue + ShL AX, 3 + Mov [CS:MouseEventData+0], AX + Add AX, 23 + Mov [CS:MouseEventData+4], AX + + Xor AH, AH + Mov AL, [SI+3] + ShL AX, 3 + Mov [CS:MouseEventData+2], AX + Add AX, 7 + Mov [CS:MouseEventData+6], AX + + Push CS + Pop DS + Assume DS:Functions + + Mov SI, Offset MouseEventData + Mov [MouseEventData+8], 102h + Mov [MouseEventData+12], Offset MouseToggle + + Call MouseAddEvent + + Ret + +EndP F_DrawToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PreToggle Far + + Call S_GetDestination + Mov BX, [SI+4] ; Segment no. + Mov DI, [SI+6] + Mov DL, [SI+8] + Add BX, BX + Call [CS:GetToggleStatus+BX] ; Returns CL with 0=off, 1=on + + Xor CH, CH + Neg CL + Add CL, 3 ; CL = number to hilight + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX + + Mov AL, 30h + Call S_HiLight + + Ret + +EndP F_PreToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PostToggle Far + + Mov SI, [BX] + + Test CL, CL + JZ F_PostToggle7 + + Cmp DX, ' ' + JNE F_PostToggle1 + + Mov BP, DI + + Mov BX, [SI+4] ; Segment no. + Mov DI, [SI+6] + Mov DL, [SI+8] + Add BX, BX + Call [CS:ToggleBit+BX] + + Mov AX, 1 + Ret + +F_PostToggle1: + Cmp CX, 1C8h + JE F_PostToggle5 + Cmp CX, 1D0h + JE F_PostToggle4 + Cmp CX, 10Fh ; Tab + JE F_PostToggle3 + Cmp CX, 1CDh + JE F_PostToggle3 + Cmp DX, 0F00h + JE F_PostToggle2 + Cmp CX, 1CBh + JE F_PostToggle2 + +F_PostToggle7: + Xor AX, AX + Ret + +F_PostToggle2: + LodsW +F_PostToggle3: + LodsW +F_PostToggle4: + LodsW +F_PostToggle5: + Add SI, 9 + LodsW + Cmp AX, 0FFFFh + JE F_PostToggle7 + + Mov [DI], AX + +F_PostToggle6: + Mov AX, 1 + Ret + +EndP F_PostToggle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetInstrument3Num + + Push DS + + Call I_GetInstrumentOffset + + Mov AL, [BX+DI] + Xor AH, AH + + Pop DS + Ret + +EndP GetInstrument3Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetInstrument3Num ; AX = value. + + Push DS + Push SI + Push AX + + Mov AX, Inst + Mov DS, AX + Assume DS:Inst + + Mov CX, MaxNode + Dec CL + Assume DS:Nothing + + + Call I_GetInstrumentOffset + + Pop AX + Cmp AL, CL + JB SetInstrument3Num1 + + Mov AL, CL + +SetInstrument3Num1: + Mov [BX+DI], AL + + Mov SI, 132h + Call Near Ptr SetInstrument3Num2 + + Mov SI, 134h + Call Near Ptr SetInstrument3Num2 + + Mov SI, 184h + Call Near Ptr SetInstrument3Num2 + + Mov SI, 186h + Call Near Ptr SetInstrument3Num2 + + Mov SI, 1D6h + Call Near Ptr SetInstrument3Num2 + + Mov SI, 1D8h + Call Near Ptr SetInstrument3Num2 + + Call I_MapEnvelope + + Pop SI + Pop DS + + Ret + +SetInstrument3Num2: + Mov AL, [BX+SI] + Cmp AL, [BX+SI+1] + JBE SetInstrument3Num3 + + Mov [BX+SI+1], AL + +SetInstrument3Num3: + RetN + +EndP SetInstrument3Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSample5Num + + Push DS + + Call I_GetSampleOffset + + Mov EAX, [BX+DI] + + Pop DS + Ret + +EndP GetSample5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetLoadSample5Num + + Push DS + Push SI + Call D_GetLoadSampleVars ; Gets SI = currentsample offset + ; DS = DiskDataArea + + Mov BX, SI + Mov EAX, [BX+DI] + + Pop SI + Pop DS + + Ret + +EndP GetLoadSample5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetInst5Num + + Push DS + Mov AX, Inst + + Mov DS, AX + Mov EAX, [DI] + + Pop DS + Ret + +EndP GetInst5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetSample5Num ; AX = value. + + Push DS + Push AX + + Call I_GetSampleOffset + + Pop AX + Mov [BX+DI], EAX + + Pop DS + + NetworkSendSample + + Ret + +EndP SetSample5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetLoadSample5Num ; AX = value. + + Push DS + Push SI + + Call D_GetLoadSampleVars ; Gets SI = currentsample offset + Mov BX, SI + + Mov [BX+DI], EAX + + Pop SI + Pop DS + Ret + +EndP SetLoadSample5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetInst5Num + + Push DS + + Mov BX, Inst + Mov DS, BX + Mov [DI], EAX + + Pop DS + + Ret + +EndP SetInst5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseNumberDecrement Far + + Mov CX, 8010h + Mov DX, '-' + Call AddMouseQueue + + Xor AX, AX + + Ret + +EndP MouseNumberDecrement + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseNumberIncrement Far + + Mov CX, 8010h + Mov DX, '+' + Call AddMouseQueue + + Xor AX, AX + + Ret + +EndP MouseNumberIncrement + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Draw3Num Far + + Mov [CS:MouseEventData+10], AX ; Store object number + + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Call [CS:Get3NumValues+BX] ; AX = value. + + Push AX + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX + Call S_GetDestination + + Pop AX + Xor DX, DX + Mov CH, 2 + Call PE_ConvAX2Num + + Xor AX, AX + Mov AL, [SI+2] ; X value + ShL AX, 3 + Mov [CS:MouseEventData+0], AX + Add AX, 3*8-1 + Mov [CS:MouseEventData+4], AX + Xor AX, AX + Mov AL, [SI+3] + ShL AX, 3 + Mov [CS:MouseEventData+2], AX + Add AX, 7 + Mov [CS:MouseEventData+6], AX + + Push CS + Pop DS + + Mov SI, Offset MouseEventData + Mov Word Ptr [SI+8], 102h + Mov Word Ptr [SI+12], Offset MouseNumberDecrement + Call MouseAddEvent + Mov Word Ptr [SI+8], 110h + Mov Word Ptr [SI+12], Offset MouseNumberIncrement + Call MouseAddEvent + + Ret + +EndP F_Draw3Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Pre3Num Far + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Mov DI, AX + Add DI, CS:TripleNumberPos + Add DI, DI + + Mov CX, 1 + Mov AL, 30h + Call S_HiLight + + Ret + +EndP F_Pre3Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Post3Num Far + + Mov SI, [BX] + Test CL, CL + JZ F_Post3Num7 + + Cmp DX, 8 + JE F_Post3Num16 + Cmp CX, 1CBh ; Left + JNE F_Post3Num1 + +F_Post3Num16: + Mov AX, CS:TripleNumberPos + Dec AX + JS F_Post3Num2 + +F_Post3Num5: + Mov CS:TripleNumberPos, AX + +F_Post3Num2: + Mov AX, 1 + Ret + +F_Post3Num1: + Cmp CX, 1CDh ; Right + JNE F_Post3Num3 + +F_Post3Num4: + Mov AX, CS:TripleNumberPos + Inc AX + Cmp AX, 2 + JA F_Post3Num2 + Jmp F_Post3Num5 + +F_Post3Num3: + Cmp CX, 1C8h ; Up + JE F_Post3Num14 + Cmp CX, 1D0h ; Down + JE F_Post3Num13 + Cmp CX, 10Fh + JE F_Post3Num12 + Cmp DX, 0F00h + JNE F_Post3Num6 + + LodsW +F_Post3Num12: + LodsW +F_Post3Num13: + LodsW +F_Post3Num14: + Add SI, 12 + LodsW + Cmp AX, 0FFFFh + JE F_Post3Num7 + + Mov [DI], AX + +F_Post3Num15: + Mov AX, 1 + Ret + +F_Post3Num18: + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Push BX + Call [CS:Get3NumValues+BX] ; AX = value. + Pop BX + Add AX, 1 + JC F_Post3Num15 + Call [CS:Set3NumValues+BX] ; AX = value. + Call Near Ptr F_Post3Num20 + Jmp F_Post3Num15 + +F_Post3Num19: + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Push BX + Call [CS:Get3NumValues+BX] ; AX = value. + Pop BX + Sub AX, 1 + JC F_Post3Num15 + Call [CS:Set3NumValues+BX] ; AX = value. + Call Near Ptr F_Post3Num20 + Jmp F_Post3Num15 + +F_Post3Num6: + Cmp DX, '+' + JE F_Post3Num18 + Cmp DX, '-' + JE F_Post3Num19 + + Cmp DX, '0' + JL F_Post3Num7 + Cmp DX, '9' + JLE F_Post3Num8 + +F_Post3Num7: + Xor AX, AX + Ret + +F_Post3Num8: ; OK... a number was inputted. + Push DX + + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Call [CS:Get3NumValues+BX] ; AX = value. + + Mov CX, 3 + Mov BX, 10 + Mov DI, Offset NumberStorage+6 + +F_Post3Num9: + Xor DX, DX + Div BX + Sub DI, 2 + Mov [CS:DI], DX + Loop F_Post3Num9 + + Mov BX, CS:TripleNumberPos + Add BX, BX + + Pop DX + Sub DX, '0' + Mov [CS:DI+BX], DX + + Xor AX, AX + Mov BX, 10 + Mov CX, 3 + Xor DX, DX + +F_Post3Num10: + Mul BX + Add AX, [CS:DI] + AdC DX, 0 + ScasW +; Add DI, 2 + Loop F_Post3Num10 + + And DX, DX + JZ F_Post3Num11 + + Mov AX, 0FFFFh + +F_Post3Num11: + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Call [CS:Set3NumValues+BX] ; AX = value. + Call Near Ptr F_Post3Num20 + Jmp F_Post3Num4 + +F_Post3Num20: + Cmp Word Ptr [SI+8], 0 + JNZ F_Post3Num17 + + Cmp Word Ptr [SI+10], 0 + JZ F_Post3Num21 + +F_Post3Num17: + Call DWord Ptr [SI+8] + +F_Post3Num21: + RetN + + +EndP F_Post3Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ConvEAX2Num Far + + Push EAX ; CH = colour + Push EBX ; DX:AX = number + Push CX + Push EDX + + Mov EBX, 10 + Mov CL, 7 + +F_ConvEAX2Num1: + Xor EDX, EDX + Div EBX + Push DX + Dec CL + JNZ F_ConvEAX2Num1 + + Mov CL, 7 + +F_ConvEAX2Num2: + Pop AX + Add AL, '0' + Mov AH, CH + StosW + + Dec CL + JNZ F_ConvEAX2Num2 + + Pop EDX + Pop CX + Pop EBX + Pop EAX + + Ret + +EndP F_ConvEAX2Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Draw5Num Far + + Mov [CS:MouseEventData+10], AX + + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Call [CS:Get5NumValues+BX] ; AX = value. + + Push AX + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX + Call S_GetDestination + + Pop AX + Xor DX, DX + Mov CH, 2 + Call F_ConvEAX2Num + + Xor AX, AX + Mov AL, [SI+2] ; X value + ShL AX, 3 + Mov [CS:MouseEventData+0], AX + Add AX, 7*8-1 + Mov [CS:MouseEventData+4], AX + Xor AX, AX + Mov AL, [SI+3] + ShL AX, 3 + Mov [CS:MouseEventData+2], AX + Add AX, 7 + Mov [CS:MouseEventData+6], AX + + Push CS + Pop DS + + Mov SI, Offset MouseEventData + Mov Word Ptr [SI+8], 102h + Mov Word Ptr [SI+12], Offset MouseNumberDecrement + Call MouseAddEvent + Mov Word Ptr [SI+8], 110h + Mov Word Ptr [SI+12], Offset MouseNumberIncrement + Call MouseAddEvent + + Ret + +EndP F_Draw5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Pre5Num Far + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Mov DI, AX + Add DI, CS:NumberPos + Add DI, DI + + Mov CX, 1 + Mov AL, 30h + Call S_HiLight + + Ret + +EndP F_Pre5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Post5Num Far + + Mov SI, [BX] + Test CL, CL + JZ F_Post5Num7 + + Cmp DX, 8 + JE F_Post5Num16 + Cmp CX, 1CBh ; Left + JNE F_Post5Num1 + +F_Post5Num16: + Mov AX, CS:NumberPos + Dec AX + JS F_Post5Num2 + +F_Post5Num5: + Mov CS:NumberPos, AX + +F_Post5Num2: + Mov AX, 1 + Ret + +F_Post5Num1: + Cmp CX, 1CDh ; Right + JNE F_Post5Num3 + +F_Post5Num4: + Mov AX, CS:NumberPos + Inc AX + Cmp AX, 6 + JA F_Post5Num2 + Jmp F_Post5Num5 + +F_Post5Num3: + Cmp CX, 1C8h ; Up + JE F_Post5Num14 + Cmp CX, 1D0h ; Down + JE F_Post5Num13 + Cmp CX, 10Fh + JE F_Post5Num12 + Cmp DX, 0F00h + JNE F_Post5Num6 + + LodsW +F_Post5Num12: + LodsW +F_Post5Num13: + LodsW +F_Post5Num14: + Add SI, 12 + LodsW + Cmp AX, 0FFFFh + JE F_Post5Num7 + + Mov [DI], AX + +F_Post5Num15: + Mov AX, 1 + Ret + +F_Post5Num18: + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Push BX + Call [CS:Get5NumValues+BX] ; AX = value. + Pop BX + Inc EAX + Call [CS:Set5NumValues+BX] ; AX = value. + Call Near Ptr F_Post5Num20 + Jmp F_Post5Num15 + +F_Post5Num19: + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Push BX + Call [CS:Get5NumValues+BX] ; AX = value. + Pop BX + Sub EAX, 1 + JC F_Post5Num15 + Call [CS:Set5NumValues+BX] ; AX = value. + Call Near Ptr F_Post5Num20 + Jmp F_Post5Num15 + +F_Post5Num6: + Cmp DX, '+' + JE F_Post5Num18 + Cmp DX, '-' + JE F_Post5Num19 + + Cmp DX, '0' + JL F_Post5Num7 + Cmp DX, '9' + JLE F_Post5Num8 + +F_Post5Num7: + Xor AX, AX + Ret + +F_Post5Num8: ; OK... a number was inputted. + Push DX + + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Call [CS:Get5NumValues+BX] ; EAX = value. + + Mov CX, 7 + Mov EBX, 10 + Mov DI, Offset NumberStorage+14 + +F_Post5Num9: + Xor EDX, EDX + Div EBX + Sub DI, 2 + Mov [CS:DI], DX + Loop F_Post5Num9 + + Mov BX, CS:NumberPos + Add BX, BX + + Pop DX + Sub DX, '0' + Mov [CS:DI+BX], DX + + Xor EAX, EAX + Mov BX, 10 + Mov CX, 7 + +F_Post5Num10: + IMul EAX, 10 + MovZX EBX, Word Ptr [CS:DI] + Add EAX, EBX + +; Add DI, 2 + ScasW + Loop F_Post5Num10 + +F_Post5Num11: + Mov BX, [SI+4] + Add BX, BX + Mov DI, [SI+6] + + Call [CS:Set5NumValues+BX] ; AX = value. + Call Near Ptr F_Post5Num20 + Jmp F_Post5Num4 + +F_Post5Num20: + Cmp Word Ptr [SI+8], 0 + JNZ F_Post5Num17 + + Cmp Word Ptr [SI+10], 0 + JZ F_Post5Num21 + +F_Post5Num17: + Call DWord Ptr [SI+8] + +F_Post5Num21: + RetN + +EndP F_Post5Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawHeader Far + +; Call MouseClearEvents + + Call Music_GetSongSegment + Mov DS, AX + Mov DL, [DS:2Ch] + + Push CS + Pop DS + + Call E_GetFreeEMS + Push AX + + Mov AH, 48h + Mov BX, 0FFFFh + Int 21h + ShR BX, 6 + Push BX + + Mov AH, 20h + Mov SI, Offset HeaderMsg1 + Mov DI, ((1*80)+2)*2 + Call S_DrawString + + Mov SI, Offset HeaderMsg2 + Call Glbl_GetHeaderMode + And AH, AH + JNZ F_DrawHeader1 + + Mov SI, Offset HeaderMsg3 + +F_DrawHeader1: + Mov AH, 20h + Call S_DrawString + + Mov SI, Offset HeaderMsg4 + Mov DI, ((4*80)+2)*2 + Call S_DrawString + + Add SP, 4 + + Call Music_GetFreeSoundCardMemory + ; Returns DS:SI, Carry set if nothing to show + JC F_DrawHeader2 ; and AX = value to print. + + Push BX + Push AX + + Mov AH, 20h + Mov DI, (63+8*80)*2 + Call S_DrawString + + Pop AX + Pop BX + +F_DrawHeader2: + Ret + +EndP F_DrawHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawSMCChannels Far + +; Call MouseClearEvents + + Push CS + Pop DS + + Xor CX, CX + +F_DrawSMCChannels1: + Mov AL, CL + Inc AX + Xor AH, AH + Mov BH, 10 + Div BH + Add AX, 3030h + Mov Word Ptr ChannelNumbers, AX + + Mov BX, CX + And BX, 0Fh + Mov AX, 160 ; Calculate DI (offset on screen) + Mul BX + Mov DI, AX + Add DI, (22*80+9)*2 + Mov BX, CX + And BX, 00F0h + ShL BX, 1 + Add DI, BX + + Mov SI, Offset ChannelMsg + Mov AH, 20h + Call S_DrawString + + Inc CX + Cmp CX, 64 + JB F_DrawSMCChannels1 + + Ret + +EndP F_DrawSMCChannels + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ConfigButtonSetup Far + + Call Music_GetSongSegment + Mov DS, AX ; OK... now check for + ; control mode first. + Mov CL, [DS:2Ch] ; CL = Flags. + Add DI, 50 ; ES:DI points to inst button + + Mov BX, [ES:DI] ; ES:BX points to inst button data +; Add DI, 2 + ScasW + Xor CH, CH + Test CL, 4 + JZ F_ConfigButtonSetup1 + + Inc CH + +F_ConfigButtonSetup1: + Mov [ES:BX+33], CH ; Instrument button + + Xor CH, 1 + Mov BX, [ES:DI] +; Add DI, 2 + ScasW + Mov [ES:BX+33], CH ; Sample button + + Mov BX, [ES:DI] +; Add DI, 2 + ScasW + Xor CH, CH + Test CL, 1 + JZ F_ConfigButtonSetup2 + + Inc CH + +F_ConfigButtonSetup2: + Mov [ES:BX+33], CH ; Stereo button + + Xor CH, 1 + Mov BX, [ES:DI] +; Add DI, 2 + ScasW + Mov [ES:BX+33], CH ; Mono button + + Mov BX, [ES:DI] +; Add DI, 2 + ScasW + Xor CH, CH + Test CL, 8 ; Slides... + JZ F_ConfigButtonSetup3 + + Inc CH + +F_ConfigButtonSetup3: + Mov [ES:BX+33], CH + + Xor CH, 1 + Mov BX, [ES:DI] +; Add DI, 2 ; Compression reasons + ScasW + Mov [ES:BX+33], CH + + Ret + +EndP F_ConfigButtonSetup + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF NETWORKENABLED +Proc F_SendSongFlags + + Push CX + Push DX + + Mov CX, 1 + Mov DX, 2Ch + Call Network_SendSongDataInformation + + Pop DX + Pop CX + + Ret + +EndP F_SendSongFlags + +SendSongFlags EQU Call F_SendSongFlags + +ELSE + +SendSongFlags EQU ; + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SetControlSample Far + + Call Music_GetSongSegment + Mov DS, AX + + And Byte Ptr [DS:2Ch], NOT 4 + + SendSongFlags + + Ret + +EndP F_SetControlSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SetControlInstrument Far + + Call Music_GetSongSegment + Mov DS, AX + + Or Byte Ptr [DS:2Ch], 4 + + Push DS + + Mov DI, Offset O1_InitialiseInstrumentList + Mov CX, 3 + Call M_Object1List + ; DX = 0 -> don't initialise + ; DX = 1 -> initialise + Pop DS ; DS = SongDataSegment + + SendSongFlags + + Test DX, DX + JZ F_SetControlInstrument3 + + Call Music_ClearAllInstruments + + ; OK.. for samples 1..99 + ; check if sample exists. + ; if so, copy name&set all + ; notes of instrument. + Push DS + Pop ES ; ES = SongDataSegment + + Xor DX, DX + +F_SetControlInstrument1: + Mov BX, DX + Add BX, BX + Mov SI, [DS:BX+64912] ; SI points to sample + Mov DI, [DS:BX+64712] ; DI points to instrument + + Test Byte Ptr [DS:SI+12h], 1 + JZ F_SetControlInstrument2 + ; No sample there! + + ; Copy name + Mov CX, 26 + Add SI, 14h + Add DI, 20h + Rep MovsB + Add DI, 7 + + Mov AL, DL ; DL = sample number + Inc AX + Mov CX, 120 + +F_SetControlInstrument4: + StosB + Inc DI + Loop F_SetControlInstrument4 + +F_SetControlInstrument2: +IF NETWORKENABLED + Call Network_GetSendQueue + JZ F_SetControlInstrument5 + + Mov AX, 400h + StosW + Mov AX, DX + StosB + +F_SetControlInstrument5: + Call Network_FinishedSendQueue +ENDIF + Inc DX + Cmp DX, 99 + JBE F_SetControlInstrument1 + +F_SetControlInstrument3: + + Ret + +EndP F_SetControlInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SetStereo Far + + Call Music_GetSongSegment + Mov DS, AX + + Or Byte Ptr [DS:2Ch], 1 + + Call Music_InitStereo + + SendSongFlags + + Ret + +EndP F_SetStereo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SetMono Far + + Call Music_GetSongSegment + Mov DS, AX + + And Byte Ptr [DS:2Ch], NOT 1 + + Call Music_InitStereo + + SendSongFlags + + Ret + +EndP F_SetMono + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SetLinear Far + + Call Music_GetSongSegment + Mov DS, AX + + Or Byte Ptr [DS:2Ch], 8 + + SendSongFlags + + Ret + +EndP F_SetLinear + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SetAmiga Far + + Call Music_GetSongSegment + Mov DS, AX + + And Byte Ptr [DS:2Ch], NOT 8 + + SendSongFlags + + Ret + +EndP F_SetAmiga + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Reset5NumInputPos Far + + Mov CS:NumberPos, 0 + Ret + +EndP F_Reset5NumInputPos + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_NewSong Far + + EnsureNoNetwork + + Mov DI, Offset O1_NewSongList + Mov CX, 11 ; OK Button.. + Call M_Object1List + And DX, DX + JZ F_NewSongEnd + + Call Music_Stop + + Cmp Word Ptr [CS:ButtonVariables+8], 0 + JE F_NewSong2 + + Call Music_ReleaseAllSamples + Call Music_ClearAllSampleNames + +F_NewSong2: + Cmp Word Ptr [CS:ButtonVariables+10], 0 + JE F_NewSong3 + + Call Music_ClearAllInstruments + +F_NewSong3: + Cmp Word Ptr [CS:ButtonVariables+12], 0 + JE F_NewSong1 + + Call D_ClearFileName + Call D_ResetTimer + + Call Music_GetSongSegment + Mov ES, AX + + Mov DI, 4 ; Clear song name + Mov CX, 13 + Xor AX, AX + Rep StosW + + Mov DI, 3Ch ; Clear Time + Xor AX, AX + StosW + StosW + + Mov CX, 64 + Mov AL, 32 + Rep StosB + + Mov CX, 64 ; Channel volume + Mov AL, 64 + Rep StosB + + Mov DI, 100h ; Orders. + Mov AL, 0FFh + Mov CX, 256 + Rep StosB + + Call Music_InitMuteTable + Call Msg_ResetMessage + +F_NewSong1: + Cmp Word Ptr [CS:ButtonVariables+6], 0 + JE F_NewSongEnd + ; Clear patterns. + Call D_ClearFileName + Call D_ResetTimer + Call Music_ReleaseAllPatterns + Call PE_ResetOrderPattern + +F_NewSongEnd: + Mov AX, 1 + Ret + +EndP F_NewSong + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_MainMenu Far + + Call S_SaveScreen + + Mov CX, 0FFFFh + Mov DI, Offset O1_MainMenu + Call M_Object1List + + Call S_RestoreScreen + + Mov AX, 1 + Ret + +EndP F_MainMenu + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ViewPattern Far + + Call MouseRestoreEvents + Add SP, 20 + Jmp Glbl_F2_2 + +EndP F_ViewPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ViewVariables Far + + Call MouseRestoreEvents + Add SP, 20 + Jmp Glbl_F12 + +EndP F_ViewVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ViewOrderPan Far + + Call MouseRestoreEvents + Add SP, 20 + Jmp Glbl_F11_2 + +EndP F_ViewOrderPan + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_MessageEditor Far + + Call MouseRestoreEvents + Add SP, 20 + Jmp Glbl_Shift_F9 + +EndP F_MessageEditor + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Help Far + + Call S_RestoreScreen + Call MouseRestoreEvents + Add SP, 20 + Jmp H_Help + +EndP F_Help + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PlaybackMenu Far + + Mov CX, 0FFFFh + Mov DI, Offset O1_PlaybackMenu + Call M_Object1List + + Call S_RestoreScreen + Mov AX, 1 + Ret + +EndP F_PlaybackMenu + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_InfoPage Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + + Add SP, 48 + Jmp Glbl_F5 + +EndP F_InfoPage + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PlaySong Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_Ctrl_F5 + +EndP F_PlaySong + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PlayPattern Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_F6 + +EndP F_PlayPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PlayOrder Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_Shift_F6 + +EndP F_PlayOrder + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PlayMark Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp PE_F7 + +EndP F_PlayMark + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_Stop Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Music_Stop + +EndP F_Stop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ReinitSoundCard Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Music_ReinitSoundCard + +EndP F_ReinitSoundCard + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_CalculateLength Far + + Call S_RestoreScreen + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Music_TimeSong + +EndP F_CalculateLEngth + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DriverScreen Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_DriverScreen + +EndP F_DriverScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SampleMenu Far + + Mov CX, 0FFFFh + Mov DI, Offset O1_SampleMenu + Call M_Object1List + + Call S_RestoreScreen + Mov AX, 1 + Ret + +EndP F_SampleMenu + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_InstrumentMenu Far + + Mov CX, 0FFFFh + Mov DI, Offset O1_InstrumentMenu + Call M_Object1List + + Call S_RestoreScreen + Mov AX, 1 + Ret + +EndP F_InstrumentMenu + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SampleList Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_F3 + +EndP F_SampleList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_InstrumentList Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_F4 + +EndP F_InstrumentList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_InstrumentLibrary Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_Ctrl_F4 + +EndP F_InstrumentLibrary + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ReloadGravis Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Music_SoundCardLoadAllSamples + +EndP F_ReloadGravis + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_SampleLibrary Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_Ctrl_F3 + +EndP F_SampleLibrary + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_FileMenu Far + + Mov CX, 0FFFFh + Mov DI, Offset O1_FileMenu + Call M_Object1List + + Call S_RestoreScreen + Mov AX, 1 + Ret + +EndP F_FileMenu + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_FileLoad Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_F9 + +EndP F_FileLoad + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_FileNew Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Call S_RestoreScreen + Add SP, 48 + Jmp F_NewSong + +EndP F_FileNew + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_FileSaveCurrent Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Call S_RestoreScreen + Add SP, 48 + Jmp D_SaveSong + +EndP F_FileSaveCurrent + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_FileSaveAs Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Add SP, 48 + Jmp Glbl_F10 + +EndP F_FileSaveAs + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_FileDOSShell Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Call S_RestoreScreen + Add SP, 48 + Jmp DOSShell + +EndP F_FileDOSShell + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_FileQuit Far + + Call MouseRestoreEvents + Call MouseRestoreEvents + Call S_RestoreScreen + Add SP, 48 + Jmp Quit + +EndP F_FileQuit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF MEMORYDEBUG + +DebugOffset DW 0 +DebugSegment DW 0 + +AddressInput DB 0 + DB 19 Dup (0) +SegmentMsg DB "Segment: ", 0FDh, 'Xh', 0 + +DebugSegmentNames DB 10, "STARTUP", 0 + DW Startup + + DB 11, "KEYBOARD", 0 + DW Keyboard + + DB 10, "PATTERN", 0 + DW Pattern + + DB 7, "DISK", 0 + DW Disk + + DB 6, "EMS", 0 + DW EMS + + DB 8, "ERROR", 0 + DW Error + + DB 7, "INST", 0 + DW Inst + + DB 12, "FUNCTIONS", 0 + DW Functions + + DB 9, "GLOBAL", 0 + DW Glbl + + DB 7, "HELP", 0 + DW Help + + DB 11, "INFOLINE", 0 + DW InfoLine + + DB 7, "MAIN", 0 + DW Main + + DB 8, "MUSIC", 0 + DW Music + + DB 9, "SCREEN", 0 + DW Screen + + DB 10, "OBJECT1", 0 + DW Object1 + + DB 11, "INFOPAGE", 0 + DW InfoPage + + DB 11, "SONGDATA", 0 +DebugSongDataSegment DW 0 + + DB 11, "DISKDATA", 0 +DebugDiskDataSegment DW 0 + + DB 14, "PATTERNDATA", 0 +DebugPatternDataSegment DW 0 + + DB 0FFh ; End of list. + +DebugMsg DB "CX: ", 0FDh, "X, DX: ", 0FDh, "X ", 0 +DebugCX DW 0 +DebugDX DW 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DrawDebug Far + + Push CS + Pop DS + Assume DS:Functions + + Call S_GetDestination + Mov SI, Offset SegmentMsg + Mov DI, (4+13*80)*2 + + Push DebugSegment +; Mov AX, DebugSegment +; Push AX + Mov AH, 21h + Call S_DrawString ; OK segment done + Pop AX ; Clear stack. + + ; Put offsets on screen. + ; Work out digits. + Mov CX, 1E04h + Mov DI, (3+15*80)*2 + Mov DX, DebugOffset + Xor BH, BH + Mov AH, 2 + +F_DrawDebug1: + Push DI + + Mov BL, DH + ShR BL, CL + Mov AL, [HexNumbers+BX] ; Blah.. how inefficient + StosW + Mov BL, DH + And BL, 0Fh + Mov AL, [HexNumbers+BX] + StosW + Mov BL, DL + ShR BL, CL + Mov AL, [HexNumbers+BX] + StosW + Mov BL, DL + And BL, 0Fh + Mov AL, [HexNumbers+BX] + StosW ; Offset is on screen. + + Mov AL, ':' + StosW + + Pop DI + Add DI, 160 + Add DX, 16 + Dec CH + JNZ F_DrawDebug1 + + ; Now to shove debug stuff. + Mov SI, DebugOffset + Mov DS, DebugSegment + Assume DS:Nothing + Mov DI, (10+15*80)*2 + + Mov DX, 30 + +F_DrawDebug2: + Push DI + Push SI + + Mov CX, 1004h + +F_DrawDebug3: + Cmp CH, 8 + JNE F_DrawDebug4 + + Mov AL, '-' + StosW + Xor AL, AL + StosW + +F_DrawDebug4: + LodsB ; Number. + Mov BL, AL + ShR BL, CL + Mov BL, [CS:HexNumbers+BX] + XChg AL, BL + And BL, 0Fh + StosW + Mov AL, [CS:HexNumbers+BX] + StosW + + Xor AL, AL + StosW + + Dec CH ; Hex number loop + JNZ F_DrawDebug3 + + StosW + + Pop SI + Mov CX, 16 + +F_DrawDebug5: + LodsB + StosW + Loop F_DrawDebug5 + + Pop DI + Add DI, 160 ; Next line. + + Dec DX ; line loop. + JNZ F_DrawDebug2 + + Push CS + Pop DS + + Push DebugDX + Push DebugCX + + Mov SI, Offset DebugMsg + Mov AH, 20h + Mov DI, (40+47*80)*2 + Call S_DrawString + Pop AX + Pop AX + + Mov AX, 1 + Ret + +EndP F_DrawDebug + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_PostDebug Far + + Mov CS:DebugCX, CX + Mov CS:DebugDX, DX + + Xor AX, AX + Ret + +EndP F_PostDebug + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DebugUp Far + + Sub CS:DebugOffset, 16 + + Mov AX, 1 + Ret + +EndP F_DebugUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DebugDown Far + + Add CS:DebugOffset, 16 + + Mov AX, 1 + Ret + +EndP F_DebugDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DebugPgUp Far + + Sub CS:DebugOffset, 16*30 + + Mov AX, 1 + Ret + +EndP F_DebugPgUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DebugPgDn Far + + Add CS:DebugOffset, 16*30 + + Mov AX, 1 + Ret + +EndP F_DebugPgDn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_DebugStringInput Far + + Mov AX, Disk + Mov DS, AX + Assume DS:Disk + Mov DX, DiskDataArea + + Xor BP, BP ; BP = ':' count. + + Mov AX, Music + Mov DS, AX + Assume DS:Music + Mov BX, SongDataArea + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + Mov SI, PatternDataArea + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Functions ; ES = functions also. + + Mov DebugSongDataSegment, BX + Mov DebugDiskDataSegment, DX + Mov DebugPatternDataSegment, SI + + Mov SI, Offset DebugSegmentNames + Xor BX, BX + +F_DebugStringInput1: + Mov DI, Offset AddressInput + LodsB + Cmp AL, 0FFh + JE F_DebugStringInput2 + + Mov BL, AL + Push SI + ; OK.. compare in here.. +F_DebugStringInput4: + LodsB + Mov AH, [DI] + + And AL, AL + JZ F_DebugStringInput3 + + And AH, AH + JZ F_DebugStringInput6 + + Cmp AH, 'a' + JB F_DebugStringInput6 + Cmp AH, 'z' + JA F_DebugStringInput6 + + Add AH, 'A'-'a' + +F_DebugStringInput6: + Inc DI + Cmp AH, AL + JE F_DebugStringInput4 + + +F_DebugStringInput5: + Pop SI + Add SI, BX + Jmp F_DebugStringInput1 + + +F_DebugStringInput3: + And AH, AH + JNZ F_DebugStringInput6 + + LodsW + Pop SI + Mov DebugSegment, AX + Mov DebugOffset, 0 + + Mov AX, 1 + Ret + +F_DebugStringInput2: ; We have a hex address(?) + Mov SI, Offset AddressInput + Cmp Byte Ptr [SI], 0 + JE F_DebugStringInput15 + +F_DebugStringInput7: + LodsB + And AL, AL + JZ F_DebugStringInput10 + + Cmp AL, '0' + JB F_DebugStringInput8 + Cmp AL, '9' + JBE F_DebugStringInput7 + +F_DebugStringInput8: + Cmp AL, 'A' + JB F_DebugStringInput9 + Cmp AL, 'F' + JBE F_DebugStringInput7 + + +F_DebugStringInput9: + Cmp AL, 'a' + JB F_DebugStringInput16 + Cmp AL, 'f' + JBE F_DebugStringInput7 + +F_DebugStringInput16: + Cmp AL, ':' + JE F_DebugStringInput7 + +F_DebugStringInput15: + Xor AX, AX + Ret + +F_DebugStringInput10: ; Hex address + Mov BX, DebugSegment + Mov CL, 4 + Xor DX, DX ; BX:DX contains address + + Xor AX, AX + Mov SI, Offset AddressInput + +F_DebugStringInput11: + LodsB + And AL, AL + JZ F_DebugStringInput12 + + Cmp AL, ':' + JE F_DebugStringInput13 + + Sub AL, '0' + Cmp AL, 9 + JBE F_DebugStringInput14 + + Sub AL, '@'-'9' + Cmp AL, 15 + JBE F_DebugStringInput14 + + Sub AL, 32 + +F_DebugStringInput14: + ShL DX, CL + Add DX, AX + + Jmp F_DebugStringInput11 + +F_DebugStringInput13: + Inc BP + Cmp BP, 2 + JAE F_DebugStringInput17 + + Mov BX, DX + Xor DX, DX + Jmp F_DebugStringInput11 + +F_DebugStringInput17: + Mov DebugSegment, BX + Mov DebugOffset, DX + Xor DX, DX + Jmp F_DebugStringInput11 + +F_DebugStringInput12: + Cmp BP, 2 + JB F_DebugStringInput18 + + LDS SI, DWord Ptr [DebugOffset] + Mov [SI], DL + Jmp F_DebugStringInput19 + +F_DebugStringInput18: + Mov DebugSegment, BX + Mov DebugOffset, DX + +F_DebugStringInput19: + Mov AX, 1 + Ret + +EndP F_DebugStringInput + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_ShowMIDIZxxInput Far + + Push CS + Pop DS + Assume DS:Functions + + Mov SI, Offset ZxxString + Mov AX, TopMIDIMacro + Add AX, 6 + Mov CX, 7 + +F_ShowMIDIZxxInput1: + Push AX + Dec AX + Loop F_ShowMIDIZxxInput1 + + Mov CX, 7 + Mov DI, (13+42*80)*2 + +F_ShowMIDIZxxInput2: + Mov AH, 20h + Call S_DrawString + Pop AX + Add DI, (80-3)*2 + Loop F_ShowMIDIZxxInput2 + + Ret + +EndP F_ShowMIDIZxxInput + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_MIDI_Up Far + + Cmp CS:TopMIDIMacro, 80h + JBE F_MIDI_Up1 + + Dec CS:TOPMIDIMacro + Jmp F_MIDI_Up2 + +F_MIDI_Up1: + Mov Word Ptr [ES:DI], 33 + +F_MIDI_Up2: + Mov AX, 1 + Ret + +EndP F_MIDI_Up + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_MIDI_Down Far + + Cmp CS:TopMIDIMacro, 0F9h + JAE F_MIDI_Down1 + + Inc CS:TOPMIDIMacro + +F_MIDI_Down1: + Mov AX, 1 + Ret + +EndP F_MIDI_Down + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_MIDI_PgUp Far + + Cmp Word Ptr [ES:DI], 33 + JBE F_MIDI_PgUp1 + + Sub Byte Ptr [CS:TopMIDIMacro], 7 + JS F_MIDI_PgUp1 + + Mov Byte Ptr [CS:TopMIDIMacro], 80h + +F_MIDI_PgUp1: + Mov AX, 1 + Ret + +EndP F_MIDI_PgUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc F_MIDI_PgDn Far + + Cmp Word Ptr [ES:DI], 33 + JBE F_MIDI_PgDn1 + + Add [CS:TopMIDIMacro], 7 + Cmp [CS:TopMIDIMacro], 0F9h + JB F_MIDI_PgDn1 + + Mov [CS:TopMIDIMacro], 0F9h + +F_MIDI_PgDn1: + Mov AX, 1 + Ret + +EndP F_MIDI_PgDn + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_FOUR.ASM b/it_four.s similarity index 95% rename from IT_FOUR.ASM rename to it_four.s index 8f9058a..f45d272 100644 --- a/IT_FOUR.ASM +++ b/it_four.s @@ -1,612 +1,612 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Fast Fourier Transform Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386P - .387 - -include switch.inc - -IF SPECTRUMANALYSER - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Object1 BYTE Public 'Data' -EndS -Segment DiskData PARA Public 'Data' -EndS - - Extrn O1_FourierDisplay:Far - - Extrn M_Object1List:Far - - Extrn Music_GetWaveForm:Far - - Extrn S_InitScreen:Far - Extrn S_SetDirectMode:Far - - Global MouseUpdateEnable:Far, MouseUpdateDisable:Far - Extrn VESA_Detect:Far - Extrn VESA_SetMode:Far - Extrn VESA_SetBlock:Far - Extrn InitMouse:Far, UnInitMouse:Far - Extrn S_DefineSmallNumbers:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - - -Segment Infopage BYTE Public 'Code' USE16 - Assume CS:Infopage, DS:Nothing, ES:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Fourier_CreateTable Far ; Fills in ES:16384 -Public Fourier_CreateTable - - Mov DI, 20480 - Xor CX, CX - -Fourier_CreateTable1: - Mov DX, 11 - - Xor AX, AX - Mov BX, CX - -Fourier_CreateTable2: - ShR BX, 1 - AdC AX, AX - - Dec DX - JNZ Fourier_CreateTable2 - - ShL AX, 3 - StosW - - Inc CX - Cmp CX, 2048 - JB Fourier_CreateTable1 - - Ret - -EndP Fourier_CreateTable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Const1_2048 DD 3C000000h -ConstHalf DD 3F000000h -Steps DW 0 -CurrentOffset DW 0 - -Proc Fourier_Transform Far -Public Fourier_Transform - ; Given DS:16384->DS:20480 = 2048 16-bit signed int samples - ; Given DS:20480->24576 = relocation table - ; Given DS:0->DS:16384 = working area - - ; Returns: DS:24576 -> 16-bit table of frequencies. (first 1024) - - Push DiskData - Pop DS - - Push DS - Pop ES - - Mov CX, 2048 ; Prepare 2048 samples - Mov SI, 16384 - Xor EDX, EDX - -Fourier_TransformRelocate1: - FILd Word Ptr [SI] - Mov DI, [SI+4096] - LodsW ; Add SI, 2 - Mov [DI+4], EDX - FStP DWord Ptr [DI] - Dec CX - JNZ Fourier_TransformRelocate1 - -; Samples relocated - now for transform - Mov CX, 1 - -Fourier_Transform1: - Mov [DS:24576], CX ; Store count - - FLdZ - FLd1 ; CurrentPhase.r, CurrentPhase.i - - FLdPi - FChs - FIDiv Word Ptr [DS:24576] ; -Pi/Step - FSinCos ; deltaphase.r, deltaphase.i, currentphase.r, currentphase.i - - Xor DX, DX - -Fourier_Transform2: - Mov SI, DX ; SI = k - Mov DI, CX ; DI = k+i - Mov BX, CX ; BX = i*2 - Add DI, DX - ShL SI, 3 ; SI = k*8 - ShL DI, 3 ; DI = (k+i)*8 - ShL BX, 4 ; BX = i*8*2 - -Fourier_Transform3: - FLd DWord Ptr [DI] - FMul ST, ST(3) ; cr*sr - FLd DWord Ptr [DI+4] - FMul ST, ST(4) ; cr*si, cr*sr, dr, di, cr, ci - FLd DWord Ptr [DI] - FMul ST, ST(6) - FLd DWord Ptr [DI+4] - FMul ST, ST(7) ; ci*si, ci*sr, cr*si, cr*sr, dr, di, cr, ci - FXCh - FAddP ST(2), ST - FSubP ST(2), ST ; tempi, tempr, dr, di, cr, ci - FLd DWord Ptr [SI+4] ; ri, tempi, tempr, dr, di, cr, ci - FAdd ST, ST(1) - FLd DWord Ptr [SI] - FAdd ST, ST(3) ; rr, ri, tempi, tempr, dr, di, cr, ci - FXCh ST(3) ; tempr, ri, tempi, rr, dr, di, cr, ci - FSubR DWord Ptr [SI] ; kr, ri, tempi, rr, dr, di, cr, ci - FXCh ST(2) - FSubR DWord Ptr [SI+4] ; ki, ri, kr, rr, dr, di, cr, ci - FXCh ST(3) ; rr, ri, kr, ki, dr, di, cr, ci - FStP DWord Ptr [SI] - FStP DWord Ptr [SI+4] - FStP DWord Ptr [DI] - FStP DWord Ptr [DI+4] - - Add SI, BX - Add DI, BX - - Cmp SI, 16384 - JB Fourier_Transform3 - -; Left with deltaphase.r, deltaphase.i, currentphase.r, currentphase.i - FLd ST ; d.r, d.r, d.i, c.r, c.i - FMul ST, ST(3) ; d.r*c.r, d.r, d.i, c.r, c.i - FXCh ST(3) ; c.r, d.r, d.i, d.r*c.r, c.i - FMul ST, ST(2) ; c.r*d.i, d.r, d.i, d.r*c.r, c.i - FLd ST(2) ; d.i, c.r*d.i, d.r, d.i, d.r*c.r, c.i - FMul ST, ST(5) ; d.i*c.i, c.r*d.i, d.r, d.i, d.r*c.r, c.i - FSubP ST(4), ST ; c.r*d.i, d.r, d.i, newr, c.i - FXCh ST(4) ; c.i, d.r, d.i, newr, c.r*d.i - FMul ST, ST(1) ; c.i*d.r, d.r, d.i, newr, c.r*d.i - FAddP ST(4), ST ; d.r, d.i, newr, newi - - Inc DX - Cmp DX, CX - JB Fourier_Transform2 - - FComPP - FComPP - - ShL CX, 1 - Cmp CX, 2048 - JB Fourier_Transform1 - -; Cleanup code. - Mov CX, 1024 - Xor SI, SI - Mov DI, 24576 - - FLd CS:Const1_2048 -; FMul ST, ST ; Include if no sqrt -; FMul ST, ST - -Fourier_CalculateMagnitudes1: ; Could be interleaved, but speed isn't - ; *really* a problem. - FLd DWord Ptr [SI] - FMul ST, ST - FLd DWord Ptr [SI+4] - FMul ST, ST - FAdd - FSqrt - FMul ST, ST(1) - - FStP DWord Ptr [DI] - - Add SI, 8 - Add DI, 4 - - Dec CX - JNZ Fourier_CalculateMagnitudes1 - - FStP ST - - Ret - -EndP Fourier_Transform - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -FourierPalette DB 0 - -Proc Fourier_ChangePalette Far -Public Fourier_ChangePalette - - Xor [CS:FourierPalette], 1 - Call Fourier_SetPalette - - Mov AX, 1 - Ret - -EndP Fourier_ChangePalette - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Fourier_SetPalette - - Mov DX, 3C8h - Xor AL, AL - Out DX, AL - Inc DX - - Cmp [CS:FourierPalette], 0 - JE Fourier_PaletteB - - Mov CX, 64 - -Fourier_PaletteA1: - Xor AL, AL - Out DX, AL - Out DX, AL - Mov AL, 64 - Sub AL, CL - ShR AL, 1 - Out DX, AL - Loop Fourier_PaletteA1 - - Mov CX, 64 - -Fourier_PaletteA2: - Xor AL, AL - Out DX, AL - Mov BL, 64 - Sub BL, CL - ShR BL, 1 - Mov AL, BL - Out DX, AL - Mov AL, BL - Add AL, 32 - Out DX, AL - Loop Fourier_PaletteA2 - - Mov CX, 128 - -Fourier_PaletteA3: - Mov AL, 128 - Sub AL, CL - ShR AL, 1 - Out DX, AL - ShR AL, 1 - Add AL, 32 - Out DX, AL - Mov AL, 63 - Out DX, AL - Loop Fourier_PaletteA3 - - Ret - -Fourier_PaletteB: - Mov CX, 32 - Xor BX, BX - -Fourier_PaletteB1: - Xor AL, AL - Out DX, AL - Out DX, AL - Mov AL, BL - Out DX, AL - Add BX, 2 - Loop Fourier_PaletteB1 - - Mov CX, 32 - Xor BL, BL - -Fourier_PaletteB2: - Mov AL, BL - Out DX, AL - Xor AL, AL - Out DX, AL - Mov AL, 63 - Out DX, AL - Add BX, 2 - - Loop Fourier_PaletteB2 - - Mov CX, 32 - -Fourier_PaletteB3: - Mov AL, 63 - Out DX, AL - Xor AL, AL - Out DX, AL - Mov AL, CL - Add AL, AL - Dec AL - Out DX, AL - Loop Fourier_PaletteB3 - - Mov CX, 32 - Xor BX, BX - -Fourier_PaletteB4: - Mov AL, 63 - Out DX, AL - Mov AL, BL - Out DX, AL - Xor AL, AL - Out DX, AL - Add BX, 2 - Loop Fourier_PaletteB4 - - Mov CX, 128 - Xor BX, BX - -Fourier_PaletteB5: - Mov AL, 63 - Out DX, AL - Out DX, AL - Mov AL, BL - ShR AL, 1 - Out DX, AL - Inc BX - Loop Fourier_PaletteB5 - - Ret - -EndP Fourier_SetPalette - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ScreenWidth DW 0 -ScreenHeight DW 0 - -Proc Fourier_Start Far -Public Fourier_Start - - Push DiskData - Pop ES - Xor DI, DI - Mov CX, 32768 - Xor AX, AX - Rep StosW ; Clear data area first. - - Call Fourier_CreateTable - - Mov AL, 1 ; Prevent S_Update calls. - Call S_SetDirectMode - - Call VESA_Detect - JC Fourier_End - - Mov AX, 107h - -Fourier_NextMode: - Call VESA_SetMode ; Returns CX = width, DX = height - JNC Fourier_ModeOK - - Sub AL, 2 - JC Fourier_End - Jmp Fourier_NextMode - -Fourier_ModeOK: - Mov ScreenWidth, CX - Mov ScreenHeight, DX - - Call Fourier_SetPalette - - Mov CurrentOffset, 0 - - Call UnInitMouse - Mov DI, Offset O1_FourierDisplay - Xor CX, CX - Call M_Object1List - -Fourier_End: - Call S_InitScreen - Call InitMouse - Call S_DefineSmallNumbers - - Ret - -EndP Fourier_Start - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Fourier_PreDrawScreen Far -Public Fourier_PreDrawScreen - - Ret - -EndP Fourier_PreDrawScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ControlWord DW 003Fh - -Proc Fourier_DrawScreen Far -Public Fourier_DrawScreen - - FLdCW [CS:ControlWord] - - Push DiskData - Pop ES - Mov DI, 16384 - Call Music_GetWaveForm - JC Fourier_DrawScreen1 - - Push ES - Pop DS - Call Fourier_Transform ; Have table at DS:0 - - Mov CX, 1024 - Mov SI, 24576 - -Fourier_ConvertToInteger: - FLd DWord Ptr [SI] - FIStP DWord Ptr [SI] - Mov EDX, [SI] - ShR EDX, 6 - Cmp EDX, 255 - JB Fourier_DrawScreen3 - - Mov DL, 255 - -Fourier_DrawScreen3: - Mov [SI], DL - Add SI, 4 - Loop Fourier_ConvertToInteger - - Xor AX, AX - Call VESA_SetBlock - - Push 0A000h - Pop ES - Mov DI, CurrentOffset - Mov CX, ScreenHeight - Sub CX, 64 - Mov BX, ScreenWidth - LEA SI, [24576+ECX*4] - -Fourier_DrawScreen2: - Mov DL, [SI] - Mov [ES:DI], DL - - Sub SI, 4 - Add DI, BX - JNC Fourier_DrawScreen4 - - Inc AX - Call VESA_SetBlock - -Fourier_DrawScreen4: - Dec CX - JNZ Fourier_DrawScreen2 - - Mov AX, CurrentOffset - Inc AX - Xor DX, DX - Div BX - Mov CurrentOffset, DX - -; Now to draw volume bars. - - Mov CX, 64 - And EBX, 0FFFFh - - Mov BP, BX - Xor EDI, EDI - Cmp BP, 1024 - JB Fourier_DrawBars2 - - Mov DI, BX - Mov BP, 1024 - Sub DI, BP - ShR DI, 1 - -Fourier_DrawBars2: - -Fourier_DrawBars1: - Push BX - Push CX - Push EDI - - Xor EAX, EAX - - Mov AX, ScreenHeight - Sub AX, CX - Mul EBX ; EAX = offset. - Add EAX, EDI - - Mov DI, AX - ShR EAX, 16 - Call VESA_SetBlock - - Mov DX, BP - Mov BL, CL - Dec BL - ShL BL, 2 ; BL = 0->256 - - Push AX - Mov SI, 24580 - -Fourier_DrawBars3: - Cmp BL, Byte Ptr [SI] - SBB AL, AL - - Mov [ES:DI], AL - - Add DI, 1 - JNC Fourier_DrawBars4 - - Pop AX - Inc AX - Call VESA_SetBlock - Push AX - -Fourier_DrawBars4: - Add SI, 4 - Dec DX - JNZ Fourier_DrawBars3 - - Pop AX - - Pop EDI - Pop CX - Pop BX - Loop Fourier_DrawBars1 - -Fourier_DrawScreen1: - Ret - -EndP Fourier_DrawScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Fourier_IdleList Far -Public Fourier_IdleList - - Mov AX, 1 - Ret - -EndP Fourier_IdleList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Fourier_PostFunction Far -Public Fourier_PostFunction - - Cmp CX, 101h - JE Fourier_PostFunction2 - -Fourier_PostFunction1: - Xor AX, AX - Ret - -Fourier_PostFunction2: - Mov AX, 4 - Ret - -EndP Fourier_PostFunction - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - - -EndS - -ENDIF - -End - +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Fast Fourier Transform Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386P + .387 + +include switch.inc + +IF SPECTRUMANALYSER + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Object1 BYTE Public 'Data' +EndS +Segment DiskData PARA Public 'Data' +EndS + + Extrn O1_FourierDisplay:Far + + Extrn M_Object1List:Far + + Extrn Music_GetWaveForm:Far + + Extrn S_InitScreen:Far + Extrn S_SetDirectMode:Far + + Global MouseUpdateEnable:Far, MouseUpdateDisable:Far + Extrn VESA_Detect:Far + Extrn VESA_SetMode:Far + Extrn VESA_SetBlock:Far + Extrn InitMouse:Far, UnInitMouse:Far + Extrn S_DefineSmallNumbers:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + + +Segment Infopage BYTE Public 'Code' USE16 + Assume CS:Infopage, DS:Nothing, ES:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Fourier_CreateTable Far ; Fills in ES:16384 +Public Fourier_CreateTable + + Mov DI, 20480 + Xor CX, CX + +Fourier_CreateTable1: + Mov DX, 11 + + Xor AX, AX + Mov BX, CX + +Fourier_CreateTable2: + ShR BX, 1 + AdC AX, AX + + Dec DX + JNZ Fourier_CreateTable2 + + ShL AX, 3 + StosW + + Inc CX + Cmp CX, 2048 + JB Fourier_CreateTable1 + + Ret + +EndP Fourier_CreateTable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Const1_2048 DD 3C000000h +ConstHalf DD 3F000000h +Steps DW 0 +CurrentOffset DW 0 + +Proc Fourier_Transform Far +Public Fourier_Transform + ; Given DS:16384->DS:20480 = 2048 16-bit signed int samples + ; Given DS:20480->24576 = relocation table + ; Given DS:0->DS:16384 = working area + + ; Returns: DS:24576 -> 16-bit table of frequencies. (first 1024) + + Push DiskData + Pop DS + + Push DS + Pop ES + + Mov CX, 2048 ; Prepare 2048 samples + Mov SI, 16384 + Xor EDX, EDX + +Fourier_TransformRelocate1: + FILd Word Ptr [SI] + Mov DI, [SI+4096] + LodsW ; Add SI, 2 + Mov [DI+4], EDX + FStP DWord Ptr [DI] + Dec CX + JNZ Fourier_TransformRelocate1 + +; Samples relocated - now for transform + Mov CX, 1 + +Fourier_Transform1: + Mov [DS:24576], CX ; Store count + + FLdZ + FLd1 ; CurrentPhase.r, CurrentPhase.i + + FLdPi + FChs + FIDiv Word Ptr [DS:24576] ; -Pi/Step + FSinCos ; deltaphase.r, deltaphase.i, currentphase.r, currentphase.i + + Xor DX, DX + +Fourier_Transform2: + Mov SI, DX ; SI = k + Mov DI, CX ; DI = k+i + Mov BX, CX ; BX = i*2 + Add DI, DX + ShL SI, 3 ; SI = k*8 + ShL DI, 3 ; DI = (k+i)*8 + ShL BX, 4 ; BX = i*8*2 + +Fourier_Transform3: + FLd DWord Ptr [DI] + FMul ST, ST(3) ; cr*sr + FLd DWord Ptr [DI+4] + FMul ST, ST(4) ; cr*si, cr*sr, dr, di, cr, ci + FLd DWord Ptr [DI] + FMul ST, ST(6) + FLd DWord Ptr [DI+4] + FMul ST, ST(7) ; ci*si, ci*sr, cr*si, cr*sr, dr, di, cr, ci + FXCh + FAddP ST(2), ST + FSubP ST(2), ST ; tempi, tempr, dr, di, cr, ci + FLd DWord Ptr [SI+4] ; ri, tempi, tempr, dr, di, cr, ci + FAdd ST, ST(1) + FLd DWord Ptr [SI] + FAdd ST, ST(3) ; rr, ri, tempi, tempr, dr, di, cr, ci + FXCh ST(3) ; tempr, ri, tempi, rr, dr, di, cr, ci + FSubR DWord Ptr [SI] ; kr, ri, tempi, rr, dr, di, cr, ci + FXCh ST(2) + FSubR DWord Ptr [SI+4] ; ki, ri, kr, rr, dr, di, cr, ci + FXCh ST(3) ; rr, ri, kr, ki, dr, di, cr, ci + FStP DWord Ptr [SI] + FStP DWord Ptr [SI+4] + FStP DWord Ptr [DI] + FStP DWord Ptr [DI+4] + + Add SI, BX + Add DI, BX + + Cmp SI, 16384 + JB Fourier_Transform3 + +; Left with deltaphase.r, deltaphase.i, currentphase.r, currentphase.i + FLd ST ; d.r, d.r, d.i, c.r, c.i + FMul ST, ST(3) ; d.r*c.r, d.r, d.i, c.r, c.i + FXCh ST(3) ; c.r, d.r, d.i, d.r*c.r, c.i + FMul ST, ST(2) ; c.r*d.i, d.r, d.i, d.r*c.r, c.i + FLd ST(2) ; d.i, c.r*d.i, d.r, d.i, d.r*c.r, c.i + FMul ST, ST(5) ; d.i*c.i, c.r*d.i, d.r, d.i, d.r*c.r, c.i + FSubP ST(4), ST ; c.r*d.i, d.r, d.i, newr, c.i + FXCh ST(4) ; c.i, d.r, d.i, newr, c.r*d.i + FMul ST, ST(1) ; c.i*d.r, d.r, d.i, newr, c.r*d.i + FAddP ST(4), ST ; d.r, d.i, newr, newi + + Inc DX + Cmp DX, CX + JB Fourier_Transform2 + + FComPP + FComPP + + ShL CX, 1 + Cmp CX, 2048 + JB Fourier_Transform1 + +; Cleanup code. + Mov CX, 1024 + Xor SI, SI + Mov DI, 24576 + + FLd CS:Const1_2048 +; FMul ST, ST ; Include if no sqrt +; FMul ST, ST + +Fourier_CalculateMagnitudes1: ; Could be interleaved, but speed isn't + ; *really* a problem. + FLd DWord Ptr [SI] + FMul ST, ST + FLd DWord Ptr [SI+4] + FMul ST, ST + FAdd + FSqrt + FMul ST, ST(1) + + FStP DWord Ptr [DI] + + Add SI, 8 + Add DI, 4 + + Dec CX + JNZ Fourier_CalculateMagnitudes1 + + FStP ST + + Ret + +EndP Fourier_Transform + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +FourierPalette DB 0 + +Proc Fourier_ChangePalette Far +Public Fourier_ChangePalette + + Xor [CS:FourierPalette], 1 + Call Fourier_SetPalette + + Mov AX, 1 + Ret + +EndP Fourier_ChangePalette + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Fourier_SetPalette + + Mov DX, 3C8h + Xor AL, AL + Out DX, AL + Inc DX + + Cmp [CS:FourierPalette], 0 + JE Fourier_PaletteB + + Mov CX, 64 + +Fourier_PaletteA1: + Xor AL, AL + Out DX, AL + Out DX, AL + Mov AL, 64 + Sub AL, CL + ShR AL, 1 + Out DX, AL + Loop Fourier_PaletteA1 + + Mov CX, 64 + +Fourier_PaletteA2: + Xor AL, AL + Out DX, AL + Mov BL, 64 + Sub BL, CL + ShR BL, 1 + Mov AL, BL + Out DX, AL + Mov AL, BL + Add AL, 32 + Out DX, AL + Loop Fourier_PaletteA2 + + Mov CX, 128 + +Fourier_PaletteA3: + Mov AL, 128 + Sub AL, CL + ShR AL, 1 + Out DX, AL + ShR AL, 1 + Add AL, 32 + Out DX, AL + Mov AL, 63 + Out DX, AL + Loop Fourier_PaletteA3 + + Ret + +Fourier_PaletteB: + Mov CX, 32 + Xor BX, BX + +Fourier_PaletteB1: + Xor AL, AL + Out DX, AL + Out DX, AL + Mov AL, BL + Out DX, AL + Add BX, 2 + Loop Fourier_PaletteB1 + + Mov CX, 32 + Xor BL, BL + +Fourier_PaletteB2: + Mov AL, BL + Out DX, AL + Xor AL, AL + Out DX, AL + Mov AL, 63 + Out DX, AL + Add BX, 2 + + Loop Fourier_PaletteB2 + + Mov CX, 32 + +Fourier_PaletteB3: + Mov AL, 63 + Out DX, AL + Xor AL, AL + Out DX, AL + Mov AL, CL + Add AL, AL + Dec AL + Out DX, AL + Loop Fourier_PaletteB3 + + Mov CX, 32 + Xor BX, BX + +Fourier_PaletteB4: + Mov AL, 63 + Out DX, AL + Mov AL, BL + Out DX, AL + Xor AL, AL + Out DX, AL + Add BX, 2 + Loop Fourier_PaletteB4 + + Mov CX, 128 + Xor BX, BX + +Fourier_PaletteB5: + Mov AL, 63 + Out DX, AL + Out DX, AL + Mov AL, BL + ShR AL, 1 + Out DX, AL + Inc BX + Loop Fourier_PaletteB5 + + Ret + +EndP Fourier_SetPalette + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ScreenWidth DW 0 +ScreenHeight DW 0 + +Proc Fourier_Start Far +Public Fourier_Start + + Push DiskData + Pop ES + Xor DI, DI + Mov CX, 32768 + Xor AX, AX + Rep StosW ; Clear data area first. + + Call Fourier_CreateTable + + Mov AL, 1 ; Prevent S_Update calls. + Call S_SetDirectMode + + Call VESA_Detect + JC Fourier_End + + Mov AX, 107h + +Fourier_NextMode: + Call VESA_SetMode ; Returns CX = width, DX = height + JNC Fourier_ModeOK + + Sub AL, 2 + JC Fourier_End + Jmp Fourier_NextMode + +Fourier_ModeOK: + Mov ScreenWidth, CX + Mov ScreenHeight, DX + + Call Fourier_SetPalette + + Mov CurrentOffset, 0 + + Call UnInitMouse + Mov DI, Offset O1_FourierDisplay + Xor CX, CX + Call M_Object1List + +Fourier_End: + Call S_InitScreen + Call InitMouse + Call S_DefineSmallNumbers + + Ret + +EndP Fourier_Start + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Fourier_PreDrawScreen Far +Public Fourier_PreDrawScreen + + Ret + +EndP Fourier_PreDrawScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ControlWord DW 003Fh + +Proc Fourier_DrawScreen Far +Public Fourier_DrawScreen + + FLdCW [CS:ControlWord] + + Push DiskData + Pop ES + Mov DI, 16384 + Call Music_GetWaveForm + JC Fourier_DrawScreen1 + + Push ES + Pop DS + Call Fourier_Transform ; Have table at DS:0 + + Mov CX, 1024 + Mov SI, 24576 + +Fourier_ConvertToInteger: + FLd DWord Ptr [SI] + FIStP DWord Ptr [SI] + Mov EDX, [SI] + ShR EDX, 6 + Cmp EDX, 255 + JB Fourier_DrawScreen3 + + Mov DL, 255 + +Fourier_DrawScreen3: + Mov [SI], DL + Add SI, 4 + Loop Fourier_ConvertToInteger + + Xor AX, AX + Call VESA_SetBlock + + Push 0A000h + Pop ES + Mov DI, CurrentOffset + Mov CX, ScreenHeight + Sub CX, 64 + Mov BX, ScreenWidth + LEA SI, [24576+ECX*4] + +Fourier_DrawScreen2: + Mov DL, [SI] + Mov [ES:DI], DL + + Sub SI, 4 + Add DI, BX + JNC Fourier_DrawScreen4 + + Inc AX + Call VESA_SetBlock + +Fourier_DrawScreen4: + Dec CX + JNZ Fourier_DrawScreen2 + + Mov AX, CurrentOffset + Inc AX + Xor DX, DX + Div BX + Mov CurrentOffset, DX + +; Now to draw volume bars. + + Mov CX, 64 + And EBX, 0FFFFh + + Mov BP, BX + Xor EDI, EDI + Cmp BP, 1024 + JB Fourier_DrawBars2 + + Mov DI, BX + Mov BP, 1024 + Sub DI, BP + ShR DI, 1 + +Fourier_DrawBars2: + +Fourier_DrawBars1: + Push BX + Push CX + Push EDI + + Xor EAX, EAX + + Mov AX, ScreenHeight + Sub AX, CX + Mul EBX ; EAX = offset. + Add EAX, EDI + + Mov DI, AX + ShR EAX, 16 + Call VESA_SetBlock + + Mov DX, BP + Mov BL, CL + Dec BL + ShL BL, 2 ; BL = 0->256 + + Push AX + Mov SI, 24580 + +Fourier_DrawBars3: + Cmp BL, Byte Ptr [SI] + SBB AL, AL + + Mov [ES:DI], AL + + Add DI, 1 + JNC Fourier_DrawBars4 + + Pop AX + Inc AX + Call VESA_SetBlock + Push AX + +Fourier_DrawBars4: + Add SI, 4 + Dec DX + JNZ Fourier_DrawBars3 + + Pop AX + + Pop EDI + Pop CX + Pop BX + Loop Fourier_DrawBars1 + +Fourier_DrawScreen1: + Ret + +EndP Fourier_DrawScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Fourier_IdleList Far +Public Fourier_IdleList + + Mov AX, 1 + Ret + +EndP Fourier_IdleList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Fourier_PostFunction Far +Public Fourier_PostFunction + + Cmp CX, 101h + JE Fourier_PostFunction2 + +Fourier_PostFunction1: + Xor AX, AX + Ret + +Fourier_PostFunction2: + Mov AX, 4 + Ret + +EndP Fourier_PostFunction + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + + +EndS + +ENDIF + +End + diff --git a/IT_G.ASM b/it_g.s similarity index 96% rename from IT_G.ASM rename to it_g.s index 081b030..197c205 100644 --- a/IT_G.ASM +++ b/it_g.s @@ -1,1026 +1,1026 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Global Key Handler ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - -include switch.inc -include network.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Pattern BYTE Public 'Code' - Extrn LastInstrument:Byte - Extrn Order:Word - Extrn MaxRow:Word - Extrn NumberOfRows:Word - Extrn PatternNumber:Word -EndS - -Segment Inst BYTE Public 'Code' - Extrn SampleNumber:Byte - Extrn InstrumentScreen:Word -EndS - -Segment Object1 BYTE Public 'Data' -EndS - - Extrn D_InitLoadModule:Far - Extrn D_InitLoadSamples:Far - Extrn D_InitLoadInstruments:Far - Extrn Display_SelectDisplayList:Far - - Extrn M_Object1List:Far - - Extrn I_ClearTables:Far - - Extrn Music_GetInstrumentMode:Far - Extrn Music_GetPlayMode:Far - Extrn Music_PlayPattern:Far - Extrn Music_PlaySong:Far - Extrn Music_Stop:Far - Extrn Music_ToggleChannel:Far - Extrn Music_GetSlaveChannelInformationTable:Far - Extrn Music_IncreaseSpeed:Far - Extrn Music_DecreaseSpeed:Far - Extrn Music_IncreaseVolume:Far - Extrn Music_DecreaseVolume:Far - Extrn Music_GetSongSegment:Far - Extrn Music_GetDriverScreen:Far - - Extrn SetInfoLine:Far - - Extrn PE_GetCurrentPattern:Far - Extrn PE_SetPatternModified:far - - Extrn O1_InstrumentListGeneral:Far - Extrn O1_InstrumentListVolume:Far - Extrn O1_InstrumentListPanning:Far - Extrn O1_InstrumentListPitch:Far - - Extrn O1_KeyboardList:Far - Extrn O1_LoadSampleList:Far - Extrn O1_OrderPanningList:Far - Extrn O1_PatternEditList:Far - Extrn O1_PEConfigList:Far - Extrn O1_SampleList:Far - Extrn O1_LoadModuleList:Far - Extrn O1_ViewInstrumentLibrary:Far - Extrn O1_SaveModuleList:Far - Extrn O1_LoadInstrumentList:Far - Extrn O1_MessageList:Far - Extrn O1_OrderVolumeList:Far - Extrn O1_DisplayList:Far - Extrn I_DrawWaveForm:Far - Extrn S_DefineSmallNumbers:Far - Extrn S_SaveScreen:Far, S_RestoreScreen:Far - Extrn RestoreMouse:Far, RestoreMouseGraphics:Far - Extrn D_ClearFileSpecifier:Far - Extrn O1_ConfigureITList:Far - Extrn O1_ViewSampleLibrary:Far - Extrn O1_ConfigurePaletteList:Far - Extrn O1_MIDIScreen:Far - Extrn O1_TimerList:Far - Extrn I_MapEnvelope:Far - Extrn NewCharacterSet:Far - Extrn S_GetDestination:Far - Extrn S_DefineHiASCII:Far - -IF MEMORYDEBUG - Extrn O1_DebugList:Far -ENDIF - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global Glbl_Ctrl_F1:Far - Global Glbl_Ctrl_F3:Far - Global Glbl_Ctrl_F4:Far - Global Glbl_Ctrl_F5:Far - Global Glbl_Ctrl_F12:Far - Global Glbl_F2:Far - Global Glbl_F3:Far - Global Glbl_F4:Far - Global Glbl_F4_2:Far - Global Glbl_F5:Far - Global Glbl_F6:Far - Global Glbl_Shift_F1:Far - Global Glbl_Shift_F6:Far - Global Glbl_Shift_F9:Far - Global Glbl_F8:Far - Global Glbl_F9:Far - Global Glbl_F10:Far - Global Glbl_F11:Far - Global Glbl_F12:Far - Global Glbl_Alt_F1:Far - Global Glbl_Alt_F2:Far - Global Glbl_Alt_F3:Far - Global Glbl_Alt_F4:Far - Global Glbl_Alt_F5:Far - Global Glbl_Alt_F6:Far - Global Glbl_Alt_F7:Far - Global Glbl_Alt_F8:Far - Global Glbl_LeftBrace:Far - Global Glbl_RightBrace:Far - Global Glbl_LeftSquareBracket:Far - Global Glbl_RightSquareBracket:Far - Global Glbl_LoadSample:Far - Global Glbl_LoadInstrument:Far - Global Glbl_GetHeaderMode:Far - Global Glbl_SetCurrentMode:Far - Global Glbl_GetCurrentMode:Far - Global Glbl_SaveMode:Far - Global Glbl_RestoreMode:Far - -IF TIMERSCREEN - Global Glbl_TimerScreen:Far -ENDIF - - Global CurrentMode:Byte - - Public Glbl_F2_2 - Public Glbl_F11_2 - -IF MEMORYDEBUG - Global Glbl_Debug:Far -ENDIF - Global Glbl_DriverScreen:Far - - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Glbl BYTE Public 'Code' - Assume CS:Glbl, DS:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -SLAVECHANNELSIZE EQU 128 - -CurrentMode DB 0 ; 2 = Pattern edit - ; 3 = Sample list - ; 4 = Instrument list - ; 5 = Info list - ; 6 = configure pattern edit - ; 9 = load list - ; 10 = save list - ; 11 = order/panning list - ; 12 = configure IT list - ; 13 = load sample list. - ; 14 = palette config list. - ; 15 = load instrument list - ; 16 = message list - ; 21 = order/volume list - ; 22 = debug - ; 23 = timer - ; 24 = Network screen - ; 31 = MIDI list - ; 1 = Keyboard list - ; 0 = Nothing in particular :) - ; 100 = Driver Screen - ; 200 = Full screen display - ; 201 = VGA display - -CurrentMode2 DB 0 -CurrentList DW 0 -CurrentListSegment DW 0 - -TempoSetMsg DB "Tempo set to ", 0FDh, "D beats per minute", 0 -SpeedSetMsg DB "Speed set to ", 0FDh, "D frames per row", 0 -VolumeSetMsg DB "Global Volume set to ", 0FDh, "D", 0 - -InstrumentScreenTable Label - DW Offset O1_InstrumentListGeneral - DW Offset O1_InstrumentListVolume - DW Offset O1_InstrumentListPanning - DW Offset O1_InstrumentListPitch - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc Glbl_F2 Far - - Call Glbl_SampleToInstrument - Cmp CS:CurrentMode, 2 - - JE Glbl_F2_1 - -Glbl_F2_2: - Call S_DefineSmallNumbers - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 2 - - Mov DX, Offset O1_PatternEditList - - Ret - -Glbl_F2_1: - Mov CS:CurrentMode, 6 - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AX, MaxRow - Inc AX - Mov NumberOfRows, AX - - Mov DI, Offset O1_PEConfigList - Mov CX, 0FFFFh - Call M_Object1List - Call PE_SetPatternModified - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov BX, NumberOfRows - Dec BX - Mov MaxRow, BX - -IF NETWORKENABLED - Call Network_GetSendQueue - JZ Glbl_F2_Network - - Mov AX, NETWORK_SETPATTERNLENGTH*100h ; Destination ALL - StosW - Mov AH, BL - Mov AL, [Byte Ptr PatternNumber] - StosW - -Glbl_F2_Network: - Call Network_FinishedSendQueue -ENDIF - Mov CS:CurrentMode, 2 - - Mov AX, 1 - Ret - -EndP Glbl_F2 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F3 Far - - Call I_DrawWaveForm - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 3 - - Mov DX, Offset O1_SampleList - Ret - -EndP Glbl_F3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F4 Far - - ; Init SampleNumber - Call Glbl_SampleToInstrument - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov BL, LastInstrument - And BL, BL - JNZ Glbl_F4_1 - - Mov LastInstrument, 1 - -Glbl_F4_1: - Mov AX, Inst - Mov DS, AX - Assume DS:Inst - Mov SampleNumber, BL - -Proc Glbl_F4_2 Far - - Call I_MapEnvelope - - Mov DI, InstrumentScreen - Add DI, DI - Mov DX, [DI+InstrumentScreenTable] - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 4 - - Ret - -EndP Glbl_F4_2 - -EndP Glbl_F4 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F5 Far - - Cmp CS:CurrentMode, 5 - JE Glbl_F5_1 - - Call S_DefineSmallNumbers - - Call Music_GetPlayMode - Test AX, AX - JNZ Glbl_F5_4 - - Call Music_GetSlaveChannelInformationTable - -Glbl_F5_3: - Test Byte Ptr [SI], 1 - JNZ Glbl_F5_4 - - Add SI, SLAVECHANNELSIZE - Loop Glbl_F5_3 - - Call I_ClearTables - - Xor AX, AX - Call Music_PlaySong - -Glbl_F5_4: - Jmp Display_SelectDisplayList - -Glbl_F5_1: - Call Music_GetPlayMode - And AX, AX - JNZ Glbl_F5_2 - - Call I_ClearTables - - Xor AX, AX - Call Music_PlaySong - -Glbl_F5_2: - Mov AX, 1 - Ret - -EndP Glbl_F5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F6 Far - - Call I_ClearTables - - Call PE_GetCurrentPattern - Xor CX, CX - Call Music_PlayPattern - - Mov AX, 1 - Ret - -EndP Glbl_F6 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_LoadSample Far - - Call D_InitLoadSamples - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 13 - - Mov DX, Offset O1_LoadSampleList - Ret - -EndP Glbl_LoadSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_LoadInstrument Far - - Call D_InitLoadInstruments - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 15 - - Mov DX, Offset O1_LoadInstrumentList - Ret - -EndP Glbl_LoadInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Shift_F1 Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 31 - - Mov DX, Offset O1_MIDIScreen - Ret - -EndP Glbl_Shift_F1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Shift_F9 Far - - Call S_DefineHIASCII - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 16 - - Mov DX, Offset O1_MessageList - Ret - -EndP Glbl_Shift_F9 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Shift_F6 Far - - Call I_ClearTables - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - Mov AX, Order - - Call Music_PlaySong - - Mov AX, 1 - Ret - -EndP Glbl_Shift_F6 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F8 Far - - Call Music_Stop - - Mov AX, 1 - Ret - -EndP Glbl_F8 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F9 Far - - Call D_InitLoadModule - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 9 - - Mov DX, Offset O1_LoadModuleList - - Mov DS, CX - Mov BX, DX - Mov Word Ptr [BX], 12 - - Ret - -EndP Glbl_F9 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F10 Far - - Call D_InitLoadModule - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 10 - - Mov DX, Offset O1_SaveModuleList - - Mov DS, CX - Mov BX, DX - Mov Word Ptr [BX], 15 - - Call D_ClearFileSpecifier - - Ret - -EndP Glbl_F10 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F11 Far - - Cmp CS:CurrentMode, 11 - JE Glbl_F11_1 - -Glbl_F11_2: - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_OrderPanningList - - Mov CS:CurrentMode, 11 - Ret - -Glbl_F11_1: - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov DX, Offset O1_OrderPanningList - - Mov CS:CurrentMode, 21 - Mov DX, Offset O1_OrderVolumeList - Ret - -EndP Glbl_F11 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_F12 Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 12 - - Mov DX, Offset O1_ConfigureITList - Ret - -EndP Glbl_F12 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Ctrl_F1 Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 1 - - Mov DX, Offset O1_KeyboardList - Ret - -EndP Glbl_Ctrl_F1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Ctrl_F3 Far - - Call D_InitLoadSamples - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 13 - - Mov DX, Offset O1_ViewSampleLibrary - Ret - -EndP Glbl_Ctrl_F3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Ctrl_F4 Far - - Call D_InitLoadInstruments - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 15 - - Mov DX, Offset O1_ViewInstrumentLibrary - Ret - -EndP Glbl_Ctrl_F4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Ctrl_F5 Far - - Call I_ClearTables - - Xor AX, AX - Call Music_PlaySong - - Mov AX, 1 - Ret - -EndP Glbl_Ctrl_F5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Ctrl_F12 Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 14 - - Mov DX, Offset O1_ConfigurePaletteList - - Ret - -EndP Glbl_Ctrl_F12 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_GetHeaderMode Far - - Push DS - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - Mov AL, LastInstrument - Pop DS - - Xor AH, AH - - Cmp CS:CurrentMode, 3 ; Sample list - JE Glbl_GetHeaderMode1 - - Cmp CS:CurrentMode, 13 ; Sample load list - JE Glbl_GetHeaderMode1 - - Cmp CS:CurrentMode, 4 - JE Glbl_GetHeaderMode2 - - Call Music_GetInstrumentMode - -Glbl_GetHeaderMode1: - Ret - -Glbl_GetHeaderMode2: - Push DS - Push AX - - Mov AX, Inst - Mov DS, AX - Assume DS:Inst - - Pop AX - Mov AL, SampleNumber - - Pop DS - Ret - -EndP Glbl_GetHeaderMode - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_SetCurrentMode Far - - Mov CS:CurrentMode, AL - - Ret - -EndP Glbl_SetCurrentMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_GetCurrentMode Far ; Returns AL - - Mov AL, CS:CurrentMode - - Ret - -EndP Glbl_GetCurrentMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Alt_F1 Far - - Mov AX, 0 - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP Glbl_Alt_F1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Alt_F2 Far - - Mov AX, 1 - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP Glbl_Alt_F2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Alt_F3 Far - - Mov AX, 2 - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP Glbl_Alt_F3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Alt_F4 Far - - Mov AX, 3 - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP Glbl_Alt_F4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Alt_F5 Far - - Mov AX, 4 - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP Glbl_Alt_F5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Alt_F6 Far - - Mov AX, 5 - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP Glbl_Alt_F6 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Alt_F7 Far - - Mov AX, 6 - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP Glbl_Alt_F7 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_Alt_F8 Far - - Mov AX, 7 - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP Glbl_Alt_F8 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_LeftBrace Far - - Push CS - Pop DS - - Call Music_IncreaseSpeed - Mov SI, Offset SpeedSetMsg - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP Glbl_LeftBrace - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_RightBrace Far - - Push CS - Pop DS - - Call Music_DecreaseSpeed - Mov SI, Offset SpeedSetMsg - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP Glbl_RightBrace - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_LeftSquareBracket Far - - Push CS - Pop DS - - Call Music_DecreaseVolume - - Mov SI, Offset VolumeSetMsg - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP Glbl_LeftSquareBracket - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_RightSquareBracket Far - - Push CS - Pop DS - - Call Music_IncreaseVolume - - Mov SI, Offset VolumeSetMsg - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP Glbl_RightSquareBracket - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_SaveMode Far - -; Call S_GetDestination -; Mov AX, 0B800h -; Mov ES, AX -; Call RestoreMouse - - Call S_SaveScreen - - Mov AL, CurrentMode - Mov CurrentMode2, AL - - Mov BP, SP - Mov AX, [BP+16] - Mov CurrentList, AX - Mov AX, [BP+18] - Mov CurrentListSegment, AX - Mov CurrentMode, 0 - - Ret - -EndP Glbl_SaveMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_RestoreMode Far - -; Call NewCharacterSet - - Call S_RestoreScreen - - Mov AL, CurrentMode2 - Mov CurrentMode, AL - - Mov AX, 5 - Mov SI, 1 - Mov CX, CurrentListSegment - Mov DX, CurrentList - - Ret - -EndP Glbl_RestoreMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF MEMORYDEBUG - -Proc Glbl_Debug Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 22 - - Mov DX, Offset O1_DebugList - Ret - -EndP Glbl_Debug - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_SampleToInstrument - - Cmp CS:CurrentMode, 3 - JNE Glbl_SampleToInstrument1 - - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - Test Byte Ptr [DS:2Ch], 4 - JZ Glbl_SampleToInstrument1 - - Mov AX, Pattern - Mov ES, AX - Assume ES:Pattern - - Mov AH, ES:LastInstrument - Mov BX, [DS:64712] ; Offset of first instrument - - ; Search for sample in tables. - Mov DX, 99 - -Glbl_SampleToInstrument2: - Push BX - - Add BX, 41h ; To note/sample tables - Mov CX, 120 - -Glbl_SampleToInstrument4: - Cmp [BX], AH - JE Glbl_SampleToInstrument3 - Add BX, 2 - Loop Glbl_SampleToInstrument4 - - Pop BX - Add BX, 554 ; Length of instrument - Dec DX - JNZ Glbl_SampleToInstrument2 - - Ret - -Glbl_SampleToInstrument3: - Pop BX - - Mov AL, 100 - Sub AL, DL - Mov ES:LastInstrument, AL - -Glbl_SampleToInstrument1: - Ret - -EndP Glbl_SampleToInstrument - Assume ES:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF TIMERSCREEN - -Proc Glbl_TimerScreen Far - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - Mov CS:CurrentMode, 23 - - Mov DX, Offset O1_TimerList - Ret - -EndP Glbl_TimerScreen - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_DriverScreen Far - - Call Music_GetDriverScreen - JC Glbl_DriverScreen1 - - Mov CurrentMode, 100 - -Glbl_DriverScreen1: - Ret - -EndP Glbl_DriverScreen - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Global Key Handler ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + +include switch.inc +include network.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Pattern BYTE Public 'Code' + Extrn LastInstrument:Byte + Extrn Order:Word + Extrn MaxRow:Word + Extrn NumberOfRows:Word + Extrn PatternNumber:Word +EndS + +Segment Inst BYTE Public 'Code' + Extrn SampleNumber:Byte + Extrn InstrumentScreen:Word +EndS + +Segment Object1 BYTE Public 'Data' +EndS + + Extrn D_InitLoadModule:Far + Extrn D_InitLoadSamples:Far + Extrn D_InitLoadInstruments:Far + Extrn Display_SelectDisplayList:Far + + Extrn M_Object1List:Far + + Extrn I_ClearTables:Far + + Extrn Music_GetInstrumentMode:Far + Extrn Music_GetPlayMode:Far + Extrn Music_PlayPattern:Far + Extrn Music_PlaySong:Far + Extrn Music_Stop:Far + Extrn Music_ToggleChannel:Far + Extrn Music_GetSlaveChannelInformationTable:Far + Extrn Music_IncreaseSpeed:Far + Extrn Music_DecreaseSpeed:Far + Extrn Music_IncreaseVolume:Far + Extrn Music_DecreaseVolume:Far + Extrn Music_GetSongSegment:Far + Extrn Music_GetDriverScreen:Far + + Extrn SetInfoLine:Far + + Extrn PE_GetCurrentPattern:Far + Extrn PE_SetPatternModified:far + + Extrn O1_InstrumentListGeneral:Far + Extrn O1_InstrumentListVolume:Far + Extrn O1_InstrumentListPanning:Far + Extrn O1_InstrumentListPitch:Far + + Extrn O1_KeyboardList:Far + Extrn O1_LoadSampleList:Far + Extrn O1_OrderPanningList:Far + Extrn O1_PatternEditList:Far + Extrn O1_PEConfigList:Far + Extrn O1_SampleList:Far + Extrn O1_LoadModuleList:Far + Extrn O1_ViewInstrumentLibrary:Far + Extrn O1_SaveModuleList:Far + Extrn O1_LoadInstrumentList:Far + Extrn O1_MessageList:Far + Extrn O1_OrderVolumeList:Far + Extrn O1_DisplayList:Far + Extrn I_DrawWaveForm:Far + Extrn S_DefineSmallNumbers:Far + Extrn S_SaveScreen:Far, S_RestoreScreen:Far + Extrn RestoreMouse:Far, RestoreMouseGraphics:Far + Extrn D_ClearFileSpecifier:Far + Extrn O1_ConfigureITList:Far + Extrn O1_ViewSampleLibrary:Far + Extrn O1_ConfigurePaletteList:Far + Extrn O1_MIDIScreen:Far + Extrn O1_TimerList:Far + Extrn I_MapEnvelope:Far + Extrn NewCharacterSet:Far + Extrn S_GetDestination:Far + Extrn S_DefineHiASCII:Far + +IF MEMORYDEBUG + Extrn O1_DebugList:Far +ENDIF + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global Glbl_Ctrl_F1:Far + Global Glbl_Ctrl_F3:Far + Global Glbl_Ctrl_F4:Far + Global Glbl_Ctrl_F5:Far + Global Glbl_Ctrl_F12:Far + Global Glbl_F2:Far + Global Glbl_F3:Far + Global Glbl_F4:Far + Global Glbl_F4_2:Far + Global Glbl_F5:Far + Global Glbl_F6:Far + Global Glbl_Shift_F1:Far + Global Glbl_Shift_F6:Far + Global Glbl_Shift_F9:Far + Global Glbl_F8:Far + Global Glbl_F9:Far + Global Glbl_F10:Far + Global Glbl_F11:Far + Global Glbl_F12:Far + Global Glbl_Alt_F1:Far + Global Glbl_Alt_F2:Far + Global Glbl_Alt_F3:Far + Global Glbl_Alt_F4:Far + Global Glbl_Alt_F5:Far + Global Glbl_Alt_F6:Far + Global Glbl_Alt_F7:Far + Global Glbl_Alt_F8:Far + Global Glbl_LeftBrace:Far + Global Glbl_RightBrace:Far + Global Glbl_LeftSquareBracket:Far + Global Glbl_RightSquareBracket:Far + Global Glbl_LoadSample:Far + Global Glbl_LoadInstrument:Far + Global Glbl_GetHeaderMode:Far + Global Glbl_SetCurrentMode:Far + Global Glbl_GetCurrentMode:Far + Global Glbl_SaveMode:Far + Global Glbl_RestoreMode:Far + +IF TIMERSCREEN + Global Glbl_TimerScreen:Far +ENDIF + + Global CurrentMode:Byte + + Public Glbl_F2_2 + Public Glbl_F11_2 + +IF MEMORYDEBUG + Global Glbl_Debug:Far +ENDIF + Global Glbl_DriverScreen:Far + + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Glbl BYTE Public 'Code' + Assume CS:Glbl, DS:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +SLAVECHANNELSIZE EQU 128 + +CurrentMode DB 0 ; 2 = Pattern edit + ; 3 = Sample list + ; 4 = Instrument list + ; 5 = Info list + ; 6 = configure pattern edit + ; 9 = load list + ; 10 = save list + ; 11 = order/panning list + ; 12 = configure IT list + ; 13 = load sample list. + ; 14 = palette config list. + ; 15 = load instrument list + ; 16 = message list + ; 21 = order/volume list + ; 22 = debug + ; 23 = timer + ; 24 = Network screen + ; 31 = MIDI list + ; 1 = Keyboard list + ; 0 = Nothing in particular :) + ; 100 = Driver Screen + ; 200 = Full screen display + ; 201 = VGA display + +CurrentMode2 DB 0 +CurrentList DW 0 +CurrentListSegment DW 0 + +TempoSetMsg DB "Tempo set to ", 0FDh, "D beats per minute", 0 +SpeedSetMsg DB "Speed set to ", 0FDh, "D frames per row", 0 +VolumeSetMsg DB "Global Volume set to ", 0FDh, "D", 0 + +InstrumentScreenTable Label + DW Offset O1_InstrumentListGeneral + DW Offset O1_InstrumentListVolume + DW Offset O1_InstrumentListPanning + DW Offset O1_InstrumentListPitch + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc Glbl_F2 Far + + Call Glbl_SampleToInstrument + Cmp CS:CurrentMode, 2 + + JE Glbl_F2_1 + +Glbl_F2_2: + Call S_DefineSmallNumbers + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 2 + + Mov DX, Offset O1_PatternEditList + + Ret + +Glbl_F2_1: + Mov CS:CurrentMode, 6 + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AX, MaxRow + Inc AX + Mov NumberOfRows, AX + + Mov DI, Offset O1_PEConfigList + Mov CX, 0FFFFh + Call M_Object1List + Call PE_SetPatternModified + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov BX, NumberOfRows + Dec BX + Mov MaxRow, BX + +IF NETWORKENABLED + Call Network_GetSendQueue + JZ Glbl_F2_Network + + Mov AX, NETWORK_SETPATTERNLENGTH*100h ; Destination ALL + StosW + Mov AH, BL + Mov AL, [Byte Ptr PatternNumber] + StosW + +Glbl_F2_Network: + Call Network_FinishedSendQueue +ENDIF + Mov CS:CurrentMode, 2 + + Mov AX, 1 + Ret + +EndP Glbl_F2 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F3 Far + + Call I_DrawWaveForm + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 3 + + Mov DX, Offset O1_SampleList + Ret + +EndP Glbl_F3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F4 Far + + ; Init SampleNumber + Call Glbl_SampleToInstrument + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov BL, LastInstrument + And BL, BL + JNZ Glbl_F4_1 + + Mov LastInstrument, 1 + +Glbl_F4_1: + Mov AX, Inst + Mov DS, AX + Assume DS:Inst + Mov SampleNumber, BL + +Proc Glbl_F4_2 Far + + Call I_MapEnvelope + + Mov DI, InstrumentScreen + Add DI, DI + Mov DX, [DI+InstrumentScreenTable] + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 4 + + Ret + +EndP Glbl_F4_2 + +EndP Glbl_F4 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F5 Far + + Cmp CS:CurrentMode, 5 + JE Glbl_F5_1 + + Call S_DefineSmallNumbers + + Call Music_GetPlayMode + Test AX, AX + JNZ Glbl_F5_4 + + Call Music_GetSlaveChannelInformationTable + +Glbl_F5_3: + Test Byte Ptr [SI], 1 + JNZ Glbl_F5_4 + + Add SI, SLAVECHANNELSIZE + Loop Glbl_F5_3 + + Call I_ClearTables + + Xor AX, AX + Call Music_PlaySong + +Glbl_F5_4: + Jmp Display_SelectDisplayList + +Glbl_F5_1: + Call Music_GetPlayMode + And AX, AX + JNZ Glbl_F5_2 + + Call I_ClearTables + + Xor AX, AX + Call Music_PlaySong + +Glbl_F5_2: + Mov AX, 1 + Ret + +EndP Glbl_F5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F6 Far + + Call I_ClearTables + + Call PE_GetCurrentPattern + Xor CX, CX + Call Music_PlayPattern + + Mov AX, 1 + Ret + +EndP Glbl_F6 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_LoadSample Far + + Call D_InitLoadSamples + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 13 + + Mov DX, Offset O1_LoadSampleList + Ret + +EndP Glbl_LoadSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_LoadInstrument Far + + Call D_InitLoadInstruments + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 15 + + Mov DX, Offset O1_LoadInstrumentList + Ret + +EndP Glbl_LoadInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Shift_F1 Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 31 + + Mov DX, Offset O1_MIDIScreen + Ret + +EndP Glbl_Shift_F1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Shift_F9 Far + + Call S_DefineHIASCII + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 16 + + Mov DX, Offset O1_MessageList + Ret + +EndP Glbl_Shift_F9 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Shift_F6 Far + + Call I_ClearTables + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + Mov AX, Order + + Call Music_PlaySong + + Mov AX, 1 + Ret + +EndP Glbl_Shift_F6 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F8 Far + + Call Music_Stop + + Mov AX, 1 + Ret + +EndP Glbl_F8 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F9 Far + + Call D_InitLoadModule + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 9 + + Mov DX, Offset O1_LoadModuleList + + Mov DS, CX + Mov BX, DX + Mov Word Ptr [BX], 12 + + Ret + +EndP Glbl_F9 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F10 Far + + Call D_InitLoadModule + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 10 + + Mov DX, Offset O1_SaveModuleList + + Mov DS, CX + Mov BX, DX + Mov Word Ptr [BX], 15 + + Call D_ClearFileSpecifier + + Ret + +EndP Glbl_F10 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F11 Far + + Cmp CS:CurrentMode, 11 + JE Glbl_F11_1 + +Glbl_F11_2: + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_OrderPanningList + + Mov CS:CurrentMode, 11 + Ret + +Glbl_F11_1: + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov DX, Offset O1_OrderPanningList + + Mov CS:CurrentMode, 21 + Mov DX, Offset O1_OrderVolumeList + Ret + +EndP Glbl_F11 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_F12 Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 12 + + Mov DX, Offset O1_ConfigureITList + Ret + +EndP Glbl_F12 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Ctrl_F1 Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 1 + + Mov DX, Offset O1_KeyboardList + Ret + +EndP Glbl_Ctrl_F1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Ctrl_F3 Far + + Call D_InitLoadSamples + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 13 + + Mov DX, Offset O1_ViewSampleLibrary + Ret + +EndP Glbl_Ctrl_F3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Ctrl_F4 Far + + Call D_InitLoadInstruments + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 15 + + Mov DX, Offset O1_ViewInstrumentLibrary + Ret + +EndP Glbl_Ctrl_F4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Ctrl_F5 Far + + Call I_ClearTables + + Xor AX, AX + Call Music_PlaySong + + Mov AX, 1 + Ret + +EndP Glbl_Ctrl_F5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Ctrl_F12 Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 14 + + Mov DX, Offset O1_ConfigurePaletteList + + Ret + +EndP Glbl_Ctrl_F12 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_GetHeaderMode Far + + Push DS + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + Mov AL, LastInstrument + Pop DS + + Xor AH, AH + + Cmp CS:CurrentMode, 3 ; Sample list + JE Glbl_GetHeaderMode1 + + Cmp CS:CurrentMode, 13 ; Sample load list + JE Glbl_GetHeaderMode1 + + Cmp CS:CurrentMode, 4 + JE Glbl_GetHeaderMode2 + + Call Music_GetInstrumentMode + +Glbl_GetHeaderMode1: + Ret + +Glbl_GetHeaderMode2: + Push DS + Push AX + + Mov AX, Inst + Mov DS, AX + Assume DS:Inst + + Pop AX + Mov AL, SampleNumber + + Pop DS + Ret + +EndP Glbl_GetHeaderMode + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_SetCurrentMode Far + + Mov CS:CurrentMode, AL + + Ret + +EndP Glbl_SetCurrentMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_GetCurrentMode Far ; Returns AL + + Mov AL, CS:CurrentMode + + Ret + +EndP Glbl_GetCurrentMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Alt_F1 Far + + Mov AX, 0 + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP Glbl_Alt_F1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Alt_F2 Far + + Mov AX, 1 + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP Glbl_Alt_F2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Alt_F3 Far + + Mov AX, 2 + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP Glbl_Alt_F3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Alt_F4 Far + + Mov AX, 3 + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP Glbl_Alt_F4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Alt_F5 Far + + Mov AX, 4 + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP Glbl_Alt_F5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Alt_F6 Far + + Mov AX, 5 + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP Glbl_Alt_F6 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Alt_F7 Far + + Mov AX, 6 + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP Glbl_Alt_F7 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_Alt_F8 Far + + Mov AX, 7 + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP Glbl_Alt_F8 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_LeftBrace Far + + Push CS + Pop DS + + Call Music_IncreaseSpeed + Mov SI, Offset SpeedSetMsg + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP Glbl_LeftBrace + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_RightBrace Far + + Push CS + Pop DS + + Call Music_DecreaseSpeed + Mov SI, Offset SpeedSetMsg + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP Glbl_RightBrace + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_LeftSquareBracket Far + + Push CS + Pop DS + + Call Music_DecreaseVolume + + Mov SI, Offset VolumeSetMsg + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP Glbl_LeftSquareBracket + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_RightSquareBracket Far + + Push CS + Pop DS + + Call Music_IncreaseVolume + + Mov SI, Offset VolumeSetMsg + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP Glbl_RightSquareBracket + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_SaveMode Far + +; Call S_GetDestination +; Mov AX, 0B800h +; Mov ES, AX +; Call RestoreMouse + + Call S_SaveScreen + + Mov AL, CurrentMode + Mov CurrentMode2, AL + + Mov BP, SP + Mov AX, [BP+16] + Mov CurrentList, AX + Mov AX, [BP+18] + Mov CurrentListSegment, AX + Mov CurrentMode, 0 + + Ret + +EndP Glbl_SaveMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_RestoreMode Far + +; Call NewCharacterSet + + Call S_RestoreScreen + + Mov AL, CurrentMode2 + Mov CurrentMode, AL + + Mov AX, 5 + Mov SI, 1 + Mov CX, CurrentListSegment + Mov DX, CurrentList + + Ret + +EndP Glbl_RestoreMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF MEMORYDEBUG + +Proc Glbl_Debug Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 22 + + Mov DX, Offset O1_DebugList + Ret + +EndP Glbl_Debug + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_SampleToInstrument + + Cmp CS:CurrentMode, 3 + JNE Glbl_SampleToInstrument1 + + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + Test Byte Ptr [DS:2Ch], 4 + JZ Glbl_SampleToInstrument1 + + Mov AX, Pattern + Mov ES, AX + Assume ES:Pattern + + Mov AH, ES:LastInstrument + Mov BX, [DS:64712] ; Offset of first instrument + + ; Search for sample in tables. + Mov DX, 99 + +Glbl_SampleToInstrument2: + Push BX + + Add BX, 41h ; To note/sample tables + Mov CX, 120 + +Glbl_SampleToInstrument4: + Cmp [BX], AH + JE Glbl_SampleToInstrument3 + Add BX, 2 + Loop Glbl_SampleToInstrument4 + + Pop BX + Add BX, 554 ; Length of instrument + Dec DX + JNZ Glbl_SampleToInstrument2 + + Ret + +Glbl_SampleToInstrument3: + Pop BX + + Mov AL, 100 + Sub AL, DL + Mov ES:LastInstrument, AL + +Glbl_SampleToInstrument1: + Ret + +EndP Glbl_SampleToInstrument + Assume ES:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF TIMERSCREEN + +Proc Glbl_TimerScreen Far + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + Mov CS:CurrentMode, 23 + + Mov DX, Offset O1_TimerList + Ret + +EndP Glbl_TimerScreen + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_DriverScreen Far + + Call Music_GetDriverScreen + JC Glbl_DriverScreen1 + + Mov CurrentMode, 100 + +Glbl_DriverScreen1: + Ret + +EndP Glbl_DriverScreen + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_H.ASM b/it_h.s similarity index 98% rename from IT_H.ASM rename to it_h.s index 4d99b62..901de30 100644 --- a/IT_H.ASM +++ b/it_h.s @@ -1,1552 +1,1552 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Help Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - .386 - Jumps - -include switch.inc - -Segment Object1 BYTE Public 'Data' -EndS - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Extrn M_Object1List:Far - Extrn Glbl_SaveMode:Far - Extrn Glbl_RestoreMode:Far - - Extrn S_DrawString:Far - - Extrn O1_HelpList:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global H_SetHelpContext:Far - Global H_DrawHelp:Far - Global H_Help:Far - Global H_HelpUp:Far - Global H_HelpDown:Far - Global H_HelpPgUp:Far - Global H_HelpPgDn:Far - Global H_HelpESC:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Object1 BYTE Public 'Data' -EndS - -Segment Help BYTE Public USE16 'Code' - Assume CS:Help, DS:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - ; Help contexts.... - ; 0 = Order list & Panning - ; 1 = Pattern edit list - ; 2 = Sample list - ; 3 = Load module - ; 4 = Order list & Volume - ; 5 = Configuration screen - ; 6 = Load sample list - ; 7 = Instrument list - ; 8 = Keyboard list - ; 9 = Info page - ; 10 = Palette configuration - ; 11 = Instrument list - ; 12 = message editor - ; 13 = MIDI Input - ; 14 = MIDI Output - -HelpContext DW 0 -TopLine DW 0 - -Positions DW 15 Dup (0) - -HelpContextPtrs Label Word - DW Offset HelpContext0Ptrs - DW Offset HelpContext1Ptrs - DW Offset HelpContext2Ptrs - DW Offset NoHelpContext - DW Offset HelpContext4Ptrs - DW Offset NoHelpContext - DW Offset NoHelpContext - DW Offset HelpContext7Ptrs - DW Offset NoHelpContext - DW Offset HelpContext9Ptrs - DW Offset NoHelpContext - DW Offset NoHelpContext - DW Offset HelpContext12Ptrs - DW Offset NoHelpContext - DW Offset NoHelpContext - -NoHelpContext DW Offset NewLine - DW Offset HelpGlobal_0 - DW Offset HelpGlobal_1 - DW Offset HelpGlobal_37 - DW Offset HelpGlobal_3 - DW Offset HelpGlobal_4 - DW Offset HelpGlobal_20 - DW Offset HelpGlobal_9 - DW Offset HelpGlobal_10 - DW Offset HelpGlobal_19 - DW Offset HelpGlobal_11 - DW Offset HelpGlobal_12 - DW Offset HelpGlobal_33 - DW Offset HelpGlobal_13 - DW Offset HelpGlobal_5 - DW Offset HelpGlobal_6 - DW Offset HelpGlobal_2 - DW Offset HelpGlobal_7 - DW Offset HelpGlobal_8 - DW Offset HelpGlobal_32 - DW Offset NewLine - DW Offset HelpGlobal_17 - DW Offset HelpGlobal_31 - DW Offset HelpGlobal_18 - DW Offset NewLine - DW Offset HelpGlobal_16 - DW Offset HelpGlobal_34 - DW Offset HelpGlobal_35 - DW Offset HelpGlobal_36 - DW Offset HelpGlobal_21 - DW Offset HelpGlobal_14 - DW Offset HelpGlobal_15 - DW 0 - -HelpContext0Ptrs DW Offset HelpContext0_26 - DW Offset HelpContext0_0 - DW Offset HelpContext0_27 - DW Offset NewLine - DW Offset HelpContext0_6 - DW Offset HelpContext0_28 - DW Offset HelpContext0_8 - DW Offset HelpContext0_9 - DW Offset HelpContext0_13 - DW Offset HelpContext0_14 - DW Offset HelpContext0_12 - DW Offset HelpContext0_15 - DW Offset NewLine - DW Offset HelpContext0_30 - DW Offset HelpContext0_29 - DW Offset NewLine - DW Offset Divider - DW Offset NewLine - DW Offset HelpGlobal_0 - DW Offset HelpGlobal_1 - DW Offset HelpGlobal_37 - DW Offset HelpGlobal_3 - DW Offset HelpGlobal_4 - DW Offset HelpGlobal_9 - DW Offset HelpGlobal_10 - DW Offset HelpGlobal_19 - DW Offset HelpGlobal_11 - DW Offset HelpGlobal_12 - DW Offset HelpGlobal_33 - DW Offset HelpGlobal_13 - DW Offset HelpGlobal_5 - DW Offset HelpGlobal_6 - DW Offset HelpGlobal_2 - DW Offset HelpGlobal_7 - DW Offset HelpGlobal_8 - DW Offset HelpGlobal_32 - DW Offset NewLine - DW Offset HelpGlobal_17 - DW Offset HelpGlobal_31 - DW Offset HelpGlobal_18 - DW Offset NewLine - DW Offset HelpGlobal_16 - DW Offset HelpGlobal_34 - DW Offset HelpGlobal_35 - DW Offset HelpGlobal_36 - DW Offset HelpGlobal_21 - DW Offset HelpGlobal_14 - DW Offset HelpGlobal_15 - DW Offset NewLine - DW Offset Divider - DW 0 - -HelpContext4Ptrs DW Offset HelpContext4_0 - DW Offset HelpContext4_1 - DW Offset HelpContext4_2 - DW Offset NewLine - DW Offset HelpContext0_6 - DW Offset HelpContext0_28 - DW Offset HelpContext0_8 - DW Offset HelpContext0_9 - DW Offset HelpContext0_13 - DW Offset HelpContext0_14 - DW Offset HelpContext0_12 - DW Offset HelpContext0_15 - DW Offset NewLine - DW Offset Divider - DW Offset NewLine - DW Offset HelpGlobal_0 - DW Offset HelpGlobal_1 - DW Offset HelpGlobal_37 - DW Offset HelpGlobal_3 - DW Offset HelpGlobal_4 - DW Offset HelpGlobal_20 - DW Offset HelpGlobal_9 - DW Offset HelpGlobal_22 - DW Offset HelpGlobal_10 - DW Offset HelpGlobal_19 - DW Offset HelpGlobal_11 - DW Offset HelpGlobal_12 - DW Offset HelpGlobal_33 - DW Offset HelpGlobal_13 - DW Offset HelpGlobal_5 - DW Offset HelpGlobal_23 - DW Offset HelpGlobal_6 - DW Offset HelpGlobal_2 - DW Offset HelpGlobal_7 - DW Offset HelpGlobal_8 - DW Offset HelpGlobal_32 - DW Offset NewLine - DW Offset HelpGlobal_17 - DW Offset HelpGlobal_31 - DW Offset HelpGlobal_18 - DW Offset NewLine - DW Offset HelpGlobal_16 - DW Offset HelpGlobal_34 - DW Offset HelpGlobal_35 - DW Offset HelpGlobal_36 - DW Offset HelpGlobal_21 - DW Offset HelpGlobal_14 - DW Offset HelpGlobal_15 - DW Offset NewLine - DW Offset Divider - DW 0 - -NewLine DB 0, 0 -Divider DB 2, 0FFh, 76, 154, 0 - -HelpContext0_26 DB 27, 0FFh, 1, 139, 0FFh, 26, 134, 0FFh, 1, 138, 0 -HelpContext0_0 DB 27, 0FFh, 1, 132, ' ', 0B9h, 0AAh, 0A1h, 0B8h, ' ', 0FFh, 1, 145, 0 -HelpContext0_27 DB 27, 0FFh, 1, 137, 0FFh, 26, 143, 0FFh, 1, 150, 0 - -HelpContext4_0 DB 22, 0FFh, 1, 139, 0FFh, 33, 134, 0FFh, 1, 138, 0 -HelpContext4_1 DB 22, 0FFh, 1, 132, ' ', 0B9h, 0AAh, 0A1h, 8Dh, 89h, ' ', 0FFh, 1, 145, 0 -HelpContext4_2 DB 22, 0FFh, 1, 137, 0FFh, 33, 143, 0FFh, 1, 150, 0 - -HelpContext0_6 DB 3, 0B9h, 0ADh, '.', 0 -HelpContext0_28 DB 5, 'N', 0FFh, 17, ' ', 83h, 0B4h, 85h, 0 -HelpContext0_8 DB 5, '-', 0FFh, 17, ' End ', 0BEh, 'song mark', 0 -HelpContext0_9 DB 5, '+', 0FFh, 17, ' Skip ', 0B1h, 0B4h, 0B9h, 'mark', 0 -HelpContext0_13 DB 5, 0C1h, 0FFh, 15, ' ', 83h, 0BFh, 85h, 0 -HelpContext0_14 DB 5, 0C2h, 0FFh, 15, ' ', 84h, 0BFh, 85h, 0 -HelpContext0_12 DB 5, 'Tab/', 82h, 'Tab', 0FFh, 5, ' ', 9Ch, 0B1h, 0B4h, 0B6h, 0 -HelpContext0_15 DB 5, 81h, 'F7', 0FFh, 11, ' ', 9Fh, 'this ', 0B9h, 0B4h, 0 - -HelpContext0_30 DB 3, 0B8h, 0ADh, '.', 0 -HelpContext0_29 DB 5, 'L/M/R/S', 0FFh, 11, ' ', 0A6h, 0B5h, 0B1h, 'Left/Middle/Right/Surround', 0 - -HelpGlobal_0 DB 3, 'G', 0B2h, 0ADh, '.', 0 -HelpGlobal_1 DB 5, 'F1', 0FFh, 16, ' Help (Context sensitive!)', 0 -HelpGlobal_37 DB 5, 82h, 'F1', 0FFh, 10, ' MIDI Screen', 0 -HelpGlobal_3 DB 5, 'F2', 0FFh, 16, ' ', 86h, 'Editor / ', 86h, 'Editor Options', 0 -HelpGlobal_4 DB 5, 'F3', 0FFh, 16, ' ', 94h, 0AAh, 0 -HelpGlobal_20 DB 5, 81h, 'F3', 0FFh, 11, ' ', 94h, 0ABh, 0 -HelpGlobal_9 DB 5, 'F4', 0FFh, 16, ' ', 8Eh, 0AAh, 0 -HelpGlobal_22 DB 5, 81h, 'F4', 0FFh, 11, ' ', 8Eh, 0ABh, 0 -HelpGlobal_10 DB 5, 'F5', 0FFh, 16, ' ', 9Fh, 'Information / ', 9Fh, 'song', 0 -HelpGlobal_19 DB 5, 81h, 'F5', 0FFh, 11, ' ', 9Fh, 'Song', 0 -HelpGlobal_11 DB 5, 'F6', 0FFh, 16, ' ', 9Fh, 0A2h, 85h, 0 -HelpGlobal_12 DB 5, 82h, 'F6', 0FFh, 10, ' ', 9Fh, 'song ', 0A9h, 0A2h, 0B9h, 0 -HelpGlobal_33 DB 5, 'F7', 0FFh, 16, ' ', 9Fh, 0A9h, 'mark / ', 0A2h, 'row', 0 -HelpGlobal_13 DB 5, 'F8', 0FFh, 16, ' Stop Playback', 0 -HelpGlobal_5 DB 5, 'F9', 0FFh, 16, ' Load Module', 0 -HelpGlobal_23 DB 5, 82h, 'F9', 0FFh, 10, ' Message Editor', 0 -HelpGlobal_6 DB 5, 'F10', 0FFh, 15, ' Save Module', 0 -HelpGlobal_2 DB 5, 'F11', 0FFh, 15, ' ', 0B9h, 0AAh, 0A1h, 0B8h, 0 -HelpGlobal_7 DB 3, '2*F11', 0FFh, 15, ' ', 0B9h, 0AAh, 0A1h, 8Dh, 89h, 0 -HelpGlobal_8 DB 5, 'F12', 0FFh, 15, ' Song Variables & Directory Configuration', 0 -HelpGlobal_32 DB 5, 81h, 'F12', 0FFh, 10, ' Palette Configuration', 0 - -HelpGlobal_17 DB 5, '{ }', 0FFh, 15, ' ', 93h, '/', 92h, ' playback ', 0C4h, 0 -HelpGlobal_31 DB 5, '[ ]', 0FFh, 15, ' ', 93h, '/', 92h, ' g', 0B2h, 8Ah, 0 -HelpGlobal_18 DB 5, 80h, 'F1 -> ', 80h, 'F8 ', 9Dh, 0A3h, 's 1->8', 0 - -HelpGlobal_16 DB 5, 81h, 'D', 0FFh, 12, ' DOS Shell', 0 -HelpGlobal_34 DB 5, 81h, 'E', 0FFh, 12, ' Refresh screen ', 0A1h, 'reset cache identification', 0 -HelpGlobal_35 DB 5, 81h, 'I', 0FFh, 12, ' Reinitialise sound driver', 0 -HelpGlobal_36 DB 5, 81h, 'M', 0FFh, 12, ' ', 9Dh, 'mouse cursor', 0 -HelpGlobal_21 DB 5, 81h, 'N', 0FFh, 12, ' New Song', 0 -HelpGlobal_14 DB 5, 81h, 'Q', 0FFh, 12, ' Quit ', 0B1h, 'DOS', 0 -HelpGlobal_15 DB 5, 81h, 'S', 0FFh, 12, ' Save ', 0A2h, 'song', 0 - - -HelpContext1Ptrs Label Word - DW Offset HelpContext1_0 - DW Offset HelpContext1_1 - DW Offset HelpContext1_2 - DW Offset NewLine - DW Offset HelpContext1_3 - DW Offset NewLine - DW Offset HelpContext1_200 - DW Offset HelpContext1_201 - DW Offset HelpContext1_202 - DW Offset HelpContext1_203 - DW Offset HelpContext1_204 - DW Offset HelpContext1_205 - DW Offset HelpContext1_206 - DW Offset HelpContext1_207 - DW Offset HelpContext1_208 - DW Offset NewLine - DW Offset HelpContext1_299 - DW Offset HelpContext1_4 - DW Offset HelpContext1_5 - DW Offset HelpContext1_6 - DW Offset HelpContext1_7 - DW Offset HelpContext1_8 - DW Offset HelpContext1_9 - DW Offset HelpContext1_10 - DW Offset HelpContext1_11 - DW Offset HelpContext1_12 - DW Offset HelpContext1_13 - DW Offset HelpContext1_14 - DW Offset HelpContext1_15 - DW Offset HelpContext1_16 - DW Offset HelpContext1_17 - DW Offset HelpContext1_18 - DW Offset HelpContext1_19 - DW Offset HelpContext1_20 - DW Offset HelpContext1_21 - DW Offset HelpContext1_22 - DW Offset HelpContext1_23 - DW Offset HelpContext1_24 - DW Offset HelpContext1_141 - DW Offset HelpContext1_142 - DW Offset HelpContext1_143 - DW Offset HelpContext1_25 - DW Offset HelpContext1_26 - DW Offset HelpContext1_135 - DW Offset HelpContext1_136 - DW Offset HelpContext1_137 - DW Offset HelpContext1_27 - DW Offset HelpContext1_28 - DW Offset HelpContext1_29 - DW Offset HelpContext1_30 - DW Offset HelpContext1_31 - DW Offset HelpContext1_32 - DW Offset HelpContext1_33 - DW Offset HelpContext1_34 - DW Offset HelpContext1_35 - DW Offset HelpContext1_36 - DW Offset HelpContext1_45 - DW Offset HelpContext1_46 - DW Offset HelpContext1_47 - DW Offset HelpContext1_48 - DW Offset HelpContext1_49 - DW Offset HelpContext1_50 - DW Offset HelpContext1_51 - DW Offset HelpContext1_62 - DW Offset HelpContext1_63 - DW Offset HelpContext1_64 - DW Offset HelpContext1_65 - DW Offset HelpContext1_66 - DW Offset HelpContext1_52 - DW Offset HelpContext1_53 - DW Offset HelpContext1_144 - DW Offset HelpContext1_145 - DW Offset HelpContext1_153 - DW Offset HelpContext1_154 - DW Offset HelpContext1_155 - DW Offset HelpContext1_156 - DW Offset HelpContext1_157 - DW Offset HelpContext1_162 - DW Offset HelpContext1_168 - DW Offset HelpContext1_169 - DW Offset HelpContext1_170 - DW Offset HelpContext1_171 - DW Offset HelpContext1_54 - DW Offset HelpContext1_55 - DW Offset HelpContext1_56 - DW Offset HelpContext1_57 - DW Offset HelpContext1_146 - DW Offset HelpContext1_58 - DW Offset HelpContext1_59 - DW Offset HelpContext1_60 - DW Offset HelpContext1_61 - DW Offset HelpContext1_179 - DW Offset HelpContext1_180 - DW Offset HelpContext1_67 - DW Offset HelpContext1_68 - DW Offset HelpContext1_69 - DW Offset HelpContext1_70 - DW Offset HelpContext1_138 - DW Offset HelpContext1_139 - DW Offset HelpContext1_140 - DW Offset HelpContext1_71 - DW Offset HelpContext1_72 - DW Offset HelpContext1_73 - DW Offset NewLine - DW Offset Divider - DW Offset NewLine - DW Offset HelpContext1_74 - DW Offset HelpContext1_114 - DW Offset HelpContext1_115 - DW Offset HelpContext1_134 - DW Offset HelpContext1_75 - DW Offset HelpContext1_76 - DW Offset HelpContext1_77 - DW Offset HelpContext1_78 - DW Offset HelpContext1_79 - DW Offset HelpContext1_80 - DW Offset HelpContext1_81 - DW Offset HelpContext1_181 - DW Offset NewLine - DW Offset HelpContext1_82 - DW Offset HelpContext1_83 - DW Offset HelpContext1_163 - DW Offset HelpContext1_84 - DW Offset HelpContext1_85 - DW Offset NewLine - DW Offset HelpContext1_86 - DW Offset HelpContext1_127 - DW Offset NewLine - DW Offset HelpContext1_87 - DW Offset HelpContext1_164 - DW Offset HelpContext1_129 - DW Offset HelpContext1_88 - DW Offset HelpContext1_131 - DW Offset HelpContext1_90 - DW Offset HelpContext1_89 - DW Offset HelpContext1_160 - DW Offset HelpContext1_91 - DW Offset HelpContext1_92 - DW Offset HelpContext1_93 - DW Offset NewLine - DW Offset HelpContext1_116 - DW Offset HelpContext1_124 - DW Offset NewLine - DW Offset HelpContext1_130 - DW Offset HelpContext1_117 - DW Offset HelpContext1_161 - DW Offset NewLine - DW Offset HelpContext1_166 - DW Offset HelpContext1_174 - DW Offset HelpContext1_300 - DW Offset NewLine - DW Offset HelpContext1_176 - DW Offset NewLine - DW Offset HelpContext1_118 - DW Offset HelpContext1_119 - DW Offset HelpContext1_120 - DW Offset HelpContext1_121 - DW Offset HelpContext1_122 - DW Offset HelpContext1_123 - DW Offset HelpContext1_128 - DW Offset NewLine - DW Offset HelpContext1_167 - DW Offset NewLine - DW Offset HelpContext1_159 - DW Offset NewLine - DW Offset HelpContext1_94 - DW Offset HelpContext1_95 - DW Offset HelpContext1_96 - DW Offset HelpContext1_97 - DW Offset HelpContext1_98 - DW Offset HelpContext1_165 - DW Offset NewLine - DW Offset HelpContext1_99 - DW Offset NewLine - DW Offset HelpContext1_113 - DW Offset HelpContext1_100 - DW Offset HelpContext1_101 - DW Offset HelpContext1_102 - DW Offset HelpContext1_103 - DW Offset HelpContext1_104 - DW Offset HelpContext1_133 - DW Offset HelpContext1_105 - DW Offset HelpContext1_106 - DW Offset HelpContext1_132 - DW Offset HelpContext1_107 - DW Offset NewLine - DW Offset HelpContext1_108 - DW Offset HelpContext1_109 - DW Offset HelpContext1_110 - DW Offset HelpContext1_111 - DW Offset HelpContext1_173 - DW Offset NewLine - DW Offset HelpContext1_125 - DW Offset HelpContext1_126 - DW Offset NewLine - DW Offset HelpContext1_112 - DW Offset HelpContext1_175 - DW Offset NewLine - DW Offset HelpContext1_147 - DW Offset HelpContext1_148 - DW Offset HelpContext1_149 - DW Offset NewLine - DW Offset HelpContext1_152 - DW Offset HelpContext1_158 - DW Offset NewLine - DW Offset HelpContext1_150 - DW Offset HelpContext1_151 - DW Offset NewLine - DW Offset HelpContext1_172 - DW Offset HelpContext1_177 - DW Offset HelpContext1_178 - DW Offset NewLine - DW Offset Divider - DW Offset NewLine - DW Offset HelpGlobal_0 - DW Offset HelpGlobal_1 - DW Offset HelpGlobal_37 - DW Offset HelpGlobal_3 - DW Offset HelpGlobal_4 - DW Offset HelpGlobal_20 - DW Offset HelpGlobal_9 - DW Offset HelpGlobal_22 - DW Offset HelpGlobal_10 - DW Offset HelpGlobal_19 - DW Offset HelpGlobal_11 - DW Offset HelpGlobal_12 - DW Offset HelpGlobal_33 - DW Offset HelpGlobal_13 - DW Offset HelpGlobal_5 - DW Offset HelpGlobal_23 - DW Offset HelpGlobal_6 - DW Offset HelpGlobal_2 - DW Offset HelpGlobal_7 - DW Offset HelpGlobal_8 - DW Offset HelpGlobal_32 - DW Offset NewLine - DW Offset HelpGlobal_17 - DW Offset HelpGlobal_31 - DW Offset HelpGlobal_18 - DW Offset NewLine - DW Offset HelpGlobal_16 - DW Offset HelpGlobal_34 - DW Offset HelpGlobal_35 - DW Offset HelpGlobal_36 - DW Offset HelpGlobal_21 - DW Offset HelpGlobal_14 - DW Offset HelpGlobal_15 - DW Offset NewLine - DW Offset Divider - - Comment & - - DW Offset NewLine - DW Offset HelpHexTable0 - DW Offset HelpHexTable1 - DW Offset HelpHexTable2 - DW Offset NewLine - DW Offset HelpHexTable3 - DW Offset Divider - DW Offset HelpHexTable4 - DW Offset HelpHexTable5 - DW Offset HelpHexTable6 - DW Offset HelpHexTable7 - DW Offset HelpHexTable8 - DW Offset HelpHexTable9 - DW Offset HelpHexTable10 - DW Offset HelpHexTable11 - DW Offset HelpHexTable12 - DW Offset HelpHexTable13 - DW Offset HelpHexTable14 - DW Offset HelpHexTable15 - DW Offset HelpHexTable16 - DW Offset HelpHexTable17 - DW Offset HelpHexTable18 - DW Offset HelpHexTable19 - DW Offset HelpHexTable20 - DW Offset HelpHexTable21 - DW Offset HelpHexTable22 - DW Offset HelpHexTable23 - DW Offset HelpHexTable24 - DW Offset HelpHexTable25 - DW Offset HelpHexTable26 - DW Offset HelpHexTable27 - DW Offset HelpHexTable28 - DW Offset HelpHexTable29 - DW Offset HelpHexTable30 - DW Offset HelpHexTable31 - DW Offset HelpHexTable32 - DW Offset HelpHexTable33 - DW Offset HelpHexTable34 - DW Offset HelpHexTable35 - DW Offset Divider - - & - DW 0 - -HelpContext1_0 DB 32, 0FFh, 1, 139, 0FFh, 16, 134, 0FFh, 1, 138, 0 -HelpContext1_1 DB 32, 0FFh, 1, 132, ' ', 86h, 'Edit ', 0FFh, 1, 145, 0 -HelpContext1_2 DB 32, 0FFh, 1, 137, 0FFh, 16, 143, 0FFh, 1, 150, 0 -HelpContext1_3 DB 3, 'Summary ', 0BEh, 'Effects.', 0 - -HelpContext1_200 DB 4, 89h, 'Column ', 0BDh, 's.', 0 -HelpContext1_201 DB 5, 'Ax', 8Bh, 8Ah, 87h, 0 -HelpContext1_202 DB 5, 'Bx', 8Bh, 8Ah, 88h, 0 -HelpContext1_203 DB 5, 'Cx ', 89h, 87h, 0 -HelpContext1_204 DB 5, 'Dx ', 89h, 88h, 0 -HelpContext1_205 DB 5, 'Ex ', 0BAh, 88h, 0 -HelpContext1_206 DB 5, 'Fx ', 0BAh, 87h, 0 -HelpContext1_207 DB 5, 'Gx ', 0BCh, 0B1h, 0A5h, 0A0h, 0C4h, 'x', 0 -HelpContext1_208 DB 5, 'Hx V', 0B3h, 0A0h, 0C6h, 'x', 0 - -HelpContext1_299 DB 4, 'General ', 0BDh, 's.', 0 - -HelpContext1_4 DB 5, 'Axx ', 0A6h, 'song ', 0C4h, '(hex)', 0 -HelpContext1_5 DB 5, 'Bxx Jump ', 0B1h, 0B9h, '(hex)', 0 -HelpContext1_6 DB 5, 'Cxx Break ', 0B1h, 'row xx (hex) ', 0BEh, 0B4h, 85h, 0 -HelpContext1_7 DB 5, 'D0x ', 89h, 88h, 0 -HelpContext1_8 DB 5, 'Dx0 ', 89h, 87h, 0 -HelpContext1_9 DB 5, 'DFx', 8Bh, 8Ah, 88h, 0 -HelpContext1_10 DB 5, 'DxF', 8Bh, 8Ah, 87h, 0 -HelpContext1_11 DB 5, 'Exx ', 0BAh, 88h, 'x', 0 -HelpContext1_12 DB 5, 'EFx', 8Bh, 0BBh, 88h, 0 -HelpContext1_13 DB 5, 'EEx Extra fine ', 0BBh, 88h, 0 -HelpContext1_14 DB 5, 'Fxx ', 0BAh, 87h, 'x', 0 -HelpContext1_15 DB 5, 'FFx', 8Bh, 0BBh, 87h, 0 -HelpContext1_16 DB 5, 'FEx Extra fine ', 0BBh, 87h, 0 -HelpContext1_17 DB 5, 'Gxx ', 0BCh, 0B1h, 0A5h, 0A0h, 0C4h, 'xx', 0 -HelpContext1_18 DB 5, 'Hxy V', 0B3h, 0A0h, 0C5h, 0 -HelpContext1_19 DB 5, 'Ixy Tremor ', 0A0h, 'ontime x ', 0A1h, 'offtime y', 0 -HelpContext1_20 DB 5, 'Jxy Arpeggio ', 0A0h, 'halftones x ', 0A1h, 'y', 0 -HelpContext1_21 DB 5, 'Kxx', 9Bh, 'H00 & Dxx', 0 -HelpContext1_22 DB 5, 'Lxx', 9Bh, 'G00 & Dxx', 0 -HelpContext1_23 DB 5, 'Mxx ', 0A6h, 0A4h, 8Ah, 0B1h, 'xx (0->40h)', 0 -HelpContext1_24 DB 5, 'N0x ', 8Dh, 8Ah, 88h, 0 -HelpContext1_141 DB 5, 'Nx0 ', 8Dh, 8Ah, 87h, 0 -HelpContext1_142 DB 5, 'NFx', 8Bh, 0A4h, 8Ah, 88h, 0 -HelpContext1_143 DB 5, 'NxF', 8Bh, 0A4h, 8Ah, 87h, 0 -HelpContext1_25 DB 5, 'Oxx ', 0A6h, 95h, ' offset ', 0B1h, 'yxx00h, y set ', 0A0h, 'SAy', 0 -HelpContext1_26 DB 5, 'P0x ', 0B8h, 0A7h, 0B1h, 'right ', 0B0h, 'x', 0 -HelpContext1_135 DB 5, 'Px0 ', 0B8h, 0A7h, 0B1h, 'left ', 0B0h, 'x', 0 -HelpContext1_136 DB 5, 'PFx', 8Bh, 0B5h, 0A7h, 0B1h, 'right ', 0B0h, 'x', 0 -HelpContext1_137 DB 5, 'PxF', 8Bh, 0B5h, 0A7h, 0B1h, 'left ', 0B0h, 'x', 0 -HelpContext1_27 DB 5, 'Qxy Retrigger ', 0A5h, 'every y ticks ', 0A0h, 8Ah, 'modifier x', 0 -HelpContext1_28 DB 7, 'Values for x:', 0 -HelpContext1_29 DB 9, '0: No ', 8Ah, 0C9h, 0FFh, 8, ' 8: Not used', 0 -HelpContext1_30 DB 9, '1: -1', 0FFh, 23, ' 9: +1', 0 -HelpContext1_31 DB 9, '2: -2', 0FFh, 23, ' A: +2', 0 -HelpContext1_32 DB 9, '3: -4', 0FFh, 23, ' B: +4', 0 -HelpContext1_33 DB 9, '4: -8', 0FFh, 23, ' C: +8', 0 -HelpContext1_34 DB 9, '5: -16', 0FFh, 22, ' D: +16', 0 -HelpContext1_35 DB 9, '6: *2/3', 0FFh, 21, ' E: *3/2', 0 -HelpContext1_36 DB 9, '7: *1/2', 0FFh, 21, ' F: *2', 0 -; HelpContext1_37 DB 9, '8: Not used', 0 -; HelpContext1_38 DB 9, '9: +1', 0 -; HelpContext1_39 DB 9, 'A: +2', 0 -; HelpContext1_40 DB 9, 'B: +4', 0 -; HelpContext1_41 DB 9, 'C: +8', 0 -; HelpContext1_42 DB 9, 'D: +16', 0 -; HelpContext1_43 DB 9, 'E: *3/2', 0 -; HelpContext1_44 DB 9, 'F: *2', 0 -HelpContext1_45 DB 5, 'Rxy Tremelo ', 0A0h, 0C5h, 0 -HelpContext1_46 DB 5, 0FEh, 7, 'S0x ', 0A6h, 'filter', 0 -HelpContext1_47 DB 5, 0FEh, 7, 'S1x ', 0A6h, 'glissando control', 0 -HelpContext1_48 DB 5, 0FEh, 7, 'S2x ', 0A6h, 'finetune', 0 -HelpContext1_49 DB 5, 'S3x ', 0A6h, 'v', 0B3h, 9Ah, 0 -HelpContext1_50 DB 5, 'S4x ', 0A6h, 'tremelo ', 9Ah, 0 -HelpContext1_51 DB 5, 'S5x ', 0A6h, 'panbrello ', 9Ah, 0 -HelpContext1_62 DB 7, 'Waveforms for commands S3x, S4x ', 0A1h, 'S5x:', 0 -HelpContext1_63 DB 9, '0: Sine wave', 0 -HelpContext1_64 DB 9, '1: Ramp down', 0 -HelpContext1_65 DB 9, '2: Square wave', 0 -HelpContext1_66 DB 9, '3: Random wave', 0 -HelpContext1_52 DB 5, 'S6x ', 86h, 'delay for x ticks', 0 -HelpContext1_53 DB 5, 'S70', 0C0h, 0A5h, 'cut', 0 -HelpContext1_144 DB 5, 'S71', 0C0h, 0A5h, 'off', 0 -HelpContext1_145 DB 5, 'S72', 0C0h, 0A5h, 'fade', 0 -HelpContext1_153 DB 5, 'S73', 96h, 0A5h, 'cut', 0 -HelpContext1_154 DB 5, 'S74', 96h, 'continue', 0 -HelpContext1_155 DB 5, 'S75', 96h, 0A5h, 'off', 0 -HelpContext1_156 DB 5, 'S76', 96h, 0A5h, 'fade', 0 -HelpContext1_157 DB 5, 'S77 ', 0ACh, 'off ', 8Ah, 8Ch, 0 -HelpContext1_162 DB 5, 'S78 ', 0ACh, 'on ', 8Ah, 8Ch, 0 -HelpContext1_168 DB 5, 'S79 ', 0ACh, 'off ', 0B5h, 8Ch, 0 -HelpContext1_169 DB 5, 'S7A ', 0ACh, 'on ', 0B5h, 8Ch, 0 -HelpContext1_170 DB 5, 'S7B ', 0ACh, 'off ', 0BBh, 8Ch, 0 -HelpContext1_171 DB 5, 'S7C ', 0ACh, 'on ', 0BBh, 8Ch, 0 -HelpContext1_54 DB 5, 'S8x ', 0A6h, 0B5h, 'position', 0 -HelpContext1_55 DB 5, 'S91 ', 0A6h, 'surround sound', 0 -HelpContext1_56 DB 5, 'SAy ', 0A6h, 'high value ', 0BEh, 95h, ' offset yxx00h', 0 -HelpContext1_57 DB 5, 'SB0 ', 0A6h, 'loopback point', 0 -HelpContext1_146 DB 5, 'SBx Loop x times ', 0B1h, 'loopback point', 0 -HelpContext1_58 DB 5, 'SCx ', 0C3h, 'cut after x ticks', 0 -HelpContext1_59 DB 5, 'SDx ', 0C3h, 'delay for x ticks', 0 -HelpContext1_60 DB 5, 'SEx ', 86h, 'delay for x rows', 0 -HelpContext1_61 DB 5, 'SFx ', 0A6h, 'parameterised MIDI Macro', 0 -HelpContext1_179 DB 5, 'T0x ', 97h, 88h, 0 -HelpContext1_180 DB 5, 'T1x ', 97h, 87h, 0 -HelpContext1_67 DB 5, 'Txx ', 0A6h, 97h, 0B1h, 'xx (20h->0FFh)', 0 -HelpContext1_68 DB 5, 'Uxy', 8Bh, 'v', 0B3h, 0A0h, 0C5h, 0 -HelpContext1_69 DB 5, 'Vxx ', 0A6h, 'g', 0B2h, 8Ah, 0B1h, 'xx (0->80h)', 0 -HelpContext1_70 DB 5, 'W0x G', 0B2h, 8Ah, 88h, 0 -HelpContext1_138 DB 5, 'Wx0 G', 0B2h, 8Ah, 87h, 0 -HelpContext1_139 DB 5, 'WFx', 8Bh, 'g', 0B2h, 8Ah, 88h, 0 -HelpContext1_140 DB 5, 'WxF', 8Bh, 'g', 0B2h, 8Ah, 87h, 0 -HelpContext1_71 DB 5, 'Xxx ', 0A6h, 0B5h, 'position (0->0FFh)', 0 -HelpContext1_72 DB 5, 'Yxy Panbrello ', 0A0h, 0C5h, 0 -HelpContext1_73 DB 5, 'Zxx MIDI Macros', 0 - -HelpContext1_74 DB 3, 86h, 'Edit ', 0ADh, '.', 0 -HelpContext1_114 DB 5, 'Grey +,-', 0FFh, 9, ' ', 0C7h, 85h, 0CDh, 0 -HelpContext1_115 DB 5, 'Shift +,-', 0FFh, 8, ' ', 0C7h, '4 ', 85h, 0CDh, 0 -HelpContext1_134 DB 5, "Ctrl +,-", 0FFh, 9, " ", 0C7h, "order's ", 85h, 0CDh, 0 -HelpContext1_75 DB 5, '0-9', 0FFh, 14, ' ', 0C8h, 'octave/volume/', 8Fh, 0 -HelpContext1_76 DB 5, '0-9, A-F', 0FFh, 9, ' ', 0C8h, 0BDh, 'value', 0 -HelpContext1_77 DB 5, 'A-Z', 0FFh, 14, ' ', 0C8h, 0BDh, 0 -HelpContext1_78 DB 5, '. (Period)', 0FFh, 7, ' Clear field(s)', 0 -HelpContext1_79 DB 5, '1', 0FFh, 16, ' ', 0C3h, 'cut (^^^)', 0 -HelpContext1_80 DB 5, '`', 0FFh, 16, ' ', 0C3h, 'off (', 0FFh, 3, 'Í) / ', 0B8h, 9Dh, 0 - -HelpContext1_81 DB 5, 'Spacebar', 0FFh, 9, ' Use last note/', 8Fh, '/volume/', 0BDh, '/', 0BDh, 'value', 0 -HelpContext1_181 DB 5, 'Caps Lock+Key', 0FFh, 4, ' Preview ', 0A5h, 0 -HelpContext1_82 DB 5, 99h, 0FFh, 11, ' Get default note/', 8Fh, '/volume/', 0BDh, 0 -HelpContext1_83 DB 5, '< or ', 81h, 'Up', 0FFh, 5, ' ', 93h, ' ', 8Fh, 0 -HelpContext1_163 DB 5, '> or ', 81h, 'Down ', 92h, ' ', 8Fh, 0 -HelpContext1_84 DB 5, 'Grey /,*', 0FFh, 9, ' ', 93h, '/', 92h, ' octave', 0 -HelpContext1_85 DB 5, ', (Comma)', 0FFh, 8, ' ', 9Dh, 'edit mask for ', 0A2h, 'field', 0 -HelpContext1_86 DB 5, 0C1h, '/', 0C2h, 0FFh, 10, ' ', 9Eh, 0BFh, 'row to/', 0A9h, 0A2h, 0A3h, 0 -HelpContext1_127 DB 5, 80h, 0C1h, '/', 0C2h, 0FFh, 6, ' ', 9Eh, 'an entire row to/', 0A9h, 85h, 0CDh, 0 -HelpContext1_87 DB 5, 'Up/Down', 0FFh, 10, ' ', 9Ch, 0B7h, 0B0h, 'the skipvalue (set ', 0A0h, 'Alt 0-9)', 0 -HelpContext1_164 DB 5, 81h, 'Home/End', 0FFh, 4, ' ', 9Ch, 0B7h, 0B0h, '1 row', 0 -HelpContext1_129 DB 5, 80h, 'Up/Down', 0FFh, 6, ' ', 0BCh, 85h, 0B7h, 0B0h, '1 row', 0 -HelpContext1_88 DB 5, 'Left/Right', 0FFh, 7, ' ', 9Ch, 'cursor left/right', 0 -HelpContext1_131 DB 5, 80h, 'Left/Right ', 9Ch, 'forwards/backwards one ', 0A3h, 0 -HelpContext1_90 DB 5, 'Tab/', 82h, 'Tab', 0FFh, 4, ' ', 9Ch, 'forwards/backwards ', 0B1h, 0A5h, 'column', 0 -HelpContext1_89 DB 5, 'PgUp/PgDn', 0FFh, 8, ' ', 9Ch, 0B7h, 'n lines (n=Row Hilight Major)', 0 -HelpContext1_160 DB 5, 81h, 'PgUp/PgDn ', 9Ch, 0B1h, 'top/bottom ', 0BEh, 85h, 0 -HelpContext1_91 DB 5, 'Home', 0FFh, 13, ' ', 9Ch, 0B1h, 'start ', 0BEh, 'column/start of line/start of ', 85h, 0 -HelpContext1_92 DB 5, 'End', 0FFh, 14, ' ', 9Ch, 0B1h, 'end ', 0BEh, 'column/end ', 0BEh, 'line/end of', 85h, 0 -HelpContext1_93 DB 5, 'Backspace', 0FFh, 8, ' ', 9Ch, 0B1h, 'previous position (accounts for Multi', 0A3h, ')', 0 -HelpContext1_116 DB 5, 80h, 'N', 0FFh, 12, ' ', 9Dh, 'Multichannel mode for ', 0A2h, 0A3h, 0 -HelpContext1_124 DB 3, '2*', 80h, 'N', 0FFh, 12, ' Multichannel Selection menu', 0 -HelpContext1_130 DB 5, 80h, 99h, 0FFh, 7, ' Store ', 85h, 90h, 0 -HelpContext1_117 DB 5, 80h, 'Backspace', 0FFh, 4, ' Revert ', 85h, 90h, ' ', 0CDh, 0 -HelpContext1_161 DB 5, 81h, 'Backspace Undo - any function ', 0A0h, 0CDh, ' can be undone', 0 - -HelpContext1_166 DB 5, 81h, 'C', 0FFh, 11, ' ', 9Dh, 'centralise cursor', 0 -HelpContext1_174 DB 5, 81h, 'H', 0FFh, 11, ' ', 9Dh, 0A2h, 'row hilight', 0 -HelpContext1_300 DB 5, 81h, 'V', 0FFh, 11, ' ', 9Dh, 'default ', 8Ah, 'display', 0 - -HelpContext1_176 DB 5, 81h, 'F2', 0FFh, 10, ' ', 0A6h, 85h, 'length', 0 - -HelpContext1_118 DB 4, 'Track View Functions.', 0 -HelpContext1_119 DB 5, 80h, "T", 0FFh, 12, " Cycle ", 0A2h, "track's view", 0 -HelpContext1_120 DB 5, 80h, 'R', 0FFh, 12, ' Clear all ', 0CBh, 'views', 0 -HelpContext1_121 DB 5, 80h, 'H', 0FFh, 12, ' ', 9Dh, 0CBh, 'view divisions', 0 -HelpContext1_122 DB 5, 81h, '0', 0FFh, 11, ' Deselect ', 0A2h, 0CBh, 0 -HelpContext1_123 DB 5, 81h, '1 - ', 81h, '5 View ', 0A2h, 0CBh, 'in scheme 1-5', 0 -HelpContext1_128 DB 5, 81h, 'Left/Right ', 9Ch, 'left/right ', 0A8h, 0CBh, 'view columns', 0 - -HelpContext1_167 DB 5, 'L-Ctrl&Shift 1-4 Quick view scheme setup', 0 - -HelpContext1_159 DB 5, 81h, 'T', 0FFh, 11, ' ', 9Dh, 'View-', 8Dh, 'cursor-tracking', 0 - -HelpContext1_94 DB 4, 'Block Functions.', 0 -HelpContext1_95 DB 5, 80h, 'B', 0FFh, 12, ' ', 0CAh, 'beginning ', 0BEh, 0CCh, 0 -HelpContext1_96 DB 5, 80h, 'E', 0FFh, 12, ' ', 0CAh, 'end ', 0BEh, 0CCh, 0 -HelpContext1_97 DB 5, 80h, 'D', 0FFh, 12, ' Quick mark n/2n/4n/... lines (n=Row Hilight Major)', 0 -HelpContext1_98 DB 5, 80h, 'L', 0FFh, 12, ' ', 0CAh, 'entire column/', 85h, 0 -HelpContext1_165 DB 5, 82h, 'Arrows', 0FFh, 5, ' ', 0CAh, 0CCh, 0 - -HelpContext1_99 DB 5, 80h, 'U', 0FFh, 12, ' Unmark block/Release ', 98h, 'memory', 0 - -HelpContext1_113 DB 5, 80h, 'Q', 0FFh, 12, ' Raise notes ', 0B0h, 0BFh, 0AFh, 0CDh, 0 -HelpContext1_100 DB 5, 80h, 'A', 0FFh, 12, ' Lower notes ', 0B0h, 0BFh, 0AFh, 0CDh, 0 -HelpContext1_101 DB 5, 80h, 'S', 0FFh, 12, ' ', 0A6h, 8Eh, 0CDh, 0 -HelpContext1_102 DB 5, 80h, 'V', 0FFh, 12, ' ', 0A6h, 'volume/', 0B5h, 0CDh, 0 -HelpContext1_103 DB 5, 80h, 'W', 0FFh, 12, ' ', 0CEh, 'vol/pan not associated ', 0A0h, 0BFh, 'note/', 8Fh, ' ', 0CDh, 0 -HelpContext1_104 DB 5, 80h, 'K', 0FFh, 12, ' ', 0BCh, 'volume/', 0B5h, 'column ', 0CDh, 0 -HelpContext1_133 DB 3, '2*', 80h, 'K', 0FFh, 12, ' ', 0CEh, 'all volume/', 0B5h, 'controls ', 0CDh, 0 -HelpContext1_105 DB 5, 80h, 'J', 0FFh, 12, ' ', 89h, 'amplifier ', 0CDh, ' / Fast ', 8Ah, 'attenuate ', 0CDh, 0 -HelpContext1_106 DB 5, 80h, 'Z', 0FFh, 12, ' Cut ', 0CCh, 0CDh, 0 -HelpContext1_132 DB 5, 80h, 'X', 0FFh, 12, ' ', 0BCh, 0BDh, ' value ', 0CDh, 0 -HelpContext1_107 DB 3, '2*', 80h, 'X', 0FFh, 12, ' ', 0CEh, 'all ', 0BDh, ' ', 90h, ' ', 0CDh, 0 - -HelpContext1_108 DB 5, 80h, 'C', 0FFh, 12, ' Copy ', 0CCh, 'into ', 98h, 0 -HelpContext1_109 DB 5, 80h, 'P', 0FFh, 12, ' Paste ', 90h, ' ', 0A9h, 98h, 0CDh, 0 -HelpContext1_110 DB 5, 80h, 'O', 0FFh, 12, ' Overwrite ', 0A0h, 90h, ' ', 0A9h, 98h, ' ', 0CDh, 0 -HelpContext1_111 DB 5, 80h, 'M', 0FFh, 12, ' Mix each row ', 0A9h, 98h, 0A0h, 85h, 90h, ' ', 0CDh, 0 -HelpContext1_173 DB 3, '2*', 80h, 'M', 0FFh, 12, ' Mix each field ', 0A9h, 98h, 0A0h, 85h, 90h, 0 - -HelpContext1_125 DB 5, 80h, 'F', 0FFh, 12, ' Double ', 0CCh, 'length ', 0CDh, 0 -HelpContext1_126 DB 5, 80h, 'G', 0FFh, 12, ' Halve ', 0CCh, 'length ', 0CDh, 0 - -HelpContext1_112 DB 5, 80h, 'I', 0FFh, 12, ' Select Template mode / Fast ', 8Ah, 'amplify ', 0CDh, 0 - -HelpContext1_175 DB 5, 81h, 'J', 0FFh, 11, ' ', 9Dh, 'fast ', 8Ah, 'mode', 0 - -HelpContext1_147 DB 3, 'Playback Functions.', 0 -HelpContext1_148 DB 5, '4', 0FFh, 16, ' ', 9Fh, 0A5h, 'under cursor', 0 -HelpContext1_149 DB 5, '8', 0FFh, 16, ' ', 9Fh, 'row', 0 - -HelpContext1_152 DB 5, 81h, 'F6', 0FFh, 10, ' ', 9Fh, 0A9h, 0A2h, 'row', 0 -HelpContext1_158 DB 5, 81h, 'F7', 0FFh, 10, ' Set/Clear playback mark (for use ', 0A0h, 'F7)', 0 - -HelpContext1_150 DB 5, 80h, 'F9', 0FFh, 11, ' ', 9Dh, 0A2h, 0A3h, 0 -HelpContext1_151 DB 5, 80h, 'F10', 0FFh, 10, ' Solo ', 0A2h, 0A3h, 0 - -HelpContext1_172 DB 5, 'Scroll Lock', 0FFh, 6, ' ', 9Dh, 'playback tracing', 0 -HelpContext1_177 DB 5, 81h, 'Z', 0FFh, 11, ' ', 0C8h, 'MIDI playback trigger', 0 -HelpContext1_178 DB 5, 80h, 'Scroll Lock ', 9Dh, 'MIDI input', 0 - -HelpContext2Ptrs Label Word - DW Offset HelpContext2_0 - DW Offset HelpContext2_1 - DW Offset HelpContext2_2 - DW Offset NewLine - DW Offset HelpContext2_3 - DW Offset HelpContext2_10 - DW Offset HelpContext2_4 - DW Offset HelpContext2_5 - DW Offset NewLine - DW Offset HelpContext2_11 - DW Offset HelpContext2_23 - DW Offset HelpContext2_8 - DW Offset HelpContext2_6 - DW Offset HelpContext2_17 - DW Offset HelpContext2_18 - DW Offset HelpContext2_27 - DW Offset HelpContext2_30 - DW Offset HelpContext2_33 - DW Offset HelpContext2_7 - DW Offset HelpContext2_29 - DW Offset HelpContext2_28 - DW Offset HelpContext2_14 - DW Offset HelpContext2_19 - DW Offset HelpContext2_12 - DW Offset HelpContext2_13 - DW Offset HelpContext2_16 - DW Offset HelpContext2_15 - DW Offset HelpContext2_9 - DW Offset NewLine - DW Offset HelpContext2_31 - DW Offset HelpContext2_32 - DW Offset NewLine - DW Offset HelpContext2_26 - DW Offset NewLine - DW Offset HelpContext2_21 - DW Offset HelpContext2_22 - DW Offset HelpContext2_24 - DW Offset HelpContext2_25 - DW Offset NewLine - DW Offset Divider - DW Offset NewLine - DW Offset HelpGlobal_0 - DW Offset HelpGlobal_1 - DW Offset HelpGlobal_37 - DW Offset HelpGlobal_3 - DW Offset HelpGlobal_4 - DW Offset HelpGlobal_20 - DW Offset HelpGlobal_9 - DW Offset HelpGlobal_22 - DW Offset HelpGlobal_10 - DW Offset HelpGlobal_19 - DW Offset HelpGlobal_11 - DW Offset HelpGlobal_12 - DW Offset HelpGlobal_33 - DW Offset HelpGlobal_13 - DW Offset HelpGlobal_5 - DW Offset HelpGlobal_23 - DW Offset HelpGlobal_6 - DW Offset HelpGlobal_2 - DW Offset HelpGlobal_7 - DW Offset HelpGlobal_8 - DW Offset HelpGlobal_32 - DW Offset NewLine - DW Offset HelpGlobal_17 - DW Offset HelpGlobal_31 - DW Offset HelpGlobal_18 - DW Offset NewLine - DW Offset HelpGlobal_16 - DW Offset HelpGlobal_34 - DW Offset HelpGlobal_35 - DW Offset HelpGlobal_36 - DW Offset HelpGlobal_21 - DW Offset HelpGlobal_14 - DW Offset HelpGlobal_15 - DW Offset NewLine - DW Offset Divider - DW 0 ; End of list. - -HelpContext2_0 DB 31, 0FFh, 1, 139, 0FFh, 17, 134, 0FFh, 1, 138, 0 -HelpContext2_1 DB 31, 0FFh, 1, 132, ' ', 94h, 0AAh, ' ', 0FFh, 1, 145, 0 -HelpContext2_2 DB 31, 0FFh, 1, 137, 0FFh, 17, 143, 0FFh, 1, 150, 0 - -HelpContext2_3 DB 3, 94h, 0AAh, 0ADh, '.', 0 -HelpContext2_10 DB 5, 99h, 0FFh, 7, ' Load new ', 95h, 0 -HelpContext2_4 DB 5, 'Tab', 0FFh, 10, ' ', 9Ch, 0A8h, 'options', 0 -HelpContext2_5 DB 5, 'PgUp/PgDn', 0FFh, 4, ' ', 9Ch, 0B7h, '(when not on list)', 0 - -HelpContext2_11 DB 5, 80h, 'A', 0FFh, 8, ' Convert Signed to/', 0A9h, 'Unsigned ', 95h, 's', 0 -HelpContext2_23 DB 5, 80h, 'B', 0FFh, 8, ' Pre-Loop cut ', 95h, 0 -HelpContext2_8 DB 5, 80h, 'C', 0FFh, 8, ' Clear ', 94h, 'Name & Filename (Used in ', 94h, 'Name ', 0B6h, ')', 0 -HelpContext2_6 DB 5, 80h, 'D', 0FFh, 8, ' ', 084h, 94h, 0 -HelpContext2_17 DB 5, 80h, 'E', 0FFh, 8, ' Resize ', 94h, '(', 0A0h, 'interpolation)', 0 -HelpContext2_18 DB 5, 80h, 'F', 0FFh, 8, ' Resize ', 94h, '(without interpolation)', 0 -HelpContext2_27 DB 5, 80h, 'G', 0FFh, 8, ' Reverse ', 94h, 0 -HelpContext2_30 DB 5, 80h, 'H', 0FFh, 8, ' Centralise ', 94h, 0 -HelpContext2_33 DB 5, 80h, 'I', 0FFh, 8, ' Invert ', 94h, 0 -HelpContext2_7 DB 5, 80h, 'L', 0FFh, 8, ' Post-Loop cut ', 95h, 0 -HelpContext2_29 DB 5, 80h, 'M', 0FFh, 8, ' ', 94h, 'amplifier', 0 -HelpContext2_28 DB 5, 80h, 'N', 0FFh, 8, ' ', 9Dh, 'Multi', 0A4h, 'playback', 0 -HelpContext2_14 DB 5, 80h, 'O', 0FFh, 8, ' Save ', 0A2h, 95h, ' ', 0B1h, 'disk (IT Format)', 0 -HelpContext2_19 DB 5, 80h, 'Q', 0FFh, 8, ' ', 9Dh, 95h, ' quality', 0 -HelpContext2_12 DB 5, 80h, 'R', 0FFh, 8, ' Replace ', 0A2h, 95h, ' in song', 0 -HelpContext2_13 DB 5, 80h, 'S', 0FFh, 8, ' Swap ', 95h, ' (in song also)', 0 -HelpContext2_16 DB 5, 80h, 'T', 0FFh, 8, ' Save ', 0A2h, 95h, ' ', 0B1h, 'disk (ST3 Format)', 0 - -IF SAVESAMPLEWAV -HelpContext2_15 DB 5, 80h, 'W', 0FFh, 8, ' Save ', 0A2h, 95h, ' ', 0B1h, 'disk (WAV Format)', 0 -ELSE -HelpContext2_15 DB 5, 80h, 'W', 0FFh, 8, ' Save ', 0A2h, 95h, ' ', 0B1h, 'disk (RAW Format)', 0 -ENDIF - -HelpContext2_9 DB 5, 80h, 'X', 0FFh, 8, ' Ex', 0C9h, 95h, ' (only in ', 94h, 'List)', 0 - -HelpContext2_31 DB 5, 80h, 0C1h, 0FFh, 6, ' ', 83h, 95h, ' ', 91h, 0 -HelpContext2_32 DB 5, 80h, 0C2h, 0FFh, 6, ' Remove ', 95h, ' ', 91h, 0 - -HelpContext2_26 DB 5, '< >', 0FFh, 10, ' ', 93h, '/', 92h, ' playback ', 0A3h, 0 - -HelpContext2_21 DB 5, 80h, 'Grey + ', 92h, 0AEh, 'octave', 0 -HelpContext2_22 DB 5, 80h, 'Grey - ', 93h, 0AEh, 'octave', 0 -HelpContext2_24 DB 5, 81h, 'Grey + ', 92h, 0AEh, 0AFh, 0 -HelpContext2_25 DB 5, 81h, 'Grey - ', 93h, 0AEh, 0AFh, 0 - -HelpContext7Ptrs Label Word - DW Offset HelpContext7_0 - DW Offset HelpContext7_1 - DW Offset HelpContext7_2 - DW Offset NewLine - DW Offset HelpContext7_8 - DW Offset HelpContext7_26 - DW Offset HelpContext7_9 - DW Offset HelpContext7_10 - DW Offset HelpContext7_36 - DW Offset HelpContext7_22 - DW Offset NewLine - DW Offset HelpContext7_25 - DW Offset HelpContext7_24 - DW Offset HelpContext7_23 - DW Offset HelpContext7_28 - DW Offset HelpContext7_11 - DW Offset HelpContext7_12 - DW Offset HelpContext7_13 - DW Offset HelpContext7_14 - DW Offset NewLine - DW Offset HelpContext7_34 - DW Offset HelpContext7_35 - DW Offset NewLine - DW Offset HelpContext7_33 - DW Offset NewLine - DW Offset HelpContext7_3 - DW Offset HelpContext7_4 - DW Offset HelpContext7_5 - DW Offset NewLine - DW Offset HelpContext7_6 - DW Offset HelpContext7_7 - DW Offset HelpContext7_27 - DW Offset HelpContext7_29 - DW Offset HelpContext7_30 - DW Offset NewLine - DW Offset HelpContext7_15 - DW Offset HelpContext7_16 - DW Offset HelpContext7_17 - DW Offset HelpContext7_18 - DW Offset HelpContext7_19 - DW Offset NewLine - DW Offset HelpContext7_20 - DW Offset HelpContext7_21 - DW Offset NewLine - DW Offset Divider - DW Offset NewLine - DW Offset HelpGlobal_0 - DW Offset HelpGlobal_1 - DW Offset HelpGlobal_37 - DW Offset HelpGlobal_3 - DW Offset HelpGlobal_4 - DW Offset HelpGlobal_20 - DW Offset HelpGlobal_9 - DW Offset HelpGlobal_22 - DW Offset HelpGlobal_10 - DW Offset HelpGlobal_19 - DW Offset HelpGlobal_11 - DW Offset HelpGlobal_12 - DW Offset HelpGlobal_33 - DW Offset HelpGlobal_13 - DW Offset HelpGlobal_5 - DW Offset HelpGlobal_23 - DW Offset HelpGlobal_6 - DW Offset HelpGlobal_2 - DW Offset HelpGlobal_7 - DW Offset HelpGlobal_8 - DW Offset HelpGlobal_32 - DW Offset NewLine - DW Offset HelpGlobal_17 - DW Offset HelpGlobal_31 - DW Offset HelpGlobal_18 - DW Offset NewLine - DW Offset HelpGlobal_16 - DW Offset HelpGlobal_34 - DW Offset HelpGlobal_35 - DW Offset HelpGlobal_36 - DW Offset HelpGlobal_21 - DW Offset HelpGlobal_14 - DW Offset HelpGlobal_15 - DW Offset NewLine - DW Offset Divider - - DW 0 ; End of list - -HelpContext7_0 DB 29, 0FFh, 1, 139, 0FFh, 21, 134, 0FFh, 1, 138, 0 -HelpContext7_1 DB 29, 0FFh, 1, 132, ' ', 8Eh, 0AAh, ' ', 0FFh, 1, 145, 0 -HelpContext7_2 DB 29, 0FFh, 1, 137, 0FFh, 21, 143, 0FFh, 1, 150, 0 - -HelpContext7_8 DB 3, 8Eh, 0AAh, 0ADh, ".", 0 -HelpContext7_26 DB 5, 99h, 0FFh, 10, " Load new ", 8Fh, 0 -HelpContext7_9 DB 5, 81h, "PgUp/PgDn ", 9Ch, 8Fh, " ", 0B7h, "(when not on list)", 0 -HelpContext7_10 DB 5, 80h, "C", 0FFh, 11, " Clear ", 8Fh, " name & filename", 0 -HelpContext7_36 DB 5, 80h, "W", 0FFh, 11, ' ', 0CEh, 8Fh, " ", 90h, 0 -HelpContext7_22 DB 5, "Spacebar", 0FFh, 8, " Edit ", 8Fh, " name (ESC ", 0B1h, "exit)", 0 - -HelpContext7_25 DB 5, 80h, 'D', 0FFh, 11, ' ', 084h, 8Fh, ' & all related ', 95h, 's', 0 -HelpContext7_24 DB 5, 80h, 'N', 0FFh, 11, ' ', 9Dh, 'Multi', 0A4h, 'playback', 0 -HelpContext7_23 DB 5, 80h, 'O', 0FFh, 11, ' Save ', 0A2h, 8Fh, ' ', 0B1h, 'disk', 0 -HelpContext7_28 DB 5, 80h, 'P', 0FFh, 11, ' Copy ', 8Fh, 0 -HelpContext7_11 DB 5, 80h, 'R', 0FFh, 11, ' Replace ', 0A2h, 8Fh, ' in song', 0 -HelpContext7_12 DB 5, 80h, 'S', 0FFh, 11, ' Swap ', 08Fh, 's (in song also)', 0 -HelpContext7_13 DB 5, 80h, 'U', 0FFh, 11, ' Update ', 85h, 90h, 0 -HelpContext7_14 DB 5, 80h, 'X', 0FFh, 11, ' Ex', 0C9h, 08Fh, 's (only in ', 08Eh, 'List)', 0 - -HelpContext7_34 DB 5, 80h, 0C1h, 0FFh, 9, ' ', 83h, 8Fh, ' ', 91h, 0 -HelpContext7_35 DB 5, 80h, 0C2h, 0FFh, 9, ' Remove ', 8Fh, ' ', 91h, 0 - -HelpContext7_33 DB 5, '< >', 0FFh, 13, ' ', 93h, '/', 92h, ' playback ', 0A3h, 0 - -HelpContext7_3 DB 3, 0C3h, "Translation.", 0 -HelpContext7_4 DB 5, 99h, 0FFh, 10, " Pickup ", 95h, " number & default play ", 0A5h, 0 -HelpContext7_5 DB 5, "< >", 0FFh, 13, " ", 93h, "/", 92h, " ", 95h, " number", 0 -HelpContext7_6 DB 5, 80h, "A", 0FFh, 11, " ", 0C8h, "all ", 95h, "s", 0 -HelpContext7_7 DB 5, 80h, "N", 0FFh, 11, " ", 99h, 0B4h, 0A5h, 0 -HelpContext7_27 DB 5, 80h, "P", 0FFh, 11, " ", 99h, "previous ", 0A5h, 0 -HelpContext7_29 DB 5, 80h, "Up/Down", 0FFh, 5, " Transpose all notes ", 0BFh, 0AFh, 0B7h, 0 -HelpContext7_30 DB 5, 80h, 0C1h, "/", 0C2h, 0FFh, 5, " ", 9Eh, 0BFh, "row ", 0A9h, "the table", 0 - -HelpContext7_15 DB 3, 'Envelope ', 0ADh, '.', 0 -HelpContext7_16 DB 5, 99h, 0FFh, 10, ' Pick up/Drop ', 0A2h, 'node', 0 -HelpContext7_17 DB 5, 83h, 0FFh, 9, ' Add node', 0 -HelpContext7_18 DB 5, 84h, 0FFh, 9, ' ', 084h, 'node', 0 -HelpContext7_19 DB 5, 80h, 'Arrow ', 0ADh, ' ', 9Ch, 'node (fast)', 0 - -HelpContext7_20 DB 5, 'Press Spacebar ', 9Fh, 'default ', 0A5h, 0 -HelpContext7_21 DB 5, 'Release Space ', 0C3h, 'off command', 0 - -HelpContext9Ptrs Label Word - DW Offset HelpContext9_0 - DW Offset HelpContext9_1 - DW Offset HelpContext9_2 - DW Offset NewLine - DW Offset HelpContext9_3 - DW Offset HelpContext9_4 - DW Offset HelpContext9_11 - DW Offset HelpContext9_5 - DW Offset HelpContext9_6 - DW Offset HelpContext9_7 - DW Offset NewLine - DW Offset HelpContext9_15 - DW Offset HelpContext9_16 - DW Offset NewLine - DW Offset HelpContext9_8 - DW Offset HelpContext9_9 - DW Offset NewLine - DW Offset HelpContext9_10 - DW Offset NewLine - DW Offset HelpContext9_12 - DW Offset HelpContext9_14 - DW Offset NewLine - DW Offset HelpContext9_13 - DW Offset NewLine - DW Offset Divider - DW Offset NewLine - DW Offset HelpGlobal_0 - DW Offset HelpGlobal_1 - DW Offset HelpGlobal_37 - DW Offset HelpGlobal_3 - DW Offset HelpGlobal_4 - DW Offset HelpGlobal_20 - DW Offset HelpGlobal_9 - DW Offset HelpGlobal_22 - DW Offset HelpGlobal_10 - DW Offset HelpGlobal_19 - DW Offset HelpGlobal_11 - DW Offset HelpGlobal_12 - DW Offset HelpGlobal_33 - DW Offset HelpGlobal_13 - DW Offset HelpGlobal_5 - DW Offset HelpGlobal_23 - DW Offset HelpGlobal_6 - DW Offset HelpGlobal_2 - DW Offset HelpGlobal_7 - DW Offset HelpGlobal_8 - DW Offset HelpGlobal_32 - DW Offset NewLine - DW Offset HelpGlobal_17 - DW Offset HelpGlobal_31 - DW Offset HelpGlobal_18 - DW Offset NewLine - DW Offset HelpGlobal_16 - DW Offset HelpGlobal_34 - DW Offset HelpGlobal_35 - DW Offset HelpGlobal_36 - DW Offset HelpGlobal_21 - DW Offset HelpGlobal_14 - DW Offset HelpGlobal_15 - DW Offset NewLine - DW Offset Divider - DW 0 - -HelpContext9_0 DB 33, 0FFh, 1, 139, 0FFh, 13, 134, 0FFh, 1, 138, 0 -HelpContext9_1 DB 33, 0FFh, 1, 132, ' Info Page ', 0FFh, 1, 145, 0 -HelpContext9_2 DB 33, 0FFh, 1, 137, 0FFh, 13, 143, 0FFh, 1, 150, 0 - -HelpContext9_3 DB 3, 83h, 0FFh, 11, ' Add ', 0BFh, 'new ', 0B6h, 0 -HelpContext9_4 DB 3, 84h, 0FFh, 11, ' ', 084h, 0A2h, 0B6h, 0 -HelpContext9_11 DB 3, 'Tab/', 82h, 'Tab', 0FFh, 5, ' ', 9Ch, 0A8h, 0B6h, 's', 0 -HelpContext9_5 DB 3, 'Up/Dn/Left/Right ', 9Ch, 'highlighted ', 0A3h, 0 -HelpContext9_6 DB 3, 'PgUp/PgDn', 0FFh, 9, ' ', 0C8h, 0B6h, ' type', 0 -HelpContext9_7 DB 3, 80h, 'Up/Down', 0FFh, 7, ' ', 9Ch, 0B6h, ' base ', 0B7h, 0 - -HelpContext9_15 DB 3, 'V', 0FFh, 17, ' ', 9Dh, 0A8h, 'volume/velocity bars', 0 -HelpContext9_16 DB 3, 'I', 0FFh, 17, ' ', 9Dh, 0A8h, 95h, '/', 8Fh, ' names', 0 - -HelpContext9_8 DB 3, 'Q', 0FFh, 17, ' Mute/Unmute ', 0A2h, 0A3h, 0 -HelpContext9_9 DB 3, 'S', 0FFh, 17, ' Solo ', 0A2h, 0A3h, 0 - -HelpContext9_10 DB 3, 'Grey +, Grey -', 0FFh, 4, ' ', 9Ch, 'forwards/backwards one ', 85h, 'in song', 0 - -HelpContext9_12 DB 3, 80h, 'S', 0FFh, 13, ' ', 9Dh, 'Stereo playback', 0 -HelpContext9_14 DB 3, 80h, 'R', 0FFh, 13, ' Reverse output ', 0A3h, 's', 0 - -Helpcontext9_13 DB 3, 'G', 0FFh, 17, ' Goto ', 85h, 'currently playing', 0 - -HelpContext12Ptrs Label Word - DW Offset HelpContext12_0 - DW Offset HelpContext12_1 - DW Offset HelpContext12_2 - DW Offset NewLine - DW Offset HelpContext12_3 - DW Offset NewLine - DW Offset HelpContext12_4 - DW Offset HelpContext12_5 - DW Offset HelpContext12_6 - DW Offset NewLine - DW Offset Divider - DW Offset NewLine - DW Offset HelpGlobal_0 - DW Offset HelpGlobal_1 - DW Offset HelpGlobal_37 - DW Offset HelpGlobal_3 - DW Offset HelpGlobal_4 - DW Offset HelpGlobal_20 - DW Offset HelpGlobal_9 - DW Offset HelpGlobal_22 - DW Offset HelpGlobal_10 - DW Offset HelpGlobal_19 - DW Offset HelpGlobal_11 - DW Offset HelpGlobal_12 - DW Offset HelpGlobal_33 - DW Offset HelpGlobal_13 - DW Offset HelpGlobal_5 - DW Offset HelpGlobal_23 - DW Offset HelpGlobal_6 - DW Offset HelpGlobal_2 - DW Offset HelpGlobal_7 - DW Offset HelpGlobal_8 - DW Offset HelpGlobal_32 - DW Offset NewLine - DW Offset HelpGlobal_17 - DW Offset HelpGlobal_31 - DW Offset HelpGlobal_18 - DW Offset NewLine - DW Offset HelpGlobal_16 - DW Offset HelpGlobal_34 - DW Offset HelpGlobal_35 - DW Offset HelpGlobal_36 - DW Offset HelpGlobal_21 - DW Offset HelpGlobal_14 - DW Offset HelpGlobal_15 - DW Offset NewLine - DW Offset Divider - DW 0 - -HelpContext12_0 DB 31, 0FFh, 1, 139, 0FFh, 18, 134, 0FFh, 1, 138, 0 -HelpContext12_1 DB 31, 0FFh, 1, 132, ' Message Editor ', 0FFh, 1, 145, 0 -HelpContext12_2 DB 31, 0FFh, 1, 137, 0FFh, 18, 143, 0FFh, 1, 150, 0 - -HelpContext12_3 DB 3, 99h, '/ ESC', 0FFh, 5, ' Edit message / finished editing', 0 - -HelpContext12_4 DB 3, 'Editing ', 0ADh, '.', 0 -HelpContext12_5 DB 5, 81h, 'Y', 0FFh, 8, ' ', 084h, 'line', 0 -HelpContext12_6 DB 5, 80h, 'C', 0FFh, 9, ' Clear message', 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -DecodeWord80h DB "Alt-", 0 -DecodeWord81h DB "Ctrl-", 0 -DecodeWord82h DB "Shift-", 0 -DecodeWord83h DB 0C1h, "ert ", 0 -DecodeWord84h DB 0C2h, "ete ", 0 -DecodeWord85h DB "pattern ", 0 -DecodeWord86h DB "Pattern ", 0 -DecodeWord87h DB 0A7h, "up ", 0B0h, "x", 0 -DecodeWord88h DB 0A7h, "down ", 0B0h, "x", 0 -DecodeWord89h DB "Volume ", 0 -DecodeWord8Ah DB "volume ", 0 -DecodeWord8Bh DB " Fine ", 0 -DecodeWord8Ch DB "envelope", 0 -DecodeWord8Dh DB "Channel ", 0 -DecodeWord8Eh DB 0C1h, "trument ", 0 -DecodeWord8Fh DB "instrument", 0 -DecodeWord90h DB "data", 0 -DecodeWord91h DB "slot (updates ", 85h, 90h, ")", 0 -DecodeWord92h DB "Increase", 0 -DecodeWord93h DB "Decrease", 0 -DecodeWord94h DB "Sample ", 0 -DecodeWord95h DB "sample", 0 -DecodeWord96h DB " ", 0A6h, "NNA ", 0B1h, 0 -DecodeWord97h DB "Tempo ", 0 -DecodeWord98h DB "clipboard ", 0 -DecodeWord99h DB "Enter ", 0 -DecodeWord9Ah DB "waveform ", 0B1h, "type x", 0 -DecodeWord9Bh DB " Dual Command: ", 0 -DecodeWord9Ch DB "Move ", 0 -DecodeWord9Dh DB "Toggle ", 0 -DecodeWord9Eh DB 0C1h, "ert/", 0C2h, "ete ", 0 -DecodeWord9Fh DB "Play ", 0 -DecodeWordA0h DB "with ", 0 -DecodeWordA1h DB "and ", 0 -DecodeWordA2h DB "current ", 0 -DecodeWordA3h DB "channel", 0 -DecodeWordA4h DB 0A3h, ' ', 0 -DecodeWordA5h DB "note ", 0 -DecodeWordA6h DB "Set ", 0 -DecodeWordA7h DB "slide ", 0 -DecodeWordA8h DB "between ", 0 -DecodeWordA9h DB "from ", 0 -DecodeWordAAh DB "List ", 0 -DecodeWordABh DB "Library ", 0 -DecodeWordACh DB "Turn ", 0 -DecodeWordADh DB "Keys", 0 -DecodeWordAEh DB ' C-5 Frequency by 1 ', 0 -DecodeWordAFh DB 'semitone ', 0 -DecodeWordB0h DB "by ", 0 -DecodeWordB1h DB "to ", 0 -DecodeWordB2h DB "lobal ", 0 -DecodeWordB3h DB "ibra", 0B1h, 0 -DecodeWordB4h DB "next ", 0 -DecodeWordB5h DB "panning ", 0 -DecodeWordB6h DB "window", 0 -DecodeWordB7h DB "up/down ", 0 -DecodeWordB8h DB "Panning ", 0 -DecodeWordB9h DB "Order ", 0 -DecodeWordBAh DB "Pitch ", 0 -DecodeWordBBh DB "pitch ", 0 -DecodeWordBCh DB "Slide ", 0 -DecodeWordBDh DB "effect", 0 -DecodeWordBEh DB "of ", 0 -DecodeWordBFh DB "a ", 0 -DecodeWordC0h DB " Past ", 0 -DecodeWordC1h DB "Ins", 0 -DecodeWordC2h DB "Del", 0 -DecodeWordC3h DB "Note ", 0 -DecodeWordC4h DB "speed ", 0 -DecodeWordC5h DB 0C4h, "x, ", 0C6h, "y", 0 -DecodeWordC6h DB "depth ", 0 -DecodeWordC7h DB "Next/Previous ", 0 -DecodeWordC8h DB "Change ", 0 -DecodeWordC9h DB "change ", 0 -DecodeWordCAh DB "Mark ", 0 -DecodeWordCBh DB "track ", 0 -DecodeWordCCh DB "block ", 0 -DecodeWordCDh DB " (*)", 0 -DecodeWordCEh DB "Wipe ", 0 - -; channel, pitch, column, effect, note, current, list, library -; speed/width, turn, on, off, down, instrument -; semitone, octave, block, edit, save, (g)lobal, (v)ibrato, (p)anbrello -; cursor, window - -DecodeBuffer DB 80 Dup (0) -DecodeWords DW Offset DecodeWord80h, Offset DecodeWord81h - DW Offset DecodeWord82h, Offset DecodeWord83h - DW Offset DecodeWord84h, Offset DecodeWord85h - DW Offset DecodeWord86h, Offset DecodeWord87h - DW Offset DecodeWord88h, Offset DecodeWord89h - DW Offset DecodeWord8Ah, Offset DecodeWord8Bh - DW Offset DecodeWord8Ch, Offset DecodeWord8Dh - DW Offset DecodeWord8Eh, Offset DecodeWord8Fh - DW Offset DecodeWord90h, Offset DecodeWord91h - DW Offset DecodeWord92h, Offset DecodeWord93h - DW Offset DecodeWord94h, Offset DecodeWord95h - DW Offset DecodeWord96h, Offset DecodeWord97h - DW Offset DecodeWord98h, Offset DecodeWord99h - DW Offset DecodeWord9Ah, Offset DecodeWord9Bh - DW Offset DecodeWord9Ch, Offset DecodeWord9Dh - DW Offset DecodeWord9Eh, Offset DecodeWord9Fh - DW Offset DecodeWordA0h, Offset DecodeWordA1h - DW Offset DecodeWordA2h, Offset DecodeWordA3h - DW Offset DecodeWordA4h, Offset DecodeWordA5h - DW Offset DecodeWordA6h, Offset DecodeWordA7h - DW Offset DecodeWordA8h, Offset DecodeWordA9h - DW Offset DecodeWordAAh, Offset DecodeWordABh - DW Offset DecodeWordACh, Offset DecodeWordADh - DW Offset DecodeWordAEh, Offset DecodeWordAFh - DW Offset DecodeWordB0h, Offset DecodeWordB1h - DW Offset DecodeWordB2h, Offset DecodeWordB3h - DW Offset DecodeWordB4h, Offset DecodeWordB5h - DW Offset DecodeWordB6h, Offset DecodeWordB7h - DW Offset DecodeWordB8h, Offset DecodeWordB9h - DW Offset DecodeWordBAh, Offset DecodeWordBBh - DW Offset DecodeWordBCh, Offset DecodeWordBDh - DW Offset DecodeWordBEh, Offset DecodeWordBFh - DW Offset DecodeWordC0h, Offset DecodeWordC1h - DW Offset DecodeWordC2h, Offset DecodeWordC3h - DW Offset DecodeWordC4h, Offset DecodeWordC5h - DW Offset DecodeWordC6h, Offset DecodeWordC7h - DW Offset DecodeWordC8h, Offset DecodeWordC9h - DW Offset DecodeWordCAh, Offset DecodeWordCBh - DW Offset DecodeWordCCh, Offset DecodeWordCDh - DW Offset DecodeWordCEh - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc H_DrawHelp Far - - Push CS - Pop DS - - Push CS - Pop ES - - Assume DS:Help - - Mov CX, 32 - Mov SI, HelpContext - Add SI, SI - Mov SI, [HelpContextPtrs+SI] - Mov DI, 13*160 - - Mov AX, TopLine - Add AX, AX - Add SI, AX - -H_DrawHelp1: - Push SI - Push DI - - Mov SI, [SI] - LodsB - Xor AH, AH - Add AX, AX - Add DI, AX - -; DS:SI points to string. Deposit into buffer - - Push DI - Mov DI, Offset DecodeBuffer - - Mov DX, 1 - -H_DecodeBuffer1: - LodsB - Test AL, AL - JZ H_DecodeBuffer4 - JS H_DecodeBuffer2 - - StosB - Jmp H_DecodeBuffer1 - -H_DecodeBuffer2: - Cmp AL, -2 - JGE H_DecodeBuffer3 - - ; Insert word - Push SI - LEA SI, [EAX*2 + Offset DecodeWords - 100h] - Inc DX - Mov SI, [SI] - Jmp H_DecodeBuffer1 - -H_DecodeBuffer3: - StosB - JE H_DecodeBuffer1 - MovsB - MovsB - Jmp H_DecodeBuffer1 - -H_DecodeBuffer4: - Dec DX - JZ H_DecodeBufferEnd - - Pop SI - Jmp H_DecodeBuffer1 - -H_DecodeBufferEnd: - Xor AL, AL - StosB - Pop DI - - Mov SI, Offset DecodeBuffer - Mov AH, 6 - Call S_DrawString - - Pop DI - Pop SI - LodsW ; Add SI, 2 - Add DI, 160 - Cmp Word Ptr [SI], 0 - LoopNZ H_DrawHelp1 - - Ret - -EndP H_DrawHelp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc H_Help Far - - Call Glbl_SaveMode - - Mov BX, CS:HelpContext - Add BX, BX - Mov AX, [CS:Positions+BX] - - Mov CS:TopLine, AX - - Mov AX, 5 - Mov CX, Object1 - Mov DX, Offset O1_HelpList - Mov SI, 1 - - Ret - -EndP H_Help - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc H_HelpUp Far - - Sub CS:TopLine, 1 - AdC CS:Topline, 0 - - Mov AX, 1 - Ret - -EndP H_HelpUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc H_HelpDown Far - - Push CX - - Push CS - Pop DS - Assume DS:Help - - Mov SI, HelpContext - Add SI, SI - Mov SI, [HelpContextPtrs+SI] - Mov BX, TopLine - Add BX, BX - Add SI, BX - Mov CX, 32 - -H_HelpDown2: - Add SI, 2 - Cmp Word Ptr [SI], 0 - LoopNZ H_HelpDown2 - JZ H_HelpDown1 - - Inc TopLine - -H_HelpDown1: - Pop CX - - Mov AX, 1 - Ret - -EndP H_HelpDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc H_HelpPgUp Far - - Mov AX, CS:TopLine - Sub AX, 32 - JNS H_HelpPgUp1 - - Xor AX, AX -H_HelpPgUp1: - Mov CS:TopLine, AX - - Mov AX, 1 - Ret - -EndP H_HelpPgUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc H_HelpPgDn Far - - Mov CX, 32 - -H_HelpPgDn1: - Call H_HelpDown - Loop H_HelpPgDn1 - - Ret ; AX = 1, set by H_HelpDown - -EndP H_HelpPgDn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc H_HelpESC Far - - Mov AX, CS:TopLine - Mov BX, CS:HelpContext - Add BX, BX - - Mov [CS:Positions+BX], AX - - Jmp Glbl_RestoreMode - -EndP H_HelpESC - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc H_SetHelpContext Far - - Mov AX, [SI+2] - Mov CS:HelpContext, AX - - Ret - -EndP H_SetHelpContext - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Help Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + .386 + Jumps + +include switch.inc + +Segment Object1 BYTE Public 'Data' +EndS + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Extrn M_Object1List:Far + Extrn Glbl_SaveMode:Far + Extrn Glbl_RestoreMode:Far + + Extrn S_DrawString:Far + + Extrn O1_HelpList:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global H_SetHelpContext:Far + Global H_DrawHelp:Far + Global H_Help:Far + Global H_HelpUp:Far + Global H_HelpDown:Far + Global H_HelpPgUp:Far + Global H_HelpPgDn:Far + Global H_HelpESC:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Object1 BYTE Public 'Data' +EndS + +Segment Help BYTE Public USE16 'Code' + Assume CS:Help, DS:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + ; Help contexts.... + ; 0 = Order list & Panning + ; 1 = Pattern edit list + ; 2 = Sample list + ; 3 = Load module + ; 4 = Order list & Volume + ; 5 = Configuration screen + ; 6 = Load sample list + ; 7 = Instrument list + ; 8 = Keyboard list + ; 9 = Info page + ; 10 = Palette configuration + ; 11 = Instrument list + ; 12 = message editor + ; 13 = MIDI Input + ; 14 = MIDI Output + +HelpContext DW 0 +TopLine DW 0 + +Positions DW 15 Dup (0) + +HelpContextPtrs Label Word + DW Offset HelpContext0Ptrs + DW Offset HelpContext1Ptrs + DW Offset HelpContext2Ptrs + DW Offset NoHelpContext + DW Offset HelpContext4Ptrs + DW Offset NoHelpContext + DW Offset NoHelpContext + DW Offset HelpContext7Ptrs + DW Offset NoHelpContext + DW Offset HelpContext9Ptrs + DW Offset NoHelpContext + DW Offset NoHelpContext + DW Offset HelpContext12Ptrs + DW Offset NoHelpContext + DW Offset NoHelpContext + +NoHelpContext DW Offset NewLine + DW Offset HelpGlobal_0 + DW Offset HelpGlobal_1 + DW Offset HelpGlobal_37 + DW Offset HelpGlobal_3 + DW Offset HelpGlobal_4 + DW Offset HelpGlobal_20 + DW Offset HelpGlobal_9 + DW Offset HelpGlobal_10 + DW Offset HelpGlobal_19 + DW Offset HelpGlobal_11 + DW Offset HelpGlobal_12 + DW Offset HelpGlobal_33 + DW Offset HelpGlobal_13 + DW Offset HelpGlobal_5 + DW Offset HelpGlobal_6 + DW Offset HelpGlobal_2 + DW Offset HelpGlobal_7 + DW Offset HelpGlobal_8 + DW Offset HelpGlobal_32 + DW Offset NewLine + DW Offset HelpGlobal_17 + DW Offset HelpGlobal_31 + DW Offset HelpGlobal_18 + DW Offset NewLine + DW Offset HelpGlobal_16 + DW Offset HelpGlobal_34 + DW Offset HelpGlobal_35 + DW Offset HelpGlobal_36 + DW Offset HelpGlobal_21 + DW Offset HelpGlobal_14 + DW Offset HelpGlobal_15 + DW 0 + +HelpContext0Ptrs DW Offset HelpContext0_26 + DW Offset HelpContext0_0 + DW Offset HelpContext0_27 + DW Offset NewLine + DW Offset HelpContext0_6 + DW Offset HelpContext0_28 + DW Offset HelpContext0_8 + DW Offset HelpContext0_9 + DW Offset HelpContext0_13 + DW Offset HelpContext0_14 + DW Offset HelpContext0_12 + DW Offset HelpContext0_15 + DW Offset NewLine + DW Offset HelpContext0_30 + DW Offset HelpContext0_29 + DW Offset NewLine + DW Offset Divider + DW Offset NewLine + DW Offset HelpGlobal_0 + DW Offset HelpGlobal_1 + DW Offset HelpGlobal_37 + DW Offset HelpGlobal_3 + DW Offset HelpGlobal_4 + DW Offset HelpGlobal_9 + DW Offset HelpGlobal_10 + DW Offset HelpGlobal_19 + DW Offset HelpGlobal_11 + DW Offset HelpGlobal_12 + DW Offset HelpGlobal_33 + DW Offset HelpGlobal_13 + DW Offset HelpGlobal_5 + DW Offset HelpGlobal_6 + DW Offset HelpGlobal_2 + DW Offset HelpGlobal_7 + DW Offset HelpGlobal_8 + DW Offset HelpGlobal_32 + DW Offset NewLine + DW Offset HelpGlobal_17 + DW Offset HelpGlobal_31 + DW Offset HelpGlobal_18 + DW Offset NewLine + DW Offset HelpGlobal_16 + DW Offset HelpGlobal_34 + DW Offset HelpGlobal_35 + DW Offset HelpGlobal_36 + DW Offset HelpGlobal_21 + DW Offset HelpGlobal_14 + DW Offset HelpGlobal_15 + DW Offset NewLine + DW Offset Divider + DW 0 + +HelpContext4Ptrs DW Offset HelpContext4_0 + DW Offset HelpContext4_1 + DW Offset HelpContext4_2 + DW Offset NewLine + DW Offset HelpContext0_6 + DW Offset HelpContext0_28 + DW Offset HelpContext0_8 + DW Offset HelpContext0_9 + DW Offset HelpContext0_13 + DW Offset HelpContext0_14 + DW Offset HelpContext0_12 + DW Offset HelpContext0_15 + DW Offset NewLine + DW Offset Divider + DW Offset NewLine + DW Offset HelpGlobal_0 + DW Offset HelpGlobal_1 + DW Offset HelpGlobal_37 + DW Offset HelpGlobal_3 + DW Offset HelpGlobal_4 + DW Offset HelpGlobal_20 + DW Offset HelpGlobal_9 + DW Offset HelpGlobal_22 + DW Offset HelpGlobal_10 + DW Offset HelpGlobal_19 + DW Offset HelpGlobal_11 + DW Offset HelpGlobal_12 + DW Offset HelpGlobal_33 + DW Offset HelpGlobal_13 + DW Offset HelpGlobal_5 + DW Offset HelpGlobal_23 + DW Offset HelpGlobal_6 + DW Offset HelpGlobal_2 + DW Offset HelpGlobal_7 + DW Offset HelpGlobal_8 + DW Offset HelpGlobal_32 + DW Offset NewLine + DW Offset HelpGlobal_17 + DW Offset HelpGlobal_31 + DW Offset HelpGlobal_18 + DW Offset NewLine + DW Offset HelpGlobal_16 + DW Offset HelpGlobal_34 + DW Offset HelpGlobal_35 + DW Offset HelpGlobal_36 + DW Offset HelpGlobal_21 + DW Offset HelpGlobal_14 + DW Offset HelpGlobal_15 + DW Offset NewLine + DW Offset Divider + DW 0 + +NewLine DB 0, 0 +Divider DB 2, 0FFh, 76, 154, 0 + +HelpContext0_26 DB 27, 0FFh, 1, 139, 0FFh, 26, 134, 0FFh, 1, 138, 0 +HelpContext0_0 DB 27, 0FFh, 1, 132, ' ', 0B9h, 0AAh, 0A1h, 0B8h, ' ', 0FFh, 1, 145, 0 +HelpContext0_27 DB 27, 0FFh, 1, 137, 0FFh, 26, 143, 0FFh, 1, 150, 0 + +HelpContext4_0 DB 22, 0FFh, 1, 139, 0FFh, 33, 134, 0FFh, 1, 138, 0 +HelpContext4_1 DB 22, 0FFh, 1, 132, ' ', 0B9h, 0AAh, 0A1h, 8Dh, 89h, ' ', 0FFh, 1, 145, 0 +HelpContext4_2 DB 22, 0FFh, 1, 137, 0FFh, 33, 143, 0FFh, 1, 150, 0 + +HelpContext0_6 DB 3, 0B9h, 0ADh, '.', 0 +HelpContext0_28 DB 5, 'N', 0FFh, 17, ' ', 83h, 0B4h, 85h, 0 +HelpContext0_8 DB 5, '-', 0FFh, 17, ' End ', 0BEh, 'song mark', 0 +HelpContext0_9 DB 5, '+', 0FFh, 17, ' Skip ', 0B1h, 0B4h, 0B9h, 'mark', 0 +HelpContext0_13 DB 5, 0C1h, 0FFh, 15, ' ', 83h, 0BFh, 85h, 0 +HelpContext0_14 DB 5, 0C2h, 0FFh, 15, ' ', 84h, 0BFh, 85h, 0 +HelpContext0_12 DB 5, 'Tab/', 82h, 'Tab', 0FFh, 5, ' ', 9Ch, 0B1h, 0B4h, 0B6h, 0 +HelpContext0_15 DB 5, 81h, 'F7', 0FFh, 11, ' ', 9Fh, 'this ', 0B9h, 0B4h, 0 + +HelpContext0_30 DB 3, 0B8h, 0ADh, '.', 0 +HelpContext0_29 DB 5, 'L/M/R/S', 0FFh, 11, ' ', 0A6h, 0B5h, 0B1h, 'Left/Middle/Right/Surround', 0 + +HelpGlobal_0 DB 3, 'G', 0B2h, 0ADh, '.', 0 +HelpGlobal_1 DB 5, 'F1', 0FFh, 16, ' Help (Context sensitive!)', 0 +HelpGlobal_37 DB 5, 82h, 'F1', 0FFh, 10, ' MIDI Screen', 0 +HelpGlobal_3 DB 5, 'F2', 0FFh, 16, ' ', 86h, 'Editor / ', 86h, 'Editor Options', 0 +HelpGlobal_4 DB 5, 'F3', 0FFh, 16, ' ', 94h, 0AAh, 0 +HelpGlobal_20 DB 5, 81h, 'F3', 0FFh, 11, ' ', 94h, 0ABh, 0 +HelpGlobal_9 DB 5, 'F4', 0FFh, 16, ' ', 8Eh, 0AAh, 0 +HelpGlobal_22 DB 5, 81h, 'F4', 0FFh, 11, ' ', 8Eh, 0ABh, 0 +HelpGlobal_10 DB 5, 'F5', 0FFh, 16, ' ', 9Fh, 'Information / ', 9Fh, 'song', 0 +HelpGlobal_19 DB 5, 81h, 'F5', 0FFh, 11, ' ', 9Fh, 'Song', 0 +HelpGlobal_11 DB 5, 'F6', 0FFh, 16, ' ', 9Fh, 0A2h, 85h, 0 +HelpGlobal_12 DB 5, 82h, 'F6', 0FFh, 10, ' ', 9Fh, 'song ', 0A9h, 0A2h, 0B9h, 0 +HelpGlobal_33 DB 5, 'F7', 0FFh, 16, ' ', 9Fh, 0A9h, 'mark / ', 0A2h, 'row', 0 +HelpGlobal_13 DB 5, 'F8', 0FFh, 16, ' Stop Playback', 0 +HelpGlobal_5 DB 5, 'F9', 0FFh, 16, ' Load Module', 0 +HelpGlobal_23 DB 5, 82h, 'F9', 0FFh, 10, ' Message Editor', 0 +HelpGlobal_6 DB 5, 'F10', 0FFh, 15, ' Save Module', 0 +HelpGlobal_2 DB 5, 'F11', 0FFh, 15, ' ', 0B9h, 0AAh, 0A1h, 0B8h, 0 +HelpGlobal_7 DB 3, '2*F11', 0FFh, 15, ' ', 0B9h, 0AAh, 0A1h, 8Dh, 89h, 0 +HelpGlobal_8 DB 5, 'F12', 0FFh, 15, ' Song Variables & Directory Configuration', 0 +HelpGlobal_32 DB 5, 81h, 'F12', 0FFh, 10, ' Palette Configuration', 0 + +HelpGlobal_17 DB 5, '{ }', 0FFh, 15, ' ', 93h, '/', 92h, ' playback ', 0C4h, 0 +HelpGlobal_31 DB 5, '[ ]', 0FFh, 15, ' ', 93h, '/', 92h, ' g', 0B2h, 8Ah, 0 +HelpGlobal_18 DB 5, 80h, 'F1 -> ', 80h, 'F8 ', 9Dh, 0A3h, 's 1->8', 0 + +HelpGlobal_16 DB 5, 81h, 'D', 0FFh, 12, ' DOS Shell', 0 +HelpGlobal_34 DB 5, 81h, 'E', 0FFh, 12, ' Refresh screen ', 0A1h, 'reset cache identification', 0 +HelpGlobal_35 DB 5, 81h, 'I', 0FFh, 12, ' Reinitialise sound driver', 0 +HelpGlobal_36 DB 5, 81h, 'M', 0FFh, 12, ' ', 9Dh, 'mouse cursor', 0 +HelpGlobal_21 DB 5, 81h, 'N', 0FFh, 12, ' New Song', 0 +HelpGlobal_14 DB 5, 81h, 'Q', 0FFh, 12, ' Quit ', 0B1h, 'DOS', 0 +HelpGlobal_15 DB 5, 81h, 'S', 0FFh, 12, ' Save ', 0A2h, 'song', 0 + + +HelpContext1Ptrs Label Word + DW Offset HelpContext1_0 + DW Offset HelpContext1_1 + DW Offset HelpContext1_2 + DW Offset NewLine + DW Offset HelpContext1_3 + DW Offset NewLine + DW Offset HelpContext1_200 + DW Offset HelpContext1_201 + DW Offset HelpContext1_202 + DW Offset HelpContext1_203 + DW Offset HelpContext1_204 + DW Offset HelpContext1_205 + DW Offset HelpContext1_206 + DW Offset HelpContext1_207 + DW Offset HelpContext1_208 + DW Offset NewLine + DW Offset HelpContext1_299 + DW Offset HelpContext1_4 + DW Offset HelpContext1_5 + DW Offset HelpContext1_6 + DW Offset HelpContext1_7 + DW Offset HelpContext1_8 + DW Offset HelpContext1_9 + DW Offset HelpContext1_10 + DW Offset HelpContext1_11 + DW Offset HelpContext1_12 + DW Offset HelpContext1_13 + DW Offset HelpContext1_14 + DW Offset HelpContext1_15 + DW Offset HelpContext1_16 + DW Offset HelpContext1_17 + DW Offset HelpContext1_18 + DW Offset HelpContext1_19 + DW Offset HelpContext1_20 + DW Offset HelpContext1_21 + DW Offset HelpContext1_22 + DW Offset HelpContext1_23 + DW Offset HelpContext1_24 + DW Offset HelpContext1_141 + DW Offset HelpContext1_142 + DW Offset HelpContext1_143 + DW Offset HelpContext1_25 + DW Offset HelpContext1_26 + DW Offset HelpContext1_135 + DW Offset HelpContext1_136 + DW Offset HelpContext1_137 + DW Offset HelpContext1_27 + DW Offset HelpContext1_28 + DW Offset HelpContext1_29 + DW Offset HelpContext1_30 + DW Offset HelpContext1_31 + DW Offset HelpContext1_32 + DW Offset HelpContext1_33 + DW Offset HelpContext1_34 + DW Offset HelpContext1_35 + DW Offset HelpContext1_36 + DW Offset HelpContext1_45 + DW Offset HelpContext1_46 + DW Offset HelpContext1_47 + DW Offset HelpContext1_48 + DW Offset HelpContext1_49 + DW Offset HelpContext1_50 + DW Offset HelpContext1_51 + DW Offset HelpContext1_62 + DW Offset HelpContext1_63 + DW Offset HelpContext1_64 + DW Offset HelpContext1_65 + DW Offset HelpContext1_66 + DW Offset HelpContext1_52 + DW Offset HelpContext1_53 + DW Offset HelpContext1_144 + DW Offset HelpContext1_145 + DW Offset HelpContext1_153 + DW Offset HelpContext1_154 + DW Offset HelpContext1_155 + DW Offset HelpContext1_156 + DW Offset HelpContext1_157 + DW Offset HelpContext1_162 + DW Offset HelpContext1_168 + DW Offset HelpContext1_169 + DW Offset HelpContext1_170 + DW Offset HelpContext1_171 + DW Offset HelpContext1_54 + DW Offset HelpContext1_55 + DW Offset HelpContext1_56 + DW Offset HelpContext1_57 + DW Offset HelpContext1_146 + DW Offset HelpContext1_58 + DW Offset HelpContext1_59 + DW Offset HelpContext1_60 + DW Offset HelpContext1_61 + DW Offset HelpContext1_179 + DW Offset HelpContext1_180 + DW Offset HelpContext1_67 + DW Offset HelpContext1_68 + DW Offset HelpContext1_69 + DW Offset HelpContext1_70 + DW Offset HelpContext1_138 + DW Offset HelpContext1_139 + DW Offset HelpContext1_140 + DW Offset HelpContext1_71 + DW Offset HelpContext1_72 + DW Offset HelpContext1_73 + DW Offset NewLine + DW Offset Divider + DW Offset NewLine + DW Offset HelpContext1_74 + DW Offset HelpContext1_114 + DW Offset HelpContext1_115 + DW Offset HelpContext1_134 + DW Offset HelpContext1_75 + DW Offset HelpContext1_76 + DW Offset HelpContext1_77 + DW Offset HelpContext1_78 + DW Offset HelpContext1_79 + DW Offset HelpContext1_80 + DW Offset HelpContext1_81 + DW Offset HelpContext1_181 + DW Offset NewLine + DW Offset HelpContext1_82 + DW Offset HelpContext1_83 + DW Offset HelpContext1_163 + DW Offset HelpContext1_84 + DW Offset HelpContext1_85 + DW Offset NewLine + DW Offset HelpContext1_86 + DW Offset HelpContext1_127 + DW Offset NewLine + DW Offset HelpContext1_87 + DW Offset HelpContext1_164 + DW Offset HelpContext1_129 + DW Offset HelpContext1_88 + DW Offset HelpContext1_131 + DW Offset HelpContext1_90 + DW Offset HelpContext1_89 + DW Offset HelpContext1_160 + DW Offset HelpContext1_91 + DW Offset HelpContext1_92 + DW Offset HelpContext1_93 + DW Offset NewLine + DW Offset HelpContext1_116 + DW Offset HelpContext1_124 + DW Offset NewLine + DW Offset HelpContext1_130 + DW Offset HelpContext1_117 + DW Offset HelpContext1_161 + DW Offset NewLine + DW Offset HelpContext1_166 + DW Offset HelpContext1_174 + DW Offset HelpContext1_300 + DW Offset NewLine + DW Offset HelpContext1_176 + DW Offset NewLine + DW Offset HelpContext1_118 + DW Offset HelpContext1_119 + DW Offset HelpContext1_120 + DW Offset HelpContext1_121 + DW Offset HelpContext1_122 + DW Offset HelpContext1_123 + DW Offset HelpContext1_128 + DW Offset NewLine + DW Offset HelpContext1_167 + DW Offset NewLine + DW Offset HelpContext1_159 + DW Offset NewLine + DW Offset HelpContext1_94 + DW Offset HelpContext1_95 + DW Offset HelpContext1_96 + DW Offset HelpContext1_97 + DW Offset HelpContext1_98 + DW Offset HelpContext1_165 + DW Offset NewLine + DW Offset HelpContext1_99 + DW Offset NewLine + DW Offset HelpContext1_113 + DW Offset HelpContext1_100 + DW Offset HelpContext1_101 + DW Offset HelpContext1_102 + DW Offset HelpContext1_103 + DW Offset HelpContext1_104 + DW Offset HelpContext1_133 + DW Offset HelpContext1_105 + DW Offset HelpContext1_106 + DW Offset HelpContext1_132 + DW Offset HelpContext1_107 + DW Offset NewLine + DW Offset HelpContext1_108 + DW Offset HelpContext1_109 + DW Offset HelpContext1_110 + DW Offset HelpContext1_111 + DW Offset HelpContext1_173 + DW Offset NewLine + DW Offset HelpContext1_125 + DW Offset HelpContext1_126 + DW Offset NewLine + DW Offset HelpContext1_112 + DW Offset HelpContext1_175 + DW Offset NewLine + DW Offset HelpContext1_147 + DW Offset HelpContext1_148 + DW Offset HelpContext1_149 + DW Offset NewLine + DW Offset HelpContext1_152 + DW Offset HelpContext1_158 + DW Offset NewLine + DW Offset HelpContext1_150 + DW Offset HelpContext1_151 + DW Offset NewLine + DW Offset HelpContext1_172 + DW Offset HelpContext1_177 + DW Offset HelpContext1_178 + DW Offset NewLine + DW Offset Divider + DW Offset NewLine + DW Offset HelpGlobal_0 + DW Offset HelpGlobal_1 + DW Offset HelpGlobal_37 + DW Offset HelpGlobal_3 + DW Offset HelpGlobal_4 + DW Offset HelpGlobal_20 + DW Offset HelpGlobal_9 + DW Offset HelpGlobal_22 + DW Offset HelpGlobal_10 + DW Offset HelpGlobal_19 + DW Offset HelpGlobal_11 + DW Offset HelpGlobal_12 + DW Offset HelpGlobal_33 + DW Offset HelpGlobal_13 + DW Offset HelpGlobal_5 + DW Offset HelpGlobal_23 + DW Offset HelpGlobal_6 + DW Offset HelpGlobal_2 + DW Offset HelpGlobal_7 + DW Offset HelpGlobal_8 + DW Offset HelpGlobal_32 + DW Offset NewLine + DW Offset HelpGlobal_17 + DW Offset HelpGlobal_31 + DW Offset HelpGlobal_18 + DW Offset NewLine + DW Offset HelpGlobal_16 + DW Offset HelpGlobal_34 + DW Offset HelpGlobal_35 + DW Offset HelpGlobal_36 + DW Offset HelpGlobal_21 + DW Offset HelpGlobal_14 + DW Offset HelpGlobal_15 + DW Offset NewLine + DW Offset Divider + + Comment & + + DW Offset NewLine + DW Offset HelpHexTable0 + DW Offset HelpHexTable1 + DW Offset HelpHexTable2 + DW Offset NewLine + DW Offset HelpHexTable3 + DW Offset Divider + DW Offset HelpHexTable4 + DW Offset HelpHexTable5 + DW Offset HelpHexTable6 + DW Offset HelpHexTable7 + DW Offset HelpHexTable8 + DW Offset HelpHexTable9 + DW Offset HelpHexTable10 + DW Offset HelpHexTable11 + DW Offset HelpHexTable12 + DW Offset HelpHexTable13 + DW Offset HelpHexTable14 + DW Offset HelpHexTable15 + DW Offset HelpHexTable16 + DW Offset HelpHexTable17 + DW Offset HelpHexTable18 + DW Offset HelpHexTable19 + DW Offset HelpHexTable20 + DW Offset HelpHexTable21 + DW Offset HelpHexTable22 + DW Offset HelpHexTable23 + DW Offset HelpHexTable24 + DW Offset HelpHexTable25 + DW Offset HelpHexTable26 + DW Offset HelpHexTable27 + DW Offset HelpHexTable28 + DW Offset HelpHexTable29 + DW Offset HelpHexTable30 + DW Offset HelpHexTable31 + DW Offset HelpHexTable32 + DW Offset HelpHexTable33 + DW Offset HelpHexTable34 + DW Offset HelpHexTable35 + DW Offset Divider + + & + DW 0 + +HelpContext1_0 DB 32, 0FFh, 1, 139, 0FFh, 16, 134, 0FFh, 1, 138, 0 +HelpContext1_1 DB 32, 0FFh, 1, 132, ' ', 86h, 'Edit ', 0FFh, 1, 145, 0 +HelpContext1_2 DB 32, 0FFh, 1, 137, 0FFh, 16, 143, 0FFh, 1, 150, 0 +HelpContext1_3 DB 3, 'Summary ', 0BEh, 'Effects.', 0 + +HelpContext1_200 DB 4, 89h, 'Column ', 0BDh, 's.', 0 +HelpContext1_201 DB 5, 'Ax', 8Bh, 8Ah, 87h, 0 +HelpContext1_202 DB 5, 'Bx', 8Bh, 8Ah, 88h, 0 +HelpContext1_203 DB 5, 'Cx ', 89h, 87h, 0 +HelpContext1_204 DB 5, 'Dx ', 89h, 88h, 0 +HelpContext1_205 DB 5, 'Ex ', 0BAh, 88h, 0 +HelpContext1_206 DB 5, 'Fx ', 0BAh, 87h, 0 +HelpContext1_207 DB 5, 'Gx ', 0BCh, 0B1h, 0A5h, 0A0h, 0C4h, 'x', 0 +HelpContext1_208 DB 5, 'Hx V', 0B3h, 0A0h, 0C6h, 'x', 0 + +HelpContext1_299 DB 4, 'General ', 0BDh, 's.', 0 + +HelpContext1_4 DB 5, 'Axx ', 0A6h, 'song ', 0C4h, '(hex)', 0 +HelpContext1_5 DB 5, 'Bxx Jump ', 0B1h, 0B9h, '(hex)', 0 +HelpContext1_6 DB 5, 'Cxx Break ', 0B1h, 'row xx (hex) ', 0BEh, 0B4h, 85h, 0 +HelpContext1_7 DB 5, 'D0x ', 89h, 88h, 0 +HelpContext1_8 DB 5, 'Dx0 ', 89h, 87h, 0 +HelpContext1_9 DB 5, 'DFx', 8Bh, 8Ah, 88h, 0 +HelpContext1_10 DB 5, 'DxF', 8Bh, 8Ah, 87h, 0 +HelpContext1_11 DB 5, 'Exx ', 0BAh, 88h, 'x', 0 +HelpContext1_12 DB 5, 'EFx', 8Bh, 0BBh, 88h, 0 +HelpContext1_13 DB 5, 'EEx Extra fine ', 0BBh, 88h, 0 +HelpContext1_14 DB 5, 'Fxx ', 0BAh, 87h, 'x', 0 +HelpContext1_15 DB 5, 'FFx', 8Bh, 0BBh, 87h, 0 +HelpContext1_16 DB 5, 'FEx Extra fine ', 0BBh, 87h, 0 +HelpContext1_17 DB 5, 'Gxx ', 0BCh, 0B1h, 0A5h, 0A0h, 0C4h, 'xx', 0 +HelpContext1_18 DB 5, 'Hxy V', 0B3h, 0A0h, 0C5h, 0 +HelpContext1_19 DB 5, 'Ixy Tremor ', 0A0h, 'ontime x ', 0A1h, 'offtime y', 0 +HelpContext1_20 DB 5, 'Jxy Arpeggio ', 0A0h, 'halftones x ', 0A1h, 'y', 0 +HelpContext1_21 DB 5, 'Kxx', 9Bh, 'H00 & Dxx', 0 +HelpContext1_22 DB 5, 'Lxx', 9Bh, 'G00 & Dxx', 0 +HelpContext1_23 DB 5, 'Mxx ', 0A6h, 0A4h, 8Ah, 0B1h, 'xx (0->40h)', 0 +HelpContext1_24 DB 5, 'N0x ', 8Dh, 8Ah, 88h, 0 +HelpContext1_141 DB 5, 'Nx0 ', 8Dh, 8Ah, 87h, 0 +HelpContext1_142 DB 5, 'NFx', 8Bh, 0A4h, 8Ah, 88h, 0 +HelpContext1_143 DB 5, 'NxF', 8Bh, 0A4h, 8Ah, 87h, 0 +HelpContext1_25 DB 5, 'Oxx ', 0A6h, 95h, ' offset ', 0B1h, 'yxx00h, y set ', 0A0h, 'SAy', 0 +HelpContext1_26 DB 5, 'P0x ', 0B8h, 0A7h, 0B1h, 'right ', 0B0h, 'x', 0 +HelpContext1_135 DB 5, 'Px0 ', 0B8h, 0A7h, 0B1h, 'left ', 0B0h, 'x', 0 +HelpContext1_136 DB 5, 'PFx', 8Bh, 0B5h, 0A7h, 0B1h, 'right ', 0B0h, 'x', 0 +HelpContext1_137 DB 5, 'PxF', 8Bh, 0B5h, 0A7h, 0B1h, 'left ', 0B0h, 'x', 0 +HelpContext1_27 DB 5, 'Qxy Retrigger ', 0A5h, 'every y ticks ', 0A0h, 8Ah, 'modifier x', 0 +HelpContext1_28 DB 7, 'Values for x:', 0 +HelpContext1_29 DB 9, '0: No ', 8Ah, 0C9h, 0FFh, 8, ' 8: Not used', 0 +HelpContext1_30 DB 9, '1: -1', 0FFh, 23, ' 9: +1', 0 +HelpContext1_31 DB 9, '2: -2', 0FFh, 23, ' A: +2', 0 +HelpContext1_32 DB 9, '3: -4', 0FFh, 23, ' B: +4', 0 +HelpContext1_33 DB 9, '4: -8', 0FFh, 23, ' C: +8', 0 +HelpContext1_34 DB 9, '5: -16', 0FFh, 22, ' D: +16', 0 +HelpContext1_35 DB 9, '6: *2/3', 0FFh, 21, ' E: *3/2', 0 +HelpContext1_36 DB 9, '7: *1/2', 0FFh, 21, ' F: *2', 0 +; HelpContext1_37 DB 9, '8: Not used', 0 +; HelpContext1_38 DB 9, '9: +1', 0 +; HelpContext1_39 DB 9, 'A: +2', 0 +; HelpContext1_40 DB 9, 'B: +4', 0 +; HelpContext1_41 DB 9, 'C: +8', 0 +; HelpContext1_42 DB 9, 'D: +16', 0 +; HelpContext1_43 DB 9, 'E: *3/2', 0 +; HelpContext1_44 DB 9, 'F: *2', 0 +HelpContext1_45 DB 5, 'Rxy Tremelo ', 0A0h, 0C5h, 0 +HelpContext1_46 DB 5, 0FEh, 7, 'S0x ', 0A6h, 'filter', 0 +HelpContext1_47 DB 5, 0FEh, 7, 'S1x ', 0A6h, 'glissando control', 0 +HelpContext1_48 DB 5, 0FEh, 7, 'S2x ', 0A6h, 'finetune', 0 +HelpContext1_49 DB 5, 'S3x ', 0A6h, 'v', 0B3h, 9Ah, 0 +HelpContext1_50 DB 5, 'S4x ', 0A6h, 'tremelo ', 9Ah, 0 +HelpContext1_51 DB 5, 'S5x ', 0A6h, 'panbrello ', 9Ah, 0 +HelpContext1_62 DB 7, 'Waveforms for commands S3x, S4x ', 0A1h, 'S5x:', 0 +HelpContext1_63 DB 9, '0: Sine wave', 0 +HelpContext1_64 DB 9, '1: Ramp down', 0 +HelpContext1_65 DB 9, '2: Square wave', 0 +HelpContext1_66 DB 9, '3: Random wave', 0 +HelpContext1_52 DB 5, 'S6x ', 86h, 'delay for x ticks', 0 +HelpContext1_53 DB 5, 'S70', 0C0h, 0A5h, 'cut', 0 +HelpContext1_144 DB 5, 'S71', 0C0h, 0A5h, 'off', 0 +HelpContext1_145 DB 5, 'S72', 0C0h, 0A5h, 'fade', 0 +HelpContext1_153 DB 5, 'S73', 96h, 0A5h, 'cut', 0 +HelpContext1_154 DB 5, 'S74', 96h, 'continue', 0 +HelpContext1_155 DB 5, 'S75', 96h, 0A5h, 'off', 0 +HelpContext1_156 DB 5, 'S76', 96h, 0A5h, 'fade', 0 +HelpContext1_157 DB 5, 'S77 ', 0ACh, 'off ', 8Ah, 8Ch, 0 +HelpContext1_162 DB 5, 'S78 ', 0ACh, 'on ', 8Ah, 8Ch, 0 +HelpContext1_168 DB 5, 'S79 ', 0ACh, 'off ', 0B5h, 8Ch, 0 +HelpContext1_169 DB 5, 'S7A ', 0ACh, 'on ', 0B5h, 8Ch, 0 +HelpContext1_170 DB 5, 'S7B ', 0ACh, 'off ', 0BBh, 8Ch, 0 +HelpContext1_171 DB 5, 'S7C ', 0ACh, 'on ', 0BBh, 8Ch, 0 +HelpContext1_54 DB 5, 'S8x ', 0A6h, 0B5h, 'position', 0 +HelpContext1_55 DB 5, 'S91 ', 0A6h, 'surround sound', 0 +HelpContext1_56 DB 5, 'SAy ', 0A6h, 'high value ', 0BEh, 95h, ' offset yxx00h', 0 +HelpContext1_57 DB 5, 'SB0 ', 0A6h, 'loopback point', 0 +HelpContext1_146 DB 5, 'SBx Loop x times ', 0B1h, 'loopback point', 0 +HelpContext1_58 DB 5, 'SCx ', 0C3h, 'cut after x ticks', 0 +HelpContext1_59 DB 5, 'SDx ', 0C3h, 'delay for x ticks', 0 +HelpContext1_60 DB 5, 'SEx ', 86h, 'delay for x rows', 0 +HelpContext1_61 DB 5, 'SFx ', 0A6h, 'parameterised MIDI Macro', 0 +HelpContext1_179 DB 5, 'T0x ', 97h, 88h, 0 +HelpContext1_180 DB 5, 'T1x ', 97h, 87h, 0 +HelpContext1_67 DB 5, 'Txx ', 0A6h, 97h, 0B1h, 'xx (20h->0FFh)', 0 +HelpContext1_68 DB 5, 'Uxy', 8Bh, 'v', 0B3h, 0A0h, 0C5h, 0 +HelpContext1_69 DB 5, 'Vxx ', 0A6h, 'g', 0B2h, 8Ah, 0B1h, 'xx (0->80h)', 0 +HelpContext1_70 DB 5, 'W0x G', 0B2h, 8Ah, 88h, 0 +HelpContext1_138 DB 5, 'Wx0 G', 0B2h, 8Ah, 87h, 0 +HelpContext1_139 DB 5, 'WFx', 8Bh, 'g', 0B2h, 8Ah, 88h, 0 +HelpContext1_140 DB 5, 'WxF', 8Bh, 'g', 0B2h, 8Ah, 87h, 0 +HelpContext1_71 DB 5, 'Xxx ', 0A6h, 0B5h, 'position (0->0FFh)', 0 +HelpContext1_72 DB 5, 'Yxy Panbrello ', 0A0h, 0C5h, 0 +HelpContext1_73 DB 5, 'Zxx MIDI Macros', 0 + +HelpContext1_74 DB 3, 86h, 'Edit ', 0ADh, '.', 0 +HelpContext1_114 DB 5, 'Grey +,-', 0FFh, 9, ' ', 0C7h, 85h, 0CDh, 0 +HelpContext1_115 DB 5, 'Shift +,-', 0FFh, 8, ' ', 0C7h, '4 ', 85h, 0CDh, 0 +HelpContext1_134 DB 5, "Ctrl +,-", 0FFh, 9, " ", 0C7h, "order's ", 85h, 0CDh, 0 +HelpContext1_75 DB 5, '0-9', 0FFh, 14, ' ', 0C8h, 'octave/volume/', 8Fh, 0 +HelpContext1_76 DB 5, '0-9, A-F', 0FFh, 9, ' ', 0C8h, 0BDh, 'value', 0 +HelpContext1_77 DB 5, 'A-Z', 0FFh, 14, ' ', 0C8h, 0BDh, 0 +HelpContext1_78 DB 5, '. (Period)', 0FFh, 7, ' Clear field(s)', 0 +HelpContext1_79 DB 5, '1', 0FFh, 16, ' ', 0C3h, 'cut (^^^)', 0 +HelpContext1_80 DB 5, '`', 0FFh, 16, ' ', 0C3h, 'off (', 0FFh, 3, 'Í) / ', 0B8h, 9Dh, 0 + +HelpContext1_81 DB 5, 'Spacebar', 0FFh, 9, ' Use last note/', 8Fh, '/volume/', 0BDh, '/', 0BDh, 'value', 0 +HelpContext1_181 DB 5, 'Caps Lock+Key', 0FFh, 4, ' Preview ', 0A5h, 0 +HelpContext1_82 DB 5, 99h, 0FFh, 11, ' Get default note/', 8Fh, '/volume/', 0BDh, 0 +HelpContext1_83 DB 5, '< or ', 81h, 'Up', 0FFh, 5, ' ', 93h, ' ', 8Fh, 0 +HelpContext1_163 DB 5, '> or ', 81h, 'Down ', 92h, ' ', 8Fh, 0 +HelpContext1_84 DB 5, 'Grey /,*', 0FFh, 9, ' ', 93h, '/', 92h, ' octave', 0 +HelpContext1_85 DB 5, ', (Comma)', 0FFh, 8, ' ', 9Dh, 'edit mask for ', 0A2h, 'field', 0 +HelpContext1_86 DB 5, 0C1h, '/', 0C2h, 0FFh, 10, ' ', 9Eh, 0BFh, 'row to/', 0A9h, 0A2h, 0A3h, 0 +HelpContext1_127 DB 5, 80h, 0C1h, '/', 0C2h, 0FFh, 6, ' ', 9Eh, 'an entire row to/', 0A9h, 85h, 0CDh, 0 +HelpContext1_87 DB 5, 'Up/Down', 0FFh, 10, ' ', 9Ch, 0B7h, 0B0h, 'the skipvalue (set ', 0A0h, 'Alt 0-9)', 0 +HelpContext1_164 DB 5, 81h, 'Home/End', 0FFh, 4, ' ', 9Ch, 0B7h, 0B0h, '1 row', 0 +HelpContext1_129 DB 5, 80h, 'Up/Down', 0FFh, 6, ' ', 0BCh, 85h, 0B7h, 0B0h, '1 row', 0 +HelpContext1_88 DB 5, 'Left/Right', 0FFh, 7, ' ', 9Ch, 'cursor left/right', 0 +HelpContext1_131 DB 5, 80h, 'Left/Right ', 9Ch, 'forwards/backwards one ', 0A3h, 0 +HelpContext1_90 DB 5, 'Tab/', 82h, 'Tab', 0FFh, 4, ' ', 9Ch, 'forwards/backwards ', 0B1h, 0A5h, 'column', 0 +HelpContext1_89 DB 5, 'PgUp/PgDn', 0FFh, 8, ' ', 9Ch, 0B7h, 'n lines (n=Row Hilight Major)', 0 +HelpContext1_160 DB 5, 81h, 'PgUp/PgDn ', 9Ch, 0B1h, 'top/bottom ', 0BEh, 85h, 0 +HelpContext1_91 DB 5, 'Home', 0FFh, 13, ' ', 9Ch, 0B1h, 'start ', 0BEh, 'column/start of line/start of ', 85h, 0 +HelpContext1_92 DB 5, 'End', 0FFh, 14, ' ', 9Ch, 0B1h, 'end ', 0BEh, 'column/end ', 0BEh, 'line/end of', 85h, 0 +HelpContext1_93 DB 5, 'Backspace', 0FFh, 8, ' ', 9Ch, 0B1h, 'previous position (accounts for Multi', 0A3h, ')', 0 +HelpContext1_116 DB 5, 80h, 'N', 0FFh, 12, ' ', 9Dh, 'Multichannel mode for ', 0A2h, 0A3h, 0 +HelpContext1_124 DB 3, '2*', 80h, 'N', 0FFh, 12, ' Multichannel Selection menu', 0 +HelpContext1_130 DB 5, 80h, 99h, 0FFh, 7, ' Store ', 85h, 90h, 0 +HelpContext1_117 DB 5, 80h, 'Backspace', 0FFh, 4, ' Revert ', 85h, 90h, ' ', 0CDh, 0 +HelpContext1_161 DB 5, 81h, 'Backspace Undo - any function ', 0A0h, 0CDh, ' can be undone', 0 + +HelpContext1_166 DB 5, 81h, 'C', 0FFh, 11, ' ', 9Dh, 'centralise cursor', 0 +HelpContext1_174 DB 5, 81h, 'H', 0FFh, 11, ' ', 9Dh, 0A2h, 'row hilight', 0 +HelpContext1_300 DB 5, 81h, 'V', 0FFh, 11, ' ', 9Dh, 'default ', 8Ah, 'display', 0 + +HelpContext1_176 DB 5, 81h, 'F2', 0FFh, 10, ' ', 0A6h, 85h, 'length', 0 + +HelpContext1_118 DB 4, 'Track View Functions.', 0 +HelpContext1_119 DB 5, 80h, "T", 0FFh, 12, " Cycle ", 0A2h, "track's view", 0 +HelpContext1_120 DB 5, 80h, 'R', 0FFh, 12, ' Clear all ', 0CBh, 'views', 0 +HelpContext1_121 DB 5, 80h, 'H', 0FFh, 12, ' ', 9Dh, 0CBh, 'view divisions', 0 +HelpContext1_122 DB 5, 81h, '0', 0FFh, 11, ' Deselect ', 0A2h, 0CBh, 0 +HelpContext1_123 DB 5, 81h, '1 - ', 81h, '5 View ', 0A2h, 0CBh, 'in scheme 1-5', 0 +HelpContext1_128 DB 5, 81h, 'Left/Right ', 9Ch, 'left/right ', 0A8h, 0CBh, 'view columns', 0 + +HelpContext1_167 DB 5, 'L-Ctrl&Shift 1-4 Quick view scheme setup', 0 + +HelpContext1_159 DB 5, 81h, 'T', 0FFh, 11, ' ', 9Dh, 'View-', 8Dh, 'cursor-tracking', 0 + +HelpContext1_94 DB 4, 'Block Functions.', 0 +HelpContext1_95 DB 5, 80h, 'B', 0FFh, 12, ' ', 0CAh, 'beginning ', 0BEh, 0CCh, 0 +HelpContext1_96 DB 5, 80h, 'E', 0FFh, 12, ' ', 0CAh, 'end ', 0BEh, 0CCh, 0 +HelpContext1_97 DB 5, 80h, 'D', 0FFh, 12, ' Quick mark n/2n/4n/... lines (n=Row Hilight Major)', 0 +HelpContext1_98 DB 5, 80h, 'L', 0FFh, 12, ' ', 0CAh, 'entire column/', 85h, 0 +HelpContext1_165 DB 5, 82h, 'Arrows', 0FFh, 5, ' ', 0CAh, 0CCh, 0 + +HelpContext1_99 DB 5, 80h, 'U', 0FFh, 12, ' Unmark block/Release ', 98h, 'memory', 0 + +HelpContext1_113 DB 5, 80h, 'Q', 0FFh, 12, ' Raise notes ', 0B0h, 0BFh, 0AFh, 0CDh, 0 +HelpContext1_100 DB 5, 80h, 'A', 0FFh, 12, ' Lower notes ', 0B0h, 0BFh, 0AFh, 0CDh, 0 +HelpContext1_101 DB 5, 80h, 'S', 0FFh, 12, ' ', 0A6h, 8Eh, 0CDh, 0 +HelpContext1_102 DB 5, 80h, 'V', 0FFh, 12, ' ', 0A6h, 'volume/', 0B5h, 0CDh, 0 +HelpContext1_103 DB 5, 80h, 'W', 0FFh, 12, ' ', 0CEh, 'vol/pan not associated ', 0A0h, 0BFh, 'note/', 8Fh, ' ', 0CDh, 0 +HelpContext1_104 DB 5, 80h, 'K', 0FFh, 12, ' ', 0BCh, 'volume/', 0B5h, 'column ', 0CDh, 0 +HelpContext1_133 DB 3, '2*', 80h, 'K', 0FFh, 12, ' ', 0CEh, 'all volume/', 0B5h, 'controls ', 0CDh, 0 +HelpContext1_105 DB 5, 80h, 'J', 0FFh, 12, ' ', 89h, 'amplifier ', 0CDh, ' / Fast ', 8Ah, 'attenuate ', 0CDh, 0 +HelpContext1_106 DB 5, 80h, 'Z', 0FFh, 12, ' Cut ', 0CCh, 0CDh, 0 +HelpContext1_132 DB 5, 80h, 'X', 0FFh, 12, ' ', 0BCh, 0BDh, ' value ', 0CDh, 0 +HelpContext1_107 DB 3, '2*', 80h, 'X', 0FFh, 12, ' ', 0CEh, 'all ', 0BDh, ' ', 90h, ' ', 0CDh, 0 + +HelpContext1_108 DB 5, 80h, 'C', 0FFh, 12, ' Copy ', 0CCh, 'into ', 98h, 0 +HelpContext1_109 DB 5, 80h, 'P', 0FFh, 12, ' Paste ', 90h, ' ', 0A9h, 98h, 0CDh, 0 +HelpContext1_110 DB 5, 80h, 'O', 0FFh, 12, ' Overwrite ', 0A0h, 90h, ' ', 0A9h, 98h, ' ', 0CDh, 0 +HelpContext1_111 DB 5, 80h, 'M', 0FFh, 12, ' Mix each row ', 0A9h, 98h, 0A0h, 85h, 90h, ' ', 0CDh, 0 +HelpContext1_173 DB 3, '2*', 80h, 'M', 0FFh, 12, ' Mix each field ', 0A9h, 98h, 0A0h, 85h, 90h, 0 + +HelpContext1_125 DB 5, 80h, 'F', 0FFh, 12, ' Double ', 0CCh, 'length ', 0CDh, 0 +HelpContext1_126 DB 5, 80h, 'G', 0FFh, 12, ' Halve ', 0CCh, 'length ', 0CDh, 0 + +HelpContext1_112 DB 5, 80h, 'I', 0FFh, 12, ' Select Template mode / Fast ', 8Ah, 'amplify ', 0CDh, 0 + +HelpContext1_175 DB 5, 81h, 'J', 0FFh, 11, ' ', 9Dh, 'fast ', 8Ah, 'mode', 0 + +HelpContext1_147 DB 3, 'Playback Functions.', 0 +HelpContext1_148 DB 5, '4', 0FFh, 16, ' ', 9Fh, 0A5h, 'under cursor', 0 +HelpContext1_149 DB 5, '8', 0FFh, 16, ' ', 9Fh, 'row', 0 + +HelpContext1_152 DB 5, 81h, 'F6', 0FFh, 10, ' ', 9Fh, 0A9h, 0A2h, 'row', 0 +HelpContext1_158 DB 5, 81h, 'F7', 0FFh, 10, ' Set/Clear playback mark (for use ', 0A0h, 'F7)', 0 + +HelpContext1_150 DB 5, 80h, 'F9', 0FFh, 11, ' ', 9Dh, 0A2h, 0A3h, 0 +HelpContext1_151 DB 5, 80h, 'F10', 0FFh, 10, ' Solo ', 0A2h, 0A3h, 0 + +HelpContext1_172 DB 5, 'Scroll Lock', 0FFh, 6, ' ', 9Dh, 'playback tracing', 0 +HelpContext1_177 DB 5, 81h, 'Z', 0FFh, 11, ' ', 0C8h, 'MIDI playback trigger', 0 +HelpContext1_178 DB 5, 80h, 'Scroll Lock ', 9Dh, 'MIDI input', 0 + +HelpContext2Ptrs Label Word + DW Offset HelpContext2_0 + DW Offset HelpContext2_1 + DW Offset HelpContext2_2 + DW Offset NewLine + DW Offset HelpContext2_3 + DW Offset HelpContext2_10 + DW Offset HelpContext2_4 + DW Offset HelpContext2_5 + DW Offset NewLine + DW Offset HelpContext2_11 + DW Offset HelpContext2_23 + DW Offset HelpContext2_8 + DW Offset HelpContext2_6 + DW Offset HelpContext2_17 + DW Offset HelpContext2_18 + DW Offset HelpContext2_27 + DW Offset HelpContext2_30 + DW Offset HelpContext2_33 + DW Offset HelpContext2_7 + DW Offset HelpContext2_29 + DW Offset HelpContext2_28 + DW Offset HelpContext2_14 + DW Offset HelpContext2_19 + DW Offset HelpContext2_12 + DW Offset HelpContext2_13 + DW Offset HelpContext2_16 + DW Offset HelpContext2_15 + DW Offset HelpContext2_9 + DW Offset NewLine + DW Offset HelpContext2_31 + DW Offset HelpContext2_32 + DW Offset NewLine + DW Offset HelpContext2_26 + DW Offset NewLine + DW Offset HelpContext2_21 + DW Offset HelpContext2_22 + DW Offset HelpContext2_24 + DW Offset HelpContext2_25 + DW Offset NewLine + DW Offset Divider + DW Offset NewLine + DW Offset HelpGlobal_0 + DW Offset HelpGlobal_1 + DW Offset HelpGlobal_37 + DW Offset HelpGlobal_3 + DW Offset HelpGlobal_4 + DW Offset HelpGlobal_20 + DW Offset HelpGlobal_9 + DW Offset HelpGlobal_22 + DW Offset HelpGlobal_10 + DW Offset HelpGlobal_19 + DW Offset HelpGlobal_11 + DW Offset HelpGlobal_12 + DW Offset HelpGlobal_33 + DW Offset HelpGlobal_13 + DW Offset HelpGlobal_5 + DW Offset HelpGlobal_23 + DW Offset HelpGlobal_6 + DW Offset HelpGlobal_2 + DW Offset HelpGlobal_7 + DW Offset HelpGlobal_8 + DW Offset HelpGlobal_32 + DW Offset NewLine + DW Offset HelpGlobal_17 + DW Offset HelpGlobal_31 + DW Offset HelpGlobal_18 + DW Offset NewLine + DW Offset HelpGlobal_16 + DW Offset HelpGlobal_34 + DW Offset HelpGlobal_35 + DW Offset HelpGlobal_36 + DW Offset HelpGlobal_21 + DW Offset HelpGlobal_14 + DW Offset HelpGlobal_15 + DW Offset NewLine + DW Offset Divider + DW 0 ; End of list. + +HelpContext2_0 DB 31, 0FFh, 1, 139, 0FFh, 17, 134, 0FFh, 1, 138, 0 +HelpContext2_1 DB 31, 0FFh, 1, 132, ' ', 94h, 0AAh, ' ', 0FFh, 1, 145, 0 +HelpContext2_2 DB 31, 0FFh, 1, 137, 0FFh, 17, 143, 0FFh, 1, 150, 0 + +HelpContext2_3 DB 3, 94h, 0AAh, 0ADh, '.', 0 +HelpContext2_10 DB 5, 99h, 0FFh, 7, ' Load new ', 95h, 0 +HelpContext2_4 DB 5, 'Tab', 0FFh, 10, ' ', 9Ch, 0A8h, 'options', 0 +HelpContext2_5 DB 5, 'PgUp/PgDn', 0FFh, 4, ' ', 9Ch, 0B7h, '(when not on list)', 0 + +HelpContext2_11 DB 5, 80h, 'A', 0FFh, 8, ' Convert Signed to/', 0A9h, 'Unsigned ', 95h, 's', 0 +HelpContext2_23 DB 5, 80h, 'B', 0FFh, 8, ' Pre-Loop cut ', 95h, 0 +HelpContext2_8 DB 5, 80h, 'C', 0FFh, 8, ' Clear ', 94h, 'Name & Filename (Used in ', 94h, 'Name ', 0B6h, ')', 0 +HelpContext2_6 DB 5, 80h, 'D', 0FFh, 8, ' ', 084h, 94h, 0 +HelpContext2_17 DB 5, 80h, 'E', 0FFh, 8, ' Resize ', 94h, '(', 0A0h, 'interpolation)', 0 +HelpContext2_18 DB 5, 80h, 'F', 0FFh, 8, ' Resize ', 94h, '(without interpolation)', 0 +HelpContext2_27 DB 5, 80h, 'G', 0FFh, 8, ' Reverse ', 94h, 0 +HelpContext2_30 DB 5, 80h, 'H', 0FFh, 8, ' Centralise ', 94h, 0 +HelpContext2_33 DB 5, 80h, 'I', 0FFh, 8, ' Invert ', 94h, 0 +HelpContext2_7 DB 5, 80h, 'L', 0FFh, 8, ' Post-Loop cut ', 95h, 0 +HelpContext2_29 DB 5, 80h, 'M', 0FFh, 8, ' ', 94h, 'amplifier', 0 +HelpContext2_28 DB 5, 80h, 'N', 0FFh, 8, ' ', 9Dh, 'Multi', 0A4h, 'playback', 0 +HelpContext2_14 DB 5, 80h, 'O', 0FFh, 8, ' Save ', 0A2h, 95h, ' ', 0B1h, 'disk (IT Format)', 0 +HelpContext2_19 DB 5, 80h, 'Q', 0FFh, 8, ' ', 9Dh, 95h, ' quality', 0 +HelpContext2_12 DB 5, 80h, 'R', 0FFh, 8, ' Replace ', 0A2h, 95h, ' in song', 0 +HelpContext2_13 DB 5, 80h, 'S', 0FFh, 8, ' Swap ', 95h, ' (in song also)', 0 +HelpContext2_16 DB 5, 80h, 'T', 0FFh, 8, ' Save ', 0A2h, 95h, ' ', 0B1h, 'disk (ST3 Format)', 0 + +IF SAVESAMPLEWAV +HelpContext2_15 DB 5, 80h, 'W', 0FFh, 8, ' Save ', 0A2h, 95h, ' ', 0B1h, 'disk (WAV Format)', 0 +ELSE +HelpContext2_15 DB 5, 80h, 'W', 0FFh, 8, ' Save ', 0A2h, 95h, ' ', 0B1h, 'disk (RAW Format)', 0 +ENDIF + +HelpContext2_9 DB 5, 80h, 'X', 0FFh, 8, ' Ex', 0C9h, 95h, ' (only in ', 94h, 'List)', 0 + +HelpContext2_31 DB 5, 80h, 0C1h, 0FFh, 6, ' ', 83h, 95h, ' ', 91h, 0 +HelpContext2_32 DB 5, 80h, 0C2h, 0FFh, 6, ' Remove ', 95h, ' ', 91h, 0 + +HelpContext2_26 DB 5, '< >', 0FFh, 10, ' ', 93h, '/', 92h, ' playback ', 0A3h, 0 + +HelpContext2_21 DB 5, 80h, 'Grey + ', 92h, 0AEh, 'octave', 0 +HelpContext2_22 DB 5, 80h, 'Grey - ', 93h, 0AEh, 'octave', 0 +HelpContext2_24 DB 5, 81h, 'Grey + ', 92h, 0AEh, 0AFh, 0 +HelpContext2_25 DB 5, 81h, 'Grey - ', 93h, 0AEh, 0AFh, 0 + +HelpContext7Ptrs Label Word + DW Offset HelpContext7_0 + DW Offset HelpContext7_1 + DW Offset HelpContext7_2 + DW Offset NewLine + DW Offset HelpContext7_8 + DW Offset HelpContext7_26 + DW Offset HelpContext7_9 + DW Offset HelpContext7_10 + DW Offset HelpContext7_36 + DW Offset HelpContext7_22 + DW Offset NewLine + DW Offset HelpContext7_25 + DW Offset HelpContext7_24 + DW Offset HelpContext7_23 + DW Offset HelpContext7_28 + DW Offset HelpContext7_11 + DW Offset HelpContext7_12 + DW Offset HelpContext7_13 + DW Offset HelpContext7_14 + DW Offset NewLine + DW Offset HelpContext7_34 + DW Offset HelpContext7_35 + DW Offset NewLine + DW Offset HelpContext7_33 + DW Offset NewLine + DW Offset HelpContext7_3 + DW Offset HelpContext7_4 + DW Offset HelpContext7_5 + DW Offset NewLine + DW Offset HelpContext7_6 + DW Offset HelpContext7_7 + DW Offset HelpContext7_27 + DW Offset HelpContext7_29 + DW Offset HelpContext7_30 + DW Offset NewLine + DW Offset HelpContext7_15 + DW Offset HelpContext7_16 + DW Offset HelpContext7_17 + DW Offset HelpContext7_18 + DW Offset HelpContext7_19 + DW Offset NewLine + DW Offset HelpContext7_20 + DW Offset HelpContext7_21 + DW Offset NewLine + DW Offset Divider + DW Offset NewLine + DW Offset HelpGlobal_0 + DW Offset HelpGlobal_1 + DW Offset HelpGlobal_37 + DW Offset HelpGlobal_3 + DW Offset HelpGlobal_4 + DW Offset HelpGlobal_20 + DW Offset HelpGlobal_9 + DW Offset HelpGlobal_22 + DW Offset HelpGlobal_10 + DW Offset HelpGlobal_19 + DW Offset HelpGlobal_11 + DW Offset HelpGlobal_12 + DW Offset HelpGlobal_33 + DW Offset HelpGlobal_13 + DW Offset HelpGlobal_5 + DW Offset HelpGlobal_23 + DW Offset HelpGlobal_6 + DW Offset HelpGlobal_2 + DW Offset HelpGlobal_7 + DW Offset HelpGlobal_8 + DW Offset HelpGlobal_32 + DW Offset NewLine + DW Offset HelpGlobal_17 + DW Offset HelpGlobal_31 + DW Offset HelpGlobal_18 + DW Offset NewLine + DW Offset HelpGlobal_16 + DW Offset HelpGlobal_34 + DW Offset HelpGlobal_35 + DW Offset HelpGlobal_36 + DW Offset HelpGlobal_21 + DW Offset HelpGlobal_14 + DW Offset HelpGlobal_15 + DW Offset NewLine + DW Offset Divider + + DW 0 ; End of list + +HelpContext7_0 DB 29, 0FFh, 1, 139, 0FFh, 21, 134, 0FFh, 1, 138, 0 +HelpContext7_1 DB 29, 0FFh, 1, 132, ' ', 8Eh, 0AAh, ' ', 0FFh, 1, 145, 0 +HelpContext7_2 DB 29, 0FFh, 1, 137, 0FFh, 21, 143, 0FFh, 1, 150, 0 + +HelpContext7_8 DB 3, 8Eh, 0AAh, 0ADh, ".", 0 +HelpContext7_26 DB 5, 99h, 0FFh, 10, " Load new ", 8Fh, 0 +HelpContext7_9 DB 5, 81h, "PgUp/PgDn ", 9Ch, 8Fh, " ", 0B7h, "(when not on list)", 0 +HelpContext7_10 DB 5, 80h, "C", 0FFh, 11, " Clear ", 8Fh, " name & filename", 0 +HelpContext7_36 DB 5, 80h, "W", 0FFh, 11, ' ', 0CEh, 8Fh, " ", 90h, 0 +HelpContext7_22 DB 5, "Spacebar", 0FFh, 8, " Edit ", 8Fh, " name (ESC ", 0B1h, "exit)", 0 + +HelpContext7_25 DB 5, 80h, 'D', 0FFh, 11, ' ', 084h, 8Fh, ' & all related ', 95h, 's', 0 +HelpContext7_24 DB 5, 80h, 'N', 0FFh, 11, ' ', 9Dh, 'Multi', 0A4h, 'playback', 0 +HelpContext7_23 DB 5, 80h, 'O', 0FFh, 11, ' Save ', 0A2h, 8Fh, ' ', 0B1h, 'disk', 0 +HelpContext7_28 DB 5, 80h, 'P', 0FFh, 11, ' Copy ', 8Fh, 0 +HelpContext7_11 DB 5, 80h, 'R', 0FFh, 11, ' Replace ', 0A2h, 8Fh, ' in song', 0 +HelpContext7_12 DB 5, 80h, 'S', 0FFh, 11, ' Swap ', 08Fh, 's (in song also)', 0 +HelpContext7_13 DB 5, 80h, 'U', 0FFh, 11, ' Update ', 85h, 90h, 0 +HelpContext7_14 DB 5, 80h, 'X', 0FFh, 11, ' Ex', 0C9h, 08Fh, 's (only in ', 08Eh, 'List)', 0 + +HelpContext7_34 DB 5, 80h, 0C1h, 0FFh, 9, ' ', 83h, 8Fh, ' ', 91h, 0 +HelpContext7_35 DB 5, 80h, 0C2h, 0FFh, 9, ' Remove ', 8Fh, ' ', 91h, 0 + +HelpContext7_33 DB 5, '< >', 0FFh, 13, ' ', 93h, '/', 92h, ' playback ', 0A3h, 0 + +HelpContext7_3 DB 3, 0C3h, "Translation.", 0 +HelpContext7_4 DB 5, 99h, 0FFh, 10, " Pickup ", 95h, " number & default play ", 0A5h, 0 +HelpContext7_5 DB 5, "< >", 0FFh, 13, " ", 93h, "/", 92h, " ", 95h, " number", 0 +HelpContext7_6 DB 5, 80h, "A", 0FFh, 11, " ", 0C8h, "all ", 95h, "s", 0 +HelpContext7_7 DB 5, 80h, "N", 0FFh, 11, " ", 99h, 0B4h, 0A5h, 0 +HelpContext7_27 DB 5, 80h, "P", 0FFh, 11, " ", 99h, "previous ", 0A5h, 0 +HelpContext7_29 DB 5, 80h, "Up/Down", 0FFh, 5, " Transpose all notes ", 0BFh, 0AFh, 0B7h, 0 +HelpContext7_30 DB 5, 80h, 0C1h, "/", 0C2h, 0FFh, 5, " ", 9Eh, 0BFh, "row ", 0A9h, "the table", 0 + +HelpContext7_15 DB 3, 'Envelope ', 0ADh, '.', 0 +HelpContext7_16 DB 5, 99h, 0FFh, 10, ' Pick up/Drop ', 0A2h, 'node', 0 +HelpContext7_17 DB 5, 83h, 0FFh, 9, ' Add node', 0 +HelpContext7_18 DB 5, 84h, 0FFh, 9, ' ', 084h, 'node', 0 +HelpContext7_19 DB 5, 80h, 'Arrow ', 0ADh, ' ', 9Ch, 'node (fast)', 0 + +HelpContext7_20 DB 5, 'Press Spacebar ', 9Fh, 'default ', 0A5h, 0 +HelpContext7_21 DB 5, 'Release Space ', 0C3h, 'off command', 0 + +HelpContext9Ptrs Label Word + DW Offset HelpContext9_0 + DW Offset HelpContext9_1 + DW Offset HelpContext9_2 + DW Offset NewLine + DW Offset HelpContext9_3 + DW Offset HelpContext9_4 + DW Offset HelpContext9_11 + DW Offset HelpContext9_5 + DW Offset HelpContext9_6 + DW Offset HelpContext9_7 + DW Offset NewLine + DW Offset HelpContext9_15 + DW Offset HelpContext9_16 + DW Offset NewLine + DW Offset HelpContext9_8 + DW Offset HelpContext9_9 + DW Offset NewLine + DW Offset HelpContext9_10 + DW Offset NewLine + DW Offset HelpContext9_12 + DW Offset HelpContext9_14 + DW Offset NewLine + DW Offset HelpContext9_13 + DW Offset NewLine + DW Offset Divider + DW Offset NewLine + DW Offset HelpGlobal_0 + DW Offset HelpGlobal_1 + DW Offset HelpGlobal_37 + DW Offset HelpGlobal_3 + DW Offset HelpGlobal_4 + DW Offset HelpGlobal_20 + DW Offset HelpGlobal_9 + DW Offset HelpGlobal_22 + DW Offset HelpGlobal_10 + DW Offset HelpGlobal_19 + DW Offset HelpGlobal_11 + DW Offset HelpGlobal_12 + DW Offset HelpGlobal_33 + DW Offset HelpGlobal_13 + DW Offset HelpGlobal_5 + DW Offset HelpGlobal_23 + DW Offset HelpGlobal_6 + DW Offset HelpGlobal_2 + DW Offset HelpGlobal_7 + DW Offset HelpGlobal_8 + DW Offset HelpGlobal_32 + DW Offset NewLine + DW Offset HelpGlobal_17 + DW Offset HelpGlobal_31 + DW Offset HelpGlobal_18 + DW Offset NewLine + DW Offset HelpGlobal_16 + DW Offset HelpGlobal_34 + DW Offset HelpGlobal_35 + DW Offset HelpGlobal_36 + DW Offset HelpGlobal_21 + DW Offset HelpGlobal_14 + DW Offset HelpGlobal_15 + DW Offset NewLine + DW Offset Divider + DW 0 + +HelpContext9_0 DB 33, 0FFh, 1, 139, 0FFh, 13, 134, 0FFh, 1, 138, 0 +HelpContext9_1 DB 33, 0FFh, 1, 132, ' Info Page ', 0FFh, 1, 145, 0 +HelpContext9_2 DB 33, 0FFh, 1, 137, 0FFh, 13, 143, 0FFh, 1, 150, 0 + +HelpContext9_3 DB 3, 83h, 0FFh, 11, ' Add ', 0BFh, 'new ', 0B6h, 0 +HelpContext9_4 DB 3, 84h, 0FFh, 11, ' ', 084h, 0A2h, 0B6h, 0 +HelpContext9_11 DB 3, 'Tab/', 82h, 'Tab', 0FFh, 5, ' ', 9Ch, 0A8h, 0B6h, 's', 0 +HelpContext9_5 DB 3, 'Up/Dn/Left/Right ', 9Ch, 'highlighted ', 0A3h, 0 +HelpContext9_6 DB 3, 'PgUp/PgDn', 0FFh, 9, ' ', 0C8h, 0B6h, ' type', 0 +HelpContext9_7 DB 3, 80h, 'Up/Down', 0FFh, 7, ' ', 9Ch, 0B6h, ' base ', 0B7h, 0 + +HelpContext9_15 DB 3, 'V', 0FFh, 17, ' ', 9Dh, 0A8h, 'volume/velocity bars', 0 +HelpContext9_16 DB 3, 'I', 0FFh, 17, ' ', 9Dh, 0A8h, 95h, '/', 8Fh, ' names', 0 + +HelpContext9_8 DB 3, 'Q', 0FFh, 17, ' Mute/Unmute ', 0A2h, 0A3h, 0 +HelpContext9_9 DB 3, 'S', 0FFh, 17, ' Solo ', 0A2h, 0A3h, 0 + +HelpContext9_10 DB 3, 'Grey +, Grey -', 0FFh, 4, ' ', 9Ch, 'forwards/backwards one ', 85h, 'in song', 0 + +HelpContext9_12 DB 3, 80h, 'S', 0FFh, 13, ' ', 9Dh, 'Stereo playback', 0 +HelpContext9_14 DB 3, 80h, 'R', 0FFh, 13, ' Reverse output ', 0A3h, 's', 0 + +Helpcontext9_13 DB 3, 'G', 0FFh, 17, ' Goto ', 85h, 'currently playing', 0 + +HelpContext12Ptrs Label Word + DW Offset HelpContext12_0 + DW Offset HelpContext12_1 + DW Offset HelpContext12_2 + DW Offset NewLine + DW Offset HelpContext12_3 + DW Offset NewLine + DW Offset HelpContext12_4 + DW Offset HelpContext12_5 + DW Offset HelpContext12_6 + DW Offset NewLine + DW Offset Divider + DW Offset NewLine + DW Offset HelpGlobal_0 + DW Offset HelpGlobal_1 + DW Offset HelpGlobal_37 + DW Offset HelpGlobal_3 + DW Offset HelpGlobal_4 + DW Offset HelpGlobal_20 + DW Offset HelpGlobal_9 + DW Offset HelpGlobal_22 + DW Offset HelpGlobal_10 + DW Offset HelpGlobal_19 + DW Offset HelpGlobal_11 + DW Offset HelpGlobal_12 + DW Offset HelpGlobal_33 + DW Offset HelpGlobal_13 + DW Offset HelpGlobal_5 + DW Offset HelpGlobal_23 + DW Offset HelpGlobal_6 + DW Offset HelpGlobal_2 + DW Offset HelpGlobal_7 + DW Offset HelpGlobal_8 + DW Offset HelpGlobal_32 + DW Offset NewLine + DW Offset HelpGlobal_17 + DW Offset HelpGlobal_31 + DW Offset HelpGlobal_18 + DW Offset NewLine + DW Offset HelpGlobal_16 + DW Offset HelpGlobal_34 + DW Offset HelpGlobal_35 + DW Offset HelpGlobal_36 + DW Offset HelpGlobal_21 + DW Offset HelpGlobal_14 + DW Offset HelpGlobal_15 + DW Offset NewLine + DW Offset Divider + DW 0 + +HelpContext12_0 DB 31, 0FFh, 1, 139, 0FFh, 18, 134, 0FFh, 1, 138, 0 +HelpContext12_1 DB 31, 0FFh, 1, 132, ' Message Editor ', 0FFh, 1, 145, 0 +HelpContext12_2 DB 31, 0FFh, 1, 137, 0FFh, 18, 143, 0FFh, 1, 150, 0 + +HelpContext12_3 DB 3, 99h, '/ ESC', 0FFh, 5, ' Edit message / finished editing', 0 + +HelpContext12_4 DB 3, 'Editing ', 0ADh, '.', 0 +HelpContext12_5 DB 5, 81h, 'Y', 0FFh, 8, ' ', 084h, 'line', 0 +HelpContext12_6 DB 5, 80h, 'C', 0FFh, 9, ' Clear message', 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +DecodeWord80h DB "Alt-", 0 +DecodeWord81h DB "Ctrl-", 0 +DecodeWord82h DB "Shift-", 0 +DecodeWord83h DB 0C1h, "ert ", 0 +DecodeWord84h DB 0C2h, "ete ", 0 +DecodeWord85h DB "pattern ", 0 +DecodeWord86h DB "Pattern ", 0 +DecodeWord87h DB 0A7h, "up ", 0B0h, "x", 0 +DecodeWord88h DB 0A7h, "down ", 0B0h, "x", 0 +DecodeWord89h DB "Volume ", 0 +DecodeWord8Ah DB "volume ", 0 +DecodeWord8Bh DB " Fine ", 0 +DecodeWord8Ch DB "envelope", 0 +DecodeWord8Dh DB "Channel ", 0 +DecodeWord8Eh DB 0C1h, "trument ", 0 +DecodeWord8Fh DB "instrument", 0 +DecodeWord90h DB "data", 0 +DecodeWord91h DB "slot (updates ", 85h, 90h, ")", 0 +DecodeWord92h DB "Increase", 0 +DecodeWord93h DB "Decrease", 0 +DecodeWord94h DB "Sample ", 0 +DecodeWord95h DB "sample", 0 +DecodeWord96h DB " ", 0A6h, "NNA ", 0B1h, 0 +DecodeWord97h DB "Tempo ", 0 +DecodeWord98h DB "clipboard ", 0 +DecodeWord99h DB "Enter ", 0 +DecodeWord9Ah DB "waveform ", 0B1h, "type x", 0 +DecodeWord9Bh DB " Dual Command: ", 0 +DecodeWord9Ch DB "Move ", 0 +DecodeWord9Dh DB "Toggle ", 0 +DecodeWord9Eh DB 0C1h, "ert/", 0C2h, "ete ", 0 +DecodeWord9Fh DB "Play ", 0 +DecodeWordA0h DB "with ", 0 +DecodeWordA1h DB "and ", 0 +DecodeWordA2h DB "current ", 0 +DecodeWordA3h DB "channel", 0 +DecodeWordA4h DB 0A3h, ' ', 0 +DecodeWordA5h DB "note ", 0 +DecodeWordA6h DB "Set ", 0 +DecodeWordA7h DB "slide ", 0 +DecodeWordA8h DB "between ", 0 +DecodeWordA9h DB "from ", 0 +DecodeWordAAh DB "List ", 0 +DecodeWordABh DB "Library ", 0 +DecodeWordACh DB "Turn ", 0 +DecodeWordADh DB "Keys", 0 +DecodeWordAEh DB ' C-5 Frequency by 1 ', 0 +DecodeWordAFh DB 'semitone ', 0 +DecodeWordB0h DB "by ", 0 +DecodeWordB1h DB "to ", 0 +DecodeWordB2h DB "lobal ", 0 +DecodeWordB3h DB "ibra", 0B1h, 0 +DecodeWordB4h DB "next ", 0 +DecodeWordB5h DB "panning ", 0 +DecodeWordB6h DB "window", 0 +DecodeWordB7h DB "up/down ", 0 +DecodeWordB8h DB "Panning ", 0 +DecodeWordB9h DB "Order ", 0 +DecodeWordBAh DB "Pitch ", 0 +DecodeWordBBh DB "pitch ", 0 +DecodeWordBCh DB "Slide ", 0 +DecodeWordBDh DB "effect", 0 +DecodeWordBEh DB "of ", 0 +DecodeWordBFh DB "a ", 0 +DecodeWordC0h DB " Past ", 0 +DecodeWordC1h DB "Ins", 0 +DecodeWordC2h DB "Del", 0 +DecodeWordC3h DB "Note ", 0 +DecodeWordC4h DB "speed ", 0 +DecodeWordC5h DB 0C4h, "x, ", 0C6h, "y", 0 +DecodeWordC6h DB "depth ", 0 +DecodeWordC7h DB "Next/Previous ", 0 +DecodeWordC8h DB "Change ", 0 +DecodeWordC9h DB "change ", 0 +DecodeWordCAh DB "Mark ", 0 +DecodeWordCBh DB "track ", 0 +DecodeWordCCh DB "block ", 0 +DecodeWordCDh DB " (*)", 0 +DecodeWordCEh DB "Wipe ", 0 + +; channel, pitch, column, effect, note, current, list, library +; speed/width, turn, on, off, down, instrument +; semitone, octave, block, edit, save, (g)lobal, (v)ibrato, (p)anbrello +; cursor, window + +DecodeBuffer DB 80 Dup (0) +DecodeWords DW Offset DecodeWord80h, Offset DecodeWord81h + DW Offset DecodeWord82h, Offset DecodeWord83h + DW Offset DecodeWord84h, Offset DecodeWord85h + DW Offset DecodeWord86h, Offset DecodeWord87h + DW Offset DecodeWord88h, Offset DecodeWord89h + DW Offset DecodeWord8Ah, Offset DecodeWord8Bh + DW Offset DecodeWord8Ch, Offset DecodeWord8Dh + DW Offset DecodeWord8Eh, Offset DecodeWord8Fh + DW Offset DecodeWord90h, Offset DecodeWord91h + DW Offset DecodeWord92h, Offset DecodeWord93h + DW Offset DecodeWord94h, Offset DecodeWord95h + DW Offset DecodeWord96h, Offset DecodeWord97h + DW Offset DecodeWord98h, Offset DecodeWord99h + DW Offset DecodeWord9Ah, Offset DecodeWord9Bh + DW Offset DecodeWord9Ch, Offset DecodeWord9Dh + DW Offset DecodeWord9Eh, Offset DecodeWord9Fh + DW Offset DecodeWordA0h, Offset DecodeWordA1h + DW Offset DecodeWordA2h, Offset DecodeWordA3h + DW Offset DecodeWordA4h, Offset DecodeWordA5h + DW Offset DecodeWordA6h, Offset DecodeWordA7h + DW Offset DecodeWordA8h, Offset DecodeWordA9h + DW Offset DecodeWordAAh, Offset DecodeWordABh + DW Offset DecodeWordACh, Offset DecodeWordADh + DW Offset DecodeWordAEh, Offset DecodeWordAFh + DW Offset DecodeWordB0h, Offset DecodeWordB1h + DW Offset DecodeWordB2h, Offset DecodeWordB3h + DW Offset DecodeWordB4h, Offset DecodeWordB5h + DW Offset DecodeWordB6h, Offset DecodeWordB7h + DW Offset DecodeWordB8h, Offset DecodeWordB9h + DW Offset DecodeWordBAh, Offset DecodeWordBBh + DW Offset DecodeWordBCh, Offset DecodeWordBDh + DW Offset DecodeWordBEh, Offset DecodeWordBFh + DW Offset DecodeWordC0h, Offset DecodeWordC1h + DW Offset DecodeWordC2h, Offset DecodeWordC3h + DW Offset DecodeWordC4h, Offset DecodeWordC5h + DW Offset DecodeWordC6h, Offset DecodeWordC7h + DW Offset DecodeWordC8h, Offset DecodeWordC9h + DW Offset DecodeWordCAh, Offset DecodeWordCBh + DW Offset DecodeWordCCh, Offset DecodeWordCDh + DW Offset DecodeWordCEh + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc H_DrawHelp Far + + Push CS + Pop DS + + Push CS + Pop ES + + Assume DS:Help + + Mov CX, 32 + Mov SI, HelpContext + Add SI, SI + Mov SI, [HelpContextPtrs+SI] + Mov DI, 13*160 + + Mov AX, TopLine + Add AX, AX + Add SI, AX + +H_DrawHelp1: + Push SI + Push DI + + Mov SI, [SI] + LodsB + Xor AH, AH + Add AX, AX + Add DI, AX + +; DS:SI points to string. Deposit into buffer + + Push DI + Mov DI, Offset DecodeBuffer + + Mov DX, 1 + +H_DecodeBuffer1: + LodsB + Test AL, AL + JZ H_DecodeBuffer4 + JS H_DecodeBuffer2 + + StosB + Jmp H_DecodeBuffer1 + +H_DecodeBuffer2: + Cmp AL, -2 + JGE H_DecodeBuffer3 + + ; Insert word + Push SI + LEA SI, [EAX*2 + Offset DecodeWords - 100h] + Inc DX + Mov SI, [SI] + Jmp H_DecodeBuffer1 + +H_DecodeBuffer3: + StosB + JE H_DecodeBuffer1 + MovsB + MovsB + Jmp H_DecodeBuffer1 + +H_DecodeBuffer4: + Dec DX + JZ H_DecodeBufferEnd + + Pop SI + Jmp H_DecodeBuffer1 + +H_DecodeBufferEnd: + Xor AL, AL + StosB + Pop DI + + Mov SI, Offset DecodeBuffer + Mov AH, 6 + Call S_DrawString + + Pop DI + Pop SI + LodsW ; Add SI, 2 + Add DI, 160 + Cmp Word Ptr [SI], 0 + LoopNZ H_DrawHelp1 + + Ret + +EndP H_DrawHelp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc H_Help Far + + Call Glbl_SaveMode + + Mov BX, CS:HelpContext + Add BX, BX + Mov AX, [CS:Positions+BX] + + Mov CS:TopLine, AX + + Mov AX, 5 + Mov CX, Object1 + Mov DX, Offset O1_HelpList + Mov SI, 1 + + Ret + +EndP H_Help + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc H_HelpUp Far + + Sub CS:TopLine, 1 + AdC CS:Topline, 0 + + Mov AX, 1 + Ret + +EndP H_HelpUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc H_HelpDown Far + + Push CX + + Push CS + Pop DS + Assume DS:Help + + Mov SI, HelpContext + Add SI, SI + Mov SI, [HelpContextPtrs+SI] + Mov BX, TopLine + Add BX, BX + Add SI, BX + Mov CX, 32 + +H_HelpDown2: + Add SI, 2 + Cmp Word Ptr [SI], 0 + LoopNZ H_HelpDown2 + JZ H_HelpDown1 + + Inc TopLine + +H_HelpDown1: + Pop CX + + Mov AX, 1 + Ret + +EndP H_HelpDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc H_HelpPgUp Far + + Mov AX, CS:TopLine + Sub AX, 32 + JNS H_HelpPgUp1 + + Xor AX, AX +H_HelpPgUp1: + Mov CS:TopLine, AX + + Mov AX, 1 + Ret + +EndP H_HelpPgUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc H_HelpPgDn Far + + Mov CX, 32 + +H_HelpPgDn1: + Call H_HelpDown + Loop H_HelpPgDn1 + + Ret ; AX = 1, set by H_HelpDown + +EndP H_HelpPgDn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc H_HelpESC Far + + Mov AX, CS:TopLine + Mov BX, CS:HelpContext + Add BX, BX + + Mov [CS:Positions+BX], AX + + Jmp Glbl_RestoreMode + +EndP H_HelpESC + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc H_SetHelpContext Far + + Mov AX, [SI+2] + Mov CS:HelpContext, AX + + Ret + +EndP H_SetHelpContext + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_I.ASM b/it_i.s similarity index 96% rename from IT_I.ASM rename to it_i.s index a9e4f49..7fb5069 100644 --- a/IT_I.ASM +++ b/it_i.s @@ -1,9023 +1,9023 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Instrument List module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386 - -include switch.inc -include network.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Object1 BYTE Public 'Data' - Extrn SampleFrequency:Word -EndS - -Segment DiskData PARA Public 'Data' -EndS - -Segment Pattern BYTE Public 'Code' - Extrn BaseOctave:Byte - Extrn LastInstrument:Byte -EndS - - Extrn F_Reset5NumInputPos:Far - Extrn Glbl_F4_2:Far - - Extrn Glbl_GetCurrentMode:Far - Extrn S_GetDestination:Far - Extrn S_SaveScreen:Far - Extrn S_RestoreScreen:Far - Extrn S_DrawString:Far - Extrn M_FunctionDivider:Far - Extrn M_Object1List:Far - Extrn M_Object1ListDefault:Far - Extrn Music_GetSongSegment:Far - Extrn Music_ReleaseSample:Far - Extrn Music_ClearSampleName:Far - Extrn Music_PlaySample:Far - Extrn Music_GetInstrumentMode:Far -; Extrn Music_UpdateSampleLocation:Far - - Extrn S_GetGenerationTableOffset:Far - Extrn S_GenerateCharacters:Far - Extrn S_SetDirectMode:Far - Extrn S_DrawBox:Far - Extrn S_DrawSmallBox:Far - - Extrn O1_ConfirmDeleteSample:Far - Extrn O1_ConfirmConvertList:Far - Extrn O1_ConfirmConvert2List:Far - Extrn O1_ConfirmCutSample:Far - Extrn O1_ExchangeSampleList:Far - Extrn O1_ExchangeInstrumentList:Far - Extrn O1_SwapSampleList:Far - Extrn O1_SwapInstrumentList:Far - Extrn O1_ReplaceSampleList:Far - Extrn O1_ReplaceInstrumentList:Far - Extrn O1_ResizeSampleList:Far - Extrn O1_ShowSampleFrequencyList:Far - Extrn O1_FrequencyIndeterminedList:Far - Extrn O1_ConfirmDeleteInstrument:Far - Extrn O1_SampleAmplificationList:Far - Extrn O1_CopyInstrumentList:Far - Extrn O1_SampleCenterList:Far - - Extrn O1_InstrumentListGeneral:Far - Extrn O1_InstrumentListVolume:Far - Extrn O1_InstrumentListPanning:Far - Extrn O1_InstrumentListPitch:Far - Extrn O1_C5FrequencyList:Far - Extrn O1_GetInstrumentAmpList:Far - - Extrn PE_GetLastInstrument:Far - Extrn PE_SwapInstruments:Far - Extrn PE_UpdateInstruments:Far - Extrn PEFunction_OutOfMemoryMessage:Far - Extrn PE_TranslateMIDI:Far, PE_RestoreMIDINote:Far - Extrn PE_InsertInstrument:Far - Extrn PE_DeleteInstrument:Far - - Extrn Music_PlayPattern:Far - Extrn Music_Stop:Far - Extrn Music_PlaySong:Far - Extrn Music_PlayNote:Far - Extrn Music_ToggleChannel:Far - Extrn Music_SoloChannel:Far - Extrn Music_GetSampleLocation:Far - Extrn Music_ClearInstrument:Far - Extrn Music_GetInstrumentMode:Far - Extrn Music_AllocateSample:Far - Extrn Music_GetSlaveChannelInformationTable:Far - Extrn Music_SoundCardLoadAllSamples:Far - Extrn Music_GetNumChannels:Far - - Extrn Music_RegetLoopInformation:Far - - Extrn SetInfoLine:Far - - Extrn MouseAddEvent:Far, AddMouseQueue:Far, MouseClearEvents:Far - Extrn SetKeyboardLock:Far, MouseSetXY:Far - Extrn MouseRemoveEvents:Far, MouseGetStatus:Far - Extrn SetMouseCursorType:Far - - Extrn Fourier_Transform:Far, Fourier_CreateTable:Far - - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global I_DrawPitchPanCenter:Far - Global I_PrePitchPanCenter:Far - Global I_PostPitchPanCenter:Far - - Global I_ClearTables:Far - Global I_TagInstrument:Far - Global I_TagSample:Far - - Global I_DrawEnvelope:Far - Global I_PreEnvelope:Far - Global I_PostEnvelope:Far - - Global I_ConvertSample:Far - Global I_DeleteSample:Far - Global I_CutSample:Far - Global I_ClearSampleName:Far - Global I_ExchangeSamples:Far - Global I_ReplaceInstrument:Far - Global I_ToggleSampleQuality:Far - Global I_CenterSample:Far - - Global I_InstrumentListSpace:Far - Global I_InstrumentListNoteOff:Far - Global I_IncreasePlayChannel:Far - Global I_DecreasePlayChannel:Far - Global I_ToggleMultiChannel:Far - - Global I_ScaleInstrumentVolumes:Far - Global I_ScaleSampleVolumes:Far - Global I_CopyInstrument:Far - Global I_DeleteInstrument:Far - Global I_DrawSampleList:Far - Global I_PreSampleList:Far - Global I_PostSampleList:Far - Global I_ShowSampleInfo:Far - Global I_SampleUp:Far - Global I_SampleDown:Far - Global I_CheckLoopValues:Far - Global I_CheckSusLoopValues:Far - Global I_MapEnvelope:Far - Global I_DrawWaveForm:Far - Global I_SampleButtonHandler:Far - - Global I_DrawInstrumentWindow:Far - Global I_PreInstrumentWindow:Far - Global I_PostInstrumentWindow:Far - - Global I_DrawNoteWindow:Far - Global I_PreNoteWindow:Far - Global I_PostNoteWindow:Far - - Global I_AmplifySample:Far - Global I_ExchangeInstruments:Far - Global I_ReverseSample:Far - Global I_SwapSamples:Far - Global I_SwapInstruments:Far - Global I_ReplaceSample:Far - Global I_UpdateInstrument:Far - Global I_ResizeSample:Far - Global I_ResizeSampleNoInt:Far - Global I_InvertSample:Far - - Global I_GetInstrumentOffset:Far - Global I_GetSampleOffset:Far - Global I_CutSampleBeforeLoop:Far - - Global I_CalculateC5Speed:Far - Global I_PrintC5Frequency:Far - - Global I_DoubleSampleSpeed:Far - Global I_HalveSampleSpeed:Far - Global I_SampleSpeedSemiUp:Far - Global I_SampleSpeedSemiDown:Far - - Global I_ShowSamplePlay:Far - Global I_ShowInstrumentPlay:Far - - Global I_PlaySample:Far - Global I_SelectScreen:Far - - Global I_GetInstrumentScreen:Far - Global I_IdleUpdateEnvelope:Far - - Global I_PlayNote:Far - - Global SampleNumberInput:Byte - Global SampleNumber:Byte - - Global MaxNode:Word - Global NewSampleSize:DWord - Global SampleAmplification:Word - - Global InstrumentEdit:Byte - Global NodeHeld:Byte - Global InstrumentScreen:Word - - Global I_GetPresetEnvelopeOffset:Far - - Public UpdateWAVEForm - Public MIDI_PlayNote, MIDI_NoteOff, MIDI_ClearTable - Public MIDI_PlaySample, MIDI_FindChannel, MIDI_AllocateChannel - Public MIDI_GetChannel - - Global InstrumentAmplification - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Inst WORD Public 'Code' USE16 - Assume CS:Inst, DS:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -SLAVECHANNELSIZE EQU 128 -HOSTCHANNELSIZE EQU 80 -ENVELOPEGRANULARITY EQU 50 -MAXENVELOPETICK EQU 9999 - -InstrumentAmplification DW 50 -InstrumentScreen DW 0 - -LastPlaySample DB 5*12 -SampleNumber DB 1 ; For instrument-sample - ; editing - -NoteReleased DB 1 -TopInstrument DW 1 -InstrumentPos DW 0 - -SamplePlayTable DB 128 Dup (0) -InstrumentPlayTable DB 128 Dup (0) - -TopNote DW 0 -CurrentNote DW 0 -NotePos DW 0 ; 0->4 - -SampleNumberInput DB 0 - DB 3 Dup(0) - -NewSampleSize DD 0 - -CurrentNode DW 0 ; Volume envelope -MaxNode DW 0 - -AmplitudeCompensate DB 0 - DB 0 ; Filler -CurrentAmplitude DW 0 -CurrentTick DW 0 -LastAmplitude DW 0 -LastTick DW 0 -UpperLimit DW 0 - -NodeHeld DB 0 - DB 0 -WaveLength DW 0 -SearchDirection DW 0 -EndPoint DW 0 - -InstrumentEdit DB 0 -LastKey DW 0 - -Interpolate DB 0 ; For resizing routines -Quality DB 0 -MultiChannel DB 0 - -PlayChannel DW 0 -SampleAmplification DW 0 ; Percentage - -MIDITable DB 128 Dup (0) ; Contains channel of each note - -NoteData DB 0, 0, 0FFh, 0, 0 ; For noteplay in notelist - -PlayNote DB 5*12 - -NotePosTable DB 4, 6, 8, 9 -SamplePos DW 25 - -Resolution DB 0 -UpdateInstrumentScreen DB 1 - -CompleteMsg DB 0FDh, "D% Complete", 0 -TopSample DW 1 -NoSampleMsg DB "No sample", 0 -Quality8Msg DB "8 bits", 0 -Quality16Msg DB "16 bits", 0 -LengthMsg DB 0FDh, 'L', 0 - -EnvelopeSetMsg DB "Envelope copied into slot ", 0FDh, "D", 0 - -EnvelopeMsg DB "Node ", 0FDh, "D/", 0FDh, "D", 13, 13 - DB "Tick ", 0FDh, "D", 13, 13 - DB "Value ", 0FDh, "S", 0 - -PlayChannelMsg DB "Using channel ", 0FDh, "D for playback", 0 - -MultiChannelEnabledMsg DB "Multichannel playback enabled", 0 -MultiChannelDisabledMsg DB "Multichannel playback disabled", 0 - -C5FrequencyText DB "Calculated C5Speed: ", 0FDh, "L", 0 - -LastWaveformValues DW 0 - -EnvelopeHeaderTable Label - DW Offset VolEnv, Offset VolEnvEdit - DW Offset PanEnv, Offset PanEnvEdit - DW Offset PitchEnv, Offset PitchEnvEdit - -VolEnv DB "Volume Envelope", 0 -VolEnvEdit DB "Volume Envelope (Edit)", 0 -PanEnv DB "Panning Envelope", 0 -PanEnvEdit DB "Panning Envelope (Edit)", 0 -PitchEnv DB "Frequency Envelope", 0 -PitchEnvEdit DB "Frequency Envelope (Edit)", 0 - -EnvelopeOffsets Label Word - DW 130h, 182h, 1D4h - -NoteTable DB "C-C#D-D#E-F-F#G-G#A-A#B-" -KeyBoardTable DW 12Ch, 0, 11Fh, 1, 12Dh, 2, 120h, 3, 12Eh, 4 - DW 12Fh, 5, 122h, 6, 130h, 7, 123h, 8, 131h, 9 - DW 124h, 10, 132h, 11, 110h, 12, 103h, 13, 111h, 14 - DW 104h, 15, 112h, 16, 113h, 17, 106h, 18, 114h, 19 - DW 107h, 20, 115h, 21, 108h, 22, 116h, 23, 117h, 24 - DW 10Ah, 25, 118h, 26, 10Bh, 27, 119h, 28, 0FFFFh - -SampleMouseEvent DW 5*8, 13*8, 35*8-1, 48*8-1 -SampleMouseCondition DW 102h, 28, Offset MouseSelectInst, Inst -SampleMouseOffEvent DW 0, 0, 0, 0, 1108h, 28, MouseSelectOff, Inst -NoteMouseEvent DW 32*8, 16*8, 42*8-1, 48*8-1 -NoteMouseCondition DW 102h, 10, Offset MouseSelectNote, Inst -NoteMouseOffEvent DW 0, 0, 0, 0, 1108h, 10, MouseSelectNoteOff, Inst - -ENVELOPELEFT EQU 32 -ENVELOPETOP EQU 18 - -MouseNodeHeld DB 0 - -MouseX DW 0 -MouseY DW 0 -LowerTickLimit DW 0 -UpperTickLimit DW 0 - -EnvelopeEvent1 DW ENVELOPELEFT*8, ENVELOPETOP*8 - DW (ENVELOPELEFT+32)*8-1, (ENVELOPETOP+8)*8-1 - DW 102h, 10, Offset MouseEnvelopeEvent1, Inst -EnvelopeEvent4 DW ENVELOPELEFT*8, ENVELOPETOP*8 - DW (ENVELOPELEFT+32)*8-1, (ENVELOPETOP+8)*8-1 - DW 110h, 10, Offset MouseEnvelopeEvent4, Inst -EnvelopeEvent2 DW 0, 0, 0, 0, 1005h, 10, Offset MouseEnvelopeEvent2, Inst -EnvelopeEvent3 DW 0, 0, 0, 0, 1108h, 10, Offset MouseEnvelopeEvent3, Inst - ; Release - -PresetEnvelopes Label Byte - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InstrumentScreenTable Label - DW Offset O1_InstrumentListGeneral - DW Offset O1_InstrumentListVolume - DW Offset O1_InstrumentListPanning - DW Offset O1_InstrumentListPitch - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -SampleListKeys Label - DB 0 ; Mouse left button - DW 8010h - DW Offset I_SelectInstrument - - DB 0 ; 0 = CX, 1 = DX, 2 = Alt CX, 3 = Ctrl - DW 1C8h - DW Offset I_SampleUp - - DB 0 - DW 1D0h - DW Offset I_SampleDown - - DB 0 - DW 1C9h - DW Offset I_SamplePgUp - - DB 0 - DW 1D1h - DW Offset I_SamplePgDn - - DB 3 - DW 1C9h - DW Offset I_SampleCtrlPgUp - - DB 3 - DW 1D1h - DW Offset I_SampleCtrlPgDn - - DB 2 - DW 1D2h ; Alt Ins - DW Offset I_InsertSample - - DB 2 - DW 1D3h ; Alt Del - DW Offset I_RemoveSample - - DB 0 - DW 1CBh - DW Offset I_SampleLeft - - DB 0 - DW 1CDh - DW Offset I_SampleRight - - DB 0 - DW 1C7h - DW Offset I_SampleHome - - DB 0 - DW 1CFh - DW Offset I_SampleEnd - - DB 0 - DW 10Fh - DW Offset I_SampleTab - - DB 1 ; Alt... - DW 2E00h ; 'C' - DW Offset I_ClearSampleName - - DB 0FFh - -InstrumentListKeys Label - DB 0 ; Mouse left button - DW 8010h - DW Offset I_SelectInstrument2 - - DB 0 ; 0 = CX, 1 = DX, 2 = Alt CX, 3 = Ctrl - DW 1C8h - DW Offset I_SampleUp - - DB 0 - DW 1D0h - DW Offset I_SampleDown - - DB 0 - DW 1C9h - DW Offset I_SamplePgUp - - DB 0 - DW 1D1h - DW Offset I_SamplePgDn - - DB 2 - DW 1D2h ; Alt Ins - DW Offset I_InsertInstrument - - DB 2 - DW 1D3h ; Alt Del - DW Offset I_RemoveInstrument - - DB 3 - DW 1C9h - DW Offset I_SampleCtrlPgUp - - DB 3 - DW 1D1h - DW Offset I_SampleCtrlPgDn - - DB 0 - DW 1CBh - DW Offset I_InstrumentLeft - - DB 0 - DW 1CDh - DW Offset I_InstrumentRight - - DB 0 - DW 1C7h - DW Offset I_InstrumentHome - - DB 0 - DW 1CFh - DW Offset I_InstrumentEnd - - DB 0 - DW 10Fh - DW Offset I_InstrumentTab - - DB 4 - DW 10Fh - DW Offset I_InstrumentShiftTab - - DB 1 ; Alt - DW 2E00h ; 'C' - DW Offset I_InstrumentNameClear - - DB 1 ; Alt... - DW 1100h ; 'W' - DW Offset I_InstrumentClear - - DB 0FFh - -NoteListKeys Label - DB 0 - DW 8010h - DW Offset I_SelectNoteMouse - - DB 0 ; 0 = CX, 1 = DX, 2 = Alt CX, 3 = Ctrl - DW 1C8h - DW Offset I_NoteUp - - DB 0 - DW 1D0h - DW Offset I_NoteDown - - DB 0 - DW 1C9h - DW Offset I_NotePgUp - - DB 0 - DW 1D1h - DW Offset I_NotePgDn - - DB 0 - DW 1C7h - DW Offset I_NoteHome - - DB 0 - DW 1CFh - DW Offset I_NoteEnd - - DB 0 - DW 1CBh - DW Offset I_NoteLeft - - DB 0 - DW 1CDh - DW Offset I_NoteRight - - DB 0 - DW 10Fh - DW Offset I_NoteTab - - DB 4 - DW 10Fh ; Shift-Tab - DW Offset I_NoteShiftTab - - DB 1 - DW '>' - DW Offset I_NoteSampleIncrease - - DB 1 - DW "'" - DW Offset I_NoteSampleIncrease - - DB 1 - DW '<' - DW Offset I_NoteSampleDecrease - - DB 1 - DW ';' - DW Offset I_NoteSampleDecrease - - DB 1 ; Alt... - DW 1E00h ; 'A' - DW Offset I_NoteAll - - DB 1 ; Alt... - DW 3100h ; 'N' - DW Offset I_NoteNext - - DB 1 ; Alt... - DW 1900h ; 'P' - DW Offset I_NotePrevious - - DB 2 ; Alt up - DW 1C8h - DW Offset I_NoteTransposeUp - - DB 2 ; Alt down - DW 1D0h - DW Offset I_NoteTransposeDown - - DB 2 - DW 1D2h ; Alt Ins - DW Offset I_NoteInsert - - DB 2 - DW 1D3h ; Alt Del - DW Offset I_NoteDelete - - DB 1 - DW ' ' - DW Offset I_NoteSpace - - DB 0 - DW 11Ch ; Enter - DW Offset I_NoteSamplePickup - - DB 0FFh - -VolumeEnvelopeKeys Label - DB 0 - DW 8010h - DW Offset I_MouseEnvelopePress - - DB 0 - DW 8001h - DW Offset I_MouseEnvelopeDrag - - DB 0 - DW 8002h - DW Offset I_MouseEnvelopeReleased - - DB 0 - DW 8003h - DW Offset I_MouseEnvelopeDelete - - DB 0 - DW 10Fh ; Tab - DW Offset I_NoteShiftTab - - DB 4 ; Shifttab - DW 10Fh - DW Offset I_NoteShiftTab - - DB 0 - DW 1CBh - DW Offset I_VolumeEnvelopeLeft - - DB 0 - DW 1CDh - DW Offset I_VolumeEnvelopeRight - - DB 0 ; Enter - DW 11Ch - DW Offset I_VolumeEnvelopeEnter - - DB 0 ; Up arrow - DW 1C8h - DW Offset I_VolumeEnvelopeUp - - DB 0 ; Up arrow - DW 1D0h - DW Offset I_VolumeEnvelopeDown - - DB 0 - DW 1D2h - DW Offset I_VolumeEnvelopeInsert - - DB 0 - DW 1D3h - DW Offset I_VolumeEnvelopeDelete - - DB 0FFh - -VolumeEnvelopeNodeKeys Label - DB 0 - DW 8010h - DW Offset I_MouseEnvelopePress - - DB 0 - DW 8001h - DW Offset I_MouseEnvelopeDrag - - DB 0 - DW 8002h - DW Offset I_MouseEnvelopeReleased - - DB 0 - DW 8003h - DW Offset I_MouseEnvelopeDelete - - DB 0 ; Enter - DW 11Ch - DW Offset I_VolumeEnvelopeEnter - - DB 0 - DW 1C8h ; Up arrow - DW Offset I_VolumeEnvelopeHeldUp - - DB 0 - DW 1D0h ; Down arrow - DW Offset I_VolumeEnvelopeHeldDown - - DB 2 - DW 1C8h - DW Offset I_VolumeEnvelopeHeldPgUp - - DB 2 - DW 1D0h - DW Offset I_VolumeEnvelopeHeldPgDn - - DB 0 - DW 1CBh - DW Offset I_VolumeEnvelopeHeldLeft - - DB 0 - DW 1CDh - DW Offset I_VolumeEnvelopeHeldRight - - DB 0 - DW 10Fh - DW Offset I_VolumeEnvelopeHeldRightFast - - DB 4 - DW 10Fh - DW Offset I_VolumeEnvelopeHeldLeftFast - - DB 2 - DW 1CBh - DW Offset I_VolumeEnvelopeHeldLeftFast - - DB 2 - DW 1CDh - DW Offset I_VolumeEnvelopeHeldRightFast - - DB 0 - DW 1C9h - DW Offset I_VolumeEnvelopeHeldPgUp - - DB 0 - DW 1D1h - DW Offset I_VolumeEnvelopeHeldPgDn - - DB 0 - DW 1C7h - DW Offset I_VolumeEnvelopeHeldHome - - DB 0 - DW 1CFh - DW Offset I_VolumeEnvelopeHeldEnd - - DB 0 - DW 1D2h - DW Offset I_VolumeEnvelopeInsert - - DB 0 - DW 1D3h - DW Offset I_VolumeEnvelopeDelete - - DB 3 - DW 1CBh - DW Offset I_VolumeEnvelopeLeft - - DB 3 - DW 1CDh - DW Offset I_VolumeEnvelopeRight - - DB 0FFh - -PitchPanCenterKeys Label - DB 0 - DW 10Fh ; Tab - DW Offset I_NoteShiftTab - - DB 4 ; Shifttab - DW 10Fh - DW Offset I_NoteShiftTab - - DB 0 - DW 1C8h ; Up arrow - DW Offset I_PitchPanCenterUp - - DB 0 - DW 1D0h ; Down arrow - DW Offset I_PitchPanCenterDown - - DB 1 - DW '+' - DW Offset I_PitchPanCenterSemiUp - - DB 1 - DW '-' - DW Offset I_PitchPanCenterSemiDown - - DB 0 - DW 1CBh - DW Offset I_PitchPanCenterSemiDown - - DB 0 - DW 1CDh - DW Offset I_PitchPanCenterSemiUp - - DB 0FFh - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_GetInstrumentScreen Far - - Push CS - Pop ES - Mov DI, Offset InstrumentScreen - - Ret - -EndP I_GetInstrumentScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_GetInstrumentOffset Far - - Call PE_GetLastInstrument - Add BX, BX - Call Music_GetSongSegment - Mov DS, AX - Mov BX, [DS:64712+BX] - - Ret - -EndP I_GetInstrumentOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_GetSampleOffset Far - - Call PE_GetLastInstrument - Add BX, BX - Call Music_GetSongSegment - Mov DS, AX - Mov BX, [DS:64912+BX] - - Ret - -EndP I_GetSampleOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_GetEnvelopeOffset ; Returns DS:SI - - Push AX - Call I_GetInstrumentOffset ; Returns DS:BX - Mov SI, CS:InstrumentScreen - Add SI, SI - Mov SI, [SI+EnvelopeOffsets-2] - Add SI, BX - Pop AX - - Ret - -EndP I_GetEnvelopeOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SelectScreen Far - - Mov BX, [SI+22] - - Push CS - Pop DS - Assume DS:Inst - - Mov InstrumentScreen, BX - - Mov AX, [ES:DI] - - Add BX, BX - Mov BX, [CS:InstrumentScreenTable+BX] - Mov [ES:BX], AX - - Jmp Glbl_F4_2 - -EndP I_SelectScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSelectOff Far - - Mov Word Ptr [SI-16+8], 102h - Mov CS:SampleMouseCondition, 102h - Mov AX, 1 - - Ret - -EndP MouseSelectOff - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSelectNoteOff Far - - Mov Word Ptr [SI-16+8], 102h - Mov CS:NoteMouseCondition, 102h - Mov AX, 1 - Ret - -EndP MouseSelectNoteOff - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSelectNote Far - - Mov CS:NoteMouseCondition, 1107h - - Push CX - Mov CX, 8010h - Call AddMouseQueue - Pop CX - - Cmp DX, 16*8 - JA MouseSelectNote1 - - Mov DX, 16*8 - -MouseSelectNote1: - Cmp DX, 48*8-1 - JB MouseSelectNote2 - - Mov DX, 48*8-1 - -MouseSelectNote2: - Call MouseSetXY - - Xor AX, AX - Ret - -EndP MouseSelectNote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSelectInst Far - - Mov CS:MouseX, CX - - Mov CS:SampleMouseCondition, 1107h - - Push CX - - Mov CX, 8010h - ShR DX, 3 - Sub DX, 13 - Call AddMouseQueue - - Pop CX - And DX, DX - JNS MouseSelectInst1 - - Mov DX, 13*8 - Jmp MouseSelectInst2 - -MouseSelectInst1: - Cmp DX, 35 - JB MouseSelectInst3 - - Mov DX, 48*8-1 - -MouseSelectInst2: - Call MouseSetXY - -MouseSelectInst3: - Xor AX, AX - Ret - -EndP MouseSelectInst - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AddSelectEvent - - Call MouseGetStatus - Test AL, 6 - JNZ AddSelectEvent1 - - Mov Word Ptr [SI+8], 102h - -AddSelectEvent1: - Call MouseAddEvent - - Ret - -EndP AddSelectEvent - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DrawSampleList Far - - Call S_GetDestination - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - - Test AL, AL - JNZ I_DrawSampleList1 - - Inc AX - Mov LastInstrument, AL - -I_DrawSampleList1: - Push CS - Pop DS - Assume DS:Inst - - Mov BX, TopSample - Cmp BL, AL - JBE I_DrawSampleList2 - - Mov BL, AL - -I_DrawSampleList2: ; BL = top, AL = current - Mov CL, BL - Add CL, 34 - Cmp CL, AL - JAE I_DrawSampleList3 - - Mov BL, AL - Sub BL, 34 - -I_DrawSampleList3: - Mov TopSample, BX - ; BX = topinstrument - - Mov DI, (2+13*80)*2 - - Mov DX, 0A23h - -I_DrawSampleList4: - Mov AX, BX - Div DH - ; AH = units, AL = tens - Add AL, '0' - StosB - Mov AL, 20h - StosB - XChg AH, AL - Add AL, '0' - StosW - - Inc BX - Add DI, 156 - Dec DL - JNE I_DrawSampleList4 - - Mov BX, TopSample - - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - Mov CX, 35 - Mov DI, (5+13*80)*2 - Dec BX - Add BX, BX - Mov SI, [BX+64912] - -I_DrawSampleList5: - Push CX - Push SI - Push DI - - Add SI, 14h - Mov CX, 25 - Mov AH, 6 - -I_DrawSampleList6: - LodsB - Cmp AL, 226 - JB I_DrawSampleNoMouse - - Mov AL, ' ' - -I_DrawSampleNoMouse: - StosW - Loop I_DrawSampleList6 - - Mov AX, 2A8h - StosW - - Mov AX, 700h+'P' - - Test Byte Ptr [SI-14h-25+12h], 1 - JZ I_DrawSampleList8 - - Mov AH, 6 - -I_DrawSampleList8: - StosW - Mov AL, 'l' - StosW - Mov AL, 'a' - StosW - Mov AL, 'y' - StosW - - Pop DI - Pop SI - Pop CX - Add SI, 80 - Add DI, 160 - - Loop I_DrawSampleList5 - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - Xor AH, AH - Sub AX, TopSample - Add AX, 13 - Mov BX, 160 - Mul BX - Add AX, 10 - Mov DI, AX - - Mov CX, 30 - -I_DrawSampleList7: - Mov AX, [ES:DI] - And AH, 0Fh - Or AH, 0E0h - StosW - - Loop I_DrawSampleList7 - - ; Add on pointer... - Push CS - Pop DS - Assume DS:Inst - - Mov SI, Offset SampleMouseEvent - Mov Word Ptr [SI+4], 35*8-1 - Mov Word Ptr [SI+10], 28 - Call AddSelectEvent - Mov SI, Offset SampleMouseOffEvent - Mov Word Ptr [SI+4], 35*8-1 - Call MouseAddEvent - - Ret - -EndP I_DrawSampleList - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PreSampleList Far - - Call S_GetDestination - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - Xor AH, AH - Mov SI, AX - Sub AX, TopSample - Add AX, 13 - Mov BX, 160 - Mul BX - Add AX, 10 - Mov DI, AX - - Mov AX, SamplePos - Cmp AX, 25 - JB I_PreSampleList1 - - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - Dec SI - Add SI, SI - Mov SI, [SI+64912] - - Mov CX, 4 - Add DI, 52 - Mov AL, 30h - Test Byte Ptr [SI+12h], 1 - JNZ I_PreSampleList2 - - Mov AL, 60h - -I_PreSampleList2: - Inc DI - StosB - - Loop I_PreSampleList2 - - Ret - -I_PreSampleList1: - Add DI, AX - Add DI, AX - - Mov AL, 30h - Inc DI - StosB - Ret - -EndP I_PreSampleList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PostSampleList Far - - Push CS - Pop DS - Assume DS:Inst - - Mov SI, Offset SampleListKeys - Call M_FunctionDivider - JC I_PostSampleList7 - - Jmp [SI] - -I_PostSampleList7: - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - Xor AH, AH - Mov SI, AX - Dec SI - - Mov AX, SamplePos - Cmp AX, 25 - JAE I_PostSampleList2 - - Mov BX, AX ; BX = Pos. SI = LastInst - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - Add SI, SI - Mov SI, [64912+SI] ; SI = sample offset. - - Test CL, CL - JZ I_PostSampleList1 - Cmp DL, 32 ; Space bar or less?? - JB I_PostSampleList1 - - Add BX, 14h ; To sample name. - Add BX, SI - Add SI, 2Ch - -I_PostSampleList3: - Cmp SI, BX - JBE I_PSL3 - - Mov AL, [SI-1] - Mov [SI], AL - Dec SI - Jmp I_PostSampleList3 - -I_PSL3: - Mov [SI], DL - - Inc SamplePos - - Jmp I_PostSampleListEnd - -I_PostSampleList1: - Cmp CX, 10Eh - JNE I_PostSampleList4 - - And BX, BX - JZ I_PostSampleList4 - - Dec SamplePos - Add BX, 14h - Add BX, SI - Add SI, 2Dh - -I_PostSampleList5: - Mov AL, [BX] - Mov [BX-1], AL - Inc BX - Cmp BX, SI - JB I_PostSampleList5 - - Mov Byte Ptr [BX-1], 0 - -I_PostSampleListEnd: - NetworkSendSample - - Mov AX, 1 - Ret - -I_PostSampleList4: - Cmp CX, 1D3h ; Delete... - JNE I_PostSampleList6 - - Add BX, 15h - Add BX, SI - Add SI, 2Dh - Jmp I_PostSampleList5 - -I_PostSampleList6: - Xor AX, AX - Ret - -I_PostSampleList2: ; Play note.... - Push CS - Pop DS - - Test CH, Not 1 - JNZ I_PostSampleList9 - - Cmp CX, LastKey - JE I_PostSampleList9 - - Mov LastKey, CX - - - Mov SI, Offset KeyBoardTable - -I_PostSampleList8: - LodsW - Cmp AX, 0FFFFh - JE I_PostSampleList9 - - Mov BX, AX - LodsW - - Cmp BL, CL - JNE I_PostSampleList8 - ; Note to play... - ; AX = notemod. - And CH, CH - JZ I_PostSampleList10 - - Mov CX, AX - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, 12 - Mul BaseOctave - Add AL, CL - Mov AH, LastInstrument - - Push CS - Pop DS - Assume DS:Inst - - Call UpdateMultiChannel - - Mov LastPlaySample, AL - - Mov CX, PlayChannel - Call Music_PlaySample - Jmp I_PostSampleList9 - -I_PostSampleList10: - Mov SI, Offset NoteData - Mov Word Ptr [SI], 0FFh - Mov AX, PlayChannel - Mov DH, 32+128 - Call Music_PlayNote ; Note off. - -I_PostSampleList9: - Xor AX, AX - Ret - -EndP I_PostSampleList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleLeft Far - - Mov AX, SamplePos - Dec AX - JS I_SampleLeft1 - - Mov SamplePos, AX - -I_SampleLeft1: - Mov AX, 1 - Ret - -EndP I_SampleLeft - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleRight Far - - Mov AX, SamplePos - Inc AX - Cmp AX, 25 - JA I_SampleRight1 - - Mov SamplePos, AX - -I_SampleRight1: - Mov AX, 1 - Ret - -EndP I_SampleRight - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_RedrawWave - - Call Glbl_GetCurrentMode - - Cmp AL, 3 - JE I_RedrawWave1 - Cmp AL, 4 - JNE I_RedrawWave2 - - Call I_MapEnvelope - Ret - -I_RedrawWave1: - Call I_DrawWaveForm - -I_RedrawWave2: - Ret - -EndP I_RedrawWave - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SelectInstrument2 - Assume DS:Inst - - ; Set Instrument pos... - Mov AX, MouseX - ShR AX, 3 - Sub AX, 5 - JNC I_SelectInstrument8 - - Xor AX, AX - -I_SelectInstrument8: - Cmp AX, 24 - JB I_SelectInstrument7 - - Mov AX, 24 - -I_SelectInstrument7: - Mov InstrumentPos, AX - - Add DX, TopInstrument - Jmp I_SelectInstrument4 - -Proc I_SelectInstrument Far - - Mov AX, MouseX - Sub AX, 40 - ShR AX, 3 - Cmp AX, 25 - JB I_SelectInstrument6 - - Mov AX, 25 - -I_SelectInstrument6: - Mov SamplePos, AX - - Add DX, TopSample - -I_SelectInstrument4: - Cmp DX, 1 - JGE I_SelectInstrument1 - - Mov DX, 1 - -I_SelectInstrument1: - Cmp DX, 99 - JL I_SelectInstrument3 - - Mov DX, 99 - -I_SelectInstrument3: - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Cmp DL, LastInstrument - Mov LastInstrument, DL - JE I_SelectInstrument5 - - Call I_RedrawWave - -I_SelectInstrument5: - Mov AX, 1 - Ret - -EndP I_SelectInstrument - -EndP I_SelectInstrument2 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleDown Far - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - - Inc AX - Cmp AL, 100 - JAE I_SampleDown1 - - Mov LastInstrument, AL - Call I_RedrawWave - -I_SampleDown1: - - Mov AX, 1 - Ret - -EndP I_SampleDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleUp Far - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - - Dec AL - JZ I_SampleUp1 - - Mov LastInstrument, AL - Call I_RedrawWave - -I_SampleUp1: - Mov AX, 1 - Ret - -EndP I_SampleUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SamplePgUp Far - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - - Cmp AL, 1 - JE I_SamplePgUp3 - - Sub AL, 16 - JZ I_SamplePgUp1 - JNC I_SamplePgUp2 - -I_SamplePgUp1: - Mov AL, 1 - -I_SamplePgUp2: - Mov LastInstrument, AL - Call I_RedrawWave - -I_SamplePgUp3: - Mov AX, 1 - Ret - -EndP I_SamplePgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SamplePgDn Far - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - Cmp AL, 99 - JE I_SamplePgDn2 - - Add AL, 16 - Cmp AL, 99 - JBE I_SamplePgDn1 - - Mov AL, 99 - -I_SamplePgDn1: - Mov LastInstrument, AL - Call I_RedrawWave - -I_SamplePgDn2: - Mov AX, 1 - Ret - -EndP I_SamplePgDn - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleCtrlPgUp Far - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov LastInstrument, 1 - Call I_RedrawWave - - Mov AX, 1 - Ret - -EndP I_SampleCtrlPgUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleCtrlPgDn Far - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov LastInstrument, 99 - Call I_RedrawWave - - Mov AX, 1 - Ret - -EndP I_SampleCtrlPgDn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleEnd Far - - Mov SamplePos, 25 - - Mov AX, 1 - Ret - -EndP I_SampleEnd - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleHome Far - - Mov SamplePos, 0 - - Mov AX, 1 - Ret - -EndP I_SampleHome - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleTab Far - - Mov Word Ptr [ES:DI], 7 - - Mov AX, 1 - Ret - -EndP I_SampleTab - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ShowSampleInfo Far - - Call I_GetSampleOffset - - Push DWord Ptr [BX+30h] - - Mov AL, [BX+12h] - - Push CS - Pop DS - Assume DS:Inst - - Mov SI, Offset NoSampleMsg - - Mov AH, 2 - Test AL, 1 - JZ I_ShowSampleInfo1 - - Mov SI, Offset Quality8Msg - Test AL, 2 - JZ I_ShowSampleInfo1 - - Mov SI, Offset Quality16Msg - -I_ShowSampleInfo1: - Mov DI, (64+22*80)*2 - Call S_DrawString - -I_ShowSampleInfo2: - Mov DI, (64+23*80)*2 - Mov SI, Offset LengthMsg - Call S_DrawString - - Pop EAX - - Ret - -EndP I_ShowSampleInfo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VibratoButtonSelect Far - - Call I_GetSampleOffset - Mov AL, [BX+04Fh] ; AL = type. - Xor AH, AH - - Add DI, 82 - Xor CX, CX - -I_VibratoButtonSelect1: - Mov SI, [ES:DI] - - Mov CH, AH ; Assume up - Cmp AL, CL - JNE I_VibratoButtonSelect2 - - Inc CH - -I_VibratoButtonSelect2: - Mov [ES:SI+33], CH - -; Add DI, 2 - ScasW - Inc CX - Cmp CL, 3 - JLE I_VibratoButtonSelect1 - - Ret - -EndP I_VibratoButtonSelect - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SetVibratoWaveform Far ; AH = waveform. - - Mov AX, [SI+24] - Push AX - Call I_GetSampleOffset - Pop AX - - Mov [BX+4Fh], AL - - Ret - -EndP I_SetVibratoWaveform - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_CheckLoopValues Far - - Call I_GetSampleOffset - - Mov EAX, [BX+30h] - Sub EAX, 1 - AdC EAX, 0 - Cmp EAX, [BX+34h] - JA I_CheckLoopValues3 - - Mov [BX+34h], EAX - -I_CheckLoopValues3: - Inc EAX - Cmp EAX, [BX+38h] - JAE I_CheckLoopValues2 - - Mov [BX+38h], EAX - -I_CheckLoopValues2: - Mov EAX, [BX+38h] - Cmp EAX, [BX+34h] - JA I_CheckLoopValues1 - - And Byte Ptr [BX+12h], NOT 00010000b - -I_CheckLoopValues1: - Call Music_RegetLoopInformation - Call I_DrawWaveForm - Ret - -EndP I_CheckLoopValues - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_CheckSusLoopValues Far - - Call I_GetSampleOffset - - Mov EAX, [BX+30h] - Sub EAX, 1 - AdC EAX, 0 - Cmp EAX, [BX+40h] - JA I_CheckSusLoopValues3 - - Mov [BX+40h], EAX - -I_CheckSusLoopValues3: - Inc EAX - Cmp EAX, [BX+44h] - JAE I_CheckSusLoopValues2 - - Mov [BX+44h], EAX - -I_CheckSusLoopValues2: - Mov EAX, [BX+44h] - Cmp EAX, [BX+40h] - JA I_CheckLoopValues1 - - And Byte Ptr [BX+12h], NOT 00100000b - -I_CheckSusLoopValues1: - Call Music_RegetLoopInformation - Call I_DrawWaveForm - Ret - -EndP I_CheckSusLoopValues - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DrawWaveForm Far - - Mov [CS:LastWaveformValues], 7f80h - - Call S_GetGenerationTableOffset - Push DI - Mov CX, 176*32 - Xor AL, AL - Rep StosB - Pop DI - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - And AL, AL - JNZ I_DrawWaveForm1 - - Mov AL, 1 - -I_DrawWaveForm1: - Mov LastInstrument, AL - Xor AH, AH - Xor CX, CX - Call Music_GetSampleLocation - Assume DS:Nothing - - JC I_DrawWaveFormEnd - - SetNZ CS:Resolution - JZ I_DrawWaveForm8Bit - - Add ECX, ECX - Inc SI - -I_DrawWaveForm8Bit: - Test ECX, ECX - JZ I_DrawWaveFormEnd - - Push AX ; AX = instrument num - ; DS:ESI = waveform, ECX = length - ; ES:DI = charactergenerationtable - - Mov EAX, ECX - Mov ECX, 176 - Xor EDX, EDX - Div ECX ; EAX = major shift. EDX = minor shift. - - Mov EBX, EAX - Xor EAX, EAX - Div ECX - - Mov EDX, EAX - Xor EAX, EAX - - Mov EBP, ESI - -I_DrawWaveForm6: - Add EAX, EDX - AdC EBP, EBX - Push EAX - Push EBX - Push ECX - Push EDX - - Mov CL, [SI] - Mov CH, CL - MovZX BX, CS:Resolution - Inc BX - -I_DrawWaveForm10: - Cmp ESI, EBP - JAE I_DrawWaveForm7 - - Mov AL, [SI] - Add SI, BX ; Get max/min vals. - JC I_DrawWaveformNewBlock - -I_DrawWaveformResume: - Cmp AL, CL - JL I_DrawWaveForm8 - - Cmp AL, CH - JLE I_DrawWaveForm10 - - Mov CH, AL - Jmp I_DrawWaveForm10 - -I_DrawWaveformNewBlock: - Add ESI, 10000h - Int 3 - Jmp I_DrawWaveFormResume - -I_DrawWaveForm8: - Mov CL, AL - Jmp I_DrawWaveForm10 - -I_DrawWaveForm7: ; CL = min, CH = max. - Mov AX, CX - - XChg CX, [CS:LastWaveformValues] - - Cmp AL, CH - JL I_DrawWaveform7a - - Mov AL, CH - -I_DrawWaveform7a: - Cmp AH, CL - JG I_DrawWaveform7b - - Mov AH, CL - -I_DrawWaveform7b: - SAR AH, 1 - SAR AL, 1 - Add AX, 202h - SAR AH, 2 - SAR AL, 2 - - Xor CH, CH - Mov CL, AH - Sub CL, AL ; CX = iterations. - Inc CX - - Mov AL, 16 - Sub AL, AH - Cmp AL, 32 - JNE I_DrawWaveForm13 - - Mov AL, 31 - -I_DrawWaveForm13: - Mov AH, 176 - Mul AH - Mov BX, AX - -I_DrawWaveForm11: - Mov Byte Ptr [ES:DI+BX], 1 - Add BX, 176 - Loop I_DrawWaveForm11 - -I_DrawWaveForm12: - Pop EDX - Pop ECX - Pop EBX - Pop EAX - Inc DI - Loop I_DrawWaveForm6 - - ; Get Sample header offset. - Call Music_GetSongSegment - Mov DS, AX - Pop SI - Dec SI - Add SI, SI - Mov SI, [64912+SI] - - Mov EBX, [DS:SI+30h] - Test Byte Ptr [DS:SI+12h], 10h - JZ I_DrawWaveForm14 - - Mov ECX, EBX - ShR ECX, 1 - - Mov EAX, 175 - Mul DWord Ptr [DS:SI+34h] - Add EAX, ECX - AdC EDX, 0 - Div EBX - - Push EAX ; AX = loop start. - - Mov EAX, 175 - Mul DWord Ptr [DS:SI+38h] - Add EAX, ECX - AdC EDX, 0 - Div EBX - Mov EDX, EAX - Pop EAX ; EDX = loop end (0-175) - ; EAX = loop start (0-175) - - Call S_GetGenerationTableOffset - ; ES:DI - Add DI, AX - Sub DX, AX - Dec DX - Mov CX, 32 - Mov AH, 1 - -I_DrawSampleWaveFormLoop1: - Push DI - -; Xor AL, AL -; Test AH, 2 -; JZ I_DrawSampleWaveFormLoop2 -; -; Inc AL -; -;I_DrawSampleWaveFormLoop2: - Mov AL, AH - ShR AL, 1 - And AL, 1 - - StosB - Add DI, DX - StosB - - Pop DI - Add DI, 176 - Inc AH - Loop I_DrawSampleWaveFormLoop1 - -I_DrawWaveForm14: - Test Byte Ptr [DS:SI+12h], 20h - JZ I_DrawWaveFormEnd - - Mov ECX, EBX - ShR ECX, 1 - - Mov EAX, 175 - Mul DWord Ptr [DS:SI+40h] - Add EAX, ECX - AdC EDX, 0 - Div EBX - - Push EAX ; AX = loop start. - - Mov EAX, 175 - Mul DWord Ptr [DS:SI+44h] - Add EAX, ECX - AdC EDX, 0 - Div EBX - Mov EDX, EAX - Pop EAX ; DX = loop end (0-175) - ; AX = loop start (0-175) - - Call S_GetGenerationTableOffset - ; ES:DI - Add DI, AX - Sub DX, AX - Dec DX - Mov CX, 32 - Mov AL, 1 - -I_DrawSampleWaveFormSusLoop1: - Push DI - - StosB - Add DI, DX - StosB - - Pop DI - Add DI, 176 - Xor AL, 1 - Loop I_DrawSampleWaveFormSusLoop1 - -I_DrawWaveFormEnd: - Mov AX, 1 - Mov BX, 22 - Mov CX, 4 - Call S_GenerateCharacters - - Ret - -EndP I_DrawWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DeleteSample Far - - Mov DI, Offset O1_ConfirmDeleteSample - Mov CX, 4 - Call M_Object1List - - And DX, DX - JZ I_DeleteSample1 - - Call Music_Stop - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - Dec AX - Xor AH, AH - - Call Music_ReleaseSample - Call Music_ClearSampleName - - Call I_DrawWaveForm - -I_DeleteSample1: - Mov AX, 1 - Ret - -EndP I_DeleteSample - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -C5Speed DD 0 - -Proc I_CalculateC5Speed Far - - Mov AX, 1 - Ret - -Comment ! - Push DiskData - Pop ES - Call Fourier_CreateTable - - Call PE_GetLastInstrument ; Into BX - Mov AX, BX - Inc AX - - Xor CX, CX - Call Music_GetSampleLocation ; Returns DS:ESI, ECX - JC I_CalculateC5SpeedEnd - - PushF - Mov DX, 2048 - Mov DI, 16384 - - Cmp CX, DX - JB I_CalculateC5Speed1 - - Mov CX, DX - -I_CalculateC5Speed1: - Sub DX, CX - PopF - JNZ I_CalculateC5Speed16Bit - -I_CalculateC5Speed8Bit: - LodsB - StosW - Loop I_CalculateC5Speed8Bit - Jmp I_CalculateC5Speed2 - -I_CalculateC5Speed16Bit: - Rep MovsW - -I_CalculateC5Speed2: - Mov CX, DX - Xor AX, AX - Rep StosW - - Push ES - Pop DS - Call Fourier_Transform - -Comment ~ - - Mov DX, 1 - JZ I_CalculateC5BitSkip - - Inc DX - -I_CalculateC5BitSkip: - Mov EBP, ECX ; EBP = number of samples - -I_CalculateC5Speed1: - Sub EBP, 512 - JC I_CalculateC5SpeedDisplay - - Mov DI, 16384 - Mov BX, 512 - -I_CalculateC5Loop1: - Cmp DX, 2 - JE I_CalculateC5Speed16Bit - -I_CalculateC5Speed8Bit: - Mov AL, [SI] - Mov AH, AL - Jmp I_CalculateC5SpeedTransfer - -I_CalculateC5Speed16Bit: - Mov AX, [SI] - -I_CalculateC5SpeedTransfer: -; StosW - Mov CX, 4 - Rep StosW - - Add SI, DX - JC I_CalculateC5UpdateSampleLocation - -I_CalculateC5Continue: - Dec BX - JNZ I_CalculateC5Loop1 - -; OK.. do fourier - Push DS - PushAD - - Call Fourier_Transform - -; Now accumulate - Mov CX, 1024-64 - Mov SI, 24576+64*4 - Mov DI, 32768+64*4 - -I_CalculateC5Speed2: - FLd DWord Ptr [SI] - FAdd DWord Ptr [DI] - FStP DWord Ptr [DI] - Add SI, 4 - Add DI, 4 - Loop I_CalculateC5Speed2 - - PopAD - Pop DS - Jmp I_CalculateC5Speed1 - -I_CalculateC5UpdateSampleLocation: - Add ESI, 10000h - Int 3 - Jmp I_CalculateC5Continue - -I_CalculateC5SpeedDisplay: - Push ES - Pop DS -~ - Mov SI, 24768 - Xor CX, CX - Xor EAX, EAX - Xor EBX, EBX - -I_CalculateC5Speed3: - Cmp EAX, [SI] - JAE I_CalculateC5Speed4 - - Mov BX, CX - Mov EAX, [SI] - -I_CalculateC5Speed4: - Add SI, 4 - Inc CX - - Cmp CX, 1024 - JB I_CalculateC5Speed3 - -; Have BX = wavelength. - Mov EAX, 17145893 ; = C5Freq * 65536 - Mul EBX ; EDX:EAX = frequency in 48:16 format - ShRD EAX, EDX, 16 - - Mov CS:C5Speed, EAX -; EAX = C5Freq - Mov DI, Offset O1_C5FrequencyList - Call M_Object1ListDefault - -I_CalculateC5SpeedEnd: - Mov AX, 1 - Ret -! - -EndP I_CalculateC5Speed - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PrintC5Frequency Far - - Push CS - Pop DS - Assume DS:Inst - - Push C5Speed - - Mov SI, Offset C5FrequencyText - Mov AH, 20h - Mov DI, (27+27*80)*2 - Call S_DrawString - - Pop AX ; Clean up stack. - Pop BX - - Ret - -EndP I_PrintC5Frequency - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DeleteInstrument Far - - Mov DI, Offset O1_ConfirmDeleteInstrument - Mov CX, 4 - Call M_Object1List - - And DX, DX - JZ I_DeleteInstrument1 - - Call Music_Stop - - Call I_GetInstrumentOffset ; Gets DS:BX - - Mov CX, 120 - Add BX, 41h - -I_DeleteInstrument2: - Mov AL, [BX] - And AX, 0FFh - JZ I_DeleteInstrument3 - - Push DS - Push BX - Push CX - - Dec AX - - Call Music_ReleaseSample - Call Music_ClearSampleName - - Pop CX - Pop BX - Pop DS - -I_DeleteInstrument3: - Add BX, 2 - Loop I_DeleteInstrument2 - - Call I_InstrumentClear ; This sends network data already - -I_DeleteInstrument1: - Mov AX, 1 - Ret - -EndP I_DeleteInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ConvertSample Far ; Signed/Unsigned - - EnsureNoNetwork - - Call PE_GetLastInstrument - Mov CX, BX - Inc CX - Add BX, BX - - Call Music_GetSongSegment - Mov DS, AX - Mov SI, [64912+BX] - Test Byte Ptr [DS:SI+12h], 1 - JZ I_ConvertSample1 - - Push CX - - Mov DI, Offset O1_ConfirmConvertList - Mov CX, 3 - Call M_Object1List - - Pop AX ; AX = sample number - - And DX, DX - JZ I_ConvertSample1 - - Call Music_Stop - - Xor CX, CX - Call Music_GetSampleLocation ; DS:SI = location - JC I_ConvertSample1 ; CX = length. - - SetNZ BL - Xor BH, BH - Add SI, BX - - Inc BX - - -I_ConvertSample2: - Xor Byte Ptr [SI], 80h - Add SI, BX - JC I_ConvertSample3 - -I_ConvertSample4: - LoopD I_ConvertSample2 - - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_ConvertSample1: - Mov AX, 1 - Ret - -I_ConvertSample3: - Add ESI, 10000h - Int 3 - Jmp I_ConvertSample4 - -EndP I_ConvertSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InvertSample Far ; Signed/Unsigned - - EnsureNoNetwork - - Call PE_GetLastInstrument - Mov CX, BX - Inc CX - Add BX, BX - - Call Music_GetSongSegment - Mov DS, AX - Mov SI, [64912+BX] - Test Byte Ptr [DS:SI+12h], 1 - JZ I_InvertSample1 - - XChg AX, CX ; AX = sample number. - - Xor CX, CX - Call Music_GetSampleLocation ; DS:SI = location - JC I_InvertSample1 ; CX = length. - JNZ I_InvertSample_16Bit - -I_InvertSample2: - Neg Byte Ptr [SI] - Add SI, 1 - JC I_InvertSample3 - -I_InvertSample4: - LoopD I_InvertSample2 - -I_InvertSampleExit: - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_InvertSample1: - Mov AX, 1 - Ret - -I_InvertSample3: - Add ESI, 10000h - Int 3 - Jmp I_InvertSample4 - -I_InvertSample_16Bit: - Neg Word Ptr [SI] - Add SI, 2 - JC I_InvertSample_16Bit2 - -I_InvertSample_16Bit1: - LoopD I_InvertSample_16Bit - - Jmp I_InvertSampleExit - -I_InvertSample_16Bit2: - Add ESI, 10000h - Int 3 - Jmp I_InvertSample_16Bit1 - -EndP I_InvertSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_CutSampleBeforeLoopUpdateLoop Near - - Sub [DS:BX+DI], EDX - JNC I_CutSampleBeforeLoopUpdateLoop1 - - Mov DWord Ptr [DS:BX+DI], 0 - -I_CutSampleBeforeLoopUpdateLoop1: - Add DI, 4 - Ret - -EndP I_CutSampleBeforeLoopUpdateLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_CutSampleBeforeLoop Far - - EnsureNoNetwork - - Call I_GetSampleOffset - - Cmp DWord Ptr [DS:BX+34h], 0 -; Test Byte Ptr [DS:BX+12h], 10h - JZ I_CutSampleBeforeLoop1 - - Push DS - Push BX - - Mov DI, Offset O1_ConfirmCutSample - Mov CX, 4 - Call M_Object1List - - Pop BX - Pop DS - - And DX, DX - JZ I_CutSampleBeforeLoop1 - - Call Music_Stop - - Mov EDX, [DS:BX+34h] - Test Byte Ptr [DS:BX+12h], 32 - JZ I_CutSampleBeforeLoop2 - - Mov EAX, [DS:BX+40h] - - Cmp EDX, EAX - JB I_CutSampleBeforeLoop2 - Mov EDX, EAX - -I_CutSampleBeforeLoop2: - Mov DI, 34h - Call I_CutSampleBeforeLoopUpdateLoop ; BX+34h - Begin - Call I_CutSampleBeforeLoopUpdateLoop ; BX+38h - End - - Add DI, 4 - Call I_CutSampleBeforeLoopUpdateLoop ; BX+40h - SusLBeg - Call I_CutSampleBeforeLoopUpdateLoop ; BX+44h - SusLEnd - -I_CutSampleBeforeLoop4: - Sub [BX+30h], EDX - Mov ECX, [BX+30h] - - Test Byte Ptr [BX+12h], 2 - JZ I_CutSampleBeforeLoop6 - - Add EDX, EDX - Add ECX, ECX - -I_CutSampleBeforeLoop6: - Mov ESI, EDX - Call I_RepositionSample - - ; To diskdata segment first. - Mov AX, DiskData - Mov ES, AX - Assume ES:Nothing - - Xor EDI, EDI - -I_CutSampleBeforeLoop7: - Mov AL, [SI] - Mov [ES:DI], AL - - Add SI, 1 - JC I_CutSampleBeforeLoop8 - -I_CutSampleBeforeLoop9: - Add DI, 1 - JC I_CutSampleBeforeLoop10 - -I_CutSampleBeforeLoop11: - LoopD I_CutSampleBeforeLoop7 - - Mov ESI, EDI - Int 3 - Mov CX, DI - - Push DS - Push ES - Pop DS - Pop ES ; Swap DS and ES - - Xor SI, SI - Xor DI, DI - Rep MovsB - - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_CutSampleBeforeLoop1: - Mov AX, 1 - Ret - -I_CutSampleBeforeLoop8: - Add ESI, 10000h - Int 3 - Jmp I_CutSampleBeforeLoop9 - -I_CutSampleBeforeLoop10: - PushAD - Push DS - Push ES - - Mov ESI, EDI - Int 3 - - Push DS - Push ES - Pop DS - Pop ES ; Swap DS and ES - - Mov CX, 16384 - Xor SI, SI - Xor DI, DI - Rep MovsD - - Pop ES - Pop DS - PopAD - - Add EDI, 10000h - - Int 3 - Jmp I_CutSampleBeforeLoop11 - -EndP I_CutSampleBeforeLoop - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_CutSample Far - - EnsureNoNetwork - - Call I_GetSampleOffset - - Cmp DWord Ptr [DS:BX+38h], 0 -; Test Byte Ptr [DS:BX+12h], 10h ; Loop? - JZ I_CutSample1 - - Push DS - Push BX - - Mov DI, Offset O1_ConfirmCutSample - Mov CX, 4 - Call M_Object1List - - Pop BX - Pop DS - - And DX, DX - JZ I_CutSample1 - - Call Music_Stop - - Mov EAX, [DS:BX+38h] - Mov EDX, [DS:BX+44h] - Cmp EAX, EDX - JAE I_CutSample2 - Mov EAX, EDX - -I_CutSample2: - Mov [DS:BX+30h], EAX - - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_CutSample1: - Mov AX, 1 - Ret - -Proc I_CutSampleCheckValue Near - - Cmp DWord Ptr [DS:BX+DI], EAX - JBE I_CutSampleCheckValue1 - - Mov [DS:BX+DI], EAX - -I_CutSampleCheckValue1: - Ret - -EndP I_CutSampleCheckValue - -EndP I_CutSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ClearSampleName Far - Assume DS:Inst - - Mov SamplePos, 0 - -I_ClearSampleName2: - Call I_GetSampleOffset - - Push DS - Pop ES - - Mov DI, BX - -I_ClearSampleName3: - Add DI, 4 - - Mov CX, 6 - Xor AX, AX - Rep StosW - - Add DI, 4 - Mov CX, 13 - Rep StosW - - NetworkSendSample - - Inc AX - Ret - -EndP I_ClearSampleName - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InsertSample Far - - EnsureNoNetwork - - Call Music_GetSongSegment - Mov DS, AX - Mov SI, [DS:64912+(99-1)*2] - Test Byte Ptr [SI+12h], 1 - JNZ I_InsertSampleEnd - - Call PE_GetLastInstrument - Cmp BL, 98 - JE I_InsertSampleEnd - - Call Music_Stop - - Call PE_GetLastInstrument - Mov DL, BL - Push BX - - Call Music_GetSongSegment - - Mov ES, AX - Mov DS, AX - - Mov AX, 98 - Sub AX, BX - Mov CX, 80 - Add BX, BX - Mul CX - Mov SI, [DS:64912+BX] - Add SI, AX - Dec SI - LEA DI, [SI+80] - Mov CX, AX - - StD - Rep MovsB - ClD - - Mov DWord Ptr [SI+1+48h], 0 - Mov Byte Ptr [SI+1+12h], 0 - - Call Music_SoundCardLoadAllSamples - - Pop AX - Push AX - Call Music_ClearSampleName - - Pop DX - Inc DX ; DL = instrument - - Call Music_GetInstrumentMode - JZ I_InsertSampleSampleMode - ; Instrument mode.. - ; step through inst. - - Xor EAX, EAX - -I_InsertSample4: - Mov SI, [DS:64712+EAX*2] - Add SI, 41h - - Mov CX, 120 - -I_InsertSample5: - Cmp [SI], DL - JB I_InsertSample6 - - Cmp Byte Ptr [SI], 99 - JAE I_InsertSample6 - - Inc Byte Ptr [SI] - -I_InsertSample6: - Add SI, 2 - Loop I_InsertSample5 - - Inc AX - Cmp AX, 99 - JB I_InsertSample4 - - Jmp I_InsertSampleFinished - -I_InsertSampleSampleMode: - Call PE_InsertInstrument - -I_InsertSampleFinished: - Call I_DrawWaveform - -I_InsertSampleEnd: - Mov AX, 1 - Ret - -EndP I_InsertSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_RemoveSample Far - - EnsureNoNetwork - - Call I_GetSampleOffset - Test Byte Ptr [BX+12h], 1 - JNZ I_RemoveSampleEnd - - Call Music_Stop - - Call PE_GetLastInstrument - Mov DL, BL - Push BX - - Call Music_GetSongSegment - - Mov ES, AX - Mov DS, AX - - Mov AX, 98 - Sub AX, BX - Mov CX, 80 - Add BX, BX - Mul CX - Mov DI, [DS:64912+BX] - LEA SI, [DI+80] - Mov CX, AX - - Rep MovsB - - Pop DX - Inc DX ; DL = instrument - - Push DS - Push DI - - Mov DWord Ptr [DI+48h], 0 - Mov Byte Ptr [DI+12h], 0 - - Call Music_SoundCardLoadAllSamples - - Call Music_GetInstrumentMode - JZ I_RemoveSampleSampleMode - ; Instrument mode.. - ; step through inst. - - Xor EAX, EAX - -I_RemoveSample4: - Mov SI, [DS:64712+EAX*2] - Add SI, 41h - - Mov CX, 120 - -I_RemoveSample5: - Cmp [SI], DL - JB I_RemoveSample6 - - Dec Byte Ptr [SI] - -I_RemoveSample6: - Add SI, 2 - Loop I_RemoveSample5 - - Inc AX - Cmp AX, 99 - JB I_RemoveSample4 - - Jmp I_RemoveSampleFinished - -I_RemoveSampleSampleMode: - Call PE_DeleteInstrument - -I_RemoveSampleFinished: - Call I_DrawWaveform - - Pop DI - Pop ES - Jmp I_ClearSampleName3 - -I_RemoveSampleEnd: - Mov AX, 1 - Ret - -EndP I_RemoveSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InsertInstrument Far - - EnsureNoNetwork - - Call PE_GetLastInstrument - Cmp BL, 98 - JE I_InsertInstrumentEnd - - Call Music_Stop - - Call PE_GetLastInstrument - Mov DL, BL - Push BX - - Call Music_GetSongSegment - - Mov ES, AX - Mov DS, AX - - Mov AX, 98 - Sub AX, BX - Mov CX, 554 - Add BX, BX - Mul CX - Mov SI, [DS:64712+BX] - Add SI, AX - Dec SI - LEA DI, [SI+554] - Mov CX, AX - - StD - Rep MovsB - ClD - - Pop DX - Inc DX ; DL = instrument - - Call Music_GetInstrumentMode - JZ I_InsertInstrumentFinished - - Call PE_InsertInstrument - -I_InsertInstrumentFinished: - Jmp I_InstrumentClear ; Sends network data - -I_InsertInstrumentEnd: - Mov AX, 1 - Ret - -EndP I_InsertInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_RemoveInstrument Far - - EnsureNoNetwork - - Call Music_Stop - - Call PE_GetLastInstrument - Mov DL, BL - Push BX - - Call Music_GetSongSegment - - Mov ES, AX - Mov DS, AX - - Mov AX, 98 - Sub AX, BX - Mov CX, 554 - Add BX, BX - Mul CX - MOv DI, [DS:64712+BX] - LEA SI, [DI+554] - Mov CX, AX - - Rep MovsB - - Pop DX - Inc DX ; DL = instrument - - Call Music_GetInstrumentMode - JZ I_RemoveInstrumentFinished - - Call PE_DeleteInstrument - -I_RemoveInstrumentFinished: - Mov AX, 98 - Call Music_ClearInstrument - - Call I_MapEnvelope - -I_RemoveInstrumentEnd: - Mov AX, 1 - Ret - -EndP I_RemoveInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSampleNumber ; Carry if not a num. - ; DX otherwise, - Push CS - Pop DS - - Mov SI, Offset SampleNumberInput - Xor DX, DX - -GetSampleNumber1: - LodsB - And AL, AL - JZ GetSampleNumber2 - - Cmp AL, '0' - JB GetSampleNumber3 - Cmp AL, '9' - JA GetSampleNumber3 - - Sub AL, '0' - XChg DL, AL - Mov AH, 10 - Mul AH - Add DL, AL - - Jmp GetSampleNumber1 - -GetSampleNumber3: - StC - Ret - -GetSampleNumber2: - Test DX, DX - JZ GetSampleNumber3 - -; ClC - Ret - -EndP GetSampleNumber - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetNumberInput ; DI = Offset of list. - ; Returns DX with sample number. - - Push DI - - Mov DI, Offset SampleNumberInput - Push CS - Pop ES - Xor AL, AL - Mov CX, 4 - Rep StosB - - Pop DI - - Call S_SaveScreen - - Mov CX, 3 - Call M_Object1List - - Call S_RestoreScreen - - And DX, DX - JZ GetNumberInput1 - - Call Music_Stop - - Call GetSampleNumber - JC GetNumberInput1 - - Ret - -GetNumberInput1: - Pop AX ; Add SP, 2 - Mov AX, 1 - RetF - -EndP GetNumberInput - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ExchangeSamples Far - - ; Clear input... - - EnsureNoNetwork - - Mov DI, Offset O1_ExchangeSampleList - Call GetNumberInput - - Mov SI, DX - Dec SI - Add SI, SI - - Call PE_GetLastInstrument - Add BX, BX - - Cmp BX, SI - JE I_ExchangeSamples1 - - Call Music_GetSongSegment - Mov ES, AX - Mov DS, AX - Mov DI, [DS:64912+BX] - Mov SI, [DS:64912+SI] ; DS:SI, ES:DI point to - ; sample headers - - Mov CX, 80 - -I_ExchangeSamples2: - Mov AL, [ES:DI] - MovsB - Mov [DS:SI-1], AL - - Loop I_ExchangeSamples2 - - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_ExchangeSamples1: - Mov AX, 1 - Ret - -EndP I_ExchangeSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SwapSamples Far - - ; Clear input... - - EnsureNoNetwork - - Mov DI, Offset O1_SwapSampleList - Call GetNumberInput - - Mov SI, DX - Dec SI - Add SI, SI - - Call PE_GetLastInstrument - Mov DH, BL - Inc DH ; DH/DL = samples to swap - Add BX, BX - - Cmp DL, DH - JE I_SwapSamples1 - - Call Music_GetSongSegment - Mov ES, AX - Mov DS, AX - Mov DI, [DS:64912+BX] - Mov SI, [DS:64912+SI] ; DS:SI, ES:DI point to - ; sample headers - - Mov CX, 80 - -I_SwapSamples2: - Mov AL, [ES:DI] ; Swapping headers. - MovsB - Mov [DS:SI-1], AL - - Loop I_SwapSamples2 - - ; Now to swap pattern - ; stuff... - Call Music_GetInstrumentMode - JZ I_SwapSamples3 - ; Instrument mode.. - ; step through inst. - Xor AX, AX - -I_SwapSamples4: - Push AX - - Mov BX, AX - Add BX, BX - Mov SI, [DS:64712+BX] - Add SI, 41h - - Mov CX, 120 - -I_SwapSamples5: - Mov AL, [SI] - Cmp AL, DL - JNE I_SwapSamples6 - - Mov [SI], DH - Jmp I_SwapSamples7 - -I_SwapSamples6: - Cmp AL, DH - JNE I_SwapSamples7 - - Mov [SI], DL - -I_SwapSamples7: - Add SI, 2 - Loop I_SwapSamples5 - - Pop AX - - Inc AX - Cmp AX, 99 - JB I_SwapSamples4 - - Jmp I_SwapSamples8 - -I_SwapSamples3: ; Sample mode.. - Call PE_SwapInstruments - -I_SwapSamples8: - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_SwapSamples1: - Mov AX, 1 - Ret - -EndP I_SwapSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ReplaceSample Far - - EnsureNoNetwork - - Mov DI, Offset O1_ReplaceSampleList - Call GetNumberInput - - Call PE_GetLastInstrument - Mov DH, BL - Inc DH ; DH/DL = samples to swap - - Cmp DL, DH - JE I_ReplaceSample1 - - Call Music_GetSongSegment - Mov ES, AX - Mov DS, AX - ; Now to swap pattern - ; stuff... - Call Music_GetInstrumentMode - JZ I_ReplaceSample3 - ; Instrument mode.. - ; step through inst. - Xor AX, AX - -I_ReplaceSample4: - Push AX - - Mov BX, AX - Add BX, BX - Mov SI, [DS:64712+BX] - Add SI, 41h - - Mov CX, 120 - -I_ReplaceSample5: - Mov AL, [SI] - - Cmp AL, DH - JNE I_ReplaceSample7 - - Mov [SI], DL - -I_ReplaceSample7: - Add SI, 2 - Loop I_ReplaceSample5 - - Pop AX - - Inc AX - Cmp AX, 99 - JBE I_ReplaceSample4 - - Mov AX, 1 - Ret - -I_ReplaceSample3: ; Sample mode.. - XChg DH, DL - Or DH, 80h - Call PE_SwapInstruments - -I_ReplaceSample1: - Mov AX, 1 - Ret - -EndP I_ReplaceSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ReMix - Assume DS:Nothing - - EnsureNoNetwork - - Call Music_Stop - ; OK... - Call I_GetSampleOffset - Mov EDX, CS:NewSampleSize - Mov AX, 99 - - Test Byte Ptr [BX+12h], 2 - JZ I_ReMix1 - - Add EDX, EDX - -I_ReMix1: - ; Limit size of EDX... - Cmp EDX, 4177920 - JBE I_ReMixLimitMaxSize - - Mov EDX, 4177920 - Mov CS:NewSampleSize, EDX - - Test Byte Ptr [BX+12h], 2 - JZ I_ReMixLimitMaxSize - - ShR CS:NewSampleSize, 1 - -I_ReMixLimitMaxSize: - Call Music_AllocateSample ; Returns ES:DI - Mov AX, ES - And AX, AX - JNZ I_ReMixEnoughMem - - Call PEFunction_OutOfMemoryMessage - -I_ReMixNoMix: - Ret - -I_ReMixEnoughMem: - Mov AX, DiskData - Mov ES, AX - Assume ES:Nothing - - Call PE_GetLastInstrument ; Into BX - Mov AX, BX - Inc AX - - Xor CX, CX - Call Music_GetSampleLocation ; Returns DS:ESI, ECX - JNZ I_ReMix16Bit - -I_ReMix8Bit: - Mov EAX, ECX - Xor EDX, EDX - Div CS:NewSampleSize - - Mov BP, AX - ShR EAX, 16 - JNZ I_ReMixNoMix - - Xor EAX, EAX ; BP:AX = skip value... - Div CS:NewSampleSize - - ShR EAX, 16 - Mov BX, AX - - ; BP:BX = skip value. - Xor ESI, ESI ; DS:ESI = source - Xor EDI, EDI ; Go from the start! - Xor CX, CX ; CX = error. - ; ES:EDI = destination - -I_ReMix8Bit2: - Cmp CS:Interpolate, 0 - JNE I_ReMix8BitInterpolate - - Mov AL, [SI] - Jmp I_ReMix8BitStore - -I_ReMix8BitInterpolate: - MovSX AX, Byte Ptr [SI] - Mov DX, 100h - Sub DL, CH - SbB DH, 0 - IMul DX ; AX = [SI]*(1-Remainder)*256 - - Push AX - - Add SI, 1 - JNC I_ReMix8BitInterpolate2 - - Add ESI, 10000h - Int 3 - -I_ReMix8BitInterpolate2: - MovSX AX, Byte Ptr [SI] - Mov DL, CH - Xor DH, DH - Mul DX - - Pop DX ; DX = Old AX = [SI]*(1-Remainder)*256 - Add AX, DX - Add AX, 80h ; Rounding. - Mov AL, AH - - Sub ESI, 1 - -I_ReMix8BitStore: - Mov [ES:DI], AL - - Add CX, BX - AdC SI, BP - JC I_ReMix8Bit3 - -I_ReMix8Bit4: - Add DI, 1 - JC I_ReMix8Bit5 - -I_ReMix8Bit6: - Cmp EDI, CS:NewSampleSize - JB I_ReMix8Bit2 - - Jmp I_ReMixCleanUp - -I_ReMix8Bit3: - Add ESI, 10000h - Int 3 - Jmp I_Remix8Bit4 - -I_ReMix8Bit5: - PushAD - Push DS - Push ES - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - Mov ESI, EDI - Int 3 - - Push DS - Push ES - Pop DS - Pop ES - - Mov CX, 16384 - Xor SI, SI - Xor DI, DI - Rep MovsD - - Pop ES - Pop DS - PopAD - - Add EDI, 10000h - - Call I_RepositionSample - Jmp I_ReMix8Bit6 - -I_ReMix16Bit: - Mov EAX, ECX - Xor EDX, EDX - Div CS:NewSampleSize - - Mov BP, AX - Add BP, BP - ShR EAX, 15 - JNZ I_ReMixNoMix - - Xor EAX, EAX ; BP:AX = skip value... - Div CS:NewSampleSize - - ShR EAX, 16 - Mov BX, AX - - ; BP:BX = skip value. - Xor ESI, ESI ; DS:ESI = source - Xor EDI, EDI ; Go from the start! - Xor CX, CX ; CX = error. - ; ES:EDI = destination - -I_ReMix16Bit2: - Cmp CS:Interpolate, 0 - JNE I_ReMix16BitInterpolate - - Mov AX, [SI] - Jmp I_ReMix16BitStore - -I_ReMix16BitInterpolate: - Mov AX, [SI] ; AX = [SI]*(1-Remainder)*256 - Mov DX, 100h - Sub DL, CH - SbB DH, 0 - IMul DX ; DX:AX = [SI]*(1-Remainder)*256 - - Push DX - Push AX - - Add SI, 2 - JNC I_ReMix16BitInterpolate2 - - Add ESI, 10000h - Int 3 - -I_ReMix16BitInterpolate2: - Mov AX, [SI] - - MovZX DX, CH - IMul DX ; DX:AX = Remainder*256 - ShL EDX, 16 - Mov DX, AX - - Pop EAX - - Add EAX, EDX - Add EAX, 80h ; Rounding. - ShR EAX, 8 - - Sub ESI, 2 - -I_ReMix16BitStore: - Mov [ES:DI], AX - - Xor AX, AX - Add CX, BX - SetC AL - Add AX, AX - Add AX, BP - Add SI, AX - JC I_ReMix16Bit3 - -I_ReMix16Bit4: - Add DI, 2 - JC I_ReMix16Bit5 - -I_ReMix16Bit6: - Mov EAX, EDI - ShR EAX, 1 - Cmp EAX, CS:NewSampleSize - JB I_ReMix16Bit2 - - Jmp I_ReMixCleanUp - -I_ReMix16Bit3: - Add ESI, 10000h - Int 3 - Jmp I_Remix16Bit4 - -I_ReMix16Bit5: - PushAD - Push DS - Push ES - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - Mov ESI, EDI - Int 3 - - Push DS - Push ES - Pop DS - Pop ES - - Mov CX, 16384 - Xor SI, SI - Xor DI, DI - Rep MovsD - - Pop ES - Pop DS - PopAD - - Add EDI, 10000h - - Call I_RepositionSample - Jmp I_ReMix16Bit6 - -I_ReMixCleanUp: - ; Copy leftover stuff... - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - Mov ESI, EDI - Int 3 - - Push DS - Push ES - Pop DS - Pop ES - - Mov CX, DI - Xor SI, SI - Xor DI, DI - Rep MovsB - - Call I_GetSampleOffset ; Gets DS:BX - Mov SI, BX - Mov ECX, [SI+30h] - Mov EBX, CS:NewSampleSize - ; ECX = length of old samp - ; EBX = length of new samp - Mov [SI+30h], EBX - Add SI, 34h - - Call Near Ptr I_ReMix5 - Call Near Ptr I_ReMix5 - Call Near Ptr I_ReMix5 - Call Near Ptr I_ReMix5 - Call Near Ptr I_ReMix5 - ; Now grab the data from Inst99 - Call I_SwapMemoryAllocation - - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - - Ret - -I_ReMix5: - Mov EAX, [SI] - Mul EBX - - Cmp EDX, ECX - JAE I_ReMix6 - - Div ECX - Cmp EAX, 9999999 - JB I_ReMix7 - -I_ReMix6: - Mov EAX, 9999999 - -I_ReMix7: - Mov [SI], EAX - Add SI, 4 - -I_ReMixEnd: - Ret - -EndP I_ReMix - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ResizeSample Far - - Mov CS:Interpolate, 1 - Jmp I_ResizeJumpPoint - -EndP I_ResizeSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ResizeSampleNoInt Far - - Mov CS:Interpolate, 0 - -I_ResizeJumpPoint: - EnsureNoNetwork - - Call I_GetSampleOffset - Mov AL, [BX+12h] - Test AL, 1 - JZ I_ResizeSampleNoInt1 - - And AL, 2 - Mov CS:Quality, AL - - Cmp DWord Ptr [DS:BX+30h], 0 - JE I_ResizeSampleNoInt1 - - Mov EAX, [DS:BX+30h] ; Old length - Mov CS:NewSampleSize, EAX - - Call F_Reset5NumInputPos - Call S_SaveScreen - - Mov DI, Offset O1_ResizeSampleList - Mov CX, 3 - Call M_Object1List - - Call S_RestoreScreen - - And DX, DX - JZ I_ResizeSampleNoInt1 - - Push CS - Pop DS - Assume DS:Inst - - Mov EDX, NewSampleSize - And EDX, EDX - JZ I_ResizeSampleNoInt1 - - Call I_Remix - -I_ResizeSampleNoInt1: - Mov AX, 1 - Ret - -EndP I_ResizeSampleNoInt - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_CenterSample Far - - EnsureNoNetwork - - Call PE_GetLastInstrument - Mov AX, BX - Inc AX - - Xor CX, CX - Call Music_GetSampleLocation ; Gets DS:SI, and ECX. - ; Zero flag if 8 bit. - JNC I_CenterSample1 - - Xor AX, AX - Ret - -I_CenterSample1: - Push AX ; Remember sample num. - ; Scan through wave first, - ; and find max deviation from - ; mean. - JNZ I_CenterSamplePre16Bit1 - Mov BL, [SI] - Mov DL, [SI] - -I_CenterSamplePre8Bit1: - Mov AL, [SI] - Cmp AL, BL - JL I_CenterSamplePre8Bit3 - Cmp AL, DL - JG I_CenterSamplePre8Bit4 - -I_CenterSamplePre8Bit2: - Add SI, 1 - JC I_CenterSamplePre8BitNextBlock - -I_CenterSamplePre8Bit5: - LoopD I_CenterSamplePre8Bit1 - - MovSX BX, BL - MovSX DX, DL - - Add BX, DX - Neg BX - SAR BX, 1 - - Jmp I_CenterSample2 - -I_CenterSamplePre8Bit3: - Mov BL, AL - Jmp I_CenterSamplePre8Bit2 - -I_CenterSamplePre8Bit4: - Mov DL, AL - Jmp I_CenterSamplePre8Bit2 - -I_CenterSamplePre8BitNextBlock: - Add ESI, 10000h - Int 3 - - Jmp I_CenterSamplePre8Bit5 - -I_CenterSamplePre16Bit: - Mov BX, [SI] - Mov DX, [SI] - -I_CenterSamplePre16Bit1: - Mov AX, [SI] - Cmp AX, BX - JL I_CenterSamplePre16Bit3 - Cmp AX, DX - JG I_CenterSamplePre16Bit4 - -I_CenterSamplePre16Bit2: - Add SI, 2 - JC I_CenterSamplePre16BitNextBlock - -I_CenterSamplePre16Bit5: - LoopD I_CenterSamplePre16Bit1 - - MovSX EBX, BX - MovSX EDX, DX - Add EBX, EDX - Neg EBX - SAR EBX, 1 - - Jmp I_CenterSample2 - -I_CenterSamplePre16Bit3: - Mov BX, AX - Jmp I_CenterSamplePre16Bit2 - -I_CenterSamplePre16Bit4: - Mov DX, AX - Jmp I_CenterSamplePre16Bit2 - -I_CenterSamplePre16BitNextBlock: - Add ESI, 10000h - Int 3 - Jmp I_CenterSamplePre16Bit5 - -I_CenterSample2: - Push BX - - Mov DI, Offset O1_SampleCenterList - Mov CX, 3 - Call M_Object1List - - Pop BX - Pop AX ; AX = sample num - Test DL, 1 - JZ I_CenterSampleEnd - - Call Music_Stop - - Xor CX, CX - Call Music_GetSampleLocation ; Loads DS:ESI and ECX again. - JNZ I_CenterSample16Bit1 - -I_CenterSample8Bit1: - Add [SI], BL - Add SI, 1 - JC I_CenterSample8BitNextBlock - -I_CenterSample8Bit2: - LoopD I_CenterSample8Bit1 - Jmp I_CenterSample3 - -I_CenterSample8BitNextBlock: - Add ESI, 10000h - Int 3 - Jmp I_CenterSample8Bit2 - -I_CenterSample16Bit1: - Add [SI], BX - Add SI, 2 - JC I_CenterSample16BitNextBlock - -I_CenterSample16Bit2: - LoopD I_CenterSample16Bit1 - Jmp I_CenterSample3 - -I_CenterSample16BitNextBlock: - Add ESI, 10000h - Int 3 - Jmp I_CenterSample16Bit2 - -I_CenterSample3: - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_CenterSampleEnd: - Mov AX, 1 - Ret - -EndP I_CenterSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_AmplifySample Far - - EnsureNoNetwork - - Call PE_GetLastInstrument - Mov AX, BX - Inc AX - - Xor CX, CX - Call Music_GetSampleLocation ; Gets DS:SI, and ECX. - JNC I_AmplifySample1 - - Xor AX, AX - Ret - -I_AmplifySample1: - Push AX ; Remember sample num. - ; Scan through wave first, - ; and find max deviation from - ; mean. - Mov BX, 0 ; BX = deviation from mean - JNZ I_AmplifySample11 ; 16 bit stuff. - -I_AmplifySample2: - Mov AL, [SI] -; Sub AL, 80h - CBW - Xor AL, AH - Sub AL, AH - - Cmp AL, BH - JB I_AmplifySample3 - - Mov BH, AL - -I_AmplifySample3: - Add SI, 1 - JC I_AmplifySample8 - -I_AmplifySample9: - LoopD I_AmplifySample2 - Jmp I_AmplifySample10 - -I_AmplifySample8: - Add ESI, 10000h - Int 3 - Jmp I_AmplifySample9 - -I_AmplifySample11: - Mov AX, [SI] -; Sub AX, 8000h - CWD - Xor AX, DX - Sub AX, DX - Cmp AX, BX - JB I_AmplifySample12 - - Mov BX, AX - -I_AmplifySample12: - Add SI, 2 - JC I_AmplifySample13 - -I_AmplifySample14: - LoopD I_AmplifySample11 - Jmp I_AmplifySample10 - -I_AmplifySample13: - Add ESI, 10000h - Int 3 - Jmp I_AmplifySample14 - - -I_AmplifySample10: - ; OK. so BL contains max dev. - ; Amplificat = (8000h/MaxDev)*100 - Xor AX, AX - Mov DX, 32h - - Cmp DX, BX - JAE I_AmplifySample4 - - Div BX - - Cmp AX, 400 - JB I_AmplifySample5 - -I_AmplifySample4: - Mov AX, 400 - -I_AmplifySample5: - Mov CS:SampleAmplification, AX - - Mov DI, Offset O1_SampleAmplificationList - Mov CX, 3 - Call M_Object1List - - Pop AX ; AX = sample num - And DX, DX - JZ I_AmplifySampleEnd - - Call Music_Stop - - Xor CX, CX - Call Music_GetSampleLocation ; Loads DS:ESI and ECX again. - - PushF - - ; NewSample = OldSample*SampleAmplification/100, clipped. - - Mov AX, CS:SampleAmplification - Xor DX, DX - Mov BX, 100 - Div BX - ShL EAX, 16 - Div BX - Mov EBX, EAX ; EBX = multiplier, 16.16 bit. - - PopF - JNZ I_AmplifySample20 - -I_AmplifySample6: - MovSX EAX, Byte Ptr [SI] - - IMul EBX - - Add EAX, 8000h ; Rounding factor - ShR EAX, 16 - - Cmp AX, 7Fh - JGE I_AmplifySampleClip1 - - Cmp AX, -80h - JGE I_AmplifySample7 - - Mov AL, 80h - Jmp I_AmplifySample7 - -I_AmplifySampleClip1: - Mov AL, 7Fh - -I_AmplifySample7: - Mov [SI], AL - Add SI, 1 - JC I_AmplifySample16 - -I_AmplifySample17: - LoopD I_AmplifySample6 - Jmp I_AmplifySample15 - -I_AmplifySample16: - Add ESI, 10000h - Int 3 - Jmp I_AmplifySample17 - -I_AmplifySample20: ; 16 bit amplification!, EBX = 16.16 bit multiplier. - ; Newsample = OldSample*SampleAmplification/100 - - Mov AX, [SI] - MovSX EAX, AX - - IMul EBX - Add EAX, 8000h ; Rounding factor - AdC EDX, 0 ; Rounding stuff, etc. - - ShRD EAX, EDX, 16 - - Cmp EAX, 7FFFh - JGE I_AmplifySampleClip2 - - Cmp EAX, -8000h - JGE I_AmplifySample18 - - Mov AX, 8000h - Jmp I_AmplifySample18 - -I_AmplifySampleClip2: - Mov AX, 7FFFh - -I_AmplifySample18: - Mov [SI], AX - - Add SI, 2 - JC I_AmplifySample21 - -I_AmplifySample19: - LoopD I_AmplifySample20 - Jmp I_AmplifySample15 - -I_AmplifySample21: - Add ESI, 10000h - Int 3 - Jmp I_AmplifySample19 - -I_AmplifySample15: - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_AmplifySampleEnd: - Mov AX, 1 - Ret - -EndP I_AmplifySample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ReverseSample Far - - EnsureNoNetwork - - Call PE_GetLastInstrument - Mov AX, BX - Inc AX - - Xor CX, CX - Call Music_GetSampleLocation ; Gets DS:SI, and CX. - JC I_ReverseSample1 - - JNZ I_ReverseSample10 - - Call Music_Stop - - Push ECX - - Mov EDX, ECX - Mov AX, 99 - Call Music_AllocateSample ; Returns ES:DI - Mov AX, ES - And AX, AX - - Pop ECX - - JZ I_ReverseSampleError - - Mov ESI, ECX - Dec ESI - Call I_RepositionSample - - Mov AX, DiskData - Mov ES, AX - Assume ES:Nothing - - Xor EDI, EDI - -I_ReverseSample2: - Mov AL, [SI] - Mov [ES:DI], AL - - Sub SI, 1 - JC I_ReverseSample4 - -I_ReverseSample5: - Add DI, 1 - JC I_ReverseSample6 - -I_ReverseSample7: - LoopD I_ReverseSample2 - Jmp I_ReverseSample3 - -I_ReverseSample4: - Sub ESI, 10000h - JC I_ReverseSample5 - Int 3 - - Jmp I_ReverseSample5 - -I_ReverseSample6: - PushAD - Push DS - Push ES - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - Mov ESI, EDI - Int 3 - - Push DS - Push ES - - Pop DS - Pop ES - - Xor SI, SI - Xor DI, DI - Mov CX, 16384 - Rep MovsD - - Pop ES - Pop DS - PopAD - Add EDI, 10000h - Call I_RepositionSample - Jmp I_ReverseSample7 - -I_ReverseSample10: - Call Music_Stop - - Push ECX - - Mov EDX, ECX - Add EDX, EDX - Mov AX, 99 - Call Music_AllocateSample ; Returns ES:DI - Mov AX, ES - And AX, AX - - Pop ECX - - JZ I_ReverseSampleError - - Mov ESI, ECX - Dec ESI - Add ESI, ESI - Call I_RepositionSample - - Mov AX, DiskData - Mov ES, AX - Assume ES:Nothing - - Xor EDI, EDI - -I_ReverseSample12: - Mov AX, [SI] - Mov [ES:DI], AX - - Sub SI, 2 - JC I_ReverseSample14 - -I_ReverseSample15: - Add DI, 2 - JC I_ReverseSample16 - -I_ReverseSample17: - LoopD I_ReverseSample12 - Jmp I_ReverseSample3 - -I_ReverseSample14: - Sub ESI, 10000h - JC I_ReverseSample15 - Int 3 - - Jmp I_ReverseSample15 - -I_ReverseSample16: - PushAD - Push DS - Push ES - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - Mov ESI, EDI - Int 3 - - Push DS - Push ES - - Pop DS - Pop ES - - Xor SI, SI - Xor DI, DI - Mov CX, 16384 - Rep MovsD - - Pop ES - Pop DS - PopAD - Add EDI, 10000h - Call I_RepositionSample - Jmp I_ReverseSample17 - - -I_ReverseSampleError: - Call PEFunction_OutOfMemoryMessage - - Mov AX, 1 - Ret - -I_ReverseSample3: - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - - Mov ESI, EDI - Int 3 - - Mov CX, DI - - Push DS - Push ES - Pop DS - Pop ES - - Xor SI, SI - Xor DI, DI - Rep MovsB - - ; Now to release old memory, and swap - ; in new lot... - Call I_SwapMemoryAllocation - - Call I_GetSampleOffset ; Returns DS:BX - - Mov EDX, [BX+30h] ; DX = length - Mov EAX, EDX - Mov ECX, EDX - - Sub EAX, [BX+34h] - Sub ECX, [BX+38h] - Mov [BX+34h], ECX - Mov [BX+38h], EAX - - Mov EAX, EDX - Mov ECX, EDX - - Sub EAX, [BX+40h] - Sub ECX, [BX+44h] - Mov [BX+40h], ECX - Mov [BX+44h], EAX - - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_ReverseSample1: - Mov AX, 1 - Ret - -EndP I_ReverseSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SwapMemoryAllocation - - Call I_GetSampleOffset ; Gets DS:BX - Mov SI, [DS:64912+99*2] - Mov EAX, [SI+48h] - XChg [BX+48h], EAX - Mov [SI+48h], EAX - - Mov AX, 99 - Call Music_ReleaseSample - - Ret - -EndP I_SwapMemoryAllocation - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_RepositionSample - - - Push AX - Push BX - Push ECX - Push ESI - - Call PE_GetLastInstrument - Mov AX, BX ; AX = sample no. - Inc AX - Xor CX, CX - Call Music_GetSampleLocation ; Return DS:ESI, ECX - - Pop ESI - Int 3 - - Pop ECX - Pop BX - Pop AX - Ret - -EndP I_RepositionSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ToggleSampleQuality Far - - EnsureNoNetwork - - Call I_GetSampleOffset - Mov AL, [BX+12h] - Test AL, 1 - JZ I_ToggleSampleQuality1 - - Test AL, 2 - JZ I_To16Bit - -I_To8Bit: - Push DS - Push BX - - Mov DI, Offset O1_ConfirmConvert2List - Mov CX, 3 - Call M_Object1List - - Pop BX - Pop DS - - And DX, DX - JZ I_ToggleSampleQuality1 - - Call Music_Stop - - Cmp DX, 1 - JE I_ConvertTo8Bit - - And Byte Ptr [BX+12h], Not 2 - - ShL DWord Ptr [BX+30h], 1 - ShL DWord Ptr [BX+34h], 1 - ShL DWord Ptr [BX+38h], 1 - ShL DWord Ptr [BX+40h], 1 - ShL DWord Ptr [BX+44h], 1 - - Jmp I_ToggleSampleQualityEnd - -I_ConvertTo8Bit: - Mov EDX, [BX+30h] - Mov AX, 99 ; Shove it into inst 99 first. - Call Music_AllocateSample - - Mov AX, ES - And AX, AX - JZ I_OutOfMemory - - And Byte Ptr [BX+12h], Not 2 - - Call PE_GetLastInstrument - Mov AX, BX ; AX = sample no. - Inc AX - - Xor CX, CX - Call Music_GetSampleLocation ; Return DS:ESI - - Mov AX, DiskData - Mov ES, AX - Assume ES:Nothing - - Xor EDI, EDI - -I_ConvertTo8Bit1: - Mov AX, [SI] -; Add AX, 80h -; SBB AH, 0 - Mov [ES:DI], AH - - Add SI, 2 - JC I_ConvertTo8Bit2 - -I_ConvertTo8Bit3: - Add DI, 1 - JC I_ConvertTo8Bit5 - -I_ConvertTo8Bit4: - LoopD I_ConvertTo8Bit1 - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - - Mov ESI, EDI - Int 3 - - Mov CX, DI - - Push DS - Push ES - Pop DS - Pop ES - - Xor SI, SI - Xor DI, DI - Rep MovsB - - ; Now to release old memory, and swap - ; in new lot... - Call I_SwapMemoryAllocation - - Jmp I_ToggleSampleQualityEnd - -I_ConvertTo8Bit2: - Add ESI, 10000h - Int 3 - Jmp I_ConvertTo8Bit3 - -I_ConvertTo8Bit5: - PushAD - Push DS - Push ES - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - - Mov ESI, EDI - Int 3 - - Push DS - Push ES - - Pop DS - Pop ES - - Xor SI, SI - Xor DI, DI - Mov CX, 16384 - Rep MovsD - - Pop ES - Pop DS - PopAD - - Call I_RepositionSample - - Add EDI, 10000h - Jmp I_ConvertTo8Bit4 - -I_OutOfMemory: - Call PEFunction_OutOfMemoryMessage - Jmp I_ToggleSampleQuality1 - -I_To16Bit: - Push DS - Push BX - - Mov DI, Offset O1_ConfirmConvert2List - Mov CX, 3 - Call M_Object1List - - Pop BX - Pop DS - - And DX, DX - JZ I_ToggleSampleQuality1 - - Call Music_Stop - - Cmp DX, 1 - JE I_ConvertTo16Bit - - Or Byte Ptr [BX+12h], 2 - - ShR DWord Ptr [BX+30h], 1 - ShR DWord Ptr [BX+34h], 1 - ShR DWord Ptr [BX+38h], 1 - ShR DWord Ptr [BX+40h], 1 - ShR DWord Ptr [BX+44h], 1 - - Jmp I_ToggleSampleQualityEnd - -I_ConvertTo16Bit: - Mov EDX, [BX+30h] - Add EDX, EDX - Mov AX, 99 ; Shove it into inst 99 first. - Call Music_AllocateSample - - Mov AX, ES - And AX, AX - JZ I_OutOfMemory - - Or Byte Ptr [BX+12h], 2 - - Mov ECX, [BX+30h] - Xor ESI, ESI - Call I_RepositionSample - - Mov AX, DiskData - Mov ES, AX - Assume ES:Nothing - - Xor EDI, EDI - -I_ConvertTo16Bit1: - Mov AH, [SI] - Xor AL, AL - Mov [ES:DI], AX - - Add SI, 1 - JC I_ConvertTo16Bit2 - -I_ConvertTo16Bit3: - Add DI, 2 - JC I_ConvertTo16Bit5 - -I_ConvertTo16Bit4: - LoopD I_ConvertTo16Bit1 - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - - Mov ESI, EDI - Int 3 - - Mov CX, DI - - Push DS - Push ES - Pop DS - Pop ES - - Xor SI, SI - Xor DI, DI - Rep MovsB - - Call I_SwapMemoryAllocation - - Jmp I_ToggleSampleQualityEnd - -I_ConvertTo16Bit2: - Add ESI, 10000h - Int 3 - Jmp I_ConvertTo16Bit3 - -I_ConvertTo16Bit5: - PushAD - Push DS - Push ES - - Mov AX, 100 - Xor CX, CX - Call Music_GetSampleLocation - - Mov ESI, EDI - Int 3 - - Push DS - Push ES - - Pop DS - Pop ES - - Xor SI, SI - Xor DI, DI - Mov CX, 16384 - Rep MovsD - - Pop ES - Pop DS - PopAD - - Call I_RepositionSample - - Add EDI, 10000h - Jmp I_ConvertTo16Bit4 - -I_ToggleSampleQualityEnd: - Call I_DrawWaveForm - Call Music_SoundCardLoadAllSamples - -I_ToggleSampleQuality1: - Mov AX, 1 - Ret - -EndP I_ToggleSampleQuality - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DrawInstrumentWindow Far - - Call S_GetDestination - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - Test AL, AL - JNZ I_DrawInstrumentWindow1 - - Inc AX - Mov LastInstrument, AL - -I_DrawInstrumentWindow1: ; AL = last instrument - Xor AH, AH ; Now for bounds check. - - Push CS - Pop DS - Assume DS:Inst - - Mov BX, TopInstrument - Cmp AX, BX - JAE I_DrawInstrumentWindow2 - - Mov BX, AX - -I_DrawInstrumentWindow2: - Mov CX, BX - Add CX, 34 - Cmp CX, AX - JAE I_DrawInstrumentWindow3 - - Mov BX, AX - Sub BX, 34 - -I_DrawInstrumentWindow3: - Mov TopInstrument, BX ; OK.. now to draw nums - Push AX - - Mov DI, (2+13*80)*2 - - Mov DX, 0A23h - -I_DrawInstrumentWindow4: - Mov AX, BX - Div DH - ; AH = units, AL = tens - Add AL, '0' - StosB - Mov AL, 20h - StosB - XChg AH, AL - Add AL, '0' - StosW - - Inc BX - Add DI, 156 - Dec DL - JNE I_DrawInstrumentWindow4 - - Mov BX, TopInstrument - - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - Mov DX, 35 - Mov DI, (5+13*80)*2 - Dec BX - Mov SI, BX - Add SI, SI - Mov SI, [SI+64712] - Add SI, 20h - - Pop CX ; CX = last instrument - Dec CX - -I_DrawInstrumentWindow5: - Push CX - - Mov AH, 6 - Cmp BX, CX - JNE I_DrawInstrumentWindow7 - - Mov AH, 0E6h - -I_DrawInstrumentWindow7: - Mov CX, 25 - -I_DrawInstrumentWindow6: - LodsB - - Cmp AL, 226 - JB I_DrawInstrumentNoMouse - - Mov AL, ' ' - -I_DrawInstrumentNoMouse: - StosW - Loop I_DrawInstrumentWindow6 - - Add DI, 160-(25*2) - Add SI, 554-25 - Pop CX - - Inc BX - Dec DX - JNZ I_DrawInstrumentWindow5 - - Push CS - Pop DS - - Mov SI,Offset SampleMouseEvent - Mov Word Ptr [SI+4], 30*8-1 - Mov Word Ptr [SI+10], 4 - Call AddSelectEvent - Mov SI, Offset SampleMouseOffEvent - Mov Word Ptr [SI+4], 30*8-1 - Call MouseAddEvent - - Ret - -EndP I_DrawInstrumentWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PreInstrumentWindow Far - - Call S_GetDestination - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, LastInstrument - Xor AH, AH - Mov SI, AX - Sub AX, TopInstrument - Add AX, 13 - Mov BX, 160 - Mul BX - Add AX, 11 - Mov DI, AX - Cmp InstrumentEdit, 1 - JE I_PreInstrumentWindow2 - - Mov CX, 25 - -I_PreInstrumentWindow1: - Mov Byte Ptr [ES:DI], 30h -; Add DI, 2 - ScasW - - Loop I_PreInstrumentWindow1 - Ret - -I_PreInstrumentWindow2: - Mov AX, CS:InstrumentPos - Add AX, AX - Add DI, AX - Mov Byte Ptr [ES:DI], 30h - - Ret - -EndP I_PreInstrumentWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_AllocateChannel Far ; Given AX = Base channel, DL = note - ; Finds physical channel, returns AX - ; if no channel available, then - ; overtakes channel at base channel - ; Given DI = max channel - Push BX CX DX SI DS - - Push DX - - Push CS - Pop DS - Assume DS:Inst - - Mov DX, AX - Mov BX, AX - -MIDI_AllocateChannel1: - Inc DX - Cmp DX, DI - JA MIDI_AllocateChannelOvertake - - Mov SI, Offset MIDITable - Mov CX, 128 - -MIDI_AllocateChannel2: - LodsB - Cmp AL, DL - JE MIDI_AllocateChannel1 - Loop MIDI_AllocateChannel2 - - Mov AX, DX - Jmp MIDI_AllocateChannelEnd - -MIDI_AllocateChannelOvertake: ; Search for basechannel - Mov SI, Offset MIDITable - -MIDI_AllocateChannel3: - LodsB - Cmp AL, DL - JNE MIDI_AllocateChannel3 - - ; Clear out last entry... - Mov Byte Ptr [SI-1], 0 - Mov AX, BX - Inc AX - -MIDI_AllocateChannelEnd: - Pop BX ; BL = note - And BX, 07Fh - Mov [MIDITable+BX], AL - - Dec AX - - Pop DS SI DX CX BX - Ret - -EndP MIDI_AllocateChannel - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_GetChannel Far - - Xor AX, AX - Mov AL, [CS:MIDITable+BX] - Ret - -EndP MIDI_GetChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_FindChannel Far ; Given BX = Note, returns AX = channel - ; number, cleans up table, AL = 0FFh = - ; note not present - - Xor AX, AX - XChg [CS:MIDITable+BX], AL - Dec AL - - Ret - -EndP MIDI_FindChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_ClearTable Far - - Push AX CX ES DI - - Push CS - Pop ES - - Mov DI, Offset MIDITable - Xor AX, AX - Mov CX, 64 - Rep StosW - - Pop DI ES CX AX - - Ret - -EndP MIDI_ClearTable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_NoteOff Far - - Push CS - Pop DS - Assume DS:Inst - - ; DL = note -MIDI_NoteOff2: - Call Music_GetInstrumentMode - Mov CX, 0FFh - JNZ MIDI_NoteOff3 - - Dec CX - -MIDI_NoteOff3: - MovZX BX, DL - Call MIDI_FindChannel - Cmp AL, 0FFh - JE MIDI_NoteOff1 - - Mov SI, Offset NoteData - Mov Word Ptr [SI], CX ; Note off/cut - Mov Word Ptr [SI+3], 0 ; No effect - Mov DH, 32 - Call Music_PlayNote - -MIDI_NoteOff1: - Mov AX, 1 -; Xor AX, AX - Ret - -EndP MIDI_NoteOff - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_PlayNote Far - - Push CS - Pop DS - Assume DS:Inst - - Call PE_TranslateMIDI - JC MIDI_PlayNote1 - JZ MIDI_NoteOff2 - - Call PE_GetLastInstrument - Mov AH, BL - Inc AH - Mov AL, DL ; Note - - Mov SI, Offset NoteData - Mov [SI], AX - Mov [SI+2], DH - Mov Word Ptr [SI+3], 0 - - Call Music_GetNumChannels ; Into AX - Mov DI, AX - Mov AX, PlayChannel - Call PE_RestoreMIDINote - Call MIDI_AllocateChannel - - Mov DH, 32 - Call Music_PlayNote - - Mov Byte Ptr [SI+2], 0FFh - Mov AX, 1 - Ret - -MIDI_PlayNote1: - Xor AX, AX - Ret - - -EndP MIDI_PlayNote - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PlayNote Far - - Push CS - Pop DS - Assume DS:Inst - - Test CH, Not 1 - JNZ I_PlayNote5 - - Cmp CX, LastKey - JE I_PlayNote5 - - Mov LastKey, CX - - Mov SI, Offset KeyBoardTable - -I_PlayNote1: - LodsW - Cmp AX, 0FFFFh - JE I_PlayNote5 - - Mov BX, AX - LodsW - - Cmp BL, CL - JNE I_PlayNote1 - ; Note to play... - ; AX = notemod. - Mov CL, AL - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, 12 - Mul BaseOctave - Add AL, CL - Cmp AL, 119 - JBE I_PlayNoteMax - - Mov AL, 119 - -I_PlayNoteMax: - Mov DL, AL - - Test CH, CH - JZ MIDI_NoteOff - - Call PE_GetLastInstrument - Mov AH, BL - Inc AH - - Push CS - Pop DS - - MovZX BX, AL - Cmp [MIDITable+BX], 0 - JNE I_PlayNote6 - - Call UpdateMultiChannel - - Mov PlayNote, AL - -I_PlayNote3: - Mov SI, Offset NoteData - Mov [SI], AX - - Push DS - - Call I_GetInstrumentOffset - - Test Byte Ptr [BX+19h], 80h - Mov DH, 32 - JZ I_PlayNote4 - - Add DH, 128 - -I_PlayNote4: - Pop DS - Call Music_GetNumChannels ; Into AX - Mov DI, AX - Mov AX, PlayChannel - Call MIDI_AllocateChannel - Call Music_PlayNote - -I_PlayNote6: - Mov AX, 1 - Ret - -I_PlayNote5: - Xor AX, AX - Ret - -EndP I_PlayNote - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PostInstrumentWindow Far - Assume DS:Inst - - Push CS - Pop DS - Mov SI, Offset InstrumentListKeys - Call M_FunctionDivider - JC I_PostInstrumentWindow1 - - Jmp [SI] - -I_PostInstrumentWindow1: - Cmp InstrumentEdit, 0 - JE I_PostInstrumentWindow7 - - Cmp CX, 101h - JE I_PostInstrumentWindow15 - Cmp CX, 11Ch - JNE I_PostInstrumentWindow13 - -I_PostInstrumentWindow15: - Mov InstrumentEdit, 0 - Jmp I_PostInstrumentWindow12 - -I_PostInstrumentWindow13: - Call PE_GetLastInstrument - Mov SI, BX - Mov BX, InstrumentPos - ; BX = Pos, SI = LastInst - Call Music_GetSongSegment - Mov DS, AX - Assume DS:Nothing - - Add SI, SI - Mov SI, [64712+SI] ; SI = instrument offset. - - Test CL, CL - JZ I_PostInstrumentWindow3 - Cmp DL, 32 - JB I_PostInstrumentWindow3 - - Add BX, 20h - Add BX, SI - Add SI, 38h - -I_PostInstrumentWindow2: - Cmp SI, BX - JBE I_PIW2 - - Mov AL, [SI-1] - Mov [SI], AL - Dec SI - Jmp I_PostInstrumentWindow2 - -I_PIW2: - - Mov [SI], DL - NetworkSendInstrument - - Push CS - Pop DS - Jmp I_InstrumentRight - -I_PostInstrumentWindow3: - Cmp CX, 10Eh ; Backspace - JNE I_PostInstrumentWindow5 - - And BX, BX - JZ I_PostInstrumentWindow6 - - Dec InstrumentPos - Add BX, 20h - Add BX, SI - Add SI, 39h - -I_PostInstrumentWindow4: - Mov AL, [BX] - Mov [BX-1], AL - Inc BX - Cmp BX, SI - JB I_PostInstrumentWindow4 - - Mov Byte Ptr [BX-1], 0 - NetworkSendInstrument - -I_PostInstrumentWindow12: - - Mov AX, 1 - Ret - -I_PostInstrumentWindow5: - Assume DS:Inst - - Cmp CX, 1D3h ; Delete... - JNE I_PostInstrumentWindow6 - - Add BX, 21h - Add BX, SI - Add SI, 39h - Jmp I_PostInstrumentWindow4 - -I_PostInstrumentWindow6: - Xor AX, AX - Ret - -I_PostInstrumentWindow7: - Assume DS:Inst - Cmp DX, ' ' ; Spacebar - JNE I_PostInstrumentWindow14 - - Mov InstrumentEdit, 1 - Mov InstrumentPos, 0 - - Mov AX, 1 - Ret - -I_PostInstrumentWindow14: - Xor AX, AX - Ret - -EndP I_PostInstrumentWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentLeft Far - - Assume DS:Inst - - Cmp InstrumentEdit, 0 - JE I_InstrumentLeft2 - - Cmp InstrumentPos, 0 - JE I_InstrumentLeft1 - - Dec InstrumentPos -; Jmp I_InstrumentLeft1 - -I_InstrumentLeft2: -; Mov Word Ptr [ES:DI], 8 - -I_InstrumentLeft1: - Mov AX, 1 - Ret - -EndP I_InstrumentLeft - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentRight Far - - Assume DS:Inst - - Cmp InstrumentEdit, 0 - JE I_InstrumentRight2 - - Cmp InstrumentPos, 24 - JAE I_InstrumentRight1 - - Inc InstrumentPos - Jmp I_InstrumentRight1 - -I_InstrumentRight2: - Mov Word Ptr [ES:DI], 5 - -I_InstrumentRight1: - Mov AX, 1 - Ret - - -EndP I_InstrumentRight - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentHome Far - - Assume DS:Inst - - Mov InstrumentPos, 0 - - Mov AX, 1 - Ret - -EndP I_InstrumentHome - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentEnd Far - - Assume DS:Inst - - Mov InstrumentPos, 24 - - Mov AX, 1 - Ret - -EndP I_InstrumentEnd - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentTab Far - - Mov Word Ptr [ES:DI], 5 - - Mov AX, 1 - Ret - -EndP I_InstrumentTab - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentShiftTab Far - - Mov Word Ptr [ES:DI], 8 - - Mov AX, 1 - Ret - -EndP I_InstrumentShiftTab - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentNameClear Far - - Call I_GetInstrumentOffset - Push DS - Pop ES - Mov DI, BX - - Xor AX, AX - Mov CX, 6 - Add DI, 4 - Rep StosW - - Add DI, 10h - Mov CX, 13 - Rep StosW - - NetworkSendInstrument - - Inc AX - Ret - -EndP I_InstrumentNameClear - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentClear Far - - Call PE_GetLastInstrument - Mov AX, BX - Call Music_ClearInstrument - - Call I_MapEnvelope - - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_InstrumentClear - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DrawNoteWindow Far - - Push CS - Pop DS - Assume DS:Inst - - Mov SI, Offset NoteMouseEvent - Call AddSelectEvent - Mov SI, Offset NoteMouseOffEvent - Call MouseAddEvent - - Mov AX, CurrentNote - ; Now for bounds check. - - Mov BX, TopNote - Cmp AX, BX - JAE I_DrawNoteWindow2 - - Mov BX, AX - -I_DrawNoteWindow2: - Mov CX, BX - Add CX, 31 - Cmp CX, AX - JAE I_DrawNoteWindow3 - - Mov BX, AX - Sub BX, 31 - -I_DrawNoteWindow3: - Mov TopNote, BX ; OK.. now to draw nums - Mov CX, BX - - Call S_GetDestination - - Call I_GetInstrumentOffset - Add BX, 40h - Add BX, CX - Add BX, CX - Mov DI, (32+16*80)*2 - - Mov DX, 0C20h - XChg SI, BX - ; DS:SI = pointer to translation - ; ES:DI = screen - ; CX = Current note. -I_DrawNoteWindow4: - ; Draw left hand note first. - Mov AX, CX - Div DH ; AH = note, AL = octave. - Push AX - - Mov AL, AH - Mov BX, AX - And BX, 0FFh ; BX = note. - Add BX, BX ; BX = note*2 - Mov AH, 2 - Mov AL, [CS:BX+NoteTable] - StosW - Mov AL, [CS:BX+NoteTable+1] - StosW - - Pop AX ; AL = octave - Add AL, '0' - Mov AH, 2 - StosW - - ; View division... - Mov AL, 0A8h - StosW - ; Note translation... - - LodsB ; AL = note.. - Xor AH, AH - Div DH - Push AX - - Mov AL, AH - Mov BX, AX - And BX, 0FFh ; BX = note. - Add BX, BX ; BX = note*2 - Mov AH, 2 - Mov AL, [CS:BX+NoteTable] - StosW - Mov AL, [CS:BX+NoteTable+1] - StosW - - Pop AX ; AL = octave - Add AL, '0' - Mov AH, 2 - StosW - - Mov AL, ' ' - StosW - ; Now sample number. - LodsB ; AL = sample number (base 0) -; Inc AL ; Convert to base 1 - - And AL, AL - JNZ I_DrawNoteWindow5 - - Mov AL, 173 - StosW - StosW - Jmp I_DrawNoteWindow6 - -I_DrawNoteWindow5: - Xor AH, AH - Mov BL, 10 - Div BL ; AH = units, AL = tens. - Add AX, 3030h - Mov BL, AH - Mov AH, 2 - StosW - Mov AL, BL - StosW - -I_DrawNoteWindow6: - Add DI, 160-10*2 - - Inc CX - Dec DL - JNZ I_DrawNoteWindow4 - - Ret - -EndP I_DrawNoteWindow - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PreNoteWindow Far - - Push CS - Pop DS - Assume DS:Inst - - Call S_GetDestination - Mov AX, CurrentNote - Sub AX, TopNote - Add AX, 16 - Mov BX, 160 - Mul BX - Add AX, 32*2 - Mov DI, AX ; First hilight the row.. - - Mov CX, 10 - Push DI - -I_PreNoteWindow1: - Inc DI - Or Byte Ptr [ES:DI], 0E0h - Inc DI - Loop I_PreNoteWindow1 - - Pop DI - - Mov BX, NotePos - Mov BL, [NotePosTable+BX] - Xor BH, BH - Add DI, BX - Add DI, BX - - Inc DI - Mov Byte Ptr [ES:DI], 30h - - Ret - -EndP I_PreNoteWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PostNoteWindow Far - - Push CS - Pop DS - Assume DS:Inst - - Mov SI, Offset NoteListKeys - Call M_FunctionDivider - JC I_PostNoteWindow1 - - Jmp [SI] - -I_PostNoteWindow1: - Cmp NotePos, 0 - JNE I_PostNoteWindow5 - - Mov SI, Offset KeyBoardTable - -I_PostNoteWindow2: - LodsW - Cmp AX, 0FFFFh - JE I_PostNoteWindow3 - - Mov BX, AX - LodsW - - Cmp BX, CX - JNE I_PostNoteWindow2 - ; Note to play... - ; AX = notemod. - Mov CX, AX - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AL, 12 - Mul BaseOctave - - Push CS - Pop DS - Assume DS:Inst - Mov SI, CurrentNote - Add SI, SI - - Add CX, AX - Cmp CX, 119 - JA I_PostNoteWindow4 ; If note > B-9... not valid! - - Mov CH, SampleNumber - - Call I_GetInstrumentOffset - Mov [DS:BX+SI+40h], CX - - Push CS - Pop DS - - Mov SI, Offset NoteData - Call PE_GetLastInstrument - Mov AH, BL - Inc AH - Mov AL, Byte Ptr CurrentNote - Mov [SI], AX - - Mov AX, PlayChannel - Mov DH, 32+128 - Call Music_PlayNote - - NetworkSendInstrument - Jmp I_NoteDown - -I_PostNoteWindow4: - Mov AX, 1 - Ret - -I_PostNoteWindow3: - Xor AX, AX - Ret - -I_PostNoteWindow5: - Cmp DL, '0' - JB I_PostNoteWindow6 - Cmp DL, '9' - JA I_PostNoteWindow6 - - Sub DL, '0' - - Mov SI, CurrentNote - Add SI, SI - - Call I_GetInstrumentOffset - Assume DS:Nothing - ; DS:BX points to inst. - Add BX, 40h - - Mov AX, NotePos - Cmp AL, 1 - JE I_PostNoteWindow7 - - Inc BX - - Cmp AL, 2 - JE I_PostNoteWindow8 - - Cmp AL, 3 - JE I_PostNoteWindow9 - -I_PostNoteWindow6: - Cmp DX, '.' - JNE I_PostNoteWindow10 - Cmp NotePos, 2 - JB I_PostNoteWindow10 - - Mov SI, CurrentNote - Add SI, SI - - Call I_GetInstrumentOffset - Assume DS:Nothing - Add BX, SI - Add BX, 41h - Mov Byte Ptr [BX], 0 - - NetworkSendInstrument - Jmp I_NoteDown - -I_PostNoteWindow10: - Xor AX, AX - Ret - -I_PostNoteWindow7: ; Octave of note. - Mov AL, [DS:BX+SI] ; AL = Note - Xor AH, AH - Mov CL, 0Ch - Div CL ; AL = octave, AH = Note - - Mov AL, DL - Mov CH, AH - Mul CL - Add AL, CH ; AL = new note - - Mov [DS:BX+SI], AL - - NetworkSendInstrument - Jmp I_NoteDown - -I_PostNoteWindow8: - Mov AL, [DS:BX+SI] ; AL = sample. - Xor AH, AH - Mov CL, 10 - Div CL ; AL = tens, AH = units - - Mov AL, DL - Mov CH, AH - Mul CL - Add AL, CH - - Mov SampleNumber, AL - Mov [DS:BX+SI], AL - - NetworkSendInstrument - Jmp I_NoteRight - -I_PostNoteWindow9: - Mov AL, [DS:BX+SI] - Xor AH, AH - Mov CL, 10 - Div CL - - Mov CH, AH - Mul CL - - Add AL, DL - - Mov SampleNumber, AL - Mov [DS:BX+SI], AL - - Mov NotePos, 2 - -I_PostNoteWindowEnd: - NetworkSendInstrument - Jmp I_NoteDown - -EndP I_PostNoteWindow - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SelectNoteMouse Far - Assume DS:Inst - - ShR DX, 3 - Add DX, TopNote - Sub DX, 16 - JNC I_SelectNoteMouse1 - - Xor DX, DX - -I_SelectNoteMouse1: - Cmp DX, 119 - JB I_SelectNoteMouse2 - - Mov DX, 119 - -I_SelectNoteMouse2: - Mov CurrentNote, DX - - Mov AX, 1 - Ret - -EndP I_SelectNoteMouse - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteUp Far - - Assume DS:Inst - - Mov AX, CurrentNote - Dec AX - JS I_NoteUp2 - - Mov CurrentNote, AX - Jmp I_NoteUp1 - -I_NoteUp2: - Mov Word Ptr [ES:DI], 5 - -I_NoteUp1: - Mov AX, 1 - Ret - -EndP I_NoteUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteDown Far - - Push CS - Pop DS - Assume DS:Inst - - Mov AX, CurrentNote - Inc AX - Cmp AX, 119 - JA I_NoteDown1 - - Mov CurrentNote, AX - -I_NoteDown1: - Mov AX, 1 - Ret - -EndP I_NoteDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NotePgUp Far - - Assume DS:Inst - - Mov AX, CurrentNote - Sub AX, 12 - JNS I_NotePgUp1 - - Xor AX, AX - -I_NotePgUp1: - Mov CurrentNote, AX - - Mov AX, 1 - Ret - -EndP I_NotePgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NotePgDn Far - - Assume DS:Inst - - Mov AX, CurrentNote - Add AX, 12 - Cmp AX, 119 - JBE I_NotePgDn1 - - Mov AX, 119 - -I_NotePgDn1: - Mov CurrentNote, AX - - Mov AX, 1 - Ret - -EndP I_NotePgDn - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteRight Far - - Push CS - Pop DS - Assume DS:Inst - - Mov AX, NotePos - Inc AX - Cmp AX, 4 - JB I_NoteRight1 - - Mov AX, 3 - -I_NoteRight1: - Mov NotePos, AX - - Mov AX, 1 - Ret - -EndP I_NoteRight - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteLeft Far - - Assume DS:Inst - Mov AX, NotePos - Dec AX - JS I_NoteLeft1 - - Mov NotePos, AX - -I_NoteLeft1: - Mov AX, 1 - Ret - -EndP I_NoteLeft - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteHome Far - Assume DS:Inst - - Mov CurrentNote, 0 - - Mov AX, 1 - Ret - -EndP I_NoteHome - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteEnd Far - Assume DS:Inst - - Mov CurrentNote, 119 - - Mov AX, 1 - Ret - -EndP I_NoteEnd - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteTab Far - - Mov Word Ptr [ES:DI], 16 - - Mov AX, 1 - Ret - -EndP I_NoteTab - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteShiftTab Far - - Mov Word Ptr [ES:DI], 4 - - Mov AX, 1 - Ret - -EndP I_NoteShiftTab - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteSampleIncrease Far - - Assume DS:Inst - - Mov AL, SampleNumber - Inc AX - Cmp AL, 99 - JA I_NoteSampleIncrease1 - - Mov SampleNumber, AL - -I_NoteSampleIncrease1: - Mov AX, 1 - Ret - -EndP I_NoteSampleIncrease - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteSampleDecrease Far - - Assume DS:Inst - - Mov AL, SampleNumber - Dec AL - JS I_NoteSampleDecrease1 - - Mov SampleNumber, AL - -I_NoteSampleDecrease1: - Mov AX, 1 - Ret - -EndP I_NoteSampleDecrease - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteSamplePickUp Far - - Assume DS:Nothing - - Call I_GetInstrumentOffset - - Mov SI, CurrentNote - Mov AX, SI - Mov PlayNote, AL - Add SI, SI - - Mov AX, [DS:BX+SI+40h] - - Mov SampleNumber, AH - - Mov AX, 1 - Ret - -EndP I_NoteSamplePickUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteNext Far - Assume DS:Inst - - Mov SI, CurrentNote - Add SI, SI - JZ I_NoteNext1 - - Call I_GetInstrumentOffset - Assume DS:Nothing - - Add BX, SI - Add BX, 40h - - Mov AX, [DS:BX-2] ; 'Last note.' - Cmp AL, 119 ; Is previous note >= B-9 - JAE I_NoteNext1 - - Inc AX - Mov [DS:BX], AX - - NetworkSendInstrument - Jmp I_NoteDown - -I_NoteNext1: - Mov AX, 1 - Ret - -EndP I_NoteNext - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NotePrevious Far - Assume DS:Inst - - Mov SI, CurrentNote - Cmp SI, 119 - JAE I_NotePrevious1 - - Add SI, SI - - Call I_GetInstrumentOffset - Assume DS:Nothing - - Add BX, SI - Add BX, 40h - - Mov AX, [DS:BX+2] ; 'Last note.' - Test AL, AL - JZ I_NotePrevious1 - - Dec AX - Mov [DS:BX], AX - - Push CS - Pop DS - Assume DS:Inst - - Mov AX, CurrentNote - Dec AX - JS I_NotePrevious1 - - Mov CurrentNote, AX - NetworkSendInstrument - -I_NotePrevious1: - - Mov AX, 1 - Ret - -EndP I_NotePrevious - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteAll Far - - Assume DS:Nothing - - Call I_GetInstrumentOffset - Push DS - Pop ES - - LEA DI, [BX+40h] - - Mov CX, 120 - Mov AH, SampleNumber - Xor AL, AL - - -I_NoteAll1: - StosW - Inc AX - Loop I_NoteAll1 - - Sub DI, 110h - - MovZX BX, SampleNumber - Add BX, BX - JZ I_NoteAll2 - - Mov SI, [BX+64910] - Add SI, 14h - - Mov CX, 26 - Rep MovsB - -I_NoteAll2: - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_NoteAll - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteInsert Far - - Assume DS:Nothing - - Call I_GetInstrumentOffset - Push DS - Pop ES - LEA DI, [BX+40h+120*2-2] - LEA SI, [DI-2] - Mov CX, 119 - - StD - Rep MovsW - Xor AX, AX - StosW - ClD - - NetworkSendInstrument - Mov AX, 1 - Ret - -EndP I_NoteInsert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteDelete Far - - Assume DS:Nothing - - Call I_GetInstrumentOffset - Push DS - Pop ES - LEA DI, [BX+40h] - LEA SI, [DI+2] - Mov CX, 119 - - Rep MovsW - Xor AX, AX - StosW - - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_NoteDelete - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteTransposeUp Far - - Assume DS:Nothing - - Call I_GetInstrumentOffset - Push DS - Pop ES - - LEA DI, [BX+40h] - - Mov CX, 120 - -I_NoteTransposeUp1: - Mov AL, [DI] - Inc AX - Cmp AL, 119 - JBE I_NoteTransposeUp2 - - Mov AL, 119 - -I_NoteTransposeUp2: - StosB - Inc DI - Loop I_NoteTransposeUp1 - - NetworkSendInstrument - Mov AX, 1 - Ret - -EndP I_NoteTransposeUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteTransposeDown Far - - Assume DS:Nothing - - Call I_GetInstrumentOffset - Push DS - Pop ES - - LEA DI, [BX+40h] - - Mov CX, 120 - -I_NoteTransposeDown1: - Mov AL, [DI] - Sub AL, 1 - AdC AL, 0 - StosB - Inc DI - Loop I_NoteTransposeDown1 - - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_NoteTransposeDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_NoteSpace Far - - Assume DS:Inst - Cmp NotePos, 2 - JB I_NoteSpace1 - - Mov SI, CurrentNote - Add SI, SI - - Call I_GetInstrumentOffset - Assume DS:Nothing - Mov AL, SampleNumber - Mov [BX+SI+41h], AL - - Jmp I_NoteDown - -I_NoteSpace1: - NetworkSendInstrument - Xor AX, AX - Ret - -EndP I_NoteSpace - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ExchangeInstruments Far - - EnsureNoNetwork - - Mov DI, Offset O1_ExchangeInstrumentList - Call GetNumberInput - - Mov SI, DX - Dec SI - Add SI, SI - - Call PE_GetLastInstrument - Add BX, BX - - Cmp SI, BX - JE I_ExchangeInstruments1 - - Call Music_GetSongSegment - Mov ES, AX - Mov DS, AX - Mov DI, [DS:64712+BX] - Mov SI, [DS:64712+SI] ; DS:SI, ES:DI point to - ; sample headers - - Mov CX, 554 - -I_ExchangeInstruments2: - Mov AL, [ES:DI] - MovsB - Mov [DS:SI-1], AL - - Loop I_ExchangeInstruments2 - - Call I_MapEnvelope - -I_ExchangeInstruments1: - Mov AX, 1 - Ret - -EndP I_ExchangeInstruments - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DoubleSampleSpeed Far - - Call I_GetSampleOffset - Mov EAX, [BX+3Ch] - ShL EAX, 1 - Cmp EAX, 9999999 - JA I_DoubleSampleSpeed1 - - Mov [BX+3Ch], EAX - -I_DoubleSampleSpeed1: - NetworkSendSample - - Mov AX, 1 - Ret - -EndP I_DoubleSampleSpeed - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_HalveSampleSpeed Far - - Call I_GetSampleOffset - ShR DWord Ptr [BX+3Ch], 1 - - NetworkSendSample - - Mov AX, 1 - Ret - -EndP I_HalveSampleSpeed - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleSpeedSemiUp Far - - Call I_GetSampleOffset - - Mov EAX, 255392045 - Mul DWord Ptr [BX+3Ch] - - Add EDX, [BX+3Ch] - JC I_SampleSpeedSemiUp1 - - Mov [BX+3Ch], EDX - -I_SampleSpeedSemiUp1: - NetworkSendSample - - Mov AX, 1 - Ret - -EndP I_SampleSpeedSemiUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleSpeedSemiDown Far - - Call I_GetSampleOffset - - Mov EAX, 4053909306 - Mul DWord Ptr [BX+3Ch] - Mov [BX+3Ch], EDX - - NetworkSendSample - - Mov AX, 1 - Ret - -EndP I_SampleSpeedSemiDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ReplaceInstrument Far - - EnsureNoNetwork - - Mov DI, Offset O1_ReplaceInstrumentList - Call GetNumberInput - - Call PE_GetLastInstrument - Mov DH, BL - Inc DH ; DH/DL = samples to swap - - Cmp DL, DH - JE I_ReplaceInstrument1 - - Call Music_GetInstrumentMode - JZ I_ReplaceInstrument1 - - XChg DH, DL - Or DH, 80h - Call PE_SwapInstruments - -I_ReplaceInstrument1: - Mov AX, 1 - Ret - -EndP I_ReplaceInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ScaleSampleVolumes Far - - EnsureNoNetwork - - Mov DI, Offset O1_GetInstrumentAmpList - Mov CX, 3 - Call M_Object1List - - Cmp DX, 1 - JNE I_ScaleSampleVolumesEnd - - Mov BP, CS:InstrumentAmplification - Mov BX, 100 - - Call Music_GetSongSegment - Mov DS, AX - Mov SI, 64912 - Mov CX, 99 - -I_ScaleSampleVolumes1: - Xor AX, AX - Mov DI, [SI] - Mov AL, [DI+11h] - Mul BP - Div BX - Cmp AX, 64 - JB I_ScaleSampleVolumes2 - - Mov AX, 64 - -I_ScaleSampleVolumes2: - Mov [DI+11h], AL - - Add SI, 2 - Dec CX - JNZ I_ScaleSampleVolumes1 - -I_ScaleSampleVolumesEnd: - Mov AX, 1 - Ret - -EndP I_ScaleSampleVolumes - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ScaleInstrumentVolumes Far - - EnsureNoNetwork - - Mov DI, Offset O1_GetInstrumentAmpList - Mov CX, 3 - Call M_Object1List - - Cmp DX, 1 - JNE I_ScaleInstrumentVolumesEnd - - Mov BP, CS:InstrumentAmplification - Mov BX, 100 - - Call Music_GetSongSegment - Mov DS, AX - Mov SI, 64712 - Mov CX, 99 - -I_ScaleInstrumentVolumes1: - Xor AX, AX - Mov DI, [SI] - Mov AL, [DI+18h] - Mul BP - Div BX - Cmp AX, 128 - JB I_ScaleInstrumentVolumes2 - - Mov AX, 128 - -I_ScaleInstrumentVolumes2: - Mov [DI+18h], AL - - Add SI, 2 - Dec CX - JNZ I_ScaleInstrumentVolumes1 - -I_ScaleInstrumentVolumesEnd: - Mov AX, 1 - Ret - -EndP I_ScaleInstrumentVolumes - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_CopyInstrument Far - - Mov DI, Offset O1_CopyInstrumentList - Call GetNumberInput - - Call I_GetInstrumentOffset ; Gets DS:BX with cur inst. - - Mov DI, BX - Mov SI, DX - Add SI, SI - Mov SI, [64710+SI] - - Push DS - Pop ES - - Mov CX, 554/2 - Rep MovsW - - Call I_MapEnvelope - - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_CopyInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SwapInstruments Far - - EnsureNoNetwork - - Mov DI, Offset O1_SwapInstrumentList - Call GetNumberInput - - Mov SI, DX -; Dec SI - Add SI, SI - - Call PE_GetLastInstrument - Mov DH, BL - Inc DH ; DH/DL = samples to swap - Add BX, BX - - Cmp DL, DH - JE I_SwapInstruments1 - - Call Music_GetSongSegment - Mov ES, AX - Mov DS, AX - Mov DI, [DS:64712+BX] - Mov SI, [DS:64710+SI] ; DS:SI, ES:DI point to - ; sample headers - - Mov CX, 554 - -I_SwapInstruments2: - Mov AL, [ES:DI] ; Swapping headers. - MovsB - Mov [DS:SI-1], AL - - Loop I_SwapInstruments2 - - ; Now to swap pattern - ; stuff... - Call Music_GetInstrumentMode - JZ I_SwapInstruments3 - - Call PE_SwapInstruments - -I_SwapInstruments3: - Call I_MapEnvelope - -I_SwapInstruments1: - Mov AX, 1 - Ret - -EndP I_SwapInstruments - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_UpdateInstrument Far - - EnsureNoNetwork - - Call PE_GetLastInstrument - Mov DX, BX - Inc DX - Add BX, BX - - Call Music_GetSongSegment - Mov ES, AX - Mov DI, [ES:64712+BX] - Add DI, 40h - - Call PE_UpdateInstruments - - Mov AX, 1 - Ret - -EndP I_UpdateInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseEnvelopeEvent1 Far - - Mov CS:MouseX, CX - Mov CS:MouseY, DX - - Mov CX, 8010h ; Envelope mouse control request.. - Call AddMouseQueue - - Xor AX, AX - Ret - -EndP MouseEnvelopeEvent1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseEnvelopeEvent4 Far ; Delete node - - Test BH, 6 - JNZ MouseEnvelopeEvent4_1 - - Mov CS:MouseX, CX - Mov CS:MouseY, DX - - Mov CX, 8003h ; Envelope mouse control request.. - Call AddMouseQueue - -MouseEnvelopeEvent4_1: - Xor AX, AX - Ret - -EndP MouseEnvelopeEvent4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseEnvelopeEvent2 Far ; Envelope drag - - Mov CS:MouseX, CX - Mov CS:MouseY, DX - - Mov CX, 8001h - Call AddMouseQueue - - Xor AX, AX - Ret - -EndP MouseEnvelopeEvent2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseEnvelopeEvent3 Far ; Release envelope - - Mov CX, 8002h - Call AddMouseQueue - - Xor AX, AX - Ret - -EndP MouseEnvelopeEvent3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawEnvelopeHeader ; AH = colour, DS = inst - Assume DS:Inst - - Mov SI, InstrumentScreen ; 1-3 - Add SI, SI ; 2-6 - Add SI, Word Ptr NodeHeld ; 2-7 - Add SI, SI ; 4-14 - Mov SI, [EnvelopeHeaderTable+SI-4] - Mov DI, (33+16*80)*2 - - Call S_DrawString - - Ret - -EndP DrawEnvelopeHeader - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DrawEnvelope Far - - Push CS - Pop DS - Assume DS:Inst - - Mov AH, 20h - Call DrawEnvelopeHeader - - Call S_GetDestination - Mov DI, (32+18*80)*2 - Mov AX, 0C00h - - Mov DX, 8 - -I_DrawEnvelope1: - Mov CX, 32 - -I_DrawEnvelope2: - StosW - Inc AX - Loop I_DrawEnvelope2 - - Add DI, (80-32)*2 - Dec DX - JNZ I_DrawEnvelope1 - - Call I_GetEnvelopeOffset ; Returns DS:SI - Mov BX, CS:CurrentNode ; to envelope table - Mov CX, BX - - Add BX, BX - Add BX, CX ; BX = CurrentNode*3 - - Mov AL, [SI+BX+6] - CBW ; Value - - Test Byte Ptr [SI], 80h - JZ I_DrawEnvelope5 - - Add AX, 32 - -I_DrawEnvelope5: - Push AX - Push Word Ptr [SI+BX+7] ; Tick - Push CS:MaxNode - Push CX ; Node - - Mov DI, (66+19*80)*2 - Mov AH, 2 - Push CS - Pop DS - Mov SI, Offset EnvelopeMsg - Call S_DrawString - - Add SP, 8 - - Cmp MouseNodeHeld, 0 - JZ I_DrawEnvelope4 - - Call MouseGetStatus - Test AL, 6 - JNZ I_DrawEnvelope3 - - Call I_MouseEnvelopeReleased - Jmp I_DrawEnvelope4 - -I_DrawEnvelope3: - Mov SI, Offset EnvelopeEvent3 - Call MouseAddEvent - Mov SI, Offset EnvelopeEvent2 - Call MouseAddEvent - - Ret - -I_DrawEnvelope4: - Mov SI, Offset EnvelopeEvent1 - Call MouseAddEvent - Mov SI, Offset EnvelopeEvent4 - Call MouseAddEvent - - Ret - -EndP I_DrawEnvelope - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PreEnvelope Far - - Push CS - Pop DS - - Mov AH, 23h - Call DrawEnvelopeHeader - - Ret - -EndP I_PreEnvelope - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PostEnvelope Far - - Push CS - Pop DS - Assume DS:Inst - - Mov SI, Offset VolumeEnvelopeNodeKeys - - Cmp NodeHeld, 1 - JE I_PostEnvelope2 - - Mov SI, Offset VolumeEnvelopeKeys - -I_PostEnvelope2: - Call M_FunctionDivider - JC I_PostEnvelope1 - - Jmp [SI] - -I_PostEnvelope1: -IF ENABLEPRESETENVELOPES - - Cmp DX, '0' - JB I_PostEnvelopeNoPreset - Cmp DX, '9' - JA I_PostEnvelopeNoPreset - - Call I_GetEnvelopeOffset - Push DS - Pop ES - Mov DI, SI ; ES:DI set - - Push CS - Pop DS - Mov AL, 81 - Sub DL, '0' - Mul DL ; AX = offset - Mov SI, AX - Add SI, Offset PresetEnvelopes - - Mov CX, 6/2 - Rep MovsW - Mov CX, 25 - -I_PostEnvelopePreset1: - LodsB - Sub AL, AmplitudeCompensate - StosB - MovsW - Loop I_PostEnvelopePreset1 - - Call I_MapEnvelope - NetworkSendInstrument - - Mov AX, 1 - Ret - -I_PostEnvelopeNoPreset: - Test CH, 60h ; Alt? - JZ I_PostEnvelopeNoSet - Test CH, 1 ; On keypress - JZ I_PostEnvelopeNoSet - - Cmp CL, 2 - JB I_PostEnvelopeNoSet - Cmp CL, 0Bh - JA I_PostEnvelopeNoSet - JNE I_PostEnvelopeSet2 - - Mov CL, 1 - -I_PostEnvelopeSet2: - Mov AX, CX - Dec AX - And AX, 0FFh - Mov SI, Offset EnvelopeSetMsg - Call SetInfoLine - Mov CL, 81 - Mul CL - - Call I_GetEnvelopeOffset ; Gets DS:SI - Push CS - Pop ES - Mov DI, AX - Add DI, Offset PresetEnvelopes ; ES:DI points to dest - - LodsW - And AL, 7Fh - StosW - - Mov CX, 4/2 - Rep MovsW - Mov CX, 25 - -I_PostEnvelopeSet1: - LodsB - Add AL, CS:AmplitudeCompensate - StosB - MovsW - Loop I_PostEnvelopeSet1 - - Call I_MapEnvelope - - Mov AX, 1 - Ret - -I_PostEnvelopeNoSet: -ENDIF ; PRESETENVELOPES - Xor AX, AX - Ret - -EndP I_PostEnvelope - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_MapEnvelope Far - - Push CS - Pop DS - Assume DS:Inst - - Cmp InstrumentScreen, 0 - JNE I_MapEnvelope1 - - Ret - -I_MapEnvelope1: - Mov UpdateInstrumentScreen, 0 - - Push BP - - Call S_GetGenerationTableOffset - Push DI ; ES:DI points to table. - Mov CX, 32*8*8*8/4 - Xor EAX, EAX - Rep StosD - Pop DI - Push DI - - Add DI, 3 - Mov CX, 32 - Inc AX - -I_MapEnvelopeYAxis1: - StosB - Add DI, 511 - Loop I_MapEnvelopeYAxis1 - - Pop DI - Push DI - - Call I_GetEnvelopeOffset ; DS:SI points to envelope - Assume DS:Nothing - - Mov AL, 32 - - Add DI, 31*256 - - Test Byte Ptr [SI], 80h - JNZ I_MapEnvelopeFilterCompensate - Cmp Byte Ptr [CS:InstrumentScreen], 1 - JNE I_MapEnvelopeXAxis1 - - Xor AL, AL -I_MapEnvelopeFilterCompensate: - Add DI, 31*256 - -I_MapEnvelopeXAxis1: - Mov CS:AmplitudeCompensate, AL - - Mov AX, 100h - Mov CX, 128 - - Rep StosW ; X-axis drawn - - Pop DI - - Xor DH, DH - Mov DL, [SI+1] - - Mov CS:MaxNode, DX - Cmp CS:CurrentNode, DX - JB I_MapEnvelope2 - - Mov AX, DX - Sub AX, 1 - AdC AX, 0 - Mov CS:CurrentNode, AX - -I_MapEnvelope2: - Test DX, DX - JZ I_MapEnvelopeEnd - - Sub DX, 1 - AdC DX, 1 - - Push DX - - ; DX = last node - ; DS:SI = envelope, ES:DI = table - Mov BX, DX ; MaxNode - Add BX, BX - Add BX, DX ; BX = MaxNode*3 - - Mov AX, [DS:SI+BX+6+1-3] ; Get last nodes tick - Xor DX, DX - Mov BX, ENVELOPEGRANULARITY - Div BX - Inc AX - Mul BX - Mov CS:UpperLimit, AX - - Push DI - Xor BP, BP - Jmp I_MapEnvelope4 - -I_MapEnvelope3: - Push CX - Push DI - -I_MapEnvelope4: ; Node drawing part - Mov BX, BP - Add BX, BX - Add BX, BP - - Mov AL, 64 - Sub AL, CS:AmplitudeCompensate - Sub AL, [SI+BX+6] - Mov AH, 244 ; 244 = 61/64*256 - Mul AH - ; AX = amplitude - Mov CS:CurrentAmplitude, AX - Mov CX, AX ; CX = amplitude - - Mov AX, [SI+BX+7] - Cmp AX, CS:UpperLimit - JAE I_MapEnvelopeError - - Mov DX, 250 ; 249 if UpperLimit = LastNode tick - Mul DX -; Add AX, 125 -; AdC DX, 0 - Div CS:UpperLimit - - Mov CS:CurrentTick, AX - - ; OK.. plot points - Xor CL, CL - Add DI, AX - Add DI, CX - Add DI, 256+3 - - Mov AX, 101h - Mov [ES:DI], AX - Mov [ES:DI-256], AX - Mov [ES:DI+256], AX - Mov [ES:DI-1], AL - Mov [ES:DI-256-1], AL - Mov [ES:DI+256-1], AL - - Cmp BP, CS:CurrentNode - JNE I_MapEnvelope5 - - Dec AX - Mov [ES:DI+2], AX - Mov [ES:DI+256+2], AX - Mov [ES:DI-256+2], AX - XChg AH, AL - Mov [ES:DI-3], AX - Mov [ES:DI+256-3], AX - Mov [ES:DI-256-3], AX - -I_MapEnvelope5: - Sub DI, CX - Sub DI, 256 - Mov AX, BP - Mov CX, 64 - - Test Byte Ptr [SI], 2 - JZ I_MapEnvelope6 - - Mov AH, 1 - - Cmp AL, [SI+2] - JE I_MapEnvelopeLoop1 - Cmp AL, [SI+3] - JNE I_MapEnvelope6 - -I_MapEnvelopeLoop1: - Mov AL, AH - ShR AL, 1 - StosB - Add DI, 255 - Inc AH - Loop I_MapEnvelopeLoop1 - - Jmp I_MapEnvelope7 - -I_MapEnvelope6: - Test Byte Ptr [SI], 4 - JZ I_MapEnvelope7 - - Cmp AL, [SI+4] - JE I_MapEnvelopeSusLoop2 - Cmp AL, [SI+5] - JNE I_MapEnvelope7 - -I_MapEnvelopeSusLoop2: - Mov AL, 1 - -I_MapEnvelopeSusLoop1: - StosB - Add DI, 255 - Xor AL, 1 - Loop I_MapEnvelopeSusLoop1 - -I_MapEnvelope7: ; Now for line segment - Test BP, BP - JZ I_MapEnvelope8 ; Don't draw line for first node - - Pop DI - Push DI - - Add DI, CS:LastTick - Add DI, 103h - - Mov CX, CS:CurrentTick - Sub CX, CS:LastTick - JC I_MapEnvelope8 ; Error.. - JNZ I_MapEnvelope11 - - ; Vertical line. - Mov AX, CS:LastAmplitude - Mov CX, CS:CurrentAmplitude - Xor AL, AL - Xor CL, CL - - Add DI, AX ; LastAmplitude - - Mov DX, 256 - - Sub CX, AX - JNS I_MapEnvelope9 - - Neg DX - Neg CX - -I_MapEnvelope9: - ShR CX, 8 - JZ I_MapEnvelope12 - -I_MapEnvelope10: - Mov Byte Ptr [ES:DI], 1 - Add DI, DX - Loop I_MapEnvelope10 - -I_MapEnvelope12: - Jmp I_MapEnvelope8 - -I_MapEnvelope11: ; Diagonal line - Push SI - - Xor SI, SI - Mov AX, CS:CurrentAmplitude - Sub AX, CS:LastAmplitude - JNS I_MapEnvelope13 - - Inc SI ; SI = 1 if opp direction - Neg AX - -I_MapEnvelope13: - Xor DX, DX - Div CX - Mov DX, AX - - Test SI, SI - Mov SI, -256 - JZ I_MapEnvelope15 - - Neg SI - Neg DX - -I_MapEnvelope15: - Mov BX, CS:LastAmplitude - Inc CX - Dec DI - Push DI - Jmp I_MapEnvelope17 - -I_MapEnvelope14: - Push DI - Push BX - Xor BL, BL - Add DI, BX - -I_MapEnvelope16: - Mov Byte Ptr [ES:DI], 1 - Add DI, SI - Dec AL - JNZ I_MapEnvelope16 - - Pop BX - -I_MapEnvelope17: - Mov AL, BH - Add BX, DX - Sub AL, BH - - CBW ; - Xor AL, AH ; AL = |AL| - Sub AL, AH ; - Sub AL, 1 - AdC AL, 1 - - Pop DI - Inc DI - Loop I_MapEnvelope14 - - Pop SI - -I_MapEnvelope8: - Mov AX, CS:CurrentAmplitude - Mov BX, CS:CurrentTick - Mov CS:LastAmplitude, AX - Mov CS:LastTick, BX - -I_MapEnvelopeError: - Pop DI - Pop CX - Inc BP - Loop I_MapEnvelope3 - - ; Now shove on playing points. - - Call PE_GetLastInstrument - Inc BX - - Mov CX, CS:InstrumentScreen - Mov BP, CX - Mov DL, 1 - Add CL, 11 - ShL BP, 4 - ShL DX, CL - Add BP, 48h - - Call Music_GetSlaveChannelInformationTable - ; Returns DS:SI, CX - Assume DS:Nothing - -I_MapEnvelopePlaying1: - Cmp [SI+33h], BL - JNE I_MapEnvelopePlayingNext - - Test Byte Ptr [SI], 1 - JZ I_MapEnvelopePlayingNext - - Mov AX, [DS:SI+BP] - And AX, AX - JNZ I_MapEnvelopePlaying2 - - Test [SI], DX - JZ I_MapEnvelopePlayingNext - -I_MapEnvelopePlaying2: - Cmp AX, CS:UpperLimit - JAE I_MapEnvelopePlayingNext - - Push CX - Push DX - - Call S_GetGenerationTableOffset - Add DI, 3 - - Mov DX, 250 - Mul DX - Div CS:UpperLimit - - Add DI, AX - Mov CX, 64 - -I_DrawEnvelopePlaying1: - Mov Byte Ptr [ES:DI], 1 - Add DI, 256 - Loop I_DrawEnvelopePlaying1 - - Mov CS:UpdateInstrumentScreen, 1 - - Pop DX - Pop CX - -I_MapEnvelopePlayingNext: - Add SI, SLAVECHANNELSIZE - Loop I_MapEnvelopePlaying1 - -I_MapEnvelopeEnd: - Xor AX, AX - Mov BX, 32 - Mov CX, 8 - Call S_GenerateCharacters - - Pop BP - - Push CS - Pop DS - - Ret - -EndP I_MapEnvelope - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_GetMouseNode ; Returns DI, carry if none - - Call I_GetEnvelopeOffset - ; Returns DS:SI to envelope - Xor CH, CH - Mov CL, [SI+1] - - Add SI, 6 ; Start of envelope.. have to find - ; a point that fits MouseX, MouseY - ; XPixel = ENVELOPELEFT*8 + 250*Tick/UpperLimit + 3 - ; YPixel = ENVELOPETOP*8 + 61*(64-AmplitudeCompensate-Amplitude)/64 + 1 - - Xor DI, DI ; DI = node number. - JCXZ I_GetMouseNode3 - -I_GetMouseNode1: - Mov BX, DI - Add BX, BX - Add BX, DI - - Mov AX, 250 - Mul Word Ptr [SI+BX+1] - Div CS:UpperLimit - Add AX, ENVELOPELEFT*8+2 - - Mov DL, 64 - Sub DL, CS:AmplitudeCompensate - Sub DL, [SI+BX] - - Mov BX, AX ; BX = XPixel - - Mov AL, 244 ; 244 = 61/64*256 - Mul DL - Mov AL, AH - Xor AH, AH - Add AX, ENVELOPETOP*8 ; AX = YPixel of node... - - Cmp MouseX, BX - JB I_GetMouseNode2 - Cmp MouseY, AX - JB I_GetMouseNode2 - Add AX, 2 - Add BX, 2 - Cmp MouseX, BX - JA I_GetMouseNode2 - Cmp MouseY, AX - JA I_GetMouseNode2 - -I_GetMouseNode3: - ClC - Ret - -I_GetMouseNode2: - Inc DI - Cmp DI, CX - JB I_GetMouseNode1 - - StC - Ret - -EndP I_GetMouseNode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_MouseEnvelopeDelete Far - - Call I_GetMouseNode - JC I_MouseEnvelopeDelete1 - Mov CS:CurrentNode, DI - - Push CS - Pop DS - Jmp I_VolumeEnvelopeDelete - -I_MouseEnvelopeDelete1: - Mov AX, 1 - Ret - -EndP I_MouseEnvelopeDelete - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_MouseEnvelopePress Far - Assume DS:Nothing - ; If on top of node, then pick up this - ; node, ; MouseNodeHeld = 1 - ; If NOT near node, and nodes < 25, - ; then CREATE new node in appropriate - ; position, MouseNodeHeld = 1. If - ; no node will fit in-between, then - ; do nothing. - ; Else nothing - Call I_GetMouseNode - JNC I_MouseEnvelopeNodeFound1 - Cmp CX, 25 - JAE I_MouseEnvelopePressError - - ; Figger out envelope tick position... - Mov AX, MouseX - Sub AX, ENVELOPELEFT*8+3 - JNC I_MouseEnvelopeCreateNode4 - - Xor AX, AX - -I_MouseEnvelopeCreateNode4: - Mov BX, 250 - Mul CS:UpperLimit - Add AX, 125 - AdC DX, 0 - Div BX - - Mov CX, AX ; CX = new position.... - Cmp AX, MAXENVELOPETICK - JB I_MouseEnvelopeCreateNode3 - - Mov CX, MAXENVELOPETICK - -I_MouseEnvelopeCreateNode3: - Call I_GetEnvelopeOffset - Mov DL, [SI+1] - Mov BX, SI - Xor DH, DH - Xor DI, DI - Add BX, 7 - -I_MouseEnvelopeCreateNode1: - Cmp CX, [BX] - JE I_MouseEnvelopePressError - JB I_MouseEnvelopeCreateNode2 - - Add BX, 3 - Inc DI - Cmp DI, DX - JB I_MouseEnvelopeCreateNode1 - -I_MouseEnvelopeCreateNode2: - ClI - - Inc Byte Ptr [SI+1] - - Push BX - Push CX - Push DI - - Mov CX, DI - Cmp CL, [SI+2] - JA I_MEPIns1 - - Inc Byte Ptr [SI+2] - -I_MEPIns1: - Cmp CL, [SI+3] - JA I_MEPIns2 - - Inc Byte Ptr [SI+3] - -I_MEPIns2: - Cmp CL, [SI+4] - JA I_MEPIns3 - - Inc Byte Ptr [SI+4] - -I_MEPIns3: - Cmp CL, [SI+5] - JA I_MEPIns4 - - Inc Byte Ptr [SI+5] - -I_MEPIns4: - - Push DS - Pop ES - - StD - - Sub DX, DI - Mov CX, DX - Add CX, CX - Add CX, DX ; CX = (Last-New)*3 - - LEA DI, [BX+1] - Add DI, CX - LEA SI, [DI-3] - - Rep MovsB - - ClD - - Pop DI - Pop CX - Pop BX - - Mov [BX], CX - - Mov CX, 61 - Mov AX, MouseY - Sub AX, ENVELOPETOP*8 - JNC I_MEPChk1 - - Xor AX, AX - -I_MEPChk1: - Cmp AX, CX - JB I_MepChk2 - - Mov AX, CX - -I_MEPChk2: - ShL AX, 6 - Xor DX, DX - Div CX - - Mov DL, 64 - Sub DL, AL - Sub DL, CS:AmplitudeCompensate - Mov [BX-1], DL - -I_MouseEnvelopeNodeFound1: ; Have to find limits... - Mov CurrentNode, DI - Call I_EnvelopeSelected - - StI - - Mov BX, DI - Mov CL, BL - Inc CX - Add BX, BX - Add BX, DI - ; AX = lower limit, DX = upper limit - Xor AX, AX - Xor DX, DX - And DI, DI - JZ I_MouseEnvelopeNodeFound3 - - Mov DX, MAXENVELOPETICK - Mov AX, [SI+BX+6+1-3] - Inc AX - -I_MouseEnvelopeNodeFound2: - Cmp CL, [SI+1] - JAE I_MouseEnvelopeNodeFound3 - - Mov DX, [SI+BX+6+1+3] - Dec DX - -I_MouseEnvelopeNodeFound3: - Mov LowerTickLimit, AX - Mov UpperTickLimit, DX - - Mov BX, 2 - Call SetMouseCursorType - - Mov AX, 1 - Mov MouseNodeHeld, AL - Call SetKeyboardLock - Jmp I_MousePressChain - -I_MouseEnvelopePressError: - Mov AX, 1 - Ret - -EndP I_MouseEnvelopePress - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_MouseEnvelopeDrag Far - Assume DS:Nothing - ; CurrentNode update - - Call I_GetEnvelopeOffset - ; Returns DS:SI to envelope - Mov AX, CurrentNode - Mov BX, AX - Add BX, BX - Add BX, AX - LEA SI, [SI+BX+6] ; DS:SI points to current node - - ; Tick first - Mov AX, MouseX - Sub AX, ENVELOPELEFT*8+3 - JNC I_MouseEnvelopeDrag1 - - Xor AX, AX - -I_MouseEnvelopeDrag1: - Mov BX, 250 - Mul CS:UpperLimit - Add AX, 125 - AdC DX, 0 - Div BX - ; AX = tick.. now to check bounds.. - Cmp AX, LowerTickLimit - JAE I_MouseEnvelopeDrag2 - - Mov AX, LowerTickLimit - -I_MouseEnvelopeDrag2: - Cmp AX, UpperTickLimit - JBE I_MouseEnvelopeDrag3 - - Mov AX, UpperTickLimit - -I_MouseEnvelopeDrag3: - ClI - - Mov [SI+1], AX - - Mov AX, MouseY - Mov CX, 61 - Sub AX, ENVELOPETOP*8 - JNC I_MouseEnvelopeDrag4 - - Xor AX, AX - -I_MouseEnvelopeDrag4: - Cmp AX, CX - JBE I_MouseEnvelopeDrag5 - - Mov AX, CX - -I_MouseEnvelopeDrag5: - ShL AX, 6 - Xor DX, DX - Div CX - - Mov DL, 64 - Sub DL, AL - Sub DL, CS:AmplitudeCompensate - Mov [SI], DL - - StI - - ; XPixel = ENVELOPELEFT*8 + 250*Tick/UpperLimit + 3 - ; YPixel = ENVELOPETOP*8 + 61*(64-AmplitudeCompensate-Amplitude)/64 + 1 - -I_MousePressChain: - Push CS:UpperLimit - Call I_RedrawWave - Pop AX - Cmp AX, CS:UpperLimit - JE I_GetMousePositionEnd - - ; Set position.... - Call I_GetEnvelopeOffset - Mov AX, CS:CurrentNode - Add SI, AX - Add SI, AX - Add SI, AX - Add SI, 6 - - Mov AX, 250 - Mul Word Ptr [SI+1] - Div CS:UpperLimit - Add AX, ENVELOPELEFT*8-1 ; +3 - Mov CX, AX - - Xor DX, DX - Mov AL, 64 - Sub AL, CS:AmplitudeCompensate - Sub AL, [SI] - Mov AH, 244 - Mul AH - Mov DL, AH - - Add DX, ENVELOPETOP*8-2 ; +1 - Call MouseSetXY - -I_GetMousePositionEnd: - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_MouseEnvelopeDrag - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_MouseEnvelopeReleased Far - Assume DS:Inst - ; MouseNodeHeld = 0 - - Xor BX, BX - Call SetMouseCursorType - - Xor AX, AX - Mov CS:MouseNodeHeld, AL - Call SetKeyboardLock - - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_MouseEnvelopeReleased - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeRight Far - - Assume DS:Inst - - Mov AX, CurrentNode - Inc AX - Cmp AX, MaxNode - JAE I_VolumeEnvelopeRight1 - - Mov CurrentNode, AX - Call I_MapEnvelope - -I_VolumeEnvelopeRight1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeRight - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeLeft Far - - Assume DS:Inst - - Cmp CurrentNode, 0 - JE I_VolumeEnvelopeLeft1 - - Dec CurrentNode - Call I_MapEnvelope - -I_VolumeEnvelopeLeft1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeLeft - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeUp Far - - Mov Word Ptr [ES:DI], 5 - - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeDown Far - - Mov Word Ptr [ES:DI], 17 - - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldUp Far - - Assume DS:Inst - - Mov CX, CurrentNode - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, CX - Add SI, CX - Add SI, 6 - - Mov AL, [SI] - Add AL, CS:AmplitudeCompensate - - Cmp AL, 64 - JAE I_VolumeEnvelopeHeldUp1 - - Inc Byte Ptr [SI] - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeHeldUp1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldDown Far - - Assume DS:Inst - - Mov CX, CurrentNode - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, CX - Add SI, CX - Add SI, 6 - - Mov AL, [SI] - Add AL, CS:AmplitudeCompensate - - JZ I_VolumeEnvelopeHeldDown1 - - Dec Byte Ptr [SI] - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeHeldDown1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldLeft Far - - Assume DS:Inst - - Mov CX, CurrentNode - Mov DX, CX - Add DX, DX - JZ I_VolumeEnvelopeHeldLeft1 - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, DX - Add SI, 7 ; DS:SI points to node's posn - - Mov AX, [SI] - - Dec AX - Cmp AX, [SI-3] ; Last node. - JE I_VolumeEnvelopeHeldLeft1 - - Mov [SI], AX - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeHeldLeft1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldLeft - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldLeftFast Far - - Assume DS:Inst - - Mov CX, CurrentNode - Mov DX, CX - Add DX, DX - JZ I_VolumeEnvelopeHeldLeftFast2 - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, DX - Add SI, 7 - - Mov AX, [SI] - - Sub AX, 16 - JNC I_VolumeEnvelopeHeldLeftFast3 - - Xor AX, AX - -I_VolumeEnvelopeHeldLeftFast3: - Cmp AX, [SI-3] ; Last node. - JA I_VolumeEnvelopeHeldLeftFast1 - - Mov AX, [SI-3] - Inc AX - -I_VolumeEnvelopeHeldLeftFast1: - Mov [SI], AX - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeHeldLeftFast2: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldLeftFast - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldHome Far - - Assume DS:Inst - - Mov CX, CurrentNode - Mov DX, CX - Add DX, DX - JZ I_VolumeEnvelopeHeldHome1 - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, DX - Add SI, 7 - - Mov AX, [SI-3] - Inc AX - Mov [SI], AX - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeHeldHome1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldHome - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldRight Far - - Assume DS:Inst - - Mov CX, CurrentNode - Mov DX, CX - Add DX, DX - JZ I_VolumeEnvelopeHeldRight1 - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, DX - Add SI, 7 - - Mov AX, [SI] - Cmp AX, MAXENVELOPETICK - JAE I_VolumeEnvelopeHeldRight1 - - Inc AX - Inc CX - Cmp CX, CS:MaxNode - JE I_VolumeEnvelopeHeldRight2 - - Cmp AX, [SI+3] ; Last node. - JE I_VolumeEnvelopeHeldRight1 - -I_VolumeEnvelopeHeldRight2: - Mov [SI], AX - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeHeldRight1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldRight - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldEnd Far - - Assume DS:Inst - - Mov CX, CurrentNode - Mov DX, CX - Add DX, DX - JZ I_VolumeEnvelopeHeldEnd1 - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, DX - Add SI, 7 - - - Mov AX, MAXENVELOPETICK - Inc CX - Cmp CX, CS:MaxNode - JE I_VolumeEnvelopeHeldEnd2 - - Mov AX, [SI+3] - Dec AX - -I_VolumeEnvelopeHeldEnd2: - Mov [SI], AX - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeHeldEnd1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldEnd - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldRightFast Far - - Assume DS:Inst - - Mov CX, CurrentNode - Mov DX, CX - Add DX, DX - JZ I_VolumeEnvelopeHeldRightFast1 - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, DX - Add SI, 7 - - Mov AX, [SI] - - Add AX, 16 - Inc CX - Cmp CX, CS:MaxNode - JE I_VolumeEnvelopeHeldRightFast3 - - Cmp AX, [SI+3] - JB I_VolumeEnvelopeHeldRightFast2 - - Mov AX, [SI+3] - Dec AX - -I_VolumeEnvelopeHeldRightFast3: - Cmp AX, MAXENVELOPETICK - JBE I_VolumeEnvelopeHeldRightFast2 - - Mov AX, MAXENVELOPETICK - -I_VolumeEnvelopeHeldRightFast2: - Mov [SI], AX - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeHeldRightFast1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldRightFast - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldPgDn Far - - Assume DS:Inst - - Mov CX, CurrentNode - Mov AH, AmplitudeCompensate - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, CX - Add SI, CX - Add SI, 6 - - Mov AL, [SI] - Add AL, AH - Sub AL, 8 - JNS I_VolumeEnvelopeHeldPgDn1 - - Xor AL, AL - -I_VolumeEnvelopeHeldPgDn1: - Sub AL, AH - Mov [SI], AL - - Call I_MapEnvelope - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldPgDn - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeHeldPgUp Far - - Assume DS:Inst - - Mov CX, CurrentNode - Mov AH, AmplitudeCompensate - - Call I_GetEnvelopeOffset - Assume DS:Nothing - - Add SI, CX - Add SI, CX - Add SI, CX - Add SI, 6 - - Mov AL, [SI] - Add AL, AH - Add AL, 8 - Cmp AL, 64 - JBE I_VolumeEnvelopeHeldPgUp1 - - Mov AL, 64 - -I_VolumeEnvelopeHeldPgUp1: - Sub AL, AH - Mov [SI], AL - - Call I_MapEnvelope - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeHeldPgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeInsert Far - Assume DS:Inst - - Mov DX, CurrentNode - - Inc DX - Mov CX, MaxNode - Cmp DX, CX - JE I_VolumeEnvelopeInsert1 - - Mov DI, CX - Sub CX, DX - - Cmp DI, 25 - JE I_VolumeEnvelopeInsert1 - - Call I_GetEnvelopeOffset ; DS:SI - Assume DS:Nothing - - LEA BX, [SI+6] - Add BX, DX - Add BX, DX - Add BX, DX - Mov AX, [BX+1] - Sub AX, [BX-2] - Cmp AX, 2 - JB I_VolumeEnvelopeInsert1 - - ClI - - Inc Byte Ptr [SI+1] - - Mov BX, DI - Add BX, BX - Add BX, DI - LEA BX, [BX+SI+6] - -I_VolumeEnvelopeInsert2: - Mov AX, [BX-3] - Mov [BX], AX - Mov AL, [BX-1] - Mov [BX+2], AL - - Sub BX, 3 - Loop I_VolumeEnvelopeInsert2 - - Mov AX, [BX+4] - Add AX, [BX-2] - ShR AX, 1 - Mov [BX+1], AX - - Mov AH, CS:AmplitudeCompensate - Mov AL, [BX+3] - Add AL, [BX-3] - Add AL, AH - Add AL, AH - ShR AL, 1 - Sub AL, AH - Mov [BX], AL - - Mov CL, Byte Ptr CS:CurrentNode - Cmp CL, [SI+2] - JAE I_VolumeEnvelopeInsert4 - - Inc Byte Ptr [SI+2] - -I_VolumeEnvelopeInsert4: - Cmp CL, [SI+3] - JAE I_VolumeEnvelopeInsert5 - - Inc Byte Ptr [SI+3] - -I_VolumeEnvelopeInsert5: - Cmp CL, [SI+4] - JAE I_VolumeEnvelopeInsert6 - - Inc Byte Ptr [SI+4] - -I_VolumeEnvelopeInsert6: - Cmp CL, [SI+5] - JAE I_VolumeEnvelopeInsert7 - - Inc Byte Ptr [SI+5] - -I_VolumeEnvelopeInsert7: - StI - - Call I_MapEnvelope - NetworkSendInstrument - -I_VolumeEnvelopeInsert1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeInsert - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeDelete Far - - Assume DS:Inst - - Mov DX, CurrentNode - Mov DI, DX - Add DI, DI - Add DI, DX ; DI = CurrentNode*3 - JZ I_VolumeEnvelopeDelete1 - - Mov CX, MaxNode - Cmp CX, 2 - JBE I_VolumeEnvelopeDelete1 - - Call I_GetEnvelopeOffset ; Returns DS:SI - Assume DS:Nothing - - ClI - - Dec Byte Ptr [SI+1] - - Mov BX, SI - LEA SI, [BX+DI+6] - - Sub CX, DX - Dec CX - JZ I_VolumeEnvelopeDelete11 - -I_VolumeEnvelopeDelete2: - Mov AL, [SI+3] - Mov [SI], AL - Mov AX, [SI+4] - Mov [SI+1], AX - - Add SI, 3 - Loop I_VolumeEnvelopeDelete2 - -I_VolumeEnvelopeDelete11: - Xor AX, AX ; Neatness.. clear ending - Mov [SI], AX - Mov [SI+2], AL - ; Ok.. check loop stuff - Mov DL, [BX+1] - Dec DX ; DL = number of nodes - Mov DH, Byte Ptr CS:CurrentNode - - Cmp DH, [BX+2] - JAE I_VolumeEnvelopeDelete7 - - Dec Byte Ptr [BX+2] - -I_VolumeEnvelopeDelete7: - Cmp DH, [BX+3] - JAE I_VolumeEnvelopeDelete8 - - Dec Byte Ptr [BX+3] - -I_VolumeEnvelopeDelete8: - Cmp DH, [BX+4] - JAE I_VolumeEnvelopeDelete9 - - Dec Byte Ptr [BX+4] - -I_VolumeEnvelopeDelete9: - Cmp DH, [BX+5] - JAE I_VolumeEnvelopeDelete10 - - Dec Byte Ptr [BX+5] - -I_VolumeEnvelopeDelete10: - Cmp DL, [BX+2] - JAE I_VolumeEnvelopeDelete3 - - Mov [BX+2], DL - -I_VolumeEnvelopeDelete3: - Cmp DL, [BX+3] - JAE I_VolumeEnvelopeDelete4 - - Mov [BX+3h], DL - -I_VolumeEnvelopeDelete4: - Cmp DL, [BX+4] - JAE I_VolumeEnvelopeDelete5 - - Mov [BX+4], DL - -I_VolumeEnvelopeDelete5: - Cmp DL, [BX+5] - JAE I_VolumeEnvelopeDelete6 - - Mov [BX+5], DL - -I_VolumeEnvelopeDelete6: - StI - Call I_MapEnvelope - -I_VolumeEnvelopeDelete1: - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeDelete - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_EnvelopeSelected - - Call I_GetEnvelopeOffset ; Returns DS:SI - -IF FILTERENVELOPES - Cmp CS:InstrumentScreen, 3 - JNE I_MouseEnvelopeNoFilter - - Test Byte Ptr [SI], 1 - JNZ I_MouseEnvelopeNoFilter - - Or Byte Ptr [SI], 80h - -I_MouseEnvelopeNoFilter: -ELSE - And Byte Ptr [SI], 7Fh ; Turn of filters. - -ENDIF - - Or Byte Ptr [SI], 1 ; Turn on envelope - Ret - -EndP I_EnvelopeSelected - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_VolumeEnvelopeEnter Far - - Assume DS:Inst - - Xor NodeHeld, 1 - JZ I_VolumeEnvelopeEnter1 - - Call I_EnvelopeSelected - -I_VolumeEnvelopeEnter1: - Mov AX, 1 - Ret - -EndP I_VolumeEnvelopeEnter - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentListSpace Far - - Push CS - Pop DS - Assume DS:Inst - - Cmp NoteReleased, 1 - JNE I_InstrumentSpace1 - - Mov NoteReleased, 0 - Mov SI, Offset NoteData - Call PE_GetLastInstrument - Mov AH, BL - Inc AH - Mov AL, PlayNote - Mov [SI], AX - Mov AX, PlayChannel - Mov DH, 32+128 - Call Music_PlayNote - -I_InstrumentSpace1: - Mov AX, 1 - Ret - -EndP I_InstrumentListSpace - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_InstrumentListNoteOff Far - - Push CS - Pop DS - Assume DS:Inst - - Mov NoteReleased, 1 - Mov SI, Offset NoteData - Mov Word Ptr [SI], 255 - Mov AX, PlayChannel - Mov DH, 32+128 - Call Music_PlayNote - - Mov AX, 1 - Ret - -EndP I_InstrumentListNoteOff - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ShowSamplePlay Far - ; Clear table first. - - Push CS - Pop DS - ; DS = Inst - Mov SI, Offset SamplePlayTable - Mov CX, 100 - -I_ShowSamplePlayClearTable: - And Byte Ptr [SI], Not 3 - Inc SI - Loop I_ShowSamplePlayClearTable - - Call Music_GetSlaveChannelInformationTable - ; DS:SI points to table. - ; CX = numchannels. - Xor BH, BH - -I_ShowSamplePlay1: - Mov AX, [SI] - Test AL, 1 ; Is channel on? - JZ I_ShowSamplePlay2 - - Test AH, 8 ; Is it muted? - JNZ I_ShowSamplePlay2 - - Mov BL, [SI+36h] - Cmp BL, 100 - JAE I_ShowSamplePlay2 - - Or [CS:SamplePlayTable+BX], 1 ; Show sample is on. - - Cmp DWord Ptr [SI+2Ch], 0 - JNE I_ShowSamplePlay2 - - Or [CS:SamplePlayTable+BX], 2 - -I_ShowSamplePlay2: - Add SI, SLAVECHANNELSIZE - Loop I_ShowSamplePlay1 - - ; OK.. now to dump the stuff - ; onscreen - - Mov BX, TopSample - Dec BX - Mov SI, Offset SamplePlayTable - - Jmp I_ShowInstrumentPlay5 - -EndP I_ShowSamplePlay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ShowInstrumentPlay Far - ; Clear table first. - - Call Music_GetInstrumentMode - JZ I_ShowInstrumentPlayEnd - - Push CS - Pop DS - ; DS = Inst - Mov SI, Offset InstrumentPlayTable - Mov CX, 100 - -I_ShowInstrumentPlayClearTable: - And Byte Ptr [SI], Not 3 - Inc SI - Loop I_ShowInstrumentPlayClearTable - - Call Music_GetSlaveChannelInformationTable - ; DS:SI points to table. - ; CX = numchannels. - Xor BH, BH - -I_ShowInstrumentPlay1: - Mov AX, [SI] - Test AL, 1 ; Is channel on? - JZ I_ShowInstrumentPlay2 - - Test AH, 8 ; Is it muted? - JNZ I_ShowInstrumentPlay2 - - Mov BL, [SI+33h] - Cmp BL, 100 - JAE I_ShowInstrumentPlay2 - - Or [CS:InstrumentPlayTable+BX], 1 ; Show sample is on. - - Cmp DWord Ptr [SI+2Ch], 0 - JNE I_ShowInstrumentPlay2 - - Or [CS:InstrumentPlayTable+BX], 2 - -I_ShowInstrumentPlay2: - Add SI, SLAVECHANNELSIZE - Loop I_ShowInstrumentPlay1 - - ; OK.. now to dump the stuff - ; onscreen - - Mov BX, TopInstrument - Mov SI, Offset InstrumentPlayTable - -I_ShowInstrumentPlay5: - Call S_GetDestination - - Mov CX, 35 - Mov DI, (1+13*80)*2 - -I_ShowInstrumentPlay3: - Mov AX, 2100h - - Mov DL, [CS:SI+BX] - - Cmp DL, 0 ; No dot. - JE I_ShowInstrumentPlay4 - - Mov AL, 173 - - Cmp DL, 4 ; Dark small dot - JE I_ShowInstrumentPlay4 - - Mov AH, 23h - - Test DL, 2 ; Small bright dot - JZ I_ShowInstrumentPlay4 - - Mov AL, 183 ; Large bright dot. - -I_ShowInstrumentPlay4: - StosW - - Add DI, 158 - Inc BX - Loop I_ShowInstrumentPlay3 - -I_ShowInstrumentPlayEnd: - Ret - - -EndP I_ShowInstrumentPlay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ClearTables Far - - Push CS - Pop ES - - Mov DI, Offset SamplePlayTable - Mov CX, 128 - - Xor AX, AX - Rep StosW - - Ret - -EndP I_ClearTables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_TagInstrument Far - - Mov Byte Ptr [CS:InstrumentPlayTable+BX], 4 - Ret - -EndP I_TagInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_TagSample Far - - Mov Byte Ptr [CS:SamplePlayTable+BX], 4 - Ret - -EndP I_TagSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_PlaySample Far - - Push CS - Pop DS - Assume DS:Inst - - Test DH, DH - JNZ MIDI_PlaySample1 - - Jmp MIDI_NoteOff2 - -MIDI_PlaySample1: - Call Music_GetNumChannels ; Into AX - Mov DI, AX - Mov AX, PlayChannel - Call MIDI_AllocateChannel - - Call PE_GetLastInstrument - Mov CX, AX - Mov AL, DL - Mov AH, BL - Inc AH - Call Music_PlaySample - -MIDI_PlaySample2: - Mov AX, 1 - Ret - -EndP MIDI_PlaySample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PlaySample Far - - Mov AX, Pattern - Mov DS, AX - Assume DS:Pattern - - Mov AH, LastInstrument - Mov AL, CS:LastPlaySample - - Mov CX, CS:PlayChannel - Call Music_PlaySample - - Xor AX, AX - Ret - -EndP I_PlaySample - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_IncreasePlayChannel Far - - Push CS - Pop DS - Assume DS:Inst - - Mov AX, PlayChannel - Cmp AX, 63 - JAE I_IncreasePlayChannel1 - - Inc AX - -I_IncreasePlayChannel1: - Mov PlayChannel, AX - - Inc AX - Mov SI, Offset PlayChannelMsg - - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP I_IncreasePlayChannel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DecreasePlayChannel Far - - Push CS - Pop DS - Assume DS:Inst - - Mov AX, PlayChannel - And AX, AX - JZ I_DecreasePlayChannel1 - - Dec AX - -I_DecreasePlayChannel1: - Mov PlayChannel, AX - - Inc AX - Mov SI, Offset PlayChannelMsg - - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP I_DecreasePlayChannel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateMultiChannel - - Cmp CS:MultiChannel, 0 - JE UpdateMultiChannel1 - - Push AX - Push BX - Push DS - Push SI - Assume DS:Inst - - Push CS - Pop DS - - Call Music_GetNumChannels ; Into AX - Mov BX, PlayChannel - Inc BX - Cmp BX, AX - JB UpdateMultiChannel2 - - Xor BX, BX - -UpdateMultiChannel2: - Mov PlayChannel, BX - Mov AX, BX - Inc AX - - Mov SI, Offset PlayChannelMsg - Call SetInfoLine - - Pop SI - Pop DS - Pop BX - Pop AX - -UpdateMultiChannel1: - Ret - -EndP UpdateMultiChannel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_ToggleMultiChannel Far - - Push CS - Pop DS - Assume DS:Inst - - Mov SI, Offset MultiChannelEnabledMsg - Xor MultiChannel, 1 - JNZ I_ToggleMultiChannel1 - - Mov SI, Offset MultiChannelDisabledMsg - -I_ToggleMultiChannel1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP I_ToggleMultiChannel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_DrawPitchPanCenter Far - - Call S_GetDestination - Call I_GetInstrumentOffset ; Returns DS:BX - Mov DI, (54+45*80)*2 - - Mov AL, [BX+17h] - Mov CL, 12 - Xor AH, AH - Xor BH, BH - - Div CL - ; AL = octave, AH = note - Mov BL, AH - Mov DL, AL - Add BX, BX - Add DL, '0' - - Mov AH, 2 - Mov AL, [CS:NoteTable+BX] - StosW - Mov AL, [CS:NoteTable+BX+1] - StosW - Mov AL, DL - StosW - - Ret - -EndP I_DrawPitchPanCenter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PrePitchPanCenter Far - - Call S_GetDestination - Mov AL, 3h - Mov DI, (54+45*80)*2+1 - StosB - Inc DI - StosB - Inc DI - StosB - - Ret - -EndP I_PrePitchPanCenter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PostPitchPanCenter Far - - Push CS - Pop DS - Assume DS:Inst - - Mov SI, Offset PitchPanCenterKeys - Call M_FunctionDivider - JC I_PostPitchPanCenter1 - - Jmp [SI] - -I_PostPitchPanCenter1: - Xor AX, AX - Ret - -EndP I_PostPitchPanCenter - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PitchPanCenterUp Far - - Mov Word Ptr [ES:DI], 27 - Mov AX, 1 - Ret - -EndP I_PitchPanCenterUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PitchPanCenterDown Far - - Mov Word Ptr [ES:DI], 29 - Mov AX, 1 - Ret - -EndP I_PitchPanCenterDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PitchPanCenterSemiUp Far - - Call I_GetInstrumentOffset - Mov AL, [BX+17h] - - Cmp AL, 119 - JAE I_PitchPanCenterSemiUp1 - - Inc AX - Mov [BX+17h], AL - -I_PitchPanCenterSemiUp1: - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_PitchPanCenterSemiUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_PitchPanCenterSemiDown Far - - Call I_GetInstrumentOffset - Mov AL, [BX+17h] - - Dec AL - JS I_PitchPanCenterSemiDown1 - - Mov [BX+17h], AL - -I_PitchPanCenterSemiDown1: - NetworkSendInstrument - - Mov AX, 1 - Ret - -EndP I_PitchPanCenterSemiDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_IdleUpdateEnvelope Far - - Push CS - Pop DS - Assume DS:Inst - - Cmp UpdateInstrumentScreen, 0 - JNE I_IdleUpdateEnvelope2 - - Mov CL, Byte Ptr InstrumentScreen - Add CL, 11 - Mov DL, 1 - ShL DX, CL - - Call PE_GetLastInstrument ; Gets BX - Inc BX - Call Music_GetSlaveChannelInformationTable - Assume DS:Nothing - -I_IdleUpdateEnvelope1: - Cmp Byte Ptr [SI+33h], BL - JNE I_IdleUpdateEnvelope4 - - Test Byte Ptr [SI], 1 - JZ I_IdleUpdateEnvelope4 - - Test [SI], DX - JZ I_IdleUpdateEnvelope4 - -I_IdleUpdateEnvelope2: - Call I_MapEnvelope - Jmp I_IdleUpdateEnvelope3 - -I_IdleUpdateEnvelope4: - Add SI, SLAVECHANNELSIZE - Loop I_IdleUpdateEnvelope1 - -I_IdleUpdateEnvelope3: - Xor AX, AX - Ret - -EndP I_IdleUpdateEnvelope - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateWAVEForm Far - - Call I_RedrawWave - Ret - -EndP UpdateWAVEForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_SampleButtonHandler Far - - Test AX, AX - JZ I_SampleButtonHandler1 - - NetworkSendSample - -I_SampleButtonHandler1: - Push DS - - Call I_GetSampleOffset - Push DS - Pop ES - Mov DI, BX - Pop DS - - Add DI, [SI+24] - - Ret - -EndP I_SampleButtonHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc I_GetPresetEnvelopeOffset Far - - Push CS - Pop DS - Mov DX, Offset PresetEnvelopes - - Ret - -EndP I_GetPresetEnvelopeOffset - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Instrument List module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386 + +include switch.inc +include network.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Object1 BYTE Public 'Data' + Extrn SampleFrequency:Word +EndS + +Segment DiskData PARA Public 'Data' +EndS + +Segment Pattern BYTE Public 'Code' + Extrn BaseOctave:Byte + Extrn LastInstrument:Byte +EndS + + Extrn F_Reset5NumInputPos:Far + Extrn Glbl_F4_2:Far + + Extrn Glbl_GetCurrentMode:Far + Extrn S_GetDestination:Far + Extrn S_SaveScreen:Far + Extrn S_RestoreScreen:Far + Extrn S_DrawString:Far + Extrn M_FunctionDivider:Far + Extrn M_Object1List:Far + Extrn M_Object1ListDefault:Far + Extrn Music_GetSongSegment:Far + Extrn Music_ReleaseSample:Far + Extrn Music_ClearSampleName:Far + Extrn Music_PlaySample:Far + Extrn Music_GetInstrumentMode:Far +; Extrn Music_UpdateSampleLocation:Far + + Extrn S_GetGenerationTableOffset:Far + Extrn S_GenerateCharacters:Far + Extrn S_SetDirectMode:Far + Extrn S_DrawBox:Far + Extrn S_DrawSmallBox:Far + + Extrn O1_ConfirmDeleteSample:Far + Extrn O1_ConfirmConvertList:Far + Extrn O1_ConfirmConvert2List:Far + Extrn O1_ConfirmCutSample:Far + Extrn O1_ExchangeSampleList:Far + Extrn O1_ExchangeInstrumentList:Far + Extrn O1_SwapSampleList:Far + Extrn O1_SwapInstrumentList:Far + Extrn O1_ReplaceSampleList:Far + Extrn O1_ReplaceInstrumentList:Far + Extrn O1_ResizeSampleList:Far + Extrn O1_ShowSampleFrequencyList:Far + Extrn O1_FrequencyIndeterminedList:Far + Extrn O1_ConfirmDeleteInstrument:Far + Extrn O1_SampleAmplificationList:Far + Extrn O1_CopyInstrumentList:Far + Extrn O1_SampleCenterList:Far + + Extrn O1_InstrumentListGeneral:Far + Extrn O1_InstrumentListVolume:Far + Extrn O1_InstrumentListPanning:Far + Extrn O1_InstrumentListPitch:Far + Extrn O1_C5FrequencyList:Far + Extrn O1_GetInstrumentAmpList:Far + + Extrn PE_GetLastInstrument:Far + Extrn PE_SwapInstruments:Far + Extrn PE_UpdateInstruments:Far + Extrn PEFunction_OutOfMemoryMessage:Far + Extrn PE_TranslateMIDI:Far, PE_RestoreMIDINote:Far + Extrn PE_InsertInstrument:Far + Extrn PE_DeleteInstrument:Far + + Extrn Music_PlayPattern:Far + Extrn Music_Stop:Far + Extrn Music_PlaySong:Far + Extrn Music_PlayNote:Far + Extrn Music_ToggleChannel:Far + Extrn Music_SoloChannel:Far + Extrn Music_GetSampleLocation:Far + Extrn Music_ClearInstrument:Far + Extrn Music_GetInstrumentMode:Far + Extrn Music_AllocateSample:Far + Extrn Music_GetSlaveChannelInformationTable:Far + Extrn Music_SoundCardLoadAllSamples:Far + Extrn Music_GetNumChannels:Far + + Extrn Music_RegetLoopInformation:Far + + Extrn SetInfoLine:Far + + Extrn MouseAddEvent:Far, AddMouseQueue:Far, MouseClearEvents:Far + Extrn SetKeyboardLock:Far, MouseSetXY:Far + Extrn MouseRemoveEvents:Far, MouseGetStatus:Far + Extrn SetMouseCursorType:Far + + Extrn Fourier_Transform:Far, Fourier_CreateTable:Far + + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global I_DrawPitchPanCenter:Far + Global I_PrePitchPanCenter:Far + Global I_PostPitchPanCenter:Far + + Global I_ClearTables:Far + Global I_TagInstrument:Far + Global I_TagSample:Far + + Global I_DrawEnvelope:Far + Global I_PreEnvelope:Far + Global I_PostEnvelope:Far + + Global I_ConvertSample:Far + Global I_DeleteSample:Far + Global I_CutSample:Far + Global I_ClearSampleName:Far + Global I_ExchangeSamples:Far + Global I_ReplaceInstrument:Far + Global I_ToggleSampleQuality:Far + Global I_CenterSample:Far + + Global I_InstrumentListSpace:Far + Global I_InstrumentListNoteOff:Far + Global I_IncreasePlayChannel:Far + Global I_DecreasePlayChannel:Far + Global I_ToggleMultiChannel:Far + + Global I_ScaleInstrumentVolumes:Far + Global I_ScaleSampleVolumes:Far + Global I_CopyInstrument:Far + Global I_DeleteInstrument:Far + Global I_DrawSampleList:Far + Global I_PreSampleList:Far + Global I_PostSampleList:Far + Global I_ShowSampleInfo:Far + Global I_SampleUp:Far + Global I_SampleDown:Far + Global I_CheckLoopValues:Far + Global I_CheckSusLoopValues:Far + Global I_MapEnvelope:Far + Global I_DrawWaveForm:Far + Global I_SampleButtonHandler:Far + + Global I_DrawInstrumentWindow:Far + Global I_PreInstrumentWindow:Far + Global I_PostInstrumentWindow:Far + + Global I_DrawNoteWindow:Far + Global I_PreNoteWindow:Far + Global I_PostNoteWindow:Far + + Global I_AmplifySample:Far + Global I_ExchangeInstruments:Far + Global I_ReverseSample:Far + Global I_SwapSamples:Far + Global I_SwapInstruments:Far + Global I_ReplaceSample:Far + Global I_UpdateInstrument:Far + Global I_ResizeSample:Far + Global I_ResizeSampleNoInt:Far + Global I_InvertSample:Far + + Global I_GetInstrumentOffset:Far + Global I_GetSampleOffset:Far + Global I_CutSampleBeforeLoop:Far + + Global I_CalculateC5Speed:Far + Global I_PrintC5Frequency:Far + + Global I_DoubleSampleSpeed:Far + Global I_HalveSampleSpeed:Far + Global I_SampleSpeedSemiUp:Far + Global I_SampleSpeedSemiDown:Far + + Global I_ShowSamplePlay:Far + Global I_ShowInstrumentPlay:Far + + Global I_PlaySample:Far + Global I_SelectScreen:Far + + Global I_GetInstrumentScreen:Far + Global I_IdleUpdateEnvelope:Far + + Global I_PlayNote:Far + + Global SampleNumberInput:Byte + Global SampleNumber:Byte + + Global MaxNode:Word + Global NewSampleSize:DWord + Global SampleAmplification:Word + + Global InstrumentEdit:Byte + Global NodeHeld:Byte + Global InstrumentScreen:Word + + Global I_GetPresetEnvelopeOffset:Far + + Public UpdateWAVEForm + Public MIDI_PlayNote, MIDI_NoteOff, MIDI_ClearTable + Public MIDI_PlaySample, MIDI_FindChannel, MIDI_AllocateChannel + Public MIDI_GetChannel + + Global InstrumentAmplification + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Inst WORD Public 'Code' USE16 + Assume CS:Inst, DS:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +SLAVECHANNELSIZE EQU 128 +HOSTCHANNELSIZE EQU 80 +ENVELOPEGRANULARITY EQU 50 +MAXENVELOPETICK EQU 9999 + +InstrumentAmplification DW 50 +InstrumentScreen DW 0 + +LastPlaySample DB 5*12 +SampleNumber DB 1 ; For instrument-sample + ; editing + +NoteReleased DB 1 +TopInstrument DW 1 +InstrumentPos DW 0 + +SamplePlayTable DB 128 Dup (0) +InstrumentPlayTable DB 128 Dup (0) + +TopNote DW 0 +CurrentNote DW 0 +NotePos DW 0 ; 0->4 + +SampleNumberInput DB 0 + DB 3 Dup(0) + +NewSampleSize DD 0 + +CurrentNode DW 0 ; Volume envelope +MaxNode DW 0 + +AmplitudeCompensate DB 0 + DB 0 ; Filler +CurrentAmplitude DW 0 +CurrentTick DW 0 +LastAmplitude DW 0 +LastTick DW 0 +UpperLimit DW 0 + +NodeHeld DB 0 + DB 0 +WaveLength DW 0 +SearchDirection DW 0 +EndPoint DW 0 + +InstrumentEdit DB 0 +LastKey DW 0 + +Interpolate DB 0 ; For resizing routines +Quality DB 0 +MultiChannel DB 0 + +PlayChannel DW 0 +SampleAmplification DW 0 ; Percentage + +MIDITable DB 128 Dup (0) ; Contains channel of each note + +NoteData DB 0, 0, 0FFh, 0, 0 ; For noteplay in notelist + +PlayNote DB 5*12 + +NotePosTable DB 4, 6, 8, 9 +SamplePos DW 25 + +Resolution DB 0 +UpdateInstrumentScreen DB 1 + +CompleteMsg DB 0FDh, "D% Complete", 0 +TopSample DW 1 +NoSampleMsg DB "No sample", 0 +Quality8Msg DB "8 bits", 0 +Quality16Msg DB "16 bits", 0 +LengthMsg DB 0FDh, 'L', 0 + +EnvelopeSetMsg DB "Envelope copied into slot ", 0FDh, "D", 0 + +EnvelopeMsg DB "Node ", 0FDh, "D/", 0FDh, "D", 13, 13 + DB "Tick ", 0FDh, "D", 13, 13 + DB "Value ", 0FDh, "S", 0 + +PlayChannelMsg DB "Using channel ", 0FDh, "D for playback", 0 + +MultiChannelEnabledMsg DB "Multichannel playback enabled", 0 +MultiChannelDisabledMsg DB "Multichannel playback disabled", 0 + +C5FrequencyText DB "Calculated C5Speed: ", 0FDh, "L", 0 + +LastWaveformValues DW 0 + +EnvelopeHeaderTable Label + DW Offset VolEnv, Offset VolEnvEdit + DW Offset PanEnv, Offset PanEnvEdit + DW Offset PitchEnv, Offset PitchEnvEdit + +VolEnv DB "Volume Envelope", 0 +VolEnvEdit DB "Volume Envelope (Edit)", 0 +PanEnv DB "Panning Envelope", 0 +PanEnvEdit DB "Panning Envelope (Edit)", 0 +PitchEnv DB "Frequency Envelope", 0 +PitchEnvEdit DB "Frequency Envelope (Edit)", 0 + +EnvelopeOffsets Label Word + DW 130h, 182h, 1D4h + +NoteTable DB "C-C#D-D#E-F-F#G-G#A-A#B-" +KeyBoardTable DW 12Ch, 0, 11Fh, 1, 12Dh, 2, 120h, 3, 12Eh, 4 + DW 12Fh, 5, 122h, 6, 130h, 7, 123h, 8, 131h, 9 + DW 124h, 10, 132h, 11, 110h, 12, 103h, 13, 111h, 14 + DW 104h, 15, 112h, 16, 113h, 17, 106h, 18, 114h, 19 + DW 107h, 20, 115h, 21, 108h, 22, 116h, 23, 117h, 24 + DW 10Ah, 25, 118h, 26, 10Bh, 27, 119h, 28, 0FFFFh + +SampleMouseEvent DW 5*8, 13*8, 35*8-1, 48*8-1 +SampleMouseCondition DW 102h, 28, Offset MouseSelectInst, Inst +SampleMouseOffEvent DW 0, 0, 0, 0, 1108h, 28, MouseSelectOff, Inst +NoteMouseEvent DW 32*8, 16*8, 42*8-1, 48*8-1 +NoteMouseCondition DW 102h, 10, Offset MouseSelectNote, Inst +NoteMouseOffEvent DW 0, 0, 0, 0, 1108h, 10, MouseSelectNoteOff, Inst + +ENVELOPELEFT EQU 32 +ENVELOPETOP EQU 18 + +MouseNodeHeld DB 0 + +MouseX DW 0 +MouseY DW 0 +LowerTickLimit DW 0 +UpperTickLimit DW 0 + +EnvelopeEvent1 DW ENVELOPELEFT*8, ENVELOPETOP*8 + DW (ENVELOPELEFT+32)*8-1, (ENVELOPETOP+8)*8-1 + DW 102h, 10, Offset MouseEnvelopeEvent1, Inst +EnvelopeEvent4 DW ENVELOPELEFT*8, ENVELOPETOP*8 + DW (ENVELOPELEFT+32)*8-1, (ENVELOPETOP+8)*8-1 + DW 110h, 10, Offset MouseEnvelopeEvent4, Inst +EnvelopeEvent2 DW 0, 0, 0, 0, 1005h, 10, Offset MouseEnvelopeEvent2, Inst +EnvelopeEvent3 DW 0, 0, 0, 0, 1108h, 10, Offset MouseEnvelopeEvent3, Inst + ; Release + +PresetEnvelopes Label Byte + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + DB 0, 2, 0, 0, 0, 0, 32, 0, 0, 32, 100, 0, 69 Dup (0) + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InstrumentScreenTable Label + DW Offset O1_InstrumentListGeneral + DW Offset O1_InstrumentListVolume + DW Offset O1_InstrumentListPanning + DW Offset O1_InstrumentListPitch + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +SampleListKeys Label + DB 0 ; Mouse left button + DW 8010h + DW Offset I_SelectInstrument + + DB 0 ; 0 = CX, 1 = DX, 2 = Alt CX, 3 = Ctrl + DW 1C8h + DW Offset I_SampleUp + + DB 0 + DW 1D0h + DW Offset I_SampleDown + + DB 0 + DW 1C9h + DW Offset I_SamplePgUp + + DB 0 + DW 1D1h + DW Offset I_SamplePgDn + + DB 3 + DW 1C9h + DW Offset I_SampleCtrlPgUp + + DB 3 + DW 1D1h + DW Offset I_SampleCtrlPgDn + + DB 2 + DW 1D2h ; Alt Ins + DW Offset I_InsertSample + + DB 2 + DW 1D3h ; Alt Del + DW Offset I_RemoveSample + + DB 0 + DW 1CBh + DW Offset I_SampleLeft + + DB 0 + DW 1CDh + DW Offset I_SampleRight + + DB 0 + DW 1C7h + DW Offset I_SampleHome + + DB 0 + DW 1CFh + DW Offset I_SampleEnd + + DB 0 + DW 10Fh + DW Offset I_SampleTab + + DB 1 ; Alt... + DW 2E00h ; 'C' + DW Offset I_ClearSampleName + + DB 0FFh + +InstrumentListKeys Label + DB 0 ; Mouse left button + DW 8010h + DW Offset I_SelectInstrument2 + + DB 0 ; 0 = CX, 1 = DX, 2 = Alt CX, 3 = Ctrl + DW 1C8h + DW Offset I_SampleUp + + DB 0 + DW 1D0h + DW Offset I_SampleDown + + DB 0 + DW 1C9h + DW Offset I_SamplePgUp + + DB 0 + DW 1D1h + DW Offset I_SamplePgDn + + DB 2 + DW 1D2h ; Alt Ins + DW Offset I_InsertInstrument + + DB 2 + DW 1D3h ; Alt Del + DW Offset I_RemoveInstrument + + DB 3 + DW 1C9h + DW Offset I_SampleCtrlPgUp + + DB 3 + DW 1D1h + DW Offset I_SampleCtrlPgDn + + DB 0 + DW 1CBh + DW Offset I_InstrumentLeft + + DB 0 + DW 1CDh + DW Offset I_InstrumentRight + + DB 0 + DW 1C7h + DW Offset I_InstrumentHome + + DB 0 + DW 1CFh + DW Offset I_InstrumentEnd + + DB 0 + DW 10Fh + DW Offset I_InstrumentTab + + DB 4 + DW 10Fh + DW Offset I_InstrumentShiftTab + + DB 1 ; Alt + DW 2E00h ; 'C' + DW Offset I_InstrumentNameClear + + DB 1 ; Alt... + DW 1100h ; 'W' + DW Offset I_InstrumentClear + + DB 0FFh + +NoteListKeys Label + DB 0 + DW 8010h + DW Offset I_SelectNoteMouse + + DB 0 ; 0 = CX, 1 = DX, 2 = Alt CX, 3 = Ctrl + DW 1C8h + DW Offset I_NoteUp + + DB 0 + DW 1D0h + DW Offset I_NoteDown + + DB 0 + DW 1C9h + DW Offset I_NotePgUp + + DB 0 + DW 1D1h + DW Offset I_NotePgDn + + DB 0 + DW 1C7h + DW Offset I_NoteHome + + DB 0 + DW 1CFh + DW Offset I_NoteEnd + + DB 0 + DW 1CBh + DW Offset I_NoteLeft + + DB 0 + DW 1CDh + DW Offset I_NoteRight + + DB 0 + DW 10Fh + DW Offset I_NoteTab + + DB 4 + DW 10Fh ; Shift-Tab + DW Offset I_NoteShiftTab + + DB 1 + DW '>' + DW Offset I_NoteSampleIncrease + + DB 1 + DW "'" + DW Offset I_NoteSampleIncrease + + DB 1 + DW '<' + DW Offset I_NoteSampleDecrease + + DB 1 + DW ';' + DW Offset I_NoteSampleDecrease + + DB 1 ; Alt... + DW 1E00h ; 'A' + DW Offset I_NoteAll + + DB 1 ; Alt... + DW 3100h ; 'N' + DW Offset I_NoteNext + + DB 1 ; Alt... + DW 1900h ; 'P' + DW Offset I_NotePrevious + + DB 2 ; Alt up + DW 1C8h + DW Offset I_NoteTransposeUp + + DB 2 ; Alt down + DW 1D0h + DW Offset I_NoteTransposeDown + + DB 2 + DW 1D2h ; Alt Ins + DW Offset I_NoteInsert + + DB 2 + DW 1D3h ; Alt Del + DW Offset I_NoteDelete + + DB 1 + DW ' ' + DW Offset I_NoteSpace + + DB 0 + DW 11Ch ; Enter + DW Offset I_NoteSamplePickup + + DB 0FFh + +VolumeEnvelopeKeys Label + DB 0 + DW 8010h + DW Offset I_MouseEnvelopePress + + DB 0 + DW 8001h + DW Offset I_MouseEnvelopeDrag + + DB 0 + DW 8002h + DW Offset I_MouseEnvelopeReleased + + DB 0 + DW 8003h + DW Offset I_MouseEnvelopeDelete + + DB 0 + DW 10Fh ; Tab + DW Offset I_NoteShiftTab + + DB 4 ; Shifttab + DW 10Fh + DW Offset I_NoteShiftTab + + DB 0 + DW 1CBh + DW Offset I_VolumeEnvelopeLeft + + DB 0 + DW 1CDh + DW Offset I_VolumeEnvelopeRight + + DB 0 ; Enter + DW 11Ch + DW Offset I_VolumeEnvelopeEnter + + DB 0 ; Up arrow + DW 1C8h + DW Offset I_VolumeEnvelopeUp + + DB 0 ; Up arrow + DW 1D0h + DW Offset I_VolumeEnvelopeDown + + DB 0 + DW 1D2h + DW Offset I_VolumeEnvelopeInsert + + DB 0 + DW 1D3h + DW Offset I_VolumeEnvelopeDelete + + DB 0FFh + +VolumeEnvelopeNodeKeys Label + DB 0 + DW 8010h + DW Offset I_MouseEnvelopePress + + DB 0 + DW 8001h + DW Offset I_MouseEnvelopeDrag + + DB 0 + DW 8002h + DW Offset I_MouseEnvelopeReleased + + DB 0 + DW 8003h + DW Offset I_MouseEnvelopeDelete + + DB 0 ; Enter + DW 11Ch + DW Offset I_VolumeEnvelopeEnter + + DB 0 + DW 1C8h ; Up arrow + DW Offset I_VolumeEnvelopeHeldUp + + DB 0 + DW 1D0h ; Down arrow + DW Offset I_VolumeEnvelopeHeldDown + + DB 2 + DW 1C8h + DW Offset I_VolumeEnvelopeHeldPgUp + + DB 2 + DW 1D0h + DW Offset I_VolumeEnvelopeHeldPgDn + + DB 0 + DW 1CBh + DW Offset I_VolumeEnvelopeHeldLeft + + DB 0 + DW 1CDh + DW Offset I_VolumeEnvelopeHeldRight + + DB 0 + DW 10Fh + DW Offset I_VolumeEnvelopeHeldRightFast + + DB 4 + DW 10Fh + DW Offset I_VolumeEnvelopeHeldLeftFast + + DB 2 + DW 1CBh + DW Offset I_VolumeEnvelopeHeldLeftFast + + DB 2 + DW 1CDh + DW Offset I_VolumeEnvelopeHeldRightFast + + DB 0 + DW 1C9h + DW Offset I_VolumeEnvelopeHeldPgUp + + DB 0 + DW 1D1h + DW Offset I_VolumeEnvelopeHeldPgDn + + DB 0 + DW 1C7h + DW Offset I_VolumeEnvelopeHeldHome + + DB 0 + DW 1CFh + DW Offset I_VolumeEnvelopeHeldEnd + + DB 0 + DW 1D2h + DW Offset I_VolumeEnvelopeInsert + + DB 0 + DW 1D3h + DW Offset I_VolumeEnvelopeDelete + + DB 3 + DW 1CBh + DW Offset I_VolumeEnvelopeLeft + + DB 3 + DW 1CDh + DW Offset I_VolumeEnvelopeRight + + DB 0FFh + +PitchPanCenterKeys Label + DB 0 + DW 10Fh ; Tab + DW Offset I_NoteShiftTab + + DB 4 ; Shifttab + DW 10Fh + DW Offset I_NoteShiftTab + + DB 0 + DW 1C8h ; Up arrow + DW Offset I_PitchPanCenterUp + + DB 0 + DW 1D0h ; Down arrow + DW Offset I_PitchPanCenterDown + + DB 1 + DW '+' + DW Offset I_PitchPanCenterSemiUp + + DB 1 + DW '-' + DW Offset I_PitchPanCenterSemiDown + + DB 0 + DW 1CBh + DW Offset I_PitchPanCenterSemiDown + + DB 0 + DW 1CDh + DW Offset I_PitchPanCenterSemiUp + + DB 0FFh + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_GetInstrumentScreen Far + + Push CS + Pop ES + Mov DI, Offset InstrumentScreen + + Ret + +EndP I_GetInstrumentScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_GetInstrumentOffset Far + + Call PE_GetLastInstrument + Add BX, BX + Call Music_GetSongSegment + Mov DS, AX + Mov BX, [DS:64712+BX] + + Ret + +EndP I_GetInstrumentOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_GetSampleOffset Far + + Call PE_GetLastInstrument + Add BX, BX + Call Music_GetSongSegment + Mov DS, AX + Mov BX, [DS:64912+BX] + + Ret + +EndP I_GetSampleOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_GetEnvelopeOffset ; Returns DS:SI + + Push AX + Call I_GetInstrumentOffset ; Returns DS:BX + Mov SI, CS:InstrumentScreen + Add SI, SI + Mov SI, [SI+EnvelopeOffsets-2] + Add SI, BX + Pop AX + + Ret + +EndP I_GetEnvelopeOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SelectScreen Far + + Mov BX, [SI+22] + + Push CS + Pop DS + Assume DS:Inst + + Mov InstrumentScreen, BX + + Mov AX, [ES:DI] + + Add BX, BX + Mov BX, [CS:InstrumentScreenTable+BX] + Mov [ES:BX], AX + + Jmp Glbl_F4_2 + +EndP I_SelectScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSelectOff Far + + Mov Word Ptr [SI-16+8], 102h + Mov CS:SampleMouseCondition, 102h + Mov AX, 1 + + Ret + +EndP MouseSelectOff + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSelectNoteOff Far + + Mov Word Ptr [SI-16+8], 102h + Mov CS:NoteMouseCondition, 102h + Mov AX, 1 + Ret + +EndP MouseSelectNoteOff + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSelectNote Far + + Mov CS:NoteMouseCondition, 1107h + + Push CX + Mov CX, 8010h + Call AddMouseQueue + Pop CX + + Cmp DX, 16*8 + JA MouseSelectNote1 + + Mov DX, 16*8 + +MouseSelectNote1: + Cmp DX, 48*8-1 + JB MouseSelectNote2 + + Mov DX, 48*8-1 + +MouseSelectNote2: + Call MouseSetXY + + Xor AX, AX + Ret + +EndP MouseSelectNote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSelectInst Far + + Mov CS:MouseX, CX + + Mov CS:SampleMouseCondition, 1107h + + Push CX + + Mov CX, 8010h + ShR DX, 3 + Sub DX, 13 + Call AddMouseQueue + + Pop CX + And DX, DX + JNS MouseSelectInst1 + + Mov DX, 13*8 + Jmp MouseSelectInst2 + +MouseSelectInst1: + Cmp DX, 35 + JB MouseSelectInst3 + + Mov DX, 48*8-1 + +MouseSelectInst2: + Call MouseSetXY + +MouseSelectInst3: + Xor AX, AX + Ret + +EndP MouseSelectInst + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AddSelectEvent + + Call MouseGetStatus + Test AL, 6 + JNZ AddSelectEvent1 + + Mov Word Ptr [SI+8], 102h + +AddSelectEvent1: + Call MouseAddEvent + + Ret + +EndP AddSelectEvent + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DrawSampleList Far + + Call S_GetDestination + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + + Test AL, AL + JNZ I_DrawSampleList1 + + Inc AX + Mov LastInstrument, AL + +I_DrawSampleList1: + Push CS + Pop DS + Assume DS:Inst + + Mov BX, TopSample + Cmp BL, AL + JBE I_DrawSampleList2 + + Mov BL, AL + +I_DrawSampleList2: ; BL = top, AL = current + Mov CL, BL + Add CL, 34 + Cmp CL, AL + JAE I_DrawSampleList3 + + Mov BL, AL + Sub BL, 34 + +I_DrawSampleList3: + Mov TopSample, BX + ; BX = topinstrument + + Mov DI, (2+13*80)*2 + + Mov DX, 0A23h + +I_DrawSampleList4: + Mov AX, BX + Div DH + ; AH = units, AL = tens + Add AL, '0' + StosB + Mov AL, 20h + StosB + XChg AH, AL + Add AL, '0' + StosW + + Inc BX + Add DI, 156 + Dec DL + JNE I_DrawSampleList4 + + Mov BX, TopSample + + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + Mov CX, 35 + Mov DI, (5+13*80)*2 + Dec BX + Add BX, BX + Mov SI, [BX+64912] + +I_DrawSampleList5: + Push CX + Push SI + Push DI + + Add SI, 14h + Mov CX, 25 + Mov AH, 6 + +I_DrawSampleList6: + LodsB + Cmp AL, 226 + JB I_DrawSampleNoMouse + + Mov AL, ' ' + +I_DrawSampleNoMouse: + StosW + Loop I_DrawSampleList6 + + Mov AX, 2A8h + StosW + + Mov AX, 700h+'P' + + Test Byte Ptr [SI-14h-25+12h], 1 + JZ I_DrawSampleList8 + + Mov AH, 6 + +I_DrawSampleList8: + StosW + Mov AL, 'l' + StosW + Mov AL, 'a' + StosW + Mov AL, 'y' + StosW + + Pop DI + Pop SI + Pop CX + Add SI, 80 + Add DI, 160 + + Loop I_DrawSampleList5 + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + Xor AH, AH + Sub AX, TopSample + Add AX, 13 + Mov BX, 160 + Mul BX + Add AX, 10 + Mov DI, AX + + Mov CX, 30 + +I_DrawSampleList7: + Mov AX, [ES:DI] + And AH, 0Fh + Or AH, 0E0h + StosW + + Loop I_DrawSampleList7 + + ; Add on pointer... + Push CS + Pop DS + Assume DS:Inst + + Mov SI, Offset SampleMouseEvent + Mov Word Ptr [SI+4], 35*8-1 + Mov Word Ptr [SI+10], 28 + Call AddSelectEvent + Mov SI, Offset SampleMouseOffEvent + Mov Word Ptr [SI+4], 35*8-1 + Call MouseAddEvent + + Ret + +EndP I_DrawSampleList + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PreSampleList Far + + Call S_GetDestination + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + Xor AH, AH + Mov SI, AX + Sub AX, TopSample + Add AX, 13 + Mov BX, 160 + Mul BX + Add AX, 10 + Mov DI, AX + + Mov AX, SamplePos + Cmp AX, 25 + JB I_PreSampleList1 + + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + Dec SI + Add SI, SI + Mov SI, [SI+64912] + + Mov CX, 4 + Add DI, 52 + Mov AL, 30h + Test Byte Ptr [SI+12h], 1 + JNZ I_PreSampleList2 + + Mov AL, 60h + +I_PreSampleList2: + Inc DI + StosB + + Loop I_PreSampleList2 + + Ret + +I_PreSampleList1: + Add DI, AX + Add DI, AX + + Mov AL, 30h + Inc DI + StosB + Ret + +EndP I_PreSampleList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PostSampleList Far + + Push CS + Pop DS + Assume DS:Inst + + Mov SI, Offset SampleListKeys + Call M_FunctionDivider + JC I_PostSampleList7 + + Jmp [SI] + +I_PostSampleList7: + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + Xor AH, AH + Mov SI, AX + Dec SI + + Mov AX, SamplePos + Cmp AX, 25 + JAE I_PostSampleList2 + + Mov BX, AX ; BX = Pos. SI = LastInst + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + Add SI, SI + Mov SI, [64912+SI] ; SI = sample offset. + + Test CL, CL + JZ I_PostSampleList1 + Cmp DL, 32 ; Space bar or less?? + JB I_PostSampleList1 + + Add BX, 14h ; To sample name. + Add BX, SI + Add SI, 2Ch + +I_PostSampleList3: + Cmp SI, BX + JBE I_PSL3 + + Mov AL, [SI-1] + Mov [SI], AL + Dec SI + Jmp I_PostSampleList3 + +I_PSL3: + Mov [SI], DL + + Inc SamplePos + + Jmp I_PostSampleListEnd + +I_PostSampleList1: + Cmp CX, 10Eh + JNE I_PostSampleList4 + + And BX, BX + JZ I_PostSampleList4 + + Dec SamplePos + Add BX, 14h + Add BX, SI + Add SI, 2Dh + +I_PostSampleList5: + Mov AL, [BX] + Mov [BX-1], AL + Inc BX + Cmp BX, SI + JB I_PostSampleList5 + + Mov Byte Ptr [BX-1], 0 + +I_PostSampleListEnd: + NetworkSendSample + + Mov AX, 1 + Ret + +I_PostSampleList4: + Cmp CX, 1D3h ; Delete... + JNE I_PostSampleList6 + + Add BX, 15h + Add BX, SI + Add SI, 2Dh + Jmp I_PostSampleList5 + +I_PostSampleList6: + Xor AX, AX + Ret + +I_PostSampleList2: ; Play note.... + Push CS + Pop DS + + Test CH, Not 1 + JNZ I_PostSampleList9 + + Cmp CX, LastKey + JE I_PostSampleList9 + + Mov LastKey, CX + + + Mov SI, Offset KeyBoardTable + +I_PostSampleList8: + LodsW + Cmp AX, 0FFFFh + JE I_PostSampleList9 + + Mov BX, AX + LodsW + + Cmp BL, CL + JNE I_PostSampleList8 + ; Note to play... + ; AX = notemod. + And CH, CH + JZ I_PostSampleList10 + + Mov CX, AX + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, 12 + Mul BaseOctave + Add AL, CL + Mov AH, LastInstrument + + Push CS + Pop DS + Assume DS:Inst + + Call UpdateMultiChannel + + Mov LastPlaySample, AL + + Mov CX, PlayChannel + Call Music_PlaySample + Jmp I_PostSampleList9 + +I_PostSampleList10: + Mov SI, Offset NoteData + Mov Word Ptr [SI], 0FFh + Mov AX, PlayChannel + Mov DH, 32+128 + Call Music_PlayNote ; Note off. + +I_PostSampleList9: + Xor AX, AX + Ret + +EndP I_PostSampleList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleLeft Far + + Mov AX, SamplePos + Dec AX + JS I_SampleLeft1 + + Mov SamplePos, AX + +I_SampleLeft1: + Mov AX, 1 + Ret + +EndP I_SampleLeft + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleRight Far + + Mov AX, SamplePos + Inc AX + Cmp AX, 25 + JA I_SampleRight1 + + Mov SamplePos, AX + +I_SampleRight1: + Mov AX, 1 + Ret + +EndP I_SampleRight + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_RedrawWave + + Call Glbl_GetCurrentMode + + Cmp AL, 3 + JE I_RedrawWave1 + Cmp AL, 4 + JNE I_RedrawWave2 + + Call I_MapEnvelope + Ret + +I_RedrawWave1: + Call I_DrawWaveForm + +I_RedrawWave2: + Ret + +EndP I_RedrawWave + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SelectInstrument2 + Assume DS:Inst + + ; Set Instrument pos... + Mov AX, MouseX + ShR AX, 3 + Sub AX, 5 + JNC I_SelectInstrument8 + + Xor AX, AX + +I_SelectInstrument8: + Cmp AX, 24 + JB I_SelectInstrument7 + + Mov AX, 24 + +I_SelectInstrument7: + Mov InstrumentPos, AX + + Add DX, TopInstrument + Jmp I_SelectInstrument4 + +Proc I_SelectInstrument Far + + Mov AX, MouseX + Sub AX, 40 + ShR AX, 3 + Cmp AX, 25 + JB I_SelectInstrument6 + + Mov AX, 25 + +I_SelectInstrument6: + Mov SamplePos, AX + + Add DX, TopSample + +I_SelectInstrument4: + Cmp DX, 1 + JGE I_SelectInstrument1 + + Mov DX, 1 + +I_SelectInstrument1: + Cmp DX, 99 + JL I_SelectInstrument3 + + Mov DX, 99 + +I_SelectInstrument3: + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Cmp DL, LastInstrument + Mov LastInstrument, DL + JE I_SelectInstrument5 + + Call I_RedrawWave + +I_SelectInstrument5: + Mov AX, 1 + Ret + +EndP I_SelectInstrument + +EndP I_SelectInstrument2 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleDown Far + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + + Inc AX + Cmp AL, 100 + JAE I_SampleDown1 + + Mov LastInstrument, AL + Call I_RedrawWave + +I_SampleDown1: + + Mov AX, 1 + Ret + +EndP I_SampleDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleUp Far + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + + Dec AL + JZ I_SampleUp1 + + Mov LastInstrument, AL + Call I_RedrawWave + +I_SampleUp1: + Mov AX, 1 + Ret + +EndP I_SampleUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SamplePgUp Far + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + + Cmp AL, 1 + JE I_SamplePgUp3 + + Sub AL, 16 + JZ I_SamplePgUp1 + JNC I_SamplePgUp2 + +I_SamplePgUp1: + Mov AL, 1 + +I_SamplePgUp2: + Mov LastInstrument, AL + Call I_RedrawWave + +I_SamplePgUp3: + Mov AX, 1 + Ret + +EndP I_SamplePgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SamplePgDn Far + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + Cmp AL, 99 + JE I_SamplePgDn2 + + Add AL, 16 + Cmp AL, 99 + JBE I_SamplePgDn1 + + Mov AL, 99 + +I_SamplePgDn1: + Mov LastInstrument, AL + Call I_RedrawWave + +I_SamplePgDn2: + Mov AX, 1 + Ret + +EndP I_SamplePgDn + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleCtrlPgUp Far + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov LastInstrument, 1 + Call I_RedrawWave + + Mov AX, 1 + Ret + +EndP I_SampleCtrlPgUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleCtrlPgDn Far + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov LastInstrument, 99 + Call I_RedrawWave + + Mov AX, 1 + Ret + +EndP I_SampleCtrlPgDn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleEnd Far + + Mov SamplePos, 25 + + Mov AX, 1 + Ret + +EndP I_SampleEnd + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleHome Far + + Mov SamplePos, 0 + + Mov AX, 1 + Ret + +EndP I_SampleHome + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleTab Far + + Mov Word Ptr [ES:DI], 7 + + Mov AX, 1 + Ret + +EndP I_SampleTab + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ShowSampleInfo Far + + Call I_GetSampleOffset + + Push DWord Ptr [BX+30h] + + Mov AL, [BX+12h] + + Push CS + Pop DS + Assume DS:Inst + + Mov SI, Offset NoSampleMsg + + Mov AH, 2 + Test AL, 1 + JZ I_ShowSampleInfo1 + + Mov SI, Offset Quality8Msg + Test AL, 2 + JZ I_ShowSampleInfo1 + + Mov SI, Offset Quality16Msg + +I_ShowSampleInfo1: + Mov DI, (64+22*80)*2 + Call S_DrawString + +I_ShowSampleInfo2: + Mov DI, (64+23*80)*2 + Mov SI, Offset LengthMsg + Call S_DrawString + + Pop EAX + + Ret + +EndP I_ShowSampleInfo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VibratoButtonSelect Far + + Call I_GetSampleOffset + Mov AL, [BX+04Fh] ; AL = type. + Xor AH, AH + + Add DI, 82 + Xor CX, CX + +I_VibratoButtonSelect1: + Mov SI, [ES:DI] + + Mov CH, AH ; Assume up + Cmp AL, CL + JNE I_VibratoButtonSelect2 + + Inc CH + +I_VibratoButtonSelect2: + Mov [ES:SI+33], CH + +; Add DI, 2 + ScasW + Inc CX + Cmp CL, 3 + JLE I_VibratoButtonSelect1 + + Ret + +EndP I_VibratoButtonSelect + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SetVibratoWaveform Far ; AH = waveform. + + Mov AX, [SI+24] + Push AX + Call I_GetSampleOffset + Pop AX + + Mov [BX+4Fh], AL + + Ret + +EndP I_SetVibratoWaveform + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_CheckLoopValues Far + + Call I_GetSampleOffset + + Mov EAX, [BX+30h] + Sub EAX, 1 + AdC EAX, 0 + Cmp EAX, [BX+34h] + JA I_CheckLoopValues3 + + Mov [BX+34h], EAX + +I_CheckLoopValues3: + Inc EAX + Cmp EAX, [BX+38h] + JAE I_CheckLoopValues2 + + Mov [BX+38h], EAX + +I_CheckLoopValues2: + Mov EAX, [BX+38h] + Cmp EAX, [BX+34h] + JA I_CheckLoopValues1 + + And Byte Ptr [BX+12h], NOT 00010000b + +I_CheckLoopValues1: + Call Music_RegetLoopInformation + Call I_DrawWaveForm + Ret + +EndP I_CheckLoopValues + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_CheckSusLoopValues Far + + Call I_GetSampleOffset + + Mov EAX, [BX+30h] + Sub EAX, 1 + AdC EAX, 0 + Cmp EAX, [BX+40h] + JA I_CheckSusLoopValues3 + + Mov [BX+40h], EAX + +I_CheckSusLoopValues3: + Inc EAX + Cmp EAX, [BX+44h] + JAE I_CheckSusLoopValues2 + + Mov [BX+44h], EAX + +I_CheckSusLoopValues2: + Mov EAX, [BX+44h] + Cmp EAX, [BX+40h] + JA I_CheckLoopValues1 + + And Byte Ptr [BX+12h], NOT 00100000b + +I_CheckSusLoopValues1: + Call Music_RegetLoopInformation + Call I_DrawWaveForm + Ret + +EndP I_CheckSusLoopValues + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DrawWaveForm Far + + Mov [CS:LastWaveformValues], 7f80h + + Call S_GetGenerationTableOffset + Push DI + Mov CX, 176*32 + Xor AL, AL + Rep StosB + Pop DI + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + And AL, AL + JNZ I_DrawWaveForm1 + + Mov AL, 1 + +I_DrawWaveForm1: + Mov LastInstrument, AL + Xor AH, AH + Xor CX, CX + Call Music_GetSampleLocation + Assume DS:Nothing + + JC I_DrawWaveFormEnd + + SetNZ CS:Resolution + JZ I_DrawWaveForm8Bit + + Add ECX, ECX + Inc SI + +I_DrawWaveForm8Bit: + Test ECX, ECX + JZ I_DrawWaveFormEnd + + Push AX ; AX = instrument num + ; DS:ESI = waveform, ECX = length + ; ES:DI = charactergenerationtable + + Mov EAX, ECX + Mov ECX, 176 + Xor EDX, EDX + Div ECX ; EAX = major shift. EDX = minor shift. + + Mov EBX, EAX + Xor EAX, EAX + Div ECX + + Mov EDX, EAX + Xor EAX, EAX + + Mov EBP, ESI + +I_DrawWaveForm6: + Add EAX, EDX + AdC EBP, EBX + Push EAX + Push EBX + Push ECX + Push EDX + + Mov CL, [SI] + Mov CH, CL + MovZX BX, CS:Resolution + Inc BX + +I_DrawWaveForm10: + Cmp ESI, EBP + JAE I_DrawWaveForm7 + + Mov AL, [SI] + Add SI, BX ; Get max/min vals. + JC I_DrawWaveformNewBlock + +I_DrawWaveformResume: + Cmp AL, CL + JL I_DrawWaveForm8 + + Cmp AL, CH + JLE I_DrawWaveForm10 + + Mov CH, AL + Jmp I_DrawWaveForm10 + +I_DrawWaveformNewBlock: + Add ESI, 10000h + Int 3 + Jmp I_DrawWaveFormResume + +I_DrawWaveForm8: + Mov CL, AL + Jmp I_DrawWaveForm10 + +I_DrawWaveForm7: ; CL = min, CH = max. + Mov AX, CX + + XChg CX, [CS:LastWaveformValues] + + Cmp AL, CH + JL I_DrawWaveform7a + + Mov AL, CH + +I_DrawWaveform7a: + Cmp AH, CL + JG I_DrawWaveform7b + + Mov AH, CL + +I_DrawWaveform7b: + SAR AH, 1 + SAR AL, 1 + Add AX, 202h + SAR AH, 2 + SAR AL, 2 + + Xor CH, CH + Mov CL, AH + Sub CL, AL ; CX = iterations. + Inc CX + + Mov AL, 16 + Sub AL, AH + Cmp AL, 32 + JNE I_DrawWaveForm13 + + Mov AL, 31 + +I_DrawWaveForm13: + Mov AH, 176 + Mul AH + Mov BX, AX + +I_DrawWaveForm11: + Mov Byte Ptr [ES:DI+BX], 1 + Add BX, 176 + Loop I_DrawWaveForm11 + +I_DrawWaveForm12: + Pop EDX + Pop ECX + Pop EBX + Pop EAX + Inc DI + Loop I_DrawWaveForm6 + + ; Get Sample header offset. + Call Music_GetSongSegment + Mov DS, AX + Pop SI + Dec SI + Add SI, SI + Mov SI, [64912+SI] + + Mov EBX, [DS:SI+30h] + Test Byte Ptr [DS:SI+12h], 10h + JZ I_DrawWaveForm14 + + Mov ECX, EBX + ShR ECX, 1 + + Mov EAX, 175 + Mul DWord Ptr [DS:SI+34h] + Add EAX, ECX + AdC EDX, 0 + Div EBX + + Push EAX ; AX = loop start. + + Mov EAX, 175 + Mul DWord Ptr [DS:SI+38h] + Add EAX, ECX + AdC EDX, 0 + Div EBX + Mov EDX, EAX + Pop EAX ; EDX = loop end (0-175) + ; EAX = loop start (0-175) + + Call S_GetGenerationTableOffset + ; ES:DI + Add DI, AX + Sub DX, AX + Dec DX + Mov CX, 32 + Mov AH, 1 + +I_DrawSampleWaveFormLoop1: + Push DI + +; Xor AL, AL +; Test AH, 2 +; JZ I_DrawSampleWaveFormLoop2 +; +; Inc AL +; +;I_DrawSampleWaveFormLoop2: + Mov AL, AH + ShR AL, 1 + And AL, 1 + + StosB + Add DI, DX + StosB + + Pop DI + Add DI, 176 + Inc AH + Loop I_DrawSampleWaveFormLoop1 + +I_DrawWaveForm14: + Test Byte Ptr [DS:SI+12h], 20h + JZ I_DrawWaveFormEnd + + Mov ECX, EBX + ShR ECX, 1 + + Mov EAX, 175 + Mul DWord Ptr [DS:SI+40h] + Add EAX, ECX + AdC EDX, 0 + Div EBX + + Push EAX ; AX = loop start. + + Mov EAX, 175 + Mul DWord Ptr [DS:SI+44h] + Add EAX, ECX + AdC EDX, 0 + Div EBX + Mov EDX, EAX + Pop EAX ; DX = loop end (0-175) + ; AX = loop start (0-175) + + Call S_GetGenerationTableOffset + ; ES:DI + Add DI, AX + Sub DX, AX + Dec DX + Mov CX, 32 + Mov AL, 1 + +I_DrawSampleWaveFormSusLoop1: + Push DI + + StosB + Add DI, DX + StosB + + Pop DI + Add DI, 176 + Xor AL, 1 + Loop I_DrawSampleWaveFormSusLoop1 + +I_DrawWaveFormEnd: + Mov AX, 1 + Mov BX, 22 + Mov CX, 4 + Call S_GenerateCharacters + + Ret + +EndP I_DrawWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DeleteSample Far + + Mov DI, Offset O1_ConfirmDeleteSample + Mov CX, 4 + Call M_Object1List + + And DX, DX + JZ I_DeleteSample1 + + Call Music_Stop + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + Dec AX + Xor AH, AH + + Call Music_ReleaseSample + Call Music_ClearSampleName + + Call I_DrawWaveForm + +I_DeleteSample1: + Mov AX, 1 + Ret + +EndP I_DeleteSample + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +C5Speed DD 0 + +Proc I_CalculateC5Speed Far + + Mov AX, 1 + Ret + +Comment ! + Push DiskData + Pop ES + Call Fourier_CreateTable + + Call PE_GetLastInstrument ; Into BX + Mov AX, BX + Inc AX + + Xor CX, CX + Call Music_GetSampleLocation ; Returns DS:ESI, ECX + JC I_CalculateC5SpeedEnd + + PushF + Mov DX, 2048 + Mov DI, 16384 + + Cmp CX, DX + JB I_CalculateC5Speed1 + + Mov CX, DX + +I_CalculateC5Speed1: + Sub DX, CX + PopF + JNZ I_CalculateC5Speed16Bit + +I_CalculateC5Speed8Bit: + LodsB + StosW + Loop I_CalculateC5Speed8Bit + Jmp I_CalculateC5Speed2 + +I_CalculateC5Speed16Bit: + Rep MovsW + +I_CalculateC5Speed2: + Mov CX, DX + Xor AX, AX + Rep StosW + + Push ES + Pop DS + Call Fourier_Transform + +Comment ~ + + Mov DX, 1 + JZ I_CalculateC5BitSkip + + Inc DX + +I_CalculateC5BitSkip: + Mov EBP, ECX ; EBP = number of samples + +I_CalculateC5Speed1: + Sub EBP, 512 + JC I_CalculateC5SpeedDisplay + + Mov DI, 16384 + Mov BX, 512 + +I_CalculateC5Loop1: + Cmp DX, 2 + JE I_CalculateC5Speed16Bit + +I_CalculateC5Speed8Bit: + Mov AL, [SI] + Mov AH, AL + Jmp I_CalculateC5SpeedTransfer + +I_CalculateC5Speed16Bit: + Mov AX, [SI] + +I_CalculateC5SpeedTransfer: +; StosW + Mov CX, 4 + Rep StosW + + Add SI, DX + JC I_CalculateC5UpdateSampleLocation + +I_CalculateC5Continue: + Dec BX + JNZ I_CalculateC5Loop1 + +; OK.. do fourier + Push DS + PushAD + + Call Fourier_Transform + +; Now accumulate + Mov CX, 1024-64 + Mov SI, 24576+64*4 + Mov DI, 32768+64*4 + +I_CalculateC5Speed2: + FLd DWord Ptr [SI] + FAdd DWord Ptr [DI] + FStP DWord Ptr [DI] + Add SI, 4 + Add DI, 4 + Loop I_CalculateC5Speed2 + + PopAD + Pop DS + Jmp I_CalculateC5Speed1 + +I_CalculateC5UpdateSampleLocation: + Add ESI, 10000h + Int 3 + Jmp I_CalculateC5Continue + +I_CalculateC5SpeedDisplay: + Push ES + Pop DS +~ + Mov SI, 24768 + Xor CX, CX + Xor EAX, EAX + Xor EBX, EBX + +I_CalculateC5Speed3: + Cmp EAX, [SI] + JAE I_CalculateC5Speed4 + + Mov BX, CX + Mov EAX, [SI] + +I_CalculateC5Speed4: + Add SI, 4 + Inc CX + + Cmp CX, 1024 + JB I_CalculateC5Speed3 + +; Have BX = wavelength. + Mov EAX, 17145893 ; = C5Freq * 65536 + Mul EBX ; EDX:EAX = frequency in 48:16 format + ShRD EAX, EDX, 16 + + Mov CS:C5Speed, EAX +; EAX = C5Freq + Mov DI, Offset O1_C5FrequencyList + Call M_Object1ListDefault + +I_CalculateC5SpeedEnd: + Mov AX, 1 + Ret +! + +EndP I_CalculateC5Speed + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PrintC5Frequency Far + + Push CS + Pop DS + Assume DS:Inst + + Push C5Speed + + Mov SI, Offset C5FrequencyText + Mov AH, 20h + Mov DI, (27+27*80)*2 + Call S_DrawString + + Pop AX ; Clean up stack. + Pop BX + + Ret + +EndP I_PrintC5Frequency + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DeleteInstrument Far + + Mov DI, Offset O1_ConfirmDeleteInstrument + Mov CX, 4 + Call M_Object1List + + And DX, DX + JZ I_DeleteInstrument1 + + Call Music_Stop + + Call I_GetInstrumentOffset ; Gets DS:BX + + Mov CX, 120 + Add BX, 41h + +I_DeleteInstrument2: + Mov AL, [BX] + And AX, 0FFh + JZ I_DeleteInstrument3 + + Push DS + Push BX + Push CX + + Dec AX + + Call Music_ReleaseSample + Call Music_ClearSampleName + + Pop CX + Pop BX + Pop DS + +I_DeleteInstrument3: + Add BX, 2 + Loop I_DeleteInstrument2 + + Call I_InstrumentClear ; This sends network data already + +I_DeleteInstrument1: + Mov AX, 1 + Ret + +EndP I_DeleteInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ConvertSample Far ; Signed/Unsigned + + EnsureNoNetwork + + Call PE_GetLastInstrument + Mov CX, BX + Inc CX + Add BX, BX + + Call Music_GetSongSegment + Mov DS, AX + Mov SI, [64912+BX] + Test Byte Ptr [DS:SI+12h], 1 + JZ I_ConvertSample1 + + Push CX + + Mov DI, Offset O1_ConfirmConvertList + Mov CX, 3 + Call M_Object1List + + Pop AX ; AX = sample number + + And DX, DX + JZ I_ConvertSample1 + + Call Music_Stop + + Xor CX, CX + Call Music_GetSampleLocation ; DS:SI = location + JC I_ConvertSample1 ; CX = length. + + SetNZ BL + Xor BH, BH + Add SI, BX + + Inc BX + + +I_ConvertSample2: + Xor Byte Ptr [SI], 80h + Add SI, BX + JC I_ConvertSample3 + +I_ConvertSample4: + LoopD I_ConvertSample2 + + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_ConvertSample1: + Mov AX, 1 + Ret + +I_ConvertSample3: + Add ESI, 10000h + Int 3 + Jmp I_ConvertSample4 + +EndP I_ConvertSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InvertSample Far ; Signed/Unsigned + + EnsureNoNetwork + + Call PE_GetLastInstrument + Mov CX, BX + Inc CX + Add BX, BX + + Call Music_GetSongSegment + Mov DS, AX + Mov SI, [64912+BX] + Test Byte Ptr [DS:SI+12h], 1 + JZ I_InvertSample1 + + XChg AX, CX ; AX = sample number. + + Xor CX, CX + Call Music_GetSampleLocation ; DS:SI = location + JC I_InvertSample1 ; CX = length. + JNZ I_InvertSample_16Bit + +I_InvertSample2: + Neg Byte Ptr [SI] + Add SI, 1 + JC I_InvertSample3 + +I_InvertSample4: + LoopD I_InvertSample2 + +I_InvertSampleExit: + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_InvertSample1: + Mov AX, 1 + Ret + +I_InvertSample3: + Add ESI, 10000h + Int 3 + Jmp I_InvertSample4 + +I_InvertSample_16Bit: + Neg Word Ptr [SI] + Add SI, 2 + JC I_InvertSample_16Bit2 + +I_InvertSample_16Bit1: + LoopD I_InvertSample_16Bit + + Jmp I_InvertSampleExit + +I_InvertSample_16Bit2: + Add ESI, 10000h + Int 3 + Jmp I_InvertSample_16Bit1 + +EndP I_InvertSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_CutSampleBeforeLoopUpdateLoop Near + + Sub [DS:BX+DI], EDX + JNC I_CutSampleBeforeLoopUpdateLoop1 + + Mov DWord Ptr [DS:BX+DI], 0 + +I_CutSampleBeforeLoopUpdateLoop1: + Add DI, 4 + Ret + +EndP I_CutSampleBeforeLoopUpdateLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_CutSampleBeforeLoop Far + + EnsureNoNetwork + + Call I_GetSampleOffset + + Cmp DWord Ptr [DS:BX+34h], 0 +; Test Byte Ptr [DS:BX+12h], 10h + JZ I_CutSampleBeforeLoop1 + + Push DS + Push BX + + Mov DI, Offset O1_ConfirmCutSample + Mov CX, 4 + Call M_Object1List + + Pop BX + Pop DS + + And DX, DX + JZ I_CutSampleBeforeLoop1 + + Call Music_Stop + + Mov EDX, [DS:BX+34h] + Test Byte Ptr [DS:BX+12h], 32 + JZ I_CutSampleBeforeLoop2 + + Mov EAX, [DS:BX+40h] + + Cmp EDX, EAX + JB I_CutSampleBeforeLoop2 + Mov EDX, EAX + +I_CutSampleBeforeLoop2: + Mov DI, 34h + Call I_CutSampleBeforeLoopUpdateLoop ; BX+34h - Begin + Call I_CutSampleBeforeLoopUpdateLoop ; BX+38h - End + + Add DI, 4 + Call I_CutSampleBeforeLoopUpdateLoop ; BX+40h - SusLBeg + Call I_CutSampleBeforeLoopUpdateLoop ; BX+44h - SusLEnd + +I_CutSampleBeforeLoop4: + Sub [BX+30h], EDX + Mov ECX, [BX+30h] + + Test Byte Ptr [BX+12h], 2 + JZ I_CutSampleBeforeLoop6 + + Add EDX, EDX + Add ECX, ECX + +I_CutSampleBeforeLoop6: + Mov ESI, EDX + Call I_RepositionSample + + ; To diskdata segment first. + Mov AX, DiskData + Mov ES, AX + Assume ES:Nothing + + Xor EDI, EDI + +I_CutSampleBeforeLoop7: + Mov AL, [SI] + Mov [ES:DI], AL + + Add SI, 1 + JC I_CutSampleBeforeLoop8 + +I_CutSampleBeforeLoop9: + Add DI, 1 + JC I_CutSampleBeforeLoop10 + +I_CutSampleBeforeLoop11: + LoopD I_CutSampleBeforeLoop7 + + Mov ESI, EDI + Int 3 + Mov CX, DI + + Push DS + Push ES + Pop DS + Pop ES ; Swap DS and ES + + Xor SI, SI + Xor DI, DI + Rep MovsB + + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_CutSampleBeforeLoop1: + Mov AX, 1 + Ret + +I_CutSampleBeforeLoop8: + Add ESI, 10000h + Int 3 + Jmp I_CutSampleBeforeLoop9 + +I_CutSampleBeforeLoop10: + PushAD + Push DS + Push ES + + Mov ESI, EDI + Int 3 + + Push DS + Push ES + Pop DS + Pop ES ; Swap DS and ES + + Mov CX, 16384 + Xor SI, SI + Xor DI, DI + Rep MovsD + + Pop ES + Pop DS + PopAD + + Add EDI, 10000h + + Int 3 + Jmp I_CutSampleBeforeLoop11 + +EndP I_CutSampleBeforeLoop + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_CutSample Far + + EnsureNoNetwork + + Call I_GetSampleOffset + + Cmp DWord Ptr [DS:BX+38h], 0 +; Test Byte Ptr [DS:BX+12h], 10h ; Loop? + JZ I_CutSample1 + + Push DS + Push BX + + Mov DI, Offset O1_ConfirmCutSample + Mov CX, 4 + Call M_Object1List + + Pop BX + Pop DS + + And DX, DX + JZ I_CutSample1 + + Call Music_Stop + + Mov EAX, [DS:BX+38h] + Mov EDX, [DS:BX+44h] + Cmp EAX, EDX + JAE I_CutSample2 + Mov EAX, EDX + +I_CutSample2: + Mov [DS:BX+30h], EAX + + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_CutSample1: + Mov AX, 1 + Ret + +Proc I_CutSampleCheckValue Near + + Cmp DWord Ptr [DS:BX+DI], EAX + JBE I_CutSampleCheckValue1 + + Mov [DS:BX+DI], EAX + +I_CutSampleCheckValue1: + Ret + +EndP I_CutSampleCheckValue + +EndP I_CutSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ClearSampleName Far + Assume DS:Inst + + Mov SamplePos, 0 + +I_ClearSampleName2: + Call I_GetSampleOffset + + Push DS + Pop ES + + Mov DI, BX + +I_ClearSampleName3: + Add DI, 4 + + Mov CX, 6 + Xor AX, AX + Rep StosW + + Add DI, 4 + Mov CX, 13 + Rep StosW + + NetworkSendSample + + Inc AX + Ret + +EndP I_ClearSampleName + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InsertSample Far + + EnsureNoNetwork + + Call Music_GetSongSegment + Mov DS, AX + Mov SI, [DS:64912+(99-1)*2] + Test Byte Ptr [SI+12h], 1 + JNZ I_InsertSampleEnd + + Call PE_GetLastInstrument + Cmp BL, 98 + JE I_InsertSampleEnd + + Call Music_Stop + + Call PE_GetLastInstrument + Mov DL, BL + Push BX + + Call Music_GetSongSegment + + Mov ES, AX + Mov DS, AX + + Mov AX, 98 + Sub AX, BX + Mov CX, 80 + Add BX, BX + Mul CX + Mov SI, [DS:64912+BX] + Add SI, AX + Dec SI + LEA DI, [SI+80] + Mov CX, AX + + StD + Rep MovsB + ClD + + Mov DWord Ptr [SI+1+48h], 0 + Mov Byte Ptr [SI+1+12h], 0 + + Call Music_SoundCardLoadAllSamples + + Pop AX + Push AX + Call Music_ClearSampleName + + Pop DX + Inc DX ; DL = instrument + + Call Music_GetInstrumentMode + JZ I_InsertSampleSampleMode + ; Instrument mode.. + ; step through inst. + + Xor EAX, EAX + +I_InsertSample4: + Mov SI, [DS:64712+EAX*2] + Add SI, 41h + + Mov CX, 120 + +I_InsertSample5: + Cmp [SI], DL + JB I_InsertSample6 + + Cmp Byte Ptr [SI], 99 + JAE I_InsertSample6 + + Inc Byte Ptr [SI] + +I_InsertSample6: + Add SI, 2 + Loop I_InsertSample5 + + Inc AX + Cmp AX, 99 + JB I_InsertSample4 + + Jmp I_InsertSampleFinished + +I_InsertSampleSampleMode: + Call PE_InsertInstrument + +I_InsertSampleFinished: + Call I_DrawWaveform + +I_InsertSampleEnd: + Mov AX, 1 + Ret + +EndP I_InsertSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_RemoveSample Far + + EnsureNoNetwork + + Call I_GetSampleOffset + Test Byte Ptr [BX+12h], 1 + JNZ I_RemoveSampleEnd + + Call Music_Stop + + Call PE_GetLastInstrument + Mov DL, BL + Push BX + + Call Music_GetSongSegment + + Mov ES, AX + Mov DS, AX + + Mov AX, 98 + Sub AX, BX + Mov CX, 80 + Add BX, BX + Mul CX + Mov DI, [DS:64912+BX] + LEA SI, [DI+80] + Mov CX, AX + + Rep MovsB + + Pop DX + Inc DX ; DL = instrument + + Push DS + Push DI + + Mov DWord Ptr [DI+48h], 0 + Mov Byte Ptr [DI+12h], 0 + + Call Music_SoundCardLoadAllSamples + + Call Music_GetInstrumentMode + JZ I_RemoveSampleSampleMode + ; Instrument mode.. + ; step through inst. + + Xor EAX, EAX + +I_RemoveSample4: + Mov SI, [DS:64712+EAX*2] + Add SI, 41h + + Mov CX, 120 + +I_RemoveSample5: + Cmp [SI], DL + JB I_RemoveSample6 + + Dec Byte Ptr [SI] + +I_RemoveSample6: + Add SI, 2 + Loop I_RemoveSample5 + + Inc AX + Cmp AX, 99 + JB I_RemoveSample4 + + Jmp I_RemoveSampleFinished + +I_RemoveSampleSampleMode: + Call PE_DeleteInstrument + +I_RemoveSampleFinished: + Call I_DrawWaveform + + Pop DI + Pop ES + Jmp I_ClearSampleName3 + +I_RemoveSampleEnd: + Mov AX, 1 + Ret + +EndP I_RemoveSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InsertInstrument Far + + EnsureNoNetwork + + Call PE_GetLastInstrument + Cmp BL, 98 + JE I_InsertInstrumentEnd + + Call Music_Stop + + Call PE_GetLastInstrument + Mov DL, BL + Push BX + + Call Music_GetSongSegment + + Mov ES, AX + Mov DS, AX + + Mov AX, 98 + Sub AX, BX + Mov CX, 554 + Add BX, BX + Mul CX + Mov SI, [DS:64712+BX] + Add SI, AX + Dec SI + LEA DI, [SI+554] + Mov CX, AX + + StD + Rep MovsB + ClD + + Pop DX + Inc DX ; DL = instrument + + Call Music_GetInstrumentMode + JZ I_InsertInstrumentFinished + + Call PE_InsertInstrument + +I_InsertInstrumentFinished: + Jmp I_InstrumentClear ; Sends network data + +I_InsertInstrumentEnd: + Mov AX, 1 + Ret + +EndP I_InsertInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_RemoveInstrument Far + + EnsureNoNetwork + + Call Music_Stop + + Call PE_GetLastInstrument + Mov DL, BL + Push BX + + Call Music_GetSongSegment + + Mov ES, AX + Mov DS, AX + + Mov AX, 98 + Sub AX, BX + Mov CX, 554 + Add BX, BX + Mul CX + MOv DI, [DS:64712+BX] + LEA SI, [DI+554] + Mov CX, AX + + Rep MovsB + + Pop DX + Inc DX ; DL = instrument + + Call Music_GetInstrumentMode + JZ I_RemoveInstrumentFinished + + Call PE_DeleteInstrument + +I_RemoveInstrumentFinished: + Mov AX, 98 + Call Music_ClearInstrument + + Call I_MapEnvelope + +I_RemoveInstrumentEnd: + Mov AX, 1 + Ret + +EndP I_RemoveInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSampleNumber ; Carry if not a num. + ; DX otherwise, + Push CS + Pop DS + + Mov SI, Offset SampleNumberInput + Xor DX, DX + +GetSampleNumber1: + LodsB + And AL, AL + JZ GetSampleNumber2 + + Cmp AL, '0' + JB GetSampleNumber3 + Cmp AL, '9' + JA GetSampleNumber3 + + Sub AL, '0' + XChg DL, AL + Mov AH, 10 + Mul AH + Add DL, AL + + Jmp GetSampleNumber1 + +GetSampleNumber3: + StC + Ret + +GetSampleNumber2: + Test DX, DX + JZ GetSampleNumber3 + +; ClC + Ret + +EndP GetSampleNumber + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetNumberInput ; DI = Offset of list. + ; Returns DX with sample number. + + Push DI + + Mov DI, Offset SampleNumberInput + Push CS + Pop ES + Xor AL, AL + Mov CX, 4 + Rep StosB + + Pop DI + + Call S_SaveScreen + + Mov CX, 3 + Call M_Object1List + + Call S_RestoreScreen + + And DX, DX + JZ GetNumberInput1 + + Call Music_Stop + + Call GetSampleNumber + JC GetNumberInput1 + + Ret + +GetNumberInput1: + Pop AX ; Add SP, 2 + Mov AX, 1 + RetF + +EndP GetNumberInput + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ExchangeSamples Far + + ; Clear input... + + EnsureNoNetwork + + Mov DI, Offset O1_ExchangeSampleList + Call GetNumberInput + + Mov SI, DX + Dec SI + Add SI, SI + + Call PE_GetLastInstrument + Add BX, BX + + Cmp BX, SI + JE I_ExchangeSamples1 + + Call Music_GetSongSegment + Mov ES, AX + Mov DS, AX + Mov DI, [DS:64912+BX] + Mov SI, [DS:64912+SI] ; DS:SI, ES:DI point to + ; sample headers + + Mov CX, 80 + +I_ExchangeSamples2: + Mov AL, [ES:DI] + MovsB + Mov [DS:SI-1], AL + + Loop I_ExchangeSamples2 + + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_ExchangeSamples1: + Mov AX, 1 + Ret + +EndP I_ExchangeSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SwapSamples Far + + ; Clear input... + + EnsureNoNetwork + + Mov DI, Offset O1_SwapSampleList + Call GetNumberInput + + Mov SI, DX + Dec SI + Add SI, SI + + Call PE_GetLastInstrument + Mov DH, BL + Inc DH ; DH/DL = samples to swap + Add BX, BX + + Cmp DL, DH + JE I_SwapSamples1 + + Call Music_GetSongSegment + Mov ES, AX + Mov DS, AX + Mov DI, [DS:64912+BX] + Mov SI, [DS:64912+SI] ; DS:SI, ES:DI point to + ; sample headers + + Mov CX, 80 + +I_SwapSamples2: + Mov AL, [ES:DI] ; Swapping headers. + MovsB + Mov [DS:SI-1], AL + + Loop I_SwapSamples2 + + ; Now to swap pattern + ; stuff... + Call Music_GetInstrumentMode + JZ I_SwapSamples3 + ; Instrument mode.. + ; step through inst. + Xor AX, AX + +I_SwapSamples4: + Push AX + + Mov BX, AX + Add BX, BX + Mov SI, [DS:64712+BX] + Add SI, 41h + + Mov CX, 120 + +I_SwapSamples5: + Mov AL, [SI] + Cmp AL, DL + JNE I_SwapSamples6 + + Mov [SI], DH + Jmp I_SwapSamples7 + +I_SwapSamples6: + Cmp AL, DH + JNE I_SwapSamples7 + + Mov [SI], DL + +I_SwapSamples7: + Add SI, 2 + Loop I_SwapSamples5 + + Pop AX + + Inc AX + Cmp AX, 99 + JB I_SwapSamples4 + + Jmp I_SwapSamples8 + +I_SwapSamples3: ; Sample mode.. + Call PE_SwapInstruments + +I_SwapSamples8: + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_SwapSamples1: + Mov AX, 1 + Ret + +EndP I_SwapSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ReplaceSample Far + + EnsureNoNetwork + + Mov DI, Offset O1_ReplaceSampleList + Call GetNumberInput + + Call PE_GetLastInstrument + Mov DH, BL + Inc DH ; DH/DL = samples to swap + + Cmp DL, DH + JE I_ReplaceSample1 + + Call Music_GetSongSegment + Mov ES, AX + Mov DS, AX + ; Now to swap pattern + ; stuff... + Call Music_GetInstrumentMode + JZ I_ReplaceSample3 + ; Instrument mode.. + ; step through inst. + Xor AX, AX + +I_ReplaceSample4: + Push AX + + Mov BX, AX + Add BX, BX + Mov SI, [DS:64712+BX] + Add SI, 41h + + Mov CX, 120 + +I_ReplaceSample5: + Mov AL, [SI] + + Cmp AL, DH + JNE I_ReplaceSample7 + + Mov [SI], DL + +I_ReplaceSample7: + Add SI, 2 + Loop I_ReplaceSample5 + + Pop AX + + Inc AX + Cmp AX, 99 + JBE I_ReplaceSample4 + + Mov AX, 1 + Ret + +I_ReplaceSample3: ; Sample mode.. + XChg DH, DL + Or DH, 80h + Call PE_SwapInstruments + +I_ReplaceSample1: + Mov AX, 1 + Ret + +EndP I_ReplaceSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ReMix + Assume DS:Nothing + + EnsureNoNetwork + + Call Music_Stop + ; OK... + Call I_GetSampleOffset + Mov EDX, CS:NewSampleSize + Mov AX, 99 + + Test Byte Ptr [BX+12h], 2 + JZ I_ReMix1 + + Add EDX, EDX + +I_ReMix1: + ; Limit size of EDX... + Cmp EDX, 4177920 + JBE I_ReMixLimitMaxSize + + Mov EDX, 4177920 + Mov CS:NewSampleSize, EDX + + Test Byte Ptr [BX+12h], 2 + JZ I_ReMixLimitMaxSize + + ShR CS:NewSampleSize, 1 + +I_ReMixLimitMaxSize: + Call Music_AllocateSample ; Returns ES:DI + Mov AX, ES + And AX, AX + JNZ I_ReMixEnoughMem + + Call PEFunction_OutOfMemoryMessage + +I_ReMixNoMix: + Ret + +I_ReMixEnoughMem: + Mov AX, DiskData + Mov ES, AX + Assume ES:Nothing + + Call PE_GetLastInstrument ; Into BX + Mov AX, BX + Inc AX + + Xor CX, CX + Call Music_GetSampleLocation ; Returns DS:ESI, ECX + JNZ I_ReMix16Bit + +I_ReMix8Bit: + Mov EAX, ECX + Xor EDX, EDX + Div CS:NewSampleSize + + Mov BP, AX + ShR EAX, 16 + JNZ I_ReMixNoMix + + Xor EAX, EAX ; BP:AX = skip value... + Div CS:NewSampleSize + + ShR EAX, 16 + Mov BX, AX + + ; BP:BX = skip value. + Xor ESI, ESI ; DS:ESI = source + Xor EDI, EDI ; Go from the start! + Xor CX, CX ; CX = error. + ; ES:EDI = destination + +I_ReMix8Bit2: + Cmp CS:Interpolate, 0 + JNE I_ReMix8BitInterpolate + + Mov AL, [SI] + Jmp I_ReMix8BitStore + +I_ReMix8BitInterpolate: + MovSX AX, Byte Ptr [SI] + Mov DX, 100h + Sub DL, CH + SbB DH, 0 + IMul DX ; AX = [SI]*(1-Remainder)*256 + + Push AX + + Add SI, 1 + JNC I_ReMix8BitInterpolate2 + + Add ESI, 10000h + Int 3 + +I_ReMix8BitInterpolate2: + MovSX AX, Byte Ptr [SI] + Mov DL, CH + Xor DH, DH + Mul DX + + Pop DX ; DX = Old AX = [SI]*(1-Remainder)*256 + Add AX, DX + Add AX, 80h ; Rounding. + Mov AL, AH + + Sub ESI, 1 + +I_ReMix8BitStore: + Mov [ES:DI], AL + + Add CX, BX + AdC SI, BP + JC I_ReMix8Bit3 + +I_ReMix8Bit4: + Add DI, 1 + JC I_ReMix8Bit5 + +I_ReMix8Bit6: + Cmp EDI, CS:NewSampleSize + JB I_ReMix8Bit2 + + Jmp I_ReMixCleanUp + +I_ReMix8Bit3: + Add ESI, 10000h + Int 3 + Jmp I_Remix8Bit4 + +I_ReMix8Bit5: + PushAD + Push DS + Push ES + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + Mov ESI, EDI + Int 3 + + Push DS + Push ES + Pop DS + Pop ES + + Mov CX, 16384 + Xor SI, SI + Xor DI, DI + Rep MovsD + + Pop ES + Pop DS + PopAD + + Add EDI, 10000h + + Call I_RepositionSample + Jmp I_ReMix8Bit6 + +I_ReMix16Bit: + Mov EAX, ECX + Xor EDX, EDX + Div CS:NewSampleSize + + Mov BP, AX + Add BP, BP + ShR EAX, 15 + JNZ I_ReMixNoMix + + Xor EAX, EAX ; BP:AX = skip value... + Div CS:NewSampleSize + + ShR EAX, 16 + Mov BX, AX + + ; BP:BX = skip value. + Xor ESI, ESI ; DS:ESI = source + Xor EDI, EDI ; Go from the start! + Xor CX, CX ; CX = error. + ; ES:EDI = destination + +I_ReMix16Bit2: + Cmp CS:Interpolate, 0 + JNE I_ReMix16BitInterpolate + + Mov AX, [SI] + Jmp I_ReMix16BitStore + +I_ReMix16BitInterpolate: + Mov AX, [SI] ; AX = [SI]*(1-Remainder)*256 + Mov DX, 100h + Sub DL, CH + SbB DH, 0 + IMul DX ; DX:AX = [SI]*(1-Remainder)*256 + + Push DX + Push AX + + Add SI, 2 + JNC I_ReMix16BitInterpolate2 + + Add ESI, 10000h + Int 3 + +I_ReMix16BitInterpolate2: + Mov AX, [SI] + + MovZX DX, CH + IMul DX ; DX:AX = Remainder*256 + ShL EDX, 16 + Mov DX, AX + + Pop EAX + + Add EAX, EDX + Add EAX, 80h ; Rounding. + ShR EAX, 8 + + Sub ESI, 2 + +I_ReMix16BitStore: + Mov [ES:DI], AX + + Xor AX, AX + Add CX, BX + SetC AL + Add AX, AX + Add AX, BP + Add SI, AX + JC I_ReMix16Bit3 + +I_ReMix16Bit4: + Add DI, 2 + JC I_ReMix16Bit5 + +I_ReMix16Bit6: + Mov EAX, EDI + ShR EAX, 1 + Cmp EAX, CS:NewSampleSize + JB I_ReMix16Bit2 + + Jmp I_ReMixCleanUp + +I_ReMix16Bit3: + Add ESI, 10000h + Int 3 + Jmp I_Remix16Bit4 + +I_ReMix16Bit5: + PushAD + Push DS + Push ES + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + Mov ESI, EDI + Int 3 + + Push DS + Push ES + Pop DS + Pop ES + + Mov CX, 16384 + Xor SI, SI + Xor DI, DI + Rep MovsD + + Pop ES + Pop DS + PopAD + + Add EDI, 10000h + + Call I_RepositionSample + Jmp I_ReMix16Bit6 + +I_ReMixCleanUp: + ; Copy leftover stuff... + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + Mov ESI, EDI + Int 3 + + Push DS + Push ES + Pop DS + Pop ES + + Mov CX, DI + Xor SI, SI + Xor DI, DI + Rep MovsB + + Call I_GetSampleOffset ; Gets DS:BX + Mov SI, BX + Mov ECX, [SI+30h] + Mov EBX, CS:NewSampleSize + ; ECX = length of old samp + ; EBX = length of new samp + Mov [SI+30h], EBX + Add SI, 34h + + Call Near Ptr I_ReMix5 + Call Near Ptr I_ReMix5 + Call Near Ptr I_ReMix5 + Call Near Ptr I_ReMix5 + Call Near Ptr I_ReMix5 + ; Now grab the data from Inst99 + Call I_SwapMemoryAllocation + + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + + Ret + +I_ReMix5: + Mov EAX, [SI] + Mul EBX + + Cmp EDX, ECX + JAE I_ReMix6 + + Div ECX + Cmp EAX, 9999999 + JB I_ReMix7 + +I_ReMix6: + Mov EAX, 9999999 + +I_ReMix7: + Mov [SI], EAX + Add SI, 4 + +I_ReMixEnd: + Ret + +EndP I_ReMix + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ResizeSample Far + + Mov CS:Interpolate, 1 + Jmp I_ResizeJumpPoint + +EndP I_ResizeSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ResizeSampleNoInt Far + + Mov CS:Interpolate, 0 + +I_ResizeJumpPoint: + EnsureNoNetwork + + Call I_GetSampleOffset + Mov AL, [BX+12h] + Test AL, 1 + JZ I_ResizeSampleNoInt1 + + And AL, 2 + Mov CS:Quality, AL + + Cmp DWord Ptr [DS:BX+30h], 0 + JE I_ResizeSampleNoInt1 + + Mov EAX, [DS:BX+30h] ; Old length + Mov CS:NewSampleSize, EAX + + Call F_Reset5NumInputPos + Call S_SaveScreen + + Mov DI, Offset O1_ResizeSampleList + Mov CX, 3 + Call M_Object1List + + Call S_RestoreScreen + + And DX, DX + JZ I_ResizeSampleNoInt1 + + Push CS + Pop DS + Assume DS:Inst + + Mov EDX, NewSampleSize + And EDX, EDX + JZ I_ResizeSampleNoInt1 + + Call I_Remix + +I_ResizeSampleNoInt1: + Mov AX, 1 + Ret + +EndP I_ResizeSampleNoInt + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_CenterSample Far + + EnsureNoNetwork + + Call PE_GetLastInstrument + Mov AX, BX + Inc AX + + Xor CX, CX + Call Music_GetSampleLocation ; Gets DS:SI, and ECX. + ; Zero flag if 8 bit. + JNC I_CenterSample1 + + Xor AX, AX + Ret + +I_CenterSample1: + Push AX ; Remember sample num. + ; Scan through wave first, + ; and find max deviation from + ; mean. + JNZ I_CenterSamplePre16Bit1 + Mov BL, [SI] + Mov DL, [SI] + +I_CenterSamplePre8Bit1: + Mov AL, [SI] + Cmp AL, BL + JL I_CenterSamplePre8Bit3 + Cmp AL, DL + JG I_CenterSamplePre8Bit4 + +I_CenterSamplePre8Bit2: + Add SI, 1 + JC I_CenterSamplePre8BitNextBlock + +I_CenterSamplePre8Bit5: + LoopD I_CenterSamplePre8Bit1 + + MovSX BX, BL + MovSX DX, DL + + Add BX, DX + Neg BX + SAR BX, 1 + + Jmp I_CenterSample2 + +I_CenterSamplePre8Bit3: + Mov BL, AL + Jmp I_CenterSamplePre8Bit2 + +I_CenterSamplePre8Bit4: + Mov DL, AL + Jmp I_CenterSamplePre8Bit2 + +I_CenterSamplePre8BitNextBlock: + Add ESI, 10000h + Int 3 + + Jmp I_CenterSamplePre8Bit5 + +I_CenterSamplePre16Bit: + Mov BX, [SI] + Mov DX, [SI] + +I_CenterSamplePre16Bit1: + Mov AX, [SI] + Cmp AX, BX + JL I_CenterSamplePre16Bit3 + Cmp AX, DX + JG I_CenterSamplePre16Bit4 + +I_CenterSamplePre16Bit2: + Add SI, 2 + JC I_CenterSamplePre16BitNextBlock + +I_CenterSamplePre16Bit5: + LoopD I_CenterSamplePre16Bit1 + + MovSX EBX, BX + MovSX EDX, DX + Add EBX, EDX + Neg EBX + SAR EBX, 1 + + Jmp I_CenterSample2 + +I_CenterSamplePre16Bit3: + Mov BX, AX + Jmp I_CenterSamplePre16Bit2 + +I_CenterSamplePre16Bit4: + Mov DX, AX + Jmp I_CenterSamplePre16Bit2 + +I_CenterSamplePre16BitNextBlock: + Add ESI, 10000h + Int 3 + Jmp I_CenterSamplePre16Bit5 + +I_CenterSample2: + Push BX + + Mov DI, Offset O1_SampleCenterList + Mov CX, 3 + Call M_Object1List + + Pop BX + Pop AX ; AX = sample num + Test DL, 1 + JZ I_CenterSampleEnd + + Call Music_Stop + + Xor CX, CX + Call Music_GetSampleLocation ; Loads DS:ESI and ECX again. + JNZ I_CenterSample16Bit1 + +I_CenterSample8Bit1: + Add [SI], BL + Add SI, 1 + JC I_CenterSample8BitNextBlock + +I_CenterSample8Bit2: + LoopD I_CenterSample8Bit1 + Jmp I_CenterSample3 + +I_CenterSample8BitNextBlock: + Add ESI, 10000h + Int 3 + Jmp I_CenterSample8Bit2 + +I_CenterSample16Bit1: + Add [SI], BX + Add SI, 2 + JC I_CenterSample16BitNextBlock + +I_CenterSample16Bit2: + LoopD I_CenterSample16Bit1 + Jmp I_CenterSample3 + +I_CenterSample16BitNextBlock: + Add ESI, 10000h + Int 3 + Jmp I_CenterSample16Bit2 + +I_CenterSample3: + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_CenterSampleEnd: + Mov AX, 1 + Ret + +EndP I_CenterSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_AmplifySample Far + + EnsureNoNetwork + + Call PE_GetLastInstrument + Mov AX, BX + Inc AX + + Xor CX, CX + Call Music_GetSampleLocation ; Gets DS:SI, and ECX. + JNC I_AmplifySample1 + + Xor AX, AX + Ret + +I_AmplifySample1: + Push AX ; Remember sample num. + ; Scan through wave first, + ; and find max deviation from + ; mean. + Mov BX, 0 ; BX = deviation from mean + JNZ I_AmplifySample11 ; 16 bit stuff. + +I_AmplifySample2: + Mov AL, [SI] +; Sub AL, 80h + CBW + Xor AL, AH + Sub AL, AH + + Cmp AL, BH + JB I_AmplifySample3 + + Mov BH, AL + +I_AmplifySample3: + Add SI, 1 + JC I_AmplifySample8 + +I_AmplifySample9: + LoopD I_AmplifySample2 + Jmp I_AmplifySample10 + +I_AmplifySample8: + Add ESI, 10000h + Int 3 + Jmp I_AmplifySample9 + +I_AmplifySample11: + Mov AX, [SI] +; Sub AX, 8000h + CWD + Xor AX, DX + Sub AX, DX + Cmp AX, BX + JB I_AmplifySample12 + + Mov BX, AX + +I_AmplifySample12: + Add SI, 2 + JC I_AmplifySample13 + +I_AmplifySample14: + LoopD I_AmplifySample11 + Jmp I_AmplifySample10 + +I_AmplifySample13: + Add ESI, 10000h + Int 3 + Jmp I_AmplifySample14 + + +I_AmplifySample10: + ; OK. so BL contains max dev. + ; Amplificat = (8000h/MaxDev)*100 + Xor AX, AX + Mov DX, 32h + + Cmp DX, BX + JAE I_AmplifySample4 + + Div BX + + Cmp AX, 400 + JB I_AmplifySample5 + +I_AmplifySample4: + Mov AX, 400 + +I_AmplifySample5: + Mov CS:SampleAmplification, AX + + Mov DI, Offset O1_SampleAmplificationList + Mov CX, 3 + Call M_Object1List + + Pop AX ; AX = sample num + And DX, DX + JZ I_AmplifySampleEnd + + Call Music_Stop + + Xor CX, CX + Call Music_GetSampleLocation ; Loads DS:ESI and ECX again. + + PushF + + ; NewSample = OldSample*SampleAmplification/100, clipped. + + Mov AX, CS:SampleAmplification + Xor DX, DX + Mov BX, 100 + Div BX + ShL EAX, 16 + Div BX + Mov EBX, EAX ; EBX = multiplier, 16.16 bit. + + PopF + JNZ I_AmplifySample20 + +I_AmplifySample6: + MovSX EAX, Byte Ptr [SI] + + IMul EBX + + Add EAX, 8000h ; Rounding factor + ShR EAX, 16 + + Cmp AX, 7Fh + JGE I_AmplifySampleClip1 + + Cmp AX, -80h + JGE I_AmplifySample7 + + Mov AL, 80h + Jmp I_AmplifySample7 + +I_AmplifySampleClip1: + Mov AL, 7Fh + +I_AmplifySample7: + Mov [SI], AL + Add SI, 1 + JC I_AmplifySample16 + +I_AmplifySample17: + LoopD I_AmplifySample6 + Jmp I_AmplifySample15 + +I_AmplifySample16: + Add ESI, 10000h + Int 3 + Jmp I_AmplifySample17 + +I_AmplifySample20: ; 16 bit amplification!, EBX = 16.16 bit multiplier. + ; Newsample = OldSample*SampleAmplification/100 + + Mov AX, [SI] + MovSX EAX, AX + + IMul EBX + Add EAX, 8000h ; Rounding factor + AdC EDX, 0 ; Rounding stuff, etc. + + ShRD EAX, EDX, 16 + + Cmp EAX, 7FFFh + JGE I_AmplifySampleClip2 + + Cmp EAX, -8000h + JGE I_AmplifySample18 + + Mov AX, 8000h + Jmp I_AmplifySample18 + +I_AmplifySampleClip2: + Mov AX, 7FFFh + +I_AmplifySample18: + Mov [SI], AX + + Add SI, 2 + JC I_AmplifySample21 + +I_AmplifySample19: + LoopD I_AmplifySample20 + Jmp I_AmplifySample15 + +I_AmplifySample21: + Add ESI, 10000h + Int 3 + Jmp I_AmplifySample19 + +I_AmplifySample15: + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_AmplifySampleEnd: + Mov AX, 1 + Ret + +EndP I_AmplifySample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ReverseSample Far + + EnsureNoNetwork + + Call PE_GetLastInstrument + Mov AX, BX + Inc AX + + Xor CX, CX + Call Music_GetSampleLocation ; Gets DS:SI, and CX. + JC I_ReverseSample1 + + JNZ I_ReverseSample10 + + Call Music_Stop + + Push ECX + + Mov EDX, ECX + Mov AX, 99 + Call Music_AllocateSample ; Returns ES:DI + Mov AX, ES + And AX, AX + + Pop ECX + + JZ I_ReverseSampleError + + Mov ESI, ECX + Dec ESI + Call I_RepositionSample + + Mov AX, DiskData + Mov ES, AX + Assume ES:Nothing + + Xor EDI, EDI + +I_ReverseSample2: + Mov AL, [SI] + Mov [ES:DI], AL + + Sub SI, 1 + JC I_ReverseSample4 + +I_ReverseSample5: + Add DI, 1 + JC I_ReverseSample6 + +I_ReverseSample7: + LoopD I_ReverseSample2 + Jmp I_ReverseSample3 + +I_ReverseSample4: + Sub ESI, 10000h + JC I_ReverseSample5 + Int 3 + + Jmp I_ReverseSample5 + +I_ReverseSample6: + PushAD + Push DS + Push ES + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + Mov ESI, EDI + Int 3 + + Push DS + Push ES + + Pop DS + Pop ES + + Xor SI, SI + Xor DI, DI + Mov CX, 16384 + Rep MovsD + + Pop ES + Pop DS + PopAD + Add EDI, 10000h + Call I_RepositionSample + Jmp I_ReverseSample7 + +I_ReverseSample10: + Call Music_Stop + + Push ECX + + Mov EDX, ECX + Add EDX, EDX + Mov AX, 99 + Call Music_AllocateSample ; Returns ES:DI + Mov AX, ES + And AX, AX + + Pop ECX + + JZ I_ReverseSampleError + + Mov ESI, ECX + Dec ESI + Add ESI, ESI + Call I_RepositionSample + + Mov AX, DiskData + Mov ES, AX + Assume ES:Nothing + + Xor EDI, EDI + +I_ReverseSample12: + Mov AX, [SI] + Mov [ES:DI], AX + + Sub SI, 2 + JC I_ReverseSample14 + +I_ReverseSample15: + Add DI, 2 + JC I_ReverseSample16 + +I_ReverseSample17: + LoopD I_ReverseSample12 + Jmp I_ReverseSample3 + +I_ReverseSample14: + Sub ESI, 10000h + JC I_ReverseSample15 + Int 3 + + Jmp I_ReverseSample15 + +I_ReverseSample16: + PushAD + Push DS + Push ES + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + Mov ESI, EDI + Int 3 + + Push DS + Push ES + + Pop DS + Pop ES + + Xor SI, SI + Xor DI, DI + Mov CX, 16384 + Rep MovsD + + Pop ES + Pop DS + PopAD + Add EDI, 10000h + Call I_RepositionSample + Jmp I_ReverseSample17 + + +I_ReverseSampleError: + Call PEFunction_OutOfMemoryMessage + + Mov AX, 1 + Ret + +I_ReverseSample3: + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + + Mov ESI, EDI + Int 3 + + Mov CX, DI + + Push DS + Push ES + Pop DS + Pop ES + + Xor SI, SI + Xor DI, DI + Rep MovsB + + ; Now to release old memory, and swap + ; in new lot... + Call I_SwapMemoryAllocation + + Call I_GetSampleOffset ; Returns DS:BX + + Mov EDX, [BX+30h] ; DX = length + Mov EAX, EDX + Mov ECX, EDX + + Sub EAX, [BX+34h] + Sub ECX, [BX+38h] + Mov [BX+34h], ECX + Mov [BX+38h], EAX + + Mov EAX, EDX + Mov ECX, EDX + + Sub EAX, [BX+40h] + Sub ECX, [BX+44h] + Mov [BX+40h], ECX + Mov [BX+44h], EAX + + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_ReverseSample1: + Mov AX, 1 + Ret + +EndP I_ReverseSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SwapMemoryAllocation + + Call I_GetSampleOffset ; Gets DS:BX + Mov SI, [DS:64912+99*2] + Mov EAX, [SI+48h] + XChg [BX+48h], EAX + Mov [SI+48h], EAX + + Mov AX, 99 + Call Music_ReleaseSample + + Ret + +EndP I_SwapMemoryAllocation + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_RepositionSample + + + Push AX + Push BX + Push ECX + Push ESI + + Call PE_GetLastInstrument + Mov AX, BX ; AX = sample no. + Inc AX + Xor CX, CX + Call Music_GetSampleLocation ; Return DS:ESI, ECX + + Pop ESI + Int 3 + + Pop ECX + Pop BX + Pop AX + Ret + +EndP I_RepositionSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ToggleSampleQuality Far + + EnsureNoNetwork + + Call I_GetSampleOffset + Mov AL, [BX+12h] + Test AL, 1 + JZ I_ToggleSampleQuality1 + + Test AL, 2 + JZ I_To16Bit + +I_To8Bit: + Push DS + Push BX + + Mov DI, Offset O1_ConfirmConvert2List + Mov CX, 3 + Call M_Object1List + + Pop BX + Pop DS + + And DX, DX + JZ I_ToggleSampleQuality1 + + Call Music_Stop + + Cmp DX, 1 + JE I_ConvertTo8Bit + + And Byte Ptr [BX+12h], Not 2 + + ShL DWord Ptr [BX+30h], 1 + ShL DWord Ptr [BX+34h], 1 + ShL DWord Ptr [BX+38h], 1 + ShL DWord Ptr [BX+40h], 1 + ShL DWord Ptr [BX+44h], 1 + + Jmp I_ToggleSampleQualityEnd + +I_ConvertTo8Bit: + Mov EDX, [BX+30h] + Mov AX, 99 ; Shove it into inst 99 first. + Call Music_AllocateSample + + Mov AX, ES + And AX, AX + JZ I_OutOfMemory + + And Byte Ptr [BX+12h], Not 2 + + Call PE_GetLastInstrument + Mov AX, BX ; AX = sample no. + Inc AX + + Xor CX, CX + Call Music_GetSampleLocation ; Return DS:ESI + + Mov AX, DiskData + Mov ES, AX + Assume ES:Nothing + + Xor EDI, EDI + +I_ConvertTo8Bit1: + Mov AX, [SI] +; Add AX, 80h +; SBB AH, 0 + Mov [ES:DI], AH + + Add SI, 2 + JC I_ConvertTo8Bit2 + +I_ConvertTo8Bit3: + Add DI, 1 + JC I_ConvertTo8Bit5 + +I_ConvertTo8Bit4: + LoopD I_ConvertTo8Bit1 + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + + Mov ESI, EDI + Int 3 + + Mov CX, DI + + Push DS + Push ES + Pop DS + Pop ES + + Xor SI, SI + Xor DI, DI + Rep MovsB + + ; Now to release old memory, and swap + ; in new lot... + Call I_SwapMemoryAllocation + + Jmp I_ToggleSampleQualityEnd + +I_ConvertTo8Bit2: + Add ESI, 10000h + Int 3 + Jmp I_ConvertTo8Bit3 + +I_ConvertTo8Bit5: + PushAD + Push DS + Push ES + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + + Mov ESI, EDI + Int 3 + + Push DS + Push ES + + Pop DS + Pop ES + + Xor SI, SI + Xor DI, DI + Mov CX, 16384 + Rep MovsD + + Pop ES + Pop DS + PopAD + + Call I_RepositionSample + + Add EDI, 10000h + Jmp I_ConvertTo8Bit4 + +I_OutOfMemory: + Call PEFunction_OutOfMemoryMessage + Jmp I_ToggleSampleQuality1 + +I_To16Bit: + Push DS + Push BX + + Mov DI, Offset O1_ConfirmConvert2List + Mov CX, 3 + Call M_Object1List + + Pop BX + Pop DS + + And DX, DX + JZ I_ToggleSampleQuality1 + + Call Music_Stop + + Cmp DX, 1 + JE I_ConvertTo16Bit + + Or Byte Ptr [BX+12h], 2 + + ShR DWord Ptr [BX+30h], 1 + ShR DWord Ptr [BX+34h], 1 + ShR DWord Ptr [BX+38h], 1 + ShR DWord Ptr [BX+40h], 1 + ShR DWord Ptr [BX+44h], 1 + + Jmp I_ToggleSampleQualityEnd + +I_ConvertTo16Bit: + Mov EDX, [BX+30h] + Add EDX, EDX + Mov AX, 99 ; Shove it into inst 99 first. + Call Music_AllocateSample + + Mov AX, ES + And AX, AX + JZ I_OutOfMemory + + Or Byte Ptr [BX+12h], 2 + + Mov ECX, [BX+30h] + Xor ESI, ESI + Call I_RepositionSample + + Mov AX, DiskData + Mov ES, AX + Assume ES:Nothing + + Xor EDI, EDI + +I_ConvertTo16Bit1: + Mov AH, [SI] + Xor AL, AL + Mov [ES:DI], AX + + Add SI, 1 + JC I_ConvertTo16Bit2 + +I_ConvertTo16Bit3: + Add DI, 2 + JC I_ConvertTo16Bit5 + +I_ConvertTo16Bit4: + LoopD I_ConvertTo16Bit1 + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + + Mov ESI, EDI + Int 3 + + Mov CX, DI + + Push DS + Push ES + Pop DS + Pop ES + + Xor SI, SI + Xor DI, DI + Rep MovsB + + Call I_SwapMemoryAllocation + + Jmp I_ToggleSampleQualityEnd + +I_ConvertTo16Bit2: + Add ESI, 10000h + Int 3 + Jmp I_ConvertTo16Bit3 + +I_ConvertTo16Bit5: + PushAD + Push DS + Push ES + + Mov AX, 100 + Xor CX, CX + Call Music_GetSampleLocation + + Mov ESI, EDI + Int 3 + + Push DS + Push ES + + Pop DS + Pop ES + + Xor SI, SI + Xor DI, DI + Mov CX, 16384 + Rep MovsD + + Pop ES + Pop DS + PopAD + + Call I_RepositionSample + + Add EDI, 10000h + Jmp I_ConvertTo16Bit4 + +I_ToggleSampleQualityEnd: + Call I_DrawWaveForm + Call Music_SoundCardLoadAllSamples + +I_ToggleSampleQuality1: + Mov AX, 1 + Ret + +EndP I_ToggleSampleQuality + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DrawInstrumentWindow Far + + Call S_GetDestination + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + Test AL, AL + JNZ I_DrawInstrumentWindow1 + + Inc AX + Mov LastInstrument, AL + +I_DrawInstrumentWindow1: ; AL = last instrument + Xor AH, AH ; Now for bounds check. + + Push CS + Pop DS + Assume DS:Inst + + Mov BX, TopInstrument + Cmp AX, BX + JAE I_DrawInstrumentWindow2 + + Mov BX, AX + +I_DrawInstrumentWindow2: + Mov CX, BX + Add CX, 34 + Cmp CX, AX + JAE I_DrawInstrumentWindow3 + + Mov BX, AX + Sub BX, 34 + +I_DrawInstrumentWindow3: + Mov TopInstrument, BX ; OK.. now to draw nums + Push AX + + Mov DI, (2+13*80)*2 + + Mov DX, 0A23h + +I_DrawInstrumentWindow4: + Mov AX, BX + Div DH + ; AH = units, AL = tens + Add AL, '0' + StosB + Mov AL, 20h + StosB + XChg AH, AL + Add AL, '0' + StosW + + Inc BX + Add DI, 156 + Dec DL + JNE I_DrawInstrumentWindow4 + + Mov BX, TopInstrument + + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + Mov DX, 35 + Mov DI, (5+13*80)*2 + Dec BX + Mov SI, BX + Add SI, SI + Mov SI, [SI+64712] + Add SI, 20h + + Pop CX ; CX = last instrument + Dec CX + +I_DrawInstrumentWindow5: + Push CX + + Mov AH, 6 + Cmp BX, CX + JNE I_DrawInstrumentWindow7 + + Mov AH, 0E6h + +I_DrawInstrumentWindow7: + Mov CX, 25 + +I_DrawInstrumentWindow6: + LodsB + + Cmp AL, 226 + JB I_DrawInstrumentNoMouse + + Mov AL, ' ' + +I_DrawInstrumentNoMouse: + StosW + Loop I_DrawInstrumentWindow6 + + Add DI, 160-(25*2) + Add SI, 554-25 + Pop CX + + Inc BX + Dec DX + JNZ I_DrawInstrumentWindow5 + + Push CS + Pop DS + + Mov SI,Offset SampleMouseEvent + Mov Word Ptr [SI+4], 30*8-1 + Mov Word Ptr [SI+10], 4 + Call AddSelectEvent + Mov SI, Offset SampleMouseOffEvent + Mov Word Ptr [SI+4], 30*8-1 + Call MouseAddEvent + + Ret + +EndP I_DrawInstrumentWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PreInstrumentWindow Far + + Call S_GetDestination + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, LastInstrument + Xor AH, AH + Mov SI, AX + Sub AX, TopInstrument + Add AX, 13 + Mov BX, 160 + Mul BX + Add AX, 11 + Mov DI, AX + Cmp InstrumentEdit, 1 + JE I_PreInstrumentWindow2 + + Mov CX, 25 + +I_PreInstrumentWindow1: + Mov Byte Ptr [ES:DI], 30h +; Add DI, 2 + ScasW + + Loop I_PreInstrumentWindow1 + Ret + +I_PreInstrumentWindow2: + Mov AX, CS:InstrumentPos + Add AX, AX + Add DI, AX + Mov Byte Ptr [ES:DI], 30h + + Ret + +EndP I_PreInstrumentWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_AllocateChannel Far ; Given AX = Base channel, DL = note + ; Finds physical channel, returns AX + ; if no channel available, then + ; overtakes channel at base channel + ; Given DI = max channel + Push BX CX DX SI DS + + Push DX + + Push CS + Pop DS + Assume DS:Inst + + Mov DX, AX + Mov BX, AX + +MIDI_AllocateChannel1: + Inc DX + Cmp DX, DI + JA MIDI_AllocateChannelOvertake + + Mov SI, Offset MIDITable + Mov CX, 128 + +MIDI_AllocateChannel2: + LodsB + Cmp AL, DL + JE MIDI_AllocateChannel1 + Loop MIDI_AllocateChannel2 + + Mov AX, DX + Jmp MIDI_AllocateChannelEnd + +MIDI_AllocateChannelOvertake: ; Search for basechannel + Mov SI, Offset MIDITable + +MIDI_AllocateChannel3: + LodsB + Cmp AL, DL + JNE MIDI_AllocateChannel3 + + ; Clear out last entry... + Mov Byte Ptr [SI-1], 0 + Mov AX, BX + Inc AX + +MIDI_AllocateChannelEnd: + Pop BX ; BL = note + And BX, 07Fh + Mov [MIDITable+BX], AL + + Dec AX + + Pop DS SI DX CX BX + Ret + +EndP MIDI_AllocateChannel + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_GetChannel Far + + Xor AX, AX + Mov AL, [CS:MIDITable+BX] + Ret + +EndP MIDI_GetChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_FindChannel Far ; Given BX = Note, returns AX = channel + ; number, cleans up table, AL = 0FFh = + ; note not present + + Xor AX, AX + XChg [CS:MIDITable+BX], AL + Dec AL + + Ret + +EndP MIDI_FindChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_ClearTable Far + + Push AX CX ES DI + + Push CS + Pop ES + + Mov DI, Offset MIDITable + Xor AX, AX + Mov CX, 64 + Rep StosW + + Pop DI ES CX AX + + Ret + +EndP MIDI_ClearTable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_NoteOff Far + + Push CS + Pop DS + Assume DS:Inst + + ; DL = note +MIDI_NoteOff2: + Call Music_GetInstrumentMode + Mov CX, 0FFh + JNZ MIDI_NoteOff3 + + Dec CX + +MIDI_NoteOff3: + MovZX BX, DL + Call MIDI_FindChannel + Cmp AL, 0FFh + JE MIDI_NoteOff1 + + Mov SI, Offset NoteData + Mov Word Ptr [SI], CX ; Note off/cut + Mov Word Ptr [SI+3], 0 ; No effect + Mov DH, 32 + Call Music_PlayNote + +MIDI_NoteOff1: + Mov AX, 1 +; Xor AX, AX + Ret + +EndP MIDI_NoteOff + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_PlayNote Far + + Push CS + Pop DS + Assume DS:Inst + + Call PE_TranslateMIDI + JC MIDI_PlayNote1 + JZ MIDI_NoteOff2 + + Call PE_GetLastInstrument + Mov AH, BL + Inc AH + Mov AL, DL ; Note + + Mov SI, Offset NoteData + Mov [SI], AX + Mov [SI+2], DH + Mov Word Ptr [SI+3], 0 + + Call Music_GetNumChannels ; Into AX + Mov DI, AX + Mov AX, PlayChannel + Call PE_RestoreMIDINote + Call MIDI_AllocateChannel + + Mov DH, 32 + Call Music_PlayNote + + Mov Byte Ptr [SI+2], 0FFh + Mov AX, 1 + Ret + +MIDI_PlayNote1: + Xor AX, AX + Ret + + +EndP MIDI_PlayNote + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PlayNote Far + + Push CS + Pop DS + Assume DS:Inst + + Test CH, Not 1 + JNZ I_PlayNote5 + + Cmp CX, LastKey + JE I_PlayNote5 + + Mov LastKey, CX + + Mov SI, Offset KeyBoardTable + +I_PlayNote1: + LodsW + Cmp AX, 0FFFFh + JE I_PlayNote5 + + Mov BX, AX + LodsW + + Cmp BL, CL + JNE I_PlayNote1 + ; Note to play... + ; AX = notemod. + Mov CL, AL + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, 12 + Mul BaseOctave + Add AL, CL + Cmp AL, 119 + JBE I_PlayNoteMax + + Mov AL, 119 + +I_PlayNoteMax: + Mov DL, AL + + Test CH, CH + JZ MIDI_NoteOff + + Call PE_GetLastInstrument + Mov AH, BL + Inc AH + + Push CS + Pop DS + + MovZX BX, AL + Cmp [MIDITable+BX], 0 + JNE I_PlayNote6 + + Call UpdateMultiChannel + + Mov PlayNote, AL + +I_PlayNote3: + Mov SI, Offset NoteData + Mov [SI], AX + + Push DS + + Call I_GetInstrumentOffset + + Test Byte Ptr [BX+19h], 80h + Mov DH, 32 + JZ I_PlayNote4 + + Add DH, 128 + +I_PlayNote4: + Pop DS + Call Music_GetNumChannels ; Into AX + Mov DI, AX + Mov AX, PlayChannel + Call MIDI_AllocateChannel + Call Music_PlayNote + +I_PlayNote6: + Mov AX, 1 + Ret + +I_PlayNote5: + Xor AX, AX + Ret + +EndP I_PlayNote + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PostInstrumentWindow Far + Assume DS:Inst + + Push CS + Pop DS + Mov SI, Offset InstrumentListKeys + Call M_FunctionDivider + JC I_PostInstrumentWindow1 + + Jmp [SI] + +I_PostInstrumentWindow1: + Cmp InstrumentEdit, 0 + JE I_PostInstrumentWindow7 + + Cmp CX, 101h + JE I_PostInstrumentWindow15 + Cmp CX, 11Ch + JNE I_PostInstrumentWindow13 + +I_PostInstrumentWindow15: + Mov InstrumentEdit, 0 + Jmp I_PostInstrumentWindow12 + +I_PostInstrumentWindow13: + Call PE_GetLastInstrument + Mov SI, BX + Mov BX, InstrumentPos + ; BX = Pos, SI = LastInst + Call Music_GetSongSegment + Mov DS, AX + Assume DS:Nothing + + Add SI, SI + Mov SI, [64712+SI] ; SI = instrument offset. + + Test CL, CL + JZ I_PostInstrumentWindow3 + Cmp DL, 32 + JB I_PostInstrumentWindow3 + + Add BX, 20h + Add BX, SI + Add SI, 38h + +I_PostInstrumentWindow2: + Cmp SI, BX + JBE I_PIW2 + + Mov AL, [SI-1] + Mov [SI], AL + Dec SI + Jmp I_PostInstrumentWindow2 + +I_PIW2: + + Mov [SI], DL + NetworkSendInstrument + + Push CS + Pop DS + Jmp I_InstrumentRight + +I_PostInstrumentWindow3: + Cmp CX, 10Eh ; Backspace + JNE I_PostInstrumentWindow5 + + And BX, BX + JZ I_PostInstrumentWindow6 + + Dec InstrumentPos + Add BX, 20h + Add BX, SI + Add SI, 39h + +I_PostInstrumentWindow4: + Mov AL, [BX] + Mov [BX-1], AL + Inc BX + Cmp BX, SI + JB I_PostInstrumentWindow4 + + Mov Byte Ptr [BX-1], 0 + NetworkSendInstrument + +I_PostInstrumentWindow12: + + Mov AX, 1 + Ret + +I_PostInstrumentWindow5: + Assume DS:Inst + + Cmp CX, 1D3h ; Delete... + JNE I_PostInstrumentWindow6 + + Add BX, 21h + Add BX, SI + Add SI, 39h + Jmp I_PostInstrumentWindow4 + +I_PostInstrumentWindow6: + Xor AX, AX + Ret + +I_PostInstrumentWindow7: + Assume DS:Inst + Cmp DX, ' ' ; Spacebar + JNE I_PostInstrumentWindow14 + + Mov InstrumentEdit, 1 + Mov InstrumentPos, 0 + + Mov AX, 1 + Ret + +I_PostInstrumentWindow14: + Xor AX, AX + Ret + +EndP I_PostInstrumentWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentLeft Far + + Assume DS:Inst + + Cmp InstrumentEdit, 0 + JE I_InstrumentLeft2 + + Cmp InstrumentPos, 0 + JE I_InstrumentLeft1 + + Dec InstrumentPos +; Jmp I_InstrumentLeft1 + +I_InstrumentLeft2: +; Mov Word Ptr [ES:DI], 8 + +I_InstrumentLeft1: + Mov AX, 1 + Ret + +EndP I_InstrumentLeft + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentRight Far + + Assume DS:Inst + + Cmp InstrumentEdit, 0 + JE I_InstrumentRight2 + + Cmp InstrumentPos, 24 + JAE I_InstrumentRight1 + + Inc InstrumentPos + Jmp I_InstrumentRight1 + +I_InstrumentRight2: + Mov Word Ptr [ES:DI], 5 + +I_InstrumentRight1: + Mov AX, 1 + Ret + + +EndP I_InstrumentRight + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentHome Far + + Assume DS:Inst + + Mov InstrumentPos, 0 + + Mov AX, 1 + Ret + +EndP I_InstrumentHome + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentEnd Far + + Assume DS:Inst + + Mov InstrumentPos, 24 + + Mov AX, 1 + Ret + +EndP I_InstrumentEnd + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentTab Far + + Mov Word Ptr [ES:DI], 5 + + Mov AX, 1 + Ret + +EndP I_InstrumentTab + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentShiftTab Far + + Mov Word Ptr [ES:DI], 8 + + Mov AX, 1 + Ret + +EndP I_InstrumentShiftTab + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentNameClear Far + + Call I_GetInstrumentOffset + Push DS + Pop ES + Mov DI, BX + + Xor AX, AX + Mov CX, 6 + Add DI, 4 + Rep StosW + + Add DI, 10h + Mov CX, 13 + Rep StosW + + NetworkSendInstrument + + Inc AX + Ret + +EndP I_InstrumentNameClear + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentClear Far + + Call PE_GetLastInstrument + Mov AX, BX + Call Music_ClearInstrument + + Call I_MapEnvelope + + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_InstrumentClear + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DrawNoteWindow Far + + Push CS + Pop DS + Assume DS:Inst + + Mov SI, Offset NoteMouseEvent + Call AddSelectEvent + Mov SI, Offset NoteMouseOffEvent + Call MouseAddEvent + + Mov AX, CurrentNote + ; Now for bounds check. + + Mov BX, TopNote + Cmp AX, BX + JAE I_DrawNoteWindow2 + + Mov BX, AX + +I_DrawNoteWindow2: + Mov CX, BX + Add CX, 31 + Cmp CX, AX + JAE I_DrawNoteWindow3 + + Mov BX, AX + Sub BX, 31 + +I_DrawNoteWindow3: + Mov TopNote, BX ; OK.. now to draw nums + Mov CX, BX + + Call S_GetDestination + + Call I_GetInstrumentOffset + Add BX, 40h + Add BX, CX + Add BX, CX + Mov DI, (32+16*80)*2 + + Mov DX, 0C20h + XChg SI, BX + ; DS:SI = pointer to translation + ; ES:DI = screen + ; CX = Current note. +I_DrawNoteWindow4: + ; Draw left hand note first. + Mov AX, CX + Div DH ; AH = note, AL = octave. + Push AX + + Mov AL, AH + Mov BX, AX + And BX, 0FFh ; BX = note. + Add BX, BX ; BX = note*2 + Mov AH, 2 + Mov AL, [CS:BX+NoteTable] + StosW + Mov AL, [CS:BX+NoteTable+1] + StosW + + Pop AX ; AL = octave + Add AL, '0' + Mov AH, 2 + StosW + + ; View division... + Mov AL, 0A8h + StosW + ; Note translation... + + LodsB ; AL = note.. + Xor AH, AH + Div DH + Push AX + + Mov AL, AH + Mov BX, AX + And BX, 0FFh ; BX = note. + Add BX, BX ; BX = note*2 + Mov AH, 2 + Mov AL, [CS:BX+NoteTable] + StosW + Mov AL, [CS:BX+NoteTable+1] + StosW + + Pop AX ; AL = octave + Add AL, '0' + Mov AH, 2 + StosW + + Mov AL, ' ' + StosW + ; Now sample number. + LodsB ; AL = sample number (base 0) +; Inc AL ; Convert to base 1 + + And AL, AL + JNZ I_DrawNoteWindow5 + + Mov AL, 173 + StosW + StosW + Jmp I_DrawNoteWindow6 + +I_DrawNoteWindow5: + Xor AH, AH + Mov BL, 10 + Div BL ; AH = units, AL = tens. + Add AX, 3030h + Mov BL, AH + Mov AH, 2 + StosW + Mov AL, BL + StosW + +I_DrawNoteWindow6: + Add DI, 160-10*2 + + Inc CX + Dec DL + JNZ I_DrawNoteWindow4 + + Ret + +EndP I_DrawNoteWindow + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PreNoteWindow Far + + Push CS + Pop DS + Assume DS:Inst + + Call S_GetDestination + Mov AX, CurrentNote + Sub AX, TopNote + Add AX, 16 + Mov BX, 160 + Mul BX + Add AX, 32*2 + Mov DI, AX ; First hilight the row.. + + Mov CX, 10 + Push DI + +I_PreNoteWindow1: + Inc DI + Or Byte Ptr [ES:DI], 0E0h + Inc DI + Loop I_PreNoteWindow1 + + Pop DI + + Mov BX, NotePos + Mov BL, [NotePosTable+BX] + Xor BH, BH + Add DI, BX + Add DI, BX + + Inc DI + Mov Byte Ptr [ES:DI], 30h + + Ret + +EndP I_PreNoteWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PostNoteWindow Far + + Push CS + Pop DS + Assume DS:Inst + + Mov SI, Offset NoteListKeys + Call M_FunctionDivider + JC I_PostNoteWindow1 + + Jmp [SI] + +I_PostNoteWindow1: + Cmp NotePos, 0 + JNE I_PostNoteWindow5 + + Mov SI, Offset KeyBoardTable + +I_PostNoteWindow2: + LodsW + Cmp AX, 0FFFFh + JE I_PostNoteWindow3 + + Mov BX, AX + LodsW + + Cmp BX, CX + JNE I_PostNoteWindow2 + ; Note to play... + ; AX = notemod. + Mov CX, AX + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AL, 12 + Mul BaseOctave + + Push CS + Pop DS + Assume DS:Inst + Mov SI, CurrentNote + Add SI, SI + + Add CX, AX + Cmp CX, 119 + JA I_PostNoteWindow4 ; If note > B-9... not valid! + + Mov CH, SampleNumber + + Call I_GetInstrumentOffset + Mov [DS:BX+SI+40h], CX + + Push CS + Pop DS + + Mov SI, Offset NoteData + Call PE_GetLastInstrument + Mov AH, BL + Inc AH + Mov AL, Byte Ptr CurrentNote + Mov [SI], AX + + Mov AX, PlayChannel + Mov DH, 32+128 + Call Music_PlayNote + + NetworkSendInstrument + Jmp I_NoteDown + +I_PostNoteWindow4: + Mov AX, 1 + Ret + +I_PostNoteWindow3: + Xor AX, AX + Ret + +I_PostNoteWindow5: + Cmp DL, '0' + JB I_PostNoteWindow6 + Cmp DL, '9' + JA I_PostNoteWindow6 + + Sub DL, '0' + + Mov SI, CurrentNote + Add SI, SI + + Call I_GetInstrumentOffset + Assume DS:Nothing + ; DS:BX points to inst. + Add BX, 40h + + Mov AX, NotePos + Cmp AL, 1 + JE I_PostNoteWindow7 + + Inc BX + + Cmp AL, 2 + JE I_PostNoteWindow8 + + Cmp AL, 3 + JE I_PostNoteWindow9 + +I_PostNoteWindow6: + Cmp DX, '.' + JNE I_PostNoteWindow10 + Cmp NotePos, 2 + JB I_PostNoteWindow10 + + Mov SI, CurrentNote + Add SI, SI + + Call I_GetInstrumentOffset + Assume DS:Nothing + Add BX, SI + Add BX, 41h + Mov Byte Ptr [BX], 0 + + NetworkSendInstrument + Jmp I_NoteDown + +I_PostNoteWindow10: + Xor AX, AX + Ret + +I_PostNoteWindow7: ; Octave of note. + Mov AL, [DS:BX+SI] ; AL = Note + Xor AH, AH + Mov CL, 0Ch + Div CL ; AL = octave, AH = Note + + Mov AL, DL + Mov CH, AH + Mul CL + Add AL, CH ; AL = new note + + Mov [DS:BX+SI], AL + + NetworkSendInstrument + Jmp I_NoteDown + +I_PostNoteWindow8: + Mov AL, [DS:BX+SI] ; AL = sample. + Xor AH, AH + Mov CL, 10 + Div CL ; AL = tens, AH = units + + Mov AL, DL + Mov CH, AH + Mul CL + Add AL, CH + + Mov SampleNumber, AL + Mov [DS:BX+SI], AL + + NetworkSendInstrument + Jmp I_NoteRight + +I_PostNoteWindow9: + Mov AL, [DS:BX+SI] + Xor AH, AH + Mov CL, 10 + Div CL + + Mov CH, AH + Mul CL + + Add AL, DL + + Mov SampleNumber, AL + Mov [DS:BX+SI], AL + + Mov NotePos, 2 + +I_PostNoteWindowEnd: + NetworkSendInstrument + Jmp I_NoteDown + +EndP I_PostNoteWindow + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SelectNoteMouse Far + Assume DS:Inst + + ShR DX, 3 + Add DX, TopNote + Sub DX, 16 + JNC I_SelectNoteMouse1 + + Xor DX, DX + +I_SelectNoteMouse1: + Cmp DX, 119 + JB I_SelectNoteMouse2 + + Mov DX, 119 + +I_SelectNoteMouse2: + Mov CurrentNote, DX + + Mov AX, 1 + Ret + +EndP I_SelectNoteMouse + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteUp Far + + Assume DS:Inst + + Mov AX, CurrentNote + Dec AX + JS I_NoteUp2 + + Mov CurrentNote, AX + Jmp I_NoteUp1 + +I_NoteUp2: + Mov Word Ptr [ES:DI], 5 + +I_NoteUp1: + Mov AX, 1 + Ret + +EndP I_NoteUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteDown Far + + Push CS + Pop DS + Assume DS:Inst + + Mov AX, CurrentNote + Inc AX + Cmp AX, 119 + JA I_NoteDown1 + + Mov CurrentNote, AX + +I_NoteDown1: + Mov AX, 1 + Ret + +EndP I_NoteDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NotePgUp Far + + Assume DS:Inst + + Mov AX, CurrentNote + Sub AX, 12 + JNS I_NotePgUp1 + + Xor AX, AX + +I_NotePgUp1: + Mov CurrentNote, AX + + Mov AX, 1 + Ret + +EndP I_NotePgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NotePgDn Far + + Assume DS:Inst + + Mov AX, CurrentNote + Add AX, 12 + Cmp AX, 119 + JBE I_NotePgDn1 + + Mov AX, 119 + +I_NotePgDn1: + Mov CurrentNote, AX + + Mov AX, 1 + Ret + +EndP I_NotePgDn + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteRight Far + + Push CS + Pop DS + Assume DS:Inst + + Mov AX, NotePos + Inc AX + Cmp AX, 4 + JB I_NoteRight1 + + Mov AX, 3 + +I_NoteRight1: + Mov NotePos, AX + + Mov AX, 1 + Ret + +EndP I_NoteRight + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteLeft Far + + Assume DS:Inst + Mov AX, NotePos + Dec AX + JS I_NoteLeft1 + + Mov NotePos, AX + +I_NoteLeft1: + Mov AX, 1 + Ret + +EndP I_NoteLeft + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteHome Far + Assume DS:Inst + + Mov CurrentNote, 0 + + Mov AX, 1 + Ret + +EndP I_NoteHome + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteEnd Far + Assume DS:Inst + + Mov CurrentNote, 119 + + Mov AX, 1 + Ret + +EndP I_NoteEnd + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteTab Far + + Mov Word Ptr [ES:DI], 16 + + Mov AX, 1 + Ret + +EndP I_NoteTab + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteShiftTab Far + + Mov Word Ptr [ES:DI], 4 + + Mov AX, 1 + Ret + +EndP I_NoteShiftTab + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteSampleIncrease Far + + Assume DS:Inst + + Mov AL, SampleNumber + Inc AX + Cmp AL, 99 + JA I_NoteSampleIncrease1 + + Mov SampleNumber, AL + +I_NoteSampleIncrease1: + Mov AX, 1 + Ret + +EndP I_NoteSampleIncrease + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteSampleDecrease Far + + Assume DS:Inst + + Mov AL, SampleNumber + Dec AL + JS I_NoteSampleDecrease1 + + Mov SampleNumber, AL + +I_NoteSampleDecrease1: + Mov AX, 1 + Ret + +EndP I_NoteSampleDecrease + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteSamplePickUp Far + + Assume DS:Nothing + + Call I_GetInstrumentOffset + + Mov SI, CurrentNote + Mov AX, SI + Mov PlayNote, AL + Add SI, SI + + Mov AX, [DS:BX+SI+40h] + + Mov SampleNumber, AH + + Mov AX, 1 + Ret + +EndP I_NoteSamplePickUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteNext Far + Assume DS:Inst + + Mov SI, CurrentNote + Add SI, SI + JZ I_NoteNext1 + + Call I_GetInstrumentOffset + Assume DS:Nothing + + Add BX, SI + Add BX, 40h + + Mov AX, [DS:BX-2] ; 'Last note.' + Cmp AL, 119 ; Is previous note >= B-9 + JAE I_NoteNext1 + + Inc AX + Mov [DS:BX], AX + + NetworkSendInstrument + Jmp I_NoteDown + +I_NoteNext1: + Mov AX, 1 + Ret + +EndP I_NoteNext + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NotePrevious Far + Assume DS:Inst + + Mov SI, CurrentNote + Cmp SI, 119 + JAE I_NotePrevious1 + + Add SI, SI + + Call I_GetInstrumentOffset + Assume DS:Nothing + + Add BX, SI + Add BX, 40h + + Mov AX, [DS:BX+2] ; 'Last note.' + Test AL, AL + JZ I_NotePrevious1 + + Dec AX + Mov [DS:BX], AX + + Push CS + Pop DS + Assume DS:Inst + + Mov AX, CurrentNote + Dec AX + JS I_NotePrevious1 + + Mov CurrentNote, AX + NetworkSendInstrument + +I_NotePrevious1: + + Mov AX, 1 + Ret + +EndP I_NotePrevious + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteAll Far + + Assume DS:Nothing + + Call I_GetInstrumentOffset + Push DS + Pop ES + + LEA DI, [BX+40h] + + Mov CX, 120 + Mov AH, SampleNumber + Xor AL, AL + + +I_NoteAll1: + StosW + Inc AX + Loop I_NoteAll1 + + Sub DI, 110h + + MovZX BX, SampleNumber + Add BX, BX + JZ I_NoteAll2 + + Mov SI, [BX+64910] + Add SI, 14h + + Mov CX, 26 + Rep MovsB + +I_NoteAll2: + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_NoteAll + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteInsert Far + + Assume DS:Nothing + + Call I_GetInstrumentOffset + Push DS + Pop ES + LEA DI, [BX+40h+120*2-2] + LEA SI, [DI-2] + Mov CX, 119 + + StD + Rep MovsW + Xor AX, AX + StosW + ClD + + NetworkSendInstrument + Mov AX, 1 + Ret + +EndP I_NoteInsert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteDelete Far + + Assume DS:Nothing + + Call I_GetInstrumentOffset + Push DS + Pop ES + LEA DI, [BX+40h] + LEA SI, [DI+2] + Mov CX, 119 + + Rep MovsW + Xor AX, AX + StosW + + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_NoteDelete + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteTransposeUp Far + + Assume DS:Nothing + + Call I_GetInstrumentOffset + Push DS + Pop ES + + LEA DI, [BX+40h] + + Mov CX, 120 + +I_NoteTransposeUp1: + Mov AL, [DI] + Inc AX + Cmp AL, 119 + JBE I_NoteTransposeUp2 + + Mov AL, 119 + +I_NoteTransposeUp2: + StosB + Inc DI + Loop I_NoteTransposeUp1 + + NetworkSendInstrument + Mov AX, 1 + Ret + +EndP I_NoteTransposeUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteTransposeDown Far + + Assume DS:Nothing + + Call I_GetInstrumentOffset + Push DS + Pop ES + + LEA DI, [BX+40h] + + Mov CX, 120 + +I_NoteTransposeDown1: + Mov AL, [DI] + Sub AL, 1 + AdC AL, 0 + StosB + Inc DI + Loop I_NoteTransposeDown1 + + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_NoteTransposeDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_NoteSpace Far + + Assume DS:Inst + Cmp NotePos, 2 + JB I_NoteSpace1 + + Mov SI, CurrentNote + Add SI, SI + + Call I_GetInstrumentOffset + Assume DS:Nothing + Mov AL, SampleNumber + Mov [BX+SI+41h], AL + + Jmp I_NoteDown + +I_NoteSpace1: + NetworkSendInstrument + Xor AX, AX + Ret + +EndP I_NoteSpace + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ExchangeInstruments Far + + EnsureNoNetwork + + Mov DI, Offset O1_ExchangeInstrumentList + Call GetNumberInput + + Mov SI, DX + Dec SI + Add SI, SI + + Call PE_GetLastInstrument + Add BX, BX + + Cmp SI, BX + JE I_ExchangeInstruments1 + + Call Music_GetSongSegment + Mov ES, AX + Mov DS, AX + Mov DI, [DS:64712+BX] + Mov SI, [DS:64712+SI] ; DS:SI, ES:DI point to + ; sample headers + + Mov CX, 554 + +I_ExchangeInstruments2: + Mov AL, [ES:DI] + MovsB + Mov [DS:SI-1], AL + + Loop I_ExchangeInstruments2 + + Call I_MapEnvelope + +I_ExchangeInstruments1: + Mov AX, 1 + Ret + +EndP I_ExchangeInstruments + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DoubleSampleSpeed Far + + Call I_GetSampleOffset + Mov EAX, [BX+3Ch] + ShL EAX, 1 + Cmp EAX, 9999999 + JA I_DoubleSampleSpeed1 + + Mov [BX+3Ch], EAX + +I_DoubleSampleSpeed1: + NetworkSendSample + + Mov AX, 1 + Ret + +EndP I_DoubleSampleSpeed + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_HalveSampleSpeed Far + + Call I_GetSampleOffset + ShR DWord Ptr [BX+3Ch], 1 + + NetworkSendSample + + Mov AX, 1 + Ret + +EndP I_HalveSampleSpeed + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleSpeedSemiUp Far + + Call I_GetSampleOffset + + Mov EAX, 255392045 + Mul DWord Ptr [BX+3Ch] + + Add EDX, [BX+3Ch] + JC I_SampleSpeedSemiUp1 + + Mov [BX+3Ch], EDX + +I_SampleSpeedSemiUp1: + NetworkSendSample + + Mov AX, 1 + Ret + +EndP I_SampleSpeedSemiUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleSpeedSemiDown Far + + Call I_GetSampleOffset + + Mov EAX, 4053909306 + Mul DWord Ptr [BX+3Ch] + Mov [BX+3Ch], EDX + + NetworkSendSample + + Mov AX, 1 + Ret + +EndP I_SampleSpeedSemiDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ReplaceInstrument Far + + EnsureNoNetwork + + Mov DI, Offset O1_ReplaceInstrumentList + Call GetNumberInput + + Call PE_GetLastInstrument + Mov DH, BL + Inc DH ; DH/DL = samples to swap + + Cmp DL, DH + JE I_ReplaceInstrument1 + + Call Music_GetInstrumentMode + JZ I_ReplaceInstrument1 + + XChg DH, DL + Or DH, 80h + Call PE_SwapInstruments + +I_ReplaceInstrument1: + Mov AX, 1 + Ret + +EndP I_ReplaceInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ScaleSampleVolumes Far + + EnsureNoNetwork + + Mov DI, Offset O1_GetInstrumentAmpList + Mov CX, 3 + Call M_Object1List + + Cmp DX, 1 + JNE I_ScaleSampleVolumesEnd + + Mov BP, CS:InstrumentAmplification + Mov BX, 100 + + Call Music_GetSongSegment + Mov DS, AX + Mov SI, 64912 + Mov CX, 99 + +I_ScaleSampleVolumes1: + Xor AX, AX + Mov DI, [SI] + Mov AL, [DI+11h] + Mul BP + Div BX + Cmp AX, 64 + JB I_ScaleSampleVolumes2 + + Mov AX, 64 + +I_ScaleSampleVolumes2: + Mov [DI+11h], AL + + Add SI, 2 + Dec CX + JNZ I_ScaleSampleVolumes1 + +I_ScaleSampleVolumesEnd: + Mov AX, 1 + Ret + +EndP I_ScaleSampleVolumes + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ScaleInstrumentVolumes Far + + EnsureNoNetwork + + Mov DI, Offset O1_GetInstrumentAmpList + Mov CX, 3 + Call M_Object1List + + Cmp DX, 1 + JNE I_ScaleInstrumentVolumesEnd + + Mov BP, CS:InstrumentAmplification + Mov BX, 100 + + Call Music_GetSongSegment + Mov DS, AX + Mov SI, 64712 + Mov CX, 99 + +I_ScaleInstrumentVolumes1: + Xor AX, AX + Mov DI, [SI] + Mov AL, [DI+18h] + Mul BP + Div BX + Cmp AX, 128 + JB I_ScaleInstrumentVolumes2 + + Mov AX, 128 + +I_ScaleInstrumentVolumes2: + Mov [DI+18h], AL + + Add SI, 2 + Dec CX + JNZ I_ScaleInstrumentVolumes1 + +I_ScaleInstrumentVolumesEnd: + Mov AX, 1 + Ret + +EndP I_ScaleInstrumentVolumes + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_CopyInstrument Far + + Mov DI, Offset O1_CopyInstrumentList + Call GetNumberInput + + Call I_GetInstrumentOffset ; Gets DS:BX with cur inst. + + Mov DI, BX + Mov SI, DX + Add SI, SI + Mov SI, [64710+SI] + + Push DS + Pop ES + + Mov CX, 554/2 + Rep MovsW + + Call I_MapEnvelope + + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_CopyInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SwapInstruments Far + + EnsureNoNetwork + + Mov DI, Offset O1_SwapInstrumentList + Call GetNumberInput + + Mov SI, DX +; Dec SI + Add SI, SI + + Call PE_GetLastInstrument + Mov DH, BL + Inc DH ; DH/DL = samples to swap + Add BX, BX + + Cmp DL, DH + JE I_SwapInstruments1 + + Call Music_GetSongSegment + Mov ES, AX + Mov DS, AX + Mov DI, [DS:64712+BX] + Mov SI, [DS:64710+SI] ; DS:SI, ES:DI point to + ; sample headers + + Mov CX, 554 + +I_SwapInstruments2: + Mov AL, [ES:DI] ; Swapping headers. + MovsB + Mov [DS:SI-1], AL + + Loop I_SwapInstruments2 + + ; Now to swap pattern + ; stuff... + Call Music_GetInstrumentMode + JZ I_SwapInstruments3 + + Call PE_SwapInstruments + +I_SwapInstruments3: + Call I_MapEnvelope + +I_SwapInstruments1: + Mov AX, 1 + Ret + +EndP I_SwapInstruments + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_UpdateInstrument Far + + EnsureNoNetwork + + Call PE_GetLastInstrument + Mov DX, BX + Inc DX + Add BX, BX + + Call Music_GetSongSegment + Mov ES, AX + Mov DI, [ES:64712+BX] + Add DI, 40h + + Call PE_UpdateInstruments + + Mov AX, 1 + Ret + +EndP I_UpdateInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseEnvelopeEvent1 Far + + Mov CS:MouseX, CX + Mov CS:MouseY, DX + + Mov CX, 8010h ; Envelope mouse control request.. + Call AddMouseQueue + + Xor AX, AX + Ret + +EndP MouseEnvelopeEvent1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseEnvelopeEvent4 Far ; Delete node + + Test BH, 6 + JNZ MouseEnvelopeEvent4_1 + + Mov CS:MouseX, CX + Mov CS:MouseY, DX + + Mov CX, 8003h ; Envelope mouse control request.. + Call AddMouseQueue + +MouseEnvelopeEvent4_1: + Xor AX, AX + Ret + +EndP MouseEnvelopeEvent4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseEnvelopeEvent2 Far ; Envelope drag + + Mov CS:MouseX, CX + Mov CS:MouseY, DX + + Mov CX, 8001h + Call AddMouseQueue + + Xor AX, AX + Ret + +EndP MouseEnvelopeEvent2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseEnvelopeEvent3 Far ; Release envelope + + Mov CX, 8002h + Call AddMouseQueue + + Xor AX, AX + Ret + +EndP MouseEnvelopeEvent3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawEnvelopeHeader ; AH = colour, DS = inst + Assume DS:Inst + + Mov SI, InstrumentScreen ; 1-3 + Add SI, SI ; 2-6 + Add SI, Word Ptr NodeHeld ; 2-7 + Add SI, SI ; 4-14 + Mov SI, [EnvelopeHeaderTable+SI-4] + Mov DI, (33+16*80)*2 + + Call S_DrawString + + Ret + +EndP DrawEnvelopeHeader + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DrawEnvelope Far + + Push CS + Pop DS + Assume DS:Inst + + Mov AH, 20h + Call DrawEnvelopeHeader + + Call S_GetDestination + Mov DI, (32+18*80)*2 + Mov AX, 0C00h + + Mov DX, 8 + +I_DrawEnvelope1: + Mov CX, 32 + +I_DrawEnvelope2: + StosW + Inc AX + Loop I_DrawEnvelope2 + + Add DI, (80-32)*2 + Dec DX + JNZ I_DrawEnvelope1 + + Call I_GetEnvelopeOffset ; Returns DS:SI + Mov BX, CS:CurrentNode ; to envelope table + Mov CX, BX + + Add BX, BX + Add BX, CX ; BX = CurrentNode*3 + + Mov AL, [SI+BX+6] + CBW ; Value + + Test Byte Ptr [SI], 80h + JZ I_DrawEnvelope5 + + Add AX, 32 + +I_DrawEnvelope5: + Push AX + Push Word Ptr [SI+BX+7] ; Tick + Push CS:MaxNode + Push CX ; Node + + Mov DI, (66+19*80)*2 + Mov AH, 2 + Push CS + Pop DS + Mov SI, Offset EnvelopeMsg + Call S_DrawString + + Add SP, 8 + + Cmp MouseNodeHeld, 0 + JZ I_DrawEnvelope4 + + Call MouseGetStatus + Test AL, 6 + JNZ I_DrawEnvelope3 + + Call I_MouseEnvelopeReleased + Jmp I_DrawEnvelope4 + +I_DrawEnvelope3: + Mov SI, Offset EnvelopeEvent3 + Call MouseAddEvent + Mov SI, Offset EnvelopeEvent2 + Call MouseAddEvent + + Ret + +I_DrawEnvelope4: + Mov SI, Offset EnvelopeEvent1 + Call MouseAddEvent + Mov SI, Offset EnvelopeEvent4 + Call MouseAddEvent + + Ret + +EndP I_DrawEnvelope + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PreEnvelope Far + + Push CS + Pop DS + + Mov AH, 23h + Call DrawEnvelopeHeader + + Ret + +EndP I_PreEnvelope + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PostEnvelope Far + + Push CS + Pop DS + Assume DS:Inst + + Mov SI, Offset VolumeEnvelopeNodeKeys + + Cmp NodeHeld, 1 + JE I_PostEnvelope2 + + Mov SI, Offset VolumeEnvelopeKeys + +I_PostEnvelope2: + Call M_FunctionDivider + JC I_PostEnvelope1 + + Jmp [SI] + +I_PostEnvelope1: +IF ENABLEPRESETENVELOPES + + Cmp DX, '0' + JB I_PostEnvelopeNoPreset + Cmp DX, '9' + JA I_PostEnvelopeNoPreset + + Call I_GetEnvelopeOffset + Push DS + Pop ES + Mov DI, SI ; ES:DI set + + Push CS + Pop DS + Mov AL, 81 + Sub DL, '0' + Mul DL ; AX = offset + Mov SI, AX + Add SI, Offset PresetEnvelopes + + Mov CX, 6/2 + Rep MovsW + Mov CX, 25 + +I_PostEnvelopePreset1: + LodsB + Sub AL, AmplitudeCompensate + StosB + MovsW + Loop I_PostEnvelopePreset1 + + Call I_MapEnvelope + NetworkSendInstrument + + Mov AX, 1 + Ret + +I_PostEnvelopeNoPreset: + Test CH, 60h ; Alt? + JZ I_PostEnvelopeNoSet + Test CH, 1 ; On keypress + JZ I_PostEnvelopeNoSet + + Cmp CL, 2 + JB I_PostEnvelopeNoSet + Cmp CL, 0Bh + JA I_PostEnvelopeNoSet + JNE I_PostEnvelopeSet2 + + Mov CL, 1 + +I_PostEnvelopeSet2: + Mov AX, CX + Dec AX + And AX, 0FFh + Mov SI, Offset EnvelopeSetMsg + Call SetInfoLine + Mov CL, 81 + Mul CL + + Call I_GetEnvelopeOffset ; Gets DS:SI + Push CS + Pop ES + Mov DI, AX + Add DI, Offset PresetEnvelopes ; ES:DI points to dest + + LodsW + And AL, 7Fh + StosW + + Mov CX, 4/2 + Rep MovsW + Mov CX, 25 + +I_PostEnvelopeSet1: + LodsB + Add AL, CS:AmplitudeCompensate + StosB + MovsW + Loop I_PostEnvelopeSet1 + + Call I_MapEnvelope + + Mov AX, 1 + Ret + +I_PostEnvelopeNoSet: +ENDIF ; PRESETENVELOPES + Xor AX, AX + Ret + +EndP I_PostEnvelope + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_MapEnvelope Far + + Push CS + Pop DS + Assume DS:Inst + + Cmp InstrumentScreen, 0 + JNE I_MapEnvelope1 + + Ret + +I_MapEnvelope1: + Mov UpdateInstrumentScreen, 0 + + Push BP + + Call S_GetGenerationTableOffset + Push DI ; ES:DI points to table. + Mov CX, 32*8*8*8/4 + Xor EAX, EAX + Rep StosD + Pop DI + Push DI + + Add DI, 3 + Mov CX, 32 + Inc AX + +I_MapEnvelopeYAxis1: + StosB + Add DI, 511 + Loop I_MapEnvelopeYAxis1 + + Pop DI + Push DI + + Call I_GetEnvelopeOffset ; DS:SI points to envelope + Assume DS:Nothing + + Mov AL, 32 + + Add DI, 31*256 + + Test Byte Ptr [SI], 80h + JNZ I_MapEnvelopeFilterCompensate + Cmp Byte Ptr [CS:InstrumentScreen], 1 + JNE I_MapEnvelopeXAxis1 + + Xor AL, AL +I_MapEnvelopeFilterCompensate: + Add DI, 31*256 + +I_MapEnvelopeXAxis1: + Mov CS:AmplitudeCompensate, AL + + Mov AX, 100h + Mov CX, 128 + + Rep StosW ; X-axis drawn + + Pop DI + + Xor DH, DH + Mov DL, [SI+1] + + Mov CS:MaxNode, DX + Cmp CS:CurrentNode, DX + JB I_MapEnvelope2 + + Mov AX, DX + Sub AX, 1 + AdC AX, 0 + Mov CS:CurrentNode, AX + +I_MapEnvelope2: + Test DX, DX + JZ I_MapEnvelopeEnd + + Sub DX, 1 + AdC DX, 1 + + Push DX + + ; DX = last node + ; DS:SI = envelope, ES:DI = table + Mov BX, DX ; MaxNode + Add BX, BX + Add BX, DX ; BX = MaxNode*3 + + Mov AX, [DS:SI+BX+6+1-3] ; Get last nodes tick + Xor DX, DX + Mov BX, ENVELOPEGRANULARITY + Div BX + Inc AX + Mul BX + Mov CS:UpperLimit, AX + + Push DI + Xor BP, BP + Jmp I_MapEnvelope4 + +I_MapEnvelope3: + Push CX + Push DI + +I_MapEnvelope4: ; Node drawing part + Mov BX, BP + Add BX, BX + Add BX, BP + + Mov AL, 64 + Sub AL, CS:AmplitudeCompensate + Sub AL, [SI+BX+6] + Mov AH, 244 ; 244 = 61/64*256 + Mul AH + ; AX = amplitude + Mov CS:CurrentAmplitude, AX + Mov CX, AX ; CX = amplitude + + Mov AX, [SI+BX+7] + Cmp AX, CS:UpperLimit + JAE I_MapEnvelopeError + + Mov DX, 250 ; 249 if UpperLimit = LastNode tick + Mul DX +; Add AX, 125 +; AdC DX, 0 + Div CS:UpperLimit + + Mov CS:CurrentTick, AX + + ; OK.. plot points + Xor CL, CL + Add DI, AX + Add DI, CX + Add DI, 256+3 + + Mov AX, 101h + Mov [ES:DI], AX + Mov [ES:DI-256], AX + Mov [ES:DI+256], AX + Mov [ES:DI-1], AL + Mov [ES:DI-256-1], AL + Mov [ES:DI+256-1], AL + + Cmp BP, CS:CurrentNode + JNE I_MapEnvelope5 + + Dec AX + Mov [ES:DI+2], AX + Mov [ES:DI+256+2], AX + Mov [ES:DI-256+2], AX + XChg AH, AL + Mov [ES:DI-3], AX + Mov [ES:DI+256-3], AX + Mov [ES:DI-256-3], AX + +I_MapEnvelope5: + Sub DI, CX + Sub DI, 256 + Mov AX, BP + Mov CX, 64 + + Test Byte Ptr [SI], 2 + JZ I_MapEnvelope6 + + Mov AH, 1 + + Cmp AL, [SI+2] + JE I_MapEnvelopeLoop1 + Cmp AL, [SI+3] + JNE I_MapEnvelope6 + +I_MapEnvelopeLoop1: + Mov AL, AH + ShR AL, 1 + StosB + Add DI, 255 + Inc AH + Loop I_MapEnvelopeLoop1 + + Jmp I_MapEnvelope7 + +I_MapEnvelope6: + Test Byte Ptr [SI], 4 + JZ I_MapEnvelope7 + + Cmp AL, [SI+4] + JE I_MapEnvelopeSusLoop2 + Cmp AL, [SI+5] + JNE I_MapEnvelope7 + +I_MapEnvelopeSusLoop2: + Mov AL, 1 + +I_MapEnvelopeSusLoop1: + StosB + Add DI, 255 + Xor AL, 1 + Loop I_MapEnvelopeSusLoop1 + +I_MapEnvelope7: ; Now for line segment + Test BP, BP + JZ I_MapEnvelope8 ; Don't draw line for first node + + Pop DI + Push DI + + Add DI, CS:LastTick + Add DI, 103h + + Mov CX, CS:CurrentTick + Sub CX, CS:LastTick + JC I_MapEnvelope8 ; Error.. + JNZ I_MapEnvelope11 + + ; Vertical line. + Mov AX, CS:LastAmplitude + Mov CX, CS:CurrentAmplitude + Xor AL, AL + Xor CL, CL + + Add DI, AX ; LastAmplitude + + Mov DX, 256 + + Sub CX, AX + JNS I_MapEnvelope9 + + Neg DX + Neg CX + +I_MapEnvelope9: + ShR CX, 8 + JZ I_MapEnvelope12 + +I_MapEnvelope10: + Mov Byte Ptr [ES:DI], 1 + Add DI, DX + Loop I_MapEnvelope10 + +I_MapEnvelope12: + Jmp I_MapEnvelope8 + +I_MapEnvelope11: ; Diagonal line + Push SI + + Xor SI, SI + Mov AX, CS:CurrentAmplitude + Sub AX, CS:LastAmplitude + JNS I_MapEnvelope13 + + Inc SI ; SI = 1 if opp direction + Neg AX + +I_MapEnvelope13: + Xor DX, DX + Div CX + Mov DX, AX + + Test SI, SI + Mov SI, -256 + JZ I_MapEnvelope15 + + Neg SI + Neg DX + +I_MapEnvelope15: + Mov BX, CS:LastAmplitude + Inc CX + Dec DI + Push DI + Jmp I_MapEnvelope17 + +I_MapEnvelope14: + Push DI + Push BX + Xor BL, BL + Add DI, BX + +I_MapEnvelope16: + Mov Byte Ptr [ES:DI], 1 + Add DI, SI + Dec AL + JNZ I_MapEnvelope16 + + Pop BX + +I_MapEnvelope17: + Mov AL, BH + Add BX, DX + Sub AL, BH + + CBW ; + Xor AL, AH ; AL = |AL| + Sub AL, AH ; + Sub AL, 1 + AdC AL, 1 + + Pop DI + Inc DI + Loop I_MapEnvelope14 + + Pop SI + +I_MapEnvelope8: + Mov AX, CS:CurrentAmplitude + Mov BX, CS:CurrentTick + Mov CS:LastAmplitude, AX + Mov CS:LastTick, BX + +I_MapEnvelopeError: + Pop DI + Pop CX + Inc BP + Loop I_MapEnvelope3 + + ; Now shove on playing points. + + Call PE_GetLastInstrument + Inc BX + + Mov CX, CS:InstrumentScreen + Mov BP, CX + Mov DL, 1 + Add CL, 11 + ShL BP, 4 + ShL DX, CL + Add BP, 48h + + Call Music_GetSlaveChannelInformationTable + ; Returns DS:SI, CX + Assume DS:Nothing + +I_MapEnvelopePlaying1: + Cmp [SI+33h], BL + JNE I_MapEnvelopePlayingNext + + Test Byte Ptr [SI], 1 + JZ I_MapEnvelopePlayingNext + + Mov AX, [DS:SI+BP] + And AX, AX + JNZ I_MapEnvelopePlaying2 + + Test [SI], DX + JZ I_MapEnvelopePlayingNext + +I_MapEnvelopePlaying2: + Cmp AX, CS:UpperLimit + JAE I_MapEnvelopePlayingNext + + Push CX + Push DX + + Call S_GetGenerationTableOffset + Add DI, 3 + + Mov DX, 250 + Mul DX + Div CS:UpperLimit + + Add DI, AX + Mov CX, 64 + +I_DrawEnvelopePlaying1: + Mov Byte Ptr [ES:DI], 1 + Add DI, 256 + Loop I_DrawEnvelopePlaying1 + + Mov CS:UpdateInstrumentScreen, 1 + + Pop DX + Pop CX + +I_MapEnvelopePlayingNext: + Add SI, SLAVECHANNELSIZE + Loop I_MapEnvelopePlaying1 + +I_MapEnvelopeEnd: + Xor AX, AX + Mov BX, 32 + Mov CX, 8 + Call S_GenerateCharacters + + Pop BP + + Push CS + Pop DS + + Ret + +EndP I_MapEnvelope + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_GetMouseNode ; Returns DI, carry if none + + Call I_GetEnvelopeOffset + ; Returns DS:SI to envelope + Xor CH, CH + Mov CL, [SI+1] + + Add SI, 6 ; Start of envelope.. have to find + ; a point that fits MouseX, MouseY + ; XPixel = ENVELOPELEFT*8 + 250*Tick/UpperLimit + 3 + ; YPixel = ENVELOPETOP*8 + 61*(64-AmplitudeCompensate-Amplitude)/64 + 1 + + Xor DI, DI ; DI = node number. + JCXZ I_GetMouseNode3 + +I_GetMouseNode1: + Mov BX, DI + Add BX, BX + Add BX, DI + + Mov AX, 250 + Mul Word Ptr [SI+BX+1] + Div CS:UpperLimit + Add AX, ENVELOPELEFT*8+2 + + Mov DL, 64 + Sub DL, CS:AmplitudeCompensate + Sub DL, [SI+BX] + + Mov BX, AX ; BX = XPixel + + Mov AL, 244 ; 244 = 61/64*256 + Mul DL + Mov AL, AH + Xor AH, AH + Add AX, ENVELOPETOP*8 ; AX = YPixel of node... + + Cmp MouseX, BX + JB I_GetMouseNode2 + Cmp MouseY, AX + JB I_GetMouseNode2 + Add AX, 2 + Add BX, 2 + Cmp MouseX, BX + JA I_GetMouseNode2 + Cmp MouseY, AX + JA I_GetMouseNode2 + +I_GetMouseNode3: + ClC + Ret + +I_GetMouseNode2: + Inc DI + Cmp DI, CX + JB I_GetMouseNode1 + + StC + Ret + +EndP I_GetMouseNode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_MouseEnvelopeDelete Far + + Call I_GetMouseNode + JC I_MouseEnvelopeDelete1 + Mov CS:CurrentNode, DI + + Push CS + Pop DS + Jmp I_VolumeEnvelopeDelete + +I_MouseEnvelopeDelete1: + Mov AX, 1 + Ret + +EndP I_MouseEnvelopeDelete + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_MouseEnvelopePress Far + Assume DS:Nothing + ; If on top of node, then pick up this + ; node, ; MouseNodeHeld = 1 + ; If NOT near node, and nodes < 25, + ; then CREATE new node in appropriate + ; position, MouseNodeHeld = 1. If + ; no node will fit in-between, then + ; do nothing. + ; Else nothing + Call I_GetMouseNode + JNC I_MouseEnvelopeNodeFound1 + Cmp CX, 25 + JAE I_MouseEnvelopePressError + + ; Figger out envelope tick position... + Mov AX, MouseX + Sub AX, ENVELOPELEFT*8+3 + JNC I_MouseEnvelopeCreateNode4 + + Xor AX, AX + +I_MouseEnvelopeCreateNode4: + Mov BX, 250 + Mul CS:UpperLimit + Add AX, 125 + AdC DX, 0 + Div BX + + Mov CX, AX ; CX = new position.... + Cmp AX, MAXENVELOPETICK + JB I_MouseEnvelopeCreateNode3 + + Mov CX, MAXENVELOPETICK + +I_MouseEnvelopeCreateNode3: + Call I_GetEnvelopeOffset + Mov DL, [SI+1] + Mov BX, SI + Xor DH, DH + Xor DI, DI + Add BX, 7 + +I_MouseEnvelopeCreateNode1: + Cmp CX, [BX] + JE I_MouseEnvelopePressError + JB I_MouseEnvelopeCreateNode2 + + Add BX, 3 + Inc DI + Cmp DI, DX + JB I_MouseEnvelopeCreateNode1 + +I_MouseEnvelopeCreateNode2: + ClI + + Inc Byte Ptr [SI+1] + + Push BX + Push CX + Push DI + + Mov CX, DI + Cmp CL, [SI+2] + JA I_MEPIns1 + + Inc Byte Ptr [SI+2] + +I_MEPIns1: + Cmp CL, [SI+3] + JA I_MEPIns2 + + Inc Byte Ptr [SI+3] + +I_MEPIns2: + Cmp CL, [SI+4] + JA I_MEPIns3 + + Inc Byte Ptr [SI+4] + +I_MEPIns3: + Cmp CL, [SI+5] + JA I_MEPIns4 + + Inc Byte Ptr [SI+5] + +I_MEPIns4: + + Push DS + Pop ES + + StD + + Sub DX, DI + Mov CX, DX + Add CX, CX + Add CX, DX ; CX = (Last-New)*3 + + LEA DI, [BX+1] + Add DI, CX + LEA SI, [DI-3] + + Rep MovsB + + ClD + + Pop DI + Pop CX + Pop BX + + Mov [BX], CX + + Mov CX, 61 + Mov AX, MouseY + Sub AX, ENVELOPETOP*8 + JNC I_MEPChk1 + + Xor AX, AX + +I_MEPChk1: + Cmp AX, CX + JB I_MepChk2 + + Mov AX, CX + +I_MEPChk2: + ShL AX, 6 + Xor DX, DX + Div CX + + Mov DL, 64 + Sub DL, AL + Sub DL, CS:AmplitudeCompensate + Mov [BX-1], DL + +I_MouseEnvelopeNodeFound1: ; Have to find limits... + Mov CurrentNode, DI + Call I_EnvelopeSelected + + StI + + Mov BX, DI + Mov CL, BL + Inc CX + Add BX, BX + Add BX, DI + ; AX = lower limit, DX = upper limit + Xor AX, AX + Xor DX, DX + And DI, DI + JZ I_MouseEnvelopeNodeFound3 + + Mov DX, MAXENVELOPETICK + Mov AX, [SI+BX+6+1-3] + Inc AX + +I_MouseEnvelopeNodeFound2: + Cmp CL, [SI+1] + JAE I_MouseEnvelopeNodeFound3 + + Mov DX, [SI+BX+6+1+3] + Dec DX + +I_MouseEnvelopeNodeFound3: + Mov LowerTickLimit, AX + Mov UpperTickLimit, DX + + Mov BX, 2 + Call SetMouseCursorType + + Mov AX, 1 + Mov MouseNodeHeld, AL + Call SetKeyboardLock + Jmp I_MousePressChain + +I_MouseEnvelopePressError: + Mov AX, 1 + Ret + +EndP I_MouseEnvelopePress + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_MouseEnvelopeDrag Far + Assume DS:Nothing + ; CurrentNode update + + Call I_GetEnvelopeOffset + ; Returns DS:SI to envelope + Mov AX, CurrentNode + Mov BX, AX + Add BX, BX + Add BX, AX + LEA SI, [SI+BX+6] ; DS:SI points to current node + + ; Tick first + Mov AX, MouseX + Sub AX, ENVELOPELEFT*8+3 + JNC I_MouseEnvelopeDrag1 + + Xor AX, AX + +I_MouseEnvelopeDrag1: + Mov BX, 250 + Mul CS:UpperLimit + Add AX, 125 + AdC DX, 0 + Div BX + ; AX = tick.. now to check bounds.. + Cmp AX, LowerTickLimit + JAE I_MouseEnvelopeDrag2 + + Mov AX, LowerTickLimit + +I_MouseEnvelopeDrag2: + Cmp AX, UpperTickLimit + JBE I_MouseEnvelopeDrag3 + + Mov AX, UpperTickLimit + +I_MouseEnvelopeDrag3: + ClI + + Mov [SI+1], AX + + Mov AX, MouseY + Mov CX, 61 + Sub AX, ENVELOPETOP*8 + JNC I_MouseEnvelopeDrag4 + + Xor AX, AX + +I_MouseEnvelopeDrag4: + Cmp AX, CX + JBE I_MouseEnvelopeDrag5 + + Mov AX, CX + +I_MouseEnvelopeDrag5: + ShL AX, 6 + Xor DX, DX + Div CX + + Mov DL, 64 + Sub DL, AL + Sub DL, CS:AmplitudeCompensate + Mov [SI], DL + + StI + + ; XPixel = ENVELOPELEFT*8 + 250*Tick/UpperLimit + 3 + ; YPixel = ENVELOPETOP*8 + 61*(64-AmplitudeCompensate-Amplitude)/64 + 1 + +I_MousePressChain: + Push CS:UpperLimit + Call I_RedrawWave + Pop AX + Cmp AX, CS:UpperLimit + JE I_GetMousePositionEnd + + ; Set position.... + Call I_GetEnvelopeOffset + Mov AX, CS:CurrentNode + Add SI, AX + Add SI, AX + Add SI, AX + Add SI, 6 + + Mov AX, 250 + Mul Word Ptr [SI+1] + Div CS:UpperLimit + Add AX, ENVELOPELEFT*8-1 ; +3 + Mov CX, AX + + Xor DX, DX + Mov AL, 64 + Sub AL, CS:AmplitudeCompensate + Sub AL, [SI] + Mov AH, 244 + Mul AH + Mov DL, AH + + Add DX, ENVELOPETOP*8-2 ; +1 + Call MouseSetXY + +I_GetMousePositionEnd: + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_MouseEnvelopeDrag + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_MouseEnvelopeReleased Far + Assume DS:Inst + ; MouseNodeHeld = 0 + + Xor BX, BX + Call SetMouseCursorType + + Xor AX, AX + Mov CS:MouseNodeHeld, AL + Call SetKeyboardLock + + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_MouseEnvelopeReleased + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeRight Far + + Assume DS:Inst + + Mov AX, CurrentNode + Inc AX + Cmp AX, MaxNode + JAE I_VolumeEnvelopeRight1 + + Mov CurrentNode, AX + Call I_MapEnvelope + +I_VolumeEnvelopeRight1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeRight + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeLeft Far + + Assume DS:Inst + + Cmp CurrentNode, 0 + JE I_VolumeEnvelopeLeft1 + + Dec CurrentNode + Call I_MapEnvelope + +I_VolumeEnvelopeLeft1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeLeft + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeUp Far + + Mov Word Ptr [ES:DI], 5 + + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeDown Far + + Mov Word Ptr [ES:DI], 17 + + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldUp Far + + Assume DS:Inst + + Mov CX, CurrentNode + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, CX + Add SI, CX + Add SI, 6 + + Mov AL, [SI] + Add AL, CS:AmplitudeCompensate + + Cmp AL, 64 + JAE I_VolumeEnvelopeHeldUp1 + + Inc Byte Ptr [SI] + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeHeldUp1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldDown Far + + Assume DS:Inst + + Mov CX, CurrentNode + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, CX + Add SI, CX + Add SI, 6 + + Mov AL, [SI] + Add AL, CS:AmplitudeCompensate + + JZ I_VolumeEnvelopeHeldDown1 + + Dec Byte Ptr [SI] + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeHeldDown1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldLeft Far + + Assume DS:Inst + + Mov CX, CurrentNode + Mov DX, CX + Add DX, DX + JZ I_VolumeEnvelopeHeldLeft1 + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, DX + Add SI, 7 ; DS:SI points to node's posn + + Mov AX, [SI] + + Dec AX + Cmp AX, [SI-3] ; Last node. + JE I_VolumeEnvelopeHeldLeft1 + + Mov [SI], AX + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeHeldLeft1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldLeft + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldLeftFast Far + + Assume DS:Inst + + Mov CX, CurrentNode + Mov DX, CX + Add DX, DX + JZ I_VolumeEnvelopeHeldLeftFast2 + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, DX + Add SI, 7 + + Mov AX, [SI] + + Sub AX, 16 + JNC I_VolumeEnvelopeHeldLeftFast3 + + Xor AX, AX + +I_VolumeEnvelopeHeldLeftFast3: + Cmp AX, [SI-3] ; Last node. + JA I_VolumeEnvelopeHeldLeftFast1 + + Mov AX, [SI-3] + Inc AX + +I_VolumeEnvelopeHeldLeftFast1: + Mov [SI], AX + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeHeldLeftFast2: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldLeftFast + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldHome Far + + Assume DS:Inst + + Mov CX, CurrentNode + Mov DX, CX + Add DX, DX + JZ I_VolumeEnvelopeHeldHome1 + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, DX + Add SI, 7 + + Mov AX, [SI-3] + Inc AX + Mov [SI], AX + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeHeldHome1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldHome + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldRight Far + + Assume DS:Inst + + Mov CX, CurrentNode + Mov DX, CX + Add DX, DX + JZ I_VolumeEnvelopeHeldRight1 + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, DX + Add SI, 7 + + Mov AX, [SI] + Cmp AX, MAXENVELOPETICK + JAE I_VolumeEnvelopeHeldRight1 + + Inc AX + Inc CX + Cmp CX, CS:MaxNode + JE I_VolumeEnvelopeHeldRight2 + + Cmp AX, [SI+3] ; Last node. + JE I_VolumeEnvelopeHeldRight1 + +I_VolumeEnvelopeHeldRight2: + Mov [SI], AX + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeHeldRight1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldRight + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldEnd Far + + Assume DS:Inst + + Mov CX, CurrentNode + Mov DX, CX + Add DX, DX + JZ I_VolumeEnvelopeHeldEnd1 + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, DX + Add SI, 7 + + + Mov AX, MAXENVELOPETICK + Inc CX + Cmp CX, CS:MaxNode + JE I_VolumeEnvelopeHeldEnd2 + + Mov AX, [SI+3] + Dec AX + +I_VolumeEnvelopeHeldEnd2: + Mov [SI], AX + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeHeldEnd1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldEnd + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldRightFast Far + + Assume DS:Inst + + Mov CX, CurrentNode + Mov DX, CX + Add DX, DX + JZ I_VolumeEnvelopeHeldRightFast1 + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, DX + Add SI, 7 + + Mov AX, [SI] + + Add AX, 16 + Inc CX + Cmp CX, CS:MaxNode + JE I_VolumeEnvelopeHeldRightFast3 + + Cmp AX, [SI+3] + JB I_VolumeEnvelopeHeldRightFast2 + + Mov AX, [SI+3] + Dec AX + +I_VolumeEnvelopeHeldRightFast3: + Cmp AX, MAXENVELOPETICK + JBE I_VolumeEnvelopeHeldRightFast2 + + Mov AX, MAXENVELOPETICK + +I_VolumeEnvelopeHeldRightFast2: + Mov [SI], AX + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeHeldRightFast1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldRightFast + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldPgDn Far + + Assume DS:Inst + + Mov CX, CurrentNode + Mov AH, AmplitudeCompensate + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, CX + Add SI, CX + Add SI, 6 + + Mov AL, [SI] + Add AL, AH + Sub AL, 8 + JNS I_VolumeEnvelopeHeldPgDn1 + + Xor AL, AL + +I_VolumeEnvelopeHeldPgDn1: + Sub AL, AH + Mov [SI], AL + + Call I_MapEnvelope + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldPgDn + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeHeldPgUp Far + + Assume DS:Inst + + Mov CX, CurrentNode + Mov AH, AmplitudeCompensate + + Call I_GetEnvelopeOffset + Assume DS:Nothing + + Add SI, CX + Add SI, CX + Add SI, CX + Add SI, 6 + + Mov AL, [SI] + Add AL, AH + Add AL, 8 + Cmp AL, 64 + JBE I_VolumeEnvelopeHeldPgUp1 + + Mov AL, 64 + +I_VolumeEnvelopeHeldPgUp1: + Sub AL, AH + Mov [SI], AL + + Call I_MapEnvelope + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeHeldPgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeInsert Far + Assume DS:Inst + + Mov DX, CurrentNode + + Inc DX + Mov CX, MaxNode + Cmp DX, CX + JE I_VolumeEnvelopeInsert1 + + Mov DI, CX + Sub CX, DX + + Cmp DI, 25 + JE I_VolumeEnvelopeInsert1 + + Call I_GetEnvelopeOffset ; DS:SI + Assume DS:Nothing + + LEA BX, [SI+6] + Add BX, DX + Add BX, DX + Add BX, DX + Mov AX, [BX+1] + Sub AX, [BX-2] + Cmp AX, 2 + JB I_VolumeEnvelopeInsert1 + + ClI + + Inc Byte Ptr [SI+1] + + Mov BX, DI + Add BX, BX + Add BX, DI + LEA BX, [BX+SI+6] + +I_VolumeEnvelopeInsert2: + Mov AX, [BX-3] + Mov [BX], AX + Mov AL, [BX-1] + Mov [BX+2], AL + + Sub BX, 3 + Loop I_VolumeEnvelopeInsert2 + + Mov AX, [BX+4] + Add AX, [BX-2] + ShR AX, 1 + Mov [BX+1], AX + + Mov AH, CS:AmplitudeCompensate + Mov AL, [BX+3] + Add AL, [BX-3] + Add AL, AH + Add AL, AH + ShR AL, 1 + Sub AL, AH + Mov [BX], AL + + Mov CL, Byte Ptr CS:CurrentNode + Cmp CL, [SI+2] + JAE I_VolumeEnvelopeInsert4 + + Inc Byte Ptr [SI+2] + +I_VolumeEnvelopeInsert4: + Cmp CL, [SI+3] + JAE I_VolumeEnvelopeInsert5 + + Inc Byte Ptr [SI+3] + +I_VolumeEnvelopeInsert5: + Cmp CL, [SI+4] + JAE I_VolumeEnvelopeInsert6 + + Inc Byte Ptr [SI+4] + +I_VolumeEnvelopeInsert6: + Cmp CL, [SI+5] + JAE I_VolumeEnvelopeInsert7 + + Inc Byte Ptr [SI+5] + +I_VolumeEnvelopeInsert7: + StI + + Call I_MapEnvelope + NetworkSendInstrument + +I_VolumeEnvelopeInsert1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeInsert + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeDelete Far + + Assume DS:Inst + + Mov DX, CurrentNode + Mov DI, DX + Add DI, DI + Add DI, DX ; DI = CurrentNode*3 + JZ I_VolumeEnvelopeDelete1 + + Mov CX, MaxNode + Cmp CX, 2 + JBE I_VolumeEnvelopeDelete1 + + Call I_GetEnvelopeOffset ; Returns DS:SI + Assume DS:Nothing + + ClI + + Dec Byte Ptr [SI+1] + + Mov BX, SI + LEA SI, [BX+DI+6] + + Sub CX, DX + Dec CX + JZ I_VolumeEnvelopeDelete11 + +I_VolumeEnvelopeDelete2: + Mov AL, [SI+3] + Mov [SI], AL + Mov AX, [SI+4] + Mov [SI+1], AX + + Add SI, 3 + Loop I_VolumeEnvelopeDelete2 + +I_VolumeEnvelopeDelete11: + Xor AX, AX ; Neatness.. clear ending + Mov [SI], AX + Mov [SI+2], AL + ; Ok.. check loop stuff + Mov DL, [BX+1] + Dec DX ; DL = number of nodes + Mov DH, Byte Ptr CS:CurrentNode + + Cmp DH, [BX+2] + JAE I_VolumeEnvelopeDelete7 + + Dec Byte Ptr [BX+2] + +I_VolumeEnvelopeDelete7: + Cmp DH, [BX+3] + JAE I_VolumeEnvelopeDelete8 + + Dec Byte Ptr [BX+3] + +I_VolumeEnvelopeDelete8: + Cmp DH, [BX+4] + JAE I_VolumeEnvelopeDelete9 + + Dec Byte Ptr [BX+4] + +I_VolumeEnvelopeDelete9: + Cmp DH, [BX+5] + JAE I_VolumeEnvelopeDelete10 + + Dec Byte Ptr [BX+5] + +I_VolumeEnvelopeDelete10: + Cmp DL, [BX+2] + JAE I_VolumeEnvelopeDelete3 + + Mov [BX+2], DL + +I_VolumeEnvelopeDelete3: + Cmp DL, [BX+3] + JAE I_VolumeEnvelopeDelete4 + + Mov [BX+3h], DL + +I_VolumeEnvelopeDelete4: + Cmp DL, [BX+4] + JAE I_VolumeEnvelopeDelete5 + + Mov [BX+4], DL + +I_VolumeEnvelopeDelete5: + Cmp DL, [BX+5] + JAE I_VolumeEnvelopeDelete6 + + Mov [BX+5], DL + +I_VolumeEnvelopeDelete6: + StI + Call I_MapEnvelope + +I_VolumeEnvelopeDelete1: + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeDelete + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_EnvelopeSelected + + Call I_GetEnvelopeOffset ; Returns DS:SI + +IF FILTERENVELOPES + Cmp CS:InstrumentScreen, 3 + JNE I_MouseEnvelopeNoFilter + + Test Byte Ptr [SI], 1 + JNZ I_MouseEnvelopeNoFilter + + Or Byte Ptr [SI], 80h + +I_MouseEnvelopeNoFilter: +ELSE + And Byte Ptr [SI], 7Fh ; Turn of filters. + +ENDIF + + Or Byte Ptr [SI], 1 ; Turn on envelope + Ret + +EndP I_EnvelopeSelected + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_VolumeEnvelopeEnter Far + + Assume DS:Inst + + Xor NodeHeld, 1 + JZ I_VolumeEnvelopeEnter1 + + Call I_EnvelopeSelected + +I_VolumeEnvelopeEnter1: + Mov AX, 1 + Ret + +EndP I_VolumeEnvelopeEnter + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentListSpace Far + + Push CS + Pop DS + Assume DS:Inst + + Cmp NoteReleased, 1 + JNE I_InstrumentSpace1 + + Mov NoteReleased, 0 + Mov SI, Offset NoteData + Call PE_GetLastInstrument + Mov AH, BL + Inc AH + Mov AL, PlayNote + Mov [SI], AX + Mov AX, PlayChannel + Mov DH, 32+128 + Call Music_PlayNote + +I_InstrumentSpace1: + Mov AX, 1 + Ret + +EndP I_InstrumentListSpace + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_InstrumentListNoteOff Far + + Push CS + Pop DS + Assume DS:Inst + + Mov NoteReleased, 1 + Mov SI, Offset NoteData + Mov Word Ptr [SI], 255 + Mov AX, PlayChannel + Mov DH, 32+128 + Call Music_PlayNote + + Mov AX, 1 + Ret + +EndP I_InstrumentListNoteOff + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ShowSamplePlay Far + ; Clear table first. + + Push CS + Pop DS + ; DS = Inst + Mov SI, Offset SamplePlayTable + Mov CX, 100 + +I_ShowSamplePlayClearTable: + And Byte Ptr [SI], Not 3 + Inc SI + Loop I_ShowSamplePlayClearTable + + Call Music_GetSlaveChannelInformationTable + ; DS:SI points to table. + ; CX = numchannels. + Xor BH, BH + +I_ShowSamplePlay1: + Mov AX, [SI] + Test AL, 1 ; Is channel on? + JZ I_ShowSamplePlay2 + + Test AH, 8 ; Is it muted? + JNZ I_ShowSamplePlay2 + + Mov BL, [SI+36h] + Cmp BL, 100 + JAE I_ShowSamplePlay2 + + Or [CS:SamplePlayTable+BX], 1 ; Show sample is on. + + Cmp DWord Ptr [SI+2Ch], 0 + JNE I_ShowSamplePlay2 + + Or [CS:SamplePlayTable+BX], 2 + +I_ShowSamplePlay2: + Add SI, SLAVECHANNELSIZE + Loop I_ShowSamplePlay1 + + ; OK.. now to dump the stuff + ; onscreen + + Mov BX, TopSample + Dec BX + Mov SI, Offset SamplePlayTable + + Jmp I_ShowInstrumentPlay5 + +EndP I_ShowSamplePlay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ShowInstrumentPlay Far + ; Clear table first. + + Call Music_GetInstrumentMode + JZ I_ShowInstrumentPlayEnd + + Push CS + Pop DS + ; DS = Inst + Mov SI, Offset InstrumentPlayTable + Mov CX, 100 + +I_ShowInstrumentPlayClearTable: + And Byte Ptr [SI], Not 3 + Inc SI + Loop I_ShowInstrumentPlayClearTable + + Call Music_GetSlaveChannelInformationTable + ; DS:SI points to table. + ; CX = numchannels. + Xor BH, BH + +I_ShowInstrumentPlay1: + Mov AX, [SI] + Test AL, 1 ; Is channel on? + JZ I_ShowInstrumentPlay2 + + Test AH, 8 ; Is it muted? + JNZ I_ShowInstrumentPlay2 + + Mov BL, [SI+33h] + Cmp BL, 100 + JAE I_ShowInstrumentPlay2 + + Or [CS:InstrumentPlayTable+BX], 1 ; Show sample is on. + + Cmp DWord Ptr [SI+2Ch], 0 + JNE I_ShowInstrumentPlay2 + + Or [CS:InstrumentPlayTable+BX], 2 + +I_ShowInstrumentPlay2: + Add SI, SLAVECHANNELSIZE + Loop I_ShowInstrumentPlay1 + + ; OK.. now to dump the stuff + ; onscreen + + Mov BX, TopInstrument + Mov SI, Offset InstrumentPlayTable + +I_ShowInstrumentPlay5: + Call S_GetDestination + + Mov CX, 35 + Mov DI, (1+13*80)*2 + +I_ShowInstrumentPlay3: + Mov AX, 2100h + + Mov DL, [CS:SI+BX] + + Cmp DL, 0 ; No dot. + JE I_ShowInstrumentPlay4 + + Mov AL, 173 + + Cmp DL, 4 ; Dark small dot + JE I_ShowInstrumentPlay4 + + Mov AH, 23h + + Test DL, 2 ; Small bright dot + JZ I_ShowInstrumentPlay4 + + Mov AL, 183 ; Large bright dot. + +I_ShowInstrumentPlay4: + StosW + + Add DI, 158 + Inc BX + Loop I_ShowInstrumentPlay3 + +I_ShowInstrumentPlayEnd: + Ret + + +EndP I_ShowInstrumentPlay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ClearTables Far + + Push CS + Pop ES + + Mov DI, Offset SamplePlayTable + Mov CX, 128 + + Xor AX, AX + Rep StosW + + Ret + +EndP I_ClearTables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_TagInstrument Far + + Mov Byte Ptr [CS:InstrumentPlayTable+BX], 4 + Ret + +EndP I_TagInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_TagSample Far + + Mov Byte Ptr [CS:SamplePlayTable+BX], 4 + Ret + +EndP I_TagSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_PlaySample Far + + Push CS + Pop DS + Assume DS:Inst + + Test DH, DH + JNZ MIDI_PlaySample1 + + Jmp MIDI_NoteOff2 + +MIDI_PlaySample1: + Call Music_GetNumChannels ; Into AX + Mov DI, AX + Mov AX, PlayChannel + Call MIDI_AllocateChannel + + Call PE_GetLastInstrument + Mov CX, AX + Mov AL, DL + Mov AH, BL + Inc AH + Call Music_PlaySample + +MIDI_PlaySample2: + Mov AX, 1 + Ret + +EndP MIDI_PlaySample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PlaySample Far + + Mov AX, Pattern + Mov DS, AX + Assume DS:Pattern + + Mov AH, LastInstrument + Mov AL, CS:LastPlaySample + + Mov CX, CS:PlayChannel + Call Music_PlaySample + + Xor AX, AX + Ret + +EndP I_PlaySample + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_IncreasePlayChannel Far + + Push CS + Pop DS + Assume DS:Inst + + Mov AX, PlayChannel + Cmp AX, 63 + JAE I_IncreasePlayChannel1 + + Inc AX + +I_IncreasePlayChannel1: + Mov PlayChannel, AX + + Inc AX + Mov SI, Offset PlayChannelMsg + + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP I_IncreasePlayChannel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DecreasePlayChannel Far + + Push CS + Pop DS + Assume DS:Inst + + Mov AX, PlayChannel + And AX, AX + JZ I_DecreasePlayChannel1 + + Dec AX + +I_DecreasePlayChannel1: + Mov PlayChannel, AX + + Inc AX + Mov SI, Offset PlayChannelMsg + + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP I_DecreasePlayChannel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateMultiChannel + + Cmp CS:MultiChannel, 0 + JE UpdateMultiChannel1 + + Push AX + Push BX + Push DS + Push SI + Assume DS:Inst + + Push CS + Pop DS + + Call Music_GetNumChannels ; Into AX + Mov BX, PlayChannel + Inc BX + Cmp BX, AX + JB UpdateMultiChannel2 + + Xor BX, BX + +UpdateMultiChannel2: + Mov PlayChannel, BX + Mov AX, BX + Inc AX + + Mov SI, Offset PlayChannelMsg + Call SetInfoLine + + Pop SI + Pop DS + Pop BX + Pop AX + +UpdateMultiChannel1: + Ret + +EndP UpdateMultiChannel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_ToggleMultiChannel Far + + Push CS + Pop DS + Assume DS:Inst + + Mov SI, Offset MultiChannelEnabledMsg + Xor MultiChannel, 1 + JNZ I_ToggleMultiChannel1 + + Mov SI, Offset MultiChannelDisabledMsg + +I_ToggleMultiChannel1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP I_ToggleMultiChannel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_DrawPitchPanCenter Far + + Call S_GetDestination + Call I_GetInstrumentOffset ; Returns DS:BX + Mov DI, (54+45*80)*2 + + Mov AL, [BX+17h] + Mov CL, 12 + Xor AH, AH + Xor BH, BH + + Div CL + ; AL = octave, AH = note + Mov BL, AH + Mov DL, AL + Add BX, BX + Add DL, '0' + + Mov AH, 2 + Mov AL, [CS:NoteTable+BX] + StosW + Mov AL, [CS:NoteTable+BX+1] + StosW + Mov AL, DL + StosW + + Ret + +EndP I_DrawPitchPanCenter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PrePitchPanCenter Far + + Call S_GetDestination + Mov AL, 3h + Mov DI, (54+45*80)*2+1 + StosB + Inc DI + StosB + Inc DI + StosB + + Ret + +EndP I_PrePitchPanCenter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PostPitchPanCenter Far + + Push CS + Pop DS + Assume DS:Inst + + Mov SI, Offset PitchPanCenterKeys + Call M_FunctionDivider + JC I_PostPitchPanCenter1 + + Jmp [SI] + +I_PostPitchPanCenter1: + Xor AX, AX + Ret + +EndP I_PostPitchPanCenter + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PitchPanCenterUp Far + + Mov Word Ptr [ES:DI], 27 + Mov AX, 1 + Ret + +EndP I_PitchPanCenterUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PitchPanCenterDown Far + + Mov Word Ptr [ES:DI], 29 + Mov AX, 1 + Ret + +EndP I_PitchPanCenterDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PitchPanCenterSemiUp Far + + Call I_GetInstrumentOffset + Mov AL, [BX+17h] + + Cmp AL, 119 + JAE I_PitchPanCenterSemiUp1 + + Inc AX + Mov [BX+17h], AL + +I_PitchPanCenterSemiUp1: + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_PitchPanCenterSemiUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_PitchPanCenterSemiDown Far + + Call I_GetInstrumentOffset + Mov AL, [BX+17h] + + Dec AL + JS I_PitchPanCenterSemiDown1 + + Mov [BX+17h], AL + +I_PitchPanCenterSemiDown1: + NetworkSendInstrument + + Mov AX, 1 + Ret + +EndP I_PitchPanCenterSemiDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_IdleUpdateEnvelope Far + + Push CS + Pop DS + Assume DS:Inst + + Cmp UpdateInstrumentScreen, 0 + JNE I_IdleUpdateEnvelope2 + + Mov CL, Byte Ptr InstrumentScreen + Add CL, 11 + Mov DL, 1 + ShL DX, CL + + Call PE_GetLastInstrument ; Gets BX + Inc BX + Call Music_GetSlaveChannelInformationTable + Assume DS:Nothing + +I_IdleUpdateEnvelope1: + Cmp Byte Ptr [SI+33h], BL + JNE I_IdleUpdateEnvelope4 + + Test Byte Ptr [SI], 1 + JZ I_IdleUpdateEnvelope4 + + Test [SI], DX + JZ I_IdleUpdateEnvelope4 + +I_IdleUpdateEnvelope2: + Call I_MapEnvelope + Jmp I_IdleUpdateEnvelope3 + +I_IdleUpdateEnvelope4: + Add SI, SLAVECHANNELSIZE + Loop I_IdleUpdateEnvelope1 + +I_IdleUpdateEnvelope3: + Xor AX, AX + Ret + +EndP I_IdleUpdateEnvelope + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateWAVEForm Far + + Call I_RedrawWave + Ret + +EndP UpdateWAVEForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_SampleButtonHandler Far + + Test AX, AX + JZ I_SampleButtonHandler1 + + NetworkSendSample + +I_SampleButtonHandler1: + Push DS + + Call I_GetSampleOffset + Push DS + Pop ES + Mov DI, BX + Pop DS + + Add DI, [SI+24] + + Ret + +EndP I_SampleButtonHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc I_GetPresetEnvelopeOffset Far + + Push CS + Pop DS + Mov DX, Offset PresetEnvelopes + + Ret + +EndP I_GetPresetEnvelopeOffset + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_K.ASM b/it_k.s similarity index 96% rename from IT_K.ASM rename to it_k.s index bfe0816..9ef7a59 100644 --- a/IT_K.ASM +++ b/it_k.s @@ -1,1812 +1,1812 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Keyboard Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386 - -include switch.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Extrn D_GotoStartingDirectory:Far - - Extrn E_UnInitEMS:Far - Extrn S_GetDestination:Far - Extrn Music_Stop:Far - Extrn Music_KBPlaySong:Far - Extrn Music_IncreaseVolume:Far - Extrn Music_DecreaseVolume:Far - Extrn S_DrawString:Far - Extrn CrashRecovery:Far - - Extrn IsStartupKeyList:Far - Extrn GetStartupKeyList:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global K_DrawTables:Far - Global K_InitKeyBoard:Far - Global K_UnInitKeyBoard:Far - Global K_IsKeyWaiting:Far - Global K_GetKey:Far - Global K_IsAnyKeyDown:Far - Global K_IsKeyDown:Far - Global K_ClearKeyBoardQueue:Far - Global K_ResetKeyboardTables:Far - Global K_SelectKBButton:Far - Global K_SetKeyboardType:Far - Global K_InstallDOSHandler:Far - Global K_UnInstallDOSHandler:Far - Global K_SwapKeyBoard:Far - Global K_InstallKeyboardType:Far - Global K_RemoveKeyboardType:Far - Global K_SetScrollLock:Far - - Global CountryTable:Byte - - Public MIDIBufferEmpty, MIDISend, K_ShowMIDIInput - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment KeyBoard BYTE Public 'Code' USE16 - Assume CS:KeyBoard, DS:KeyBoard - -CREATENEWLOGFILE EQU 0 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -KeyBoardTable DB 256 Dup (?) ; Table of current keypresses -KeyBoardBuffer DB 256 Dup (?) ; Queue of keys. -LastKey DW 0 ; For Caps/Numlock processing - ; only on FIRST press -KBStart DW 0 ; Buffer start ptr -KBEnd DW 0 ; Buffer end ptr - -OldKBHandler Label DWord -OldKBHandlerOffset DW ? ; Old Interrupt handler offset -OldKBHandlerSegment DW ? ; Old interrupt handler segment - -HighSet DB 0 - -Caps DB 0 ; Internal flag -NumLock DB 0 ; Internal flag -ScrollLock DB 0 - -KeyboardFile DB "KEYBOARD.CFG", 0 -KeyboardFileLength DW 0 - -KeypadValueFlag DB 0 -KeypadValue DB 0 - -MIDIStatusByte DB 0 -MIDIDataByte1 DB 0 -MIDIDataByte2 DB 0 -MIDIDataInput DB 0 - -MIDIMessage DB "MIDI Input: ", 0FDh, "X ", 0FDh, "X ", 0FDh, "X ", 0 - -TranslationTable Label DWord -TranslationTableOffset DW Offset USKeyboardTable -TranslationTableSegment DW Keyboard - -USKeyboardTable Label Byte - - DB 2 ; 1 - DB 0 - DW '1' - DB 3 ; ! - DW '!' - DB 0FFh - - DB 3 ; 2 - DB 0 - DW '2' - DB 3 ; @ - DW '@' - DB 0FFh - - DB 4 ; 3 - DB 0 - DW '3' - DB 3 ; # - DW '#' - DB 0FFh - - DB 5 ; 4 - DB 0 - DW '4' - DB 3 ; $ - DW '$' - DB 0FFh - - DB 6 ; 5 - DB 0 - DW '5' - DB 3 ; % - DW '%' - DB 0FFh - - DB 7 ; 6 - DB 0 - DW '6' - DB 3 ; ^ - DW '^' - DB 0FFh - - DB 8 ; 7 - DB 0 - DW '7' - DB 3 ; & - DW '&' - DB 0FFh - - DB 9 ; 8 - DB 0 - DW '8' - DB 3 ; * - DW '*' - DB 0FFh - - DB 10 ; 9 - DB 0 - DW '9' - DB 3 ; ( - DW '(' - DB 0FFh - - DB 11 ; 0 - DB 0 - DW '0' - DB 3 ; ) - DW ')' - DB 0FFh - - DB 12 ; - - DB 0 - DW '-' - DB 3 ; _ - DW '_' - DB 0FFh - - DB 13 ; = - DB 0 - DW '=' - DB 3 ; + - DW '+' - DB 0FFh - - DB 14 ; Backspace - DB 4 ; Ctrl-Backspace - DW 127 - DB 0FFh - - DB 15 ; Tab - DB 3 ; ShiftTab - DW 0F00h - DB 0FFh - - DB 16 ; Q - DB 1 - DW 'Q' - DB 2 ; q - DW 'q' - DB 4 ; Ctrl-Q - DW 11h - DB 5 ; Alt-Q - DW 1000h - DB 0FFh - - DB 17 ; W - DB 1 - DW 'W' - DB 2 ; w - DW 'w' - DB 4 ; Ctrl-W - DW 17h - DB 5 ; Alt-W - DW 1100h - DB 0FFh - - DB 18 ; E - DB 1 - DW 'E' - DB 2 ;e - DW 'e' - DB 4 ; Ctrl-E - DW 5 - DB 5 ; Alt-E - DW 1200h - DB 0FFh - - DB 19 ; R - DB 1 - DW 'R' - DB 2 ; r - DW 'r' - DB 4 ; Ctrl-R - DW 12h - DB 5 ; Alt-R - DW 1300h - DB 0FFh - - DB 20 ; T - DB 1 - DW 'T' - DB 2 ; t - DW 't' - DB 4 ; Ctrl-T - DW 14h - DB 5 ; Alt-T - DW 1400h - DB 0FFh - - DB 21 ; Y - DB 1 - DW 'Y' - DB 2 ; y - DW 'y' - DB 4 ; Ctrl-Y - DW 19h - DB 5 ; Alt-Y - DW 1500h - DB 0FFh - - DB 22 ; U - DB 1 - DW 'U' - DB 2 ; u - DW 'u' - DB 4 ; Ctrl-U - DW 15h - DB 5 ; Alt-U - DW 1600h - DB 0FFh - - DB 23 ; I - DB 1 - DW 'I' - DB 2 ; i - DW 'i' - DB 4 ; Ctrl-I - DW 9 - DB 5 ; Alt-I - DW 1700h - DB 0FFh - - DB 24 ; O - DB 1 - DW 'O' - DB 2 ; o - DW 'o' - DB 4 ; Ctrl-O - DW 0Fh - DB 5 ; Alt-O - DW 1800h - DB 0FFh - - DB 25 ; P - DB 1 - DW 'P' - DB 2 ; p - DW 'p' - DB 4 ; Ctrl-P - DW 10h - DB 5 ; Alt-P - DW 1900h - DB 0FFh - - DB 26 ; [ - DB 0 - DW '[' - DB 3 ; { - DW '{' - DB 0FFh - - DB 27 ; ] - DB 0 - DW ']' - DB 3 ; } - DW '}' - DB 0FFh - - DB 30 ; A - DB 1 - DW 'A' - DB 2 ; a - DW 'a' - DB 4 ; Ctrl-A - DW 1 - DB 5 ; Alt-A - DW 1E00h - DB 0FFh - - DB 31 ; S - DB 1 - DW 'S' - DB 2 ; s - DW 's' - DB 4 ; Ctrl-S - DW 13h - DB 5 ; Alt-S - DW 1F00h - DB 0FFh - - DB 32 ; D - DB 1 - DW 'D' - DB 2 ; d - DW 'd' - DB 4 ; Ctrl-D - DW 4 - DB 5 ; Alt-D - DW 2000h - DB 0FFh - - DB 33 ; F - DB 1 - DW 'F' - DB 2 ; f - DW 'f' - DB 4 ; Ctrl-F - DW 6 - DB 5 ; Alt-F - DW 2100h - DB 0FFh - - DB 34 ; G - DB 1 - DW 'G' - DB 2 ; g - DW 'g' - DB 4 ; Ctrl-G - DW 7 - DB 5 ; Alt-G - DW 2200h - DB 0FFh - - DB 35 ; H - DB 1 - DW 'H' - DB 2 ; h - DW 'h' - DB 4 ; Ctrl-H - DW 8 - DB 5 ; Alt-H - DW 2300h - DB 0FFh - - DB 36 ; J - DB 1 - DW 'J' - DB 2 ; j - DW 'j' - DB 4 ; Ctrl-J - DW 0Ah - DB 5 ; Alt-J - DW 2400h - DB 0FFh - - DB 37 ; K - DB 1 - DW 'K' - DB 2 ; k - DW 'k' - DB 4 ; Ctrl-K - DW 0Bh - DB 5 ; Alt-K - DW 2500h - DB 0FFh - - DB 38 ; L - DB 1 - DW 'L' - DB 2 ; l - DW 'l' - DB 4 ; Ctrl-L - DW 0Ch - DB 5 ; Alt-L - DW 2600h - DB 0FFh - - DB 39 ; ; - DB 0 - DW ';' - DB 3 ; : - DW ':' - DB 0FFh - - DB 40 ; ' - DB 0 - DW "'" - DB 3 ; " - DW '"' - DB 0FFh - - DB 41 ; ` - DB 0 - DW '`' - DB 3 ; ~ - DW '~' - DB 0FFh - - DB 43 ; \ - DB 0 - DW '\' - DB 3 ; | - DW '|' - DB 0FFh - - DB 44 ; z - DB 1 - DW 'Z' - DB 2 ; z - DW 'z' - DB 4 ; Ctrl-Z - DW 1Ah - DB 5 ; Alt-Z - DW 2C00h - DB 0FFh - - DB 45 ; X - DB 1 - DW 'X' - DB 2 ; x - DW 'x' - DB 4 ; Ctrl-X - DW 1Ah - DB 5 ; Alt-X - DW 2D00h - DB 0FFh - - DB 46 ; C - DB 1 - DW 'C' - DB 2 ; c - DW 'c' - DB 4 ; Ctrl-C - DW 3 - DB 5 ; Alt-C - DW 2E00h - DB 0FFh - - DB 47 ; V - DB 1 - DW 'V' - DB 2 ; v - DW 'v' - DB 4 ; Ctrl-V - DW 16h - DB 5 ; Alt-V - DW 2F00h - DB 0FFh - - DB 48 ; B - DB 1 - DW 'B' - DB 2 ; b - DW 'b' - DB 4 ; Ctrl-B - DW 2 - DB 5 ; Alt-B - DW 3000h - DB 0FFh - - DB 49 ; N - DB 1 - DW 'N' - DB 2 ; n - DW 'n' - DB 4 ; Ctrl-N - DW 0Eh - DB 5 ; Alt-N - DW 3100h - DB 0FFh - - DB 50 ; M - DB 1 - DW 'M' - DB 2 - DW 'm' - DB 4 ; Ctrl-M - DW 0Dh - DB 5 ; Alt-M - DW 3200h - DB 0FFh - - DB 51 ; , - DB 0 - DW ',' - DB 3 - DW '<' - DB 0FFh - - DB 52 ; . - DB 0 - DW '.' - DB 3 - DW '>' - DB 0FFh - - DB 53 ; / - DB 0 - DW '/' - DB 3 - DW '?' - DB 0FFh - - DB 55 ; XT/AT printscreen, Enhanced keyboard * - DB 0 - DW '*' - DB 0FFh - - DB 57 ; Spacebar - DB 0 - DW ' ' - DB 3 - DW ' ' - DB 0FFh - - DB 71 ; Keypad 7 - DB 8 - DW '7' - DB 10 - DW 7 - DB 0FFh - - DB 72 ; Keypad 8 - DB 8 - DW '8' - DB 10 - DW 8 - DB 0FFh - - DB 73 ; Keypad 9 - DB 8 - DW '9' - DB 10 - DW 9 - DB 0FFh - - DB 74 ; Grey - - DB 0 - DW '-' - DB 0FFh - - DB 75 ; Keypad 4 - DB 8 - DW '4' - DB 10 - DW 4 - DB 0FFh - - DB 76 ; Keypad 5 - DB 8 - DW '5' - DB 10 - DW 5 - DB 0FFh - - DB 77 ; Keypad 6 - DB 8 - DW '6' - DB 10 - DW 6 - DB 0FFh - - DB 78 ; Grey + - DB 0 - DW '+' - DB 0FFh - - DB 79 ; Keypad 1 - DB 8 - DW '1' - DB 10 - DW 1 - DB 0FFh - - DB 80 ; Keypad 2 - DB 8 - DW '2' - DB 10 - DW 2 - DB 0FFh - - DB 81 ; Keypad 3 - DB 8 - DW '3' - DB 10 - DW 3 - DB 0FFh - - DB 82 ; Keypad 0 - DB 8 - DW '0' - DB 10 - DW 0 - DB 0FFh - - DB 83 - DB 8 - DW '.' - DB 0FFh - - DB 128+35h ; Grey / - DB 0 - DW '/' - DB 0FFh - - DB 0FFh - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Alt DB 0 -Ctrl DB 0 - -Proc K_KBHandler - - Push AX - Push BX - Push DS - - Push CS - Pop DS - - In AL, 60h ; Get input from port - - Cmp AL, 0FAh - JE K_KBHandler3 ; Is it a LED response?, 2 prev. - - Mov BX, KBEnd ; No... add a key to the queue - Inc BX - And BX, 0FFh - Cmp BX, KBStart - JE K_KBHandler1 - - Mov [KeyBoardBuffer+BX], AL - Mov KBEnd, BX - -K_KBHandler1: - Cmp AL, 1Dh ; Left Ctrl, Right Ctrl - JE K_KBHandlerCtrlPressed - Cmp AL, 9Dh - JE K_KBHandlerCtrlReleased - - Cmp AL, 38h ; Left Alt, Right Alt - JE K_KBHandlerAltPressed - Cmp AL, 0B8h - JE K_KBHandlerAltReleased - - Cmp AL, 42h ; F8 - JNE K_KBHandlerDel - - Cmp Word Ptr [Alt], 0 - JNE K_KBHandler3 - - Call Music_Stop - Jmp K_KBHandler3 - -K_KBHandlerCtrlPressed: - Mov Ctrl, 1 - Jmp K_KBHandler3 - -K_KBHandlerCtrlReleased: - Mov Ctrl, 0 - Jmp K_KBHandler3 - -K_KBHandlerAltPressed: - Mov Alt, 1 - Jmp K_KBHandler3 - -K_KBHandlerAltReleased: - Mov Alt, 0 - Jmp K_KBHandler3 - -K_KBHandlerDel: -CRASHRECOVERYKEY EQU $+1 - Cmp AL, 53h ; Delete, 52h = insert - JNE K_KBHandler3 - - Cmp Word Ptr [Alt], 101h - JNE K_KBHandler3 - - ; Crash recovery - Push BP - Mov BP, SP - DB 66h, 0C7h, 46h, 08h ; Mov DWord Ptr [BP+8], CrashRecovery - DD DWord Ptr CrashRecovery ; - Pop BP - -K_KBHandler3: - In AL, 61h ; KB Acknowledgement. - Mov AH, AL ; (Only for old 8042 chips.) - Or AL, 80h - Out 61h, AL - Mov AL, AH - Out 61h, AL - -K_KBHandler2: - Mov AL, 20h ; IRQ Acknowledgement. - Out 20h, AL - - Pop DS - Pop BX - Pop AX - IRet - -EndP K_KBHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_DOSKBHandler Far - - Push AX - - In AL, 60h - - Cmp AL, 4Eh ; Grey plus - JE K_DOSKBHandler5 - - Cmp AL, 4Ah ; Grey Minus - JE K_DOSKBHandler6 - - Cmp AL, 0E0h - JNE K_DOSKBHandler3 - - Mov CS:HighSet, 1 - Jmp K_DOSKBHandler4 - -K_DOSKBHandler3: - Cmp CS:HighSet, 0 - JE K_DOSKBHandler4 - - Mov CS:HighSet, 0 - - Cmp AL, 1Dh ; Right Ctrl. - JNE K_DOSKBHandler1 - - PushF - Call DWord Ptr [CS:OldKBHandler] - Call Music_KBPlaySong - Pop AX - IRet - -K_DOSKBHandler1: - Cmp AL, 38h ; Right Alt. - JNE K_DOSKBHandler4 - - PushF - Call DWord Ptr [CS:OldKBHandler] - Call Music_Stop - Pop AX - IRet - -K_DOSKBHandler4: - Pop AX - Jmp DWord Ptr [CS:OldKBHandler] - -K_DOSKBHandler5: ; Grey Plus - Mov AL, 20h - Out 20h, AL - - Call Music_IncreaseVolume - - Pop AX - IRet - -K_DOSKBHandler6: - Mov AL, 20h - Out 20h, AL - - Call Music_DecreaseVolume ; Grey minus - - Pop AX - IRet - -EndP K_DOSKBHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_SetKeyBoardLights ; Reqs: DS:KeyBoard - ; Sets keyboard lights (duh!) - Push AX - Mov AL, 0EDh - Out 60h, AL - - Xor AL, AL - - Cmp Caps, 0 - JE K_SetKeyBoardLights1 - - Mov AL, 4 - -K_SetKeyBoardLights1: - Cmp NumLock, 0 - JE K_SetKeyBoardLights2 - - Or AL, 2 - -K_SetKeyBoardLights2: - Cmp ScrollLock, 0 - JE K_SetKeyboardLights3 - - Or AL, 1 - -K_SetKeyBoardLights3: - Out 60h, AL - Pop AX - - Ret - -EndP K_SetKeyBoardLights - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_InitKeyBoard Far ; Raises key repeat rate - ; to 30 char/s, - ; delay before second char=0.25s - ; Gets old IRQ handler - ; and CAPS/NumLock states - ; Checks for Keyboard chip - ; Installs new IRQ handler - - Push AX - Push DS - Push ES - - Push CS - Pop DS - - Trace " - Detecting Windows presence" - - Mov AX, 1600h ; Windows detection. - Int 2Fh - Test AL, 7Fh - JZ NoWindows - - Mov Byte Ptr [CRASHRECOVERYKEY], 52h - -NoWindows: - Trace " - Setting keyboard repeat rate" - - Mov AX, 305h ; Set repeat rate - Xor BX, BX - Int 16h - - Trace " - Installing keyboard handler" - - ClI - - In AL, 21h - Or AL, 00000010b ; Disable keyboard IRQ - Out 21h, AL - - Xor AX, AX - Mov ES, AX - - Mov EAX, [ES:36] - Mov OldKBHandler, EAX - -K_InitKeyBoard3: ; Chained to from K_UnInstallDOSHandler - Mov AL, [ES:417h] ; Keyboard status byte. - Mov AH, AL - And AL, 40h - Mov Caps, AL - And AH, 20h - Mov NumLock, AH - - ; New keyboard IRQ handler - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset K_KBHandler - - Mov Word Ptr [ES:5], 0 ; Screw Int1 - Mov [ES:36], EAX - - In AL, 21h - And AL, 11111101b - Out 21h, AL - - StI - - Trace " - Initialising keyboard tables" - - Call K_ResetKeyboardTables ; Initialise keyboard tables. - - Trace " - Initialising keyboard lights" - - Call K_SetKeyboardLights - - Pop ES - Pop DS - Pop AX - - Ret - -EndP K_InitKeyBoard - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_UnInitKeyBoard Far - - Push AX - Push DS - Push ES - - Push CS - Pop DS - - ClI - - In AL, 21h - Or AL, 00000010b - Out 21h, AL - - Xor AX, AX - Mov ES, AX - - Mov EAX, OldKBHandler - Mov [ES:36], EAX - -K_UnInitKeyBoard3: ; Chain to from InstallDOSHandler - In AL, 21h - And AL, 11111101b - Out 21h, AL - - StI - - Mov AL, [ES:417h] - And AL, 10010000b - Cmp CS:Caps, 0 - JE K_UnInitKeyBoard2 - - Or AL, 40h ; Set caps lock flag - -K_UnInitKeyBoard2: - Cmp CS:NumLock, 0 - JZ K_UnInitKeyBoard1 - - Or AL, 20h - -K_UnInitKeyBoard1: - Mov [ES:417h], AL - - Pop ES - Pop DS - Pop AX - - Ret - -EndP K_UnInitKeyBoard - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_InstallDOSHandler Far - - Push AX - Push DS - Push ES - - Push CS - Pop DS - - ClI - - In AL, 21h - Or AL, 00000010b - Out 21h, AL - - Xor AX, AX - Mov ES, AX - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset K_DOSKBHandler - - Mov [ES:36], EAX - - Jmp K_UnInitKeyBoard3 - -EndP K_InstallDOSHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_UnInstallDOSHandler Far - - Push AX - Push DS - Push ES - - Push CS - Pop DS - - Mov AX, 305h ; Set repeat rate - Xor BX, BX - Int 16h - - ClI - - In AL, 21h - Or AL, 00000010b ; Disable keyboard IRQ - Out 21h, AL - - Xor AX, AX - Mov ES, AX - - Jmp K_InitKeyBoard3 - -EndP K_UnInstallDOSHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_GetNextKeyByte - - Inc BX - And BX, 0FFh - Mov AL, [KeyBoardBuffer+BX] - - Ret - -EndP K_GetNextKeyByte - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_IsKeyWaiting Far ; Returns 1 in AX if key is ready - ; 0 in AX if no key is ready - - Push DS - Push BX - Push CX - - Call IsStartupKeyList - And AX, 0FFh - - JNZ K_IsKeyWaiting1 - - Push CS - Pop DS - - Mov AX, KBEnd - Sub AX, KBStart - And AX, 0FFh - JZ K_IsKeyWaiting1 - - Mov CX, AX - - Mov BX, KBStart - Call K_GetNextKeyByte - Cmp AL, 0E0h - JNE K_IsKeyWaiting2 - - Mov AX, CX - Dec AX - Jmp K_IsKeyWaiting1 - -K_IsKeyWaiting2: - Mov AX, 1 - -K_IsKeyWaiting1: - Pop CX - Pop BX - Pop DS - Ret - -EndP K_IsKeyWaiting - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_GetKey Far ; CX/DX = input/translated - - Push AX - Push BX - Push DS - Push SI - - Push CS - Pop DS - - Call IsStartupKeyList - Test AL, AL - JZ K_GetKeyNoStartupKeyList - - Call GetStartupKeyList - Jmp K_GetKey20 - -K_GetKeyNoStartupKeyList: - ; Check MIDI first - Cmp [MIDIDataInput], 2 - JB K_GetKey1 - - ; OK.. have MIDI message - - Mov CH, [MIDIStatusByte] - Xor CL, CL - Mov DX, Word Ptr [MIDIDataByte1] - Mov [MIDIDataInput], 0 - Jmp K_GetKey20 - -K_GetKey1: - Call K_IsKeyWaiting - And AX, AX - JZ K_GetKey1 - - Xor SI, SI - - Mov BX, KBStart - Call K_GetNextKeyByte - Cmp AL, 0E0h - JB K_GetKey2 - Cmp AL, 0E1h - JA K_GetKey2 - - Mov CX, AX - And CX, 1 - Inc CX - -K_GetKey18: - Mov KBStart, BX - Call K_IsKeyWaiting - And AX, AX - JZ K_GetKey18 - - Add SI, 128 - Call K_GetNextKeyByte - - Loop K_GetKey18 - - Cmp SI, 128 - JBE K_GetKey2 - - Mov SI, 64 - -K_GetKey2: - Mov KBStart, BX - And AL, AL - JS K_GetKey3 - - Inc BH - -K_GetKey3: - And AX, 07Fh - Add SI, AX - Mov CX, SI - Mov CH, BH - - ; OK test for - ; stupid input. - Cmp CL, 0AAh - JE K_GetKey17 - Cmp CL, 0B6h - JE K_GetKey17 - - Mov [KeyBoardTable+SI], BH - - Cmp CX, 13Ah - JNE K_GetKey14 - - Cmp LastKey, CX - JE K_GetKey10 - - Xor Caps, 40h ; Toggle Caps Lock - Call K_SetKeyBoardLights - Jmp K_GetKey10 - -K_GetKey14: - Cmp CX, 145h ; Num Lock - JNE K_GetKey10 - - Cmp LastKey, CX - JE K_GetKey10 - - Xor NumLock, 20h - Call K_SetKeyBoardLights - -K_GetKey10: - Mov LastKey, CX - Cmp Byte Ptr [KeyBoardTable+02Ah], 0 ; Left Shift Key - JE K_GetKey4 - - Or CH, 2 ; Left Shift Key - -K_GetKey4: - Cmp Byte Ptr [KeyBoardTable+36h], 0 ; Right Shift Key - JE K_GetKey5 - - Or CH, 4 ; Right Shift Key - -K_GetKey5: - Cmp Byte Ptr [KeyBoardTable+1Dh], 0 ; Left Ctrl Key - JE K_GetKey6 - - Or CH, 8 - -K_GetKey6: - Cmp Byte Ptr [KeyBoardTable+9Dh], 0 ; Right Ctrl Key - JE K_GetKey7 - - Or CH, 16 ; Right Ctrl Key - -K_GetKey7: - Cmp Byte Ptr [KeyBoardTable+38h], 0 ; Left Alt Key - JE K_GetKey8 - - Or CH, 32 ; Left Alt Key - -K_GetKey8: - Cmp Byte Ptr [KeyBoardTable+0B8h], 0 ; Right Alt Key - JE K_GetKey9 - - Or CH, 64 ; Right Alt Key - -K_GetKey9: - Test CH, 1 ; Keypress? - actually need to check for - ; Alt-keypad stuff. - JNZ K_TranslateKeyPress - - Cmp CL, 38h - JE K_TranslateAltRelease - Cmp CL, 0B8h - JNE K_TranslateKeyNoKey - -K_TranslateAltRelease: - Xor DX, DX - - Cmp KeypadValueFlag, 0 - JE K_TranslateKeyNoKey - - XChg Word Ptr KeypadValueFlag, DX ; Reset flag + value - ShR DX, 8 - Cmp DL, 32 - JB K_TranslateKeyNoKey - Jmp K_TranslateKeyEnd - -K_TranslateKeyPress: - LDS SI, TranslationTable - Assume DS:Nothing - -K_TranslateKey1: - LodsB - Cmp AL, CL - JE K_TranslateKey3 - Cmp AL, 0FFh - JE K_TranslateKeyNoKey - -K_TranslateKey2: - LodsB - Cmp AL, 0FFh - JE K_TranslateKey1 - LodsW - Jmp K_TranslateKey2 - -K_TranslateKey3: - LodsB - Mov BL, AL - LodsW - Mov DX, AX - Cmp BL, 1 - JB K_TranslateCondition0 - JE K_TranslateCondition1 - - Cmp BL, 3 - JB K_TranslateCondition2 - JE K_TranslateCondition3 - - Cmp BL, 5 - JB K_TranslateCondition4 - JE K_TranslateCondition5 - - Cmp BL, 7 - JB K_TranslateCondition6 - JE K_TranslateCondition7 - - Cmp BL, 9 - JB K_TranslateCondition8 - JE K_TranslateCondition9 - - Cmp BL, 11 - JB K_TranslateCondition10 - - Jmp K_TranslateKeyNoKey - -K_TranslateCondition0: ; Keypress - Test CH, Not 1 - JNZ K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition1: - Cmp Caps, 0 - JE K_TranslateCondition3 ; Caps off -> check shift - -K_TranslateConditionNoShift: - Test CH, Not 7 - JNZ K_TranslateKey3 - Test CH, 6 - JNZ K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition2: - Cmp Caps, 0 - JE K_TranslateConditionNoShift - ; Fall through to shift check - -K_TranslateCondition3: ; Shift - Test CH, Not 7 - JNZ K_TranslateKey3 - Test CH, 6 - JZ K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition4: ; Ctrl - Test CH, Not 19h - JNZ K_TranslateKey3 - Test CH, 18h - JZ K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition5: ; Alt - Test CH, Not 61h - JNZ K_TranslateKey3 - Test CH, 60h - JZ K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition6: ; Left alt - Test CH, Not 21h - JNZ K_TranslateKey3 - Test CH, 20h - JZ K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition7: ; Right alt - Test CH, Not 41h - JNZ K_TranslateKey3 - Test CH, 40h - JZ K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition8: - Test CH, Not 1 - JNZ K_TranslateKey3 - Cmp NumLock, 0 - JE K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition9: - Test CH, Not 1 - JNZ K_TranslateKey3 - Cmp NumLock, 0 - JNE K_TranslateKey3 - Jmp K_TranslateKeyEnd - -K_TranslateCondition10: - Test CH, Not 61h - JNZ K_TranslateKey3 - Test CH, 60h - JZ K_TranslateKey3 - - Mov CS:KeyPadValueFlag, 1 - Mov AL, 10 - Mul CS:KeyPadValue - Add AL, DL - Mov CS:KeyPadValue, AL - -K_TranslateKeyNoKey: - Xor DX, DX - -K_TranslateKeyEnd: - Cmp NumLock, 0 - JNE K_GetKey15 - - Cmp CL, 47h - JB K_GetKey15 - Cmp CL, 53h - JA K_GetKey15 - Cmp CL, 4Ah - JE K_GetKey15 - Cmp CL, 4Eh - JE K_GetKey15 - - Add CL, 80h - Jmp K_GetKey20 - -K_GetKey15: - Cmp CL, 9Ch ; Grey enter... - JNE K_GetKey20 - - Mov CL, 1Ch ; Normal enter! - Jmp K_GetKey20 - -K_GetKey17: - Xor CX, CX - Xor DX, DX - -K_GetKey20: - Pop SI - Pop DS - Pop BX - Pop AX - Ret - - -EndP K_GetKey - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_ClearKeyBoardQueue Far - - Push AX - -K_ClearKeyBoardQueue1: - Call K_IsKeyWaiting - Test AX, AX - JZ K_ClearKeyBoardQueue2 - Call K_GetKey - Jmp K_ClearKeyBoardQueue1 - -K_ClearKeyBoardQueue2: - Pop AX - Ret - -EndP K_ClearKeyBoardQueue - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_IsAnyKeyDown Far ; Returns AL = 1 if key is down. - - Push CX - Push DS - Push SI - - Push CS - Pop DS - Assume DS:Keyboard - - Mov SI, Offset KeyBoardTable - Mov CX, 256 - -K_IsAnyKeyDown1: - LodsB - And AL, AL - LoopZ K_IsAnyKeyDown1 - - JCXZ K_IsAnyKeyDown2 - - Mov AL, 1 - -K_IsAnyKeyDown2: - Pop SI - Pop DS - Pop CX - - Ret - -EndP K_IsAnyKeyDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_IsKeyDown Far ; BX = key to test - - Cmp [CS:KeyboardTable+BX], 0 - Ret - -EndP K_IsKeyDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_ResetKeyboardTables Far - - Push CS - Pop ES - Mov DI, Offset KeyboardTable - Mov CX, 518 - Xor AL, AL - Rep StosB - - Mov AX, 1 - Ret - -EndP K_ResetKeyboardTables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_DrawTables Far - - Call S_GetDestination - Mov DI, (2+15*80)*2 - - Push CS - Pop DS - Assume DS:KeyBoard - Mov SI, Offset KeyboardBuffer - - Mov CX, 2004h ; CH = row count, CL = ShR - Mov AH, 2h - -K_DrawTables1: - Mov DL, 08h ; BL = count - Push DI - -K_DrawTables3: - LodsB - Mov DH, AL - ShR AL, CL - Cmp AL, 10 - SBB AL, 69h - DAS - StosW - - Mov AL, DH - And AL, 0Fh - Cmp AL, 10 - SBB AL, 69h - DAS - StosW - - Dec DL - JZ K_DrawTables2 - - Mov AL, ' ' - StosW - Jmp K_DrawTables3 - -K_DrawTables2: - Pop DI - Add DI, 160 - - Dec CH - JNZ K_DrawTables1 - - ; Now for keypress tables. - Mov SI, Offset KeyboardTable - Mov DI, (29+15*80)*2 - - Mov CX, 2004h ; CH = row count, CL = ShR - Xor DL, DL - -K_DrawTable4: - Mov DH, 8 - Push DI - -K_DrawTable5: - Mov AH, 2 - LodsB - - Cmp AL, 1 - SBB AH, -1 - - Mov AL, DL - ShR AL, CL - Cmp AL, 10 - SBB AL, 69h - DAS - StosW - - Mov AL, DL - And AL, 0Fh - Cmp AL, 10 - SBB AL, 69h - DAS - StosW - - Inc DL - Dec DH - JZ K_DrawTable7 - - Mov AL, ' ' - StosW - Jmp K_DrawTable5 - -K_DrawTable7: - Pop DI - Add DI, 160 - - Dec CH - JNZ K_DrawTable4 - - Xor AX, AX - Ret - -EndP K_DrawTables - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_ShowMIDIInput Far - - Push CS - Pop DS - Assume DS:Keyboard - - ; Now to shove the MIDI input info. - Xor AX, AX - Mov AL, [MIDIDataByte2] - Push AX - Mov AL, [MIDIDataByte1] - Push AX - Mov AL, [MIDIStatusByte] - Push AX - - Mov DI, (2+13*80)*2 - Mov SI, Offset MIDIMessage - Mov AH, 20h - Call S_DrawString - - Add SP, 6 - - Xor AX, AX - Ret - -EndP K_ShowMIDIInput - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_InstallKeyboardType Far - - Call D_GotoStartingDirectory - - Push CS - Pop DS - Assume DS:Keyboard - - Mov AX, 3D00h - Mov DX, Offset KeyboardFile - Int 21h - JC K_InstallKeyboardType2 - - Trace " - Custom keyboard file found" - - Mov BX, AX - - Mov AH, 3Fh - Mov CX, 2 ; Read 2 bytes - Mov DX, Offset KeyboardFileLength - Int 21h - JC K_InstallKeyboardType1 - - Trace " - Allocating memory" - - Push BX - Mov AH, 48h ; Allocate memory - Mov BX, KeyboardFileLength - Mov CX, BX ; CX = length for next call. - Add BX, 15 - ShR BX, 4 - Int 21h - Pop BX - JC K_InstallKeyboardType1 - ; AX = load destination - - Trace " - Loading custom keyboard data" - - Mov DS, AX - Xor DX, DX - Mov AH, 3Fh ; Load data - Int 21h - JC K_InstallKeyboardType3 - - Trace " - Installing new keyboard translation table" - - Mov AX, DS - ShL EAX, 16 - Mov CS:TranslationTable, EAX - Jmp K_InstallKeyboardType1 - -K_InstallKeyboardType3: - Push DS - Pop ES - Mov AH, 49h - Int 21h - -K_InstallKeyboardType1: - Mov AH, 3Eh ; Close file - Int 21h - -K_InstallKeyboardType2: - Ret - -EndP K_InstallKeyboardType - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_RemoveKeyboardType Far - - Push CS - Pop DS - Assume DS:Keyboard - - Mov AX, TranslationTableSegment - Mov BX, CS - Cmp AX, BX - JE K_RemoveKeyboardType1 - - Mov ES, AX - Mov AH, 49h - Int 21h - -K_RemoveKeyboardType1: - Ret - -EndP K_RemoveKeyboardType - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc K_SetScrollLock Far - - Push CS - Pop DS - Mov ScrollLock, AL - Call K_SetKeyboardLights - Ret - -EndP K_SetScrollLock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDIBufferEmpty Far ; Returns carry set if input OK. - ; Returns carry CLEAR if input full. - - Cmp [CS:MIDIDataInput], 2 - Ret - -EndP MIDIBufferEmpty - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDISend Far ; Given AL = data byte. - - Push DS - - Push CS - Pop DS - Assume DS:Keyboard - - Test AL, AL ; Status byte? - JNS MIDISend1 - - Mov [MIDIStatusByte], AL - Mov [MIDIDataInput], 0 - Jmp MIDISendEnd - -MIDISend1: - Xor BX, BX - Mov SI, Offset MIDIDataByte1 - Add BL, [MIDIDataInput] - Mov [SI+BX], AL - Mov AL, [MIDIStatusByte] - Inc BX - Cmp AL, 0C0h - JB MIDISend2 - Cmp AL, 0E0h - JAE MIDISend2 - - Inc BX - Mov [MIDIDataByte2], 0 - -MIDISend2: - Mov [MIDIDataInput], BL - -MIDISendEnd: - Pop DS - Ret - -EndP MIDISend - Assume DS:Nothing - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Keyboard Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386 + +include switch.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Extrn D_GotoStartingDirectory:Far + + Extrn E_UnInitEMS:Far + Extrn S_GetDestination:Far + Extrn Music_Stop:Far + Extrn Music_KBPlaySong:Far + Extrn Music_IncreaseVolume:Far + Extrn Music_DecreaseVolume:Far + Extrn S_DrawString:Far + Extrn CrashRecovery:Far + + Extrn IsStartupKeyList:Far + Extrn GetStartupKeyList:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global K_DrawTables:Far + Global K_InitKeyBoard:Far + Global K_UnInitKeyBoard:Far + Global K_IsKeyWaiting:Far + Global K_GetKey:Far + Global K_IsAnyKeyDown:Far + Global K_IsKeyDown:Far + Global K_ClearKeyBoardQueue:Far + Global K_ResetKeyboardTables:Far + Global K_SelectKBButton:Far + Global K_SetKeyboardType:Far + Global K_InstallDOSHandler:Far + Global K_UnInstallDOSHandler:Far + Global K_SwapKeyBoard:Far + Global K_InstallKeyboardType:Far + Global K_RemoveKeyboardType:Far + Global K_SetScrollLock:Far + + Global CountryTable:Byte + + Public MIDIBufferEmpty, MIDISend, K_ShowMIDIInput + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment KeyBoard BYTE Public 'Code' USE16 + Assume CS:KeyBoard, DS:KeyBoard + +CREATENEWLOGFILE EQU 0 +include debug.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +KeyBoardTable DB 256 Dup (?) ; Table of current keypresses +KeyBoardBuffer DB 256 Dup (?) ; Queue of keys. +LastKey DW 0 ; For Caps/Numlock processing + ; only on FIRST press +KBStart DW 0 ; Buffer start ptr +KBEnd DW 0 ; Buffer end ptr + +OldKBHandler Label DWord +OldKBHandlerOffset DW ? ; Old Interrupt handler offset +OldKBHandlerSegment DW ? ; Old interrupt handler segment + +HighSet DB 0 + +Caps DB 0 ; Internal flag +NumLock DB 0 ; Internal flag +ScrollLock DB 0 + +KeyboardFile DB "KEYBOARD.CFG", 0 +KeyboardFileLength DW 0 + +KeypadValueFlag DB 0 +KeypadValue DB 0 + +MIDIStatusByte DB 0 +MIDIDataByte1 DB 0 +MIDIDataByte2 DB 0 +MIDIDataInput DB 0 + +MIDIMessage DB "MIDI Input: ", 0FDh, "X ", 0FDh, "X ", 0FDh, "X ", 0 + +TranslationTable Label DWord +TranslationTableOffset DW Offset USKeyboardTable +TranslationTableSegment DW Keyboard + +USKeyboardTable Label Byte + + DB 2 ; 1 + DB 0 + DW '1' + DB 3 ; ! + DW '!' + DB 0FFh + + DB 3 ; 2 + DB 0 + DW '2' + DB 3 ; @ + DW '@' + DB 0FFh + + DB 4 ; 3 + DB 0 + DW '3' + DB 3 ; # + DW '#' + DB 0FFh + + DB 5 ; 4 + DB 0 + DW '4' + DB 3 ; $ + DW '$' + DB 0FFh + + DB 6 ; 5 + DB 0 + DW '5' + DB 3 ; % + DW '%' + DB 0FFh + + DB 7 ; 6 + DB 0 + DW '6' + DB 3 ; ^ + DW '^' + DB 0FFh + + DB 8 ; 7 + DB 0 + DW '7' + DB 3 ; & + DW '&' + DB 0FFh + + DB 9 ; 8 + DB 0 + DW '8' + DB 3 ; * + DW '*' + DB 0FFh + + DB 10 ; 9 + DB 0 + DW '9' + DB 3 ; ( + DW '(' + DB 0FFh + + DB 11 ; 0 + DB 0 + DW '0' + DB 3 ; ) + DW ')' + DB 0FFh + + DB 12 ; - + DB 0 + DW '-' + DB 3 ; _ + DW '_' + DB 0FFh + + DB 13 ; = + DB 0 + DW '=' + DB 3 ; + + DW '+' + DB 0FFh + + DB 14 ; Backspace + DB 4 ; Ctrl-Backspace + DW 127 + DB 0FFh + + DB 15 ; Tab + DB 3 ; ShiftTab + DW 0F00h + DB 0FFh + + DB 16 ; Q + DB 1 + DW 'Q' + DB 2 ; q + DW 'q' + DB 4 ; Ctrl-Q + DW 11h + DB 5 ; Alt-Q + DW 1000h + DB 0FFh + + DB 17 ; W + DB 1 + DW 'W' + DB 2 ; w + DW 'w' + DB 4 ; Ctrl-W + DW 17h + DB 5 ; Alt-W + DW 1100h + DB 0FFh + + DB 18 ; E + DB 1 + DW 'E' + DB 2 ;e + DW 'e' + DB 4 ; Ctrl-E + DW 5 + DB 5 ; Alt-E + DW 1200h + DB 0FFh + + DB 19 ; R + DB 1 + DW 'R' + DB 2 ; r + DW 'r' + DB 4 ; Ctrl-R + DW 12h + DB 5 ; Alt-R + DW 1300h + DB 0FFh + + DB 20 ; T + DB 1 + DW 'T' + DB 2 ; t + DW 't' + DB 4 ; Ctrl-T + DW 14h + DB 5 ; Alt-T + DW 1400h + DB 0FFh + + DB 21 ; Y + DB 1 + DW 'Y' + DB 2 ; y + DW 'y' + DB 4 ; Ctrl-Y + DW 19h + DB 5 ; Alt-Y + DW 1500h + DB 0FFh + + DB 22 ; U + DB 1 + DW 'U' + DB 2 ; u + DW 'u' + DB 4 ; Ctrl-U + DW 15h + DB 5 ; Alt-U + DW 1600h + DB 0FFh + + DB 23 ; I + DB 1 + DW 'I' + DB 2 ; i + DW 'i' + DB 4 ; Ctrl-I + DW 9 + DB 5 ; Alt-I + DW 1700h + DB 0FFh + + DB 24 ; O + DB 1 + DW 'O' + DB 2 ; o + DW 'o' + DB 4 ; Ctrl-O + DW 0Fh + DB 5 ; Alt-O + DW 1800h + DB 0FFh + + DB 25 ; P + DB 1 + DW 'P' + DB 2 ; p + DW 'p' + DB 4 ; Ctrl-P + DW 10h + DB 5 ; Alt-P + DW 1900h + DB 0FFh + + DB 26 ; [ + DB 0 + DW '[' + DB 3 ; { + DW '{' + DB 0FFh + + DB 27 ; ] + DB 0 + DW ']' + DB 3 ; } + DW '}' + DB 0FFh + + DB 30 ; A + DB 1 + DW 'A' + DB 2 ; a + DW 'a' + DB 4 ; Ctrl-A + DW 1 + DB 5 ; Alt-A + DW 1E00h + DB 0FFh + + DB 31 ; S + DB 1 + DW 'S' + DB 2 ; s + DW 's' + DB 4 ; Ctrl-S + DW 13h + DB 5 ; Alt-S + DW 1F00h + DB 0FFh + + DB 32 ; D + DB 1 + DW 'D' + DB 2 ; d + DW 'd' + DB 4 ; Ctrl-D + DW 4 + DB 5 ; Alt-D + DW 2000h + DB 0FFh + + DB 33 ; F + DB 1 + DW 'F' + DB 2 ; f + DW 'f' + DB 4 ; Ctrl-F + DW 6 + DB 5 ; Alt-F + DW 2100h + DB 0FFh + + DB 34 ; G + DB 1 + DW 'G' + DB 2 ; g + DW 'g' + DB 4 ; Ctrl-G + DW 7 + DB 5 ; Alt-G + DW 2200h + DB 0FFh + + DB 35 ; H + DB 1 + DW 'H' + DB 2 ; h + DW 'h' + DB 4 ; Ctrl-H + DW 8 + DB 5 ; Alt-H + DW 2300h + DB 0FFh + + DB 36 ; J + DB 1 + DW 'J' + DB 2 ; j + DW 'j' + DB 4 ; Ctrl-J + DW 0Ah + DB 5 ; Alt-J + DW 2400h + DB 0FFh + + DB 37 ; K + DB 1 + DW 'K' + DB 2 ; k + DW 'k' + DB 4 ; Ctrl-K + DW 0Bh + DB 5 ; Alt-K + DW 2500h + DB 0FFh + + DB 38 ; L + DB 1 + DW 'L' + DB 2 ; l + DW 'l' + DB 4 ; Ctrl-L + DW 0Ch + DB 5 ; Alt-L + DW 2600h + DB 0FFh + + DB 39 ; ; + DB 0 + DW ';' + DB 3 ; : + DW ':' + DB 0FFh + + DB 40 ; ' + DB 0 + DW "'" + DB 3 ; " + DW '"' + DB 0FFh + + DB 41 ; ` + DB 0 + DW '`' + DB 3 ; ~ + DW '~' + DB 0FFh + + DB 43 ; \ + DB 0 + DW '\' + DB 3 ; | + DW '|' + DB 0FFh + + DB 44 ; z + DB 1 + DW 'Z' + DB 2 ; z + DW 'z' + DB 4 ; Ctrl-Z + DW 1Ah + DB 5 ; Alt-Z + DW 2C00h + DB 0FFh + + DB 45 ; X + DB 1 + DW 'X' + DB 2 ; x + DW 'x' + DB 4 ; Ctrl-X + DW 1Ah + DB 5 ; Alt-X + DW 2D00h + DB 0FFh + + DB 46 ; C + DB 1 + DW 'C' + DB 2 ; c + DW 'c' + DB 4 ; Ctrl-C + DW 3 + DB 5 ; Alt-C + DW 2E00h + DB 0FFh + + DB 47 ; V + DB 1 + DW 'V' + DB 2 ; v + DW 'v' + DB 4 ; Ctrl-V + DW 16h + DB 5 ; Alt-V + DW 2F00h + DB 0FFh + + DB 48 ; B + DB 1 + DW 'B' + DB 2 ; b + DW 'b' + DB 4 ; Ctrl-B + DW 2 + DB 5 ; Alt-B + DW 3000h + DB 0FFh + + DB 49 ; N + DB 1 + DW 'N' + DB 2 ; n + DW 'n' + DB 4 ; Ctrl-N + DW 0Eh + DB 5 ; Alt-N + DW 3100h + DB 0FFh + + DB 50 ; M + DB 1 + DW 'M' + DB 2 + DW 'm' + DB 4 ; Ctrl-M + DW 0Dh + DB 5 ; Alt-M + DW 3200h + DB 0FFh + + DB 51 ; , + DB 0 + DW ',' + DB 3 + DW '<' + DB 0FFh + + DB 52 ; . + DB 0 + DW '.' + DB 3 + DW '>' + DB 0FFh + + DB 53 ; / + DB 0 + DW '/' + DB 3 + DW '?' + DB 0FFh + + DB 55 ; XT/AT printscreen, Enhanced keyboard * + DB 0 + DW '*' + DB 0FFh + + DB 57 ; Spacebar + DB 0 + DW ' ' + DB 3 + DW ' ' + DB 0FFh + + DB 71 ; Keypad 7 + DB 8 + DW '7' + DB 10 + DW 7 + DB 0FFh + + DB 72 ; Keypad 8 + DB 8 + DW '8' + DB 10 + DW 8 + DB 0FFh + + DB 73 ; Keypad 9 + DB 8 + DW '9' + DB 10 + DW 9 + DB 0FFh + + DB 74 ; Grey - + DB 0 + DW '-' + DB 0FFh + + DB 75 ; Keypad 4 + DB 8 + DW '4' + DB 10 + DW 4 + DB 0FFh + + DB 76 ; Keypad 5 + DB 8 + DW '5' + DB 10 + DW 5 + DB 0FFh + + DB 77 ; Keypad 6 + DB 8 + DW '6' + DB 10 + DW 6 + DB 0FFh + + DB 78 ; Grey + + DB 0 + DW '+' + DB 0FFh + + DB 79 ; Keypad 1 + DB 8 + DW '1' + DB 10 + DW 1 + DB 0FFh + + DB 80 ; Keypad 2 + DB 8 + DW '2' + DB 10 + DW 2 + DB 0FFh + + DB 81 ; Keypad 3 + DB 8 + DW '3' + DB 10 + DW 3 + DB 0FFh + + DB 82 ; Keypad 0 + DB 8 + DW '0' + DB 10 + DW 0 + DB 0FFh + + DB 83 + DB 8 + DW '.' + DB 0FFh + + DB 128+35h ; Grey / + DB 0 + DW '/' + DB 0FFh + + DB 0FFh + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Alt DB 0 +Ctrl DB 0 + +Proc K_KBHandler + + Push AX + Push BX + Push DS + + Push CS + Pop DS + + In AL, 60h ; Get input from port + + Cmp AL, 0FAh + JE K_KBHandler3 ; Is it a LED response?, 2 prev. + + Mov BX, KBEnd ; No... add a key to the queue + Inc BX + And BX, 0FFh + Cmp BX, KBStart + JE K_KBHandler1 + + Mov [KeyBoardBuffer+BX], AL + Mov KBEnd, BX + +K_KBHandler1: + Cmp AL, 1Dh ; Left Ctrl, Right Ctrl + JE K_KBHandlerCtrlPressed + Cmp AL, 9Dh + JE K_KBHandlerCtrlReleased + + Cmp AL, 38h ; Left Alt, Right Alt + JE K_KBHandlerAltPressed + Cmp AL, 0B8h + JE K_KBHandlerAltReleased + + Cmp AL, 42h ; F8 + JNE K_KBHandlerDel + + Cmp Word Ptr [Alt], 0 + JNE K_KBHandler3 + + Call Music_Stop + Jmp K_KBHandler3 + +K_KBHandlerCtrlPressed: + Mov Ctrl, 1 + Jmp K_KBHandler3 + +K_KBHandlerCtrlReleased: + Mov Ctrl, 0 + Jmp K_KBHandler3 + +K_KBHandlerAltPressed: + Mov Alt, 1 + Jmp K_KBHandler3 + +K_KBHandlerAltReleased: + Mov Alt, 0 + Jmp K_KBHandler3 + +K_KBHandlerDel: +CRASHRECOVERYKEY EQU $+1 + Cmp AL, 53h ; Delete, 52h = insert + JNE K_KBHandler3 + + Cmp Word Ptr [Alt], 101h + JNE K_KBHandler3 + + ; Crash recovery + Push BP + Mov BP, SP + DB 66h, 0C7h, 46h, 08h ; Mov DWord Ptr [BP+8], CrashRecovery + DD DWord Ptr CrashRecovery ; + Pop BP + +K_KBHandler3: + In AL, 61h ; KB Acknowledgement. + Mov AH, AL ; (Only for old 8042 chips.) + Or AL, 80h + Out 61h, AL + Mov AL, AH + Out 61h, AL + +K_KBHandler2: + Mov AL, 20h ; IRQ Acknowledgement. + Out 20h, AL + + Pop DS + Pop BX + Pop AX + IRet + +EndP K_KBHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_DOSKBHandler Far + + Push AX + + In AL, 60h + + Cmp AL, 4Eh ; Grey plus + JE K_DOSKBHandler5 + + Cmp AL, 4Ah ; Grey Minus + JE K_DOSKBHandler6 + + Cmp AL, 0E0h + JNE K_DOSKBHandler3 + + Mov CS:HighSet, 1 + Jmp K_DOSKBHandler4 + +K_DOSKBHandler3: + Cmp CS:HighSet, 0 + JE K_DOSKBHandler4 + + Mov CS:HighSet, 0 + + Cmp AL, 1Dh ; Right Ctrl. + JNE K_DOSKBHandler1 + + PushF + Call DWord Ptr [CS:OldKBHandler] + Call Music_KBPlaySong + Pop AX + IRet + +K_DOSKBHandler1: + Cmp AL, 38h ; Right Alt. + JNE K_DOSKBHandler4 + + PushF + Call DWord Ptr [CS:OldKBHandler] + Call Music_Stop + Pop AX + IRet + +K_DOSKBHandler4: + Pop AX + Jmp DWord Ptr [CS:OldKBHandler] + +K_DOSKBHandler5: ; Grey Plus + Mov AL, 20h + Out 20h, AL + + Call Music_IncreaseVolume + + Pop AX + IRet + +K_DOSKBHandler6: + Mov AL, 20h + Out 20h, AL + + Call Music_DecreaseVolume ; Grey minus + + Pop AX + IRet + +EndP K_DOSKBHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_SetKeyBoardLights ; Reqs: DS:KeyBoard + ; Sets keyboard lights (duh!) + Push AX + Mov AL, 0EDh + Out 60h, AL + + Xor AL, AL + + Cmp Caps, 0 + JE K_SetKeyBoardLights1 + + Mov AL, 4 + +K_SetKeyBoardLights1: + Cmp NumLock, 0 + JE K_SetKeyBoardLights2 + + Or AL, 2 + +K_SetKeyBoardLights2: + Cmp ScrollLock, 0 + JE K_SetKeyboardLights3 + + Or AL, 1 + +K_SetKeyBoardLights3: + Out 60h, AL + Pop AX + + Ret + +EndP K_SetKeyBoardLights + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_InitKeyBoard Far ; Raises key repeat rate + ; to 30 char/s, + ; delay before second char=0.25s + ; Gets old IRQ handler + ; and CAPS/NumLock states + ; Checks for Keyboard chip + ; Installs new IRQ handler + + Push AX + Push DS + Push ES + + Push CS + Pop DS + + Trace " - Detecting Windows presence" + + Mov AX, 1600h ; Windows detection. + Int 2Fh + Test AL, 7Fh + JZ NoWindows + + Mov Byte Ptr [CRASHRECOVERYKEY], 52h + +NoWindows: + Trace " - Setting keyboard repeat rate" + + Mov AX, 305h ; Set repeat rate + Xor BX, BX + Int 16h + + Trace " - Installing keyboard handler" + + ClI + + In AL, 21h + Or AL, 00000010b ; Disable keyboard IRQ + Out 21h, AL + + Xor AX, AX + Mov ES, AX + + Mov EAX, [ES:36] + Mov OldKBHandler, EAX + +K_InitKeyBoard3: ; Chained to from K_UnInstallDOSHandler + Mov AL, [ES:417h] ; Keyboard status byte. + Mov AH, AL + And AL, 40h + Mov Caps, AL + And AH, 20h + Mov NumLock, AH + + ; New keyboard IRQ handler + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset K_KBHandler + + Mov Word Ptr [ES:5], 0 ; Screw Int1 + Mov [ES:36], EAX + + In AL, 21h + And AL, 11111101b + Out 21h, AL + + StI + + Trace " - Initialising keyboard tables" + + Call K_ResetKeyboardTables ; Initialise keyboard tables. + + Trace " - Initialising keyboard lights" + + Call K_SetKeyboardLights + + Pop ES + Pop DS + Pop AX + + Ret + +EndP K_InitKeyBoard + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_UnInitKeyBoard Far + + Push AX + Push DS + Push ES + + Push CS + Pop DS + + ClI + + In AL, 21h + Or AL, 00000010b + Out 21h, AL + + Xor AX, AX + Mov ES, AX + + Mov EAX, OldKBHandler + Mov [ES:36], EAX + +K_UnInitKeyBoard3: ; Chain to from InstallDOSHandler + In AL, 21h + And AL, 11111101b + Out 21h, AL + + StI + + Mov AL, [ES:417h] + And AL, 10010000b + Cmp CS:Caps, 0 + JE K_UnInitKeyBoard2 + + Or AL, 40h ; Set caps lock flag + +K_UnInitKeyBoard2: + Cmp CS:NumLock, 0 + JZ K_UnInitKeyBoard1 + + Or AL, 20h + +K_UnInitKeyBoard1: + Mov [ES:417h], AL + + Pop ES + Pop DS + Pop AX + + Ret + +EndP K_UnInitKeyBoard + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_InstallDOSHandler Far + + Push AX + Push DS + Push ES + + Push CS + Pop DS + + ClI + + In AL, 21h + Or AL, 00000010b + Out 21h, AL + + Xor AX, AX + Mov ES, AX + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset K_DOSKBHandler + + Mov [ES:36], EAX + + Jmp K_UnInitKeyBoard3 + +EndP K_InstallDOSHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_UnInstallDOSHandler Far + + Push AX + Push DS + Push ES + + Push CS + Pop DS + + Mov AX, 305h ; Set repeat rate + Xor BX, BX + Int 16h + + ClI + + In AL, 21h + Or AL, 00000010b ; Disable keyboard IRQ + Out 21h, AL + + Xor AX, AX + Mov ES, AX + + Jmp K_InitKeyBoard3 + +EndP K_UnInstallDOSHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_GetNextKeyByte + + Inc BX + And BX, 0FFh + Mov AL, [KeyBoardBuffer+BX] + + Ret + +EndP K_GetNextKeyByte + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_IsKeyWaiting Far ; Returns 1 in AX if key is ready + ; 0 in AX if no key is ready + + Push DS + Push BX + Push CX + + Call IsStartupKeyList + And AX, 0FFh + + JNZ K_IsKeyWaiting1 + + Push CS + Pop DS + + Mov AX, KBEnd + Sub AX, KBStart + And AX, 0FFh + JZ K_IsKeyWaiting1 + + Mov CX, AX + + Mov BX, KBStart + Call K_GetNextKeyByte + Cmp AL, 0E0h + JNE K_IsKeyWaiting2 + + Mov AX, CX + Dec AX + Jmp K_IsKeyWaiting1 + +K_IsKeyWaiting2: + Mov AX, 1 + +K_IsKeyWaiting1: + Pop CX + Pop BX + Pop DS + Ret + +EndP K_IsKeyWaiting + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_GetKey Far ; CX/DX = input/translated + + Push AX + Push BX + Push DS + Push SI + + Push CS + Pop DS + + Call IsStartupKeyList + Test AL, AL + JZ K_GetKeyNoStartupKeyList + + Call GetStartupKeyList + Jmp K_GetKey20 + +K_GetKeyNoStartupKeyList: + ; Check MIDI first + Cmp [MIDIDataInput], 2 + JB K_GetKey1 + + ; OK.. have MIDI message + + Mov CH, [MIDIStatusByte] + Xor CL, CL + Mov DX, Word Ptr [MIDIDataByte1] + Mov [MIDIDataInput], 0 + Jmp K_GetKey20 + +K_GetKey1: + Call K_IsKeyWaiting + And AX, AX + JZ K_GetKey1 + + Xor SI, SI + + Mov BX, KBStart + Call K_GetNextKeyByte + Cmp AL, 0E0h + JB K_GetKey2 + Cmp AL, 0E1h + JA K_GetKey2 + + Mov CX, AX + And CX, 1 + Inc CX + +K_GetKey18: + Mov KBStart, BX + Call K_IsKeyWaiting + And AX, AX + JZ K_GetKey18 + + Add SI, 128 + Call K_GetNextKeyByte + + Loop K_GetKey18 + + Cmp SI, 128 + JBE K_GetKey2 + + Mov SI, 64 + +K_GetKey2: + Mov KBStart, BX + And AL, AL + JS K_GetKey3 + + Inc BH + +K_GetKey3: + And AX, 07Fh + Add SI, AX + Mov CX, SI + Mov CH, BH + + ; OK test for + ; stupid input. + Cmp CL, 0AAh + JE K_GetKey17 + Cmp CL, 0B6h + JE K_GetKey17 + + Mov [KeyBoardTable+SI], BH + + Cmp CX, 13Ah + JNE K_GetKey14 + + Cmp LastKey, CX + JE K_GetKey10 + + Xor Caps, 40h ; Toggle Caps Lock + Call K_SetKeyBoardLights + Jmp K_GetKey10 + +K_GetKey14: + Cmp CX, 145h ; Num Lock + JNE K_GetKey10 + + Cmp LastKey, CX + JE K_GetKey10 + + Xor NumLock, 20h + Call K_SetKeyBoardLights + +K_GetKey10: + Mov LastKey, CX + Cmp Byte Ptr [KeyBoardTable+02Ah], 0 ; Left Shift Key + JE K_GetKey4 + + Or CH, 2 ; Left Shift Key + +K_GetKey4: + Cmp Byte Ptr [KeyBoardTable+36h], 0 ; Right Shift Key + JE K_GetKey5 + + Or CH, 4 ; Right Shift Key + +K_GetKey5: + Cmp Byte Ptr [KeyBoardTable+1Dh], 0 ; Left Ctrl Key + JE K_GetKey6 + + Or CH, 8 + +K_GetKey6: + Cmp Byte Ptr [KeyBoardTable+9Dh], 0 ; Right Ctrl Key + JE K_GetKey7 + + Or CH, 16 ; Right Ctrl Key + +K_GetKey7: + Cmp Byte Ptr [KeyBoardTable+38h], 0 ; Left Alt Key + JE K_GetKey8 + + Or CH, 32 ; Left Alt Key + +K_GetKey8: + Cmp Byte Ptr [KeyBoardTable+0B8h], 0 ; Right Alt Key + JE K_GetKey9 + + Or CH, 64 ; Right Alt Key + +K_GetKey9: + Test CH, 1 ; Keypress? - actually need to check for + ; Alt-keypad stuff. + JNZ K_TranslateKeyPress + + Cmp CL, 38h + JE K_TranslateAltRelease + Cmp CL, 0B8h + JNE K_TranslateKeyNoKey + +K_TranslateAltRelease: + Xor DX, DX + + Cmp KeypadValueFlag, 0 + JE K_TranslateKeyNoKey + + XChg Word Ptr KeypadValueFlag, DX ; Reset flag + value + ShR DX, 8 + Cmp DL, 32 + JB K_TranslateKeyNoKey + Jmp K_TranslateKeyEnd + +K_TranslateKeyPress: + LDS SI, TranslationTable + Assume DS:Nothing + +K_TranslateKey1: + LodsB + Cmp AL, CL + JE K_TranslateKey3 + Cmp AL, 0FFh + JE K_TranslateKeyNoKey + +K_TranslateKey2: + LodsB + Cmp AL, 0FFh + JE K_TranslateKey1 + LodsW + Jmp K_TranslateKey2 + +K_TranslateKey3: + LodsB + Mov BL, AL + LodsW + Mov DX, AX + Cmp BL, 1 + JB K_TranslateCondition0 + JE K_TranslateCondition1 + + Cmp BL, 3 + JB K_TranslateCondition2 + JE K_TranslateCondition3 + + Cmp BL, 5 + JB K_TranslateCondition4 + JE K_TranslateCondition5 + + Cmp BL, 7 + JB K_TranslateCondition6 + JE K_TranslateCondition7 + + Cmp BL, 9 + JB K_TranslateCondition8 + JE K_TranslateCondition9 + + Cmp BL, 11 + JB K_TranslateCondition10 + + Jmp K_TranslateKeyNoKey + +K_TranslateCondition0: ; Keypress + Test CH, Not 1 + JNZ K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition1: + Cmp Caps, 0 + JE K_TranslateCondition3 ; Caps off -> check shift + +K_TranslateConditionNoShift: + Test CH, Not 7 + JNZ K_TranslateKey3 + Test CH, 6 + JNZ K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition2: + Cmp Caps, 0 + JE K_TranslateConditionNoShift + ; Fall through to shift check + +K_TranslateCondition3: ; Shift + Test CH, Not 7 + JNZ K_TranslateKey3 + Test CH, 6 + JZ K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition4: ; Ctrl + Test CH, Not 19h + JNZ K_TranslateKey3 + Test CH, 18h + JZ K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition5: ; Alt + Test CH, Not 61h + JNZ K_TranslateKey3 + Test CH, 60h + JZ K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition6: ; Left alt + Test CH, Not 21h + JNZ K_TranslateKey3 + Test CH, 20h + JZ K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition7: ; Right alt + Test CH, Not 41h + JNZ K_TranslateKey3 + Test CH, 40h + JZ K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition8: + Test CH, Not 1 + JNZ K_TranslateKey3 + Cmp NumLock, 0 + JE K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition9: + Test CH, Not 1 + JNZ K_TranslateKey3 + Cmp NumLock, 0 + JNE K_TranslateKey3 + Jmp K_TranslateKeyEnd + +K_TranslateCondition10: + Test CH, Not 61h + JNZ K_TranslateKey3 + Test CH, 60h + JZ K_TranslateKey3 + + Mov CS:KeyPadValueFlag, 1 + Mov AL, 10 + Mul CS:KeyPadValue + Add AL, DL + Mov CS:KeyPadValue, AL + +K_TranslateKeyNoKey: + Xor DX, DX + +K_TranslateKeyEnd: + Cmp NumLock, 0 + JNE K_GetKey15 + + Cmp CL, 47h + JB K_GetKey15 + Cmp CL, 53h + JA K_GetKey15 + Cmp CL, 4Ah + JE K_GetKey15 + Cmp CL, 4Eh + JE K_GetKey15 + + Add CL, 80h + Jmp K_GetKey20 + +K_GetKey15: + Cmp CL, 9Ch ; Grey enter... + JNE K_GetKey20 + + Mov CL, 1Ch ; Normal enter! + Jmp K_GetKey20 + +K_GetKey17: + Xor CX, CX + Xor DX, DX + +K_GetKey20: + Pop SI + Pop DS + Pop BX + Pop AX + Ret + + +EndP K_GetKey + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_ClearKeyBoardQueue Far + + Push AX + +K_ClearKeyBoardQueue1: + Call K_IsKeyWaiting + Test AX, AX + JZ K_ClearKeyBoardQueue2 + Call K_GetKey + Jmp K_ClearKeyBoardQueue1 + +K_ClearKeyBoardQueue2: + Pop AX + Ret + +EndP K_ClearKeyBoardQueue + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_IsAnyKeyDown Far ; Returns AL = 1 if key is down. + + Push CX + Push DS + Push SI + + Push CS + Pop DS + Assume DS:Keyboard + + Mov SI, Offset KeyBoardTable + Mov CX, 256 + +K_IsAnyKeyDown1: + LodsB + And AL, AL + LoopZ K_IsAnyKeyDown1 + + JCXZ K_IsAnyKeyDown2 + + Mov AL, 1 + +K_IsAnyKeyDown2: + Pop SI + Pop DS + Pop CX + + Ret + +EndP K_IsAnyKeyDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_IsKeyDown Far ; BX = key to test + + Cmp [CS:KeyboardTable+BX], 0 + Ret + +EndP K_IsKeyDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_ResetKeyboardTables Far + + Push CS + Pop ES + Mov DI, Offset KeyboardTable + Mov CX, 518 + Xor AL, AL + Rep StosB + + Mov AX, 1 + Ret + +EndP K_ResetKeyboardTables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_DrawTables Far + + Call S_GetDestination + Mov DI, (2+15*80)*2 + + Push CS + Pop DS + Assume DS:KeyBoard + Mov SI, Offset KeyboardBuffer + + Mov CX, 2004h ; CH = row count, CL = ShR + Mov AH, 2h + +K_DrawTables1: + Mov DL, 08h ; BL = count + Push DI + +K_DrawTables3: + LodsB + Mov DH, AL + ShR AL, CL + Cmp AL, 10 + SBB AL, 69h + DAS + StosW + + Mov AL, DH + And AL, 0Fh + Cmp AL, 10 + SBB AL, 69h + DAS + StosW + + Dec DL + JZ K_DrawTables2 + + Mov AL, ' ' + StosW + Jmp K_DrawTables3 + +K_DrawTables2: + Pop DI + Add DI, 160 + + Dec CH + JNZ K_DrawTables1 + + ; Now for keypress tables. + Mov SI, Offset KeyboardTable + Mov DI, (29+15*80)*2 + + Mov CX, 2004h ; CH = row count, CL = ShR + Xor DL, DL + +K_DrawTable4: + Mov DH, 8 + Push DI + +K_DrawTable5: + Mov AH, 2 + LodsB + + Cmp AL, 1 + SBB AH, -1 + + Mov AL, DL + ShR AL, CL + Cmp AL, 10 + SBB AL, 69h + DAS + StosW + + Mov AL, DL + And AL, 0Fh + Cmp AL, 10 + SBB AL, 69h + DAS + StosW + + Inc DL + Dec DH + JZ K_DrawTable7 + + Mov AL, ' ' + StosW + Jmp K_DrawTable5 + +K_DrawTable7: + Pop DI + Add DI, 160 + + Dec CH + JNZ K_DrawTable4 + + Xor AX, AX + Ret + +EndP K_DrawTables + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_ShowMIDIInput Far + + Push CS + Pop DS + Assume DS:Keyboard + + ; Now to shove the MIDI input info. + Xor AX, AX + Mov AL, [MIDIDataByte2] + Push AX + Mov AL, [MIDIDataByte1] + Push AX + Mov AL, [MIDIStatusByte] + Push AX + + Mov DI, (2+13*80)*2 + Mov SI, Offset MIDIMessage + Mov AH, 20h + Call S_DrawString + + Add SP, 6 + + Xor AX, AX + Ret + +EndP K_ShowMIDIInput + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_InstallKeyboardType Far + + Call D_GotoStartingDirectory + + Push CS + Pop DS + Assume DS:Keyboard + + Mov AX, 3D00h + Mov DX, Offset KeyboardFile + Int 21h + JC K_InstallKeyboardType2 + + Trace " - Custom keyboard file found" + + Mov BX, AX + + Mov AH, 3Fh + Mov CX, 2 ; Read 2 bytes + Mov DX, Offset KeyboardFileLength + Int 21h + JC K_InstallKeyboardType1 + + Trace " - Allocating memory" + + Push BX + Mov AH, 48h ; Allocate memory + Mov BX, KeyboardFileLength + Mov CX, BX ; CX = length for next call. + Add BX, 15 + ShR BX, 4 + Int 21h + Pop BX + JC K_InstallKeyboardType1 + ; AX = load destination + + Trace " - Loading custom keyboard data" + + Mov DS, AX + Xor DX, DX + Mov AH, 3Fh ; Load data + Int 21h + JC K_InstallKeyboardType3 + + Trace " - Installing new keyboard translation table" + + Mov AX, DS + ShL EAX, 16 + Mov CS:TranslationTable, EAX + Jmp K_InstallKeyboardType1 + +K_InstallKeyboardType3: + Push DS + Pop ES + Mov AH, 49h + Int 21h + +K_InstallKeyboardType1: + Mov AH, 3Eh ; Close file + Int 21h + +K_InstallKeyboardType2: + Ret + +EndP K_InstallKeyboardType + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_RemoveKeyboardType Far + + Push CS + Pop DS + Assume DS:Keyboard + + Mov AX, TranslationTableSegment + Mov BX, CS + Cmp AX, BX + JE K_RemoveKeyboardType1 + + Mov ES, AX + Mov AH, 49h + Int 21h + +K_RemoveKeyboardType1: + Ret + +EndP K_RemoveKeyboardType + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc K_SetScrollLock Far + + Push CS + Pop DS + Mov ScrollLock, AL + Call K_SetKeyboardLights + Ret + +EndP K_SetScrollLock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDIBufferEmpty Far ; Returns carry set if input OK. + ; Returns carry CLEAR if input full. + + Cmp [CS:MIDIDataInput], 2 + Ret + +EndP MIDIBufferEmpty + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDISend Far ; Given AL = data byte. + + Push DS + + Push CS + Pop DS + Assume DS:Keyboard + + Test AL, AL ; Status byte? + JNS MIDISend1 + + Mov [MIDIStatusByte], AL + Mov [MIDIDataInput], 0 + Jmp MIDISendEnd + +MIDISend1: + Xor BX, BX + Mov SI, Offset MIDIDataByte1 + Add BL, [MIDIDataInput] + Mov [SI+BX], AL + Mov AL, [MIDIStatusByte] + Inc BX + Cmp AL, 0C0h + JB MIDISend2 + Cmp AL, 0E0h + JAE MIDISend2 + + Inc BX + Mov [MIDIDataByte2], 0 + +MIDISend2: + Mov [MIDIDataInput], BL + +MIDISendEnd: + Pop DS + Ret + +EndP MIDISend + Assume DS:Nothing + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_L.ASM b/it_l.s similarity index 96% rename from IT_L.ASM rename to it_l.s index 7085bce..53cf64e 100644 --- a/IT_L.ASM +++ b/it_l.s @@ -1,559 +1,559 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Info Line Module - Playing info updates / other messages ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386 - -include switch.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Glbl BYTE Public 'Code' - Extrn CurrentMode:Byte -EndS - - Extrn I_ShowSamplePlay:Far - Extrn I_ShowInstrumentPlay:Far - - Extrn S_UpdateScreen:Far - Extrn S_DrawString:Far - Extrn S_SetDirectMode:Far - Extrn S_GetDestination:Far - - Extrn Music_GetPlayMode:Far - Extrn Music_Poll:Far - Extrn Music_GetSlaveChannelInformationTable:Far - -IF NETWORKENABLED - Extrn Network_Poll:Far -ENDIF - - Extrn PE_ShowOrder:Far - Extrn PE_FillSpeedTempo:Far - Extrn PE_GetMaxOrder:Far - Extrn Glbl_TutorialHandler:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global UpdateInfoLine:Far - Global IdleUpdateInfoLine:Far - Global ClearInfoLine:Far - Global SetInfoLine:Far, SetInfoLine2:Far - Global StartClock:Far - Global GlobalStartTime:Far - Public ShowUsageTime - Public InitTimerHandler - Public UnInitTimerHandler - Public GetTimerCounter - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment InfoLine DWORD Public 'Code' USE16 - Assume CS:InfoLine, DS:InfoLine - -CREATENEWLOGFILE EQU 0 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -SLAVECHANNELSIZE = 128 - -OldTimerHandler DD 0 -TimerCounter DD 0 -PlaybackTimer DD 0 - -InfoLineText DD 0 -InfoLineDelay DW 0 -InfoLineVariable DW 0 - -; Colouring for ZaStaR -; PatternPlayMsg DB "Playing, Pattern: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Row: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FDh, "D", 0FFh, 13, " ", 0 -; SongPlayMsg DB "Playing, Order: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FDh, "D, Pattern: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Row: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FDh, "D", 0FFh, 6, " ", 0 - -NoSoundDriverMsg DB "Error: No sound driver loaded.", 0 -PatternPlayMsg DB "Playing, Pattern: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Row: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, " Channels", 0FFh, 10, " ", 0 -SongPlayMsg DB "Playing, Order: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Pattern: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Row: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, " Channels", 0FFh, 10, " ", 0 -ChannelMsg DB "Playing, ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, " Channels", 0 -EmptyMsg DB 0 -TimeMsg DB " Time ", 0FDh, "D:" -Minutes DB "00:" -Seconds DB "00", 0 -DisplayChannelMsg DB 0 -ShowUsageTime DB 1 - - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc TimerInterruptHandler - - Sub CS:InfoLineDelay, 1 - AdC CS:InfoLineDelay, 0 - - Inc CS:TimerCounter - Jmp [CS:OldTimerHandler] - -EndP TimerInterruptHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitTimerHandler Far - - Push DS - - Trace " - Installing new timer interrupt" - - Xor AX, AX - Mov DS, AX - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset TimerInterruptHandler - - ClI - XChg EAX, [DS:20h] - Mov [CS:OldTimerHandler], EAX - StI - - Pop DS - Ret - -EndP InitTimerHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UninitTimerHandler Far - - Push DS - - Xor AX, AX - Mov DS, AX - - Mov EAX, [CS:OldTimerHandler] - ClI - Mov [DS:20h], EAX - StI - - Pop DS - Ret - -EndP UninitTimerHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FillToEOL - - Push ES - Mov AX, ' ' + 2000h - Call S_GetDestination - -UpdateInfoLineEOL: - Cmp DI, (61+9*80)*2 - JAE UpdateInfoLineEOL2 - - StosW - Jmp UpdateInfoLineEOL - -UpdateInfoLineEOL2: - Pop ES - Ret - -EndP FillToEOL - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateInfoLine Far - - Push DS - Push SI - - Push Glbl - Pop DS - Assume DS:Glbl - - Cmp CurrentMode, 200 - JAE UpdateInfoLineEnd2 - - Push CS - Pop DS - - Mov DI, (2+9*80)*2 - - Cmp InfoLineDelay, 0 - JE UpdateInfoLine1 -; Mov CX, InfoLineDelay -; JCXZ UpdateInfoLine1 -; -; Dec InfoLineDelay - -UpdateInfoLine2: - LDS SI, InfoLineText - Mov CX, DS - JCXZ UpdateInfoLineEnd - - Mov AX, CS:InfoLineVariable - Push AX - - Mov AH, 20h - Call S_DrawString - Call FillToEOL - - Pop AX - - Call Music_GetPlayMode -; Call ShowTime - Jmp UpdateInfoLine6 - -UpdateInfoLine1: -; ****** - Call Music_GetSlaveChannelInformationTable - ; DS:SI points to tables - ; CX = numchannels. - Xor DI, DI ; DI = counter of - ; currently act. - ; channels. -CountChannels1: - Mov AX, [SI] - Test AH, 8 - JNZ CountChannels2 - - And AX, 1 - Add DI, AX - -CountChannels2: - Add SI, SLAVECHANNELSIZE - Loop CountChannels1 - - Push CS - Pop DS -; ****** - Call Music_GetPlayMode - ; AX = playmode - ; BX = row - ; CX = pattern - ; DX = order - ; SI = max row. - - Push AX - Push DI - Cmp AX, 1 - JB UpdateInfoLineChanMsg - Push SI - Push BX ; BX = row - Push CX ; CX = pattern - JE UpdateInfoLine3 - JA UpdateInfoLine4 - -UpdateInfoLineChanMsg: - Mov SI, Offset ChannelMsg - Cmp DI, 1 - JA UpdateInfoLineChanMsg2 - - Mov SI, Offset EmptyMsg - -UpdateInfoLineChanMsg2: - Mov DI, (2+9*80)*2 - Mov AH, 20h - Call S_DrawString - Call FillToEOL - Pop AX - - Pop AX - Mov DisplayChannelMsg, 1 - Jmp UpdateInfoLine7 - -UpdateInfoLineEnd: - Call ShowTime - -UpdateInfoLineEnd2: - Pop SI - Pop DS - - Mov AX, 1 - Ret - -UpdateInfoLine3: - Mov DI, (2+9*80)*2 - Mov SI, Offset PatternPlayMsg - Mov AH, 20h - Call S_DrawString - Call FillToEOL - - Add SP, 8 - Jmp UpdateInfoLine5 - -UpdateInfoLine4: - Call PE_GetMaxOrder - - Push AX - Push DX - - Mov DI, (2+9*80)*2 - Mov SI, Offset SongPlayMsg - Mov AH, 20h - Call S_DrawString - Call FillToEOL - - Add SP, 12 - -UpdateInfoLine5: - Pop AX - -UpdateInfoLine6: -; Cmp AX, 2 -; JNE UpdateInfoLine7 - - -UpdateInfoLine7: - Call ShowTime - Call UpdatePointers - - Pop SI - Pop DS - - Mov AX, 1 - Ret - -EndP UpdateInfoLine - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc IdleUpdateInfoLine Far - - Call Music_Poll - -IF TUTORIAL -ELSE - Mov AL, 1 - Call S_SetDirectMode -ENDIF - - Call UpdateInfoLine - -IF TUTORIAL - Call Glbl_TutorialHandler -ENDIF - -IF TUTORIAL - Call S_UpdateScreen -ELSE - Mov AL, 0 - Call S_SetDirectMode -ENDIF - -IF NETWORKENABLED - Jmp Network_Poll -ELSE - Xor AX, AX - Ret -ENDIF - -EndP IdleUpdateInfoLine - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ClearInfoLine Far - - Mov DWord Ptr [CS:InfoLineText], 0 - - Ret - -EndP ClearInfoLine - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetInfoLine Far ; DS:SI points to msg. - - Mov CS:InfoLineDelay, 20 - -SetInfoLineChain: - Mov Word Ptr [CS:InfoLineText], SI - Mov Word Ptr [CS:InfoLineText+2], DS - Mov Word Ptr [CS:InfoLineVariable], AX - - Ret - -EndP SetInfoLine - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetInfoLine2 Far ; DS:SI points to msg. - - Mov CS:InfoLineDelay, BX - Jmp SetInfoLineChain - -EndP SetInfoLine2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdatePointers ; BX = row, CX = pattern - - Mov SI, Glbl - Mov DS, SI - Assume DS:Glbl - - Mov AH, CurrentMode - -; And AH, AH -; JZ UpdatePointers6 - - Push AX - Push BX - Push CX - -; Call S_GetDestination ; Get ES. - Call PE_FillSpeedTempo - - Pop CX - Pop BX - Pop AX - -UpdatePointers6: -; Cmp AH, 2 -; JNE UpdatePointers1 -; -; Cmp AL, 1 -; JB UpdatePointersEnd -; -; Call PE_ShowPatternRow -; Ret -; -; UpdatePointers1: - Cmp AL, 2 ; Playmode. - JNE UpdatePointers3 - - Cmp AH, 11 - JE UpdatePointers2 - Cmp AH, 21 - JNE UpdatePointers3 - -UpdatePointers2: - Call PE_ShowOrder - - Ret - -UpdatePointers3: - Cmp AH, 3 - JNE UpdatePointers4 - - Call I_ShowSamplePlay - Ret - -UpdatePointers4: - Cmp AH, 4 - JNE UpdatePointers5 - - Call I_ShowInstrumentPlay - Ret - -UpdatePointers5: -UpdatePointersEnd: - Ret - -EndP UpdatePointers - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ShowTime - - PushA - Push DS - - Push CS - Pop DS - Assume DS:InfoLine - - Cmp AX, 2 - Mov EAX, [TimerCounter] - JE ShowTime3 - - Cmp ShowUsageTime, 0 - JE ShowTime2 - - Jmp ShowTime4 - -ShowTime3: - Sub EAX, [PlaybackTimer] - -ShowTime4: - Mov EDX, 3600 - Mul EDX - ShRD EAX, EDX, 16 - ShR EDX, 16 - JNZ ShowTime2 - ; EAX = number of seconds - Mov EBX, 60 - Div EBX ; EAX = minutes, EDX = seconds - - Push EDX - Xor EDX, EDX - Div EBX ; EAX = hours, EDX = minutes - - Pop ECX - Push AX ; Hours on stack, CX = seconds, DX = min - Mov BL, 10 - - Mov AX, DX - Div BL - Add AX, 3030h - Mov [Word Ptr Minutes], AX - - Mov AX, CX - Div BL - Add AX, 3030h - Mov [Word Ptr Seconds], AX - - Mov SI, Offset TimeMsg - Mov DI, (62+9*80)*2 - Mov AH, 20h - Call S_DrawString - Pop AX ; To clear stack - -ShowTime2: - Pop DS - PopA - - Ret - -EndP ShowTime - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc StartClock Far - - Push EAX - Mov EAX, CS:TimerCounter - Mov [CS:PlaybackTimer], EAX - Pop EAX - - Ret - -EndP StartClock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetTimerCounter Far - - Mov EAX, [CS:TimerCounter] - Ret - -EndP GetTimerCounter - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Info Line Module - Playing info updates / other messages ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386 + +include switch.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Glbl BYTE Public 'Code' + Extrn CurrentMode:Byte +EndS + + Extrn I_ShowSamplePlay:Far + Extrn I_ShowInstrumentPlay:Far + + Extrn S_UpdateScreen:Far + Extrn S_DrawString:Far + Extrn S_SetDirectMode:Far + Extrn S_GetDestination:Far + + Extrn Music_GetPlayMode:Far + Extrn Music_Poll:Far + Extrn Music_GetSlaveChannelInformationTable:Far + +IF NETWORKENABLED + Extrn Network_Poll:Far +ENDIF + + Extrn PE_ShowOrder:Far + Extrn PE_FillSpeedTempo:Far + Extrn PE_GetMaxOrder:Far + Extrn Glbl_TutorialHandler:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global UpdateInfoLine:Far + Global IdleUpdateInfoLine:Far + Global ClearInfoLine:Far + Global SetInfoLine:Far, SetInfoLine2:Far + Global StartClock:Far + Global GlobalStartTime:Far + Public ShowUsageTime + Public InitTimerHandler + Public UnInitTimerHandler + Public GetTimerCounter + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment InfoLine DWORD Public 'Code' USE16 + Assume CS:InfoLine, DS:InfoLine + +CREATENEWLOGFILE EQU 0 +include debug.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +SLAVECHANNELSIZE = 128 + +OldTimerHandler DD 0 +TimerCounter DD 0 +PlaybackTimer DD 0 + +InfoLineText DD 0 +InfoLineDelay DW 0 +InfoLineVariable DW 0 + +; Colouring for ZaStaR +; PatternPlayMsg DB "Playing, Pattern: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Row: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FDh, "D", 0FFh, 13, " ", 0 +; SongPlayMsg DB "Playing, Order: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FDh, "D, Pattern: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Row: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FDh, "D", 0FFh, 6, " ", 0 + +NoSoundDriverMsg DB "Error: No sound driver loaded.", 0 +PatternPlayMsg DB "Playing, Pattern: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Row: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, " Channels", 0FFh, 10, " ", 0 +SongPlayMsg DB "Playing, Order: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Pattern: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", Row: ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, "/", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, ", ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, " Channels", 0FFh, 10, " ", 0 +ChannelMsg DB "Playing, ", 0FEh, 23h, 0FDh, "D", 0FEh, 20h, " Channels", 0 +EmptyMsg DB 0 +TimeMsg DB " Time ", 0FDh, "D:" +Minutes DB "00:" +Seconds DB "00", 0 +DisplayChannelMsg DB 0 +ShowUsageTime DB 1 + + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc TimerInterruptHandler + + Sub CS:InfoLineDelay, 1 + AdC CS:InfoLineDelay, 0 + + Inc CS:TimerCounter + Jmp [CS:OldTimerHandler] + +EndP TimerInterruptHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitTimerHandler Far + + Push DS + + Trace " - Installing new timer interrupt" + + Xor AX, AX + Mov DS, AX + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset TimerInterruptHandler + + ClI + XChg EAX, [DS:20h] + Mov [CS:OldTimerHandler], EAX + StI + + Pop DS + Ret + +EndP InitTimerHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UninitTimerHandler Far + + Push DS + + Xor AX, AX + Mov DS, AX + + Mov EAX, [CS:OldTimerHandler] + ClI + Mov [DS:20h], EAX + StI + + Pop DS + Ret + +EndP UninitTimerHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FillToEOL + + Push ES + Mov AX, ' ' + 2000h + Call S_GetDestination + +UpdateInfoLineEOL: + Cmp DI, (61+9*80)*2 + JAE UpdateInfoLineEOL2 + + StosW + Jmp UpdateInfoLineEOL + +UpdateInfoLineEOL2: + Pop ES + Ret + +EndP FillToEOL + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateInfoLine Far + + Push DS + Push SI + + Push Glbl + Pop DS + Assume DS:Glbl + + Cmp CurrentMode, 200 + JAE UpdateInfoLineEnd2 + + Push CS + Pop DS + + Mov DI, (2+9*80)*2 + + Cmp InfoLineDelay, 0 + JE UpdateInfoLine1 +; Mov CX, InfoLineDelay +; JCXZ UpdateInfoLine1 +; +; Dec InfoLineDelay + +UpdateInfoLine2: + LDS SI, InfoLineText + Mov CX, DS + JCXZ UpdateInfoLineEnd + + Mov AX, CS:InfoLineVariable + Push AX + + Mov AH, 20h + Call S_DrawString + Call FillToEOL + + Pop AX + + Call Music_GetPlayMode +; Call ShowTime + Jmp UpdateInfoLine6 + +UpdateInfoLine1: +; ****** + Call Music_GetSlaveChannelInformationTable + ; DS:SI points to tables + ; CX = numchannels. + Xor DI, DI ; DI = counter of + ; currently act. + ; channels. +CountChannels1: + Mov AX, [SI] + Test AH, 8 + JNZ CountChannels2 + + And AX, 1 + Add DI, AX + +CountChannels2: + Add SI, SLAVECHANNELSIZE + Loop CountChannels1 + + Push CS + Pop DS +; ****** + Call Music_GetPlayMode + ; AX = playmode + ; BX = row + ; CX = pattern + ; DX = order + ; SI = max row. + + Push AX + Push DI + Cmp AX, 1 + JB UpdateInfoLineChanMsg + Push SI + Push BX ; BX = row + Push CX ; CX = pattern + JE UpdateInfoLine3 + JA UpdateInfoLine4 + +UpdateInfoLineChanMsg: + Mov SI, Offset ChannelMsg + Cmp DI, 1 + JA UpdateInfoLineChanMsg2 + + Mov SI, Offset EmptyMsg + +UpdateInfoLineChanMsg2: + Mov DI, (2+9*80)*2 + Mov AH, 20h + Call S_DrawString + Call FillToEOL + Pop AX + + Pop AX + Mov DisplayChannelMsg, 1 + Jmp UpdateInfoLine7 + +UpdateInfoLineEnd: + Call ShowTime + +UpdateInfoLineEnd2: + Pop SI + Pop DS + + Mov AX, 1 + Ret + +UpdateInfoLine3: + Mov DI, (2+9*80)*2 + Mov SI, Offset PatternPlayMsg + Mov AH, 20h + Call S_DrawString + Call FillToEOL + + Add SP, 8 + Jmp UpdateInfoLine5 + +UpdateInfoLine4: + Call PE_GetMaxOrder + + Push AX + Push DX + + Mov DI, (2+9*80)*2 + Mov SI, Offset SongPlayMsg + Mov AH, 20h + Call S_DrawString + Call FillToEOL + + Add SP, 12 + +UpdateInfoLine5: + Pop AX + +UpdateInfoLine6: +; Cmp AX, 2 +; JNE UpdateInfoLine7 + + +UpdateInfoLine7: + Call ShowTime + Call UpdatePointers + + Pop SI + Pop DS + + Mov AX, 1 + Ret + +EndP UpdateInfoLine + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc IdleUpdateInfoLine Far + + Call Music_Poll + +IF TUTORIAL +ELSE + Mov AL, 1 + Call S_SetDirectMode +ENDIF + + Call UpdateInfoLine + +IF TUTORIAL + Call Glbl_TutorialHandler +ENDIF + +IF TUTORIAL + Call S_UpdateScreen +ELSE + Mov AL, 0 + Call S_SetDirectMode +ENDIF + +IF NETWORKENABLED + Jmp Network_Poll +ELSE + Xor AX, AX + Ret +ENDIF + +EndP IdleUpdateInfoLine + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ClearInfoLine Far + + Mov DWord Ptr [CS:InfoLineText], 0 + + Ret + +EndP ClearInfoLine + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetInfoLine Far ; DS:SI points to msg. + + Mov CS:InfoLineDelay, 20 + +SetInfoLineChain: + Mov Word Ptr [CS:InfoLineText], SI + Mov Word Ptr [CS:InfoLineText+2], DS + Mov Word Ptr [CS:InfoLineVariable], AX + + Ret + +EndP SetInfoLine + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetInfoLine2 Far ; DS:SI points to msg. + + Mov CS:InfoLineDelay, BX + Jmp SetInfoLineChain + +EndP SetInfoLine2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdatePointers ; BX = row, CX = pattern + + Mov SI, Glbl + Mov DS, SI + Assume DS:Glbl + + Mov AH, CurrentMode + +; And AH, AH +; JZ UpdatePointers6 + + Push AX + Push BX + Push CX + +; Call S_GetDestination ; Get ES. + Call PE_FillSpeedTempo + + Pop CX + Pop BX + Pop AX + +UpdatePointers6: +; Cmp AH, 2 +; JNE UpdatePointers1 +; +; Cmp AL, 1 +; JB UpdatePointersEnd +; +; Call PE_ShowPatternRow +; Ret +; +; UpdatePointers1: + Cmp AL, 2 ; Playmode. + JNE UpdatePointers3 + + Cmp AH, 11 + JE UpdatePointers2 + Cmp AH, 21 + JNE UpdatePointers3 + +UpdatePointers2: + Call PE_ShowOrder + + Ret + +UpdatePointers3: + Cmp AH, 3 + JNE UpdatePointers4 + + Call I_ShowSamplePlay + Ret + +UpdatePointers4: + Cmp AH, 4 + JNE UpdatePointers5 + + Call I_ShowInstrumentPlay + Ret + +UpdatePointers5: +UpdatePointersEnd: + Ret + +EndP UpdatePointers + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ShowTime + + PushA + Push DS + + Push CS + Pop DS + Assume DS:InfoLine + + Cmp AX, 2 + Mov EAX, [TimerCounter] + JE ShowTime3 + + Cmp ShowUsageTime, 0 + JE ShowTime2 + + Jmp ShowTime4 + +ShowTime3: + Sub EAX, [PlaybackTimer] + +ShowTime4: + Mov EDX, 3600 + Mul EDX + ShRD EAX, EDX, 16 + ShR EDX, 16 + JNZ ShowTime2 + ; EAX = number of seconds + Mov EBX, 60 + Div EBX ; EAX = minutes, EDX = seconds + + Push EDX + Xor EDX, EDX + Div EBX ; EAX = hours, EDX = minutes + + Pop ECX + Push AX ; Hours on stack, CX = seconds, DX = min + Mov BL, 10 + + Mov AX, DX + Div BL + Add AX, 3030h + Mov [Word Ptr Minutes], AX + + Mov AX, CX + Div BL + Add AX, 3030h + Mov [Word Ptr Seconds], AX + + Mov SI, Offset TimeMsg + Mov DI, (62+9*80)*2 + Mov AH, 20h + Call S_DrawString + Pop AX ; To clear stack + +ShowTime2: + Pop DS + PopA + + Ret + +EndP ShowTime + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc StartClock Far + + Push EAX + Mov EAX, CS:TimerCounter + Mov [CS:PlaybackTimer], EAX + Pop EAX + + Ret + +EndP StartClock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetTimerCounter Far + + Mov EAX, [CS:TimerCounter] + Ret + +EndP GetTimerCounter + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_M.ASM b/it_m.s similarity index 97% rename from IT_M.ASM rename to it_m.s index 7ba3bf9..2b11f6a 100644 --- a/IT_M.ASM +++ b/it_m.s @@ -1,664 +1,664 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Main Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386 - -include switch.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Object1 BYTE Public 'Data' USE16 -EndS - - - Extrn F_DrawStringInput:Far - Extrn F_PreStringInput:Far - Extrn F_PostStringInput:Far - Extrn F_Nothing:Far - Extrn F_DrawBoxObject:Far - Extrn F_DrawTextObject:Far - Extrn F_PostExitObject:Far - Extrn F_SetDirectMode:Far - Extrn F_CharacterDefinitions:Far - Extrn F_DrawButtonObject:Far - Extrn F_PreButtonObject:Far - Extrn F_PostButtonObject:Far - Extrn F_CallFarFunction:Far - Extrn F_DrawThumbBar:Far - Extrn F_DrawScalableThumbBar:Far - Extrn F_PreThumbBar:Far - Extrn F_PreScalableThumbBar:Far - Extrn F_PostThumbBar:Far - Extrn F_PostScalableThumbBar:Far - Extrn F_DrawInfoLine:Far - Extrn F_CallFarPreFunction:Far - Extrn F_CallFarPostFunction:Far - Extrn F_DrawToggle:Far - Extrn F_PreToggle:Far - Extrn F_PostToggle:Far - - Extrn F_Draw5Num:Far - Extrn F_Pre5Num:Far - Extrn F_Post5Num:Far - - Extrn F_Draw3Num:Far - Extrn F_Pre3Num:Far - Extrn F_Post3Num:Far - - Extrn Glbl_TutorialHandler:Far - - Extrn H_SetHelpContext:Far - - Extrn K_GetKey:Far - Extrn K_InitKeyBoard:Far - Extrn K_UnInitKeyBoard:Far - Extrn K_IsKeyWaiting:Far - Extrn K_IsAnyKeyDown:Far - - Extrn PE_DrawOrderList:Far - Extrn PE_PreOrderList:Far - Extrn PE_PostOrderList:Far - - Extrn S_Set80x25Mode:Far - Extrn S_SetPalette:Far - Extrn S_RedefineCharacters:Far - Extrn S_DrawBox:Far - Extrn S_ClearScreen:Far - Extrn S_UpdateScreen:Far - -; Extrn MouseDirectEnable:Far, MouseDirectDisable:Far - Extrn MouseSaveEvents:Far, MouseRestoreEvents:Far - Extrn MouseInput:Far, MouseClearEvents:Far - Extrn GetKeyboardLock:Far, MIDIBufferEmpty:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global M_FunctionDivider:Far - Global M_FunctionHandler:Far - Global M_Object1List:Far - Global M_Object1ListDefault:Far - Public ReleaseTimeSlice - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Main DWORD Public 'Code' USE16 - Assume CS:Main, DS:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -DrawObjectList Label DWord - DD DWord Ptr F_DrawBoxObject ; 0 - DD DWord Ptr F_DrawTextObject ; 1 - DD DWord Ptr F_DrawButtonObject ; 2 - DD DWord Ptr F_Nothing ; Empty obj number, 3 - DD DWord Ptr F_Nothing ; 4 - DD DWord Ptr F_SetDirectMode ; 5 - DD DWord Ptr F_CharacterDefinitions ; 6 - DD DWord Ptr F_Nothing ; Empty obj number 7 - DD DWord Ptr F_CallFarFunction ; 8 - DD DWord Ptr F_DrawThumbBar ; 9 - DD DWord Ptr F_DrawInfoLine ; 10 - DD DWord Ptr H_SetHelpContext ; 11 - DD DWord Ptr PE_DrawOrderList ; 12 - DD DWord Ptr F_Draw3Num ; 13 - DD DWord Ptr F_DrawScalableThumbBar ; 14 - DD DWord Ptr F_CallFarFunction ; 15 - DD DWord Ptr F_DrawStringInput ; 16 - DD DWord Ptr F_DrawToggle ; 17 - DD DWord Ptr F_Draw5Num ; 18 - - -PreFunctionList Label DWord - DD DWord Ptr F_Nothing ; 0 - DD DWord Ptr F_Nothing ; 1 - DD DWord Ptr F_PreButtonObject ; 2 - DD DWord Ptr F_Nothing ; 3 - DD DWord Ptr F_Nothing ; 4 - DD DWord Ptr F_Nothing ; 5 - DD DWord Ptr F_Nothing ; 6 - DD DWord Ptr F_Nothing ; 7 - DD DWord Ptr F_Nothing ; 8 - DD DWord Ptr F_PreThumbBar ; 9 - DD DWord Ptr F_Nothing ; 10 - DD DWord Ptr F_Nothing ; 11 - DD DWord Ptr PE_PreOrderList ; 12 - DD DWord Ptr F_Pre3Num ; 13 - DD DWord Ptr F_PreScalableThumbBar ; 14 - DD DWord Ptr F_CallFarPreFunction ; 15 - DD DWord Ptr F_PreStringInput ; 16 - DD DWord Ptr F_PreToggle ; 17 - DD DWord Ptr F_Pre5Num ; 18 - -PostFunctionList Label DWord - DD DWord Ptr F_Nothing ; 0 - DD DWord Ptr F_Nothing ; 1 - DD DWord Ptr F_PostButtonObject ; 2 - DD DWord Ptr F_Nothing ; 3 - DD DWord Ptr F_PostExitObject ; 4 - DD DWord Ptr F_Nothing ; 5 - DD DWord Ptr F_Nothing ; 6 - DD DWord Ptr F_Nothing ; 7 - DD DWord Ptr F_Nothing ; 8 - DD DWord Ptr F_PostThumbBar ; 9 - DD DWord Ptr F_Nothing ; 10 - DD DWord Ptr F_Nothing ; 11 - DD DWord Ptr PE_PostOrderList ; 12 - DD DWord Ptr F_Post3Num ; 13 - DD DWord Ptr F_PostScalableThumbBar ; 14 - DD DWord Ptr F_CallFarPostFunction ; 15 - DD DWord Ptr F_PostStringInput ; 16 - DD DWord Ptr F_PostToggle ; 17 - DD DWord Ptr F_Post5Num ; 18 - -GlobalKeyList DD ? -ReleaseTimeSlice DB 0 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc M_FunctionDivider Far ; Given DS:SI points to list - ; Carry set if none found - Push BX - -M_FunctionDivider1: ; 0 = Direct comparison - ; 1 = Key comparison - ; 2 = Alt, 3 = Ctrl, 4 = Shift - ; 5 = capital key comparison - ; 6 = MIDI message - LodsB - Test AL, AL - JS M_FunctionDivider4 ; End of list - - Mov BX, CX - JZ M_FunctionDivider2 ; If AL = 0 - - Cmp AL, 2 - JE M_FunctionDivider8 - JB M_FunctionDivider5 - - Cmp AL, 4 - JB M_FunctionDivider18 - JE M_FunctionDivider10 ; If AL = 4 - - Cmp AL, 6 - JB M_FunctionDividerCAPS - -M_FunctionDividerMIDI: - Test CL, CL - JNZ M_FunctionDivider9 - Mov BX, CX - And BX, 0F000h - Jmp M_FunctionDividerCheck - -M_FunctionDividerCAPS: - Mov BX, DX - Cmp BX, 'a' - JB M_FunctionDivider6 - Cmp BX, 'z' - JA M_FunctionDivider9 - - Sub BL, 32 - -M_FunctionDivider6: - Cmp BX, 'A' - JB M_FunctionDivider9 - Cmp BX, 'Z' - JA M_FunctionDivider9 - Jmp M_FunctionDivider2 - -M_FunctionDivider5: - Mov BX, DX ; If al = 1... - Jmp M_FunctionDivider2 - -M_FunctionDivider8: - Test CH, 60h - JZ M_FunctionDivider9 - - And BX, 1FFh - Jmp M_FunctionDivider2 - -M_FunctionDivider18: - Test CH, 18h ; Ctrl - JZ M_FunctionDivider9 - And BX, 1FFh - - Jmp M_FunctionDivider2 - -M_FunctionDivider10: - Test CH, 6 - JZ M_FunctionDivider9 - And BX, 1FFh - -M_FunctionDivider2: - Test CL, CL - JZ M_FunctionDivider9 - -M_FunctionDividerCheck: - LodsW - Cmp AX, BX - JE M_FunctionDivider3 - - LodsW - Jmp M_FunctionDivider1 - -M_FunctionDivider9: - LodsW - LodsW - Jmp M_FunctionDivider1 - -M_FunctionDivider3: - DB 85h ; ClC -M_FunctionDivider4: ; - StC ; - - Pop BX - - Ret - -EndP M_FunctionDivider - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M_FunctionHandler Far - ARG ObjectList:DWord - - Push BP - Mov BP, SP - - Call MouseSaveEvents - -M_FunctionHandler1: ; Draw all objects in list - Call GetKeyboardLock - Cmp AL, 2 - JE MouseInput1 - - Call MouseClearEvents - - LDS SI, ObjectList ; DS:SI points to object list - Add SI, 6 ; Skip pass list header - Xor AX, AX - -M_FunctionHandler2: - Cmp Word Ptr [SI], 0 ; DS:SI points to an offset of - JE M_FunctionHandler4 ; an object - -M_FunctionHandler3: - Push AX ; AX = object number - Push DS - Push SI - Push BP - - LES DI, ObjectList ; ES:DI points to object list - Mov SI, [SI] ; DS:SI points to object - Mov BX, [SI] ; BX = object type - Mov CL, 2 - ShL BX, CL - - Call DWord Ptr [DrawObjectList+BX] - - Pop BP - Pop SI ; DS:SI Points to an offset of - Pop DS ; an object - Pop AX - Inc AX - Add SI, 2 ; Advance Pointer - Jmp M_FunctionHandler2 ; Next Object - -M_FunctionHandler4: ; Call Prefunction for object - LDS SI, ObjectList ; DS:SI points to object list - Mov AX, [SI] ; AX = Active object number - LEA SI, [ESI+EAX*2+6] ; Skip pas list header (+6) - ; AX = object number - - Cmp Word Ptr [SI], 0 ; if list doesn't point to - JE M_FunctionHandler21 ; anything, don't call prefunc - -M_FunctionHandler20: - Mov SI, [SI] ; DS:SI points to object - Mov BX, [SI] ; BX = object type - ShL BX, 2 - - Push BP - Call DWord Ptr [PreFunctionList+BX] - Pop BP - -M_FunctionHandler21: - -IF TUTORIAL - Call Glbl_TutorialHandler -ENDIF - - Call S_UpdateScreen - -M_FunctionHandler5: ; Input... -; Call K_IsAnyKeyDown -; And AL, AL -; JNZ M_KeyBoardInput1 - -MouseInput1: - Call MouseInput ; returns 0 if nothing - ; 1 if input (BX, CX, DX set) - ; 2 if no input, but keyboard - ; locked - Cmp AX, 1 - JB M_KeyBoardInput1 - JA M_FunctionHandler6 ; IdleList - ; Handle postobject, of - ; object BX - - Mov AX, DI - Cmp BX, 0FFFFh - JE M_FunctionHandler23 - - LES DI, ObjectList ; ES:DI points to object list - Push ES - Pop DS - - Mov [DI], BX ; Object number in BX. - LEA BX, [EBX*2+EDI+6] ; ES:BX points to offset of - ; active object. - - Mov SI, [BX] ; DS:SI points to object - - Mov SI, [SI] ; SI = object type of active obj - ShL SI, 2 - - Push BP - Call DWord Ptr [PostFunctionList+SI] - Pop BP - Jmp M_FunctionHandler23 - -M_KeyBoardInput1: - Call MIDIBufferEmpty - JAE M_FunctionHandler8 - - Call K_IsKeyWaiting - - Test AX, AX - JNZ M_FunctionHandler8 - ; Check for mouse info... - -M_FunctionHandler6: ; IdleList - Cmp CS:ReleaseTimeSlice, 0 - JE NoReleaseTimeSlice - - Mov AX, 1680h - Int 2Fh - -NoReleaseTimeSlice: -; StI - - LDS SI, ObjectList ; DS:SI points to object list - Add SI, 2 ; DS:SI points to idle list - - Cmp Word Ptr [SI], 0 - JE M_FunctionHandler5 ; If Offset of IdleList = 0, - ; check for another key - -M_FunctionHandler7: - Mov SI, [SI] - Xor BX, BX ; Clear flag. - -M_FunctionHandler19: - Cmp Word Ptr [SI], 0 - JNE M_FunctionHandler18 - - Cmp Word Ptr [SI+2], 0 - JE M_FunctionHandler29 - -M_FunctionHandler18: - Push SI - Push BX - Push DS - Push BP - - Call DWord Ptr [SI] - - Pop BP - Pop DS - Pop BX - - Cmp AX, 5 - JE M_FunctionHandlerIdleCommand - - Pop SI - - Add SI, 4 - - Or BX, AX - Jmp M_FunctionHandler19 - -M_FunctionHandlerIdleCommand: - Pop AX ; Pull off SI from the stack - Mov AX, DI - Jmp M_FunctionHandler10 -; Mov SI, 1 -; Jmp M_FunctionHandler16 - -M_FunctionHandler29: - Test BX, BX - JZ M_FunctionHandler5 - - Jmp M_FunctionHandler1 - -M_FunctionHandler8: - Call K_GetKey ; CX = Keyboard Input Data - ; DX = Translated Input Data - ; else MIDI input if CL = 0 - -M_FunctionHandler9: - LES DI, ObjectList ; ES:DI points to object list - Push ES - Pop DS - - Mov BX, [DI] ; BX = active object number - LEA BX, [EDI+EBX*2+6] ; ES:BX points to offset of - ; active object. - Xor AX, AX - - Cmp Word Ptr [BX], 0 - JE M_FunctionHandler23 - -M_FunctionHandler22: - Mov SI, [BX] ; DS:SI points to object - - Mov SI, [SI] ; SI = object type of active obj - ShL SI, 2 - - Push BP - Call DWord Ptr [PostFunctionList+SI] - Pop BP - -M_FunctionHandler23: - Push DS - Push SI - - LDS SI, ObjectList - Add SI, 4 - Mov SI, [SI] - Mov Word Ptr CS:GlobalKeyList+2, DS - Mov Word Ptr CS:GlobalKeyList, SI - - Pop SI - Pop DS - -; Xor BX, BX ; Extra key list starts at 0 - -M_FunctionHandler10: - Cmp AX, 1 - JB M_FunctionHandler11 ; If AX = 0 - JE M_FunctionHandler1 ; Redraw screen if AX = 1 - - Cmp AX, 3 - JB M_FunctionHandler4 ; Goto preobject if AX = 2 - JE M_FunctionHandler5 ; Get next input - - Cmp AX, 5 ; New list - JE M_FunctionHandler16 - JA M_FunctionHandler11 ; If > 5 - - Call MouseRestoreEvents - - Pop BP - Ret 4 - -M_FunctionHandler16: - Mov Word Ptr Offset ObjectList, DX - Mov Word Ptr Offset ObjectList+2, CX - Mov AX, SI - - Jmp M_FunctionHandler10 - -M_FunctionHandler11: - LDS SI, CS:GlobalKeyList - - Cmp Word Ptr [SI], 0 - JE M_FunctionHandler4 - -M_FunctionHandler12: - LodsB - Mov BX, DX - Cmp AL, 1 - JE M_FunctionHandler13 ; Keycode compare (1) - Mov BX, CX - JB M_FunctionHandler13 ; Scancode compare (0) - - And BX, 1FFh - - Cmp AL, 3 - JB M_FunctionHandlerAlt ; Alt-keycode compare (2) - JE M_FunctionHandlerCtrl ; Ctrl-keycode compare (3) - - Cmp AL, 5 - JB M_FunctionHandlerForced ; Always call function (4) - JE M_FunctionHandlerNewListNear ; Chain to new list (5) - - Cmp AL, 7 - JB M_FunctionHandlerShift ; Shift-keycode compare (6) - JE M_FunctionHandlerNewListFar ; Chain to far list (7) - - Cmp AL, 9 - JB M_FunctionHandlerCapCheck ; Capitalised keycode (8) - JE M_FunctionHandlerMIDI ; MIDI message (9) - -; Jmp M_FunctionHandler1 - Jmp M_FunctionHandler4 ; Undefined compare.. -; ; -> end of list - -M_FunctionHandlerAlt: - Test CH, 60h - JZ M_FunctionHandler14 - Jmp M_FunctionHandler13 - -M_FunctionHandlerCtrl: - Test CH, 18h - JZ M_FunctionHandler14 - Jmp M_FunctionHandler13 - -M_FunctionHandlerShift: - Test CH, 6h - JZ M_FunctionHandler14 - Jmp M_FunctionHandler13 - -M_FunctionHandlerNewListNear: - LodsW - Mov Word Ptr CS:GlobalKeyList, AX - Jmp M_FunctionHandler11 - -M_FunctionHandlerNewListFar: - LodsD - Mov CS:GlobalKeyList, EAX - Jmp M_FunctionHandler11 - -M_FunctionHandlerForced: - LodsW - Jmp M_FunctionHandler26 - -M_FunctionHandlerCapCheck: ; Capital OK? (8) - Mov BX, DX - Cmp BX, 'A' - JB M_FunctionHandler14 - Cmp BX, 'z' - JA M_FunctionHandler14 - Cmp BX, 'a' - JB M_FunctionHandlerCapCheck1 - - Sub BL, 32 - -M_FunctionHandlerCapCheck1: - Jmp M_FunctionHandler13 - -M_FunctionHandlerMIDI: - Test CL, CL - JNZ M_FunctionHandler14 - Mov BX, CX - And BX, 0F000h - Jmp M_FunctionHandlerCheck - -M_FunctionHandler13: - Test CL, CL - JZ M_FunctionHandler14 - -M_FunctionHandlerCheck: - LodsW - Cmp BX, AX - JNE M_FunctionHandler14 - -M_FunctionHandler26: - LES DI, ObjectList ; ES:DI points to object list - Push BP - Call DWord Ptr [SI] - Pop BP - Jmp M_FunctionHandler15 - -M_FunctionHandler14: - Xor AX, AX - -M_FunctionHandler15: - Add Word Ptr CS:GlobalKeyList, 7 - Jmp M_FunctionHandler10 - -EndP M_FunctionHandler - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc M_Object1ListDefault Far ; Reqs: DI = offset of list - - Mov CX, 0FFFFh - -Proc M_Object1List Far ; Reqs.. CX = inital object. - ; Reqs.. DI = offset of list - - Mov AX, Object1 - Push AX - Mov ES, AX - Push DI - Cmp CX, 0FFFFh - JE M_Object1List1 - - Mov Word Ptr [ES:DI], CX - -M_Object1List1: - Call M_FunctionHandler - - Ret - -EndP M_Object1List -EndP M_Object1ListDefault - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Main Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386 + +include switch.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Object1 BYTE Public 'Data' USE16 +EndS + + + Extrn F_DrawStringInput:Far + Extrn F_PreStringInput:Far + Extrn F_PostStringInput:Far + Extrn F_Nothing:Far + Extrn F_DrawBoxObject:Far + Extrn F_DrawTextObject:Far + Extrn F_PostExitObject:Far + Extrn F_SetDirectMode:Far + Extrn F_CharacterDefinitions:Far + Extrn F_DrawButtonObject:Far + Extrn F_PreButtonObject:Far + Extrn F_PostButtonObject:Far + Extrn F_CallFarFunction:Far + Extrn F_DrawThumbBar:Far + Extrn F_DrawScalableThumbBar:Far + Extrn F_PreThumbBar:Far + Extrn F_PreScalableThumbBar:Far + Extrn F_PostThumbBar:Far + Extrn F_PostScalableThumbBar:Far + Extrn F_DrawInfoLine:Far + Extrn F_CallFarPreFunction:Far + Extrn F_CallFarPostFunction:Far + Extrn F_DrawToggle:Far + Extrn F_PreToggle:Far + Extrn F_PostToggle:Far + + Extrn F_Draw5Num:Far + Extrn F_Pre5Num:Far + Extrn F_Post5Num:Far + + Extrn F_Draw3Num:Far + Extrn F_Pre3Num:Far + Extrn F_Post3Num:Far + + Extrn Glbl_TutorialHandler:Far + + Extrn H_SetHelpContext:Far + + Extrn K_GetKey:Far + Extrn K_InitKeyBoard:Far + Extrn K_UnInitKeyBoard:Far + Extrn K_IsKeyWaiting:Far + Extrn K_IsAnyKeyDown:Far + + Extrn PE_DrawOrderList:Far + Extrn PE_PreOrderList:Far + Extrn PE_PostOrderList:Far + + Extrn S_Set80x25Mode:Far + Extrn S_SetPalette:Far + Extrn S_RedefineCharacters:Far + Extrn S_DrawBox:Far + Extrn S_ClearScreen:Far + Extrn S_UpdateScreen:Far + +; Extrn MouseDirectEnable:Far, MouseDirectDisable:Far + Extrn MouseSaveEvents:Far, MouseRestoreEvents:Far + Extrn MouseInput:Far, MouseClearEvents:Far + Extrn GetKeyboardLock:Far, MIDIBufferEmpty:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global M_FunctionDivider:Far + Global M_FunctionHandler:Far + Global M_Object1List:Far + Global M_Object1ListDefault:Far + Public ReleaseTimeSlice + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Main DWORD Public 'Code' USE16 + Assume CS:Main, DS:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +DrawObjectList Label DWord + DD DWord Ptr F_DrawBoxObject ; 0 + DD DWord Ptr F_DrawTextObject ; 1 + DD DWord Ptr F_DrawButtonObject ; 2 + DD DWord Ptr F_Nothing ; Empty obj number, 3 + DD DWord Ptr F_Nothing ; 4 + DD DWord Ptr F_SetDirectMode ; 5 + DD DWord Ptr F_CharacterDefinitions ; 6 + DD DWord Ptr F_Nothing ; Empty obj number 7 + DD DWord Ptr F_CallFarFunction ; 8 + DD DWord Ptr F_DrawThumbBar ; 9 + DD DWord Ptr F_DrawInfoLine ; 10 + DD DWord Ptr H_SetHelpContext ; 11 + DD DWord Ptr PE_DrawOrderList ; 12 + DD DWord Ptr F_Draw3Num ; 13 + DD DWord Ptr F_DrawScalableThumbBar ; 14 + DD DWord Ptr F_CallFarFunction ; 15 + DD DWord Ptr F_DrawStringInput ; 16 + DD DWord Ptr F_DrawToggle ; 17 + DD DWord Ptr F_Draw5Num ; 18 + + +PreFunctionList Label DWord + DD DWord Ptr F_Nothing ; 0 + DD DWord Ptr F_Nothing ; 1 + DD DWord Ptr F_PreButtonObject ; 2 + DD DWord Ptr F_Nothing ; 3 + DD DWord Ptr F_Nothing ; 4 + DD DWord Ptr F_Nothing ; 5 + DD DWord Ptr F_Nothing ; 6 + DD DWord Ptr F_Nothing ; 7 + DD DWord Ptr F_Nothing ; 8 + DD DWord Ptr F_PreThumbBar ; 9 + DD DWord Ptr F_Nothing ; 10 + DD DWord Ptr F_Nothing ; 11 + DD DWord Ptr PE_PreOrderList ; 12 + DD DWord Ptr F_Pre3Num ; 13 + DD DWord Ptr F_PreScalableThumbBar ; 14 + DD DWord Ptr F_CallFarPreFunction ; 15 + DD DWord Ptr F_PreStringInput ; 16 + DD DWord Ptr F_PreToggle ; 17 + DD DWord Ptr F_Pre5Num ; 18 + +PostFunctionList Label DWord + DD DWord Ptr F_Nothing ; 0 + DD DWord Ptr F_Nothing ; 1 + DD DWord Ptr F_PostButtonObject ; 2 + DD DWord Ptr F_Nothing ; 3 + DD DWord Ptr F_PostExitObject ; 4 + DD DWord Ptr F_Nothing ; 5 + DD DWord Ptr F_Nothing ; 6 + DD DWord Ptr F_Nothing ; 7 + DD DWord Ptr F_Nothing ; 8 + DD DWord Ptr F_PostThumbBar ; 9 + DD DWord Ptr F_Nothing ; 10 + DD DWord Ptr F_Nothing ; 11 + DD DWord Ptr PE_PostOrderList ; 12 + DD DWord Ptr F_Post3Num ; 13 + DD DWord Ptr F_PostScalableThumbBar ; 14 + DD DWord Ptr F_CallFarPostFunction ; 15 + DD DWord Ptr F_PostStringInput ; 16 + DD DWord Ptr F_PostToggle ; 17 + DD DWord Ptr F_Post5Num ; 18 + +GlobalKeyList DD ? +ReleaseTimeSlice DB 0 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc M_FunctionDivider Far ; Given DS:SI points to list + ; Carry set if none found + Push BX + +M_FunctionDivider1: ; 0 = Direct comparison + ; 1 = Key comparison + ; 2 = Alt, 3 = Ctrl, 4 = Shift + ; 5 = capital key comparison + ; 6 = MIDI message + LodsB + Test AL, AL + JS M_FunctionDivider4 ; End of list + + Mov BX, CX + JZ M_FunctionDivider2 ; If AL = 0 + + Cmp AL, 2 + JE M_FunctionDivider8 + JB M_FunctionDivider5 + + Cmp AL, 4 + JB M_FunctionDivider18 + JE M_FunctionDivider10 ; If AL = 4 + + Cmp AL, 6 + JB M_FunctionDividerCAPS + +M_FunctionDividerMIDI: + Test CL, CL + JNZ M_FunctionDivider9 + Mov BX, CX + And BX, 0F000h + Jmp M_FunctionDividerCheck + +M_FunctionDividerCAPS: + Mov BX, DX + Cmp BX, 'a' + JB M_FunctionDivider6 + Cmp BX, 'z' + JA M_FunctionDivider9 + + Sub BL, 32 + +M_FunctionDivider6: + Cmp BX, 'A' + JB M_FunctionDivider9 + Cmp BX, 'Z' + JA M_FunctionDivider9 + Jmp M_FunctionDivider2 + +M_FunctionDivider5: + Mov BX, DX ; If al = 1... + Jmp M_FunctionDivider2 + +M_FunctionDivider8: + Test CH, 60h + JZ M_FunctionDivider9 + + And BX, 1FFh + Jmp M_FunctionDivider2 + +M_FunctionDivider18: + Test CH, 18h ; Ctrl + JZ M_FunctionDivider9 + And BX, 1FFh + + Jmp M_FunctionDivider2 + +M_FunctionDivider10: + Test CH, 6 + JZ M_FunctionDivider9 + And BX, 1FFh + +M_FunctionDivider2: + Test CL, CL + JZ M_FunctionDivider9 + +M_FunctionDividerCheck: + LodsW + Cmp AX, BX + JE M_FunctionDivider3 + + LodsW + Jmp M_FunctionDivider1 + +M_FunctionDivider9: + LodsW + LodsW + Jmp M_FunctionDivider1 + +M_FunctionDivider3: + DB 85h ; ClC +M_FunctionDivider4: ; + StC ; + + Pop BX + + Ret + +EndP M_FunctionDivider + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M_FunctionHandler Far + ARG ObjectList:DWord + + Push BP + Mov BP, SP + + Call MouseSaveEvents + +M_FunctionHandler1: ; Draw all objects in list + Call GetKeyboardLock + Cmp AL, 2 + JE MouseInput1 + + Call MouseClearEvents + + LDS SI, ObjectList ; DS:SI points to object list + Add SI, 6 ; Skip pass list header + Xor AX, AX + +M_FunctionHandler2: + Cmp Word Ptr [SI], 0 ; DS:SI points to an offset of + JE M_FunctionHandler4 ; an object + +M_FunctionHandler3: + Push AX ; AX = object number + Push DS + Push SI + Push BP + + LES DI, ObjectList ; ES:DI points to object list + Mov SI, [SI] ; DS:SI points to object + Mov BX, [SI] ; BX = object type + Mov CL, 2 + ShL BX, CL + + Call DWord Ptr [DrawObjectList+BX] + + Pop BP + Pop SI ; DS:SI Points to an offset of + Pop DS ; an object + Pop AX + Inc AX + Add SI, 2 ; Advance Pointer + Jmp M_FunctionHandler2 ; Next Object + +M_FunctionHandler4: ; Call Prefunction for object + LDS SI, ObjectList ; DS:SI points to object list + Mov AX, [SI] ; AX = Active object number + LEA SI, [ESI+EAX*2+6] ; Skip pas list header (+6) + ; AX = object number + + Cmp Word Ptr [SI], 0 ; if list doesn't point to + JE M_FunctionHandler21 ; anything, don't call prefunc + +M_FunctionHandler20: + Mov SI, [SI] ; DS:SI points to object + Mov BX, [SI] ; BX = object type + ShL BX, 2 + + Push BP + Call DWord Ptr [PreFunctionList+BX] + Pop BP + +M_FunctionHandler21: + +IF TUTORIAL + Call Glbl_TutorialHandler +ENDIF + + Call S_UpdateScreen + +M_FunctionHandler5: ; Input... +; Call K_IsAnyKeyDown +; And AL, AL +; JNZ M_KeyBoardInput1 + +MouseInput1: + Call MouseInput ; returns 0 if nothing + ; 1 if input (BX, CX, DX set) + ; 2 if no input, but keyboard + ; locked + Cmp AX, 1 + JB M_KeyBoardInput1 + JA M_FunctionHandler6 ; IdleList + ; Handle postobject, of + ; object BX + + Mov AX, DI + Cmp BX, 0FFFFh + JE M_FunctionHandler23 + + LES DI, ObjectList ; ES:DI points to object list + Push ES + Pop DS + + Mov [DI], BX ; Object number in BX. + LEA BX, [EBX*2+EDI+6] ; ES:BX points to offset of + ; active object. + + Mov SI, [BX] ; DS:SI points to object + + Mov SI, [SI] ; SI = object type of active obj + ShL SI, 2 + + Push BP + Call DWord Ptr [PostFunctionList+SI] + Pop BP + Jmp M_FunctionHandler23 + +M_KeyBoardInput1: + Call MIDIBufferEmpty + JAE M_FunctionHandler8 + + Call K_IsKeyWaiting + + Test AX, AX + JNZ M_FunctionHandler8 + ; Check for mouse info... + +M_FunctionHandler6: ; IdleList + Cmp CS:ReleaseTimeSlice, 0 + JE NoReleaseTimeSlice + + Mov AX, 1680h + Int 2Fh + +NoReleaseTimeSlice: +; StI + + LDS SI, ObjectList ; DS:SI points to object list + Add SI, 2 ; DS:SI points to idle list + + Cmp Word Ptr [SI], 0 + JE M_FunctionHandler5 ; If Offset of IdleList = 0, + ; check for another key + +M_FunctionHandler7: + Mov SI, [SI] + Xor BX, BX ; Clear flag. + +M_FunctionHandler19: + Cmp Word Ptr [SI], 0 + JNE M_FunctionHandler18 + + Cmp Word Ptr [SI+2], 0 + JE M_FunctionHandler29 + +M_FunctionHandler18: + Push SI + Push BX + Push DS + Push BP + + Call DWord Ptr [SI] + + Pop BP + Pop DS + Pop BX + + Cmp AX, 5 + JE M_FunctionHandlerIdleCommand + + Pop SI + + Add SI, 4 + + Or BX, AX + Jmp M_FunctionHandler19 + +M_FunctionHandlerIdleCommand: + Pop AX ; Pull off SI from the stack + Mov AX, DI + Jmp M_FunctionHandler10 +; Mov SI, 1 +; Jmp M_FunctionHandler16 + +M_FunctionHandler29: + Test BX, BX + JZ M_FunctionHandler5 + + Jmp M_FunctionHandler1 + +M_FunctionHandler8: + Call K_GetKey ; CX = Keyboard Input Data + ; DX = Translated Input Data + ; else MIDI input if CL = 0 + +M_FunctionHandler9: + LES DI, ObjectList ; ES:DI points to object list + Push ES + Pop DS + + Mov BX, [DI] ; BX = active object number + LEA BX, [EDI+EBX*2+6] ; ES:BX points to offset of + ; active object. + Xor AX, AX + + Cmp Word Ptr [BX], 0 + JE M_FunctionHandler23 + +M_FunctionHandler22: + Mov SI, [BX] ; DS:SI points to object + + Mov SI, [SI] ; SI = object type of active obj + ShL SI, 2 + + Push BP + Call DWord Ptr [PostFunctionList+SI] + Pop BP + +M_FunctionHandler23: + Push DS + Push SI + + LDS SI, ObjectList + Add SI, 4 + Mov SI, [SI] + Mov Word Ptr CS:GlobalKeyList+2, DS + Mov Word Ptr CS:GlobalKeyList, SI + + Pop SI + Pop DS + +; Xor BX, BX ; Extra key list starts at 0 + +M_FunctionHandler10: + Cmp AX, 1 + JB M_FunctionHandler11 ; If AX = 0 + JE M_FunctionHandler1 ; Redraw screen if AX = 1 + + Cmp AX, 3 + JB M_FunctionHandler4 ; Goto preobject if AX = 2 + JE M_FunctionHandler5 ; Get next input + + Cmp AX, 5 ; New list + JE M_FunctionHandler16 + JA M_FunctionHandler11 ; If > 5 + + Call MouseRestoreEvents + + Pop BP + Ret 4 + +M_FunctionHandler16: + Mov Word Ptr Offset ObjectList, DX + Mov Word Ptr Offset ObjectList+2, CX + Mov AX, SI + + Jmp M_FunctionHandler10 + +M_FunctionHandler11: + LDS SI, CS:GlobalKeyList + + Cmp Word Ptr [SI], 0 + JE M_FunctionHandler4 + +M_FunctionHandler12: + LodsB + Mov BX, DX + Cmp AL, 1 + JE M_FunctionHandler13 ; Keycode compare (1) + Mov BX, CX + JB M_FunctionHandler13 ; Scancode compare (0) + + And BX, 1FFh + + Cmp AL, 3 + JB M_FunctionHandlerAlt ; Alt-keycode compare (2) + JE M_FunctionHandlerCtrl ; Ctrl-keycode compare (3) + + Cmp AL, 5 + JB M_FunctionHandlerForced ; Always call function (4) + JE M_FunctionHandlerNewListNear ; Chain to new list (5) + + Cmp AL, 7 + JB M_FunctionHandlerShift ; Shift-keycode compare (6) + JE M_FunctionHandlerNewListFar ; Chain to far list (7) + + Cmp AL, 9 + JB M_FunctionHandlerCapCheck ; Capitalised keycode (8) + JE M_FunctionHandlerMIDI ; MIDI message (9) + +; Jmp M_FunctionHandler1 + Jmp M_FunctionHandler4 ; Undefined compare.. +; ; -> end of list + +M_FunctionHandlerAlt: + Test CH, 60h + JZ M_FunctionHandler14 + Jmp M_FunctionHandler13 + +M_FunctionHandlerCtrl: + Test CH, 18h + JZ M_FunctionHandler14 + Jmp M_FunctionHandler13 + +M_FunctionHandlerShift: + Test CH, 6h + JZ M_FunctionHandler14 + Jmp M_FunctionHandler13 + +M_FunctionHandlerNewListNear: + LodsW + Mov Word Ptr CS:GlobalKeyList, AX + Jmp M_FunctionHandler11 + +M_FunctionHandlerNewListFar: + LodsD + Mov CS:GlobalKeyList, EAX + Jmp M_FunctionHandler11 + +M_FunctionHandlerForced: + LodsW + Jmp M_FunctionHandler26 + +M_FunctionHandlerCapCheck: ; Capital OK? (8) + Mov BX, DX + Cmp BX, 'A' + JB M_FunctionHandler14 + Cmp BX, 'z' + JA M_FunctionHandler14 + Cmp BX, 'a' + JB M_FunctionHandlerCapCheck1 + + Sub BL, 32 + +M_FunctionHandlerCapCheck1: + Jmp M_FunctionHandler13 + +M_FunctionHandlerMIDI: + Test CL, CL + JNZ M_FunctionHandler14 + Mov BX, CX + And BX, 0F000h + Jmp M_FunctionHandlerCheck + +M_FunctionHandler13: + Test CL, CL + JZ M_FunctionHandler14 + +M_FunctionHandlerCheck: + LodsW + Cmp BX, AX + JNE M_FunctionHandler14 + +M_FunctionHandler26: + LES DI, ObjectList ; ES:DI points to object list + Push BP + Call DWord Ptr [SI] + Pop BP + Jmp M_FunctionHandler15 + +M_FunctionHandler14: + Xor AX, AX + +M_FunctionHandler15: + Add Word Ptr CS:GlobalKeyList, 7 + Jmp M_FunctionHandler10 + +EndP M_FunctionHandler + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc M_Object1ListDefault Far ; Reqs: DI = offset of list + + Mov CX, 0FFFFh + +Proc M_Object1List Far ; Reqs.. CX = inital object. + ; Reqs.. DI = offset of list + + Mov AX, Object1 + Push AX + Mov ES, AX + Push DI + Cmp CX, 0FFFFh + JE M_Object1List1 + + Mov Word Ptr [ES:DI], CX + +M_Object1List1: + Call M_FunctionHandler + + Ret + +EndP M_Object1List +EndP M_Object1ListDefault + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_M_EFF.INC b/it_m_eff.inc similarity index 96% rename from IT_M_EFF.INC rename to it_m_eff.inc index 0bbc2be..d96628f 100644 --- a/IT_M_EFF.INC +++ b/it_m_eff.inc @@ -1,2945 +1,2945 @@ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -SlideTable DB 1, 4, 8, 16, 32, 64, 96, 128, 255 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Comment ~ - -Proc GetC5Speed - - Push BX - Push SI - Push BP - - Cmp Byte Ptr [DI+0Fh], 101 ; MIDI sample - JNE GetC5Speed1 - -; OK.. we have a MIDI sample -; Check whether the midi sample points to a valid sample -; And if so, use that sample's C5 speed. - Mov SI, [DS:DI+3] ; Not a note? - And SI, 0FFh - - Mov BP, [DS:DI+4] - And EBP, 0FFh - JZ GetC5Speed1 ; No sample? - - Add SI, SI - Mov BP, [ES:64710+EBP+EBP] - - Mov AX, [ES:BP+SI+40h] ; AL = note - ; AH = sample. - - Test AH, AH ; No sample? - JZ GetC5Speed1 - Mov SI, AX - ShR SI, 8 - - Add SI, SI - Mov SI, [ES:64910+SI] ; Sample offset - Test Byte Ptr [ES:SI+12h], 1 - JZ GetC5Speed1 - - Mov BX, SI - -GetC5Speed1: - Mov EAX, [ES:BX+3Ch] ; EAX = C5Spd - - Pop BP - Pop SI - Pop BX - - Ret - -EndP GetC5Speed - -~ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitVolumeEffect ; Done A, B, H - - Test Byte Ptr [DI+2], 44h - JNZ InitVolumeProcess - -InitVolumeEffectNoEffect: - Ret - -InitVolumeProcess: - Mov AL, [DI+5] - Mov AH, AL - - And AL, 7Fh - Sub AL, 65 - JC InitVolumeEffectNoEffect - - Test AH, 80h - JZ InitVolumeEffect1 - - Add AL, 60 - -InitVolumeEffect1: - Mov DL, 10 - Xor AH, AH - Div DL ; AL = effect number - ; AH = effect parameter - Mov [DI+0Ah], AL ; Store effect number - - ; Memory for effects A->D, (EFG)/H dont' share. - - ; Effects Ax and Bx (fine volume slide up and down) require immediate - ; handling. No flags required. (effect 0 and 1) - - ; Effects Cx, Dx, Ex, Fx (volume/pitch slides) require flag to be - ; set (effects 2->5) - - ; Effects Gx and Hx need init (handling) code + flags. - ; (effects 6 and 7). - - Test AH, AH - JZ InitVolumeEffectNoMemory - - Cmp AL, 4 - JB InitNormalMemory - - Cmp AL, 6 - JB InitSlideMemory - JA InitVolumeEffectNoMemory - - MovZX BX, AH - Mov DL, [SlideTable+BX-1] - - Test Byte Ptr [ES:2Ch], 20h ; Link command G? - JZ CommandGMemoryOldEffects - - Mov [DI+1Eh], DL - Jmp InitVolumeEffectNoMemory - -CommandGMemoryOldEffects: - Mov [DI+11h], DL - Jmp InitVolumeEffectNoMemory - -InitSlideMemory: - ShL AH, 2 - Mov [DI+11h], AH - Jmp InitVolumeEffectNoMemory - -InitNormalMemory: - Mov [DI+0Bh], AH - -InitVolumeEffectNoMemory: - Test Byte Ptr [DI], 4 ; Channel not on! - JZ InitVolumeEffect3 - Mov SI, [DI+24h] - - Cmp AL, 1 - JA InitVolumeEffect2 - Mov AL, [DI+0Bh] - JE InitVolumeEffectB - -InitVolumeEffectA: ; Fine volume slide up. - Add AL, [SI+22h] - Cmp AL, 64 - JBE InitVolumeEffectABEnd - Mov AL, 64 - Jmp InitVolumeEffectABEnd - -InitVolumeEffectB: ; Fine volume slide down - Sub AL, [SI+22h] - Neg AL - JNS InitVolumeEffectABEnd - Xor AL, AL - -InitVolumeEffectABEnd: - Jmp CommandD2 - -InitVolumeEffect2: - Or Word Ptr [DI], 100h - - Cmp AL, 6 - JA InitVolumeEffectH - JE InitVolumeEffectG - -InitVolumeEffectCDEF: -InitVolumeEffectEnd: - Ret - -InitVolumeEffect3: - Cmp AL, 7 ; Vibrato? - JNE InitVolumeEffectCDEF - -InitVolumeEffectH: - ShL AH, 2 - JZ InitVolumeEffectH1 - - Mov [DI+3Ah], AH - -InitVolumeEffectH1: - Test Byte Ptr [DI], 4 - JZ InitVolumeEffectCDEF - - Jmp InitVibrato - -InitVolumeEffectG: - Jmp InitCommandG11 - -EndP InitVolumeEffect - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VolumeCommandC - - Mov SI, [DI+24h] - Mov AL, [DI+0Bh] - Add AL, [SI+22h] - Cmp AL, 64 - JBE VolumeCommandC1 - - And Word Ptr [DI], Not 100h ; Turn off effect calling - Mov AL, 64 - -VolumeCommandC1: - Jmp CommandD2 - -EndP VolumeCommandC - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VolumeCommandD - - Mov SI, [DI+24h] - Mov AL, [SI+22h] - Sub AL, [DI+0Bh] - JNC VolumeCommandD1 - - And Word Ptr [DI], Not 100h ; Turn off effect calling - Xor AL, AL - -VolumeCommandD1: - Jmp CommandD2 - -EndP VolumeCommandD - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VolumeCommandE ; Pitch slide down - - Mov BX, [DI+11h] - And BX, 0FFh - ShL BX, 2 - Jmp CommandEChain - Ret - -EndP VolumeCommandE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VolumeCommandF - - Mov BX, [DI+11h] - And BX, 0FFh - ShL BX, 2 - Jmp CommandFChain - -EndP VolumeCommandF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VolumeCommandG - - Test Byte Ptr [DI], 16 - JZ VolumeCommandGEnd - - Mov BX, [DI+11h] - - Test Byte Ptr [ES:2Ch], 20h ; Command G linked? - JZ VolumeCommandGMemoryOldEffects - - Mov BX, [DI+1Eh] - -VolumeCommandGMemoryOldEffects: - And BX, 0FFh - JZ VolumeCommandGEnd - - ShL BX, 2 - - Mov SI, [DI+24h] - - Cmp Byte Ptr [DI+42h], 1 - JE VolumeCommandG1 - ; Slide down - Call PitchSlideDown - ; Check that frequency is above porta - ; to frequency. - Mov EAX, [SI+10h] - Cmp EAX, [DI+34h] - JA VolumeCommandG6 - -VolumeCommandG4: - Mov EAX, [DI+34h] - And Word Ptr [DI], Not (110h) ; Turn off calling - -VolumeCommandG3: - Mov [SI+10h], EAX - -VolumeCommandG6: - Mov [SI+14h], EAX - -VolumeCommandGEnd: - Ret - -VolumeCommandG1: ; Slide up! - Call PitchSlideUp - ; Check that - ; 1) Channel is on - ; 2) Frequency (set) is below porta to - ; frequency - Mov EAX, [SI+10h] - - Test Word Ptr [SI], 200h - JNZ VolumeCommandG5 - - Cmp EAX, [DI+34h] - JB VolumeCommandG6 - -VolumeCommandG5: - And Word Ptr [SI], Not 200h - Or Byte Ptr [DI], 4 ; Turn on. - Jmp VolumeCommandG4 - -EndP VolumeCommandG - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InitNoCommand4: - Test CH, 4 - JZ InitNoCommand10 ; Taken if the channel's off. - - Mov SI, [DI+24h] - - Cmp AL, 0FEh - JA InitNoCommand5 ; Noteoff - JNE InitNoCommandNoteFade - - And CH, Not 4 - - Cmp Byte Ptr [SI+36h], 100 - JE MIDINoteCut - - Test Byte Ptr CS:DriverFlags, 2 - JNZ MIDINoteCut - - Mov Word Ptr [SI], 200h - Jmp NoOldEffect - -MIDINoteCut: -; And CH, Not 4 - Or Word Ptr [SI], 200h - -InitNoCommand10: ; Jump point. - Jmp NoOldEffect ; InitNoCommand1 - -InitNoCommandNoteFade: - Or Byte Ptr [SI], 8 ; Note fade - - Jmp NoOldEffect ; InitNoCommand1 - -InitNoCommand5: - Or Byte Ptr [SI], 4 ; Note off - -; Cmp Byte Ptr [SI+22h], 0 ; Volume = 0??? -; JE InitNoCommand13 - Jmp InitNoCommand11 - -Proc InitNoCommand ; DS:DI points to CIT area. - - Assume DS:Music - Mov CL, [DI+2] ; CL = mask - Mov CH, [DI] ; CH = channel info. - - Test CL, 33h - JZ NoOldEffect ; InitCommand1 - - ; Note here! - ; Check for noteoff. - Mov AL, [DI+0Eh] - Cmp AL, 120 - JAE InitNoCommand4 - - Test CH, 4 - JZ InitNoCommand9 - - Mov SI, [DI+24h] - Test CL, 11h - JNZ InitNoCommand9 - - Mov BX, [SI+32h] - Cmp BX, [DI+03h] - JE NoOldEffect ; InitNoCommand1 - -InitNoCommand9: - Test CL, 44h - JZ NoVolumePorta - - Cmp Byte Ptr [DI+5], 193 - JB NoVolumePorta - Cmp Byte Ptr [DI+5], 202 - JA NoVolumePorta - - Test Byte Ptr [DI], 4 - JNZ InitVolumeEffect - -NoVolumePorta: - Call AllocateChannel -; JC InitNoCommand1 - JC NoOldEffect - ; Channel allocated. - ; put volume - Mov BX, [SI+34h] ; Sample offset. - Mov AL, [DI+22h] - Mov AH, AL - Mov [SI+21h], AX ; Volset - - Test Byte Ptr [ES:2Ch], 4 ; Instrument mode? - JNZ InitNoCommandNoDefaultPan - - Mov AL, [ES:BX+2Fh] - Test AL, AL - JNS InitNoCommandNoDefaultPan - - Mov AH, AL - And AX, 7F7Fh - Mov [DI+2Eh], AL - Mov [SI+2Ah], AX - -InitNoCommandNoDefaultPan: - Mov EAX, [ES:BX+3Ch] ; EAX = C5Spd -; Call GetC5Speed - - Xor EBX, EBX - Mov [SI+2Ch], EBX - Mov [SI+48h], BX - Mov [SI+4Ch], EBX - ; Calculate frequency. - Mov BL, [DI+0Eh] ; BL = note. - - Mul [PitchTable+4*EBX] - SHRD EAX, EDX, 16 - Mov [SI+10h], EAX - Mov [SI+14h], EAX - - Or CH, 4 - And CH, Not 16 - -InitNoCommand11: - Push CX - Call GetLoopInformation - Pop CX - -InitNoCommand1: - Test CL, 22h+44h - JZ InitNoCommand3 - - Mov AH, [ES:2Ch] ; Instrument mode and old effects? - And AH, 14h - Cmp AH, 14h - JNE NoOldEffect -; Test AH, 4 -; JZ NoOldEffect - - Test CL, 22h - JZ NoOldEffect - - MovZX EBX, Byte Ptr [DI+4] - Cmp BL, 0FFh - JE NoOldEffect - - Mov Word Ptr [SI+26h], 0400h - Mov BX, [ES:EBX*2+64710] ; Instrument offset. - - Call InitPlayInstrument - -NoOldEffect: - Test CL, 44h - JZ InitNoCommand7 - - Mov AL, [DI+5] - Cmp AL, 64 - JBE InitNoCommand8 ; Volume set... - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JNC InitNoCommand7 - -InitNoCommandPanning: ; Panning set! - Mov [DI], CH - - Sub AL, 128 - Call InitCommandX2 ; Destroys (SI), AX - -InitNoCommand7: - Test CL, 22h ; Instrument present? -> - ; Change volume - JZ InitNoCommand3 - - Mov BL, [DI+0Fh] ; Get instrument offset. - And BX, 0FFh - JZ InitNoCommand3 - - Add BX, BX - Mov BX, [ES:64910+BX] - - Mov AL, [ES:BX+13h] ; Default volume - -InitNoCommand8: - Mov [DI+22h], AL - - Test CH, 4 - JZ InitNoCommand3 - - Mov SI, [DI+24h] - - Mov AH, AL - Mov [SI+21h], AX - Or Byte Ptr [SI], 10h ; recalc volume - -InitNoCommand3: ; Randomise volume if required. - Test Byte Ptr [DI], 80h - Mov [DI], CH - JZ InitNoCommandEnd - - Push CX - Call ApplyRandomValues - Pop CX - -InitNoCommandEnd: - Jmp InitVolumeEffect - -EndP InitNoCommand - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandA - - Assume DS:Music - - Mov AL, [DS:DI+7] - And AX, 0FFh - JZ InitCommandA_1 - - Mov CX, CurrentSpeed - Sub CurrentTick, CX - Sub ProcessTick, CX - Add CurrentTick, AX - Add ProcessTick, AX - Mov CurrentSpeed, AX - -InitCommandA_1: - Jmp InitNoCommand - -EndP InitCommandA - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandB - Assume DS:Music - - MovZX AX, Byte Ptr [DI+7] - Cmp AX, CurrentOrder - JA InitCommandB1 - - Mov StopSong, 1 - -InitCommandB1: - Dec AX - Mov ProcessOrder, AX - Mov ProcessRow, 0FFFEh - - Jmp InitNoCommand - -EndP InitCommandB - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandC - - Assume DS:Music - - Cmp PatternLooping, 0 - JNE InitCommandC1 - - MovZX AX, Byte Ptr [DS:DI+7] - Mov BreakRow, AX - - Mov ProcessRow, 0FFFEh - -InitCommandC1: - Jmp InitNoCommand - -EndP InitCommandC - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandD - Assume DS:Music - - Call InitNoCommand - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandD1 - - Mov [DI+10h], AL - -InitCommandD1: - Test Byte Ptr [DI], 4 - JZ InitCommandD6 - - Mov SI, [DI+24h] - -InitCommandD7: ; Jmp point for Lxx - Mov AL, [DI+10h] - Or Byte Ptr [SI], 16 ; Recalc vol - - Mov AH, AL - Test AH, 0Fh - JZ InitCommandD2 - Test AH, 0F0h - JZ InitCommandD3 - And AX, 0FF0h - Cmp AH, 0Fh - JE InitCommandD5 - Cmp AL, 0F0h - JE InitCommandD4 - -InitCommandD6: - Ret - -InitCommandD2: ; Slide up. - ShR AL, 4 - Mov [DI+30h], AL - - Or Byte Ptr [DI], 1 - Cmp AL, 0Fh - JE InitCommandD8 - - Ret - -InitCommandD8: - Jmp CommandD - -InitCommandD3: ; Slide down - Neg AL - Mov [DI+30h], AL - - Or Byte Ptr [DI], 1 - Cmp AL, -15 - JE InitCommandD9 - - Ret - -InitCommandD9: - Jmp CommandD - -InitCommandD4: ; Slide down (fine) - Mov Byte Ptr [DI+30h], 0 - Mov AL, [SI+22h] - Sub AL, AH ; Slide down - JNS InitCommandD4_1 - - Xor AL, AL - -InitCommandD4_1: - Mov AH, AL - Mov [SI+21h], AX - Mov [DI+22h], AL - Ret - -InitCommandD5: ; Slide up (fine) - Mov Byte Ptr [DI+30h], 0 - - ShR AL, 4 - Mov AH, [SI+22h] - Add AL, AH - Cmp AL, 64 - JBE InitCommandD4_1 - - Mov AL, 64 - Jmp InitCommandD4_1 - -EndP InitCommandD - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandE - Assume DS:Music - - Call InitNoCommand - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandE2 - - Mov [DI+11h], AL - -InitCommandE2: - Test Byte Ptr [DI], 4 - JZ InitCommandE1 - - Mov SI, [DI+24h] - Mov AL, [DI+11h] - - Test AL, AL - JZ InitCommandE1 ; still no slide?? - - Mov AH, AL - And AH, 0F0h - Cmp AH, 0E0h - JB InitCommandE4 - - And AL, 0Fh - JZ InitCommandE1 - - Xor BX, BX - - Cmp AH, 0E0h - JE InitCommandE5 - - ShL AL, 2 - -InitCommandE5: - Mov BL, AL - Call PitchSlideDown - - Mov EAX, [SI+10h] - Mov [SI+14h], EAX - Ret - -InitCommandE4: - Xor AH, AH - ShL AX, 2 - Mov [DI+40h], AX - Or Byte Ptr [DI], 1 ; call update only if necess. - -InitCommandE1: - Ret - -EndP InitCommandE - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandF - Assume DS:Music - - Call InitNoCommand - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandF2 - - Mov [DI+11h], AL - -InitCommandF2: - Test Byte Ptr [DI], 4 - JZ InitCommandF1 - - Mov SI, [DI+24h] - ; OK.. now processing is dependent - ; upon slide mode. - - Mov AL, [DI+11h] - Test AL, AL - JZ InitCommandF1 ; still no slide?? - - Mov AH, AL - And AH, 0F0h - Cmp AH, 0E0h - JB InitCommandF4 - - And AL, 0Fh - JZ InitCommandF1 - - Xor BX, BX - - Cmp AH, 0E0h - JE InitCommandF5 - - ShL AL, 2 - -InitCommandF5: - Mov BL, AL - Call PitchSlideUp - - Mov EAX, [SI+10h] ; Update frequency set field. - Mov [SI+14h], EAX - Ret - -InitCommandF4: - Xor AH, AH - ShL AX, 2 - Mov [DI+40h], AX - Or Byte Ptr [DI], 1 ; call update only if necess. - -InitCommandF1: - Ret - -EndP InitCommandF - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InitCommandG15: - Jmp InitNoCommand - -Proc InitCommandG - Assume DS:Music - ; Check whether channel on/owned - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandG6 - - Test Byte Ptr [ES:2Ch], 20h ; Compatibility Gxx? - JZ InitCommandGNotOldEffects1 - - Mov [DI+1Eh], AL - Jmp InitCommandG6 - -InitCommandGNotOldEffects1: - Mov [DI+11h], AL - -InitCommandG6: - Test Byte Ptr [DI], 4 - JZ InitCommandG15 - -InitcommandG11: ; Jumped to from Lxx - Mov SI, [DI+24h] - - Mov CL, [DI+2] ; CL = mask. - - Test CL, 22h - JZ InitCommandG17 - ; Checking for change of - ; Sample or instrument. - Mov AL, [DI+0Fh] ; Sample - And EAX, 0FFh - JZ InitCommandG17 - - Dec AX - - Mov DX, [DI+3] - Test Byte Ptr [ES:2Ch], 20h - JNZ InitGXXCompat1 - -; Don't overwrite note if MIDI! - Cmp Byte Ptr [DI+0Fh], 101 - JE InitCommandG13 - - Cmp [SI+33h], DH ; Ins the same? - Mov [SI+32h], DX ; Nte + Ins. - - JNE InitCommandG19 - - Cmp AL, [SI+36h] - JNE InitCommandG16 - -InitCommandG17: - Jmp InitCommandG13 - -InitCommandGNoSample: - Mov Word Ptr [SI], 200h - And Byte Ptr [DI], Not 4 - Ret - -InitGXXCompat1: - Mov AL, [SI+36h] - Inc AX - Mov [DI+0Fh], AL - - Mov BX, [ES:EAX+EAX+64910] - Mov AX, [ES:BX+11h] - Add AL, AL - Mov [SI+24h], AL - - Jmp InitCommandG18 - -InitCommandG19: - Cmp AL, [SI+36h] ; Sample the same? - JE InitCommandG18 - -InitCommandG16: - Mov BX, [ES:EAX+EAX+64912] - Mov Byte Ptr [SI+1], 1 - ; Now to update sample info. - Mov [SI+34h], BX ; Offset of sample - Mov [SI+36h], AL ; Sample num. - - Xor EAX, EAX - - Mov [SI+1Ah], AX ; Reset vibrato.. - Mov [SI+0Bh], AL ; Reset loop direction. - Mov [SI+2Ch], EAX - Mov [SI+48h], AX - Mov [SI+4Ch], EAX - - Mov AX, [ES:BX+11h] - Add AL, AL - Mov [SI+24h], AL - - Test AH, 1 - JZ InitCommandGNoSample - - And AH, 2 ; 16 bit... - ShR AX, 8 - Mov [SI+18h], AX - - Call GetLoopInformation - Mov CL, [DI+2] - -InitCommandG18: - Test Byte Ptr [ES:2Ch], 4 ; Instrument/sample mode? - JZ InitCommandG14 - ; Now for instruments - - Mov Word Ptr [SI+26h], 0400h - MovZX EBX, Byte Ptr [DI+4] - - Mov BX, [ES:EBX*2+64710] ; Instrument offset. - - Push Word Ptr [SI] - Call InitPlayInstrument - Pop AX - - Test AL, 1 - JZ InitCommandGXXCompat3 - - And Word Ptr [SI], Not 100h - -InitCommandGXXCompat3: - - Mov AL, [ES:BX+18h] - Mul Byte Ptr [SI+24h] - ShR AX, 7 - Mov [SI+24h], AL - - Jmp InitCommandG14 - -InitCommandG13: - Test CL, 11h - JZ InitCommandG1 - - ; OK. Time to calc freq. -InitCommandG14: - Mov AL, [DI+0Eh] - Cmp AL, 119 - JBE InitCommandG5 - -InitCommandG12: - Test Byte Ptr [DI], 4 - JZ InitCommandG1 - - Cmp AL, 0FEh - JA InitCommandGNoteOff - JNE InitCommandGNoteFade - - And Byte Ptr [DI], Not 4 ; Note cut! - Mov Word Ptr [SI], 200h ; Cut. - Jmp InitCommandG1 - -InitCommandGNoteOff: - Or Byte Ptr [SI], 4 ; Note off - Push CX - Call GetLoopInformation - Pop CX - Jmp InitCommandG1 - -InitcommandGNoteFade: - Or Byte Ptr [SI], 8 - Jmp InitCommandG1 - -InitCommandG5: -; Don't overwrite note if MIDI! - Cmp Byte Ptr [DI+0Fh], 101 - JE InitCommandGMIDI2 - - Mov [SI+32h], AL - -InitCommandGMIDI2: - Xor EDX, EDX - Mov BX, [SI+34h] - Mov DL, AL - Mov EAX, [ES:BX+3Ch] ; BP = C5Spd -; Call GetC5Speed - - Mul [PitchTable+EDX*4] - SHRD EAX, EDX, 16 - - Mov [DI+34h], EAX - Or Byte Ptr [DI], 16 - -InitCommandG1: - Test CL, 44h - JZ InitCommandG2 -; JZ InitCommandG3 - - Mov AL, [DI+5] - - Cmp AL, 64 - JBE InitCommandG4 - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JNC InitCommandG2 - -InitCommandGPanning: - Sub AL, 128 - Call InitCommandX2 ; Panning set... - -InitCommandG2: - Test CL, 22h - JZ InitCommandG3 - - Mov BX, [SI+34h] ; Sample memory offset. - Mov AL, [ES:BX+13h] - -InitCommandG4: - Or Byte Ptr [SI], 16 ; recalc volume. - Mov AH, AL - Mov [SI+21h], AX - Mov [DI+22h], AL - -InitCommandG3: - Test Byte Ptr [DI], 16 ; Slide on??? - JZ InitCommandGEnd - - MovZX AX, Byte Ptr [DI+11h] ; Work out magnitude + dirn - - Test Byte Ptr [ES:2Ch], 20h ; Command G memory - JZ InitCommandGNotOldEffects2 - - Mov AL, [DI+1Eh] - -InitCommandGNotOldEffects2: - ShL AX, 2 - JZ PrepareCommandGEnd - - Mov [DI+40h], AX - - Mov AX, [DI+34h] - Mov DX, [DI+36h] ; Port freq. - - Cmp DX, [SI+16h] - JA InitCommandG8 - JB InitCommandG9 - Cmp AX, [SI+14h] - JA InitCommandG8 - JB InitCommandG9 - ; equal?!?!? - ; then don't update effect. - Jmp PrepareCommandGEnd - -InitCommandG8: - Mov Byte Ptr [DI+42h], 1 ; slide up - Jmp InitCommandG10 - -InitCommandG9: - Mov Byte Ptr [DI+42h], 0 ; slide down. - -InitCommandG10: - Test Word Ptr [DI], 100h - JNZ PrepareCommandGEnd - - Or Byte Ptr [DI], 1 ; Update effect if necess. - -PrepareCommandGEnd: - -InitCommandGEnd: ; Don't call volume - ; effects if it has a Gxx! - Test Word Ptr [DI], 100h - JNZ InitCommandGNoVolEffect - - Jmp InitVolumeEffect - -InitCommandGNoVolEffect: - Ret - -EndP InitCommandG - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandH - Assume DS:Music - - Test Byte Ptr Byte Ptr [DI+2], 11h - JZ InitCommandH2 - Cmp Byte Ptr [DI+3], 119 - JA InitCommandH2 - - Mov Byte Ptr [DI+39h], 0 - Mov Byte Ptr [DI+2Dh], 0 - -InitCommandH2: - Mov AL, [DI+7] - Mov AH, AL - And AX, 0FF0h ; AH = depth - - JZ InitCommandH4 - - ShR AL, 2 ; AL = speed. - JZ InitCommandH3 - - - Mov [DI+3Bh], AL - -InitCommandH3: - ShL AH, 2 ; Depth * 4 - JZ InitCommandH4 - - Test Byte Ptr [ES:2Ch], 10h - JZ InitCommandH5 - - Add AH, AH - -InitCommandH5: - Mov [DI+3Ah], AH - -InitCommandH4: - Call InitNoCommand - - Test Byte Ptr [DI], 4 - JZ InitCommandH1 - - Or Byte Ptr [DI], 1 ; Update mode. - - Jmp InitVibrato - -InitCommandH1: - Ret - -EndP InitCommandH - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandI - - Call InitNoCommand - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandI2 - - Mov [DI+13h], AL - -InitCommandI2: - Test Byte Ptr [DI], 4 - JZ InitCommandI1 - ; OK.. now to handle tremor - Or Byte Ptr [DI], 1 - - Mov AL, [DI+13h] - Mov AH, AL - And AL, 0Fh - ShR AH, 4 - - Test Byte Ptr [ES:2Ch], 16 - JZ InitCommandI3 - - Add AX, 101h - -InitCommandI3: - Mov [DI+40h], AX ; AL = Offtime, AH = ontime - - Jmp CommandI - -InitCommandI1: - Ret - -EndP InitCommandI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandJ - Assume DS:Music - - Call InitNoCommand - - Mov Word Ptr [DI+40h], 0 - Mov AL, [DI+7] - Test AL, AL - JNZ InitCommandJ2 - - Mov AL, [DI+14h] - Jmp InitCommandJ3 - -InitCommandJ2: - Mov [DI+14h], AL - -InitCommandJ3: - Test Byte Ptr [DI], 4 - JZ InitCommandJ1 - - Mov BL, AL - ShR AL, 4 - And EBX, 0Fh - - Or Byte Ptr [DI], 1 ; Update when channel on - - LEA DX, [EBX*4+PitchTable+240] - Mov BL, AL - Mov [DI+44h], DX - LEA DX, [EBX*4+PitchTable+240] - Mov [DI+42h], DX - -InitCommandJ1: - Ret - -EndP InitCommandJ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandK - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandK1 - - Mov [DI+10h], AL - -InitCommandK1: - Call InitNoCommand - - Test Byte Ptr [DI], 4 - JZ InitCommandKEnd - - Call InitVibrato - Call InitCommandD7 - Or Byte Ptr [DI], 2 ; Always update. - -InitCommandKEnd: - Ret - -EndP InitCommandK - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandL - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandL1 - - Mov [DI+10h], AL - -InitCommandL1: - Test Byte Ptr [DI], 4 - JZ InitCommandLEnd - - Call InitCommandG11 - Call InitCommandD7 - Or Byte Ptr [DI], 2 ; Always update. - -InitCommandLEnd: - Ret - -EndP InitCommandL - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandM - Assume DS:Music - - Call InitNoCommand - - Mov AL, [DI+7] ; AL = command val. - Cmp AL, 40h - JA InitCommandM3 - -InitCommandM2: - Test Byte Ptr [DI], 4 - JZ InitCommandM1 - - Mov SI, [DI+24h] - - Mov [SI+23h], AL - Or Byte Ptr [SI], 16 ; recalc volume - -InitCommandM1: - Mov [DI+2Fh], AL - -InitCommandM3: - Ret - -EndP InitCommandM - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandN - Assume DS:Music - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandN1 - - Mov [DI+16h], AL - -InitCommandN1: - Call InitNoCommand - - Mov AL, [DI+16h] - Mov AH, AL - Test AH, 0Fh - JZ InitCommandN2 - Test AH, 0F0h - JZ InitCommandN3 - And AX, 0FF0h - Cmp AH, 0Fh - JE InitCommandN4 - Cmp AL, 0F0h - JE InitCommandN5 - Ret - -InitCommandN2: - ShR AL, 4 - Mov [DI+40h], AL - Or Byte Ptr [DI], 2 ; Always update effect - Ret - -InitCommandN3: - Neg AL - Mov [DI+40h], AL - Or Byte Ptr [DI], 2 - Ret - -InitCommandN4: - ShR AL, 4 - Add AL, [DI+2Fh] - Cmp AL, 64 - JBE InitCommandN6 - Mov AL, 64 - Jmp InitCommandM2 - -InitCommandN5: - Mov AL, [DI+2Fh] - Sub AL, AH - JNC InitCommandN6 - Xor AL, AL - -InitCommandN6: - Jmp InitCommandM2 - - -EndP InitCommandN - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandO - Assume DS:Music - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandO2 - - Mov [DI+12h], AL - -InitCommandO2: - Call InitNoCommand - -; Mov AL, [DI+2] -; Test AL, 22h -; JNZ InitCommandO1 - -; Test AL, 11h -; Test Byte Ptr [DI+2], 11h - Test Byte Ptr [DI+2], 33h - JZ InitCommandO1 - - Cmp Byte Ptr [DI+0Eh], 120 - JAE InitCommandO1 - -InitCommandO3: - Test Byte Ptr [DI], 4 - JZ InitCommandO1 - - Xor EAX, EAX - Mov SI, [DI+24h] - Mov AH, [DI+1Bh] - Mov AL, [DI+12h] - ShL EAX, 8 - - Cmp EAX, [SI+44h] ; End of sample/end of sample loop - JB InitCommandO4 - - Test Byte Ptr [ES:2Ch], 16 - JZ InitCommandO1 - - Mov EAX, [SI+44h] - Dec EAX - -InitCommandO4: - Mov [SI+4Ch], EAX - Mov [SI+2Ch], EAX - - Xor AX, AX - Mov [SI+48h], AX - Ret - -InitCommandO1: - Ret - -EndP InitCommandO - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandP - Assume DS:Music - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandP1 - - Mov [DI+17h], AL - -InitCommandP1: - Call InitNoCommand - - Mov DL, [DI+2Eh] - Test Byte Ptr [DI], 4 - JZ InitCommandP8 - - Mov SI, [DI+24h] - Mov DL, [SI+2Bh] ; Pan set - -InitCommandP8: - Cmp DL, 100 ; Surround?? - JE InitCommandP7 - - Mov AL, [DI+17h] - Mov AH, AL - Test AH, 0Fh - JZ InitCommandP2 - Test AH, 0F0h - JZ InitCommandP3 - And AX, 0F00Fh - Cmp AL, 0Fh - JE InitCommandP4 - Cmp AH, 0F0h - JE InitCommandP5 - -InitCommandP7: - Ret - -InitCommandP2: - ShR AL, 4 - Neg AL - Mov [DI+40h], AL - Or Byte Ptr [DI], 2 ; Always update effect - Ret - -InitCommandP3: - Mov [DI+40h], AL - Or Byte Ptr [DI], 2 - Ret - -InitCommandP4: - ShR AH, 4 - Mov AL, DL - Sub AL, AH - JNC InitCommandP6 - Xor AL, AL - Jmp InitCommandX2 - -InitCommandP5: - Add AL, DL - Cmp AL, 64 - JBE InitCommandP6 - - Mov AL, 64 - -InitCommandP6: - Jmp InitCommandX2 - -EndP InitCommandP - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandQ - - Call InitNoCommand - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandQ1 - - Mov [DI+18h], AL - -InitCommandQ1: - Test Byte Ptr [DI], 4 - JZ InitCommandQ2 - - Or Byte Ptr [DI], 1 - - Test Byte Ptr [DI+2], 11h - JZ InitCommandQ3 - - Mov AL, [DI+18h] - And AL, 0Fh ; AL = retrig count - Mov [DI+33h], AL ; retrig countdown - -InitCommandQ2: - Ret - -InitCommandQ3: - Jmp CommandQ - -EndP InitCommandQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandR - Assume DS:Music - - Mov AL, [DI+7] - Mov AH, AL - And AX, 0FF0h ; AH = depth - JZ InitCommandR4 - - ShR AL, 2 ; AL = speed. - JZ InitCommandR3 - - Mov [DI+3Fh], AL - -InitCommandR3: - ShL AH, 1 - JZ InitCommandR4 - - Mov [DI+3Eh], AH - -InitCommandR4: - Call InitNoCommand - - Test Byte Ptr [DI], 4 - JZ InitCommandR1 - - Or Byte Ptr [DI], 1 ; Update mode. - - Jmp InitTremelo - -InitCommandR1: - Ret - -EndP InitCommandR - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -CommandSTable Label Word - DW Offset InitNoCommand ; 0 - DW Offset InitNoCommand ; 1 - DW Offset InitNoCommand ; 2 - DW Offset InitCommandS3x ; 3 - set vibrato waveform - DW Offset InitCommandS4x ; 4 - set tremelo waveform - DW Offset InitCommandS5x ; 5 - set panbrello waveform - DW Offset InitCommandS6x ; 6 - extra delay of x frames - DW Offset InitCommandS7x ; 7 - instrument functions - DW Offset InitCommandS8x ; 8 - set pan - DW Offset InitCommandS9x ; 9 - set surround - DW Offset InitCommandSAx ; A - Set high order offset - DW Offset InitCommandSBx ; B - loop control - DW Offset InitCommandSCx ; C - note cut - DW Offset InitCommandSDx ; D - note delay - DW Offset InitCommandSEx ; E - pattern delay - DW Offset InitCommandSFx ; F - MIDI Macro select - -CommandS7Table Label Word - DW Offset InitCommandS70 ; Past note cut - DW Offset InitCommandS71 ; Past note off - DW Offset InitCommandS72 ; Past note fade - DW Offset InitCommandS73 ; Set NNA to cut - DW Offset InitCommandS73 ; Set NNA to continue - DW Offset InitCommandS73 ; Set NNA to off - DW Offset InitCommandS73 ; Set NNA to fade - DW Offset InitCommandS77 ; Set volume envelope on - DW Offset InitCommandS78 ; Set volume envelope off - DW Offset InitCommandS79 ; Set panning envelope on - DW Offset InitCommandS7A ; Set panning envelope off - DW Offset InitCommandS7B ; Set pitch envelope on - DW Offset InitCommandS7C ; Set pitch envelope off - DW Offset InitNoCommand - DW Offset InitNoCommand - DW Offset InitNoCommand - -Proc InitCommandS - Assume DS:Music - - Mov AL, [DI+7] - Test AL, AL - JNZ @ICS1 - - Mov AL, [DI+1Ah] - -@ICS1: - Mov [DI+1Ah], AL - - Mov AH, AL - And AX, 0F00Fh - - Mov [DI+40h], AX ; Misc effects data. - - Mov BX, AX - ShR BX, 11 ; BX = (AH>>4)*2 - - Jmp [CommandSTable+BX] - -InitCommandS3x: - Cmp AL, 3 - JA @ICS2 - Mov [DI+38h], AL - -@ICS2: - Jmp InitNoCommand - -InitCommandS4x: - Cmp AL, 3 - JA @ICS3 - Mov [DI+3Ch], AL - -@ICS3: - Jmp InitNoCommand - -InitCommandS5x: - Cmp AL, 3 - JA @ICS4 - - Mov [DI+28h], AL - Mov Byte Ptr [DI+29h], 0 - -@ICS4: - Jmp InitNoCommand - -InitCommandS6x: - And AX, 0FFh - Add CurrentTick, AX - Add ProcessTick, AX - Jmp InitNoCommand - -InitCommandS7x: - Mov BL, AL - Add BL, BL - Jmp [CommandS7Table+BX] - -InitCommandS70: ; Past Note cut. - Call InitNoCommand - Mov SI, Offset SlaveChannelInformationTable - Mov CX, NumChannels - Mov AL, [DI+20h] - Or AL, 80h - -InitCommandS70_1: - Cmp AL, [SI+3Ah] - JNE @ICS5 - - Test Byte Ptr CS:DriverFlags, 2 - JZ @ICS70_2 - - Or Word Ptr [SI], 200h - Jmp @ICS5 - -@ICS70_2: - Mov Word Ptr [SI], 200h - -@ICS5: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ InitCommandS70_1 - - Ret - -InitCommandS71: ; Past note off - Call InitNoCommand - Mov AH, 4 - Jmp InitCommandS72_1 - -InitCommandS72: ; Past note fade. - Call InitNoCommand - Mov AH, 8 - -InitCommandS72_1: - Mov SI, Offset SlaveChannelInformationTable - Mov CX, NumChannels - Mov AL, [DI+20h] - Or AL, 80h - -InitCommandS72_2: - Cmp AL, [SI+3Ah] - JNE @ICS6 - - Or [SI], AH - - Push AX - Push CX - Call GetLoopInformation - Pop CX - Pop AX - -@ICS6: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ InitCommandS72_2 - - Ret - -InitCommandS73: - Push AX - Call InitNoCommand - Pop AX - - Test Byte Ptr [DI], 4 - JZ @ICS7 - - Sub AL, 3 - Mov SI, [DI+24h] - Mov [SI+3Bh], AL - -@ICS7: - Ret - -InitCommandS77: - Call InitNoCommand - Test Byte Ptr [DI], 4 - JZ @ICS9 - - Mov SI, [DI+24h] - And Word Ptr [SI], Not 1000h - -@ICS9: - Ret - -InitCommandS78: - Call InitNoCommand - Test Byte Ptr [DI], 4 - JZ @ICS9 - - Mov SI, [DI+24h] - Or Word Ptr [SI], 1000h - - Ret - -InitCommandS79: - Call InitNoCommand - Test Byte Ptr [DI], 4 - JZ @ICS9 - - Mov SI, [DI+24h] - And Word Ptr [SI], Not 2000h - - Ret - -InitCommandS7A: - Call InitNoCommand - Test Byte Ptr [DI], 4 - JZ @ICS10 - - Mov SI, [DI+24h] - Or Word Ptr [SI], 2000h - - Ret - -InitCommandS7B: - Call InitNoCommand - Test Byte Ptr [DI], 4 - JZ @ICS10 - - Mov SI, [DI+24h] - And Word Ptr [SI], Not 4000h - -@ICS10: - Ret - -InitCommandS7C: - Call InitNoCommand - Test Byte Ptr [DI], 4 - JZ @ICS10 - - Mov SI, [DI+24h] - Or Word Ptr [SI], 4000h - - Ret - -InitCommandS8x: - Mov AH, AL - ShL AH, 4 - Or AL, AH - And AX, 0FFh - Add AX, 2 - SHR AX, 2 - -InitCommandS8x_1: - Push AX - Call InitNoCommand - Pop AX - - Jmp InitCommandX2 - -InitCommandS9x: - Cmp AL, 1 - Mov AL, 100 - JE InitCommandS8x_1 - Jmp InitNoCommand - -InitCommandSAx: - Mov [DI+1Bh], AL - Jmp InitNoCommand - -InitCommandSBx: - Push AX - Call InitNoCommand - Pop AX - - Test AL, AL - JZ InitCommandSBx_1 - - Cmp Byte Ptr [DI+27h], 0 - JNE InitCommandSBx_2 - - Mov [DI+27h], AL - -InitCommandSBx_3: - MovZX AX, Byte Ptr [DI+26h] - - Dec AX - Mov ProcessRow, AX - Mov PatternLooping, 1 - - Ret - -InitCommandSBx_2: - Dec Byte Ptr [DI+27h] - JNZ InitCommandSBx_3 - Mov AX, CurrentRow - - Inc AX - Mov [DI+26h], AL - Ret - -InitCommandSBx_1: - Mov AX, CurrentRow - Mov [DI+26h], AL - Ret - -InitCommandSCx: - Or Byte Ptr [DI], 1 - Jmp InitNoCommand - -InitCommandSDx: - Or Byte Ptr [DI], 2 - Ret - -InitCommandSEx: - Cmp RowDelayOn, 0 - JNE @ICS8 - - Inc AX - Mov AH, 1 - Mov [Word Ptr RowDelay], AX - -@ICS8: - Jmp InitNoCommand - -InitCommandSFx: ; Set MIDI Macro - Mov [DI+1Fh], AL - Jmp InitNoCommand - -EndP InitCommandS - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandT - Assume DS:Music - - Mov AL, [DI+7] - Test AL, AL - JZ InitCommandT2 - - Mov [DI+19h], AL - -InitCommandT2: - Mov AL, [DI+19h] - -InitCommandT3: - Cmp AL, 20h - JB InitCommandT1 - - Mov Tempo, AL - Call Music_InitTempo - Jmp InitNoCommand - -InitCommandT1: - Call InitNoCommand - Or Byte Ptr [DI], 2 ; Update mode - Ret - -EndP InitCommandT - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandU - Assume DS:Music - - Test Byte Ptr Byte Ptr [DI+2], 11h - JZ InitCommandU2 - - Mov Byte Ptr [DI+39h], 0 - Mov Byte Ptr [DI+2Dh], 0 - -InitCommandU2: - Mov AL, [DI+7] - Mov AH, AL - And AX, 0FF0h ; AH = depth - - Test AL, AL - JZ InitCommandU3 - - ShR AL, 2 ; AL = speed. - - Mov [DI+3Bh], AL - -InitCommandU3: - Test AH, AH - JZ InitCommandU4 - - Test Byte Ptr [ES:2Ch], 16 - JZ InitCommandU5 - - Add AH, AH - -InitCommandU5: - Mov [DI+3Ah], AH - -InitCommandU4: - Call InitNoCommand - - Test Byte Ptr [DI], 4 - JZ InitCommandU1 - - Or Byte Ptr [DI], 1 ; Update mode. - - Jmp InitVibrato - -InitCommandU1: - Ret - -EndP InitCommandU - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandV - Assume DS:Music - - Mov AL, [DI+7] - Cmp AL, 80h - JA InitCommandV1 - - Mov GlobalVolume, AL - Call RecalculateAllVolumes - -InitCommandV1: - Jmp InitNoCommand - -EndP InitCommandV - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandW ; Global volume slides! - Assume DS:Music - - Call InitNoCommand - - Mov AL, [DI+7] - Test AL, AL - JNZ InitCommandW1 - - Mov AL, [DI+1Ch] - Jmp InitCommandW2 - -InitCommandW1: - Mov [DI+1Ch], AL - -InitCommandW2: - Mov AH, AL - And AX, 0F00Fh - JZ InitCommandW3 - Test AH, AH - JZ InitCommandW4 - Test AL, AL - JZ InitCommandW5 - Cmp AH, 0F0h - JE InitCommandW6 - Cmp AL, 0Fh - JE InitCommandW8 - - Ret - -InitCommandW4: - Neg AL - Mov [DI+40h], AL - Or Byte Ptr [DI], 2 - Ret - -InitCommandW5: - ShR AH, 4 - Mov [DI+40h], AH - Or Byte Ptr [DI], 2 - Ret - -InitCommandW6: - Mov AH, GlobalVolume - Sub AH, AL - JNC InitCommandW7 - - Xor AH, AH - -InitCommandW7: - Mov GlobalVolume, AH - - Call RecalculateAllVolumes - Ret - -InitCommandW8: - ShR AH, 4 - Mov AL, GlobalVolume - Add AL, AH - JNS InitCommandW9 - - Mov AL, 128 - -InitCommandW9: - Mov GlobalVolume, AL - - Call RecalculateAllVolumes - Ret - -InitCommandW3: - Ret - -EndP InitCommandW - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandX - Assume DS:Music - - Call InitNoCommand - - MovZX AX, Byte Ptr [DI+7] ; AL = command val. - Add AX, 2 - SHR AX, 2 - -InitCommandX2: - Test Byte Ptr [DI], 4 - JZ InitCommandX1 - - Mov SI, [DI+24h] - Mov AH, AL - Mov [SI+2Ah], AX - - Or Byte Ptr [SI], 64+2 ; Recalculate pan - -InitCommandX1: - Mov [DI+2Eh], AL - Ret - -EndP InitCommandX - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandY - Assume DS:Music - - Mov AL, [DI+7] - Mov AH, AL - And AX, 0FF0h ; AH = depth - JZ InitCommandY4 - - ShR AL, 4 - JZ InitCommandY3 - - Mov [DI+2Bh], AL - -InitCommandY3: - ShL AH, 1 - JZ InitCommandY4 - - Mov [DI+2Ah], AH - -InitCommandY4: - Call InitNoCommand - - Test Byte Ptr [DI], 4 - JZ InitCommandY1 - - Or Byte Ptr [DI], 1 ; Update mode. - - Jmp CommandY - -InitCommandY1: - Ret - -EndP InitCommandY - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitCommandZ ; Macros start at 120h, 320h - - Call InitNoCommand - - Mov BL, [DI+7] - Mov SI, [DI+24h] - - Test BL, BL - JS InitCommandZ1 - -; Test SI, SI -; JZ InitCommandZ2 - - Mov BL, [DI+1Fh] ; 0->7Fh - And BX, 0Fh ; BX = SFx number - ShL BX, 5 - Add BX, 120h - Jmp MIDITranslate - -InitCommandZ1: ; Macros! - And BX, 7Fh - ShL BX, 5 ; BX = (xx-80h)*20h - Add BX, 320h - Jmp MIDITranslate - -InitCommandZ2: - Ret - -EndP InitCommandZ - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Proc NoCommand ; DS:DI points to CIT Area - - Ret - -EndP NoCommand - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandD - Assume DS:Music - - Mov SI, [DI+24h] - Mov AL, [DI+30h] - Add AL, [SI+22h] ; Volset. - JS CommandD1 - - Cmp AL, 64 - JBE CommandD2 - - And Byte Ptr [DI], Not 1 - - Mov AL, 64 - Jmp CommandD2 - -CommandD1: - And Byte Ptr [DI], Not 1 - Xor AL, AL - -CommandD2: - Mov [SI+21h], AL - Mov [SI+22h], AL - Mov [DI+22h], AL - Or Byte Ptr [SI], 16 ; Recalc vol - Ret - -EndP CommandD - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandE - Assume DS:Music - - Mov BX, [DI+40h] - -CommandEChain: - Mov SI, [DI+24h] - Call PitchSlideDown - - Mov EAX, [SI+10h] - Mov [SI+14h], EAX - - Ret - -EndP CommandE - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandF - Assume DS:Music - - Mov BX, [DI+40h] - -CommandFChain: - Mov SI, [DI+24h] - Call PitchSlideUp - - Mov EAX, [SI+10h] - Mov [SI+14h], EAX - - Ret - -EndP CommandF - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandG - - Test Byte Ptr [DI], 16 - JZ CommandGEnd - - Mov BX, [DI+40h] - Mov SI, [DI+24h] - Cmp Byte Ptr [DI+42h], 1 - JE CommandG1 - ; Slide down - Call PitchSlideDown - ; Check that frequency is above porta - ; to frequency. - Mov EAX, [SI+10h] - Cmp EAX, [DI+34h] - JA CommandG6 - -CommandG4: - Mov EAX, [DI+34h] - And Byte Ptr [DI], Not (3 Or 16) ; Turn off calling - -CommandG3: - Mov [SI+10h], EAX - -CommandG6: - Mov [SI+14h], EAX - -CommandGEnd: - Ret - -CommandG1: ; Slide up! - Call PitchSlideUp - ; Check that - ; 1) Channel is on - ; 2) Frequency (set) is below porta to - ; frequency - Mov EAX, [SI+10h] - - Test Word Ptr [SI], 200h - JNZ CommandG5 - - Cmp EAX, [DI+34h] - JB CommandG6 - -CommandG5: -; Or Byte Ptr [SI], 1 -; And Byte Ptr [SI+1], Not 2 - And Word Ptr [SI], Not 200h - Or Byte Ptr [DI], 4 ; Turn on. - Jmp CommandG4 - -EndP CommandG - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InitVibrato: - Test Byte Ptr [ES:2Ch], 10h - JZ CommandH - - Mov SI, [DI+24h] - Or Byte Ptr [SI], 32 ; Freq change... - Mov AL, [DI+2Dh] - Jmp CommandH5 - -Proc CommandH - - Mov SI, [DI+24h] - Or Byte Ptr [SI], 32 ; Freq change... - - Mov BL, [DI+39h] - Add BL, [DI+3Bh] ; Add speed. - Mov [DI+39h], BL ; Save value - Mov BH, [DI+38h] ; AL = waveform - - Cmp BH, 3 - JE CommandH1 - - Mov AL, [FineSineData+BX] ; AL = -64 -> 64 - - Jmp CommandH2 - -CommandH1: ; Random. - Call Random - And AL, 127 - Sub AL, 64 - -CommandH2: - Mov [DI+2Dh], AL ; Save last vibrato. - -CommandH5: - IMul Byte Ptr [DI+3Ah] - SAL AX, 2 - Add AX, 80h - - Test Byte Ptr [ES:2Ch], 16 - JZ CommandH9 - - Neg AH - -CommandH9: - MovZX BX, AH - ; AH = EEx/FEx command value - Test AH, AH - JS CommandH4 - JNS CommandH3 - Ret - -CommandH3: - Jmp PitchSlideUp - -CommandH4: - Neg BL - Jmp PitchSlideDown - Ret - -EndP CommandH - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandI - - Mov SI, [DI+24h] - - Or Byte Ptr [SI], 16 ; recalc volume - - Dec Byte Ptr [DI+31h] - JS CommandI2 - JZ CommandI2 - -CommandI1: - Cmp Byte Ptr [DI+32h], 1 - JE CommandI3 - - Mov Byte Ptr [SI+21h], 0 - -CommandI3: - Ret - -CommandI2: - Xor Byte Ptr [DI+32h], 1 - MovZX BX, Byte Ptr [DI+32h] - Mov AL, [DI+40h+BX] - Mov [DI+31h], AL - Jmp CommandI1 - -EndP CommandI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandJ - Assume DS:Music - - Mov SI, [DI+24h] - Mov BX, [DI+40h] - - Or Byte Ptr [SI], 32 - - Add BX, 2 - Cmp BX, 6 - JB CommandJ1 - - Mov Word Ptr [DI+40h], 0 - Ret - -CommandJ1: - Push DI - - Mov [DI+40h], BX - Mov DI, [DI+BX+40h] ; DI points to freq mult. - - Mov EAX, [SI+10h] - Mul DWord Ptr [DI] - - Test EDX, 0FFFF0000h - JNZ CommandJ2 - - SHRD EAX, EDX, 16 - Mov [SI+10h], EAX - - Pop DI - Ret - -CommandJ2: - Xor EAX, EAX - Mov [SI+10h], EAX - - Pop DI - Ret - -EndP CommandJ - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandK - - Call CommandH - Call CommandD - Ret - -EndP CommandK - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandL - - Test Byte Ptr [DI], 16 - JZ CommandL1 - - Call CommandG - Or Byte Ptr [DI], 1 - -CommandL1: - Call CommandD - Ret - -EndP CommandL - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandN - - Mov AL, [DI+2Fh] - Add AL, [DI+40h] - JNS CommandN1 - - Xor AL, AL - Jmp InitCommandM2 - -CommandN1: - Cmp AL, 64 - JBE CommandN2 - - Mov AL, 64 - -CommandN2: - Jmp InitCommandM2 - -EndP CommandN - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandP - - Mov AL, [DI+2Eh] - Test Byte Ptr [DI], 4 - JZ CommandP3 - - Mov SI, [DI+24h] - Mov AL, [SI+2Bh] ; Pan set - -CommandP3: - Add AL, [DI+40h] - JNS CommandP1 - - Xor AL, AL - Jmp InitCommandX2 - -CommandP1: - Cmp AL, 64 - JBE CommandP2 - - Mov AL, 64 - -CommandP2: - Jmp InitCommandX2 - -EndP CommandP - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandQ - - Dec Byte Ptr [DI+33h] - JS CommandQ1 - JZ CommandQ1 - - Ret - -CommandQ1: ; OK... reset counter. - Mov BL, [DI+18h] - Mov BH, BL - And BX, 0F00Fh - Mov [DI+33h], BL ; retrig count done. - - Mov SI, [DI+24h] - - Test Byte Ptr DriverFlags, 2 ; Hiqual? - JZ CommandQNoHiQual - - Push ES - Push DI - - Test Byte Ptr [ES:2Ch], 4 ; Instrument mode? - - Push DS - Pop ES - - JNZ CommandQHiqualInstruments - -CommandQHiqualSamples: - Lea DI, [SI+64*SLAVECHANNELSIZE] - - Mov CX, SLAVECHANNELSIZE/4 - Rep MovsD - Or Byte Ptr [DI-SLAVECHANNELSIZE+1], 2h ; Cut - Or Byte Ptr [DI-SLAVECHANNELSIZE+3Ah], 80h ; Disowned - Sub SI, SLAVECHANNELSIZE - - Pop DI - Jmp CommandQHiqualEnd - -CommandQHiqualInstruments: - Mov DI, Offset SlaveChannelInformationTable - Mov CX, NumChannels - -CommandQFindChannel: - Test Byte Ptr [DI], 1 - JZ CommandQHiqualCopy - - Add DI, SLAVECHANNELSIZE - Loop CommandQFindChannel - Pop DI - Jmp CommandQHiqualEnd - -CommandQHiqualCopy: - Mov CX, SLAVECHANNELSIZE/4 - Rep MovsD - - Or Byte Ptr [SI-SLAVECHANNELSIZE+1], 2h ; Cut - Or Byte Ptr [SI-SLAVECHANNELSIZE+3Ah], 80h ; Disowned - LEA SI, [DI-SLAVECHANNELSIZE] - Pop DI - - Mov [DI+24h], SI - -CommandQHiqualEnd: - Pop ES - -CommandQNoHiQual: - Xor EAX, EAX - Mov [SI+2Ch], EAX - Mov [SI+48h], AX - Mov [SI+4Ch], EAX - - Or Word Ptr [SI], 540h - - Mov AL, [SI+22h] - ShR BX, 11 - - Jmp [RetrigOffsets+BX] - -CommandQ_0: - Ret - -CommandQ_1: - Dec AL - Jmp CommandQCheckLow - -CommandQ_2: - Sub AL, 2 - Jmp CommandQCheckLow - -CommandQ_3: - Sub AL, 4 - Jmp CommandQCheckLow - -CommandQ_4: - Sub AL, 8 - Jmp CommandQCheckLow - -CommandQ_5: - Sub AL, 16 - Jmp CommandQCheckLow - -CommandQ_6: - ShL AL, 1 - Mov BL, 3 - Div BL - Jmp CommandQEnd - -CommandQ_7: - ShR AL, 1 - Jmp CommandQEnd - -CommandQ_8: - Ret - -CommandQ_9: - Inc AX - Jmp CommandQCheckHigh - -CommandQ_A: - Add AL, 2 - Jmp CommandQCheckHigh - -CommandQ_B: - Add AL, 4 - Jmp CommandQCheckHigh - -CommandQ_C: - Add AL, 8 - Jmp CommandQCheckHigh - -CommandQ_D: - Add AL, 16 - Jmp CommandQCheckHigh - -CommandQ_E: - Mov AH, AL - Add AL, AL - Add AL, AH - ShR AL, 1 - Jmp CommandQCheckHigh - -CommandQ_F: - ShL AL, 1 - Jmp CommandQCheckHigh - - -CommandQCheckLow: - JNS CommandQEnd - Xor AL, AL - Jmp CommandQEnd - -CommandQCheckHigh: - Cmp AL, 64 - JBE CommandQEnd - Mov AL, 64 - -CommandQEnd: - Mov [SI+21h], AL - Mov [SI+22h], AL - Mov [DI+22h], AL - Or Byte Ptr [SI], 16 ; recalc volume flag - - Cmp Byte Ptr [DI+0Fh], 101 ; MIDI sample - JNE CommandQNoMidi - - Mov BX, MIDICOMMAND_STOPNOTE - Call MIDITranslate - -CommandQNoMidi: - Ret - -EndP CommandQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InitTremelo: - Test Byte Ptr [ES:2Ch], 10h - JZ CommandR - - Mov SI, [DI+24h] - Or Byte Ptr [SI], 64 ; Volume change... - Mov AL, [DI+23h] - Jmp CommandR2 - -Proc CommandR - - Mov SI, [DI+24h] - Or Byte Ptr [SI], 16 ; Volume change - - Mov BL, [DI+3Dh] - Add BL, [DI+3Fh] ; Add speed. - Mov [DI+3Dh], BL ; Save value - Mov BH, [DI+3Ch] ; AL = waveform - - Cmp BH, 3 - JE CommandR1 - - Mov AL, [FineSineData+BX] ; AL = -64 -> 64 - - Jmp CommandR5 - -CommandR1: ; Random. - Call Random - And AL, 127 - Sub AL, 64 - -CommandR5: - Mov [DI+23h], AL ; Save last tremelo - -CommandR2: - IMul Byte Ptr [DI+3Eh] - SAL AX, 2 - Add AX, 80h - MovZX BX, AH - ; AH = volume change - Mov AL, [SI+21h] ; AL = vol. - Add AL, AH - JNS CommandR3 - - Xor AL, AL - -CommandR3: - Cmp AL, 64 - JBE CommandR4 - - Mov AL, 64 - -CommandR4: - Mov [SI+21h], AL - Ret - -EndP CommandR - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandS ; Have to handle SDx, SCx - Assume DS:Music - - Mov AX, [DI+40h] ; AH = command, AL = value. - Cmp AH, 0D0h - JE CommandS1 - - Cmp AH, 0C0h - JE CommandS3 - -CommandS4: - Ret - -CommandS3: - Test Byte Ptr [DI], 4 - JZ CommandS4 - - Dec Byte Ptr [DI+40h] - JZ CommandS5 - JS CommandS5 - - Ret - -CommandS5: - Mov SI, [DI+24h] ; Note cut. - - Mov AL, [DI] - - And AL, Not 4 - Mov [DI], AL - - Cmp Byte Ptr [SI+36h], 100 - JE CommandS7 - - Test Byte Ptr CS:DriverFlags, 2 - JNZ CommandS7 - - Mov Word Ptr [SI], 200h - Ret - -CommandS7: - Or Word Ptr [SI], 200h - Ret - -CommandS1: - Dec Byte Ptr [DI+40h] - JS CommandS2 - JZ CommandS2 - - Ret - -CommandS2: - And Byte Ptr [DI], Not 3 - Call InitNoCommand - - Or Byte Ptr [DI], 64 - - MovZX BX, Byte Ptr [DI+20h] ; Check whether chn - ; is on - Test Byte Ptr [ES:BX+40h], 80h - JZ CommandS6 - - Test Byte Ptr [DI], 32 - JNZ CommandS6 - - Test Byte Ptr [DI], 4 - JZ CommandS6 ; Channel was off. - - Mov SI, [DI+24h] - Or Byte Ptr [SI+1], 8 - -CommandS6: - Ret - -EndP CommandS - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandT - Assume DS:Music - - Mov AL, [DI+19h] - Mov BL, Tempo - Xor AH, AH - Xor BH, BH - - Test AL, 0F0h - JZ CommandT1 - ; Slide up - Add BX, AX - Sub BX, 10h - Cmp BX, 0FFh - JBE CommandT2 - Mov BL, 0FFh - Jmp CommandT2 - -CommandT1: ; Slide down - Sub BX, AX - Cmp BX, 20h - JGE CommandT2 - - Mov BL, 20h - -CommandT2: - Mov Tempo, BL - PushA - Call [DriverSetTempo] - PopA - Ret - -EndP CommandT - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandW ; Global volume slide! - Assume DS:Music - - Xor BH, BH - MovSX AX, Byte Ptr [DI+40h] - Mov BL, GlobalVolume - - Add AX, BX - - JNS CommandW1 - - Xor AL, AL - -CommandW1: - Cmp AL, 128 - JBE CommandW2 - - Mov AL, 128 - -CommandW2: - Mov GlobalVolume, AL - - Call RecalculateAllVolumes - Ret - -EndP CommandW - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CommandY - - Test Byte Ptr [DI], 4 - JZ CommandY5 - - Mov SI, [DI+24h] - - Mov BH, [DI+28h] ; AL = waveform - Cmp BH, 3 - JAE CommandY1 - - Mov BL, [DI+29h] ; Pos - Add BL, [DI+2Bh] ; Add speed. - Mov [DI+29h], BL ; Save value - - Mov AL, [FineSineData+BX] ; AL = -64 -> 64 - - Jmp CommandY2 - -CommandY1: ; Random panning make - ; speed the delay time. - Dec Byte Ptr [DI+29h] - JZ CommandY6 - JS CommandY6 - - Mov AL, [DI+2Ch] - Jmp CommandY2 - -CommandY6: - Mov BL, [DI+2Bh] - Mov [DI+29h], BL ; reset countdown. - - Call Random - And AL, 127 - Sub AL, 64 - - Mov [DI+2Ch], AL - -CommandY2: - IMul Byte Ptr [DI+2Ah] - SAL AX, 2 - Add AX, 80h - MovZX BX, AH - ; AH = panning change - Mov AL, [SI+2Bh] ; AL = panning - Cmp AL, 100 ; Surround? - JE CommandY5 - - Add AL, AH - JNS CommandY3 - - Xor AL, AL - -CommandY3: - Cmp AL, 64 - JBE CommandY4 - - Mov AL, 64 - -CommandY4: - Or Byte Ptr [SI], 2 ; Panning change - Mov [SI+2Ah], AL - -CommandY5: - Ret - -EndP CommandY - - +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +SlideTable DB 1, 4, 8, 16, 32, 64, 96, 128, 255 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Comment ~ + +Proc GetC5Speed + + Push BX + Push SI + Push BP + + Cmp Byte Ptr [DI+0Fh], 101 ; MIDI sample + JNE GetC5Speed1 + +; OK.. we have a MIDI sample +; Check whether the midi sample points to a valid sample +; And if so, use that sample's C5 speed. + Mov SI, [DS:DI+3] ; Not a note? + And SI, 0FFh + + Mov BP, [DS:DI+4] + And EBP, 0FFh + JZ GetC5Speed1 ; No sample? + + Add SI, SI + Mov BP, [ES:64710+EBP+EBP] + + Mov AX, [ES:BP+SI+40h] ; AL = note + ; AH = sample. + + Test AH, AH ; No sample? + JZ GetC5Speed1 + Mov SI, AX + ShR SI, 8 + + Add SI, SI + Mov SI, [ES:64910+SI] ; Sample offset + Test Byte Ptr [ES:SI+12h], 1 + JZ GetC5Speed1 + + Mov BX, SI + +GetC5Speed1: + Mov EAX, [ES:BX+3Ch] ; EAX = C5Spd + + Pop BP + Pop SI + Pop BX + + Ret + +EndP GetC5Speed + +~ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitVolumeEffect ; Done A, B, H + + Test Byte Ptr [DI+2], 44h + JNZ InitVolumeProcess + +InitVolumeEffectNoEffect: + Ret + +InitVolumeProcess: + Mov AL, [DI+5] + Mov AH, AL + + And AL, 7Fh + Sub AL, 65 + JC InitVolumeEffectNoEffect + + Test AH, 80h + JZ InitVolumeEffect1 + + Add AL, 60 + +InitVolumeEffect1: + Mov DL, 10 + Xor AH, AH + Div DL ; AL = effect number + ; AH = effect parameter + Mov [DI+0Ah], AL ; Store effect number + + ; Memory for effects A->D, (EFG)/H dont' share. + + ; Effects Ax and Bx (fine volume slide up and down) require immediate + ; handling. No flags required. (effect 0 and 1) + + ; Effects Cx, Dx, Ex, Fx (volume/pitch slides) require flag to be + ; set (effects 2->5) + + ; Effects Gx and Hx need init (handling) code + flags. + ; (effects 6 and 7). + + Test AH, AH + JZ InitVolumeEffectNoMemory + + Cmp AL, 4 + JB InitNormalMemory + + Cmp AL, 6 + JB InitSlideMemory + JA InitVolumeEffectNoMemory + + MovZX BX, AH + Mov DL, [SlideTable+BX-1] + + Test Byte Ptr [ES:2Ch], 20h ; Link command G? + JZ CommandGMemoryOldEffects + + Mov [DI+1Eh], DL + Jmp InitVolumeEffectNoMemory + +CommandGMemoryOldEffects: + Mov [DI+11h], DL + Jmp InitVolumeEffectNoMemory + +InitSlideMemory: + ShL AH, 2 + Mov [DI+11h], AH + Jmp InitVolumeEffectNoMemory + +InitNormalMemory: + Mov [DI+0Bh], AH + +InitVolumeEffectNoMemory: + Test Byte Ptr [DI], 4 ; Channel not on! + JZ InitVolumeEffect3 + Mov SI, [DI+24h] + + Cmp AL, 1 + JA InitVolumeEffect2 + Mov AL, [DI+0Bh] + JE InitVolumeEffectB + +InitVolumeEffectA: ; Fine volume slide up. + Add AL, [SI+22h] + Cmp AL, 64 + JBE InitVolumeEffectABEnd + Mov AL, 64 + Jmp InitVolumeEffectABEnd + +InitVolumeEffectB: ; Fine volume slide down + Sub AL, [SI+22h] + Neg AL + JNS InitVolumeEffectABEnd + Xor AL, AL + +InitVolumeEffectABEnd: + Jmp CommandD2 + +InitVolumeEffect2: + Or Word Ptr [DI], 100h + + Cmp AL, 6 + JA InitVolumeEffectH + JE InitVolumeEffectG + +InitVolumeEffectCDEF: +InitVolumeEffectEnd: + Ret + +InitVolumeEffect3: + Cmp AL, 7 ; Vibrato? + JNE InitVolumeEffectCDEF + +InitVolumeEffectH: + ShL AH, 2 + JZ InitVolumeEffectH1 + + Mov [DI+3Ah], AH + +InitVolumeEffectH1: + Test Byte Ptr [DI], 4 + JZ InitVolumeEffectCDEF + + Jmp InitVibrato + +InitVolumeEffectG: + Jmp InitCommandG11 + +EndP InitVolumeEffect + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VolumeCommandC + + Mov SI, [DI+24h] + Mov AL, [DI+0Bh] + Add AL, [SI+22h] + Cmp AL, 64 + JBE VolumeCommandC1 + + And Word Ptr [DI], Not 100h ; Turn off effect calling + Mov AL, 64 + +VolumeCommandC1: + Jmp CommandD2 + +EndP VolumeCommandC + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VolumeCommandD + + Mov SI, [DI+24h] + Mov AL, [SI+22h] + Sub AL, [DI+0Bh] + JNC VolumeCommandD1 + + And Word Ptr [DI], Not 100h ; Turn off effect calling + Xor AL, AL + +VolumeCommandD1: + Jmp CommandD2 + +EndP VolumeCommandD + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VolumeCommandE ; Pitch slide down + + Mov BX, [DI+11h] + And BX, 0FFh + ShL BX, 2 + Jmp CommandEChain + Ret + +EndP VolumeCommandE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VolumeCommandF + + Mov BX, [DI+11h] + And BX, 0FFh + ShL BX, 2 + Jmp CommandFChain + +EndP VolumeCommandF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VolumeCommandG + + Test Byte Ptr [DI], 16 + JZ VolumeCommandGEnd + + Mov BX, [DI+11h] + + Test Byte Ptr [ES:2Ch], 20h ; Command G linked? + JZ VolumeCommandGMemoryOldEffects + + Mov BX, [DI+1Eh] + +VolumeCommandGMemoryOldEffects: + And BX, 0FFh + JZ VolumeCommandGEnd + + ShL BX, 2 + + Mov SI, [DI+24h] + + Cmp Byte Ptr [DI+42h], 1 + JE VolumeCommandG1 + ; Slide down + Call PitchSlideDown + ; Check that frequency is above porta + ; to frequency. + Mov EAX, [SI+10h] + Cmp EAX, [DI+34h] + JA VolumeCommandG6 + +VolumeCommandG4: + Mov EAX, [DI+34h] + And Word Ptr [DI], Not (110h) ; Turn off calling + +VolumeCommandG3: + Mov [SI+10h], EAX + +VolumeCommandG6: + Mov [SI+14h], EAX + +VolumeCommandGEnd: + Ret + +VolumeCommandG1: ; Slide up! + Call PitchSlideUp + ; Check that + ; 1) Channel is on + ; 2) Frequency (set) is below porta to + ; frequency + Mov EAX, [SI+10h] + + Test Word Ptr [SI], 200h + JNZ VolumeCommandG5 + + Cmp EAX, [DI+34h] + JB VolumeCommandG6 + +VolumeCommandG5: + And Word Ptr [SI], Not 200h + Or Byte Ptr [DI], 4 ; Turn on. + Jmp VolumeCommandG4 + +EndP VolumeCommandG + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InitNoCommand4: + Test CH, 4 + JZ InitNoCommand10 ; Taken if the channel's off. + + Mov SI, [DI+24h] + + Cmp AL, 0FEh + JA InitNoCommand5 ; Noteoff + JNE InitNoCommandNoteFade + + And CH, Not 4 + + Cmp Byte Ptr [SI+36h], 100 + JE MIDINoteCut + + Test Byte Ptr CS:DriverFlags, 2 + JNZ MIDINoteCut + + Mov Word Ptr [SI], 200h + Jmp NoOldEffect + +MIDINoteCut: +; And CH, Not 4 + Or Word Ptr [SI], 200h + +InitNoCommand10: ; Jump point. + Jmp NoOldEffect ; InitNoCommand1 + +InitNoCommandNoteFade: + Or Byte Ptr [SI], 8 ; Note fade + + Jmp NoOldEffect ; InitNoCommand1 + +InitNoCommand5: + Or Byte Ptr [SI], 4 ; Note off + +; Cmp Byte Ptr [SI+22h], 0 ; Volume = 0??? +; JE InitNoCommand13 + Jmp InitNoCommand11 + +Proc InitNoCommand ; DS:DI points to CIT area. + + Assume DS:Music + Mov CL, [DI+2] ; CL = mask + Mov CH, [DI] ; CH = channel info. + + Test CL, 33h + JZ NoOldEffect ; InitCommand1 + + ; Note here! + ; Check for noteoff. + Mov AL, [DI+0Eh] + Cmp AL, 120 + JAE InitNoCommand4 + + Test CH, 4 + JZ InitNoCommand9 + + Mov SI, [DI+24h] + Test CL, 11h + JNZ InitNoCommand9 + + Mov BX, [SI+32h] + Cmp BX, [DI+03h] + JE NoOldEffect ; InitNoCommand1 + +InitNoCommand9: + Test CL, 44h + JZ NoVolumePorta + + Cmp Byte Ptr [DI+5], 193 + JB NoVolumePorta + Cmp Byte Ptr [DI+5], 202 + JA NoVolumePorta + + Test Byte Ptr [DI], 4 + JNZ InitVolumeEffect + +NoVolumePorta: + Call AllocateChannel +; JC InitNoCommand1 + JC NoOldEffect + ; Channel allocated. + ; put volume + Mov BX, [SI+34h] ; Sample offset. + Mov AL, [DI+22h] + Mov AH, AL + Mov [SI+21h], AX ; Volset + + Test Byte Ptr [ES:2Ch], 4 ; Instrument mode? + JNZ InitNoCommandNoDefaultPan + + Mov AL, [ES:BX+2Fh] + Test AL, AL + JNS InitNoCommandNoDefaultPan + + Mov AH, AL + And AX, 7F7Fh + Mov [DI+2Eh], AL + Mov [SI+2Ah], AX + +InitNoCommandNoDefaultPan: + Mov EAX, [ES:BX+3Ch] ; EAX = C5Spd +; Call GetC5Speed + + Xor EBX, EBX + Mov [SI+2Ch], EBX + Mov [SI+48h], BX + Mov [SI+4Ch], EBX + ; Calculate frequency. + Mov BL, [DI+0Eh] ; BL = note. + + Mul [PitchTable+4*EBX] + SHRD EAX, EDX, 16 + Mov [SI+10h], EAX + Mov [SI+14h], EAX + + Or CH, 4 + And CH, Not 16 + +InitNoCommand11: + Push CX + Call GetLoopInformation + Pop CX + +InitNoCommand1: + Test CL, 22h+44h + JZ InitNoCommand3 + + Mov AH, [ES:2Ch] ; Instrument mode and old effects? + And AH, 14h + Cmp AH, 14h + JNE NoOldEffect +; Test AH, 4 +; JZ NoOldEffect + + Test CL, 22h + JZ NoOldEffect + + MovZX EBX, Byte Ptr [DI+4] + Cmp BL, 0FFh + JE NoOldEffect + + Mov Word Ptr [SI+26h], 0400h + Mov BX, [ES:EBX*2+64710] ; Instrument offset. + + Call InitPlayInstrument + +NoOldEffect: + Test CL, 44h + JZ InitNoCommand7 + + Mov AL, [DI+5] + Cmp AL, 64 + JBE InitNoCommand8 ; Volume set... + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JNC InitNoCommand7 + +InitNoCommandPanning: ; Panning set! + Mov [DI], CH + + Sub AL, 128 + Call InitCommandX2 ; Destroys (SI), AX + +InitNoCommand7: + Test CL, 22h ; Instrument present? -> + ; Change volume + JZ InitNoCommand3 + + Mov BL, [DI+0Fh] ; Get instrument offset. + And BX, 0FFh + JZ InitNoCommand3 + + Add BX, BX + Mov BX, [ES:64910+BX] + + Mov AL, [ES:BX+13h] ; Default volume + +InitNoCommand8: + Mov [DI+22h], AL + + Test CH, 4 + JZ InitNoCommand3 + + Mov SI, [DI+24h] + + Mov AH, AL + Mov [SI+21h], AX + Or Byte Ptr [SI], 10h ; recalc volume + +InitNoCommand3: ; Randomise volume if required. + Test Byte Ptr [DI], 80h + Mov [DI], CH + JZ InitNoCommandEnd + + Push CX + Call ApplyRandomValues + Pop CX + +InitNoCommandEnd: + Jmp InitVolumeEffect + +EndP InitNoCommand + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandA + + Assume DS:Music + + Mov AL, [DS:DI+7] + And AX, 0FFh + JZ InitCommandA_1 + + Mov CX, CurrentSpeed + Sub CurrentTick, CX + Sub ProcessTick, CX + Add CurrentTick, AX + Add ProcessTick, AX + Mov CurrentSpeed, AX + +InitCommandA_1: + Jmp InitNoCommand + +EndP InitCommandA + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandB + Assume DS:Music + + MovZX AX, Byte Ptr [DI+7] + Cmp AX, CurrentOrder + JA InitCommandB1 + + Mov StopSong, 1 + +InitCommandB1: + Dec AX + Mov ProcessOrder, AX + Mov ProcessRow, 0FFFEh + + Jmp InitNoCommand + +EndP InitCommandB + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandC + + Assume DS:Music + + Cmp PatternLooping, 0 + JNE InitCommandC1 + + MovZX AX, Byte Ptr [DS:DI+7] + Mov BreakRow, AX + + Mov ProcessRow, 0FFFEh + +InitCommandC1: + Jmp InitNoCommand + +EndP InitCommandC + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandD + Assume DS:Music + + Call InitNoCommand + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandD1 + + Mov [DI+10h], AL + +InitCommandD1: + Test Byte Ptr [DI], 4 + JZ InitCommandD6 + + Mov SI, [DI+24h] + +InitCommandD7: ; Jmp point for Lxx + Mov AL, [DI+10h] + Or Byte Ptr [SI], 16 ; Recalc vol + + Mov AH, AL + Test AH, 0Fh + JZ InitCommandD2 + Test AH, 0F0h + JZ InitCommandD3 + And AX, 0FF0h + Cmp AH, 0Fh + JE InitCommandD5 + Cmp AL, 0F0h + JE InitCommandD4 + +InitCommandD6: + Ret + +InitCommandD2: ; Slide up. + ShR AL, 4 + Mov [DI+30h], AL + + Or Byte Ptr [DI], 1 + Cmp AL, 0Fh + JE InitCommandD8 + + Ret + +InitCommandD8: + Jmp CommandD + +InitCommandD3: ; Slide down + Neg AL + Mov [DI+30h], AL + + Or Byte Ptr [DI], 1 + Cmp AL, -15 + JE InitCommandD9 + + Ret + +InitCommandD9: + Jmp CommandD + +InitCommandD4: ; Slide down (fine) + Mov Byte Ptr [DI+30h], 0 + Mov AL, [SI+22h] + Sub AL, AH ; Slide down + JNS InitCommandD4_1 + + Xor AL, AL + +InitCommandD4_1: + Mov AH, AL + Mov [SI+21h], AX + Mov [DI+22h], AL + Ret + +InitCommandD5: ; Slide up (fine) + Mov Byte Ptr [DI+30h], 0 + + ShR AL, 4 + Mov AH, [SI+22h] + Add AL, AH + Cmp AL, 64 + JBE InitCommandD4_1 + + Mov AL, 64 + Jmp InitCommandD4_1 + +EndP InitCommandD + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandE + Assume DS:Music + + Call InitNoCommand + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandE2 + + Mov [DI+11h], AL + +InitCommandE2: + Test Byte Ptr [DI], 4 + JZ InitCommandE1 + + Mov SI, [DI+24h] + Mov AL, [DI+11h] + + Test AL, AL + JZ InitCommandE1 ; still no slide?? + + Mov AH, AL + And AH, 0F0h + Cmp AH, 0E0h + JB InitCommandE4 + + And AL, 0Fh + JZ InitCommandE1 + + Xor BX, BX + + Cmp AH, 0E0h + JE InitCommandE5 + + ShL AL, 2 + +InitCommandE5: + Mov BL, AL + Call PitchSlideDown + + Mov EAX, [SI+10h] + Mov [SI+14h], EAX + Ret + +InitCommandE4: + Xor AH, AH + ShL AX, 2 + Mov [DI+40h], AX + Or Byte Ptr [DI], 1 ; call update only if necess. + +InitCommandE1: + Ret + +EndP InitCommandE + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandF + Assume DS:Music + + Call InitNoCommand + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandF2 + + Mov [DI+11h], AL + +InitCommandF2: + Test Byte Ptr [DI], 4 + JZ InitCommandF1 + + Mov SI, [DI+24h] + ; OK.. now processing is dependent + ; upon slide mode. + + Mov AL, [DI+11h] + Test AL, AL + JZ InitCommandF1 ; still no slide?? + + Mov AH, AL + And AH, 0F0h + Cmp AH, 0E0h + JB InitCommandF4 + + And AL, 0Fh + JZ InitCommandF1 + + Xor BX, BX + + Cmp AH, 0E0h + JE InitCommandF5 + + ShL AL, 2 + +InitCommandF5: + Mov BL, AL + Call PitchSlideUp + + Mov EAX, [SI+10h] ; Update frequency set field. + Mov [SI+14h], EAX + Ret + +InitCommandF4: + Xor AH, AH + ShL AX, 2 + Mov [DI+40h], AX + Or Byte Ptr [DI], 1 ; call update only if necess. + +InitCommandF1: + Ret + +EndP InitCommandF + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InitCommandG15: + Jmp InitNoCommand + +Proc InitCommandG + Assume DS:Music + ; Check whether channel on/owned + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandG6 + + Test Byte Ptr [ES:2Ch], 20h ; Compatibility Gxx? + JZ InitCommandGNotOldEffects1 + + Mov [DI+1Eh], AL + Jmp InitCommandG6 + +InitCommandGNotOldEffects1: + Mov [DI+11h], AL + +InitCommandG6: + Test Byte Ptr [DI], 4 + JZ InitCommandG15 + +InitcommandG11: ; Jumped to from Lxx + Mov SI, [DI+24h] + + Mov CL, [DI+2] ; CL = mask. + + Test CL, 22h + JZ InitCommandG17 + ; Checking for change of + ; Sample or instrument. + Mov AL, [DI+0Fh] ; Sample + And EAX, 0FFh + JZ InitCommandG17 + + Dec AX + + Mov DX, [DI+3] + Test Byte Ptr [ES:2Ch], 20h + JNZ InitGXXCompat1 + +; Don't overwrite note if MIDI! + Cmp Byte Ptr [DI+0Fh], 101 + JE InitCommandG13 + + Cmp [SI+33h], DH ; Ins the same? + Mov [SI+32h], DX ; Nte + Ins. + + JNE InitCommandG19 + + Cmp AL, [SI+36h] + JNE InitCommandG16 + +InitCommandG17: + Jmp InitCommandG13 + +InitCommandGNoSample: + Mov Word Ptr [SI], 200h + And Byte Ptr [DI], Not 4 + Ret + +InitGXXCompat1: + Mov AL, [SI+36h] + Inc AX + Mov [DI+0Fh], AL + + Mov BX, [ES:EAX+EAX+64910] + Mov AX, [ES:BX+11h] + Add AL, AL + Mov [SI+24h], AL + + Jmp InitCommandG18 + +InitCommandG19: + Cmp AL, [SI+36h] ; Sample the same? + JE InitCommandG18 + +InitCommandG16: + Mov BX, [ES:EAX+EAX+64912] + Mov Byte Ptr [SI+1], 1 + ; Now to update sample info. + Mov [SI+34h], BX ; Offset of sample + Mov [SI+36h], AL ; Sample num. + + Xor EAX, EAX + + Mov [SI+1Ah], AX ; Reset vibrato.. + Mov [SI+0Bh], AL ; Reset loop direction. + Mov [SI+2Ch], EAX + Mov [SI+48h], AX + Mov [SI+4Ch], EAX + + Mov AX, [ES:BX+11h] + Add AL, AL + Mov [SI+24h], AL + + Test AH, 1 + JZ InitCommandGNoSample + + And AH, 2 ; 16 bit... + ShR AX, 8 + Mov [SI+18h], AX + + Call GetLoopInformation + Mov CL, [DI+2] + +InitCommandG18: + Test Byte Ptr [ES:2Ch], 4 ; Instrument/sample mode? + JZ InitCommandG14 + ; Now for instruments + + Mov Word Ptr [SI+26h], 0400h + MovZX EBX, Byte Ptr [DI+4] + + Mov BX, [ES:EBX*2+64710] ; Instrument offset. + + Push Word Ptr [SI] + Call InitPlayInstrument + Pop AX + + Test AL, 1 + JZ InitCommandGXXCompat3 + + And Word Ptr [SI], Not 100h + +InitCommandGXXCompat3: + + Mov AL, [ES:BX+18h] + Mul Byte Ptr [SI+24h] + ShR AX, 7 + Mov [SI+24h], AL + + Jmp InitCommandG14 + +InitCommandG13: + Test CL, 11h + JZ InitCommandG1 + + ; OK. Time to calc freq. +InitCommandG14: + Mov AL, [DI+0Eh] + Cmp AL, 119 + JBE InitCommandG5 + +InitCommandG12: + Test Byte Ptr [DI], 4 + JZ InitCommandG1 + + Cmp AL, 0FEh + JA InitCommandGNoteOff + JNE InitCommandGNoteFade + + And Byte Ptr [DI], Not 4 ; Note cut! + Mov Word Ptr [SI], 200h ; Cut. + Jmp InitCommandG1 + +InitCommandGNoteOff: + Or Byte Ptr [SI], 4 ; Note off + Push CX + Call GetLoopInformation + Pop CX + Jmp InitCommandG1 + +InitcommandGNoteFade: + Or Byte Ptr [SI], 8 + Jmp InitCommandG1 + +InitCommandG5: +; Don't overwrite note if MIDI! + Cmp Byte Ptr [DI+0Fh], 101 + JE InitCommandGMIDI2 + + Mov [SI+32h], AL + +InitCommandGMIDI2: + Xor EDX, EDX + Mov BX, [SI+34h] + Mov DL, AL + Mov EAX, [ES:BX+3Ch] ; BP = C5Spd +; Call GetC5Speed + + Mul [PitchTable+EDX*4] + SHRD EAX, EDX, 16 + + Mov [DI+34h], EAX + Or Byte Ptr [DI], 16 + +InitCommandG1: + Test CL, 44h + JZ InitCommandG2 +; JZ InitCommandG3 + + Mov AL, [DI+5] + + Cmp AL, 64 + JBE InitCommandG4 + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JNC InitCommandG2 + +InitCommandGPanning: + Sub AL, 128 + Call InitCommandX2 ; Panning set... + +InitCommandG2: + Test CL, 22h + JZ InitCommandG3 + + Mov BX, [SI+34h] ; Sample memory offset. + Mov AL, [ES:BX+13h] + +InitCommandG4: + Or Byte Ptr [SI], 16 ; recalc volume. + Mov AH, AL + Mov [SI+21h], AX + Mov [DI+22h], AL + +InitCommandG3: + Test Byte Ptr [DI], 16 ; Slide on??? + JZ InitCommandGEnd + + MovZX AX, Byte Ptr [DI+11h] ; Work out magnitude + dirn + + Test Byte Ptr [ES:2Ch], 20h ; Command G memory + JZ InitCommandGNotOldEffects2 + + Mov AL, [DI+1Eh] + +InitCommandGNotOldEffects2: + ShL AX, 2 + JZ PrepareCommandGEnd + + Mov [DI+40h], AX + + Mov AX, [DI+34h] + Mov DX, [DI+36h] ; Port freq. + + Cmp DX, [SI+16h] + JA InitCommandG8 + JB InitCommandG9 + Cmp AX, [SI+14h] + JA InitCommandG8 + JB InitCommandG9 + ; equal?!?!? + ; then don't update effect. + Jmp PrepareCommandGEnd + +InitCommandG8: + Mov Byte Ptr [DI+42h], 1 ; slide up + Jmp InitCommandG10 + +InitCommandG9: + Mov Byte Ptr [DI+42h], 0 ; slide down. + +InitCommandG10: + Test Word Ptr [DI], 100h + JNZ PrepareCommandGEnd + + Or Byte Ptr [DI], 1 ; Update effect if necess. + +PrepareCommandGEnd: + +InitCommandGEnd: ; Don't call volume + ; effects if it has a Gxx! + Test Word Ptr [DI], 100h + JNZ InitCommandGNoVolEffect + + Jmp InitVolumeEffect + +InitCommandGNoVolEffect: + Ret + +EndP InitCommandG + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandH + Assume DS:Music + + Test Byte Ptr Byte Ptr [DI+2], 11h + JZ InitCommandH2 + Cmp Byte Ptr [DI+3], 119 + JA InitCommandH2 + + Mov Byte Ptr [DI+39h], 0 + Mov Byte Ptr [DI+2Dh], 0 + +InitCommandH2: + Mov AL, [DI+7] + Mov AH, AL + And AX, 0FF0h ; AH = depth + + JZ InitCommandH4 + + ShR AL, 2 ; AL = speed. + JZ InitCommandH3 + + + Mov [DI+3Bh], AL + +InitCommandH3: + ShL AH, 2 ; Depth * 4 + JZ InitCommandH4 + + Test Byte Ptr [ES:2Ch], 10h + JZ InitCommandH5 + + Add AH, AH + +InitCommandH5: + Mov [DI+3Ah], AH + +InitCommandH4: + Call InitNoCommand + + Test Byte Ptr [DI], 4 + JZ InitCommandH1 + + Or Byte Ptr [DI], 1 ; Update mode. + + Jmp InitVibrato + +InitCommandH1: + Ret + +EndP InitCommandH + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandI + + Call InitNoCommand + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandI2 + + Mov [DI+13h], AL + +InitCommandI2: + Test Byte Ptr [DI], 4 + JZ InitCommandI1 + ; OK.. now to handle tremor + Or Byte Ptr [DI], 1 + + Mov AL, [DI+13h] + Mov AH, AL + And AL, 0Fh + ShR AH, 4 + + Test Byte Ptr [ES:2Ch], 16 + JZ InitCommandI3 + + Add AX, 101h + +InitCommandI3: + Mov [DI+40h], AX ; AL = Offtime, AH = ontime + + Jmp CommandI + +InitCommandI1: + Ret + +EndP InitCommandI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandJ + Assume DS:Music + + Call InitNoCommand + + Mov Word Ptr [DI+40h], 0 + Mov AL, [DI+7] + Test AL, AL + JNZ InitCommandJ2 + + Mov AL, [DI+14h] + Jmp InitCommandJ3 + +InitCommandJ2: + Mov [DI+14h], AL + +InitCommandJ3: + Test Byte Ptr [DI], 4 + JZ InitCommandJ1 + + Mov BL, AL + ShR AL, 4 + And EBX, 0Fh + + Or Byte Ptr [DI], 1 ; Update when channel on + + LEA DX, [EBX*4+PitchTable+240] + Mov BL, AL + Mov [DI+44h], DX + LEA DX, [EBX*4+PitchTable+240] + Mov [DI+42h], DX + +InitCommandJ1: + Ret + +EndP InitCommandJ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandK + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandK1 + + Mov [DI+10h], AL + +InitCommandK1: + Call InitNoCommand + + Test Byte Ptr [DI], 4 + JZ InitCommandKEnd + + Call InitVibrato + Call InitCommandD7 + Or Byte Ptr [DI], 2 ; Always update. + +InitCommandKEnd: + Ret + +EndP InitCommandK + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandL + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandL1 + + Mov [DI+10h], AL + +InitCommandL1: + Test Byte Ptr [DI], 4 + JZ InitCommandLEnd + + Call InitCommandG11 + Call InitCommandD7 + Or Byte Ptr [DI], 2 ; Always update. + +InitCommandLEnd: + Ret + +EndP InitCommandL + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandM + Assume DS:Music + + Call InitNoCommand + + Mov AL, [DI+7] ; AL = command val. + Cmp AL, 40h + JA InitCommandM3 + +InitCommandM2: + Test Byte Ptr [DI], 4 + JZ InitCommandM1 + + Mov SI, [DI+24h] + + Mov [SI+23h], AL + Or Byte Ptr [SI], 16 ; recalc volume + +InitCommandM1: + Mov [DI+2Fh], AL + +InitCommandM3: + Ret + +EndP InitCommandM + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandN + Assume DS:Music + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandN1 + + Mov [DI+16h], AL + +InitCommandN1: + Call InitNoCommand + + Mov AL, [DI+16h] + Mov AH, AL + Test AH, 0Fh + JZ InitCommandN2 + Test AH, 0F0h + JZ InitCommandN3 + And AX, 0FF0h + Cmp AH, 0Fh + JE InitCommandN4 + Cmp AL, 0F0h + JE InitCommandN5 + Ret + +InitCommandN2: + ShR AL, 4 + Mov [DI+40h], AL + Or Byte Ptr [DI], 2 ; Always update effect + Ret + +InitCommandN3: + Neg AL + Mov [DI+40h], AL + Or Byte Ptr [DI], 2 + Ret + +InitCommandN4: + ShR AL, 4 + Add AL, [DI+2Fh] + Cmp AL, 64 + JBE InitCommandN6 + Mov AL, 64 + Jmp InitCommandM2 + +InitCommandN5: + Mov AL, [DI+2Fh] + Sub AL, AH + JNC InitCommandN6 + Xor AL, AL + +InitCommandN6: + Jmp InitCommandM2 + + +EndP InitCommandN + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandO + Assume DS:Music + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandO2 + + Mov [DI+12h], AL + +InitCommandO2: + Call InitNoCommand + +; Mov AL, [DI+2] +; Test AL, 22h +; JNZ InitCommandO1 + +; Test AL, 11h +; Test Byte Ptr [DI+2], 11h + Test Byte Ptr [DI+2], 33h + JZ InitCommandO1 + + Cmp Byte Ptr [DI+0Eh], 120 + JAE InitCommandO1 + +InitCommandO3: + Test Byte Ptr [DI], 4 + JZ InitCommandO1 + + Xor EAX, EAX + Mov SI, [DI+24h] + Mov AH, [DI+1Bh] + Mov AL, [DI+12h] + ShL EAX, 8 + + Cmp EAX, [SI+44h] ; End of sample/end of sample loop + JB InitCommandO4 + + Test Byte Ptr [ES:2Ch], 16 + JZ InitCommandO1 + + Mov EAX, [SI+44h] + Dec EAX + +InitCommandO4: + Mov [SI+4Ch], EAX + Mov [SI+2Ch], EAX + + Xor AX, AX + Mov [SI+48h], AX + Ret + +InitCommandO1: + Ret + +EndP InitCommandO + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandP + Assume DS:Music + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandP1 + + Mov [DI+17h], AL + +InitCommandP1: + Call InitNoCommand + + Mov DL, [DI+2Eh] + Test Byte Ptr [DI], 4 + JZ InitCommandP8 + + Mov SI, [DI+24h] + Mov DL, [SI+2Bh] ; Pan set + +InitCommandP8: + Cmp DL, 100 ; Surround?? + JE InitCommandP7 + + Mov AL, [DI+17h] + Mov AH, AL + Test AH, 0Fh + JZ InitCommandP2 + Test AH, 0F0h + JZ InitCommandP3 + And AX, 0F00Fh + Cmp AL, 0Fh + JE InitCommandP4 + Cmp AH, 0F0h + JE InitCommandP5 + +InitCommandP7: + Ret + +InitCommandP2: + ShR AL, 4 + Neg AL + Mov [DI+40h], AL + Or Byte Ptr [DI], 2 ; Always update effect + Ret + +InitCommandP3: + Mov [DI+40h], AL + Or Byte Ptr [DI], 2 + Ret + +InitCommandP4: + ShR AH, 4 + Mov AL, DL + Sub AL, AH + JNC InitCommandP6 + Xor AL, AL + Jmp InitCommandX2 + +InitCommandP5: + Add AL, DL + Cmp AL, 64 + JBE InitCommandP6 + + Mov AL, 64 + +InitCommandP6: + Jmp InitCommandX2 + +EndP InitCommandP + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandQ + + Call InitNoCommand + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandQ1 + + Mov [DI+18h], AL + +InitCommandQ1: + Test Byte Ptr [DI], 4 + JZ InitCommandQ2 + + Or Byte Ptr [DI], 1 + + Test Byte Ptr [DI+2], 11h + JZ InitCommandQ3 + + Mov AL, [DI+18h] + And AL, 0Fh ; AL = retrig count + Mov [DI+33h], AL ; retrig countdown + +InitCommandQ2: + Ret + +InitCommandQ3: + Jmp CommandQ + +EndP InitCommandQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandR + Assume DS:Music + + Mov AL, [DI+7] + Mov AH, AL + And AX, 0FF0h ; AH = depth + JZ InitCommandR4 + + ShR AL, 2 ; AL = speed. + JZ InitCommandR3 + + Mov [DI+3Fh], AL + +InitCommandR3: + ShL AH, 1 + JZ InitCommandR4 + + Mov [DI+3Eh], AH + +InitCommandR4: + Call InitNoCommand + + Test Byte Ptr [DI], 4 + JZ InitCommandR1 + + Or Byte Ptr [DI], 1 ; Update mode. + + Jmp InitTremelo + +InitCommandR1: + Ret + +EndP InitCommandR + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +CommandSTable Label Word + DW Offset InitNoCommand ; 0 + DW Offset InitNoCommand ; 1 + DW Offset InitNoCommand ; 2 + DW Offset InitCommandS3x ; 3 - set vibrato waveform + DW Offset InitCommandS4x ; 4 - set tremelo waveform + DW Offset InitCommandS5x ; 5 - set panbrello waveform + DW Offset InitCommandS6x ; 6 - extra delay of x frames + DW Offset InitCommandS7x ; 7 - instrument functions + DW Offset InitCommandS8x ; 8 - set pan + DW Offset InitCommandS9x ; 9 - set surround + DW Offset InitCommandSAx ; A - Set high order offset + DW Offset InitCommandSBx ; B - loop control + DW Offset InitCommandSCx ; C - note cut + DW Offset InitCommandSDx ; D - note delay + DW Offset InitCommandSEx ; E - pattern delay + DW Offset InitCommandSFx ; F - MIDI Macro select + +CommandS7Table Label Word + DW Offset InitCommandS70 ; Past note cut + DW Offset InitCommandS71 ; Past note off + DW Offset InitCommandS72 ; Past note fade + DW Offset InitCommandS73 ; Set NNA to cut + DW Offset InitCommandS73 ; Set NNA to continue + DW Offset InitCommandS73 ; Set NNA to off + DW Offset InitCommandS73 ; Set NNA to fade + DW Offset InitCommandS77 ; Set volume envelope on + DW Offset InitCommandS78 ; Set volume envelope off + DW Offset InitCommandS79 ; Set panning envelope on + DW Offset InitCommandS7A ; Set panning envelope off + DW Offset InitCommandS7B ; Set pitch envelope on + DW Offset InitCommandS7C ; Set pitch envelope off + DW Offset InitNoCommand + DW Offset InitNoCommand + DW Offset InitNoCommand + +Proc InitCommandS + Assume DS:Music + + Mov AL, [DI+7] + Test AL, AL + JNZ @ICS1 + + Mov AL, [DI+1Ah] + +@ICS1: + Mov [DI+1Ah], AL + + Mov AH, AL + And AX, 0F00Fh + + Mov [DI+40h], AX ; Misc effects data. + + Mov BX, AX + ShR BX, 11 ; BX = (AH>>4)*2 + + Jmp [CommandSTable+BX] + +InitCommandS3x: + Cmp AL, 3 + JA @ICS2 + Mov [DI+38h], AL + +@ICS2: + Jmp InitNoCommand + +InitCommandS4x: + Cmp AL, 3 + JA @ICS3 + Mov [DI+3Ch], AL + +@ICS3: + Jmp InitNoCommand + +InitCommandS5x: + Cmp AL, 3 + JA @ICS4 + + Mov [DI+28h], AL + Mov Byte Ptr [DI+29h], 0 + +@ICS4: + Jmp InitNoCommand + +InitCommandS6x: + And AX, 0FFh + Add CurrentTick, AX + Add ProcessTick, AX + Jmp InitNoCommand + +InitCommandS7x: + Mov BL, AL + Add BL, BL + Jmp [CommandS7Table+BX] + +InitCommandS70: ; Past Note cut. + Call InitNoCommand + Mov SI, Offset SlaveChannelInformationTable + Mov CX, NumChannels + Mov AL, [DI+20h] + Or AL, 80h + +InitCommandS70_1: + Cmp AL, [SI+3Ah] + JNE @ICS5 + + Test Byte Ptr CS:DriverFlags, 2 + JZ @ICS70_2 + + Or Word Ptr [SI], 200h + Jmp @ICS5 + +@ICS70_2: + Mov Word Ptr [SI], 200h + +@ICS5: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ InitCommandS70_1 + + Ret + +InitCommandS71: ; Past note off + Call InitNoCommand + Mov AH, 4 + Jmp InitCommandS72_1 + +InitCommandS72: ; Past note fade. + Call InitNoCommand + Mov AH, 8 + +InitCommandS72_1: + Mov SI, Offset SlaveChannelInformationTable + Mov CX, NumChannels + Mov AL, [DI+20h] + Or AL, 80h + +InitCommandS72_2: + Cmp AL, [SI+3Ah] + JNE @ICS6 + + Or [SI], AH + + Push AX + Push CX + Call GetLoopInformation + Pop CX + Pop AX + +@ICS6: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ InitCommandS72_2 + + Ret + +InitCommandS73: + Push AX + Call InitNoCommand + Pop AX + + Test Byte Ptr [DI], 4 + JZ @ICS7 + + Sub AL, 3 + Mov SI, [DI+24h] + Mov [SI+3Bh], AL + +@ICS7: + Ret + +InitCommandS77: + Call InitNoCommand + Test Byte Ptr [DI], 4 + JZ @ICS9 + + Mov SI, [DI+24h] + And Word Ptr [SI], Not 1000h + +@ICS9: + Ret + +InitCommandS78: + Call InitNoCommand + Test Byte Ptr [DI], 4 + JZ @ICS9 + + Mov SI, [DI+24h] + Or Word Ptr [SI], 1000h + + Ret + +InitCommandS79: + Call InitNoCommand + Test Byte Ptr [DI], 4 + JZ @ICS9 + + Mov SI, [DI+24h] + And Word Ptr [SI], Not 2000h + + Ret + +InitCommandS7A: + Call InitNoCommand + Test Byte Ptr [DI], 4 + JZ @ICS10 + + Mov SI, [DI+24h] + Or Word Ptr [SI], 2000h + + Ret + +InitCommandS7B: + Call InitNoCommand + Test Byte Ptr [DI], 4 + JZ @ICS10 + + Mov SI, [DI+24h] + And Word Ptr [SI], Not 4000h + +@ICS10: + Ret + +InitCommandS7C: + Call InitNoCommand + Test Byte Ptr [DI], 4 + JZ @ICS10 + + Mov SI, [DI+24h] + Or Word Ptr [SI], 4000h + + Ret + +InitCommandS8x: + Mov AH, AL + ShL AH, 4 + Or AL, AH + And AX, 0FFh + Add AX, 2 + SHR AX, 2 + +InitCommandS8x_1: + Push AX + Call InitNoCommand + Pop AX + + Jmp InitCommandX2 + +InitCommandS9x: + Cmp AL, 1 + Mov AL, 100 + JE InitCommandS8x_1 + Jmp InitNoCommand + +InitCommandSAx: + Mov [DI+1Bh], AL + Jmp InitNoCommand + +InitCommandSBx: + Push AX + Call InitNoCommand + Pop AX + + Test AL, AL + JZ InitCommandSBx_1 + + Cmp Byte Ptr [DI+27h], 0 + JNE InitCommandSBx_2 + + Mov [DI+27h], AL + +InitCommandSBx_3: + MovZX AX, Byte Ptr [DI+26h] + + Dec AX + Mov ProcessRow, AX + Mov PatternLooping, 1 + + Ret + +InitCommandSBx_2: + Dec Byte Ptr [DI+27h] + JNZ InitCommandSBx_3 + Mov AX, CurrentRow + + Inc AX + Mov [DI+26h], AL + Ret + +InitCommandSBx_1: + Mov AX, CurrentRow + Mov [DI+26h], AL + Ret + +InitCommandSCx: + Or Byte Ptr [DI], 1 + Jmp InitNoCommand + +InitCommandSDx: + Or Byte Ptr [DI], 2 + Ret + +InitCommandSEx: + Cmp RowDelayOn, 0 + JNE @ICS8 + + Inc AX + Mov AH, 1 + Mov [Word Ptr RowDelay], AX + +@ICS8: + Jmp InitNoCommand + +InitCommandSFx: ; Set MIDI Macro + Mov [DI+1Fh], AL + Jmp InitNoCommand + +EndP InitCommandS + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandT + Assume DS:Music + + Mov AL, [DI+7] + Test AL, AL + JZ InitCommandT2 + + Mov [DI+19h], AL + +InitCommandT2: + Mov AL, [DI+19h] + +InitCommandT3: + Cmp AL, 20h + JB InitCommandT1 + + Mov Tempo, AL + Call Music_InitTempo + Jmp InitNoCommand + +InitCommandT1: + Call InitNoCommand + Or Byte Ptr [DI], 2 ; Update mode + Ret + +EndP InitCommandT + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandU + Assume DS:Music + + Test Byte Ptr Byte Ptr [DI+2], 11h + JZ InitCommandU2 + + Mov Byte Ptr [DI+39h], 0 + Mov Byte Ptr [DI+2Dh], 0 + +InitCommandU2: + Mov AL, [DI+7] + Mov AH, AL + And AX, 0FF0h ; AH = depth + + Test AL, AL + JZ InitCommandU3 + + ShR AL, 2 ; AL = speed. + + Mov [DI+3Bh], AL + +InitCommandU3: + Test AH, AH + JZ InitCommandU4 + + Test Byte Ptr [ES:2Ch], 16 + JZ InitCommandU5 + + Add AH, AH + +InitCommandU5: + Mov [DI+3Ah], AH + +InitCommandU4: + Call InitNoCommand + + Test Byte Ptr [DI], 4 + JZ InitCommandU1 + + Or Byte Ptr [DI], 1 ; Update mode. + + Jmp InitVibrato + +InitCommandU1: + Ret + +EndP InitCommandU + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandV + Assume DS:Music + + Mov AL, [DI+7] + Cmp AL, 80h + JA InitCommandV1 + + Mov GlobalVolume, AL + Call RecalculateAllVolumes + +InitCommandV1: + Jmp InitNoCommand + +EndP InitCommandV + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandW ; Global volume slides! + Assume DS:Music + + Call InitNoCommand + + Mov AL, [DI+7] + Test AL, AL + JNZ InitCommandW1 + + Mov AL, [DI+1Ch] + Jmp InitCommandW2 + +InitCommandW1: + Mov [DI+1Ch], AL + +InitCommandW2: + Mov AH, AL + And AX, 0F00Fh + JZ InitCommandW3 + Test AH, AH + JZ InitCommandW4 + Test AL, AL + JZ InitCommandW5 + Cmp AH, 0F0h + JE InitCommandW6 + Cmp AL, 0Fh + JE InitCommandW8 + + Ret + +InitCommandW4: + Neg AL + Mov [DI+40h], AL + Or Byte Ptr [DI], 2 + Ret + +InitCommandW5: + ShR AH, 4 + Mov [DI+40h], AH + Or Byte Ptr [DI], 2 + Ret + +InitCommandW6: + Mov AH, GlobalVolume + Sub AH, AL + JNC InitCommandW7 + + Xor AH, AH + +InitCommandW7: + Mov GlobalVolume, AH + + Call RecalculateAllVolumes + Ret + +InitCommandW8: + ShR AH, 4 + Mov AL, GlobalVolume + Add AL, AH + JNS InitCommandW9 + + Mov AL, 128 + +InitCommandW9: + Mov GlobalVolume, AL + + Call RecalculateAllVolumes + Ret + +InitCommandW3: + Ret + +EndP InitCommandW + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandX + Assume DS:Music + + Call InitNoCommand + + MovZX AX, Byte Ptr [DI+7] ; AL = command val. + Add AX, 2 + SHR AX, 2 + +InitCommandX2: + Test Byte Ptr [DI], 4 + JZ InitCommandX1 + + Mov SI, [DI+24h] + Mov AH, AL + Mov [SI+2Ah], AX + + Or Byte Ptr [SI], 64+2 ; Recalculate pan + +InitCommandX1: + Mov [DI+2Eh], AL + Ret + +EndP InitCommandX + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandY + Assume DS:Music + + Mov AL, [DI+7] + Mov AH, AL + And AX, 0FF0h ; AH = depth + JZ InitCommandY4 + + ShR AL, 4 + JZ InitCommandY3 + + Mov [DI+2Bh], AL + +InitCommandY3: + ShL AH, 1 + JZ InitCommandY4 + + Mov [DI+2Ah], AH + +InitCommandY4: + Call InitNoCommand + + Test Byte Ptr [DI], 4 + JZ InitCommandY1 + + Or Byte Ptr [DI], 1 ; Update mode. + + Jmp CommandY + +InitCommandY1: + Ret + +EndP InitCommandY + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitCommandZ ; Macros start at 120h, 320h + + Call InitNoCommand + + Mov BL, [DI+7] + Mov SI, [DI+24h] + + Test BL, BL + JS InitCommandZ1 + +; Test SI, SI +; JZ InitCommandZ2 + + Mov BL, [DI+1Fh] ; 0->7Fh + And BX, 0Fh ; BX = SFx number + ShL BX, 5 + Add BX, 120h + Jmp MIDITranslate + +InitCommandZ1: ; Macros! + And BX, 7Fh + ShL BX, 5 ; BX = (xx-80h)*20h + Add BX, 320h + Jmp MIDITranslate + +InitCommandZ2: + Ret + +EndP InitCommandZ + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Proc NoCommand ; DS:DI points to CIT Area + + Ret + +EndP NoCommand + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandD + Assume DS:Music + + Mov SI, [DI+24h] + Mov AL, [DI+30h] + Add AL, [SI+22h] ; Volset. + JS CommandD1 + + Cmp AL, 64 + JBE CommandD2 + + And Byte Ptr [DI], Not 1 + + Mov AL, 64 + Jmp CommandD2 + +CommandD1: + And Byte Ptr [DI], Not 1 + Xor AL, AL + +CommandD2: + Mov [SI+21h], AL + Mov [SI+22h], AL + Mov [DI+22h], AL + Or Byte Ptr [SI], 16 ; Recalc vol + Ret + +EndP CommandD + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandE + Assume DS:Music + + Mov BX, [DI+40h] + +CommandEChain: + Mov SI, [DI+24h] + Call PitchSlideDown + + Mov EAX, [SI+10h] + Mov [SI+14h], EAX + + Ret + +EndP CommandE + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandF + Assume DS:Music + + Mov BX, [DI+40h] + +CommandFChain: + Mov SI, [DI+24h] + Call PitchSlideUp + + Mov EAX, [SI+10h] + Mov [SI+14h], EAX + + Ret + +EndP CommandF + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandG + + Test Byte Ptr [DI], 16 + JZ CommandGEnd + + Mov BX, [DI+40h] + Mov SI, [DI+24h] + Cmp Byte Ptr [DI+42h], 1 + JE CommandG1 + ; Slide down + Call PitchSlideDown + ; Check that frequency is above porta + ; to frequency. + Mov EAX, [SI+10h] + Cmp EAX, [DI+34h] + JA CommandG6 + +CommandG4: + Mov EAX, [DI+34h] + And Byte Ptr [DI], Not (3 Or 16) ; Turn off calling + +CommandG3: + Mov [SI+10h], EAX + +CommandG6: + Mov [SI+14h], EAX + +CommandGEnd: + Ret + +CommandG1: ; Slide up! + Call PitchSlideUp + ; Check that + ; 1) Channel is on + ; 2) Frequency (set) is below porta to + ; frequency + Mov EAX, [SI+10h] + + Test Word Ptr [SI], 200h + JNZ CommandG5 + + Cmp EAX, [DI+34h] + JB CommandG6 + +CommandG5: +; Or Byte Ptr [SI], 1 +; And Byte Ptr [SI+1], Not 2 + And Word Ptr [SI], Not 200h + Or Byte Ptr [DI], 4 ; Turn on. + Jmp CommandG4 + +EndP CommandG + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InitVibrato: + Test Byte Ptr [ES:2Ch], 10h + JZ CommandH + + Mov SI, [DI+24h] + Or Byte Ptr [SI], 32 ; Freq change... + Mov AL, [DI+2Dh] + Jmp CommandH5 + +Proc CommandH + + Mov SI, [DI+24h] + Or Byte Ptr [SI], 32 ; Freq change... + + Mov BL, [DI+39h] + Add BL, [DI+3Bh] ; Add speed. + Mov [DI+39h], BL ; Save value + Mov BH, [DI+38h] ; AL = waveform + + Cmp BH, 3 + JE CommandH1 + + Mov AL, [FineSineData+BX] ; AL = -64 -> 64 + + Jmp CommandH2 + +CommandH1: ; Random. + Call Random + And AL, 127 + Sub AL, 64 + +CommandH2: + Mov [DI+2Dh], AL ; Save last vibrato. + +CommandH5: + IMul Byte Ptr [DI+3Ah] + SAL AX, 2 + Add AX, 80h + + Test Byte Ptr [ES:2Ch], 16 + JZ CommandH9 + + Neg AH + +CommandH9: + MovZX BX, AH + ; AH = EEx/FEx command value + Test AH, AH + JS CommandH4 + JNS CommandH3 + Ret + +CommandH3: + Jmp PitchSlideUp + +CommandH4: + Neg BL + Jmp PitchSlideDown + Ret + +EndP CommandH + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandI + + Mov SI, [DI+24h] + + Or Byte Ptr [SI], 16 ; recalc volume + + Dec Byte Ptr [DI+31h] + JS CommandI2 + JZ CommandI2 + +CommandI1: + Cmp Byte Ptr [DI+32h], 1 + JE CommandI3 + + Mov Byte Ptr [SI+21h], 0 + +CommandI3: + Ret + +CommandI2: + Xor Byte Ptr [DI+32h], 1 + MovZX BX, Byte Ptr [DI+32h] + Mov AL, [DI+40h+BX] + Mov [DI+31h], AL + Jmp CommandI1 + +EndP CommandI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandJ + Assume DS:Music + + Mov SI, [DI+24h] + Mov BX, [DI+40h] + + Or Byte Ptr [SI], 32 + + Add BX, 2 + Cmp BX, 6 + JB CommandJ1 + + Mov Word Ptr [DI+40h], 0 + Ret + +CommandJ1: + Push DI + + Mov [DI+40h], BX + Mov DI, [DI+BX+40h] ; DI points to freq mult. + + Mov EAX, [SI+10h] + Mul DWord Ptr [DI] + + Test EDX, 0FFFF0000h + JNZ CommandJ2 + + SHRD EAX, EDX, 16 + Mov [SI+10h], EAX + + Pop DI + Ret + +CommandJ2: + Xor EAX, EAX + Mov [SI+10h], EAX + + Pop DI + Ret + +EndP CommandJ + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandK + + Call CommandH + Call CommandD + Ret + +EndP CommandK + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandL + + Test Byte Ptr [DI], 16 + JZ CommandL1 + + Call CommandG + Or Byte Ptr [DI], 1 + +CommandL1: + Call CommandD + Ret + +EndP CommandL + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandN + + Mov AL, [DI+2Fh] + Add AL, [DI+40h] + JNS CommandN1 + + Xor AL, AL + Jmp InitCommandM2 + +CommandN1: + Cmp AL, 64 + JBE CommandN2 + + Mov AL, 64 + +CommandN2: + Jmp InitCommandM2 + +EndP CommandN + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandP + + Mov AL, [DI+2Eh] + Test Byte Ptr [DI], 4 + JZ CommandP3 + + Mov SI, [DI+24h] + Mov AL, [SI+2Bh] ; Pan set + +CommandP3: + Add AL, [DI+40h] + JNS CommandP1 + + Xor AL, AL + Jmp InitCommandX2 + +CommandP1: + Cmp AL, 64 + JBE CommandP2 + + Mov AL, 64 + +CommandP2: + Jmp InitCommandX2 + +EndP CommandP + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandQ + + Dec Byte Ptr [DI+33h] + JS CommandQ1 + JZ CommandQ1 + + Ret + +CommandQ1: ; OK... reset counter. + Mov BL, [DI+18h] + Mov BH, BL + And BX, 0F00Fh + Mov [DI+33h], BL ; retrig count done. + + Mov SI, [DI+24h] + + Test Byte Ptr DriverFlags, 2 ; Hiqual? + JZ CommandQNoHiQual + + Push ES + Push DI + + Test Byte Ptr [ES:2Ch], 4 ; Instrument mode? + + Push DS + Pop ES + + JNZ CommandQHiqualInstruments + +CommandQHiqualSamples: + Lea DI, [SI+64*SLAVECHANNELSIZE] + + Mov CX, SLAVECHANNELSIZE/4 + Rep MovsD + Or Byte Ptr [DI-SLAVECHANNELSIZE+1], 2h ; Cut + Or Byte Ptr [DI-SLAVECHANNELSIZE+3Ah], 80h ; Disowned + Sub SI, SLAVECHANNELSIZE + + Pop DI + Jmp CommandQHiqualEnd + +CommandQHiqualInstruments: + Mov DI, Offset SlaveChannelInformationTable + Mov CX, NumChannels + +CommandQFindChannel: + Test Byte Ptr [DI], 1 + JZ CommandQHiqualCopy + + Add DI, SLAVECHANNELSIZE + Loop CommandQFindChannel + Pop DI + Jmp CommandQHiqualEnd + +CommandQHiqualCopy: + Mov CX, SLAVECHANNELSIZE/4 + Rep MovsD + + Or Byte Ptr [SI-SLAVECHANNELSIZE+1], 2h ; Cut + Or Byte Ptr [SI-SLAVECHANNELSIZE+3Ah], 80h ; Disowned + LEA SI, [DI-SLAVECHANNELSIZE] + Pop DI + + Mov [DI+24h], SI + +CommandQHiqualEnd: + Pop ES + +CommandQNoHiQual: + Xor EAX, EAX + Mov [SI+2Ch], EAX + Mov [SI+48h], AX + Mov [SI+4Ch], EAX + + Or Word Ptr [SI], 540h + + Mov AL, [SI+22h] + ShR BX, 11 + + Jmp [RetrigOffsets+BX] + +CommandQ_0: + Ret + +CommandQ_1: + Dec AL + Jmp CommandQCheckLow + +CommandQ_2: + Sub AL, 2 + Jmp CommandQCheckLow + +CommandQ_3: + Sub AL, 4 + Jmp CommandQCheckLow + +CommandQ_4: + Sub AL, 8 + Jmp CommandQCheckLow + +CommandQ_5: + Sub AL, 16 + Jmp CommandQCheckLow + +CommandQ_6: + ShL AL, 1 + Mov BL, 3 + Div BL + Jmp CommandQEnd + +CommandQ_7: + ShR AL, 1 + Jmp CommandQEnd + +CommandQ_8: + Ret + +CommandQ_9: + Inc AX + Jmp CommandQCheckHigh + +CommandQ_A: + Add AL, 2 + Jmp CommandQCheckHigh + +CommandQ_B: + Add AL, 4 + Jmp CommandQCheckHigh + +CommandQ_C: + Add AL, 8 + Jmp CommandQCheckHigh + +CommandQ_D: + Add AL, 16 + Jmp CommandQCheckHigh + +CommandQ_E: + Mov AH, AL + Add AL, AL + Add AL, AH + ShR AL, 1 + Jmp CommandQCheckHigh + +CommandQ_F: + ShL AL, 1 + Jmp CommandQCheckHigh + + +CommandQCheckLow: + JNS CommandQEnd + Xor AL, AL + Jmp CommandQEnd + +CommandQCheckHigh: + Cmp AL, 64 + JBE CommandQEnd + Mov AL, 64 + +CommandQEnd: + Mov [SI+21h], AL + Mov [SI+22h], AL + Mov [DI+22h], AL + Or Byte Ptr [SI], 16 ; recalc volume flag + + Cmp Byte Ptr [DI+0Fh], 101 ; MIDI sample + JNE CommandQNoMidi + + Mov BX, MIDICOMMAND_STOPNOTE + Call MIDITranslate + +CommandQNoMidi: + Ret + +EndP CommandQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InitTremelo: + Test Byte Ptr [ES:2Ch], 10h + JZ CommandR + + Mov SI, [DI+24h] + Or Byte Ptr [SI], 64 ; Volume change... + Mov AL, [DI+23h] + Jmp CommandR2 + +Proc CommandR + + Mov SI, [DI+24h] + Or Byte Ptr [SI], 16 ; Volume change + + Mov BL, [DI+3Dh] + Add BL, [DI+3Fh] ; Add speed. + Mov [DI+3Dh], BL ; Save value + Mov BH, [DI+3Ch] ; AL = waveform + + Cmp BH, 3 + JE CommandR1 + + Mov AL, [FineSineData+BX] ; AL = -64 -> 64 + + Jmp CommandR5 + +CommandR1: ; Random. + Call Random + And AL, 127 + Sub AL, 64 + +CommandR5: + Mov [DI+23h], AL ; Save last tremelo + +CommandR2: + IMul Byte Ptr [DI+3Eh] + SAL AX, 2 + Add AX, 80h + MovZX BX, AH + ; AH = volume change + Mov AL, [SI+21h] ; AL = vol. + Add AL, AH + JNS CommandR3 + + Xor AL, AL + +CommandR3: + Cmp AL, 64 + JBE CommandR4 + + Mov AL, 64 + +CommandR4: + Mov [SI+21h], AL + Ret + +EndP CommandR + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandS ; Have to handle SDx, SCx + Assume DS:Music + + Mov AX, [DI+40h] ; AH = command, AL = value. + Cmp AH, 0D0h + JE CommandS1 + + Cmp AH, 0C0h + JE CommandS3 + +CommandS4: + Ret + +CommandS3: + Test Byte Ptr [DI], 4 + JZ CommandS4 + + Dec Byte Ptr [DI+40h] + JZ CommandS5 + JS CommandS5 + + Ret + +CommandS5: + Mov SI, [DI+24h] ; Note cut. + + Mov AL, [DI] + + And AL, Not 4 + Mov [DI], AL + + Cmp Byte Ptr [SI+36h], 100 + JE CommandS7 + + Test Byte Ptr CS:DriverFlags, 2 + JNZ CommandS7 + + Mov Word Ptr [SI], 200h + Ret + +CommandS7: + Or Word Ptr [SI], 200h + Ret + +CommandS1: + Dec Byte Ptr [DI+40h] + JS CommandS2 + JZ CommandS2 + + Ret + +CommandS2: + And Byte Ptr [DI], Not 3 + Call InitNoCommand + + Or Byte Ptr [DI], 64 + + MovZX BX, Byte Ptr [DI+20h] ; Check whether chn + ; is on + Test Byte Ptr [ES:BX+40h], 80h + JZ CommandS6 + + Test Byte Ptr [DI], 32 + JNZ CommandS6 + + Test Byte Ptr [DI], 4 + JZ CommandS6 ; Channel was off. + + Mov SI, [DI+24h] + Or Byte Ptr [SI+1], 8 + +CommandS6: + Ret + +EndP CommandS + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandT + Assume DS:Music + + Mov AL, [DI+19h] + Mov BL, Tempo + Xor AH, AH + Xor BH, BH + + Test AL, 0F0h + JZ CommandT1 + ; Slide up + Add BX, AX + Sub BX, 10h + Cmp BX, 0FFh + JBE CommandT2 + Mov BL, 0FFh + Jmp CommandT2 + +CommandT1: ; Slide down + Sub BX, AX + Cmp BX, 20h + JGE CommandT2 + + Mov BL, 20h + +CommandT2: + Mov Tempo, BL + PushA + Call [DriverSetTempo] + PopA + Ret + +EndP CommandT + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandW ; Global volume slide! + Assume DS:Music + + Xor BH, BH + MovSX AX, Byte Ptr [DI+40h] + Mov BL, GlobalVolume + + Add AX, BX + + JNS CommandW1 + + Xor AL, AL + +CommandW1: + Cmp AL, 128 + JBE CommandW2 + + Mov AL, 128 + +CommandW2: + Mov GlobalVolume, AL + + Call RecalculateAllVolumes + Ret + +EndP CommandW + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CommandY + + Test Byte Ptr [DI], 4 + JZ CommandY5 + + Mov SI, [DI+24h] + + Mov BH, [DI+28h] ; AL = waveform + Cmp BH, 3 + JAE CommandY1 + + Mov BL, [DI+29h] ; Pos + Add BL, [DI+2Bh] ; Add speed. + Mov [DI+29h], BL ; Save value + + Mov AL, [FineSineData+BX] ; AL = -64 -> 64 + + Jmp CommandY2 + +CommandY1: ; Random panning make + ; speed the delay time. + Dec Byte Ptr [DI+29h] + JZ CommandY6 + JS CommandY6 + + Mov AL, [DI+2Ch] + Jmp CommandY2 + +CommandY6: + Mov BL, [DI+2Bh] + Mov [DI+29h], BL ; reset countdown. + + Call Random + And AL, 127 + Sub AL, 64 + + Mov [DI+2Ch], AL + +CommandY2: + IMul Byte Ptr [DI+2Ah] + SAL AX, 2 + Add AX, 80h + MovZX BX, AH + ; AH = panning change + Mov AL, [SI+2Bh] ; AL = panning + Cmp AL, 100 ; Surround? + JE CommandY5 + + Add AL, AH + JNS CommandY3 + + Xor AL, AL + +CommandY3: + Cmp AL, 64 + JBE CommandY4 + + Mov AL, 64 + +CommandY4: + Or Byte Ptr [SI], 2 ; Panning change + Mov [SI+2Ah], AL + +CommandY5: + Ret + +EndP CommandY + + diff --git a/IT_MDATA.ASM b/it_mdata.s similarity index 97% rename from IT_MDATA.ASM rename to it_mdata.s index e4e01cc..02ca425 100644 --- a/IT_MDATA.ASM +++ b/it_mdata.s @@ -1,3652 +1,3657 @@ - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment SongData PARA Public 'Data' - -Org 0 - - DB "IMPM", 36 Dup (0) - DW 0, 0, 9, 0 - DB 128, 30h, 6, 125, 128, 0 - DW 0, 0, 0, 0, 0 - DB 64 Dup (32), 64 Dup (64), 64 Dup (0) - - DB 256 Dup (0FFh) ; 512 bytes - -; Instrument headers, unrolled simply because TASM runs out of memory otherwise - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 4 Dup (0) - -; Sample headers - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - - - DW 400 Dup (0) - -OffsetCounter = 512 - -Rept 100 - DW OffsetCounter - OffsetCounter = OffsetCounter + 554 -EndM - -Rept 100 - DW OffsetCounter - OffsetCounter = OffsetCounter + 80 -EndM - - DW 65114 - -MIDISampleHeader Label Byte - DB "MIDI", 13 Dup (0), 64, 11h, 64, "MIDI Instrument", 13 Dup (0) - DD 8, 0, 8, 44100, 0, 0 - DW 1 - - DW SongData+4075 - DD 0 - - DB 22 Dup (0) - DW (128+16+9)*32/2 Dup (0) -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End - + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +;Segment SongData PARA Public 'Data' +section .data +extern SongData +SongData: + DB "IMPM", 36 Dup (0) + DW 0, 0, 9, 0 + DB 128, 30h, 6, 125, 128, 0 + DW 0, 0, 0, 0, 0 + DB 64 Dup (32), 64 Dup (64), 64 Dup (0) + + DB 256 Dup (0FFh) ; 512 bytes + +; Instrument headers, unrolled simply because TASM runs out of memory otherwise + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 4 Dup (0) + +; Sample headers + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + + + DW 400 Dup (0) + +%if 0 +OffsetCounter = 512 + +Rept 100 + DW OffsetCounter + OffsetCounter = OffsetCounter + 554 +EndM + +Rept 100 + DW OffsetCounter + OffsetCounter = OffsetCounter + 80 +EndM +%endif + +%include "gen/it_mdata.s" + + DW 65114 + +MIDISampleHeader:; Label Byte + DB "MIDI", 13 Dup (0), 64, 11h, 64, "MIDI Instrument", 13 Dup (0) + DD 8, 0, 8, 44100, 0, 0 + DW 1 + + ;DW SongData+4075 + DW 4075 + DD 0 + + DB 22 Dup (0) + DW (128+16+9)*32/2 Dup (0) +;EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +;End + diff --git a/IT_MMTSR.ASM b/it_mmtsr.s similarity index 95% rename from IT_MMTSR.ASM rename to it_mmtsr.s index 7aebdcd..2cfec75 100644 --- a/IT_MMTSR.ASM +++ b/it_mmtsr.s @@ -1,1028 +1,1028 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ MMTSR Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - .386 - -include switch.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Extrn E_AllocateEMS:Far - Extrn E_GetEMSPageFrame:Far - Extrn E_ReleaseEMS:Far - Extrn E_MapEMSMemory:Far - Extrn Music_Stop:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global MMTSR_InstallMMTSR:Far - Global MMTSR_UninstallMMTSR:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment MMTSR PARA Public USE16 'Code' - Assume CS:MMTSR, DS:MMTSR - -CREATENEWLOGFILE EQU 0 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -MAX8 equ 0f8H ; decompression constants -MAX16 equ 0fff0h - -BBsize equ 0 ; stucture of MMCMP BigBlocks header -BBcmpsize equ 4 ; (relative offset) -BBxorchk equ 8 -BBnblk equ 12 -BBflag equ 14 -BBntab equ 16 -BBsnbit equ 18 -BBheadersize equ 20 - -InstalledFromIT DB 0 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Proc MMTSR_InstallMMTSR Far - - Push CS - Push CS - Pop DS - Pop ES - - Trace " - Determining if MMTSR is already installed" - - mov ax,4370h - int 21h ; check if already installed - - cmp eax,4352697ah - je @error ; if installed, don't install it again - -@notinstalled: - Trace " - Allocating 64kb of EMS memory for MMTSR decoding" - - StC - Mov EAX, 65536 ; 64k - Call E_AllocateEMS - - Test AX, AX - JZ @error ; AX = handle, 0 if error. - -@emsdriver: - Mov _memhandle, AX - Call E_GetEMSPageFrame - Mov BaseSeg, AX - -@fixups: - Trace " - Installing new INT21h handler" - - mov si,offset _inbuf+2 - mov [si],ax - mov dx,Bufsize - shr dx,4 - add ax,dx - mov [si+4],ax - add ax,20h - mov [si+8],ax - add ax,110h - mov [si+12],ax - add ax,dx - mov [si+16],ax - - mov ax,3521h - int 21h - mov word ptr [_old21],bx ; get old INT 21h handler - mov word ptr [_old21+2],es - mov dx,offset @new21 - mov ax,2521h - int 21h ; set new INT 21h handler - - mov byte ptr [_actived],1 ; MMTSR is ACTIVE! - - Mov InstalledFromIT, 1 - -@error: -@error0: ; print message at offset DS:DX onto screen - Ret - -EndP MMTSR_InstallMMTSR - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Proc MMTSR_UninstallMMTSR Far - - Push CS - Pop DS - - Cmp InstalledFromIT, 0 - JE MMTSR_UninstallMMTSR1 - - Mov DX, Word Ptr [_old21] ; Reset handler. - Mov DS, Word Ptr [_old21+2] - Mov AX, 2521h - Int 21h - - Mov AX, CS:_memhandle - Call E_ReleaseEMS - -MMTSR_UninstallMMTSR1: - Ret - -EndP MMTSR_UninstallMMTSR - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - - -;**************************************************************************** -; NEW INTERRUPT 21 HANDLER -;**************************************************************************** - -@activate: - and al,1 - mov byte ptr cs:[_actived],al - IRet - -@installcheck: - mov eax,4352697ah - iret -@new21: ; <<<<---------- INT 21 starts here - cmp ax,4370h - je short @installcheck - cmp ax,4371h - je short @activate - cmp ax,4372h - je short @activate - cmp byte ptr cs:[_actived],1 - jne short @noopen ; originaly intercepts 'open' only... - cmp ah,3dh ; now stands for 'do old interrupt' - je short @intercept - cmp ah,3eh ; MMTSR intercepts 'open file' calls, and - jne short @noopen ; close file if the handle is the - cmp bx,cs:_modulehandle ; temporary decompressed module handle - je short @intercept - -@noopen: - jmp dword ptr cs:[_old21] ; Chain to old interrupt - -@intercept: - mov byte ptr cs:[_actived],0 ; desactivate MMTSR while running - mov byte ptr cs:[_function],ah - mov word ptr cs:[_oldstack],sp ; une hook's stack - mov word ptr cs:[_oldstack+2],ss - - pushf - - Call DWord Ptr [CS:_old21] - - push es bx ax - les bx,cs:[_oldstack] ; - pushf ; - pushf ; preserve "returned from interrupt" flags - pop ax ; and set IF!! ;) - or ah,2 ; - mov word ptr es:[bx+4],ax ; - popf ; "or" modifies flags... - pop ax bx es ; - jc @eoi ; I/O error - cmp cs:[_function],3dh - je short @open - - ; close temporary file and delete it -@close: - cmp byte ptr cs:_openedfile,1 - jne @eoi - pusha - push ds - mov ax,cs - mov ds,ax - mov dx,offset _tempfile - mov ah,41h - int 21h - pop ds - popa - mov word ptr cs:[_modulehandle],0 - mov byte ptr cs:[_openedfile],0 - jmp @eoi - - ; open file, create the temporary one, decompress, etc.... -@open: - mov word ptr cs:[_cmphandle],ax - pushad - push ds - push es - push fs - push gs - -;---------------------------------------------------------------------------- -; all registers are preserved -;---------------------------------------------------------------------------- - mov ax,cs - mov ds,ax - mov bp,sp - - mov bx,[_cmphandle] - mov ax,4400h - int 21h - test dx,0080h - jne @nochg ; handle is a DEVICE handle, not a file! - mov bx,[_cmphandle] - mov cx,8 - mov dx,OFFSET _signaturecheck - mov ah,03fh ; read first 8 bytes of the opened file - int 21h - push ax - mov bx,[_cmphandle] - xor edx,edx ; reset file pointer to its beginning - call @lseek - pop ax - cmp ax,8 - jne @nochg - cmp dword ptr _signaturecheck,4352697ah ; - jne @nochg ; check for ziRCONia - cmp dword ptr [_signaturecheck+4],61694e4fh ; - jne @nochg ; - - Call Music_Stop - -@emsswap: - mov dx,_memhandle - Mov AH, 47h - Int 67h - - Mov CX, 4 - Call E_MapEMSMemory - -;------------------ we now have free mem to work --------------------------- -@afterswap: - mov ah,3ch ; - mov cx,20h ; create temporary file - mov dx,offset _tempfile ; - int 21h - jc @swapback - mov word ptr [_modulehandle],ax - mov byte ptr [_openedfile],1 - mov bx,[_cmphandle] - mov edx,8 - call @lseek - push 16 - push ds - push offset _filehead ; read file header, 16 bytes minimum - call @read ; (as for now, 16 bytes max too....) - add sp,6 - mov bx,[_cmphandle] - mov edx,_blockptr - call @lseek - mov ax,_blktoprocess - shl ax,2 ; load the BigBlock offset table into - push ax ; memory - push dword ptr _blkoffset - call @read - add sp,6 - mov word ptr _curblock,0 - -@blockloop: - les di,_blkoffset - add di,_curblock - add word ptr _curblock,4 - mov edx,es:[di] ; - mov bx,_cmphandle ; lseek to next BigBlock - call @lseek - les di,_BB ; es:0 -> current BB - mov di,BBheadersize - push di - push dword ptr [_BB] ; read the BB - call @read ; - add sp,6 - mov ax,es:[BBnblk] ; number of small block within BB - shl ax,3 - push ax - push es - push di - call @read ; read all 'small blocks' info - add sp,6 ; (dw offset, dw size) = 8 bytes each - mov dword ptr _curblkpos,0 ; offset 0 in the first small blk - mov al,es:[BBsnbit] - mov _snbit,al ; snbit: compression info... - test word ptr es:[BBflag],1 - je @notcompressed ; if not compressed, why bother? - -@compressed: - push word ptr es:[BBntab] - push dword ptr _ttabl ; read translation table (cmp stuff...) - call @read - add sp,6 - movzx eax,ax - mov esi,es:[BBcmpsize] ; esi = toread (copmressed size) - sub esi,eax ; - trans table size - xor eax,eax - mov _lasteax,eax ; _lastXXXX: since blocks may be larger - ; than the buffer, small blocks may have - ; to be decompressed in more than one shot. - ; _lastXXX preserve current state of reg. - - mov dword ptr _left,eax ; changes also _lastsmp - mov byte ptr _lastch,al - jmp @compressloopend -@compressloop: - movzx eax,word ptr Bufsize - sub ax,_left - cmp esi,eax ; read the most we can... - jnb short @readbuf - mov eax,esi -@readbuf: - push ax - mov eax,_inbuf - add ax,_left - push eax - call @read ; fill inbuf - add sp,6 - movzx eax,ax - sub esi,eax - add ax,_left - mov _rd,ax ; _rd = number of bytes of data in inbuf - test word ptr es:[BBflag],4 - jne short @16bits - call @Uncompbuf8 ; (inbuf, outbuf, &used) in DS - mov _towrite,ax - call @Translatebuf8 ; (outbuf, towrite) in DS - test word ptr es:[BBflag],2 - je short @nodelta8 - call @Undeltabuf8; (outbuf, towrite, lastbyte) in DS -@nodelta8: - mov cl,8 - jmp short @deltadone -@16bits: - call @UncompBuf16 ; for now, write function is ok even is we have a - mov _towrite,ax ; 16 bits buffer with and odd length. - call @UndeltaBuf16 ; (outbuf, towrite, lastbyte) in DS - xor cl,cl - -@deltadone: - lfs bx,_outbuf - add bx,_towrite - mov ax,fs:[bx-2] - shr ax,cl - mov word ptr _lastsmp,ax ; keep the last sample for future 'undelta' - mov cx,_rd - sub cx,_used - jnb short @leftok - xor cx,cx -@leftok: - mov _left,cx ; inbuf might not have been used up, some is left - je short @writeblock - add cx,3 - shr cx,2 - push ds es si di - les di,_inbuf - mov si,_used ; copy unused part of inbuf to its bottom - add si,di - mov ds,word ptr [_inbuf+2] - rep movsd - pop di si es ds -@writeblock: - call @writeblk ; function to write blocks of data (see it...) -@compressloopend: - movzx eax,word ptr _left - or eax,esi ; is there something left to uncompress? - jne @compressloop - jmp short @blockloopend - - ; this part simply copy the uncompressed buffer from the compressed - ; module to the temp uncompressed module -@notcompressed: - mov esi,es:[BBcmpsize] ; esi = toread -@continuenc: - movzx eax,word ptr Bufsize - cmp esi,eax - jnb short @readubuf - mov ax,si -@readubuf: - push ax - push dword ptr _outbuf - call @read - add sp,6 - mov _towrite,ax - movzx eax,ax - sub esi,eax - call @writeblk - or esi,esi - jne short @continuenc - -@blockloopend: - dec word ptr _blktoprocess ; BigBlocks loop end - jne @blockloop - -; ----------------------------- done decompressing! ------------------------- - mov bx,_modulehandle - mov ah,3eh - int 21h ; close temp file to set file size correctly - mov dx,offset _tempfile - mov ax,3d00h - int 21h ; reeopen it in read only for the Player/tracker - mov _modulehandle,bx - mov [bp+36],bx ; put handle in preserved register - mov ah,3eh - mov bx,_cmphandle - int 21h - -;------------------ swap back memory --------------------------- - -@swapback: -@emsswapback: - mov ah,48h - mov dx,_memhandle - int 67h - -@swapbackdone: -; pop gs ; this part must be used to return -; pop fs ; after somthing has been done when -; pop es ; debugging. -; pop ds -; popad -; lss sp,cs:[_oldstack] -; mov cs:byte ptr [_actived],1 -; iret -;---------------------------------------------------------------------------- -; restore all registers -;---------------------------------------------------------------------------- -@nochg: - pop gs - pop fs - pop es - pop ds - popad -@eoi: -; lss sp,cs:[_oldstack] - mov cs:byte ptr [_actived],1 - iret - -;**************************************************************************** -; I/O ROUTINES -;**************************************************************************** - - ; writes decompressed blocks of data at their respective offsets - ; withing the temp module - ; _towrite = lenght to write - ; _curblkpos = current position relative to beginning of the current - ; small block -@writeblk proc near - push ebp - push si - xor si,si - mov ebp,_curblkpos -@writeloop: - mov edx,es:[di] - add edx,ebp - mov bx,_modulehandle - call @lseek - mov ecx,es:[di+4] - sub ecx,ebp - xor ebx,ebx - mov bx,_towrite - cmp ebx,ecx - jnb short @100 - mov cx,bx -@100:push cx - mov bx,_modulehandle - mov ah,40h - push ds - lds dx,_outbuf - add dx,si - int 21h - pop ds - pop ax - add si,ax - sub _towrite,ax - movzx eax,ax - add ebp,eax - cmp ebp,es:[di+4] - jne short @notblockend - add di,8 - dec word ptr es:[BBnblk] - xor ebp,ebp -@notblockend: - or word ptr _towrite,0 - jz short @writeend - or word ptr es:[BBnblk],0 - jnz short @writeloop -@writeend: - mov _curblkpos,ebp - pop si - pop ebp - ret -@writeblk endp - - ; this reads only from the compressed module! -@read proc near - push bp - -; Mov DX, _memhandle -; Mov CX, 4 -; Call E_MapEMSMemory - - mov bp,sp - mov bx,_cmphandle - push ds - lds dx,[bp+4] - mov cx,[bp+8] - mov ah,3fh - int 21h - pop ds bp - ret -@read endp - -@lseek proc near - shld ecx,edx,16 - mov ax,4200h - int 21h - ret -@lseek endp - -;**************************************************************************** -; ROUTINES TO UNCOMPRESS -;**************************************************************************** - - ; unsigned int Uncompress(char far *ib, char far *ob, word far *used) -@Uncompbuf8 proc near - push bp - mov bp,sp - sub sp,2 - push si - push di - push fs - push es - lfs si,_inbuf - les di,_outbuf - - lea ax,[di-100h] - add ax,Bufsize - mov [bp-2],ax - - mov ch,_lastch ; bit count in eax - mov eax,_lasteax ; eax : data - mov cl,_snbit ; num of bit to use - inc cl - xor bh,bh - xor dx,dx - jmp short @017 - -@012:shrd dx,ax,cl - shr eax,cl - rol dx,cl - sub ch,cl - mov bl,cl -@013:cmp dl,[bx+_bchg8-1] - jb short @016 - shl bx,1 - jmp word ptr [bx+_fct1-2] -@015c:and dl,7 ; 3 bits used - jmp short @011 -@015b:and dl,3 ; 2 bits used, get highest bit - shr eax,1 - rcl dl,1 - sub ch,1 - jmp short @011 -@015a:and dl,1 ; 1 bit used, get 2 highest bits - shl dl,2 - shrd dx,ax,2 - shr eax,2 - rol dx,2 - sub ch,2 - jmp short @011 -@015:xor dl,dl ; no bit used, get 3 bits - shrd dx,ax,3 - shr eax,3 - rol dx,3 - sub ch,3 -@011:shr bx,1 - inc dl - cmp cl,dl - je short @011a - mov cl,dl - jmp short @017 -@011a: ; Special commands (254,255, end); - mov dl,al - shr eax,3 - sub ch,3 - and dl,7 - cmp dl,7 - je short @019 ; maybe end-of-buf command -@016a:add dl,MAX8 -@016:mov es:[di],dl ; Store uncompressed data - inc di - cmp di,[bp-2] - je short @019b - xor dl,dl -@017:cmp ch,10H - jnb short @012 -@018:xchg cl,ch - ror eax,cl - mov ax,fs:[si] - add si,2 - rol eax,cl - add cl,10H - xchg cl,ch - jmp @012 -@019:dec ch - shr eax,1 - jnc @016a ; no only a 255 -@019b: - mov _lastch,ch - mov _lasteax,eax - dec cl - mov _snbit,cl - sub si,word ptr _inbuf - mov _used,si - sub di,word ptr _outbuf - mov ax,di - pop es - pop fs - pop di - pop si - leave - ret -@Uncompbuf8 endp - -; void UndeltaBuf8(void far *buf, unsigned int len, char lastbyte) -@UndeltaBuf8 proc near - push ds - mov cx,_towrite - add cx,3 - and cl,0fch - mov dl,byte ptr _lastsmp - lds bx,_outbuf - add cx,bx -@091:mov eax,[bx] - add al,dl - add ah,al - mov dl,ah - ror eax,16 - add al,dl - add ah,al - mov dl,ah - ror eax,16 - mov [bx],eax - add bx,4 - cmp bx,cx - jne short @091 -@092:pop ds - ret -@UndeltaBuf8 endp - -; void TranslateBuf8(char far *buf, unsigned int len) -@TranslateBuf8 proc near - push es - push ds - push si - push di - mov cx,_towrite - add cx,3 - shr cx,2 - les di,_outbuf - lds si,_ttabl - xor bh,bh -@110: mov eax,es:[di] - mov bl,al - mov al,[bx+si] - mov bl,ah - mov ah,[bx+si] - ror eax,16 - mov bl,al - mov al,[bx+si] - mov bl,ah - mov ah,[bx+si] - ror eax,16 - stosd - dec cx - jne short @110 - pop di - pop si - pop ds - pop es - ret -@TranslateBuf8 endp - -;******************************************************************* -;******************** 16 bits decompression code ******************* - - ; unsigned int Uncompbuf16(char far *ib, char far *ob, CompProcess *CP) -@Uncompbuf16 proc near - push bp - mov bp,sp - sub sp,2 - push si - push di - push fs - push es - lfs si,_inbuf - les di,_outbuf - - lea ax,[di-100h] - add ax,Bufsize - mov [bp-2],ax - - mov ch,_lastch ; bit count in eax - mov eax,_lasteax ; eax : data - mov cl,_snbit ; num of bit to use - - inc cl - xor dx,dx - xor ebx,ebx - jmp @217 - -@212:shrd dx,ax,cl - shr eax,cl - rol dx,cl - sub ch,cl - mov bl,cl - cmp ch,10H - jnb short @213 - xchg cl,ch - ror eax,cl - mov ax,fs:[si] - add si,2 - rol eax,cl - add cl,10H - xchg cl,ch -@213: dd 1b943b67H ;\ - dw (_bchg16-2) ; } cmp dx,[ebx+ebx+_bchg16-2] - dw 0 ;/ - jb @216 - dd 1ba4ff67H ;\ jmp word ptr [ebx+ebx+_fct3-2] still this - dw (_fct3-2) ; } bug with 16 bits labels... - dw 0 ;/ -@215d:and dx,15 ; 4 bits used - jmp short @211 -@215c:and dl,7 ; 3 bits used, get highest bit - shr eax,1 - rcl dl,1 - dec ch - jmp short @211 -@215b:and dl,3 ; 2 bit used, get 2 highest bits - shl dl,2 - shrd dx,ax,2 - shr eax,2 - rol dx,2 - sub ch,2 - jmp short @211 -@215a:and dl,1 ; 1 bit used, get 3 highest bits - shl dl,3 - shrd dx,ax,3 - shr eax,3 - rol dx,3 - sub ch,3 - jmp short @211 -@215:xor dl,dl ; no bit used, get 4 bits - shrd dx,ax,4 - shr eax,4 - rol dx,4 - sub ch,4 -@211:inc dl - cmp cl,dl - je short @211a - mov cl,dl - jmp short @217 -@211a: ; Special commands; - cmp ch,10H - jnb short @216b - xchg cl,ch - ror eax,cl - mov ax,fs:[si] - add si,2 - rol eax,cl - add cl,10H - xchg cl,ch -@216b:mov dl,al - shr eax,4 - sub ch,4 - and dx,15 - cmp dl,15 - je short @219 ; maybe end-of-buf command -@216a:add dx,MAX16 -@216:mov es:[di],dx ; Store uncompressed data - add di,2 - cmp di,[bp-2] - je short @219b - xor dx,dx -@217:cmp ch,10H - jnb @212 -@218:xchg cl,ch - ror eax,cl - mov ax,fs:[si] - add si,2 - rol eax,cl - add cl,10H - xchg cl,ch - jmp @212 -@219:cmp ch,10H - jnb short @219a - xchg cl,ch - ror eax,cl - mov ax,fs:[si] - add si,2 - rol eax,cl - add cl,10H - xchg cl,ch -@219a:dec ch - shr eax,1 - jnc @216a ; no only a 65535 -@219b: - mov _lastch,ch - mov _lasteax,eax - dec cl - mov _snbit,cl - sub si,word ptr _inbuf - mov _used,si - sub di,word ptr _outbuf - mov ax,di - pop es - pop fs - pop di - pop si - leave - ret -@Uncompbuf16 endp - -; void UndeltaBuf16(char far *buf, unsigned int len, CompProcess *CP) -@UndeltaBuf16 proc near - push ds - push si - mov cx,_towrite - add cx,3 - shr cx,2 - mov bx,_lastsmp - lds si,_outbuf - test word ptr es:[BBflag],2 - je short @321 -@320:mov eax,[si] - shr ax,1 - rcr dx,1 - sar dx,15 - xor ax,dx - add ax,bx - mov bx,ax - ror eax,16 - shr ax,1 - rcr dx,1 - sar dx,15 - xor ax,dx - add ax,bx - mov bx,ax - ror eax,16 - mov [si],eax - add si,4 - dec cx - jne short @320 - jmp short @323 -@321:test word ptr es:[BBflag],200h - je short @323 -@322:mov eax,[si] - shr ax,1 - rcr dx,1 - sar dx,15 - xor ax,dx - ror eax,16 - shr ax,1 - rcr dx,1 - sar dx,15 - xor ax,dx - ror eax,16 - mov [si],eax - add si,4 - dec cx - jne short @322 -@323:pop si - pop ds - mov word ptr _lastsmp,bx - ret -@UndeltaBuf16 endp - -;******************************************************************* -;******************** 8 bits decompression data ******************** -_bchg8 label byte - db 01H - db 03H - db 07H - db 0fH - db 1eH - db 3cH - db 78H - db 0f8H -EVEN -_fct1 label word - dw @015 - dw @015 - dw @015 - dw @015 - dw @015a - dw @015b - dw @015c - dw @015c -;******************************************************************* -;********************* 16 bits compression data ******************** -_bchg16 label word - dw 00001H ;1 - dw 00003H ;2 - dw 00007H ;3 - dw 0000fH ;4 - dw 0001eH ;5 - dw 0003cH ;6 - dw 00078H ;7 - dw 000f0H ;8 - dw 001f0H ;9 - dw 003f0H ;10 - dw 007f0H ;11 - dw 00ff0H ;12 - dw 01ff0H ;13 - dw 03ff0H ;14 - dw 07ff0H ;15 - dw 0fff0H ;16 - -_fct3 label word - dw @215 - dw @215 - dw @215 - dw @215 - dw @215a - dw @215b - dw @215c - dw @215d - dw @215d - dw @215d - dw @215d - dw @215d - dw @215d - dw @215d - dw @215d - dw @215d - -@settings: -align 4 -BaseSeg dw 08000h -Bufsize dw 06E00h ; 0b000h or anything else for XMS... - -_inbuf dd 0 ; size: Bufsize ; Basemem -_ttabl dd 0 ; size: 200h ; Basemem + Bufsize -_BB dd 0 ; size: 1100h ; Basemem + Bufsize + 200h -_outbuf dd 0 ; size: Bufsize ; Basemem + Bufsize + 1300h -_blkoffset dd 0 ; size: 2000h ; Basemem + 2*Bufsize + 1300h - -_tempfile db 'C:\_~zirc~_.tmp',0,0,0,0,0,0,0,0 ; 23 b + NULL (24 b) - -_old21 dd 0 -_driver dd 0 -_oldstack dd 0 -_memhandle dw 0 -_actived db 0 -_openedfile db 0 -_function db 0 - -_signaturecheck label qword -_filehead: - _headersize dw 0 - _version dw 0 - _blktoprocess dw 0 - _unpacklen dd 0 - _blockptr dd 0 - _dummy dw 0 - -_cmphandle dw 0 -_modulehandle dw 0 - -_lasteax dd 0 -_left dw 0 -_lastsmp dw 0 -_lastch db 0 - -_curblock dw 0 -_curblkpos dd 0 -_towrite dw 0 -_rd dw 0 -_used dw 0 -_snbit db 0 - -align 2 - -EndS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ MMTSR Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + .386 + +include switch.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Extrn E_AllocateEMS:Far + Extrn E_GetEMSPageFrame:Far + Extrn E_ReleaseEMS:Far + Extrn E_MapEMSMemory:Far + Extrn Music_Stop:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global MMTSR_InstallMMTSR:Far + Global MMTSR_UninstallMMTSR:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment MMTSR PARA Public USE16 'Code' + Assume CS:MMTSR, DS:MMTSR + +CREATENEWLOGFILE EQU 0 +include debug.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +MAX8 equ 0f8H ; decompression constants +MAX16 equ 0fff0h + +BBsize equ 0 ; stucture of MMCMP BigBlocks header +BBcmpsize equ 4 ; (relative offset) +BBxorchk equ 8 +BBnblk equ 12 +BBflag equ 14 +BBntab equ 16 +BBsnbit equ 18 +BBheadersize equ 20 + +InstalledFromIT DB 0 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Proc MMTSR_InstallMMTSR Far + + Push CS + Push CS + Pop DS + Pop ES + + Trace " - Determining if MMTSR is already installed" + + mov ax,4370h + int 21h ; check if already installed + + cmp eax,4352697ah + je @error ; if installed, don't install it again + +@notinstalled: + Trace " - Allocating 64kb of EMS memory for MMTSR decoding" + + StC + Mov EAX, 65536 ; 64k + Call E_AllocateEMS + + Test AX, AX + JZ @error ; AX = handle, 0 if error. + +@emsdriver: + Mov _memhandle, AX + Call E_GetEMSPageFrame + Mov BaseSeg, AX + +@fixups: + Trace " - Installing new INT21h handler" + + mov si,offset _inbuf+2 + mov [si],ax + mov dx,Bufsize + shr dx,4 + add ax,dx + mov [si+4],ax + add ax,20h + mov [si+8],ax + add ax,110h + mov [si+12],ax + add ax,dx + mov [si+16],ax + + mov ax,3521h + int 21h + mov word ptr [_old21],bx ; get old INT 21h handler + mov word ptr [_old21+2],es + mov dx,offset @new21 + mov ax,2521h + int 21h ; set new INT 21h handler + + mov byte ptr [_actived],1 ; MMTSR is ACTIVE! + + Mov InstalledFromIT, 1 + +@error: +@error0: ; print message at offset DS:DX onto screen + Ret + +EndP MMTSR_InstallMMTSR + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Proc MMTSR_UninstallMMTSR Far + + Push CS + Pop DS + + Cmp InstalledFromIT, 0 + JE MMTSR_UninstallMMTSR1 + + Mov DX, Word Ptr [_old21] ; Reset handler. + Mov DS, Word Ptr [_old21+2] + Mov AX, 2521h + Int 21h + + Mov AX, CS:_memhandle + Call E_ReleaseEMS + +MMTSR_UninstallMMTSR1: + Ret + +EndP MMTSR_UninstallMMTSR + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + + +;**************************************************************************** +; NEW INTERRUPT 21 HANDLER +;**************************************************************************** + +@activate: + and al,1 + mov byte ptr cs:[_actived],al + IRet + +@installcheck: + mov eax,4352697ah + iret +@new21: ; <<<<---------- INT 21 starts here + cmp ax,4370h + je short @installcheck + cmp ax,4371h + je short @activate + cmp ax,4372h + je short @activate + cmp byte ptr cs:[_actived],1 + jne short @noopen ; originaly intercepts 'open' only... + cmp ah,3dh ; now stands for 'do old interrupt' + je short @intercept + cmp ah,3eh ; MMTSR intercepts 'open file' calls, and + jne short @noopen ; close file if the handle is the + cmp bx,cs:_modulehandle ; temporary decompressed module handle + je short @intercept + +@noopen: + jmp dword ptr cs:[_old21] ; Chain to old interrupt + +@intercept: + mov byte ptr cs:[_actived],0 ; desactivate MMTSR while running + mov byte ptr cs:[_function],ah + mov word ptr cs:[_oldstack],sp ; une hook's stack + mov word ptr cs:[_oldstack+2],ss + + pushf + + Call DWord Ptr [CS:_old21] + + push es bx ax + les bx,cs:[_oldstack] ; + pushf ; + pushf ; preserve "returned from interrupt" flags + pop ax ; and set IF!! ;) + or ah,2 ; + mov word ptr es:[bx+4],ax ; + popf ; "or" modifies flags... + pop ax bx es ; + jc @eoi ; I/O error + cmp cs:[_function],3dh + je short @open + + ; close temporary file and delete it +@close: + cmp byte ptr cs:_openedfile,1 + jne @eoi + pusha + push ds + mov ax,cs + mov ds,ax + mov dx,offset _tempfile + mov ah,41h + int 21h + pop ds + popa + mov word ptr cs:[_modulehandle],0 + mov byte ptr cs:[_openedfile],0 + jmp @eoi + + ; open file, create the temporary one, decompress, etc.... +@open: + mov word ptr cs:[_cmphandle],ax + pushad + push ds + push es + push fs + push gs + +;---------------------------------------------------------------------------- +; all registers are preserved +;---------------------------------------------------------------------------- + mov ax,cs + mov ds,ax + mov bp,sp + + mov bx,[_cmphandle] + mov ax,4400h + int 21h + test dx,0080h + jne @nochg ; handle is a DEVICE handle, not a file! + mov bx,[_cmphandle] + mov cx,8 + mov dx,OFFSET _signaturecheck + mov ah,03fh ; read first 8 bytes of the opened file + int 21h + push ax + mov bx,[_cmphandle] + xor edx,edx ; reset file pointer to its beginning + call @lseek + pop ax + cmp ax,8 + jne @nochg + cmp dword ptr _signaturecheck,4352697ah ; + jne @nochg ; check for ziRCONia + cmp dword ptr [_signaturecheck+4],61694e4fh ; + jne @nochg ; + + Call Music_Stop + +@emsswap: + mov dx,_memhandle + Mov AH, 47h + Int 67h + + Mov CX, 4 + Call E_MapEMSMemory + +;------------------ we now have free mem to work --------------------------- +@afterswap: + mov ah,3ch ; + mov cx,20h ; create temporary file + mov dx,offset _tempfile ; + int 21h + jc @swapback + mov word ptr [_modulehandle],ax + mov byte ptr [_openedfile],1 + mov bx,[_cmphandle] + mov edx,8 + call @lseek + push 16 + push ds + push offset _filehead ; read file header, 16 bytes minimum + call @read ; (as for now, 16 bytes max too....) + add sp,6 + mov bx,[_cmphandle] + mov edx,_blockptr + call @lseek + mov ax,_blktoprocess + shl ax,2 ; load the BigBlock offset table into + push ax ; memory + push dword ptr _blkoffset + call @read + add sp,6 + mov word ptr _curblock,0 + +@blockloop: + les di,_blkoffset + add di,_curblock + add word ptr _curblock,4 + mov edx,es:[di] ; + mov bx,_cmphandle ; lseek to next BigBlock + call @lseek + les di,_BB ; es:0 -> current BB + mov di,BBheadersize + push di + push dword ptr [_BB] ; read the BB + call @read ; + add sp,6 + mov ax,es:[BBnblk] ; number of small block within BB + shl ax,3 + push ax + push es + push di + call @read ; read all 'small blocks' info + add sp,6 ; (dw offset, dw size) = 8 bytes each + mov dword ptr _curblkpos,0 ; offset 0 in the first small blk + mov al,es:[BBsnbit] + mov _snbit,al ; snbit: compression info... + test word ptr es:[BBflag],1 + je @notcompressed ; if not compressed, why bother? + +@compressed: + push word ptr es:[BBntab] + push dword ptr _ttabl ; read translation table (cmp stuff...) + call @read + add sp,6 + movzx eax,ax + mov esi,es:[BBcmpsize] ; esi = toread (copmressed size) + sub esi,eax ; - trans table size + xor eax,eax + mov _lasteax,eax ; _lastXXXX: since blocks may be larger + ; than the buffer, small blocks may have + ; to be decompressed in more than one shot. + ; _lastXXX preserve current state of reg. + + mov dword ptr _left,eax ; changes also _lastsmp + mov byte ptr _lastch,al + jmp @compressloopend +@compressloop: + movzx eax,word ptr Bufsize + sub ax,_left + cmp esi,eax ; read the most we can... + jnb short @readbuf + mov eax,esi +@readbuf: + push ax + mov eax,_inbuf + add ax,_left + push eax + call @read ; fill inbuf + add sp,6 + movzx eax,ax + sub esi,eax + add ax,_left + mov _rd,ax ; _rd = number of bytes of data in inbuf + test word ptr es:[BBflag],4 + jne short @16bits + call @Uncompbuf8 ; (inbuf, outbuf, &used) in DS + mov _towrite,ax + call @Translatebuf8 ; (outbuf, towrite) in DS + test word ptr es:[BBflag],2 + je short @nodelta8 + call @Undeltabuf8; (outbuf, towrite, lastbyte) in DS +@nodelta8: + mov cl,8 + jmp short @deltadone +@16bits: + call @UncompBuf16 ; for now, write function is ok even is we have a + mov _towrite,ax ; 16 bits buffer with and odd length. + call @UndeltaBuf16 ; (outbuf, towrite, lastbyte) in DS + xor cl,cl + +@deltadone: + lfs bx,_outbuf + add bx,_towrite + mov ax,fs:[bx-2] + shr ax,cl + mov word ptr _lastsmp,ax ; keep the last sample for future 'undelta' + mov cx,_rd + sub cx,_used + jnb short @leftok + xor cx,cx +@leftok: + mov _left,cx ; inbuf might not have been used up, some is left + je short @writeblock + add cx,3 + shr cx,2 + push ds es si di + les di,_inbuf + mov si,_used ; copy unused part of inbuf to its bottom + add si,di + mov ds,word ptr [_inbuf+2] + rep movsd + pop di si es ds +@writeblock: + call @writeblk ; function to write blocks of data (see it...) +@compressloopend: + movzx eax,word ptr _left + or eax,esi ; is there something left to uncompress? + jne @compressloop + jmp short @blockloopend + + ; this part simply copy the uncompressed buffer from the compressed + ; module to the temp uncompressed module +@notcompressed: + mov esi,es:[BBcmpsize] ; esi = toread +@continuenc: + movzx eax,word ptr Bufsize + cmp esi,eax + jnb short @readubuf + mov ax,si +@readubuf: + push ax + push dword ptr _outbuf + call @read + add sp,6 + mov _towrite,ax + movzx eax,ax + sub esi,eax + call @writeblk + or esi,esi + jne short @continuenc + +@blockloopend: + dec word ptr _blktoprocess ; BigBlocks loop end + jne @blockloop + +; ----------------------------- done decompressing! ------------------------- + mov bx,_modulehandle + mov ah,3eh + int 21h ; close temp file to set file size correctly + mov dx,offset _tempfile + mov ax,3d00h + int 21h ; reeopen it in read only for the Player/tracker + mov _modulehandle,bx + mov [bp+36],bx ; put handle in preserved register + mov ah,3eh + mov bx,_cmphandle + int 21h + +;------------------ swap back memory --------------------------- + +@swapback: +@emsswapback: + mov ah,48h + mov dx,_memhandle + int 67h + +@swapbackdone: +; pop gs ; this part must be used to return +; pop fs ; after somthing has been done when +; pop es ; debugging. +; pop ds +; popad +; lss sp,cs:[_oldstack] +; mov cs:byte ptr [_actived],1 +; iret +;---------------------------------------------------------------------------- +; restore all registers +;---------------------------------------------------------------------------- +@nochg: + pop gs + pop fs + pop es + pop ds + popad +@eoi: +; lss sp,cs:[_oldstack] + mov cs:byte ptr [_actived],1 + iret + +;**************************************************************************** +; I/O ROUTINES +;**************************************************************************** + + ; writes decompressed blocks of data at their respective offsets + ; withing the temp module + ; _towrite = lenght to write + ; _curblkpos = current position relative to beginning of the current + ; small block +@writeblk proc near + push ebp + push si + xor si,si + mov ebp,_curblkpos +@writeloop: + mov edx,es:[di] + add edx,ebp + mov bx,_modulehandle + call @lseek + mov ecx,es:[di+4] + sub ecx,ebp + xor ebx,ebx + mov bx,_towrite + cmp ebx,ecx + jnb short @100 + mov cx,bx +@100:push cx + mov bx,_modulehandle + mov ah,40h + push ds + lds dx,_outbuf + add dx,si + int 21h + pop ds + pop ax + add si,ax + sub _towrite,ax + movzx eax,ax + add ebp,eax + cmp ebp,es:[di+4] + jne short @notblockend + add di,8 + dec word ptr es:[BBnblk] + xor ebp,ebp +@notblockend: + or word ptr _towrite,0 + jz short @writeend + or word ptr es:[BBnblk],0 + jnz short @writeloop +@writeend: + mov _curblkpos,ebp + pop si + pop ebp + ret +@writeblk endp + + ; this reads only from the compressed module! +@read proc near + push bp + +; Mov DX, _memhandle +; Mov CX, 4 +; Call E_MapEMSMemory + + mov bp,sp + mov bx,_cmphandle + push ds + lds dx,[bp+4] + mov cx,[bp+8] + mov ah,3fh + int 21h + pop ds bp + ret +@read endp + +@lseek proc near + shld ecx,edx,16 + mov ax,4200h + int 21h + ret +@lseek endp + +;**************************************************************************** +; ROUTINES TO UNCOMPRESS +;**************************************************************************** + + ; unsigned int Uncompress(char far *ib, char far *ob, word far *used) +@Uncompbuf8 proc near + push bp + mov bp,sp + sub sp,2 + push si + push di + push fs + push es + lfs si,_inbuf + les di,_outbuf + + lea ax,[di-100h] + add ax,Bufsize + mov [bp-2],ax + + mov ch,_lastch ; bit count in eax + mov eax,_lasteax ; eax : data + mov cl,_snbit ; num of bit to use + inc cl + xor bh,bh + xor dx,dx + jmp short @017 + +@012:shrd dx,ax,cl + shr eax,cl + rol dx,cl + sub ch,cl + mov bl,cl +@013:cmp dl,[bx+_bchg8-1] + jb short @016 + shl bx,1 + jmp word ptr [bx+_fct1-2] +@015c:and dl,7 ; 3 bits used + jmp short @011 +@015b:and dl,3 ; 2 bits used, get highest bit + shr eax,1 + rcl dl,1 + sub ch,1 + jmp short @011 +@015a:and dl,1 ; 1 bit used, get 2 highest bits + shl dl,2 + shrd dx,ax,2 + shr eax,2 + rol dx,2 + sub ch,2 + jmp short @011 +@015:xor dl,dl ; no bit used, get 3 bits + shrd dx,ax,3 + shr eax,3 + rol dx,3 + sub ch,3 +@011:shr bx,1 + inc dl + cmp cl,dl + je short @011a + mov cl,dl + jmp short @017 +@011a: ; Special commands (254,255, end); + mov dl,al + shr eax,3 + sub ch,3 + and dl,7 + cmp dl,7 + je short @019 ; maybe end-of-buf command +@016a:add dl,MAX8 +@016:mov es:[di],dl ; Store uncompressed data + inc di + cmp di,[bp-2] + je short @019b + xor dl,dl +@017:cmp ch,10H + jnb short @012 +@018:xchg cl,ch + ror eax,cl + mov ax,fs:[si] + add si,2 + rol eax,cl + add cl,10H + xchg cl,ch + jmp @012 +@019:dec ch + shr eax,1 + jnc @016a ; no only a 255 +@019b: + mov _lastch,ch + mov _lasteax,eax + dec cl + mov _snbit,cl + sub si,word ptr _inbuf + mov _used,si + sub di,word ptr _outbuf + mov ax,di + pop es + pop fs + pop di + pop si + leave + ret +@Uncompbuf8 endp + +; void UndeltaBuf8(void far *buf, unsigned int len, char lastbyte) +@UndeltaBuf8 proc near + push ds + mov cx,_towrite + add cx,3 + and cl,0fch + mov dl,byte ptr _lastsmp + lds bx,_outbuf + add cx,bx +@091:mov eax,[bx] + add al,dl + add ah,al + mov dl,ah + ror eax,16 + add al,dl + add ah,al + mov dl,ah + ror eax,16 + mov [bx],eax + add bx,4 + cmp bx,cx + jne short @091 +@092:pop ds + ret +@UndeltaBuf8 endp + +; void TranslateBuf8(char far *buf, unsigned int len) +@TranslateBuf8 proc near + push es + push ds + push si + push di + mov cx,_towrite + add cx,3 + shr cx,2 + les di,_outbuf + lds si,_ttabl + xor bh,bh +@110: mov eax,es:[di] + mov bl,al + mov al,[bx+si] + mov bl,ah + mov ah,[bx+si] + ror eax,16 + mov bl,al + mov al,[bx+si] + mov bl,ah + mov ah,[bx+si] + ror eax,16 + stosd + dec cx + jne short @110 + pop di + pop si + pop ds + pop es + ret +@TranslateBuf8 endp + +;******************************************************************* +;******************** 16 bits decompression code ******************* + + ; unsigned int Uncompbuf16(char far *ib, char far *ob, CompProcess *CP) +@Uncompbuf16 proc near + push bp + mov bp,sp + sub sp,2 + push si + push di + push fs + push es + lfs si,_inbuf + les di,_outbuf + + lea ax,[di-100h] + add ax,Bufsize + mov [bp-2],ax + + mov ch,_lastch ; bit count in eax + mov eax,_lasteax ; eax : data + mov cl,_snbit ; num of bit to use + + inc cl + xor dx,dx + xor ebx,ebx + jmp @217 + +@212:shrd dx,ax,cl + shr eax,cl + rol dx,cl + sub ch,cl + mov bl,cl + cmp ch,10H + jnb short @213 + xchg cl,ch + ror eax,cl + mov ax,fs:[si] + add si,2 + rol eax,cl + add cl,10H + xchg cl,ch +@213: dd 1b943b67H ;\ + dw (_bchg16-2) ; } cmp dx,[ebx+ebx+_bchg16-2] + dw 0 ;/ + jb @216 + dd 1ba4ff67H ;\ jmp word ptr [ebx+ebx+_fct3-2] still this + dw (_fct3-2) ; } bug with 16 bits labels... + dw 0 ;/ +@215d:and dx,15 ; 4 bits used + jmp short @211 +@215c:and dl,7 ; 3 bits used, get highest bit + shr eax,1 + rcl dl,1 + dec ch + jmp short @211 +@215b:and dl,3 ; 2 bit used, get 2 highest bits + shl dl,2 + shrd dx,ax,2 + shr eax,2 + rol dx,2 + sub ch,2 + jmp short @211 +@215a:and dl,1 ; 1 bit used, get 3 highest bits + shl dl,3 + shrd dx,ax,3 + shr eax,3 + rol dx,3 + sub ch,3 + jmp short @211 +@215:xor dl,dl ; no bit used, get 4 bits + shrd dx,ax,4 + shr eax,4 + rol dx,4 + sub ch,4 +@211:inc dl + cmp cl,dl + je short @211a + mov cl,dl + jmp short @217 +@211a: ; Special commands; + cmp ch,10H + jnb short @216b + xchg cl,ch + ror eax,cl + mov ax,fs:[si] + add si,2 + rol eax,cl + add cl,10H + xchg cl,ch +@216b:mov dl,al + shr eax,4 + sub ch,4 + and dx,15 + cmp dl,15 + je short @219 ; maybe end-of-buf command +@216a:add dx,MAX16 +@216:mov es:[di],dx ; Store uncompressed data + add di,2 + cmp di,[bp-2] + je short @219b + xor dx,dx +@217:cmp ch,10H + jnb @212 +@218:xchg cl,ch + ror eax,cl + mov ax,fs:[si] + add si,2 + rol eax,cl + add cl,10H + xchg cl,ch + jmp @212 +@219:cmp ch,10H + jnb short @219a + xchg cl,ch + ror eax,cl + mov ax,fs:[si] + add si,2 + rol eax,cl + add cl,10H + xchg cl,ch +@219a:dec ch + shr eax,1 + jnc @216a ; no only a 65535 +@219b: + mov _lastch,ch + mov _lasteax,eax + dec cl + mov _snbit,cl + sub si,word ptr _inbuf + mov _used,si + sub di,word ptr _outbuf + mov ax,di + pop es + pop fs + pop di + pop si + leave + ret +@Uncompbuf16 endp + +; void UndeltaBuf16(char far *buf, unsigned int len, CompProcess *CP) +@UndeltaBuf16 proc near + push ds + push si + mov cx,_towrite + add cx,3 + shr cx,2 + mov bx,_lastsmp + lds si,_outbuf + test word ptr es:[BBflag],2 + je short @321 +@320:mov eax,[si] + shr ax,1 + rcr dx,1 + sar dx,15 + xor ax,dx + add ax,bx + mov bx,ax + ror eax,16 + shr ax,1 + rcr dx,1 + sar dx,15 + xor ax,dx + add ax,bx + mov bx,ax + ror eax,16 + mov [si],eax + add si,4 + dec cx + jne short @320 + jmp short @323 +@321:test word ptr es:[BBflag],200h + je short @323 +@322:mov eax,[si] + shr ax,1 + rcr dx,1 + sar dx,15 + xor ax,dx + ror eax,16 + shr ax,1 + rcr dx,1 + sar dx,15 + xor ax,dx + ror eax,16 + mov [si],eax + add si,4 + dec cx + jne short @322 +@323:pop si + pop ds + mov word ptr _lastsmp,bx + ret +@UndeltaBuf16 endp + +;******************************************************************* +;******************** 8 bits decompression data ******************** +_bchg8 label byte + db 01H + db 03H + db 07H + db 0fH + db 1eH + db 3cH + db 78H + db 0f8H +EVEN +_fct1 label word + dw @015 + dw @015 + dw @015 + dw @015 + dw @015a + dw @015b + dw @015c + dw @015c +;******************************************************************* +;********************* 16 bits compression data ******************** +_bchg16 label word + dw 00001H ;1 + dw 00003H ;2 + dw 00007H ;3 + dw 0000fH ;4 + dw 0001eH ;5 + dw 0003cH ;6 + dw 00078H ;7 + dw 000f0H ;8 + dw 001f0H ;9 + dw 003f0H ;10 + dw 007f0H ;11 + dw 00ff0H ;12 + dw 01ff0H ;13 + dw 03ff0H ;14 + dw 07ff0H ;15 + dw 0fff0H ;16 + +_fct3 label word + dw @215 + dw @215 + dw @215 + dw @215 + dw @215a + dw @215b + dw @215c + dw @215d + dw @215d + dw @215d + dw @215d + dw @215d + dw @215d + dw @215d + dw @215d + dw @215d + +@settings: +align 4 +BaseSeg dw 08000h +Bufsize dw 06E00h ; 0b000h or anything else for XMS... + +_inbuf dd 0 ; size: Bufsize ; Basemem +_ttabl dd 0 ; size: 200h ; Basemem + Bufsize +_BB dd 0 ; size: 1100h ; Basemem + Bufsize + 200h +_outbuf dd 0 ; size: Bufsize ; Basemem + Bufsize + 1300h +_blkoffset dd 0 ; size: 2000h ; Basemem + 2*Bufsize + 1300h + +_tempfile db 'C:\_~zirc~_.tmp',0,0,0,0,0,0,0,0 ; 23 b + NULL (24 b) + +_old21 dd 0 +_driver dd 0 +_oldstack dd 0 +_memhandle dw 0 +_actived db 0 +_openedfile db 0 +_function db 0 + +_signaturecheck label qword +_filehead: + _headersize dw 0 + _version dw 0 + _blktoprocess dw 0 + _unpacklen dd 0 + _blockptr dd 0 + _dummy dw 0 + +_cmphandle dw 0 +_modulehandle dw 0 + +_lasteax dd 0 +_left dw 0 +_lastsmp dw 0 +_lastch db 0 + +_curblock dw 0 +_curblkpos dd 0 +_towrite dw 0 +_rd dw 0 +_used dw 0 +_snbit db 0 + +align 2 + +EndS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_MOUSE.ASM b/it_mouse.s similarity index 96% rename from IT_MOUSE.ASM rename to it_mouse.s index d58a965..3639089 100644 --- a/IT_MOUSE.ASM +++ b/it_mouse.s @@ -1,1412 +1,1412 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Mouse Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386P - -; MouseRecord Structure... -; Area DW Left, Top, Right, Bottom -; Condition DB ? -; Flags DB ? -; ObjectNumber DW ? -; Function DD DWord FunctionPtr -; -; Condition bits -; Bit 0: Mouse moved -; Bit 1: Left button pressed -; Bit 2: Left button held -; Bit 3: Left button released -; Bit 4: Right button pressed -; Bit 5: Right button held -; Bit 6: Right button released -; -; Flags -; Bit 0-1: Condition test -; 0 = equal -; 1 = result when ANDed -; 2, 3 = reserved -; Bit 2: NOT of condition test -; Bit 3: Off - Cursor within area -; On - Cursor outside area -; Bit 4: Always call, ignore area - -include switch.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Extrn S_SetSequencer:Far, S_ResetSequencer:Far - Extrn S_SetDirectMode:Far - Extrn S_GetDestination:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global InitMouse:Far, UnInitMouse:Far - Global MouseCharacterGenerationOffset:Word - Global RestoreMouse:Far, DrawMouse:Far - Global MouseSecondSetEnable:Far, MouseSecondSetDisable:Far - Global RestoreMouseGraphics:Far, MouseToggle:Far - Global MouseInput:Far, AddMouseQueue:Far - Global SetKeyboardLock:Far, GetKeyboardLock:Far - Global MouseSaveEvents:Far, MouseRestoreEvents:Far - Global MouseAddEvent:Far, MouseClearEvents:Far - Global MouseRemoveEvents:Far, MouseSetXY:Far - Global MouseGetStatus:Far, NewCharacterSet:Far - Global MouseUpdateEnable:Far, MouseUpdateDisable:Far - Global SetMouseCursorType:Far, CmdLineDisableMouse:Far - Global ForceMouseRestore:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Mouse PARA Public 'Code' USE16 - Assume CS:Mouse, DS:Nothing - -CREATENEWLOGFILE EQU 0 -include debug.inc - - ; Assumes 80x50 display (512 characters, 8x8 pixels per char.) - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -STARTINGCHARACTER EQU 247 ; Use last 9 characters -QUEUEELEMENTSIZE EQU 8 -MAXXPIXEL EQU 639 -MAXYPIXEL EQU 399 - -MouseCharacterGenerationOffset DW 512*32 -MouseAvailable DB 0 -MouseDisplay DB 1 -MouseEnabled DB 1 - -MouseCursorType DW 0 - -MouseCursorOffset DW 0 -MouseCursorWidth DB 0 -MouseCursorHeight DB 0 - -NewMouseX DW 40*8 -NewMouseY DW 30*8 -MouseX DW 40*8 -MouseY DW 30*8 -MouseXHotSpot DW 0 -MouseYHotSpot DW 0 - -OldCharacterData DW 9 Dup (0) -Label EndOldCharacterData -CharacterTypes DW 247, 248, 249, 250, 251, 252, 253, 254, 255 - -OldBitmapData DB 9*8 Dup (0) -NewBitmapData DB 24*4 Dup (0) - -OverWriteSecondSet DB 1 -RestoreGraphicsRequired DB 0 -LockKeyBoard DB 0 -UpdateScreen DB 0 - -MouseCursorHotSpot Label - DB 0, 0 - DB 4, 3 -; DB 8, 16 - -MouseCursorTypes Label - DW Offset MouseCursorArrow - DW Offset MouseCursorCrossHairs -; DW Offset MouseCursorDownArrow - -Label MouseCursorArrow - DW 0011111111111111b, 0000000000000000b - DW 0001111111111111b, 0100000000000000b - DW 0000111111111111b, 0110000000000000b - DW 0000011111111111b, 0111000000000000b - DW 0000001111111111b, 0111100000000000b - DW 0000000111111111b, 0111110000000000b - DW 0000000011111111b, 0111111000000000b - DW 0000000001111111b, 0111111100000000b - DW 0000000000111111b, 0111111110000000b - DW 0000000001111111b, 0111111100000000b - DW 0000000111111111b, 0111110000000000b - DW 0000000011111111b, 0100011000000000b - DW 1011000011111111b, 0000011000000000b - DW 1111100001111111b, 0000001100000000b - DW 1111100001111111b, 0000001100000000b - DW 1111110011111111b, 0000000000000000b - -Label MouseCursorCrossHairs - DW 1111111111111111b, 0000000000000000b - DW 1111011111111111b, 0000000000000000b - DW 1100000111111111b, 0000100000000000b - DW 1000000011111111b, 0011111000000000b - DW 1100000111111111b, 0000100000000000b - DW 1111011111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - DW 1111111111111111b, 0000000000000000b - - Comment ~ - -Label MouseCursorDownArrow - DW 1111111111111111b, 0000000000000000b - DW 1111000000001111b, 0000000000000000b - DW 1111000000001111b, 0000011111100000b - DW 1111000000001111b, 0000011111100000b - DW 1111000000001111b, 0000011111100000b - DW 1111000000001111b, 0000011111100000b - DW 1111000000001111b, 0000011111100000b - DW 0000000000000000b, 0000011111100000b - DW 0000000000000000b, 0111111111111110b - DW 1000000000000001b, 0011111111111100b - DW 1100000000000011b, 0001111111111000b - DW 1110000000000111b, 0000111111110000b - DW 1111000000001111b, 0000011111100000b - DW 1111100000011111b, 0000001111000000b - DW 1111110000111111b, 0000000110000000b - DW 1111111001111111b, 0000000000000000b - - ~ - -MouseEvents DB 100 * 16 Dup (0) -MouseEventStack DW 8 Dup (0) -MouseEventStackPointer DW 0 -MouseEventStart DW Offset MouseEvents -MouseEventEnd DW Offset MouseEvents - -MouseStatus DB 0 ; Same as conditions... - -MouseQueue DW 128 Dup (0) -MouseQueueStart DB 0 -MouseQueueEnd DB 0 - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RestoreMouse Far - - Push CS - Pop DS - Assume DS:Mouse - - Cmp MouseDisplay, 0 - JE RestoreMouse1 - - Call RemoveMouseCursor - -RestoreMouse1: - Ret - -EndP RestoreMouse - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RemoveMouseCursor ; Given ES=cursor to remove - - Assume DS:Mouse - Mov BX, Offset OldCharacterData - Mov DI, MouseCursorOffset - - - Mov DX, Word Ptr MouseCursorWidth - Test DH, DH - JZ RemoveMouseCursor3 - Test DL, DL - JZ RemoveMouseCursor3 - - Mov CL, STARTINGCHARACTER - -RemoveMouseCursor1: - Push CX - Push BX - Push DI - Mov DL, MouseCursorWidth - -RemoveMouseCursor2: - Mov AX, [BX] - Test AH, 8 - JNZ RemoveMouseCursor4 - - Cmp [ES:DI], CL - JNE RemoveMouseCursor8 - Mov [ES:DI], AX - Jmp RemoveMouseCursor8 - -RemoveMouseCursor4: - Or RestoreGraphicsRequired, 1 - -RemoveMouseCursor8: -; Add DI, 2 - ScasW - Add BX, 2 - Inc CX - Dec DL - JNZ RemoveMouseCursor2 - - Pop DI - Pop BX - Pop CX - - Add CL, 3 - Add BX, 6 - Add DI, 160 - - Dec DH - JNZ RemoveMouseCursor1 - -RemoveMouseCursor3: - Ret - -EndP RemoveMouseCursor - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc RestoreMouseGraphics Far - - Push CS - Pop DS - Assume DS:Mouse - - Mov AL, RestoreGraphicsRequired - Cmp MouseDisplay, 0 - JE RestoreMouseGraphics4 - Cmp OverWriteSecondSet, 1 - JE RestoreMouseGraphics4 - Test AL, 10 - JNZ RestoreMouseGraphics4 - Test AL, 4 - JZ RestoreMouseGraphics4 - - Or RestoreGraphicsRequired, 8 - Test AL, 1 - JZ RestoreMouseGraphics4 - - Call S_SetSequencer - - Mov AX, 0A000h - Mov ES, AX - - Xor BX, BX - Mov DH, MouseCursorHeight - Test DH, DH - JZ RestoreMouseGraphics4 - -RestoreMouseGraphics1: - Push BX - Mov DL, MouseCursorWidth - -RestoreMouseGraphics2: - Mov AX, [OldCharacterData+BX] - Test AH, 8 - JZ RestoreMouseGraphics3 - - ; AL = character in extended set. - And AX, 0FFh - Mov DI, AX - Mov SI, BX - ShL DI, 5 - ShL SI, 2 ; DS:SI points to OldBitMap table - Add SI, Offset OldBitMapData - Add DI, MouseCharacterGenerationOffset - ; ES:DI points to output table - - Mov CX, 8 - Rep MovsB - -RestoreMouseGraphics3: - Add BX, 2 - Dec DL - JNZ RestoreMouseGraphics2 - - Pop BX - Add BX, 6 - - Dec DH - JNZ RestoreMouseGraphics1 - - Call S_ResetSequencer - -RestoreMouseGraphics4: - Ret - -EndP RestoreMouseGraphics - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SaveMouseCursor - Assume DS:Mouse - - Push CS ; *** - Pop DS ; *** - - PushF - ClI - Mov SI, NewMouseX - Mov AX, NewMouseY - PopF - - Mov MouseX, SI - Mov MouseY, AX - - -; Mov AX, MouseY - ShR AX, 3 - - Mov DX, 50 - Sub DX, AX ; CX = height - - Cmp DX, 3 - JB SaveMouseCursor1 - - Mov DL, 3 - -SaveMouseCursor1: - Mov MouseCursorHeight, DL - - Mov BL, 160 - Mul BL -; Mov SI, MouseX - ShR SI, 3 - - Mov CX, 80 - Sub CX, SI - Cmp CX, 3 - JB SaveMouseCursor2 - - Mov CL, 3 - -SaveMouseCursor2: - Add SI, SI - Mov MouseCursorWidth, CL - - Add SI, AX - Mov MouseCursorOffset, SI - Mov DI, Offset OldCharacterData - Xor EAX, EAX - - Mov DWord Ptr [DI], EAX ; Clear buffer first. - Mov DWord Ptr [DI+4], EAX - Mov DWord Ptr [DI+8], EAX - Mov DWord Ptr [DI+12], EAX - Mov Word Ptr [DI+16], AX - -SaveMouseCursor3: - Push DI - Push SI - Push CX - -SaveMouseCursor4: - Mov AX, [ES:SI] - Mov [DI], AX - - Add SI, 2 -; Add DI, 2 - ScasW - Dec CX - JNZ SaveMouseCursor4 - - Pop CX - Pop SI - Pop DI - Add SI, 160 - Add DI, 6 - - Dec DX - JNZ SaveMouseCursor3 - - ; Now get bitmap data... - - Call S_SetSequencer - - Push ES - - Mov AX, 0A000h - Mov ES, AX - - Mov BX, Offset OldCharacterData - Mov DI, Offset OldBitmapData - -SaveMouseCursor5: - Mov AX, [BX] - Mov SI, AX - And SI, 0FFh - ShL SI, 5 - Test AH, 8 - JZ SaveMouseCursor6 - - Mov AL, RestoreGraphicsRequired - Test AL, 1 - JZ SaveMouseCursor8 - Test AL, 10 - JZ SaveMouseCursor7 ; JNZ 8 -; Test AL, 4 -; JZ SaveMouseCursor7 - -SaveMouseCursor8: - Add SI, MouseCharacterGenerationOffset - -SaveMouseCursor6: - Mov EAX, [ES:SI] - Mov [DI], EAX - Mov EAX, [ES:SI+4] - Mov [DI+4], EAX - -SaveMouseCursor7: - Add DI, 8 - Add BX, 2 - Cmp BX, Offset EndOldCharacterData - JB SaveMouseCursor5 - - Pop ES - - Test RestoreGraphicsRequired, 10 - JZ SaveMouseCursor9 - - And RestoreGraphicsRequired, Not 14 - -SaveMouseCursor9: - Ret - -EndP SaveMouseCursor - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GenerateMouseCursor - Assume DS:Mouse - -; Push CS ; *** -; Pop DS ; *** - - ; Has to work out new table and write chars - Mov SI, Offset OldBitMapData - Mov DI, Offset NewBitMapData - Mov DX, 3 - -GenerateMouseCursor1: - Mov CX, 8 - -GenerateMouseCursor2: -; Mov Byte Ptr [DI], 0 - Mov AL, [SI+16] - Mov [DI+1], AL - Mov AL, [SI+8] - Mov [DI+2], AL - Mov AL, [SI] - Mov [DI+3], AL - - Inc SI - Add DI, 4 - Loop GenerateMouseCursor2 - - Add SI, 16 - - Dec DX - JNZ GenerateMouseCursor1 - - Mov BX, MouseX - And BX, 7 ; CX = MouseX % 8 - Mov CX, 8 - Sub CX, BX - Mov EDX, 0FF000000h - ShL EDX, CL ; EDX = 0FF000000h << (8 - shift); - Mov CX, BX - - Mov SI, MouseCursorType -; Add SI, SI - Mov SI, [MouseCursorTypes+SI] - ; DS:SI points to masks. - Mov DI, MouseY - And DI, 7 - ShL DI, 2 - Add DI, Offset NewBitMapData - - Mov BX, 16 ; Cursor height = 16 - -GenerateMouseCharacter3: - Mov AX, [SI] - ShL EAX, 16 - Mov AX, 0FFFFh - RCR EAX, CL - Or EAX, EDX - And [DI], EAX - - Mov AX, [SI+2] - ShL EAX, 16 - ShR EAX, CL - Or [DI], EAX - - Add SI, 4 - Add DI, 4 - Dec BX - JNZ GenerateMouseCharacter3 - - ; Lets write the characters! - - Push ES - Mov AX, 0A000h - Mov ES, AX - - Mov BX, Offset OldCharacterData - Mov SI, Offset NewBitmapData+3 - - Mov DL, 3 - -GenerateMouseCharacter7: - Mov DH, 3 - -GenerateMouseCharacter4: - Mov AX, [BX] - ; Get DI = char to write to... - Test AH, 8 - JZ GenerateMouseCharacter5 - - Cmp OverWriteSecondSet, 0 - JNE GenerateMouseCharacter6 - - And AX, 0FFh - ShL AX, 5 - Add AX, MouseCharacterGenerationOffset - Mov DI, AX - Jmp GenerateMouseCharacter9 - -GenerateMouseCharacter5: - Mov AX, [BX+18] - ShL AX, 5 - Mov DI, AX - -GenerateMouseCharacter9: - ; ES:DI points to character map memory - - Mov CX, 8 - Push SI - -GenerateMouseCharacter8: - MovsB - Add SI, 3 - -; Mov AL, [SI] -; StosB - Loop GenerateMouseCharacter8 - - Pop SI - -GenerateMouseCharacter6: - Dec SI -; Inc SI - - Add BX, 2 - Dec DH - JNZ GenerateMouseCharacter4 - - Add SI, 35 -; Add SI, 32-3 - - Dec DL - JNZ GenerateMouseCharacter7 - - Cmp BX, Offset EndOldCharacterData - JB GenerateMouseCharacter4 - - - Pop ES - - Ret - -EndP GenerateMouseCursor - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PlotMouseCursor - Assume DS:Mouse - - Push CS ; *** - Pop DS ; *** - - Mov DH, MouseCursorHeight - And DH, DH - JZ PlotMouseCursor4 - - Mov AL, STARTINGCHARACTER - Mov BX, MouseCursorOffset - -PlotMouseCursor1: - Push AX - Push BX - - Mov DL, MouseCursorWidth - -PlotMouseCursor2: - Test Word Ptr [ES:BX], 800h - JNZ PlotMouseCursor3 - - Mov [ES:BX], AL - -PlotMouseCursor3: - Inc AX - Add BX, 2 - Dec DL - JNZ PlotMouseCursor2 - - Pop BX - Pop AX - Add BX, 160 - Add AX, 3 - - Dec DH - JNZ PlotMouseCursor1 - -PlotMouseCursor4: - Ret - -EndP PlotMouseCursor - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawMouseCursor ; Given ES to write to. - - Call SaveMouseCursor - Call GenerateMouseCursor - - Call S_ResetSequencer - - ; Write block... - Call PlotMouseCursor - - Ret - -EndP DrawMouseCursor - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DrawMouse Far - - Push CS - Pop DS - Assume DS:Mouse - - Cmp MouseDisplay, 0 - JE DrawMouse1 - - Call DrawMouseCursor - -DrawMouse1: - Ret - -EndP DrawMouse - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseInterruptHandler Far - - PushF - - ClI - CLD - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Mouse - - Mov NewMouseX, CX - Mov NewMouseY, DX - - Xor BH, BH ; BH = new status. - Mov BL, MouseStatus - - Test AL, 1 ; Mouse moved - JZ MIH1 - - Or BH, 1 - Or RestoreGraphicsRequired, 4 - -MIH1: - Test AL, 2 ; Left pressed - JZ MIH2 - - Or BH, 2 - Jmp MIH4 - -MIH2: - Test AL, 4 - JZ MIH3 - - Or BH, 8 - Jmp MIH4 - -MIH3: - Test BL, 6 ; If last status had press or - JZ MIH4 ; held... - - Or BH, 4 ; Set held - -MIH4: - Test AL, 8 ; Left pressed - JZ MIH5 - - Or BH, 10h - Jmp MIH7 - -MIH5: - Test AL, 10h - JZ MIH6 - - Or BH, 40h - Jmp MIH7 - -MIH6: - Test BL, 30h ; If last status had press or - JZ MIH7 ; held... - - Or BH, 20h ; Set held - -MIH7: - - Mov MouseStatus, BH - - Cmp MouseDisplay, 0 - JE MouseInterruptHandler1 - - Mov SI, MouseEventStart - - Cmp UpdateScreen, 0 - JE NoUpdateCursor - - Test BH, 1 ; Moved? - JZ NoUpdateCursor - - PushAD - Mov AX, 0B800h - Mov ES, AX - Push ES - Call RemoveMouseCursor - Call RestoreMouseGraphics - Pop ES - Call DrawMouseCursor - PopAD - -NoUpdateCursor: - Add CX, MouseXHotSpot - Add DX, MouseYHotSpot - -MouseInterruptHandler2: ; BH = status - Cmp SI, MouseEventEnd - JAE MouseInterruptHandler1 - Mov AX, [SI+8] ; AH = flags, AL = conditions - ; AH: Bit 0-1 = test case - ; 0 = equal - ; 1 = result when and - ; Bit 2: NOT of test case - ; Bit 3: Inside/outside area - ; Bit 4: Ignore area - Test AH, 10h - JNZ MouseCheckCondition - - Cmp CX, [SI] - JB MouseAreaOutside1 - Cmp CX, [SI+4] - JA MouseAreaOutside1 - Cmp DX, [SI+2] - JB MouseAreaOutside1 - Cmp DX, [SI+6] - JA MouseAreaOutside1 - - Test AH, 8 - JZ MouseCheckCondition - Jmp MouseInterruptHandler3 - -MouseAreaOutside1: - Test AH, 8 - JZ MouseInterruptHandler3 - -MouseCheckCondition: - And AH, 7 - Cmp AH, 1 - JB MouseCheckCondition0 - JE MouseCheckCondition1 - - Cmp AH, 5 - JB MouseCheckCondition4 - JE MouseCheckCondition5 - Jmp MouseInterruptHandler3 - -MouseCheckCondition0: - Cmp AL, BH - JE MouseEventOK - Jmp MouseInterruptHandler3 - -MouseCheckCondition1: - Test AL, BH - JNZ MouseEventOK - Jmp MouseInterruptHandler3 - -MouseCheckCondition4: - Cmp AL, BH - JNE MouseEventOK - Jmp MouseInterruptHandler3 - -MouseCheckCondition5: - Test AL, BH - JNZ MouseInterruptHandler3 -; JZ MouseEventOK -; Jmp MouseInterruptHandler3 - -MouseEventOK: ; Call function! - Mov AX, [SI+10] - Call DWord Ptr [SI+12] - And AX, AX - JZ MouseInterruptHandler1 - -MouseInterruptHandler3: - Add SI, 16 - Jmp MouseInterruptHandler2 - -MouseInterruptHandler1: - Pop ES - Pop DS - PopAD - PopF - - Ret - -EndP MouseInterruptHandler - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitMouse Far - - Cmp CS:MouseEnabled, 0 - JE InitMouse2 - - Trace " - Determining mouse availability" - - Xor AX, AX - Mov ES, AX - - Mov Byte Ptr [ES:449h], 6 ; 'Setting' display mode - - Int 33h - - Cmp AX, -1 - JE InitMouse1 - - Mov MouseDisplay, 0 - -InitMouse2: - Ret - -InitMouse1: - Trace " - Setting Mouse extents" - - Mov MouseAvailable, 1 - - Xor CX, CX ; X Limits - Mov DX, MAXXPIXEL - Mov AX, 7 - Int 33h - - Xor CX, CX ; Y Limits - Mov DX, MAXYPIXEL - Mov AX, 8 - Int 33h - - Mov CX, MouseX - Mov DX, MouseY - Call MouseSetXY - - Trace " - Installing mouse handler" - - Push CS - Pop ES - Mov CX, 1Fh ; Call on mouse move - ; left button press, release. - ; right button press, release. - ; Ignores central button (if any) - Mov DX, Offset MouseInterruptHandler - Mov AX, 0Ch - Int 33h - - Ret - -EndP InitMouse - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UnInitMouse Far - - Xor AX, AX - Int 33h - - Ret - -EndP UnInitMouse - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSecondSetEnable Far - - Mov CS:OverwriteSecondSet, 0 - Ret - -EndP MouseSecondSetEnable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSecondSetDisable Far - - Mov CS:OverwriteSecondSet, 1 - Ret - -EndP MouseSecondSetDisable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseToggle Far - - Push CS - Pop DS - Assume DS:Mouse - - Cmp MouseAvailable, 0 - JE MouseToggle1 - - Xor MouseDisplay, 1 - JNZ MouseToggle1 - - Mov AX, 0B800h - Mov ES, AX - Call RemoveMouseCursor - Mov MouseDisplay, 1 - Or RestoreGraphicsRequired, 4 - Call RestoreMouseGraphics - Mov MouseDisplay, 0 - -MouseToggle1: - Mov AX, 1 - Ret - -EndP MouseToggle - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSetXY Far - - PushF - - Mov NewMouseX, CX - Mov NewMouseY, DX - - Cmp CS:MouseAvailable, 0 - JE MouseSetXY1 - - ClI - - Mov AX, 4 - Int 33h - - Sub CX, MouseXHotSpot - JNS MouseSetXY2 - - Xor CX, CX - -MouseSetXY2: - Sub DX, MouseYHotSpot - JNS MouseSetXY3 - - Xor DX, DX - -MouseSetXY3: - Cmp CX, MAXXPIXEL - JB MouseSetXY4 - - Mov CX, MAXXPIXEL - -MouseSetXY4: - Cmp DX, MAXYPIXEL - JB MouseSetXY5 - - Mov DX, MAXYPIXEL - -MouseSetXY5: - Mov MouseX, CX - Mov MouseY, DX - - Or CS:RestoreGraphicsRequired, 4 - -MouseSetXY1: - PopF - - Ret - -EndP MouseSetXY - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseSaveEvents Far - - PushF - Push DS - - Push CS - Pop DS - Assume DS:Mouse - - Cmp MouseAvailable, 0 - JE MouseSaveEvents1 - - ClI - - Mov AX, MouseEventStart - Mov SI, MouseEventStackPointer - Mov [MouseEventStack+SI], AX - Add MouseEventStackPointer, 2 - - Mov AX, MouseEventEnd - Mov MouseEventStart, AX - -MouseSaveEvents1: - Pop DS - PopF - - Ret - -EndP MouseSaveEvents - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseRestoreEvents Far - - PushF - Push DS - - Push CS - Pop DS - Assume DS:Mouse - - Cmp MouseAvailable, 0 - JE MouseRestoreEvents1 - - ClI - - Mov AX, MouseEventStart - Mov MouseEventEnd, AX - - Sub MouseEventStackPointer, 2 - Mov SI, MouseEventStackPointer - Mov AX, [MouseEventStack+SI] - Mov MouseEventStart, AX - -MouseRestoreEvents1: - Pop DS - PopF - - Ret - -EndP MouseRestoreEvents - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetKeyboardLock Far ; AL = lock state - - Mov CS:LockKeyBoard, AL - Ret - -EndP SetKeyboardLock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetKeyboardLock Far - - Mov AL, CS:LockKeyBoard - Ret - -EndP GetKeyboardLock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AddMouseQueue Far ; AX, CX, DX - - Push DS - - Push CS - Pop DS - Assume DS:Mouse - - Mov BH, QUEUEELEMENTSIZE - Mov BL, MouseQueueEnd - Add BH, BL - Cmp BH, MouseQueueStart - JE AddMouseQueue1 ; No space left on queue. - - Mov MouseQueueEnd, BH - And BX, 0FFh - Mov [MouseQueue+BX], AX - Mov [MouseQueue+BX+2], CX - Mov [MouseQueue+BX+4], DX - Mov [MouseQueue+BX+6], DI - -AddMouseQueue1: - Pop DS - Ret - -EndP AddMouseQueue - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseInput Far - - PushF - - Push CS - Pop DS - Assume DS:Mouse - - ClI - - Cmp MouseDisplay, 0 - JE MouseInput1 - - Mov CL, MouseQueueEnd - Mov BL, MouseQueueStart - Sub CL, BL - JNZ MouseInput2 - - Cmp LockKeyBoard, 0 - JE MouseInput1 - - Mov AX, 2 - PopF - Ret - -MouseInput1: - Mov AX, 0 - PopF - Ret - -MouseInput2: - And BX, 0FFh - Mov SI, BX - - Add MouseQueueStart, QUEUEELEMENTSIZE - -MouseInput3: - Mov BX, [MouseQueue+SI] - Mov CX, [MouseQueue+SI+2] - Mov DX, [MouseQueue+SI+4] - Mov DI, [MouseQueue+SI+6] - - Mov AX, 1 - PopF - Ret - -EndP MouseInput - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseAddEvent Far ; Given DS:SI to event - - PushF - - Cmp CS:MouseAvailable, 0 - JE MouseAddEvent1 - - Push SI - Push ES - Push DI - - ClI - CLD - - Push CS - Pop ES - Mov DI, CS:MouseEventEnd - - Mov CX, 8 - Rep MovsW - - Mov CS:MouseEventEnd, DI - - Pop DI - Pop ES - Pop SI - -MouseAddEvent1: - PopF - Ret - -EndP MouseAddEvent - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseClearEvents Far - - Mov AX, CS:MouseEventStart - Mov CS:MouseEventEnd, AX - Ret - -EndP MouseClearEvents - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseRemoveEvents Far ; AX = number to remove - - ShL AX, 4 - Sub CS:MouseEventEnd, AX - Ret - -EndP MouseRemoveEvents - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseGetStatus Far - - Mov AL, CS:MouseStatus - Ret - -EndP MouseGetStatus - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc NewCharacterSet Far - - Or CS:RestoreGraphicsRequired, 2 - Ret - -EndP NewCharacterSet - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseUpdateEnable Far - - Mov CS:UpdateScreen, 1 - Ret - -EndP MouseUpdateEnable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MouseUpdateDisable Far - - Mov CS:UpdateScreen, 0 - Ret - -EndP MouseUpdateDisable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetMouseCursorType Far - - PushF - Push DS - - Push CS - Pop DS - Assume DS:Mouse - ClI - - Mov MouseCursorType, BX - Mov AX, [MouseCursorHotSpot+BX] - Mov CX, MouseX - Mov DX, MouseY - - Add CX, MouseXHotSpot - Add DX, MouseYHotSpot - - Mov Byte Ptr MouseXHotSpot, AL - Mov Byte Ptr MouseYHotSpot, AH - - Sub CX, MouseXHotSpot - JNS SetMouseCursorType1 - - Xor CX, CX - -SetMouseCursorType1: - Sub DX, MouseYHotSpot - JNS SetMouseCursorType2 - - Xor DX, DX - -SetMouseCursorType2: - Cmp CX, MAXXPIXEL - JB SetMouseCursorType3 - - Mov CX, MAXXPIXEL - -SetMouseCursorType3: - Cmp DX, MAXYPIXEL - JB SetMouseCursorType4 - - Mov DX, MAXYPIXEL - -SetMouseCursorType4: -; Mov NewMouseX, CX -; Mov NewMouseY, DX - - Call MouseSetXY - - Pop DS - PopF - Ret - -EndP SetMouseCursorType - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CmdLineDisableMouse Far - - Mov Word Ptr CS:MouseDisplay, 0 - Ret - -EndP CmdLineDisableMouse - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ForceMouseRestore Far - - Call MouseUpdateDisable - ClI - Call RestoreMouse - Or RestoreGraphicsRequired, 4 - Call RestoreMouseGraphics - StI - Jmp MouseUpdateEnable - -EndP ForceMouseRestore - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Mouse Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386P + +; MouseRecord Structure... +; Area DW Left, Top, Right, Bottom +; Condition DB ? +; Flags DB ? +; ObjectNumber DW ? +; Function DD DWord FunctionPtr +; +; Condition bits +; Bit 0: Mouse moved +; Bit 1: Left button pressed +; Bit 2: Left button held +; Bit 3: Left button released +; Bit 4: Right button pressed +; Bit 5: Right button held +; Bit 6: Right button released +; +; Flags +; Bit 0-1: Condition test +; 0 = equal +; 1 = result when ANDed +; 2, 3 = reserved +; Bit 2: NOT of condition test +; Bit 3: Off - Cursor within area +; On - Cursor outside area +; Bit 4: Always call, ignore area + +include switch.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Extrn S_SetSequencer:Far, S_ResetSequencer:Far + Extrn S_SetDirectMode:Far + Extrn S_GetDestination:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global InitMouse:Far, UnInitMouse:Far + Global MouseCharacterGenerationOffset:Word + Global RestoreMouse:Far, DrawMouse:Far + Global MouseSecondSetEnable:Far, MouseSecondSetDisable:Far + Global RestoreMouseGraphics:Far, MouseToggle:Far + Global MouseInput:Far, AddMouseQueue:Far + Global SetKeyboardLock:Far, GetKeyboardLock:Far + Global MouseSaveEvents:Far, MouseRestoreEvents:Far + Global MouseAddEvent:Far, MouseClearEvents:Far + Global MouseRemoveEvents:Far, MouseSetXY:Far + Global MouseGetStatus:Far, NewCharacterSet:Far + Global MouseUpdateEnable:Far, MouseUpdateDisable:Far + Global SetMouseCursorType:Far, CmdLineDisableMouse:Far + Global ForceMouseRestore:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Mouse PARA Public 'Code' USE16 + Assume CS:Mouse, DS:Nothing + +CREATENEWLOGFILE EQU 0 +include debug.inc + + ; Assumes 80x50 display (512 characters, 8x8 pixels per char.) + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +STARTINGCHARACTER EQU 247 ; Use last 9 characters +QUEUEELEMENTSIZE EQU 8 +MAXXPIXEL EQU 639 +MAXYPIXEL EQU 399 + +MouseCharacterGenerationOffset DW 512*32 +MouseAvailable DB 0 +MouseDisplay DB 1 +MouseEnabled DB 1 + +MouseCursorType DW 0 + +MouseCursorOffset DW 0 +MouseCursorWidth DB 0 +MouseCursorHeight DB 0 + +NewMouseX DW 40*8 +NewMouseY DW 30*8 +MouseX DW 40*8 +MouseY DW 30*8 +MouseXHotSpot DW 0 +MouseYHotSpot DW 0 + +OldCharacterData DW 9 Dup (0) +Label EndOldCharacterData +CharacterTypes DW 247, 248, 249, 250, 251, 252, 253, 254, 255 + +OldBitmapData DB 9*8 Dup (0) +NewBitmapData DB 24*4 Dup (0) + +OverWriteSecondSet DB 1 +RestoreGraphicsRequired DB 0 +LockKeyBoard DB 0 +UpdateScreen DB 0 + +MouseCursorHotSpot Label + DB 0, 0 + DB 4, 3 +; DB 8, 16 + +MouseCursorTypes Label + DW Offset MouseCursorArrow + DW Offset MouseCursorCrossHairs +; DW Offset MouseCursorDownArrow + +Label MouseCursorArrow + DW 0011111111111111b, 0000000000000000b + DW 0001111111111111b, 0100000000000000b + DW 0000111111111111b, 0110000000000000b + DW 0000011111111111b, 0111000000000000b + DW 0000001111111111b, 0111100000000000b + DW 0000000111111111b, 0111110000000000b + DW 0000000011111111b, 0111111000000000b + DW 0000000001111111b, 0111111100000000b + DW 0000000000111111b, 0111111110000000b + DW 0000000001111111b, 0111111100000000b + DW 0000000111111111b, 0111110000000000b + DW 0000000011111111b, 0100011000000000b + DW 1011000011111111b, 0000011000000000b + DW 1111100001111111b, 0000001100000000b + DW 1111100001111111b, 0000001100000000b + DW 1111110011111111b, 0000000000000000b + +Label MouseCursorCrossHairs + DW 1111111111111111b, 0000000000000000b + DW 1111011111111111b, 0000000000000000b + DW 1100000111111111b, 0000100000000000b + DW 1000000011111111b, 0011111000000000b + DW 1100000111111111b, 0000100000000000b + DW 1111011111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + DW 1111111111111111b, 0000000000000000b + + Comment ~ + +Label MouseCursorDownArrow + DW 1111111111111111b, 0000000000000000b + DW 1111000000001111b, 0000000000000000b + DW 1111000000001111b, 0000011111100000b + DW 1111000000001111b, 0000011111100000b + DW 1111000000001111b, 0000011111100000b + DW 1111000000001111b, 0000011111100000b + DW 1111000000001111b, 0000011111100000b + DW 0000000000000000b, 0000011111100000b + DW 0000000000000000b, 0111111111111110b + DW 1000000000000001b, 0011111111111100b + DW 1100000000000011b, 0001111111111000b + DW 1110000000000111b, 0000111111110000b + DW 1111000000001111b, 0000011111100000b + DW 1111100000011111b, 0000001111000000b + DW 1111110000111111b, 0000000110000000b + DW 1111111001111111b, 0000000000000000b + + ~ + +MouseEvents DB 100 * 16 Dup (0) +MouseEventStack DW 8 Dup (0) +MouseEventStackPointer DW 0 +MouseEventStart DW Offset MouseEvents +MouseEventEnd DW Offset MouseEvents + +MouseStatus DB 0 ; Same as conditions... + +MouseQueue DW 128 Dup (0) +MouseQueueStart DB 0 +MouseQueueEnd DB 0 + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RestoreMouse Far + + Push CS + Pop DS + Assume DS:Mouse + + Cmp MouseDisplay, 0 + JE RestoreMouse1 + + Call RemoveMouseCursor + +RestoreMouse1: + Ret + +EndP RestoreMouse + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RemoveMouseCursor ; Given ES=cursor to remove + + Assume DS:Mouse + Mov BX, Offset OldCharacterData + Mov DI, MouseCursorOffset + + + Mov DX, Word Ptr MouseCursorWidth + Test DH, DH + JZ RemoveMouseCursor3 + Test DL, DL + JZ RemoveMouseCursor3 + + Mov CL, STARTINGCHARACTER + +RemoveMouseCursor1: + Push CX + Push BX + Push DI + Mov DL, MouseCursorWidth + +RemoveMouseCursor2: + Mov AX, [BX] + Test AH, 8 + JNZ RemoveMouseCursor4 + + Cmp [ES:DI], CL + JNE RemoveMouseCursor8 + Mov [ES:DI], AX + Jmp RemoveMouseCursor8 + +RemoveMouseCursor4: + Or RestoreGraphicsRequired, 1 + +RemoveMouseCursor8: +; Add DI, 2 + ScasW + Add BX, 2 + Inc CX + Dec DL + JNZ RemoveMouseCursor2 + + Pop DI + Pop BX + Pop CX + + Add CL, 3 + Add BX, 6 + Add DI, 160 + + Dec DH + JNZ RemoveMouseCursor1 + +RemoveMouseCursor3: + Ret + +EndP RemoveMouseCursor + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc RestoreMouseGraphics Far + + Push CS + Pop DS + Assume DS:Mouse + + Mov AL, RestoreGraphicsRequired + Cmp MouseDisplay, 0 + JE RestoreMouseGraphics4 + Cmp OverWriteSecondSet, 1 + JE RestoreMouseGraphics4 + Test AL, 10 + JNZ RestoreMouseGraphics4 + Test AL, 4 + JZ RestoreMouseGraphics4 + + Or RestoreGraphicsRequired, 8 + Test AL, 1 + JZ RestoreMouseGraphics4 + + Call S_SetSequencer + + Mov AX, 0A000h + Mov ES, AX + + Xor BX, BX + Mov DH, MouseCursorHeight + Test DH, DH + JZ RestoreMouseGraphics4 + +RestoreMouseGraphics1: + Push BX + Mov DL, MouseCursorWidth + +RestoreMouseGraphics2: + Mov AX, [OldCharacterData+BX] + Test AH, 8 + JZ RestoreMouseGraphics3 + + ; AL = character in extended set. + And AX, 0FFh + Mov DI, AX + Mov SI, BX + ShL DI, 5 + ShL SI, 2 ; DS:SI points to OldBitMap table + Add SI, Offset OldBitMapData + Add DI, MouseCharacterGenerationOffset + ; ES:DI points to output table + + Mov CX, 8 + Rep MovsB + +RestoreMouseGraphics3: + Add BX, 2 + Dec DL + JNZ RestoreMouseGraphics2 + + Pop BX + Add BX, 6 + + Dec DH + JNZ RestoreMouseGraphics1 + + Call S_ResetSequencer + +RestoreMouseGraphics4: + Ret + +EndP RestoreMouseGraphics + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SaveMouseCursor + Assume DS:Mouse + + Push CS ; *** + Pop DS ; *** + + PushF + ClI + Mov SI, NewMouseX + Mov AX, NewMouseY + PopF + + Mov MouseX, SI + Mov MouseY, AX + + +; Mov AX, MouseY + ShR AX, 3 + + Mov DX, 50 + Sub DX, AX ; CX = height + + Cmp DX, 3 + JB SaveMouseCursor1 + + Mov DL, 3 + +SaveMouseCursor1: + Mov MouseCursorHeight, DL + + Mov BL, 160 + Mul BL +; Mov SI, MouseX + ShR SI, 3 + + Mov CX, 80 + Sub CX, SI + Cmp CX, 3 + JB SaveMouseCursor2 + + Mov CL, 3 + +SaveMouseCursor2: + Add SI, SI + Mov MouseCursorWidth, CL + + Add SI, AX + Mov MouseCursorOffset, SI + Mov DI, Offset OldCharacterData + Xor EAX, EAX + + Mov DWord Ptr [DI], EAX ; Clear buffer first. + Mov DWord Ptr [DI+4], EAX + Mov DWord Ptr [DI+8], EAX + Mov DWord Ptr [DI+12], EAX + Mov Word Ptr [DI+16], AX + +SaveMouseCursor3: + Push DI + Push SI + Push CX + +SaveMouseCursor4: + Mov AX, [ES:SI] + Mov [DI], AX + + Add SI, 2 +; Add DI, 2 + ScasW + Dec CX + JNZ SaveMouseCursor4 + + Pop CX + Pop SI + Pop DI + Add SI, 160 + Add DI, 6 + + Dec DX + JNZ SaveMouseCursor3 + + ; Now get bitmap data... + + Call S_SetSequencer + + Push ES + + Mov AX, 0A000h + Mov ES, AX + + Mov BX, Offset OldCharacterData + Mov DI, Offset OldBitmapData + +SaveMouseCursor5: + Mov AX, [BX] + Mov SI, AX + And SI, 0FFh + ShL SI, 5 + Test AH, 8 + JZ SaveMouseCursor6 + + Mov AL, RestoreGraphicsRequired + Test AL, 1 + JZ SaveMouseCursor8 + Test AL, 10 + JZ SaveMouseCursor7 ; JNZ 8 +; Test AL, 4 +; JZ SaveMouseCursor7 + +SaveMouseCursor8: + Add SI, MouseCharacterGenerationOffset + +SaveMouseCursor6: + Mov EAX, [ES:SI] + Mov [DI], EAX + Mov EAX, [ES:SI+4] + Mov [DI+4], EAX + +SaveMouseCursor7: + Add DI, 8 + Add BX, 2 + Cmp BX, Offset EndOldCharacterData + JB SaveMouseCursor5 + + Pop ES + + Test RestoreGraphicsRequired, 10 + JZ SaveMouseCursor9 + + And RestoreGraphicsRequired, Not 14 + +SaveMouseCursor9: + Ret + +EndP SaveMouseCursor + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GenerateMouseCursor + Assume DS:Mouse + +; Push CS ; *** +; Pop DS ; *** + + ; Has to work out new table and write chars + Mov SI, Offset OldBitMapData + Mov DI, Offset NewBitMapData + Mov DX, 3 + +GenerateMouseCursor1: + Mov CX, 8 + +GenerateMouseCursor2: +; Mov Byte Ptr [DI], 0 + Mov AL, [SI+16] + Mov [DI+1], AL + Mov AL, [SI+8] + Mov [DI+2], AL + Mov AL, [SI] + Mov [DI+3], AL + + Inc SI + Add DI, 4 + Loop GenerateMouseCursor2 + + Add SI, 16 + + Dec DX + JNZ GenerateMouseCursor1 + + Mov BX, MouseX + And BX, 7 ; CX = MouseX % 8 + Mov CX, 8 + Sub CX, BX + Mov EDX, 0FF000000h + ShL EDX, CL ; EDX = 0FF000000h << (8 - shift); + Mov CX, BX + + Mov SI, MouseCursorType +; Add SI, SI + Mov SI, [MouseCursorTypes+SI] + ; DS:SI points to masks. + Mov DI, MouseY + And DI, 7 + ShL DI, 2 + Add DI, Offset NewBitMapData + + Mov BX, 16 ; Cursor height = 16 + +GenerateMouseCharacter3: + Mov AX, [SI] + ShL EAX, 16 + Mov AX, 0FFFFh + RCR EAX, CL + Or EAX, EDX + And [DI], EAX + + Mov AX, [SI+2] + ShL EAX, 16 + ShR EAX, CL + Or [DI], EAX + + Add SI, 4 + Add DI, 4 + Dec BX + JNZ GenerateMouseCharacter3 + + ; Lets write the characters! + + Push ES + Mov AX, 0A000h + Mov ES, AX + + Mov BX, Offset OldCharacterData + Mov SI, Offset NewBitmapData+3 + + Mov DL, 3 + +GenerateMouseCharacter7: + Mov DH, 3 + +GenerateMouseCharacter4: + Mov AX, [BX] + ; Get DI = char to write to... + Test AH, 8 + JZ GenerateMouseCharacter5 + + Cmp OverWriteSecondSet, 0 + JNE GenerateMouseCharacter6 + + And AX, 0FFh + ShL AX, 5 + Add AX, MouseCharacterGenerationOffset + Mov DI, AX + Jmp GenerateMouseCharacter9 + +GenerateMouseCharacter5: + Mov AX, [BX+18] + ShL AX, 5 + Mov DI, AX + +GenerateMouseCharacter9: + ; ES:DI points to character map memory + + Mov CX, 8 + Push SI + +GenerateMouseCharacter8: + MovsB + Add SI, 3 + +; Mov AL, [SI] +; StosB + Loop GenerateMouseCharacter8 + + Pop SI + +GenerateMouseCharacter6: + Dec SI +; Inc SI + + Add BX, 2 + Dec DH + JNZ GenerateMouseCharacter4 + + Add SI, 35 +; Add SI, 32-3 + + Dec DL + JNZ GenerateMouseCharacter7 + + Cmp BX, Offset EndOldCharacterData + JB GenerateMouseCharacter4 + + + Pop ES + + Ret + +EndP GenerateMouseCursor + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PlotMouseCursor + Assume DS:Mouse + + Push CS ; *** + Pop DS ; *** + + Mov DH, MouseCursorHeight + And DH, DH + JZ PlotMouseCursor4 + + Mov AL, STARTINGCHARACTER + Mov BX, MouseCursorOffset + +PlotMouseCursor1: + Push AX + Push BX + + Mov DL, MouseCursorWidth + +PlotMouseCursor2: + Test Word Ptr [ES:BX], 800h + JNZ PlotMouseCursor3 + + Mov [ES:BX], AL + +PlotMouseCursor3: + Inc AX + Add BX, 2 + Dec DL + JNZ PlotMouseCursor2 + + Pop BX + Pop AX + Add BX, 160 + Add AX, 3 + + Dec DH + JNZ PlotMouseCursor1 + +PlotMouseCursor4: + Ret + +EndP PlotMouseCursor + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawMouseCursor ; Given ES to write to. + + Call SaveMouseCursor + Call GenerateMouseCursor + + Call S_ResetSequencer + + ; Write block... + Call PlotMouseCursor + + Ret + +EndP DrawMouseCursor + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DrawMouse Far + + Push CS + Pop DS + Assume DS:Mouse + + Cmp MouseDisplay, 0 + JE DrawMouse1 + + Call DrawMouseCursor + +DrawMouse1: + Ret + +EndP DrawMouse + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseInterruptHandler Far + + PushF + + ClI + CLD + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Mouse + + Mov NewMouseX, CX + Mov NewMouseY, DX + + Xor BH, BH ; BH = new status. + Mov BL, MouseStatus + + Test AL, 1 ; Mouse moved + JZ MIH1 + + Or BH, 1 + Or RestoreGraphicsRequired, 4 + +MIH1: + Test AL, 2 ; Left pressed + JZ MIH2 + + Or BH, 2 + Jmp MIH4 + +MIH2: + Test AL, 4 + JZ MIH3 + + Or BH, 8 + Jmp MIH4 + +MIH3: + Test BL, 6 ; If last status had press or + JZ MIH4 ; held... + + Or BH, 4 ; Set held + +MIH4: + Test AL, 8 ; Left pressed + JZ MIH5 + + Or BH, 10h + Jmp MIH7 + +MIH5: + Test AL, 10h + JZ MIH6 + + Or BH, 40h + Jmp MIH7 + +MIH6: + Test BL, 30h ; If last status had press or + JZ MIH7 ; held... + + Or BH, 20h ; Set held + +MIH7: + + Mov MouseStatus, BH + + Cmp MouseDisplay, 0 + JE MouseInterruptHandler1 + + Mov SI, MouseEventStart + + Cmp UpdateScreen, 0 + JE NoUpdateCursor + + Test BH, 1 ; Moved? + JZ NoUpdateCursor + + PushAD + Mov AX, 0B800h + Mov ES, AX + Push ES + Call RemoveMouseCursor + Call RestoreMouseGraphics + Pop ES + Call DrawMouseCursor + PopAD + +NoUpdateCursor: + Add CX, MouseXHotSpot + Add DX, MouseYHotSpot + +MouseInterruptHandler2: ; BH = status + Cmp SI, MouseEventEnd + JAE MouseInterruptHandler1 + Mov AX, [SI+8] ; AH = flags, AL = conditions + ; AH: Bit 0-1 = test case + ; 0 = equal + ; 1 = result when and + ; Bit 2: NOT of test case + ; Bit 3: Inside/outside area + ; Bit 4: Ignore area + Test AH, 10h + JNZ MouseCheckCondition + + Cmp CX, [SI] + JB MouseAreaOutside1 + Cmp CX, [SI+4] + JA MouseAreaOutside1 + Cmp DX, [SI+2] + JB MouseAreaOutside1 + Cmp DX, [SI+6] + JA MouseAreaOutside1 + + Test AH, 8 + JZ MouseCheckCondition + Jmp MouseInterruptHandler3 + +MouseAreaOutside1: + Test AH, 8 + JZ MouseInterruptHandler3 + +MouseCheckCondition: + And AH, 7 + Cmp AH, 1 + JB MouseCheckCondition0 + JE MouseCheckCondition1 + + Cmp AH, 5 + JB MouseCheckCondition4 + JE MouseCheckCondition5 + Jmp MouseInterruptHandler3 + +MouseCheckCondition0: + Cmp AL, BH + JE MouseEventOK + Jmp MouseInterruptHandler3 + +MouseCheckCondition1: + Test AL, BH + JNZ MouseEventOK + Jmp MouseInterruptHandler3 + +MouseCheckCondition4: + Cmp AL, BH + JNE MouseEventOK + Jmp MouseInterruptHandler3 + +MouseCheckCondition5: + Test AL, BH + JNZ MouseInterruptHandler3 +; JZ MouseEventOK +; Jmp MouseInterruptHandler3 + +MouseEventOK: ; Call function! + Mov AX, [SI+10] + Call DWord Ptr [SI+12] + And AX, AX + JZ MouseInterruptHandler1 + +MouseInterruptHandler3: + Add SI, 16 + Jmp MouseInterruptHandler2 + +MouseInterruptHandler1: + Pop ES + Pop DS + PopAD + PopF + + Ret + +EndP MouseInterruptHandler + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitMouse Far + + Cmp CS:MouseEnabled, 0 + JE InitMouse2 + + Trace " - Determining mouse availability" + + Xor AX, AX + Mov ES, AX + + Mov Byte Ptr [ES:449h], 6 ; 'Setting' display mode + + Int 33h + + Cmp AX, -1 + JE InitMouse1 + + Mov MouseDisplay, 0 + +InitMouse2: + Ret + +InitMouse1: + Trace " - Setting Mouse extents" + + Mov MouseAvailable, 1 + + Xor CX, CX ; X Limits + Mov DX, MAXXPIXEL + Mov AX, 7 + Int 33h + + Xor CX, CX ; Y Limits + Mov DX, MAXYPIXEL + Mov AX, 8 + Int 33h + + Mov CX, MouseX + Mov DX, MouseY + Call MouseSetXY + + Trace " - Installing mouse handler" + + Push CS + Pop ES + Mov CX, 1Fh ; Call on mouse move + ; left button press, release. + ; right button press, release. + ; Ignores central button (if any) + Mov DX, Offset MouseInterruptHandler + Mov AX, 0Ch + Int 33h + + Ret + +EndP InitMouse + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UnInitMouse Far + + Xor AX, AX + Int 33h + + Ret + +EndP UnInitMouse + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSecondSetEnable Far + + Mov CS:OverwriteSecondSet, 0 + Ret + +EndP MouseSecondSetEnable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSecondSetDisable Far + + Mov CS:OverwriteSecondSet, 1 + Ret + +EndP MouseSecondSetDisable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseToggle Far + + Push CS + Pop DS + Assume DS:Mouse + + Cmp MouseAvailable, 0 + JE MouseToggle1 + + Xor MouseDisplay, 1 + JNZ MouseToggle1 + + Mov AX, 0B800h + Mov ES, AX + Call RemoveMouseCursor + Mov MouseDisplay, 1 + Or RestoreGraphicsRequired, 4 + Call RestoreMouseGraphics + Mov MouseDisplay, 0 + +MouseToggle1: + Mov AX, 1 + Ret + +EndP MouseToggle + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSetXY Far + + PushF + + Mov NewMouseX, CX + Mov NewMouseY, DX + + Cmp CS:MouseAvailable, 0 + JE MouseSetXY1 + + ClI + + Mov AX, 4 + Int 33h + + Sub CX, MouseXHotSpot + JNS MouseSetXY2 + + Xor CX, CX + +MouseSetXY2: + Sub DX, MouseYHotSpot + JNS MouseSetXY3 + + Xor DX, DX + +MouseSetXY3: + Cmp CX, MAXXPIXEL + JB MouseSetXY4 + + Mov CX, MAXXPIXEL + +MouseSetXY4: + Cmp DX, MAXYPIXEL + JB MouseSetXY5 + + Mov DX, MAXYPIXEL + +MouseSetXY5: + Mov MouseX, CX + Mov MouseY, DX + + Or CS:RestoreGraphicsRequired, 4 + +MouseSetXY1: + PopF + + Ret + +EndP MouseSetXY + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseSaveEvents Far + + PushF + Push DS + + Push CS + Pop DS + Assume DS:Mouse + + Cmp MouseAvailable, 0 + JE MouseSaveEvents1 + + ClI + + Mov AX, MouseEventStart + Mov SI, MouseEventStackPointer + Mov [MouseEventStack+SI], AX + Add MouseEventStackPointer, 2 + + Mov AX, MouseEventEnd + Mov MouseEventStart, AX + +MouseSaveEvents1: + Pop DS + PopF + + Ret + +EndP MouseSaveEvents + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseRestoreEvents Far + + PushF + Push DS + + Push CS + Pop DS + Assume DS:Mouse + + Cmp MouseAvailable, 0 + JE MouseRestoreEvents1 + + ClI + + Mov AX, MouseEventStart + Mov MouseEventEnd, AX + + Sub MouseEventStackPointer, 2 + Mov SI, MouseEventStackPointer + Mov AX, [MouseEventStack+SI] + Mov MouseEventStart, AX + +MouseRestoreEvents1: + Pop DS + PopF + + Ret + +EndP MouseRestoreEvents + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetKeyboardLock Far ; AL = lock state + + Mov CS:LockKeyBoard, AL + Ret + +EndP SetKeyboardLock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetKeyboardLock Far + + Mov AL, CS:LockKeyBoard + Ret + +EndP GetKeyboardLock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AddMouseQueue Far ; AX, CX, DX + + Push DS + + Push CS + Pop DS + Assume DS:Mouse + + Mov BH, QUEUEELEMENTSIZE + Mov BL, MouseQueueEnd + Add BH, BL + Cmp BH, MouseQueueStart + JE AddMouseQueue1 ; No space left on queue. + + Mov MouseQueueEnd, BH + And BX, 0FFh + Mov [MouseQueue+BX], AX + Mov [MouseQueue+BX+2], CX + Mov [MouseQueue+BX+4], DX + Mov [MouseQueue+BX+6], DI + +AddMouseQueue1: + Pop DS + Ret + +EndP AddMouseQueue + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseInput Far + + PushF + + Push CS + Pop DS + Assume DS:Mouse + + ClI + + Cmp MouseDisplay, 0 + JE MouseInput1 + + Mov CL, MouseQueueEnd + Mov BL, MouseQueueStart + Sub CL, BL + JNZ MouseInput2 + + Cmp LockKeyBoard, 0 + JE MouseInput1 + + Mov AX, 2 + PopF + Ret + +MouseInput1: + Mov AX, 0 + PopF + Ret + +MouseInput2: + And BX, 0FFh + Mov SI, BX + + Add MouseQueueStart, QUEUEELEMENTSIZE + +MouseInput3: + Mov BX, [MouseQueue+SI] + Mov CX, [MouseQueue+SI+2] + Mov DX, [MouseQueue+SI+4] + Mov DI, [MouseQueue+SI+6] + + Mov AX, 1 + PopF + Ret + +EndP MouseInput + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseAddEvent Far ; Given DS:SI to event + + PushF + + Cmp CS:MouseAvailable, 0 + JE MouseAddEvent1 + + Push SI + Push ES + Push DI + + ClI + CLD + + Push CS + Pop ES + Mov DI, CS:MouseEventEnd + + Mov CX, 8 + Rep MovsW + + Mov CS:MouseEventEnd, DI + + Pop DI + Pop ES + Pop SI + +MouseAddEvent1: + PopF + Ret + +EndP MouseAddEvent + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseClearEvents Far + + Mov AX, CS:MouseEventStart + Mov CS:MouseEventEnd, AX + Ret + +EndP MouseClearEvents + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseRemoveEvents Far ; AX = number to remove + + ShL AX, 4 + Sub CS:MouseEventEnd, AX + Ret + +EndP MouseRemoveEvents + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseGetStatus Far + + Mov AL, CS:MouseStatus + Ret + +EndP MouseGetStatus + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc NewCharacterSet Far + + Or CS:RestoreGraphicsRequired, 2 + Ret + +EndP NewCharacterSet + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseUpdateEnable Far + + Mov CS:UpdateScreen, 1 + Ret + +EndP MouseUpdateEnable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MouseUpdateDisable Far + + Mov CS:UpdateScreen, 0 + Ret + +EndP MouseUpdateDisable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetMouseCursorType Far + + PushF + Push DS + + Push CS + Pop DS + Assume DS:Mouse + ClI + + Mov MouseCursorType, BX + Mov AX, [MouseCursorHotSpot+BX] + Mov CX, MouseX + Mov DX, MouseY + + Add CX, MouseXHotSpot + Add DX, MouseYHotSpot + + Mov Byte Ptr MouseXHotSpot, AL + Mov Byte Ptr MouseYHotSpot, AH + + Sub CX, MouseXHotSpot + JNS SetMouseCursorType1 + + Xor CX, CX + +SetMouseCursorType1: + Sub DX, MouseYHotSpot + JNS SetMouseCursorType2 + + Xor DX, DX + +SetMouseCursorType2: + Cmp CX, MAXXPIXEL + JB SetMouseCursorType3 + + Mov CX, MAXXPIXEL + +SetMouseCursorType3: + Cmp DX, MAXYPIXEL + JB SetMouseCursorType4 + + Mov DX, MAXYPIXEL + +SetMouseCursorType4: +; Mov NewMouseX, CX +; Mov NewMouseY, DX + + Call MouseSetXY + + Pop DS + PopF + Ret + +EndP SetMouseCursorType + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CmdLineDisableMouse Far + + Mov Word Ptr CS:MouseDisplay, 0 + Ret + +EndP CmdLineDisableMouse + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ForceMouseRestore Far + + Call MouseUpdateDisable + ClI + Call RestoreMouse + Or RestoreGraphicsRequired, 4 + Call RestoreMouseGraphics + StI + Jmp MouseUpdateEnable + +EndP ForceMouseRestore + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_MSG.ASM b/it_msg.s similarity index 96% rename from IT_MSG.ASM rename to it_msg.s index 8b25efd..817ee39 100644 --- a/IT_MSG.ASM +++ b/it_msg.s @@ -1,1031 +1,1031 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Message Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - .386 - Jumps - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Extrn M_FunctionDivider:Far - Extrn M_Object1List:Far - Extrn S_GetDestination:Far - Extrn O1_LongMessageList:Far - Extrn O1_ConfirmClearMessage:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global Msg_ResetMessage:Far - Global Msg_DrawMessage:Far - Global Msg_PreMessage:Far - Global Msg_PostMessage:Far - Global Msg_GetMessageLength:Far - Global Msg_GetMessageOffset:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Message BYTE Public 'Code' USE16 - Assume CS:Message, DS:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -MESSAGELENGTH Equ 8000 - -TopLine DW 0 -CurrentPosition DW 0 -MessageData DB MESSAGELENGTH Dup (0) - DW 0 ; Security -MessageDataTerminator DB 0 -Edit DB 0 ; if Edit=1, show '' for enter. -HorizontalPosition DW 0 -CurrentLine DW 0 -CharacterColour DB 12 - -NoEditKeys Label - DB 0 - DW 1C8h ; Up arrow - DW Msg_ViewMsgUp - - DB 0 - DW 1D0h ; Down arrow - DW Msg_ViewMsgDown - - DB 0 - DW 1C9h - DW Msg_ViewMsgPgUp - - DB 0 - DW 1D1h - DW Msg_ViewMsgPgDn - - DB 0 - DW 11Ch - DW Msg_ViewMsgEdit - - DB 1 - DW 'T'-'@' ; Ctrl 'T' - DW Msg_ToggleCharacterSet - - DB 0FFh ; End of List - -EditMsgKeys Label - DB 0 - DW 1C7h - DW Msg_EditMsgHome - - DB 0 - DW 1CFh - DW Msg_EditMsgEnd - - DB 0 - DW 1CBh - DW Msg_EditMsgLeft - - DB 0 - DW 1CDh - DW Msg_EditMsgRight - - DB 0 - DW 1C8h ; Up arrow - DW Msg_EditMsgUp - - DB 0 - DW 1D0h ; Down arrow - DW Msg_EditMsgDown - - DB 0 - DW 1C9h ; PgUp - DW Msg_EditMsgPgUp - - DB 0 - DW 1D1h ; PgDn - DW Msg_EditMsgPgDn - -; DB 2 -; DW 1C8h ; Up arrow -; DW Msg_ViewMsgUp -; -; DB 2 -; DW 1D0h ; Down arrow -; DW Msg_ViewMsgDown - - DB 0 - DW 1D2h ; Insert - DW Msg_EditMsgInsert - - DB 0 - DW 10Fh - DW Msg_Tab - - DB 0 - DW 1D3h ; Delete - DW Msg_EditMsgDelete - - DB 0 - DW 101h ; Escape - DW Msg_EditMsgView - - DB 0 - DW 10Eh ; Backspace - DW Msg_EditMsgBackSpace - - DB 1 - DW 19h - DW Msg_EditMsgDeleteLine - - DB 1 - DW 2E00h ; Alt 'C' - DW Msg_ClearMessage - - DB 1 - DW 'T'-'@' ; Ctrl 'T' - DW Msg_ToggleCharacterSet - - DB 0FFh - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_ResetMessage Far - - Push CS - Pop ES - Mov DI, Offset MessageData - Xor AX, AX - Mov CX, 4000 - Rep StosW - - Mov CS:Edit, 0 - Mov CS:TopLine, 0 - - Ret - -EndP Msg_ResetMessage - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_DrawMessage Far - - Call S_GetDestination - - Push CS - Pop DS - Assume DS:Message - - Cmp Edit, 0 - JE Msg_DrawMessage7 - - Mov SI, Offset MessageData - Mov CX, CurrentPosition - Xor DX, DX ; DX = line count. - Xor BX, BX ; BX = cursor position. - JCXZ Msg_DrawMessage4 - -Msg_DrawMessage1: - LodsB - Test AL, AL - JZ Msg_DrawMessage4 - - Inc BX - - Cmp AL, 13 ; Enter? - JNE Msg_DrawMessage2 - - Inc DX ; Increase current line. - Xor BX, BX - -Msg_DrawMessage2: - Loop Msg_DrawMessage1 - -Msg_DrawMessage4: - Mov CurrentLine, DX - Mov HorizontalPosition, BX - - Mov AX, TopLine ; Boundary checking... - Cmp AX, DX - JBE Msg_DrawMessage5 - - Mov AX, DX ; Need new top line. - -Msg_DrawMessage5: - LEA CX, [EAX+34] - Cmp CX, DX - JAE Msg_DrawMessage6 - - Mov AX, DX - Sub AX, 34 - JNC Msg_DrawMessage6 - - Xor AX, AX - -Msg_DrawMessage6: - Mov TopLine, AX - ; Now to get the stuff onto - ; the screen... -Msg_DrawMessage7: - Mov CX, TopLine - Mov SI, Offset MessageData - JCXZ Msg_DrawMessage9 - -Msg_DrawMessage8: - LodsB - And AL, AL - JZ Msg_DrawMessageEnd - - Cmp AL, 13 - JNE Msg_DrawMessage8 - Loop Msg_DrawMessage8 - -Msg_DrawMessage9: - Mov DI, (2+13*80)*2 - Mov BL, CharacterColour - Mov CX, 35 - Mov DX, 20+100h - Mov AH, BL - - Push DI - - Cmp Edit, 1 - JE Msg_DrawMessage10 - - Mov DX, 300h - -Msg_DrawMessage10: - LodsB - And AL, AL - JZ Msg_DrawMessage12 - - Cmp AL, 13 - JE Msg_DrawMessage11 - - Cmp AL, ' ' - JE Msg_DrawMessage14 - - StosW - Jmp Msg_DrawMessage10 - -Msg_DrawMessage14: - Mov AH, 3 - StosW - Mov AH, BL - Jmp Msg_DrawMessage10 - -Msg_DrawMessage11: - Mov AX, DX - StosW - - Mov AH, BL - - Pop DI - Add DI, 160 - Push DI - - Loop Msg_DrawMessage10 - Jmp Msg_DrawMessage13 - -Msg_DrawMessage12: - Mov AX, DX - Inc AH - StosW - -Msg_DrawMessage13: - Pop DI - -Msg_DrawMessageEnd: - Ret - -EndP Msg_DrawMessage - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_PreMessage Far - - Push CS - Pop DS - Assume DS:Message - - Cmp Edit, 0 - JE Msg_PreMessage1 - - Call S_GetDestination - - Mov AX, CurrentLine - Sub AX, TopLine - Mov BX, 80 - Mul BX - Add AX, HorizontalPosition - LEA DI, [EAX*2+(2+13*80)*2+1] - - And Byte Ptr [ES:DI], 8 - Or Byte Ptr [ES:DI], 30h - -Msg_PreMessage1: - Ret - -EndP Msg_PreMessage - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_PostMessage Far - - Push CS - Pop DS - - Cmp Edit, 0 - JNE Msg_PostMessage2 - - Mov SI, Offset NoEditKeys - Call M_FunctionDivider - JC Msg_PostMessage1 - - Jmp [SI] - -Msg_PostMessage1: - Xor AX, AX - Ret - -Msg_PostMessage2: - Mov SI, Offset EditMsgKeys - Call M_FunctionDivider - JC Msg_PostMessage3 - - Jmp [SI] - -Msg_PostMessage3: - Cmp CX, 11Ch ; Enter - JE Msg_PostMessage6 - Test CL, CL - JZ Msg_PostMessage1 - - Cmp DL, 32 - JB Msg_PostMessage1 - Jmp Msg_PostMessage4 - -Msg_PostMessage6: - Mov DL, 13 - -Msg_PostMessage4: - Push DX - - Mov DX, 1 - Mov SI, CurrentPosition - Call InsertData - - Pop DX - - JC Msg_PostMessage5 - - Mov [SI+MessageData], DL - Call CheckWordWrap - Jmp Msg_EditMsgRight - -Msg_PostMessage5: - Mov AX, 1 - Ret - -EndP Msg_PostMessage - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_Tab Far - - Mov CX, 8 - -Msg_Tab1: - Push CX - Mov DX, 32 - Call Far Ptr Msg_PostMessage4 - Pop CX - Loop Msg_Tab1 - - Ret - - -EndP Msg_Tab - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_ViewMsgUp Far - Assume DS:Message - - Mov AX, TopLine - Sub AX, 1 - AdC AX, 0 - Mov TopLine, AX - - Mov AX, 1 - Ret - -EndP Msg_ViewMsgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_ViewMsgDown Far - Assume DS:Message - - Mov AX, TopLine - Inc AX - Cmp AX, 7970 - JB Msg_ViewMsgDown1 - - Mov AX, 7970 - -Msg_ViewMsgDown1: - Mov TopLine, AX - - Mov AX, 1 - Ret - -EndP Msg_ViewMsgDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_ViewMsgPgUp Far - Assume DS:Message - - Mov AX, TopLine - Sub AX, 35 - JNC Msg_ViewMsgPgUp1 - - Xor AX, AX - -Msg_ViewMsgPgUp1: - Mov TopLine, AX - - Mov AX, 1 - Ret - -EndP Msg_ViewMsgPgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_ViewMsgPgDn Far - Assume DS:Message - - Mov AX, TopLine - Add AX, 35 - Cmp AX, 7970 - JB Msg_ViewMsgPgDn1 - - Mov AX, 7970 - -Msg_ViewMsgPgDn1: - Mov TopLine, AX - - Mov AX, 1 - Ret - -EndP Msg_ViewMsgPgDn - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_ViewMsgEdit Far - Assume DS:Message - - Mov TopLine, 0 - Mov CurrentLine, 0 - Mov CurrentPosition, 0 - Mov Edit, 1 - - Mov AX, 1 - Ret - -EndP Msg_ViewMsgEdit - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgView Far - Assume DS:Message - - Mov Edit, 0 - - Mov AX, 1 - Ret - -EndP Msg_EditMsgView - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgLeft Far - Assume DS:Message - - Sub CurrentPosition, 1 - AdC CurrentPosition, 0 - - Mov AX, 1 - Ret - -EndP Msg_EditMsgLeft - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgRight Far - Assume DS:Message - - Mov SI, CurrentPosition - Cmp SI, MESSAGELENGTH-2 - JAE Msg_EditMsgRight1 - - Cmp Word Ptr [SI+MessageData], 0 - JE Msg_EditMsgRight1 - - Inc CurrentPosition - -Msg_EditMsgRight1: - Mov AX, 1 - Ret - -EndP Msg_EditMsgRight - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgUp Far - Assume DS:Message - - Mov SI, CurrentPosition ; Need to search back - ; twice... - Call FindStart - And SI, SI - JZ Msg_EditMsgUpEnd - Dec SI - Call FindStart - - Add SI, Offset MessageData - - Mov CX, HorizontalPosition - JCXZ Msg_EditMsgUp3 - -Msg_EditMsgUp2: - LodsB - Cmp AL, 13 - LoopNE Msg_EditMsgUp2 - JNE Msg_EditMsgUp3 - - Dec SI - -Msg_EditMsgUp3: - Sub SI, Offset MessageData - Mov CurrentPosition, SI - -Msg_EditMsgUpEnd: - Mov AX, 1 - Ret - -EndP Msg_EditMsgUp - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgPgUp Far - - Mov CX, 35 - -Msg_EditMsgPgUp1: - Push CX - Call Msg_EditMsgUp - Pop CX - Loop Msg_EditMsgPgUp1 - - Mov AX, 1 - Ret - -EndP Msg_EditMsgPgUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgDown Far - Assume DS:Message - ; Search for enter - Mov SI, CurrentPosition - -Msg_EditMsgDown1: - Mov AL, [SI+MessageData] - Inc SI - And AL, AL - JZ Msg_EditMsgDownEnd - - Cmp AL, 13 - JNE Msg_EditMsgDown1 - - Mov CX, HorizontalPosition - JCXZ Msg_EditMsgDown3 - -Msg_EditMsgDown2: - Mov AL, [SI+MessageData] - And AL, AL - JZ Msg_EditMsgDown3 - - Cmp AL, 13 - JE Msg_EditMsgDown3 - - Inc SI - Loop Msg_EditMsgDown2 - -Msg_EditMsgDown3: - Cmp SI, MESSAGELENGTH-2 - JAE Msg_EditMsgDownEnd - - Mov CurrentPosition, SI - -Msg_EditMsgDownEnd: - Mov AX, 1 - Ret - -EndP Msg_EditMsgDown - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgPgDn Far - - Mov CX, 35 - -Msg_EditMsgPgDn1: - Push CX - Call Msg_EditMsgDown - Pop CX - Loop Msg_EditMsgPgDn1 - - Mov AX, 1 - Ret - -EndP Msg_EditMsgPgDn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgDelete Far - Assume DS:Message - - Mov SI, CurrentPosition - Mov DX, 1 - Call DeleteData - Call CheckWordWrap - - Mov AX, 1 - Ret - -EndP Msg_EditMsgDelete - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgInsert Far - - Mov SI, CurrentPosition - Mov DX, 1 - Call InsertData - JC Msg_EditMsgInsert1 - - Mov Byte Ptr [SI+MessageData], 32 - Call CheckWordWrap - -Msg_EditMsgInsert1: - Mov AX, 1 - Ret - -EndP Msg_EditMsgInsert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgBackspace Far - Assume DS:Message - - Mov SI, CurrentPosition - And SI, SI - JZ Msg_EditMsgBackspace1 - - Call Msg_EditMsgLeft - Call Msg_EditMsgDelete - -Msg_EditMsgBackspace1: - Mov AX, 1 - Ret - -EndP Msg_EditMsgBackspace - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgDeleteLine Far - Assume DS:Message - - Mov SI, CurrentPosition ; Search back for - ; start of line.. - Call FindStart - - ; Find length to delete. - Xor BX, BX ; DI = length - -Msg_EditMsgDeleteLine3: - Mov AL, [SI+BX+MessageData] - Inc BX - - And AL, AL - JZ Msg_EditMsgDeleteLine4 - Cmp AL, 13 - JNE Msg_EditMsgDeleteLine3 - -Msg_EditMsgDeleteLine4: - Mov DX, BX - Call DeleteData - - Mov CurrentPosition, SI - - Mov AX, 1 - Ret - -EndP Msg_EditMsgDeleteLine - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_ClearMessage Far - - Mov DI, Offset O1_ConfirmClearMessage - Mov CX, 4 - Call M_Object1List - - And DX, DX - JZ Msg_ClearMessage1 - - Call Msg_ResetMessage - -Msg_ClearMessage1: - Mov AX, 1 - Ret - -EndP Msg_ClearMessage - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgHome Far - Assume DS:Message - - Mov SI, CurrentPosition - Call FindStart - Mov CurrentPosition, SI - - Mov AX, 1 - Ret - -EndP Msg_EditMsgHome - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_EditMsgEnd Far - Assume DS:Message - - Mov SI, CurrentPosition - -Msg_EditMsgEndLoop: - Mov AL, [SI+MessageData] - - Inc SI - - And AL, AL - JZ Msg_EditMsgEnd1 - - Cmp AL, 13 - JNE Msg_EditMsgEndLoop - -Msg_EditMsgEnd1: - Dec SI - Mov CurrentPosition, SI - - Mov AX, 1 - Ret - -EndP Msg_EditMsgEnd - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc FindStart - -FindStart1: - Sub SI, 1 - JC FindStart2 - - Cmp Byte Ptr [SI+MessageData], 13 - JNE FindStart1 - -FindStart2: - Inc SI - Ret - -EndP FindStart - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InsertData ; SI = pos, DX = length. - - Push CX - Push DX - Push SI - - Mov CX, MESSAGELENGTH-1 - Sub CX, SI - Sub CX, DX - - Mov SI, Offset MessageData+MESSAGELENGTH-2 - Mov DI, SI - Sub SI, DX - - Cmp Byte Ptr [SI], 0 - JNE InsertDataError - - Push DS - Pop ES - - StD - Rep MovsB - ClD - - ClC - Jmp InsertDataEnd - -InsertDataError: - Push DS - - Mov DI, Offset O1_LongMessageList - Mov CX, 2 - Call M_Object1List - - Pop DS - - StC - -InsertDataEnd: - Pop SI - Pop DX - Pop CX - Ret - -EndP InsertData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc DeleteData ; SI = pos, DX = length - ; Assume DS:Message - - Push CX - Push DX - Push SI - - Push CS - Pop ES - - Mov CX, MESSAGELENGTH - Sub CX, SI - Sub CX, DX - JS DeleteData1 - - Add SI, Offset MessageData - Mov DI, SI - Add SI, DX - - Rep MovsB - - Xor AX, AX - Mov CX, DX - Rep StosB - -DeleteData1: - Pop SI - Pop DX - Pop CX - Ret - -EndP DeleteData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckWordWrap ; Check current line only. - - Mov SI, CurrentPosition - Call FindStart - - ; OK, so SI = pos of last line. - ; Now count length of new line. - Xor BX, BX ; BX = count. - -CheckWordWrap3: - Mov AL, [SI+BX+MessageData] - - Inc BX - - And AL, AL - JZ CheckWordWrap4 - Cmp AL, 13 - JNE CheckWordWrap3 - -CheckWordWrap4: ; OK.. now if BX > 66... - Cmp BX, 75 - JA CheckWordWrap5 - - Ret - -CheckWordWrap5: ; Search back for a space and REPLACE - ; it with an enter... - Mov BX, 75 - -CheckWordWrap6: - Dec BX - JZ CheckWordWrap7 - - Cmp Byte Ptr [SI+BX+MessageData], 32 - JNE CheckWordWrap6 - - Mov Byte Ptr [SI+BX+MessageData], 13 - - Ret - -CheckWordWrap7: ; Insert an enter - Mov DX, 1 - Add SI, 75 - Call InsertData - Mov Byte Ptr [SI+MessageData], 13 - -CheckWordWrap8: - Ret - -EndP CheckWordWrap - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_GetMessageLength Far ; Returns AX - - Push DS - Push SI - - Push CS - Pop DS - - Mov SI, Offset MessageData - -Msg_GetMessageLength1: - LodsB - And AL, AL - JNZ Msg_GetMessageLength1 - - Sub SI, Offset MessageData - Mov AX, SI - - Pop SI - Pop DS - Ret - -EndP Msg_GetMessageLength - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_GetMessageOffset Far - - Push CS - Pop DS - - Mov DX, Offset MessageData - Ret - -EndP Msg_GetMessageOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Msg_ToggleCharacterSet Far - Assume DS:Message - - Xor CharacterColour, 6 xor 12 - - Mov AX, 1 - Ret - -EndP Msg_ToggleCharacterSet - Assume DS:Nothing - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Message Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + .386 + Jumps + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Extrn M_FunctionDivider:Far + Extrn M_Object1List:Far + Extrn S_GetDestination:Far + Extrn O1_LongMessageList:Far + Extrn O1_ConfirmClearMessage:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global Msg_ResetMessage:Far + Global Msg_DrawMessage:Far + Global Msg_PreMessage:Far + Global Msg_PostMessage:Far + Global Msg_GetMessageLength:Far + Global Msg_GetMessageOffset:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Message BYTE Public 'Code' USE16 + Assume CS:Message, DS:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +MESSAGELENGTH Equ 8000 + +TopLine DW 0 +CurrentPosition DW 0 +MessageData DB MESSAGELENGTH Dup (0) + DW 0 ; Security +MessageDataTerminator DB 0 +Edit DB 0 ; if Edit=1, show '' for enter. +HorizontalPosition DW 0 +CurrentLine DW 0 +CharacterColour DB 12 + +NoEditKeys Label + DB 0 + DW 1C8h ; Up arrow + DW Msg_ViewMsgUp + + DB 0 + DW 1D0h ; Down arrow + DW Msg_ViewMsgDown + + DB 0 + DW 1C9h + DW Msg_ViewMsgPgUp + + DB 0 + DW 1D1h + DW Msg_ViewMsgPgDn + + DB 0 + DW 11Ch + DW Msg_ViewMsgEdit + + DB 1 + DW 'T'-'@' ; Ctrl 'T' + DW Msg_ToggleCharacterSet + + DB 0FFh ; End of List + +EditMsgKeys Label + DB 0 + DW 1C7h + DW Msg_EditMsgHome + + DB 0 + DW 1CFh + DW Msg_EditMsgEnd + + DB 0 + DW 1CBh + DW Msg_EditMsgLeft + + DB 0 + DW 1CDh + DW Msg_EditMsgRight + + DB 0 + DW 1C8h ; Up arrow + DW Msg_EditMsgUp + + DB 0 + DW 1D0h ; Down arrow + DW Msg_EditMsgDown + + DB 0 + DW 1C9h ; PgUp + DW Msg_EditMsgPgUp + + DB 0 + DW 1D1h ; PgDn + DW Msg_EditMsgPgDn + +; DB 2 +; DW 1C8h ; Up arrow +; DW Msg_ViewMsgUp +; +; DB 2 +; DW 1D0h ; Down arrow +; DW Msg_ViewMsgDown + + DB 0 + DW 1D2h ; Insert + DW Msg_EditMsgInsert + + DB 0 + DW 10Fh + DW Msg_Tab + + DB 0 + DW 1D3h ; Delete + DW Msg_EditMsgDelete + + DB 0 + DW 101h ; Escape + DW Msg_EditMsgView + + DB 0 + DW 10Eh ; Backspace + DW Msg_EditMsgBackSpace + + DB 1 + DW 19h + DW Msg_EditMsgDeleteLine + + DB 1 + DW 2E00h ; Alt 'C' + DW Msg_ClearMessage + + DB 1 + DW 'T'-'@' ; Ctrl 'T' + DW Msg_ToggleCharacterSet + + DB 0FFh + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_ResetMessage Far + + Push CS + Pop ES + Mov DI, Offset MessageData + Xor AX, AX + Mov CX, 4000 + Rep StosW + + Mov CS:Edit, 0 + Mov CS:TopLine, 0 + + Ret + +EndP Msg_ResetMessage + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_DrawMessage Far + + Call S_GetDestination + + Push CS + Pop DS + Assume DS:Message + + Cmp Edit, 0 + JE Msg_DrawMessage7 + + Mov SI, Offset MessageData + Mov CX, CurrentPosition + Xor DX, DX ; DX = line count. + Xor BX, BX ; BX = cursor position. + JCXZ Msg_DrawMessage4 + +Msg_DrawMessage1: + LodsB + Test AL, AL + JZ Msg_DrawMessage4 + + Inc BX + + Cmp AL, 13 ; Enter? + JNE Msg_DrawMessage2 + + Inc DX ; Increase current line. + Xor BX, BX + +Msg_DrawMessage2: + Loop Msg_DrawMessage1 + +Msg_DrawMessage4: + Mov CurrentLine, DX + Mov HorizontalPosition, BX + + Mov AX, TopLine ; Boundary checking... + Cmp AX, DX + JBE Msg_DrawMessage5 + + Mov AX, DX ; Need new top line. + +Msg_DrawMessage5: + LEA CX, [EAX+34] + Cmp CX, DX + JAE Msg_DrawMessage6 + + Mov AX, DX + Sub AX, 34 + JNC Msg_DrawMessage6 + + Xor AX, AX + +Msg_DrawMessage6: + Mov TopLine, AX + ; Now to get the stuff onto + ; the screen... +Msg_DrawMessage7: + Mov CX, TopLine + Mov SI, Offset MessageData + JCXZ Msg_DrawMessage9 + +Msg_DrawMessage8: + LodsB + And AL, AL + JZ Msg_DrawMessageEnd + + Cmp AL, 13 + JNE Msg_DrawMessage8 + Loop Msg_DrawMessage8 + +Msg_DrawMessage9: + Mov DI, (2+13*80)*2 + Mov BL, CharacterColour + Mov CX, 35 + Mov DX, 20+100h + Mov AH, BL + + Push DI + + Cmp Edit, 1 + JE Msg_DrawMessage10 + + Mov DX, 300h + +Msg_DrawMessage10: + LodsB + And AL, AL + JZ Msg_DrawMessage12 + + Cmp AL, 13 + JE Msg_DrawMessage11 + + Cmp AL, ' ' + JE Msg_DrawMessage14 + + StosW + Jmp Msg_DrawMessage10 + +Msg_DrawMessage14: + Mov AH, 3 + StosW + Mov AH, BL + Jmp Msg_DrawMessage10 + +Msg_DrawMessage11: + Mov AX, DX + StosW + + Mov AH, BL + + Pop DI + Add DI, 160 + Push DI + + Loop Msg_DrawMessage10 + Jmp Msg_DrawMessage13 + +Msg_DrawMessage12: + Mov AX, DX + Inc AH + StosW + +Msg_DrawMessage13: + Pop DI + +Msg_DrawMessageEnd: + Ret + +EndP Msg_DrawMessage + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_PreMessage Far + + Push CS + Pop DS + Assume DS:Message + + Cmp Edit, 0 + JE Msg_PreMessage1 + + Call S_GetDestination + + Mov AX, CurrentLine + Sub AX, TopLine + Mov BX, 80 + Mul BX + Add AX, HorizontalPosition + LEA DI, [EAX*2+(2+13*80)*2+1] + + And Byte Ptr [ES:DI], 8 + Or Byte Ptr [ES:DI], 30h + +Msg_PreMessage1: + Ret + +EndP Msg_PreMessage + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_PostMessage Far + + Push CS + Pop DS + + Cmp Edit, 0 + JNE Msg_PostMessage2 + + Mov SI, Offset NoEditKeys + Call M_FunctionDivider + JC Msg_PostMessage1 + + Jmp [SI] + +Msg_PostMessage1: + Xor AX, AX + Ret + +Msg_PostMessage2: + Mov SI, Offset EditMsgKeys + Call M_FunctionDivider + JC Msg_PostMessage3 + + Jmp [SI] + +Msg_PostMessage3: + Cmp CX, 11Ch ; Enter + JE Msg_PostMessage6 + Test CL, CL + JZ Msg_PostMessage1 + + Cmp DL, 32 + JB Msg_PostMessage1 + Jmp Msg_PostMessage4 + +Msg_PostMessage6: + Mov DL, 13 + +Msg_PostMessage4: + Push DX + + Mov DX, 1 + Mov SI, CurrentPosition + Call InsertData + + Pop DX + + JC Msg_PostMessage5 + + Mov [SI+MessageData], DL + Call CheckWordWrap + Jmp Msg_EditMsgRight + +Msg_PostMessage5: + Mov AX, 1 + Ret + +EndP Msg_PostMessage + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_Tab Far + + Mov CX, 8 + +Msg_Tab1: + Push CX + Mov DX, 32 + Call Far Ptr Msg_PostMessage4 + Pop CX + Loop Msg_Tab1 + + Ret + + +EndP Msg_Tab + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_ViewMsgUp Far + Assume DS:Message + + Mov AX, TopLine + Sub AX, 1 + AdC AX, 0 + Mov TopLine, AX + + Mov AX, 1 + Ret + +EndP Msg_ViewMsgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_ViewMsgDown Far + Assume DS:Message + + Mov AX, TopLine + Inc AX + Cmp AX, 7970 + JB Msg_ViewMsgDown1 + + Mov AX, 7970 + +Msg_ViewMsgDown1: + Mov TopLine, AX + + Mov AX, 1 + Ret + +EndP Msg_ViewMsgDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_ViewMsgPgUp Far + Assume DS:Message + + Mov AX, TopLine + Sub AX, 35 + JNC Msg_ViewMsgPgUp1 + + Xor AX, AX + +Msg_ViewMsgPgUp1: + Mov TopLine, AX + + Mov AX, 1 + Ret + +EndP Msg_ViewMsgPgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_ViewMsgPgDn Far + Assume DS:Message + + Mov AX, TopLine + Add AX, 35 + Cmp AX, 7970 + JB Msg_ViewMsgPgDn1 + + Mov AX, 7970 + +Msg_ViewMsgPgDn1: + Mov TopLine, AX + + Mov AX, 1 + Ret + +EndP Msg_ViewMsgPgDn + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_ViewMsgEdit Far + Assume DS:Message + + Mov TopLine, 0 + Mov CurrentLine, 0 + Mov CurrentPosition, 0 + Mov Edit, 1 + + Mov AX, 1 + Ret + +EndP Msg_ViewMsgEdit + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgView Far + Assume DS:Message + + Mov Edit, 0 + + Mov AX, 1 + Ret + +EndP Msg_EditMsgView + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgLeft Far + Assume DS:Message + + Sub CurrentPosition, 1 + AdC CurrentPosition, 0 + + Mov AX, 1 + Ret + +EndP Msg_EditMsgLeft + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgRight Far + Assume DS:Message + + Mov SI, CurrentPosition + Cmp SI, MESSAGELENGTH-2 + JAE Msg_EditMsgRight1 + + Cmp Word Ptr [SI+MessageData], 0 + JE Msg_EditMsgRight1 + + Inc CurrentPosition + +Msg_EditMsgRight1: + Mov AX, 1 + Ret + +EndP Msg_EditMsgRight + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgUp Far + Assume DS:Message + + Mov SI, CurrentPosition ; Need to search back + ; twice... + Call FindStart + And SI, SI + JZ Msg_EditMsgUpEnd + Dec SI + Call FindStart + + Add SI, Offset MessageData + + Mov CX, HorizontalPosition + JCXZ Msg_EditMsgUp3 + +Msg_EditMsgUp2: + LodsB + Cmp AL, 13 + LoopNE Msg_EditMsgUp2 + JNE Msg_EditMsgUp3 + + Dec SI + +Msg_EditMsgUp3: + Sub SI, Offset MessageData + Mov CurrentPosition, SI + +Msg_EditMsgUpEnd: + Mov AX, 1 + Ret + +EndP Msg_EditMsgUp + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgPgUp Far + + Mov CX, 35 + +Msg_EditMsgPgUp1: + Push CX + Call Msg_EditMsgUp + Pop CX + Loop Msg_EditMsgPgUp1 + + Mov AX, 1 + Ret + +EndP Msg_EditMsgPgUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgDown Far + Assume DS:Message + ; Search for enter + Mov SI, CurrentPosition + +Msg_EditMsgDown1: + Mov AL, [SI+MessageData] + Inc SI + And AL, AL + JZ Msg_EditMsgDownEnd + + Cmp AL, 13 + JNE Msg_EditMsgDown1 + + Mov CX, HorizontalPosition + JCXZ Msg_EditMsgDown3 + +Msg_EditMsgDown2: + Mov AL, [SI+MessageData] + And AL, AL + JZ Msg_EditMsgDown3 + + Cmp AL, 13 + JE Msg_EditMsgDown3 + + Inc SI + Loop Msg_EditMsgDown2 + +Msg_EditMsgDown3: + Cmp SI, MESSAGELENGTH-2 + JAE Msg_EditMsgDownEnd + + Mov CurrentPosition, SI + +Msg_EditMsgDownEnd: + Mov AX, 1 + Ret + +EndP Msg_EditMsgDown + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgPgDn Far + + Mov CX, 35 + +Msg_EditMsgPgDn1: + Push CX + Call Msg_EditMsgDown + Pop CX + Loop Msg_EditMsgPgDn1 + + Mov AX, 1 + Ret + +EndP Msg_EditMsgPgDn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgDelete Far + Assume DS:Message + + Mov SI, CurrentPosition + Mov DX, 1 + Call DeleteData + Call CheckWordWrap + + Mov AX, 1 + Ret + +EndP Msg_EditMsgDelete + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgInsert Far + + Mov SI, CurrentPosition + Mov DX, 1 + Call InsertData + JC Msg_EditMsgInsert1 + + Mov Byte Ptr [SI+MessageData], 32 + Call CheckWordWrap + +Msg_EditMsgInsert1: + Mov AX, 1 + Ret + +EndP Msg_EditMsgInsert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgBackspace Far + Assume DS:Message + + Mov SI, CurrentPosition + And SI, SI + JZ Msg_EditMsgBackspace1 + + Call Msg_EditMsgLeft + Call Msg_EditMsgDelete + +Msg_EditMsgBackspace1: + Mov AX, 1 + Ret + +EndP Msg_EditMsgBackspace + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgDeleteLine Far + Assume DS:Message + + Mov SI, CurrentPosition ; Search back for + ; start of line.. + Call FindStart + + ; Find length to delete. + Xor BX, BX ; DI = length + +Msg_EditMsgDeleteLine3: + Mov AL, [SI+BX+MessageData] + Inc BX + + And AL, AL + JZ Msg_EditMsgDeleteLine4 + Cmp AL, 13 + JNE Msg_EditMsgDeleteLine3 + +Msg_EditMsgDeleteLine4: + Mov DX, BX + Call DeleteData + + Mov CurrentPosition, SI + + Mov AX, 1 + Ret + +EndP Msg_EditMsgDeleteLine + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_ClearMessage Far + + Mov DI, Offset O1_ConfirmClearMessage + Mov CX, 4 + Call M_Object1List + + And DX, DX + JZ Msg_ClearMessage1 + + Call Msg_ResetMessage + +Msg_ClearMessage1: + Mov AX, 1 + Ret + +EndP Msg_ClearMessage + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgHome Far + Assume DS:Message + + Mov SI, CurrentPosition + Call FindStart + Mov CurrentPosition, SI + + Mov AX, 1 + Ret + +EndP Msg_EditMsgHome + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_EditMsgEnd Far + Assume DS:Message + + Mov SI, CurrentPosition + +Msg_EditMsgEndLoop: + Mov AL, [SI+MessageData] + + Inc SI + + And AL, AL + JZ Msg_EditMsgEnd1 + + Cmp AL, 13 + JNE Msg_EditMsgEndLoop + +Msg_EditMsgEnd1: + Dec SI + Mov CurrentPosition, SI + + Mov AX, 1 + Ret + +EndP Msg_EditMsgEnd + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc FindStart + +FindStart1: + Sub SI, 1 + JC FindStart2 + + Cmp Byte Ptr [SI+MessageData], 13 + JNE FindStart1 + +FindStart2: + Inc SI + Ret + +EndP FindStart + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InsertData ; SI = pos, DX = length. + + Push CX + Push DX + Push SI + + Mov CX, MESSAGELENGTH-1 + Sub CX, SI + Sub CX, DX + + Mov SI, Offset MessageData+MESSAGELENGTH-2 + Mov DI, SI + Sub SI, DX + + Cmp Byte Ptr [SI], 0 + JNE InsertDataError + + Push DS + Pop ES + + StD + Rep MovsB + ClD + + ClC + Jmp InsertDataEnd + +InsertDataError: + Push DS + + Mov DI, Offset O1_LongMessageList + Mov CX, 2 + Call M_Object1List + + Pop DS + + StC + +InsertDataEnd: + Pop SI + Pop DX + Pop CX + Ret + +EndP InsertData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc DeleteData ; SI = pos, DX = length + ; Assume DS:Message + + Push CX + Push DX + Push SI + + Push CS + Pop ES + + Mov CX, MESSAGELENGTH + Sub CX, SI + Sub CX, DX + JS DeleteData1 + + Add SI, Offset MessageData + Mov DI, SI + Add SI, DX + + Rep MovsB + + Xor AX, AX + Mov CX, DX + Rep StosB + +DeleteData1: + Pop SI + Pop DX + Pop CX + Ret + +EndP DeleteData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckWordWrap ; Check current line only. + + Mov SI, CurrentPosition + Call FindStart + + ; OK, so SI = pos of last line. + ; Now count length of new line. + Xor BX, BX ; BX = count. + +CheckWordWrap3: + Mov AL, [SI+BX+MessageData] + + Inc BX + + And AL, AL + JZ CheckWordWrap4 + Cmp AL, 13 + JNE CheckWordWrap3 + +CheckWordWrap4: ; OK.. now if BX > 66... + Cmp BX, 75 + JA CheckWordWrap5 + + Ret + +CheckWordWrap5: ; Search back for a space and REPLACE + ; it with an enter... + Mov BX, 75 + +CheckWordWrap6: + Dec BX + JZ CheckWordWrap7 + + Cmp Byte Ptr [SI+BX+MessageData], 32 + JNE CheckWordWrap6 + + Mov Byte Ptr [SI+BX+MessageData], 13 + + Ret + +CheckWordWrap7: ; Insert an enter + Mov DX, 1 + Add SI, 75 + Call InsertData + Mov Byte Ptr [SI+MessageData], 13 + +CheckWordWrap8: + Ret + +EndP CheckWordWrap + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_GetMessageLength Far ; Returns AX + + Push DS + Push SI + + Push CS + Pop DS + + Mov SI, Offset MessageData + +Msg_GetMessageLength1: + LodsB + And AL, AL + JNZ Msg_GetMessageLength1 + + Sub SI, Offset MessageData + Mov AX, SI + + Pop SI + Pop DS + Ret + +EndP Msg_GetMessageLength + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_GetMessageOffset Far + + Push CS + Pop DS + + Mov DX, Offset MessageData + Ret + +EndP Msg_GetMessageOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Msg_ToggleCharacterSet Far + Assume DS:Message + + Xor CharacterColour, 6 xor 12 + + Mov AX, 1 + Ret + +EndP Msg_ToggleCharacterSet + Assume DS:Nothing + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_MUSIC.ASM b/it_music.s similarity index 96% rename from IT_MUSIC.ASM rename to it_music.s index ce4deba..8c78bb6 100644 --- a/IT_MUSIC.ASM +++ b/it_music.s @@ -1,7481 +1,7481 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Music Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - .386 - .387 - -include switch.inc -include network.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Extrn D_GotoStartingDirectory:Far - Extrn D_SetDriveDirectoryFar:Far - Extrn D_GetFileName:Far - Extrn D_Showtime:Far - - Extrn E_EMSAvailable:Far - Extrn E_SaveEMSPageFrame:Far - Extrn E_RestoreEMSPageFrame:Far - Extrn E_UnInitEMS:Far - Extrn E_AllocateEMS:Far - Extrn E_MapEMSMemory:Far - Extrn E_GetEMSPageFrame:Far - Extrn E_ReleaseEMS:Far - Extrn E_AllocateBlockEMS:Far, E_ReleaseBlockEMS:Far - Extrn E_MapAlignedBlockEMS:Far - Extrn E_GetInternalEMSHandle:Far - - Extrn I_TagInstrument:Far - Extrn I_TagSample:Far - - Extrn O1_OutOfSoundCardMemoryList:Far - - Extrn M_FunctionHandler:Far - Extrn M_Object1List:Far - - Extrn Network_UpdatePatternIfIdle:Far - - Extrn PE_GetCurrentPattern:Far - Extrn PE_FillHeader:Far - Extrn S_GetDestination:Far - Extrn S_UnInitScreen:Far - Extrn S_DirectDrawString:Far - Extrn S_DrawString:Far - Extrn S_SetDirectMode:Far - Extrn S_SaveScreen:Far - Extrn S_RestoreScreen:Far - Extrn S_DrawBox:Far - Extrn S_DrawString:Far - Extrn S_UpdateScreen:Far - Extrn S_DrawSmallBox:Far - Extrn F_DrawHeader:Far - - Extrn K_GetKey:Far - Extrn StartClock:Far - Extrn SetInfoLine:Far, SetInfoLine2:Far - Extrn M_Object1List:Far - - Extrn MaxRow - - Extrn IdleUpdateInfoLine:Far - Extrn GlobalKeyList:Far - Extrn GetEnvironment:Far - - Extrn MIDIBufferEmpty:Far, MIDISend:Far, MIDI_ClearTable:Far - Extrn O1_ShowTime - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global Music_GetDisplayVariables:Far - Global Music_AutoDetectSoundCard:Far - - Global Music_Poll:Far - - Global Music_ReinitSoundCard:Far - Global Music_InitMusic:Far - Global Music_UnInitMusic:Far - Global Music_GetSongSegment:Far - Global Music_GetInstrumentMode:Far - Global Music_ReleasePattern:Far - Global Music_GetPattern:Far - Global Music_GetPatternLocation:Far - Global Music_GetPatternLocationNoCount:Far - Global Music_AllocatePattern:Far - Global Music_AllocateSample:Far - Global Music_IncreaseSpeed:Far - Global Music_DecreaseSpeed:Far - Global Music_GetOutputWaveform:Far - Global Music_PlayPartSong:Far - Global Music_GetPatternLength:Far - Global Music_ShowAutodetectSoundcard:Far - Global Music_GetWaveForm:Far - Global Music_ToggleOrderUpdate:Far - - Global Music_NextOrder:Far - Global Music_LastOrder:Far - - Global Music_SetSoundCard:Far - Global Music_SetDMA:Far - Global Music_SetMixSpeed:Far - Global Music_SetIRQ:Far - Global Music_SetAddress:Far - Global Music_SetLimit:Far - Global Music_ReverseChannels:Far - - Global Music_GetNumChannels:Far - Global Music_InitStereo:Far - Global Music_ReleaseSample:Far - Global Music_ReleaseAllSamples:Far - Global Music_ReleaseAllPatterns:Far - Global Music_ClearSampleName:Far - Global Music_ClearAllSampleNames:Far - Global Music_GetNumberOfSamples:Far - Global Music_GetNumberOfInstruments:Far - Global Music_ClearInstrument:Far - Global Music_ClearAllInstruments:Far - Global Music_GetHostChannelInformationTable:Far - Global Music_GetSlaveChannelInformationTable:Far - Global Music_SetGlobalVolume:Far - - Global Music_InitMuteTable:Far - Global Music_UnmuteAll:Far - - Global Music_GetPlayMode:Far - Global Music_GetPlayMode2:Far - Global Music_PlayPattern:Far - Global Music_PlaySample:Far - Global Music_PlayNote:Far - Global Music_Stop:Far - Global Music_PlaySong:Far - Global Music_ToggleChannel:Far - Global Music_SoloChannel:Far - Global Music_InitMixTable:Far - Global Music_GetSampleLocation:Far - Global Music_UpdatePatternOffset:Far - Global Music_AssignSampleToInstrument:Far - Global Music_KBPlaySong:Far - Global Music_IncreaseVolume:Far - Global Music_DecreaseVolume:Far - Global Music_SetSoundCardDriver:Far - Global Music_RegetLoopInformation:Far - - Global Music_SoundCardLoadSample:Far - Global Music_SoundCardLoadAllSamples:Far - Global Music_GetFreeSoundCardMemory:Far - Global Music_GetPitchTable:Far - Global Music_GetMIDIDataArea:Far - - Global Music_ToggleReverse:Far - Global Music_PatternStorage:Far - - Global Music_GetDriverScreen:Far - Global Music_GetLastChannel:Far - - Global SongDataArea:Word - Global MixDataArea:Word - - Global Music_GetDriverVariable:Far, Music_SetDriverVariable:Far - Public Music_GetDelay - Public Music_SetNextOrder - Public Music_TimeSong - Public Music_ShowTime - Public Music_SaveMIDIConfig - Public MIDIDataArea - - Public Music_ToggleSoloInstrument, Music_ToggleSoloSample - - Extrn PE_GetLastInstrument:Far - Public CurrentPattern - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -; -; Functions for playing control -; Music_PlaySong........ parameters, AX = order -; Music_Stop............ parameters, None -; Music_PlayPattern..... parameters, AX = pattern, BX = number of rows, CX = row -; Music_ToggleChannel... parameters, AX = channel -; Music_SoloChannel..... parameters, AX = channel -; - -Segment SongData PARA Public 'Data' -EndS - -Segment Music DWORD Public 'Code' USE16 - Assume CS:Music - -CREATENEWLOGFILE EQU 0 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -HOSTCHANNELSIZE EQU 80 -SLAVECHANNELSIZE EQU 128 -MAXSLAVECHANNELS EQU 256 -NONOTE EQU 0FDh - -MIDICOMMAND_START EQU 0 -MIDICOMMAND_STOP EQU 20h -MIDICOMMAND_TICK EQU 40h -MIDICOMMAND_PLAYNOTE EQU 60h -MIDICOMMAND_STOPNOTE EQU 80h -MIDICOMMAND_CHANGEVOLUME EQU 0A0h -MIDICOMMAND_CHANGEPAN EQU 0C0h -MIDICOMMAND_BANKSELECT EQU 0E0h -MIDICOMMAND_PROGRAMSELECT EQU 100h -MIDICOMMAND_CHANGEPITCH EQU 0FFFFh - -FineSineData Label Byte - DB 0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 19, 20, 22, 23 - DB 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44 - DB 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59 - DB 59, 60, 60, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, 64, 64, 64 - DB 64, 64, 64, 64, 64, 64, 63, 63, 63, 62, 62, 62, 61, 61, 60, 60 - DB 59, 59, 58, 57, 56, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46 - DB 45, 44, 43, 42, 41, 39, 38, 37, 36, 34, 33, 32, 30, 29, 27, 26 - DB 24, 23, 22, 20, 19, 17, 16, 14, 12, 11, 9, 8, 6, 5, 3, 2 - DB 0, -2, -3, -5, -6, -8, -9,-11,-12,-14,-16,-17,-19,-20,-22,-23 - DB -24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42,-43,-44 - DB -45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-56,-57,-58,-59 - DB -59,-60,-60,-61,-61,-62,-62,-62,-63,-63,-63,-64,-64,-64,-64,-64 - DB -64,-64,-64,-64,-64,-64,-63,-63,-63,-62,-62,-62,-61,-61,-60,-60 - DB -59,-59,-58,-57,-56,-56,-55,-54,-53,-52,-51,-50,-49,-48,-47,-46 - DB -45,-44,-43,-42,-41,-39,-38,-37,-36,-34,-33,-32,-30,-29,-27,-26 - DB -24,-23,-22,-20,-19,-17,-16,-14,-12,-11, -9, -8, -6, -5, -3, -2 - -FineRampDownData Label Byte - DB 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56 - DB 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50, 49, 49, 48 - DB 48, 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 40 - DB 40, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32 - DB 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24 - DB 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16 - DB 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8 - DB 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0 - DB 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8 - DB -8, -9, -9,-10,-10,-11,-11,-12,-12,-13,-13,-14,-14,-15,-15,-16 - DB -16,-17,-17,-18,-18,-19,-19,-20,-20,-21,-21,-22,-22,-23,-23,-24 - DB -24,-25,-25,-26,-26,-27,-27,-28,-28,-29,-29,-30,-30,-31,-31,-32 - DB -32,-33,-33,-34,-34,-35,-35,-36,-36,-37,-37,-38,-38,-39,-39,-40 - DB -40,-41,-41,-42,-42,-43,-43,-44,-44,-45,-45,-46,-46,-47,-47,-48 - DB -48,-49,-49,-50,-50,-51,-51,-52,-52,-53,-53,-54,-54,-55,-55,-56 - DB -56,-57,-57,-58,-58,-59,-59,-60,-60,-61,-61,-62,-62,-63,-63,-64 - -FineSquareWave Label Byte - DB 128 Dup (64), 128 Dup (0) - -EmptyPattern Label - DW 64, 64, 0, 0 - DB 64 Dup (0) - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - ; Zero globals. - -LastSample DW 0 -PlayMode DW 0 ; Playmode 0 = Freeplay - ; Playmode 1 = Pattern - ; Playmode 2 = Song -CurrentOrder DW 0 ; } Must follow -CurrentPattern DW 0 ; } -CurrentRow DW 0 ; } -ProcessOrder DW 0 -ProcessRow DW 0 -BytesToMix DW 0 ; = Bytes per frame -PatternOffset DW 0 -PatternSegment DW 0 -BreakRow DW 0 -RowDelay DB 0 ; } Must join on. -RowDelayOn DB 0 ; } -PatternArray DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ALIGN 4 - -PitchDepthConstant DD 98304.0 -HostChannelInformationTable DB 64*HOSTCHANNELSIZE Dup(?) -SlaveChannelInformationTable DB MAXSLAVECHANNELS*SLAVECHANNELSIZE Dup(?) -MuteChannelTable DB 64 Dup (?) -ChannelCountTable DB 400 Dup (?) -;AllocateCount1 DB 0 -;AllocateCount2 DB 0 -;AllocateCount3 DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ALIGN 2 - -PatternDataSegment DW ? -CurrentEditPattern DW ? -PatternEditMaxRow DW ? - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -NumberOfRows DW 64 ; Non zero globals -CurrentTick DW 6 -CurrentSpeed DW 6 -ProcessTick DW 0 -Tempo DB 125 -GlobalVolume DB 128 -NumChannels DW 256 -SoloSample DB 0FFh ; * ORDER IS IMPORTANT -SoloInstrument DB 0FFh ; * ORDER IS IMPORTANT - -AllocateNumChannels DW 0 -AllocateSlaveOffset DW 0 -LastSlaveChannel DW 0 - -DecodeExpectedPattern DW 0FFFEh -DecodeExpectedRow DW 0FFFEh - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -CmdLineNumChannels DW 0FFFFh - -DriverRequiredVariables Label ; * ORDER IS IMPORTANT -BasePort DW 0FFFFh ; * ORDER IS IMPORTANT -IRQ DW 0FFFFh ; * ORDER IS IMPORTANT -DMA DW 0FFFFh ; * ORDER IS IMPORTANT -CmdLineMixSpeed DW 0 ; * ORDER IS IMPORTANT -SongDataArea DW SongData ; * ORDER IS IMPORTANT -MIDIDataArea DW SongData + 4076 - -CmdLineDMASize DW 1024 ; default -ReverseChannels DB 0 - -InstrumentHeader Label Byte - DB "IMPI" - DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) - DB 0, 0FFh, 0FFh, 0FFh - DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 - DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 - DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 - DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 - DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 - DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 - DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 - DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 - DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 - DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 - DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 - DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 - DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 - DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 - DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 - DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 - DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 - DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 - DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 - DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 - DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 - DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 - DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 - DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 - DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) - DB 7 Dup (0) - -SampleHeader Label Byte - DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) - DW 8363 - DB 18 Dup (0) - -MidiPitchSendString DB 65h, 0, 64h, 0, 06 - -PatternLooping DB 0 -PatternStorage DB 1 ; 0 = conventional only - ; 1 = selective - ; 2 = EMS only. - -PrepareSamplesMsg DB "Preparing Samples", 0 -ReverseMsg DB "Left/right outputs reversed", 0 -NoSoundCardMsg DB " No sound card detected", 0 -MIDIConfigFileName DB "ITMIDI.CFG", 0 - -OrderUpdateEnabledMsg DB "Order list unlocked", 0 -OrderUpdateDisabledMsg DB "Order list locked", 0 -OrderLockFlag DB 0 - -UnsoloMsg DB "Solo disabled", 0 -SoloSampleMsg DB "Solo sample ", 0FDh, "D", 0 -SoloInstrumentMsg DB "Solo instrument ", 0FDh, "D", 0 - -IFDEF DEBUG - -LoadDriverMessage DB "Loading driver:", 0 -UnableToReadFileMessage DB "Unable to read file", 0 -DetectingMessage DB "Testing driver", 0 -ScreenOffset DW 0 - -ENDIF - -PCSpeakerDriver DB "ITPCSPKR.DRV", 0 -SBDriver DB "ITSB.DRV", 0 -SB2Driver DB "ITSB2.DRV", 0 -SBProDriver DB "ITSBPRO.DRV", 0 -SB16Driver DB "ITSB16.DRV", 0 -AWE32Driver DB "ITAWE32.DRV", 0 -GUSDriver DB "ITGUS.DRV", 0 -InterwaveDriver DB "ITIW.DRV", 0 -PASDriver DB "ITPAS.DRV", 0 -PAS16Driver DB "ITPAS16.DRV", 0 -WSSDriver DB "ITWSS.DRV", 0 -ESSDriver DB "ITES1868.DRV", 0 -MIDIDriver DB "ITMPU401.DRV", 0 -EWSCodecDriver DB "ITEWSCOD.DRV", 0 -VIVOCodecDriver DB "ITVIVO.DRV", 0 -ST97PCICodecDriver DB "ITSTCODE.DRV", 0 -WAVDriver DB "ITWAV.DRV", 0 -MIDDriver DB "ITMID.DRV", 0 -VSoundMMXDriver DB "ITVSOUND.MMX", 0 -VSoundDriver DB "ITVSOUND.DRV", 0 -DefaultDriver DB "ITSOUND.DRV", 0 - -DriverNameTable Label - DW 0FFFFh - DW Offset PAS16Driver, SB16Driver - DW Offset InterwaveDriver, Offset GUSDriver - DW Offset AWE32Driver, Offset SBProDriver - DW Offset SBDriver, Offset PCSpeakerDriver - DW Offset SB2Driver, Offset PASDriver - DW Offset WAVDriver, Offset WSSDriver - DW Offset ESSDriver, MIDIDriver - DW Offset EWSCodecDriver, VIVOCodecDriver - DW Offset ST97PCICodecDriver, Offset MIDDRIVER - DW Offset DefaultDriver, Offset VSoundMMXDriver - DW Offset VSoundDriver - -DriverName DD 0 - -DriverDetectionOrder DW 19, 20, 21, 17, 16, 15, 13, 1, 10, 2, 12, 3, 4, 5, 6, 9, 7, 8, 0FFFFh -DriverSoundCard DW 0, 8, 7, 9, 6 - DW 2, 5, 4, 3, 10 - DW 1, 12, 13, 15, 16 - DW 0, 0, 0, 0, 14 - DW 11, 18 - -ALIGN 4 - -PitchTable Label DWord - DW 2048, 0, 2170, 0, 2299, 0, 2435, 0, 2580, 0, 2734, 0 - DW 2896, 0, 3069, 0, 3251, 0, 3444, 0, 3649, 0, 3866, 0 - - DW 4096, 0, 4340, 0, 4598, 0, 4871, 0, 5161, 0, 5468, 0 - DW 5793, 0, 6137, 0, 6502, 0, 6889, 0, 7298, 0, 7732, 0 - - DW 8192, 0, 8679, 0, 9195, 0, 9742, 0, 10321, 0, 10935, 0 - DW 11585, 0, 12274, 0, 13004, 0, 13777, 0, 14596, 0, 15464, 0 - - DW 16384, 0, 17358, 0, 18390, 0, 19484, 0, 20643, 0, 21870, 0 - DW 23170, 0, 24548, 0, 26008, 0, 27554, 0, 29193, 0, 30929, 0 - - DW 32768, 0, 34716, 0, 36781, 0, 38968, 0, 41285, 0, 43740, 0 - DW 46341, 0, 49097, 0, 52016, 0, 55109, 0, 58386, 0, 61858, 0 - - DW 0, 1, 3897, 1, 8026, 1, 12400, 1, 17034, 1, 21944, 1 - DW 27146, 1, 32657, 1, 38496, 1, 44682, 1, 51236, 1, 58179, 1 - - DW 0, 2, 7794, 2, 16051, 2, 24800, 2, 34068, 2, 43888, 2 - DW 54292, 2, 65314, 2, 11456, 3, 23828, 3, 36936, 3, 50823, 3 - - DW 0, 4, 15588, 4, 32103, 4, 49600, 4, 2601, 5, 22240, 5 - DW 43048, 5, 65092, 5, 22912, 6, 47656, 6, 8336, 7, 36110, 7 - - DW 0, 8, 31176, 8, 64205, 8, 33663, 9, 5201, 10, 44481, 10 - DW 20559, 11, 64648, 11, 45823, 12, 29776, 13, 16671, 14, 6684, 15 - - DW 0, 16, 62352, 16, 62875, 17, 1790, 19, 10403, 20, 23425, 21 - DW 41118, 22, 63761, 23, 26111, 25, 59552, 26, 33342, 28, 13368, 30 - -; Pitch extention for loading some XIs - - DW 0, 32, 59167, 33, 60214, 35, 3580, 38, 20806, 40, 46850, 42 - DW 16701, 45, 61986, 47, 52221, 50, 53567, 53, 1148, 57, 26736, 60 - -IF USEFPUCODE - -FPSave DB 128 Dup (0) - -Const_14317456 DD 14317456.0 -Const1_On_768 DD 3AAAAAABh -SlideValue DW 0 -NewControlWord DW 7Fh - -ELSE - -FineLinearSlideUpTable Label - DW 0, 1, 59, 1, 118, 1, 178, 1, 237, 1 ; 0->4 - DW 296, 1, 356, 1, 415, 1, 475, 1, 535, 1 ; 5->9 - DW 594, 1, 654, 1, 714, 1, 773, 1, 833, 1 ; 10->14 - DW 893, 1 ; 15 - -LinearSlideUpTable Label ; Value = 2^(Val/192) - DW 0, 1, 237, 1, 475, 1, 714, 1, 953, 1 ; 0->4 - DW 1194, 1, 1435, 1, 1677, 1, 1920, 1, 2164, 1 ; 5->9 - DW 2409, 1, 2655, 1, 2902, 1, 3149, 1, 3397, 1 ; 10->14 - DW 3647, 1, 3897, 1, 4148, 1, 4400, 1, 4653, 1 ; 15->19 - DW 4907, 1, 5157, 1, 5417, 1, 5674, 1, 5932, 1 ; 20->24 - DW 6190, 1, 6449, 1, 6710, 1, 6971, 1, 7233, 1 ; 25->29 - DW 7496, 1, 7761, 1, 8026, 1, 8292, 1, 8559, 1 ; 30->34 - DW 8027, 1, 9096, 1, 9366, 1, 9636, 1, 9908, 1 ; 35->39 - DW 10181, 1, 10455, 1, 10730, 1, 11006, 1, 11283,1 ; 40->44 - DW 11560, 1, 11839, 1, 12119, 1, 12400, 1, 12682,1 ; 45->49 - DW 12965, 1, 13249, 1, 13533, 1, 13819, 1, 14106,1 ; 50->54 - DW 14394, 1, 14684, 1, 14974, 1, 15265, 1, 15557,1 ; 55->59 - DW 15850, 1, 16145, 1, 16440, 1, 16737, 1, 17034,1 ; 60->64 - DW 17333, 1, 17633, 1, 17933, 1, 18235, 1, 18538,1 ; 65->69 - DW 18842, 1, 19147, 1, 19454, 1, 19761, 1, 20070,1 ; 70->74 - DW 20379, 1, 20690, 1, 21002, 1, 21315, 1, 21629,1 ; 75->79 - DW 21944, 1, 22260, 1, 22578, 1, 22897, 1, 23216,1 ; 80->84 - DW 23537, 1, 23860, 1, 24183, 1, 24507, 1, 24833,1 ; 85->89 - DW 25160, 1, 25488, 1, 25817, 1, 26148, 1, 26479,1 ; 90->94 - DW 26812, 1, 27146, 1, 27481, 1, 27818, 1, 28155,1 ; 95->99 - DW 28494, 1, 28834, 1, 29175, 1, 29518, 1, 29862,1 ; 100->104 - DW 30207, 1, 30553, 1, 30900, 1, 31248, 1, 31599,1 ; 105->109 - DW 31951, 1, 32303, 1, 32657, 1, 33012, 1, 33369,1 ; 110->114 - DW 33726, 1, 34085, 1, 34446, 1, 34807, 1, 35170,1 ; 115->119 - DW 35534, 1, 35900, 1, 36267, 1, 36635, 1, 37004,1 ; 120->124 - DW 37375, 1, 37747, 1, 38121, 1, 38496, 1, 38872,1 ; 125->129 - DW 39250, 1, 39629, 1, 40009, 1, 40391, 1, 40774,1 ; 130->134 - DW 41158, 1, 41544, 1, 41932, 1, 42320, 1, 42710,1 ; 135->139 - DW 43102, 1, 43495, 1, 43889, 1, 44285, 1, 44682,1 ; 140->144 - DW 45081, 1, 45481, 1, 45882, 1, 46285, 1, 46690,1 ; 145->149 - DW 47095, 1, 47503, 1, 47917, 1, 48322, 1, 48734,1 ; 150->154 - DW 49147, 1, 49562, 1, 49978, 1, 50396, 1, 50815,1 ; 155->159 - DW 51236, 1, 51658, 1, 52082, 1, 52507, 1, 52934,1 ; 160->164 - DW 53363, 1, 53793, 1, 54224, 1, 54658, 1, 55092,1 ; 165->169 - DW 55529, 1, 55966, 1, 56406, 1, 56847, 1, 57289,1 ; 170->174 - DW 57734, 1, 58179, 1, 58627, 1, 59076, 1, 59527,1 ; 175->179 - DW 59979, 1, 60433, 1, 60889, 1, 61346, 1, 61805,1 ; 180->184 - DW 62265, 1, 62727, 1, 63191, 1, 63657, 1, 64124,1 ; 185->189 - DW 64593, 1, 65064, 1, 0, 2, 474, 2, 950, 2 ; 190->194 - DW 1427, 2, 1906, 2, 2387, 2, 2870, 2, 3355, 2 ; 195->199 - DW 3841, 2, 4327, 2, 4818, 2, 5310, 2, 5803, 2 ; 200->204 - DW 6298, 2, 6795, 2, 7294, 2, 7794, 2, 8296, 2 ; 205->209 - DW 8800, 2, 9306, 2, 9814, 2, 10323, 2, 10835,2 ; 210->214 - DW 11348, 2, 11863, 2, 12380, 2, 12899, 2, 13419,2 ; 215->219 - DW 13942, 2, 14467, 2, 14993, 2, 15521, 2, 16051,2 ; 220->224 - DW 16583, 2, 17117, 2, 17653, 2, 18191, 2, 18731,2 ; 225->229 - DW 19273, 2, 19817, 2, 20362, 2, 20910, 2, 21460,2 ; 230->234 - DW 22011, 2, 22565, 2, 23121, 2, 23678, 2, 24238,2 ; 235->239 - DW 24800, 2, 25363, 2, 25929, 2, 25497, 2, 27067,2 ; 240->244 - DW 27639, 2, 28213, 2, 28789, 2, 29367, 2, 29947,2 ; 245->249 - DW 30530, 2, 31114, 2, 31701, 2, 32289, 2, 32880, 2 ; 250->254 - DW 33473, 2, 34068, 2 ; 255->256 - -FineLinearSlideDownTable Label - DW 65535, 65477, 65418, 65359, 65300, 65241, 65182, 65359 ; 0->7 - DW 65065, 65006, 64947, 64888, 64830, 64772, 64713, 64645 ; 8->15 - -LinearSlideDownTable Label - DW 65535, 65300, 65065, 64830, 64596, 64364, 64132, 63901 ; 0->7 - DW 63670, 63441, 63212, 62984, 62757, 62531, 62306, 62081 ; 8->15 - DW 61858, 61635, 61413, 61191, 60971, 60751, 60532, 60314 ; 16->23 - DW 60097, 59880, 59664, 59449, 59235, 59022, 58809, 58597 ; 24->31 - DW 58386, 58176, 57966, 57757, 57549, 57341, 57135, 56929 ; 32->39 - DW 56724, 56519, 56316, 56113, 55911, 55709, 55508, 55308 ; 40->47 - DW 55109, 54910, 54713, 54515, 54319, 54123, 53928, 53734 ; 48->55 - DW 53540, 53347, 53155, 52963, 52773, 52582, 52393, 52204 ; 56->63 - DW 52016, 51829, 51642, 51456, 51270, 51085, 50901, 50718 ; 64->71 - DW 50535, 50353, 50172, 49991, 49811, 49631, 49452, 49274 ; 72->79 - DW 49097, 48920, 48743, 48568, 48393, 48128, 48044, 47871 ; 80->87 - DW 47699, 47527, 47356, 47185, 47015, 46846, 46677, 46509 ; 88->95 - DW 46341, 46174, 46008, 45842, 45677, 45512, 45348, 45185 ; 96->103 - DW 45022, 44859, 44698, 44537, 44376, 44216, 44057, 43898 ;104->111 - DW 43740, 43582, 43425, 43269, 43113, 42958, 42803, 42649 ;112->119 - DW 42495, 42342, 42189, 42037, 41886, 41735, 41584, 41434 ;120->127 - DW 41285, 41136, 40988, 40840, 40639, 40566, 40400, 40253 ;128->135 - DW 40110, 39965, 39821, 39678, 39535, 39392, 39250, 39109 ;136->143 - DW 38968, 38828, 38688, 38548, 38409, 38271, 38133, 37996 ;144->151 - DW 37859, 37722, 37586, 37451, 37316, 37181, 37047, 36914 ;152->159 - DW 36781, 36648, 36516, 36385, 36254, 36123, 35993, 35863 ;160->167 - DW 35734, 35605, 35477, 35349, 35221, 35095, 34968, 34842 ;168->175 - DW 34716, 34591, 34467, 34343, 34219, 34095, 33973, 33850 ;176->183 - DW 33728, 33607, 33486, 33365, 33245, 33125, 33005, 32887 ;184->191 - DW 32768, 32650, 32532, 32415, 32298, 32182, 32066, 31950 ;192->199 - DW 31835, 31720, 31606, 31492, 31379, 31266, 31153, 31041 ;200->207 - DW 30929, 30817, 30706, 30596, 30485, 30376, 30226, 30157 ;208->215 - DW 30048, 29940, 29832, 29725, 29618, 29511, 29405, 29299 ;216->223 - DW 29193, 29088, 28983, 28879, 28774, 28671, 28567, 28464 ;224->231 - DW 28362, 28260, 28158, 28056, 27955, 27855, 27754, 27654 ;232->239 - DW 27554, 27455, 27356, 27258, 27159, 27062, 26964, 26867 ;240->247 - DW 26770, 26674, 26577, 26482, 26386, 26291, 26196, 26102 ;248->255 - DW 26008 ; 256 - -ENDIF ; USEFPUCODE - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -InitCommandTable Label Word - DW Offset InitNoCommand, Offset InitCommandA - DW Offset InitCommandB, Offset InitCommandC - DW Offset InitCommandD, Offset InitCommandE - DW Offset InitCommandF, Offset InitCommandG - DW Offset InitCommandH, Offset InitCommandI - DW Offset InitCommandJ, Offset InitCommandK - DW Offset InitCommandL, Offset InitCommandM - DW Offset InitCommandN, Offset InitCommandO - DW Offset InitCommandP, Offset InitCommandQ - DW Offset InitCommandR, Offset InitCommandS - DW Offset InitCommandT, Offset InitCommandU - DW Offset InitCommandV, Offset InitCommandW - DW Offset InitCommandX, Offset InitCommandY - DW Offset InitCommandZ, Offset InitNoCommand - DW Offset InitNoCommand, Offset InitNoCommand - DW Offset InitNoCommand, Offset InitNoCommand - -CommandTable Label Word - DW Offset NoCommand, Offset NoCommand - DW Offset NoCommand, Offset NoCommand - DW Offset CommandD, Offset CommandE - DW Offset CommandF, Offset CommandG - DW Offset CommandH, Offset CommandI - DW Offset CommandJ, Offset CommandK - DW Offset CommandL, Offset NoCommand - DW Offset CommandN, Offset NoCommand - DW Offset CommandP, Offset CommandQ - DW Offset CommandR, Offset CommandS - DW Offset CommandT, Offset CommandH - DW Offset NoCommand, Offset CommandW - DW Offset NoCommand, Offset CommandY - DW Offset NoCommand, Offset NoCommand - DW Offset NoCommand, Offset NoCommand - -VolumeEffectTable Label Word - DW Offset NoCommand, Offset NoCommand ; Last 2 of command - ; table + VolumeComA - ; and VolumeComB - DW Offset VolumeCommandC, Offset VolumeCommandD - DW Offset VolumeCommandE, Offset VolumeCommandF - DW Offset VolumeCommandG, Offset CommandH - - -RetrigOffsets Label - DW CommandQ_0, CommandQ_1, CommandQ_2, CommandQ_3 - DW CommandQ_4, CommandQ_5, CommandQ_6, CommandQ_7 - DW CommandQ_8, CommandQ_9, CommandQ_A, CommandQ_B - DW CommandQ_C, CommandQ_D, CommandQ_E, CommandQ_F - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Sound Driver Data ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -IF OLDDRIVER - DriverID DB "Impulse Tracker Sound Driver" -ELSE - DriverID DB "Impulse Tracker Advanced Sound Driver" -ENDIF - -ALIGN 2 -SoundDriverSegment DW 0 - -;******************* - -DriverVariableTable Label -DriverMaxChannels DW 32 -StopEndOfPlaySection DW 0 -DefaultChannels DW 32 -DriverFlags DW 0 ; Bit 1 = MIDI Out supported - ; Bit 2 = Hiqual - ; Bit 3 = Output waveform data available - -IF OLDDRIVER - DB 64 - ($ - DriverVariableTable) Dup (0) -ELSE - DB 16 - ($ - DriverVariableTable) Dup (0) -ENDIF - - -ALIGN 4 - -StartDriverFunctions Label -DriverDetectCard DD 0 -DriverInitSound DD 0 -DriverReinitSound DD 0 -DriverUninitSound DD 0 - -DriverPoll DD 0 - -DriverSetTempo DD 0 -DriverSetMixVolume DD 0 -DriverSetStereo DD 0 - -DriverLoadSample DD 0 -DriverReleaseSample DD 0 -DriverResetMemory DD 0 -DriverGetStatus DD 0 - -DriverSoundCardScreen DD 0 -DriverGetVariable DD 0 -DriverSetVariable DD 0 - -DriverMIDIOut DD 0 -DriverGetWaveform DD 0 - -EndDriverFunctions Label - -IF OLDDRIVER - DD 63-(EndDriverFunctions-StartDriverFunctions)/4 Dup (0) -ELSE - DD 31-(EndDriverFunctions-StartDriverFunctions)/4 Dup (0) -ENDIF - DW 0 - -DriverLength DW 0 - -DriverRequiredFunctions Label - DD DWord Ptr Update - DD DWord Ptr Music_GetSampleHeader - DD DWord Ptr Music_GetSampleLocation - DD DWord Ptr Music_FarUpdateSampleLocation - DD DWord Ptr E_GetEMSPageFrame - DD DWord Ptr E_SaveEMSPageFrame - DD DWord Ptr E_RestoreEMSPageFrame - DD DWord Ptr Music_GetTempo - DD DWord Ptr M_FunctionHandler - DD DWord Ptr SetInfoLine2 - DD DWord Ptr Music_SoundCardLoadAllSamples - DD DWord Ptr GlobalKeyList - DD DWord Ptr IdleUpdateInfoLine - DD DWord Ptr F_DrawHeader - DD DWord Ptr PE_FillHeader - DD DWord Ptr D_GotoStartingDirectory - DD DWord Ptr D_GetFileName - DD DWord Ptr D_SetDriveDirectoryFar - DD DWord Ptr Music_Stop - DD DWord Ptr GetEnvironment - DD DWord Ptr Music_GetSlaveChannelInformationTable - DD DWord Ptr RecalculateAllVolumes - DD DWord Ptr MIDIBufferEmpty - DD DWord Ptr MIDISend - DD DWord Ptr S_GetDestination - DD DWord Ptr S_DrawString - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Command/Effect (call it what you like) information here!! ³ -;³ ³ -;³ For initialisation, DS:DI points to host channel data. ³ -;³ Registers for use: All except DS:DI & ES (points to SongDataSegment) ³ -;³ ³ -;³ For update, DS:DI points to host channel data. ³ -;³ Registers for use: AX, BX, DX, ES, SI ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc RecalculateAllVolumes Far - - Mov CX, NumChannels - Mov SI, Offset SlaveChannelInformationTable - -RecalculateAllVolumes1: - Or Byte Ptr [SI], 18 - - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ RecalculateAllVolumes1 - - Ret - -EndP RecalculateAllVolumes - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc InitPlayInstrument ; BX = instrument offset - - Push ECX - - Mov [SI+30h], BX ; InsOffset - - Mov AL, [ES:BX+11h] ; NNA - Mov [SI+3Bh], AL - - Mov AX, [ES:BX+12h] ; DCT and DCA - Mov [SI+28h], AX - - Mov AX, [DI+0Ch] ; MCh and MPr - Test AL, AL - JZ InitPlayInstrumentNoMIDI - - Mov [SI+3Ch], AX - Mov AX, [ES:BX+3Eh] ; MidiBank - Mov [SI+3Eh], AX - Mov AL, [DI+3] - Mov [SI+0Bh], AL - -InitPlayInstrumentNoMIDI: - Mov DX, [DI+2Eh] ; ChannelVol=DH, Pan=DL - - Mov AL, [ES:BX+19h] ; Instrument pan - Mov [SI+23h], DH - - Test AL, 80h - JNZ AllocatePan1 - - Mov DL, AL - -AllocatePan1: - Push BX ; Check for sample pan - - Mov BL, [DI+0Fh] - And BX, 0FFh - JZ InitPlayInstrumentNoSamplePan - - Add BX, BX - Mov BX, [ES:64910+BX] ; BX = sample offset - Mov AL, [ES:BX+2Fh] - Test AL, AL - - JNS InitPlayInstrumentNoSamplePan - - And AL, 7Fh - Mov DL, AL - -InitPlayInstrumentNoSamplePan: - Pop BX - - Cmp DL, 100 - JE AllocatePanSurround - - Xor DH, DH - Mov AL, [DI+3] ; Note - Mov CX, [ES:BX+16h] ; Pitch pan separation - Sub AL, CH - IMul CL - - SAR AX, 3 - - Add AX, DX - JS AllocatePan2 - Cmp AX, 64 - JBE AllocatePan3 - - Mov AL, 64 - Jmp AllocatePan3 - -AllocatePan2: - Xor AL, AL - Jmp AllocatePan3 - -AllocatePanSurround: - Mov AL, 100 - -AllocatePan3: - Mov AH, AL - Xor ECX, ECX ; Envelope init - Mov [SI+2Ah], AX ; Write panning - - Mov [SI+58h], ECX - Mov [SI+5Ch], CX - Mov [SI+60h], ECX - Mov [SI+68h], ECX - Mov [SI+6Ch], CX - Mov [SI+70h], ECX - Mov [SI+78h], ECX - Mov [SI+7Ch], CX - Mov DWord Ptr [SI+50h], 400000h ; 64*65536 - - Mov AH, [ES:BX+1D4h] - Mov AL, [ES:BX+182h] - And AX, 101h - ShL AH, 1 - Or AH, AL - Mov AL, [ES:BX+130h] - ShL AH, 1 - And AL, 1 - Or AH, AL - ShL AH, 4 - Or AX, 133h - - Mov Word Ptr [SI], AX - - Push DI - - Mov DI, LastSlaveChannel - Test DI, DI - JZ InitInstrumentCarry - -InitInstrumentVolumeCarry: - Mov AL, [ES:BX+130h] - And AL, 9 - Cmp AL, 9 - JNE InitInstrumentPanCarry - -; Transfer volume data - Mov ECX, [DI+50h] - Mov EDX, [DI+54h] - Mov [SI+50h], ECX - Mov [SI+54h], EDX - Mov ECX, [DI+58h] - Mov DX, [DI+5Ch] - Mov [SI+58h], ECX - Mov [SI+5Ch], DX - -InitInstrumentPanCarry: - Mov AL, [ES:BX+182h] - And AL, 9 - Cmp AL, 9 - JNE InitInstrumentPitchCarry -; Transfer pan data - Mov ECX, [DI+60h] - Mov EDX, [DI+64h] - Mov [SI+60h], ECX - Mov [SI+64h], EDX - Mov ECX, [DI+68h] - Mov DX, [DI+6Ch] - Mov [SI+68h], ECX - Mov [SI+6Ch], DX - - -InitInstrumentPitchCarry: - Mov AL, [ES:BX+1D4h] - And AL, 9 - Cmp AL, 9 - JNE InitInstrumentCarry -; Transfer pitch data - Mov ECX, [DI+70h] - Mov EDX, [DI+74h] - Mov [SI+70h], ECX - Mov [SI+74h], EDX - Mov ECX, [DI+78h] - Mov DX, [DI+7Ch] - Mov [SI+78h], ECX - Mov [SI+7Ch], DX - -InitInstrumentCarry: - Pop DI - - Or Byte Ptr [DI], 80h ; Apply random volume/pan - - Cmp Byte Ptr [DI+0Ch], 0 - JNE InitPlayInstrumentNoSample - - Push BX - Mov BX, [ES:BX+3Ah] ; Initial filter cutoff -; If IFC bit 7 == 1, then set filter cutoff - - Mov Word Ptr [SI+3Eh], 0FFh - -; Test BL, 8080h -; JNZ InitPlayInstrumentFilter -; -;; No filters, reset devices. -; Mov BL, 7Fh -; Call SetFilterCutoff -; Xor BL, BL -; Call SetFilterResonance -; -; Jmp InitPlayInstrumentFilterResonance -; -;InitPlayInstrumentFilter: - Test BL, BL - JNS InitPlayInstrumentFilterCutoff - - And BL, 7Fh -; Mov [SI+3Eh], BL - Call SetFilterCutoff - -InitPlayInstrumentFilterCutoff: -; If IFR bit 7 == 1, then set filter resonance - Test BX, BX - JNS InitPlayInstrumentFilterResonance - - Mov BL, BH - And BL, 7Fh - Mov [SI+3Fh], BL - Call SetFilterResonance - -InitPlayInstrumentFilterResonance: - Pop BX - -InitPlayInstrumentNoSample: - Pop ECX - - Ret - -EndP InitPlayInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ApplyRandomValues - - Mov SI, [DI+24h] - Mov BX, [SI+30h] - - And Byte Ptr [DI], Not 80h - - Call Random ; AL = -128->+127 - - Mov AH, [ES:BX+1Ah] ; Random volume, 0->100 - Test AH, AH - JZ RandomVolumeEnd - - IMul AH ; AX = -12800->12700 - SAR AX, 6 ; AX = -200->+198(.4) - Inc AX ; AX = -199->+199 - - MovZX DX, Byte Ptr [SI+24h] ; Sample volume set - Mov CX, 199 - Push DX - IMul DX ; AX = -199*128->199*128 - ; AX = -25472->25472 - - IDiv CX ; AX = -128->+128 - Pop CX - Add AX, CX - - Cmp AX, 0 - JL RandomVolume3 - Cmp AX, 128 - JG RandomVolume4 - - Mov [SI+24h], AL - Jmp RandomVolumeEnd - -RandomVolume3: - Mov Byte Ptr [SI+24h], 0 - Jmp RandomVolumeEnd - -RandomVolume4: - Mov Byte Ptr [SI+24h], 128 - -RandomVolumeEnd: - Call Random ; AL = -128->+127 - - Mov AH, [ES:BX+1Bh] ; Random pan, 0->64 - Test AH, AH - JZ RandomPanEnd - - Xor DX, DX - IMul AH ; AX = -64*128->64*127, -8192->8128 - Mov DL, [SI+2Ah] - SAR AX, 7 - Cmp DL, 100 - JE RandomPanEnd - Add DX, AX - JS RandomPan1 - Cmp DX, 64 - JA RandomPan2 - - Mov DH, DL - Mov [SI+2Ah], DX - Ret - -RandomPan2: - Mov Word Ptr [SI+2Ah], 4040h - Ret - -RandomPan1: - Mov Word Ptr [SI+2Ah], 0 - -RandomPanEnd: - Ret - -EndP ApplyRandomValues - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -LastMIDIByte DB 0FFh - -Proc MIDISendFilter - - Test CS:DriverFlags, 1 - JZ MIDISendFilter2 - - Test AL, AL - JNS MIDISendFilter1 - Cmp AL, 0F0h - JAE MIDISendFilter1 - - Cmp AL, CS:LastMIDIByte - JE MIDISendFilter2 - - Mov CS:LastMIDIByte, AL - -MIDISendFilter1: - Call DriverMIDIOut - -MIDISendFilter2: - Ret - -EndP MIDISendFilter - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilterCutoff ; Given BL = filtervalue. - ; Assumes that channel is non-disowned - - Push DI - - Mov DI, [SI+38h] - - Mov AL, 0F0h - Call MIDISendFilter - Mov AL, 0F0h - Call MIDISendFilter - Xor AL, AL - Call MIDISendFilter - Mov AL, BL - Call MIDISendFilter - - Pop DI - Ret - -EndP SetFilterCutoff - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SetFilterResonance ; Given BL = filtervalue. - ; Assumes that channel is non-disowned - - Push DI - - Mov DI, [SI+38h] - - Mov AL, 0F0h - Call MIDISendFilter - Mov AL, 0F0h - Call MIDISendFilter - Mov AL, 1 - Call MIDISendFilter - Mov AL, BL - Call MIDISendFilter - - Pop DI - Ret - -EndP SetFilterResonance - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -MIDIPitchDepthSent DW 0 - -Proc MIDITranslate ; Assumes DS:SI points to slave - ; And DS:DI points to host. - ; BX = offset of MIDI command to interpret - - Assume DS:Music - - Test DriverFlags, 1 - JZ MIDITranslateEnd - - PushA - - Cmp BX, 0F000h - JB MIDITranslateParameterised - -; Internal MIDI commands. - - Test Byte Ptr [ES:2Ch], 64 ; Do pitch wheel? - JZ MIDITranslateInternalEnd - -; Pitch wheel -; Formula is: Depth = 16384*12 / PitchWheelDepth * log2(Freq / OldFreq) -; Do calculation, check whether pitch needs to be sent. - - Xor EAX, EAX - Mov AL, [ES:35h] ; AL = PWD - - Test AL, AL ; No depth! - JZ MIDITranslateInternalEnd - - Mov DWord Ptr [ChannelCountTable+200], EAX ; scratch area - -IFE USEFPUCODE ; If FPU code is being used, FP registers are already saved - FNSave [ChannelCountTable] ; Scratch area - FNInit -ENDIF - FLd [PitchDepthConstant] - FIDiv DWord Ptr [ChannelCountTable+200] - FILd DWord Ptr [SI+10h] ; Current pitch - FIDiv DWord Ptr [SI+1Ch] ; Original pitch - FYL2X - FIStP DWord Ptr [ChannelCountTable+200] -IFE USEFPUCODE - FRstor [ChannelCountTable] -ENDIF - -; OK.. [ChannelCountTable] contains pitch depth. -; Have to check: -; a) Within ranges? -; b) Comparison to old pitch for this channel - - Mov CL, [SI+3Ch] - Mov AX, 1 - Dec CL - JS MIDITranslateInternalEnd - - Cmp DWord Ptr [ChannelCountTable+200], 0 - JE MIDIPitchDepthSent1 - - ShL AX, CL - Test MIDIPitchDepthSent, AX - JNZ MIDIPitchDepthSent1 - - Or MIDIPitchDepthSent, AX - -; Send MIDI Pitch depth stuff - - Push SI - - Mov AL, 0B0h - Or AL, CL - Call MIDISendFilter - - Mov DX, 5 - Mov SI, Offset MIDIPitchSendString - -Music_SendPitchDepth1: - LodsB - Call MIDISendFilter - Dec DX - JNZ Music_SendPitchDepth1 - - Pop SI - - Mov AL, [ES:35h] - Call MIDISendFilter - -MIDIPitchDepthSent1: - Mov EAX, DWord Ptr [ChannelCountTable+200] - Add EAX, 2000h - JNS PitchRange1 - - Xor EAX, EAX - -PitchRange1: - Cmp EAX, 4000h - JL PitchRange2 - - Mov AX, 3FFFh - -PitchRange2: - Mov BL, [SI+3Ch] ; BL = channel - And BX, 0FFh - Add BX, BX - Cmp [MIDIPitch+BX-2], AX - JE MIDITranslateInternalEnd - - Mov [MIDIPitch+BX-2], AX - -; Output pitch change - - Mov AL, 0E0h - Or AL, CL - - Call MIDISendFilter ; Ec command - - Mov AL, Byte Ptr [MIDIPitch+BX-2] - And AL, 7Fh - Call MIDISendFilter - - Mov AX, [MIDIPitch+BX-2] - ShR AX, 7 - And AL, 7Fh - Call MIDISendFilter - -MIDITranslateInternalEnd: - PopA - Ret - -; Now for user input MIDI stuff. - -MIDITranslateParameterised: - Push FS - - Xor AX, AX - Xor CX, CX - Mov FS, MIDIDataArea - -MIDITranslate1: - Mov AH, [FS:BX] - Inc BX - Test AH, AH - JZ MIDITranslate2 - - Cmp AH, ' ' ; Interpretation time. - JNE MIDITranslateNoSpace - - Test CX, CX - JZ MIDITranslate1 - Jmp MIDITranslateSend - -MIDITranslateNoSpace: - Sub AH, '0' - JC MIDITranslate1 - Cmp AH, 9 - JA MIDITranslateValue1 - - ShL AL, 4 - Or AL, AH - Inc CX - Jmp MIDITranslateValueEnd - -MIDITranslateValue1: - Sub AH, 'A'-'0' - JC MIDITranslate1 - Cmp AH, 'F'-'A' - JA MIDITranslateValue2 - - ShL AL, 4 - Add AH, 10 - Or AL, AH - Inc CX - Jmp MIDITranslateValueEnd - -MIDITranslateValue2: - Sub AH, 'a'-'A' - JC MIDITranslate1 - Cmp AH, 'z'-'a' - JA MIDITranslate1 - - Cmp AH, 'c'-'a' - JNE MIDITranslateValue3 - - Test SI, SI - JZ MIDITranslate1 - -; Mov AH, [DI+0Ch] - Mov AH, [SI+3Ch] - ShL AL, 4 - Dec AH - Or AL, AH - Inc CX - Jmp MIDITranslateValueEnd - -MIDITranslateValue3: - Test CX, CX - JZ MIDITranslateValue4 - - Call MIDISendFilter - - Xor CX, CX - -MIDITranslateValue4: - Mov AL, [DI+7] ; Effect. - Cmp AH, 'z'-'a' ; Zxx? - JE MIDITranslateSend - - Mov AL, [DI+12h] - Cmp AH, 'o'-'a' - JE MIDITranslateSend - - Test SI, SI - JZ MIDITranslate1 - - Mov AL, [SI+32h] ; [DI+0Eh] - Cmp AH, 'n'-'a' ; Note? - JE MIDITranslateSend - - Mov AL, [SI+0Bh] - Cmp AH, 'm'-'a' - JE MIDITranslateSend - - Cmp AH, 'v'-'a' ; Velocity? - JNE MIDITranslateValue7 - - Xor AL, AL - Test Word Ptr [SI], 800h - JNZ MIDITranslateSend - - Mov AL, [SI+22h] ; 0->2^6 - Xor DX, DX - Mul GlobalVolume ; 0->2^13 - Mov DL, [SI+23h] ; Channel volume - Mul DX ; 0->2^19 - SHRD AX, DX, 4 ; 0->2^15 - Mov DL, [SI+24h] ; Sample & Instrument Volume - Mul DX ; 0->2^22 - SHRD AX, DX, 15 ; 0->2^7 - Sub AL, 1 - AdC AL, 1 ; 1->2^7 - JNS MIDITranslateSend - Dec AX -; Mov AL, 7Fh - Jmp MIDITranslateSend - -Comment ~ - Mov AL, [SI+22h] ; 0->64 - Add AL, AL ; 0->128 - Sub AL, 1 - AdC AL, 1 ; 1->128 - Cmp AL, 128 - JB MIDITranslateSend - Dec AX - Jmp MIDITranslateSend -~ - -MIDITranslateValue7: - Cmp AH, 'u'-'a' ; Volume? - JNE MIDITranslateValue8 - - Xor AL, AL - Test Word Ptr [SI], 800h - JNZ MIDITranslateSend - - Mov AL, [SI+20h] ; 0->128 - Sub AL, 1 - AdC AL, 1 ; 1->128 - Cmp AL, 128 - JB MIDITranslateSend - Dec AX - Jmp MIDITranslateSend - -MIDITranslateValue8: - Mov AL, [SI+3Ah] ; HCN - And AL, 7Fh - Cmp AH, 'h'-'a' - JE MIDITranslateSend - - Mov AL, [SI+2Ah] ; Pan set - Cmp AH, 'x'-'a' - JE MIDITranslatePanValue - - Mov AL, [SI+25h] ; Final pan - Cmp AH, 'y'-'a' - JE MIDITranslatePanValue - - Mov AL, [SI+3Dh] - Cmp AH, 'p'-'a' ; Program? - JE MIDITranslateSend - - Mov DX, [SI+3Eh] - Mov AL, DL - Add AL, 1 - AdC AX, 0 - Dec AX - Cmp AH, 'b'-'a' - JE MIDITranslateSend - - Mov AL, DH - Add AL, 1 - AdC AX, 0 - Dec AX - Cmp AH, 'a'-'a' - JE MIDITranslateSend - - Xor AX, AX - Jmp MIDITranslate1 - -MIDITranslatePanValue: - Add AL, AL - Cmp AL, 7Fh - JBE MIDITranslateSend - Dec AX - Cmp AL, 7Fh - JBE MIDITranslateSend - Mov AL, 40h - Jmp MIDITranslateSend - -MIDITranslateValueEnd: - Cmp CL, 2 - JB MIDITranslate1 - -MIDITranslateSend: - Call MIDISendFilter - - Xor AX, AX - Xor CX, CX - Jmp MIDITranslate1 - -MIDITranslate2: - Test CX, CX - JZ MIDITranslate3 - - Call MIDISendFilter - -MIDITranslate3: - Pop FS - PopA - -MIDITranslateEnd: - Ret - -EndP MIDITranslate - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc AllocateChannel ; Returns SI. Carry set if problems - Assume DS:Music - - Push CX - Mov LastSlaveChannel, 0 - - Test Byte Ptr [ES:2Ch], 4 - JNZ AllocateChannel1 - -AllocateChannel15: ; Sample handler - MovZX SI, Byte Ptr [DI+20h] - Mov AX, SI - ShL SI, 7 ; SLAVECHANNELSIZE - Add SI, Offset SlaveChannelInformationTable - - Test Byte Ptr CS:DriverFlags, 2 - JZ AllocateChannelHiQual1 - Test Byte Ptr [SI], 1 ; Channel on? - JZ AllocateChannelHiQual1 - -; copy out channel - Push CX - Push SI - Push DI - Push ES - - Push DS - Pop ES - - Or Word Ptr [SI], 200h - Or Byte Ptr [SI+3Ah], 80h - - LEA DI, [SI+64*SLAVECHANNELSIZE] - Mov CX, SLAVECHANNELSIZE/4 - Rep MovsD - - Pop ES - Pop DI - Pop SI - Pop CX - -AllocateChannelHiQual1: - Mov [DI+24h], SI - Mov [SI+38h], DI - Mov [SI+3Ah], AL - Mov Word Ptr [SI], 133h ; Recalc freq,vol&pan Channel on. - - Mov AX, [DI+2Eh] ; ChannelVol=AH, Pan=AL - Mov [SI+23h], AH - Mov AH, AL - Mov [SI+2Ah], AX - ; Get sample offset. -AllocateChannel3: ; General stuff. - Pop CX - - Mov Word Ptr [SI+26h], 0400h ; FadeOut - Mov Word Ptr [SI+52h], 64 - Mov Word Ptr [SI+3Eh], 0FFh ; Filter cutoff - - Mov AX, [DI+3] - Mov [SI+32h], AX ; Nte&Ins - - Mov BL, [DI+0Fh] - And BX, 0FFh - JZ AllocateChannel21 - Dec BX - - Call I_TagSample - - Mov [SI+36h], BL - - Add BX, BX - Mov BX, [ES:64912+BX] - Mov [SI+34h], BX ; Sample memory offset. - - Xor EAX, EAX - Mov [SI+18h], EAX ; Reset vibrato info. - Mov Word Ptr [SI+62h], AX ; No pan deviation - Mov Word Ptr [SI+72h], AX ; No pitch deviation - Mov Byte Ptr [SI+0Bh], AL ; Reset loop dirn - - Cmp [ES:BX+30h], EAX ; No sample! - JE AllocateChannel21 - - Mov AX, [ES:BX+11h] - Test AH, 1 - JZ AllocateChannel21 ; No sample! - - And AH, 2 - Add AL, AL - Mov [SI+18h], AH - Mov [SI+24h], AL ; Sample volume - - ClC - Ret - -AllocateChannel21: - Mov Word Ptr [SI], 200h - And CH, Not 4 - StC - Ret - -AllocateChannel5: - Pop CX - StC - Ret - -AllocateChannel1: ; Instrument handler! - Mov DX, NumChannels - - Mov AllocateSlaveOffset, Offset SlaveChannelInformationTable - Mov AllocateNumChannels, DX - - Mov BX, MAXSLAVECHANNELS - Cmp Byte Ptr [DI+0Fh], 101 - JNE AllocateChannelNoMIDI - Cmp DX, BX - JE AllocateChannelNoMIDI - - Sub BX, DX ; CX = number of channels remaining - ShL DX, 7 - Mov AllocateNumChannels, BX - Add DX, Offset SlaveChannelInformationTable - Mov AllocateSlaveOffset, DX - -AllocateChannelNoMIDI: - Mov BL, [DI+4] - - Cmp BL, 0FFh - JE AllocateChannel15 - - And EBX, 0FFh - JZ AllocateChannel5 - - Call I_TagInstrument - - Mov BX, [ES:64710+EBX*2] ; ES:BX points to instrument - - Test CH, 4 ; Test Byte Ptr [DI], 4 - JZ AllocateChannel8 - ; New note action handling... - Mov SI, [DI+24h] - - Cmp [SI+30h], BX - JNE AllocateLastChannelDifferentInstrument - - Mov LastSlaveChannel, SI - -AllocateLastChannelDifferentInstrument: - Mov AL, [SI+3Bh] - - Test AL, AL - JZ AllocateChannel20 ; Notecut. - - Or Byte Ptr [SI+3Ah], 80h ; Disown channel - -AllocateHandleNNA: - Cmp Byte Ptr [SI+22h], 0 ; Is volume set = 0? - JE AllocateChannel20 - Cmp Byte Ptr [SI+23h], 0 ; Is channel volume = 0? - JE AllocateChannel20 - Cmp Byte Ptr [SI+24h], 0 ; Is sample volume = 0? - JE AllocateChannel20 - - Cmp AL, 2 - JB AllocateChannel8 ; Note continue - JE AllocateChannel14 ; Note off. - - ; AL = 3 -> Fade - Or Byte Ptr [SI], 8 ; Fade flag. - Jmp AllocateChannel8 - -AllocateChannel14: - Or Byte Ptr [SI], 4 ; Note off.. - - Push BX - Call GetLoopInformation - Pop BX - - Jmp AllocateChannel8 - -AllocateChannel20MIDI: - Or Word Ptr [SI], 200h - Or Byte Ptr [SI+3Ah], 80h ; Disown channel - - Cmp Byte Ptr [DI+0Fh], 101 - JNE AllocateChannel4 ; Sample.. - -AllocateChannelMIDIDC: - Mov SI, AllocateSlaveOffset - Mov CX, AllocateNumChannels - - Mov DL, [DI+0Eh] - Mov DH, [DI+4] - Mov BP, 32h - Mov AH, [DI+0Ch] - Mov CH, [ES:BX+13h] ; CH = DCA - Jmp AllocateChannel6 - -AllocateChannel20: - Cmp Byte Ptr [SI+36h], 100 ; MIDI? - JE AllocateChannel20MIDI - -AllocateChannel20Samples: - Test Byte Ptr CS:DriverFlags, 2 - JNZ AllocateChannelHiQual - - Mov AL, [ES:BX+12h] - Mov Word Ptr [SI], 200h - Test AL, AL - JZ AllocateChannelInstrument - Jmp AllocateChannel11 - -AllocateChannelHiQual: - Or Word Ptr [SI], 200h - Or Byte Ptr [SI+3Ah], 80h ; Disown channel - Jmp AllocateChannel4 - -AllocateChannel8: - Cmp Byte Ptr [DI+0Fh], 101 - JE AllocateChannelMIDIDC - - Mov AL, [ES:BX+12h] - Test AL, AL - JZ AllocateChannel4 ; Duplicate check off. - -AllocateChannel11: ; Duplicate check... - Mov SI, AllocateSlaveOffset - Mov CX, AllocateNumChannels - - Mov DX, [DI+3] ; DX = note - Mov BP, 32h - Cmp AL, 1 - JE AllocateDCT - - Mov BP, 33h ; Duplicate instrument - Mov DL, DH - Cmp AL, 3 - JE AllocateDCT - - Mov BP, 36h ; Duplicate sample - Mov DL, [DI+0Fh] - Dec DL - JS AllocateChannel4 - -AllocateDCT: - Mov AH, [DI+20h] ; AH = HCN - Or AH, 80h - Mov CH, [ES:BX+13h] ; CH = DCA - -AllocateChannel6: - Test Byte Ptr [SI], 1 - JZ AllocateChannel7 - - Cmp Byte Ptr [DI+0Fh], 101 - JE AllocateChannelMIDIDCT - - Mov AL, [SI+3Ah] ; AL = HCN of slave. - Cmp AH, AL - JNE AllocateChannel7 - ; OK. same channel... now.. - -AllocateChannelMIDIDCT: - Cmp DH, [SI+33h] ; Same inst? - JNE AllocateChannel7 - - Cmp DL, [DS:SI+BP] ; Same note/sample/inst? - JNE AllocateChannel7 - - Cmp Byte Ptr [DI+0Fh], 101 ; New note is a MIDI? - JE AllocateChannelMIDIHandling - - Cmp CH, [SI+29h] - JNE AllocateChannel7 - - Test CH, CH ; Checks for hiqual - JZ AllocateChannel20Samples - - Mov Word Ptr [SI+28h], 0 - Mov AL, CH - Inc AX - Jmp AllocateHandleNNA - -AllocateChannelMIDIHandling: - Cmp Byte Ptr [SI+36h], 100 ; Is current channel a MIDI chan - JNE AllocateChannel7 - - Cmp AH, [SI+3Ch] - JNE AllocateChannel7 - - Or Word Ptr [SI], 200h - Test Byte Ptr [SI+3Ah], 80h - JNZ AllocateChannel7 - - Mov BP, [SI+38h] - Or Byte Ptr [SI+3Ah], 80h - And Byte Ptr [DS:BP], Not 4 - -AllocateChannel7: - Add SI, SLAVECHANNELSIZE - Dec CL - JNZ AllocateChannel6 - -AllocateChannel4: - Mov CX, AllocateNumChannels - Mov SI, AllocateSlaveOffset - - Cmp Byte Ptr [DI+0Fh], 101 - JNE AllocateChannel10 - -; MIDI 'slave channels' have to be maintained if still referenced - - Push DI - -AllocateMIDIChannel1: - Test Byte Ptr [SI], 1 - JNZ AllocateMIDIChannel2 - - ; Have a channel.. check that it's host's slave isn't SI - Mov DI, [SI+38h] - Test DI, DI - JZ AllocateMIDIChannelFound - Cmp SI, [DI+24h] - JNE AllocateMIDIChannelFound - -AllocateMIDIChannel2: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ AllocateMIDIChannel1 - - Pop DI - - Jmp AllocateChannel17 - -AllocateChannel10: - Test Byte Ptr [SI], 1 - JZ AllocateChannelInstrument - - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ AllocateChannel10 - -AllocateChannel17: ; Common sample search - Push BX - Push DI - Push ES - - Push CS - Pop ES - - Mov DI, Offset ChannelCountTable - Xor AX, AX - Mov CX, (100+200)/2 - Rep StosW ; Clear table - Dec AX - Mov CX, 100/2 ; Volumes - Rep StosW - - Pop ES - - Mov CX, AllocateNumChannels - Xor EBX, EBX - Mov DI, AllocateSlaveOffset - -AllocateChannelCommonSample1: - Mov BL, [DI+36h] ; BX = sample pointer into - ; table. - Cmp BL, 99 ; Just for safety - JA AllocateChannelCommonSample2 - - Inc Byte Ptr [ChannelCountTable+BX] - - Mov AH, [ChannelCountTable+BX+300] ; Volume - - Test Byte Ptr [DI+3Ah], 80h ; Disowned channel? - JZ AllocateChannelCommonSample2 - - Cmp AH, [DI+20h] ; Lower Volume? - JBE AllocateChannelCommonSample2 - - Mov AH, [DI+20h] ; Get volume - Mov Word Ptr [ChannelCountTable+EBX+EBX+100], DI ; Store location - Mov [ChannelCountTable+BX+300], AH ; Store volume - -AllocateChannelCommonSample2: - Add DI, SLAVECHANNELSIZE - Dec CX - JNZ AllocateChannelCommonSample1 - - ; OK.. now search table for maximum - ; occurrence of sample... - - Xor EDI, EDI - Xor SI, SI - Mov AH, 2 ; Find maximum count, has to be - ; greater than 2 channels - Mov CX, 100 - -AllocateChannelCommonSample3: - Cmp AH, [ChannelCountTable+DI] - JAE AllocateChannelCommonSample4 - - Mov AH, [ChannelCountTable+DI] - Mov SI, Word Ptr [ChannelCountTable+EDI+EDI+100] - -AllocateChannelCommonSample4: - Inc DI - Dec CX - JNZ AllocateChannelCommonSample3 - - Pop DI - Pop BX - -; Inc AllocateCount1 - - Test SI, SI - JNZ AllocateChannelInstrument - -; Dec AllocateCount1 - - ; Find out which host channel has the most - ; (disowned) slave channels - ; Then find the softest non-single sample - ; in that channel. - Push BX - - Push ES - Push DI - - Push CS - Pop ES - Mov DI, Offset ChannelCountTable - Xor AX, AX - Mov CX, 32 - Rep StosW - - Pop DI - Pop ES - - Xor BX, BX - Mov CX, AllocateNumChannels - Mov SI, AllocateSlaveOffset - -AllocateChannelCount1: - Mov BL, [SI+3Ah] ; Host channel number - And BL, 3Fh - Inc Byte Ptr [ChannelCountTable+BX] - -AllocateChannelCount2: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ AllocateChannelCount1 - -AllocateChannelCountEnd: - ; OK.. search through and find - ; the most heavily used channel - - Mov AX, 100h ; AH = channel count - Xor BX, BX ; AL = channel - Mov CX, 64 ; 64 = physical channels - -AllocateChannelCountSearch1: - Cmp AH, [BX+ChannelCountTable] - JAE AllocateChannelCountSearch2 - - Mov AH, [BX+ChannelCountTable] - Mov AL, BL - -AllocateChannelCountSearch2: - Inc BX - Dec CX - JNZ AllocateChannelCountSearch1 - - Pop BX - - ; AH = channel to use. - Cmp AH, 1 - JBE AllocateChannelSoftestSearch - - Or AL, 80h ; Search for disowned only - - Push BX - Push DI - - Mov BH, [DI+0Fh] - Dec BH - - Mov CX, AllocateNumChannels - Mov DI, AllocateSlaveOffset - Xor SI, SI ; Offset - Mov AH, 0FFh - -AllocateChannelNonSingle1: - Cmp AL, [DI+3Ah] - JNE AllocateChannelNonSingle3 - - Cmp AH, [DI+20h] ; Lower Volume? - JBE AllocateChannelNonSingle3 - - ; Now check if any other - ; channel contains this - ; sample - Cmp BH, [DI+36h] - JE AllocateChannelNonSingle6 - - Push CX - Push SI - - Mov BL, [DI+36h] ; Sample number - Mov Byte Ptr [DI+36h], 0FFh - - Mov SI, AllocateSlaveOffset - Mov CX, AllocateNumChannels - -AllocateChannelNonSingle2: - Cmp BH, [SI+36h] - JE AllocateChannelNonSingle5 - - Cmp BL, [SI+36h] ; A second sample? - JE AllocateChannelNonSingle5 - -AllocateChannelNonSingle4: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ AllocateChannelNonSingle2 - - Mov [DI+36h], BL - - Pop SI - Pop CX - Jmp AllocateChannelNonSingle3 - -AllocateChannelNonSingle5: - Mov [DI+36h], BL - - Pop SI - Pop CX - -AllocateChannelNonSingle6: ; OK found a second sample. - Mov SI, DI ; get offset. - Mov AH, [DI+20h] ; Get volume - -AllocateChannelNonSingle3: - Add DI, SLAVECHANNELSIZE - Dec CX - JNZ AllocateChannelNonSingle1 - - Pop DI - Pop BX - - Test SI, SI - JNZ AllocateChannelSampleSearch -; JNZ AllocateChannelInstrument - - Push BX - Mov SI, AX - And SI, 03Fh - Mov Byte Ptr [ChannelCountTable+SI], 0 - Jmp AllocateChannelCountEnd ; Next cycle... - -AllocateChannelSampleSearch: -; Inc AllocateCount2 - - Push DI - - Mov AL, [SI+36h] - - Mov CX, AllocateNumChannels - Mov DI, AllocateSlaveOffset - Mov AH, 0FFh - -AllocateChannelSampleSearch1: - Cmp AL, [DI+36h] ; Same sample? - JNE AllocateChannelSampleSearch2 - - Test Byte Ptr [DI+3Ah], 80h ; Disowned channel? - JZ AllocateChannelSampleSearch2 - - Cmp AH, [DI+20h] ; Lower Volume? - JBE AllocateChannelSampleSearch2 - - Mov SI, DI ; get offset. - Mov AH, [DI+20h] ; Get volume - -AllocateChannelSampleSearch2: - Add DI, SLAVECHANNELSIZE - Dec CX - JNZ AllocateChannelSampleSearch1 - - Pop DI - - Jmp AllocateChannelInstrument - -AllocateChannelSoftestSearch: - Push DI ; Now search for softest - ; disowned sample - ; (not non-single) - - Mov CX, AllocateNumChannels - Mov DI, AllocateSlaveOffset - Xor SI, SI ; Offset - Mov AH, 0FFh - -AllocateChannel18: - Test Byte Ptr [DI+3Ah], 80h ; Disowned??? - JZ AllocateChannel19 ; No.. then look for next - - Cmp AH, [DI+20h] ; Volume set... - JB AllocateChannel19 - - Mov SI, DI ; get offset. - Mov AH, [DI+20h] ; Get volume - -AllocateChannel19: - Add DI, SLAVECHANNELSIZE - Dec CX - JNZ AllocateChannel18 - - Pop DI - -; Inc AllocateCount3 - - Test SI, SI - JNZ AllocateChannelInstrument - - Pop CX - And CH, Not 4 - - StC - Ret - -AllocateMIDIChannelFound: - Pop DI - -AllocateChannelInstrument: - Mov [DI+24h], SI ; SCOffset - - Mov AL, [DI+20h] - Mov [SI+3Ah], AL ; HCN - - Mov [SI+38h], DI ; HCOffset - - Xor EAX, EAX - Mov [SI+18h], EAX ; Reset vibrato info. - Mov Byte Ptr [SI+0Bh], AL ; Reset loop dirn - - Call InitPlayInstrument - - Mov AL, [ES:BX+18h] - Mov [SI+24h], AL - - Pop CX - - Mov Word Ptr [SI+26h], 0400h ; FadeOut, VolEnv&Pos - - Mov AX, [DI+3] - Cmp Byte Ptr [DI+0Fh], 101 - JNE NoMIDINote - - Mov AL, [DI+0Eh] - -NoMIDINote: - Mov [SI+32h], AX ; Nte&Ins - - Mov BL, [DI+0Fh] - And BX, 0FFh - JZ AllocateChannel21 - Dec BX - - Call I_TagSample - - Mov [SI+36h], BL - - Add BX, BX - Mov BX, [ES:64912+BX] - Mov [SI+34h], BX ; Sample memory offset. - - Cmp DWord Ptr [ES:BX+30h], 0 - JE AllocateChannelInstrument2 ; No sample! - - Mov AX, [ES:BX+11h] - Test AH, 1 - JZ AllocateChannelInstrument2 ; No sample! - - And AH, 2 - Mov [SI+18h], AH - - Mul Byte Ptr [SI+24h] - ShR AX, 6 - Mov [SI+24h], AL ; SI = 0->128 - - ClC - Ret - -AllocateChannelInstrument2: - Mov Word Ptr [SI], 200h - And CH, Not 4 - StC - Ret - -EndP AllocateChannel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Seed1 DW 1234h -Seed2 DW 5678h - -Proc Random - - Push BX - Push CX - Push DX - - Mov AX, Seed1 - Mov BX, Seed2 - Mov CX, BX - Mov DX, BX - - Add AX, BX - Rol AX, CL - Xor AX, DX - XChg CL, CH - Add BX, CX - Add DX, BX - Add CX, AX - Ror BX, 1 - SBB AX, DX - Mov Seed2, DX - Mov Seed1, AX - - Pop DX - Pop CX - Pop BX - - Ret - -EndP Random - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetLoopInformation - ; Destroys AX, BX, CX, DX - Mov BX, [SI+34h] ; ES:BX points to sample header - Mov AL, [ES:BX+12h] ; AL = sample flags - - Test AL, 30h ; Loop?? - JZ GetLoopInformation4 - - Mov ECX, [ES:BX+34h] ; CX = loopbeg - Mov EDX, [ES:BX+38h] ; DX = loopend - - Mov AH, AL - - Test AL, 20h ; SusLoop? - JZ GetLoopInformation2 - - Test Byte Ptr [SI], 4 - JNZ GetLoopInformation1 - - Mov ECX, [ES:BX+40h] - Mov EDX, [ES:BX+44h] - ShR AH, 1 - Jmp GetLoopInformation2 - -GetLoopInformation1: - Test AL, 10h - JZ GetLoopInformation4 - -GetLoopInformation2: - Test AH, 40h - JNZ GetLoopInformation3 - - Mov AH, 8 - Jmp GetLoopInformation5 - -GetLoopInformation3: - Mov AH, 24 - Jmp GetLoopInformation5 - -GetLoopInformation4: - Xor ECX, ECX - Mov EDX, [ES:BX+30h] - Mov AH, 0 - -GetLoopInformation5: - Cmp [SI+0Ah], AH - JNE GetLoopInformation6 - Cmp [SI+40h], ECX - JNE GetLoopInformation6 - Cmp [SI+44h], EDX - JNE GetLoopInformation6 - - Ret - -GetLoopInformation6: - Mov [SI+0Ah], AH - Mov [SI+40h], ECX - Mov [SI+44h], EDX - Or Word Ptr [SI], 400h ; Loop changed. - - Ret - -EndP GetLoopInformation - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include it_m_eff.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PitchSlideDown ; Expects SI to slave - ; BX = slide value - Assume DS:Music - -IF USEFPUCODE - Neg BX - -EndP PitchSlideDown ; EndP for PitchSlideDown - -ELSE - Test Byte Ptr [ES:2Ch], 8 - JNZ PitchSlideDownLinear - ; Go on to amiga slide down. -EndP PitchSlideDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PitchSlideDownAmiga - - Or Byte Ptr [SI], 32 ; recalculate pitch! - - Mov EAX, [SI+10h] - MovZX EBX, BX - Mul EBX ; EDX:EAX = cmd*InitialFreq - - Xor CX, CX ; CX = counter. - - Add EAX, 1712*8363 - AdC EDX, 0 - JZ PitchSlideDownAmiga1 - -PitchSlideDownAmiga2: - ShR EDX, 1 - RCR EAX, 1 - Inc CX - - Test EDX, EDX - JNZ PitchSlideDownAmiga2 - -PitchSlideDownAmiga1: - Mov EBX, EAX ; EBX = 1712*8363+Cmd*InitialFreq - - Mov EAX, 8363*1712 - Mul DWord Ptr [SI+10h] - - JCXZ PitchSlideDownAmiga4 - -PitchSlideDownAmiga5: - ShR EDX, 1 - RCR EAX, 1 - Loop PitchSlideDownAmiga5 - -PitchSlideDownAmiga4: - Cmp EBX, EDX - JBE PitchSlideDownAmiga3 - - Div EBX - - Mov [SI+10h], EAX - -PitchSlideDownAmiga3: - Ret - -EndP PitchSlideDownAmiga - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PitchSlideDownLinear -; Given BX = slide down value = 0->1024 - - Or Byte Ptr [SI], 32 ; recalculate pitch! - - Push DI - Mov DI, Offset LinearSlideDownTable - - Cmp BX, 0Fh - JA PitchSlideDownLinear1 - - Mov DI, Offset FineLinearSlideDownTable - Add BX, BX - Jmp PitchSlideDownLinear2 - -PitchSlideDownLinear1: - ShR BX, 1 - And BX, Not 1 - -PitchSlideDownLinear2: - MovZX EAX, Word Ptr [DI+BX] - Mul DWord Ptr [SI+10h] - SHRD EAX, EDX, 16 - - Mov [SI+10h], EAX - - Pop DI - Ret - -EndP PitchSlideDownLinear - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ENDIF ; USEFPUCODE - -Proc PitchSlideUp ; Expects SI to slave - ; BX = slide value - Test Byte Ptr [ES:2Ch], 8 - JZ PitchSlideUpAmiga - ; Go on to linear slide - -EndP PitchSlideUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PitchSlideUpLinear - -IF USEFPUCODE - Mov [CS:SlideValue], BX - FILD Word Ptr [CS:SlideValue] - FMul [CS:Const1_On_768] ; Have SlideValue/768.0 - FLd ST - FRndInt - FSub ST(1), ST - FXCh - F2XM1 - FLd1 - FAdd - FScale - FIMul DWord Ptr [SI+10h] - FIStP DWord Ptr [SI+10h] - FStP ST - -PitchSlideUpFPUFreqCheck: - Or Byte Ptr [SI], 32 ; recalculate pitch! - Cmp DWord Ptr [SI+10h], 07FFFFFFFh - JAE PitchSlideUpLinear1 - Ret - -PitchSlideUpLinear1: ; Turn off channel - Or Word Ptr [SI], 200h - And Byte Ptr [DI], Not 4 -ELSE - - Or Byte Ptr [SI], 32 ; recalculate pitch! - - Push DI - Cmp BX, 0Fh - Mov DI, Offset LinearSlideUpTable - JA PitchSlideUpLinear3 - - Mov DI, Offset FineLinearSlideUpTable - ShL BX, 2 - - Jmp PitchSlideUpLinear2 - -PitchSlideUpLinear3: - And BX, Not 3 - -PitchSlideUpLinear2: - Mov EAX, [SI+10h] - Mul DWord Ptr [DI+BX] - SHRD EAX, EDX, 16 - - Test EDX, 0FFFF0000h - JNZ PitchSlideUpLinear1 - - Mov [SI+10h], EAX - - Pop DI - Ret - -PitchSlideUpLinear1: ; Turn off channel - Pop DI - Or Word Ptr [SI], 200h - And Byte Ptr [DI], Not 4 -; And Byte Ptr [SI], Not 1 -; Or Byte Ptr [SI+1], 2 ; Cut! -; And Byte Ptr [DI], Not 4 - -ENDIF - - Ret - -EndP PitchSlideUpLinear - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PitchSlideUpAmiga - -IF USEFPUCODE - Mov [CS:SlideValue], BX - FILD Word Ptr [CS:SlideValue] - FILD DWord Ptr [SI+10h] ; InitFreq, Cmd - FMul ST(1), ST ; InitFreq, Cmd.InitFreq - FLd [CS:Const_14317456] ; 1712*8363, InitFreq, Cmd.InitFreq - FSubR ST(2), ST ; 1712*8363, InitFreq, 1712*8363-Cmd.InitFreq - FMul ; 1712*8363*InitFreq, 1712*8363-Cmd.InitFreq - FDivRP ST(1), ST ; FinalFreq - FIStP DWord Ptr [SI+10h] - Jmp PitchSlideUpFPUFreqCheck - -ELSE - Or Byte Ptr [SI], 32 ; recalculate pitch! - - Mov EAX, [SI+10h] - MovZX EBX, BX - Mul EBX ; EDX:EAX = InitialFreq*Cmd - - Test EDX, EDX - JNZ PitchSlideUpAmiga1 - - Mov ECX, 1712*8363 - Mov EDX, ECX - Sub ECX, EAX ; ECX = 1712*8363-Cmd*InitialFreq - JBE PitchSlideUpAmiga1 - - Mov EAX, [SI+10h] - Mul EDX - Cmp ECX, EDX - JBE PitchSlideUpAmiga1 - - Div ECX - - Mov [SI+10h], EAX - - Ret - -PitchSlideUpAmiga1: ; Turn off channel - Or Word Ptr [SI], 200h - And Byte Ptr [DI], Not 4 -; And Byte Ptr [SI], Not 1 -; Or Byte Ptr [SI+1], 2 ; Cut! -; And Byte Ptr [DI], Not 4 - - Ret -ENDIF - -EndP PitchSlideUpAmiga - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetWaveForm Far - - Test Byte Ptr CS:DriverFlags, 4 - JZ Music_GetWaveForm1 - - Call [CS:DriverGetWaveform] - - DB 85h - -Music_GetWaveForm1: - StC - Ret - -EndP Music_GetWaveForm - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_Poll Far - - Mov AX, CS:PlayMode - Mov BX, CS:CurrentPattern - Jmp [DriverPoll] - -EndP Music_Poll - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_InitTempo Far - - PushA - Call Music_GetTempo - Call [DriverSetTempo] - PopA - - Ret - -EndP Music_InitTempo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetChannels ; Returns min of NumChannels & DriverMaxChannels - ; Also uses default channels if num channels - ; = 0ffffh - Push DS - - Push CS - Pop DS - Assume DS:Music - - Mov AX, CmdLineNumChannels - Cmp AX, 0FFFFh - JNE GetChannels2 - - Mov AX, DefaultChannels - -GetChannels2: - Cmp AX, DriverMaxChannels - JBE GetChannels1 - - Mov AX, DriverMaxChannels - -GetChannels1: - Cmp AX, MAXSLAVECHANNELS - JB GetChannels3 ; MC4 - - Mov AX, MAXSLAVECHANNELS - -GetChannels3: ; MC4 - Mov NumChannels, AX - - Pop DS - Ret - -EndP GetChannels - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ReinitSoundCard Far - - Call GetChannels - Call [DriverReinitSound] - Jmp Music_SoundCardLoadAllSamples - -EndP Music_ReinitSoundCard - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_UnInitSoundCard Far - - Jmp [DriverUninitSound] - -EndP Music_UnInitSoundCard - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_InitMusic Far - - PushAD - Push DS - Push ES - - Xor AX, AX - Mov DS, AX - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset Music_UpdateSampleLocation -IF ENABLEINT3 -ELSE - Mov [DS:0Ch], EAX -ENDIF - - Trace " - Initialising SoundDriver Tables" - - Call Music_ClearDriverTables - Call D_GotoStartingDirectory - - Push CS - Pop DS - - Assume DS:Music - - Trace " - Loading MIDI configuration" - - ; Open MIDI Config file. - Mov AX, 3D00h - Mov DX, Offset MIDIConfigFileName - Int 21h - JC Music_InitMusic1 - - Mov BX, AX - - Mov DS, MIDIDataArea - Xor DX, DX - Mov AH, 3Fh - Mov CX, (128+16+9)*32 - Int 21h - - Mov AH, 3Eh ; Close - Int 21h - -Music_InitMusic1: - Trace " - Initialising playback tables" - - Call Music_Stop - - Pop ES - Pop DS - PopAD - Assume DS:Nothing - - Ret - -EndP Music_InitMusic - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ReleasePattern Far ; AX = pattern number - - Push AX - Push DS - Push SI - Push ES - - LEA SI, [63912+EAX*4] - Push SI - - Mov DS, CS:SongDataArea - - LodsW - Cmp AL, 1 - JB Music_ReleasePattern1 - JA Music_ReleasePattern2 - - LodsW - Mov ES, AX - Mov AH, 49h - Int 21h - Jmp Music_ReleasePattern1 - -Music_ReleasePattern2: - Cmp AL, 3 - JB Music_ReleasePattern3 - JA Music_ReleasePattern1 - - LodsW - Dec AX - Call E_ReleaseBlockEMS - - Jmp Music_ReleasePattern1 - -Music_ReleasePattern3: - LodsW - Call E_ReleaseEMS - -Music_ReleasePattern1: - Pop SI - Mov DWord Ptr [SI], 0 - - Pop ES - Pop SI - Pop DS - Pop AX - - Ret - -EndP Music_ReleasePattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetPattern Far ; AX = pattern number - ; Returns DS:SI points to pattern data. - - Push AX - -; ShL AX, 2 -; Mov SI, 63912 -; Add SI, AX - LEA SI, [63912+EAX*4] - - Mov DS, CS:SongDataArea - - LodsW - Cmp AL, 1 - JE Music_GetPattern1 - JA Music_GetPattern2 - - Push CS - Pop DS - Mov SI, Offset EmptyPattern - - Pop AX - Ret - -Music_GetPattern1: - LodsW - Mov DS, AX - Xor SI, SI - - Pop AX - Ret - -Music_GetPattern2: - Cmp AL, 3 - JB Music_GetPattern3 - - LodsW - Call E_MapAlignedBlockEMS - - Pop AX - Ret - -Music_GetPattern3: - Push CX - Push DX - - MovZX CX, AH - Mov DX, [SI] - Call E_MapEMSMemory - Call E_GetEMSPageFrame - Mov DS, AX - Xor SI, SI - - Pop DX - Pop CX - - Pop AX - Ret - -EndP Music_GetPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetPatternLocation Far ; AX = pattern number - ; Returns AX = handle - ; EBX = page/offset or - ; seg/offset - ; CX = length - - Call Music_GetPattern ; Returns DS:SI - Mov CX, [SI] - Add CX, 8 ; CX = size of data including header - -Proc Music_GetPatternLocationNoCount Far - - LEA SI, [63912+EAX*4] - - Mov DS, CS:SongDataArea - - LodsW - Cmp AL, 1 - JE Music_GetPatternLocation1 - JA Music_GetPatternLocation2 - - Mov BX, CS - Xor AX, AX - ShL EBX, 16 - Xor DX, DX - Mov BX, Offset EmptyPattern - - Ret - -Music_GetPatternLocation1: - LodsW - Mov BX, AX - ShL EBX, 16 - Xor AX, AX - Xor DX, DX - - Ret - -Music_GetPatternLocation2: - Cmp AL, 3 - JB Music_GetPatternLocation3 - - LodsW ; AX = "Segment" into EMS block - ; Want page = (AX >> 10) - ; offset = (AX << 4) & 0xFFFF - Mov BX, AX - ShL AX, 4 - ShL EBX, 6 - - Mov BX, AX - And EBX, 03F3FFFh - - Call E_GetInternalEMSHandle - Mov DL, 1 - - Ret - -Music_GetPatternLocation3: - LodsW - Xor EBX, EBX - Mov DL, 1 - - Ret - -EndP Music_GetPatternLocationNoCount - -EndP Music_GetPatternLocation - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_AllocatePattern Far ; DX = length. - ; SI = Pattern - ; ES:DI points to pattern area - Cmp CS:PatternStorage, 1 - JB Music_AllocatePatternConventionalOnly - JA Music_AllocatePatternEMS2 - -Music_AllocatePatternEMS: ; Try allocating EMS - Xor EAX, EAX - Mov AX, DX - Call E_AllocateBlockEMS - JC Music_AllocatePatternEMS2 - - Mov ES, CS:SongDataArea - LEA DI, [ESI*4+63914] - Inc AX - StosW - Mov Word Ptr [ES:DI-4], 3 - - Push DS - Push SI - - Call E_MapAlignedBlockEMS - - Push DS - Pop ES - Mov DI, SI - - Pop SI - Pop DS - Ret - -Music_AllocatePatternEMS2: - MovZX EAX, DX - ClC - Call E_AllocateEMS - Test AX, AX - JZ Music_AllocatePatternConventional - - Push CX - Push DX - - Mov ES, CS:SongDataArea - LEA DI, [ESI*4+63914] -; Mov DI, SI -; ShL DI, 2 -; Add DI, 63914 - StosW - - Add DX, 16383 - RCR DX, 1 - ShR DX, 13 - Mov CX, DX - Mov DX, AX - Call E_MapEMSMemory - - Mov CH, CL - Mov CL, 2 - - Mov [ES:DI-4], CX - Call E_GetEMSPageFrame - - Mov ES, AX - Xor DI, DI - - Pop DX - Pop CX - - Ret - -Music_AllocatePatternConventionalOnly: - Mov AH, 48h ; How much free? - Mov BX, 0FFFFh - Int 21h - - Cmp BX, -1 - JE Music_AllocatePatternEMS - - Cmp BX, 4096 - JAE Music_AllocatePatternConventional - - ShL BX, 4 ; BX = size in bytes of - ; conv remaining - Cmp DX, BX - JA Music_AllocatePatternEMS - -Music_AllocatePatternConventional: - Mov AH, 48h - Mov BX, DX - - Add BX, 15 - RCR BX, 1 - ShR BX, 3 - - Int 21h - JC Music_AllocatePattern2 - - Push DS - Mov DS, CS:SongDataArea - LEA SI, [ESI*4+63912] -; ShL SI, 2 -; Add SI, 63912 - Mov Word Ptr [SI], 1 - Mov [SI+2], AX - - Pop DS - Mov ES, AX - Xor DI, DI - - Ret - -Music_AllocatePattern2: - Xor AX, AX - Mov ES, AX - - Ret - -EndP Music_AllocatePattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_AllocateSample Far ; AX = Sample number, 0 based - ; EDX = length - ; Returns ES:DI, ES = 0 if not. - Push EAX - Push BX - Push CX - Push EDX - Push DS - Push SI - - Mov AH, 2 - Call Music_ReleaseSample - And AX, 0FFh - - Add EDX, 8 ; Extra 8 bytes allocated.. - - Mov BX, AX - Add BX, BX - Mov DS, CS:SongDataArea - Mov SI, [64912+BX] - - Cmp EDX, 1024 - JA Music_AllocateSample5 - - Mov EBX, EDX - Add EBX, 15 - RCR EBX, 1 - SHR EBX, 3 - - Mov AH, 48h - Int 21h - - JNC Music_AllocateSample4 - -Music_AllocateSample5: - Mov EAX, EDX - StC - Call E_AllocateEMS - Test AX, AX ; AX = handle - JZ Music_AllocateSample1 - - Mov Byte Ptr [DS:SI+48h], 2 - Mov [DS:SI+4Ah], AX - Add EDX, 16383 - RCR EDX, 1 - ShR EDX, 13 - Mov [DS:SI+49h], DL - - Xor CH, CH - Mov CL, DL - Mov DX, AX - Call E_MapEMSMemory - - Call E_GetEMSPageFrame - Mov ES, AX - Xor DI, DI - Or Byte Ptr [SI+12h], 1 - - Jmp Music_AllocateSample3 - -Music_AllocateSample1: - Cmp EDX, 1048576 - JAE Music_AllocateSample2 - - Mov EBX, EDX - Add EBX, 15 - RCR EBX, 1 - SHR EBX, 3 - - Mov AH, 48h - Int 21h - - JC Music_AllocateSample2 - -Music_AllocateSample4: - Mov Byte Ptr [SI+48h], 1 - Mov [SI+4Ah], AX - Or Byte Ptr [SI+12h], 1 - - Mov ES, AX - Xor DI, DI - Jmp Music_AllocateSample3 - -Music_AllocateSample2: - And Byte Ptr [SI+12h], 0F0h - - Xor AX, AX - Mov ES, AX - -Music_AllocateSample3: - Pop SI - Pop DS - Pop EDX - Pop CX - Pop BX - Pop EAX - Ret - -EndP Music_AllocateSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ReleaseSample Far ; AX = sample number, 0 based - ; AH = 1 = called from network - ; = 2 = called from allocate - - PushAD - Push DS - Push ES - - Mov DX, AX - And AX, 0FFh - - Mov BX, AX - Add BX, BX - Mov DS, CS:SongDataArea - Mov BX, [BX+64912] - ; DS:BX points to sample - PushAD - Mov SI, BX - Call [DriverReleaseSample] - PopAD - - Mov DI, BX - - Test Byte Ptr [BX+12h], 1 - JZ Music_ReleaseSample1 ; Used to be ReleaseSample5. - ; Changed for network code - - Mov AL, [BX+48h] - Cmp AL, 1 - JB Music_ReleaseSample5 - JE Music_ReleaseSample2 - Cmp AL, 2 - JA Music_ReleaseSample1 - - Mov AX, [BX+4Ah] - Call E_ReleaseEMS - Jmp Music_ReleaseSample1 - -Music_ReleaseSample2: - Mov ES, [BX+4Ah] - Mov AH, 49h - Int 21h - -Music_ReleaseSample1: - Mov DWord Ptr [DI+30h], 0 - Mov DWord Ptr [DI+48h], 0 - - Cmp DH, 1 - JA Music_ReleaseSample5 - JE Music_ReleaseSample6 - -IF NETWORKENABLED - Mov AH, DL - Mov AL, NETWORK_DELETESAMPLEOBJECT - Call Network_AddWordToQueue -ENDIF - -Music_ReleaseSample6: - Push DS - Pop ES - Xor AX, AX - And Byte Ptr [DI+12h], 0FEh - Add DI, 14h - Mov CX, 3Ch/2 - Rep StosW - -Music_ReleaseSample5: - Pop ES - Pop DS - PopAD - Ret - -EndP Music_ReleaseSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ClearSampleName Far ; AX = Sample number (0 based) - - Push CX - Push DS - Push SI - Push ES - Push DI - - Push CS - Pop DS - Mov SI, Offset SampleHeader - - Mov ES, CS:SongDataArea - Mov DI, AX - Add DI, DI - Mov DI, [ES:64912+DI] - - Mov CX, 80 - Rep MovsB - - Pop DI - Pop ES - Pop SI - Pop DS - Pop CX - Ret - -EndP Music_ClearSampleName - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ClearAllSampleNames Far - - Push AX - Push CX - - Mov CX, 100 - -Music_ClearAllSampleNames1: - Mov AX, CX - Dec AX - Call Music_ClearSampleName - - Loop Music_ClearAllSampleNames1 - - Pop CX - Pop AX - - Ret - -EndP Music_ClearAllSampleNames - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ReleaseAllSamples Far - - Push AX - Push CX - - Mov CX, 100 - -Music_ReleaseAllSamples1: - Mov AX, CX - Dec AX - Call Music_ReleaseSample - - Loop Music_ReleaseAllSamples1 - - Pop CX - Pop AX - Ret - -EndP Music_ReleaseAllSamples - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ReleaseAllPatterns Far - - Push AX - Push CX - - Mov CX, 200 - -Music_ReleaseAllPatterns1: - Mov AX, CX - Dec AX - Call Music_ReleasePattern - Loop Music_ReleaseAllPatterns1 - - Pop CX - Pop AX - Ret - -EndP Music_ReleaseAllPatterns - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ClearInstrument Far ; AX = Instrument number - ; (0 based) - - Push CX - Push DS - Push SI - Push ES - Push DI - - Push CS - Pop DS - Assume DS:Music - - Mov DI, AX - Add DI, DI - Mov ES, SongDataArea - Mov DI, [ES:DI+64712] ; ES:DI points to inst. - Mov SI, Offset InstrumentHeader - Mov CX, 554 - Rep MovsB - - Pop DI - Pop ES - Pop SI - Pop DS - Pop CX - Ret - -EndP Music_ClearInstrument - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ClearAllInstruments Far - - Mov AX, 99 - -Music_ClearAllInstruments1: - Call Music_ClearInstrument - Dec AX - JNS Music_ClearAllInstruments1 - - Ret - -EndP Music_ClearAllInstruments - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_UnInitMusic Far - - Call Music_UnInitSoundCard - Call Music_UnloadDriver - - Cmp CS:SongDataArea, 0 - JE Music_UnInitMusic1 - - Call Music_ReleaseAllPatterns - Call Music_ReleaseAllSamples - -Music_UnInitMusic1: - Mov ES, CS:SongDataArea - Mov AH, 49h - Int 21h - - Ret - -EndP Music_UnInitMusic - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetSongSegment Far - - Mov AX, CS:SongDataArea - Ret - -EndP Music_GetSongSegment - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_UnloadDriver - - Xor AX, AX - XChg AX, CS:SoundDriverSegment - Test AX, AX - JZ Music_UnloadDriver1 - - Mov ES, AX - Mov AH, 49h - Int 21h - -Music_UnloadDriver1: - Ret - -EndP Music_UnloadDriver - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc NoFunction2 - - Push CS - Pop DS - Mov SI, Offset NoSoundCardMsg - -Proc NoFunction Far - - Xor AX, AX - StC - Ret - -EndP NoFunction - -EndP NoFunction2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ClearDriverTables - ; Makes all of them point to - ; Xor AX, AX, StC, RetF - Mov AX, CS - Mov ES, AX - - ShL EAX, 16 - Mov AX, Offset NoFunction2 - Mov DI, Offset StartDriverFunctions - StosD - StosD - - Mov AX, Offset NoFunction -IF OLDDRIVER - Mov CX, 61 -ELSE - Mov CX, 29 -ENDIF - Rep StosD - - Xor EAX, EAX - StosD - - Mov DriverMaxChannels, 32 - - Ret - -EndP Music_ClearDriverTables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_LoadDriver ; Given DS:DX = filename - Assume DS:Nothing - -IFDEF DEBUG - - PushA - Push ES - Push DS - - Mov DI, 0B800h - Mov ES, DI - - Push CS - Pop DS - Assume DS:Music - - Mov DI, [ScreenOffset] - Mov SI, Offset LoadDriverMessage - Mov AH, 2 - -LoadDriverMessage1: - LodsB - StosW - Test AL, AL - JNZ LoadDriverMessage1 - - Pop DS - Assume DS:Nothing - - Mov SI, DX - -LoadDriverMessage2: - LodsB - StosW - Test AL, AL - JNZ LoadDriverMessage2 - - Add [CS:ScreenOffset], 160 - - Pop ES - PopA - -ENDIF - - Mov AX, 3D00h - Int 21h - ClD - JNC Music_LoadDriver2 - -IFDEF DEBUG - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Music - - Mov DI, 0B800h - Mov ES, DI - - Mov SI, Offset UnableToReadFileMessage - Mov DI, [ScreenOffset] - Mov AH, 2 - -UnableToReadFileLoop: - LodsB - StosW - Test AL, AL - JNZ UnableToReadFileLoop - - Add [ScreenOffset], 160 - - Pop ES - Pop DS - PopA - Assume DS:Nothing - -ENDIF - - Jmp Music_LoadDriverNoClose - -Music_LoadDriverError: - Mov AH, 3Eh - Int 21h - -Music_LoadDriverNoClose: - ClD - - Call Music_ClearDriverTables - - Push CS - Pop DS - - StC - Ret - -Music_LoadDriver2: - Mov BX, AX ; BX = file handle - Mov AH, 3Fh ; Read file - -IF OLDDRIVER - Mov CX, 256 -ELSE - Mov CX, 128 -ENDIF - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Music - - Mov DX, Offset StartDriverFunctions - Mov SI, DX - Int 21h - JC Music_LoadDriverError - Cmp AX, CX - JNE Music_LoadDriverError - -IF OLDDRIVER - Mov CX, 28 -ELSE - Mov CX, 37 ; Length of ID -ENDIF - - Mov DI, Offset DriverID - RepE CmpsB - JNE Music_LoadDriverError - - ; OK.. ID OK. Now get length, allocate memory - ; load driver, and fill in headers. - Push BX - - Mov BX, DriverLength - Add BX, 15 - Mov AH, 48h - ShR BX, 4 - Int 21h - Pop BX - JC Music_LoadDriverError ; Insufficient memory - - Mov CX, DriverLength - Mov SoundDriverSegment, AX - Mov DS, AX - Assume DS:Nothing - - Mov DI, AX ; DI = segment of driver... - - Mov AH, 3Fh ; Load driver into memory! - Xor DX, DX - Int 21h - - Push CS - Pop DS - Assume DS:Music - - Mov AH, 3Fh - Mov DX, Offset DriverVariableTable - -IF OLDDRIVER - Mov CX, 64 -ELSE - Mov CX, 16 -ENDIF - Int 21h - - Mov AH, 3Fh - -IF OLDDRIVER - Mov CX, 128 - Mov DX, Offset StartDriverFunctions+128 -ELSE - Mov CX, 64 - Mov DX, Offset StartDriverFunctions+64 -ENDIF - Mov SI, DX - Int 21h - JC Music_LoadDriverError - Cmp AX, CX - JNE Music_LoadDriverError - - Mov AH, 3Eh - Int 21h - - ; Setup reqd function table - SHRD EAX, EDI, 16 ; High word of EAX contains - ; segment... - Mov DI, Offset StartDriverFunctions - -IF OLDDRIVER - Mov CX, 64 -ELSE - Mov CX, 32 -ENDIF - -DriverFunctionLoop1: - LodsW - StosD - Loop DriverFunctionLoop1 - - ; Setup variable table - Mov ES, SoundDriverSegment - Xor DI, DI - -IF OLDDRIVER - Mov CX, 256 -ELSE - Mov CX, 16 -ENDIF - Mov SI, Offset DriverRequiredVariables - Rep MovsB - - Mov SI, Offset DriverRequiredFunctions - -IF OLDDRIVER - Mov CX, 128 -ELSE - Mov CX, 32 -ENDIF - Rep MovsD - -IFDEF DEBUG - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Music - - Mov DI, 0B800h - Mov ES, DI - - Mov SI, Offset DetectingMessage - Mov DI, [ScreenOffset] - Mov AH, 2 - -DetectingMessageLoop: - LodsB - StosW - Test AL, AL - JNZ DetectingMessageLoop - - Add [ScreenOffset], 160 - - Pop ES - Pop DS - PopA - Assume DS:Nothing - -ENDIF - ClC - - Ret - -EndP Music_LoadDriver - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ADSCParams DW 7 Dup (0) - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_AutoDetectSoundCard Far - ; Returns DS:SI = string - ; AX, BX, CX, DX, DI = parameters - - Call D_GotoStartingDirectory - - Xor SI, SI - - Mov DX, Word Ptr [CS:DriverName] - And DX, DX - JZ Music_AutoDetectSoundCard1 - - Trace " - Loading specific soundcard driver" - - Cmp DX, 0FFFFh - JE Music_AutoDetectSoundCard4 - - Mov DS, Word Ptr [CS:DriverName+2] - Call Music_LoadDriver - JC Music_AutoDetectSoundCard4 - - Mov AL, 1 ; Forced - Mov BX, TRACKERVERSION - Mov ECX, [CS:DriverName] - Call [DriverDetectCard] - JC Music_AutodetectSoundCard5 - Cmp EAX, 'Jeff' - JE Music_AutoDetectSoundCard4 - -Music_AutodetectSoundCard5: - Call Music_UnloadDriver - Call Music_ClearDriverTables - Jmp Music_AutoDetectSoundCard4 - -Music_AutoDetectSoundCard1: - Trace " - Testing soundcard driver" - - Push SI - Push CS - Pop DS - Assume DS:Music - - Mov Word Ptr [DriverName+2], DS - - Mov BX, [SI+DriverDetectionOrder] - Cmp BX, 0FFFFh - JE Music_AutoDetectSoundCard2 - - Add BX, BX - Mov DX, [DriverNameTable+BX] - Mov Word Ptr [DriverName], DX - Call Music_LoadDriver - JC Music_AutoDetectSoundCard3 - - Xor AX, AX ; Not forced - Mov BX, TRACKERVERSION - Mov ECX, [CS:DriverName] - Call [DriverDetectCard] - JC Music_AutoDetectSoundCard6 - - Cmp EAX, 'Jeff' - JE Music_AutoDetectSoundCard2 - -Music_AutoDetectSoundCard6: - Call Music_UnloadDriver - Call Music_ClearDriverTables - -Music_AutoDetectSoundCard3: - - Pop SI - Add SI, 2 - Jmp Music_AutoDetectSoundCard1 - -Music_AutoDetectSoundCard2: - Pop AX - -Music_AutoDetectSoundCard4: - Call GetChannels - Call [CS:DriverInitSound] - - Mov [CS:ADSCParams+2], DS - - Push CS - Pop DS - Assume DS:Music - - Mov [ADSCParams], SI - Mov [ADSCParams+12], DI - Mov [ADSCParams+10], DX - Mov [ADSCParams+8], CX - Mov [ADSCParams+6], BX - Mov [ADSCParams+4], AX - - Call Music_InitStereo - - Call Music_InitMixTable - - Ret - -EndP Music_AutoDetectSoundCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ShowAutoDetectSoundCard Far - - Push CS - Pop DS - Assume DS:Music - - Push DWord Ptr [ADSCParams+10] - Push DWord Ptr [ADSCParams+6] - Push [ADSCParams+4] - - LDS SI, DWord Ptr [ADSCParams] - - Mov AH, 20h - Mov DI, (26+28*80)*2 - Call S_DrawString - - Add SP, 10 - Ret - -EndP Music_ShowAutoDetectSoundCard - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetInstrumentMode Far - - Push DS - Mov DS, CS:SongDataArea - Mov AH, [DS:2Ch] - And AH, 4 - - Pop DS - - Ret - -EndP Music_GetInstrumentMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateGOTONote ; Get offset & arrayed flag. - - Push DS - Assume DS:Nothing - - Call PE_GetCurrentPattern - ; AX = Pattern number - ; BX = MaxRow - ; DS = PatternDataSegment - Cmp AX, CS:CurrentPattern - JNE UpdateGOTONote1 - - Mov DecodeExpectedPattern, AX - Mov CS:PatternSegment, DS - - Pop DS - Assume DS:Music - Mov NumberOfRows, BX - Mov AX, ProcessRow - Cmp AX, BX - JB UpdateGOTONote2 - - Xor AX, AX - Mov ProcessRow, AX - Mov CurrentRow, AX - -UpdateGOTONote2: - Mov DecodeExpectedRow, AX - - LEA AX, [EAX*4+EAX] ; PatternRowSize = *320 - ShL AX, 6 -; Mov BX, 320 -; Mul BX - Mov PatternOffset, AX - Mov PatternArray, 1 - - Ret - -UpdateGOTONote1: - Pop DS - Assume DS:Music - - Mov AX, CurrentPattern - Mov DecodeExpectedPattern, AX -IF NETWORKENABLED - Call Network_UpdatePatternIfIdle -ENDIF - Call Music_GetPattern - Assume DS:Nothing - ; DS:SI points to pattern. - - LodsW - LodsW ; AX = number of rows - - Mov CX, ProcessRow - Cmp AX, CX - JA UpdateGotoNote3 - - Xor CX, CX - -UpdateGOTONote3: - Mov CurrentRow, CX - Mov ProcessRow, CX - Mov DecodeExpectedRow, CX - Mov NumberOfRows, AX - Add SI, 4 - Inc CX - -UpdateGOTONote10: - Dec CX - JZ UpdateGOTONote5 - -UpdateGOTONote4: ; OK.. now to find the right - ; offset & update tables. - LodsB - Test AL, AL - JZ UpdateGOTONote10 - - Mov DL, AL - - And AX, 7Fh - Dec AX - LEA BX, [EAX*4+EAX] ; BX = AX*5 - ShL BX, 4 ; BX = AX*80 - LEA DI, [HostChannelInformationTable+BX] - - -; And AL, 7Fh -; Dec AL -; Mov AH, HOSTCHANNELSIZE -; Mul AH -; Mov DI, AX -; Add DI, Offset HostChannelInformationTable - ; CS:DI points. - - Mov DH, [CS:DI+2] - Test DL, 80h - JZ UpdateGOTONote6 - - Mov DH, [SI] - Inc SI - Mov [CS:DI+2], DH - -UpdateGOTONote6: - Test DH, 1 - JZ UpdateGOTONote7 - - LodsB - Mov [CS:DI+3], AL - -UpdateGOTONote7: - Test DH, 2 - JZ UpdateGOTONote8 - - LodsB - Mov [CS:DI+4], AL - -UpdateGOTONote8: - Test DH, 4 - JZ UpdateGOTONote9 - - LodsB - Mov [CS:DI+5], AL - -UpdateGOTONote9: - Test DH, 8 - JZ UpdateGOTONote4 - - LodsW - Mov [CS:DI+8], AX - Jmp UpdateGOTONote4 - -UpdateGOTONote5: - Push CS - Pop DS - Assume DS:Music - - Mov PatternOffset, SI - Mov PatternArray, 0 - - Ret - -EndP UpdateGOTONote - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PreInitCommand - - Push DS - Push SI - - Push CS - Pop DS - Assume DS:Music - - Test Byte Ptr [DI+2], 33h - JZ PreInitCommandEnd - - Test Byte Ptr [ES:2Ch], 4 - JNZ PreInitCommand1 - -PreInitCommand2: - Mov AX, [DS:DI+3] - Mov [DS:DI+0Eh], AX ; Sample/note - - Jmp PreInitCommandEnd - -PreInitCommand1: ; Have to xlat. - Mov SI, [DS:DI+3] ; Not a note? - And SI, 0FFh - Cmp SI, 120 - JAE PreInitCommand2 - - Mov BL, [DS:DI+4] - And EBX, 0FFh - JZ PreInitCommand2 - - Add SI, SI - Mov BX, [ES:64710+EBX+EBX] - - Mov AX, [ES:BX+3Ch] - Cmp AL, 0 - JE PreInitCommandNoMIDI - Cmp AL, 17 - JNE PreInitCommandMIDI1 - - Mov AL, [DS:DI+20h] - And AL, 0Fh - Inc AL ; AL = HCN - -PreInitCommandMIDI1: - Mov [DS:DI+0Ch], AX - Mov AH, 101 - Mov AL, [ES:BX+SI+40h] -; Mov AL, [DS:DI+3] - Jmp PreInitCommandMIDIEnd - -PreInitCommandNoMIDI: - Mov AX, [ES:BX+SI+40h] - -PreInitCommandMIDIEnd: - Mov [DS:DI+0Eh], AX - Test AH, AH ; No sample? - JZ PreInitCommand4 - -PreInitCommandEnd: - Mov BL, [DS:DI+6] - And EBX, 31 - - Call Word Ptr [InitCommandTable+EBX+EBX] ; Init note - - Or Byte Ptr [DI], 64 - - MovZX BX, Byte Ptr [DI+20h] ; Check whether chn - ; is on - Test Byte Ptr [ES:BX+40h], 80h - JZ PreInitCommand4 - - Test Byte Ptr [DI], 32 - JNZ PreInitCommand4 - - Test Byte Ptr [DI], 4 - JZ PreInitCommand4 ; Channel was off. - - Mov SI, [DI+24h] - Or Byte Ptr [SI+1], 8 - -PreInitCommand4: - Pop SI - Pop DS - Ret - -EndP PreInitCommand - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateNoteData - Assume DS:Music - - Mov PatternLooping, 0 - - Mov AX, CurrentPattern - Cmp AX, DecodeExpectedPattern - JNE UpdateNoteData1 - - Mov AX, CurrentRow - Inc DecodeExpectedRow - Cmp AX, DecodeExpectedRow - JE UpdateNoteData2 - -UpdateNoteData1: - Call UpdateGOTONote - -UpdateNoteData2: - Mov CX, 64 ; 64 channels -; Xor AX, AX ; Just to get rid of "jumps" - Mov DI, Offset HostChannelInformationTable - - Cmp PatternArray, 1 - JE UpdateNoteArrayed - -UpdateNoteCompressed: ; First clear all old command&value. -; Mov CX, 64 ; Done above - -UpdateNoteCompressed1: - And Word Ptr [DI], Not (3+32+64+256) - Add DI, HOSTCHANNELSIZE - Dec CX - JNZ UpdateNoteCompressed1 - - Push DS - - Mov AX, CurrentPattern -IF NETWORKENABLED -; Call Network_UpdatePatternIfIdle -ENDIF - Call Music_GetPattern ; Gets DS - - Mov SI, CS:PatternOffset -; Mov DS, PatternSegment - Assume DS:Nothing - -UpdateNoteCompressed2: - LodsB - Test AL, AL - JZ UpdateNoteCompressed3 ; No more! - ; else... go through decoding. - Mov DL, AL - - And AX, 7Fh - Dec AX - LEA DI, [EAX*4+EAX] - ShL DI, 4 ; HOSTCHANNELSIZE - Add DI, Offset HostChannelInformationTable - - Mov DH, [CS:DI+2] ; mask. - Test DL, 80h - JZ UpdateNoteCompressed4 - - Mov DH, [SI] - Inc SI - Mov [CS:DI+2], DH - -UpdateNoteCompressed4: ; DH = mask - Test DH, 1 - JZ UpdateNoteCompressed6 - - LodsB - Mov [CS:DI+3], AL - -UpdateNoteCompressed6: - Test DH, 2 - JZ UpdateNoteCompressed8 - - LodsB - Mov [CS:DI+4], AL - -UpdateNoteCompressed8: - Test DH, 4 - JZ UpdateNoteCompressed10 - - LodsB - Mov [CS:DI+5], AL - -UpdateNoteCompressed10: - Test DH, 8 - JZ UpdateNoteCompressed11 - - LodsW - Mov [CS:DI+8], AX - Jmp UpdateNoteCompressed13 - -UpdateNoteCompressed11: - Test DH, 80h - JZ UpdateNoteCompressed12 - - Mov AX, [CS:DI+8] - Jmp UpdateNoteCompressed13 - -UpdateNoteCompressed12: - Xor AX, AX - -UpdateNoteCompressed13: - Mov [CS:DI+6], AX - Call PreInitCommand - - Jmp UpdateNoteCompressed2 - -UpdateNoteCompressed3: - Pop DS - Assume DS:Music - - Mov PatternOffset, SI - - Ret - -UpdateNoteArrayed: - Assume DS:Music - - Push DS - - Mov SI, PatternOffset - Mov DS, PatternSegment - Assume DS:Nothing - -; Mov CX, 64 ; 64 channels -; Mov DI, Offset HostChannelInformationTable - -UpdateNoteArrayed1: - Xor DL, DL ; DL = mask. - And Word Ptr [CS:DI], Not (3+32+64+256) - ; Turn off all calling... - - LodsB ; AL = note data. - Cmp AL, NONOTE - JE UpdateNoteArrayed2 - - Mov [CS:DI+3], AL - Or DL, 1 - -UpdateNoteArrayed2: - LodsB - Test AL, AL - JZ UpdateNoteArrayed3 - - Mov [CS:DI+4], AL - Or DL, 2 - -UpdateNoteArrayed3: - LodsB - Cmp AL, 0FFh - JE UpdateNoteArrayed4 - - Mov [CS:DI+5], AL - Or DL, 4 - -UpdateNoteArrayed4: - LodsW - Mov [CS:DI+6], AX - Mov [CS:DI+8], AX - - Test AX, AX - JZ UpdateNoteArrayed5 - - Or DL, 8 - -UpdateNoteArrayed5: - Test DL, DL - JZ UpdateNoteArrayed6 - - Mov [CS:DI+2], DL - Push CX - - Call PreInitCommand - - Pop CX - Assume DS:Nothing - - -UpdateNoteArrayed6: - Add DI, HOSTCHANNELSIZE - Dec CX - JNZ UpdateNoteArrayed1 - - Pop DS - Assume DS:Music - - Mov PatternOffset, SI - - Ret - -EndP UpdateNoteData - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateVibrato ; DS:SI points to slavechannelstruct. - - Mov BX, [SI+34h] ; ES:BX points to sample - Mov DL, [ES:BX+4Dh] ; Vibrato depth - Test DL, DL - JZ UpdateVibrato1 - - Mov CX, [SI+1Ah] - Add CL, [ES:BX+4Eh] ; Vibrato rate - AdC CH, 0 - - Cmp CH, DL - JBE UpdateVibrato5 - - Mov CH, DL - -UpdateVibrato5: - Mov [SI+1Ah], CX - - Mov AH, [ES:BX+4Ch] ; AH = speed - Mov BH, [ES:BX+4Fh] ; BH = waveform - Test AH, AH - JZ UpdateVibrato1 - - Cmp BH, 3 - JE UpdateVibrato2 - - Mov BL, [SI+19h] - - Add BL, AH - Mov [SI+19h], BL ; Update pointer. - - Mov AL, [FineSineData+BX] - Jmp UpdateVibrato3 - -UpdateVibrato2: - Call Random - And AL, 127 - Sub AL, 64 - -UpdateVibrato3: - IMul CH - - SAL AX, 2 - MovSX BX, AH - -IFE USEFPUCODE - JS UpdateVibrato4 -ENDIF - JZ UpdateVibrato1 - - Push DI - Mov DI, [SI+38h] - Call PitchSlideUpLinear - Pop DI - -IFE USEFPUCODE - Jmp UpdateVibrato1 - -UpdateVibrato4: - Neg BX - Call PitchSlideDownLinear -ENDIF - -UpdateVibrato1: - Ret - -EndP UpdateVibrato - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Update Far - - Push CS - Pop DS - Assume DS:Music - -IF USEFPUCODE - FNSave FPSave - FNInit - FLdCW [NewControlWord] -ENDIF - - Mov CX, MAXSLAVECHANNELS - Mov SI, Offset SlaveChannelInformationTable - Mov DI, [SI+38h] - - Mov BX, MIDICOMMAND_TICK - Call MIDITranslate - - Mov ES, SongDataArea - -Update2: - Test Byte Ptr [SI], 1 - JZ Update3 - ; reset volume - Mov BL, [SI+22h] - Cmp BL, [SI+21h] - JE Update4 - - Mov [SI+21h], BL - Or Byte Ptr [SI], 10h - -Update4: - Mov EAX, [SI+14h] ; Freq - Cmp EAX, [SI+10h] - JE Update3 - - Mov [SI+10h], EAX - Or Byte Ptr [SI], 20h ; Recalc freq. - -Update3: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ Update2 - - Call UpdateData - - Test Byte Ptr [ES:2Ch], 4 - JZ Update5 - - Call UpdateInstruments - Jmp UpdateEnd - -Update5: - Call UpdateSamples - -UpdateEnd: - Mov CX, NumChannels - Mov SI, Offset SlaveChannelInformationTable - Mov AX, PlayMode - -IF USEFPUCODE - FRstor FPSave -ENDIF - Ret - - -EndP Update - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateSamples - - Assume DS:Music - - Mov CX, NumChannels - Mov SI, Offset SlaveChannelInformationTable - -UpdateSamples1: - Test Byte Ptr [SI], 1 - JZ UpdateSamples2 - - Mov BX, [SI] ; OK.. if recalc volume is on. - ; then recalc volume! :) - Push CX - - Test BL, 16 - JZ UpdateSamples3 - - And BL, Not 16 - Mov CL, SoloSample - - Or BL, 64 ; Recalc final vol - Cmp CL, 0FFh - JE UpdateSamples6 - - Cmp [SI+36h], CL - JE UpdateSamples6 - - Or BH, 8 - -UpdateSamples6: - Xor DX, DX - Mov AL, [SI+21h] ; AL = vol - Mul Byte Ptr [SI+23h] ; Channel volume, AX = 0->64^2 - Mov DL, Byte Ptr [SI+24h] ; Sample volume - Mul DX ; AX = 0->64*64*128 - - SHRD AX, DX, 4 ; AX = 0->32768 - - Mov DL, GlobalVolume - Mul DX ; AX = 0->32768*128 - - SHRD AX, DX, 7 - - Mov [SI+20h], AH ; Final vol stored. - Mov [SI+4Ah], AX - -UpdateSamples3: - Test BL, 2 - JZ UpdateSamples4 - - And BL, Not 2 - Or BH, 128 - - Mov AL, [SI+2Ah] - Mov [SI+25h], AL - Cmp AL, 100 - JE UpdateSamples5 - - Sub AL, 32 - ; Pan = (Pan-32)* Separation/128 + 32 - Mov AH, [ES:34h] - ShR AH, 1 ; AH = 0->64 (Separation) - IMul AH ; AX = -2048->+2048 - ; ie. AH = -8->+8 - SAR AX, 6 ; AL = -32->+32 - - Cmp ReverseChannels, 0 - JE UpdateSamplePan3 - - Neg AL - -UpdateSamplePan3: - Add AL, 32 - -UpdateSamples5: - Mov [SI+37h], AL - -UpdateSamples4: - Mov [SI], BX - - Call UpdateVibrato - - Pop CX - -UpdateSamples2: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ UpdateSamples1 - - Ret - -EndP UpdateSamples - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateEnvelope ; Returns Carry if envelope needs - ; to be turned off - ; Reqs ES:DI points to envelope - ; DS:SI points to slave channel envelope structure - ; Called only if envelope is ON - ; BP != 0 if sustain points released, 0 otherwise - - Mov DX, [SI+8] ; DX = current pos - - Cmp DX, [SI+0Ch] ; Expected end pos - JAE UpdateEnvelope1 - - Inc DX - Mov EAX, [SI+4] ; Update value - - Mov [SI+8], DX ; Increase position - Add [SI], EAX - - ClC - Ret - -UpdateEnvelope1: ; Procedure: - ; 1) Get current pos' value - ; 2) Figure out next pos (inc/loop) - ; 3) Figure out delta to next pos - ; 4) Terminate if no loop (with carry) - ; or place new check in [SI+0Ch] - - Xor BX, BX - Mov BL, [SI+0Ah] ; BX = cur env node - LEA AX, [BX+1] - LEA BX, [EBX*2+EBX] ; BX = BX*3 - - Xor DH, DH - Mov DL, [ES:DI+BX+6] - ShL EDX, 16 - Mov [SI], EDX ; Current pos value done. - - ; AX = next cur env node - Mov DX, [ES:DI] - - Test DL, 6 ; Any loop at all? - JZ UpdateEnvelope2 - - Mov BX, [ES:DI+2] ; Normal Loop - - Test DL, 4 ; No SusLoop? - JZ UpdateEnvelope3 - - Test BP, BP - JNZ UpdateEnvelope4 - - Mov BX, [ES:DI+4] - Jmp UpdateEnvelope3 - -UpdateEnvelope4: - Test DL, 2 - JZ UpdateEnvelope2 - -UpdateEnvelope3: ; Loop - Cmp AL, BH - JBE UpdateEnvelope2 - - Xor BH, BH - Mov [SI+0Ah], BL ; BL=New node - LEA BX, [EBX*2+EBX] - - Mov AX, [ES:DI+BX+7] - Mov [SI+8], AX - Mov [SI+0Ch], AX - - ClC - Ret - -UpdateEnvelope2: ; AX = new node - Cmp AL, DH ; DH = number of nodes - JB UpdateEnvelope7 - - StC - Ret - -UpdateEnvelope7: - Mov [SI+0Ah], AL ; New node - LEA BX, [EAX*2+EAX] - - Mov DX, [ES:DI+BX+7] ; New node's tick - Mov [SI+0Ch], DX - Mov AX, [ES:DI+BX+7-3] ; Last node's tick - Sub DX, AX - Inc AX - Mov [SI+8], AX ; For security. - - Mov AL, [ES:DI+BX+6] ; New node's amplitude - Sub AL, [ES:DI+BX+6-3] ; Last node's amplitude - - Mov BX, DX ; BX = delta(ticks) - Xor DX, DX - CBW - Test AX, AX - PushF - JNS UpdateEnvelope5 - - Neg AX - -UpdateEnvelope5: - Sub BX, 1 - AdC BX, 1 ; Just to prevent div 0 errors - - Div BX - ShL EAX, 16 ; This clears AX also - Div BX - ; EAX = value - PopF - JNS UpdateEnvelope6 - - Neg EAX - -UpdateEnvelope6: - Mov [SI+4], EAX ; Delta done - - ClC - Ret - -EndP UpdateEnvelope - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -DoMIDICycle DB 0 - -MIDIPrograms DB 16 Dup (0FFh) ; Do NOT change order! -MIDIBanks DW 16 Dup (0FFFFh) -MIDIPan DB 16 Dup (0FFh) -MIDIPitch DW 16 Dup (2000h) - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateMIDI - Assume DS:Music - -; Stop cycle - - Mov CX, MAXSLAVECHANNELS - Mov SI, Offset SlaveChannelInformationTable - -UpdateMIDI1: - Test Word Ptr [SI], 200h - JZ UpdateMIDI2 - Cmp Byte Ptr [SI+36h], 100 - JNE UpdateMIDI2 - Test Byte Ptr [SI], 1 - JZ UpdateMIDI2 - - Mov Word Ptr [SI], 0 - Mov DI, [SI+38h] ; Host channel in DI - - Mov BX, MIDICOMMAND_STOPNOTE - Call MIDITranslate - - Test Byte Ptr [SI+3Ah], 80h - JNZ UpdateMIDI2 - - Or Byte Ptr [SI+3Ah], 80h - And Byte Ptr [DI], Not 4 ; Signify channel off - -UpdateMIDI2: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ UpdateMIDI1 - -; Play cycle - - Mov CX, MAXSLAVECHANNELS - Mov SI, Offset SlaveChannelInformationTable - -UpdateMIDI3: - Cmp Byte Ptr [SI+36h], 100 ; MIDI Instrument? - JNE UpdateMIDI4 - - Mov DX, [SI] - Test DL, 1 - JZ UpdateMIDI4 - - Mov AL, [SI+4Ch] - Mov Byte Ptr [SI+4Ch], 1 - Mov [SI+2Ch], AL - - Test DX, 800h ; Muted? - JNZ UpdateMIDI4 - - Mov DI, [SI+38h] ; Host channel in DI - And Word Ptr [SI], 0111100010001101b - - Test DH, 1 - JZ UpdateMIDINoPlayNote - -UpdateMIDIPlayNote: ; Check if there's a bank select. - Mov AX, [SI+3Eh] ; MIDI Bank - Cmp AX, 0FFFFh - JE UpdatemIDIBankSelectDone - - Mov BL, [SI+3Ch] ; BL = channel - And BX, 0FFh - Add BX, BX - Cmp [MIDIBanks+BX-2], AX - JE UpdateMIDIBankSelectDone - - Mov [MIDIBanks+BX-2], AX - ShR BX, 1 - Mov [MIDIPrograms+BX-1], 0FFh ; Reset program - - Mov BX, MIDICOMMAND_BANKSELECT - Call MIDITranslate - -UpdateMIDIBankSelectDone: ; Check for a program specification - Cmp Byte Ptr [SI+3Dh], 0 - JL UpdateMIDIProgramDone - - Mov BL, [SI+3Ch] ; BL = channel - And BX, 0FFh - Mov AL, [SI+3Dh] ; MIDI program - Cmp [MIDIPrograms+BX-1], AL - JE UpdateMIDIProgramDone - - Mov [MIDIPrograms+BX-1], AL - - Mov BX, MIDICOMMAND_PROGRAMSELECT - Call MIDITranslate - -UpdateMIDIProgramDone: -; Check for MIDI pitch wheel.. - Test Byte Ptr [ES:2Ch], 64 - JZ UpdateMIDINoPitchWheel - - Mov BL, [SI+3Ch] ; BL = channel - And BX, 0FFh - Add BX, BX - Cmp [MIDIPitch+BX-2], 2000h - JE UpdateMIDINoPitchWheel - - Mov [MIDIPitch+BX-2], 2000h - Mov AL, [SI+3Ch] - Dec AL - Or AL, 0E0h - Call MIDISendFilter - Xor AL, AL - Call MIDISendFilter ; Reset pitch wheel - Mov AL, 40h - Call MIDISendFilter - -UpdateMIDINoPitchWheel: - Mov EAX, [SI+14h] - Mov BX, MIDICOMMAND_PLAYNOTE - Mov [SI+1Ch], EAX - Call MIDITranslate - Jmp UpdateMIDINoChangeVolume - -UpdateMIDINoPlayNote: ; Change in volume? - Test DL, 64 - JZ UpdateMIDINoChangeVolume - - Mov BX, MIDICOMMAND_CHANGEVOLUME - Call MIDITranslate - -UpdateMIDINoChangeVolume: - Test DH, 80h ; Pan changed? - JZ UpdateMIDINoChangePan - - Mov BL, [SI+3Ch] ; BL = channel - And BX, 0FFh - Mov AL, [SI+37h] ; FPP - - Cmp [MIDIPan+BX-1], AL - JE UpdateMIDINoChangePan - - Mov [MIDIPan+BX-1], AL - - Mov BX, MIDICOMMAND_CHANGEPAN - Call MIDITranslate - -UpdateMIDINoChangePan: ; Pitch changed? - Test DL, 32 - JZ UpdateMIDINoPitchChange - - Mov BX, MIDICOMMAND_CHANGEPITCH - Call MIDITranslate - -UpdateMIDINoPitchChange: - -UpdateMIDI4: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ UpdateMIDI3 - - Ret - -EndP UpdateMIDI - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateInstruments - Assume DS:Music ; Things to update: - ; 1) Volume envelope - ; 2) Fadeout - ; 3) FinalVolume - ; 4) Vibrato. - ; Turn off channel if - ; 1) Volume envelope is off & VEV = 0 or - ; 2) Fadeout = 0 - - Mov CX, MAXSLAVECHANNELS - Mov SI, Offset SlaveChannelInformationTable - Mov [DoMIDICycle], 0 - -UpdateInstruments1: - Test Byte Ptr [SI], 1 - JNZ UpdateInstruments16 ; Channel on!! - -UpdateInstruments2: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ UpdateInstruments1 - - Cmp [DoMIDICycle], 0 - JE UpdateInstrumentNoMIDICycle - - Call UpdateMIDI - -UpdateInstrumentNoMIDICycle: - Ret - -; UpdateInstruments14: -; Jmp UpdateInstruments5 ; Jump point - -UpdateInstruments16: - Push CX - - Mov CX, [SI] - - MovZX EDI, Word Ptr [SI+30h] ; ES:DI = instrument - - Cmp Byte Ptr [SI+33h], 0FFh ; No instrument? - JE UpdateInstruments5 ; Prev Intruments14 - - Mov BP, CX - And BP, 4 ; BP = sustain for envelope calls - -UpdatePitchEnvelope: - Test CH, 40h - JZ UpdatePitchEnvelopeApply - - Push SI - Push DI - - Add SI, 70h - Add DI, 1D4h - Call UpdateEnvelope - - Pop DI - Pop SI - - JNC UpdatePitchEnvelopeApply - - And CH, Not 40h - -UpdatePitchEnvelopeApply: - Test Byte Ptr [ES:DI+1D4h], 80h - JZ UpdatePitchEnvelopePitch - - Cmp Byte Ptr [SI+36h], 100 - JE UpdatePanEnvelope - -UpdatePitchEnvelopeFilter: - Mov BX, [SI+71h] - SAR BX, 6 ; Range -128 to +128 - Add BX, 128 ; Range 0 -> 256 - Cmp BH, 1 - AdC BL, -1 - Mov [SI+3Eh], BL - - Or CL, 64 ; Recalculate final volume - -; Test Byte Ptr [SI+3Ah], 80h -; JNZ UpdatePanEnvelope -; -; Call SetFilterCutoff -; - Jmp UpdatePanEnvelope - -UpdatePitchEnvelopePitch: - Mov BX, [SI+71h] - SAR BX, 3 - JZ UpdatePanEnvelope -IFE USEFPUCODE - JS UpdatePitchEnvDown -ENDIF - - Push DI - Mov DI, [SI+38h] - - Call PitchSlideUpLinear ; req: DS:SI points to table - ; DS:DI points to host channel - ; BX = magnintude - Pop DI -IFE USEFPUCODE - Jmp UpdatePostPitchEnvelope - -UpdatePitchEnvDown: - Neg BX - Call PitchSlideDownLinear - -UpdatePostPitchEnvelope: -ENDIF - Or CL, 32 ; Recalculate freq - -UpdatePanEnvelope: - Test CH, 20h - JZ UpdateVolumeEnvelope - - Or CL, 2 ; Recalculate pan - - Push SI - Push DI - - Add SI, 60h - Add DI, 182h - Call UpdateEnvelope - - Pop DI - Pop SI - - JNC UpdateVolumeEnvelope - - And CH, Not 20h - -UpdateVolumeEnvelope: - Test CH, 10h ; Volume envelope on? - JZ UpdateInstruments3 - - Or CL, 16 ; Recalculate volume - - Push SI - Push DI - - Add SI, 50h - Add DI, 130h - Call UpdateEnvelope - - Pop DI - Pop SI - - JC UpdateVolumeEnvelope1 - Test CL, 8 ; Note fade on? - JNZ UpdateInstruments13 - - ; Now, check if loop + sustain - ; off - Test BP, BP - JZ UpdateInstruments5 - - Test Byte Ptr [ES:DI+130h], 2 ; Normal vol env loop? - JNZ UpdateInstruments19 - Jmp UpdateInstruments5 ; Volume calculation - -UpdateVolumeEnvelope1: ; Envelope turned off... - And CH, Not 10h ; Turn off envelope flag - - Cmp Byte Ptr [SI+52h], 0 ; Turn off if end of loop is - JE UpdateInstruments17 ; reached - - Jmp UpdateInstruments19 - -UpdateInstruments3: - Test CL, 8 ; Note fade?? - JNZ UpdateInstruments13 - - ; Also apply fade if No vol env - ; AND sustain off - - Test CL, 4 ; Note off issued? - JZ UpdateInstruments5 - -UpdateInstruments19: - Or CL, 8 - -UpdateInstruments13: - Mov AX, [ES:DI+14h] ; AX = fadeout. - Sub [SI+26h], AX - JG UpdateInstruments4 - Mov Word Ptr [SI+26h], 0 - -UpdateInstruments17: ; Turn off channel - Test Byte Ptr [SI+3Ah], 80h - JNZ UpdateInstruments18 - - Or Byte Ptr [SI+3Ah], 80h - ; Host channel exists - Mov BX, [SI+38h] - And Byte Ptr [BX], Not 4 - -UpdateInstruments18: -; Mov Word Ptr [SI], 200h -; Pop CX -; Jmp UpdateInstruments2 - Or CH, 2 - -UpdateInstruments4: - Or CL, 16 ; Recalc volume flag. - -UpdateInstruments5: - Test CL, 16 - JZ UpdateInstrument10 - ; Calculate volume - And CL, Not 16 - Mov DX, Word Ptr [SoloSample] ; DL = sample, DH = inst - - Or CL, 64 ; Recalc final volume - Mov AL, [SI+21h] ; Note volume.. - - Mul Byte Ptr [SI+23h] ; Channel volume - ; AX = (0->4096) - Cmp DL, 0FFh - JE UpdateInstrumentNoSampleSolo - - Cmp [SI+36h], DL - JNE UpdateInstrumentSolo - -UpdateInstrumentNoSampleSolo: - Cmp DH, 0FFh - JE UpdateInstrumentNoInstrumentSolo - - Cmp [SI+33h], DH - JE UpdateInstrumentNoInstrumentSolo - -UpdateInstrumentSolo: - Or CH, 8 - -UpdateInstrumentNoInstrumentSolo: - Mul Word Ptr [SI+26h] ; Fadeout Vol (0->1024) - ; DX:AX = 0->4194304 - SHRD AX, DX, 7 - ; AX = (0->32768) - Mov DL, [SI+24h] ; Sample volume - Mul DX ; DX:AX = 0->4194304 - - SHRD AX, DX, 7 ; AX = 0->32768 - - Mov DX, Word Ptr [SI+51h] ; VEV, 0->64*256 - Mul DX ; DX:AX = 0->536870912 - - SHRD AX, DX, 14 ; AX = 0->32768 - - Xor DH, DH - Mov DL, GlobalVolume - Mul DX ; DX:AX = 0->4194304 - - SHRD AX, DX, 7 - Mov [SI+20h], AH - Mov [SI+4Ah], AX - -UpdateInstrument10: - Test CL, 2 ; Change in panning? - JZ UpdateInstrument20 - - And CL, Not 2 - Or CH, 128 - - Mov DL, [SI+2Ah] ; DL = actual pan - Mov AL, DL - Cmp DL, 100 - JE UpdateInstrumentSurroundPan - - Mov AL, 32 - Sub AL, DL - CBW - Xor AL, AH - Sub AL, AH ; AL = |32-ActualPan| - - Neg AL - Add AL, 32 - IMul Byte Ptr [SI+62h] ; Pan envelope.. - SAR AX, 5 - Add AL, DL - - Mov [SI+25h], AL ; Value to show.. - - Sub AL, 32 - ; Pan = (Pan-32)* Separation/128 + 32 - Mov AH, [ES:34h] - ShR AH, 1 ; AH = 0->64 (Separation) - IMul AH ; AX = -2048->+2048 - ; ie. AH = -8->+8 - SAR AX, 6 ; AL = -32->+32 - - Cmp ReverseChannels, 0 - JE UpdateInstrumentPan3 - - Neg AL - -UpdateInstrumentPan3: - Add AL, 32 - Jmp UpdateInstrumentPan2 - -UpdateInstrumentSurroundPan: - Mov [SI+25h], AL - -UpdateInstrumentPan2: - Mov [SI+37h], AL - -UpdateInstrument20: - Mov [SI], CX - - Call UpdateVibrato - - Cmp Byte Ptr [SI+36h], 100 ; MIDI? - JNE UpdateInstrumentsNoMIDI - - Mov [DoMIDICycle], 1 - -UpdateInstrumentsNoMIDI: - Pop CX - - Jmp UpdateInstruments2 - -EndP UpdateInstruments - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc UpdateData - - Assume DS:Music - - Mov CX, 64 - Mov AX, PlayMode - Cmp AX, 1 - JE UpdateData_PlayMode1 - JB UpdateData_PlayMode0 - Jmp UpdateData_PlayMode2 - -UpdateData_PlayMode0: ; Step through each channel. - ; Check if on/updatemode OK - Mov DI, Offset HostChannelInformationTable - -UpdateData1: - Cmp Byte Ptr [DI+21h], 0 - JE PlayMode0UpdateVolume1 - - Dec Byte Ptr [DI+21h] ; Handle counter - JNZ UpdateData4 - - And Word Ptr [DI], Not 303h ; Turn off mode. - -UpdateData4: - Mov AX, [DI] - - Test AL, 4 ; Channel on? - JZ UpdateData2 - - Test AH, 1 - JZ UpdateData2 ; Don't update effect?? - -PlayMode0UpdateVolume2: - Push CX - - Mov BX, [DI+0Ah] - And BX, 7 - Add BX, BX - - Call Word Ptr [VolumeEffectTable+BX] - - Pop CX - - Mov AL, [DI] - -UpdateData2: - Test AL, 2 - JNZ UpdateData3 ; Update effect regardless.. - - Test AL, 4 ; Channel on? - JZ PlayMode0UpdateVolume1 - - Test AL, 1 - JZ PlayMode0UpdateVolume1 ; Don't update effect?? - -UpdateData3: ; OK. now handle counter. - Push CX - - Mov BX, [DI+6] - And BX, 31 - Add BX, BX - - Call Word Ptr [CommandTable+BX] - - Pop CX - -PlayMode0UpdateVolume1: - Add DI, HOSTCHANNELSIZE ; Progress to next channel - Dec CX - JNZ UpdateData1 - - Ret ; That's all! - -UpdateData_PlayMode1: - ; Pattern stuff.. - Dec ProcessTick - Dec CurrentTick - JZ UpdateData_Pattern1 - -UpdateData_NoNewRow: ; OK. call update command. - Mov DI, Offset HostChannelInformationTable - -UpdateData_NoNewRow1: - Mov AX, [DI] ; AX = host flags. - - Test AL, 4 - JZ UpdateData_NoNewRow5 - - Test AH, 1 - JZ UpdateData_NoNewRow5 - -UpdateData_NoNewRow4: - Push CX - - Mov BX, [DI+0Ah] - And BX, 7 - Add BX, BX - - Call Word Ptr [VolumeEffectTable+BX] - - Pop CX - - Mov AL, [DI] ; AX = host flags. - -UpdateData_NoNewRow5: - Test AL, 3 - JZ UpdateData_NoNewRow2 - - Test AL, 2 - JNZ UpdateData_NoNewRow3 - - Test AL, 4 - JZ UpdateData_NoNewRow2 - -UpdateData_NoNewRow3: - Push CX - - Mov BX, [DI+6] - And BX, 31 - Add BX, BX - - Call Word Ptr [CommandTable+BX] - - Pop CX - -UpdateData_NoNewRow2: - Add DI, HOSTCHANNELSIZE - Dec CX - JNZ UpdateData_NoNewRow1 - - Ret - -UpdateData_Pattern1: ; OK... have to update row. - Mov AX, CurrentSpeed - Mov CurrentTick, AX - Mov ProcessTick, AX - - Dec RowDelay - JNZ UpdateEffectData - - Mov Word Ptr RowDelay, 1 - - Mov AX, ProcessRow - Inc AX ; Progress to new row. - Cmp AX, NumberOfRows - JB UpdateData_Pattern2 - - Cmp StopEndOfPlaySection, 0 - JNE UpdateDataStopSong - ; Wrap row. - Xor AX, AX - XChg AX, BreakRow - -UpdateData_Pattern2: - Jmp UpdateData_Song1 -; Mov ProcessRow, AX -; Mov CurrentRow, AX -; -; ; Gotta get note data. -; Call UpdateNoteData -; Ret - -UpdateEffectData: - Mov DI, Offset HostChannelInformationTable - -UpdateEffectData1: - Test Byte Ptr [DI], 64 - JZ UpdateEffectData2 - - Mov AL, [DI+2] - Test AL, 88h - JZ UpdateEffectData2 - - Push AX - Push CX - - And AL, 88h - Mov [DI+2], AL - - Mov BL, [DI+6] - And BX, 31 - Add BX, BX - - Call Word Ptr [InitCommandTable + BX] ; Init note - - Pop CX - Pop AX - - Mov [DI+2], AL - -UpdateEffectData2: - Add DI, HOSTCHANNELSIZE - Dec CX - JNZ UpdateEffectData1 - Ret - -UpdateData_PlayMode2: - Dec ProcessTick - Dec CurrentTick - JNZ UpdateData_NoNewRow - ; Play song stuff... - - Mov AX, CurrentSpeed - Mov CurrentTick, AX - Mov ProcessTick, AX - - Dec RowDelay - JNZ UpdateEffectData - - Mov Word Ptr RowDelay, 1 - - Mov AX, ProcessRow - Inc AX - Cmp AX, NumberOfRows - JB UpdateData_Song1 - - Test OrderLockFlag, 1 - JNZ UpdateData_Song5 - - Mov BX, ProcessOrder ; Get new pattern. - Xor DX, DX - Inc BX - -UpdateData_Song2: - Cmp BX, 100h - JGE UpdateData_Song4 - - Mov CL, [ES:BX+100h] ; CL = next pattern. - Cmp CL, 200 - JB UpdateData_Song3 - - Inc BX - Cmp CL, 0FEh - JE UpdateData_Song2 - - Mov StopSong, 1 - - Cmp StopEndOfPlaySection, 0 - JE UpdateData_Song4 - -UpdateDataStopSong: - Call Music_Stop ; Optionally.. loop! - Ret - -UpdateData_Song4: - Test DX, DX - JNZ UpdateDataStopSong - - Inc DX - Xor BX, BX - Jmp UpdateData_Song2 - -UpdateData_Song3: - Mov ProcessOrder, BX - Mov CurrentOrder, BX - - Mov Byte Ptr CurrentPattern, CL - -UpdateData_Song5: - Xor AX, AX - XChg AX, BreakRow - -UpdateData_Song1: - Mov ProcessRow, AX - Mov CurrentRow, AX - - Call UpdateNoteData - Ret - -EndP UpdateData - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetNumberOfSamples Far ; Returns AX - - Push CX - Push DS - Push SI - Push ES - Push DI - - Push CS - Pop DS - Assume DS:Music - - Mov ES, SongDataArea - Mov DI, 63912-160 - - Mov AX, 99 - -Music_GetNumberOfSamples1: - Mov CX, 80 - Mov SI, Offset SampleHeader - RepE CmpsB - JNE Music_GetNumberOfSamples2 - - Sub DI, 160 - Dec AX - JNZ Music_GetNumberOfSamples1 - -Music_GetNumberOfSamples2: - - Pop DI - Pop ES - Pop SI - Pop DS - Pop CX - - Ret - -EndP Music_GetNumberOfSamples - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetNumberOfInstruments Far ; Returns AX - - Push CX - Push DS - Push SI - Push ES - Push DI - - Push CS - Pop DS - Assume DS:Music - - Mov ES, SongDataArea - Mov DI, 55912-554*2 - - Mov AX, 99 - -Music_GetNumberOfInstruments1: - Mov CX, 554 - Mov SI, Offset InstrumentHeader - RepE CmpsB - JNE Music_GetNumberOfInstruments2 - - Sub DI, 1108 - Dec AX - JNZ Music_GetNumberOfInstruments1 - -Music_GetNumberOfInstruments2: - - Pop DI - Pop ES - Pop SI - Pop DS - Pop CX - - Ret - -EndP Music_GetNumberOfInstruments - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetSampleHeader Far ; AX = sample, 1 based - - Mov SI, AX - Mov DS, CS:SongDataArea - Add SI, SI - - Mov SI, [DS:64910+SI] - - Ret - -EndP Music_GetSampleHeader - ; Returns DS:SI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetSampleLocation Far ; AX = sample (1based) - ; CH = page. - ; Returns DS:ESI - ; ECX = length - ; Carry if no sample. - ; Zero set if 8 bit - Mov CS:LastSample, AX - - Push AX - Push BX - Push DX - - Mov BX, AX - Add BX, BX - - Mov DS, CS:SongDataArea - Mov BX, [64910+BX] - Test Byte Ptr [BX+12h], 1 - JZ Music_GetSampleLocationEnd - -Music_GetSampleLocation3: - Mov AL, [BX+48h] - Test AL, AL - JZ Music_GetSampleLocationEnd - - Cmp AL, 2 - JA Music_GetSampleLocationEnd - JE Music_GetSampleLocation4 - - Mov AX, [BX+4Ah] - Xor CL, CL - ShL CX, 2 - Add AX, CX - - Jmp Music_GetSampleLocation2 - -Music_GetSampleLocation4: - Mov DX, [BX+4Ah] - Mov CL, [BX+49h] - Call E_MapEMSMemory - Call E_GetEMSPageFrame - -Music_GetSampleLocation2: - Xor ESI, ESI - Mov ECX, [BX+30h] - - Test Byte Ptr [BX+12h], 2 ; Zero flag for 8-bit. - - Mov DS, AX - -Music_GetSampleLocation5: - ClC - Jmp Music_GetSampleLocationEnd2 ; Need to preserve zero flag - -Music_GetSampleLocationEnd: - StC - -Music_GetSampleLocationEnd2: - Pop DX - Pop BX - Pop AX - - Ret - -EndP Music_GetSampleLocation - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -; Accessed via Int 3 -Proc Music_UpdateSampleLocation Far ; Reqs ESI. - - PushAD - - Mov AX, CS:LastSample - Mov ECX, ESI - ShR ECX, 8 - ShL CH, 2 - - Call Music_GetSampleLocation - - PopAD - IRet - -EndP Music_UpdateSampleLocation - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_FarUpdateSampleLocation Far - - PushF - - PushF - ClI - Call Far Ptr Music_UpdateSampleLocation - - PopF - - Ret - -EndP Music_FarUpdateSampleLocation - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetPlayMode Far - - Push DS - - Push CS - Pop DS - Assume DS:Music - - Mov AX, PlayMode - Mov BX, CurrentRow - Mov CX, CurrentPattern - Mov DX, CurrentOrder - Mov SI, NumberOfRows - - Pop DS - - Ret - Assume DS:Nothing - -EndP Music_GetPlayMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetPlayMode2 Far - - Push DS - - Push CS - Pop DS - Assume DS:Music - - Mov AX, PlayMode - Mov EBX, DWord Ptr CurrentOrder - Mov CX, CurrentRow - ShL ECX, 16 - Mov CX, CurrentTick - - Pop DS - Ret - -EndP Music_GetPlayMode2 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_PlayPattern Far ; AX = pattern, BX = number of rows - ; CX = row to start - - Push DS - - Call Music_Stop - - Push CS - Pop DS - Assume DS:Music - - Mov MIDIPitchDepthSent, 0 - Mov LastMIDIByte, 0FFh - - Mov CurrentPattern, AX - Mov CurrentRow, CX - Dec CX - Mov NumberOfRows, BX - Mov ProcessRow, CX - Mov PlayMode, 1 - - Pop DS - - Ret - -EndP Music_PlayPattern - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_PlaySong Far ; AX = Order - - PushA - Push DS - - Call Music_Stop - - Push CS - Pop DS - Assume DS:Music - - Mov MIDIPitchDepthSent, 0 - Mov LastMIDIByte, 0FFh - - Mov CurrentOrder, AX - Dec AX - Mov ProcessOrder, AX - Mov ProcessRow, 0FFFEh - Mov PlayMode, 2 - - Call StartClock - - Mov BX, MIDICOMMAND_START - Mov SI, Offset SlaveChannelInformationTable - Call MIDITranslate - - Pop DS - PopA - Ret - -EndP Music_PlaySong - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_PlayPartSong Far ; AX = order, BX = row. - - Push AX - Push BX - Push DS - - Call Music_Stop - - Mov CS:NumberOfRows, 200 - Mov CS:ProcessOrder, AX - Mov CS:CurrentOrder, AX - Mov CS:CurrentRow, BX - Dec BX - Mov CS:ProcessRow, BX - - Mov BX, AX - - Mov DS, CS:SongDataArea - MovZX AX, Byte Ptr [DS:BX+100h] - Mov CS:CurrentPattern, AX - - Mov CS:PlayMode, 2 - - Call StartClock - - Pop DS - Pop BX - Pop AX - Ret - -EndP Music_PlayPartSong - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_KBPlaySong Far - - Xor AX, AX - Cmp CS:PlayMode, 2 - JNE Music_PlaySong - - Ret - -EndP Music_KBPlaySong - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_StopChannels - - Push CX - Push DS - Push SI - Push DI - - Push CS - Pop DS - Assume DS:Music - - Mov CX, 64 - Mov SI, Offset HostChannelInformationTable - -Music_StopChannels1: - Mov Word Ptr [SI], 0 - Mov Word Ptr [SI+26h], 0 - Add SI, HOSTCHANNELSIZE - Loop Music_StopChannels1 - - Mov CX, MAXSLAVECHANNELS - Mov SI, Offset SlaveChannelInformationTable - -Music_StopChannels2: - Test Byte Ptr [SI], 1 - JZ Music_StopChannelsNoMIDI - - Cmp Byte Ptr [SI+36h], 100 - JNE Music_StopChannelsNoMIDI - - PushF - ClI - Mov DI, [SI+38h] - Mov BX, MIDICOMMAND_STOPNOTE - Call MIDITranslate - PopF - -Music_StopChannelsNoMIDI: - Mov Word Ptr [SI], 200h - Add SI, SLAVECHANNELSIZE - Loop Music_StopChannels2 - - Pop DI - Pop SI - Pop DS - Pop CX - - Ret - -EndP Music_StopChannels - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_Stop Far - - PushA - PushF - Push DS - Push ES - - CLI - - Push CS - Pop DS - Assume DS:Music - -; Turn off MIDI channels first. - - Test OrderLockFlag, 1 - JZ Music_StopNoOrderLocked - - Call Music_ToggleOrderUpdate - -Music_StopNoOrderLocked: - Mov CX, MAXSLAVECHANNELS - Mov SI, Offset SlaveChannelInformationTable - -Music_StopMIDI1: - Test Byte Ptr [SI], 1 - JZ Music_StopNoMIDI - - Cmp Byte Ptr [SI+36h], 100 - JNE Music_StopNoMIDI - - Mov DI, [SI+38h] - Mov BX, MIDICOMMAND_STOPNOTE - Call MIDITranslate - -Music_StopNoMIDI: - Add SI, SLAVECHANNELSIZE - Loop Music_StopMIDI1 - - Mov BX, MIDICOMMAND_STOP ; Stop - Mov SI, Offset SlaveChannelInformationTable - Call MIDITranslate - - Mov PlayMode, 0 - - Mov DecodeExpectedPattern, 0FFFEh - Mov DecodeExpectedRow, 0FFFEh - Mov RowDelay, 1 - Mov CurrentRow, 0 - Mov CurrentOrder, 0 - Mov CurrentTick, 1 - Mov BreakRow, 0 - - Push CX - Push DS - Push SI - Push DI - - Push CS - Pop ES - - Mov DI, Offset MIDIPrograms - Mov CX, 32 - Mov AX, 0FFFFh - Rep StosW - - Mov DI, Offset HostChannelInformationTable - Mov DS, SongDataArea - Assume DS:Nothing - - Mov SI, 40h - Mov DX, 040h - Xor AX, AX - -Music_Clear1: - Mov CX, 16 - Rep StosW - Mov AL, DH - StosW - - Xor AX, AX - Mov CX, 6 - Rep StosW - - Mov AH, [SI+40h] - LodsB - And AL, 7Fh - StosW - Xor AX, AX - Mov CX, 16 - Rep StosW - - Inc DH - Dec DL - JNZ Music_Clear1 - - ; Now clear SlaveChannel - Mov DX, MAXSLAVECHANNELS - -Music_Clear2: - Mov AX, 200h - StosW - Mov CX, SLAVECHANNELSIZE/2-1 - Xor AX, AX - Rep StosW - Dec DX - JNZ Music_Clear2 - - Push DS - Pop ES ; ES = SongDataArea - - Pop DI - Pop SI - Pop DS - Pop CX - Assume DS:Music - - Mov AX, [ES:32h] ; AL = speed, AH = tempo - Mov BX, [ES:30h] ; BL = globalvol - - Xor DX, DX - Mov DL, AL - Mov GlobalVolume, BL - Mov CurrentSpeed, DX - Mov ProcessTick, DX - Mov Tempo, AH - - Call Music_InitTempo - Call MIDI_ClearTable - - Pop ES - Pop DS - PopF - PopA - - Ret - -EndP Music_Stop - Assume DS:Nothing, ES:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_UpdatePatternOffset Far - - Mov CS:DecodeExpectedPattern, 0FFFEh - - Ret - -EndP Music_UpdatePatternOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_PlayNote Far ; DS:SI points to 5-note struct - ; AX = channel - ; DH = +32 means ignore mute - ; settings - ; DH = +128 means to use central - ; pan and max volume. - PushAD - Push DS - Push ES - - Mov AH, HOSTCHANNELSIZE - Mul AH - Mov DI, Offset HostChannelInformationTable - Add DI, AX - - Mov ES, CS:SongDataArea - - Xor DL, DL ; DL = mask - - ClI - - LodsB - Cmp AL, NONOTE - JE Music_PlayNote1 - - Or DL, 1 - Mov [CS:DI+3], AL - -Music_PlayNote1: - LodsB - Test AL, AL - JZ Music_PlayNote2 - - Or DL, 2 - Mov [CS:DI+4], AL - -Music_PlayNote2: - LodsB - Cmp AL, 0FFh - JE Music_PlayNote3 - - Or DL, 4 - Mov [CS:DI+5], AL - -Music_PlayNote3: - LodsW - Test AX, AX - JZ Music_PlayNote4 - - Or DL, 8 - -Music_PlayNote4: - Push CS - Pop DS - Assume DS:Music - - Push DX - - And DH, 7Fh - Mov [DI+6], AX - Mov [DI+8], AX - Mov [DI+2], DL - And Word Ptr [DI], Not (3+32+64+256) - Or Byte Ptr [DI], DH ; Now for command update count - - Mov AX, CurrentSpeed - Mov [DI+21h], AL - - Call PreInitCommand - - Pop DX - - Test Byte Ptr [DI], 4 - JZ Music_PlayNote5 - - Test DH, 128 - JZ Music_PlayNote5 - - Mov SI, [DI+24h] - Mov Word Ptr [SI+2Ah], 2020h; Pan and pan set. - Mov Byte Ptr [SI+23h], 40h ; Full channel volume. - -Music_PlayNote5: - Mov DecodeExpectedRow, 0FFFEh - StI - - Pop ES - Pop DS - PopAD - - Ret - -EndP Music_PlayNote - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_PlaySample Far - ; AL = Note - ; AH = sample number - ; CX = channel. - - PushAD - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Music - - Mov ES, SongDataArea - - Push AX - - Mov AX, HOSTCHANNELSIZE - Mul CX - Add AX, Offset HostChannelInformationTable - Mov DI, AX - - Pop AX - -; Mov DI, Offset HostChannelInformationTable - - ClI - - Mov Byte Ptr [DI+2], 3 ; Note & Sample - Mov [DI+3], AL ; Note... - Mov Byte Ptr [DI+4], 0FFh - Mov [DI+0Eh], AX - Or Word Ptr [DI], 8020h - - Call InitNoCommand - - Test Byte Ptr [DI], 4 - JZ Music_PlaySample1 - - Mov SI, [DI+24h] - Mov Word Ptr [SI+2Ah], 2020h - Mov Byte Ptr [SI+23h], 40h ; Full channel volume. - Mov Byte Ptr [SI+3Bh], 0 ; Note cut. - Mov Word Ptr [SI+28h], 0 - -Music_PlaySample1: - And Word Ptr [DI], Not 8000h - - Mov DecodeExpectedRow, 0FFFEh - StI - - Pop ES - Pop DS - PopAD - - Ret - -EndP Music_PlaySample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetHostChannelInformationTable Far - - Push CS - Pop DS - Assume DS:Music - - Mov SI, Offset HostChannelInformationTable - - Ret - -EndP Music_GetHostChannelInformationTable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetSlaveChannelInformationTable Far - - Push CS - Pop DS - Assume DS:Music - - Mov SI, Offset SlaveChannelInformationTable - Mov CX, MAXSLAVECHANNELS - - Ret - -EndP Music_GetSlaveChannelInformationTable - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_NextOrder Far - - Push DS - - Push CS - Pop DS - Assume DS:Music - - Cmp PlayMode, 2 - JNE Music_NextOrder1 - - Mov PlayMode, 0 - Call Music_StopChannels - Mov ProcessRow, 0FFFEh - Mov CurrentTick, 1 - Mov RowDelay, 1 - Mov PlayMode, 2 - -Music_NextOrder1: - Pop DS - Ret - -EndP Music_NextOrder - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_LastOrder Far - - Push DS - - Push CS - Pop DS - Assume DS:Music - - Cmp PlayMode, 2 - JNE Music_NextOrder1 - - Mov AX, ProcessOrder - Cmp AX, 0 - JLE Music_LastOrder1 - - ClI - - Mov PlayMode, 0 - Call Music_StopChannels - Sub AX, 2 - Mov ProcessOrder, AX - Mov ProcessRow, 0FFFEh - Mov CurrentTick, 1 - Mov RowDelay, 1 - Mov PlayMode, 2 - - StI - -Music_LastOrder1: - Pop DS - Ret - -EndP Music_LastOrder - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetGlobalVolume Far - - Push CX - Push DS - Push SI - - Push CS - Pop DS - Assume DS:Music - - Mov GlobalVolume, AL - Call RecalculateAllVolumes - - Pop SI - Pop DS - Pop CX - Ret - -EndP Music_SetGlobalVolume - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_MuteChannel Far ; AX = channel number - - Push AX - Push CX - Push DS - Push SI - Push DI - - Push CS - Pop DS - Assume DS:Music - - Mov CX, NumChannels - Mov SI, Offset SlaveChannelInformationTable - -Music_MuteChannel1: - Test Byte Ptr [SI], 1 - JZ Music_MuteChannel2 - - Mov AH, [SI+3Ah] - And AH, 07Fh - Cmp AH, AL - JNE Music_MuteChannel2 - - Or Word Ptr [SI], 840h - -Music_MuteChannel2: - Add SI, SLAVECHANNELSIZE - Loop Music_MuteChannel1 - - Pop DI - Pop SI - Pop DS - Pop CX - Pop AX - Ret - -EndP Music_MuteChannel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_UnmuteChannel Far ; AX = channel number - - Push AX - Push CX - Push DS - Push SI - Push DI - - Push CS - Pop DS - Assume DS:Music - - Mov CX, NumChannels - Mov Word Ptr [SoloSample], 0FFFFh - Mov SI, Offset SlaveChannelInformationTable - -Music_UnmuteChannel1: - Test Byte Ptr [SI], 1 - JZ Music_UnmuteChannel2 - - Mov AH, [SI+3Ah] - And AH, 07Fh - Cmp AH, AL - JNE Music_UnmuteChannel2 - -Comment ~ -Music_UnmuteChannel3: - Test DL, DL - JS Music_UnmuteChannel5 - - Cmp [SI+36h], DL - JE Music_UnmuteChannel2 - -Music_UnmuteChannel4: - Test DH, DH - JS Music_UnmuteChannel5 - - Cmp [SI+33h], DH - JE Music_UnmuteChannel2 - -Music_UnmuteChannel5: -~ - And Byte Ptr [SI+1], Not 8 - Or Byte Ptr [SI], 64 - -Music_UnmuteChannel2: - Add SI, SLAVECHANNELSIZE - Loop Music_UnmuteChannel1 - - Pop DI - Pop SI - Pop DS - Pop CX - Pop AX - Ret - -EndP Music_UnmuteChannel - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ToggleChannel Far ; AX = channel number. - - Push BX - Push DS - - Mov BX, AX - Mov DS, CS:SongDataArea - - Test Byte Ptr [BX+40h], 80h - JZ Music_ToggleChannel1 - - And Byte Ptr [BX+40h], 7Fh - Call Music_UnmuteChannel - - Mov [CS:MuteChannelTable+BX], 0 - - Pop DS - Pop BX - Ret - -Music_ToggleChannel1: ; Mute channel - Xor [CS:MuteChannelTable+BX], 1 - Or Byte Ptr [BX+40h], 80h - Call Music_MuteChannel - - Pop DS - Pop BX - Ret - -EndP Music_ToggleChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_UnmuteAll Far - - Push BX - Push CX - Push DX - Push DS - Push SI - - Jmp Music_SoloChannel3 - - -Proc Music_SoloChannel Far ; AX = channel - - Push BX - Push CX - Push DX - Push DS - Push SI - ; Check & count whether any playing. - - Mov BX, AX - - Mov DS, CS:SongDataArea - Mov SI, 40h - Mov CX, SI - Mov DX, CX - -Music_SoloChannel1: - LodsB - ShL AL, 1 - SbB DX, 0 - - Loop Music_SoloChannel1 - ; DX = num playing. - Cmp DX, 1 - JNE Music_SoloChannel6 - -Music_SoloChannel2: ; check whether it's the current - Test Byte Ptr [BX+40h], 80h - JZ Music_SoloChannel3 - -Music_SoloChannel6: - Mov CX, 64 ; 64 channel to step through - ; turn 'em all off. -Music_SoloChannel7: - Mov SI, CX - Dec SI - Cmp SI, BX - JE Music_SoloChannel9 - - Test Byte Ptr [SI+40h], 80h - JNZ Music_SoloChannel8 - -Music_SoloChannel10: - Mov AX, SI - Call Music_ToggleChannel - -Music_SoloChannel8: - Loop Music_SoloChannel7 - Jmp Music_SoloChannel11 - -Music_SoloChannel9: - Test Byte Ptr [SI+40h], 80h - JZ Music_SoloChannel8 - Jmp Music_SoloChannel10 - -Music_SoloChannel3: ; solo pressed on already soloed - ; channel -> turn everything on. - Mov CX, 64 - -Music_SoloChannel4: - Mov BX, CX - Dec BX - Cmp [CS:MuteChannelTable+BX], 1 - JNE Music_SoloChannel5 - - Mov AX, BX - Call Music_ToggleChannel - -Music_SoloChannel5: - Loop Music_SoloChannel4 - -Music_SoloChannel11: - Pop SI - Pop DS - Pop DX - Pop CX - Pop BX - - Ret - -EndP Music_SoloChannel -EndP Music_UnmuteAll - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_InitMuteTable Far - - Push AX - Push CX - Push ES - Push DI - - Mov DI, Offset MuteChannelTable - Mov CX, 32 - Push CS - Pop ES - - Xor AX, AX - Rep StosW - - Mov DWord Ptr [CS:SoloSample], 0FFFFh - - Pop DI - Pop ES - Pop CX - Pop AX - - Ret - -EndP Music_InitMuteTable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_InitStereo Far - - Push DS - - Mov DS, CS:SongDataArea - Mov AL, [DS:2Ch] - And AL, 1 - - Call [DriverSetStereo] - - Push CS - Pop DS - Call RecalculateAllVolumes - - Pop DS - Ret - -EndP Music_InitStereo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_IncreaseSpeed Far ; Returns AX = speed - - Mov AX, CS:CurrentSpeed - Cmp AX, 1 - JE Music_IncreaseSpeed1 - - Dec AX - Mov CS:CurrentSpeed, AX - Push DS - - Mov DS, SongDataArea - Mov [DS:32h], AL - - Pop DS - -Music_IncreaseSpeed1: - Ret - -EndP Music_IncreaseSpeed - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_DecreaseSpeed Far - - Mov AX, CS:CurrentSpeed - Cmp AX, 0FFh - JAE Music_DecreaseSpeed1 - - Inc AX - Mov CS:CurrentSpeed, AX - Push DS - - Mov DS, SongDataArea - Mov [DS:32h], AL - - Pop DS - - -Music_DecreaseSpeed1: - Ret - -EndP Music_DecreaseSpeed - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetSoundCard Far ; AL contains sound card num - - Xor AH, AH - - Push EBX - - Mov BX, CS - ShL EBX, 16 - - Mov BX, AX - Add BX, BX - Mov BX, [CS:DriverSoundCard+BX] - Add BX, BX - Mov BX, [CS:DriverNameTable+BX] - Mov [CS:DriverName], EBX - - Pop EBX - - Ret - -EndP Music_SetSoundCard - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetSoundCardDriver Far - - Mov Word Ptr [CS:DriverName], SI - Mov Word Ptr [CS:DriverName+2], DS - - Ret - -EndP Music_SetSoundCardDriver - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetDMA Far - - Xor AH, AH - Mov DMA, AX - - Ret - -EndP Music_SetDMA - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetMixSpeed Far - Assume DS:Nothing - - Mov CmdLineMixSpeed, CX - - Ret - -EndP Music_SetMixSpeed - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetIRQ Far - Assume DS:Nothing - - Mov IRQ, CX - - Ret - -EndP Music_SetIRQ - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetAddress Far - - Mov BasePort, DX - - Ret - -EndP Music_SetAddress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetDisplayVariables Far - - Mov AX, CS:CurrentSpeed - MovZX BX, CS:Tempo - MovZX CX, CS:GlobalVolume - - Ret - -EndP Music_GetDisplayVariables - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_AssignSampleToInstrument Far ; BX = sample num - ; returns AX - - Push CX DX DS SI ES DI - - Push CS - Pop DS - Assume DS:Music - - Mov ES, SongDataArea - -; Check for sample-number's instrument first. - Mov AX, 554 - Mul BX - Mov DI, AX - Add DI, 512 - - LEA AX, [BX+1] - Mov SI, Offset InstrumentHeader - Mov CX, 554 - - RepE CmpsB - JE Music_AssignSampleToInstrument4 - -; Search - Mov CX, 99 - Mov DI, 512 ; Points to first inst. - Mov AX, 1 - -Music_AssignSampleToInstrument1: - Push CX - - Mov SI, Offset InstrumentHeader - Mov CX, 554 - - RepE CmpsB - JE Music_AssignSampleToInstrument2 - - Add DI, CX - Pop CX - Inc AX - Loop Music_AssignSampleToInstrument1 - - StC - -Music_AssignSampleToInstrumentEnd: - Pop DI ES SI DS DX CX - Ret - -Music_AssignSampleToInstrument2: - Pop CX ; Clear the stack - -Music_AssignSampleToInstrument4: -IF NETWORKENABLED - Call Network_GetSendQueue - JZ Music_AssignSampleNetwork - - Mov SI, AX - Mov AX, 400h - StosW - Mov AX, SI - Dec AX - StosB - -Music_AssignSampleNetwork: - Call Network_FinishedSendQueue -ENDIF - - Push ES - Pop DS - - Sub DI, 554-20h ; Points to name - Mov SI, BX - Mov SI, [64912+SI+BX] - Add SI, 14h - - Mov CX, 26 - Rep MovsB - - Add DI, 7 - - ; Now to fill in table. - Mov CX, 120 - Inc BX - -Music_AssignSampleToInstrument3: - Mov [DI], BL -; Add DI, 2 - ScasW - Loop Music_AssignSampleToInstrument3 - - ClC - Jmp Music_AssignSampleToInstrumentEnd - -EndP Music_AssignSampleToInstrument - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetLimit Far - - Mov CS:CmdLineNumChannels, CX - Ret - -EndP Music_SetLimit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ReverseChannels Far - - Mov CS:ReverseChannels, 1 - Ret - -EndP Music_ReverseChannels - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_IncreaseVolume Far - - Push CX - Push DS - Push SI - - Push CS - Pop DS - Assume DS:Music - - Mov AL, GlobalVolume - And AX, 0FFh - Cmp AX, 128 - JAE Music_IncreaseVolume1 - - Inc AX - Mov GlobalVolume, AL - Call RecalculateAllVolumes - -Music_IncreaseVolume1: - Pop SI - Pop DS - Pop CX - - Ret - -EndP Music_IncreaseVolume - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_DecreaseVolume Far - - Push CX - Push DS - Push SI - - Push CS - Pop DS - Assume DS:Music - - Mov AL, GlobalVolume - And AX, 0FFh - JZ Music_DecreaseVolume1 - - Dec AX - Mov GlobalVolume, AL - Call RecalculateAllVolumes - -Music_DecreaseVolume1: - Pop SI - Pop DS - Pop CX - - Ret - -EndP Music_DecreaseVolume - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_RegetLoopInformation Far - - Push AX - Push BX - Push CX - Push DX - - Push DS - Push SI - Push ES - - Push CS - Pop DS ; DS setup - Assume DS:Music - - Mov ES, SongDataArea - - Mov CX, NumChannels - Mov SI, Offset SlaveChannelInformationTable - -Music_RegetLoopInformation1: - Test Byte Ptr [SI], 1 - JZ Music_RegetLoopInformation2 - - Push CX - ClI - - Call GetLoopInformation - - Or Byte Ptr [SI], 40h - - StI - Pop CX - -Music_RegetLoopInformation2: - Add SI, SLAVECHANNELSIZE - Loop Music_RegetLoopInformation1 - - - - Pop ES - Pop SI - Pop DS - - Pop DX - Pop CX - Pop BX - Pop AX - - Ret - -EndP Music_RegetLoopInformation - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetSoundCardMemory Far - - Jmp [DriverResetMemory] - -EndP ResetSoundCardMemory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SoundCardLoadSample Far ; AX = sample number - ; (1 based) - ; Carry set if insuf mem - PushA - Call [DriverLoadSample] - PushF - - JC Music_SoundCardLoadSample1 - - Mov CX, 2 - Mov DI, Offset O1_OutOfSoundCardMemoryList - Call M_Object1List - -Music_SoundCardLoadSample1: - PopF - PopA - Ret - -EndP Music_SoundCardLoadSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SoundCardLoadAllSamples Far - - PushAD - Push DS - - Call Music_Stop - Call S_SaveScreen - - Push 30 - Push 28 - Push 50 - Push 30 - Push 3 - Call S_DrawBox - Add SP, 10 - - Push CS - Pop DS - - Mov DI, (32+29*80)*2 - Mov SI, Offset PrepareSamplesMsg - Mov AH, 20h - Call S_DrawString - - Call S_UpdateScreen - - Call ResetSoundCardMemory - - Mov AX, 1 - -Music_SoundCardLoadAllSamples1: - Call Music_SoundCardLoadSample - JNC Music_SoundCardLoadAllSamples2 - - Inc AX - Cmp AX, 100 - JBE Music_SoundCardLoadAllSamples1 - -Music_SoundCardLoadAllSamples3: - Call S_RestoreScreen - -Music_SoundCardLoadAllSamples2: - Pop DS - PopAD - - Mov AX, 1 - Ret - -EndP Music_SoundCardLoadAllSamples - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetFreeSoundCardMemory Far - - Call [DriverGetStatus] - Ret - -EndP Music_GetFreeSoundCardMemory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetNumChannels Far - - Mov AX, CS:NumChannels - - Ret - -EndP Music_GetNumChannels - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetPitchTable Far ; Returns ES:DI to pitch table - - Push CS - Pop ES - Mov DI, Offset PitchTable - - Ret - -EndP Music_GetPitchTable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ToggleReverse Far - - Push CS - Pop DS - Assume DS:Music - - Xor ReverseChannels, 1 - Call ReCalculateAllVolumes - Mov SI, Offset ReverseMsg - Call SetInfoLine - - Ret - -EndP Music_ToggleReverse - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_PatternStorage Far - - Mov CS:PatternStorage, AL - Ret - -EndP Music_PatternStorage - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_InitMixTable Far - - Push AX - Push DS - - Xor AX, AX - Mov DS, CS:SongDataArea - Mov AL, Byte Ptr [DS:31h] ; AL = 0->128 - - Call [DriverSetMixVolume] - - Pop DS - Pop AX - Ret - -EndP Music_InitMixTable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetTempo Far - - Xor BH, BH - Mov BL, CS:Tempo - - Ret - -EndP Music_GetTempo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetLastChannel Far ; Returns AX - - Push DS - - Mov DS, CS:SongDataArea - Xor SI, SI - Mov CX, 64 - Xor AX, AX - Xor DX, DX - -Music_GetLastChannel1: - Mov BL, [SI+40h] - ShR BL, 7 - Xor BL, [CS:MuteChannelTable+SI] - JNZ Music_GetLastChannel2 - - Mov AX, DX - -Music_GetLastChannel2: - Inc DX - Inc SI - Loop Music_GetLastChannel1 - - Pop DS - Ret - -EndP Music_GetLastChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetDriverScreen Far - - Jmp [DriverSoundCardScreen] - -EndP Music_GetDriverScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetDriverVariable Far - - Jmp [DriverGetVariable] - -EndP Music_GetDriverVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetDriverVariable Far - - Jmp [DriverSetVariable] - -EndP Music_SetDriverVariable - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SetNextOrder Far - - Dec AX - Mov CS:ProcessOrder, AX - - Ret - -EndP Music_SetNextOrder - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetDelay Far - - ClI - - Xor DX, DX - Mov CX, CS:PlayMode - Test CX, CX - JZ Music_GetDelay2 - - Mov DX, CS:CurrentSpeed - Cmp AX, CS:CurrentRow - JNE Music_GetDelay3 - - Sub DX, CS:ProcessTick - JZ Music_GetDelay2 - - Cmp DX, 0Fh - JAE Music_GetDelay4 - Jmp Music_GetDelay1 - -Music_GetDelay3: - Dec DX - Cmp DX, 0Fh - JBE Music_GetDelay1 - -Music_GetDelay4: - Mov DX, 0Fh - -Music_GetDelay1: - ShL DX, 8 - Or DX, 'S'-'@'+0D000h - -Music_GetDelay2: - StI - Ret - -EndP Music_GetDelay - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -StopSong DB 0 -TimerCounter DD 0 -TotalTimer DD 0 -TotalTimerHigh DD 0 -PleaseWaitMsg DB "Please Wait...", 0 - -Proc InternalTimer Far - - PushAD - - Mov EAX, 0C214h - Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo - Div BX - Add EAX, EAX - Mov CS:TimerCounter, EAX - - PopAD - Ret - -EndP InternalTimer - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_TimeSong Far ; Time song! - - Push CS - Pop DS - Assume DS:Music - - Call S_SaveScreen - - Mov AL, 1 - Call S_SetDirectMode - Call S_DrawSmallBox - - Mov SI, Offset PleaseWaitMsg - Mov AH, 20h - Mov DI, (33+26*80)*2 - Call S_DrawString - - Call Music_Stop - - Mov CX, 0FFFFh - -Music_TimeSong1: - In AL, 21h ; Delay mechanism - In AL, 0A1h ; Delay mechanism - Loop Music_TimeSong1 - - Mov StopSong, 0 - Mov TotalTimer, 0 - Mov TotalTimerHigh, 0 - - ClI - In AL, 0A1h - Mov AH, AL - In AL, 21h - Push AX - - Mov AL, 0FFh - Out 0A1h, AL - Out 21h, AL - - Push DWord Ptr [DriverSetTempo] - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset InternalTimer - Mov [DriverSetTempo], EAX - - Push Word Ptr [NumChannels] - - Mov ES, SongDataArea - - Push Word Ptr [ES:2Ch] - And Byte Ptr [ES:2Ch], Not 4 - - Xor AX, AX - Call Music_PlaySong - -Music_TimeSong3: - Assume DS:Nothing - Call Update - - Cmp CS:StopSong, 0 - JNE Music_TimeSong4 - - Mov EAX, CS:TimerCounter - Add CS:TotalTimer, EAX - AdC CS:TotalTimerHigh, 0 - Jmp Music_TimeSong3 - -Music_TimeSong4: - Call Music_Stop - - Mov ES, CS:SongDataArea - - Pop Word Ptr [ES:2Ch] - Pop Word Ptr [CS:NumChannels] - Pop DWord Ptr [CS:DriverSetTempo] - - Pop AX - Out 21h, AL - Mov AL, AH - Out 0A1h, AL - - StI - - Mov AL, 0 - Call S_SetDirectMode - - Call S_RestoreScreen - - Mov CX, 0FFFFh - Mov DI, Offset O1_ShowTime - Call M_Object1List - - Mov AX, 1 - Ret - -EndP Music_TimeSong - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ShowTime Far - - Call S_GetDestination - - Mov EDX, CS:TotalTimerHigh - Mov EAX, CS:TotalTimer - - SHRD EAX, EDX, 16 - - Mov DI, (43+27*80)*2 - Call D_ShowTime - - Ret - -EndP Music_ShowTime - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetPatternLength Far - - Mov AX, CS:NumberOfRows - Ret - -EndP Music_GetPatternLength - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_SaveMIDIConfig Far - - Call D_GotoStartingDirectory - - Push CS - Pop DS - Assume DS:Music - - Mov AH, 3Ch - Xor CX, CX - Mov DX, Offset MIDIConfigFileName - Int 21h - JC Music_SaveMIDIConfig1 - - Mov BX, AX - - Mov AH, 40h - Mov DS, CS:MIDIDataArea - Xor DX, DX - Mov CX, (128+16+9)*32 - Int 21h - - Mov AH, 3Eh - Int 21h - -Music_SaveMIDIConfig1: - Xor AX, AX - Ret - -EndP Music_SaveMIDIConfig - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_GetMIDIDataArea Far - - Mov DS, CS:MIDIDataArea - Ret - -EndP Music_GetMIDIDataArea - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ToggleOrderUpdate Far - - Push CS - Pop DS - Assume DS:Music - - Mov SI, Offset OrderUpdateEnabledMsg - Xor OrderLockFlag, 1 - JZ Music_ToggleOrderUpdate1 - - Mov SI, Offset OrderUpdateDisabledMsg - -Music_ToggleOrderUpdate1: - Call SetInfoLine - - Ret - -EndP Music_ToggleOrderUpdate - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ToggleSoloInstrument Far - - Mov SI, Offset SoloInstrumentMsg - Mov DI, Offset SoloInstrument - Mov BP, 1 - Jmp Music_ToggleSolo - -EndP Music_ToggleSoloInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ToggleSoloSample Far - - Mov SI, Offset SoloSampleMsg - Mov DI, Offset SoloSample - Xor BP, BP - -EndP Music_ToggleSoloSample - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Music_ToggleSolo Far - - Push CS - Pop DS - Assume DS:Music - - Call PE_GetLastInstrument ; Returns BX - - Mov AX, BX - Add BX, BP - - Cmp [DI], BL - Mov Word Ptr [SoloSample], 0FFFFh - JE Music_ToggleSolo1 - - Inc AX - Mov Byte Ptr [DI], BL - - Jmp Music_ToggleSolo2 - -Music_ToggleSolo1: - Mov SI, Offset UnsoloMsg - -Music_ToggleSolo2: - Call SetInfoLine - - Mov CX, NumChannels - Mov SI, Offset SlaveChannelInformationTable - Xor BX, BX - - Mov ES, SongDataArea - -Music_ToggleSolo3: - Or Byte Ptr [SI], 18 - Mov BL, [SI+3Ah] ; BX = channel - - Test Byte Ptr [ES:BX+40h], 80h - JNZ Music_ToggleSolo4 - - And Word Ptr [SI], Not 800h - -Music_ToggleSolo4: - Add SI, SLAVECHANNELSIZE - Dec CX - JNZ Music_ToggleSolo3 - - Call RecalculateAllVolumes - - Mov AX, 1 - Ret - -EndP Music_ToggleSolo - Assume DS:Nothing - - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Music Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + .386 + .387 + +include switch.inc +include network.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Extrn D_GotoStartingDirectory:Far + Extrn D_SetDriveDirectoryFar:Far + Extrn D_GetFileName:Far + Extrn D_Showtime:Far + + Extrn E_EMSAvailable:Far + Extrn E_SaveEMSPageFrame:Far + Extrn E_RestoreEMSPageFrame:Far + Extrn E_UnInitEMS:Far + Extrn E_AllocateEMS:Far + Extrn E_MapEMSMemory:Far + Extrn E_GetEMSPageFrame:Far + Extrn E_ReleaseEMS:Far + Extrn E_AllocateBlockEMS:Far, E_ReleaseBlockEMS:Far + Extrn E_MapAlignedBlockEMS:Far + Extrn E_GetInternalEMSHandle:Far + + Extrn I_TagInstrument:Far + Extrn I_TagSample:Far + + Extrn O1_OutOfSoundCardMemoryList:Far + + Extrn M_FunctionHandler:Far + Extrn M_Object1List:Far + + Extrn Network_UpdatePatternIfIdle:Far + + Extrn PE_GetCurrentPattern:Far + Extrn PE_FillHeader:Far + Extrn S_GetDestination:Far + Extrn S_UnInitScreen:Far + Extrn S_DirectDrawString:Far + Extrn S_DrawString:Far + Extrn S_SetDirectMode:Far + Extrn S_SaveScreen:Far + Extrn S_RestoreScreen:Far + Extrn S_DrawBox:Far + Extrn S_DrawString:Far + Extrn S_UpdateScreen:Far + Extrn S_DrawSmallBox:Far + Extrn F_DrawHeader:Far + + Extrn K_GetKey:Far + Extrn StartClock:Far + Extrn SetInfoLine:Far, SetInfoLine2:Far + Extrn M_Object1List:Far + + Extrn MaxRow + + Extrn IdleUpdateInfoLine:Far + Extrn GlobalKeyList:Far + Extrn GetEnvironment:Far + + Extrn MIDIBufferEmpty:Far, MIDISend:Far, MIDI_ClearTable:Far + Extrn O1_ShowTime + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global Music_GetDisplayVariables:Far + Global Music_AutoDetectSoundCard:Far + + Global Music_Poll:Far + + Global Music_ReinitSoundCard:Far + Global Music_InitMusic:Far + Global Music_UnInitMusic:Far + Global Music_GetSongSegment:Far + Global Music_GetInstrumentMode:Far + Global Music_ReleasePattern:Far + Global Music_GetPattern:Far + Global Music_GetPatternLocation:Far + Global Music_GetPatternLocationNoCount:Far + Global Music_AllocatePattern:Far + Global Music_AllocateSample:Far + Global Music_IncreaseSpeed:Far + Global Music_DecreaseSpeed:Far + Global Music_GetOutputWaveform:Far + Global Music_PlayPartSong:Far + Global Music_GetPatternLength:Far + Global Music_ShowAutodetectSoundcard:Far + Global Music_GetWaveForm:Far + Global Music_ToggleOrderUpdate:Far + + Global Music_NextOrder:Far + Global Music_LastOrder:Far + + Global Music_SetSoundCard:Far + Global Music_SetDMA:Far + Global Music_SetMixSpeed:Far + Global Music_SetIRQ:Far + Global Music_SetAddress:Far + Global Music_SetLimit:Far + Global Music_ReverseChannels:Far + + Global Music_GetNumChannels:Far + Global Music_InitStereo:Far + Global Music_ReleaseSample:Far + Global Music_ReleaseAllSamples:Far + Global Music_ReleaseAllPatterns:Far + Global Music_ClearSampleName:Far + Global Music_ClearAllSampleNames:Far + Global Music_GetNumberOfSamples:Far + Global Music_GetNumberOfInstruments:Far + Global Music_ClearInstrument:Far + Global Music_ClearAllInstruments:Far + Global Music_GetHostChannelInformationTable:Far + Global Music_GetSlaveChannelInformationTable:Far + Global Music_SetGlobalVolume:Far + + Global Music_InitMuteTable:Far + Global Music_UnmuteAll:Far + + Global Music_GetPlayMode:Far + Global Music_GetPlayMode2:Far + Global Music_PlayPattern:Far + Global Music_PlaySample:Far + Global Music_PlayNote:Far + Global Music_Stop:Far + Global Music_PlaySong:Far + Global Music_ToggleChannel:Far + Global Music_SoloChannel:Far + Global Music_InitMixTable:Far + Global Music_GetSampleLocation:Far + Global Music_UpdatePatternOffset:Far + Global Music_AssignSampleToInstrument:Far + Global Music_KBPlaySong:Far + Global Music_IncreaseVolume:Far + Global Music_DecreaseVolume:Far + Global Music_SetSoundCardDriver:Far + Global Music_RegetLoopInformation:Far + + Global Music_SoundCardLoadSample:Far + Global Music_SoundCardLoadAllSamples:Far + Global Music_GetFreeSoundCardMemory:Far + Global Music_GetPitchTable:Far + Global Music_GetMIDIDataArea:Far + + Global Music_ToggleReverse:Far + Global Music_PatternStorage:Far + + Global Music_GetDriverScreen:Far + Global Music_GetLastChannel:Far + + Global SongDataArea:Word + Global MixDataArea:Word + + Global Music_GetDriverVariable:Far, Music_SetDriverVariable:Far + Public Music_GetDelay + Public Music_SetNextOrder + Public Music_TimeSong + Public Music_ShowTime + Public Music_SaveMIDIConfig + Public MIDIDataArea + + Public Music_ToggleSoloInstrument, Music_ToggleSoloSample + + Extrn PE_GetLastInstrument:Far + Public CurrentPattern + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +; +; Functions for playing control +; Music_PlaySong........ parameters, AX = order +; Music_Stop............ parameters, None +; Music_PlayPattern..... parameters, AX = pattern, BX = number of rows, CX = row +; Music_ToggleChannel... parameters, AX = channel +; Music_SoloChannel..... parameters, AX = channel +; + +Segment SongData PARA Public 'Data' +EndS + +Segment Music DWORD Public 'Code' USE16 + Assume CS:Music + +CREATENEWLOGFILE EQU 0 +include debug.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +HOSTCHANNELSIZE EQU 80 +SLAVECHANNELSIZE EQU 128 +MAXSLAVECHANNELS EQU 256 +NONOTE EQU 0FDh + +MIDICOMMAND_START EQU 0 +MIDICOMMAND_STOP EQU 20h +MIDICOMMAND_TICK EQU 40h +MIDICOMMAND_PLAYNOTE EQU 60h +MIDICOMMAND_STOPNOTE EQU 80h +MIDICOMMAND_CHANGEVOLUME EQU 0A0h +MIDICOMMAND_CHANGEPAN EQU 0C0h +MIDICOMMAND_BANKSELECT EQU 0E0h +MIDICOMMAND_PROGRAMSELECT EQU 100h +MIDICOMMAND_CHANGEPITCH EQU 0FFFFh + +FineSineData Label Byte + DB 0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 19, 20, 22, 23 + DB 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44 + DB 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59 + DB 59, 60, 60, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, 64, 64, 64 + DB 64, 64, 64, 64, 64, 64, 63, 63, 63, 62, 62, 62, 61, 61, 60, 60 + DB 59, 59, 58, 57, 56, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46 + DB 45, 44, 43, 42, 41, 39, 38, 37, 36, 34, 33, 32, 30, 29, 27, 26 + DB 24, 23, 22, 20, 19, 17, 16, 14, 12, 11, 9, 8, 6, 5, 3, 2 + DB 0, -2, -3, -5, -6, -8, -9,-11,-12,-14,-16,-17,-19,-20,-22,-23 + DB -24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42,-43,-44 + DB -45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-56,-57,-58,-59 + DB -59,-60,-60,-61,-61,-62,-62,-62,-63,-63,-63,-64,-64,-64,-64,-64 + DB -64,-64,-64,-64,-64,-64,-63,-63,-63,-62,-62,-62,-61,-61,-60,-60 + DB -59,-59,-58,-57,-56,-56,-55,-54,-53,-52,-51,-50,-49,-48,-47,-46 + DB -45,-44,-43,-42,-41,-39,-38,-37,-36,-34,-33,-32,-30,-29,-27,-26 + DB -24,-23,-22,-20,-19,-17,-16,-14,-12,-11, -9, -8, -6, -5, -3, -2 + +FineRampDownData Label Byte + DB 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56 + DB 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50, 49, 49, 48 + DB 48, 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 40 + DB 40, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32 + DB 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24 + DB 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16 + DB 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8 + DB 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0 + DB 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8 + DB -8, -9, -9,-10,-10,-11,-11,-12,-12,-13,-13,-14,-14,-15,-15,-16 + DB -16,-17,-17,-18,-18,-19,-19,-20,-20,-21,-21,-22,-22,-23,-23,-24 + DB -24,-25,-25,-26,-26,-27,-27,-28,-28,-29,-29,-30,-30,-31,-31,-32 + DB -32,-33,-33,-34,-34,-35,-35,-36,-36,-37,-37,-38,-38,-39,-39,-40 + DB -40,-41,-41,-42,-42,-43,-43,-44,-44,-45,-45,-46,-46,-47,-47,-48 + DB -48,-49,-49,-50,-50,-51,-51,-52,-52,-53,-53,-54,-54,-55,-55,-56 + DB -56,-57,-57,-58,-58,-59,-59,-60,-60,-61,-61,-62,-62,-63,-63,-64 + +FineSquareWave Label Byte + DB 128 Dup (64), 128 Dup (0) + +EmptyPattern Label + DW 64, 64, 0, 0 + DB 64 Dup (0) + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + ; Zero globals. + +LastSample DW 0 +PlayMode DW 0 ; Playmode 0 = Freeplay + ; Playmode 1 = Pattern + ; Playmode 2 = Song +CurrentOrder DW 0 ; } Must follow +CurrentPattern DW 0 ; } +CurrentRow DW 0 ; } +ProcessOrder DW 0 +ProcessRow DW 0 +BytesToMix DW 0 ; = Bytes per frame +PatternOffset DW 0 +PatternSegment DW 0 +BreakRow DW 0 +RowDelay DB 0 ; } Must join on. +RowDelayOn DB 0 ; } +PatternArray DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ALIGN 4 + +PitchDepthConstant DD 98304.0 +HostChannelInformationTable DB 64*HOSTCHANNELSIZE Dup(?) +SlaveChannelInformationTable DB MAXSLAVECHANNELS*SLAVECHANNELSIZE Dup(?) +MuteChannelTable DB 64 Dup (?) +ChannelCountTable DB 400 Dup (?) +;AllocateCount1 DB 0 +;AllocateCount2 DB 0 +;AllocateCount3 DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ALIGN 2 + +PatternDataSegment DW ? +CurrentEditPattern DW ? +PatternEditMaxRow DW ? + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +NumberOfRows DW 64 ; Non zero globals +CurrentTick DW 6 +CurrentSpeed DW 6 +ProcessTick DW 0 +Tempo DB 125 +GlobalVolume DB 128 +NumChannels DW 256 +SoloSample DB 0FFh ; * ORDER IS IMPORTANT +SoloInstrument DB 0FFh ; * ORDER IS IMPORTANT + +AllocateNumChannels DW 0 +AllocateSlaveOffset DW 0 +LastSlaveChannel DW 0 + +DecodeExpectedPattern DW 0FFFEh +DecodeExpectedRow DW 0FFFEh + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +CmdLineNumChannels DW 0FFFFh + +DriverRequiredVariables Label ; * ORDER IS IMPORTANT +BasePort DW 0FFFFh ; * ORDER IS IMPORTANT +IRQ DW 0FFFFh ; * ORDER IS IMPORTANT +DMA DW 0FFFFh ; * ORDER IS IMPORTANT +CmdLineMixSpeed DW 0 ; * ORDER IS IMPORTANT +SongDataArea DW SongData ; * ORDER IS IMPORTANT +MIDIDataArea DW SongData + 4076 + +CmdLineDMASize DW 1024 ; default +ReverseChannels DB 0 + +InstrumentHeader Label Byte + DB "IMPI" + DB 19 Dup (0), 60, 128, 32+128, 34 Dup (0) + DB 0, 0FFh, 0FFh, 0FFh + DB 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 + DB 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 + DB 10, 0, 11, 0, 12, 0, 13, 0, 14, 0 + DB 15, 0, 16, 0, 17, 0, 18, 0, 19, 0 + DB 20, 0, 21, 0, 22, 0, 23, 0, 24, 0 + DB 25, 0, 26, 0, 27, 0, 28, 0, 29, 0 + DB 30, 0, 31, 0, 32, 0, 33, 0, 34, 0 + DB 35, 0, 36, 0, 37, 0, 38, 0, 39, 0 + DB 40, 0, 41, 0, 42, 0, 43, 0, 44, 0 + DB 45, 0, 46, 0, 47, 0, 48, 0, 49, 0 + DB 50, 0, 51, 0, 52, 0, 53, 0, 54, 0 + DB 55, 0, 56, 0, 57, 0, 58, 0, 59, 0 + DB 60, 0, 61, 0, 62, 0, 63, 0, 64, 0 + DB 65, 0, 66, 0, 67, 0, 68, 0, 69, 0 + DB 70, 0, 71, 0, 72, 0, 73, 0, 74, 0 + DB 75, 0, 76, 0, 77, 0, 78, 0, 79, 0 + DB 80, 0, 81, 0, 82, 0, 83, 0, 84, 0 + DB 85, 0, 86, 0, 87, 0, 88, 0, 89, 0 + DB 90, 0, 91, 0, 92, 0, 93, 0, 94, 0 + DB 95, 0, 96, 0, 97, 0, 98, 0, 99, 0 + DB 100, 0, 101, 0, 102, 0, 103, 0, 104, 0 + DB 105, 0, 106, 0, 107, 0, 108, 0, 109, 0 + DB 110, 0, 111, 0, 112, 0, 113, 0, 114, 0 + DB 115, 0, 116, 0, 117, 0, 118, 0, 119, 0 + DB 0, 2, 4 Dup (0), 64, 0, 0, 64, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 0, 2, 4 Dup (0), 0, 0, 0, 0, 100, 0, 70 Dup (0) + DB 7 Dup (0) + +SampleHeader Label Byte + DB "IMPS", 13 Dup (0), 64, 0, 64, 40 Dup (0) + DW 8363 + DB 18 Dup (0) + +MidiPitchSendString DB 65h, 0, 64h, 0, 06 + +PatternLooping DB 0 +PatternStorage DB 1 ; 0 = conventional only + ; 1 = selective + ; 2 = EMS only. + +PrepareSamplesMsg DB "Preparing Samples", 0 +ReverseMsg DB "Left/right outputs reversed", 0 +NoSoundCardMsg DB " No sound card detected", 0 +MIDIConfigFileName DB "ITMIDI.CFG", 0 + +OrderUpdateEnabledMsg DB "Order list unlocked", 0 +OrderUpdateDisabledMsg DB "Order list locked", 0 +OrderLockFlag DB 0 + +UnsoloMsg DB "Solo disabled", 0 +SoloSampleMsg DB "Solo sample ", 0FDh, "D", 0 +SoloInstrumentMsg DB "Solo instrument ", 0FDh, "D", 0 + +IFDEF DEBUG + +LoadDriverMessage DB "Loading driver:", 0 +UnableToReadFileMessage DB "Unable to read file", 0 +DetectingMessage DB "Testing driver", 0 +ScreenOffset DW 0 + +ENDIF + +PCSpeakerDriver DB "ITPCSPKR.DRV", 0 +SBDriver DB "ITSB.DRV", 0 +SB2Driver DB "ITSB2.DRV", 0 +SBProDriver DB "ITSBPRO.DRV", 0 +SB16Driver DB "ITSB16.DRV", 0 +AWE32Driver DB "ITAWE32.DRV", 0 +GUSDriver DB "ITGUS.DRV", 0 +InterwaveDriver DB "ITIW.DRV", 0 +PASDriver DB "ITPAS.DRV", 0 +PAS16Driver DB "ITPAS16.DRV", 0 +WSSDriver DB "ITWSS.DRV", 0 +ESSDriver DB "ITES1868.DRV", 0 +MIDIDriver DB "ITMPU401.DRV", 0 +EWSCodecDriver DB "ITEWSCOD.DRV", 0 +VIVOCodecDriver DB "ITVIVO.DRV", 0 +ST97PCICodecDriver DB "ITSTCODE.DRV", 0 +WAVDriver DB "ITWAV.DRV", 0 +MIDDriver DB "ITMID.DRV", 0 +VSoundMMXDriver DB "ITVSOUND.MMX", 0 +VSoundDriver DB "ITVSOUND.DRV", 0 +DefaultDriver DB "ITSOUND.DRV", 0 + +DriverNameTable Label + DW 0FFFFh + DW Offset PAS16Driver, SB16Driver + DW Offset InterwaveDriver, Offset GUSDriver + DW Offset AWE32Driver, Offset SBProDriver + DW Offset SBDriver, Offset PCSpeakerDriver + DW Offset SB2Driver, Offset PASDriver + DW Offset WAVDriver, Offset WSSDriver + DW Offset ESSDriver, MIDIDriver + DW Offset EWSCodecDriver, VIVOCodecDriver + DW Offset ST97PCICodecDriver, Offset MIDDRIVER + DW Offset DefaultDriver, Offset VSoundMMXDriver + DW Offset VSoundDriver + +DriverName DD 0 + +DriverDetectionOrder DW 19, 20, 21, 17, 16, 15, 13, 1, 10, 2, 12, 3, 4, 5, 6, 9, 7, 8, 0FFFFh +DriverSoundCard DW 0, 8, 7, 9, 6 + DW 2, 5, 4, 3, 10 + DW 1, 12, 13, 15, 16 + DW 0, 0, 0, 0, 14 + DW 11, 18 + +ALIGN 4 + +PitchTable Label DWord + DW 2048, 0, 2170, 0, 2299, 0, 2435, 0, 2580, 0, 2734, 0 + DW 2896, 0, 3069, 0, 3251, 0, 3444, 0, 3649, 0, 3866, 0 + + DW 4096, 0, 4340, 0, 4598, 0, 4871, 0, 5161, 0, 5468, 0 + DW 5793, 0, 6137, 0, 6502, 0, 6889, 0, 7298, 0, 7732, 0 + + DW 8192, 0, 8679, 0, 9195, 0, 9742, 0, 10321, 0, 10935, 0 + DW 11585, 0, 12274, 0, 13004, 0, 13777, 0, 14596, 0, 15464, 0 + + DW 16384, 0, 17358, 0, 18390, 0, 19484, 0, 20643, 0, 21870, 0 + DW 23170, 0, 24548, 0, 26008, 0, 27554, 0, 29193, 0, 30929, 0 + + DW 32768, 0, 34716, 0, 36781, 0, 38968, 0, 41285, 0, 43740, 0 + DW 46341, 0, 49097, 0, 52016, 0, 55109, 0, 58386, 0, 61858, 0 + + DW 0, 1, 3897, 1, 8026, 1, 12400, 1, 17034, 1, 21944, 1 + DW 27146, 1, 32657, 1, 38496, 1, 44682, 1, 51236, 1, 58179, 1 + + DW 0, 2, 7794, 2, 16051, 2, 24800, 2, 34068, 2, 43888, 2 + DW 54292, 2, 65314, 2, 11456, 3, 23828, 3, 36936, 3, 50823, 3 + + DW 0, 4, 15588, 4, 32103, 4, 49600, 4, 2601, 5, 22240, 5 + DW 43048, 5, 65092, 5, 22912, 6, 47656, 6, 8336, 7, 36110, 7 + + DW 0, 8, 31176, 8, 64205, 8, 33663, 9, 5201, 10, 44481, 10 + DW 20559, 11, 64648, 11, 45823, 12, 29776, 13, 16671, 14, 6684, 15 + + DW 0, 16, 62352, 16, 62875, 17, 1790, 19, 10403, 20, 23425, 21 + DW 41118, 22, 63761, 23, 26111, 25, 59552, 26, 33342, 28, 13368, 30 + +; Pitch extention for loading some XIs + + DW 0, 32, 59167, 33, 60214, 35, 3580, 38, 20806, 40, 46850, 42 + DW 16701, 45, 61986, 47, 52221, 50, 53567, 53, 1148, 57, 26736, 60 + +IF USEFPUCODE + +FPSave DB 128 Dup (0) + +Const_14317456 DD 14317456.0 +Const1_On_768 DD 3AAAAAABh +SlideValue DW 0 +NewControlWord DW 7Fh + +ELSE + +FineLinearSlideUpTable Label + DW 0, 1, 59, 1, 118, 1, 178, 1, 237, 1 ; 0->4 + DW 296, 1, 356, 1, 415, 1, 475, 1, 535, 1 ; 5->9 + DW 594, 1, 654, 1, 714, 1, 773, 1, 833, 1 ; 10->14 + DW 893, 1 ; 15 + +LinearSlideUpTable Label ; Value = 2^(Val/192) + DW 0, 1, 237, 1, 475, 1, 714, 1, 953, 1 ; 0->4 + DW 1194, 1, 1435, 1, 1677, 1, 1920, 1, 2164, 1 ; 5->9 + DW 2409, 1, 2655, 1, 2902, 1, 3149, 1, 3397, 1 ; 10->14 + DW 3647, 1, 3897, 1, 4148, 1, 4400, 1, 4653, 1 ; 15->19 + DW 4907, 1, 5157, 1, 5417, 1, 5674, 1, 5932, 1 ; 20->24 + DW 6190, 1, 6449, 1, 6710, 1, 6971, 1, 7233, 1 ; 25->29 + DW 7496, 1, 7761, 1, 8026, 1, 8292, 1, 8559, 1 ; 30->34 + DW 8027, 1, 9096, 1, 9366, 1, 9636, 1, 9908, 1 ; 35->39 + DW 10181, 1, 10455, 1, 10730, 1, 11006, 1, 11283,1 ; 40->44 + DW 11560, 1, 11839, 1, 12119, 1, 12400, 1, 12682,1 ; 45->49 + DW 12965, 1, 13249, 1, 13533, 1, 13819, 1, 14106,1 ; 50->54 + DW 14394, 1, 14684, 1, 14974, 1, 15265, 1, 15557,1 ; 55->59 + DW 15850, 1, 16145, 1, 16440, 1, 16737, 1, 17034,1 ; 60->64 + DW 17333, 1, 17633, 1, 17933, 1, 18235, 1, 18538,1 ; 65->69 + DW 18842, 1, 19147, 1, 19454, 1, 19761, 1, 20070,1 ; 70->74 + DW 20379, 1, 20690, 1, 21002, 1, 21315, 1, 21629,1 ; 75->79 + DW 21944, 1, 22260, 1, 22578, 1, 22897, 1, 23216,1 ; 80->84 + DW 23537, 1, 23860, 1, 24183, 1, 24507, 1, 24833,1 ; 85->89 + DW 25160, 1, 25488, 1, 25817, 1, 26148, 1, 26479,1 ; 90->94 + DW 26812, 1, 27146, 1, 27481, 1, 27818, 1, 28155,1 ; 95->99 + DW 28494, 1, 28834, 1, 29175, 1, 29518, 1, 29862,1 ; 100->104 + DW 30207, 1, 30553, 1, 30900, 1, 31248, 1, 31599,1 ; 105->109 + DW 31951, 1, 32303, 1, 32657, 1, 33012, 1, 33369,1 ; 110->114 + DW 33726, 1, 34085, 1, 34446, 1, 34807, 1, 35170,1 ; 115->119 + DW 35534, 1, 35900, 1, 36267, 1, 36635, 1, 37004,1 ; 120->124 + DW 37375, 1, 37747, 1, 38121, 1, 38496, 1, 38872,1 ; 125->129 + DW 39250, 1, 39629, 1, 40009, 1, 40391, 1, 40774,1 ; 130->134 + DW 41158, 1, 41544, 1, 41932, 1, 42320, 1, 42710,1 ; 135->139 + DW 43102, 1, 43495, 1, 43889, 1, 44285, 1, 44682,1 ; 140->144 + DW 45081, 1, 45481, 1, 45882, 1, 46285, 1, 46690,1 ; 145->149 + DW 47095, 1, 47503, 1, 47917, 1, 48322, 1, 48734,1 ; 150->154 + DW 49147, 1, 49562, 1, 49978, 1, 50396, 1, 50815,1 ; 155->159 + DW 51236, 1, 51658, 1, 52082, 1, 52507, 1, 52934,1 ; 160->164 + DW 53363, 1, 53793, 1, 54224, 1, 54658, 1, 55092,1 ; 165->169 + DW 55529, 1, 55966, 1, 56406, 1, 56847, 1, 57289,1 ; 170->174 + DW 57734, 1, 58179, 1, 58627, 1, 59076, 1, 59527,1 ; 175->179 + DW 59979, 1, 60433, 1, 60889, 1, 61346, 1, 61805,1 ; 180->184 + DW 62265, 1, 62727, 1, 63191, 1, 63657, 1, 64124,1 ; 185->189 + DW 64593, 1, 65064, 1, 0, 2, 474, 2, 950, 2 ; 190->194 + DW 1427, 2, 1906, 2, 2387, 2, 2870, 2, 3355, 2 ; 195->199 + DW 3841, 2, 4327, 2, 4818, 2, 5310, 2, 5803, 2 ; 200->204 + DW 6298, 2, 6795, 2, 7294, 2, 7794, 2, 8296, 2 ; 205->209 + DW 8800, 2, 9306, 2, 9814, 2, 10323, 2, 10835,2 ; 210->214 + DW 11348, 2, 11863, 2, 12380, 2, 12899, 2, 13419,2 ; 215->219 + DW 13942, 2, 14467, 2, 14993, 2, 15521, 2, 16051,2 ; 220->224 + DW 16583, 2, 17117, 2, 17653, 2, 18191, 2, 18731,2 ; 225->229 + DW 19273, 2, 19817, 2, 20362, 2, 20910, 2, 21460,2 ; 230->234 + DW 22011, 2, 22565, 2, 23121, 2, 23678, 2, 24238,2 ; 235->239 + DW 24800, 2, 25363, 2, 25929, 2, 25497, 2, 27067,2 ; 240->244 + DW 27639, 2, 28213, 2, 28789, 2, 29367, 2, 29947,2 ; 245->249 + DW 30530, 2, 31114, 2, 31701, 2, 32289, 2, 32880, 2 ; 250->254 + DW 33473, 2, 34068, 2 ; 255->256 + +FineLinearSlideDownTable Label + DW 65535, 65477, 65418, 65359, 65300, 65241, 65182, 65359 ; 0->7 + DW 65065, 65006, 64947, 64888, 64830, 64772, 64713, 64645 ; 8->15 + +LinearSlideDownTable Label + DW 65535, 65300, 65065, 64830, 64596, 64364, 64132, 63901 ; 0->7 + DW 63670, 63441, 63212, 62984, 62757, 62531, 62306, 62081 ; 8->15 + DW 61858, 61635, 61413, 61191, 60971, 60751, 60532, 60314 ; 16->23 + DW 60097, 59880, 59664, 59449, 59235, 59022, 58809, 58597 ; 24->31 + DW 58386, 58176, 57966, 57757, 57549, 57341, 57135, 56929 ; 32->39 + DW 56724, 56519, 56316, 56113, 55911, 55709, 55508, 55308 ; 40->47 + DW 55109, 54910, 54713, 54515, 54319, 54123, 53928, 53734 ; 48->55 + DW 53540, 53347, 53155, 52963, 52773, 52582, 52393, 52204 ; 56->63 + DW 52016, 51829, 51642, 51456, 51270, 51085, 50901, 50718 ; 64->71 + DW 50535, 50353, 50172, 49991, 49811, 49631, 49452, 49274 ; 72->79 + DW 49097, 48920, 48743, 48568, 48393, 48128, 48044, 47871 ; 80->87 + DW 47699, 47527, 47356, 47185, 47015, 46846, 46677, 46509 ; 88->95 + DW 46341, 46174, 46008, 45842, 45677, 45512, 45348, 45185 ; 96->103 + DW 45022, 44859, 44698, 44537, 44376, 44216, 44057, 43898 ;104->111 + DW 43740, 43582, 43425, 43269, 43113, 42958, 42803, 42649 ;112->119 + DW 42495, 42342, 42189, 42037, 41886, 41735, 41584, 41434 ;120->127 + DW 41285, 41136, 40988, 40840, 40639, 40566, 40400, 40253 ;128->135 + DW 40110, 39965, 39821, 39678, 39535, 39392, 39250, 39109 ;136->143 + DW 38968, 38828, 38688, 38548, 38409, 38271, 38133, 37996 ;144->151 + DW 37859, 37722, 37586, 37451, 37316, 37181, 37047, 36914 ;152->159 + DW 36781, 36648, 36516, 36385, 36254, 36123, 35993, 35863 ;160->167 + DW 35734, 35605, 35477, 35349, 35221, 35095, 34968, 34842 ;168->175 + DW 34716, 34591, 34467, 34343, 34219, 34095, 33973, 33850 ;176->183 + DW 33728, 33607, 33486, 33365, 33245, 33125, 33005, 32887 ;184->191 + DW 32768, 32650, 32532, 32415, 32298, 32182, 32066, 31950 ;192->199 + DW 31835, 31720, 31606, 31492, 31379, 31266, 31153, 31041 ;200->207 + DW 30929, 30817, 30706, 30596, 30485, 30376, 30226, 30157 ;208->215 + DW 30048, 29940, 29832, 29725, 29618, 29511, 29405, 29299 ;216->223 + DW 29193, 29088, 28983, 28879, 28774, 28671, 28567, 28464 ;224->231 + DW 28362, 28260, 28158, 28056, 27955, 27855, 27754, 27654 ;232->239 + DW 27554, 27455, 27356, 27258, 27159, 27062, 26964, 26867 ;240->247 + DW 26770, 26674, 26577, 26482, 26386, 26291, 26196, 26102 ;248->255 + DW 26008 ; 256 + +ENDIF ; USEFPUCODE + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +InitCommandTable Label Word + DW Offset InitNoCommand, Offset InitCommandA + DW Offset InitCommandB, Offset InitCommandC + DW Offset InitCommandD, Offset InitCommandE + DW Offset InitCommandF, Offset InitCommandG + DW Offset InitCommandH, Offset InitCommandI + DW Offset InitCommandJ, Offset InitCommandK + DW Offset InitCommandL, Offset InitCommandM + DW Offset InitCommandN, Offset InitCommandO + DW Offset InitCommandP, Offset InitCommandQ + DW Offset InitCommandR, Offset InitCommandS + DW Offset InitCommandT, Offset InitCommandU + DW Offset InitCommandV, Offset InitCommandW + DW Offset InitCommandX, Offset InitCommandY + DW Offset InitCommandZ, Offset InitNoCommand + DW Offset InitNoCommand, Offset InitNoCommand + DW Offset InitNoCommand, Offset InitNoCommand + +CommandTable Label Word + DW Offset NoCommand, Offset NoCommand + DW Offset NoCommand, Offset NoCommand + DW Offset CommandD, Offset CommandE + DW Offset CommandF, Offset CommandG + DW Offset CommandH, Offset CommandI + DW Offset CommandJ, Offset CommandK + DW Offset CommandL, Offset NoCommand + DW Offset CommandN, Offset NoCommand + DW Offset CommandP, Offset CommandQ + DW Offset CommandR, Offset CommandS + DW Offset CommandT, Offset CommandH + DW Offset NoCommand, Offset CommandW + DW Offset NoCommand, Offset CommandY + DW Offset NoCommand, Offset NoCommand + DW Offset NoCommand, Offset NoCommand + +VolumeEffectTable Label Word + DW Offset NoCommand, Offset NoCommand ; Last 2 of command + ; table + VolumeComA + ; and VolumeComB + DW Offset VolumeCommandC, Offset VolumeCommandD + DW Offset VolumeCommandE, Offset VolumeCommandF + DW Offset VolumeCommandG, Offset CommandH + + +RetrigOffsets Label + DW CommandQ_0, CommandQ_1, CommandQ_2, CommandQ_3 + DW CommandQ_4, CommandQ_5, CommandQ_6, CommandQ_7 + DW CommandQ_8, CommandQ_9, CommandQ_A, CommandQ_B + DW CommandQ_C, CommandQ_D, CommandQ_E, CommandQ_F + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Sound Driver Data ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +IF OLDDRIVER + DriverID DB "Impulse Tracker Sound Driver" +ELSE + DriverID DB "Impulse Tracker Advanced Sound Driver" +ENDIF + +ALIGN 2 +SoundDriverSegment DW 0 + +;******************* + +DriverVariableTable Label +DriverMaxChannels DW 32 +StopEndOfPlaySection DW 0 +DefaultChannels DW 32 +DriverFlags DW 0 ; Bit 1 = MIDI Out supported + ; Bit 2 = Hiqual + ; Bit 3 = Output waveform data available + +IF OLDDRIVER + DB 64 - ($ - DriverVariableTable) Dup (0) +ELSE + DB 16 - ($ - DriverVariableTable) Dup (0) +ENDIF + + +ALIGN 4 + +StartDriverFunctions Label +DriverDetectCard DD 0 +DriverInitSound DD 0 +DriverReinitSound DD 0 +DriverUninitSound DD 0 + +DriverPoll DD 0 + +DriverSetTempo DD 0 +DriverSetMixVolume DD 0 +DriverSetStereo DD 0 + +DriverLoadSample DD 0 +DriverReleaseSample DD 0 +DriverResetMemory DD 0 +DriverGetStatus DD 0 + +DriverSoundCardScreen DD 0 +DriverGetVariable DD 0 +DriverSetVariable DD 0 + +DriverMIDIOut DD 0 +DriverGetWaveform DD 0 + +EndDriverFunctions Label + +IF OLDDRIVER + DD 63-(EndDriverFunctions-StartDriverFunctions)/4 Dup (0) +ELSE + DD 31-(EndDriverFunctions-StartDriverFunctions)/4 Dup (0) +ENDIF + DW 0 + +DriverLength DW 0 + +DriverRequiredFunctions Label + DD DWord Ptr Update + DD DWord Ptr Music_GetSampleHeader + DD DWord Ptr Music_GetSampleLocation + DD DWord Ptr Music_FarUpdateSampleLocation + DD DWord Ptr E_GetEMSPageFrame + DD DWord Ptr E_SaveEMSPageFrame + DD DWord Ptr E_RestoreEMSPageFrame + DD DWord Ptr Music_GetTempo + DD DWord Ptr M_FunctionHandler + DD DWord Ptr SetInfoLine2 + DD DWord Ptr Music_SoundCardLoadAllSamples + DD DWord Ptr GlobalKeyList + DD DWord Ptr IdleUpdateInfoLine + DD DWord Ptr F_DrawHeader + DD DWord Ptr PE_FillHeader + DD DWord Ptr D_GotoStartingDirectory + DD DWord Ptr D_GetFileName + DD DWord Ptr D_SetDriveDirectoryFar + DD DWord Ptr Music_Stop + DD DWord Ptr GetEnvironment + DD DWord Ptr Music_GetSlaveChannelInformationTable + DD DWord Ptr RecalculateAllVolumes + DD DWord Ptr MIDIBufferEmpty + DD DWord Ptr MIDISend + DD DWord Ptr S_GetDestination + DD DWord Ptr S_DrawString + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Command/Effect (call it what you like) information here!! ³ +;³ ³ +;³ For initialisation, DS:DI points to host channel data. ³ +;³ Registers for use: All except DS:DI & ES (points to SongDataSegment) ³ +;³ ³ +;³ For update, DS:DI points to host channel data. ³ +;³ Registers for use: AX, BX, DX, ES, SI ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc RecalculateAllVolumes Far + + Mov CX, NumChannels + Mov SI, Offset SlaveChannelInformationTable + +RecalculateAllVolumes1: + Or Byte Ptr [SI], 18 + + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ RecalculateAllVolumes1 + + Ret + +EndP RecalculateAllVolumes + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc InitPlayInstrument ; BX = instrument offset + + Push ECX + + Mov [SI+30h], BX ; InsOffset + + Mov AL, [ES:BX+11h] ; NNA + Mov [SI+3Bh], AL + + Mov AX, [ES:BX+12h] ; DCT and DCA + Mov [SI+28h], AX + + Mov AX, [DI+0Ch] ; MCh and MPr + Test AL, AL + JZ InitPlayInstrumentNoMIDI + + Mov [SI+3Ch], AX + Mov AX, [ES:BX+3Eh] ; MidiBank + Mov [SI+3Eh], AX + Mov AL, [DI+3] + Mov [SI+0Bh], AL + +InitPlayInstrumentNoMIDI: + Mov DX, [DI+2Eh] ; ChannelVol=DH, Pan=DL + + Mov AL, [ES:BX+19h] ; Instrument pan + Mov [SI+23h], DH + + Test AL, 80h + JNZ AllocatePan1 + + Mov DL, AL + +AllocatePan1: + Push BX ; Check for sample pan + + Mov BL, [DI+0Fh] + And BX, 0FFh + JZ InitPlayInstrumentNoSamplePan + + Add BX, BX + Mov BX, [ES:64910+BX] ; BX = sample offset + Mov AL, [ES:BX+2Fh] + Test AL, AL + + JNS InitPlayInstrumentNoSamplePan + + And AL, 7Fh + Mov DL, AL + +InitPlayInstrumentNoSamplePan: + Pop BX + + Cmp DL, 100 + JE AllocatePanSurround + + Xor DH, DH + Mov AL, [DI+3] ; Note + Mov CX, [ES:BX+16h] ; Pitch pan separation + Sub AL, CH + IMul CL + + SAR AX, 3 + + Add AX, DX + JS AllocatePan2 + Cmp AX, 64 + JBE AllocatePan3 + + Mov AL, 64 + Jmp AllocatePan3 + +AllocatePan2: + Xor AL, AL + Jmp AllocatePan3 + +AllocatePanSurround: + Mov AL, 100 + +AllocatePan3: + Mov AH, AL + Xor ECX, ECX ; Envelope init + Mov [SI+2Ah], AX ; Write panning + + Mov [SI+58h], ECX + Mov [SI+5Ch], CX + Mov [SI+60h], ECX + Mov [SI+68h], ECX + Mov [SI+6Ch], CX + Mov [SI+70h], ECX + Mov [SI+78h], ECX + Mov [SI+7Ch], CX + Mov DWord Ptr [SI+50h], 400000h ; 64*65536 + + Mov AH, [ES:BX+1D4h] + Mov AL, [ES:BX+182h] + And AX, 101h + ShL AH, 1 + Or AH, AL + Mov AL, [ES:BX+130h] + ShL AH, 1 + And AL, 1 + Or AH, AL + ShL AH, 4 + Or AX, 133h + + Mov Word Ptr [SI], AX + + Push DI + + Mov DI, LastSlaveChannel + Test DI, DI + JZ InitInstrumentCarry + +InitInstrumentVolumeCarry: + Mov AL, [ES:BX+130h] + And AL, 9 + Cmp AL, 9 + JNE InitInstrumentPanCarry + +; Transfer volume data + Mov ECX, [DI+50h] + Mov EDX, [DI+54h] + Mov [SI+50h], ECX + Mov [SI+54h], EDX + Mov ECX, [DI+58h] + Mov DX, [DI+5Ch] + Mov [SI+58h], ECX + Mov [SI+5Ch], DX + +InitInstrumentPanCarry: + Mov AL, [ES:BX+182h] + And AL, 9 + Cmp AL, 9 + JNE InitInstrumentPitchCarry +; Transfer pan data + Mov ECX, [DI+60h] + Mov EDX, [DI+64h] + Mov [SI+60h], ECX + Mov [SI+64h], EDX + Mov ECX, [DI+68h] + Mov DX, [DI+6Ch] + Mov [SI+68h], ECX + Mov [SI+6Ch], DX + + +InitInstrumentPitchCarry: + Mov AL, [ES:BX+1D4h] + And AL, 9 + Cmp AL, 9 + JNE InitInstrumentCarry +; Transfer pitch data + Mov ECX, [DI+70h] + Mov EDX, [DI+74h] + Mov [SI+70h], ECX + Mov [SI+74h], EDX + Mov ECX, [DI+78h] + Mov DX, [DI+7Ch] + Mov [SI+78h], ECX + Mov [SI+7Ch], DX + +InitInstrumentCarry: + Pop DI + + Or Byte Ptr [DI], 80h ; Apply random volume/pan + + Cmp Byte Ptr [DI+0Ch], 0 + JNE InitPlayInstrumentNoSample + + Push BX + Mov BX, [ES:BX+3Ah] ; Initial filter cutoff +; If IFC bit 7 == 1, then set filter cutoff + + Mov Word Ptr [SI+3Eh], 0FFh + +; Test BL, 8080h +; JNZ InitPlayInstrumentFilter +; +;; No filters, reset devices. +; Mov BL, 7Fh +; Call SetFilterCutoff +; Xor BL, BL +; Call SetFilterResonance +; +; Jmp InitPlayInstrumentFilterResonance +; +;InitPlayInstrumentFilter: + Test BL, BL + JNS InitPlayInstrumentFilterCutoff + + And BL, 7Fh +; Mov [SI+3Eh], BL + Call SetFilterCutoff + +InitPlayInstrumentFilterCutoff: +; If IFR bit 7 == 1, then set filter resonance + Test BX, BX + JNS InitPlayInstrumentFilterResonance + + Mov BL, BH + And BL, 7Fh + Mov [SI+3Fh], BL + Call SetFilterResonance + +InitPlayInstrumentFilterResonance: + Pop BX + +InitPlayInstrumentNoSample: + Pop ECX + + Ret + +EndP InitPlayInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ApplyRandomValues + + Mov SI, [DI+24h] + Mov BX, [SI+30h] + + And Byte Ptr [DI], Not 80h + + Call Random ; AL = -128->+127 + + Mov AH, [ES:BX+1Ah] ; Random volume, 0->100 + Test AH, AH + JZ RandomVolumeEnd + + IMul AH ; AX = -12800->12700 + SAR AX, 6 ; AX = -200->+198(.4) + Inc AX ; AX = -199->+199 + + MovZX DX, Byte Ptr [SI+24h] ; Sample volume set + Mov CX, 199 + Push DX + IMul DX ; AX = -199*128->199*128 + ; AX = -25472->25472 + + IDiv CX ; AX = -128->+128 + Pop CX + Add AX, CX + + Cmp AX, 0 + JL RandomVolume3 + Cmp AX, 128 + JG RandomVolume4 + + Mov [SI+24h], AL + Jmp RandomVolumeEnd + +RandomVolume3: + Mov Byte Ptr [SI+24h], 0 + Jmp RandomVolumeEnd + +RandomVolume4: + Mov Byte Ptr [SI+24h], 128 + +RandomVolumeEnd: + Call Random ; AL = -128->+127 + + Mov AH, [ES:BX+1Bh] ; Random pan, 0->64 + Test AH, AH + JZ RandomPanEnd + + Xor DX, DX + IMul AH ; AX = -64*128->64*127, -8192->8128 + Mov DL, [SI+2Ah] + SAR AX, 7 + Cmp DL, 100 + JE RandomPanEnd + Add DX, AX + JS RandomPan1 + Cmp DX, 64 + JA RandomPan2 + + Mov DH, DL + Mov [SI+2Ah], DX + Ret + +RandomPan2: + Mov Word Ptr [SI+2Ah], 4040h + Ret + +RandomPan1: + Mov Word Ptr [SI+2Ah], 0 + +RandomPanEnd: + Ret + +EndP ApplyRandomValues + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +LastMIDIByte DB 0FFh + +Proc MIDISendFilter + + Test CS:DriverFlags, 1 + JZ MIDISendFilter2 + + Test AL, AL + JNS MIDISendFilter1 + Cmp AL, 0F0h + JAE MIDISendFilter1 + + Cmp AL, CS:LastMIDIByte + JE MIDISendFilter2 + + Mov CS:LastMIDIByte, AL + +MIDISendFilter1: + Call DriverMIDIOut + +MIDISendFilter2: + Ret + +EndP MIDISendFilter + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilterCutoff ; Given BL = filtervalue. + ; Assumes that channel is non-disowned + + Push DI + + Mov DI, [SI+38h] + + Mov AL, 0F0h + Call MIDISendFilter + Mov AL, 0F0h + Call MIDISendFilter + Xor AL, AL + Call MIDISendFilter + Mov AL, BL + Call MIDISendFilter + + Pop DI + Ret + +EndP SetFilterCutoff + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SetFilterResonance ; Given BL = filtervalue. + ; Assumes that channel is non-disowned + + Push DI + + Mov DI, [SI+38h] + + Mov AL, 0F0h + Call MIDISendFilter + Mov AL, 0F0h + Call MIDISendFilter + Mov AL, 1 + Call MIDISendFilter + Mov AL, BL + Call MIDISendFilter + + Pop DI + Ret + +EndP SetFilterResonance + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +MIDIPitchDepthSent DW 0 + +Proc MIDITranslate ; Assumes DS:SI points to slave + ; And DS:DI points to host. + ; BX = offset of MIDI command to interpret + + Assume DS:Music + + Test DriverFlags, 1 + JZ MIDITranslateEnd + + PushA + + Cmp BX, 0F000h + JB MIDITranslateParameterised + +; Internal MIDI commands. + + Test Byte Ptr [ES:2Ch], 64 ; Do pitch wheel? + JZ MIDITranslateInternalEnd + +; Pitch wheel +; Formula is: Depth = 16384*12 / PitchWheelDepth * log2(Freq / OldFreq) +; Do calculation, check whether pitch needs to be sent. + + Xor EAX, EAX + Mov AL, [ES:35h] ; AL = PWD + + Test AL, AL ; No depth! + JZ MIDITranslateInternalEnd + + Mov DWord Ptr [ChannelCountTable+200], EAX ; scratch area + +IFE USEFPUCODE ; If FPU code is being used, FP registers are already saved + FNSave [ChannelCountTable] ; Scratch area + FNInit +ENDIF + FLd [PitchDepthConstant] + FIDiv DWord Ptr [ChannelCountTable+200] + FILd DWord Ptr [SI+10h] ; Current pitch + FIDiv DWord Ptr [SI+1Ch] ; Original pitch + FYL2X + FIStP DWord Ptr [ChannelCountTable+200] +IFE USEFPUCODE + FRstor [ChannelCountTable] +ENDIF + +; OK.. [ChannelCountTable] contains pitch depth. +; Have to check: +; a) Within ranges? +; b) Comparison to old pitch for this channel + + Mov CL, [SI+3Ch] + Mov AX, 1 + Dec CL + JS MIDITranslateInternalEnd + + Cmp DWord Ptr [ChannelCountTable+200], 0 + JE MIDIPitchDepthSent1 + + ShL AX, CL + Test MIDIPitchDepthSent, AX + JNZ MIDIPitchDepthSent1 + + Or MIDIPitchDepthSent, AX + +; Send MIDI Pitch depth stuff + + Push SI + + Mov AL, 0B0h + Or AL, CL + Call MIDISendFilter + + Mov DX, 5 + Mov SI, Offset MIDIPitchSendString + +Music_SendPitchDepth1: + LodsB + Call MIDISendFilter + Dec DX + JNZ Music_SendPitchDepth1 + + Pop SI + + Mov AL, [ES:35h] + Call MIDISendFilter + +MIDIPitchDepthSent1: + Mov EAX, DWord Ptr [ChannelCountTable+200] + Add EAX, 2000h + JNS PitchRange1 + + Xor EAX, EAX + +PitchRange1: + Cmp EAX, 4000h + JL PitchRange2 + + Mov AX, 3FFFh + +PitchRange2: + Mov BL, [SI+3Ch] ; BL = channel + And BX, 0FFh + Add BX, BX + Cmp [MIDIPitch+BX-2], AX + JE MIDITranslateInternalEnd + + Mov [MIDIPitch+BX-2], AX + +; Output pitch change + + Mov AL, 0E0h + Or AL, CL + + Call MIDISendFilter ; Ec command + + Mov AL, Byte Ptr [MIDIPitch+BX-2] + And AL, 7Fh + Call MIDISendFilter + + Mov AX, [MIDIPitch+BX-2] + ShR AX, 7 + And AL, 7Fh + Call MIDISendFilter + +MIDITranslateInternalEnd: + PopA + Ret + +; Now for user input MIDI stuff. + +MIDITranslateParameterised: + Push FS + + Xor AX, AX + Xor CX, CX + Mov FS, MIDIDataArea + +MIDITranslate1: + Mov AH, [FS:BX] + Inc BX + Test AH, AH + JZ MIDITranslate2 + + Cmp AH, ' ' ; Interpretation time. + JNE MIDITranslateNoSpace + + Test CX, CX + JZ MIDITranslate1 + Jmp MIDITranslateSend + +MIDITranslateNoSpace: + Sub AH, '0' + JC MIDITranslate1 + Cmp AH, 9 + JA MIDITranslateValue1 + + ShL AL, 4 + Or AL, AH + Inc CX + Jmp MIDITranslateValueEnd + +MIDITranslateValue1: + Sub AH, 'A'-'0' + JC MIDITranslate1 + Cmp AH, 'F'-'A' + JA MIDITranslateValue2 + + ShL AL, 4 + Add AH, 10 + Or AL, AH + Inc CX + Jmp MIDITranslateValueEnd + +MIDITranslateValue2: + Sub AH, 'a'-'A' + JC MIDITranslate1 + Cmp AH, 'z'-'a' + JA MIDITranslate1 + + Cmp AH, 'c'-'a' + JNE MIDITranslateValue3 + + Test SI, SI + JZ MIDITranslate1 + +; Mov AH, [DI+0Ch] + Mov AH, [SI+3Ch] + ShL AL, 4 + Dec AH + Or AL, AH + Inc CX + Jmp MIDITranslateValueEnd + +MIDITranslateValue3: + Test CX, CX + JZ MIDITranslateValue4 + + Call MIDISendFilter + + Xor CX, CX + +MIDITranslateValue4: + Mov AL, [DI+7] ; Effect. + Cmp AH, 'z'-'a' ; Zxx? + JE MIDITranslateSend + + Mov AL, [DI+12h] + Cmp AH, 'o'-'a' + JE MIDITranslateSend + + Test SI, SI + JZ MIDITranslate1 + + Mov AL, [SI+32h] ; [DI+0Eh] + Cmp AH, 'n'-'a' ; Note? + JE MIDITranslateSend + + Mov AL, [SI+0Bh] + Cmp AH, 'm'-'a' + JE MIDITranslateSend + + Cmp AH, 'v'-'a' ; Velocity? + JNE MIDITranslateValue7 + + Xor AL, AL + Test Word Ptr [SI], 800h + JNZ MIDITranslateSend + + Mov AL, [SI+22h] ; 0->2^6 + Xor DX, DX + Mul GlobalVolume ; 0->2^13 + Mov DL, [SI+23h] ; Channel volume + Mul DX ; 0->2^19 + SHRD AX, DX, 4 ; 0->2^15 + Mov DL, [SI+24h] ; Sample & Instrument Volume + Mul DX ; 0->2^22 + SHRD AX, DX, 15 ; 0->2^7 + Sub AL, 1 + AdC AL, 1 ; 1->2^7 + JNS MIDITranslateSend + Dec AX +; Mov AL, 7Fh + Jmp MIDITranslateSend + +Comment ~ + Mov AL, [SI+22h] ; 0->64 + Add AL, AL ; 0->128 + Sub AL, 1 + AdC AL, 1 ; 1->128 + Cmp AL, 128 + JB MIDITranslateSend + Dec AX + Jmp MIDITranslateSend +~ + +MIDITranslateValue7: + Cmp AH, 'u'-'a' ; Volume? + JNE MIDITranslateValue8 + + Xor AL, AL + Test Word Ptr [SI], 800h + JNZ MIDITranslateSend + + Mov AL, [SI+20h] ; 0->128 + Sub AL, 1 + AdC AL, 1 ; 1->128 + Cmp AL, 128 + JB MIDITranslateSend + Dec AX + Jmp MIDITranslateSend + +MIDITranslateValue8: + Mov AL, [SI+3Ah] ; HCN + And AL, 7Fh + Cmp AH, 'h'-'a' + JE MIDITranslateSend + + Mov AL, [SI+2Ah] ; Pan set + Cmp AH, 'x'-'a' + JE MIDITranslatePanValue + + Mov AL, [SI+25h] ; Final pan + Cmp AH, 'y'-'a' + JE MIDITranslatePanValue + + Mov AL, [SI+3Dh] + Cmp AH, 'p'-'a' ; Program? + JE MIDITranslateSend + + Mov DX, [SI+3Eh] + Mov AL, DL + Add AL, 1 + AdC AX, 0 + Dec AX + Cmp AH, 'b'-'a' + JE MIDITranslateSend + + Mov AL, DH + Add AL, 1 + AdC AX, 0 + Dec AX + Cmp AH, 'a'-'a' + JE MIDITranslateSend + + Xor AX, AX + Jmp MIDITranslate1 + +MIDITranslatePanValue: + Add AL, AL + Cmp AL, 7Fh + JBE MIDITranslateSend + Dec AX + Cmp AL, 7Fh + JBE MIDITranslateSend + Mov AL, 40h + Jmp MIDITranslateSend + +MIDITranslateValueEnd: + Cmp CL, 2 + JB MIDITranslate1 + +MIDITranslateSend: + Call MIDISendFilter + + Xor AX, AX + Xor CX, CX + Jmp MIDITranslate1 + +MIDITranslate2: + Test CX, CX + JZ MIDITranslate3 + + Call MIDISendFilter + +MIDITranslate3: + Pop FS + PopA + +MIDITranslateEnd: + Ret + +EndP MIDITranslate + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc AllocateChannel ; Returns SI. Carry set if problems + Assume DS:Music + + Push CX + Mov LastSlaveChannel, 0 + + Test Byte Ptr [ES:2Ch], 4 + JNZ AllocateChannel1 + +AllocateChannel15: ; Sample handler + MovZX SI, Byte Ptr [DI+20h] + Mov AX, SI + ShL SI, 7 ; SLAVECHANNELSIZE + Add SI, Offset SlaveChannelInformationTable + + Test Byte Ptr CS:DriverFlags, 2 + JZ AllocateChannelHiQual1 + Test Byte Ptr [SI], 1 ; Channel on? + JZ AllocateChannelHiQual1 + +; copy out channel + Push CX + Push SI + Push DI + Push ES + + Push DS + Pop ES + + Or Word Ptr [SI], 200h + Or Byte Ptr [SI+3Ah], 80h + + LEA DI, [SI+64*SLAVECHANNELSIZE] + Mov CX, SLAVECHANNELSIZE/4 + Rep MovsD + + Pop ES + Pop DI + Pop SI + Pop CX + +AllocateChannelHiQual1: + Mov [DI+24h], SI + Mov [SI+38h], DI + Mov [SI+3Ah], AL + Mov Word Ptr [SI], 133h ; Recalc freq,vol&pan Channel on. + + Mov AX, [DI+2Eh] ; ChannelVol=AH, Pan=AL + Mov [SI+23h], AH + Mov AH, AL + Mov [SI+2Ah], AX + ; Get sample offset. +AllocateChannel3: ; General stuff. + Pop CX + + Mov Word Ptr [SI+26h], 0400h ; FadeOut + Mov Word Ptr [SI+52h], 64 + Mov Word Ptr [SI+3Eh], 0FFh ; Filter cutoff + + Mov AX, [DI+3] + Mov [SI+32h], AX ; Nte&Ins + + Mov BL, [DI+0Fh] + And BX, 0FFh + JZ AllocateChannel21 + Dec BX + + Call I_TagSample + + Mov [SI+36h], BL + + Add BX, BX + Mov BX, [ES:64912+BX] + Mov [SI+34h], BX ; Sample memory offset. + + Xor EAX, EAX + Mov [SI+18h], EAX ; Reset vibrato info. + Mov Word Ptr [SI+62h], AX ; No pan deviation + Mov Word Ptr [SI+72h], AX ; No pitch deviation + Mov Byte Ptr [SI+0Bh], AL ; Reset loop dirn + + Cmp [ES:BX+30h], EAX ; No sample! + JE AllocateChannel21 + + Mov AX, [ES:BX+11h] + Test AH, 1 + JZ AllocateChannel21 ; No sample! + + And AH, 2 + Add AL, AL + Mov [SI+18h], AH + Mov [SI+24h], AL ; Sample volume + + ClC + Ret + +AllocateChannel21: + Mov Word Ptr [SI], 200h + And CH, Not 4 + StC + Ret + +AllocateChannel5: + Pop CX + StC + Ret + +AllocateChannel1: ; Instrument handler! + Mov DX, NumChannels + + Mov AllocateSlaveOffset, Offset SlaveChannelInformationTable + Mov AllocateNumChannels, DX + + Mov BX, MAXSLAVECHANNELS + Cmp Byte Ptr [DI+0Fh], 101 + JNE AllocateChannelNoMIDI + Cmp DX, BX + JE AllocateChannelNoMIDI + + Sub BX, DX ; CX = number of channels remaining + ShL DX, 7 + Mov AllocateNumChannels, BX + Add DX, Offset SlaveChannelInformationTable + Mov AllocateSlaveOffset, DX + +AllocateChannelNoMIDI: + Mov BL, [DI+4] + + Cmp BL, 0FFh + JE AllocateChannel15 + + And EBX, 0FFh + JZ AllocateChannel5 + + Call I_TagInstrument + + Mov BX, [ES:64710+EBX*2] ; ES:BX points to instrument + + Test CH, 4 ; Test Byte Ptr [DI], 4 + JZ AllocateChannel8 + ; New note action handling... + Mov SI, [DI+24h] + + Cmp [SI+30h], BX + JNE AllocateLastChannelDifferentInstrument + + Mov LastSlaveChannel, SI + +AllocateLastChannelDifferentInstrument: + Mov AL, [SI+3Bh] + + Test AL, AL + JZ AllocateChannel20 ; Notecut. + + Or Byte Ptr [SI+3Ah], 80h ; Disown channel + +AllocateHandleNNA: + Cmp Byte Ptr [SI+22h], 0 ; Is volume set = 0? + JE AllocateChannel20 + Cmp Byte Ptr [SI+23h], 0 ; Is channel volume = 0? + JE AllocateChannel20 + Cmp Byte Ptr [SI+24h], 0 ; Is sample volume = 0? + JE AllocateChannel20 + + Cmp AL, 2 + JB AllocateChannel8 ; Note continue + JE AllocateChannel14 ; Note off. + + ; AL = 3 -> Fade + Or Byte Ptr [SI], 8 ; Fade flag. + Jmp AllocateChannel8 + +AllocateChannel14: + Or Byte Ptr [SI], 4 ; Note off.. + + Push BX + Call GetLoopInformation + Pop BX + + Jmp AllocateChannel8 + +AllocateChannel20MIDI: + Or Word Ptr [SI], 200h + Or Byte Ptr [SI+3Ah], 80h ; Disown channel + + Cmp Byte Ptr [DI+0Fh], 101 + JNE AllocateChannel4 ; Sample.. + +AllocateChannelMIDIDC: + Mov SI, AllocateSlaveOffset + Mov CX, AllocateNumChannels + + Mov DL, [DI+0Eh] + Mov DH, [DI+4] + Mov BP, 32h + Mov AH, [DI+0Ch] + Mov CH, [ES:BX+13h] ; CH = DCA + Jmp AllocateChannel6 + +AllocateChannel20: + Cmp Byte Ptr [SI+36h], 100 ; MIDI? + JE AllocateChannel20MIDI + +AllocateChannel20Samples: + Test Byte Ptr CS:DriverFlags, 2 + JNZ AllocateChannelHiQual + + Mov AL, [ES:BX+12h] + Mov Word Ptr [SI], 200h + Test AL, AL + JZ AllocateChannelInstrument + Jmp AllocateChannel11 + +AllocateChannelHiQual: + Or Word Ptr [SI], 200h + Or Byte Ptr [SI+3Ah], 80h ; Disown channel + Jmp AllocateChannel4 + +AllocateChannel8: + Cmp Byte Ptr [DI+0Fh], 101 + JE AllocateChannelMIDIDC + + Mov AL, [ES:BX+12h] + Test AL, AL + JZ AllocateChannel4 ; Duplicate check off. + +AllocateChannel11: ; Duplicate check... + Mov SI, AllocateSlaveOffset + Mov CX, AllocateNumChannels + + Mov DX, [DI+3] ; DX = note + Mov BP, 32h + Cmp AL, 1 + JE AllocateDCT + + Mov BP, 33h ; Duplicate instrument + Mov DL, DH + Cmp AL, 3 + JE AllocateDCT + + Mov BP, 36h ; Duplicate sample + Mov DL, [DI+0Fh] + Dec DL + JS AllocateChannel4 + +AllocateDCT: + Mov AH, [DI+20h] ; AH = HCN + Or AH, 80h + Mov CH, [ES:BX+13h] ; CH = DCA + +AllocateChannel6: + Test Byte Ptr [SI], 1 + JZ AllocateChannel7 + + Cmp Byte Ptr [DI+0Fh], 101 + JE AllocateChannelMIDIDCT + + Mov AL, [SI+3Ah] ; AL = HCN of slave. + Cmp AH, AL + JNE AllocateChannel7 + ; OK. same channel... now.. + +AllocateChannelMIDIDCT: + Cmp DH, [SI+33h] ; Same inst? + JNE AllocateChannel7 + + Cmp DL, [DS:SI+BP] ; Same note/sample/inst? + JNE AllocateChannel7 + + Cmp Byte Ptr [DI+0Fh], 101 ; New note is a MIDI? + JE AllocateChannelMIDIHandling + + Cmp CH, [SI+29h] + JNE AllocateChannel7 + + Test CH, CH ; Checks for hiqual + JZ AllocateChannel20Samples + + Mov Word Ptr [SI+28h], 0 + Mov AL, CH + Inc AX + Jmp AllocateHandleNNA + +AllocateChannelMIDIHandling: + Cmp Byte Ptr [SI+36h], 100 ; Is current channel a MIDI chan + JNE AllocateChannel7 + + Cmp AH, [SI+3Ch] + JNE AllocateChannel7 + + Or Word Ptr [SI], 200h + Test Byte Ptr [SI+3Ah], 80h + JNZ AllocateChannel7 + + Mov BP, [SI+38h] + Or Byte Ptr [SI+3Ah], 80h + And Byte Ptr [DS:BP], Not 4 + +AllocateChannel7: + Add SI, SLAVECHANNELSIZE + Dec CL + JNZ AllocateChannel6 + +AllocateChannel4: + Mov CX, AllocateNumChannels + Mov SI, AllocateSlaveOffset + + Cmp Byte Ptr [DI+0Fh], 101 + JNE AllocateChannel10 + +; MIDI 'slave channels' have to be maintained if still referenced + + Push DI + +AllocateMIDIChannel1: + Test Byte Ptr [SI], 1 + JNZ AllocateMIDIChannel2 + + ; Have a channel.. check that it's host's slave isn't SI + Mov DI, [SI+38h] + Test DI, DI + JZ AllocateMIDIChannelFound + Cmp SI, [DI+24h] + JNE AllocateMIDIChannelFound + +AllocateMIDIChannel2: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ AllocateMIDIChannel1 + + Pop DI + + Jmp AllocateChannel17 + +AllocateChannel10: + Test Byte Ptr [SI], 1 + JZ AllocateChannelInstrument + + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ AllocateChannel10 + +AllocateChannel17: ; Common sample search + Push BX + Push DI + Push ES + + Push CS + Pop ES + + Mov DI, Offset ChannelCountTable + Xor AX, AX + Mov CX, (100+200)/2 + Rep StosW ; Clear table + Dec AX + Mov CX, 100/2 ; Volumes + Rep StosW + + Pop ES + + Mov CX, AllocateNumChannels + Xor EBX, EBX + Mov DI, AllocateSlaveOffset + +AllocateChannelCommonSample1: + Mov BL, [DI+36h] ; BX = sample pointer into + ; table. + Cmp BL, 99 ; Just for safety + JA AllocateChannelCommonSample2 + + Inc Byte Ptr [ChannelCountTable+BX] + + Mov AH, [ChannelCountTable+BX+300] ; Volume + + Test Byte Ptr [DI+3Ah], 80h ; Disowned channel? + JZ AllocateChannelCommonSample2 + + Cmp AH, [DI+20h] ; Lower Volume? + JBE AllocateChannelCommonSample2 + + Mov AH, [DI+20h] ; Get volume + Mov Word Ptr [ChannelCountTable+EBX+EBX+100], DI ; Store location + Mov [ChannelCountTable+BX+300], AH ; Store volume + +AllocateChannelCommonSample2: + Add DI, SLAVECHANNELSIZE + Dec CX + JNZ AllocateChannelCommonSample1 + + ; OK.. now search table for maximum + ; occurrence of sample... + + Xor EDI, EDI + Xor SI, SI + Mov AH, 2 ; Find maximum count, has to be + ; greater than 2 channels + Mov CX, 100 + +AllocateChannelCommonSample3: + Cmp AH, [ChannelCountTable+DI] + JAE AllocateChannelCommonSample4 + + Mov AH, [ChannelCountTable+DI] + Mov SI, Word Ptr [ChannelCountTable+EDI+EDI+100] + +AllocateChannelCommonSample4: + Inc DI + Dec CX + JNZ AllocateChannelCommonSample3 + + Pop DI + Pop BX + +; Inc AllocateCount1 + + Test SI, SI + JNZ AllocateChannelInstrument + +; Dec AllocateCount1 + + ; Find out which host channel has the most + ; (disowned) slave channels + ; Then find the softest non-single sample + ; in that channel. + Push BX + + Push ES + Push DI + + Push CS + Pop ES + Mov DI, Offset ChannelCountTable + Xor AX, AX + Mov CX, 32 + Rep StosW + + Pop DI + Pop ES + + Xor BX, BX + Mov CX, AllocateNumChannels + Mov SI, AllocateSlaveOffset + +AllocateChannelCount1: + Mov BL, [SI+3Ah] ; Host channel number + And BL, 3Fh + Inc Byte Ptr [ChannelCountTable+BX] + +AllocateChannelCount2: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ AllocateChannelCount1 + +AllocateChannelCountEnd: + ; OK.. search through and find + ; the most heavily used channel + + Mov AX, 100h ; AH = channel count + Xor BX, BX ; AL = channel + Mov CX, 64 ; 64 = physical channels + +AllocateChannelCountSearch1: + Cmp AH, [BX+ChannelCountTable] + JAE AllocateChannelCountSearch2 + + Mov AH, [BX+ChannelCountTable] + Mov AL, BL + +AllocateChannelCountSearch2: + Inc BX + Dec CX + JNZ AllocateChannelCountSearch1 + + Pop BX + + ; AH = channel to use. + Cmp AH, 1 + JBE AllocateChannelSoftestSearch + + Or AL, 80h ; Search for disowned only + + Push BX + Push DI + + Mov BH, [DI+0Fh] + Dec BH + + Mov CX, AllocateNumChannels + Mov DI, AllocateSlaveOffset + Xor SI, SI ; Offset + Mov AH, 0FFh + +AllocateChannelNonSingle1: + Cmp AL, [DI+3Ah] + JNE AllocateChannelNonSingle3 + + Cmp AH, [DI+20h] ; Lower Volume? + JBE AllocateChannelNonSingle3 + + ; Now check if any other + ; channel contains this + ; sample + Cmp BH, [DI+36h] + JE AllocateChannelNonSingle6 + + Push CX + Push SI + + Mov BL, [DI+36h] ; Sample number + Mov Byte Ptr [DI+36h], 0FFh + + Mov SI, AllocateSlaveOffset + Mov CX, AllocateNumChannels + +AllocateChannelNonSingle2: + Cmp BH, [SI+36h] + JE AllocateChannelNonSingle5 + + Cmp BL, [SI+36h] ; A second sample? + JE AllocateChannelNonSingle5 + +AllocateChannelNonSingle4: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ AllocateChannelNonSingle2 + + Mov [DI+36h], BL + + Pop SI + Pop CX + Jmp AllocateChannelNonSingle3 + +AllocateChannelNonSingle5: + Mov [DI+36h], BL + + Pop SI + Pop CX + +AllocateChannelNonSingle6: ; OK found a second sample. + Mov SI, DI ; get offset. + Mov AH, [DI+20h] ; Get volume + +AllocateChannelNonSingle3: + Add DI, SLAVECHANNELSIZE + Dec CX + JNZ AllocateChannelNonSingle1 + + Pop DI + Pop BX + + Test SI, SI + JNZ AllocateChannelSampleSearch +; JNZ AllocateChannelInstrument + + Push BX + Mov SI, AX + And SI, 03Fh + Mov Byte Ptr [ChannelCountTable+SI], 0 + Jmp AllocateChannelCountEnd ; Next cycle... + +AllocateChannelSampleSearch: +; Inc AllocateCount2 + + Push DI + + Mov AL, [SI+36h] + + Mov CX, AllocateNumChannels + Mov DI, AllocateSlaveOffset + Mov AH, 0FFh + +AllocateChannelSampleSearch1: + Cmp AL, [DI+36h] ; Same sample? + JNE AllocateChannelSampleSearch2 + + Test Byte Ptr [DI+3Ah], 80h ; Disowned channel? + JZ AllocateChannelSampleSearch2 + + Cmp AH, [DI+20h] ; Lower Volume? + JBE AllocateChannelSampleSearch2 + + Mov SI, DI ; get offset. + Mov AH, [DI+20h] ; Get volume + +AllocateChannelSampleSearch2: + Add DI, SLAVECHANNELSIZE + Dec CX + JNZ AllocateChannelSampleSearch1 + + Pop DI + + Jmp AllocateChannelInstrument + +AllocateChannelSoftestSearch: + Push DI ; Now search for softest + ; disowned sample + ; (not non-single) + + Mov CX, AllocateNumChannels + Mov DI, AllocateSlaveOffset + Xor SI, SI ; Offset + Mov AH, 0FFh + +AllocateChannel18: + Test Byte Ptr [DI+3Ah], 80h ; Disowned??? + JZ AllocateChannel19 ; No.. then look for next + + Cmp AH, [DI+20h] ; Volume set... + JB AllocateChannel19 + + Mov SI, DI ; get offset. + Mov AH, [DI+20h] ; Get volume + +AllocateChannel19: + Add DI, SLAVECHANNELSIZE + Dec CX + JNZ AllocateChannel18 + + Pop DI + +; Inc AllocateCount3 + + Test SI, SI + JNZ AllocateChannelInstrument + + Pop CX + And CH, Not 4 + + StC + Ret + +AllocateMIDIChannelFound: + Pop DI + +AllocateChannelInstrument: + Mov [DI+24h], SI ; SCOffset + + Mov AL, [DI+20h] + Mov [SI+3Ah], AL ; HCN + + Mov [SI+38h], DI ; HCOffset + + Xor EAX, EAX + Mov [SI+18h], EAX ; Reset vibrato info. + Mov Byte Ptr [SI+0Bh], AL ; Reset loop dirn + + Call InitPlayInstrument + + Mov AL, [ES:BX+18h] + Mov [SI+24h], AL + + Pop CX + + Mov Word Ptr [SI+26h], 0400h ; FadeOut, VolEnv&Pos + + Mov AX, [DI+3] + Cmp Byte Ptr [DI+0Fh], 101 + JNE NoMIDINote + + Mov AL, [DI+0Eh] + +NoMIDINote: + Mov [SI+32h], AX ; Nte&Ins + + Mov BL, [DI+0Fh] + And BX, 0FFh + JZ AllocateChannel21 + Dec BX + + Call I_TagSample + + Mov [SI+36h], BL + + Add BX, BX + Mov BX, [ES:64912+BX] + Mov [SI+34h], BX ; Sample memory offset. + + Cmp DWord Ptr [ES:BX+30h], 0 + JE AllocateChannelInstrument2 ; No sample! + + Mov AX, [ES:BX+11h] + Test AH, 1 + JZ AllocateChannelInstrument2 ; No sample! + + And AH, 2 + Mov [SI+18h], AH + + Mul Byte Ptr [SI+24h] + ShR AX, 6 + Mov [SI+24h], AL ; SI = 0->128 + + ClC + Ret + +AllocateChannelInstrument2: + Mov Word Ptr [SI], 200h + And CH, Not 4 + StC + Ret + +EndP AllocateChannel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Seed1 DW 1234h +Seed2 DW 5678h + +Proc Random + + Push BX + Push CX + Push DX + + Mov AX, Seed1 + Mov BX, Seed2 + Mov CX, BX + Mov DX, BX + + Add AX, BX + Rol AX, CL + Xor AX, DX + XChg CL, CH + Add BX, CX + Add DX, BX + Add CX, AX + Ror BX, 1 + SBB AX, DX + Mov Seed2, DX + Mov Seed1, AX + + Pop DX + Pop CX + Pop BX + + Ret + +EndP Random + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetLoopInformation + ; Destroys AX, BX, CX, DX + Mov BX, [SI+34h] ; ES:BX points to sample header + Mov AL, [ES:BX+12h] ; AL = sample flags + + Test AL, 30h ; Loop?? + JZ GetLoopInformation4 + + Mov ECX, [ES:BX+34h] ; CX = loopbeg + Mov EDX, [ES:BX+38h] ; DX = loopend + + Mov AH, AL + + Test AL, 20h ; SusLoop? + JZ GetLoopInformation2 + + Test Byte Ptr [SI], 4 + JNZ GetLoopInformation1 + + Mov ECX, [ES:BX+40h] + Mov EDX, [ES:BX+44h] + ShR AH, 1 + Jmp GetLoopInformation2 + +GetLoopInformation1: + Test AL, 10h + JZ GetLoopInformation4 + +GetLoopInformation2: + Test AH, 40h + JNZ GetLoopInformation3 + + Mov AH, 8 + Jmp GetLoopInformation5 + +GetLoopInformation3: + Mov AH, 24 + Jmp GetLoopInformation5 + +GetLoopInformation4: + Xor ECX, ECX + Mov EDX, [ES:BX+30h] + Mov AH, 0 + +GetLoopInformation5: + Cmp [SI+0Ah], AH + JNE GetLoopInformation6 + Cmp [SI+40h], ECX + JNE GetLoopInformation6 + Cmp [SI+44h], EDX + JNE GetLoopInformation6 + + Ret + +GetLoopInformation6: + Mov [SI+0Ah], AH + Mov [SI+40h], ECX + Mov [SI+44h], EDX + Or Word Ptr [SI], 400h ; Loop changed. + + Ret + +EndP GetLoopInformation + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include it_m_eff.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PitchSlideDown ; Expects SI to slave + ; BX = slide value + Assume DS:Music + +IF USEFPUCODE + Neg BX + +EndP PitchSlideDown ; EndP for PitchSlideDown + +ELSE + Test Byte Ptr [ES:2Ch], 8 + JNZ PitchSlideDownLinear + ; Go on to amiga slide down. +EndP PitchSlideDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PitchSlideDownAmiga + + Or Byte Ptr [SI], 32 ; recalculate pitch! + + Mov EAX, [SI+10h] + MovZX EBX, BX + Mul EBX ; EDX:EAX = cmd*InitialFreq + + Xor CX, CX ; CX = counter. + + Add EAX, 1712*8363 + AdC EDX, 0 + JZ PitchSlideDownAmiga1 + +PitchSlideDownAmiga2: + ShR EDX, 1 + RCR EAX, 1 + Inc CX + + Test EDX, EDX + JNZ PitchSlideDownAmiga2 + +PitchSlideDownAmiga1: + Mov EBX, EAX ; EBX = 1712*8363+Cmd*InitialFreq + + Mov EAX, 8363*1712 + Mul DWord Ptr [SI+10h] + + JCXZ PitchSlideDownAmiga4 + +PitchSlideDownAmiga5: + ShR EDX, 1 + RCR EAX, 1 + Loop PitchSlideDownAmiga5 + +PitchSlideDownAmiga4: + Cmp EBX, EDX + JBE PitchSlideDownAmiga3 + + Div EBX + + Mov [SI+10h], EAX + +PitchSlideDownAmiga3: + Ret + +EndP PitchSlideDownAmiga + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PitchSlideDownLinear +; Given BX = slide down value = 0->1024 + + Or Byte Ptr [SI], 32 ; recalculate pitch! + + Push DI + Mov DI, Offset LinearSlideDownTable + + Cmp BX, 0Fh + JA PitchSlideDownLinear1 + + Mov DI, Offset FineLinearSlideDownTable + Add BX, BX + Jmp PitchSlideDownLinear2 + +PitchSlideDownLinear1: + ShR BX, 1 + And BX, Not 1 + +PitchSlideDownLinear2: + MovZX EAX, Word Ptr [DI+BX] + Mul DWord Ptr [SI+10h] + SHRD EAX, EDX, 16 + + Mov [SI+10h], EAX + + Pop DI + Ret + +EndP PitchSlideDownLinear + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ENDIF ; USEFPUCODE + +Proc PitchSlideUp ; Expects SI to slave + ; BX = slide value + Test Byte Ptr [ES:2Ch], 8 + JZ PitchSlideUpAmiga + ; Go on to linear slide + +EndP PitchSlideUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PitchSlideUpLinear + +IF USEFPUCODE + Mov [CS:SlideValue], BX + FILD Word Ptr [CS:SlideValue] + FMul [CS:Const1_On_768] ; Have SlideValue/768.0 + FLd ST + FRndInt + FSub ST(1), ST + FXCh + F2XM1 + FLd1 + FAdd + FScale + FIMul DWord Ptr [SI+10h] + FIStP DWord Ptr [SI+10h] + FStP ST + +PitchSlideUpFPUFreqCheck: + Or Byte Ptr [SI], 32 ; recalculate pitch! + Cmp DWord Ptr [SI+10h], 07FFFFFFFh + JAE PitchSlideUpLinear1 + Ret + +PitchSlideUpLinear1: ; Turn off channel + Or Word Ptr [SI], 200h + And Byte Ptr [DI], Not 4 +ELSE + + Or Byte Ptr [SI], 32 ; recalculate pitch! + + Push DI + Cmp BX, 0Fh + Mov DI, Offset LinearSlideUpTable + JA PitchSlideUpLinear3 + + Mov DI, Offset FineLinearSlideUpTable + ShL BX, 2 + + Jmp PitchSlideUpLinear2 + +PitchSlideUpLinear3: + And BX, Not 3 + +PitchSlideUpLinear2: + Mov EAX, [SI+10h] + Mul DWord Ptr [DI+BX] + SHRD EAX, EDX, 16 + + Test EDX, 0FFFF0000h + JNZ PitchSlideUpLinear1 + + Mov [SI+10h], EAX + + Pop DI + Ret + +PitchSlideUpLinear1: ; Turn off channel + Pop DI + Or Word Ptr [SI], 200h + And Byte Ptr [DI], Not 4 +; And Byte Ptr [SI], Not 1 +; Or Byte Ptr [SI+1], 2 ; Cut! +; And Byte Ptr [DI], Not 4 + +ENDIF + + Ret + +EndP PitchSlideUpLinear + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PitchSlideUpAmiga + +IF USEFPUCODE + Mov [CS:SlideValue], BX + FILD Word Ptr [CS:SlideValue] + FILD DWord Ptr [SI+10h] ; InitFreq, Cmd + FMul ST(1), ST ; InitFreq, Cmd.InitFreq + FLd [CS:Const_14317456] ; 1712*8363, InitFreq, Cmd.InitFreq + FSubR ST(2), ST ; 1712*8363, InitFreq, 1712*8363-Cmd.InitFreq + FMul ; 1712*8363*InitFreq, 1712*8363-Cmd.InitFreq + FDivRP ST(1), ST ; FinalFreq + FIStP DWord Ptr [SI+10h] + Jmp PitchSlideUpFPUFreqCheck + +ELSE + Or Byte Ptr [SI], 32 ; recalculate pitch! + + Mov EAX, [SI+10h] + MovZX EBX, BX + Mul EBX ; EDX:EAX = InitialFreq*Cmd + + Test EDX, EDX + JNZ PitchSlideUpAmiga1 + + Mov ECX, 1712*8363 + Mov EDX, ECX + Sub ECX, EAX ; ECX = 1712*8363-Cmd*InitialFreq + JBE PitchSlideUpAmiga1 + + Mov EAX, [SI+10h] + Mul EDX + Cmp ECX, EDX + JBE PitchSlideUpAmiga1 + + Div ECX + + Mov [SI+10h], EAX + + Ret + +PitchSlideUpAmiga1: ; Turn off channel + Or Word Ptr [SI], 200h + And Byte Ptr [DI], Not 4 +; And Byte Ptr [SI], Not 1 +; Or Byte Ptr [SI+1], 2 ; Cut! +; And Byte Ptr [DI], Not 4 + + Ret +ENDIF + +EndP PitchSlideUpAmiga + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetWaveForm Far + + Test Byte Ptr CS:DriverFlags, 4 + JZ Music_GetWaveForm1 + + Call [CS:DriverGetWaveform] + + DB 85h + +Music_GetWaveForm1: + StC + Ret + +EndP Music_GetWaveForm + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_Poll Far + + Mov AX, CS:PlayMode + Mov BX, CS:CurrentPattern + Jmp [DriverPoll] + +EndP Music_Poll + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_InitTempo Far + + PushA + Call Music_GetTempo + Call [DriverSetTempo] + PopA + + Ret + +EndP Music_InitTempo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetChannels ; Returns min of NumChannels & DriverMaxChannels + ; Also uses default channels if num channels + ; = 0ffffh + Push DS + + Push CS + Pop DS + Assume DS:Music + + Mov AX, CmdLineNumChannels + Cmp AX, 0FFFFh + JNE GetChannels2 + + Mov AX, DefaultChannels + +GetChannels2: + Cmp AX, DriverMaxChannels + JBE GetChannels1 + + Mov AX, DriverMaxChannels + +GetChannels1: + Cmp AX, MAXSLAVECHANNELS + JB GetChannels3 ; MC4 + + Mov AX, MAXSLAVECHANNELS + +GetChannels3: ; MC4 + Mov NumChannels, AX + + Pop DS + Ret + +EndP GetChannels + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ReinitSoundCard Far + + Call GetChannels + Call [DriverReinitSound] + Jmp Music_SoundCardLoadAllSamples + +EndP Music_ReinitSoundCard + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_UnInitSoundCard Far + + Jmp [DriverUninitSound] + +EndP Music_UnInitSoundCard + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_InitMusic Far + + PushAD + Push DS + Push ES + + Xor AX, AX + Mov DS, AX + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset Music_UpdateSampleLocation +IF ENABLEINT3 +ELSE + Mov [DS:0Ch], EAX +ENDIF + + Trace " - Initialising SoundDriver Tables" + + Call Music_ClearDriverTables + Call D_GotoStartingDirectory + + Push CS + Pop DS + + Assume DS:Music + + Trace " - Loading MIDI configuration" + + ; Open MIDI Config file. + Mov AX, 3D00h + Mov DX, Offset MIDIConfigFileName + Int 21h + JC Music_InitMusic1 + + Mov BX, AX + + Mov DS, MIDIDataArea + Xor DX, DX + Mov AH, 3Fh + Mov CX, (128+16+9)*32 + Int 21h + + Mov AH, 3Eh ; Close + Int 21h + +Music_InitMusic1: + Trace " - Initialising playback tables" + + Call Music_Stop + + Pop ES + Pop DS + PopAD + Assume DS:Nothing + + Ret + +EndP Music_InitMusic + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ReleasePattern Far ; AX = pattern number + + Push AX + Push DS + Push SI + Push ES + + LEA SI, [63912+EAX*4] + Push SI + + Mov DS, CS:SongDataArea + + LodsW + Cmp AL, 1 + JB Music_ReleasePattern1 + JA Music_ReleasePattern2 + + LodsW + Mov ES, AX + Mov AH, 49h + Int 21h + Jmp Music_ReleasePattern1 + +Music_ReleasePattern2: + Cmp AL, 3 + JB Music_ReleasePattern3 + JA Music_ReleasePattern1 + + LodsW + Dec AX + Call E_ReleaseBlockEMS + + Jmp Music_ReleasePattern1 + +Music_ReleasePattern3: + LodsW + Call E_ReleaseEMS + +Music_ReleasePattern1: + Pop SI + Mov DWord Ptr [SI], 0 + + Pop ES + Pop SI + Pop DS + Pop AX + + Ret + +EndP Music_ReleasePattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetPattern Far ; AX = pattern number + ; Returns DS:SI points to pattern data. + + Push AX + +; ShL AX, 2 +; Mov SI, 63912 +; Add SI, AX + LEA SI, [63912+EAX*4] + + Mov DS, CS:SongDataArea + + LodsW + Cmp AL, 1 + JE Music_GetPattern1 + JA Music_GetPattern2 + + Push CS + Pop DS + Mov SI, Offset EmptyPattern + + Pop AX + Ret + +Music_GetPattern1: + LodsW + Mov DS, AX + Xor SI, SI + + Pop AX + Ret + +Music_GetPattern2: + Cmp AL, 3 + JB Music_GetPattern3 + + LodsW + Call E_MapAlignedBlockEMS + + Pop AX + Ret + +Music_GetPattern3: + Push CX + Push DX + + MovZX CX, AH + Mov DX, [SI] + Call E_MapEMSMemory + Call E_GetEMSPageFrame + Mov DS, AX + Xor SI, SI + + Pop DX + Pop CX + + Pop AX + Ret + +EndP Music_GetPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetPatternLocation Far ; AX = pattern number + ; Returns AX = handle + ; EBX = page/offset or + ; seg/offset + ; CX = length + + Call Music_GetPattern ; Returns DS:SI + Mov CX, [SI] + Add CX, 8 ; CX = size of data including header + +Proc Music_GetPatternLocationNoCount Far + + LEA SI, [63912+EAX*4] + + Mov DS, CS:SongDataArea + + LodsW + Cmp AL, 1 + JE Music_GetPatternLocation1 + JA Music_GetPatternLocation2 + + Mov BX, CS + Xor AX, AX + ShL EBX, 16 + Xor DX, DX + Mov BX, Offset EmptyPattern + + Ret + +Music_GetPatternLocation1: + LodsW + Mov BX, AX + ShL EBX, 16 + Xor AX, AX + Xor DX, DX + + Ret + +Music_GetPatternLocation2: + Cmp AL, 3 + JB Music_GetPatternLocation3 + + LodsW ; AX = "Segment" into EMS block + ; Want page = (AX >> 10) + ; offset = (AX << 4) & 0xFFFF + Mov BX, AX + ShL AX, 4 + ShL EBX, 6 + + Mov BX, AX + And EBX, 03F3FFFh + + Call E_GetInternalEMSHandle + Mov DL, 1 + + Ret + +Music_GetPatternLocation3: + LodsW + Xor EBX, EBX + Mov DL, 1 + + Ret + +EndP Music_GetPatternLocationNoCount + +EndP Music_GetPatternLocation + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_AllocatePattern Far ; DX = length. + ; SI = Pattern + ; ES:DI points to pattern area + Cmp CS:PatternStorage, 1 + JB Music_AllocatePatternConventionalOnly + JA Music_AllocatePatternEMS2 + +Music_AllocatePatternEMS: ; Try allocating EMS + Xor EAX, EAX + Mov AX, DX + Call E_AllocateBlockEMS + JC Music_AllocatePatternEMS2 + + Mov ES, CS:SongDataArea + LEA DI, [ESI*4+63914] + Inc AX + StosW + Mov Word Ptr [ES:DI-4], 3 + + Push DS + Push SI + + Call E_MapAlignedBlockEMS + + Push DS + Pop ES + Mov DI, SI + + Pop SI + Pop DS + Ret + +Music_AllocatePatternEMS2: + MovZX EAX, DX + ClC + Call E_AllocateEMS + Test AX, AX + JZ Music_AllocatePatternConventional + + Push CX + Push DX + + Mov ES, CS:SongDataArea + LEA DI, [ESI*4+63914] +; Mov DI, SI +; ShL DI, 2 +; Add DI, 63914 + StosW + + Add DX, 16383 + RCR DX, 1 + ShR DX, 13 + Mov CX, DX + Mov DX, AX + Call E_MapEMSMemory + + Mov CH, CL + Mov CL, 2 + + Mov [ES:DI-4], CX + Call E_GetEMSPageFrame + + Mov ES, AX + Xor DI, DI + + Pop DX + Pop CX + + Ret + +Music_AllocatePatternConventionalOnly: + Mov AH, 48h ; How much free? + Mov BX, 0FFFFh + Int 21h + + Cmp BX, -1 + JE Music_AllocatePatternEMS + + Cmp BX, 4096 + JAE Music_AllocatePatternConventional + + ShL BX, 4 ; BX = size in bytes of + ; conv remaining + Cmp DX, BX + JA Music_AllocatePatternEMS + +Music_AllocatePatternConventional: + Mov AH, 48h + Mov BX, DX + + Add BX, 15 + RCR BX, 1 + ShR BX, 3 + + Int 21h + JC Music_AllocatePattern2 + + Push DS + Mov DS, CS:SongDataArea + LEA SI, [ESI*4+63912] +; ShL SI, 2 +; Add SI, 63912 + Mov Word Ptr [SI], 1 + Mov [SI+2], AX + + Pop DS + Mov ES, AX + Xor DI, DI + + Ret + +Music_AllocatePattern2: + Xor AX, AX + Mov ES, AX + + Ret + +EndP Music_AllocatePattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_AllocateSample Far ; AX = Sample number, 0 based + ; EDX = length + ; Returns ES:DI, ES = 0 if not. + Push EAX + Push BX + Push CX + Push EDX + Push DS + Push SI + + Mov AH, 2 + Call Music_ReleaseSample + And AX, 0FFh + + Add EDX, 8 ; Extra 8 bytes allocated.. + + Mov BX, AX + Add BX, BX + Mov DS, CS:SongDataArea + Mov SI, [64912+BX] + + Cmp EDX, 1024 + JA Music_AllocateSample5 + + Mov EBX, EDX + Add EBX, 15 + RCR EBX, 1 + SHR EBX, 3 + + Mov AH, 48h + Int 21h + + JNC Music_AllocateSample4 + +Music_AllocateSample5: + Mov EAX, EDX + StC + Call E_AllocateEMS + Test AX, AX ; AX = handle + JZ Music_AllocateSample1 + + Mov Byte Ptr [DS:SI+48h], 2 + Mov [DS:SI+4Ah], AX + Add EDX, 16383 + RCR EDX, 1 + ShR EDX, 13 + Mov [DS:SI+49h], DL + + Xor CH, CH + Mov CL, DL + Mov DX, AX + Call E_MapEMSMemory + + Call E_GetEMSPageFrame + Mov ES, AX + Xor DI, DI + Or Byte Ptr [SI+12h], 1 + + Jmp Music_AllocateSample3 + +Music_AllocateSample1: + Cmp EDX, 1048576 + JAE Music_AllocateSample2 + + Mov EBX, EDX + Add EBX, 15 + RCR EBX, 1 + SHR EBX, 3 + + Mov AH, 48h + Int 21h + + JC Music_AllocateSample2 + +Music_AllocateSample4: + Mov Byte Ptr [SI+48h], 1 + Mov [SI+4Ah], AX + Or Byte Ptr [SI+12h], 1 + + Mov ES, AX + Xor DI, DI + Jmp Music_AllocateSample3 + +Music_AllocateSample2: + And Byte Ptr [SI+12h], 0F0h + + Xor AX, AX + Mov ES, AX + +Music_AllocateSample3: + Pop SI + Pop DS + Pop EDX + Pop CX + Pop BX + Pop EAX + Ret + +EndP Music_AllocateSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ReleaseSample Far ; AX = sample number, 0 based + ; AH = 1 = called from network + ; = 2 = called from allocate + + PushAD + Push DS + Push ES + + Mov DX, AX + And AX, 0FFh + + Mov BX, AX + Add BX, BX + Mov DS, CS:SongDataArea + Mov BX, [BX+64912] + ; DS:BX points to sample + PushAD + Mov SI, BX + Call [DriverReleaseSample] + PopAD + + Mov DI, BX + + Test Byte Ptr [BX+12h], 1 + JZ Music_ReleaseSample1 ; Used to be ReleaseSample5. + ; Changed for network code + + Mov AL, [BX+48h] + Cmp AL, 1 + JB Music_ReleaseSample5 + JE Music_ReleaseSample2 + Cmp AL, 2 + JA Music_ReleaseSample1 + + Mov AX, [BX+4Ah] + Call E_ReleaseEMS + Jmp Music_ReleaseSample1 + +Music_ReleaseSample2: + Mov ES, [BX+4Ah] + Mov AH, 49h + Int 21h + +Music_ReleaseSample1: + Mov DWord Ptr [DI+30h], 0 + Mov DWord Ptr [DI+48h], 0 + + Cmp DH, 1 + JA Music_ReleaseSample5 + JE Music_ReleaseSample6 + +IF NETWORKENABLED + Mov AH, DL + Mov AL, NETWORK_DELETESAMPLEOBJECT + Call Network_AddWordToQueue +ENDIF + +Music_ReleaseSample6: + Push DS + Pop ES + Xor AX, AX + And Byte Ptr [DI+12h], 0FEh + Add DI, 14h + Mov CX, 3Ch/2 + Rep StosW + +Music_ReleaseSample5: + Pop ES + Pop DS + PopAD + Ret + +EndP Music_ReleaseSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ClearSampleName Far ; AX = Sample number (0 based) + + Push CX + Push DS + Push SI + Push ES + Push DI + + Push CS + Pop DS + Mov SI, Offset SampleHeader + + Mov ES, CS:SongDataArea + Mov DI, AX + Add DI, DI + Mov DI, [ES:64912+DI] + + Mov CX, 80 + Rep MovsB + + Pop DI + Pop ES + Pop SI + Pop DS + Pop CX + Ret + +EndP Music_ClearSampleName + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ClearAllSampleNames Far + + Push AX + Push CX + + Mov CX, 100 + +Music_ClearAllSampleNames1: + Mov AX, CX + Dec AX + Call Music_ClearSampleName + + Loop Music_ClearAllSampleNames1 + + Pop CX + Pop AX + + Ret + +EndP Music_ClearAllSampleNames + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ReleaseAllSamples Far + + Push AX + Push CX + + Mov CX, 100 + +Music_ReleaseAllSamples1: + Mov AX, CX + Dec AX + Call Music_ReleaseSample + + Loop Music_ReleaseAllSamples1 + + Pop CX + Pop AX + Ret + +EndP Music_ReleaseAllSamples + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ReleaseAllPatterns Far + + Push AX + Push CX + + Mov CX, 200 + +Music_ReleaseAllPatterns1: + Mov AX, CX + Dec AX + Call Music_ReleasePattern + Loop Music_ReleaseAllPatterns1 + + Pop CX + Pop AX + Ret + +EndP Music_ReleaseAllPatterns + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ClearInstrument Far ; AX = Instrument number + ; (0 based) + + Push CX + Push DS + Push SI + Push ES + Push DI + + Push CS + Pop DS + Assume DS:Music + + Mov DI, AX + Add DI, DI + Mov ES, SongDataArea + Mov DI, [ES:DI+64712] ; ES:DI points to inst. + Mov SI, Offset InstrumentHeader + Mov CX, 554 + Rep MovsB + + Pop DI + Pop ES + Pop SI + Pop DS + Pop CX + Ret + +EndP Music_ClearInstrument + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ClearAllInstruments Far + + Mov AX, 99 + +Music_ClearAllInstruments1: + Call Music_ClearInstrument + Dec AX + JNS Music_ClearAllInstruments1 + + Ret + +EndP Music_ClearAllInstruments + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_UnInitMusic Far + + Call Music_UnInitSoundCard + Call Music_UnloadDriver + + Cmp CS:SongDataArea, 0 + JE Music_UnInitMusic1 + + Call Music_ReleaseAllPatterns + Call Music_ReleaseAllSamples + +Music_UnInitMusic1: + Mov ES, CS:SongDataArea + Mov AH, 49h + Int 21h + + Ret + +EndP Music_UnInitMusic + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetSongSegment Far + + Mov AX, CS:SongDataArea + Ret + +EndP Music_GetSongSegment + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_UnloadDriver + + Xor AX, AX + XChg AX, CS:SoundDriverSegment + Test AX, AX + JZ Music_UnloadDriver1 + + Mov ES, AX + Mov AH, 49h + Int 21h + +Music_UnloadDriver1: + Ret + +EndP Music_UnloadDriver + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc NoFunction2 + + Push CS + Pop DS + Mov SI, Offset NoSoundCardMsg + +Proc NoFunction Far + + Xor AX, AX + StC + Ret + +EndP NoFunction + +EndP NoFunction2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ClearDriverTables + ; Makes all of them point to + ; Xor AX, AX, StC, RetF + Mov AX, CS + Mov ES, AX + + ShL EAX, 16 + Mov AX, Offset NoFunction2 + Mov DI, Offset StartDriverFunctions + StosD + StosD + + Mov AX, Offset NoFunction +IF OLDDRIVER + Mov CX, 61 +ELSE + Mov CX, 29 +ENDIF + Rep StosD + + Xor EAX, EAX + StosD + + Mov DriverMaxChannels, 32 + + Ret + +EndP Music_ClearDriverTables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_LoadDriver ; Given DS:DX = filename + Assume DS:Nothing + +IFDEF DEBUG + + PushA + Push ES + Push DS + + Mov DI, 0B800h + Mov ES, DI + + Push CS + Pop DS + Assume DS:Music + + Mov DI, [ScreenOffset] + Mov SI, Offset LoadDriverMessage + Mov AH, 2 + +LoadDriverMessage1: + LodsB + StosW + Test AL, AL + JNZ LoadDriverMessage1 + + Pop DS + Assume DS:Nothing + + Mov SI, DX + +LoadDriverMessage2: + LodsB + StosW + Test AL, AL + JNZ LoadDriverMessage2 + + Add [CS:ScreenOffset], 160 + + Pop ES + PopA + +ENDIF + + Mov AX, 3D00h + Int 21h + ClD + JNC Music_LoadDriver2 + +IFDEF DEBUG + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Music + + Mov DI, 0B800h + Mov ES, DI + + Mov SI, Offset UnableToReadFileMessage + Mov DI, [ScreenOffset] + Mov AH, 2 + +UnableToReadFileLoop: + LodsB + StosW + Test AL, AL + JNZ UnableToReadFileLoop + + Add [ScreenOffset], 160 + + Pop ES + Pop DS + PopA + Assume DS:Nothing + +ENDIF + + Jmp Music_LoadDriverNoClose + +Music_LoadDriverError: + Mov AH, 3Eh + Int 21h + +Music_LoadDriverNoClose: + ClD + + Call Music_ClearDriverTables + + Push CS + Pop DS + + StC + Ret + +Music_LoadDriver2: + Mov BX, AX ; BX = file handle + Mov AH, 3Fh ; Read file + +IF OLDDRIVER + Mov CX, 256 +ELSE + Mov CX, 128 +ENDIF + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Music + + Mov DX, Offset StartDriverFunctions + Mov SI, DX + Int 21h + JC Music_LoadDriverError + Cmp AX, CX + JNE Music_LoadDriverError + +IF OLDDRIVER + Mov CX, 28 +ELSE + Mov CX, 37 ; Length of ID +ENDIF + + Mov DI, Offset DriverID + RepE CmpsB + JNE Music_LoadDriverError + + ; OK.. ID OK. Now get length, allocate memory + ; load driver, and fill in headers. + Push BX + + Mov BX, DriverLength + Add BX, 15 + Mov AH, 48h + ShR BX, 4 + Int 21h + Pop BX + JC Music_LoadDriverError ; Insufficient memory + + Mov CX, DriverLength + Mov SoundDriverSegment, AX + Mov DS, AX + Assume DS:Nothing + + Mov DI, AX ; DI = segment of driver... + + Mov AH, 3Fh ; Load driver into memory! + Xor DX, DX + Int 21h + + Push CS + Pop DS + Assume DS:Music + + Mov AH, 3Fh + Mov DX, Offset DriverVariableTable + +IF OLDDRIVER + Mov CX, 64 +ELSE + Mov CX, 16 +ENDIF + Int 21h + + Mov AH, 3Fh + +IF OLDDRIVER + Mov CX, 128 + Mov DX, Offset StartDriverFunctions+128 +ELSE + Mov CX, 64 + Mov DX, Offset StartDriverFunctions+64 +ENDIF + Mov SI, DX + Int 21h + JC Music_LoadDriverError + Cmp AX, CX + JNE Music_LoadDriverError + + Mov AH, 3Eh + Int 21h + + ; Setup reqd function table + SHRD EAX, EDI, 16 ; High word of EAX contains + ; segment... + Mov DI, Offset StartDriverFunctions + +IF OLDDRIVER + Mov CX, 64 +ELSE + Mov CX, 32 +ENDIF + +DriverFunctionLoop1: + LodsW + StosD + Loop DriverFunctionLoop1 + + ; Setup variable table + Mov ES, SoundDriverSegment + Xor DI, DI + +IF OLDDRIVER + Mov CX, 256 +ELSE + Mov CX, 16 +ENDIF + Mov SI, Offset DriverRequiredVariables + Rep MovsB + + Mov SI, Offset DriverRequiredFunctions + +IF OLDDRIVER + Mov CX, 128 +ELSE + Mov CX, 32 +ENDIF + Rep MovsD + +IFDEF DEBUG + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Music + + Mov DI, 0B800h + Mov ES, DI + + Mov SI, Offset DetectingMessage + Mov DI, [ScreenOffset] + Mov AH, 2 + +DetectingMessageLoop: + LodsB + StosW + Test AL, AL + JNZ DetectingMessageLoop + + Add [ScreenOffset], 160 + + Pop ES + Pop DS + PopA + Assume DS:Nothing + +ENDIF + ClC + + Ret + +EndP Music_LoadDriver + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ADSCParams DW 7 Dup (0) + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_AutoDetectSoundCard Far + ; Returns DS:SI = string + ; AX, BX, CX, DX, DI = parameters + + Call D_GotoStartingDirectory + + Xor SI, SI + + Mov DX, Word Ptr [CS:DriverName] + And DX, DX + JZ Music_AutoDetectSoundCard1 + + Trace " - Loading specific soundcard driver" + + Cmp DX, 0FFFFh + JE Music_AutoDetectSoundCard4 + + Mov DS, Word Ptr [CS:DriverName+2] + Call Music_LoadDriver + JC Music_AutoDetectSoundCard4 + + Mov AL, 1 ; Forced + Mov BX, TRACKERVERSION + Mov ECX, [CS:DriverName] + Call [DriverDetectCard] + JC Music_AutodetectSoundCard5 + Cmp EAX, 'Jeff' + JE Music_AutoDetectSoundCard4 + +Music_AutodetectSoundCard5: + Call Music_UnloadDriver + Call Music_ClearDriverTables + Jmp Music_AutoDetectSoundCard4 + +Music_AutoDetectSoundCard1: + Trace " - Testing soundcard driver" + + Push SI + Push CS + Pop DS + Assume DS:Music + + Mov Word Ptr [DriverName+2], DS + + Mov BX, [SI+DriverDetectionOrder] + Cmp BX, 0FFFFh + JE Music_AutoDetectSoundCard2 + + Add BX, BX + Mov DX, [DriverNameTable+BX] + Mov Word Ptr [DriverName], DX + Call Music_LoadDriver + JC Music_AutoDetectSoundCard3 + + Xor AX, AX ; Not forced + Mov BX, TRACKERVERSION + Mov ECX, [CS:DriverName] + Call [DriverDetectCard] + JC Music_AutoDetectSoundCard6 + + Cmp EAX, 'Jeff' + JE Music_AutoDetectSoundCard2 + +Music_AutoDetectSoundCard6: + Call Music_UnloadDriver + Call Music_ClearDriverTables + +Music_AutoDetectSoundCard3: + + Pop SI + Add SI, 2 + Jmp Music_AutoDetectSoundCard1 + +Music_AutoDetectSoundCard2: + Pop AX + +Music_AutoDetectSoundCard4: + Call GetChannels + Call [CS:DriverInitSound] + + Mov [CS:ADSCParams+2], DS + + Push CS + Pop DS + Assume DS:Music + + Mov [ADSCParams], SI + Mov [ADSCParams+12], DI + Mov [ADSCParams+10], DX + Mov [ADSCParams+8], CX + Mov [ADSCParams+6], BX + Mov [ADSCParams+4], AX + + Call Music_InitStereo + + Call Music_InitMixTable + + Ret + +EndP Music_AutoDetectSoundCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ShowAutoDetectSoundCard Far + + Push CS + Pop DS + Assume DS:Music + + Push DWord Ptr [ADSCParams+10] + Push DWord Ptr [ADSCParams+6] + Push [ADSCParams+4] + + LDS SI, DWord Ptr [ADSCParams] + + Mov AH, 20h + Mov DI, (26+28*80)*2 + Call S_DrawString + + Add SP, 10 + Ret + +EndP Music_ShowAutoDetectSoundCard + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetInstrumentMode Far + + Push DS + Mov DS, CS:SongDataArea + Mov AH, [DS:2Ch] + And AH, 4 + + Pop DS + + Ret + +EndP Music_GetInstrumentMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateGOTONote ; Get offset & arrayed flag. + + Push DS + Assume DS:Nothing + + Call PE_GetCurrentPattern + ; AX = Pattern number + ; BX = MaxRow + ; DS = PatternDataSegment + Cmp AX, CS:CurrentPattern + JNE UpdateGOTONote1 + + Mov DecodeExpectedPattern, AX + Mov CS:PatternSegment, DS + + Pop DS + Assume DS:Music + Mov NumberOfRows, BX + Mov AX, ProcessRow + Cmp AX, BX + JB UpdateGOTONote2 + + Xor AX, AX + Mov ProcessRow, AX + Mov CurrentRow, AX + +UpdateGOTONote2: + Mov DecodeExpectedRow, AX + + LEA AX, [EAX*4+EAX] ; PatternRowSize = *320 + ShL AX, 6 +; Mov BX, 320 +; Mul BX + Mov PatternOffset, AX + Mov PatternArray, 1 + + Ret + +UpdateGOTONote1: + Pop DS + Assume DS:Music + + Mov AX, CurrentPattern + Mov DecodeExpectedPattern, AX +IF NETWORKENABLED + Call Network_UpdatePatternIfIdle +ENDIF + Call Music_GetPattern + Assume DS:Nothing + ; DS:SI points to pattern. + + LodsW + LodsW ; AX = number of rows + + Mov CX, ProcessRow + Cmp AX, CX + JA UpdateGotoNote3 + + Xor CX, CX + +UpdateGOTONote3: + Mov CurrentRow, CX + Mov ProcessRow, CX + Mov DecodeExpectedRow, CX + Mov NumberOfRows, AX + Add SI, 4 + Inc CX + +UpdateGOTONote10: + Dec CX + JZ UpdateGOTONote5 + +UpdateGOTONote4: ; OK.. now to find the right + ; offset & update tables. + LodsB + Test AL, AL + JZ UpdateGOTONote10 + + Mov DL, AL + + And AX, 7Fh + Dec AX + LEA BX, [EAX*4+EAX] ; BX = AX*5 + ShL BX, 4 ; BX = AX*80 + LEA DI, [HostChannelInformationTable+BX] + + +; And AL, 7Fh +; Dec AL +; Mov AH, HOSTCHANNELSIZE +; Mul AH +; Mov DI, AX +; Add DI, Offset HostChannelInformationTable + ; CS:DI points. + + Mov DH, [CS:DI+2] + Test DL, 80h + JZ UpdateGOTONote6 + + Mov DH, [SI] + Inc SI + Mov [CS:DI+2], DH + +UpdateGOTONote6: + Test DH, 1 + JZ UpdateGOTONote7 + + LodsB + Mov [CS:DI+3], AL + +UpdateGOTONote7: + Test DH, 2 + JZ UpdateGOTONote8 + + LodsB + Mov [CS:DI+4], AL + +UpdateGOTONote8: + Test DH, 4 + JZ UpdateGOTONote9 + + LodsB + Mov [CS:DI+5], AL + +UpdateGOTONote9: + Test DH, 8 + JZ UpdateGOTONote4 + + LodsW + Mov [CS:DI+8], AX + Jmp UpdateGOTONote4 + +UpdateGOTONote5: + Push CS + Pop DS + Assume DS:Music + + Mov PatternOffset, SI + Mov PatternArray, 0 + + Ret + +EndP UpdateGOTONote + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PreInitCommand + + Push DS + Push SI + + Push CS + Pop DS + Assume DS:Music + + Test Byte Ptr [DI+2], 33h + JZ PreInitCommandEnd + + Test Byte Ptr [ES:2Ch], 4 + JNZ PreInitCommand1 + +PreInitCommand2: + Mov AX, [DS:DI+3] + Mov [DS:DI+0Eh], AX ; Sample/note + + Jmp PreInitCommandEnd + +PreInitCommand1: ; Have to xlat. + Mov SI, [DS:DI+3] ; Not a note? + And SI, 0FFh + Cmp SI, 120 + JAE PreInitCommand2 + + Mov BL, [DS:DI+4] + And EBX, 0FFh + JZ PreInitCommand2 + + Add SI, SI + Mov BX, [ES:64710+EBX+EBX] + + Mov AX, [ES:BX+3Ch] + Cmp AL, 0 + JE PreInitCommandNoMIDI + Cmp AL, 17 + JNE PreInitCommandMIDI1 + + Mov AL, [DS:DI+20h] + And AL, 0Fh + Inc AL ; AL = HCN + +PreInitCommandMIDI1: + Mov [DS:DI+0Ch], AX + Mov AH, 101 + Mov AL, [ES:BX+SI+40h] +; Mov AL, [DS:DI+3] + Jmp PreInitCommandMIDIEnd + +PreInitCommandNoMIDI: + Mov AX, [ES:BX+SI+40h] + +PreInitCommandMIDIEnd: + Mov [DS:DI+0Eh], AX + Test AH, AH ; No sample? + JZ PreInitCommand4 + +PreInitCommandEnd: + Mov BL, [DS:DI+6] + And EBX, 31 + + Call Word Ptr [InitCommandTable+EBX+EBX] ; Init note + + Or Byte Ptr [DI], 64 + + MovZX BX, Byte Ptr [DI+20h] ; Check whether chn + ; is on + Test Byte Ptr [ES:BX+40h], 80h + JZ PreInitCommand4 + + Test Byte Ptr [DI], 32 + JNZ PreInitCommand4 + + Test Byte Ptr [DI], 4 + JZ PreInitCommand4 ; Channel was off. + + Mov SI, [DI+24h] + Or Byte Ptr [SI+1], 8 + +PreInitCommand4: + Pop SI + Pop DS + Ret + +EndP PreInitCommand + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateNoteData + Assume DS:Music + + Mov PatternLooping, 0 + + Mov AX, CurrentPattern + Cmp AX, DecodeExpectedPattern + JNE UpdateNoteData1 + + Mov AX, CurrentRow + Inc DecodeExpectedRow + Cmp AX, DecodeExpectedRow + JE UpdateNoteData2 + +UpdateNoteData1: + Call UpdateGOTONote + +UpdateNoteData2: + Mov CX, 64 ; 64 channels +; Xor AX, AX ; Just to get rid of "jumps" + Mov DI, Offset HostChannelInformationTable + + Cmp PatternArray, 1 + JE UpdateNoteArrayed + +UpdateNoteCompressed: ; First clear all old command&value. +; Mov CX, 64 ; Done above + +UpdateNoteCompressed1: + And Word Ptr [DI], Not (3+32+64+256) + Add DI, HOSTCHANNELSIZE + Dec CX + JNZ UpdateNoteCompressed1 + + Push DS + + Mov AX, CurrentPattern +IF NETWORKENABLED +; Call Network_UpdatePatternIfIdle +ENDIF + Call Music_GetPattern ; Gets DS + + Mov SI, CS:PatternOffset +; Mov DS, PatternSegment + Assume DS:Nothing + +UpdateNoteCompressed2: + LodsB + Test AL, AL + JZ UpdateNoteCompressed3 ; No more! + ; else... go through decoding. + Mov DL, AL + + And AX, 7Fh + Dec AX + LEA DI, [EAX*4+EAX] + ShL DI, 4 ; HOSTCHANNELSIZE + Add DI, Offset HostChannelInformationTable + + Mov DH, [CS:DI+2] ; mask. + Test DL, 80h + JZ UpdateNoteCompressed4 + + Mov DH, [SI] + Inc SI + Mov [CS:DI+2], DH + +UpdateNoteCompressed4: ; DH = mask + Test DH, 1 + JZ UpdateNoteCompressed6 + + LodsB + Mov [CS:DI+3], AL + +UpdateNoteCompressed6: + Test DH, 2 + JZ UpdateNoteCompressed8 + + LodsB + Mov [CS:DI+4], AL + +UpdateNoteCompressed8: + Test DH, 4 + JZ UpdateNoteCompressed10 + + LodsB + Mov [CS:DI+5], AL + +UpdateNoteCompressed10: + Test DH, 8 + JZ UpdateNoteCompressed11 + + LodsW + Mov [CS:DI+8], AX + Jmp UpdateNoteCompressed13 + +UpdateNoteCompressed11: + Test DH, 80h + JZ UpdateNoteCompressed12 + + Mov AX, [CS:DI+8] + Jmp UpdateNoteCompressed13 + +UpdateNoteCompressed12: + Xor AX, AX + +UpdateNoteCompressed13: + Mov [CS:DI+6], AX + Call PreInitCommand + + Jmp UpdateNoteCompressed2 + +UpdateNoteCompressed3: + Pop DS + Assume DS:Music + + Mov PatternOffset, SI + + Ret + +UpdateNoteArrayed: + Assume DS:Music + + Push DS + + Mov SI, PatternOffset + Mov DS, PatternSegment + Assume DS:Nothing + +; Mov CX, 64 ; 64 channels +; Mov DI, Offset HostChannelInformationTable + +UpdateNoteArrayed1: + Xor DL, DL ; DL = mask. + And Word Ptr [CS:DI], Not (3+32+64+256) + ; Turn off all calling... + + LodsB ; AL = note data. + Cmp AL, NONOTE + JE UpdateNoteArrayed2 + + Mov [CS:DI+3], AL + Or DL, 1 + +UpdateNoteArrayed2: + LodsB + Test AL, AL + JZ UpdateNoteArrayed3 + + Mov [CS:DI+4], AL + Or DL, 2 + +UpdateNoteArrayed3: + LodsB + Cmp AL, 0FFh + JE UpdateNoteArrayed4 + + Mov [CS:DI+5], AL + Or DL, 4 + +UpdateNoteArrayed4: + LodsW + Mov [CS:DI+6], AX + Mov [CS:DI+8], AX + + Test AX, AX + JZ UpdateNoteArrayed5 + + Or DL, 8 + +UpdateNoteArrayed5: + Test DL, DL + JZ UpdateNoteArrayed6 + + Mov [CS:DI+2], DL + Push CX + + Call PreInitCommand + + Pop CX + Assume DS:Nothing + + +UpdateNoteArrayed6: + Add DI, HOSTCHANNELSIZE + Dec CX + JNZ UpdateNoteArrayed1 + + Pop DS + Assume DS:Music + + Mov PatternOffset, SI + + Ret + +EndP UpdateNoteData + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateVibrato ; DS:SI points to slavechannelstruct. + + Mov BX, [SI+34h] ; ES:BX points to sample + Mov DL, [ES:BX+4Dh] ; Vibrato depth + Test DL, DL + JZ UpdateVibrato1 + + Mov CX, [SI+1Ah] + Add CL, [ES:BX+4Eh] ; Vibrato rate + AdC CH, 0 + + Cmp CH, DL + JBE UpdateVibrato5 + + Mov CH, DL + +UpdateVibrato5: + Mov [SI+1Ah], CX + + Mov AH, [ES:BX+4Ch] ; AH = speed + Mov BH, [ES:BX+4Fh] ; BH = waveform + Test AH, AH + JZ UpdateVibrato1 + + Cmp BH, 3 + JE UpdateVibrato2 + + Mov BL, [SI+19h] + + Add BL, AH + Mov [SI+19h], BL ; Update pointer. + + Mov AL, [FineSineData+BX] + Jmp UpdateVibrato3 + +UpdateVibrato2: + Call Random + And AL, 127 + Sub AL, 64 + +UpdateVibrato3: + IMul CH + + SAL AX, 2 + MovSX BX, AH + +IFE USEFPUCODE + JS UpdateVibrato4 +ENDIF + JZ UpdateVibrato1 + + Push DI + Mov DI, [SI+38h] + Call PitchSlideUpLinear + Pop DI + +IFE USEFPUCODE + Jmp UpdateVibrato1 + +UpdateVibrato4: + Neg BX + Call PitchSlideDownLinear +ENDIF + +UpdateVibrato1: + Ret + +EndP UpdateVibrato + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Update Far + + Push CS + Pop DS + Assume DS:Music + +IF USEFPUCODE + FNSave FPSave + FNInit + FLdCW [NewControlWord] +ENDIF + + Mov CX, MAXSLAVECHANNELS + Mov SI, Offset SlaveChannelInformationTable + Mov DI, [SI+38h] + + Mov BX, MIDICOMMAND_TICK + Call MIDITranslate + + Mov ES, SongDataArea + +Update2: + Test Byte Ptr [SI], 1 + JZ Update3 + ; reset volume + Mov BL, [SI+22h] + Cmp BL, [SI+21h] + JE Update4 + + Mov [SI+21h], BL + Or Byte Ptr [SI], 10h + +Update4: + Mov EAX, [SI+14h] ; Freq + Cmp EAX, [SI+10h] + JE Update3 + + Mov [SI+10h], EAX + Or Byte Ptr [SI], 20h ; Recalc freq. + +Update3: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ Update2 + + Call UpdateData + + Test Byte Ptr [ES:2Ch], 4 + JZ Update5 + + Call UpdateInstruments + Jmp UpdateEnd + +Update5: + Call UpdateSamples + +UpdateEnd: + Mov CX, NumChannels + Mov SI, Offset SlaveChannelInformationTable + Mov AX, PlayMode + +IF USEFPUCODE + FRstor FPSave +ENDIF + Ret + + +EndP Update + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateSamples + + Assume DS:Music + + Mov CX, NumChannels + Mov SI, Offset SlaveChannelInformationTable + +UpdateSamples1: + Test Byte Ptr [SI], 1 + JZ UpdateSamples2 + + Mov BX, [SI] ; OK.. if recalc volume is on. + ; then recalc volume! :) + Push CX + + Test BL, 16 + JZ UpdateSamples3 + + And BL, Not 16 + Mov CL, SoloSample + + Or BL, 64 ; Recalc final vol + Cmp CL, 0FFh + JE UpdateSamples6 + + Cmp [SI+36h], CL + JE UpdateSamples6 + + Or BH, 8 + +UpdateSamples6: + Xor DX, DX + Mov AL, [SI+21h] ; AL = vol + Mul Byte Ptr [SI+23h] ; Channel volume, AX = 0->64^2 + Mov DL, Byte Ptr [SI+24h] ; Sample volume + Mul DX ; AX = 0->64*64*128 + + SHRD AX, DX, 4 ; AX = 0->32768 + + Mov DL, GlobalVolume + Mul DX ; AX = 0->32768*128 + + SHRD AX, DX, 7 + + Mov [SI+20h], AH ; Final vol stored. + Mov [SI+4Ah], AX + +UpdateSamples3: + Test BL, 2 + JZ UpdateSamples4 + + And BL, Not 2 + Or BH, 128 + + Mov AL, [SI+2Ah] + Mov [SI+25h], AL + Cmp AL, 100 + JE UpdateSamples5 + + Sub AL, 32 + ; Pan = (Pan-32)* Separation/128 + 32 + Mov AH, [ES:34h] + ShR AH, 1 ; AH = 0->64 (Separation) + IMul AH ; AX = -2048->+2048 + ; ie. AH = -8->+8 + SAR AX, 6 ; AL = -32->+32 + + Cmp ReverseChannels, 0 + JE UpdateSamplePan3 + + Neg AL + +UpdateSamplePan3: + Add AL, 32 + +UpdateSamples5: + Mov [SI+37h], AL + +UpdateSamples4: + Mov [SI], BX + + Call UpdateVibrato + + Pop CX + +UpdateSamples2: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ UpdateSamples1 + + Ret + +EndP UpdateSamples + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateEnvelope ; Returns Carry if envelope needs + ; to be turned off + ; Reqs ES:DI points to envelope + ; DS:SI points to slave channel envelope structure + ; Called only if envelope is ON + ; BP != 0 if sustain points released, 0 otherwise + + Mov DX, [SI+8] ; DX = current pos + + Cmp DX, [SI+0Ch] ; Expected end pos + JAE UpdateEnvelope1 + + Inc DX + Mov EAX, [SI+4] ; Update value + + Mov [SI+8], DX ; Increase position + Add [SI], EAX + + ClC + Ret + +UpdateEnvelope1: ; Procedure: + ; 1) Get current pos' value + ; 2) Figure out next pos (inc/loop) + ; 3) Figure out delta to next pos + ; 4) Terminate if no loop (with carry) + ; or place new check in [SI+0Ch] + + Xor BX, BX + Mov BL, [SI+0Ah] ; BX = cur env node + LEA AX, [BX+1] + LEA BX, [EBX*2+EBX] ; BX = BX*3 + + Xor DH, DH + Mov DL, [ES:DI+BX+6] + ShL EDX, 16 + Mov [SI], EDX ; Current pos value done. + + ; AX = next cur env node + Mov DX, [ES:DI] + + Test DL, 6 ; Any loop at all? + JZ UpdateEnvelope2 + + Mov BX, [ES:DI+2] ; Normal Loop + + Test DL, 4 ; No SusLoop? + JZ UpdateEnvelope3 + + Test BP, BP + JNZ UpdateEnvelope4 + + Mov BX, [ES:DI+4] + Jmp UpdateEnvelope3 + +UpdateEnvelope4: + Test DL, 2 + JZ UpdateEnvelope2 + +UpdateEnvelope3: ; Loop + Cmp AL, BH + JBE UpdateEnvelope2 + + Xor BH, BH + Mov [SI+0Ah], BL ; BL=New node + LEA BX, [EBX*2+EBX] + + Mov AX, [ES:DI+BX+7] + Mov [SI+8], AX + Mov [SI+0Ch], AX + + ClC + Ret + +UpdateEnvelope2: ; AX = new node + Cmp AL, DH ; DH = number of nodes + JB UpdateEnvelope7 + + StC + Ret + +UpdateEnvelope7: + Mov [SI+0Ah], AL ; New node + LEA BX, [EAX*2+EAX] + + Mov DX, [ES:DI+BX+7] ; New node's tick + Mov [SI+0Ch], DX + Mov AX, [ES:DI+BX+7-3] ; Last node's tick + Sub DX, AX + Inc AX + Mov [SI+8], AX ; For security. + + Mov AL, [ES:DI+BX+6] ; New node's amplitude + Sub AL, [ES:DI+BX+6-3] ; Last node's amplitude + + Mov BX, DX ; BX = delta(ticks) + Xor DX, DX + CBW + Test AX, AX + PushF + JNS UpdateEnvelope5 + + Neg AX + +UpdateEnvelope5: + Sub BX, 1 + AdC BX, 1 ; Just to prevent div 0 errors + + Div BX + ShL EAX, 16 ; This clears AX also + Div BX + ; EAX = value + PopF + JNS UpdateEnvelope6 + + Neg EAX + +UpdateEnvelope6: + Mov [SI+4], EAX ; Delta done + + ClC + Ret + +EndP UpdateEnvelope + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +DoMIDICycle DB 0 + +MIDIPrograms DB 16 Dup (0FFh) ; Do NOT change order! +MIDIBanks DW 16 Dup (0FFFFh) +MIDIPan DB 16 Dup (0FFh) +MIDIPitch DW 16 Dup (2000h) + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateMIDI + Assume DS:Music + +; Stop cycle + + Mov CX, MAXSLAVECHANNELS + Mov SI, Offset SlaveChannelInformationTable + +UpdateMIDI1: + Test Word Ptr [SI], 200h + JZ UpdateMIDI2 + Cmp Byte Ptr [SI+36h], 100 + JNE UpdateMIDI2 + Test Byte Ptr [SI], 1 + JZ UpdateMIDI2 + + Mov Word Ptr [SI], 0 + Mov DI, [SI+38h] ; Host channel in DI + + Mov BX, MIDICOMMAND_STOPNOTE + Call MIDITranslate + + Test Byte Ptr [SI+3Ah], 80h + JNZ UpdateMIDI2 + + Or Byte Ptr [SI+3Ah], 80h + And Byte Ptr [DI], Not 4 ; Signify channel off + +UpdateMIDI2: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ UpdateMIDI1 + +; Play cycle + + Mov CX, MAXSLAVECHANNELS + Mov SI, Offset SlaveChannelInformationTable + +UpdateMIDI3: + Cmp Byte Ptr [SI+36h], 100 ; MIDI Instrument? + JNE UpdateMIDI4 + + Mov DX, [SI] + Test DL, 1 + JZ UpdateMIDI4 + + Mov AL, [SI+4Ch] + Mov Byte Ptr [SI+4Ch], 1 + Mov [SI+2Ch], AL + + Test DX, 800h ; Muted? + JNZ UpdateMIDI4 + + Mov DI, [SI+38h] ; Host channel in DI + And Word Ptr [SI], 0111100010001101b + + Test DH, 1 + JZ UpdateMIDINoPlayNote + +UpdateMIDIPlayNote: ; Check if there's a bank select. + Mov AX, [SI+3Eh] ; MIDI Bank + Cmp AX, 0FFFFh + JE UpdatemIDIBankSelectDone + + Mov BL, [SI+3Ch] ; BL = channel + And BX, 0FFh + Add BX, BX + Cmp [MIDIBanks+BX-2], AX + JE UpdateMIDIBankSelectDone + + Mov [MIDIBanks+BX-2], AX + ShR BX, 1 + Mov [MIDIPrograms+BX-1], 0FFh ; Reset program + + Mov BX, MIDICOMMAND_BANKSELECT + Call MIDITranslate + +UpdateMIDIBankSelectDone: ; Check for a program specification + Cmp Byte Ptr [SI+3Dh], 0 + JL UpdateMIDIProgramDone + + Mov BL, [SI+3Ch] ; BL = channel + And BX, 0FFh + Mov AL, [SI+3Dh] ; MIDI program + Cmp [MIDIPrograms+BX-1], AL + JE UpdateMIDIProgramDone + + Mov [MIDIPrograms+BX-1], AL + + Mov BX, MIDICOMMAND_PROGRAMSELECT + Call MIDITranslate + +UpdateMIDIProgramDone: +; Check for MIDI pitch wheel.. + Test Byte Ptr [ES:2Ch], 64 + JZ UpdateMIDINoPitchWheel + + Mov BL, [SI+3Ch] ; BL = channel + And BX, 0FFh + Add BX, BX + Cmp [MIDIPitch+BX-2], 2000h + JE UpdateMIDINoPitchWheel + + Mov [MIDIPitch+BX-2], 2000h + Mov AL, [SI+3Ch] + Dec AL + Or AL, 0E0h + Call MIDISendFilter + Xor AL, AL + Call MIDISendFilter ; Reset pitch wheel + Mov AL, 40h + Call MIDISendFilter + +UpdateMIDINoPitchWheel: + Mov EAX, [SI+14h] + Mov BX, MIDICOMMAND_PLAYNOTE + Mov [SI+1Ch], EAX + Call MIDITranslate + Jmp UpdateMIDINoChangeVolume + +UpdateMIDINoPlayNote: ; Change in volume? + Test DL, 64 + JZ UpdateMIDINoChangeVolume + + Mov BX, MIDICOMMAND_CHANGEVOLUME + Call MIDITranslate + +UpdateMIDINoChangeVolume: + Test DH, 80h ; Pan changed? + JZ UpdateMIDINoChangePan + + Mov BL, [SI+3Ch] ; BL = channel + And BX, 0FFh + Mov AL, [SI+37h] ; FPP + + Cmp [MIDIPan+BX-1], AL + JE UpdateMIDINoChangePan + + Mov [MIDIPan+BX-1], AL + + Mov BX, MIDICOMMAND_CHANGEPAN + Call MIDITranslate + +UpdateMIDINoChangePan: ; Pitch changed? + Test DL, 32 + JZ UpdateMIDINoPitchChange + + Mov BX, MIDICOMMAND_CHANGEPITCH + Call MIDITranslate + +UpdateMIDINoPitchChange: + +UpdateMIDI4: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ UpdateMIDI3 + + Ret + +EndP UpdateMIDI + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateInstruments + Assume DS:Music ; Things to update: + ; 1) Volume envelope + ; 2) Fadeout + ; 3) FinalVolume + ; 4) Vibrato. + ; Turn off channel if + ; 1) Volume envelope is off & VEV = 0 or + ; 2) Fadeout = 0 + + Mov CX, MAXSLAVECHANNELS + Mov SI, Offset SlaveChannelInformationTable + Mov [DoMIDICycle], 0 + +UpdateInstruments1: + Test Byte Ptr [SI], 1 + JNZ UpdateInstruments16 ; Channel on!! + +UpdateInstruments2: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ UpdateInstruments1 + + Cmp [DoMIDICycle], 0 + JE UpdateInstrumentNoMIDICycle + + Call UpdateMIDI + +UpdateInstrumentNoMIDICycle: + Ret + +; UpdateInstruments14: +; Jmp UpdateInstruments5 ; Jump point + +UpdateInstruments16: + Push CX + + Mov CX, [SI] + + MovZX EDI, Word Ptr [SI+30h] ; ES:DI = instrument + + Cmp Byte Ptr [SI+33h], 0FFh ; No instrument? + JE UpdateInstruments5 ; Prev Intruments14 + + Mov BP, CX + And BP, 4 ; BP = sustain for envelope calls + +UpdatePitchEnvelope: + Test CH, 40h + JZ UpdatePitchEnvelopeApply + + Push SI + Push DI + + Add SI, 70h + Add DI, 1D4h + Call UpdateEnvelope + + Pop DI + Pop SI + + JNC UpdatePitchEnvelopeApply + + And CH, Not 40h + +UpdatePitchEnvelopeApply: + Test Byte Ptr [ES:DI+1D4h], 80h + JZ UpdatePitchEnvelopePitch + + Cmp Byte Ptr [SI+36h], 100 + JE UpdatePanEnvelope + +UpdatePitchEnvelopeFilter: + Mov BX, [SI+71h] + SAR BX, 6 ; Range -128 to +128 + Add BX, 128 ; Range 0 -> 256 + Cmp BH, 1 + AdC BL, -1 + Mov [SI+3Eh], BL + + Or CL, 64 ; Recalculate final volume + +; Test Byte Ptr [SI+3Ah], 80h +; JNZ UpdatePanEnvelope +; +; Call SetFilterCutoff +; + Jmp UpdatePanEnvelope + +UpdatePitchEnvelopePitch: + Mov BX, [SI+71h] + SAR BX, 3 + JZ UpdatePanEnvelope +IFE USEFPUCODE + JS UpdatePitchEnvDown +ENDIF + + Push DI + Mov DI, [SI+38h] + + Call PitchSlideUpLinear ; req: DS:SI points to table + ; DS:DI points to host channel + ; BX = magnintude + Pop DI +IFE USEFPUCODE + Jmp UpdatePostPitchEnvelope + +UpdatePitchEnvDown: + Neg BX + Call PitchSlideDownLinear + +UpdatePostPitchEnvelope: +ENDIF + Or CL, 32 ; Recalculate freq + +UpdatePanEnvelope: + Test CH, 20h + JZ UpdateVolumeEnvelope + + Or CL, 2 ; Recalculate pan + + Push SI + Push DI + + Add SI, 60h + Add DI, 182h + Call UpdateEnvelope + + Pop DI + Pop SI + + JNC UpdateVolumeEnvelope + + And CH, Not 20h + +UpdateVolumeEnvelope: + Test CH, 10h ; Volume envelope on? + JZ UpdateInstruments3 + + Or CL, 16 ; Recalculate volume + + Push SI + Push DI + + Add SI, 50h + Add DI, 130h + Call UpdateEnvelope + + Pop DI + Pop SI + + JC UpdateVolumeEnvelope1 + Test CL, 8 ; Note fade on? + JNZ UpdateInstruments13 + + ; Now, check if loop + sustain + ; off + Test BP, BP + JZ UpdateInstruments5 + + Test Byte Ptr [ES:DI+130h], 2 ; Normal vol env loop? + JNZ UpdateInstruments19 + Jmp UpdateInstruments5 ; Volume calculation + +UpdateVolumeEnvelope1: ; Envelope turned off... + And CH, Not 10h ; Turn off envelope flag + + Cmp Byte Ptr [SI+52h], 0 ; Turn off if end of loop is + JE UpdateInstruments17 ; reached + + Jmp UpdateInstruments19 + +UpdateInstruments3: + Test CL, 8 ; Note fade?? + JNZ UpdateInstruments13 + + ; Also apply fade if No vol env + ; AND sustain off + + Test CL, 4 ; Note off issued? + JZ UpdateInstruments5 + +UpdateInstruments19: + Or CL, 8 + +UpdateInstruments13: + Mov AX, [ES:DI+14h] ; AX = fadeout. + Sub [SI+26h], AX + JG UpdateInstruments4 + Mov Word Ptr [SI+26h], 0 + +UpdateInstruments17: ; Turn off channel + Test Byte Ptr [SI+3Ah], 80h + JNZ UpdateInstruments18 + + Or Byte Ptr [SI+3Ah], 80h + ; Host channel exists + Mov BX, [SI+38h] + And Byte Ptr [BX], Not 4 + +UpdateInstruments18: +; Mov Word Ptr [SI], 200h +; Pop CX +; Jmp UpdateInstruments2 + Or CH, 2 + +UpdateInstruments4: + Or CL, 16 ; Recalc volume flag. + +UpdateInstruments5: + Test CL, 16 + JZ UpdateInstrument10 + ; Calculate volume + And CL, Not 16 + Mov DX, Word Ptr [SoloSample] ; DL = sample, DH = inst + + Or CL, 64 ; Recalc final volume + Mov AL, [SI+21h] ; Note volume.. + + Mul Byte Ptr [SI+23h] ; Channel volume + ; AX = (0->4096) + Cmp DL, 0FFh + JE UpdateInstrumentNoSampleSolo + + Cmp [SI+36h], DL + JNE UpdateInstrumentSolo + +UpdateInstrumentNoSampleSolo: + Cmp DH, 0FFh + JE UpdateInstrumentNoInstrumentSolo + + Cmp [SI+33h], DH + JE UpdateInstrumentNoInstrumentSolo + +UpdateInstrumentSolo: + Or CH, 8 + +UpdateInstrumentNoInstrumentSolo: + Mul Word Ptr [SI+26h] ; Fadeout Vol (0->1024) + ; DX:AX = 0->4194304 + SHRD AX, DX, 7 + ; AX = (0->32768) + Mov DL, [SI+24h] ; Sample volume + Mul DX ; DX:AX = 0->4194304 + + SHRD AX, DX, 7 ; AX = 0->32768 + + Mov DX, Word Ptr [SI+51h] ; VEV, 0->64*256 + Mul DX ; DX:AX = 0->536870912 + + SHRD AX, DX, 14 ; AX = 0->32768 + + Xor DH, DH + Mov DL, GlobalVolume + Mul DX ; DX:AX = 0->4194304 + + SHRD AX, DX, 7 + Mov [SI+20h], AH + Mov [SI+4Ah], AX + +UpdateInstrument10: + Test CL, 2 ; Change in panning? + JZ UpdateInstrument20 + + And CL, Not 2 + Or CH, 128 + + Mov DL, [SI+2Ah] ; DL = actual pan + Mov AL, DL + Cmp DL, 100 + JE UpdateInstrumentSurroundPan + + Mov AL, 32 + Sub AL, DL + CBW + Xor AL, AH + Sub AL, AH ; AL = |32-ActualPan| + + Neg AL + Add AL, 32 + IMul Byte Ptr [SI+62h] ; Pan envelope.. + SAR AX, 5 + Add AL, DL + + Mov [SI+25h], AL ; Value to show.. + + Sub AL, 32 + ; Pan = (Pan-32)* Separation/128 + 32 + Mov AH, [ES:34h] + ShR AH, 1 ; AH = 0->64 (Separation) + IMul AH ; AX = -2048->+2048 + ; ie. AH = -8->+8 + SAR AX, 6 ; AL = -32->+32 + + Cmp ReverseChannels, 0 + JE UpdateInstrumentPan3 + + Neg AL + +UpdateInstrumentPan3: + Add AL, 32 + Jmp UpdateInstrumentPan2 + +UpdateInstrumentSurroundPan: + Mov [SI+25h], AL + +UpdateInstrumentPan2: + Mov [SI+37h], AL + +UpdateInstrument20: + Mov [SI], CX + + Call UpdateVibrato + + Cmp Byte Ptr [SI+36h], 100 ; MIDI? + JNE UpdateInstrumentsNoMIDI + + Mov [DoMIDICycle], 1 + +UpdateInstrumentsNoMIDI: + Pop CX + + Jmp UpdateInstruments2 + +EndP UpdateInstruments + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc UpdateData + + Assume DS:Music + + Mov CX, 64 + Mov AX, PlayMode + Cmp AX, 1 + JE UpdateData_PlayMode1 + JB UpdateData_PlayMode0 + Jmp UpdateData_PlayMode2 + +UpdateData_PlayMode0: ; Step through each channel. + ; Check if on/updatemode OK + Mov DI, Offset HostChannelInformationTable + +UpdateData1: + Cmp Byte Ptr [DI+21h], 0 + JE PlayMode0UpdateVolume1 + + Dec Byte Ptr [DI+21h] ; Handle counter + JNZ UpdateData4 + + And Word Ptr [DI], Not 303h ; Turn off mode. + +UpdateData4: + Mov AX, [DI] + + Test AL, 4 ; Channel on? + JZ UpdateData2 + + Test AH, 1 + JZ UpdateData2 ; Don't update effect?? + +PlayMode0UpdateVolume2: + Push CX + + Mov BX, [DI+0Ah] + And BX, 7 + Add BX, BX + + Call Word Ptr [VolumeEffectTable+BX] + + Pop CX + + Mov AL, [DI] + +UpdateData2: + Test AL, 2 + JNZ UpdateData3 ; Update effect regardless.. + + Test AL, 4 ; Channel on? + JZ PlayMode0UpdateVolume1 + + Test AL, 1 + JZ PlayMode0UpdateVolume1 ; Don't update effect?? + +UpdateData3: ; OK. now handle counter. + Push CX + + Mov BX, [DI+6] + And BX, 31 + Add BX, BX + + Call Word Ptr [CommandTable+BX] + + Pop CX + +PlayMode0UpdateVolume1: + Add DI, HOSTCHANNELSIZE ; Progress to next channel + Dec CX + JNZ UpdateData1 + + Ret ; That's all! + +UpdateData_PlayMode1: + ; Pattern stuff.. + Dec ProcessTick + Dec CurrentTick + JZ UpdateData_Pattern1 + +UpdateData_NoNewRow: ; OK. call update command. + Mov DI, Offset HostChannelInformationTable + +UpdateData_NoNewRow1: + Mov AX, [DI] ; AX = host flags. + + Test AL, 4 + JZ UpdateData_NoNewRow5 + + Test AH, 1 + JZ UpdateData_NoNewRow5 + +UpdateData_NoNewRow4: + Push CX + + Mov BX, [DI+0Ah] + And BX, 7 + Add BX, BX + + Call Word Ptr [VolumeEffectTable+BX] + + Pop CX + + Mov AL, [DI] ; AX = host flags. + +UpdateData_NoNewRow5: + Test AL, 3 + JZ UpdateData_NoNewRow2 + + Test AL, 2 + JNZ UpdateData_NoNewRow3 + + Test AL, 4 + JZ UpdateData_NoNewRow2 + +UpdateData_NoNewRow3: + Push CX + + Mov BX, [DI+6] + And BX, 31 + Add BX, BX + + Call Word Ptr [CommandTable+BX] + + Pop CX + +UpdateData_NoNewRow2: + Add DI, HOSTCHANNELSIZE + Dec CX + JNZ UpdateData_NoNewRow1 + + Ret + +UpdateData_Pattern1: ; OK... have to update row. + Mov AX, CurrentSpeed + Mov CurrentTick, AX + Mov ProcessTick, AX + + Dec RowDelay + JNZ UpdateEffectData + + Mov Word Ptr RowDelay, 1 + + Mov AX, ProcessRow + Inc AX ; Progress to new row. + Cmp AX, NumberOfRows + JB UpdateData_Pattern2 + + Cmp StopEndOfPlaySection, 0 + JNE UpdateDataStopSong + ; Wrap row. + Xor AX, AX + XChg AX, BreakRow + +UpdateData_Pattern2: + Jmp UpdateData_Song1 +; Mov ProcessRow, AX +; Mov CurrentRow, AX +; +; ; Gotta get note data. +; Call UpdateNoteData +; Ret + +UpdateEffectData: + Mov DI, Offset HostChannelInformationTable + +UpdateEffectData1: + Test Byte Ptr [DI], 64 + JZ UpdateEffectData2 + + Mov AL, [DI+2] + Test AL, 88h + JZ UpdateEffectData2 + + Push AX + Push CX + + And AL, 88h + Mov [DI+2], AL + + Mov BL, [DI+6] + And BX, 31 + Add BX, BX + + Call Word Ptr [InitCommandTable + BX] ; Init note + + Pop CX + Pop AX + + Mov [DI+2], AL + +UpdateEffectData2: + Add DI, HOSTCHANNELSIZE + Dec CX + JNZ UpdateEffectData1 + Ret + +UpdateData_PlayMode2: + Dec ProcessTick + Dec CurrentTick + JNZ UpdateData_NoNewRow + ; Play song stuff... + + Mov AX, CurrentSpeed + Mov CurrentTick, AX + Mov ProcessTick, AX + + Dec RowDelay + JNZ UpdateEffectData + + Mov Word Ptr RowDelay, 1 + + Mov AX, ProcessRow + Inc AX + Cmp AX, NumberOfRows + JB UpdateData_Song1 + + Test OrderLockFlag, 1 + JNZ UpdateData_Song5 + + Mov BX, ProcessOrder ; Get new pattern. + Xor DX, DX + Inc BX + +UpdateData_Song2: + Cmp BX, 100h + JGE UpdateData_Song4 + + Mov CL, [ES:BX+100h] ; CL = next pattern. + Cmp CL, 200 + JB UpdateData_Song3 + + Inc BX + Cmp CL, 0FEh + JE UpdateData_Song2 + + Mov StopSong, 1 + + Cmp StopEndOfPlaySection, 0 + JE UpdateData_Song4 + +UpdateDataStopSong: + Call Music_Stop ; Optionally.. loop! + Ret + +UpdateData_Song4: + Test DX, DX + JNZ UpdateDataStopSong + + Inc DX + Xor BX, BX + Jmp UpdateData_Song2 + +UpdateData_Song3: + Mov ProcessOrder, BX + Mov CurrentOrder, BX + + Mov Byte Ptr CurrentPattern, CL + +UpdateData_Song5: + Xor AX, AX + XChg AX, BreakRow + +UpdateData_Song1: + Mov ProcessRow, AX + Mov CurrentRow, AX + + Call UpdateNoteData + Ret + +EndP UpdateData + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetNumberOfSamples Far ; Returns AX + + Push CX + Push DS + Push SI + Push ES + Push DI + + Push CS + Pop DS + Assume DS:Music + + Mov ES, SongDataArea + Mov DI, 63912-160 + + Mov AX, 99 + +Music_GetNumberOfSamples1: + Mov CX, 80 + Mov SI, Offset SampleHeader + RepE CmpsB + JNE Music_GetNumberOfSamples2 + + Sub DI, 160 + Dec AX + JNZ Music_GetNumberOfSamples1 + +Music_GetNumberOfSamples2: + + Pop DI + Pop ES + Pop SI + Pop DS + Pop CX + + Ret + +EndP Music_GetNumberOfSamples + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetNumberOfInstruments Far ; Returns AX + + Push CX + Push DS + Push SI + Push ES + Push DI + + Push CS + Pop DS + Assume DS:Music + + Mov ES, SongDataArea + Mov DI, 55912-554*2 + + Mov AX, 99 + +Music_GetNumberOfInstruments1: + Mov CX, 554 + Mov SI, Offset InstrumentHeader + RepE CmpsB + JNE Music_GetNumberOfInstruments2 + + Sub DI, 1108 + Dec AX + JNZ Music_GetNumberOfInstruments1 + +Music_GetNumberOfInstruments2: + + Pop DI + Pop ES + Pop SI + Pop DS + Pop CX + + Ret + +EndP Music_GetNumberOfInstruments + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetSampleHeader Far ; AX = sample, 1 based + + Mov SI, AX + Mov DS, CS:SongDataArea + Add SI, SI + + Mov SI, [DS:64910+SI] + + Ret + +EndP Music_GetSampleHeader + ; Returns DS:SI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetSampleLocation Far ; AX = sample (1based) + ; CH = page. + ; Returns DS:ESI + ; ECX = length + ; Carry if no sample. + ; Zero set if 8 bit + Mov CS:LastSample, AX + + Push AX + Push BX + Push DX + + Mov BX, AX + Add BX, BX + + Mov DS, CS:SongDataArea + Mov BX, [64910+BX] + Test Byte Ptr [BX+12h], 1 + JZ Music_GetSampleLocationEnd + +Music_GetSampleLocation3: + Mov AL, [BX+48h] + Test AL, AL + JZ Music_GetSampleLocationEnd + + Cmp AL, 2 + JA Music_GetSampleLocationEnd + JE Music_GetSampleLocation4 + + Mov AX, [BX+4Ah] + Xor CL, CL + ShL CX, 2 + Add AX, CX + + Jmp Music_GetSampleLocation2 + +Music_GetSampleLocation4: + Mov DX, [BX+4Ah] + Mov CL, [BX+49h] + Call E_MapEMSMemory + Call E_GetEMSPageFrame + +Music_GetSampleLocation2: + Xor ESI, ESI + Mov ECX, [BX+30h] + + Test Byte Ptr [BX+12h], 2 ; Zero flag for 8-bit. + + Mov DS, AX + +Music_GetSampleLocation5: + ClC + Jmp Music_GetSampleLocationEnd2 ; Need to preserve zero flag + +Music_GetSampleLocationEnd: + StC + +Music_GetSampleLocationEnd2: + Pop DX + Pop BX + Pop AX + + Ret + +EndP Music_GetSampleLocation + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +; Accessed via Int 3 +Proc Music_UpdateSampleLocation Far ; Reqs ESI. + + PushAD + + Mov AX, CS:LastSample + Mov ECX, ESI + ShR ECX, 8 + ShL CH, 2 + + Call Music_GetSampleLocation + + PopAD + IRet + +EndP Music_UpdateSampleLocation + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_FarUpdateSampleLocation Far + + PushF + + PushF + ClI + Call Far Ptr Music_UpdateSampleLocation + + PopF + + Ret + +EndP Music_FarUpdateSampleLocation + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetPlayMode Far + + Push DS + + Push CS + Pop DS + Assume DS:Music + + Mov AX, PlayMode + Mov BX, CurrentRow + Mov CX, CurrentPattern + Mov DX, CurrentOrder + Mov SI, NumberOfRows + + Pop DS + + Ret + Assume DS:Nothing + +EndP Music_GetPlayMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetPlayMode2 Far + + Push DS + + Push CS + Pop DS + Assume DS:Music + + Mov AX, PlayMode + Mov EBX, DWord Ptr CurrentOrder + Mov CX, CurrentRow + ShL ECX, 16 + Mov CX, CurrentTick + + Pop DS + Ret + +EndP Music_GetPlayMode2 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_PlayPattern Far ; AX = pattern, BX = number of rows + ; CX = row to start + + Push DS + + Call Music_Stop + + Push CS + Pop DS + Assume DS:Music + + Mov MIDIPitchDepthSent, 0 + Mov LastMIDIByte, 0FFh + + Mov CurrentPattern, AX + Mov CurrentRow, CX + Dec CX + Mov NumberOfRows, BX + Mov ProcessRow, CX + Mov PlayMode, 1 + + Pop DS + + Ret + +EndP Music_PlayPattern + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_PlaySong Far ; AX = Order + + PushA + Push DS + + Call Music_Stop + + Push CS + Pop DS + Assume DS:Music + + Mov MIDIPitchDepthSent, 0 + Mov LastMIDIByte, 0FFh + + Mov CurrentOrder, AX + Dec AX + Mov ProcessOrder, AX + Mov ProcessRow, 0FFFEh + Mov PlayMode, 2 + + Call StartClock + + Mov BX, MIDICOMMAND_START + Mov SI, Offset SlaveChannelInformationTable + Call MIDITranslate + + Pop DS + PopA + Ret + +EndP Music_PlaySong + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_PlayPartSong Far ; AX = order, BX = row. + + Push AX + Push BX + Push DS + + Call Music_Stop + + Mov CS:NumberOfRows, 200 + Mov CS:ProcessOrder, AX + Mov CS:CurrentOrder, AX + Mov CS:CurrentRow, BX + Dec BX + Mov CS:ProcessRow, BX + + Mov BX, AX + + Mov DS, CS:SongDataArea + MovZX AX, Byte Ptr [DS:BX+100h] + Mov CS:CurrentPattern, AX + + Mov CS:PlayMode, 2 + + Call StartClock + + Pop DS + Pop BX + Pop AX + Ret + +EndP Music_PlayPartSong + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_KBPlaySong Far + + Xor AX, AX + Cmp CS:PlayMode, 2 + JNE Music_PlaySong + + Ret + +EndP Music_KBPlaySong + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_StopChannels + + Push CX + Push DS + Push SI + Push DI + + Push CS + Pop DS + Assume DS:Music + + Mov CX, 64 + Mov SI, Offset HostChannelInformationTable + +Music_StopChannels1: + Mov Word Ptr [SI], 0 + Mov Word Ptr [SI+26h], 0 + Add SI, HOSTCHANNELSIZE + Loop Music_StopChannels1 + + Mov CX, MAXSLAVECHANNELS + Mov SI, Offset SlaveChannelInformationTable + +Music_StopChannels2: + Test Byte Ptr [SI], 1 + JZ Music_StopChannelsNoMIDI + + Cmp Byte Ptr [SI+36h], 100 + JNE Music_StopChannelsNoMIDI + + PushF + ClI + Mov DI, [SI+38h] + Mov BX, MIDICOMMAND_STOPNOTE + Call MIDITranslate + PopF + +Music_StopChannelsNoMIDI: + Mov Word Ptr [SI], 200h + Add SI, SLAVECHANNELSIZE + Loop Music_StopChannels2 + + Pop DI + Pop SI + Pop DS + Pop CX + + Ret + +EndP Music_StopChannels + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_Stop Far + + PushA + PushF + Push DS + Push ES + + CLI + + Push CS + Pop DS + Assume DS:Music + +; Turn off MIDI channels first. + + Test OrderLockFlag, 1 + JZ Music_StopNoOrderLocked + + Call Music_ToggleOrderUpdate + +Music_StopNoOrderLocked: + Mov CX, MAXSLAVECHANNELS + Mov SI, Offset SlaveChannelInformationTable + +Music_StopMIDI1: + Test Byte Ptr [SI], 1 + JZ Music_StopNoMIDI + + Cmp Byte Ptr [SI+36h], 100 + JNE Music_StopNoMIDI + + Mov DI, [SI+38h] + Mov BX, MIDICOMMAND_STOPNOTE + Call MIDITranslate + +Music_StopNoMIDI: + Add SI, SLAVECHANNELSIZE + Loop Music_StopMIDI1 + + Mov BX, MIDICOMMAND_STOP ; Stop + Mov SI, Offset SlaveChannelInformationTable + Call MIDITranslate + + Mov PlayMode, 0 + + Mov DecodeExpectedPattern, 0FFFEh + Mov DecodeExpectedRow, 0FFFEh + Mov RowDelay, 1 + Mov CurrentRow, 0 + Mov CurrentOrder, 0 + Mov CurrentTick, 1 + Mov BreakRow, 0 + + Push CX + Push DS + Push SI + Push DI + + Push CS + Pop ES + + Mov DI, Offset MIDIPrograms + Mov CX, 32 + Mov AX, 0FFFFh + Rep StosW + + Mov DI, Offset HostChannelInformationTable + Mov DS, SongDataArea + Assume DS:Nothing + + Mov SI, 40h + Mov DX, 040h + Xor AX, AX + +Music_Clear1: + Mov CX, 16 + Rep StosW + Mov AL, DH + StosW + + Xor AX, AX + Mov CX, 6 + Rep StosW + + Mov AH, [SI+40h] + LodsB + And AL, 7Fh + StosW + Xor AX, AX + Mov CX, 16 + Rep StosW + + Inc DH + Dec DL + JNZ Music_Clear1 + + ; Now clear SlaveChannel + Mov DX, MAXSLAVECHANNELS + +Music_Clear2: + Mov AX, 200h + StosW + Mov CX, SLAVECHANNELSIZE/2-1 + Xor AX, AX + Rep StosW + Dec DX + JNZ Music_Clear2 + + Push DS + Pop ES ; ES = SongDataArea + + Pop DI + Pop SI + Pop DS + Pop CX + Assume DS:Music + + Mov AX, [ES:32h] ; AL = speed, AH = tempo + Mov BX, [ES:30h] ; BL = globalvol + + Xor DX, DX + Mov DL, AL + Mov GlobalVolume, BL + Mov CurrentSpeed, DX + Mov ProcessTick, DX + Mov Tempo, AH + + Call Music_InitTempo + Call MIDI_ClearTable + + Pop ES + Pop DS + PopF + PopA + + Ret + +EndP Music_Stop + Assume DS:Nothing, ES:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_UpdatePatternOffset Far + + Mov CS:DecodeExpectedPattern, 0FFFEh + + Ret + +EndP Music_UpdatePatternOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_PlayNote Far ; DS:SI points to 5-note struct + ; AX = channel + ; DH = +32 means ignore mute + ; settings + ; DH = +128 means to use central + ; pan and max volume. + PushAD + Push DS + Push ES + + Mov AH, HOSTCHANNELSIZE + Mul AH + Mov DI, Offset HostChannelInformationTable + Add DI, AX + + Mov ES, CS:SongDataArea + + Xor DL, DL ; DL = mask + + ClI + + LodsB + Cmp AL, NONOTE + JE Music_PlayNote1 + + Or DL, 1 + Mov [CS:DI+3], AL + +Music_PlayNote1: + LodsB + Test AL, AL + JZ Music_PlayNote2 + + Or DL, 2 + Mov [CS:DI+4], AL + +Music_PlayNote2: + LodsB + Cmp AL, 0FFh + JE Music_PlayNote3 + + Or DL, 4 + Mov [CS:DI+5], AL + +Music_PlayNote3: + LodsW + Test AX, AX + JZ Music_PlayNote4 + + Or DL, 8 + +Music_PlayNote4: + Push CS + Pop DS + Assume DS:Music + + Push DX + + And DH, 7Fh + Mov [DI+6], AX + Mov [DI+8], AX + Mov [DI+2], DL + And Word Ptr [DI], Not (3+32+64+256) + Or Byte Ptr [DI], DH ; Now for command update count + + Mov AX, CurrentSpeed + Mov [DI+21h], AL + + Call PreInitCommand + + Pop DX + + Test Byte Ptr [DI], 4 + JZ Music_PlayNote5 + + Test DH, 128 + JZ Music_PlayNote5 + + Mov SI, [DI+24h] + Mov Word Ptr [SI+2Ah], 2020h; Pan and pan set. + Mov Byte Ptr [SI+23h], 40h ; Full channel volume. + +Music_PlayNote5: + Mov DecodeExpectedRow, 0FFFEh + StI + + Pop ES + Pop DS + PopAD + + Ret + +EndP Music_PlayNote + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_PlaySample Far + ; AL = Note + ; AH = sample number + ; CX = channel. + + PushAD + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Music + + Mov ES, SongDataArea + + Push AX + + Mov AX, HOSTCHANNELSIZE + Mul CX + Add AX, Offset HostChannelInformationTable + Mov DI, AX + + Pop AX + +; Mov DI, Offset HostChannelInformationTable + + ClI + + Mov Byte Ptr [DI+2], 3 ; Note & Sample + Mov [DI+3], AL ; Note... + Mov Byte Ptr [DI+4], 0FFh + Mov [DI+0Eh], AX + Or Word Ptr [DI], 8020h + + Call InitNoCommand + + Test Byte Ptr [DI], 4 + JZ Music_PlaySample1 + + Mov SI, [DI+24h] + Mov Word Ptr [SI+2Ah], 2020h + Mov Byte Ptr [SI+23h], 40h ; Full channel volume. + Mov Byte Ptr [SI+3Bh], 0 ; Note cut. + Mov Word Ptr [SI+28h], 0 + +Music_PlaySample1: + And Word Ptr [DI], Not 8000h + + Mov DecodeExpectedRow, 0FFFEh + StI + + Pop ES + Pop DS + PopAD + + Ret + +EndP Music_PlaySample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetHostChannelInformationTable Far + + Push CS + Pop DS + Assume DS:Music + + Mov SI, Offset HostChannelInformationTable + + Ret + +EndP Music_GetHostChannelInformationTable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetSlaveChannelInformationTable Far + + Push CS + Pop DS + Assume DS:Music + + Mov SI, Offset SlaveChannelInformationTable + Mov CX, MAXSLAVECHANNELS + + Ret + +EndP Music_GetSlaveChannelInformationTable + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_NextOrder Far + + Push DS + + Push CS + Pop DS + Assume DS:Music + + Cmp PlayMode, 2 + JNE Music_NextOrder1 + + Mov PlayMode, 0 + Call Music_StopChannels + Mov ProcessRow, 0FFFEh + Mov CurrentTick, 1 + Mov RowDelay, 1 + Mov PlayMode, 2 + +Music_NextOrder1: + Pop DS + Ret + +EndP Music_NextOrder + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_LastOrder Far + + Push DS + + Push CS + Pop DS + Assume DS:Music + + Cmp PlayMode, 2 + JNE Music_NextOrder1 + + Mov AX, ProcessOrder + Cmp AX, 0 + JLE Music_LastOrder1 + + ClI + + Mov PlayMode, 0 + Call Music_StopChannels + Sub AX, 2 + Mov ProcessOrder, AX + Mov ProcessRow, 0FFFEh + Mov CurrentTick, 1 + Mov RowDelay, 1 + Mov PlayMode, 2 + + StI + +Music_LastOrder1: + Pop DS + Ret + +EndP Music_LastOrder + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetGlobalVolume Far + + Push CX + Push DS + Push SI + + Push CS + Pop DS + Assume DS:Music + + Mov GlobalVolume, AL + Call RecalculateAllVolumes + + Pop SI + Pop DS + Pop CX + Ret + +EndP Music_SetGlobalVolume + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_MuteChannel Far ; AX = channel number + + Push AX + Push CX + Push DS + Push SI + Push DI + + Push CS + Pop DS + Assume DS:Music + + Mov CX, NumChannels + Mov SI, Offset SlaveChannelInformationTable + +Music_MuteChannel1: + Test Byte Ptr [SI], 1 + JZ Music_MuteChannel2 + + Mov AH, [SI+3Ah] + And AH, 07Fh + Cmp AH, AL + JNE Music_MuteChannel2 + + Or Word Ptr [SI], 840h + +Music_MuteChannel2: + Add SI, SLAVECHANNELSIZE + Loop Music_MuteChannel1 + + Pop DI + Pop SI + Pop DS + Pop CX + Pop AX + Ret + +EndP Music_MuteChannel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_UnmuteChannel Far ; AX = channel number + + Push AX + Push CX + Push DS + Push SI + Push DI + + Push CS + Pop DS + Assume DS:Music + + Mov CX, NumChannels + Mov Word Ptr [SoloSample], 0FFFFh + Mov SI, Offset SlaveChannelInformationTable + +Music_UnmuteChannel1: + Test Byte Ptr [SI], 1 + JZ Music_UnmuteChannel2 + + Mov AH, [SI+3Ah] + And AH, 07Fh + Cmp AH, AL + JNE Music_UnmuteChannel2 + +Comment ~ +Music_UnmuteChannel3: + Test DL, DL + JS Music_UnmuteChannel5 + + Cmp [SI+36h], DL + JE Music_UnmuteChannel2 + +Music_UnmuteChannel4: + Test DH, DH + JS Music_UnmuteChannel5 + + Cmp [SI+33h], DH + JE Music_UnmuteChannel2 + +Music_UnmuteChannel5: +~ + And Byte Ptr [SI+1], Not 8 + Or Byte Ptr [SI], 64 + +Music_UnmuteChannel2: + Add SI, SLAVECHANNELSIZE + Loop Music_UnmuteChannel1 + + Pop DI + Pop SI + Pop DS + Pop CX + Pop AX + Ret + +EndP Music_UnmuteChannel + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ToggleChannel Far ; AX = channel number. + + Push BX + Push DS + + Mov BX, AX + Mov DS, CS:SongDataArea + + Test Byte Ptr [BX+40h], 80h + JZ Music_ToggleChannel1 + + And Byte Ptr [BX+40h], 7Fh + Call Music_UnmuteChannel + + Mov [CS:MuteChannelTable+BX], 0 + + Pop DS + Pop BX + Ret + +Music_ToggleChannel1: ; Mute channel + Xor [CS:MuteChannelTable+BX], 1 + Or Byte Ptr [BX+40h], 80h + Call Music_MuteChannel + + Pop DS + Pop BX + Ret + +EndP Music_ToggleChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_UnmuteAll Far + + Push BX + Push CX + Push DX + Push DS + Push SI + + Jmp Music_SoloChannel3 + + +Proc Music_SoloChannel Far ; AX = channel + + Push BX + Push CX + Push DX + Push DS + Push SI + ; Check & count whether any playing. + + Mov BX, AX + + Mov DS, CS:SongDataArea + Mov SI, 40h + Mov CX, SI + Mov DX, CX + +Music_SoloChannel1: + LodsB + ShL AL, 1 + SbB DX, 0 + + Loop Music_SoloChannel1 + ; DX = num playing. + Cmp DX, 1 + JNE Music_SoloChannel6 + +Music_SoloChannel2: ; check whether it's the current + Test Byte Ptr [BX+40h], 80h + JZ Music_SoloChannel3 + +Music_SoloChannel6: + Mov CX, 64 ; 64 channel to step through + ; turn 'em all off. +Music_SoloChannel7: + Mov SI, CX + Dec SI + Cmp SI, BX + JE Music_SoloChannel9 + + Test Byte Ptr [SI+40h], 80h + JNZ Music_SoloChannel8 + +Music_SoloChannel10: + Mov AX, SI + Call Music_ToggleChannel + +Music_SoloChannel8: + Loop Music_SoloChannel7 + Jmp Music_SoloChannel11 + +Music_SoloChannel9: + Test Byte Ptr [SI+40h], 80h + JZ Music_SoloChannel8 + Jmp Music_SoloChannel10 + +Music_SoloChannel3: ; solo pressed on already soloed + ; channel -> turn everything on. + Mov CX, 64 + +Music_SoloChannel4: + Mov BX, CX + Dec BX + Cmp [CS:MuteChannelTable+BX], 1 + JNE Music_SoloChannel5 + + Mov AX, BX + Call Music_ToggleChannel + +Music_SoloChannel5: + Loop Music_SoloChannel4 + +Music_SoloChannel11: + Pop SI + Pop DS + Pop DX + Pop CX + Pop BX + + Ret + +EndP Music_SoloChannel +EndP Music_UnmuteAll + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_InitMuteTable Far + + Push AX + Push CX + Push ES + Push DI + + Mov DI, Offset MuteChannelTable + Mov CX, 32 + Push CS + Pop ES + + Xor AX, AX + Rep StosW + + Mov DWord Ptr [CS:SoloSample], 0FFFFh + + Pop DI + Pop ES + Pop CX + Pop AX + + Ret + +EndP Music_InitMuteTable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_InitStereo Far + + Push DS + + Mov DS, CS:SongDataArea + Mov AL, [DS:2Ch] + And AL, 1 + + Call [DriverSetStereo] + + Push CS + Pop DS + Call RecalculateAllVolumes + + Pop DS + Ret + +EndP Music_InitStereo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_IncreaseSpeed Far ; Returns AX = speed + + Mov AX, CS:CurrentSpeed + Cmp AX, 1 + JE Music_IncreaseSpeed1 + + Dec AX + Mov CS:CurrentSpeed, AX + Push DS + + Mov DS, SongDataArea + Mov [DS:32h], AL + + Pop DS + +Music_IncreaseSpeed1: + Ret + +EndP Music_IncreaseSpeed + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_DecreaseSpeed Far + + Mov AX, CS:CurrentSpeed + Cmp AX, 0FFh + JAE Music_DecreaseSpeed1 + + Inc AX + Mov CS:CurrentSpeed, AX + Push DS + + Mov DS, SongDataArea + Mov [DS:32h], AL + + Pop DS + + +Music_DecreaseSpeed1: + Ret + +EndP Music_DecreaseSpeed + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetSoundCard Far ; AL contains sound card num + + Xor AH, AH + + Push EBX + + Mov BX, CS + ShL EBX, 16 + + Mov BX, AX + Add BX, BX + Mov BX, [CS:DriverSoundCard+BX] + Add BX, BX + Mov BX, [CS:DriverNameTable+BX] + Mov [CS:DriverName], EBX + + Pop EBX + + Ret + +EndP Music_SetSoundCard + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetSoundCardDriver Far + + Mov Word Ptr [CS:DriverName], SI + Mov Word Ptr [CS:DriverName+2], DS + + Ret + +EndP Music_SetSoundCardDriver + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetDMA Far + + Xor AH, AH + Mov DMA, AX + + Ret + +EndP Music_SetDMA + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetMixSpeed Far + Assume DS:Nothing + + Mov CmdLineMixSpeed, CX + + Ret + +EndP Music_SetMixSpeed + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetIRQ Far + Assume DS:Nothing + + Mov IRQ, CX + + Ret + +EndP Music_SetIRQ + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetAddress Far + + Mov BasePort, DX + + Ret + +EndP Music_SetAddress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetDisplayVariables Far + + Mov AX, CS:CurrentSpeed + MovZX BX, CS:Tempo + MovZX CX, CS:GlobalVolume + + Ret + +EndP Music_GetDisplayVariables + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_AssignSampleToInstrument Far ; BX = sample num + ; returns AX + + Push CX DX DS SI ES DI + + Push CS + Pop DS + Assume DS:Music + + Mov ES, SongDataArea + +; Check for sample-number's instrument first. + Mov AX, 554 + Mul BX + Mov DI, AX + Add DI, 512 + + LEA AX, [BX+1] + Mov SI, Offset InstrumentHeader + Mov CX, 554 + + RepE CmpsB + JE Music_AssignSampleToInstrument4 + +; Search + Mov CX, 99 + Mov DI, 512 ; Points to first inst. + Mov AX, 1 + +Music_AssignSampleToInstrument1: + Push CX + + Mov SI, Offset InstrumentHeader + Mov CX, 554 + + RepE CmpsB + JE Music_AssignSampleToInstrument2 + + Add DI, CX + Pop CX + Inc AX + Loop Music_AssignSampleToInstrument1 + + StC + +Music_AssignSampleToInstrumentEnd: + Pop DI ES SI DS DX CX + Ret + +Music_AssignSampleToInstrument2: + Pop CX ; Clear the stack + +Music_AssignSampleToInstrument4: +IF NETWORKENABLED + Call Network_GetSendQueue + JZ Music_AssignSampleNetwork + + Mov SI, AX + Mov AX, 400h + StosW + Mov AX, SI + Dec AX + StosB + +Music_AssignSampleNetwork: + Call Network_FinishedSendQueue +ENDIF + + Push ES + Pop DS + + Sub DI, 554-20h ; Points to name + Mov SI, BX + Mov SI, [64912+SI+BX] + Add SI, 14h + + Mov CX, 26 + Rep MovsB + + Add DI, 7 + + ; Now to fill in table. + Mov CX, 120 + Inc BX + +Music_AssignSampleToInstrument3: + Mov [DI], BL +; Add DI, 2 + ScasW + Loop Music_AssignSampleToInstrument3 + + ClC + Jmp Music_AssignSampleToInstrumentEnd + +EndP Music_AssignSampleToInstrument + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetLimit Far + + Mov CS:CmdLineNumChannels, CX + Ret + +EndP Music_SetLimit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ReverseChannels Far + + Mov CS:ReverseChannels, 1 + Ret + +EndP Music_ReverseChannels + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_IncreaseVolume Far + + Push CX + Push DS + Push SI + + Push CS + Pop DS + Assume DS:Music + + Mov AL, GlobalVolume + And AX, 0FFh + Cmp AX, 128 + JAE Music_IncreaseVolume1 + + Inc AX + Mov GlobalVolume, AL + Call RecalculateAllVolumes + +Music_IncreaseVolume1: + Pop SI + Pop DS + Pop CX + + Ret + +EndP Music_IncreaseVolume + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_DecreaseVolume Far + + Push CX + Push DS + Push SI + + Push CS + Pop DS + Assume DS:Music + + Mov AL, GlobalVolume + And AX, 0FFh + JZ Music_DecreaseVolume1 + + Dec AX + Mov GlobalVolume, AL + Call RecalculateAllVolumes + +Music_DecreaseVolume1: + Pop SI + Pop DS + Pop CX + + Ret + +EndP Music_DecreaseVolume + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_RegetLoopInformation Far + + Push AX + Push BX + Push CX + Push DX + + Push DS + Push SI + Push ES + + Push CS + Pop DS ; DS setup + Assume DS:Music + + Mov ES, SongDataArea + + Mov CX, NumChannels + Mov SI, Offset SlaveChannelInformationTable + +Music_RegetLoopInformation1: + Test Byte Ptr [SI], 1 + JZ Music_RegetLoopInformation2 + + Push CX + ClI + + Call GetLoopInformation + + Or Byte Ptr [SI], 40h + + StI + Pop CX + +Music_RegetLoopInformation2: + Add SI, SLAVECHANNELSIZE + Loop Music_RegetLoopInformation1 + + + + Pop ES + Pop SI + Pop DS + + Pop DX + Pop CX + Pop BX + Pop AX + + Ret + +EndP Music_RegetLoopInformation + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetSoundCardMemory Far + + Jmp [DriverResetMemory] + +EndP ResetSoundCardMemory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SoundCardLoadSample Far ; AX = sample number + ; (1 based) + ; Carry set if insuf mem + PushA + Call [DriverLoadSample] + PushF + + JC Music_SoundCardLoadSample1 + + Mov CX, 2 + Mov DI, Offset O1_OutOfSoundCardMemoryList + Call M_Object1List + +Music_SoundCardLoadSample1: + PopF + PopA + Ret + +EndP Music_SoundCardLoadSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SoundCardLoadAllSamples Far + + PushAD + Push DS + + Call Music_Stop + Call S_SaveScreen + + Push 30 + Push 28 + Push 50 + Push 30 + Push 3 + Call S_DrawBox + Add SP, 10 + + Push CS + Pop DS + + Mov DI, (32+29*80)*2 + Mov SI, Offset PrepareSamplesMsg + Mov AH, 20h + Call S_DrawString + + Call S_UpdateScreen + + Call ResetSoundCardMemory + + Mov AX, 1 + +Music_SoundCardLoadAllSamples1: + Call Music_SoundCardLoadSample + JNC Music_SoundCardLoadAllSamples2 + + Inc AX + Cmp AX, 100 + JBE Music_SoundCardLoadAllSamples1 + +Music_SoundCardLoadAllSamples3: + Call S_RestoreScreen + +Music_SoundCardLoadAllSamples2: + Pop DS + PopAD + + Mov AX, 1 + Ret + +EndP Music_SoundCardLoadAllSamples + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetFreeSoundCardMemory Far + + Call [DriverGetStatus] + Ret + +EndP Music_GetFreeSoundCardMemory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetNumChannels Far + + Mov AX, CS:NumChannels + + Ret + +EndP Music_GetNumChannels + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetPitchTable Far ; Returns ES:DI to pitch table + + Push CS + Pop ES + Mov DI, Offset PitchTable + + Ret + +EndP Music_GetPitchTable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ToggleReverse Far + + Push CS + Pop DS + Assume DS:Music + + Xor ReverseChannels, 1 + Call ReCalculateAllVolumes + Mov SI, Offset ReverseMsg + Call SetInfoLine + + Ret + +EndP Music_ToggleReverse + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_PatternStorage Far + + Mov CS:PatternStorage, AL + Ret + +EndP Music_PatternStorage + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_InitMixTable Far + + Push AX + Push DS + + Xor AX, AX + Mov DS, CS:SongDataArea + Mov AL, Byte Ptr [DS:31h] ; AL = 0->128 + + Call [DriverSetMixVolume] + + Pop DS + Pop AX + Ret + +EndP Music_InitMixTable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetTempo Far + + Xor BH, BH + Mov BL, CS:Tempo + + Ret + +EndP Music_GetTempo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetLastChannel Far ; Returns AX + + Push DS + + Mov DS, CS:SongDataArea + Xor SI, SI + Mov CX, 64 + Xor AX, AX + Xor DX, DX + +Music_GetLastChannel1: + Mov BL, [SI+40h] + ShR BL, 7 + Xor BL, [CS:MuteChannelTable+SI] + JNZ Music_GetLastChannel2 + + Mov AX, DX + +Music_GetLastChannel2: + Inc DX + Inc SI + Loop Music_GetLastChannel1 + + Pop DS + Ret + +EndP Music_GetLastChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetDriverScreen Far + + Jmp [DriverSoundCardScreen] + +EndP Music_GetDriverScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetDriverVariable Far + + Jmp [DriverGetVariable] + +EndP Music_GetDriverVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetDriverVariable Far + + Jmp [DriverSetVariable] + +EndP Music_SetDriverVariable + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SetNextOrder Far + + Dec AX + Mov CS:ProcessOrder, AX + + Ret + +EndP Music_SetNextOrder + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetDelay Far + + ClI + + Xor DX, DX + Mov CX, CS:PlayMode + Test CX, CX + JZ Music_GetDelay2 + + Mov DX, CS:CurrentSpeed + Cmp AX, CS:CurrentRow + JNE Music_GetDelay3 + + Sub DX, CS:ProcessTick + JZ Music_GetDelay2 + + Cmp DX, 0Fh + JAE Music_GetDelay4 + Jmp Music_GetDelay1 + +Music_GetDelay3: + Dec DX + Cmp DX, 0Fh + JBE Music_GetDelay1 + +Music_GetDelay4: + Mov DX, 0Fh + +Music_GetDelay1: + ShL DX, 8 + Or DX, 'S'-'@'+0D000h + +Music_GetDelay2: + StI + Ret + +EndP Music_GetDelay + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +StopSong DB 0 +TimerCounter DD 0 +TotalTimer DD 0 +TotalTimerHigh DD 0 +PleaseWaitMsg DB "Please Wait...", 0 + +Proc InternalTimer Far + + PushAD + + Mov EAX, 0C214h + Mov DX, 16h ; Ticks = (1193181/(2*0.4))/Tempo + Div BX + Add EAX, EAX + Mov CS:TimerCounter, EAX + + PopAD + Ret + +EndP InternalTimer + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_TimeSong Far ; Time song! + + Push CS + Pop DS + Assume DS:Music + + Call S_SaveScreen + + Mov AL, 1 + Call S_SetDirectMode + Call S_DrawSmallBox + + Mov SI, Offset PleaseWaitMsg + Mov AH, 20h + Mov DI, (33+26*80)*2 + Call S_DrawString + + Call Music_Stop + + Mov CX, 0FFFFh + +Music_TimeSong1: + In AL, 21h ; Delay mechanism + In AL, 0A1h ; Delay mechanism + Loop Music_TimeSong1 + + Mov StopSong, 0 + Mov TotalTimer, 0 + Mov TotalTimerHigh, 0 + + ClI + In AL, 0A1h + Mov AH, AL + In AL, 21h + Push AX + + Mov AL, 0FFh + Out 0A1h, AL + Out 21h, AL + + Push DWord Ptr [DriverSetTempo] + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset InternalTimer + Mov [DriverSetTempo], EAX + + Push Word Ptr [NumChannels] + + Mov ES, SongDataArea + + Push Word Ptr [ES:2Ch] + And Byte Ptr [ES:2Ch], Not 4 + + Xor AX, AX + Call Music_PlaySong + +Music_TimeSong3: + Assume DS:Nothing + Call Update + + Cmp CS:StopSong, 0 + JNE Music_TimeSong4 + + Mov EAX, CS:TimerCounter + Add CS:TotalTimer, EAX + AdC CS:TotalTimerHigh, 0 + Jmp Music_TimeSong3 + +Music_TimeSong4: + Call Music_Stop + + Mov ES, CS:SongDataArea + + Pop Word Ptr [ES:2Ch] + Pop Word Ptr [CS:NumChannels] + Pop DWord Ptr [CS:DriverSetTempo] + + Pop AX + Out 21h, AL + Mov AL, AH + Out 0A1h, AL + + StI + + Mov AL, 0 + Call S_SetDirectMode + + Call S_RestoreScreen + + Mov CX, 0FFFFh + Mov DI, Offset O1_ShowTime + Call M_Object1List + + Mov AX, 1 + Ret + +EndP Music_TimeSong + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ShowTime Far + + Call S_GetDestination + + Mov EDX, CS:TotalTimerHigh + Mov EAX, CS:TotalTimer + + SHRD EAX, EDX, 16 + + Mov DI, (43+27*80)*2 + Call D_ShowTime + + Ret + +EndP Music_ShowTime + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetPatternLength Far + + Mov AX, CS:NumberOfRows + Ret + +EndP Music_GetPatternLength + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_SaveMIDIConfig Far + + Call D_GotoStartingDirectory + + Push CS + Pop DS + Assume DS:Music + + Mov AH, 3Ch + Xor CX, CX + Mov DX, Offset MIDIConfigFileName + Int 21h + JC Music_SaveMIDIConfig1 + + Mov BX, AX + + Mov AH, 40h + Mov DS, CS:MIDIDataArea + Xor DX, DX + Mov CX, (128+16+9)*32 + Int 21h + + Mov AH, 3Eh + Int 21h + +Music_SaveMIDIConfig1: + Xor AX, AX + Ret + +EndP Music_SaveMIDIConfig + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_GetMIDIDataArea Far + + Mov DS, CS:MIDIDataArea + Ret + +EndP Music_GetMIDIDataArea + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ToggleOrderUpdate Far + + Push CS + Pop DS + Assume DS:Music + + Mov SI, Offset OrderUpdateEnabledMsg + Xor OrderLockFlag, 1 + JZ Music_ToggleOrderUpdate1 + + Mov SI, Offset OrderUpdateDisabledMsg + +Music_ToggleOrderUpdate1: + Call SetInfoLine + + Ret + +EndP Music_ToggleOrderUpdate + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ToggleSoloInstrument Far + + Mov SI, Offset SoloInstrumentMsg + Mov DI, Offset SoloInstrument + Mov BP, 1 + Jmp Music_ToggleSolo + +EndP Music_ToggleSoloInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ToggleSoloSample Far + + Mov SI, Offset SoloSampleMsg + Mov DI, Offset SoloSample + Xor BP, BP + +EndP Music_ToggleSoloSample + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Music_ToggleSolo Far + + Push CS + Pop DS + Assume DS:Music + + Call PE_GetLastInstrument ; Returns BX + + Mov AX, BX + Add BX, BP + + Cmp [DI], BL + Mov Word Ptr [SoloSample], 0FFFFh + JE Music_ToggleSolo1 + + Inc AX + Mov Byte Ptr [DI], BL + + Jmp Music_ToggleSolo2 + +Music_ToggleSolo1: + Mov SI, Offset UnsoloMsg + +Music_ToggleSolo2: + Call SetInfoLine + + Mov CX, NumChannels + Mov SI, Offset SlaveChannelInformationTable + Xor BX, BX + + Mov ES, SongDataArea + +Music_ToggleSolo3: + Or Byte Ptr [SI], 18 + Mov BL, [SI+3Ah] ; BX = channel + + Test Byte Ptr [ES:BX+40h], 80h + JNZ Music_ToggleSolo4 + + And Word Ptr [SI], Not 800h + +Music_ToggleSolo4: + Add SI, SLAVECHANNELSIZE + Dec CX + JNZ Music_ToggleSolo3 + + Call RecalculateAllVolumes + + Mov AX, 1 + Ret + +EndP Music_ToggleSolo + Assume DS:Nothing + + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_NET.ASM b/it_net.s similarity index 96% rename from IT_NET.ASM rename to it_net.s index 570dd1a..36e6242 100644 --- a/IT_NET.ASM +++ b/it_net.s @@ -1,2722 +1,2722 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Network Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386P - -include switch.inc - -IF NETWORKENABLED - -SHOWQUEUESIZE EQU 0 - -NUMREQUIREDVARIABLES EQU 16 ; Number of bytes required from IT.EXE by Driver -NUMREQUIREDFUNCTIONS EQU 32 ; Number of functions (DD Offsets) required by - ; Network driver -NUMPROVIDEDVARIABLES EQU 16 ; Number of bytes provided from driver to IT.EXE -NUMPROVIDEDFUNCTIONS EQU 16 ; Number of functions (DW Offsets) provided by - ; Network driver - -; Has to handle: -; 1. Loading the network driver -; 2. Messages to/from network driver/buffering, etc. - -; Interface - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Extrn D_ClearFileName:Far - - Extrn E_AllocateEMS:Far - Extrn E_ReleaseEMS:Far - Extrn E_MapEMSMemory:Far - Extrn E_GetEMSPageFrame:Far - Extrn E_GetEMSVersion:Far -; Extrn E_SavePageFrame:Far -; Extrn E_RestorePageFrame:Far - - Extrn F_DrawHeader:Far - - Extrn Glbl_SetCurrentMode:Far - Extrn Glbl_GetCurrentMode:Far - - Extrn I_MapEnvelope:Far - - Extrn M_FunctionDivider:Far - Extrn M_FunctionHandler:Far - Extrn M_Object1List:Far - - Extrn Music_GetPatternLocation:Far ; Returns AX = handle - ; EBX = segment:offset - ; DL = type. - ; CX = pattern length - Extrn Music_GetPatternLocationNoCount:Far ; Returns AX = handle - ; EBX = segment:offset - ; DL = type. - Extrn Music_ReleasePattern:Far ; Requires AX = pattern - Extrn Music_AllocatePattern:Far ; SI = pattern, DX = length - Extrn Music_UpdatePatternOffset:Far - Extrn Music_ReleaseAllSamples:Far - Extrn Music_AllocateSample:Far - Extrn Music_Stop:Far - Extrn Music_ReleaseSample:Far - - Extrn IdleUpdateInfoLine:Far - Extrn SetInfoLine:Far - Extrn SetInfoLine2:Far - Extrn GetTimerCounter:Far - - Extrn O1_LoadNetworkDriver:Far - Extrn O1_NetworkErrorList:Far - Extrn GlobalKeyList - - Extrn PE_FillHeader:Far - Extrn PE_NewPattern:Far - Extrn PEFunction_OutOfMemoryMessage:Far - Extrn PEFunction_StoreCurrentPattern:Far - Extrn PE_GetLastInstrument:Far - - Extrn S_GetDestination:Far - Extrn S_DrawString:Far - Extrn S_SaveScreen:Far - Extrn S_RestoreScreen:Far - -Segment Object1 BYTE Public 'Data' -EndS - -Segment SongData PARA Public 'Data' -EndS - -Segment SongData PARA Public 'Data' -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - - Public Network_DriverScreen - Public Network_DrawDriverScreen - Public Network_PreDriverScreen - Public Network_PostDriverScreen - Public Network_Shutdown - Public Network_Poll - Public Network_GetSendQueue ; Returns ES:DI - Public Network_FinishedSendQueue ; Finished with send queue - Public Network_AddWordToQueue - Public Network_UpdatePattern - Public Network_UpdatePatternIfIdle - Public Network_EnsureNoNetwork - Public Network_SendSampleHeader - Public Network_SendInstrumentHeader - Public Network_QueueSampleData - Public Network_SendSongDataInformation - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ -; -; Not used? -; -;Segment Network BYTE Public 'Code' USE16 -; Assume CS:Network, DS:Nothing, ES:Nothing -;EndS -; -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment DiskData PARA Public 'Data' -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Pattern BYTE Public 'Code' USE16 - Extrn PatternDataArea:Word - Extrn PatternNumber:Word - Extrn Modified:Byte - Extrn PatternModified:Byte - Extrn MaxRow:Word -EndS - -Segment Music BYTE Public 'Code' USE16 - Extrn CurrentOrder:Word - Extrn CurrentPattern:Word - Extrn CurrentRow:Word -EndS - -Segment Disk DWORD Public 'Code' USE16 - Assume CS:Disk, DS:Nothing, ES:Nothing - - Extrn DiskDataArea:Word - Extrn D_GotoStartingDirectory:Far - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -;******************** THESE BLOCKS CANNOT CHANGE ORDER ************************ - -Label NetworkRequiredVariables - DD DWord Ptr GlobalKeyList - DD DWord Ptr IdleUpdateInfoLine - DW DiskData - DB NUMREQUIREDVARIABLES - ($-Offset NetworkRequiredVariables) Dup (0) - -Label NetworkRequiredFunctions - DD DWord Ptr Network_UnloadDriver - DD DWord Ptr M_FunctionHandler - DD DWord Ptr M_FunctionDivider - DD DWord Ptr Network_ReceiveData - DD DWord Ptr Network_SendData - DD DWord Ptr Network_EstablishConnection - DD DWord Ptr D_GotoStartingDirectory - DD DWord Ptr GetTimerCounter - DD DWord Ptr SetInfoLine2 - DD DWord Ptr F_DrawHeader - DD DWord Ptr PE_FillHeader - DD DWord Ptr S_GetDestination - DD DWord Ptr S_DrawString - DD DWord Ptr S_SaveScreen - DD DWord Ptr S_RestoreScreen - DD DWord Ptr Glbl_GetCurrentMode - DD DWord Ptr Network_NewConnection - DD DWord Ptr Network_DecodeUserName - DD NUMREQUIREDFUNCTIONS - ($-Offset NetworkrequiredFunctions)/4 Dup (0) - -Label NetworkDriverVariables Byte - DB NUMPROVIDEDVARIABLES - ($-Offset NetworkDriverVariables) Dup (0) - -Label NetworkDriverFunctions DWord -NetworkDriver_Initialise DD Network_EmptyFunction -NetworkDriver_Shutdown DD Network_EmptyFunction -NetworkDriver_Screen DD Network_EmptyFunction -NetworkDriver_Update DD Network_EmptyFunction -NetworkDriver_ConnectionStatus DD Network_EmptyFunction - DD NUMPROVIDEDFUNCTIONS - ($-Offset NetworkDriverFunctions)/4 Dup (0) - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -DriverIdentification DB "Impulse Tracker Network Driver" -DriverMask DB "IT*.NET", 0 -NoDriverMsg DB "No Network Drivers Found", 0 -NetworkDriverUnloaded DB "Network driver unloaded", 0 - -IF SHOWQUEUESIZE -DebugMessage DB "SendQueueSize: ", 0FDh, "D", 0 -ENDIF -; NetworkOverflowMessage DB "Network Overflow: Driver Unloaded", 0 - -ALIGN 2 -NumDrivers DW 0 -CurrentDriver DW 0 -TopDriver DW 0 - -DriverSegment DW 0 - -EMS_SENDBUFFERPAGE EQU (0*100h + 4) - -LastReceiveCX DW 0 -NetworkEMSHandle DW 0 ; 384kb -> 64kb = receive buffer 1a - ; 64kb = receive buffer 1b - ; 64kb = receive buffer 2a - ; 64kb = receive buffer 2b - ; 64kb = receive buffer 3a - ; 64kb = receive buffer 3b -NetworkSendEMSHandle DW 0 ; 64kb, separated for Win9x's - ; inattention to the int-flag. - -SendQueueSegment DW 0 ; MUST be adjacent -SendDataQueueTail DW 0 ; MUST be adjacent -SendDataQueueHead DW 0 ; MUST be adjacent -Destination DB 0 ; MUST be adjacent -DriverValidated DB 0 ; MUST be adjacent -SendBufferRemaining DW 0 ; MUST be adjacent -SendBufferOffset DW 0 ; MUST be adjacent - -PatternDataUpdated DW 50 Dup (0) ; Bit table of pattern numbers - -Label NetworkKeys Byte - DB 0 - DW 1C8h ; Up arrow - DW Network_Up - - DB 0 - DW 1D0h ; Down arrow - DW Network_Down - - DB 0 - DW 11Ch - DW Network_LoadDriver - - DB 0FFh - -EMSTransferTable Label -TransferLength DW 0, 0 -SourceType DB 0 -SourceHandle DW 0 -SourceOffset DD 0 -DestinationType DB 0 -DestinationHandle DW 0 -DestinationOffset DD 0 - -PatternModifiedTable DB 200 Dup (0) ; Bit field for 200 patterns - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_EmptyFunction Far - - Xor AX, AX - Ret - -EndP Network_EmptyFunction - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_DriverScreen Far - -; If no network driver loaded, show load screen -; If driver loaded, then call driver's screen interface - - Mov AL, 24 - Call Glbl_SetCurrentMode - - Push CS - Pop DS - Assume DS:Disk - - Cmp [DriverSegment], 0 - JE Network_DriverScreen1 - - Jmp [NetworkDriver_Screen] - -Network_DriverScreen1: - Call D_GotoStartingDirectory -; Clear data area. - - Mov ES, [DiskDataArea] - Mov CX, 32768 - Xor DI, DI - Xor AX, AX - Rep StosW ; Clear diskdata Area... - - Mov [NumDrivers], AX - Mov [CurrentDriver], AX - Mov [TopDriver], AX - -; Now shift DTA to DS:64000 - - Push DS - - Push ES - Pop DS - - Mov DX, 64000 - Mov AH, 1Ah - Int 21h ; Shift DTA address.. - - Pop DS - -; Load file names. - - Mov DX, Offset DriverMask ; Wanna search for IT*.NET - Xor CX, CX ; Normal File types - Mov AH, 4Eh - -Network_DriverScreenLoadFileNames1: - Int 21h - JC Network_DriverScreenLoadFileNamesEnd - - Push DS - - Push ES - Pop DS ; DS = Diskdata - -; OK.. have the file. -; Open it and read the first 128 bytes in from it. -; Check for identification string. If all OK, then copy details into -; network list. - - Mov AX, 3D00h - Mov DX, 64000+1Eh ; Filename - Int 21h - JC Network_DriverScreenLoadFileNext - - Mov BX, AX ; File handle. - -; Read first 128 bytes of file - - Mov AH, 3Fh - Mov CX, 128 - Mov DX, 65000 - Mov DI, DX - - Int 21h ; Read file. - JC Network_DriverScreenLoadFileNextClose - -; Check for matching ID - - Mov SI, Offset DriverIdentification - Mov CX, 30 - - SegCS RepE CmpSB - JNE Network_DriverScreenLoadFileNextClose - -; Have a matching driver! -; Copy filename and Header. - - Mov DI, [CS:NumDrivers] - Inc [CS:NumDrivers] - ShL DI, 7 ; Deposit information at 128*DI - Mov CX, 13 - Mov SI, 64000+1Eh - Rep MovsB - Mov SI, 65000+64 - Mov CX, 32 - Rep MovsW - -Network_DriverScreenLoadFileNextClose: - Mov AH, 3Eh - Int 21h - -Network_DriverScreenLoadFileNext: - Pop DS - Mov AH, 4Fh - Jmp Network_DriverScreenLoadFileNames1 - -Network_DriverScreenLoadFileNamesEnd: -; OK.. jump to network screen list - - Mov AX, 5 - Mov SI, 1 - Mov CX, Object1 - - Mov DX, Offset O1_LoadNetworkDriver - Ret - -EndP Network_DriverScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_DrawDriverScreen Far - - Push CS - Pop DS - Assume DS:Disk - - Call S_GetDestination ; Gets ES - - Cmp [NumDrivers], 0 - JNE Network_DrawDriverScreen1 - - Mov DI, (27+29*80)*2 ; (6, 13) - Mov SI, Offset NoDriverMsg - - Mov AH, 3 - Call S_DrawString - - Ret - -Network_DrawDriverScreen1: - Mov AX, 168+200h - Mov DI, (13*80+15)*2 - Mov CX, 36 - -Network_DrawDriverScreen2: - StosW - Add DI, 158 - Loop Network_DrawDriverScreen2 - - Mov SI, [TopDriver] - Mov DX, [NumDrivers] - Mov BX, [CurrentDriver] - -; Need to make sure they're within bounds. - Cmp BX, SI - JAE Network_DrawDriverScreenClip1 - - Mov SI, BX - -Network_DrawDriverScreenClip1: - LEA DI, [SI+35] - Cmp BX, DI - JBE Network_DrawDriverScreenClip2 - - LEA SI, [BX-35] - -Network_DrawDriverScreenClip2: - Mov DI, (13*80+2)*2 - Mov [TopDriver], SI - - Sub DX, SI - JZ Network_DrawDriverScreenEnd - - ShL SI, 7 - Mov DS, [DiskDataArea] - Assume DS:Nothing - - Cmp DX, 36 - JB Network_DrawDriverScreenClip - - Mov DX, 36 - -Network_DrawDriverScreenClip: - Mov AH, 3 - Mov CX, 13 - -Network_DrawDriverScreenFileNames: - LodsB - StosW - Loop Network_DrawDriverScreenFileNames - -; Add DI, 2 - ScasW - - Mov CX, 62 - -Network_DrawDriverScreenDriverName: - LodsB - StosW - Loop Network_DrawDriverScreenDriverName - - Add SI, 128-62-13 - Add DI, 8 - - Dec DX - JNZ Network_DrawDriverScreenClip - -Network_DrawDriverScreenEnd: - Ret - -EndP Network_DrawDriverScreen - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_PreDriverScreen Far - - Push CS - Pop DS - Assume DS:Disk - - Cmp [NumDrivers], 0 - JE Network_PreDriverScreenEnd - - Mov AX, [CurrentDriver] - Sub AX, [TopDriver] - Add AX, 13 - Mov BX, 160 - Mul BX - - Call S_GetDestination - - LEA DI, [EAX+4] - Mov CX, 76 - -Network_PreDriverScreen1: - Mov AX, [ES:DI] - Mov AH, 30h - Cmp CX, 76-13 - JNE Network_PreDriverScreen2 - - Mov AH, 32h - -Network_PreDriverScreen2: - StosW - Loop Network_PreDriverScreen1 - -Network_PreDriverScreenEnd: - Ret - -EndP Network_PreDriverScreen - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_Up Far - Assume DS:Disk - - Sub [CurrentDriver], 1 - AdC [CurrentDriver], 0 - - Mov AX, 1 - Ret - -EndP Network_Up - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_Down Far - - Mov AX, [CurrentDriver] - Inc AX - Cmp AX, [NumDrivers] - JAE Network_Down1 - - Mov [CurrentDriver], AX - -Network_Down1: - Mov AX, 1 - Ret - -EndP Network_Down - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_PostDriverScreen Far - -; Has to handle up, down, Enter. - - Push CS - Pop DS - Assume DS:Disk - - Mov SI, Offset NetworkKeys - Call M_FunctionDivider - JC Network_PostDriverScreen1 - - Jmp [Word Ptr SI] - -Network_PostDriverScreen1: - Xor AX, AX - Ret - -EndP Network_PostDriverScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_LoadDriver Far - Assume DS:Disk - -; Allocate EMS memory buffers first - - Cmp NetworkEMSHandle, 1 - JAE Network_LoadDriverMemoryAlreadyAllocated - - Call E_GetEMSVersion - Cmp AL, 40h - JB Network_LoadDriverInsufficientMemory - - ; Carry flag set -> essential allocation - StC - Mov EAX, 384*1024 - Call E_AllocateEMS - Test AX, AX - JNZ Network_LoadDriverMemoryOK - -Network_LoadDriverInsufficientMemory: - Jmp PEFunction_OutOfMemoryMessage - -Network_LoadDriverMemoryOK: - Mov NetworkEMSHandle, AX - -Network_LoadDriverMemoryAlreadyAllocated: - Cmp NetworkSendEMSHandle, 1 - JAE Network_LoadDriverSendEMSHandleAlreadyAllocated - - Mov EAX, 64*1024 - Call E_AllocateEMS - Test AX, AX - JZ Network_LoadDriverInsufficientMemory - - Mov NetworkSendEMSHandle, AX - -Network_LoadDriverSendEMSHandleAlreadyAllocated: - Cmp SendqueueSegment, 0 - JNE Network_LoadDriverMemoryAlreadyAllocated2 - - Mov AH, 48h - Mov BX, 1024 - Int 21h ; Allocate 16kb of memory for the SendQueue - JC Network_LoadDriverInsufficientMemory - - Mov SendQueueSegment, AX - -Network_LoadDriverMemoryAlreadyAllocated2: - Xor EAX, EAX - Mov DWord Ptr [SendDataQueueTail], EAX - Mov DWord Ptr [Destination], EAX - - Mov AX, [NumDrivers] - Mov DX, [CurrentDriver] - - Test AX, AX - JNZ Network_LoadDriver1 - - Ret - -Network_LoadDriver1: - ShL DX, 7 - Mov DS, [DiskDataArea] - Assume DS:Nothing - Mov DI, DX - -; Try allocating memory first. - Mov BX, [DI+13+62] ; Bytes to read - Mov AH, 48h - Add BX, 15 - ShR BX, 4 ; BX = number of parags required. - Int 21h - JNC Network_LoadDriver2 - - Jmp PEFunction_OutOfMemoryMessage - -Network_LoadDriver2: - Mov ES, AX - Mov [CS:DriverSegment], AX - - Mov AX, 3D00h - Int 21h ; Open file - JC Network_LoadDriver3 - - Mov BX, AX - Mov AX, 4200h - Xor CX, CX - Mov DX, 128 - Int 21h - JC Network_LoadDriver4 - - Mov AH, 3Fh - Mov CX, [DI+13+62] - Mov DS, [CS:DriverSegment] - Xor DX, DX - Int 21h ; Read driver - JC Network_LoadDriver4 - - Push CS - Pop DS - Assume DS:Disk - - Mov AH, 3Fh - Mov CX, NUMPROVIDEDVARIABLES - Mov DX, Offset NetworkDriverVariables - Int 21h - JC Network_LoadDriver4 - - Mov AH, 3Fh - Mov CX, NUMPROVIDEDFUNCTIONS*2 - Mov DX, Offset NetworkDriverFunctions+NUMPROVIDEDFUNCTIONS*2 - Int 21h - JC Network_LoadDriver4 - - Mov AH, 3Eh - Int 21h ; Close file. - -; Setup tables - Mov SI, Offset NetworkRequiredVariables - Xor DI, DI - Mov CX, NUMREQUIREDVARIABLES+4*NUMREQUIREDFUNCTIONS - Rep MovsB - - Mov AX, ES - Push DS - Pop ES - Mov SI, DX - Mov DI, Offset NetworkDriverFunctions - Mov CX, NUMPROVIDEDFUNCTIONS - ShL EAX, 16 - -Network_LoadDriver5: - LodsW - StosD - Loop Network_LoadDriver5 - -; Initialise Send/Receive buffers. - Mov DX, CS:NetworkEMSHandle - Mov CL, 512/16 - Mov CH, 28 - Call E_GetEMSPageFrame - Mov ES, AX - -Network_InitialiseBuffers1: - Call E_MapEMSMemory - Mov DWord Ptr [ES:65532], 0 - Sub CH, 4 - JNS Network_InitialiseBuffers1 - -; Should jump to network initialise function now. - - Jmp NetworkDriver_Initialise - Assume DS:Nothing - -Network_LoadDriver4: - Mov AH, 3Eh - Int 21h - -Network_LoadDriver3: - Jmp Network_UnloadDriver - -EndP Network_LoadDriver - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_UnloadDriver Far - - Push CS - Push CS - Pop DS - Pop ES - Assume DS:Disk - - Mov SI, Offset NetworkDriverUnloaded - Call SetInfoLine - - Mov AH, 49h - Mov ES, [DriverSegment] - Int 21h - - Mov [DriverSegment], 0 - - Mov AH, 49h - Mov ES, SendQueueSegment - Int 21h - - Mov SendQueueSegment, 0 - - Push CS - Pop ES - - Mov AX, CS - ShL EAX, 16 - Mov AX, Offset Network_EmptyFunction - Mov DI, Offset NetworkDriverFunctions - Mov CX, NUMPROVIDEDFUNCTIONS - Rep StosD - - Jmp Network_DriverScreen - -EndP Network_UnloadDriver - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -; PatternCycle DW 0 - -Proc Network_Poll Far - -Comment ~ - Mov AX, CS:PatternCycle - Inc AX - Cmp AX, 200 - JB Network_Poll1 - - Xor AX, AX - -Network_Poll1: - Mov CS:PatternCycle, AX - - Call Network_UpdatePatternIfIdle -~ - Jmp NetworkDriver_Update - -EndP Network_Poll - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_DecodeUserName Far ; Given DS:SI = name - ; CX = count (including key) - - Test CX, CX - JZ Network_DecodeUserName3 - - Mov BX, CX - Xor DX, DX - -Network_DecodeUserName1: - LodsB - Add DL, AL - StosB - Xor DH, DL - Loop Network_DecodeUserName1 - - Add DX, 0FFFFh - JC Network_UnloadDriver - - Sub SI, BX - Mov CX, BX - - Xor AH, AH -Network_DecodeUserName2: - LodsB - Add AH, AL - XChg AL, AH - Xor AL, 0AAh - RoR AL, 2 - Mov [SI-1], AL - Loop Network_DecodeUserName2 - -Network_DecodeUserName3: - Mov CS:DriverValidated, 1 - -Network_DecodeUserNameEnd: - Ret - -EndP Network_DecodeUserName - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_Shutdown Far - - Mov AX, CS:NetworkEMSHandle - Test AX, AX - JZ Network_Shutdown1 - - Call E_ReleaseEMS - -Network_Shutdown1: - Mov AX, CS:NetworkSendEMSHandle - Test AX, AX - JZ Network_Shutdown2 - - Call E_ReleaseEMS - -Network_Shutdown2: - Jmp NetworkDriver_Shutdown - -EndP Network_Shutdown - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ -; -; Internal structures -; ------------------- -; -; SendBuffer is the raw data to transmit: -; Offset Size Contents Notes -; 0 DWord Block Header ID 'JLNP' - "J.L. Network Protocol" -; 4 Word Block Size Byte count, includes headers -; and CRC check. -; 6 Byte Block Type -; 7 <...> Data Maximum of 65000 bytes -; Word CRC Calculated -; -; Block types. -; -; SendQueue contains a queue of objects to transmit. -; Structure: -; Offset Size Contents Notes -; 0 Byte Destination 0=all, 1-3=specific, others=ignore -; 1 Byte Object Type -; 2 <> Data -; -; Object types: -; 0: Partial pattern data -; Extra data: Pattern Number (1), Bounding Box (4), Data -; 1: Entire pattern -; Extra data: Pattern Number (1), Data (Compressed) -; 2: Request pattern -; Extra data: Pattern Number (1) -; 3: SongData information (includes order list + song parameters) -; Extra data: Length (2), Offset (2) -; 4: Instrument information -; Extra data: Instrument Number (1) -; 5: Sample information -; Extra data: Sample Number (1) -; 6: Pattern Length -; Extra data: Pattern Number (1), New MaxRow (1) -; 7: Delete sample -; Extra data: Sample Number (1) -; 8: New sample - sends length also -; Extra data: Sample Number (1) -; 9: Sample Data -; Extra data: Sample Number (1), Offset (4) - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_CalculateCRC - ; Calculates CRC and appends 6 byte header - - ; Given ES = EMSSegment - ; Given DI = end of data written - - Push DS - - Push ES - Pop DS - - Mov CX, DI - Xor SI, SI - LEA BX, [DI+2] - Xor DX, DX - Mov Word Ptr [SI+4], BX - Xor AX, AX - Mov DWord Ptr [SI], 'JLNP' - -Network_CalculateCRC1: - LodsB - Add DH, AL - Xor DL, DH - Loop Network_CalculateCRC1 - -; Have DH = sum, DL = xor of running sum. -; Want to have DX = 0 after next two bytes -; second last byte = DL-DH -; last byte = -DL - - Sub AH, DL ; AH = -DL - Sub DL, DH ; DL = DL-DH - Mov AL, DL ; AL = DL-DH - - StosW - Mov CS:SendBufferOffset, 0 - Mov CS:SendBufferRemaining, BX - - Pop DS - - Ret - -EndP Network_CalculateCRC - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_GetSendBufferPage Near - ; Returns AX = EMSPageFrame - - Push CX - Push DX - - Mov CX, EMS_SENDBUFFERPAGE - Mov DX, CS:NetworkSendEMSHandle - Call E_MapEMSMemory - Call E_GetEMSPageFrame - - Pop DX - Pop CX - - Ret - -EndP Network_GetSendBufferPage - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -; Send Procedure Jump Table -; Each procedure is given DS:SI = Send queue data -; ES:DI = Send buffer -; Each procedure only need write to ES:DI. -; Count of bytes is taken from return value of DI, CRC+Header will be appended -; Can use AX, BX, CX, DX, DS, SI -; Must update CS:SendDataQueueHead - -NUMBEROFBLOCKTYPES EQU 10 - -ConvertQueueObjectTypes DW Offset SendNetworkBlock0 - DW Offset SendNetworkBlock1 - DW Offset SendNetworkBlock2 - DW Offset SendNetworkBlock3 - DW Offset SendNetworkBlock4 - DW Offset SendNetworkBlock5 - DW Offset SendNetworkBlock6 - DW Offset SendNetworkBlock7 - DW Offset SendNetworkBlock8 - DW Offset SendNetworkBlock9 - -; Receive Procedure Jump Table -; Given DS = Receive buffer -; Can use any register - -InterpretObjectTypes DW Offset ReceiveNetworkBlock0 - DW Offset ReceiveNetworkBlock1 - DW Offset ReceiveNetworkBlock2 - DW Offset ReceiveNetworkBlock3 - DW Offset ReceiveNetworkBlock4 - DW Offset ReceiveNetworkBlock5 - DW Offset ReceiveNetworkBlock6 - DW Offset ReceiveNetworkBlock7 - DW Offset ReceiveNetworkBlock8 - DW Offset ReceiveNetworkBlock9 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; -; Block Type 0 notes -; -; If first byte is between 80 and EF, then Val & 7F rows down are empty -; If first byte is between F0 and F7, then -; note field is empty, other fields are: -; Val & 1, ins present -; Val & 2, vol present -; Val & 4, eff present -; -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock0 Near - -; Block type 0 -; Offset 0: Pattern Number -; 1: Channel -; 2: Row -; 3: Width -; 4: Height - - LodsB - StosB - Mov DX, AX ; DL = Pattern Number - LodsW - StosW - Mov CX, AX ; CL = Channel, CH = Row - LodsW - Mov BX, AX ; BL = Width, BH = Height - - Mov CS:SendDataQueueHead, SI - - Push Pattern - Pop DS - Assume DS:Pattern - - Cmp DL, Byte Ptr PatternNumber ; Still editing the pattern? - JE SendNetworkBlock0_0 - - Xor AX, AX - StosW - - Ret - -SendNetworkBlock0_0: - StosW - Mov DS, PatternDataArea - Assume DS:Nothing - - Mov AL, 64 - Mul CH - Add AL, CL - LEA ESI, [EAX*4+EAX] - -SendNetworkBlock0_1: - Push BX - Push SI - - Xor DX, DX ; DL = num empty rows - -SendNetworkBlock0_2: - Push SI - - Cmp Byte Ptr [SI], 0FDh - JNE SendNetworkBlock0_3 - Cmp DWord Ptr [SI+1], 0000FF00h - JNE SendNetworkBlock0_3 - - Inc DX - Cmp DL, 6Fh - JB SendNetworkBlock0_NextCell - - Mov AL, 80h - Add AL, DL - StosB - Xor DX, DX - Jmp SendNetworkBlock0_NextCell - -SendNetworkBlock0_3: - Test DX, DX - JZ SendNetworkBlock0_4 - - Mov AL, 80h - Add AL, DL - StosB - Xor DX, DX - -SendNetworkBlock0_4: - LodsB - Cmp AL, 0FDh ; Empty note? - JE SendNetworkBlock0_5 - - StosB - MovsD - Jmp SendNetworkBlock0_NextCell - -SendNetworkBlock0_5: - Push BX - - Mov BX, DI - StosB ; Increment.. needs to be filled later - - Mov CL, 0F0h - LodsB - Test AL, AL ; instrument - JZ SendNetworkBlock0_6 - - StosB - Or CL, 1 - -SendNetworkBlock0_6: ; Volume - LodsB - Cmp AL, 0FFh - JE SendNetworkBlock0_7 - - StosB - Or CL, 2 - -SendNetworkBlock0_7: ; Effect - LodsW - Test AX, AX - JZ SendNetworkBlock0_8 - - StosW - Or CL, 4 - -SendNetworkBlock0_8: - Mov [ES:BX], CL - - Pop BX - -SendNetworkBlock0_NextCell: - Pop SI - Add SI, 320 - - Dec BH - JNZ SendNetworkBlock0_2 - - Test DX, DX - JZ SendNetworkBlock0_9 - - Mov AL, 80h - Or AL, DL - StosB - -SendNetworkBlock0_9: - Pop SI - Pop BX - - Add SI, 5 ; Next column - - Dec BL - JNZ SendNetworkBlock0_1 - - Ret - -EndP SendNetworkBlock0 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock0 Near - - Push Pattern - Pop ES - Assume ES:Pattern - - Mov [Word Ptr ES:Modified], 101h - - Mov AL, [DS:07h] ; AL = Pattern Number - - Cmp AL, [Byte Ptr ES:PatternNumber] - JNE ReceiveNetworkBlock0_1 - - Mov ES, [ES:PatternDataArea] - Assume ES:Nothing - - Mov CX, [DS:08h] ; CL = Channel, CH = Row - Mov BX, [DS:0Ah] ; BL = Width, BH = Height - - Test BX, BX - JZ ReceiveNetworkBlock0_1 - - Mov AL, 64 - Mul CH - Add AL, CL - LEA EDI, [EAX*4+EAX] - Mov AL, 5 - - Mul BL - Mov SI, 0Ch - -ReceiveNetworkBlock0_0: - Push BX - Push DI - -ReceiveNetworkBlock0_3: - LodsB - Cmp AL, 80h - JB ReceiveNetworkBlock0_4 - Cmp AL, 0F8h - JAE ReceiveNetworkBlock0_4 - - Cmp AL, 0F0h - JAE ReceiveNetworkBlock0_6 - -; Empty rows here. - And AL, 7Fh - Sub BH, AL - -ReceiveNetworkBlock0_11: - Mov Byte Ptr [ES:DI], 0FDh - Mov DWord Ptr [ES:DI+1], 0000FF00h - Add DI, 320 - Dec AL - JNZ ReceiveNetworkBlock0_11 - - Test BH, BH - JNZ ReceiveNetworkBlock0_3 - Jmp ReceiveNetworkBlock0_5 - -ReceiveNetworkBlock0_6: ; Partial row here. - Mov AH, AL - - Mov AL, 0FDh ; NONOTE - StosB - - Xor AL, AL - - Test AH, 1 - JZ ReceiveNetworkBlock0_7 - - LodsB - -ReceiveNetworkBlock0_7: - StosB - - Mov AL, 0FFh - Test AH, 2 - JZ ReceiveNetworkBlock0_8 - - LodsB - -ReceiveNetworkBlock0_8: - StosB - Test AH, 4 - Mov AX, 0 ; Don't erase flags - JZ ReceiveNetworkBlock0_9 - - LodsW - -ReceiveNetworkBlock0_9: - StosW - Jmp ReceiveNetworkBlock0_10 - -ReceiveNetworkBlock0_4: - StosB - MovsD - -ReceiveNetworkBlock0_10: - Add DI, 320-5 - - Dec BH - JNZ ReceiveNetworkBlock0_3 - -ReceiveNetworkBlock0_5: - - Pop DI - Pop BX - - Add DI, 5 - Dec BL - JNZ ReceiveNetworkBlock0_0 - - Ret - -ReceiveNetworkBlock0_1: ; Not the same, or zero width -> mark modified - -; DX = connection ID -; AL = Pattern number - - ; Sanity check - Cmp AL, 200 - JAE ReceiveNetworkBlock0_2 - - Mov BX, AX - Inc DX - And BX, 0FFh - Mov [CS:PatternModifiedTable+BX], DL - -ReceiveNetworkBlock0_2: - Ret - -EndP ReceiveNetworkBlock0 - Assume ES:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock1 - -; Block type 1 -; Offset 0: Pattern number - - Push FS - - Push Pattern - Pop FS - Assume FS:Pattern - - LodsB - Mov CS:SendDataQueueHead, SI - StosB - - And AX, 0FFh - -; Check whether request should be sent off to another node instead. -; AL = Pattern number - - Mov BX, AX - - Mov DH, [CS:PatternModifiedTable+BX] - - Test DH, DH - JZ SendNetworkBlock1_1 - - Mov CS:Destination, DH - Mov Byte Ptr [ES:DI-2], 2 ; NETWORK_REQUESTPATTERNOBJECT - - Jmp SendNetworkBlock1_2 - -SendNetworkBlock1_1: - Cmp AL, [Byte Ptr FS:PatternNumber] - JNE SendNetworkBlock1_0 - - Mov [FS:PatternModified], 0 - - PushAD - Push DS - Push ES - - Call PEFunction_StoreCurrentPattern - - Pop ES - Pop DS - PopAD - -SendNetworkBlock1_0: - Call Music_GetPatternLocation - ; Returns AX = handle - ; EBX = offset/segment (or page/segment) - ; CX = length (not including header) - ; DL = 0 for conv, 1 for EMS - - Push CS - Pop DS - Assume DS:Disk - - Add CX, 8 -; Setup EMS transfer - Mov TransferLength, CX - - Mov SourceType, DL - Mov SourceHandle, AX - Mov SourceOffset, EBX - - Mov AX, NetworkSendEMSHandle - Mov DestinationType, 1 - Mov DestinationHandle, AX - Mov [Word Ptr DestinationOffset], DI - Mov [Word Ptr DestinationOffset+2], 0 - -; Data is ready to go! - Mov AX, 5700h - Mov SI, Offset EMSTransferTable - Int 67h - - Add DI, CX - -SendNetworkBlock1_2: - Call Network_GetSendBufferPage - Mov ES, AX - - Pop FS - - Ret - -EndP SendNetworkBlock1 - Assume DS:Nothing, FS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock1 - - Push FS - - Push Music - Pop FS - Assume FS:Music - - Mov EDX, [DS:8] - Mov AL, [DS:7] - - And AX, 0FFh ; AX = Pattern Number - ; DX = length - -; Sanity check - Cmp AL, 200 - JAE ReceiveNetworkBlock1_2 - - Call Music_ReleasePattern - - Cmp EDX, 400040h - JE ReceiveNetworkBlock1_1 - - Push AX - - Add DX, 8 - Push DX - Push AX - - Mov SI, AX - Call Music_AllocatePattern - - Pop AX - Call Music_GetPatternLocationNoCount - -; Setup EMS transfer - Push CS - Pop DS - Assume DS:Disk - - Mov DestinationType, 1 - Mov DestinationHandle, AX - Mov DestinationOffset, EBX - - Pop DX - - Mov AX, NetworkEMSHandle - Mov CX, LastReceiveCX ; CH = page - Mov TransferLength, DX - ShR CX, 8 - Mov SourceType, 1 - Mov SourceHandle, AX - Mov [Word Ptr SourceOffset], 8 - Mov [Word Ptr SourceOffset+2], CX - -; Data is ready to go! - Mov AX, 5700h - Mov SI, Offset EMSTransferTable - Int 67h - - Pop AX - -; Mark it off as handled -; AX = Pattern number - -ReceiveNetworkBlock1_1: - Mov BX, AX - Mov [CS:PatternModifiedTable+BX], 0 - - Push Pattern - Pop DS - Assume DS:Pattern - - Cmp AL, [Byte Ptr DS:PatternNumber] - JNE ReceiveNetworkBlock1_0 - - Call PE_NewPattern - -ReceiveNetworkBlock1_0: - Cmp AL, [Byte Ptr FS:CurrentPattern] - JNE ReceiveNetworkBlock1_2 - - Call Music_UpdatePatternOffset - -ReceiveNetworkBlock1_2: - Pop FS - Ret - -EndP ReceiveNetworkBlock1 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock2 - - MovsB - Mov CS:SendDataQueueHead, SI - Ret - -EndP SendNetworkBlock2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock2 - - Mov AH, [DS:7] ; AH = pattern - Mov AL, 1 ; NETWORK_ENTIREPATTERNOBJECT - - ; Sanity check - Cmp AH, 200 - JAE ReceiveNetworkBlock2_1 - - Call Network_AddWordToQueue - -ReceiveNetworkBlock2_1: - Ret - -EndP ReceiveNetworkBlock2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock3 - - LodsW ; Length - StosW - Mov CX, AX - LodsW - StosW - Mov CS:SendDataQueueHead, SI - - Push SongData - Pop DS - Mov SI, AX - - Rep MovsB - - Ret - -EndP SendNetworkBlock3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock3 - - Push SongData - Pop ES - - Mov CX, [DS:7] - Mov DI, [DS:9] - Mov SI, 11 - - ; Sanity check - Mov AX, CX - Add AX, DI - - Cmp AX, 512 - JA ReceiveNetworkBlock3_1 - - Rep MovsB - -ReceiveNetworkBlock3_1: - Ret - -EndP ReceiveNetworkBlock3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock4 - - LodsB - StosB - And AX, 0FFh - Mov CS:SendDataQueueHead, SI - Add AX, AX - Mov SI, AX - - Push SongData - Pop DS - Mov SI, [64712+SI] - - Mov CX, 554/2 - Rep MovsW - -SendNetworkBlock4_1: - Ret - -EndP SendNetworkBlock4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock4 - - Mov DI, [DS:7] - And DI, 0FFh - Mov AX, DI ; AX = instrument - - ; Sanity check - Cmp AX, 100 - JAE ReceiveNetworkBlock4_1 - - Add DI, DI - - Push SongData - Pop ES - - Mov DI, [ES:64712+DI] - Mov SI, 8 - Mov CX, 554/2 - Rep MovsW - - Call PE_GetLastInstrument - Cmp AX, BX - JNE ReceiveNetworkBlock4_1 - - Call Glbl_GetCurrentMode - Cmp AL, 4 - JNE ReceiveNetworkBlock4_1 - - Call I_MapEnvelope - -ReceiveNetworkBlock4_1: - - Ret - -EndP ReceiveNetworkBlock4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock5 ; Does not send length or - ; sample pointer. - - LodsB - StosB - And AX, 0FFh - Mov CS:SendDataQueueHead, SI - Add AX, AX - Mov SI, AX - - Push SongData - Pop DS - Mov SI, [64912+SI] - - Add SI, 4 - Mov CX, 2Ch/2 - Rep MovsW - LodsW ; Skip length - LodsW - Mov CX, 14h/2 - Rep MovsW - LodsW - LodsW - MovsW - MovsW - - Ret - -EndP SendNetworkBlock5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock5 - - Mov DI, [DS:7] - And DI, 0FFh - - Cmp DI, 100 - JAE ReceiveNetworkBlock5_1 - - Add DI, DI - - Push SongData - Pop ES - - Mov DI, [ES:64912+DI] - Mov SI, 8 - ScasW - ScasW - Mov CX, 2Ch/2 - Rep MovsW - ScasW - ScasW - Mov CX, 14h/2 - Rep MovsW - ScasW - ScasW - MovsW - MovsW - -ReceiveNetworkBlock5_1: - Ret - -EndP ReceiveNetworkBlock5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock6 - - MovsW - Mov CS:SendDataQueueHead, SI - - Ret - -EndP SendNetworkBlock6 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock6 - - Mov AX, [DS:7] ; AL = pattern number, AH = numrows - - Push Pattern - Pop DS - Assume DS:Pattern - - Cmp AL, [Byte Ptr PatternNumber] - JNE ReceiveNetworkBlock6_1 - - Cmp AH, 200 - JAE ReceiveNetworkBlock6_2 - - Mov [Byte Ptr MaxRow], AH - -ReceiveNetworkBlock6_2: - Ret - -ReceiveNetworkBlock6_1: - Jmp ReceiveNetworkBlock0_1 ; Marks pattern as modified. - -EndP ReceiveNetworkBlock6 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock7 - - MovsB - Mov CS:SendDataQueueHead, SI - Ret - -EndP SendNetworkBlock7 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock7 - - Mov AL, [DS:7] - Mov AH, 1 - - Cmp AL, 100 - JAE ReceiveNetworkBlock7_1 - - Call Music_ReleaseSample - -ReceiveNetworkBlock7_1: - Ret - -EndP ReceiveNetworkBlock7 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock8 ; New sample - - MovsB - MovsD - Mov CS:SendDataQueueHead, SI - - Ret - -EndP SendNetworkBlock8 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock8 ; New sample - -; Call Music_Stop - - Mov AX, [DS:7] - And AX, 0FFh ; AX = Sample number - - ; Sanity check - Cmp AX, 100 - JAE ReceiveNetworkBlock8_2 - - Mov SI, AX - Add SI, AX - Mov EDX, [DS:8] - - Push SongData - Pop DS - - Mov SI, [SI+64912] ; DS:SI = sample - Mov ECX, EDX - - Test Byte Ptr [SI+12h], 2 ; 16 bit? - JZ ReceiveNetworkBlock8_1 - - Add EDX, EDX - -ReceiveNetworkBlock8_1: - Call Music_AllocateSample - Mov [SI+30h], ECX - -ReceiveNetworkBlock8_2: - Ret - -EndP ReceiveNetworkBlock8 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetSampleLocation ; Given BX = EMS transfer structure - ; Given DX = sample number - ; Given ECX = offset - ; Returns carry if problem. - - PushAD - Push DS - - Push SongData - Pop DS - Mov SI, DX - Add SI, DX - Mov SI, [64912+SI] ; DS:SI = sample header - - Mov EAX, [SI+30h] - - Test Byte Ptr [SI+12h], 2 - JZ GetSampleLocation2 - - Add EAX, EAX - -GetSampleLocation2: - Cmp EAX, ECX - JB GetSampleLocation1 - - Mov EDX, EAX - Sub EDX, ECX - Cmp EDX, 32768 - JB GetSampleLocation6 - - Mov DX, 32768 - -GetSampleLocation6: - Mov [CS:TransferLength], DX - - Cmp Byte Ptr [SI+48h], 1 - JB GetSampleLocation1 - JA GetSampleLocation4 - -GetSampleLocation3: ; Conventional memory - Mov Byte Ptr [CS:BX], 0 ; type - Mov DWord Ptr [CS:BX+1], 0 ; handle,Offset - ShR ECX, 4 - Add CX, [SI+4Ah] - Mov Word Ptr [CS:BX+5], CX ; segment - - Jmp GetSampleLocation5 - -GetSampleLocation4: ; Expanded memory - Mov AX, [SI+4Ah] - Mov Byte Ptr [CS:BX], 1 - Mov Word Ptr [CS:BX+1], AX ; handle - Mov AX, CX - ShR ECX, 14 - And AX, 3FFFh - Mov [CS:BX+3], AX ; Offset - Mov [CS:BX+5], CX ; Page - - Jmp GetSampleLocation5 - -GetSampleLocation1: - StC - -GetSampleLocation5: - Pop DS - PopAD - - Ret - -EndP GetSampleLocation - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc SendNetworkBlock9 - - LodsB - StosB - Mov DX, AX - LodsD - StosD - Mov ECX, EAX - And DX, 0FFh - Mov CS:SendDataQueueHead, SI - - Mov BX, Offset SourceType - Call GetSampleLocation - JC SendNetworkBlock9_1 - - Push CS - Pop DS - Assume DS:Disk - - Mov AX, NetworkSendEMSHandle - Mov DestinationType, 1 - Mov DestinationHandle, AX - Mov [Word Ptr DestinationOffset], DI - Mov [Word Ptr DestinationOffset+2], 0 - - Add DI, TransferLength - -; Data is ready to go! - Mov AX, 5700h - Mov SI, Offset EMSTransferTable - Int 67h - - Ret - -SendNetworkBlock9_1: - Sub DI, 5 - - Ret - -EndP SendNetworkBlock9 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReceiveNetworkBlock9 - - Mov DX, [DS:7] - Mov ECX, [DS:8] - And DX, 0FFh - Mov BX, Offset DestinationType - Mov AX, NetworkEMSHandle - Mov SI, LastReceiveCX ; CH = page - - ; Sanity Check - Cmp DX, 100 - JAE ReceiveNetworkBlock9_1 - - Call GetSampleLocation - JC ReceiveNetworkBlock9_1 - - Push CS - Pop DS - Assume DS:Disk - - ShR SI, 8 - Mov SourceType, 1 - Mov SourceHandle, AX - Mov [Word Ptr SourceOffset], 12 - Mov [Word Ptr SourceOffset+2], SI - -; Data is ready to go! - Mov AX, 5700h - Mov SI, Offset EMSTransferTable - Int 67h - -ReceiveNetworkBlock9_1: - Ret - -EndP ReceiveNetworkBlock9 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_SendData Far -; Called by driver when it is able to send data -; -; Provided: AX = number of bytes it can send. -; ES:DI = buffer location -; -; Returns: CX = number of bytes to send, 0 if no data. -; DX = receiver's connection ID. 0 = all, 1->3 = specific. - - PushF - CLI - Push DS - Push ES - Push DI - - Push AX - Push DX - - Mov AH, 47h - Mov DX, CS:NetworkSendEMSHandle - Int 67h - - Test AH, AH - - Pop DX - Pop AX - - JNZ Network_SendDataError - - Cmp CS:DriverValidated, 1 - JNE Network_SendDataError - - Mov CX, CS:SendBufferRemaining - Test CX, CX - JNZ Network_SendData1 - -; Need to get a new block of data into the buffer. - -Network_SendData3: - Mov CX, CS:SendDataQueueTail - Mov SI, CS:SendDataQueueHead - - Sub CX, SI - JZ Network_SendDataEnd - - Mov DS, SendQueueSegment - Assume DS:Nothing - - Push AX - Push BX - Push BP - Push ES - Push DI - Push FS - -; Mov DX, CS:NetworkEMSHandle -; Call E_SavePageFrame - - Call Network_GetSendBufferPage - Mov ES, AX - Mov DI, 6 - - LodsB - Mov CS:Destination, AL - LodsB - StosB - Mov BL, AL - And BX, 0FFh - Add BX, BX - Call [CS:ConvertQueueObjectTypes+BX] - Call Network_CalculateCRC - - Cmp [CS:SendDataQueueHead], 16384-16 - JB Network_SendData4 - - Mov [CS:SendDataQueueHead], 0 - -Network_SendData4: - - Mov CX, BX ; CX = SendBufferRemaining - - Pop FS - Pop DI - Pop ES - Pop BP - Pop BX - Pop AX - -; Push DX -; Mov DX, CS:NetworkEMSHandle -; Call E_RestorePageFrame -; Pop DX - - Cmp CX, 9 - JA Network_SendData1 - - Mov DWord Ptr [CS:SendBufferRemaining], 0 - Jmp Network_SendData3 - -Network_SendData1: ; Send buffer has data remaining - Mov SI, CS:SendBufferOffset - - Cmp CX, AX - JB Network_SendData2 - - Mov CX, AX - -Network_SendData2: - Add CS:SendBufferOffset, CX - Sub CS:SendBufferRemaining, CX - - Call Network_GetSendBufferPage - Mov DS, AX - - Xor DX, DX - Push CX - Rep MovsB - Pop CX - Mov DL, CS:Destination - -Network_SendDataEnd: - Push DX - - Mov AH, 48h - Mov DX, CS:NetworkSendEMSHandle - Int 67h - - Pop DX - - Pop DI - Pop ES - Pop DS - PopF - - Ret - -Network_SendDataError: - Pop DI - Pop ES - Pop DS - PopF - - Xor CX, CX - Xor DX, DX - Ret - -EndP Network_SendData - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ReceiveToBlock DB 0, 8, 16 - -; EMS layout: -; EMS:65532: Check word -; EMS:65534: Buffer Offset - -Proc Network_ReceiveData Far -; Called by driver when data is received -; -; Provided: DS:SI = data block received -; BX = sender's connection ID (0->2) -; CX = byte count received - - PushF - CLI - Push CX - - Mov AH, 47h - Mov DX, CS:NetworkEMSHandle - Int 67h - - Test AH, AH - JNZ Network_ReceiveData3 -; Call E_SavePageFrame - - Cmp CS:DriverValidated, 1 - JNE Network_ReceiveData3 - - Mov CL, 512/16 - Mov CH, [CS:ReceiveToBlock+BX] - Mov CS:LastReceiveCX, CX - Call E_MapEMSMemory - - Call E_GetEMSPageFrame - - Pop CX - - Mov ES, AX - Mov DI, [ES:65534] - -; Consistency check -> if at start of block, make sure that the header contains -; 'JLNP' - - Test DI, DI - JNZ Network_ReceiveData1 - - Cmp DWord Ptr [SI], 'JLNP' - JNE Network_ReceiveDataEnd - -Network_ReceiveData1: - Mov DX, [ES:65532] - -; Assume OK.. now place data into buffer, updating check word. -Network_ReceiveData2: - LodsB - Add DL, AL - StosB - Xor DH, DL - Loop Network_ReceiveData2 - - Cmp DI, [ES:4] - JAE Network_ReceiveDataBlockFinished - - Mov [ES:65532], DX - Mov [ES:65534], DI - -Network_ReceiveDataEnd: - Mov AH, 48h - Mov DX, CS:NetworkEMSHandle - Int 67h -; Mov DX, CS:NetworkEMSHandle -; Call E_RestorePageFrame - - PopF - - ClC - - Ret - -Network_ReceiveDataBlockFinished: - Xor Byte Ptr [CS:ReceiveToBlock+BX], 4 - Mov DWord Ptr [ES:65532], 0 - Test DX, DX - JNZ Network_CRCFail ; CRC check failed - -; ********************* Need to handle block types here. - PushAD - Push DS - - Push ES - Pop DS - - Mov SI, [DS:6] - And SI, 0FFh - - Cmp SI, NUMBEROFBLOCKTYPES - JAE Network_ReceiveDataBlockError - - Add SI, SI - Mov DX, BX - Call [InterpretObjectTypes+SI] - -Network_ReceiveDataBlockError: - Pop DS - PopAD - Jmp Network_ReceiveDataEnd - -Network_CRCFail: - Mov AH, 48h - Mov DX, CS:NetworkEMSHandle - Int 67h - Push CX - -Network_ReceiveData3: - Pop CX - PopF - - StC - - Ret - -EndP Network_ReceiveData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_GetSendQueue Far - - PushAD - PushF - Push DS - Push ES - - Sub SP, 4 - Push BP - Mov BP, SP - Mov EDI, [BP+44] - Mov [BP+2], EDI - Pop BP - - Push AX - Push DS - - ClI - - Push CS - Pop DS - Assume DS:Disk - -Comment ~ - This code is incomplete - Mov AX, SendDataQueueTail - Sub AX, SendDataQueueHead - Cmp AX, 16384-16 - JB Network_GetSendQueue2 - - Call [NetworkDriver_UnloadDriver] - - Xor AX, AX - Jmp Network_GetSendQueue1 - -Network_GetSendQueue2: -~ - Call [NetworkDriver_ConnectionStatus] - Mov DI, [SendQueueSegment] - Or AX, DI - Mov ES, DI - Mov DI, [SendDataQueueTail] - -Network_GetSendQueue1: - Pop DS - Pop AX - - Ret - -EndP Network_GetSendQueue - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_FinishedSendQueue Far - - Cmp DI, 16384-16 ; 16 bytes slack area - JB Network_FinishedSendQueue1 - - Xor DI, DI - -Network_FinishedSendQueue1: - Mov [CS:SendDataQueueTail], DI - Mov BP, SP - Pop EAX - Mov [BP+42], EAX - -IF SHOWQUEUESIZE - Push CS - Pop DS - Mov AX, SendDataQueueTail - Sub AX, SendDataQueueHead - Mov SI, Offset DebugMessage - Call SetInfoLine -ENDIF - - Pop ES - Pop DS - PopF - PopAD - - Ret - -EndP Network_FinishedSendQueue - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_NewConnection Far ; Called when this computer - ; joins a group - - PushA - Push ES - - Push CS - Pop ES - - Mov CX, 200/2 ; Mark all patterns as requiring - ; update from host connection - Mov DI, Offset PatternModifiedTable - Mov AX, 101h - Rep StosW - - Call Music_Stop - Call D_ClearFileName - - Pop ES - PopA - Ret - - -EndP Network_NewConnection - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ResetDI - - Cmp DI, 16384-16 - JB ResetDI1 - - Xor DI, DI - -ResetDI1: - Ret - -EndP ResetDI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_QueueSampleData Far ; Given CX = Sample number, 0 base - ; DL = ConnectionID - - Push EAX - Push EBX - Push ECX - Push DX - Push SI - Push DS - - Push SongData - Pop DS - - Call Network_GetSendQueue - JZ Network_QueueSampleData2 - - Mov SI, CX - Add SI, CX - Mov SI, [SI+64912] ; DS:SI = sample - - Test Byte Ptr [SI+12h], 1 - JZ Network_QueueSampleData2 - - Mov EBX, [SI+30h] - Test EBX, EBX - JZ Network_QueueSampleData2 - - Mov AL, DL - Mov AH, 8 - StosW - Mov AL, CL - StosB - Mov EAX, EBX ; Length - StosD - Call ResetDI - - Mov DH, CL - - Xor ECX, ECX - Test Byte Ptr [SI+12h], 2 - JZ Network_QueueSampleData1 - - Add EBX, EBX - -Network_QueueSampleData1: - Mov AL, DL - Mov AH, 9 - StosW - Mov AL, DH - StosB - Mov EAX, ECX - StosD - Call ResetDI - - Add ECX, 32768 - Cmp ECX, EBX - JB Network_QueueSampleData1 - -Network_QueueSampleData2: - Call Network_FinishedSendQueue - - Pop DS - Pop SI - Pop DX - Pop ECX - Pop EBX - Pop EAX - - Ret - -EndP Network_QueueSampleData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_EstablishConnection Far ; Called when a connection is - ; made to this computer -; Called when a successful connection is made -; Given AL = new connection number - -; This basically adds all samples, instruments, patterns, -; and order list to the send queue (or requests to the appropriate nodes) - - PushA - Push DS - Push ES - - Mov ES, CS:SendQueueSegment - Mov DI, CS:SendDataQueueTail - -; Send Patterns - Xor CX, CX - Mov DX, AX - -Network_EstablishConnection1: ; 3 * 200 bytes - Mov AL, DL ; Destination - Mov AH, 1 ; NETWORK_ENTIREPATTERNOBJECT - StosW - Mov AL, CL - StosB - Call ResetDI - Inc CX - Cmp CX, 200 - JB Network_EstablishConnection1 - -; Send Instruments - Xor CX, CX - -Network_EstablishConnection2: ; 3 * 100 bytes - Mov AL, DL ; Destination - Mov AH, 4 - StosW - Mov AL, CL - StosB - Call ResetDI - Inc CX - Cmp CX, 100 - JB Network_EstablishConnection2 - -; Send Sample headers - Xor CX, CX - -Network_EstablishConnection3: ; 3 * 100 bytes - Mov AL, DL ; Destination - Mov AH, 5 - StosW - Mov AL, CL - StosB - Call ResetDI - Inc CX - Cmp CX, 100 - JB Network_EstablishConnection3 - -; Now send order list ; 6 bytes - Mov AL, DL ; Destination - Mov AH, 3 ; NETWORK_SONGDATAOBJECT - StosW - Mov AX, 512 ; Length - StosW - Xor AX, AX ; Offset - StosW - Call ResetDI - - Mov CS:SendDataQueueTail, DI - - Xor CX, CX - -Network_EstablishConnection4: - Call Network_QueueSampleData - - Inc CX - - Cmp CX, 100 - JB Network_EstablishConnection4 - -; Loop through patterns and make sure that no patterns are destined for new -; connection - - Push CS - Pop ES - - Mov CX, 200 - Mov DI, Offset PatternModifiedTable - -Network_EstablishConnection5: - Mov AL, [ES:DI] - Cmp AL, DL - JNE Network_EstablishConnection6 - - Xor AL, AL - -Network_EstablishConnection6: - StosB - Loop Network_EstablishConnection5 - - Pop ES - Pop DS - PopA - - Ret - -EndP Network_EstablishConnection - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_AddWordToQueue Far ; Given AX, broadcasts to all - - Call Network_GetSendQueue - JZ Network_AddWordToQueue0 - - Push AX - Xor AL, AL - StosB - Pop AX - StosW - -Network_AddWordToQueue0: - Call Network_FinishedSendQueue - Ret - -EndP Network_AddWordToQueue - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_UpdatePatternIfIdle Far - - Cmp CS:SendQueueSegment, 0 - JE Network_UpdatePatternEnd - - Push AX - Mov AX, CS:SendDataQueueTail - Cmp AX, CS:SendDataQueueHead - Pop AX - JNE Network_UpdatePatternEnd - -Proc Network_UpdatePattern Far - - PushA - ; AX = pattern number -; Check whether it is current. -; AL = Pattern number - - Mov BX, AX - And BX, 0FFh - Xor AX, AX - - XChg [CS:PatternModifiedTable+BX], AL - Test AL, AL - JZ Network_UpdatePattern1 - -; AL = connection request - Call Network_GetSendQueue - JZ Network_UpdatePattern2 - - StosB - Mov AL, 2 ; NETWORK_REQUESTPATTERNOBJECT - Mov AH, BL - StosW - -Network_UpdatePattern2: - Call Network_FinishedSendQueue - -Network_UpdatePattern1: - PopA - -Network_UpdatePatternEnd: - Ret - -EndP Network_UpdatePattern - -EndP Network_UpdatePatternIfIdle - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_EnsureNoNetwork Far - - Push AX - Call [CS:NetworkDriver_ConnectionStatus] - Test AL, AL - Pop AX - JZ Network_EnsureNoNetwork1 - - Mov DI, Offset O1_NetworkErrorList - Mov CX, 2 - Call M_Object1List - - Mov AX, 1 - Add SP, 4 - -Network_EnsureNoNetwork1: - Ret - -EndP Network_EnsureNoNetwork - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_SendSampleHeader Far - - Call Network_GetSendQueue - JZ Network_SendSampleHeader1 - - Mov AX, 500h ; Sample header, broadcast - StosW - Call PE_GetLastInstrument - Mov AL, BL - StosB - -Network_SendSampleHeader1: - Call Network_FinishedSendQueue - Ret - -EndP Network_SendSampleHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_SendInstrumentHeader Far - - Call Network_GetSendQueue - JZ Network_SendInstrumentHeader1 - - Mov AX, 400h ; Instrument header, broadcast - StosW - Call PE_GetLastInstrument - Mov AL, BL - StosB - -Network_SendInstrumentHeader1: - Call Network_FinishedSendQueue - Ret - -EndP Network_SendInstrumentHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Network_SendSongDataInformation Far ; CX = Count, DX = offset - - Call Network_GetSendQueue - JZ Network_SendSongDataInformation1 - - Mov AX, 300h - StosW - Mov AX, CX - StosW - Mov AX, DX - StosW - -Network_SendSongDataInformation1: - Call Network_FinishedSendQueue - Ret - -EndP Network_SendSongDataInformation - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndS - -ENDIF - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Network Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386P + +include switch.inc + +IF NETWORKENABLED + +SHOWQUEUESIZE EQU 0 + +NUMREQUIREDVARIABLES EQU 16 ; Number of bytes required from IT.EXE by Driver +NUMREQUIREDFUNCTIONS EQU 32 ; Number of functions (DD Offsets) required by + ; Network driver +NUMPROVIDEDVARIABLES EQU 16 ; Number of bytes provided from driver to IT.EXE +NUMPROVIDEDFUNCTIONS EQU 16 ; Number of functions (DW Offsets) provided by + ; Network driver + +; Has to handle: +; 1. Loading the network driver +; 2. Messages to/from network driver/buffering, etc. + +; Interface + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Extrn D_ClearFileName:Far + + Extrn E_AllocateEMS:Far + Extrn E_ReleaseEMS:Far + Extrn E_MapEMSMemory:Far + Extrn E_GetEMSPageFrame:Far + Extrn E_GetEMSVersion:Far +; Extrn E_SavePageFrame:Far +; Extrn E_RestorePageFrame:Far + + Extrn F_DrawHeader:Far + + Extrn Glbl_SetCurrentMode:Far + Extrn Glbl_GetCurrentMode:Far + + Extrn I_MapEnvelope:Far + + Extrn M_FunctionDivider:Far + Extrn M_FunctionHandler:Far + Extrn M_Object1List:Far + + Extrn Music_GetPatternLocation:Far ; Returns AX = handle + ; EBX = segment:offset + ; DL = type. + ; CX = pattern length + Extrn Music_GetPatternLocationNoCount:Far ; Returns AX = handle + ; EBX = segment:offset + ; DL = type. + Extrn Music_ReleasePattern:Far ; Requires AX = pattern + Extrn Music_AllocatePattern:Far ; SI = pattern, DX = length + Extrn Music_UpdatePatternOffset:Far + Extrn Music_ReleaseAllSamples:Far + Extrn Music_AllocateSample:Far + Extrn Music_Stop:Far + Extrn Music_ReleaseSample:Far + + Extrn IdleUpdateInfoLine:Far + Extrn SetInfoLine:Far + Extrn SetInfoLine2:Far + Extrn GetTimerCounter:Far + + Extrn O1_LoadNetworkDriver:Far + Extrn O1_NetworkErrorList:Far + Extrn GlobalKeyList + + Extrn PE_FillHeader:Far + Extrn PE_NewPattern:Far + Extrn PEFunction_OutOfMemoryMessage:Far + Extrn PEFunction_StoreCurrentPattern:Far + Extrn PE_GetLastInstrument:Far + + Extrn S_GetDestination:Far + Extrn S_DrawString:Far + Extrn S_SaveScreen:Far + Extrn S_RestoreScreen:Far + +Segment Object1 BYTE Public 'Data' +EndS + +Segment SongData PARA Public 'Data' +EndS + +Segment SongData PARA Public 'Data' +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + + Public Network_DriverScreen + Public Network_DrawDriverScreen + Public Network_PreDriverScreen + Public Network_PostDriverScreen + Public Network_Shutdown + Public Network_Poll + Public Network_GetSendQueue ; Returns ES:DI + Public Network_FinishedSendQueue ; Finished with send queue + Public Network_AddWordToQueue + Public Network_UpdatePattern + Public Network_UpdatePatternIfIdle + Public Network_EnsureNoNetwork + Public Network_SendSampleHeader + Public Network_SendInstrumentHeader + Public Network_QueueSampleData + Public Network_SendSongDataInformation + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ +; +; Not used? +; +;Segment Network BYTE Public 'Code' USE16 +; Assume CS:Network, DS:Nothing, ES:Nothing +;EndS +; +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment DiskData PARA Public 'Data' +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Pattern BYTE Public 'Code' USE16 + Extrn PatternDataArea:Word + Extrn PatternNumber:Word + Extrn Modified:Byte + Extrn PatternModified:Byte + Extrn MaxRow:Word +EndS + +Segment Music BYTE Public 'Code' USE16 + Extrn CurrentOrder:Word + Extrn CurrentPattern:Word + Extrn CurrentRow:Word +EndS + +Segment Disk DWORD Public 'Code' USE16 + Assume CS:Disk, DS:Nothing, ES:Nothing + + Extrn DiskDataArea:Word + Extrn D_GotoStartingDirectory:Far + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +;******************** THESE BLOCKS CANNOT CHANGE ORDER ************************ + +Label NetworkRequiredVariables + DD DWord Ptr GlobalKeyList + DD DWord Ptr IdleUpdateInfoLine + DW DiskData + DB NUMREQUIREDVARIABLES - ($-Offset NetworkRequiredVariables) Dup (0) + +Label NetworkRequiredFunctions + DD DWord Ptr Network_UnloadDriver + DD DWord Ptr M_FunctionHandler + DD DWord Ptr M_FunctionDivider + DD DWord Ptr Network_ReceiveData + DD DWord Ptr Network_SendData + DD DWord Ptr Network_EstablishConnection + DD DWord Ptr D_GotoStartingDirectory + DD DWord Ptr GetTimerCounter + DD DWord Ptr SetInfoLine2 + DD DWord Ptr F_DrawHeader + DD DWord Ptr PE_FillHeader + DD DWord Ptr S_GetDestination + DD DWord Ptr S_DrawString + DD DWord Ptr S_SaveScreen + DD DWord Ptr S_RestoreScreen + DD DWord Ptr Glbl_GetCurrentMode + DD DWord Ptr Network_NewConnection + DD DWord Ptr Network_DecodeUserName + DD NUMREQUIREDFUNCTIONS - ($-Offset NetworkrequiredFunctions)/4 Dup (0) + +Label NetworkDriverVariables Byte + DB NUMPROVIDEDVARIABLES - ($-Offset NetworkDriverVariables) Dup (0) + +Label NetworkDriverFunctions DWord +NetworkDriver_Initialise DD Network_EmptyFunction +NetworkDriver_Shutdown DD Network_EmptyFunction +NetworkDriver_Screen DD Network_EmptyFunction +NetworkDriver_Update DD Network_EmptyFunction +NetworkDriver_ConnectionStatus DD Network_EmptyFunction + DD NUMPROVIDEDFUNCTIONS - ($-Offset NetworkDriverFunctions)/4 Dup (0) + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +DriverIdentification DB "Impulse Tracker Network Driver" +DriverMask DB "IT*.NET", 0 +NoDriverMsg DB "No Network Drivers Found", 0 +NetworkDriverUnloaded DB "Network driver unloaded", 0 + +IF SHOWQUEUESIZE +DebugMessage DB "SendQueueSize: ", 0FDh, "D", 0 +ENDIF +; NetworkOverflowMessage DB "Network Overflow: Driver Unloaded", 0 + +ALIGN 2 +NumDrivers DW 0 +CurrentDriver DW 0 +TopDriver DW 0 + +DriverSegment DW 0 + +EMS_SENDBUFFERPAGE EQU (0*100h + 4) + +LastReceiveCX DW 0 +NetworkEMSHandle DW 0 ; 384kb -> 64kb = receive buffer 1a + ; 64kb = receive buffer 1b + ; 64kb = receive buffer 2a + ; 64kb = receive buffer 2b + ; 64kb = receive buffer 3a + ; 64kb = receive buffer 3b +NetworkSendEMSHandle DW 0 ; 64kb, separated for Win9x's + ; inattention to the int-flag. + +SendQueueSegment DW 0 ; MUST be adjacent +SendDataQueueTail DW 0 ; MUST be adjacent +SendDataQueueHead DW 0 ; MUST be adjacent +Destination DB 0 ; MUST be adjacent +DriverValidated DB 0 ; MUST be adjacent +SendBufferRemaining DW 0 ; MUST be adjacent +SendBufferOffset DW 0 ; MUST be adjacent + +PatternDataUpdated DW 50 Dup (0) ; Bit table of pattern numbers + +Label NetworkKeys Byte + DB 0 + DW 1C8h ; Up arrow + DW Network_Up + + DB 0 + DW 1D0h ; Down arrow + DW Network_Down + + DB 0 + DW 11Ch + DW Network_LoadDriver + + DB 0FFh + +EMSTransferTable Label +TransferLength DW 0, 0 +SourceType DB 0 +SourceHandle DW 0 +SourceOffset DD 0 +DestinationType DB 0 +DestinationHandle DW 0 +DestinationOffset DD 0 + +PatternModifiedTable DB 200 Dup (0) ; Bit field for 200 patterns + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_EmptyFunction Far + + Xor AX, AX + Ret + +EndP Network_EmptyFunction + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_DriverScreen Far + +; If no network driver loaded, show load screen +; If driver loaded, then call driver's screen interface + + Mov AL, 24 + Call Glbl_SetCurrentMode + + Push CS + Pop DS + Assume DS:Disk + + Cmp [DriverSegment], 0 + JE Network_DriverScreen1 + + Jmp [NetworkDriver_Screen] + +Network_DriverScreen1: + Call D_GotoStartingDirectory +; Clear data area. + + Mov ES, [DiskDataArea] + Mov CX, 32768 + Xor DI, DI + Xor AX, AX + Rep StosW ; Clear diskdata Area... + + Mov [NumDrivers], AX + Mov [CurrentDriver], AX + Mov [TopDriver], AX + +; Now shift DTA to DS:64000 + + Push DS + + Push ES + Pop DS + + Mov DX, 64000 + Mov AH, 1Ah + Int 21h ; Shift DTA address.. + + Pop DS + +; Load file names. + + Mov DX, Offset DriverMask ; Wanna search for IT*.NET + Xor CX, CX ; Normal File types + Mov AH, 4Eh + +Network_DriverScreenLoadFileNames1: + Int 21h + JC Network_DriverScreenLoadFileNamesEnd + + Push DS + + Push ES + Pop DS ; DS = Diskdata + +; OK.. have the file. +; Open it and read the first 128 bytes in from it. +; Check for identification string. If all OK, then copy details into +; network list. + + Mov AX, 3D00h + Mov DX, 64000+1Eh ; Filename + Int 21h + JC Network_DriverScreenLoadFileNext + + Mov BX, AX ; File handle. + +; Read first 128 bytes of file + + Mov AH, 3Fh + Mov CX, 128 + Mov DX, 65000 + Mov DI, DX + + Int 21h ; Read file. + JC Network_DriverScreenLoadFileNextClose + +; Check for matching ID + + Mov SI, Offset DriverIdentification + Mov CX, 30 + + SegCS RepE CmpSB + JNE Network_DriverScreenLoadFileNextClose + +; Have a matching driver! +; Copy filename and Header. + + Mov DI, [CS:NumDrivers] + Inc [CS:NumDrivers] + ShL DI, 7 ; Deposit information at 128*DI + Mov CX, 13 + Mov SI, 64000+1Eh + Rep MovsB + Mov SI, 65000+64 + Mov CX, 32 + Rep MovsW + +Network_DriverScreenLoadFileNextClose: + Mov AH, 3Eh + Int 21h + +Network_DriverScreenLoadFileNext: + Pop DS + Mov AH, 4Fh + Jmp Network_DriverScreenLoadFileNames1 + +Network_DriverScreenLoadFileNamesEnd: +; OK.. jump to network screen list + + Mov AX, 5 + Mov SI, 1 + Mov CX, Object1 + + Mov DX, Offset O1_LoadNetworkDriver + Ret + +EndP Network_DriverScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_DrawDriverScreen Far + + Push CS + Pop DS + Assume DS:Disk + + Call S_GetDestination ; Gets ES + + Cmp [NumDrivers], 0 + JNE Network_DrawDriverScreen1 + + Mov DI, (27+29*80)*2 ; (6, 13) + Mov SI, Offset NoDriverMsg + + Mov AH, 3 + Call S_DrawString + + Ret + +Network_DrawDriverScreen1: + Mov AX, 168+200h + Mov DI, (13*80+15)*2 + Mov CX, 36 + +Network_DrawDriverScreen2: + StosW + Add DI, 158 + Loop Network_DrawDriverScreen2 + + Mov SI, [TopDriver] + Mov DX, [NumDrivers] + Mov BX, [CurrentDriver] + +; Need to make sure they're within bounds. + Cmp BX, SI + JAE Network_DrawDriverScreenClip1 + + Mov SI, BX + +Network_DrawDriverScreenClip1: + LEA DI, [SI+35] + Cmp BX, DI + JBE Network_DrawDriverScreenClip2 + + LEA SI, [BX-35] + +Network_DrawDriverScreenClip2: + Mov DI, (13*80+2)*2 + Mov [TopDriver], SI + + Sub DX, SI + JZ Network_DrawDriverScreenEnd + + ShL SI, 7 + Mov DS, [DiskDataArea] + Assume DS:Nothing + + Cmp DX, 36 + JB Network_DrawDriverScreenClip + + Mov DX, 36 + +Network_DrawDriverScreenClip: + Mov AH, 3 + Mov CX, 13 + +Network_DrawDriverScreenFileNames: + LodsB + StosW + Loop Network_DrawDriverScreenFileNames + +; Add DI, 2 + ScasW + + Mov CX, 62 + +Network_DrawDriverScreenDriverName: + LodsB + StosW + Loop Network_DrawDriverScreenDriverName + + Add SI, 128-62-13 + Add DI, 8 + + Dec DX + JNZ Network_DrawDriverScreenClip + +Network_DrawDriverScreenEnd: + Ret + +EndP Network_DrawDriverScreen + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_PreDriverScreen Far + + Push CS + Pop DS + Assume DS:Disk + + Cmp [NumDrivers], 0 + JE Network_PreDriverScreenEnd + + Mov AX, [CurrentDriver] + Sub AX, [TopDriver] + Add AX, 13 + Mov BX, 160 + Mul BX + + Call S_GetDestination + + LEA DI, [EAX+4] + Mov CX, 76 + +Network_PreDriverScreen1: + Mov AX, [ES:DI] + Mov AH, 30h + Cmp CX, 76-13 + JNE Network_PreDriverScreen2 + + Mov AH, 32h + +Network_PreDriverScreen2: + StosW + Loop Network_PreDriverScreen1 + +Network_PreDriverScreenEnd: + Ret + +EndP Network_PreDriverScreen + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_Up Far + Assume DS:Disk + + Sub [CurrentDriver], 1 + AdC [CurrentDriver], 0 + + Mov AX, 1 + Ret + +EndP Network_Up + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_Down Far + + Mov AX, [CurrentDriver] + Inc AX + Cmp AX, [NumDrivers] + JAE Network_Down1 + + Mov [CurrentDriver], AX + +Network_Down1: + Mov AX, 1 + Ret + +EndP Network_Down + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_PostDriverScreen Far + +; Has to handle up, down, Enter. + + Push CS + Pop DS + Assume DS:Disk + + Mov SI, Offset NetworkKeys + Call M_FunctionDivider + JC Network_PostDriverScreen1 + + Jmp [Word Ptr SI] + +Network_PostDriverScreen1: + Xor AX, AX + Ret + +EndP Network_PostDriverScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_LoadDriver Far + Assume DS:Disk + +; Allocate EMS memory buffers first + + Cmp NetworkEMSHandle, 1 + JAE Network_LoadDriverMemoryAlreadyAllocated + + Call E_GetEMSVersion + Cmp AL, 40h + JB Network_LoadDriverInsufficientMemory + + ; Carry flag set -> essential allocation + StC + Mov EAX, 384*1024 + Call E_AllocateEMS + Test AX, AX + JNZ Network_LoadDriverMemoryOK + +Network_LoadDriverInsufficientMemory: + Jmp PEFunction_OutOfMemoryMessage + +Network_LoadDriverMemoryOK: + Mov NetworkEMSHandle, AX + +Network_LoadDriverMemoryAlreadyAllocated: + Cmp NetworkSendEMSHandle, 1 + JAE Network_LoadDriverSendEMSHandleAlreadyAllocated + + Mov EAX, 64*1024 + Call E_AllocateEMS + Test AX, AX + JZ Network_LoadDriverInsufficientMemory + + Mov NetworkSendEMSHandle, AX + +Network_LoadDriverSendEMSHandleAlreadyAllocated: + Cmp SendqueueSegment, 0 + JNE Network_LoadDriverMemoryAlreadyAllocated2 + + Mov AH, 48h + Mov BX, 1024 + Int 21h ; Allocate 16kb of memory for the SendQueue + JC Network_LoadDriverInsufficientMemory + + Mov SendQueueSegment, AX + +Network_LoadDriverMemoryAlreadyAllocated2: + Xor EAX, EAX + Mov DWord Ptr [SendDataQueueTail], EAX + Mov DWord Ptr [Destination], EAX + + Mov AX, [NumDrivers] + Mov DX, [CurrentDriver] + + Test AX, AX + JNZ Network_LoadDriver1 + + Ret + +Network_LoadDriver1: + ShL DX, 7 + Mov DS, [DiskDataArea] + Assume DS:Nothing + Mov DI, DX + +; Try allocating memory first. + Mov BX, [DI+13+62] ; Bytes to read + Mov AH, 48h + Add BX, 15 + ShR BX, 4 ; BX = number of parags required. + Int 21h + JNC Network_LoadDriver2 + + Jmp PEFunction_OutOfMemoryMessage + +Network_LoadDriver2: + Mov ES, AX + Mov [CS:DriverSegment], AX + + Mov AX, 3D00h + Int 21h ; Open file + JC Network_LoadDriver3 + + Mov BX, AX + Mov AX, 4200h + Xor CX, CX + Mov DX, 128 + Int 21h + JC Network_LoadDriver4 + + Mov AH, 3Fh + Mov CX, [DI+13+62] + Mov DS, [CS:DriverSegment] + Xor DX, DX + Int 21h ; Read driver + JC Network_LoadDriver4 + + Push CS + Pop DS + Assume DS:Disk + + Mov AH, 3Fh + Mov CX, NUMPROVIDEDVARIABLES + Mov DX, Offset NetworkDriverVariables + Int 21h + JC Network_LoadDriver4 + + Mov AH, 3Fh + Mov CX, NUMPROVIDEDFUNCTIONS*2 + Mov DX, Offset NetworkDriverFunctions+NUMPROVIDEDFUNCTIONS*2 + Int 21h + JC Network_LoadDriver4 + + Mov AH, 3Eh + Int 21h ; Close file. + +; Setup tables + Mov SI, Offset NetworkRequiredVariables + Xor DI, DI + Mov CX, NUMREQUIREDVARIABLES+4*NUMREQUIREDFUNCTIONS + Rep MovsB + + Mov AX, ES + Push DS + Pop ES + Mov SI, DX + Mov DI, Offset NetworkDriverFunctions + Mov CX, NUMPROVIDEDFUNCTIONS + ShL EAX, 16 + +Network_LoadDriver5: + LodsW + StosD + Loop Network_LoadDriver5 + +; Initialise Send/Receive buffers. + Mov DX, CS:NetworkEMSHandle + Mov CL, 512/16 + Mov CH, 28 + Call E_GetEMSPageFrame + Mov ES, AX + +Network_InitialiseBuffers1: + Call E_MapEMSMemory + Mov DWord Ptr [ES:65532], 0 + Sub CH, 4 + JNS Network_InitialiseBuffers1 + +; Should jump to network initialise function now. + + Jmp NetworkDriver_Initialise + Assume DS:Nothing + +Network_LoadDriver4: + Mov AH, 3Eh + Int 21h + +Network_LoadDriver3: + Jmp Network_UnloadDriver + +EndP Network_LoadDriver + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_UnloadDriver Far + + Push CS + Push CS + Pop DS + Pop ES + Assume DS:Disk + + Mov SI, Offset NetworkDriverUnloaded + Call SetInfoLine + + Mov AH, 49h + Mov ES, [DriverSegment] + Int 21h + + Mov [DriverSegment], 0 + + Mov AH, 49h + Mov ES, SendQueueSegment + Int 21h + + Mov SendQueueSegment, 0 + + Push CS + Pop ES + + Mov AX, CS + ShL EAX, 16 + Mov AX, Offset Network_EmptyFunction + Mov DI, Offset NetworkDriverFunctions + Mov CX, NUMPROVIDEDFUNCTIONS + Rep StosD + + Jmp Network_DriverScreen + +EndP Network_UnloadDriver + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +; PatternCycle DW 0 + +Proc Network_Poll Far + +Comment ~ + Mov AX, CS:PatternCycle + Inc AX + Cmp AX, 200 + JB Network_Poll1 + + Xor AX, AX + +Network_Poll1: + Mov CS:PatternCycle, AX + + Call Network_UpdatePatternIfIdle +~ + Jmp NetworkDriver_Update + +EndP Network_Poll + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_DecodeUserName Far ; Given DS:SI = name + ; CX = count (including key) + + Test CX, CX + JZ Network_DecodeUserName3 + + Mov BX, CX + Xor DX, DX + +Network_DecodeUserName1: + LodsB + Add DL, AL + StosB + Xor DH, DL + Loop Network_DecodeUserName1 + + Add DX, 0FFFFh + JC Network_UnloadDriver + + Sub SI, BX + Mov CX, BX + + Xor AH, AH +Network_DecodeUserName2: + LodsB + Add AH, AL + XChg AL, AH + Xor AL, 0AAh + RoR AL, 2 + Mov [SI-1], AL + Loop Network_DecodeUserName2 + +Network_DecodeUserName3: + Mov CS:DriverValidated, 1 + +Network_DecodeUserNameEnd: + Ret + +EndP Network_DecodeUserName + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_Shutdown Far + + Mov AX, CS:NetworkEMSHandle + Test AX, AX + JZ Network_Shutdown1 + + Call E_ReleaseEMS + +Network_Shutdown1: + Mov AX, CS:NetworkSendEMSHandle + Test AX, AX + JZ Network_Shutdown2 + + Call E_ReleaseEMS + +Network_Shutdown2: + Jmp NetworkDriver_Shutdown + +EndP Network_Shutdown + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ +; +; Internal structures +; ------------------- +; +; SendBuffer is the raw data to transmit: +; Offset Size Contents Notes +; 0 DWord Block Header ID 'JLNP' - "J.L. Network Protocol" +; 4 Word Block Size Byte count, includes headers +; and CRC check. +; 6 Byte Block Type +; 7 <...> Data Maximum of 65000 bytes +; Word CRC Calculated +; +; Block types. +; +; SendQueue contains a queue of objects to transmit. +; Structure: +; Offset Size Contents Notes +; 0 Byte Destination 0=all, 1-3=specific, others=ignore +; 1 Byte Object Type +; 2 <> Data +; +; Object types: +; 0: Partial pattern data +; Extra data: Pattern Number (1), Bounding Box (4), Data +; 1: Entire pattern +; Extra data: Pattern Number (1), Data (Compressed) +; 2: Request pattern +; Extra data: Pattern Number (1) +; 3: SongData information (includes order list + song parameters) +; Extra data: Length (2), Offset (2) +; 4: Instrument information +; Extra data: Instrument Number (1) +; 5: Sample information +; Extra data: Sample Number (1) +; 6: Pattern Length +; Extra data: Pattern Number (1), New MaxRow (1) +; 7: Delete sample +; Extra data: Sample Number (1) +; 8: New sample - sends length also +; Extra data: Sample Number (1) +; 9: Sample Data +; Extra data: Sample Number (1), Offset (4) + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_CalculateCRC + ; Calculates CRC and appends 6 byte header + + ; Given ES = EMSSegment + ; Given DI = end of data written + + Push DS + + Push ES + Pop DS + + Mov CX, DI + Xor SI, SI + LEA BX, [DI+2] + Xor DX, DX + Mov Word Ptr [SI+4], BX + Xor AX, AX + Mov DWord Ptr [SI], 'JLNP' + +Network_CalculateCRC1: + LodsB + Add DH, AL + Xor DL, DH + Loop Network_CalculateCRC1 + +; Have DH = sum, DL = xor of running sum. +; Want to have DX = 0 after next two bytes +; second last byte = DL-DH +; last byte = -DL + + Sub AH, DL ; AH = -DL + Sub DL, DH ; DL = DL-DH + Mov AL, DL ; AL = DL-DH + + StosW + Mov CS:SendBufferOffset, 0 + Mov CS:SendBufferRemaining, BX + + Pop DS + + Ret + +EndP Network_CalculateCRC + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_GetSendBufferPage Near + ; Returns AX = EMSPageFrame + + Push CX + Push DX + + Mov CX, EMS_SENDBUFFERPAGE + Mov DX, CS:NetworkSendEMSHandle + Call E_MapEMSMemory + Call E_GetEMSPageFrame + + Pop DX + Pop CX + + Ret + +EndP Network_GetSendBufferPage + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +; Send Procedure Jump Table +; Each procedure is given DS:SI = Send queue data +; ES:DI = Send buffer +; Each procedure only need write to ES:DI. +; Count of bytes is taken from return value of DI, CRC+Header will be appended +; Can use AX, BX, CX, DX, DS, SI +; Must update CS:SendDataQueueHead + +NUMBEROFBLOCKTYPES EQU 10 + +ConvertQueueObjectTypes DW Offset SendNetworkBlock0 + DW Offset SendNetworkBlock1 + DW Offset SendNetworkBlock2 + DW Offset SendNetworkBlock3 + DW Offset SendNetworkBlock4 + DW Offset SendNetworkBlock5 + DW Offset SendNetworkBlock6 + DW Offset SendNetworkBlock7 + DW Offset SendNetworkBlock8 + DW Offset SendNetworkBlock9 + +; Receive Procedure Jump Table +; Given DS = Receive buffer +; Can use any register + +InterpretObjectTypes DW Offset ReceiveNetworkBlock0 + DW Offset ReceiveNetworkBlock1 + DW Offset ReceiveNetworkBlock2 + DW Offset ReceiveNetworkBlock3 + DW Offset ReceiveNetworkBlock4 + DW Offset ReceiveNetworkBlock5 + DW Offset ReceiveNetworkBlock6 + DW Offset ReceiveNetworkBlock7 + DW Offset ReceiveNetworkBlock8 + DW Offset ReceiveNetworkBlock9 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; +; Block Type 0 notes +; +; If first byte is between 80 and EF, then Val & 7F rows down are empty +; If first byte is between F0 and F7, then +; note field is empty, other fields are: +; Val & 1, ins present +; Val & 2, vol present +; Val & 4, eff present +; +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock0 Near + +; Block type 0 +; Offset 0: Pattern Number +; 1: Channel +; 2: Row +; 3: Width +; 4: Height + + LodsB + StosB + Mov DX, AX ; DL = Pattern Number + LodsW + StosW + Mov CX, AX ; CL = Channel, CH = Row + LodsW + Mov BX, AX ; BL = Width, BH = Height + + Mov CS:SendDataQueueHead, SI + + Push Pattern + Pop DS + Assume DS:Pattern + + Cmp DL, Byte Ptr PatternNumber ; Still editing the pattern? + JE SendNetworkBlock0_0 + + Xor AX, AX + StosW + + Ret + +SendNetworkBlock0_0: + StosW + Mov DS, PatternDataArea + Assume DS:Nothing + + Mov AL, 64 + Mul CH + Add AL, CL + LEA ESI, [EAX*4+EAX] + +SendNetworkBlock0_1: + Push BX + Push SI + + Xor DX, DX ; DL = num empty rows + +SendNetworkBlock0_2: + Push SI + + Cmp Byte Ptr [SI], 0FDh + JNE SendNetworkBlock0_3 + Cmp DWord Ptr [SI+1], 0000FF00h + JNE SendNetworkBlock0_3 + + Inc DX + Cmp DL, 6Fh + JB SendNetworkBlock0_NextCell + + Mov AL, 80h + Add AL, DL + StosB + Xor DX, DX + Jmp SendNetworkBlock0_NextCell + +SendNetworkBlock0_3: + Test DX, DX + JZ SendNetworkBlock0_4 + + Mov AL, 80h + Add AL, DL + StosB + Xor DX, DX + +SendNetworkBlock0_4: + LodsB + Cmp AL, 0FDh ; Empty note? + JE SendNetworkBlock0_5 + + StosB + MovsD + Jmp SendNetworkBlock0_NextCell + +SendNetworkBlock0_5: + Push BX + + Mov BX, DI + StosB ; Increment.. needs to be filled later + + Mov CL, 0F0h + LodsB + Test AL, AL ; instrument + JZ SendNetworkBlock0_6 + + StosB + Or CL, 1 + +SendNetworkBlock0_6: ; Volume + LodsB + Cmp AL, 0FFh + JE SendNetworkBlock0_7 + + StosB + Or CL, 2 + +SendNetworkBlock0_7: ; Effect + LodsW + Test AX, AX + JZ SendNetworkBlock0_8 + + StosW + Or CL, 4 + +SendNetworkBlock0_8: + Mov [ES:BX], CL + + Pop BX + +SendNetworkBlock0_NextCell: + Pop SI + Add SI, 320 + + Dec BH + JNZ SendNetworkBlock0_2 + + Test DX, DX + JZ SendNetworkBlock0_9 + + Mov AL, 80h + Or AL, DL + StosB + +SendNetworkBlock0_9: + Pop SI + Pop BX + + Add SI, 5 ; Next column + + Dec BL + JNZ SendNetworkBlock0_1 + + Ret + +EndP SendNetworkBlock0 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock0 Near + + Push Pattern + Pop ES + Assume ES:Pattern + + Mov [Word Ptr ES:Modified], 101h + + Mov AL, [DS:07h] ; AL = Pattern Number + + Cmp AL, [Byte Ptr ES:PatternNumber] + JNE ReceiveNetworkBlock0_1 + + Mov ES, [ES:PatternDataArea] + Assume ES:Nothing + + Mov CX, [DS:08h] ; CL = Channel, CH = Row + Mov BX, [DS:0Ah] ; BL = Width, BH = Height + + Test BX, BX + JZ ReceiveNetworkBlock0_1 + + Mov AL, 64 + Mul CH + Add AL, CL + LEA EDI, [EAX*4+EAX] + Mov AL, 5 + + Mul BL + Mov SI, 0Ch + +ReceiveNetworkBlock0_0: + Push BX + Push DI + +ReceiveNetworkBlock0_3: + LodsB + Cmp AL, 80h + JB ReceiveNetworkBlock0_4 + Cmp AL, 0F8h + JAE ReceiveNetworkBlock0_4 + + Cmp AL, 0F0h + JAE ReceiveNetworkBlock0_6 + +; Empty rows here. + And AL, 7Fh + Sub BH, AL + +ReceiveNetworkBlock0_11: + Mov Byte Ptr [ES:DI], 0FDh + Mov DWord Ptr [ES:DI+1], 0000FF00h + Add DI, 320 + Dec AL + JNZ ReceiveNetworkBlock0_11 + + Test BH, BH + JNZ ReceiveNetworkBlock0_3 + Jmp ReceiveNetworkBlock0_5 + +ReceiveNetworkBlock0_6: ; Partial row here. + Mov AH, AL + + Mov AL, 0FDh ; NONOTE + StosB + + Xor AL, AL + + Test AH, 1 + JZ ReceiveNetworkBlock0_7 + + LodsB + +ReceiveNetworkBlock0_7: + StosB + + Mov AL, 0FFh + Test AH, 2 + JZ ReceiveNetworkBlock0_8 + + LodsB + +ReceiveNetworkBlock0_8: + StosB + Test AH, 4 + Mov AX, 0 ; Don't erase flags + JZ ReceiveNetworkBlock0_9 + + LodsW + +ReceiveNetworkBlock0_9: + StosW + Jmp ReceiveNetworkBlock0_10 + +ReceiveNetworkBlock0_4: + StosB + MovsD + +ReceiveNetworkBlock0_10: + Add DI, 320-5 + + Dec BH + JNZ ReceiveNetworkBlock0_3 + +ReceiveNetworkBlock0_5: + + Pop DI + Pop BX + + Add DI, 5 + Dec BL + JNZ ReceiveNetworkBlock0_0 + + Ret + +ReceiveNetworkBlock0_1: ; Not the same, or zero width -> mark modified + +; DX = connection ID +; AL = Pattern number + + ; Sanity check + Cmp AL, 200 + JAE ReceiveNetworkBlock0_2 + + Mov BX, AX + Inc DX + And BX, 0FFh + Mov [CS:PatternModifiedTable+BX], DL + +ReceiveNetworkBlock0_2: + Ret + +EndP ReceiveNetworkBlock0 + Assume ES:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock1 + +; Block type 1 +; Offset 0: Pattern number + + Push FS + + Push Pattern + Pop FS + Assume FS:Pattern + + LodsB + Mov CS:SendDataQueueHead, SI + StosB + + And AX, 0FFh + +; Check whether request should be sent off to another node instead. +; AL = Pattern number + + Mov BX, AX + + Mov DH, [CS:PatternModifiedTable+BX] + + Test DH, DH + JZ SendNetworkBlock1_1 + + Mov CS:Destination, DH + Mov Byte Ptr [ES:DI-2], 2 ; NETWORK_REQUESTPATTERNOBJECT + + Jmp SendNetworkBlock1_2 + +SendNetworkBlock1_1: + Cmp AL, [Byte Ptr FS:PatternNumber] + JNE SendNetworkBlock1_0 + + Mov [FS:PatternModified], 0 + + PushAD + Push DS + Push ES + + Call PEFunction_StoreCurrentPattern + + Pop ES + Pop DS + PopAD + +SendNetworkBlock1_0: + Call Music_GetPatternLocation + ; Returns AX = handle + ; EBX = offset/segment (or page/segment) + ; CX = length (not including header) + ; DL = 0 for conv, 1 for EMS + + Push CS + Pop DS + Assume DS:Disk + + Add CX, 8 +; Setup EMS transfer + Mov TransferLength, CX + + Mov SourceType, DL + Mov SourceHandle, AX + Mov SourceOffset, EBX + + Mov AX, NetworkSendEMSHandle + Mov DestinationType, 1 + Mov DestinationHandle, AX + Mov [Word Ptr DestinationOffset], DI + Mov [Word Ptr DestinationOffset+2], 0 + +; Data is ready to go! + Mov AX, 5700h + Mov SI, Offset EMSTransferTable + Int 67h + + Add DI, CX + +SendNetworkBlock1_2: + Call Network_GetSendBufferPage + Mov ES, AX + + Pop FS + + Ret + +EndP SendNetworkBlock1 + Assume DS:Nothing, FS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock1 + + Push FS + + Push Music + Pop FS + Assume FS:Music + + Mov EDX, [DS:8] + Mov AL, [DS:7] + + And AX, 0FFh ; AX = Pattern Number + ; DX = length + +; Sanity check + Cmp AL, 200 + JAE ReceiveNetworkBlock1_2 + + Call Music_ReleasePattern + + Cmp EDX, 400040h + JE ReceiveNetworkBlock1_1 + + Push AX + + Add DX, 8 + Push DX + Push AX + + Mov SI, AX + Call Music_AllocatePattern + + Pop AX + Call Music_GetPatternLocationNoCount + +; Setup EMS transfer + Push CS + Pop DS + Assume DS:Disk + + Mov DestinationType, 1 + Mov DestinationHandle, AX + Mov DestinationOffset, EBX + + Pop DX + + Mov AX, NetworkEMSHandle + Mov CX, LastReceiveCX ; CH = page + Mov TransferLength, DX + ShR CX, 8 + Mov SourceType, 1 + Mov SourceHandle, AX + Mov [Word Ptr SourceOffset], 8 + Mov [Word Ptr SourceOffset+2], CX + +; Data is ready to go! + Mov AX, 5700h + Mov SI, Offset EMSTransferTable + Int 67h + + Pop AX + +; Mark it off as handled +; AX = Pattern number + +ReceiveNetworkBlock1_1: + Mov BX, AX + Mov [CS:PatternModifiedTable+BX], 0 + + Push Pattern + Pop DS + Assume DS:Pattern + + Cmp AL, [Byte Ptr DS:PatternNumber] + JNE ReceiveNetworkBlock1_0 + + Call PE_NewPattern + +ReceiveNetworkBlock1_0: + Cmp AL, [Byte Ptr FS:CurrentPattern] + JNE ReceiveNetworkBlock1_2 + + Call Music_UpdatePatternOffset + +ReceiveNetworkBlock1_2: + Pop FS + Ret + +EndP ReceiveNetworkBlock1 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock2 + + MovsB + Mov CS:SendDataQueueHead, SI + Ret + +EndP SendNetworkBlock2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock2 + + Mov AH, [DS:7] ; AH = pattern + Mov AL, 1 ; NETWORK_ENTIREPATTERNOBJECT + + ; Sanity check + Cmp AH, 200 + JAE ReceiveNetworkBlock2_1 + + Call Network_AddWordToQueue + +ReceiveNetworkBlock2_1: + Ret + +EndP ReceiveNetworkBlock2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock3 + + LodsW ; Length + StosW + Mov CX, AX + LodsW + StosW + Mov CS:SendDataQueueHead, SI + + Push SongData + Pop DS + Mov SI, AX + + Rep MovsB + + Ret + +EndP SendNetworkBlock3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock3 + + Push SongData + Pop ES + + Mov CX, [DS:7] + Mov DI, [DS:9] + Mov SI, 11 + + ; Sanity check + Mov AX, CX + Add AX, DI + + Cmp AX, 512 + JA ReceiveNetworkBlock3_1 + + Rep MovsB + +ReceiveNetworkBlock3_1: + Ret + +EndP ReceiveNetworkBlock3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock4 + + LodsB + StosB + And AX, 0FFh + Mov CS:SendDataQueueHead, SI + Add AX, AX + Mov SI, AX + + Push SongData + Pop DS + Mov SI, [64712+SI] + + Mov CX, 554/2 + Rep MovsW + +SendNetworkBlock4_1: + Ret + +EndP SendNetworkBlock4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock4 + + Mov DI, [DS:7] + And DI, 0FFh + Mov AX, DI ; AX = instrument + + ; Sanity check + Cmp AX, 100 + JAE ReceiveNetworkBlock4_1 + + Add DI, DI + + Push SongData + Pop ES + + Mov DI, [ES:64712+DI] + Mov SI, 8 + Mov CX, 554/2 + Rep MovsW + + Call PE_GetLastInstrument + Cmp AX, BX + JNE ReceiveNetworkBlock4_1 + + Call Glbl_GetCurrentMode + Cmp AL, 4 + JNE ReceiveNetworkBlock4_1 + + Call I_MapEnvelope + +ReceiveNetworkBlock4_1: + + Ret + +EndP ReceiveNetworkBlock4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock5 ; Does not send length or + ; sample pointer. + + LodsB + StosB + And AX, 0FFh + Mov CS:SendDataQueueHead, SI + Add AX, AX + Mov SI, AX + + Push SongData + Pop DS + Mov SI, [64912+SI] + + Add SI, 4 + Mov CX, 2Ch/2 + Rep MovsW + LodsW ; Skip length + LodsW + Mov CX, 14h/2 + Rep MovsW + LodsW + LodsW + MovsW + MovsW + + Ret + +EndP SendNetworkBlock5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock5 + + Mov DI, [DS:7] + And DI, 0FFh + + Cmp DI, 100 + JAE ReceiveNetworkBlock5_1 + + Add DI, DI + + Push SongData + Pop ES + + Mov DI, [ES:64912+DI] + Mov SI, 8 + ScasW + ScasW + Mov CX, 2Ch/2 + Rep MovsW + ScasW + ScasW + Mov CX, 14h/2 + Rep MovsW + ScasW + ScasW + MovsW + MovsW + +ReceiveNetworkBlock5_1: + Ret + +EndP ReceiveNetworkBlock5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock6 + + MovsW + Mov CS:SendDataQueueHead, SI + + Ret + +EndP SendNetworkBlock6 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock6 + + Mov AX, [DS:7] ; AL = pattern number, AH = numrows + + Push Pattern + Pop DS + Assume DS:Pattern + + Cmp AL, [Byte Ptr PatternNumber] + JNE ReceiveNetworkBlock6_1 + + Cmp AH, 200 + JAE ReceiveNetworkBlock6_2 + + Mov [Byte Ptr MaxRow], AH + +ReceiveNetworkBlock6_2: + Ret + +ReceiveNetworkBlock6_1: + Jmp ReceiveNetworkBlock0_1 ; Marks pattern as modified. + +EndP ReceiveNetworkBlock6 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock7 + + MovsB + Mov CS:SendDataQueueHead, SI + Ret + +EndP SendNetworkBlock7 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock7 + + Mov AL, [DS:7] + Mov AH, 1 + + Cmp AL, 100 + JAE ReceiveNetworkBlock7_1 + + Call Music_ReleaseSample + +ReceiveNetworkBlock7_1: + Ret + +EndP ReceiveNetworkBlock7 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock8 ; New sample + + MovsB + MovsD + Mov CS:SendDataQueueHead, SI + + Ret + +EndP SendNetworkBlock8 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock8 ; New sample + +; Call Music_Stop + + Mov AX, [DS:7] + And AX, 0FFh ; AX = Sample number + + ; Sanity check + Cmp AX, 100 + JAE ReceiveNetworkBlock8_2 + + Mov SI, AX + Add SI, AX + Mov EDX, [DS:8] + + Push SongData + Pop DS + + Mov SI, [SI+64912] ; DS:SI = sample + Mov ECX, EDX + + Test Byte Ptr [SI+12h], 2 ; 16 bit? + JZ ReceiveNetworkBlock8_1 + + Add EDX, EDX + +ReceiveNetworkBlock8_1: + Call Music_AllocateSample + Mov [SI+30h], ECX + +ReceiveNetworkBlock8_2: + Ret + +EndP ReceiveNetworkBlock8 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetSampleLocation ; Given BX = EMS transfer structure + ; Given DX = sample number + ; Given ECX = offset + ; Returns carry if problem. + + PushAD + Push DS + + Push SongData + Pop DS + Mov SI, DX + Add SI, DX + Mov SI, [64912+SI] ; DS:SI = sample header + + Mov EAX, [SI+30h] + + Test Byte Ptr [SI+12h], 2 + JZ GetSampleLocation2 + + Add EAX, EAX + +GetSampleLocation2: + Cmp EAX, ECX + JB GetSampleLocation1 + + Mov EDX, EAX + Sub EDX, ECX + Cmp EDX, 32768 + JB GetSampleLocation6 + + Mov DX, 32768 + +GetSampleLocation6: + Mov [CS:TransferLength], DX + + Cmp Byte Ptr [SI+48h], 1 + JB GetSampleLocation1 + JA GetSampleLocation4 + +GetSampleLocation3: ; Conventional memory + Mov Byte Ptr [CS:BX], 0 ; type + Mov DWord Ptr [CS:BX+1], 0 ; handle,Offset + ShR ECX, 4 + Add CX, [SI+4Ah] + Mov Word Ptr [CS:BX+5], CX ; segment + + Jmp GetSampleLocation5 + +GetSampleLocation4: ; Expanded memory + Mov AX, [SI+4Ah] + Mov Byte Ptr [CS:BX], 1 + Mov Word Ptr [CS:BX+1], AX ; handle + Mov AX, CX + ShR ECX, 14 + And AX, 3FFFh + Mov [CS:BX+3], AX ; Offset + Mov [CS:BX+5], CX ; Page + + Jmp GetSampleLocation5 + +GetSampleLocation1: + StC + +GetSampleLocation5: + Pop DS + PopAD + + Ret + +EndP GetSampleLocation + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc SendNetworkBlock9 + + LodsB + StosB + Mov DX, AX + LodsD + StosD + Mov ECX, EAX + And DX, 0FFh + Mov CS:SendDataQueueHead, SI + + Mov BX, Offset SourceType + Call GetSampleLocation + JC SendNetworkBlock9_1 + + Push CS + Pop DS + Assume DS:Disk + + Mov AX, NetworkSendEMSHandle + Mov DestinationType, 1 + Mov DestinationHandle, AX + Mov [Word Ptr DestinationOffset], DI + Mov [Word Ptr DestinationOffset+2], 0 + + Add DI, TransferLength + +; Data is ready to go! + Mov AX, 5700h + Mov SI, Offset EMSTransferTable + Int 67h + + Ret + +SendNetworkBlock9_1: + Sub DI, 5 + + Ret + +EndP SendNetworkBlock9 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReceiveNetworkBlock9 + + Mov DX, [DS:7] + Mov ECX, [DS:8] + And DX, 0FFh + Mov BX, Offset DestinationType + Mov AX, NetworkEMSHandle + Mov SI, LastReceiveCX ; CH = page + + ; Sanity Check + Cmp DX, 100 + JAE ReceiveNetworkBlock9_1 + + Call GetSampleLocation + JC ReceiveNetworkBlock9_1 + + Push CS + Pop DS + Assume DS:Disk + + ShR SI, 8 + Mov SourceType, 1 + Mov SourceHandle, AX + Mov [Word Ptr SourceOffset], 12 + Mov [Word Ptr SourceOffset+2], SI + +; Data is ready to go! + Mov AX, 5700h + Mov SI, Offset EMSTransferTable + Int 67h + +ReceiveNetworkBlock9_1: + Ret + +EndP ReceiveNetworkBlock9 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_SendData Far +; Called by driver when it is able to send data +; +; Provided: AX = number of bytes it can send. +; ES:DI = buffer location +; +; Returns: CX = number of bytes to send, 0 if no data. +; DX = receiver's connection ID. 0 = all, 1->3 = specific. + + PushF + CLI + Push DS + Push ES + Push DI + + Push AX + Push DX + + Mov AH, 47h + Mov DX, CS:NetworkSendEMSHandle + Int 67h + + Test AH, AH + + Pop DX + Pop AX + + JNZ Network_SendDataError + + Cmp CS:DriverValidated, 1 + JNE Network_SendDataError + + Mov CX, CS:SendBufferRemaining + Test CX, CX + JNZ Network_SendData1 + +; Need to get a new block of data into the buffer. + +Network_SendData3: + Mov CX, CS:SendDataQueueTail + Mov SI, CS:SendDataQueueHead + + Sub CX, SI + JZ Network_SendDataEnd + + Mov DS, SendQueueSegment + Assume DS:Nothing + + Push AX + Push BX + Push BP + Push ES + Push DI + Push FS + +; Mov DX, CS:NetworkEMSHandle +; Call E_SavePageFrame + + Call Network_GetSendBufferPage + Mov ES, AX + Mov DI, 6 + + LodsB + Mov CS:Destination, AL + LodsB + StosB + Mov BL, AL + And BX, 0FFh + Add BX, BX + Call [CS:ConvertQueueObjectTypes+BX] + Call Network_CalculateCRC + + Cmp [CS:SendDataQueueHead], 16384-16 + JB Network_SendData4 + + Mov [CS:SendDataQueueHead], 0 + +Network_SendData4: + + Mov CX, BX ; CX = SendBufferRemaining + + Pop FS + Pop DI + Pop ES + Pop BP + Pop BX + Pop AX + +; Push DX +; Mov DX, CS:NetworkEMSHandle +; Call E_RestorePageFrame +; Pop DX + + Cmp CX, 9 + JA Network_SendData1 + + Mov DWord Ptr [CS:SendBufferRemaining], 0 + Jmp Network_SendData3 + +Network_SendData1: ; Send buffer has data remaining + Mov SI, CS:SendBufferOffset + + Cmp CX, AX + JB Network_SendData2 + + Mov CX, AX + +Network_SendData2: + Add CS:SendBufferOffset, CX + Sub CS:SendBufferRemaining, CX + + Call Network_GetSendBufferPage + Mov DS, AX + + Xor DX, DX + Push CX + Rep MovsB + Pop CX + Mov DL, CS:Destination + +Network_SendDataEnd: + Push DX + + Mov AH, 48h + Mov DX, CS:NetworkSendEMSHandle + Int 67h + + Pop DX + + Pop DI + Pop ES + Pop DS + PopF + + Ret + +Network_SendDataError: + Pop DI + Pop ES + Pop DS + PopF + + Xor CX, CX + Xor DX, DX + Ret + +EndP Network_SendData + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ReceiveToBlock DB 0, 8, 16 + +; EMS layout: +; EMS:65532: Check word +; EMS:65534: Buffer Offset + +Proc Network_ReceiveData Far +; Called by driver when data is received +; +; Provided: DS:SI = data block received +; BX = sender's connection ID (0->2) +; CX = byte count received + + PushF + CLI + Push CX + + Mov AH, 47h + Mov DX, CS:NetworkEMSHandle + Int 67h + + Test AH, AH + JNZ Network_ReceiveData3 +; Call E_SavePageFrame + + Cmp CS:DriverValidated, 1 + JNE Network_ReceiveData3 + + Mov CL, 512/16 + Mov CH, [CS:ReceiveToBlock+BX] + Mov CS:LastReceiveCX, CX + Call E_MapEMSMemory + + Call E_GetEMSPageFrame + + Pop CX + + Mov ES, AX + Mov DI, [ES:65534] + +; Consistency check -> if at start of block, make sure that the header contains +; 'JLNP' + + Test DI, DI + JNZ Network_ReceiveData1 + + Cmp DWord Ptr [SI], 'JLNP' + JNE Network_ReceiveDataEnd + +Network_ReceiveData1: + Mov DX, [ES:65532] + +; Assume OK.. now place data into buffer, updating check word. +Network_ReceiveData2: + LodsB + Add DL, AL + StosB + Xor DH, DL + Loop Network_ReceiveData2 + + Cmp DI, [ES:4] + JAE Network_ReceiveDataBlockFinished + + Mov [ES:65532], DX + Mov [ES:65534], DI + +Network_ReceiveDataEnd: + Mov AH, 48h + Mov DX, CS:NetworkEMSHandle + Int 67h +; Mov DX, CS:NetworkEMSHandle +; Call E_RestorePageFrame + + PopF + + ClC + + Ret + +Network_ReceiveDataBlockFinished: + Xor Byte Ptr [CS:ReceiveToBlock+BX], 4 + Mov DWord Ptr [ES:65532], 0 + Test DX, DX + JNZ Network_CRCFail ; CRC check failed + +; ********************* Need to handle block types here. + PushAD + Push DS + + Push ES + Pop DS + + Mov SI, [DS:6] + And SI, 0FFh + + Cmp SI, NUMBEROFBLOCKTYPES + JAE Network_ReceiveDataBlockError + + Add SI, SI + Mov DX, BX + Call [InterpretObjectTypes+SI] + +Network_ReceiveDataBlockError: + Pop DS + PopAD + Jmp Network_ReceiveDataEnd + +Network_CRCFail: + Mov AH, 48h + Mov DX, CS:NetworkEMSHandle + Int 67h + Push CX + +Network_ReceiveData3: + Pop CX + PopF + + StC + + Ret + +EndP Network_ReceiveData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_GetSendQueue Far + + PushAD + PushF + Push DS + Push ES + + Sub SP, 4 + Push BP + Mov BP, SP + Mov EDI, [BP+44] + Mov [BP+2], EDI + Pop BP + + Push AX + Push DS + + ClI + + Push CS + Pop DS + Assume DS:Disk + +Comment ~ + This code is incomplete + Mov AX, SendDataQueueTail + Sub AX, SendDataQueueHead + Cmp AX, 16384-16 + JB Network_GetSendQueue2 + + Call [NetworkDriver_UnloadDriver] + + Xor AX, AX + Jmp Network_GetSendQueue1 + +Network_GetSendQueue2: +~ + Call [NetworkDriver_ConnectionStatus] + Mov DI, [SendQueueSegment] + Or AX, DI + Mov ES, DI + Mov DI, [SendDataQueueTail] + +Network_GetSendQueue1: + Pop DS + Pop AX + + Ret + +EndP Network_GetSendQueue + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_FinishedSendQueue Far + + Cmp DI, 16384-16 ; 16 bytes slack area + JB Network_FinishedSendQueue1 + + Xor DI, DI + +Network_FinishedSendQueue1: + Mov [CS:SendDataQueueTail], DI + Mov BP, SP + Pop EAX + Mov [BP+42], EAX + +IF SHOWQUEUESIZE + Push CS + Pop DS + Mov AX, SendDataQueueTail + Sub AX, SendDataQueueHead + Mov SI, Offset DebugMessage + Call SetInfoLine +ENDIF + + Pop ES + Pop DS + PopF + PopAD + + Ret + +EndP Network_FinishedSendQueue + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_NewConnection Far ; Called when this computer + ; joins a group + + PushA + Push ES + + Push CS + Pop ES + + Mov CX, 200/2 ; Mark all patterns as requiring + ; update from host connection + Mov DI, Offset PatternModifiedTable + Mov AX, 101h + Rep StosW + + Call Music_Stop + Call D_ClearFileName + + Pop ES + PopA + Ret + + +EndP Network_NewConnection + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ResetDI + + Cmp DI, 16384-16 + JB ResetDI1 + + Xor DI, DI + +ResetDI1: + Ret + +EndP ResetDI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_QueueSampleData Far ; Given CX = Sample number, 0 base + ; DL = ConnectionID + + Push EAX + Push EBX + Push ECX + Push DX + Push SI + Push DS + + Push SongData + Pop DS + + Call Network_GetSendQueue + JZ Network_QueueSampleData2 + + Mov SI, CX + Add SI, CX + Mov SI, [SI+64912] ; DS:SI = sample + + Test Byte Ptr [SI+12h], 1 + JZ Network_QueueSampleData2 + + Mov EBX, [SI+30h] + Test EBX, EBX + JZ Network_QueueSampleData2 + + Mov AL, DL + Mov AH, 8 + StosW + Mov AL, CL + StosB + Mov EAX, EBX ; Length + StosD + Call ResetDI + + Mov DH, CL + + Xor ECX, ECX + Test Byte Ptr [SI+12h], 2 + JZ Network_QueueSampleData1 + + Add EBX, EBX + +Network_QueueSampleData1: + Mov AL, DL + Mov AH, 9 + StosW + Mov AL, DH + StosB + Mov EAX, ECX + StosD + Call ResetDI + + Add ECX, 32768 + Cmp ECX, EBX + JB Network_QueueSampleData1 + +Network_QueueSampleData2: + Call Network_FinishedSendQueue + + Pop DS + Pop SI + Pop DX + Pop ECX + Pop EBX + Pop EAX + + Ret + +EndP Network_QueueSampleData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_EstablishConnection Far ; Called when a connection is + ; made to this computer +; Called when a successful connection is made +; Given AL = new connection number + +; This basically adds all samples, instruments, patterns, +; and order list to the send queue (or requests to the appropriate nodes) + + PushA + Push DS + Push ES + + Mov ES, CS:SendQueueSegment + Mov DI, CS:SendDataQueueTail + +; Send Patterns + Xor CX, CX + Mov DX, AX + +Network_EstablishConnection1: ; 3 * 200 bytes + Mov AL, DL ; Destination + Mov AH, 1 ; NETWORK_ENTIREPATTERNOBJECT + StosW + Mov AL, CL + StosB + Call ResetDI + Inc CX + Cmp CX, 200 + JB Network_EstablishConnection1 + +; Send Instruments + Xor CX, CX + +Network_EstablishConnection2: ; 3 * 100 bytes + Mov AL, DL ; Destination + Mov AH, 4 + StosW + Mov AL, CL + StosB + Call ResetDI + Inc CX + Cmp CX, 100 + JB Network_EstablishConnection2 + +; Send Sample headers + Xor CX, CX + +Network_EstablishConnection3: ; 3 * 100 bytes + Mov AL, DL ; Destination + Mov AH, 5 + StosW + Mov AL, CL + StosB + Call ResetDI + Inc CX + Cmp CX, 100 + JB Network_EstablishConnection3 + +; Now send order list ; 6 bytes + Mov AL, DL ; Destination + Mov AH, 3 ; NETWORK_SONGDATAOBJECT + StosW + Mov AX, 512 ; Length + StosW + Xor AX, AX ; Offset + StosW + Call ResetDI + + Mov CS:SendDataQueueTail, DI + + Xor CX, CX + +Network_EstablishConnection4: + Call Network_QueueSampleData + + Inc CX + + Cmp CX, 100 + JB Network_EstablishConnection4 + +; Loop through patterns and make sure that no patterns are destined for new +; connection + + Push CS + Pop ES + + Mov CX, 200 + Mov DI, Offset PatternModifiedTable + +Network_EstablishConnection5: + Mov AL, [ES:DI] + Cmp AL, DL + JNE Network_EstablishConnection6 + + Xor AL, AL + +Network_EstablishConnection6: + StosB + Loop Network_EstablishConnection5 + + Pop ES + Pop DS + PopA + + Ret + +EndP Network_EstablishConnection + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_AddWordToQueue Far ; Given AX, broadcasts to all + + Call Network_GetSendQueue + JZ Network_AddWordToQueue0 + + Push AX + Xor AL, AL + StosB + Pop AX + StosW + +Network_AddWordToQueue0: + Call Network_FinishedSendQueue + Ret + +EndP Network_AddWordToQueue + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_UpdatePatternIfIdle Far + + Cmp CS:SendQueueSegment, 0 + JE Network_UpdatePatternEnd + + Push AX + Mov AX, CS:SendDataQueueTail + Cmp AX, CS:SendDataQueueHead + Pop AX + JNE Network_UpdatePatternEnd + +Proc Network_UpdatePattern Far + + PushA + ; AX = pattern number +; Check whether it is current. +; AL = Pattern number + + Mov BX, AX + And BX, 0FFh + Xor AX, AX + + XChg [CS:PatternModifiedTable+BX], AL + Test AL, AL + JZ Network_UpdatePattern1 + +; AL = connection request + Call Network_GetSendQueue + JZ Network_UpdatePattern2 + + StosB + Mov AL, 2 ; NETWORK_REQUESTPATTERNOBJECT + Mov AH, BL + StosW + +Network_UpdatePattern2: + Call Network_FinishedSendQueue + +Network_UpdatePattern1: + PopA + +Network_UpdatePatternEnd: + Ret + +EndP Network_UpdatePattern + +EndP Network_UpdatePatternIfIdle + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_EnsureNoNetwork Far + + Push AX + Call [CS:NetworkDriver_ConnectionStatus] + Test AL, AL + Pop AX + JZ Network_EnsureNoNetwork1 + + Mov DI, Offset O1_NetworkErrorList + Mov CX, 2 + Call M_Object1List + + Mov AX, 1 + Add SP, 4 + +Network_EnsureNoNetwork1: + Ret + +EndP Network_EnsureNoNetwork + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_SendSampleHeader Far + + Call Network_GetSendQueue + JZ Network_SendSampleHeader1 + + Mov AX, 500h ; Sample header, broadcast + StosW + Call PE_GetLastInstrument + Mov AL, BL + StosB + +Network_SendSampleHeader1: + Call Network_FinishedSendQueue + Ret + +EndP Network_SendSampleHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_SendInstrumentHeader Far + + Call Network_GetSendQueue + JZ Network_SendInstrumentHeader1 + + Mov AX, 400h ; Instrument header, broadcast + StosW + Call PE_GetLastInstrument + Mov AL, BL + StosB + +Network_SendInstrumentHeader1: + Call Network_FinishedSendQueue + Ret + +EndP Network_SendInstrumentHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Network_SendSongDataInformation Far ; CX = Count, DX = offset + + Call Network_GetSendQueue + JZ Network_SendSongDataInformation1 + + Mov AX, 300h + StosW + Mov AX, CX + StosW + Mov AX, DX + StosW + +Network_SendSongDataInformation1: + Call Network_FinishedSendQueue + Ret + +EndP Network_SendSongDataInformation + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndS + +ENDIF + +End diff --git a/IT_OBJ1.ASM b/it_obj1.s similarity index 97% rename from IT_OBJ1.ASM rename to it_obj1.s index c825fa7..b12dfb8 100644 --- a/IT_OBJ1.ASM +++ b/it_obj1.s @@ -1,8902 +1,8902 @@ - Jumps - -include switch.inc - - Extrn D_SaveInstrument:Far - Extrn D_LSCheckLoopValues:Far - Extrn D_LSCheckSusLoopValues:Far - - Extrn D_PreLoadSampleWindow:Far - Extrn D_DrawLoadSampleWindow:Far - Extrn D_PostLoadSampleWindow:Far - - Extrn D_LSDrawDriveWindow:Far - Extrn D_LSPreDriveWindow:Far - Extrn D_LSPostDriveWindow:Far - - Extrn D_LIDrawDriveWindow:Far - Extrn D_LIPreDriveWindow:Far - Extrn D_LIPostDriveWindow:Far - - Extrn D_SaveSample:Far - Extrn D_SaveRawSample:Far - Extrn D_SaveST3Sample:Far - - Extrn D_GetFormatType:Far - - Extrn D_SlowSampleSort:Far - Extrn D_SlowInstrumentSort:Far - Extrn D_SaveDirectoryConfiguration:Far - Extrn D_LoadSampleNames:Far - Extrn D_LoadSongNames:Far - Extrn D_DrawFileWindow:Far - Extrn D_DrawDirectoryWindow:Far - Extrn D_DrawDriveWindow:Far - Extrn D_PreFileWindow:Far - Extrn D_SaveModule:Far - Extrn D_PostFileLoadWindow:Far - Extrn D_PostFileSaveWindow:Far - Extrn D_PreDirectoryWindow:Far - Extrn D_PostDirectoryWindow:Far - Extrn D_PostViewSampleLibrary:Far - Extrn D_PreDriveWindow:Far - Extrn D_PostDriveWindow:Far - Extrn D_PostSaveDriveWindow:Far - Extrn D_NewDirectory:Far - Extrn D_NewSpecifier:Far - -IF TUTORIAL -ELSE - Extrn D_LoadXM:Far - Extrn D_LoadS3M:Far - Extrn D_LoadMOD:Far - Extrn D_LoadIT:Far - Extrn D_LoadMTM:Far - Extrn D_Load669:Far -ENDIF - Extrn D_DrawHeader:Far - Extrn D_SaveIT:Far - Extrn D_SaveS3M:Far - Extrn D_SaveSong:Far - Extrn Quit:Far - - Extrn D_DrawLoadInstrument:Far - Extrn D_PreLoadInstrument:Far - Extrn D_PostLoadInstrument:Far - Extrn D_LoadInstrumentNames:Far - Extrn D_ViewInstrument:Far - -IF EMSDEBUG - - Extrn E_DumpEMSMemory:Far - -ENDIF - - Extrn LSWindow_Up:Far - Extrn LSWindow_Down:Far - - Extrn SongDirectory:Byte - Extrn FileSpecifier:Byte - - Extrn F_InstrumentButtonHandler:Far - - - Extrn F_DrawHeader:Far - Extrn F_Return0:Far - Extrn F_Return1:Far - Extrn F_ShowChannels:Far - Extrn F_RedrawScreen:Far - Extrn F_GotoEmptyList:Far - Extrn F_DrawSMCChannels:Far - Extrn F_Nothing:Far - Extrn F_CalculateLength:Far - - Extrn F_MainMenu:Far - Extrn F_Help:Far ; Menu functions - Extrn F_ViewVariables:Far - Extrn F_ViewOrderPan:Far - Extrn F_ViewPattern:Far - - Extrn F_FileMenu:Far - Extrn F_FileLoad:Far - Extrn F_FileNew:Far - Extrn F_FileSaveCurrent:Far - Extrn F_FileSaveAs:Far - Extrn F_FileDOSShell:Far - Extrn F_FileQuit:Far - - Extrn F_PlaybackMenu:Far - Extrn F_InfoPage:Far - Extrn F_PlaySong:Far - Extrn F_PlayPattern:Far - Extrn F_PlayOrder:Far - Extrn F_PlayMark:Far - Extrn F_Stop:Far - Extrn F_ReinitSoundCard:Far - Extrn F_DriverScreen:Far - Extrn F_CalculateLength:Far - - Extrn F_MessageEditor:Far - Extrn F_SampleMenu:Far - Extrn F_SampleList:Far - Extrn F_SampleLibrary:Far - Extrn F_ReloadGravis:Far - - Extrn F_Return64:Far - Extrn F_Return192:Far - - Extrn F_InstrumentMenu:Far - Extrn F_InstrumentList:Far - Extrn F_InstrumentLibrary:Far - - Extrn F_ShowMIDIZxxInput:Far - Extrn F_MIDI_Up:Far, F_MIDI_Down:Far - Extrn F_MIDI_PgUp:Far, F_MIDI_PgDn:Far - -IF SPECTRUMANALYSER - Extrn Fourier_Start:Far - Extrn Fourier_PreDrawScreen:Far - Extrn Fourier_DrawScreen:Far - Extrn Fourier_PostFunction:Far - Extrn Fourier_IdleList:Far - Extrn Fourier_ChangePalette:Far -ENDIF - - Extrn K_DrawTables:Far - Extrn K_ResetKeyboardTables:Far - Extrn K_ShowMIDIInput:Far - - Extrn PEFunction_IncreaseOctave:Far - Extrn PEFunction_DecreaseOctave:Far - - Extrn Glbl_DriverScreen:Far - Extrn Glbl_Ctrl_F1:Far - Extrn Glbl_Ctrl_F3:Far - Extrn Glbl_Ctrl_F4:Far - Extrn Glbl_Ctrl_F5:Far - Extrn Glbl_Ctrl_F12:Far - Extrn Glbl_F8:Far - Extrn Glbl_F9:Far - Extrn Glbl_F10:Far - Extrn Glbl_F11:Far - Extrn Glbl_F12:Far - Extrn Glbl_F2:Far - Extrn Glbl_F3:Far - Extrn Glbl_F4:Far - Extrn Glbl_F5:Far - Extrn Glbl_F6:Far - Extrn PE_F7:Far ; Global... - Extrn Glbl_Shift_F1:Far - Extrn Glbl_Shift_F6:Far - Extrn Glbl_Shift_F9:Far - Extrn Glbl_Alt_F1:Far - Extrn Glbl_Alt_F2:Far - Extrn Glbl_Alt_F3:Far - Extrn Glbl_Alt_F4:Far - Extrn Glbl_Alt_F5:Far - Extrn Glbl_Alt_F6:Far - Extrn Glbl_Alt_F7:Far - Extrn Glbl_Alt_F8:Far - Extrn Glbl_LoadSample:Far - Extrn Glbl_LoadInstrument:Far - Extrn Glbl_LeftBrace:Far - Extrn Glbl_RightBrace:Far - Extrn Glbl_LeftSquareBracket:Far - Extrn Glbl_RightSquareBracket:Far - -IF NETWORKENABLED - Extrn Network_DriverScreen:Far - Extrn Network_DrawDriverScreen:Far - Extrn Network_PreDriverScreen:Far - Extrn Network_PostDriverScreen:Far - - Public O1_LoadNetworkDriver -ENDIF - -IF TIMERSCREEN - Extrn Glbl_TimerScreen:Far - Extrn D_DrawTimer:Far, D_PostTimerList:Far -ENDIF - - Extrn H_HelpESC:Far - Extrn H_Help:Far - Extrn H_DrawHelp:Far - - Extrn H_HelpUp:Far - Extrn H_HelpDown:Far - Extrn H_HelpPgUp:Far - Extrn H_HelpPgDn:Far - - Extrn I_SelectScreen:Far - Extrn I_InstrumentListSpace:Far - Extrn I_InstrumentListNoteOff:Far - Extrn I_AmplifySample:Far - Extrn I_GetInstrumentScreen:Far - Extrn I_SampleButtonHandler:Far - Extrn I_CalculateC5Speed:Far - Extrn I_PrintC5Frequency:Far - - Extrn I_DoubleSampleSpeed:Far - Extrn I_HalveSampleSpeed:Far - Extrn I_SampleSpeedSemiUp:Far - Extrn I_SampleSpeedSemiDown:Far - - Extrn I_PlaySample:Far - Extrn I_PlayNote:Far - - Extrn I_DrawPitchPanCenter:Far - Extrn I_PrePitchPanCenter:Far - Extrn I_PostPitchPanCenter:Far - - Extrn I_IncreasePlayChannel:Far - Extrn I_DecreasePlayChannel:Far - - Extrn I_DeleteInstrument:Far - Extrn I_ReverseSample:Far - Extrn I_InvertSample:Far - Extrn I_CutSampleBeforeLoop:Far - Extrn I_ConvertSample:Far - Extrn I_DeleteSample:Far - Extrn I_CutSample:Far - Extrn I_ExchangeSamples:Far - Extrn I_SwapSamples:Far - Extrn I_ReplaceSample:Far - Extrn I_ReplaceInstrument:Far - Extrn I_SwapInstruments:Far - Extrn I_ResizeSample:Far - Extrn I_ResizeSampleNoInt:Far - Extrn I_UpdateInstrument:Far - Extrn I_ToggleSampleQuality:Far - Extrn I_CopyInstrument:Far - Extrn I_CenterSample:Far - Extrn I_ScaleInstrumentVolumes:Far - Extrn I_ScaleSampleVolumes:Far - - Extrn I_DrawInstrumentWindow:Far - Extrn I_PreInstrumentWindow:Far - Extrn I_PostInstrumentWindow:Far - Extrn I_ToggleMultiChannel:Far - - Extrn I_DrawNoteWindow:Far - Extrn I_PreNoteWindow:Far - Extrn I_PostNoteWindow:Far - - Extrn I_DrawEnvelope:Far - Extrn I_PreEnvelope:Far - Extrn I_PostEnvelope:Far - - Extrn I_ShowSampleInfo:Far - Extrn I_SampleUp:Far - Extrn I_SampleDown:Far - Extrn I_CheckLoopValues:Far - Extrn I_CheckSusLoopValues:Far - - Extrn I_DrawSampleList:Far - Extrn I_PreSampleList:Far - Extrn I_PostSampleList:Far - Extrn I_IdleUpdateEnvelope:Far - - Extrn Msg_DrawMessage:Far - Extrn Msg_PreMessage:Far - Extrn Msg_PostMessage:Far - - Extrn Music_SoundCardLoadAllSamples:Far - Extrn Music_ReinitSoundCard:Far - Extrn Music_SaveMIDIConfig:Far - Extrn Music_ShowAutodetectSoundcard:Far - Extrn Music_ToggleOrderUpdate:Far - - Extrn PE_FillHeader:Far - Extrn PE_SetCommandCursor:Far - Extrn PE_DrawPatternEdit:Far - Extrn PE_PrePatternEdit:Far - Extrn PE_PostPatternEdit:Far - - Extrn PEFunction_DrawUndo:Far - Extrn PEFunction_PreUndo:Far - Extrn PEFunction_PostUndo:Far - - Extrn S_UpdateScreen:Far - Extrn S_RestoreScreen:Far - - Extrn DrawDisplayData:Far - Extrn PostDisplayData:Far - Extrn DisplayUpdateScreen:Far - - Extrn BaseOctave - Extrn SkipValue - Extrn RowHiLight1 - Extrn RowHiLight2 - Extrn NumberOfRows:Word - Extrn Amplification - Extrn InstrumentAmplification - Extrn FastVolumeAmplification - Extrn SampleAmplification - Extrn CommandToValue - Extrn MultiChannelInfo - Extrn SampleNumberInput:Byte - Extrn SongDirectory:Byte - Extrn SampleDirectory:Byte - Extrn InstrumentDirectory:Byte - - Extrn IdleUpdateInfoLine:Far - Extrn DOSShell:Far - - Extrn I_ExchangeInstruments:Far - - Extrn F_ConfigButtonSetup:Far - Extrn F_SetControlInstrument:Far - Extrn F_SetControlSample:Far - Extrn F_SetMono:Far - Extrn F_SetStereo:Far - Extrn F_SetAmiga:Far - Extrn F_SetLinear:Far - - Extrn F_NewSong:Far - - Extrn AddressInput:Byte - Extrn NewSampleSize:Word - Extrn ThumbStringEnter:Byte - Extrn SampleName:Byte - -If MEMORYDEBUG - - Extrn F_PostDebug:Far - Extrn Glbl_Debug:Far - Extrn F_DrawDebug:Far - Extrn F_DebugUp:Far - Extrn F_DebugDown:Far - Extrn F_DebugPgUp:Far - Extrn F_DebugPgDn:Far - Extrn F_DebugStringInput:Far - Global O1_DebugList - -ENDIF - - Extrn PaletteDefs:Byte - - Extrn S_UsePresetPalette:Far - Extrn DisplayMinus:Far - Extrn DisplayPlus:Far - Extrn PatternSetLength, PatternLengthStart, PatternLengthEnd - - Extrn MouseToggle:Far - Extrn Refresh:Far - - Extrn MIDI_SetInstrument:Far, CentraliseCursor - Extrn MIDI_PlayNote:Far, MIDI_NoteOff:Far, MIDI_PlaySample:Far - Extrn MIDICentralNote, MIDIAmplification - - Extrn Music_TimeSong:Far, Music_ShowTime:Far - Extrn Flags - - Extrn Music_ToggleSoloInstrument:Far - Extrn Music_ToggleSoloSample:Far - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - - Global O1_MIDIScreen - Global O1_LongMessageList - Global O1_MessageList - Global O1_ConfirmNoSave - - Global O1_MainMenu - Global O1_PlayBackMenu - Global O1_SampleMenu - Global O1_FileMenu - Global O1_InstrumentMenu - - Global O1_EditSampleName - - Global O1_AutoDetectList - - Global O1_ShowTime - Global O1_SampleCenterList - Global O1_ConfirmClearMessage - Global O1_SampleAmplificationList - Global O1_EnableInstrumentMode - Global O1_OutOfSoundCardMemoryList - Global O1_OutOfSamplesList - Global O1_NewSongList - Global O1_InitInstrument - Global O1_ThumbStringList - Global O1_ConfigureITList - Global O1_OrderVolumeList - Global O1_HelpList - Global O1_OrderPanningList - Global O1_PatternEditList - Global O1_PEConfigList - Global O1_OutOfMemoryList - Global O1_OutOfSoundCardMemoryList - Global O1_SwapOutOfRangeList - Global O1_OverlapBlockList - Global O1_NoBlockMarkedList - Global O1_NoBlockDataList - Global O1_GetAmpList - Global O1_GetInstrumentAmpList - Global O1_GetFastAmpList - -IF SHOWPATTERNLENGTH - Global O1_ShowPatternLengthList -ENDIF - - Global O1_C5FrequencyList - -IF SPECTRUMANALYSER - Global O1_FourierDisplay -ENDIF - Global O1_EMSWarningMessage -IF NETWORKENABLED - Global O1_NetworkErrorList -ENDIF - Global O1_TemplateErrorList - Global O1_PatternTooLongList - Global O1_SampleList - Global O1_LoadModuleList - Global O1_SaveModuleList - Global O1_SaveS3MList - Global O1_LoadS3MList - Global O1_LoadXMList - Global O1_LoadMODList - Global O1_Load669List - Global O1_LoadMTMList - Global O1_LoadITList - Global O1_SaveITList - Global O1_EmptyList - Global O1_ConfirmOverWriteList - Global O1_UnableToSaveList - Global O1_ConfirmQuit - Global O1_SelectMultiChannel - Global O1_ConfirmDelete - Global O1_ConfirmDelete2 - Global O1_ConfirmDelete3 - Global O1_ConfirmDeleteSample - Global O1_ConfirmDeleteInstrument - Global O1_ConfirmCutSample - Global O1_ConfirmConvertList - Global O1_ConfirmConvert2List - Global O1_ExchangeSampleList - Global O1_ExchangeInstrumentList - Global O1_ReplaceSampleList - Global O1_ReplaceInstrumentList - Global O1_LoadSampleList - Global O1_ConfirmSaveRenameList - Global O1_ConfirmResaveList - Global O1_ConfirmDiscardList - Global O1_InitialiseInstrumentList - Global O1_SwapSampleList - Global O1_SwapInstrumentList - Global O1_ResizeSampleList - Global O1_KeyboardList - Global O1_DisplayList - Global O1_FullDisplayList - Global O1_ViewSampleLibrary - Global O1_ConfigurePaletteList - Global O1_LoadInstrumentList - Global O1_ViewInstrumentLibrary - Global O1_ConfirmDeleteInstrument - Global O1_CopyInstrumentList - - Global O1_CrashRecovery - - Global O1_UndoList - - Global O1_InstrumentListGeneral - Global O1_InstrumentListVolume - Global O1_InstrumentListPanning - Global O1_InstrumentListPitch - Global O1_SetPatternLength - - Global O1_StereoSampleList - Global O1_PatternSizeMismatchList - - Global PatternLength - Global HelpKeyValue, OrderKeyValue - Global GlobalKeyList:Byte - Global LogoCharacter:Word - Global EMSErrorValue, EMSErrorValue2 - Global EMSErrorValue3, EMSErrorValue4 - Global EMSErrorValue5, EMSErrorValue6 - Global EMSErrorValue7, EMSErrorValue8 - -IF TIMERSCREEN - Public O1_TimerList -ENDIF - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Object1 BYTE Public 'Data' - -O1_AutoDetectList DW 6 - DW 0 - DW Near Ptr ESCContinueList - DW Near Ptr AboutBox - DW Near Ptr ImpulseLogo - DW Near Ptr AutoMiniBox - DW Near Ptr AboutText - DW Near Ptr AutoDetectText - DW Near Ptr CallAutoDetect - DW Near Ptr AutoContinueButton - DW 0 - -ESCContinueList DB 0 ; ESC - DW 101h - DD Glbl_F2 - - DB 0FFh - -O1_OrderPanningList DW 10 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr FillHeader ; 2 - DW Near Ptr OrderandPanningMsg ; 3 - DW Near Ptr OrderBox ; 4 - DW Near Ptr PanBox1 ; 5 - DW Near Ptr PanBox2 ; 6 - DW Near Ptr ShowChannelMsgs ; 7 - DW Near Ptr PanText1 ; 8 - DW Near Ptr PanText2 ; 9 - DW Near Ptr OrderList ; 10 - DW Near Ptr Channel1 ; 11 - DW Near Ptr Channel2 ; 12 - DW Near Ptr Channel3 ; 13 - DW Near Ptr Channel4 ; 14 - DW Near Ptr Channel5 ; 15 - DW Near Ptr Channel6 ; 16 - DW Near Ptr Channel7 ; 17 - DW Near Ptr Channel8 ; 18 - DW Near Ptr Channel9 ; 19 - DW Near Ptr Channel10 ; 20 - DW Near Ptr Channel11 ; 21 - DW Near Ptr Channel12 ; 22 - DW Near Ptr Channel13 ; 23 - DW Near Ptr Channel14 ; 24 - DW Near Ptr Channel15 ; 25 - DW Near Ptr Channel16 ; 26 - DW Near Ptr Channel17 - DW Near Ptr Channel18 - DW Near Ptr Channel19 - DW Near Ptr Channel20 - DW Near Ptr Channel21 - DW Near Ptr Channel22 - DW Near Ptr Channel23 - DW Near Ptr Channel24 - DW Near Ptr Channel25 - DW Near Ptr Channel26 - DW Near Ptr Channel27 - DW Near Ptr Channel28 - DW Near Ptr Channel29 - DW Near Ptr Channel30 - DW Near Ptr Channel31 - DW Near Ptr Channel32 - DW Near Ptr Channel33 - DW Near Ptr Channel34 - DW Near Ptr Channel35 - DW Near Ptr Channel36 - DW Near Ptr Channel37 - DW Near Ptr Channel38 - DW Near Ptr Channel39 - DW Near Ptr Channel40 - DW Near Ptr Channel41 - DW Near Ptr Channel42 - DW Near Ptr Channel43 - DW Near Ptr Channel44 - DW Near Ptr Channel45 - DW Near Ptr Channel46 - DW Near Ptr Channel47 - DW Near Ptr Channel48 - DW Near Ptr Channel49 - DW Near Ptr Channel50 - DW Near Ptr Channel51 - DW Near Ptr Channel52 - DW Near Ptr Channel53 - DW Near Ptr Channel54 - DW Near Ptr Channel55 - DW Near Ptr Channel56 - DW Near Ptr Channel57 - DW Near Ptr Channel58 - DW Near Ptr Channel59 - DW Near Ptr Channel60 - DW Near Ptr Channel61 - DW Near Ptr Channel62 - DW Near Ptr Channel63 - DW Near Ptr Channel64 - DW Near Ptr SetHelpContext0 - DW 0 - -O1_HelpList DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr HelpKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr FillHeader ; 2 - DW Near Ptr HelpMsg ; 3 - DW Near Ptr HelpBox ; 4 - DW Near Ptr ShowHelp ; 5 - DW Near Ptr HelpDoneButton ; 6 - DW 0 - -O1_PatternEditList DW 3 - DW Near Ptr InfoPageIdleList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr PatternEditMsg ; 2 - DW Near Ptr PatternEdit ; 3 - DW Near Ptr FillHeader ; 4 - DW Near Ptr SetHelpContext1 ; 5 - DW 0 - -O1_PEConfigList DW 14 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCF2&ReturnList - DW Near Ptr PEConfigBox ; 0 - DW Near Ptr PEConfigText ; 1 - DW Near Ptr PEConfigBsOctText ; 2 - DW Near Ptr PEConfigSkipValueText ; 3 - DW Near Ptr PEConfigRHLMinorText ; 4 - DW Near Ptr PEConfigRHLMajorText ;5 - DW Near Ptr PEConfigMaxRowsText ; 6 - DW Near Ptr PEConfigCommandCursor ; 7 - DW Near Ptr PECBox1 - DW Near Ptr PECBox2 - DW Near Ptr PECBox3 - DW Near Ptr PECBox4 - DW Near Ptr PECBox5 - DW Near Ptr PEConfigDoneButton ; 13 - DW Near Ptr PETBBaseOctave ; 14 - DW Near Ptr PETBSkipValue ; 15 - DW Near Ptr PETBRHLMinor ; 16 - DW Near Ptr PETBRHLMajor ; 17 - DW Near Ptr PETBMaxRow ; 18 - DW Near Ptr PECLinkButton ; 19 - DW Near Ptr PECSplitButton ; 20 - DW Near Ptr FillHeader - DW 0 - -O1_SetPatternLength DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr ESC&ReturnList - DW Near Ptr SetPatternLengthBox ; 0 - DW Near Ptr SetPatternLengthHeader - DW Near Ptr SetPatternLengthThumbBox1 - DW Near Ptr SetPatternLengthThumbBox2 - DW Near Ptr SetPatternLengthThumbBar ; 4 - DW Near Ptr SetPatternLengthStart ; 5 - DW Near Ptr SetPatternLengthEnd ; 6 - DW Near Ptr SetPatternLengthOKButton ; 7 - DW Near Ptr SetPatternLengthText - DW 0 - -SetPatternLengthBox DW 0 - DB 15, 19, 65, 33 - DB 3 - -SetPatternLengthHeader DW 1 - DB 31, 21 - DB 20h - DB "Set Pattern Length", 0 - -SetPatternLengthText DW 1 - DB 19, 24 - DB 20h - DB "Pattern Length", 13 - DB 13 - DB 13 - DB " Start Pattern", 13 - DB " End Pattern", 0 - -SetPatternLengthThumbBox1 DW 0 - DB 33, 23, 56, 25 - DB 25 - -SetPatternLengthThumbBox2 DW 0 - DB 33, 26, 60, 29 - DB 25 - -SetPatternLengthThumbBar DW 9 - DB 34, 24 - DW 32, 200 - DW 1, Offset PatternSetLength - DW 0FFFFh, 5, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -SetPatternLengthStart DW 9 - DB 34, 27 - DW 0, 199 - DW 1, Offset PatternLengthStart - DW 4, 6, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -SetPatternLengthEnd DW 9 - DB 34, 28 - DW 0, 199 - DW 1, Offset PatternLengthEnd - DW 5, 7, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh - -SetPatternLengthOKButton DW 2 - DW 6, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 0 - DW 1 ; Returns 1 - DW 0, 0, 0, 0 - DB 35, 30, 44, 32 - DB 8 - DB 0 - DB " OK", 0 - -OKCancelList DB 8 ; 'O' - DW 'O' - DD DWord Ptr F_Return1 - - DB 8 ; 'C' - DW 'C' - DD DWord Ptr F_Return0 - - DB 8 ; 'Y' - DW 'Y' - DD DWord Ptr F_Return1 - - DB 8 ; 'N' - DW 'N' - DD DWord Ptr F_Return0 - -ESCReturnList DB 0 - DW 101h - DD DWord Ptr F_Return0 - - DB 5 - DW Near Ptr ChainMIDICommands - -O1_NoBlockMarkedList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr NBMText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_OutOfSoundCardMemoryList DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr OOSoundCardMemoryText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_OutOfMemoryList DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr OOMText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_PatternSizeMismatchList DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr PSMText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_LongMessageList DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr LongMsgText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_OutOfSamplesList DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr OOSText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_OverlapBlockList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr OLBText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_SwapOutOfRangeList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr SOORText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_NoBlockDataList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr NBDText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_PatternTooLongList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr PatternTooLongText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_GetAmpList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr AmpExtraKeyList - DW Near Ptr AmpBox ; 0 - DW Near Ptr AmpText ; 1 - DW Near Ptr AmpTBBox ; 2 - DW Near Ptr AmpTB ; 3 - DW Near Ptr ConfirmOKButton ; 4 - DW Near Ptr ConfirmCancelButton ; 5 - DW Near Ptr FillHeader - DW 0 - -O1_GetInstrumentAmpList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr AmpExtraKeyList - DW Near Ptr AmpBox ; 0 - DW Near Ptr AmpText ; 1 - DW Near Ptr AmpTBBox ; 2 - DW Near Ptr InstrumentAmpTB ; 3 - DW Near Ptr ConfirmOKButton ; 4 - DW Near Ptr ConfirmCancelButton ; 5 - DW Near Ptr FillHeader - DW 0 - -O1_GetFastAmpList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr AmpExtraKeyList - DW Near Ptr AmpBox ; 0 - DW Near Ptr AmpText ; 1 - DW Near Ptr FastAmpTBBox ; 2 - DW Near Ptr FastAmpTB ; 3 - DW Near Ptr ConfirmOKButton ; 4 - DW Near Ptr ConfirmCancelButton ; 5 - DW Near Ptr FillHeader - DW 0 - -O1_SampleAmplificationList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESC&ReturnList - DW Near Ptr SampleAmpBox - DW Near Ptr SampleAmpText ; 1 - DW Near Ptr SampleAmpTBBox ; 2 - DW Near Ptr SampleAmpTB ; 3 - DW Near Ptr ConfirmOKButton ; 4 - DW Near Ptr ConfirmCancelButton ; 5 - DW Near Ptr FillHeader - DW 0 - -IF SHOWPATTERNLENGTH - -O1_ShowPatternLengthList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr PatternLengthText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -ENDIF - -O1_C5FrequencyList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr C5FrequencyText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -O1_EMSWarningMessage DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr EMSErrorBox - DW Near Ptr EMSErrorText - DW Near Ptr OKButton - DW Near Ptr FillHeader - DW 0 - -IF NETWORKENABLED -O1_NetworkErrorList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr TemplateErrorBox - DW Near Ptr NetworkErrorText - DW Near Ptr TemplateOKButton - DW Near Ptr FillHeader - DW 0 -ENDIF - -O1_TemplateErrorList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr TemplateErrorBox - DW Near Ptr TemplateErrorText - DW Near Ptr TemplateOKButton - DW Near Ptr FillHeader - DW 0 - -O1_CrashRecovery DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr CrashRecoveryBox - DW Near Ptr CrashRecoveryText - DW Near Ptr CrashRecoveryOKButton - DW 0 - -O1_LoadSampleList DW 15 - DW Near Ptr SampleNameLoader - DW Near Ptr LoadSampleKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr LoadSampleHeader ; 2 - DW Near Ptr FillHeader ; 3 - DW Near Ptr LoadSampleBox - DW Near Ptr DriveSampleBox - DW Near Ptr LSInfoBox - DW Near Ptr LSInfoText - DW Near Ptr LSWaveFormBox - DW Near Ptr LSParametersBox - DW Near Ptr LSParametersText ; 10 - DW Near Ptr LSParametersVolBox ; 11 - DW Near Ptr LSParametersVibBox - DW Near Ptr LSFileInfoBox - DW Near Ptr LSFileInfoText - DW Near Ptr LoadSampleWindow ; 15 - DW Near Ptr LSDriveWindow ; 16 - DW Near Ptr LSFileNameInput ; 17 - DW Near Ptr LSSpeedInput - DW Near Ptr LSLoopToggle ; 19 - DW Near Ptr LSLoopBeginInput - DW Near Ptr LSLoopEndInput - DW Near Ptr LSSusLoopToggle ; 22 - DW Near Ptr LSSusLoopBeginInput - DW Near Ptr LSSusLoopEndInput - DW Near Ptr LSDefaultVolumeInput ; 25 - DW Near Ptr LSGlobalVolumeInput ; 26 - DW Near Ptr LSVibratoSpeedInput ; 27 - DW Near Ptr LSVibratoDepthInput ; 28 - DW Near Ptr LSVibratoRateInput ; 29 - DW Near Ptr SetHelpContext6 - DW 0 - -O1_ViewSampleLibrary DW 15 - DW Near Ptr SampleNameLoader - DW Near Ptr LoadSampleKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr ViewSampleHeader ; 2 - DW Near Ptr FillHeader ; 3 - DW Near Ptr LoadSampleBox - DW Near Ptr DriveSampleBox - DW Near Ptr LSInfoBox - DW Near Ptr LSInfoText - DW Near Ptr LSWaveFormBox - DW Near Ptr LSParametersBox - DW Near Ptr LSParametersText ; 10 - DW Near Ptr LSParametersVolBox ; 11 - DW Near Ptr LSParametersVibBox - DW Near Ptr LSFileInfoBox - DW Near Ptr LSFileInfoText - DW Near Ptr ViewSampleWindow ; 15 - DW Near Ptr LSDriveWindow ; 16 - DW Near Ptr LSFileNameInput ; 17 - DW Near Ptr LSSpeedInput - DW Near Ptr LSLoopToggle ; 19 - DW Near Ptr LSLoopBeginInput - DW Near Ptr LSLoopEndInput - DW Near Ptr LSSusLoopToggle ; 22 - DW Near Ptr LSSusLoopBeginInput - DW Near Ptr LSSusLoopEndInput - DW Near Ptr LSDefaultVolumeInput ; 25 - DW Near Ptr LSGlobalVolumeInput ; 26 - DW Near Ptr LSVibratoSpeedInput ; 27 - DW Near Ptr LSVibratoDepthInput ; 28 - DW Near Ptr LSVibratoRateInput ; 29 - DW Near Ptr SetHelpContext6 - DW 0 - - -LSFileNameInput DW 16 - DB 64, 13 - DW 3, 4 - DW 13 - DD 0 - DW 0FFFFh, 18, 25, 16 - -LSSpeedInput DW 18 - DB 64, 14 - DW 1, 3Ch - DD 0 - DW 17, 19, 25, 16 - -LSLoopToggle DW 17 - DB 64, 15 - DW 3, 12h - DB 16 - DW 18, 20, 25, 16 - -LSLoopBeginInput DW 18 - DB 64, 16 - DW 1, 34h - DD DWord Ptr D_LSCheckLoopValues - DW 19, 21, 25, 16 - -LSLoopEndInput DW 18 - DB 64, 17 - DW 1, 38h - DD DWord Ptr D_LSCheckLoopValues - DW 20, 22, 25, 16 - -LSSusLoopToggle DW 17 - DB 64, 18 - DW 3, 12h - DB 32 - DW 21, 23, 25, 16 - -LSSusLoopBeginInput DW 18 - DB 64, 19 - DW 1, 40h - DD DWord Ptr D_LSCheckSusLoopValues - DW 22, 24, 25, 16 - -LSSusLoopEndInput DW 18 - DB 64, 20 - DW 1, 44h - DD DWord Ptr D_LSCheckSusLoopValues - DW 23, 25, 25, 16 - -LSDefaultVolumeInput DW 9 - DB 63, 33 - DW 0, 64 - DW 5, 13h - DW 24, 26, 15, 17 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -LSGlobalVolumeInput DW 9 - DB 63, 34 - DW 0, 64 - DW 5, 11h - DW 25, 27, 15, 17 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -LSVibratoSpeedInput DW 9 - DB 63, 37 - DW 0, 64 - DW 5, 4Ch - DW 26, 28, 15, 17 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -LSVibratoDepthInput DW 14 - DB 63, 38 - DW 0, 32 - DW 5, 4Dh - DW 27, 29, 15, 17 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - DW 8 - -LSVibratoRateInput DW 14 - DB 63, 39 - DW 0, 255 - DW 5, 4Eh - DW 28, 0FFFFh, 15, 17 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - DW 8 - -SampleNameLoader DD DWord Ptr D_LoadSampleNames -IdleFunctionList DD DWord Ptr IdleUpdateInfoLine - DD 0 - -IdleInstrumentList DD DWord Ptr IdleUpdateInfoLine - DD DWord Ptr I_IdleUpdateEnvelope - DD 0 - -LoadSampleHeader DW 10 - DB "Load Sample", 0 - -ViewSampleHeader DW 10 - DB "Sample Library (Ctrl-F3)", 0 - -LoadSampleBox DW 0 - DB 5, 12, 44, 48 - DB 27 - -DriveSampleBox DW 0 - DB 45, 12, 54, 23 - DB 27 - -LSInfoBox DW 0 - DB 63, 12, 77, 23 - DB 27 - -LSInfoText DW 1 - DB 55, 13 - DB 20h - DB "Filename", 13 - DB " Speed", 13 - DB " Loop", 13 - DB " LoopBeg", 13 - DB " LoopEnd", 13 - DB " SusLoop", 13 - DB " SusLBeg", 13 - DB " SusLEnd", 13 - DB " Quality", 13 - DB " Length" - DB 0 - -LSWaveFormBox DW 0 - DB 45, 24, 77, 29 - DB 27 - -LSParametersBox DW 0 - DB 45, 30, 77, 42 - DB 9 - -LSParametersText DW 1 - DB 48, 33 - DB 20h - DB "Default Volume", 13 - DB " Global Volume", 13 - DB 13 - DB 13 - DB " Vibrato Speed", 13 - DB " Vibrato Depth", 13 - DB " Vibrato Rate" - DB 0 - -LSParametersVolBox DW 0 - DB 62, 32, 72, 35 - DB 25 - -LSParametersVibBox DW 0 - DB 62, 36, 72, 40 - DB 25 - -LSFileInfoBox DW 0 - DB 52, 43, 77, 48 - DB 27 - -LSFileInfoText DW 1 - DB 46, 44 - DB 20h - DB "Format", 13 - DB " Size", 13 - DB " Date", 13 - DB " Time" - DB 0 - -LoadSampleWindow DW 15 - DD DWord Ptr D_DrawLoadSampleWindow - DD DWord Ptr D_PreLoadSampleWindow - DD DWord Ptr D_PostLoadSampleWindow - -ViewSampleWindow DW 15 - DD DWord Ptr D_DrawLoadSampleWindow - DD DWord Ptr D_PreLoadSampleWindow - DD DWord Ptr D_PostViewSampleLibrary - -LSDriveWindow DW 15 - DD DWord Ptr D_LSDrawDriveWindow - DD DWord Ptr D_LSPreDriveWindow - DD DWord Ptr D_LSPostDriveWindow - -O1_SampleList DW 28 - DW Near Ptr IdleFunctionList - DW Near Ptr SampleGlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr SampleListHeader - DW Near Ptr SampleListBox - DW Near Ptr InstDVBox - DW Near Ptr InstDVText - DW Near Ptr InstDVTBBox - DW Near Ptr InstDVTB ; 7 - DW Near Ptr InstGVBox - DW Near Ptr InstGVText - DW Near Ptr InstGVTBBox - DW Near Ptr InstGVTB ; 11 - DW Near Ptr InstVSBox - DW Near Ptr InstVSText - DW Near Ptr InstVSTBBox - DW Near Ptr InstVSTB ; 15 - DW Near Ptr InstVDBox - DW Near Ptr InstVDText - DW Near Ptr InstVDTBBox - DW Near Ptr InstVDTB ; 19 - DW Near Ptr InstVRBox - DW Near Ptr InstVRText - DW Near Ptr InstVRTBBox - DW Near Ptr InstVRTB ; 23 - DW Near Ptr InstVWBox - DW Near Ptr InstVWText - DW Near Ptr InstParamBox - DW Near Ptr InstParamText - DW Near Ptr SampleList ; 28 - DW Near Ptr InstFileName ; 29 - DW Near Ptr InstSpeed - DW Near Ptr InstLoopToggle - DW Near Ptr InstLoopBegin - DW Near Ptr InstLoopEnd - DW Near Ptr InstSusLoopToggle - DW Near Ptr InstSusLoopBegin - DW Near Ptr InstSusLoopEnd ;36 - DW Near Ptr InstVibSine ; 37 - DW Near Ptr InstVibRamp ; 38 - DW Near Ptr InstVibSquare ; 39 - DW Near Ptr InstVibRandom ; 40 - DW Near Ptr InstWaveFormBox ; 41 - DW Near Ptr InstWaveFormText ; 42 - DW Near Ptr InstDPBox ; 43 - DW Near Ptr InstDPText - DW Near Ptr InstDPTBBox - DW Near Ptr InstDPToggle ; 46 - DW Near Ptr InstDPTB ; 47 - DW Near Ptr InstFillInfo - DW Near Ptr FillHeader - DW Near Ptr SetHelpContext2 - DW 0 - -O1_LoadModuleList DW 12 - DW Near Ptr SongNameModuleLoader - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr LoadModuleText - DW Near Ptr FileBox - DW Near Ptr DirBox ; 5 - DW Near Ptr DriveBox - DW Near Ptr SearchBox - DW Near Ptr FileInfoBox - DW Near Ptr FileNameBox - DW Near Ptr SearchText ; 10 - DW Near Ptr FileText - DW Near Ptr FileWindow ; 12 - DW Near Ptr DirectoryWindow - DW Near Ptr DriveWindow - DW Near Ptr FileNamePrompt ; 15 - DW Near Ptr SongDirectoryPrompt - DW Near Ptr SetHelpContext3 - DW 0 - -O1_SaveModuleList DW 15 - DW Near Ptr SongNameModuleLoader - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SaveModuleText - DW Near Ptr FileBox - DW Near Ptr DirBox ; 5 - DW Near Ptr DriveBox - DW Near Ptr SearchBox - DW Near Ptr FileInfoBox - DW Near Ptr FileNameBox - DW Near Ptr SearchText ; 10 - DW Near Ptr FileText - DW Near Ptr FileSaveWindow ; 12 - DW Near Ptr DirectoryWindow - DW Near Ptr SaveDriveWindow - DW Near Ptr FileNameSavePrompt ; 15 - DW Near Ptr SongDirectoryPrompt - DW Near Ptr ITFormatButton ; 17 - DW Near Ptr S3MFormatButton ; 18 - DW Near Ptr OldITFormatButton ; 19 -IF DDCOMPRESS - DW Near Ptr IT215FormatButton ; 20 -ENDIF - DW 0 - -IF NETWORKENABLED -O1_LoadNetworkDriver DW 6 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SaveModuleText - DW Near Ptr LoadNetworkText - DW Near Ptr LoadNetworkBox - DW Near Ptr LoadNetworkFunctions - DW 0 -ENDIF - -O1_SaveITList DW 7 - DW Near Ptr IdleFunctionGotoEmpty - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SaveModuleText - DW Near Ptr LoadBox - DW Near Ptr SaveITModuleText - DW Near Ptr DirectScreen ; 6 - DW Near Ptr SaveIT ; 7 - DW 0 - -O1_SaveS3MList DW 7 - DW Near Ptr IdleFunctionGotoEmpty - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr SaveModuleText - DW Near Ptr LoadBox - DW Near Ptr SaveS3MModuleText - DW Near Ptr DirectScreen ; 6 - DW Near Ptr SaveS3M ; 7 - DW 0 - -IF TUTORIAL -ELSE - -O1_LoadS3MList DW 7 - DW Near Ptr IdleFunctionGotoEmpty - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr LoadModuleText - DW Near Ptr LoadBox - DW Near Ptr LoadS3MModuleText - DW Near Ptr DirectScreen ; 6 - DW Near Ptr LoadS3M ; 7 - DW 0 - -O1_LoadXMList DW 7 - DW Near Ptr IdleFunctionGotoEmpty - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr LoadModuleText - DW Near Ptr LoadBox - DW Near Ptr LoadXMModuleText - DW Near Ptr DirectScreen ; 6 - DW Near Ptr LoadXM ; 7 - DW 0 - -O1_LoadMTMList DW 7 - DW Near Ptr IdleFunctionGotoEmpty - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr LoadModuleText - DW Near Ptr LoadBox - DW Near Ptr LoadMTMModuleText - DW Near Ptr DirectScreen ; 6 - DW Near Ptr LoadMTM ; 7 - DW 0 - -O1_LoadMODList DW 7 - DW Near Ptr IdleFunctionGotoEmpty - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr LoadModuleText - DW Near Ptr LoadBox - DW Near Ptr LoadMODModuleText - DW Near Ptr DirectScreen ; 6 - DW Near Ptr LoadMOD ; 7 - DW 0 - -O1_Load669List DW 7 - DW Near Ptr IdleFunctionGotoEmpty - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr LoadModuleText - DW Near Ptr LoadBox - DW Near Ptr Load669ModuleText - DW Near Ptr DirectScreen ; 6 - DW Near Ptr Load669 ; 7 - DW 0 - -O1_LoadITList DW 7 - DW Near Ptr IdleFunctionGotoEmpty - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr LoadModuleText - DW Near Ptr LoadBox - DW Near Ptr LoadITModuleText - DW Near Ptr DirectScreen ; 6 - DW Near Ptr LoadIT ; 7 - DW 0 -ENDIF - -O1_EmptyList DW 0 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyList - DW Near Ptr InDirectScreen ; 0 - DW Near Ptr FullScreenBox ; 1 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr NoText - DW 0 - -ITFormatButton DW 2 - DW 0FFFFh, 18, 14, 15 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr D_GetFormatType - DW 0 - DW 0, 0 - DB 69, 12, 77, 14 - DB 8 - DB 0 - DB " IT214", 0 - -S3MFormatButton DW 2 - DW 17, 19, 14, 15 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr D_GetFormatType - DW 1 - DW 0, 0 - DB 69, 15, 77, 17 - DB 8 - DB 0 - DB " S3M", 0 - -IF DDCOMPRESS - -OldITFormatButton DW 2 - DW 18, 20, 14, 15 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr D_GetFormatType - DW 2 - DW 0, 0 - DB 69, 18, 77, 20 - DB 8 - DB 0 - DB " IT2xx", 0 - -IT215FormatButton DW 2 - DW 19, 15, 14, 15 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr D_GetFormatType - DW 3 - DW 0, 0 - DB 69, 21, 77, 23 - DB 8 - DB 0 - DB " IT215", 0 - - -ELSE - -OldITFormatButton DW 2 - DW 18, 15, 14, 15 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr D_GetFormatType - DW 2 - DW 0, 0 - DB 69, 18, 77, 20 - DB 8 - DB 0 - DB " IT2xx", 0 -ENDIF - - -NoText DW 10 - DB 0 - -LoadBox DW 0 - DB 1, 12, 78, 48 - DB 27 - -SaveITModuleText DW 1 - DB 3, 14 - DB 2h - DB "Saving Impulse 2 Module", 13 - DB 0FFh, 23, 129, 0 - -SaveS3MModuleText DW 1 - DB 3, 14 - DB 2h - DB "Saving Scream Tracker 3 Module", 13 - DB 0FFh, 30, 129, 0 - -LoadS3MModuleText DW 1 - DB 3, 14 - DB 2h - DB "Scream Tracker III Module", 13 - DB 0FFh, 25, 129, 0 - -LoadXMModuleText DW 1 - DB 3, 14 - DB 2h - DB "Fast Tracker II Module", 13 - DB 0FFh, 22, 129, 0 - -LoadMTMModuleText DW 1 - DB 3, 14 - DB 2h - DB "MultiTracker Module", 13 - DB 0FFh, 19, 129, 0 - -LoadMODModuleText DW 1 - DB 3, 14 - DB 2h - DB "MOD Format Module", 13 - DB 0FFh, 17, 129, 0 - -Load669ModuleText DW 1 - DB 3, 14 - DB 2h - DB "Composer 669 Module", 13 - DB 0FFh, 19, 129, 0 - -LoadITModuleText DW 1 - DB 3, 14 - DB 2h - DB "Impulse Tracker Module", 13 - DB 0FFh, 22, 129, 0 - -IdleFunctionGotoEmpty DD DWord Ptr F_GotoEmptyList - DD 0 - -IF TUTORIAL -ELSE - -LoadMOD DW 15 - DD DWord Ptr F_Return0 - DD DWord Ptr D_LoadMOD - DD DWord Ptr F_GotoEmptyList - -Load669 DW 15 - DD DWord Ptr F_Return0 - DD DWord Ptr D_Load669 - DD DWord Ptr F_GotoEmptyList - -LoadS3M DW 15 - DD DWord Ptr F_Return0 - DD DWord Ptr D_LoadS3M - DD DWord Ptr F_GotoEmptyList - -LoadXM DW 15 - DD DWord Ptr F_Return0 - DD DWord Ptr D_LoadXM - DD DWord Ptr F_GotoEmptyList - -LoadMTM DW 15 - DD DWord Ptr F_Return0 - DD DWord Ptr D_LoadMTM - DD DWord Ptr F_GotoEmptyList - -LoadIT DW 15 - DD DWord Ptr F_Return0 - DD DWord Ptr D_LoadIT - DD DWord Ptr F_GotoEmptyList - -ENDIF - -SaveIT DW 15 - DD DWord Ptr F_Return0 - DD DWord Ptr D_SaveIT - DD DWord Ptr F_GotoEmptyList - -SaveS3M DW 15 - DD DWord Ptr F_Return0 - DD DWord Ptr D_SaveS3M - DD DWord Ptr F_GotoEmptyList - -FileNamePrompt DW 16 - DB 13, 46 - DW 0 ; Disk segment - DW Offset FileSpecifier - DW 64 ; Length - DD D_NewSpecifier - DW 12, 16, 16, 14 - -FileNameSavePrompt DW 16 - DB 13, 46 - DW 0 ; Disk segment - DW Offset FileSpecifier - DW 64 ; Length - DD D_SaveModule - DW 12, 16, 16, 14 - -SongDirectoryPrompt DW 16 - DB 13, 47 - DW 0 - DW Offset SongDirectory - DW 64 - DD D_NewDirectory - DW 15, 12, 12, 15 - -SongNameModuleLoader Label DWord - DD DWord Ptr D_LoadSongNames - DD DWord Ptr IdleUpdateInfoLine - DD 0 - -FileWindow DW 15 - DD DWord Ptr D_DrawFileWindow - DD DWord Ptr D_PreFileWindow - DD DWord Ptr D_PostFileLoadWindow - -FileSaveWindow DW 15 - DD DWord Ptr D_DrawFileWindow - DD DWord Ptr D_PreFileWindow - DD DWord Ptr D_PostFileSaveWindow - -DirectoryWindow DW 15 - DD DWord Ptr D_DrawDirectoryWindow - DD DWord Ptr D_PreDirectoryWindow - DD DWord Ptr D_PostDirectoryWindow - -DriveWindow DW 15 - DD DWord Ptr D_DrawDriveWindow - DD DWord Ptr D_PreDriveWindow - DD DWord Ptr D_PostDriveWindow - -SaveDriveWindow DW 15 - DD DWord Ptr D_DrawDriveWindow - DD DWord Ptr D_PreDriveWindow - DD DWord Ptr D_PostSaveDriveWindow - -IF NETWORKENABLED -LoadNetworkText DW 10 - DB "Load Network Driver", 0 - -LoadNetworkBox DW 0 - DB 1, 12, 78, 49 - DB 27 - -LoadNetworkFunctions DW 15 - DD DWord Ptr Network_DrawDriverScreen - DD DWord Ptr Network_PreDriverScreen - DD DWord Ptr Network_PostDriverScreen - -ENDIF - -LoadModuleText DW 10 - DB "Load Module (F9)", 0 - -SaveModuleText DW 10 - DB "Save Module (F10)", 0 - -FileBox DW 0 - DB 2, 12, 41, 44 - DB 27 - -DirBox DW 0 - DB 43, 12, 56, 34 - DB 27 - -DriveBox DW 0 - DB 58, 12, 67, 34 - DB 27 - -SearchBox DW 0 - DB 50, 36, 77, 38 - DB 27 - -FileInfoBox DW 0 - DB 50, 39, 77, 44 - DB 27 - -FileNameBox DW 0 - DB 12, 45, 77, 48 - DB 27 - -SearchText DW 1 - DB 44, 37 - DB 20h - DB "Search", 13 - DB 13 - DB 13 - DB "Format", 13 - DB " Size", 13 - DB " Date", 13 - DB " Time", 0 - -FileText DW 1 - DB 3, 46 - DB 20h - DB " Filename", 13 - DB "Directory", 0 - -SampleListHeader DW 10 - DB "Sample List (F3)", 0 - -InstFillInfo DW 8 - DD DWord Ptr I_ShowSampleInfo - -InstFileName DW 16 - DB 64, 13 - DW 1 - DW 4 - DW 13 - DD 0 - DW 0FFFFh, 30, 28, 7 - -InstSpeed DW 18 - DB 64, 14 - DW 0 - DW 3Ch - DD DWord Ptr I_PlaySample - DW 29, 31, 28, 7 - -InstLoopToggle DW 17 - DB 64, 15 - DW 0 - DW 12h - DB 16 - DW 30, 32, 28, 7 - -InstLoopBegin DW 18 - DB 64, 16 - DW 0 - DW 34h - DD DWord Ptr I_CheckLoopValues - DW 31, 33, 28, 7 - -InstLoopEnd DW 18 - DB 64, 17 - DW 0 - DW 38h - DD DWord Ptr I_CheckLoopValues - DW 32, 34, 28, 7 - -InstSusLoopToggle DW 17 - DB 64, 18 - DW 0 - DW 12h - DB 32 - DW 33, 35, 28, 7 - -InstSusLoopBegin DW 18 - DB 64, 19 - DW 0 - DW 40h - DD DWord Ptr I_CheckSusLoopValues - DW 34, 36, 28, 7 - -InstSusLoopEnd DW 18 - DB 64, 20 - DW 0 - DW 44h - DD DWord Ptr I_CheckSusLoopValues - DW 35, 37, 28, 7 - -SetHelpContext0 DW 11 - DW 0 - -SetHelpContext1 DW 11 - DW 1 - -SetHelpContext2 DW 11 - DW 2 - -SetHelpContext3 DW 11 - DW 3 - -SetHelpContext4 DW 11 - DW 4 - -SetHelpContext5 DW 11 - DW 5 - -SetHelpContext6 DW 11 - DW 6 - -SetHelpContext7 DW 11 - DW 7 - -SetHelpContext8 DW 11 - DW 8 - -SetHelpContext9 DW 11 - DW 9 - -SetHelpContext10 DW 11 - DW 10 - -SetHelpContext11 DW 11 - DW 11 - -SetHelpContext12 DW 11 - DW 12 - -SetHelpContext13 DW 11 - DW 13 - -SampleListBox DW 0 - DB 4, 12, 35, 48 - DB 27 - -InstDVBox DW 0 - DB 36, 12, 53, 18 - DB 9 - -InstDVTBBox DW 0 - DB 37, 15, 47, 17 - DB 9 - -InstDVTB DW 9 - DB 38, 16 - DW 0, 64 - DW 2, 13h - DW 0FFFFh, 11, 29, 28 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -InstGVTBBox DW 0 - DB 37, 22, 47, 24 - DB 9 - -InstGVTB DW 9 - DB 38, 23 - DW 0, 64 - DW 2, 11h - DW 7, 46, 29, 28 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -InstDPTBBox DW 0 - DB 37, 29, 47, 32 - DB 25 - -InstDPToggle DW 17 - DB 38, 30 - DW 0, 2Fh - DB 80h - DW 11, 47, 29, 28 - -InstDPTB DW 9 - DB 38, 31 - DW 0, 64 - DW 2, 2Fh - DW 46, 15, 29, 28 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -InstVSTBBox DW 0 - DB 37, 38, 47, 40 - DB 9 - -InstVSTB DW 9 - DB 38, 39 - DW 0, 64 - DW 2, 4Ch - DW 47, 19, 37, 28 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -InstVDTBBox DW 0 - DB 37, 45, 47, 47 - DB 9 - -InstVDTB DW 14 - DB 38, 46 - DW 0, 32 - DW 2, 4Dh - DW 15, 0FFFFh, 23, 28 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - DW 8 - -InstVRTBBox DW 0 - DB 55, 45, 72, 47 - DB 9 - -InstVRTB DW 14 - DB 56, 46 - DW 0, 255 - DW 2, 4Eh - DW 39, 0FFFFh, 28, 19 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - DW 15 - -InstGVBox DW 0 - DB 36, 19, 53, 25 - DB 9 - -InstDPBox DW 0 - DB 36, 26, 53, 33 - DB 9 - -InstVSBox DW 0 - DB 36, 35, 53, 41 - DB 9 - -InstVDBox DW 0 - DB 36, 42, 53, 48 - DB 9 - -InstVRBox DW 0 - DB 54, 42, 77, 48 - DB 9 - -InstParamBox DW 0 - DB 63, 12, 77, 24 - DB 27 - -InstVWBox DW 0 - DB 54, 31, 77, 41 - DB 9 - -InstDVText DW 1 - DB 38, 14 - DB 20h - DB "Default Volume", 0 - -InstGVText DW 1 - DB 38, 21 - DB 20h - DB "Global Volume", 0 - -InstDPText DW 1 - DB 39, 28 - DB 20h - DB "Default Pan", 0 - -InstVSText DW 1 - DB 38, 37 - DB 20h - DB "Vibrato Speed", 0 - -InstVDText DW 1 - DB 38, 44 - DB 20h - DB "Vibrato Depth", 0 - -InstVRText DW 1 - DB 60, 44 - DB 20h - DB "Vibrato Rate", 0 - -InstVWText DW 1 - DB 58, 33 - DB 20h - DB "Vibrato Waveform", 0 - -InstParamText DW 1 - DB 55, 13 - DB 20h - DB "Filename", 13 - DB " Speed", 13 - DB " Loop", 13 - DB " LoopBeg", 13 - DB " LoopEnd", 13 - DB " SusLoop", 13 - DB " SusLBeg", 13 - DB " SusLEnd", 13 - DB 0FFh, 8, ' ', 0FEh, 21h, 146, 0FEh, 3, 0FFh, 13, 154, 0FEh, 20h, 13 - DB " Quality", 13 - DB " Length" - DB 0 - -InstVibSine DW 2 - DW 36, 39, 15, 38 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr I_SampleButtonHandler - DW 0, 4Fh, 0 - DB 56, 35, 65, 37 - DB 8 - DB 0 - DB " ", 185, 186, 0 - -InstVibRamp DW 2 - DW 36, 40, 37, 28 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr I_SampleButtonHandler - DW 1, 4Fh, 0 - DB 66, 35, 75, 37 - DB 8 - DB 0 - DB " ", 189, 190, 0 - -InstVibSquare DW 2 - DW 37, 23, 15, 40 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr I_SampleButtonHandler - DW 2, 4Fh, 0 - DB 56, 38, 65, 40 - DB 8 - DB 0 - DB " ", 187, 188, 0 - -InstVibRandom DW 2 - DW 38, 23, 39, 28 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr I_SampleButtonHandler - DW 3, 4Fh, 0 - DB 66, 38, 75, 40 - DB 8 - DB 0 - DB " Random", 0 - -InstWaveFormBox DW 0 - DB 54, 25, 77, 30 - DB 9 - -InstWaveFormText DW 1 - DB 55, 26 - DB 0Dh - DB 1, 2, 3, 4, 5, 6, 7, 8, 9, 0FFh, 1, 10, 11 - DB 12, 0FFh, 1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 13 - DB 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 - DB 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 13 - DB 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55 - DB 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 13 - DB 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77 - DB 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88 - DB 0 - -SampleList DW 15 - DD DWord Ptr I_DrawSampleList - DD DWord Ptr I_PreSampleList - DD DWord Ptr I_PostSampleList - -EMSErrorText DW 1 - DB 27, 26 - DB 20h - DB "Crash warning: EMS error", 13 - DB " Debug: ", 0FDh, "Xh, ", 0FDh, "D, ", 0FDh, "D, ", 0FDh, "X", 13 - DB 0FFh, 8, " " - DB 0FDh, "X:" - DB 0FDh, "X:" - DB 0FDh, "X:" - DB 0FDh, "X", 0 -EMSErrorValue7 DW 0 -EMSErrorValue6 DW 0 -EMSErrorValue5 DW 0 -EMSErrorValue4 DW 0 -EMSErrorValue8 DW 0 -EMSErrorValue3 DW 0 -EMSErrorValue2 DW 0 -EMSErrorValue DW 0 - -EMSErrorBox DW 0 - DB 25, 24, 54, 32 - DB 3 - -TemplateErrorBox DW 0 - DB 20, 23, 59, 34 - DB 3 - -TemplateErrorText DW 1 - DB 24, 25 - DB 20h - DB 0FFh, 9, " Template Error", 13, 13 - DB "No note in the top left position", 13 - DB " of the clipboard on which to", 13 - DB 0FFh, 7, " base translations.", 0 - -IF NETWORKENABLED -NetworkErrorText DW 1 - DB 23, 25 - DB 20h - DB 0FFh, 10, " Network Error", 13, 13 - DB "This function is not available in", 13 - DB " multi-composer mode. Disconnect", 13 - DB " from network mode to enable.", 0 -ENDIF - -CrashRecoveryBox DW 0 - DB 20, 19, 60, 30 - DB 3 - -CrashRecoveryText DW 1 - DB 22, 21 - DB 20h - DB 0FFh, 12, " Crash Recovery", 13, 13 - DB " Please save your work under a", 13 - DB " different filename, reboot your", 13 - DB "computer and rerun Impulse Tracker as", 13 - DB " the system is likely to be unstable", 0 - -IF SHOWPATTERNLENGTH - -PatternLengthText DW 1 - DB 27, 27 - DB 20h - DB "Pattern is ", 0FDh, 'D', " bytes long", 0 -PatternLength DW 0 - -ENDIF - -C5FrequencyText DW 8 - DD DWord Ptr I_PrintC5Frequency - -AmpExtraKeyList Label - DB 1 - DW 2400h ; Alt-J - DD DWord Ptr F_Return1 - - DB 0 ; ESC - DW 101h - DD DWord Ptr F_Return0 - - DB 0 ; Enter - DW 11Ch - DD DWord Ptr F_Return1 - - DB 0FFh - -AmpBox DW 0 - DB 22, 25, 57, 35 - DB 3 - -SampleAmpBox DW 0 - DB 9, 25, 69, 35 - DB 3 - -AmpText DW 1 - DB 27, 27 - DB " Volume Amplification %", 0 - -SampleAmpText DW 1 - DB 27, 27 - DB " Sample Amplification %", 0 - -AmpTBBox DW 0 - DB 25, 29, 52, 31 - DB 25 - -FastAmpTBBox DW 0 - DB 32, 29, 44, 31 - DB 25 - -SampleAmpTBBox DW 0 - DB 12, 29, 64, 31 - DB 25 - -AmpTB DW 9 - DB 26, 30 - DW 0, 200 - DW 1, Offset Amplification - DW 4, 4, 4, 4 - DW 0FFFFh, 0FFFFh - -InstrumentAmpTB DW 9 - DB 26, 30 - DW 0, 200 - DW 8, Offset InstrumentAmplification - DW 4, 4, 4, 4 - DW 0FFFFh, 0FFFFh - -FastAmpTB DW 9 - DB 33, 30 - DW 10, 90 - DW 1, Offset FastVolumeAmplification - DW 4, 4, 4, 4 - DW 0FFFFh, 0FFFFh - -SampleAmpTB DW 9 - DB 13, 30 - DW 0, 400 - DW 8, Offset SampleAmplification - DW 4, 4, 4, 4 - DW 0FFFFh, 0FFFFh - - -ConfirmOKButton DW 2 - DW 3, 3, 5, 5 - DW 0 - DW 0, 0 - DW 0 - DW 1 ; Returns 1 - DW 0, 0, 0, 0 - DB 30, 32, 39, 34 - DB 8 - DB 0 - DB " OK", 0 - -ConfirmCancelButton DW 2 - DW 3, 3, 4, 4 - DW 0 - DW 0, 0 - DW 0 - DW 0 ; Returns 0 - DW 0, 0, 0, 0 - DB 40, 32, 49, 34 - DB 8 - DB 0 - DB " Cancel", 0 - -PatternTooLongText DW 1 - DB 28, 27 - DB 20h - DB "Pattern data exceeds 64k", 0 - -NBDText DW 1 - DB 30, 27 - DB 20h - DB "No data in clipboard", 0 - -OOSoundCardMemoryText DW 1 - DB 27, 27 - DB 20h - DB "Insufficient Soundcard RAM", 0 - -OOSText DW 1 - DB 31, 27 - DB 20h - DB "Too many samples!", 0 - - -OOMText DW 1 - DB 30, 27 - DB 20h - DB "Insufficient memory", 0 - -PSMText DW 1 - DB 27, 26 - DB 20h - DB " Crash Warning:", 13 - DB " Pattern Size Mismatch", 13 - DB "Fix: Remove corrupted data", 0 - -LongMsgText DW 1 - DB 29, 27 - DB 20h - DB "Song message too long!", 0 - -OLBText DW 1 - DB 30, 27 - DB 20h - DB "Swap blocks overlap", 0 - -SOORText DW 1 - DB 30, 27 - DB 20h - DB "Out of pattern range", 0 - -NBMBox DW 0 - DB 25, 25, 54, 32 - DB 3 - -NBMText DW 1 - DB 31, 27 - DB 20h - DB "No block is marked", 0 - -OKButton DW 2 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 0 - DW 0 ; Returns 0 - DW 0, 0, 0, 0 - DB 35, 29, 44, 31 - DB 8 - DB 0 - DB " OK", 0 - - -CrashRecoveryOKButton DW 2 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 0 - DW 0 ; Returns 0 - DW 0, 0, 0, 0 - DB 35, 27, 44, 29 - DB 8 - DB 0 - DB " OK", 0 - - -TemplateOKButton DW 2 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 0 - DW 0 ; Returns 0 - DW 0, 0, 0, 0 - DB 35, 31, 44, 33 - DB 8 - DB 0 - DB " OK", 0 - - -PECLinkButton DW 2 - DW 18, 13, 20, 20 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr PE_SetCommandCursor - DW 1 - DW 0 - DW 0 - DB 39, 37, 50, 39 - DB 8 - DB 0 - DB " Link", 0 - -PECSplitButton DW 2 - DW 18, 13, 19, 19 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr PE_SetCommandCursor - DW 0 - DW 0 - DW 0 - DB 51, 37, 63, 39 - DB 8 - DB 0 - DB " Split", 0 - - -PECBox1 DW 0 - DB 39, 22, 42, 24 - DB 9 - -PECBox2 DW 0 - DB 39, 25, 43, 27 - DB 9 - -PECBox3 DW 0 - DB 39, 28, 45, 30 - DB 9 - -PECBox4 DW 0 - DB 39, 31, 57, 33 - DB 9 - -PECBox5 DW 0 - DB 39, 34, 62, 36 - DB 9 - -PEConfigBox DW 0 - DB 10, 18, 69, 43 - DB 3 - -PEConfigText DW 1 - DB 28, 19 - DB 20h - DB "Pattern Editor Options", 0 - -PEConfigBsOctText DW 1 - DB 28, 23 - DB 20h - DB "Base octave", 0 - -PEConfigSkipValueText DW 1 - DB 28, 26 - DB 20h - DB "Cursor step", 0 - -PEConfigRHLMinorText DW 1 - DB 22, 29 - DB 20h - DB "Row hilight minor", 0 - -PEConfigRHLMajorText DW 1 - DB 22, 32 - DB 20h - DB "Row hilight major", 0 - -PEConfigMaxRowsText DW 1 - DB 14, 35 - DB 20h - DB "Number of rows in pattern", 0 - -PEConfigCommandCursor DW 1 - DB 18, 38 - DB 20h - DB "Command/Value columns", 0 - -PEConfigDoneButton DW 2 - DW 19, 14, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 0 - DW 0 ; Returns 0 - DW 0, 0, 0, 0 - DB 34, 40, 45, 42 - DB 8 - DB 0 - DB " Done", 0 - -PETBBaseOctave DW 9 - DB 40, 23 - DW 0, 8 - DW 1, Offset BaseOctave - DW 13, 15, 15, 13 - DW 0FFFFh, 0FFFFh - -PETBSkipValue DW 9 - DB 40, 26 - DW 0, 16 - DW 1, Offset SkipValue - DW 14, 16, 16, 14 - DW 0FFFFh, 0FFFFh - -PETBRHLMinor DW 9 - DB 40, 29 - DW 0, 32 - DW 1, Offset RowHiLight1 - DW 15, 17, 17, 15 - DW 0FFFFh, 0FFFFh - -PETBRHLMajor DW 9 - DB 40, 32 - DW 0, 128 - DW 1, Offset RowHiLight2 - DW 16, 18, 18, 16 - DW 0FFFFh, 0FFFFh - -PETBMaxRow DW 9 - DB 40, 35 - DW 32, 200 - DW 1, Offset NumberOfRows - DW 17, 19, 19, 17 - DW 0FFFFh, 0FFFFh - -PatternEdit DW 15 - DD DWord Ptr PE_DrawPatternEdit - DD DWord Ptr PE_PrePatternEdit - DD DWord Ptr PE_PostPatternEdit - -PatternEditMsg DW 10 - DB "Pattern Editor (F2)", 0 - -HelpKeyList DB 0 - DW 1C8h - DD DWord Ptr H_HelpUp - - DB 0 - DW 1D0h - DD DWord Ptr H_HelpDown - - DB 0 - DW 1C9h - DD DWord Ptr H_HelpPgUp - - DB 0 - DW 1D1h - DD DWord Ptr H_HelpPgDn - - DB 0 - DW 101h - DD DWord Ptr H_HelpESC - - DB 5 - DW Offset GlobalKeyChain - -ShowHelp DW 8 - DD DWord Ptr H_DrawHelp - -HelpBox DW 0 - DB 1, 12, 78, 45 - DW 27 - -HelpMsg DW 10 - DB "Help", 0 - -HelpDoneButton DW 2 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr H_HelpESC - DW 0, 0, 0 - DB 34, 46, 45, 48 - DB 8 - DB 0 - DB " Done", 0 - -SetHelpOrderPanning DW 11 - DW 0 - -OrderBox DW 0 - DB 5, 14, 9, 47 - DB 27 - -OrderList DW 12 - DB 2, 15 - DW 32 - DW 11, 43 - -ShowChannelMsgs DW 8 - DD DWord Ptr F_ShowChannels - -FillHeader DW 8 - DD DWord Ptr PE_FillHeader - -PanBox1 DW 0 - DB 30, 14, 40, 47 - DB 15 - -PanBox2 DW 0 - DB 64, 14, 74, 47 - DB 15 - -PanText1 DW 1 - DB 30, 14 - DB 23h - DB 146, 0FEh, 30h, "L M R", 0FEh, 23h, 145, 0 - -PanText2 DW 1 - DB 64, 14 - DB 23h - DB 146, 0FEh, 30h, "L M R", 0FEh, 23h, 145, 0 - -VolumeText1 DW 1 - DB 30, 14 - DB 23h - DB 146, 0FEh, 30h, " Volumes ", 0FEh, 23h, 145, 0 - -VolumeText2 DW 1 - DB 64, 14 - DB 23h - DB 146, 0FEh, 30h, " Volumes ", 0FEh, 23h, 145, 0 - - -Channel1 DW 9 ; Object 9 - DB 31, 15 ; x,y - DW 0, 64 ; Ranges - DW 0, 0 ; Pan/Channel 1 - DW 11, 12, 43, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 19 ; PgUp/PgDn - -Channel2 DW 9 - DB 31, 16 - DW 0, 64 - DW 0, 1 ; Pan/Channel 2 - DW 11, 13, 44, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 20 ; PgUp/PgDn - -Channel3 DW 9 ; Object 9 - DB 31, 17 ; x,y - DW 0, 64 ; Ranges - DW 0, 2 ; Pan/Channel 3 - DW 12, 14, 45, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 21 ; PgUp/PgDn - -Channel4 DW 9 - DB 31, 18 - DW 0, 64 - DW 0, 3 ; Pan/Channel 4 - DW 13, 15, 46, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 22 ; PgUp/PgDn - -Channel5 DW 9 ; Object 9 - DB 31, 19 ; x,y - DW 0, 64 ; Ranges - DW 0, 4 ; Pan/Channel 5 - DW 14, 16, 47, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 23 ; PgUp/PgDn - -Channel6 DW 9 - DB 31, 20 - DW 0, 64 - DW 0, 5 ; Pan/Channel 6 - DW 15, 17, 48, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 24 ; PgUp/PgDn - -Channel7 DW 9 ; Object 9 - DB 31, 21 ; x,y - DW 0, 64 ; Ranges - DW 0, 6 ; Pan/Channel 7 - DW 16, 18, 49, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 25 ; PgUp/PgDn - -Channel8 DW 9 - DB 31, 22 - DW 0, 64 - DW 0, 7 ; Pan/Channel 8 - DW 17, 19, 50, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 26 ; PgUp/PgDn - -Channel9 DW 9 ; Object 9 - DB 31, 23 ; x,y - DW 0, 64 ; Ranges - DW 0, 8 ; Pan/Channel 9 - DW 18, 20, 51, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 27 ; PgUp/PgDn - -Channel10 DW 9 - DB 31, 24 - DW 0, 64 - DW 0, 9 ; Pan/Channel 10 - DW 19, 21, 52, 10 ; Up/Down/Tab/Shift-Tab - DW 12, 28 ; PgUp/PgDn - -Channel11 DW 9 ; Object 9 - DB 31, 25 ; x,y - DW 0, 64 ; Ranges - DW 0, 10 ; Pan/Channel 11 - DW 20, 22, 53, 10 ; Up/Down/Tab/Shift-Tab - DW 13, 29 ; PgUp/PgDn - -Channel12 DW 9 - DB 31, 26 - DW 0, 64 - DW 0, 11 ; Pan/Channel 12 - DW 21, 23, 54, 10 ; Up/Down/Tab/Shift-Tab - DW 14, 30 ; PgUp/PgDn - -Channel13 DW 9 ; Object 9 - DB 31, 27 ; x,y - DW 0, 64 ; Ranges - DW 0, 12 ; Pan/Channel 13 - DW 22, 24, 55, 10 ; Up/Down/Tab/Shift-Tab - DW 15, 31 ; PgUp/PgDn - -Channel14 DW 9 - DB 31, 28 - DW 0, 64 - DW 0, 13 ; Pan/Channel 14 - DW 23, 25, 56, 10 ; Up/Down/Tab/Shift-Tab - DW 16, 32 ; PgUp/PgDn - -Channel15 DW 9 ; Object 9 - DB 31, 29 ; x,y - DW 0, 64 ; Ranges - DW 0, 14 ; Pan/Channel 15 - DW 24, 26, 57, 10 ; Up/Down/Tab/Shift-Tab - DW 17, 33 ; PgUp/PgDn - -Channel16 DW 9 - DB 31, 30 - DW 0, 64 - DW 0, 15 ; Pan/Channel 16 - DW 25, 27, 58, 10 ; Up/Down/Tab/Shift-Tab - DW 18, 34 ; PgUp/PgDn - -Channel17 DW 9 ; Object 9 - DB 31, 31 ; x,y - DW 0, 64 ; Ranges - DW 0, 16 ; Pan/Channel 17 - DW 26, 28, 59, 10 ; Up/Down/Tab/Shift-Tab - DW 19, 35 ; PgUp/PgDn - -Channel18 DW 9 - DB 31, 32 - DW 0, 64 - DW 0, 17 ; Pan/Channel 18 - DW 27, 29, 60, 10 ; Up/Down/Tab/Shift-Tab - DW 20, 36 ; PgUp/PgDn - -Channel19 DW 9 ; Object 9 - DB 31, 33 ; x,y - DW 0, 64 ; Ranges - DW 0, 18 ; Pan/Channel 19 - DW 28, 30, 61, 10 ; Up/Down/Tab/Shift-Tab - DW 21, 37 ; PgUp/PgDn - -Channel20 DW 9 - DB 31, 34 - DW 0, 64 - DW 0, 19 ; Pan/Channel 20 - DW 29, 31, 62, 10 ; Up/Down/Tab/Shift-Tab - DW 22, 38 ; PgUp/PgDn - -Channel21 DW 9 ; Object 9 - DB 31, 35 ; x,y - DW 0, 64 ; Ranges - DW 0, 20 ; Pan/Channel 21 - DW 30, 32, 63, 10 ; Up/Down/Tab/Shift-Tab - DW 23, 39 ; PgUp/PgDn - -Channel22 DW 9 - DB 31, 36 - DW 0, 64 - DW 0, 21 ; Pan/Channel 22 - DW 31, 33, 64, 10 ; Up/Down/Tab/Shift-Tab - DW 24, 40 ; PgUp/PgDn - -Channel23 DW 9 ; Object 9 - DB 31, 37 ; x,y - DW 0, 64 ; Ranges - DW 0, 22 ; Pan/Channel 23 - DW 32, 34, 65, 10 ; Up/Down/Tab/Shift-Tab - DW 25, 41 ; PgUp/PgDn - -Channel24 DW 9 - DB 31, 38 - DW 0, 64 - DW 0, 23 ; Pan/Channel 24 - DW 33, 35, 66, 10 ; Up/Down/Tab/Shift-Tab - DW 26, 42 ; PgUp/PgDn - -Channel25 DW 9 ; Object 9 - DB 31, 39 ; x,y - DW 0, 64 ; Ranges - DW 0, 24 ; Pan/Channel 25 - DW 34, 36, 67, 10 ; Up/Down/Tab/Shift-Tab - DW 27, 43 ; PgUp/PgDn - -Channel26 DW 9 - DB 31, 40 - DW 0, 64 - DW 0, 25 ; Pan/Channel 26 - DW 35, 37, 68, 10 ; Up/Down/Tab/Shift-Tab - DW 28, 44 ; PgUp/PgDn - -Channel27 DW 9 ; Object 9 - DB 31, 41 ; x,y - DW 0, 64 ; Ranges - DW 0, 26 ; Pan/Channel 27 - DW 36, 38, 69, 10 ; Up/Down/Tab/Shift-Tab - DW 29, 45 ; PgUp/PgDn - -Channel28 DW 9 - DB 31, 42 - DW 0, 64 - DW 0, 27 ; Pan/Channel 28 - DW 37, 39, 70, 10 ; Up/Down/Tab/Shift-Tab - DW 30, 46 ; PgUp/PgDn - -Channel29 DW 9 ; Object 9 - DB 31, 43 ; x,y - DW 0, 64 ; Ranges - DW 0, 28 ; Pan/Channel 29 - DW 38, 40, 71, 10 ; Up/Down/Tab/Shift-Tab - DW 31, 47 ; PgUp/PgDn - -Channel30 DW 9 - DB 31, 44 - DW 0, 64 - DW 0, 29 ; Pan/Channel 30 - DW 39, 41, 72, 10 ; Up/Down/Tab/Shift-Tab - DW 32, 48 ; PgUp/PgDn - -Channel31 DW 9 ; Object 9 - DB 31, 45 ; x,y - DW 0, 64 ; Ranges - DW 0, 30 ; Pan/Channel 31 - DW 40, 42, 73, 10 ; Up/Down/Tab/Shift-Tab - DW 33, 49 ; PgUp/PgDn - -Channel32 DW 9 - DB 31, 46 - DW 0, 64 - DW 0, 31 ; Pan/Channel 32 - DW 41, 43, 74, 10 ; Up/Down/Tab/Shift-Tab - DW 34, 50 ; PgUp/PgDn - -Channel33 DW 9 ; Object 9 - DB 65, 15 ; x,y - DW 0, 64 ; Ranges - DW 0, 32 ; Pan/Channel 33 - DW 42, 44, 10, 11 ; Up/Down/Tab/Shift-Tab - DW 35, 51 ; PgUp/PgDn - -Channel34 DW 9 - DB 65, 16 - DW 0, 64 - DW 0, 33 ; Pan/Channel 34 - DW 43, 45, 10, 12 ; Up/Down/Tab/Shift-Tab - DW 36, 52 ; PgUp/PgDn - -Channel35 DW 9 ; Object 9 - DB 65, 17 ; x,y - DW 0, 64 ; Ranges - DW 0, 34 ; Pan/Channel 35 - DW 44, 46, 10, 13 ; Up/Down/Tab/Shift-Tab - DW 37, 53 ; PgUp/PgDn - -Channel36 DW 9 - DB 65, 18 - DW 0, 64 - DW 0, 35 ; Pan/Channel 36 - DW 45, 47, 10, 14 ; Up/Down/Tab/Shift-Tab - DW 38, 54 ; PgUp/PgDn - -Channel37 DW 9 ; Object 9 - DB 65, 19 ; x,y - DW 0, 64 ; Ranges - DW 0, 36 ; Pan/Channel 37 - DW 46, 48, 10, 15 ; Up/Down/Tab/Shift-Tab - DW 39, 55 ; PgUp/PgDn - -Channel38 DW 9 - DB 65, 20 - DW 0, 64 - DW 0, 37 ; Pan/Channel 38 - DW 47, 49, 10, 16 ; Up/Down/Tab/Shift-Tab - DW 40, 56 ; PgUp/PgDn - -Channel39 DW 9 ; Object 9 - DB 65, 21 ; x,y - DW 0, 64 ; Ranges - DW 0, 38 ; Pan/Channel 39 - DW 48, 50, 10, 17 ; Up/Down/Tab/Shift-Tab - DW 41, 57 ; PgUp/PgDn - -Channel40 DW 9 - DB 65, 22 - DW 0, 64 - DW 0, 39 ; Pan/Channel 40 - DW 49, 51, 10, 18 ; Up/Down/Tab/Shift-Tab - DW 42, 58 ; PgUp/PgDn - -Channel41 DW 9 ; Object 9 - DB 65, 23 ; x,y - DW 0, 64 ; Ranges - DW 0, 40 ; Pan/Channel 41 - DW 50, 52, 10, 19 ; Up/Down/Tab/Shift-Tab - DW 43, 59 ; PgUp/PgDn - -Channel42 DW 9 - DB 65, 24 - DW 0, 64 - DW 0, 41 ; Pan/Channel 42 - DW 51, 53, 10, 20 ; Up/Down/Tab/Shift-Tab - DW 44, 60 ; PgUp/PgDn - -Channel43 DW 9 ; Object 9 - DB 65, 25 ; x,y - DW 0, 64 ; Ranges - DW 0, 42 ; Pan/Channel 43 - DW 52, 54, 10, 21 ; Up/Down/Tab/Shift-Tab - DW 45, 61 ; PgUp/PgDn - -Channel44 DW 9 - DB 65, 26 - DW 0, 64 - DW 0, 43 ; Pan/Channel 44 - DW 53, 55, 10, 22 ; Up/Down/Tab/Shift-Tab - DW 46, 62 ; PgUp/PgDn - -Channel45 DW 9 ; Object 9 - DB 65, 27 ; x,y - DW 0, 64 ; Ranges - DW 0, 44 ; Pan/Channel 45 - DW 54, 56, 10, 23 ; Up/Down/Tab/Shift-Tab - DW 47, 63 ; PgUp/PgDn - -Channel46 DW 9 - DB 65, 28 - DW 0, 64 - DW 0, 45 ; Pan/Channel 46 - DW 55, 57, 10, 24 ; Up/Down/Tab/Shift-Tab - DW 48, 64 ; PgUp/PgDn - -Channel47 DW 9 ; Object 9 - DB 65, 29 ; x,y - DW 0, 64 ; Ranges - DW 0, 46 ; Pan/Channel 47 - DW 56, 58, 10, 25 ; Up/Down/Tab/Shift-Tab - DW 49, 65 ; PgUp/PgDn - -Channel48 DW 9 - DB 65, 30 - DW 0, 64 - DW 0, 47 ; Pan/Channel 48 - DW 57, 59, 10, 26 ; Up/Down/Tab/Shift-Tab - DW 50, 66 ; PgUp/PgDn - -Channel49 DW 9 ; Object 9 - DB 65, 31 ; x,y - DW 0, 64 ; Ranges - DW 0, 48 ; Pan/Channel 49 - DW 58, 60, 10, 27 ; Up/Down/Tab/Shift-Tab - DW 51, 67 ; PgUp/PgDn - -Channel50 DW 9 - DB 65, 32 - DW 0, 64 - DW 0, 49 ; Pan/Channel 50 - DW 59, 61, 10, 28 ; Up/Down/Tab/Shift-Tab - DW 52, 68 ; PgUp/PgDn - -Channel51 DW 9 ; Object 9 - DB 65, 33 ; x,y - DW 0, 64 ; Ranges - DW 0, 50 ; Pan/Channel 51 - DW 60, 62, 10, 29 ; Up/Down/Tab/Shift-Tab - DW 53, 69 ; PgUp/PgDn - -Channel52 DW 9 - DB 65, 34 - DW 0, 64 - DW 0, 51 ; Pan/Channel 52 - DW 61, 63, 10, 30 ; Up/Down/Tab/Shift-Tab - DW 54, 70 ; PgUp/PgDn - -Channel53 DW 9 ; Object 9 - DB 65, 35 ; x,y - DW 0, 64 ; Ranges - DW 0, 52 ; Pan/Channel 53 - DW 62, 64, 10, 31 ; Up/Down/Tab/Shift-Tab - DW 55, 71 ; PgUp/PgDn - -Channel54 DW 9 - DB 65, 36 - DW 0, 64 - DW 0, 53 ; Pan/Channel 54 - DW 63, 65, 10, 32 ; Up/Down/Tab/Shift-Tab - DW 56, 72 ; PgUp/PgDn - -Channel55 DW 9 ; Object 9 - DB 65, 37 ; x,y - DW 0, 64 ; Ranges - DW 0, 54 ; Pan/Channel 55 - DW 64, 66, 10, 33 ; Up/Down/Tab/Shift-Tab - DW 57, 73 ; PgUp/PgDn - -Channel56 DW 9 - DB 65, 38 - DW 0, 64 - DW 0, 55 ; Pan/Channel 56 - DW 65, 67, 10, 34 ; Up/Down/Tab/Shift-Tab - DW 58, 74 ; PgUp/PgDn - -Channel57 DW 9 ; Object 9 - DB 65, 39 ; x,y - DW 0, 64 ; Ranges - DW 0, 56 ; Pan/Channel 57 - DW 66, 68, 10, 35 ; Up/Down/Tab/Shift-Tab - DW 59, 74 ; PgUp/PgDn - -Channel58 DW 9 - DB 65, 40 - DW 0, 64 - DW 0, 57 ; Pan/Channel 58 - DW 67, 69, 10, 36 ; Up/Down/Tab/Shift-Tab - DW 60, 74 ; PgUp/PgDn - -Channel59 DW 9 ; Object 9 - DB 65, 41 ; x,y - DW 0, 64 ; Ranges - DW 0, 58 ; Pan/Channel 59 - DW 68, 70, 10, 37 ; Up/Down/Tab/Shift-Tab - DW 61, 74 ; PgUp/PgDn - -Channel60 DW 9 - DB 65, 42 - DW 0, 64 - DW 0, 59 ; Pan/Channel 60 - DW 69, 71, 10, 38 ; Up/Down/Tab/Shift-Tab - DW 62, 74 ; PgUp/PgDn - -Channel61 DW 9 ; Object 9 - DB 65, 43 ; x,y - DW 0, 64 ; Ranges - DW 0, 60 ; Pan/Channel 61 - DW 70, 72, 10, 39 ; Up/Down/Tab/Shift-Tab - DW 63, 74 ; PgUp/PgDn - -Channel62 DW 9 - DB 65, 44 - DW 0, 64 - DW 0, 61 ; Pan/Channel 62 - DW 71, 73, 10, 40 ; Up/Down/Tab/Shift-Tab - DW 64, 74 ; PgUp/PgDn - -Channel63 DW 9 ; Object 9 - DB 65, 45 ; x,y - DW 0, 64 ; Ranges - DW 0, 62 ; Pan/Channel 63 - DW 72, 74, 10, 41 ; Up/Down/Tab/Shift-Tab - DW 65, 74 ; PgUp/PgDn - -Channel64 DW 9 - DB 65, 46 - DW 0, 64 - DW 0, 63 ; Pan/Channel 64 - DW 73, 74, 10, 42 ; Up/Down/Tab/Shift-Tab - DW 66, 74 ; PgUp/PgDn - -OrderAndPanningMsg DW 10 - DB "Order List and Panning (F11)", 0 - -OrderAndVolumeMsg DW 10 - DB "Order List and Channel Volume (F11)", 0 - -FullScreenBox DW 0 - DB 0, 0, 79, 49 - DB 4 - -ScreenHeader DW 8 - DD DWord Ptr F_DrawHeader - -CallAutoDetect DW 8 - DD DWord Ptr Music_ShowAutoDetectSoundCard - -AutoMiniBox DW 0 - DB 25, 25, 55, 30 - DB 0 - -AutoDetectText DW 1 - DB 32, 26 - DB 20h - DB "Sound Card Setup", 0 - -LoadSampleKeyList DB 0 - DW 101h ; ESC - DD DWord Ptr Glbl_F3 - -ViewSampleKeyList Label - DB 0 - DW 1C9h ; PgUp - DD DWord Ptr LSWindow_Up - - DB 0 - DW 1D1h ; PgDn - DD DWord Ptr LSWindow_Down - - DB 1 ; Alt - DW 1F00h ; 'S' - DD DWord Ptr D_SlowSampleSort - - DB 5 ; Chain to... - DW Offset GlobalKeyList - - -LoadInstrumentKeyList DB 0 - DW 101h ; ESC - DD DWord Ptr Glbl_F4 - - DB 1 ; Alt - DW 1F00h ; 'S' - DD DWord Ptr D_SlowInstrumentSort - - DB 5 - DW Offset GlobalKeyList - -GlobalKeyList DB 0 ; F1 -HelpKeyValue DW 13Bh - DD DWord Ptr H_Help - -GlobalKeyChain: - DB 3 ; Ctrl... - DW 13Bh ; F1 - DD DWord Ptr Glbl_Ctrl_F1 - - DB 0 ; F2 - DW 13Ch - DD DWord Ptr Glbl_F2 - - DB 0 ; F3 - DW 13Dh - DD DWord Ptr Glbl_F3 - - DB 3 ; Ctrl... - DW 13Dh ; F3 - DD DWord Ptr Glbl_Ctrl_F3 - - DB 0 ; F4 - DW 13Eh - DD DWord Ptr Glbl_F4 - - DB 3 ; Ctrl... - DW 13Eh ; F4 - DD DWord Ptr Glbl_Ctrl_F4 - - DB 0 ; F5 - DW 13Fh - DD DWord Ptr Glbl_F5 - - DB 1 - DW 12h ; Ctrl 'R' - DD DWord Ptr Glbl_F9 - - DB 1 - DW 0Ch ; Ctrl 'L' - DD DWord Ptr Glbl_F9 - - DB 0 ; F9 - DW 142h - DD DWord Ptr Glbl_F8 - - DB 0 ; F9 - DW 143h - DD DWord Ptr Glbl_F9 - - DB 6 ; F9 - DW 143h - DD DWord Ptr Glbl_Shift_F9 - - DB 1 - DW 17h ; Ctrl 'W' - DD DWord Ptr Glbl_F10 - - DB 0 ; F10 - DW 144h - DD DWord Ptr Glbl_F10 - - DB 0 ; F11 -OrderKeyValue DW 157h - DD DWord Ptr Glbl_F11 - - DB 0 ; F12 - DW 158h - DD DWord Ptr Glbl_F12 - - DB 3 ; Ctrl.. - DW 158h ; F1 - DD DWord Ptr Glbl_Ctrl_F12 - - DB 0 ; ESC - DW 101h - DD DWord Ptr F_MainMenu - - DB 1 - DW 04h ; Ctrl 'D' - DD DWord Ptr DOSShell - - DB 1 - DW 05h ; Ctrl 'E' - DD DWord Ptr Refresh - - DB 1 - DW 13h ; Ctrl 'S' - DD DWord Ptr D_SaveSong - - DB 1 - DW 11h ; Ctrl 'Q' - DD DWord Ptr Quit - - DB 1 - DW 0Dh ; Ctrl 'M' - DD DWord Ptr MouseToggle - - DB 1 - DW 0Eh ; Ctrl 'N' - DD DWord Ptr F_NewSong - - DB 1 - DW 7h ; Ctrl 'G' - DD DWord Ptr Music_SoundCardLoadAllSamples - - DB 1 - DW 9 ; Ctrl 'I' - DD DWord Ptr Music_ReinitSoundCard - - DB 1 - DW 16 ; Ctrl 'P' - DD DWord Ptr Music_TimeSong - -IF MEMORYDEBUG - DB 0 - DW 15B7h ; Right shift+Ctrl+Printscreen - DD DWord Ptr Glbl_Debug -ENDIF - - DB 2 ; Alt.. - DW 13Bh ; F1 - DD DWord Ptr Glbl_Alt_F1 - - DB 2 ; Alt.. - DW 13Ch ; F2 - DD DWord Ptr Glbl_Alt_F2 - - DB 2 ; Alt.. - DW 13Dh ; F3 - DD DWord Ptr Glbl_Alt_F3 - - DB 2 ; Alt.. - DW 13Eh ; F4 - DD DWord Ptr Glbl_Alt_F4 - - DB 2 ; Alt.. - DW 13Fh ; F5 - DD DWord Ptr Glbl_Alt_F5 - - DB 2 ; Alt.. - DW 140h ; F6 - DD DWord Ptr Glbl_Alt_F6 - - DB 2 ; Alt.. - DW 141h ; F7 - DD DWord Ptr Glbl_Alt_F7 - - DB 2 ; Alt.. - DW 142h ; F8 - DD DWord Ptr Glbl_Alt_F8 - - DB 2 ; Alt.. - DW 157h ; F11 - DD DWord Ptr Music_ToggleOrderUpdate - -IF NETWORKENABLED - DB 6 ; Shift - DW 101h ; ESC - DD DWord Ptr Network_DriverScreen -ENDIF - - DB 6 ; Shift F1 - DW 13Bh - DD DWord Ptr Glbl_Shift_F1 - - DB 6 ; Shift F5 - DW 13Fh - DD DWord Ptr Glbl_DriverScreen - -IF TIMERSCREEN - DB 0 ; Left shift, left+right alt - DW 73C6h ; Right ctrl + Pause - DD DWord Ptr Glbl_TimerScreen -ENDIF - -IF EMSDEBUG - DB 0 ; Left shift, Left alt, right alt - DW 6329h ; + ~ - DD DWord Ptr E_DumpEMSMemory -ENDIF - -PlayCommandChain: - DB 3 ; Ctrl... - DW 13Fh ; F5 - DD DWord Ptr Glbl_Ctrl_F5 - - DB 0 ; F6 - DW 140h - DD DWord Ptr Glbl_F6 - - DB 6 ; F6 - DW 140h - DD DWord Ptr Glbl_Shift_F6 - - DB 0 - DW 141h ; F7 - DD DWord Ptr PE_F7 - - DB 3 ; Ctrl - DW 1CBh ; Left - DD DWord Ptr DisplayMinus - - DB 3 ; Ctrl - DW 1CDh ; Right - DD DWord Ptr DisplayPlus - - DB 0 - DW 1B5h - DD DWord Ptr PEFunction_DecreaseOctave - - DB 0 - DW 137h - DD DWord Ptr PEFunction_IncreaseOctave - - DB 6 - DW 1B5h - DD DWord Ptr PEFunction_DecreaseOctave - - DB 6 - DW 137h - DD DWord Ptr PEFunction_IncreaseOctave - - DB 1 - DW '{' - DD DWord Ptr Glbl_LeftBrace - - DB 1 - DW '}' - DD DWord Ptr Glbl_RightBrace - - DB 1 - DW '[' - DD DWord Ptr Glbl_LeftSquareBracket - - DB 1 - DW ']' - DD DWord Ptr Glbl_RightSquareBracket - -ChainMIDICommands: - DB 9 ; MIDI Message - DW 08000h - DD DWord Ptr MIDI_NoteOff - - DB 9 ; MIDI Message - DW 09000h - DD DWord Ptr MIDI_PlayNote - - DB 9 ; MIDI Message - DW 0C000h - DD DWord Ptr MIDI_SetInstrument - - DB 0FFh ; End of list - -ESCExitList DB 0 ; ESC - DW 101h - DD DWord Ptr F_Return0 - - DB 5 - DW Near Ptr ChainMIDICommands - -SampleGlobalKeyList Label -IF ENABLESOLO - DB 1 - DW '`' - DD DWord Ptr Music_ToggleSoloSample -ENDIF - - DB 0 - DW 1C9h - DD DWord Ptr I_SampleUp - - DB 0 - DW 1D1h - DD DWord Ptr I_SampleDown - - DB 1 - DW '<' - DD DWord Ptr I_DecreasePlayChannel - - DB 1 - DW '>' - DD DWord Ptr I_IncreasePlayChannel - - DB 1 - DW ',' - DD DWord Ptr I_DecreasePlayChannel - - DB 1 - DW '.' - DD DWord Ptr I_IncreasePlayChannel - - DB 1 - DW 1E00h ; Alt 'A' - DD DWord Ptr I_ConvertSample - - DB 1 - DW 3000h ; Alt 'B' - DD DWord Ptr I_CutSampleBeforeLoop - - DB 1 - DW 2000h ; Alt 'D' - DD DWord Ptr I_DeleteSample - - DB 1 - DW 1200h ; Alt 'E' - DD DWord Ptr I_ResizeSample - - DB 1 - DW 2100h ; Alt 'F' - DD DWord Ptr I_ResizeSampleNoInt - - DB 1 - DW 2200h ; Alt 'G' - DD DWord Ptr I_ReverseSample - - DB 1 - DW 2300h ; Alt 'H' - DD DWord Ptr I_CenterSample - - DB 1 - DW 1700h ; Alt 'I' - DD DWord Ptr I_InvertSample - - DB 1 ; Alt 'J' - DW 2400h - DD DWord Ptr I_ScaleSampleVolumes - - DB 1 - DW 2600h ; Alt 'L' - DD DWord Ptr I_CutSample - - DB 1 - DW 3200h ; Alt 'M' - DD DWord Ptr I_AmplifySample - - DB 1 - DW 3100h ; Alt 'N' - DD DWord Ptr I_ToggleMultiChannel - - DB 1 - DW 1800h ; Alt 'O' - DD DWord Ptr D_SaveSample - - DB 1 - DW 1000h ; Alt 'Q' - DD DWord Ptr I_ToggleSampleQuality - - DB 1 - DW 1300h ; Alt 'R' - DD DWord Ptr I_ReplaceSample - - DB 1 - DW 1F00h ; Alt 'S' - DD DWord Ptr I_SwapSamples - - DB 1 - DW 1400h ; Alt 'T' - DD DWord Ptr D_SaveST3Sample - - DB 1 - DW 1100h ; Alt 'W' - DD DWord Ptr D_SaveRawSample - - DB 1 - DW 2D00h ; Alt 'X' - DD DWord Ptr I_ExchangeSamples - - DB 1 ; Alt 'Y' - DW 1500h - DD DWord Ptr I_CalculateC5Speed - - - DB 2 ; Alt... - DW 14Eh ; Grey plus - DD DWord Ptr I_DoubleSampleSpeed - - DB 2 ; Alt... - DW 14Ah ; Grey minus - DD DWord Ptr I_HalveSampleSpeed - - DB 3 - DW 14Eh - DD DWord Ptr I_SampleSpeedSemiUp - - DB 3 - DW 14Ah - DD DWord Ptr I_SampleSpeedSemiDown - - DB 9 - DW 9000h - DD DWord Ptr MIDI_PlaySample - - DB 0 ; Enter... to load sample! - DW 11Ch - DD DWord Ptr Glbl_LoadSample - - DB 5 - DW Offset GlobalKeyList - -ScreenBox DW 0 ; Object type 0 - DB 0, 0, 79, 49 ; Coordinates - DB 7 ; Box style - -AboutBox DW 0 ; Object type 0 - DB 11, 16, 68, 34 ; Coordinates - DB 0 ; Box style - -AboutText DW 1 ; Object type 1 - DB 24, 19 - DB 02Bh - DB 0FFh, 1, 0, 4, 8, 0FFh, 8, 55, 37, 41, 0FFh, 5, 55, 56, 58, 62, 66, 0FFh, 6, 55, 88, 92, 13 - DB 1, 5, 9, 12, 15, 18, 22, 25, 28, 31, 34, 38, 42, 45, 48, 51, 55, 55, 57, 59, 63, 67, 70, 73, 76, 79, 82, 85, 89, 93, 96, 99, 102, 105, 13 - DB 2, 6, 0FFh, 1, 10, 0FFh, 1, 13, 16, 19, 23, 26, 29, 32, 35, 39, 43, 46, 49, 52, 54, 55, 55, 60, 64, 68, 71, 74, 77, 80, 83, 86, 90, 94, 97, 100, 103, 106, 13 - DB 3, 7, 11, 14, 17, 20, 24, 27, 30, 33, 36, 40, 44, 47, 50, 53, 55, 55, 55, 61, 65, 69, 72, 75, 78, 81, 84, 87, 91, 95, 98, 101, 104, 107, 13 - DB 0FFh, 5, 55, 21, 0 -; DB 0FEh, 20h -; DB " http://www.citenet.net/noise/it", 0 - -AutoContinueButton DW 2 ; Object type 2 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 ; Button usage type - DW 0, 0 ; ???? - DW 4 ; New List - DD DWord Ptr Glbl_F9 - DW 0, 0, 0 ; ???? - DB 32, 31, 47, 33 ; Left/Top/Right/Bottom - DB 8 ; Box initial style - DB 0 ; Button Up - DB " Continue", 0 - -UpdateScreen DW 8 - DD DWord Ptr S_UpdateScreen - -Exit DW 4 ; Object type 4 - DW 0 ; Return value - -DirectScreen DW 5 ; Object type 5 - DB 1 - -InDirectScreen DW 5 ; Object type 5 - DB 0 - -ImpulseLogo DW 6 ; Object type 6 -LogoCharacter DW 256 ; First char to define - DW 108 - DB 0, 0, 0, 0, 1, 7, 15, 31 ; 0 - DB 63, 127, 127, 254, 252, 255, 255, 126 ; 1 - DB 24, 0, 0, 0, 0, 0, 0, 0 ; 2 - DB 0, 1, 3, 3, 3, 1, 0, 0 ; 3 - DB 7, 31, 63, 255, 255, 254, 248, 240 ; 4 - DB 192, 128, 0, 1, 1, 131, 3, 7 ; 5 - DB 7, 15, 14, 30, 60, 60, 120, 240 ; 6 - DB 240, 224, 224, 224, 224, 192, 0, 0 ; 7 - DB 240, 240, 248, 248, 248, 120, 56, 120 ; 8 - DB 112, 240, 240, 224, 224, 192, 192, 131 ; 9 - DB 7, 15, 31, 31, 62, 60, 61, 63 ; 10 - DB 63, 63, 62, 28, 8, 0, 0, 0 ; 11 - DB 0, 0, 0, 0, 0, 0, 193, 227 ; 12 - DB 199, 223, 191, 127, 247, 239, 207, 159 ; 13 - DB 31, 31, 63, 60, 24, 0, 0, 0 ; 14 - DB 0, 0, 0, 0, 0, 240, 240, 240 ; 15 - DB 241, 227, 239, 223, 191, 251, 247, 231 ; 16 - DB 159, 159, 31, 31, 14, 0, 0, 0 ; 17 - DB 0, 0, 0, 0, 0, 48, 112, 248 ; 18 - DB 248, 240, 224, 192, 193, 131, 7, 30 ; 19 - DB 252, 240, 225, 131, 3, 7, 7, 15 ; 20 - DB 15, 30, 30, 28, 8, 0, 0, 0 ; 21 - DB 0, 0, 0, 1, 3, 3, 7, 15 ; 22 - DB 31, 63, 127, 255, 191, 190, 124, 126 ; 23 - DB 255, 255, 255, 255, 199, 128, 128, 0 ; 24 - DB 60, 124, 248, 240, 224, 192, 135, 159 ; 25 - DB 127, 255, 223, 143, 30, 60, 56, 113 ; 26 - DB 255, 255, 252, 240, 192, 0, 0, 0 ; 27 - DB 0, 0, 0, 0, 0, 0, 128, 129 ; 28 - DB 131, 135, 15, 15, 30, 60, 124, 253 ; 29 - DB 191, 31, 31, 14, 0, 0, 0, 0 ; 30 - DB 0, 0, 0, 0, 0, 112, 248, 240 ; 31 - DB 225, 195, 135, 15, 31, 63, 127, 255 ; 32 - DB 239, 223, 159, 15, 14, 0, 0, 0 ; 33 - DB 0, 0, 0, 0, 24, 56, 124, 248 ; 34 - DB 248, 241, 225, 193, 129, 131, 15, 31 ; 35 - DB 249, 241, 225, 192, 0, 0, 0, 0 ; 36 - DB 0, 0, 0, 0, 0, 0, 1, 3 ; 37 - DB 7, 15, 30, 61, 57, 123, 119, 254 ; 38 - DB 252, 248, 240, 224, 192, 192, 192, 225 ; 39 - DB 247, 255, 254, 252, 0, 0, 0, 0 ; 40 - DB 0, 0, 24, 56, 120, 248, 248, 240 ; 41 - DB 112, 96, 224, 192, 192, 128, 0, 1 ; 42 - DB 3, 7, 14, 28, 56, 112, 248, 252 ; 43 - DB 255, 127, 63, 31, 7, 0, 0, 0 ; 44 - DB 0, 0, 0, 48, 120, 120, 248, 248 ; 45 - DB 252, 124, 124, 120, 120, 112, 241, 231 ; 46 - DB 142, 252, 248, 224, 128, 0, 0, 0 ; 47 - DB 0, 0, 0, 0, 0, 0, 3, 7 ; 48 - DB 15, 30, 60, 63, 127, 254, 252, 60 ; 49 - DB 126, 63, 63, 31, 6, 0, 0, 0 ; 50 - DB 0, 0, 0, 0, 60, 254, 254, 222 ; 51 - DB 30, 60, 248, 224, 128, 1, 7, 14 ; 52 - DB 124, 248, 224, 192, 0, 0, 0, 0 ; 53 - DB 0, 0, 0, 0, 128, 128, 0, 0 ; 54 - DB 0, 0, 0, 0, 0, 0, 0, 0 ; 55 - DB 0, 0, 7, 31, 63, 127, 127, 255 ; 56 - DB 255, 252, 127, 0, 0, 0, 0, 0 ; 57 - DB 3, 255, 255, 255, 255, 255, 255, 252 ; 58 - DB 128, 0, 0, 0, 0, 0, 0, 0 ; 59 - DB 0, 0, 0, 1, 1, 3, 3, 7 ; 60 - DB 7, 15, 31, 31, 31, 30, 0, 0 ; 61 - DB 255, 255, 255, 255, 255, 255, 255, 0 ; 62 - DB 0, 1, 3, 7, 7, 15, 31, 62 ; 63 - DB 60, 124, 248, 248, 240, 240, 224, 224 ; 64 - DB 192, 192, 128, 128, 0, 0, 0, 0 ; 65 - DB 128, 224, 240, 240, 248, 248, 248, 112 ; 66 - DB 240, 224, 192, 192, 128, 6, 15, 31 ; 67 - DB 63, 127, 127, 112, 33, 97, 195, 131 ; 68 - DB 7, 7, 7, 3, 1, 0, 0, 0 ; 69 - DB 0, 0, 0, 0, 0, 0, 252, 254 ; 70 - DB 254, 252, 248, 240, 224, 193, 195, 199 ; 71 - DB 223, 253, 240, 224, 128, 0, 0, 0 ; 72 - DB 0, 0, 0, 0, 0, 0, 0, 3 ; 73 - DB 15, 31, 63, 124, 248, 240, 225, 195 ; 74 - DB 199, 254, 252, 120, 48, 0, 0, 0 ; 75 - DB 0, 0, 0, 0, 0, 31, 255, 255 ; 76 - DB 255, 255, 191, 63, 126, 252, 248, 184 ; 77 - DB 63, 127, 127, 126, 124, 48, 0, 0 ; 78 - DB 0, 0, 0, 0, 0, 0, 128, 128 ; 79 - DB 129, 3, 7, 15, 15, 31, 62, 126 ; 80 - DB 239, 207, 143, 7, 3, 0, 0, 0 ; 81 - DB 0, 0, 0, 0, 0, 15, 63, 255 ; 82 - DB 255, 255, 238, 204, 0, 0, 0, 3 ; 83 - DB 15, 255, 254, 248, 224, 0, 0, 0 ; 84 - DB 0, 0, 0, 0, 0, 193, 195, 131 ; 85 - DB 135, 15, 15, 31, 63, 127, 255, 255 ; 86 - DB 190, 60, 28, 24, 0, 0, 0, 0 ; 87 - DB 0, 0, 0, 0, 0, 1, 3, 7 ; 88 - DB 15, 31, 63, 126, 252, 248, 240, 227 ; 89 - DB 199, 223, 188, 112, 225, 199, 254, 252 ; 90 - DB 252, 126, 127, 63, 31, 0, 0, 0 ; 91 - DB 0, 12, 60, 124, 248, 248, 240, 224 ; 92 - DB 192, 128, 0, 0, 0, 48, 248, 248 ; 93 - DB 248, 120, 241, 225, 195, 3, 15, 31 ; 94 - DB 59, 243, 227, 129, 0, 0, 0, 0 ; 95 - DB 0, 0, 0, 0, 1, 15, 31, 62 ; 96 - DB 120, 241, 231, 239, 252, 240, 192, 192 ; 97 - DB 227, 255, 255, 252, 112, 0, 0, 0 ; 98 - DB 0, 0, 0, 0, 192, 240, 241, 243 ; 99 - DB 231, 207, 143, 14, 12, 28, 56, 112 ; 100 - DB 225, 193, 1, 0, 0, 0, 0, 0 ; 101 - DB 0, 0, 0, 0, 0, 192, 255, 255 ; 102 - DB 255, 255, 254, 60, 120, 112, 240, 241 ; 103 - DB 247, 255, 252, 248, 96, 0, 0, 0 ; 104 - DB 0, 0, 0, 0, 0, 0, 0, 128 ; 105 - DB 128, 0, 0, 0, 0, 0, 0, 192 ; 106 - DB 192, 0, 0, 0, 0, 0, 0, 0 ; 107 - -O1_ConfirmConvertList DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmConvertSampleText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmConvert2List DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmConvertSampleText - DW Near Ptr ConfirmConvertYesButton - DW Near Ptr ConfirmConvertNoButton - DW 0 - -O1_SampleCenterList DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmCenterSampleText - DW Near Ptr ConfirmConvertYesButton - DW Near Ptr ConfirmConvertNoButton - DW 0 - -O1_EnableInstrumentMode DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr EnableInstrumentModeText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - - -O1_InitInstrument DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr InitInstrumentText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmInitialiseNoButton - DW 0 - -O1_ConfirmOverWriteList DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmOverWriteText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_InitialiseInstrumentList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmInitialiseText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmInitialiseNoButton - DW 0 - -O1_ConfirmDelete DW 4 - DW Near Ptr SongNameModuleLoader - DW Near Ptr OKCancelList - DW Near Ptr DrawFileNameWindow - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmDeleteText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmDelete2 DW 4 - DW Near Ptr SampleNameLoader - DW Near Ptr OKCancelList - DW Near Ptr DrawLoadSampleWindow - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmDeleteText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmDelete3 DW 4 - DW Near Ptr InstrumentNameLoader - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmDeleteText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - - -O1_ConfirmSaveRenameList DW 3 - DW Near Ptr SampleNameLoader - DW Near Ptr OKCancelList - DW Near Ptr DrawLoadSampleWindow - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmSaveRenameText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmResaveList DW 3 - DW Near Ptr SampleNameLoader - DW Near Ptr OKCancelList - DW Near Ptr DrawLoadSampleWindow - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmResaveText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmDiscardList DW 3 - DW Near Ptr SampleNameLoader - DW Near Ptr OKCancelList - DW Near Ptr DrawLoadSampleWindow - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmDiscardText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmCutSample DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmCutSampleText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmDeleteSample DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmDeleteSampleText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmDeleteInstrument DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmDeleteInstrumentText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmClearMessage DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmClearMessageText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_ConfirmNoSave DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmNoSaveBox - DW Near Ptr ConfirmNoSaveMessage - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -EmptyObject DW 8 - DD DWord Ptr F_Nothing - -DrawFileNameWindow DW 8 - DD DWord Ptr D_DrawFileWindow - -DrawLoadSampleWindow DW 8 - DD DWord Ptr D_DrawLoadSampleWindow - -DrawLoadInstrumentWindow DW 8 - DD DWord Ptr D_DrawLoadInstrument - -ConfirmOverWriteBox DW 0 ; Box Object - DB 26, 25, 54, 32 - DB 3 - -ConfirmNosaveBox DW 0 ; Box Object - DB 20, 25, 60, 32 - DB 3 - -EnableInstrumentModeText DW 1 - DB 29, 27 - DB 20h - DB "Enable Instrument mode?", 0 - -ConfirmCenterSampleText DW 1 - DB 31, 27 - DB 20h - DB "Centralise sample?", 0 - -ConfirmOverWriteText DW 1 - DB 33, 27 - DB 20h - DB "Overwrite file?", 0 - -ConfirmDeleteText DW 1 - DB 35, 27 - DB 20h - DB "Delete file?", 0 - -ConfirmDeleteSampleText DW 1 - DB 34, 27 - DB 20h - DB "Delete sample?", 0 - -ConfirmDeleteInstrumentText DW 1 - DB 32, 27 - DB 20h - DB "Delete instrument?", 0 - -ConfirmClearMessageText DW 1 - DB 31, 27 - DB 20h - DB "Clear song message?", 0 - -ConfirmNoSaveMessage DW 1 - DB 23, 27 - DB 20h - DB "Current module not saved. Proceed?", 0 - -ConfirmSaveRenameText DW 1 - DB 31, 27 - DB 20h - DB "Save/Rename sample?", 0 - -ConfirmDiscardText DW 1 - DB 33, 27 - DB 20h - DB "Discard changes?", 0 - -ConfirmResaveText DW 1 - DB 35, 27 - DB 20h - DB "Save sample?", 0 - -InitInstrumentText DW 1 - DB 29, 27 - DB 20h - DB "Create host instrument?", 0 - -ConfirmConvertSampleText DW 1 - DB 33, 27 - DB 20h - DB "Convert sample?", 0 - -ConfirmInitialiseText DW 1 - DB 29, 27 - DB 20h - DB "Initialise instruments?", 0 - -ConfirmCutSampleText DW 1 - DB 35, 27 - DB 20h - DB "Cut sample?", 0 - -ConfirmQuitText DW 1 - DB 30, 27 - DB 20h - DB "Exit Impulse Tracker?", 0 - -ConfirmOverWriteOKButton DW 2 - DW 0FFFFh, 0FFFFh, 4, 4 - DW 0 - DW 0, 0 - DW 0 - DW 1 ; Return OK to overwrite - DW 0, 0, 0, 0 - DB 30, 29, 39, 31 - DB 8 - DB 0 - DB " OK", 0 - -ConfirmOverWriteCancelButton DW 2 - DW 0FFFFh, 0FFFFh, 3, 3 - DW 0 - DW 0, 0 - DW 0 - DW 0 ; Returns 0 - DW 0, 0, 0, 0 - DB 41, 29, 50, 31 - DB 8 - DB 0 - DB " Cancel", 0 - -ConfirmConvertYesButton DW 2 - DW 0FFFFh, 0FFFFh, 4, 4 - DW 0 - DW 0, 0 - DW 0 - DW 1 ; Return 1 - DW 0, 0, 0, 0 - DB 29, 29, 39, 31 - DB 8 - DB 0 - DB " Yes", 0 - -ConfirmConvertNoButton DW 2 - DW 0FFFFh, 0FFFFh, 3, 3 - DW 0 - DW 0, 0 - DW 0 - DW 2 ; Returns 2 - DW 0, 0, 0, 0 - DB 41, 29, 50, 31 - DB 8 - DB 0 - DB " No", 0 - -ConfirmInitialiseNoButton DW 2 - DW 0FFFFh, 0FFFFh, 3, 3 - DW 0 - DW 0, 0 - DW 0 - DW 0 ; Returns 0 - DW 0, 0, 0, 0 - DB 41, 29, 50, 31 - DB 8 - DB 0 - DB " No", 0 - -O1_UnableToSaveList DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr UnableToSaveText - DW Near Ptr NoSaveOKButton - DW 0 - -UnableToSaveText DW 1 - DB 31, 27 - DB 20h - DB "Unable to save file", 0 - -NoSaveOKButton DW 2 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 0 - DW 1 - DW 0, 0, 0, 0 - DB 36, 29, 45, 31 - DB 8 - DB 0 - DB " OK", 0 - -O1_ConfirmQuit DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr EmptyObject - DW Near Ptr ConfirmOverWriteBox - DW Near Ptr ConfirmQuitText - DW Near Ptr ConfirmOverWriteOKButton - DW Near Ptr ConfirmOverWriteCancelButton - DW 0 - -O1_SelectMultiChannel DW 7 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr SMCBox ; 0 - DW Near Ptr SMCText ; 1 - DW Near Ptr SMCInBox1 ; 2 - DW Near Ptr SMCInBox2 ; 3 - DW Near Ptr SMCInBox3 ; 4 - DW Near Ptr SMCInBox4 ; 5 - DW Near Ptr SMCDrawChannel ; 6 - DW Near Ptr SMCChannel00Toggle ; 7 - DW Near Ptr SMCChannel01Toggle - DW Near Ptr SMCChannel02Toggle - DW Near Ptr SMCChannel03Toggle - DW Near Ptr SMCChannel04Toggle - DW Near Ptr SMCChannel05Toggle - DW Near Ptr SMCChannel06Toggle - DW Near Ptr SMCChannel07Toggle - DW Near Ptr SMCChannel08Toggle - DW Near Ptr SMCChannel09Toggle - DW Near Ptr SMCChannel10Toggle - DW Near Ptr SMCChannel11Toggle - DW Near Ptr SMCChannel12Toggle - DW Near Ptr SMCChannel13Toggle - DW Near Ptr SMCChannel14Toggle - DW Near Ptr SMCChannel15Toggle - DW Near Ptr SMCChannel16Toggle - DW Near Ptr SMCChannel17Toggle - DW Near Ptr SMCChannel18Toggle - DW Near Ptr SMCChannel19Toggle - DW Near Ptr SMCChannel20Toggle - DW Near Ptr SMCChannel21Toggle - DW Near Ptr SMCChannel22Toggle - DW Near Ptr SMCChannel23Toggle - DW Near Ptr SMCChannel24Toggle - DW Near Ptr SMCChannel25Toggle - DW Near Ptr SMCChannel26Toggle - DW Near Ptr SMCChannel27Toggle - DW Near Ptr SMCChannel28Toggle - DW Near Ptr SMCChannel29Toggle - DW Near Ptr SMCChannel30Toggle - DW Near Ptr SMCChannel31Toggle - DW Near Ptr SMCChannel32Toggle - DW Near Ptr SMCChannel33Toggle - DW Near Ptr SMCChannel34Toggle - DW Near Ptr SMCChannel35Toggle - DW Near Ptr SMCChannel36Toggle - DW Near Ptr SMCChannel37Toggle - DW Near Ptr SMCChannel38Toggle - DW Near Ptr SMCChannel39Toggle - DW Near Ptr SMCChannel40Toggle - DW Near Ptr SMCChannel41Toggle - DW Near Ptr SMCChannel42Toggle - DW Near Ptr SMCChannel43Toggle - DW Near Ptr SMCChannel44Toggle - DW Near Ptr SMCChannel45Toggle - DW Near Ptr SMCChannel46Toggle - DW Near Ptr SMCChannel47Toggle - DW Near Ptr SMCChannel48Toggle - DW Near Ptr SMCChannel49Toggle - DW Near Ptr SMCChannel50Toggle - DW Near Ptr SMCChannel51Toggle - DW Near Ptr SMCChannel52Toggle - DW Near Ptr SMCChannel53Toggle - DW Near Ptr SMCChannel54Toggle - DW Near Ptr SMCChannel55Toggle - DW Near Ptr SMCChannel56Toggle - DW Near Ptr SMCChannel57Toggle - DW Near Ptr SMCChannel58Toggle - DW Near Ptr SMCChannel59Toggle - DW Near Ptr SMCChannel60Toggle - DW Near Ptr SMCChannel61Toggle - DW Near Ptr SMCChannel62Toggle - DW Near Ptr SMCChannel63Toggle ; 70 - DW Near Ptr SMCOKButton ; 71 - DW 0 - -SMCBox DW 0 - DB 7, 18, 72, 42 - DB 3 - -SMCInBox1 DW 0 - DB 19, 21, 23, 38 - DB 27 - -SMCInBox2 DW 0 - DB 35, 21, 39, 38 - DB 27 - -SMCInBox3 DW 0 - DB 51, 21, 55, 38 - DB 27 - -SMCInBox4 DW 0 - DB 67, 21, 71, 38 - DB 27 - -SMCText DW 1 - DB 29, 19 - DB 23h - DB "Multichannel Selection", 0 - -SMCDrawChannel DW 8 - DD DWord Ptr F_DrawSMCChannels - -SMCChannel00Toggle DW 17 - DB 20, 22 - DW 1 - DW Offset MultiChannelInfo+00 - DB 1 - DW 71, 8, 23, 55 - -SMCChannel01Toggle DW 17 - DB 20, 23 - DW 1 - DW Offset MultiChannelInfo+01 - DB 1 - DW 7, 9, 24, 56 - -SMCChannel02Toggle DW 17 - DB 20, 24 - DW 1 - DW Offset MultiChannelInfo+02 - DB 1 - DW 8, 10, 25, 57 - -SMCChannel03Toggle DW 17 - DB 20, 25 - DW 1 - DW Offset MultiChannelInfo+03 - DB 1 - DW 9, 11, 26, 58 - -SMCChannel04Toggle DW 17 - DB 20, 26 - DW 1 - DW Offset MultiChannelInfo+04 - DB 1 - DW 10, 12, 27, 59 - -SMCChannel05Toggle DW 17 - DB 20, 27 - DW 1 - DW Offset MultiChannelInfo+05 - DB 1 - DW 11, 13, 28, 60 - -SMCChannel06Toggle DW 17 - DB 20, 28 - DW 1 - DW Offset MultiChannelInfo+06 - DB 1 - DW 12, 14, 29, 61 - -SMCChannel07Toggle DW 17 - DB 20, 29 - DW 1 - DW Offset MultiChannelInfo+07 - DB 1 - DW 13, 15, 30, 62 - -SMCChannel08Toggle DW 17 - DB 20, 30 - DW 1 - DW Offset MultiChannelInfo+08 - DB 1 - DW 14, 16, 31, 63 - -SMCChannel09Toggle DW 17 - DB 20, 31 - DW 1 - DW Offset MultiChannelInfo+09 - DB 1 - DW 15, 17, 32, 64 - -SMCChannel10Toggle DW 17 - DB 20, 32 - DW 1 - DW Offset MultiChannelInfo+10 - DB 1 - DW 16, 18, 33, 65 - -SMCChannel11Toggle DW 17 - DB 20, 33 - DW 1 - DW Offset MultiChannelInfo+11 - DB 1 - DW 17, 19, 34, 66 - -SMCChannel12Toggle DW 17 - DB 20, 34 - DW 1 - DW Offset MultiChannelInfo+12 - DB 1 - DW 18, 20, 35, 67 - -SMCChannel13Toggle DW 17 - DB 20, 35 - DW 1 - DW Offset MultiChannelInfo+13 - DB 1 - DW 19, 21, 36, 68 - -SMCChannel14Toggle DW 17 - DB 20, 36 - DW 1 - DW Offset MultiChannelInfo+14 - DB 1 - DW 20, 22, 37, 69 - -SMCChannel15Toggle DW 17 - DB 20, 37 - DW 1 - DW Offset MultiChannelInfo+15 - DB 1 - DW 21, 71, 38, 70 - -SMCChannel16Toggle DW 17 - DB 36, 22 - DW 1 - DW Offset MultiChannelInfo+16 - DB 1 - DW 71, 24, 39, 7 - -SMCChannel17Toggle DW 17 - DB 36, 23 - DW 1 - DW Offset MultiChannelInfo+17 - DB 1 - DW 23, 25, 40, 8 - -SMCChannel18Toggle DW 17 - DB 36, 24 - DW 1 - DW Offset MultiChannelInfo+18 - DB 1 - DW 24, 26, 41, 9 - -SMCChannel19Toggle DW 17 - DB 36, 25 - DW 1 - DW Offset MultiChannelInfo+19 - DB 1 - DW 25, 27, 42, 10 - -SMCChannel20Toggle DW 17 - DB 36, 26 - DW 1 - DW Offset MultiChannelInfo+20 - DB 1 - DW 26, 28, 43, 11 - -SMCChannel21Toggle DW 17 - DB 36, 27 - DW 1 - DW Offset MultiChannelInfo+21 - DB 1 - DW 27, 29, 44, 12 - -SMCChannel22Toggle DW 17 - DB 36, 28 - DW 1 - DW Offset MultiChannelInfo+22 - DB 1 - DW 28, 30, 45, 13 - -SMCChannel23Toggle DW 17 - DB 36, 29 - DW 1 - DW Offset MultiChannelInfo+23 - DB 1 - DW 29, 31, 46, 14 - -SMCChannel24Toggle DW 17 - DB 36, 30 - DW 1 - DW Offset MultiChannelInfo+24 - DB 1 - DW 30, 32, 47, 15 - -SMCChannel25Toggle DW 17 - DB 36, 31 - DW 1 - DW Offset MultiChannelInfo+25 - DB 1 - DW 31, 33, 48, 16 - -SMCChannel26Toggle DW 17 - DB 36, 32 - DW 1 - DW Offset MultiChannelInfo+26 - DB 1 - DW 32, 34, 49, 17 - -SMCChannel27Toggle DW 17 - DB 36, 33 - DW 1 - DW Offset MultiChannelInfo+27 - DB 1 - DW 33, 35, 50, 18 - -SMCChannel28Toggle DW 17 - DB 36, 34 - DW 1 - DW Offset MultiChannelInfo+28 - DB 1 - DW 34, 36, 51, 19 - -SMCChannel29Toggle DW 17 - DB 36, 35 - DW 1 - DW Offset MultiChannelInfo+29 - DB 1 - DW 35, 37, 52, 20 - -SMCChannel30Toggle DW 17 - DB 36, 36 - DW 1 - DW Offset MultiChannelInfo+30 - DB 1 - DW 36, 38, 53, 21 - -SMCChannel31Toggle DW 17 - DB 36, 37 - DW 1 - DW Offset MultiChannelInfo+31 - DB 1 - DW 37, 71, 54, 22 - -SMCChannel32Toggle DW 17 - DB 52, 22 - DW 1 - DW Offset MultiChannelInfo+32 - DB 1 - DW 71, 40, 55, 23 - -SMCChannel33Toggle DW 17 - DB 52, 23 - DW 1 - DW Offset MultiChannelInfo+33 - DB 1 - DW 39, 41, 56, 24 - -SMCChannel34Toggle DW 17 - DB 52, 24 - DW 1 - DW Offset MultiChannelInfo+34 - DB 1 - DW 40, 42, 57, 25 - -SMCChannel35Toggle DW 17 - DB 52, 25 - DW 1 - DW Offset MultiChannelInfo+35 - DB 1 - DW 41, 43, 58, 26 - -SMCChannel36Toggle DW 17 - DB 52, 26 - DW 1 - DW Offset MultiChannelInfo+36 - DB 1 - DW 42, 44, 59, 27 - -SMCChannel37Toggle DW 17 - DB 52, 27 - DW 1 - DW Offset MultiChannelInfo+37 - DB 1 - DW 43, 45, 60, 28 - -SMCChannel38Toggle DW 17 - DB 52, 28 - DW 1 - DW Offset MultiChannelInfo+38 - DB 1 - DW 44, 46, 61, 29 - -SMCChannel39Toggle DW 17 - DB 52, 29 - DW 1 - DW Offset MultiChannelInfo+39 - DB 1 - DW 45, 47, 62, 30 - -SMCChannel40Toggle DW 17 - DB 52, 30 - DW 1 - DW Offset MultiChannelInfo+40 - DB 1 - DW 46, 48, 63, 31 - -SMCChannel41Toggle DW 17 - DB 52, 31 - DW 1 - DW Offset MultiChannelInfo+41 - DB 1 - DW 47, 49, 64, 32 - -SMCChannel42Toggle DW 17 - DB 52, 32 - DW 1 - DW Offset MultiChannelInfo+42 - DB 1 - DW 48, 50, 65, 33 - -SMCChannel43Toggle DW 17 - DB 52, 33 - DW 1 - DW Offset MultiChannelInfo+43 - DB 1 - DW 49, 51, 66, 34 - -SMCChannel44Toggle DW 17 - DB 52, 34 - DW 1 - DW Offset MultiChannelInfo+44 - DB 1 - DW 50, 52, 67, 35 - -SMCChannel45Toggle DW 17 - DB 52, 35 - DW 1 - DW Offset MultiChannelInfo+45 - DB 1 - DW 51, 53, 68, 36 - -SMCChannel46Toggle DW 17 - DB 52, 36 - DW 1 - DW Offset MultiChannelInfo+46 - DB 1 - DW 52, 54, 69, 37 - -SMCChannel47Toggle DW 17 - DB 52, 37 - DW 1 - DW Offset MultiChannelInfo+47 - DB 1 - DW 53, 71, 70, 38 - -SMCChannel48Toggle DW 17 - DB 68, 22 - DW 1 - DW Offset MultiChannelInfo+48 - DB 1 - DW 71, 56, 7, 39 - -SMCChannel49Toggle DW 17 - DB 68, 23 - DW 1 - DW Offset MultiChannelInfo+49 - DB 1 - DW 55, 57, 8, 40 - -SMCChannel50Toggle DW 17 - DB 68, 24 - DW 1 - DW Offset MultiChannelInfo+50 - DB 1 - DW 56, 58, 9, 41 - -SMCChannel51Toggle DW 17 - DB 68, 25 - DW 1 - DW Offset MultiChannelInfo+51 - DB 1 - DW 57, 59, 10, 42 - -SMCChannel52Toggle DW 17 - DB 68, 26 - DW 1 - DW Offset MultiChannelInfo+52 - DB 1 - DW 58, 60, 11, 43 - -SMCChannel53Toggle DW 17 - DB 68, 27 - DW 1 - DW Offset MultiChannelInfo+53 - DB 1 - DW 59, 61, 12, 44 - -SMCChannel54Toggle DW 17 - DB 68, 28 - DW 1 - DW Offset MultiChannelInfo+54 - DB 1 - DW 60, 62, 13, 45 - -SMCChannel55Toggle DW 17 - DB 68, 29 - DW 1 - DW Offset MultiChannelInfo+55 - DB 1 - DW 61, 63, 14, 46 - -SMCChannel56Toggle DW 17 - DB 68, 30 - DW 1 - DW Offset MultiChannelInfo+56 - DB 1 - DW 62, 64, 15, 47 - -SMCChannel57Toggle DW 17 - DB 68, 31 - DW 1 - DW Offset MultiChannelInfo+57 - DB 1 - DW 63, 65, 16, 48 - -SMCChannel58Toggle DW 17 - DB 68, 32 - DW 1 - DW Offset MultiChannelInfo+58 - DB 1 - DW 64, 66, 17, 49 - -SMCChannel59Toggle DW 17 - DB 68, 33 - DW 1 - DW Offset MultiChannelInfo+59 - DB 1 - DW 65, 67, 18, 50 - -SMCChannel60Toggle DW 17 - DB 68, 34 - DW 1 - DW Offset MultiChannelInfo+60 - DB 1 - DW 66, 68, 19, 51 - -SMCChannel61Toggle DW 17 - DB 68, 35 - DW 1 - DW Offset MultiChannelInfo+61 - DB 1 - DW 67, 69, 20, 52 - -SMCChannel62Toggle DW 17 - DB 68, 36 - DW 1 - DW Offset MultiChannelInfo+62 - DB 1 - DW 68, 70, 21, 53 - -SMCChannel63Toggle DW 17 - DB 68, 37 - DW 1 - DW Offset MultiChannelInfo+63 - DB 1 - DW 69, 71, 22, 54 - -SMCOKButton DW 2 - DW 22, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 0 - DW 0 - DW 0, 0, 0, 0 - DB 35, 39, 44, 41 - DB 8 - DB 0 - DB " OK ", 0 - -O1_ExchangeSampleList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr ExchangeSampleBox - DW Near Ptr ExchangeSampleText - DW Near Ptr ExchangeSampleInputBox - DW Near Ptr ExchangeSampleInput ; 3 - DW Near Ptr CancelExchangeButton ; 4 - DW 0 - -O1_ReplaceSampleList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr ExchangeSampleBox - DW Near Ptr ReplaceSampleText - DW Near Ptr ExchangeSampleInputBox - DW Near Ptr ExchangeSampleInput ; 3 - DW Near Ptr CancelExchangeButton ; 4 - DW 0 - -O1_ReplaceInstrumentList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr ExchangeSampleBox - DW Near Ptr ReplaceInstrumentText - DW Near Ptr ExchangeSampleInputBox - DW Near Ptr ExchangeSampleInput ; 3 - DW Near Ptr CancelExchangeButton ; 4 - DW 0 - -O1_SwapSampleList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr ExchangeSampleBox - DW Near Ptr SwapSampleText - DW Near Ptr ExchangeSampleInputBox - DW Near Ptr ExchangeSampleInput ; 3 - DW Near Ptr CancelExchangeButton ; 4 - DW 0 - -O1_SwapInstrumentList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr ExchangeSampleBox - DW Near Ptr SwapInstrumentText - DW Near Ptr ExchangeSampleInputBox - DW Near Ptr ExchangeSampleInput ; 3 - DW Near Ptr CancelExchangeButton ; 4 - DW 0 - -O1_CopyInstrumentList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr ExchangeSampleBox - DW Near Ptr CopyInstrumentText - DW Near Ptr ExchangeSampleInputBox - DW Near Ptr ExchangeSampleInput ; 3 - DW Near Ptr CancelExchangeButton ; 4 - DW 0 - -O1_ExchangeInstrumentList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr OKCancelList - DW Near Ptr ExchangeSampleBox - DW Near Ptr ExchangeInstrumentText - DW Near Ptr ExchangeSampleInputBox - DW Near Ptr ExchangeSampleInput ; 3 - DW Near Ptr CancelExchangeButton ; 4 - DW 0 - -O1_ResizeSampleList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESC&ReturnList - DW Near Ptr ResizeSampleBox ; 0 - DW Near Ptr ResizeSampleText ; 1 - DW Near Ptr ResizeSampleInputBox ; 2 - DW Near Ptr ResizeSampleInput ; 3 - DW Near Ptr CancelExchangeButton - DW 0 - -ESCF2&ReturnList DB 0 - DW 13Ch - DD DWord Ptr F_Return0 - -ESC&ReturnList DB 0 - DW 101h - DD DWord Ptr F_Return0 - - DB 0 - DW 11Ch - DD DWord Ptr F_Return1 - - DB 5 - DW Near Ptr ChainMIDICommands - -ExchangeSampleBox DW 0 - DB 26, 23, 54, 32 - DB 3 - -ExchangeSampleText DW 1 - DB 30, 25 - DB 20h - DB "Exchange sample with:", 13 - DB 13 - DB 0FFh, 5, " Sample", 0 - -ResizeSampleBox DW 0 - DB 26, 22, 54, 32 - DB 3 - -ResizeSampleText DW 1 - DB 31, 24 - DB 23h - DB " Resize Sample", 13, 13 - DB 13, 0FEh, 20h - DB "New Length", 0 - -ResizeSampleInputBox DW 0 - DB 41, 26, 49, 28 - DB 27 - -ResizeSampleInput DW 18 - DB 42, 27 - DW 2 - DW Offset NewSampleSize - DD 0 - DW 0FFFFh, 4, 4, 0FFFFh - -SwapSampleText DW 1 - DB 32, 25 - DB 20h - DB "Swap sample with:", 13 - DB 13 - DB " Sample", 0 - -SwapInstrumentText DW 1 - DB 29, 25 - DB 20h - DB "Swap instrument with:", 13 - DB 13 - DB " Instrument", 0 - -CopyInstrumentText DW 1 - DB 31, 25 - DB 20h - DB " Copy instrument:", 13 - DB 13 - DB "Instrument", 0 - -ReplaceSampleText DW 1 - DB 30, 25 - DB 20h - DB "Replace sample with:", 13 - DB 13 - DB 0FFh, 5, " Sample", 0 - -ReplaceInstrumentText DW 1 - DB 28, 25 - DB 20h - DB "Replace instrument with:", 13 - DB 13 - DB " Instrument", 0 - -ExchangeInstrumentText DW 1 - DB 28, 25 - DB 20h - DB "Exchange instrument with:", 13 - DB 13 - DB " Instrument", 0 - -ExchangeSampleInputBox DW 0 - DB 41, 26, 45, 28 - DB 27 - -ExchangeSampleInput DW 16 - DB 42, 27 - DW 2 - DW Offset SampleNumberInput - DW 3 - DD DWord Ptr F_Return1 - DW 0FFFFh, 4, 4, 0FFFFh - -CancelExchangeButton DW 2 - DW 3, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 0 - DW 0 ; Returns 0 - DW 0, 0, 0, 0 - DB 35, 29, 44, 31 - DB 8 - DB 0 - DB " Cancel", 0 - - -O1_OrderVolumeList DW 10 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr FillHeader ; 2 - DW Near Ptr OrderandVolumeMsg ; 3 - DW Near Ptr OrderBox ; 4 - DW Near Ptr PanBox1 ; 5 - DW Near Ptr PanBox2 ; 6 - DW Near Ptr ShowChannelMsgs ; 7 - DW Near Ptr VolumeText1 ; 8 - DW Near Ptr VolumeText2 ; 9 - DW Near Ptr OrderList ; 10 - DW Near Ptr ChannelVol1 ; 11 - DW Near Ptr ChannelVol2 ; 12 - DW Near Ptr ChannelVol3 ; 13 - DW Near Ptr ChannelVol4 ; 14 - DW Near Ptr ChannelVol5 ; 15 - DW Near Ptr ChannelVol6 ; 16 - DW Near Ptr ChannelVol7 ; 17 - DW Near Ptr ChannelVol8 ; 18 - DW Near Ptr ChannelVol9 ; 19 - DW Near Ptr ChannelVol10 ; 20 - DW Near Ptr ChannelVol11 ; 21 - DW Near Ptr ChannelVol12 ; 22 - DW Near Ptr ChannelVol13 ; 23 - DW Near Ptr ChannelVol14 ; 24 - DW Near Ptr ChannelVol15 ; 25 - DW Near Ptr ChannelVol16 ; 26 - DW Near Ptr ChannelVol17 - DW Near Ptr ChannelVol18 - DW Near Ptr ChannelVol19 - DW Near Ptr ChannelVol20 - DW Near Ptr ChannelVol21 - DW Near Ptr ChannelVol22 - DW Near Ptr ChannelVol23 - DW Near Ptr ChannelVol24 - DW Near Ptr ChannelVol25 - DW Near Ptr ChannelVol26 - DW Near Ptr ChannelVol27 - DW Near Ptr ChannelVol28 - DW Near Ptr ChannelVol29 - DW Near Ptr ChannelVol30 - DW Near Ptr ChannelVol31 - DW Near Ptr ChannelVol32 - DW Near Ptr ChannelVol33 - DW Near Ptr ChannelVol34 - DW Near Ptr ChannelVol35 - DW Near Ptr ChannelVol36 - DW Near Ptr ChannelVol37 - DW Near Ptr ChannelVol38 - DW Near Ptr ChannelVol39 - DW Near Ptr ChannelVol40 - DW Near Ptr ChannelVol41 - DW Near Ptr ChannelVol42 - DW Near Ptr ChannelVol43 - DW Near Ptr ChannelVol44 - DW Near Ptr ChannelVol45 - DW Near Ptr ChannelVol46 - DW Near Ptr ChannelVol47 - DW Near Ptr ChannelVol48 - DW Near Ptr ChannelVol49 - DW Near Ptr ChannelVol50 - DW Near Ptr ChannelVol51 - DW Near Ptr ChannelVol52 - DW Near Ptr ChannelVol53 - DW Near Ptr ChannelVol54 - DW Near Ptr ChannelVol55 - DW Near Ptr ChannelVol56 - DW Near Ptr ChannelVol57 - DW Near Ptr ChannelVol58 - DW Near Ptr ChannelVol59 - DW Near Ptr ChannelVol60 - DW Near Ptr ChannelVol61 - DW Near Ptr ChannelVol62 - DW Near Ptr ChannelVol63 - DW Near Ptr ChannelVol64 ; 74 - DW Near Ptr SetHelpContext4 - DW 0 - -ChannelVol1 DW 9 ; Object 9 - DB 31, 15 ; x,y - DW 0, 64 ; Ranges - DW 4, 0+64 ; Volume/Channel 1 - DW 11, 12, 43, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 19 ; PgUp/PgDn - -ChannelVol2 DW 9 - DB 31, 16 - DW 0, 64 - DW 4, 1+64 ; Volume/Channel 2 - DW 11, 13, 44, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 20 ; PgUp/PgDn - -ChannelVol3 DW 9 ; Object 9 - DB 31, 17 ; x,y - DW 0, 64 ; Ranges - DW 4, 2+64 ; Volume/Channel 3 - DW 12, 14, 45, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 21 ; PgUp/PgDn - -ChannelVol4 DW 9 - DB 31, 18 - DW 0, 64 - DW 4, 3+64 ; Volume/Channel 4 - DW 13, 15, 46, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 22 ; PgUp/PgDn - -ChannelVol5 DW 9 ; Object 9 - DB 31, 19 ; x,y - DW 0, 64 ; Ranges - DW 4, 4+64 ; Volume/Channel 5 - DW 14, 16, 47, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 23 ; PgUp/PgDn - -ChannelVol6 DW 9 - DB 31, 20 - DW 0, 64 - DW 4, 5+64 ; Volume/Channel 6 - DW 15, 17, 48, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 24 ; PgUp/PgDn - -ChannelVol7 DW 9 ; Object 9 - DB 31, 21 ; x,y - DW 0, 64 ; Ranges - DW 4, 6+64 ; Volume/Channel 7 - DW 16, 18, 49, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 25 ; PgUp/PgDn - -ChannelVol8 DW 9 - DB 31, 22 - DW 0, 64 - DW 4, 7+64 ; Volume/Channel 8 - DW 17, 19, 50, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 26 ; PgUp/PgDn - -ChannelVol9 DW 9 ; Object 9 - DB 31, 23 ; x,y - DW 0, 64 ; Ranges - DW 4, 8+64 ; Volume/Channel 9 - DW 18, 20, 51, 10 ; Up/Down/Tab/Shift-Tab - DW 11, 27 ; PgUp/PgDn - -ChannelVol10 DW 9 - DB 31, 24 - DW 0, 64 - DW 4, 9+64 ; Volume/Channel 10 - DW 19, 21, 52, 10 ; Up/Down/Tab/Shift-Tab - DW 12, 28 ; PgUp/PgDn - -ChannelVol11 DW 9 ; Object 9 - DB 31, 25 ; x,y - DW 0, 64 ; Ranges - DW 4, 10+64 ; Volume/Channel 11 - DW 20, 22, 53, 10 ; Up/Down/Tab/Shift-Tab - DW 13, 29 ; PgUp/PgDn - -ChannelVol12 DW 9 - DB 31, 26 - DW 0, 64 - DW 4, 11+64 ; Volume/Channel 12 - DW 21, 23, 54, 10 ; Up/Down/Tab/Shift-Tab - DW 14, 30 ; PgUp/PgDn - -ChannelVol13 DW 9 ; Object 9 - DB 31, 27 ; x,y - DW 0, 64 ; Ranges - DW 4, 12+64 ; Volume/Channel 13 - DW 22, 24, 55, 10 ; Up/Down/Tab/Shift-Tab - DW 15, 31 ; PgUp/PgDn - -ChannelVol14 DW 9 - DB 31, 28 - DW 0, 64 - DW 4, 13+64 ; Volume/Channel 14 - DW 23, 25, 56, 10 ; Up/Down/Tab/Shift-Tab - DW 16, 32 ; PgUp/PgDn - -ChannelVol15 DW 9 ; Object 9 - DB 31, 29 ; x,y - DW 0, 64 ; Ranges - DW 4, 14+64 ; Volume/Channel 15 - DW 24, 26, 57, 10 ; Up/Down/Tab/Shift-Tab - DW 17, 33 ; PgUp/PgDn - -ChannelVol16 DW 9 - DB 31, 30 - DW 0, 64 - DW 4, 15+64 ; Volume/Channel 16 - DW 25, 27, 58, 10 ; Up/Down/Tab/Shift-Tab - DW 18, 34 ; PgUp/PgDn - -ChannelVol17 DW 9 ; Object 9 - DB 31, 31 ; x,y - DW 0, 64 ; Ranges - DW 4, 16+64 ; Volume/Channel 17 - DW 26, 28, 59, 10 ; Up/Down/Tab/Shift-Tab - DW 19, 35 ; PgUp/PgDn - -ChannelVol18 DW 9 - DB 31, 32 - DW 0, 64 - DW 4, 17+64 ; Volume/Channel 18 - DW 27, 29, 60, 10 ; Up/Down/Tab/Shift-Tab - DW 20, 36 ; PgUp/PgDn - -ChannelVol19 DW 9 ; Object 9 - DB 31, 33 ; x,y - DW 0, 64 ; Ranges - DW 4, 18+64 ; Volume/Channel 19 - DW 28, 30, 61, 10 ; Up/Down/Tab/Shift-Tab - DW 21, 37 ; PgUp/PgDn - -ChannelVol20 DW 9 - DB 31, 34 - DW 0, 64 - DW 4, 19+64 ; Volume/Channel 20 - DW 29, 31, 62, 10 ; Up/Down/Tab/Shift-Tab - DW 22, 38 ; PgUp/PgDn - -ChannelVol21 DW 9 ; Object 9 - DB 31, 35 ; x,y - DW 0, 64 ; Ranges - DW 4, 20+64 ; Volume/Channel 21 - DW 30, 32, 63, 10 ; Up/Down/Tab/Shift-Tab - DW 23, 39 ; PgUp/PgDn - -ChannelVol22 DW 9 - DB 31, 36 - DW 0, 64 - DW 4, 21+64 ; Volume/Channel 22 - DW 31, 33, 64, 10 ; Up/Down/Tab/Shift-Tab - DW 24, 40 ; PgUp/PgDn - -ChannelVol23 DW 9 ; Object 9 - DB 31, 37 ; x,y - DW 0, 64 ; Ranges - DW 4, 22+64 ; Volume/Channel 23 - DW 32, 34, 65, 10 ; Up/Down/Tab/Shift-Tab - DW 25, 41 ; PgUp/PgDn - -ChannelVol24 DW 9 - DB 31, 38 - DW 0, 64 - DW 4, 23+64 ; Volume/Channel 24 - DW 33, 35, 66, 10 ; Up/Down/Tab/Shift-Tab - DW 26, 42 ; PgUp/PgDn - -ChannelVol25 DW 9 ; Object 9 - DB 31, 39 ; x,y - DW 0, 64 ; Ranges - DW 4, 24+64 ; Volume/Channel 25 - DW 34, 36, 67, 10 ; Up/Down/Tab/Shift-Tab - DW 27, 43 ; PgUp/PgDn - -ChannelVol26 DW 9 - DB 31, 40 - DW 0, 64 - DW 4, 25+64 ; Volume/Channel 26 - DW 35, 37, 68, 10 ; Up/Down/Tab/Shift-Tab - DW 28, 44 ; PgUp/PgDn - -ChannelVol27 DW 9 ; Object 9 - DB 31, 41 ; x,y - DW 0, 64 ; Ranges - DW 4, 26+64 ; Volume/Channel 27 - DW 36, 38, 69, 10 ; Up/Down/Tab/Shift-Tab - DW 29, 45 ; PgUp/PgDn - -ChannelVol28 DW 9 - DB 31, 42 - DW 0, 64 - DW 4, 27+64 ; Volume/Channel 28 - DW 37, 39, 70, 10 ; Up/Down/Tab/Shift-Tab - DW 30, 46 ; PgUp/PgDn - -ChannelVol29 DW 9 ; Object 9 - DB 31, 43 ; x,y - DW 0, 64 ; Ranges - DW 4, 28+64 ; Volume/Channel 29 - DW 38, 40, 71, 10 ; Up/Down/Tab/Shift-Tab - DW 31, 47 ; PgUp/PgDn - -ChannelVol30 DW 9 - DB 31, 44 - DW 0, 64 - DW 4, 29+64 ; Volume/Channel 30 - DW 39, 41, 72, 10 ; Up/Down/Tab/Shift-Tab - DW 32, 48 ; PgUp/PgDn - -ChannelVol31 DW 9 ; Object 9 - DB 31, 45 ; x,y - DW 0, 64 ; Ranges - DW 4, 30+64 ; Volume/Channel 31 - DW 40, 42, 73, 10 ; Up/Down/Tab/Shift-Tab - DW 33, 49 ; PgUp/PgDn - -ChannelVol32 DW 9 - DB 31, 46 - DW 0, 64 - DW 4, 31+64 ; Volume/Channel 32 - DW 41, 43, 74, 10 ; Up/Down/Tab/Shift-Tab - DW 34, 50 ; PgUp/PgDn - -ChannelVol33 DW 9 ; Object 9 - DB 65, 15 ; x,y - DW 0, 64 ; Ranges - DW 4, 32+64 ; Volume/Channel 33 - DW 42, 44, 10, 11 ; Up/Down/Tab/Shift-Tab - DW 35, 51 ; PgUp/PgDn - -ChannelVol34 DW 9 - DB 65, 16 - DW 0, 64 - DW 4, 33+64 ; Volume/Channel 34 - DW 43, 45, 10, 12 ; Up/Down/Tab/Shift-Tab - DW 36, 52 ; PgUp/PgDn - -ChannelVol35 DW 9 ; Object 9 - DB 65, 17 ; x,y - DW 0, 64 ; Ranges - DW 4, 34+64 ; Volume/Channel 35 - DW 44, 46, 10, 13 ; Up/Down/Tab/Shift-Tab - DW 37, 53 ; PgUp/PgDn - -ChannelVol36 DW 9 - DB 65, 18 - DW 0, 64 - DW 4, 35+64 ; Volume/Channel 36 - DW 45, 47, 10, 14 ; Up/Down/Tab/Shift-Tab - DW 38, 54 ; PgUp/PgDn - -ChannelVol37 DW 9 ; Object 9 - DB 65, 19 ; x,y - DW 0, 64 ; Ranges - DW 4, 36+64 ; Volume/Channel 37 - DW 46, 48, 10, 15 ; Up/Down/Tab/Shift-Tab - DW 39, 55 ; PgUp/PgDn - -ChannelVol38 DW 9 - DB 65, 20 - DW 0, 64 - DW 4, 37+64 ; Volume/Channel 38 - DW 47, 49, 10, 16 ; Up/Down/Tab/Shift-Tab - DW 40, 56 ; PgUp/PgDn - -ChannelVol39 DW 9 ; Object 9 - DB 65, 21 ; x,y - DW 0, 64 ; Ranges - DW 4, 38+64 ; Volume/Channel 39 - DW 48, 50, 10, 17 ; Up/Down/Tab/Shift-Tab - DW 41, 57 ; PgUp/PgDn - -ChannelVol40 DW 9 - DB 65, 22 - DW 0, 64 - DW 4, 39+64 ; Volume/Channel 40 - DW 49, 51, 10, 18 ; Up/Down/Tab/Shift-Tab - DW 42, 58 ; PgUp/PgDn - -ChannelVol41 DW 9 ; Object 9 - DB 65, 23 ; x,y - DW 0, 64 ; Ranges - DW 4, 40+64 ; Volume/Channel 41 - DW 50, 52, 10, 19 ; Up/Down/Tab/Shift-Tab - DW 43, 59 ; PgUp/PgDn - -ChannelVol42 DW 9 - DB 65, 24 - DW 0, 64 - DW 4, 41+64 ; Volume/Channel 42 - DW 51, 53, 10, 20 ; Up/Down/Tab/Shift-Tab - DW 44, 60 ; PgUp/PgDn - -ChannelVol43 DW 9 ; Object 9 - DB 65, 25 ; x,y - DW 0, 64 ; Ranges - DW 4, 42+64 ; Volume/Channel 43 - DW 52, 54, 10, 21 ; Up/Down/Tab/Shift-Tab - DW 45, 61 ; PgUp/PgDn - -ChannelVol44 DW 9 - DB 65, 26 - DW 0, 64 - DW 4, 43+64 ; Volume/Channel 44 - DW 53, 55, 10, 22 ; Up/Down/Tab/Shift-Tab - DW 46, 62 ; PgUp/PgDn - -ChannelVol45 DW 9 ; Object 9 - DB 65, 27 ; x,y - DW 0, 64 ; Ranges - DW 4, 44+64 ; Volume/Channel 45 - DW 54, 56, 10, 23 ; Up/Down/Tab/Shift-Tab - DW 47, 63 ; PgUp/PgDn - -ChannelVol46 DW 9 - DB 65, 28 - DW 0, 64 - DW 4, 45+64 ; Volume/Channel 46 - DW 55, 57, 10, 24 ; Up/Down/Tab/Shift-Tab - DW 48, 64 ; PgUp/PgDn - -ChannelVol47 DW 9 ; Object 9 - DB 65, 29 ; x,y - DW 0, 64 ; Ranges - DW 4, 46+64 ; Volume/Channel 47 - DW 56, 58, 10, 25 ; Up/Down/Tab/Shift-Tab - DW 49, 65 ; PgUp/PgDn - -ChannelVol48 DW 9 - DB 65, 30 - DW 0, 64 - DW 4, 47+64 ; Volume/Channel 48 - DW 57, 59, 10, 26 ; Up/Down/Tab/Shift-Tab - DW 50, 66 ; PgUp/PgDn - -ChannelVol49 DW 9 ; Object 9 - DB 65, 31 ; x,y - DW 0, 64 ; Ranges - DW 4, 48+64 ; Volume/Channel 49 - DW 58, 60, 10, 27 ; Up/Down/Tab/Shift-Tab - DW 51, 67 ; PgUp/PgDn - -ChannelVol50 DW 9 - DB 65, 32 - DW 0, 64 - DW 4, 49+64 ; Volume/Channel 50 - DW 59, 61, 10, 28 ; Up/Down/Tab/Shift-Tab - DW 52, 68 ; PgUp/PgDn - -ChannelVol51 DW 9 ; Object 9 - DB 65, 33 ; x,y - DW 0, 64 ; Ranges - DW 4, 50+64 ; Volume/Channel 51 - DW 60, 62, 10, 29 ; Up/Down/Tab/Shift-Tab - DW 53, 69 ; PgUp/PgDn - -ChannelVol52 DW 9 - DB 65, 34 - DW 0, 64 - DW 4, 51+64 ; Volume/Channel 52 - DW 61, 63, 10, 30 ; Up/Down/Tab/Shift-Tab - DW 54, 70 ; PgUp/PgDn - -ChannelVol53 DW 9 ; Object 9 - DB 65, 35 ; x,y - DW 0, 64 ; Ranges - DW 4, 52+64 ; Volume/Channel 53 - DW 62, 64, 10, 31 ; Up/Down/Tab/Shift-Tab - DW 55, 71 ; PgUp/PgDn - -ChannelVol54 DW 9 - DB 65, 36 - DW 0, 64 - DW 4, 53+64 ; Volume/Channel 54 - DW 63, 65, 10, 32 ; Up/Down/Tab/Shift-Tab - DW 56, 72 ; PgUp/PgDn - -ChannelVol55 DW 9 ; Object 9 - DB 65, 37 ; x,y - DW 0, 64 ; Ranges - DW 4, 54+64 ; Volume/Channel 55 - DW 64, 66, 10, 33 ; Up/Down/Tab/Shift-Tab - DW 57, 73 ; PgUp/PgDn - -ChannelVol56 DW 9 - DB 65, 38 - DW 0, 64 - DW 4, 55+64 ; Volume/Channel 56 - DW 65, 67, 10, 34 ; Up/Down/Tab/Shift-Tab - DW 58, 74 ; PgUp/PgDn - -ChannelVol57 DW 9 ; Object 9 - DB 65, 39 ; x,y - DW 0, 64 ; Ranges - DW 4, 56+64 ; Volume/Channel 57 - DW 66, 68, 10, 35 ; Up/Down/Tab/Shift-Tab - DW 59, 74 ; PgUp/PgDn - -ChannelVol58 DW 9 - DB 65, 40 - DW 0, 64 - DW 4, 57+64 ; Volume/Channel 58 - DW 67, 69, 10, 36 ; Up/Down/Tab/Shift-Tab - DW 60, 74 ; PgUp/PgDn - -ChannelVol59 DW 9 ; Object 9 - DB 65, 41 ; x,y - DW 0, 64 ; Ranges - DW 4, 58+64 ; Volume/Channel 59 - DW 68, 70, 10, 37 ; Up/Down/Tab/Shift-Tab - DW 61, 74 ; PgUp/PgDn - -ChannelVol60 DW 9 - DB 65, 42 - DW 0, 64 - DW 4, 59+64 ; Volume/Channel 60 - DW 69, 71, 10, 38 ; Up/Down/Tab/Shift-Tab - DW 62, 74 ; PgUp/PgDn - -ChannelVol61 DW 9 ; Object 9 - DB 65, 43 ; x,y - DW 0, 64 ; Ranges - DW 4, 60+64 ; Volume/Channel 61 - DW 70, 72, 10, 39 ; Up/Down/Tab/Shift-Tab - DW 63, 74 ; PgUp/PgDn - -ChannelVol62 DW 9 - DB 65, 44 - DW 0, 64 - DW 4, 61+64 ; Volume/Channel 62 - DW 71, 73, 10, 40 ; Up/Down/Tab/Shift-Tab - DW 64, 74 ; PgUp/PgDn - -ChannelVol63 DW 9 ; Object 9 - DB 65, 45 ; x,y - DW 0, 64 ; Ranges - DW 4, 62+64 ; Volume/Channel 63 - DW 72, 74, 10, 41 ; Up/Down/Tab/Shift-Tab - DW 65, 74 ; PgUp/PgDn - -ChannelVol64 DW 9 - DB 65, 46 - DW 0, 64 - DW 4, 63+64 ; Volume/Channel 64 - DW 73, 74, 10, 42 ; Up/Down/Tab/Shift-Tab - DW 66, 74 ; PgUp/PgDn - -O1_ConfigureITList DW 14 ; Song name input - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr FillHeader ; 2 - DW Near Ptr ConfigureListHeader - DW Near Ptr DivisionLine - DW Near Ptr SongVarText1 - DW Near Ptr SongNameBox - DW Near Ptr InitialSpeedBox - DW Near Ptr VolumeBox - DW Near Ptr SongVarText2 - DW Near Ptr LinkCommandGToggle ; 10 - DW Near Ptr DirectoryText1 - DW Near Ptr DirectoryText2 - DW Near Ptr DirectoryInputBox - DW Near Ptr SongNameInput ; 14 - DW Near Ptr InitialTempoInput ; 15 - DW Near Ptr InitialSpeedInput ; 16 - DW Near Ptr GlobalVolumeInput ; 17 - DW Near Ptr MixingVolumeInput ; 18 - DW Near Ptr SeparationInput ; 19 - DW Near Ptr OldEffectsModeToggle ; 20 - DW Near Ptr ConfigSetupButtons ; 21 - DW Near Ptr ControlInstrumentButton ; 22 - DW Near Ptr ControlSampleButton ; 23 - DW Near Ptr PlayBackStereoButton ; 24 - DW Near Ptr PlayBackMonoButton ; 25 - DW Near Ptr SlideLinearButton ; 26 - DW Near Ptr SlideAmigaButton ; 27 - DW Near Ptr SongDirectoryInput ; 28 - DW Near Ptr SampleDirectoryInput ; 29 - DW Near Ptr InstrumentDirectoryInput ; 30 - DW Near Ptr SaveDirectoryConfigButton ; 31 - DW Near Ptr LinkCommandGToggle ; 32 - DW Near Ptr SetHelpContext5 - DW 0 - -ConfigureListHeader DW 10 - DB "Song Variables & Directory Configuration (F12)", 0 - -DivisionLine DW 1 - DB 1, 39 - DB 21h - DB 0FFh, 78, 129, 0 - -SongVarText1 DW 1 - DB 33, 13 - DB 23h - DB "Song Variables", 0 - -SongNameBox DW 0 - DB 16, 15, 43, 17 - DB 25 - -InitialSpeedBox DW 0 - DB 16, 18, 50, 21 - DB 9 - -VolumeBox DW 0 - DB 16, 22, 34, 28 - DB 25 - -SongVarText2 DW 1 - DB 2, 16 - DB 20h - DB 0FFh, 5, " Song Name", 13 - DB 13 - DB 13 - DB " Initial Tempo", 13 - DB " Initial Speed", 13 - DB 13 - DB 13 - DB " Global Volume", 13 - DB " Mixing Volume", 13 - DB 0FFh, 4, " Separation", 13 - DB " Old Effects", 13 - DB "Compatible Gxx", 13 - DB 13 - DB 13 - DB 0FFh, 7, " Control", 13 - DB 13 - DB 13 - DB 0FFh, 6, " Playback", 13 - DB 13 - DB 13 - DB " Pitch Slides" - DB 0 - -DirectoryText1 DW 1 - DB 34, 40 - DB 23h - DB "Directories", 0 - -DirectoryText2 DW 1 - DB 2, 42 - DB 20h - DB 0FFh, 4, " Module", 13 - DB 0FFh, 4, " Sample", 13 - DB "Instrument", 13 - DB 0 - -DirectoryInputBox DW 0 - DB 12, 41, 78, 45 - DB 27 - -SongNameInput DW 16 - DB 17, 16 - DW 4, 4 ; Song seg, Song name - DW 26 - DD 0 - DW 0FFFFh, 15, 15, 0FFFFh - -InitialTempoInput DW 14 - DB 17, 19 - DW 31, 255 - DW 3, 33h ; Init. Tempo=Music:33h - DW 14, 16, 16, 14 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - DW 32 - -InitialSpeedInput DW 14 - DB 17, 20 - DW 1, 255 - DW 3, 32h ; Init. Tempo=Music:33h - DW 15, 17, 17, 15 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - DW 32 - -GlobalVolumeInput DW 9 - DB 17, 23 - DW 0, 128 - DW 3, 30h - DW 16, 18, 18, 16 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -MixingVolumeInput DW 9 - DB 17, 24 - DW 0, 128 - DW 3, 31h - DW 17, 19, 19, 17 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -SeparationInput DW 9 - DB 17, 25 - DW 0, 128 - DW 3, 34h - DW 18, 20, 20, 18 - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - -OldEffectsModeToggle DW 17 - DB 17, 26 - DW 2 - DW 2Ch ; Offset of 'Flags' - DB 16 - DW 19, 10, 10, 19 - -LinkCommandGToggle DW 17 - DB 17, 27 - DW 2 - DW 2Ch ; Offset of 'Flags' - DB 32 - DW 20, 22, 22, 20 - -ConfigSetupButtons DW 8 - DD DWord Ptr F_ConfigButtonSetup - -ControlInstrumentButton DW 2 - DW 10, 24, 23, 23 - DW 0 - DW 0, 0 ; Empty Data... - DW 2 ; Call Function - DD DWord Ptr F_SetControlInstrument - DW 0, 0, 0 ; Empty data... - DB 16, 29, 30, 31 - DB 8 - DB 0 - DB " Instruments", 0 - -ControlSampleButton DW 2 - DW 10, 25, 22, 22 - DW 0 - DW 0, 0 ; Empty Data... - DW 2 ; Call Function - DD DWord Ptr F_SetControlSample - DW 0, 0, 0 ; Empty data... - DB 31, 29, 45, 31 - DB 8 - DB 0 - DB " Samples", 0 - -PlayBackStereoButton DW 2 - DW 22, 26, 25, 25 - DW 0 - DW 0, 0 ; Empty Data... - DW 2 ; Call Function - DD DWord Ptr F_SetStereo - DW 0, 0, 0 ; Empty data... - DB 16, 32, 30, 34 - DB 8 - DB 0 - DB " Stereo", 0 - -PlayBackMonoButton DW 2 - DW 23, 27, 24, 24 - DW 0 - DW 0, 0 ; Empty Data... - DW 2 ; Call Function - DD DWord Ptr F_SetMono - DW 0, 0, 0 ; Empty data... - DB 31, 32, 45, 34 - DB 8 - DB 0 - DB " Mono", 0 - -SlideLinearButton DW 2 - DW 24, 28, 27, 27 - DW 0 - DW 0, 0 ; Empty Data... - DW 2 ; Call Function - DD DWord Ptr F_SetLinear - DW 0, 0, 0 ; Empty data... - DB 16, 35, 30, 37 - DB 8 - DB 0 - DB " Linear", 0 - -SlideAmigaButton DW 2 - DW 25, 28, 26, 26 - DW 0 - DW 0, 0 ; Empty Data... - DW 2 ; Call Function - DD DWord Ptr F_SetAmiga - DW 0, 0, 0 ; Empty data... - DB 31, 35, 45, 37 - DB 8 - DB 0 - DB " Amiga", 0 - - - -SongDirectoryInput DW 16 - DB 13, 42 - DW 0, Offset SongDirectory - DW 65 - DD 0 - DW 26, 29, 29, 26 - -SampleDirectoryInput DW 16 - DB 013, 43 - DW 0, Offset SampleDirectory - DW 65 - DD 0 - DW 28, 30, 30, 28 - -InstrumentDirectoryInput DW 16 - DB 13, 44 - DW 0, Offset InstrumentDirectory - DW 65 - DD 0 - DW 29, 31, 31, 29 - -SaveDirectoryConfigButton DW 2 - DW 30, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 ; Press... no data reqd - DW 2 - DD DWord Ptr D_SaveDirectoryConfiguration - DW 0, 0, 0 ; Unused data.. - DB 27, 46, 52, 48 - DB 8 ; Thin box up - DB 0 ; Button up - DB " Save all Preferences", 0 - -O1_KeyboardList DW 8 - DW Near Ptr IdleKeyboardFunctionList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr FillHeader ; 2 - DW Near Ptr KeyboardHeader ; 3 - DW Near Ptr KeyboardBox1 ; 4 - DW Near Ptr KeyboardBox2 ; 5 - DW Near Ptr KeyboardText1 ; 6 - DW Near Ptr KeyboardText2 ; 7 - DW Near Ptr KBClearTableButton ; 8 - DW Near Ptr KBDrawTables - DW Near Ptr SetHelpContext8 - DW 0 - -IdleKeyboardFunctionList DD DWord Ptr IdleUpdateInfoLine - DD DWord Ptr K_DrawTables - DD 0 - -KBDrawTables DW 8 - DD DWord Ptr K_DrawTables - -KeyboardHeader DW 10 - DB "Keyboard Information (Ctrl-F1)", 0 - -KeyboardBox1 DW 0 - DB 1, 14, 25, 47 - DB 27 - -KeyboardBox2 DW 0 - DB 28, 14, 52, 47 - DB 27 - -KeyboardText1 DW 1 - DB 2, 13 - DB 20h - DB "Keyboard Queue", 0 - -KeyboardText2 DW 1 - DB 29, 13 - DB 20h - DB "Keypress Table", 0 - -KBClearTableButton DW 2 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 2 - DD DWord Ptr K_ResetKeyboardTables - DW 0, 0, 0 - DB 53, 14, 77, 16 - DB 8 - DB 0 - DB " Clear Keyboard Tables", 0 - - -O1_InstrumentListGeneral DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr InstrumentGlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr InstrumentListHeader ; 2 - DW Near Ptr InstrumentNameBox ; 3 - DW Near Ptr InstrumentWindow ; 4 - DW Near Ptr GInstrumentGeneralButton ; 5 - DW Near Ptr GInstrumentVolumeButton ; 6 - DW Near Ptr GInstrumentPanningButton ; 7 - DW Near Ptr GInstrumentPitchButton ; 8 - DW Near Ptr InstrumentTranslateBox ; 9 - DW Near Ptr InstrumentNoteWindow ; 10 - DW Near Ptr InstrumentFileDivision - DW Near Ptr InstrumentDCTDivision - DW Near Ptr InstrumentGeneralNNAText - DW Near Ptr InstrumentGeneralDCTText - DW Near Ptr InstrumentGeneralFileNameText ; 15 - DW Near Ptr NNAButtonCut ; 16 - DW Near Ptr NNAButtonContinue ; 17 - DW Near Ptr NNAButtonOff ;18 - DW Near Ptr NNAButtonFade ; 19 - DW Near Ptr DCTButtonOff ; 20 - DW Near Ptr DCTButtonNote ; 21 - DW Near Ptr DCTButtonSample ; 22 - DW Near Ptr DCTButtonInstrument ; 23 - DW Near Ptr DCAButtonCut ; 24 - DW Near Ptr DCAButtonOff ; 25 - DW Near Ptr DCAButtonFade ; 26 - DW Near Ptr InstrumentFilenameBox ; 27 - DW Near Ptr InstrumentFilename ; 28 - DW Near Ptr InstrumentNNADivision - DW Near Ptr FillHeader - DW Near Ptr SetHelpContext7 - DW 0 - -InstrumentDCTDivision DW 1 - DB 44, 30 - DB 20h - DB 0FFh, 35, 134, 0 - -InstrumentFileDivision DW 1 - DB 44, 45 - DB 20h - DB 0FFh, 35, 154, 0 - -InstrumentNNADivision DW 1 - DB 44, 15 - DB 20h - DB 0FFh, 35, 134, 0 - -NNAButtonCut DW 2 - DW 6, 17, 10, 4 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 0 ; Set to 0 - DW 11h - DW 0 ; Unused - DB 45, 18, 77, 20, 8 - DB 0 - DB " Note Cut", 0 - -NNAButtonContinue DW 2 - DW 16, 18, 10, 4 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 1 ; Set to 1 - DW 11h - DW 0 ; Unused - DB 45, 21, 77, 23, 8 - DB 0 - DB " Continue", 0 - -NNAButtonOff DW 2 - DW 17, 19, 10, 4 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 2 - DW 11h - DW 0 ; Unused - DB 45, 24, 77, 26, 8 - DB 0 - DB " Note Off", 0 - -NNAButtonFade DW 2 - DW 18, 20, 10, 4 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 3 - DW 11h - DW 0 ; Unused - DB 45, 27, 77, 29, 8 - DB 0 - DB " Note Fade", 0 - -DCTButtonOff DW 2 - DW 19, 21, 10, 24 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 0 ; Set to 0 - DW 12h - DW 0 ; Unused - DB 45, 33, 60, 35, 8 - DB 0 - DB " Disabled", 0 - -DCTButtonNote DW 2 - DW 20, 22, 10, 25 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 1 - DW 12h - DW 0 ; Unused - DB 45, 36, 60, 38, 8 - DB 0 - DB " Note", 0 - -DCTButtonSample DW 2 - DW 21, 23, 10, 26 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 2 - DW 12h - DW 0 ; Unused - DB 45, 39, 60, 41, 8 - DB 0 - DB " Sample", 0 - -DCTButtonInstrument DW 2 - DW 22, 28, 10, 0FFFFh - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 3 - DW 12h - DW 0 ; Unused - DB 45, 42, 60, 44, 8 - DB 0 - DB " Instrument", 0 - -DCAButtonCut DW 2 - DW 19, 25, 20, 4 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 0 ; Set to 0 - DW 13h - DW 0 ; Unused - DB 61, 33, 77, 35, 8 - DB 0 - DB " Note Cut", 0 - -DCAButtonOff DW 2 - DW 24, 26, 21, 4 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 1 ; Set to 0 - DW 13h - DW 0 ; Unused - DB 61, 36, 77, 38, 8 - DB 0 - DB " Note Off", 0 - -DCAButtonFade DW 2 - DW 25, 28, 22, 4 - DW 0 - DW 0, 0 - DW 5 - DD DWord Ptr F_InstrumentButtonHandler - DW 2 ; Set to 0 - DW 13h - DW 0 ; Unused - DB 61, 39, 77, 41, 8 - DB 0 - DB " Note Fade", 0 - - -InstrumentGeneralNNAText DW 1 - DB 54, 17 - DB 20h - DB "New Note Action", 0 - -InstrumentGeneralDCTText DW 1 - DB 47, 32 - DB 20h - DB "Duplicate Check Type & Action", 0 - -InstrumentGeneralFileNameText DW 1 - DB 47, 47 - DB 20h - DB "Filename", 0 - -InstrumentFilenameBox DW 0 - DB 55, 46, 73, 48 - DB 27 - -InstrumentFileName DW 16 - DB 56, 47 - DW 6, 4 - DW 13 - DD 0 - DW 22, 0FFFFh, 4, 10 - -GInstrumentGeneralButton DW 2 - DW 0FFFFh, 10, 4, 6 - DW 0, 0, 0 - DW 6 - DD I_GetInstrumentScreen - DW 0 - DD I_SelectScreen - DB 31, 12, 41, 14 - DB 8, 0 - DB " General", 0 - -GInstrumentVolumeButton DW 2 - DW 0FFFFh, 16, 5, 7 - DW 0, 0, 0 - DW 6 - DD I_GetInstrumentScreen - DW 1 - DD I_SelectScreen - DB 43, 12, 53, 14 - DB 8, 0 - DB " Volume", 0 - -GInstrumentPanningButton DW 2 - DW 0FFFFh, 16, 6, 8 - DW 0, 0, 0 - DW 6 - DD I_GetInstrumentScreen - DW 2 - DD I_SelectScreen - DB 55, 12, 65, 14 - DB 8, 0 - DB " Panning", 0 - -GInstrumentPitchButton DW 2 - DW 0FFFFh, 16, 7, 4 - DW 0, 0, 0 - DW 6 - DD I_GetInstrumentScreen - DW 3 - DD I_SelectScreen - DB 67, 12, 77, 14 - DB 8, 0 - DB " Pitch", 0 - - -O1_InstrumentListVolume DW 4 - DW Near Ptr IdleInstrumentList - DW Near Ptr InstrumentGlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr InstrumentListHeader ; 2 - DW Near Ptr InstrumentNameBox ; 3 - DW Near Ptr InstrumentWindow ; 4 - DW Near Ptr VInstrumentGeneralButton ; 5 - DW Near Ptr VInstrumentVolumeButton ; 6 - DW Near Ptr VInstrumentPanningButton ; 7 - DW Near Ptr VInstrumentPitchButton ; 8 - DW Near Ptr InstrumentEnvelopeBox ; 9 - DW Near Ptr InstrumentEnvelope ; 10 - DW Near Ptr InstrumentVEBox ; 11 - DW Near Ptr InstrumentVELBox ; 12 - DW Near Ptr InstrumentVESLBox ; 13 - DW Near Ptr InstrumentVEText ; 14 - DW Near Ptr InstrumentVELText ; 15 - DW Near Ptr InstrumentVESLText ; 16 - DW Near Ptr InstrumentVEToggle ; 17 - DW Near Ptr InstrumentVELToggle ; 18 - DW Near Ptr InstrumentVELBeg ; 19 - DW Near Ptr InstrumentVELEnd ; 20 - DW Near Ptr InstrumentVESLToggle ; 21 - DW Near Ptr InstrumentVESLBeg ; 22 - DW Near Ptr InstrumentVESLEnd ; 23 - DW Near Ptr InstrumentGlobalVolumeBox ; 24 - DW Near Ptr InstrumentGlobalVolumeText ; 25 - DW Near Ptr InstrumentVolume2 ; 26 - DW Near Ptr InstrumentFadeOut2 ; 27 - DW Near Ptr InstrumentRandomVolBox ; 28 - DW Near Ptr InstrumentRandomVolBar ; 29 - DW Near Ptr InstrumentVECToggle ; 30 - DW Near Ptr FillHeader - DW Near Ptr SetHelpContext7 - DW 0 - -InstrumentVEBox DW 0 - DB 53, 27, 63, 30 - DB 27 - -InstrumentVEText DW 1 - DB 38, 28 - DB 20h - DB "Volume Envelope", 13 - DB " Carry", 0 - -InstrumentVEToggle DW 17 - DB 54, 28 - DW 4, 130h - DB 1 - DW 10, 30, 4, 4 - -InstrumentVECToggle DW 17 - DB 54, 29 - DW 4, 130h - DB 8 - DW 17, 18, 4, 4 - -InstrumentVELBox DW 0 - DB 53, 31, 63, 35 - DB 27 - -InstrumentVELToggle DW 17 - DB 54, 32 - DW 4, 130h - DB 2 - DW 30, 19, 4, 4 - -InstrumentVELBeg DW 13 - DB 54, 33 - DW 0, 132h - DD 0 - DW 18, 20, 4, 4 - -InstrumentVELEnd DW 13 - DB 54, 34 - DW 0, 133h - DD 0 - DW 19, 21, 4, 4 - -InstrumentVELText DW 1 - DB 40, 32 - DB 20h - DB "Envelope Loop", 13 - DB " Loop Begin", 13 - DB 0FFh, 5, " Loop End", 0 - -InstrumentVESLBox DW 0 - DB 53, 36, 63, 40 - DB 27 - -InstrumentVESLText DW 1 - DB 40, 37 - DB 20h - DB " Sustain Loop", 13 - DB "SusLoop Begin", 13 - DB " SusLoop End", 0 - -InstrumentVESLToggle DW 17 - DB 54, 37 - DW 4, 130h - DB 4 - DW 20, 22, 4, 4 - -InstrumentVESLBeg DW 13 - DB 54, 38 - DW 0, 134h - DD 0 - DW 21, 23, 4, 4 - -InstrumentVESLEnd DW 13 - DB 54, 39 - DW 0, 135h - DD 0 - DW 22, 26, 4, 4 - -InstrumentEnvelopeBox DW 0 - DB 31, 17, 77, 26 - DB 27 - -InstrumentGlobalVolumeBox DW 0 - DB 53, 41, 71, 44 - DB 27 - -InstrumentGlobalVolumeText DW 1 - DB 39, 42 - DB 20h - DB " Global Volume", 13 - DB 0FFh, 7, " Fadeout", 13 - DB 13 - DB 13 - DB "Volume Swing %", 0 - -InstrumentRandomVolBox DW 0 - DB 53, 45, 71, 47 - DB 27 - -InstrumentRandomVolBar DW 14 - DB 54, 46 - DW 0, 100 - DW 6, 1Ah - DW 27, 0FFFFh, 4, 4 - DW 0FFFFh, 0FFFFh - DW 16 - -InstrumentVolume2 DW 9 - DB 54, 42 - DW 0, 128 - DW 6, 18h - DW 23, 27, 4, 4 - DW 0FFFFh, 0FFFFh - -InstrumentFadeOut2 DW 14 - DB 54, 43 - DW 0, 256 - DW 6, 14h - DW 26, 29, 4, 4 - DW 0FFFFh, 0FFFFh - DW 16 - -InstrumentEnvelope DW 15 - DD DWord Ptr I_DrawEnvelope - DD DWord Ptr I_PreEnvelope - DD DWord Ptr I_PostEnvelope - -VInstrumentGeneralButton DW 2 - DW 0FFFFh, 10, 4, 6 - DW 0, 0, 0 - DW 6 - DD I_GetInstrumentScreen - DW 0 - DD I_SelectScreen - DB 31, 12, 41, 14 - DB 8, 0 - DB " General", 0 - -VInstrumentVolumeButton DW 2 - DW 0FFFFh, 10, 5, 7 - DW 0, 0, 0 - DW 6 - DD I_GetInstrumentScreen - DW 1 - DD I_SelectScreen - DB 43, 12, 53, 14 - DB 8, 0 - DB " Volume", 0 - -VInstrumentPanningButton DW 2 - DW 0FFFFh, 10, 6, 8 - DW 0, 0, 0 - DW 6 - DD I_GetInstrumentScreen - DW 2 - DD I_SelectScreen - DB 55, 12, 65, 14 - DB 8, 0 - DB " Panning", 0 - -VInstrumentPitchButton DW 2 - DW 0FFFFh, 10, 7, 4 - DW 0, 0, 0 - DW 6 - DD I_GetInstrumentScreen - DW 3 - DD I_SelectScreen - DB 67, 12, 77, 14 - DB 8, 0 - DB " Pitch", 0 - -O1_InstrumentListPanning DW 4 - DW Near Ptr IdleInstrumentList - DW Near Ptr InstrumentGlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr InstrumentListHeader ; 2 - DW Near Ptr InstrumentNameBox ; 3 - DW Near Ptr InstrumentWindow ; 4 - DW Near Ptr VInstrumentGeneralButton ; 5 - DW Near Ptr VInstrumentVolumeButton ; 6 - DW Near Ptr VInstrumentPanningButton ; 7 - DW Near Ptr VInstrumentPitchButton ; 8 - DW Near Ptr InstrumentEnvelopeBox ; 9 - DW Near Ptr InstrumentEnvelope ; 10 - DW Near Ptr InstrumentVEBox ; 11 - DW Near Ptr InstrumentVELBox ; 12 - DW Near Ptr InstrumentVESLBox ; 13 - DW Near Ptr InstrumentPanText ; 14 - DW Near Ptr InstrumentVELText ; 15 - DW Near Ptr InstrumentVESLText ; 16 - DW Near Ptr InstrumentPanToggle ; 17 - DW Near Ptr InstrumentPanLToggle ; 18 - DW Near Ptr InstrumentPanLBeg ; 19 - DW Near Ptr InstrumentPanLEnd ; 20 - DW Near Ptr InstrumentPanSLToggle ; 21 - DW Near Ptr InstrumentPanSLBeg ; 22 - DW Near Ptr InstrumentPanSLEnd ; 23 - DW Near Ptr InstrumentDefaultPanBox ; 24 - DW Near Ptr InstrumentDefaultPanText ; 25 - DW Near Ptr InstrumentDefaultPanToggle ; 26 - DW Near Ptr InstrumentDefaultPanValue ; 27 - DW Near Ptr InstrumentPitchPanCenter ; 28 - DW Near Ptr InstrumentPitchPanSeparation ; 29 - DW Near Ptr InstrumentPanSwing ; 30 - DW Near Ptr InstrumentPanBoxFiller - DW Near Ptr InstrumentPanCToggle ; 32 - DW Near Ptr FillHeader - DW Near Ptr SetHelpContext7 - DW 0 - -InstrumentPanBoxFiller DW 1 - DB 54, 44 - DB 2 - DB 0FFh, 9, 09Ah, 0 - -InstrumentPanText DW 1 - DB 37, 28 - DB 20h - DB "Panning Envelope", 13 - DB " Carry", 0 - -InstrumentPanToggle DW 17 - DB 54, 28 - DW 4, 182h - DB 1 - DW 10, 32, 4, 4 - -InstrumentPanCToggle DW 17 - DB 54, 29 - DW 4, 182h - DB 8 - DW 17, 18, 4, 4 - -InstrumentPanLToggle DW 17 - DB 54, 32 - DW 4, 182h - DB 2 - DW 32, 19, 4, 4 - -InstrumentPanLBeg DW 13 - DB 54, 33 - DW 0, 184h - DD 0 - DW 18, 20, 4, 4 - -InstrumentPanLEnd DW 13 - DB 54, 34 - DW 0, 185h - DD 0 - DW 19, 21, 4, 4 - -InstrumentPanSLToggle DW 17 - DB 54, 37 - DW 4, 182h - DB 4 - DW 20, 22, 4, 4 - -InstrumentPanSLBeg DW 13 - DB 54, 38 - DW 0, 186h - DD 0 - DW 21, 23, 4, 4 - -InstrumentPanSLEnd DW 13 - DB 54, 39 - DW 0, 187h - DD 0 - DW 22, 26, 4, 4 - -InstrumentDefaultPanBox DW 0 - DB 53, 41, 63, 48 - DB 27 - -InstrumentDefaultPanText DW 1 - DB 33, 42 - DB 20h - DB 0FFh, 9, " Default Pan", 13 - DB 0FFh, 11, " Pan Value", 13, 13 - DB 0FFh, 4, " Pitch-Pan Center", 13 - DB "Pitch-Pan Separation", 13 - DB 0FFh, 11, " Pan swing", 0 - -InstrumentDefaultPanToggle DW 17 - DB 54, 42 - DW 4, 19h - DB 80h - DW 23, 27, 4, 4 - -InstrumentDefaultPanValue DW 9 - DB 54, 43 - DW 0, 64 - DW 6, 19h - DW 26, 28, 4, 4 - DW 0FFFFh, 0FFFFh - -InstrumentPitchPanCenter DW 15 - DD DWord Ptr I_DrawPitchPanCenter - DD DWord Ptr I_PrePitchPanCenter - DD DWord Ptr I_PostPitchPanCenter - -InstrumentPitchPanSeparation DW 9 - DB 54, 46 - DW -32, 32 - DW 6, 16h - DW 28, 30, 4, 4 - DW 0FFFFh, 0FFFFh - -InstrumentPanSwing DW 9 - DB 54, 47 - DW 0, 64 - DW 6, 1Bh - DW 29, 0FFFFh, 4, 4 - DW 0FFFFh, 0FFFFh - -O1_InstrumentListPitch DW 4 - DW Near Ptr IdleInstrumentList - DW Near Ptr InstrumentGlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr InstrumentListHeader ; 2 - DW Near Ptr InstrumentNameBox ; 3 - DW Near Ptr InstrumentWindow ; 4 - DW Near Ptr VInstrumentGeneralButton ; 5 - DW Near Ptr VInstrumentVolumeButton ; 6 - DW Near Ptr VInstrumentPanningButton ; 7 - DW Near Ptr VInstrumentPitchButton ; 8 - DW Near Ptr InstrumentEnvelopeBox ; 9 - DW Near Ptr InstrumentEnvelope ; 10 - DW Near Ptr InstrumentVEBox ; 11 - DW Near Ptr InstrumentVELBox ; 12 - DW Near Ptr InstrumentVESLBox ; 13 - DW Near Ptr InstrumentPitchText ; 14 - DW Near Ptr InstrumentVELText ; 15 - DW Near Ptr InstrumentVESLText ; 16 - DW Near Ptr InstrumentPitchToggle ; 17 - DW Near Ptr InstrumentPitchLToggle ; 18 - DW Near Ptr InstrumentPitchLBeg ; 19 - DW Near Ptr InstrumentPitchLEnd ; 20 - DW Near Ptr InstrumentPitchSLToggle ; 21 - DW Near Ptr InstrumentPitchSLBeg ; 22 - DW Near Ptr InstrumentPitchSLEnd ; 23 - DW Near Ptr InstrumentMIDIBox1 ; 24 - DW Near Ptr InstrumentMIDIChannel ; 25 - DW Near Ptr InstrumentMIDIProgram ; 26 - DW Near Ptr InstrumentMIDIBank1 ; 27 - DW Near Ptr InstrumentMIDIBank2 ; 28 - DW Near Ptr InstrumentPitchCToggle ; 29 -IF FILTERENVELOPES - DW Near Ptr InstrumentFilterCutoff ; 30 - DW Near Ptr InstrumentFilterResonance ; 31 -ENDIF - DW Near Ptr InstrumentMIDIText - DW Near Ptr FillHeader - DW Near Ptr SetHelpContext7 - DW 0 - -InstrumentMIDIText DW 1 - DB 36, 42 - DB 20h - -IF FILTERENVELOPES - DB "Default Cutoff", 13 - DB "Default Resonance", 13 -ENDIF - DB "MIDI Channel", 13 - DB "MIDI Program", 13 - DB "MIDI Bank Low", 13 - DB "MIDI Bank High", 0 - -InstrumentPitchText DW 1 - DB 35, 28 - DB 20h - DB "Frequency Envelope", 13 - DB " Carry", 0 - -InstrumentPitchToggle DW 17 - DB 54, 28 - DW 4, 1D4h - DB 1 - DW 10, 29, 4, 4 - -InstrumentPitchCToggle DW 17 - DB 54, 29 - DW 4, 1D4h - DB 8 - DW 17, 18, 4, 4 - -InstrumentPitchLToggle DW 17 - DB 54, 32 - DW 4, 1D4h - DB 2 - DW 29, 19, 4, 4 - -InstrumentPitchLBeg DW 13 - DB 54, 33 - DW 0, 1D6h - DD 0 - DW 18, 20, 4, 4 - -InstrumentPitchLEnd DW 13 - DB 54, 34 - DW 0, 1D7h - DD 0 - DW 19, 21, 4, 4 - -InstrumentPitchSLToggle DW 17 - DB 54, 37 - DW 4, 1D4h - DB 4 - DW 20, 22, 4, 4 - -InstrumentPitchSLBeg DW 13 - DB 54, 38 - DW 0, 1D8h - DD 0 - DW 21, 23, 4, 4 - -InstrumentPitchSLEnd DW 13 - DB 54, 39 - DW 0, 1D9h - DD 0 -IF FILTERENVELOPES - DW 22, 30, 4, 4 -ELSE - DW 22, 25, 4, 4 -ENDIF - -InstrumentMIDIChannel DW 14 -IF FILTERENVELOPES - DB 54, 44 -ELSE - DB 54, 42 -ENDIF - DW 0, 17 - DW 6, 3Ch -IF FILTERENVELOPES - DW 30, 26, 4, 4 -ELSE - DW 23, 26, 4, 4 -ENDIF - - DW 0FFFFh, 0FFFFh - DW 16 - -InstrumentFilterCutoff DW 14 - DB 54, 42 - DW 0, 127 - DW 6, 3Ah - DW 23, 31, 4, 4 - DW 0FFFFh, 0FFFFh - DW 16 - -InstrumentFilterResonance DW 14 - DB 54, 43 - DW 0, 127 - DW 6, 3Bh - DW 30, 25, 4, 4 - DW 0FFFFh, 0FFFFh - DW 16 - -InstrumentMIDIProgram DW 14 -IF FILTERENVELOPES - DB 54, 45 -ELSE - DB 54, 43 -ENDIF - DW -1, 127 - DW 6, 3Dh - DW 25, 27, 4, 4 - DW 0FFFFh, 0FFFFh - DW 16 - -InstrumentMIDIBank1 DW 14 -IF FILTERENVELOPES - DB 54, 46 -ELSE - DB 54, 44 -ENDIF - DW -1, 127 - DW 6, 3Eh - DW 26, 28, 4, 4 - DW 0FFFFh, 0FFFFh - DW 16 - -InstrumentMIDIBank2 DW 14 -IF FILTERENVELOPES - DB 54, 47 -ELSE - DB 54, 45 -ENDIF - DW -1, 127 - DW 6, 3Fh - DW 27, 0FFFFh, 4, 4 - DW 0FFFFh, 0FFFFh - DW 16 - -InstrumentListHeader DW 10 - DB "Instrument List (F4)", 0 - -InstrumentNameBox DW 0 - DB 4, 12, 30, 48 - DB 27 - -InstrumentTranslateBox DW 0 - DB 31, 15, 42, 48 - DB 27 - -InstrumentMIDIBox1 DW 0 -IF FILTERENVELOPES - DB 53, 41, 71, 48 -ELSE - DB 53, 41, 71, 46 -ENDIF - DB 27 - -InstrumentWindow DW 15 - DD DWord Ptr I_DrawInstrumentWindow - DD DWord Ptr I_PreInstrumentWindow - DD DWord Ptr I_PostInstrumentWindow - -InstrumentNoteWindow DW 15 - DD DWord Ptr I_DrawNoteWindow - DD DWord Ptr I_PreNoteWindow - DD DWord Ptr I_PostNoteWindow - -InstrumentGlobalKeyList Label -IF ENABLESOLO - DB 1 - DW '`' - DD DWord Ptr Music_ToggleSoloInstrument -ENDIF - - DB 3 ; Ctrl - DW 1C9h - DD DWord Ptr I_SampleUp - - DB 3 ; Ctrl. - DW 1D1h - DD DWord Ptr I_SampleDown - - DB 0 - DW 1C9h - DD DWord Ptr I_SampleUp - - DB 0 - DW 1D1h - DD DWord Ptr I_SampleDown - - DB 1 - DW '<' - DD DWord Ptr I_DecreasePlayChannel - - DB 1 - DW '>' - DD DWord Ptr I_IncreasePlayChannel - - DB 1 - DW ',' - DD DWord Ptr I_DecreasePlayChannel - - DB 1 - DW '.' - DD DWord Ptr I_IncreasePlayChannel - - DB 1 - DW 2000h ; Alt 'D' - DD DWord Ptr I_DeleteInstrument - - DB 1 - DW 1300h ; Alt 'R' - DD DWord Ptr I_ReplaceInstrument - - DB 1 - DW 1F00h ; Alt 'S' - DD DWord Ptr I_SwapInstruments - - DB 1 - DW 1800h ; Alt 'O' - DD DWord Ptr D_SaveInstrument - - DB 1 - DW 1900h ; Alt 'P' - DD DWord Ptr I_CopyInstrument - - DB 1 - DW 1600h ; Alt 'U' - DD DWord Ptr I_UpdateInstrument - - DB 1 ; Alt 'J' - DW 2400h - DD DWord Ptr I_ScaleInstrumentVolumes - - DB 1 - DW 2D00h ; Alt 'X' - DD DWord Ptr I_ExchangeInstruments - - DB 1 - DW 3100h ; Alt 'N' - DD DWord Ptr I_ToggleMultiChannel - - DB 0 - DW 139h - DD DWord Ptr I_InstrumentListSpace - - DB 0 - DW 039h - DD DWord Ptr I_InstrumentListNoteOff - - DB 0 ; Enter... to load sample! - DW 11Ch - DD DWord Ptr Glbl_LoadInstrument - - DB 4 ; Always call function - DW 0 - DD DWord Ptr I_PlayNote - - DB 5 - DW Offset GlobalKeyList - -O1_DisplayList DW 4 - DW Near Ptr InfoPageIdleList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr FillHeader ; 2 - DW Near Ptr DisplayHeader ; 3 - DW Near Ptr DisplayObject ; 4 - DW Near Ptr SetHelpContext9 - DW 0 - -O1_FullDisplayList DW 1 - DW Near Ptr InfoPageIdleList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr DisplayObject ; 1 - DW Near Ptr SetHelpContext9 - DW 0 - -InfoPageIdleList Label DWord - DD DWord Ptr DisplayUpdateScreen - DD 0 - -DisplayHeader DW 10 - DB "Info Page (F5)", 0 - -DisplayObject DW 15 - DD DWord Ptr DrawDisplayData - DD DWord Ptr F_Nothing - DD DWord Ptr PostDisplayData - -O1_ThumbStringList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESC&ReturnList - DW Near Ptr ThumbBox - DW Near Ptr ThumbInputText - DW Near Ptr ThumbInputBox - DW Near Ptr ThumbInput - DW 0 - -ThumbBox DW 0 - DB 29, 24, 50, 28 - DB 3 - -ThumbInputText DW 1 - DB 32, 26 - DB 23h - DB "Enter Value", 0 - -ThumbInputBox DW 0 - DB 43, 25, 48, 27 - DB 27 - -ThumbInput DW 16 - DB 44, 26 - DW 5, Offset ThumbStringEnter - DW 4 - DD 0 ; No function - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -O1_NewSongList DW 11 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr NewSongBox ; 0 - DW Near Ptr NewSongText ; 1 - DW Near Ptr NewSongText2 ; 2 - DW Near Ptr KeepPatternButton ; 3 - DW Near Ptr ClearPatternButton ; 4 - DW Near Ptr KeepSampleButton ; 5 - DW Near Ptr ClearSampleButton ; 6 - DW Near Ptr KeepInstrumentButton ; 7 - DW Near Ptr ClearInstrumentButton ; 8 - DW Near Ptr KeepOrderListButton ; 9 - DW Near Ptr ClearOrderListButton ; 10 - DW Near Ptr NewSongOKButton ; 11 - DW Near Ptr NewSongCancelButton ; 12 - - DW 0 - -NewSongBox DW 0 - DB 21, 20, 58, 38 - DB 3 - -NewSongText DW 1 - DB 36, 21 - DB 23h - DB "New Song", 0 - -NewSongText2 DW 1 - DB 23, 24 - DB 20h - DB " Patterns", 13 - DB 13 - DB 13 - DB 0FFh, 4, " Samples", 13 - DB 13 - DB 13 - DB "Instruments", 13 - DB 13 - DB 13 - DB " Order List", 0 - -KeepPatternButton DW 2 - DW 0FFFFh, 5, 4, 4 - DW 2 - DW 3, 4 - DW 3 ; Set var! - DW 3, 0 - DW 0, 0, 0 - DB 34, 23, 43, 25 - DB 8 - DB 0 - DB " Keep", 0 - -ClearPatternButton DW 2 - DW 4, 6, 3, 3 - DW 2 - DW 3, 4 - DW 3 - DW 3, 1 ; Clear pattern flag - DW 0, 0, 0 - DB 44, 23, 54, 25 - DB 8 - DB 3 ; Default to down - DB " Clear", 0 - -KeepSampleButton DW 2 - DW 3, 7, 6, 6 - DW 2 - DW 5, 6 - DW 3 ; Set var! - DW 4, 0 - DW 0, 0, 0 - DB 34, 26, 43, 28 - DB 8 - DB 0 - DB " Keep", 0 - -ClearSampleButton DW 2 - DW 4, 8, 5, 5 - DW 2 - DW 5, 6 - DW 3 - DW 4, 1 ; Clear pattern flag - DW 0, 0, 0 - DB 44, 26, 54, 28 - DB 8 - DB 3 ; Default to down - DB " Clear", 0 - -KeepInstrumentButton DW 2 - DW 5, 9, 8, 8 - DW 2 - DW 7, 8 - DW 3 ; Set var! - DW 5, 0 - DW 0, 0, 0 - DB 34, 29, 43, 31 - DB 8 - DB 0 - DB " Keep", 0 - -ClearInstrumentButton DW 2 - DW 6, 10, 7, 7 - DW 2 - DW 7, 8 - DW 3 - DW 5, 1 ; Clear pattern flag - DW 0, 0, 0 - DB 44, 29, 54, 31 - DB 8 - DB 3 ; Default to down - DB " Clear", 0 - -KeepOrderListButton DW 2 - DW 7, 11, 10, 10 - DW 2 - DW 9, 10 - DW 3 ; Set var! - DW 6, 0 - DW 0, 0, 0 - DB 34, 32, 43, 34 - DB 8 - DB 0 - DB " Keep", 0 - -ClearOrderListButton DW 2 - DW 8, 12, 9, 9 - DW 2 - DW 9, 10 - DW 3 - DW 6, 1 ; Clear pattern flag - DW 0, 0, 0 - DB 44, 32, 54, 34 - DB 8 - DB 3 ; Default to down - DB " Clear", 0 - -NewSongOKButton DW 2 - DW 9, 0FFFFh, 12, 12 - DW 0 ; Press. - DW 0, 0 - DW 0 ; Return value. - DW 1 ; Return OK. - DW 0, 0, 0, 0 - DB 27, 35, 38, 37 - DB 8 - DB 0 - DB " OK", 0 - -NewSongCancelButton DW 2 - DW 9, 0FFFFh, 11, 11 - DW 0 - DW 0, 0 - DW 0 - DW 0 - DW 0, 0, 0, 0 - DB 40, 35, 51, 37 - DB 8 - DB 0 - DB " Cancel", 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -O1_MainMenu DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr MainMenuBox1 ; 0 - DW Near Ptr MainMenuBox2 ; 1 - DW Near Ptr MainMenuText ; 2 - DW Near Ptr MainMenuFile ; 3 - DW Near Ptr MainMenuPlayBack ; 4 - DW Near Ptr MainMenuViewPatterns ; 5 - DW Near Ptr MainMenuViewSamples ; 6 - DW Near Ptr MainMenuViewInstruments; 7 - DW Near Ptr MainMenuViewOrderPan ; 8 - DW Near Ptr MainMenuViewVariables ; 9 - DW Near Ptr MainMenuMessage - DW Near Ptr MainMenuHelp ; 11 - - DW 0 - -MainMenuBox1 DW 0 - DB 6, 14, 38, 46 - DB 3 - -MainMenuBox2 DW 0 - DB 7, 15, 37, 45 - DB 0 - -MainMenuText DW 1 - DB 12, 16 - DB 23h - DB "Main Menu", 0 - -MainMenuFile DW 2 - DW 0FFFFh, 4, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 2 - DD DWord Ptr F_FileMenu - DW 0, 0, 0 - DB 8, 18, 36, 20 - DB 28 - DB 0 - DB " File Menu...", 0 - -MainMenuPlayBack DW 2 - DW 3, 5, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 2 - DD DWord Ptr F_PlayBackMenu - DW 0, 0, 0 - DB 8, 21, 36, 23 - DB 28 - DB 0 - DB " Playback Menu...", 0 - -MainMenuViewPatterns DW 2 - DW 4, 6, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 ; Jump to function - DD DWord Ptr F_ViewPattern - DW 0, 0, 0 - DB 8, 24, 36, 26 - DB 28 - DB 0 - DB " View Patterns (F2)", 0 - -MainMenuViewSamples DW 2 - DW 5, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 2 - DD DWord Ptr F_SampleMenu - DW 0, 0, 0 - DB 8, 27, 36, 29 - DB 28 - DB 0 - DB " Sample Menu...", 0 - -MainMenuViewInstruments DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 2 - DD DWord Ptr F_InstrumentMenu - DW 0, 0, 0 - DB 8, 30, 36, 32 - DB 28 - DB 0 - DB " Instrument Menu...", 0 - -MainMenuViewOrderPan DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_ViewOrderPan - DW 0, 0, 0 - DB 8, 33, 36, 35 - DB 28 - DB 0 - DB " View Orders/Panning (F11)", 0 - -MainMenuViewVariables DW 2 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_ViewVariables - DW 0, 0, 0 - DB 8, 36, 36, 38 - DB 28 - DB 0 - DB " View Variables (F12)", 0 - -MainMenuMessage DW 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_MessageEditor - DW 0, 0, 0 - DB 8, 39, 36, 41 - DB 28 - DB 0 - DB " Message Editor (Shift-F9)", 0 - -MainMenuHelp DW 2 - DW 10, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_Help - DW 0, 0, 0 - DB 8, 42, 36, 44 - DB 28 - DB 0 - DB " Help! (F1)", 0 - -O1_FileMenu DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr FileBox1 ; 0 - DW Near Ptr FileBox2 ; 1 - DW Near Ptr FileMenuText ; 2 - DW Near Ptr FileLoad ; 3 - DW Near Ptr FileNew - DW Near Ptr FileSaveCurrent - DW Near Ptr FileSaveAs - DW Near Ptr FileDOSShell - DW Near Ptr FileQuit - DW 0 - -FileBox1 DW 0 - DB 25, 16, 54, 39 - DB 1 - -FileBox2 DW 0 - DB 26, 17, 53, 38 - DB 0 - -FileMenuText DW 1 - DB 30, 18 - DB 23h - DB "File Menu", 0 - -FileLoad DW 2 - DW 0FFFFh, 4, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_FileLoad - DW 0, 0, 0 - DB 27, 20, 52, 22 - DB 28 - DB 0 - DB " Load... (F9)", 0 - -FileNew DW 2 - DW 3, 5, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_FileNew - DW 0, 0, 0 - DB 27, 23, 52, 25 - DB 28 - DB 0 - DB " New... (Ctrl-N)", 0 - -FileSaveCurrent DW 2 - DW 4, 6, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_FileSaveCurrent - DW 0, 0, 0 - DB 27, 26, 52, 28 - DB 28 - DB 0 - DB " Save Current (Ctrl-S)", 0 - -FileSaveAs DW 2 - DW 5, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_FileSaveAs - DW 0, 0, 0 - DB 27, 29, 52, 31 - DB 28 - DB 0 - DB " Save As... (F10)", 0 - -FileDOSShell DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_FileDOSShell - DW 0, 0, 0 - DB 27, 32, 52, 34 - DB 28 - DB 0 - DB " Shell to DOS (Ctrl-D)", 0 - -FileQuit DW 2 - DW 7, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_FileQuit - DW 0, 0, 0 - DB 27, 35, 52, 37 - DB 28 - DB 0 - DB " Quit (Ctrl-Q)", 0 - -O1_PlayBackMenu DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr PlayBackBox1 ; 0 - DW Near Ptr PlayBackBox2 ; 1 - DW Near Ptr PlayBackText ; 2 - DW Near Ptr PlayBackShowInfoPage ; 3 - DW Near Ptr PlayBackSong ; 4 - DW Near Ptr PlayBackPattern ; 5 - DW Near Ptr PlayBackOrder ; 6 - DW Near Ptr PlayBackMark ; 7 - DW Near Ptr PlayBackStop ; 8 - DW Near Ptr PlayBackReinit ; 9 - DW Near Ptr PlayBackDriverScreen ; 10 - DW Near Ptr PlayBackCalculateLength ; 11 - DW 0 - -PlayBackBox1 DW 0 - DB 25, 16, 59, 48 - DB 1 - -PlayBackBox2 DW 0 - DB 26, 17, 58, 47 - DB 0 - -PlayBackText DW 1 - DB 31, 18 - DB 23h - DB "Playback Menu", 0 - -PlayBackShowInfoPage DW 2 - DW 0FFFFh, 4, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_InfoPage - DW 0, 0, 0 - DB 27, 20, 57, 22 - DB 28 - DB 0 - DB " Show Infopage (F5)", 0 - -PlayBackSong DW 2 - DW 3, 5, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_PlaySong - DW 0, 0, 0 - DB 27, 23, 57, 25 - DB 28 - DB 0 - DB " Play Song (Ctrl-F5)", 0 - -PlayBackPattern DW 2 - DW 4, 6, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_PlayPattern - DW 0, 0, 0 - DB 27, 26, 57, 28 - DB 28 - DB 0 - DB " Play Pattern (F6)", 0 - -PlayBackOrder DW 2 - DW 5, 7, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_PlayOrder - DW 0, 0, 0 - DB 27, 29, 57, 31 - DB 28 - DB 0 - DB " Play from Order (Shift-F6)", 0 - -PlayBackMark DW 2 - DW 6, 8, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_PlayMark - DW 0, 0, 0 - DB 27, 32, 57, 34 - DB 28 - DB 0 - DB " Play from Mark/Cursor (F7)", 0 - -PlayBackStop DW 2 - DW 7, 9, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_Stop - DW 0, 0, 0 - DB 27, 35, 57, 37 - DB 28 - DB 0 - DB " Stop (F8)", 0 - -PlayBackReinit DW 2 - DW 8, 10, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_ReinitSoundCard - DW 0, 0, 0 - DB 27, 38, 57, 40 - DB 28 - DB 0 - DB " Reinit Soundcard (Ctrl-I)", 0 - -PlayBackDriverScreen DW 2 - DW 9, 11, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_DriverScreen - DW 0, 0, 0 - DB 27, 41, 57, 43 - DB 28 - DB 0 - DB " Driver Screen (Shift-F5)", 0 - -PlayBackCalculateLength DW 2 - DW 10, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_CalculateLength - DW 0, 0, 0 - DB 27, 44, 57, 46 - DB 28 - DB 0 - DB " Calculate Length (Ctrl-P)", 0 - - -O1_SampleMenu DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr SampleBox1 ; 0 - DW Near Ptr SampleBox2 ; 1 - DW Near Ptr SampleText ; 2 - DW Near Ptr SampleMenuList ; 3 - DW Near Ptr SampleLibrary ; 4 - DW Near Ptr ReloadGravis ; 5 - - DW 0 - -SampleBox1 DW 0 - DB 25, 23, 57, 37 - DB 1 - - -SampleBox2 DW 0 - DB 26, 24, 56, 36 - DB 0 - -SampleText DW 1 - DB 30, 25 - DB 23h - DB "Sample Menu", 0 - -SampleMenuList DW 2 - DW 0FFFFh, 4, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_SampleList - DW 0, 0, 0 - DB 27, 27, 55, 29 - DB 28 - DB 0 - DB " Sample List (F3)", 0 - -SampleLibrary DW 2 - DW 3, 5, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_SampleLibrary - DW 0, 0, 0 - DB 27, 30, 55, 32 - DB 28 - DB 0 - DB " Sample Library (Ctrl-F3)", 0 - -ReloadGravis DW 2 - DW 4, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_ReloadGravis - DW 0, 0, 0 - DB 27, 33, 55, 35 - DB 28 - DB 0 - DB " Reload Soundcard (Ctrl-G)", 0 - -O1_InstrumentMenu DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCReturnList - DW Near Ptr InstrumentBox1 ; 0 - DW Near Ptr InstrumentBox2 ; 1 - DW Near Ptr InstrumentText ; 2 - DW Near Ptr InstrumentMenuList ; 3 - DW Near Ptr InstrumentLibrary ; 4 - DW 0 - -InstrumentBox1 DW 0 - DB 20, 23, 56, 34 - DB 1 - - -InstrumentBox2 DW 0 - DB 21, 24, 55, 33 - DB 0 - -InstrumentText DW 1 - DB 25, 25 - DB 23h - DB "Instrument Menu", 0 - -InstrumentMenuList DW 2 - DW 0FFFFh, 4, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_InstrumentList - DW 0, 0, 0 - DB 22, 27, 54, 29 - DB 28 - DB 0 - DB " Instrument List (F4)", 0 - -InstrumentLibrary DW 2 - DW 3, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 4 - DD DWord Ptr F_InstrumentLibrary - DW 0, 0, 0 - DB 22, 30, 54, 32 - DB 28 - DB 0 - DB " Instrument Library (Ctrl-F4)", 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -O1_EditSampleName DW 3 - DW IdleFunctionList - DW ESCReturnList - DW EditSampleNameBox ; 0 - DW EditSampleNameText ; 1 - DW EditSampleNameInputBox ; 2 - DW EditSampleNameInput ;3 - DW 0 - -EditSampleNameBox DW 0 - DB 23, 25, 56, 31 - DB 3 - -EditSampleNameText DW 1 - DB 32, 26 - DB 23h - DB "Edit Sample Name", 0 - -EditSampleNameInputBox DW 0 - DB 26, 28, 53, 30 - DB 27 - -EditSampleNameInput DW 16 - DB 27, 29 - DW 0, Offset SampleName - DW 26 - DD DWord Ptr F_Return1 - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF MEMORYDEBUG - -O1_DebugList DW 5 - DW Near Ptr IdleDebugFunctionList - DW Near Ptr DebugKeyList - DW Near Ptr FullScreenBox - DW Near Ptr ScreenHeader - DW Near Ptr DebugBox - DW Near Ptr DebugText - DW Near Ptr DebugInputBox - DW Near Ptr DebugAddressInput - DW Near Ptr DebugInfo - DW Near Ptr FillHeader - DW Near Ptr DebugHeader - DW 0 - - -DebugInfo DW 8 -IdleDebugFunctionList DD DWord Ptr F_DrawDebug - DD DWord Ptr IdleUpdateInfoLine - DD 0 - -DebugKeyList Label - DB 4 - DW 0 - DD DWord Ptr F_PostDebug - - DB 0 - DW 1C8h - DD DWord Ptr F_DebugUp - - DB 0 - DW 1D0h - DD DWord Ptr F_DebugDown - - DB 0 - DW 1C9h - DD DWord Ptr F_DebugPgUp - - DB 0 - DW 1D1h - DD DWord Ptr F_DebugPgDn - - DB 5 - DW Offset GlobalKeyList - - -DebugBox DW 0 - DB 1, 14, 78, 45 - DB 27 - -DebugText DW 1 - DB 4, 47 - DB 20h - DB "Address", 0 - -DebugInputBox DW 0 - DB 11, 46, 30, 48 - DB 25 - -DebugAddressInput DW 16 - DB 12, 47 - DW 5, Offset AddressInput - DW 18 - DD DWord Ptr F_DebugStringInput - DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -DebugHeader DW 10 - DB "Debug", 0 - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -O1_ConfigurePaletteList DW 53 - DW IdleFunctionList - DW GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr FillHeader ; 2 - DW Near Ptr ConfigurePaletteHeader ; 3 - DW Near Ptr SetHelpContext10 - DW Near Ptr PaletteColourBorder1 - DW Near Ptr PaletteColourBorder2 - DW Near Ptr PaletteColourBorder3 - DW Near Ptr PaletteColourBorder4 - DW Near Ptr PaletteColourBorder5 - DW Near Ptr PaletteColourBorder6 ; 10 - DW Near Ptr PaletteColourBorder7 - DW Near Ptr PaletteColourBorder8 - DW Near Ptr PaletteColourBorder9 - DW Near Ptr PaletteColourBorder10 - DW Near Ptr PaletteColourBorder11 - DW Near Ptr PaletteColourBorder12 - DW Near Ptr PaletteColourBorder13 - DW Near Ptr PaletteColourBorder14 - DW Near Ptr PaletteColourBorder15 - DW Near Ptr PaletteColourBorder16 ; 20 - DW Near Ptr PaletteColourBox1 - DW Near Ptr PaletteColourBox2 - DW Near Ptr PaletteColourBox3 - DW Near Ptr PaletteColourBox4 - DW Near Ptr PaletteColourBox5 - DW Near Ptr PaletteColourBox6 - DW Near Ptr PaletteColourBox7 - DW Near Ptr PaletteColourBox8 - DW Near Ptr PaletteColourBox9 - DW Near Ptr PaletteColourBox10 ; 30 - DW Near Ptr PaletteColourBox11 - DW Near Ptr PaletteColourBox12 - DW Near Ptr PaletteColourBox13 - DW Near Ptr PaletteColourBox14 - DW Near Ptr PaletteColourBox15 - DW Near Ptr PaletteColourBox16 - DW Near Ptr PaletteInputBox1 - DW Near Ptr PaletteInputBox2 - DW Near Ptr PaletteInputBox3 - DW Near Ptr PaletteInputBox4 ; 40 - DW Near Ptr PaletteInputBox5 - DW Near Ptr PaletteInputBox6 - DW Near Ptr PaletteInputBox7 - DW Near Ptr PaletteInputBox8 - DW Near Ptr PaletteInputBox9 - DW Near Ptr PaletteInputBox10 - DW Near Ptr PaletteInputBox11 - DW Near Ptr PaletteInputBox12 - DW Near Ptr PaletteInputBox13 - DW Near Ptr PaletteInputBox14 ; 50 - DW Near Ptr PaletteInputBox15 - DW Near Ptr PaletteInputBox16 - DW Near Ptr Colour0RedInput ; 53 - DW Near Ptr Colour0GreenInput - DW Near Ptr Colour0BlueInput - DW Near Ptr Colour1RedInput ; 56 - DW Near Ptr Colour1GreenInput - DW Near Ptr Colour1BlueInput - DW Near Ptr Colour2RedInput - DW Near Ptr Colour2GreenInput ; 60 - DW Near Ptr Colour2BlueInput - DW Near Ptr Colour3RedInput - DW Near Ptr Colour3GreenInput - DW Near Ptr Colour3BlueInput - DW Near Ptr Colour4RedInput - DW Near Ptr Colour4GreenInput - DW Near Ptr Colour4BlueInput - DW Near Ptr Colour5RedInput - DW Near Ptr Colour5GreenInput - DW Near Ptr Colour5BlueInput ; 70 - DW Near Ptr Colour6RedInput - DW Near Ptr Colour6GreenInput - DW Near Ptr Colour6BlueInput - DW Near Ptr Colour7RedInput ; 74 - DW Near Ptr Colour7GreenInput - DW Near Ptr Colour7BlueInput - DW Near Ptr Colour8RedInput - DW Near Ptr Colour8GreenInput - DW Near Ptr Colour8BlueInput - DW Near Ptr Colour9RedInput ; 80 - DW Near Ptr Colour9GreenInput - DW Near Ptr Colour9BlueInput - DW Near Ptr Colour10RedInput - DW Near Ptr Colour10GreenInput - DW Near Ptr Colour10BlueInput - DW Near Ptr Colour11RedInput - DW Near Ptr Colour11GreenInput - DW Near Ptr Colour11BlueInput - DW Near Ptr Colour12RedInput - DW Near Ptr Colour12GreenInput ; 90 - DW Near Ptr Colour12BlueInput - DW Near Ptr Colour13RedInput - DW Near Ptr Colour13GreenInput - DW Near Ptr Colour13BlueInput - DW Near Ptr Colour14RedInput - DW Near Ptr Colour14GreenInput - DW Near Ptr Colour14BlueInput - DW Near Ptr Colour15RedInput - DW Near Ptr Colour15GreenInput - DW Near Ptr Colour15BlueInput ; 100 - DW Near Ptr PredefinedPaletteMsg - DW Near Ptr PredefinedPalette1 - DW Near Ptr PredefinedPalette2 - DW Near Ptr PredefinedPalette3 - DW Near Ptr PredefinedPalette4 - DW Near Ptr PredefinedPalette5 - DW Near Ptr PredefinedPalette6 - DW Near Ptr PredefinedPalette7 - DW 0 - -ConfigurePaletteHeader DW 10 - DB "Palette Configuration (Ctrl-F12)", 0 - -PaletteColourBorder1 DW 0 - DB 2, 13, 8, 17 - DB 11 - -PaletteColourBorder2 DW 0 - DB 2, 18, 8, 22 - DB 11 - -PaletteColourBorder3 DW 0 - DB 2, 23, 8, 27 - DB 11 - -PaletteColourBorder4 DW 0 - DB 2, 28, 8, 32 - DB 11 - -PaletteColourBorder5 DW 0 - DB 2, 33, 8, 37 - DB 11 - -PaletteColourBorder6 DW 0 - DB 2, 38, 8, 42 - DB 11 - -PaletteColourBorder7 DW 0 - DB 2, 43, 8, 47 - DB 11 - -PaletteColourBorder8 DW 0 - DB 29, 13, 35, 17 - DB 11 - -PaletteColourBorder9 DW 0 - DB 29, 18, 35, 22 - DB 11 - -PaletteColourBorder10 DW 0 - DB 29, 23, 35, 27 - DB 11 - -PaletteColourBorder11 DW 0 - DB 29, 28, 35, 32 - DB 11 - -PaletteColourBorder12 DW 0 - DB 29, 33, 35, 37 - DB 11 - -PaletteColourBorder13 DW 0 - DB 29, 38, 35, 42 - DB 11 - -PaletteColourBorder14 DW 0 - DB 29, 43, 35, 47 - DB 11 - -PaletteColourBorder15 DW 0 - DB 56, 13, 62, 17 - DB 11 - -PaletteColourBorder16 DW 0 - DB 56, 18, 62, 22 - DB 11 - -PaletteColourBox1 DW 1 - DB 3, 14 - DB 00h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox2 DW 1 - DB 3, 19 - DB 10h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox3 DW 1 - DB 3, 24 - DB 20h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox4 DW 1 - DB 3, 29 - DB 30h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox5 DW 1 - DB 3, 34 - DB 40h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox6 DW 1 - DB 3, 39 - DB 50h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox7 DW 1 - DB 3, 44 - DB 60h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox8 DW 1 - DB 30, 14 - DB 70h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox9 DW 1 - DB 30, 19 - DB 80h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox10 DW 1 - DB 30, 24 - DB 90h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox11 DW 1 - DB 30, 29 - DB 0A0h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox12 DW 1 - DB 30, 34 - DB 0B0h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox13 DW 1 - DB 30, 39 - DB 0C0h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox14 DW 1 - DB 30, 44 - DB 0D0h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox15 DW 1 - DB 57, 14 - DB 0E0h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteColourBox16 DW 1 - DB 57, 19 - DB 0F0h - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 13 - DB 0FFh, 5, " ", 0 - -PaletteInputBox1 DW 0 - DB 9, 13, 19, 17 - DB 27 - -PaletteInputBox2 DW 0 - DB 9, 18, 19, 22 - DB 27 - -PaletteInputBox3 DW 0 - DB 9, 23, 19, 27 - DB 27 - -PaletteInputBox4 DW 0 - DB 9, 28, 19, 32 - DB 27 - -PaletteInputBox5 DW 0 - DB 9, 33, 19, 37 - DB 27 - -PaletteInputBox6 DW 0 - DB 9, 38, 19, 42 - DB 27 - -PaletteInputBox7 DW 0 - DB 9, 43, 19, 47 - DB 27 - -PaletteInputBox8 DW 0 - DB 36, 13, 46, 17 - DB 27 - -PaletteInputBox9 DW 0 - DB 36, 18, 46, 22 - DB 27 - -PaletteInputBox10 DW 0 - DB 36, 23, 46, 27 - DB 27 - -PaletteInputBox11 DW 0 - DB 36, 28, 46, 32 - DB 27 - -PaletteInputBox12 DW 0 - DB 36, 33, 46, 37 - DB 27 - -PaletteInputBox13 DW 0 - DB 36, 38, 46, 42 - DB 27 - -PaletteInputBox14 DW 0 - DB 36, 43, 46, 47 - DB 27 - -PaletteInputBox15 DW 0 - DB 63, 13, 73, 17 - DB 27 - -PaletteInputBox16 DW 0 - DB 63, 18, 73, 22 - DB 27 - -Colour0RedInput DW 9 - DB 10, 14 - DW 0, 63 - DW 7, Offset PaletteDefs - DW 0FFFFh, 54, 74, 95, 0FFFFh, 56 - -Colour0GreenInput DW 9 - DB 10, 15 - DW 0, 63 - DW 7, Offset PaletteDefs+1 - DW 53, 55, 75, 96, 0FFFFh, 57 - -Colour0BlueInput DW 9 - DB 10, 16 - DW 0, 63 - DW 7, Offset PaletteDefs+2 - DW 54, 56, 76, 97, 0FFFFh, 58 - -Colour1RedInput DW 9 - DB 10, 19 - DW 0, 63 - DW 7, Offset PaletteDefs+3 - DW 55, 57, 77, 98, 53, 59 - -Colour1GreenInput DW 9 - DB 10, 20 - DW 0, 63 - DW 7, Offset PaletteDefs+4 - DW 56, 58, 78, 99, 54, 60 - -Colour1BlueInput DW 9 - DB 10, 21 - DW 0, 63 - DW 7, Offset PaletteDefs+5 - DW 57, 59, 79, 100, 55, 61 - -Colour2RedInput DW 9 - DB 10, 24 - DW 0, 63 - DW 7, Offset PaletteDefs+6 - DW 58, 60, 80, 0FFFFh, 56, 62 - -Colour2GreenInput DW 9 - DB 10, 25 - DW 0, 63 - DW 7, Offset PaletteDefs+7 - DW 59, 61, 81, 0FFFFh, 57, 63 - -Colour2BlueInput DW 9 - DB 10, 26 - DW 0, 63 - DW 7, Offset PaletteDefs+8 - DW 60, 62, 82, 0FFFFh, 58, 64 - -Colour3RedInput DW 9 - DB 10, 29 - DW 0, 63 - DW 7, Offset PaletteDefs+9 - DW 61, 63, 83, 0FFFFh, 59, 65 - -Colour3GreenInput DW 9 - DB 10, 30 - DW 0, 63 - DW 7, Offset PaletteDefs+10 - DW 62, 64, 84, 0FFFFh, 60, 66 - -Colour3BlueInput DW 9 - DB 10, 31 - DW 0, 63 - DW 7, Offset PaletteDefs+11 - DW 63, 65, 85, 0FFFFh, 61, 67 - -Colour4RedInput DW 9 - DB 10, 34 - DW 0, 63 - DW 7, Offset PaletteDefs+12 - DW 64, 66, 86, 0FFFFh, 62, 68 - -Colour4GreenInput DW 9 - DB 10, 35 - DW 0, 63 - DW 7, Offset PaletteDefs+13 - DW 65, 67, 87, 0FFFFh, 63, 69 - -Colour4BlueInput DW 9 - DB 10, 36 - DW 0, 63 - DW 7, Offset PaletteDefs+14 - DW 66, 68, 88, 0FFFFh, 64, 70 - -Colour5RedInput DW 9 - DB 10, 39 - DW 0, 63 - DW 7, Offset PaletteDefs+15 - DW 67, 69, 89, 0FFFFh, 65, 71 - -Colour5GreenInput DW 9 - DB 10, 40 - DW 0, 63 - DW 7, Offset PaletteDefs+16 - DW 68, 70, 90, 0FFFFh, 66, 72 - -Colour5BlueInput DW 9 - DB 10, 41 - DW 0, 63 - DW 7, Offset PaletteDefs+17 - DW 69, 71, 91, 0FFFFh, 67, 73 - -Colour6RedInput DW 9 - DB 10, 44 - DW 0, 63 - DW 7, Offset PaletteDefs+18 - DW 70, 72, 92, 0FFFFh, 68, 74 - -Colour6GreenInput DW 9 - DB 10, 45 - DW 0, 63 - DW 7, Offset PaletteDefs+19 - DW 71, 73, 93, 0FFFFh, 69, 75 - -Colour6BlueInput DW 9 - DB 10, 46 - DW 0, 63 - DW 7, Offset PaletteDefs+20 - DW 72, 74, 94, 0FFFFh, 70, 76 - -Colour7RedInput DW 9 - DB 37, 14 - DW 0, 63 - DW 7, Offset PaletteDefs+21 - DW 73, 75, 95, 53, 71, 77 - -Colour7GreenInput DW 9 - DB 37, 15 - DW 0, 63 - DW 7, Offset PaletteDefs+22 - DW 74, 76, 96, 54, 72, 78 - -Colour7BlueInput DW 9 - DB 37, 16 - DW 0, 63 - DW 7, Offset PaletteDefs+23 - DW 75, 77, 97, 55, 73, 79 - -Colour8RedInput DW 9 - DB 37, 19 - DW 0, 63 - DW 7, Offset PaletteDefs+24 - DW 76, 78, 98, 56, 74, 80 - -Colour8GreenInput DW 9 - DB 37, 20 - DW 0, 63 - DW 7, Offset PaletteDefs+25 - DW 77, 79, 99, 57, 75, 81 - -Colour8BlueInput DW 9 - DB 37, 21 - DW 0, 63 - DW 7, Offset PaletteDefs+26 - DW 78, 80, 100, 58, 76, 82 - -Colour9RedInput DW 9 - DB 37, 24 - DW 0, 63 - DW 7, Offset PaletteDefs+27 - DW 79, 81, 102, 59, 77, 83 - -Colour9GreenInput DW 9 - DB 37, 25 - DW 0, 63 - DW 7, Offset PaletteDefs+28 - DW 80, 82, 102, 60, 78, 84 - -Colour9BlueInput DW 9 - DB 37, 26 - DW 0, 63 - DW 7, Offset PaletteDefs+29 - DW 81, 83, 102, 61, 79, 85 - -Colour10RedInput DW 9 - DB 37, 29 - DW 0, 63 - DW 7, Offset PaletteDefs+30 - DW 82, 84, 102, 62, 80, 86 - -Colour10GreenInput DW 9 - DB 37, 30 - DW 0, 63 - DW 7, Offset PaletteDefs+31 - DW 83, 85, 102, 63, 81, 87 - -Colour10BlueInput DW 9 - DB 37, 31 - DW 0, 63 - DW 7, Offset PaletteDefs+32 - DW 84, 86, 102, 64, 82, 88 - -Colour11RedInput DW 9 - DB 37, 34 - DW 0, 63 - DW 7, Offset PaletteDefs+33 - DW 85, 87, 102, 65, 83, 89 - -Colour11GreenInput DW 9 - DB 37, 35 - DW 0, 63 - DW 7, Offset PaletteDefs+34 - DW 86, 88, 102, 66, 84, 90 - -Colour11BlueInput DW 9 - DB 37, 36 - DW 0, 63 - DW 7, Offset PaletteDefs+35 - DW 87, 89, 102, 67, 85, 91 - -Colour12RedInput DW 9 - DB 37, 39 - DW 0, 63 - DW 7, Offset PaletteDefs+36 - DW 88, 90, 102, 68, 86, 92 - -Colour12GreenInput DW 9 - DB 37, 40 - DW 0, 63 - DW 7, Offset PaletteDefs+37 - DW 89, 91, 102, 69, 87, 93 - -Colour12BlueInput DW 9 - DB 37, 41 - DW 0, 63 - DW 7, Offset PaletteDefs+38 - DW 90, 92, 102, 70, 88, 94 - -Colour13RedInput DW 9 - DB 37, 44 - DW 0, 63 - DW 7, Offset PaletteDefs+39 - DW 91, 93, 102, 71, 89, 95 - -Colour13GreenInput DW 9 - DB 37, 45 - DW 0, 63 - DW 7, Offset PaletteDefs+40 - DW 92, 94, 102, 72, 90, 96 - -Colour13BlueInput DW 9 - DB 37, 46 - DW 0, 63 - DW 7, Offset PaletteDefs+41 - DW 93, 95, 102, 73, 91, 97 - -Colour14RedInput DW 9 - DB 64, 14 - DW 0, 63 - DW 7, Offset PaletteDefs+42 - DW 94, 96, 53, 74, 92, 98 - -Colour14GreenInput DW 9 - DB 64, 15 - DW 0, 63 - DW 7, Offset PaletteDefs+43 - DW 95, 97, 54, 75, 93, 99 - -Colour14BlueInput DW 9 - DB 64, 16 - DW 0, 63 - DW 7, Offset PaletteDefs+44 - DW 96, 98, 55, 76, 94, 100 - -Colour15RedInput DW 9 - DB 64, 19 - DW 0, 63 - DW 7, Offset PaletteDefs+45 - DW 97, 99, 56, 77, 95, 102 - -Colour15GreenInput DW 9 - DB 64, 20 - DW 0, 63 - DW 7, Offset PaletteDefs+46 - DW 98, 100, 57, 78, 96, 102 - -Colour15BlueInput DW 9 - DB 64, 21 - DW 0, 63 - DW 7, Offset PaletteDefs+47 - DW 99, 102, 58, 79, 97, 102 - -PredefinedPaletteMsg DW 1 - DB 57, 25 - DB 20h - DB "Predefined Palettes", 0 - -PredefinedPalette1 DW 2 - DW 100, 103, 82, 61 - DW 0 - DW 0, 0 - DW 4 ; Jump to function - DD DWord Ptr S_UsePresetPalette - DW 0 ; First palette - DW 0, 0 ; Unused data - DB 55, 27, 77, 29 - DB 8 - DB 0 - DB " Light Blue", 0 - -PredefinedPalette2 DW 2 - DW 102, 104, 85, 64 - DW 0 - DW 0, 0 - DW 4 ; Jump to function - DD DWord Ptr S_UsePresetPalette - DW 1 ; First palette - DW 0, 0 ; Unused data - DB 55, 30, 77, 32 - DB 8 - DB 0 - DB " Gold", 0 - -PredefinedPalette3 DW 2 - DW 103, 105, 86, 65 - DW 0 - DW 0, 0 - DW 4 ; Jump to function - DD DWord Ptr S_UsePresetPalette - DW 2 ; First palette - DW 0, 0 ; Unused data - DB 55, 33, 77, 35 - DB 8 - DB 0 - DB " Camouflage", 0 - -PredefinedPalette4 DW 2 - DW 104, 106, 88, 67 - DW 0 - DW 0, 0 - DW 4 ; Jump to function - DD DWord Ptr S_UsePresetPalette - DW 3 - DW 0, 0 ; Unused data - DB 55, 36, 77, 38 - DB 8 - DB 0 - DB " Midnight Tracking", 0 - -PredefinedPalette5 DW 2 - DW 105, 107, 90, 69 - DW 0 - DW 0, 0 - DW 4 ; Jump to function - DD DWord Ptr S_UsePresetPalette - DW 4 - DW 0, 0 ; Unused data - DB 55, 39, 77, 41 - DB 8 - DB 0 - DB " Pine Colours", 0 - -PredefinedPalette6 DW 2 - DW 106, 108, 91, 70 - DW 0 - DW 0, 0 - DW 4 ; Jump to function - DD DWord Ptr S_UsePresetPalette - DW 5 - DW 0, 0 ; Unused data - DB 55, 42, 77, 44 - DB 8 - DB 0 - DB " Soundtracker", 0 - -PredefinedPalette7 DW 2 - DW 107, 0FFFFh, 94, 73 - DW 0 - DW 0, 0 - DW 4 ; Jump to function - DD DWord Ptr S_UsePresetPalette - DW 6 - DW 0, 0 ; Unused data - DB 55, 45, 77, 47 - DB 8 - DB 0 - DB " Volcanic", 0 - -O1_LoadInstrumentList DW 5 - DW Near Ptr InstrumentNameLoader ; Idlekey - DW Near Ptr LoadInstrumentKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr LoadInstrumentHeader ; 2 - DW Near Ptr FillHeader ; 3 - DW Near Ptr LoadInstrumentWindow - DW Near Ptr LoadInstrument ; 5 - DW Near Ptr LoadInstrumentDriveWindow - DW Near Ptr LoadInstrumentDrive - DW Near Ptr SetHelpContext11 - DW 0 - -LoadInstrumentDriveWindow DW 0 - DB 63, 15, 72, 48 - DB 27 - -LoadInstrumentDrive DW 15 - DD DWord Ptr D_LIDrawDriveWindow - DD DWord Ptr D_LIPreDriveWindow - DD DWord Ptr D_LIPostDriveWindow - -O1_ViewInstrumentLibrary DW 5 - DW Near Ptr InstrumentNameLoader ; Idlekey - DW Near Ptr LoadInstrumentKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr InstrumentLibraryHeader ; 2 - DW Near Ptr FillHeader ; 3 - DW Near Ptr LoadInstrumentWindow - DW Near Ptr ViewInstrument ; 5 - DW Near Ptr LoadInstrumentDriveWindow - DW Near Ptr LoadInstrumentDrive - DW Near Ptr SetHelpContext11 - DW 0 - -LoadInstrumentHeader DW 10 - DB "Load Instrument", 0 - -InstrumentLibraryHeader DW 10 - DB "Instrument Library (Ctrl-F4)", 0 - -LoadInstrumentWindow DW 0 - DB 5, 12, 62, 48 - DB 27 - -LoadInstrument DW 15 - DD DWord Ptr D_DrawLoadInstrument - DD DWord Ptr D_PreLoadInstrument - DD DWord Ptr D_PostLoadInstrument - -ViewInstrument DW 15 - DD DWord Ptr D_DrawLoadInstrument - DD DWord Ptr D_PreLoadInstrument - DD DWord Ptr D_ViewInstrument - -InstrumentNameLoader DD DWord Ptr D_LoadInstrumentNames - DD DWord Ptr IdleUpdateInfoLine - DD 0 - -O1_UndoList DW 3 - DW Near Ptr IdleFunctionList - DW Near Ptr ESCExitList - DW Near Ptr UndoBox1 - DW Near Ptr UndoBox2 - DW Near Ptr UndoText - DW Near Ptr UndoSelector - DW 0 - -UndoBox1 DW 0 - DB 16, 21, 63, 36 - DB 3 - -UndoBox2 DW 0 - DB 19, 23, 60, 34 - DB 27 - -UndoText DW 1 - DB 38, 22 - DB 23h - DB "Undo", 0 - -UndoSelector DW 15 - DD DWord Ptr PEFunction_DrawUndo - DD DWord Ptr PEFunction_PreUndo - DD DWord Ptr PEFunction_PostUndo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -O1_MessageList DW 4 - DW Near Ptr IdleFunctionList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr MessageBox - DW Near Ptr MessageObject - DW Near Ptr MessageHeader - DW Near Ptr SetHelpContext12 - DW 0 - -MessageBox DW 0 - DB 1, 12, 78, 48 - DB 27 - -MessageObject DW 15 - DD DWord Ptr Msg_DrawMessage - DD DWord Ptr Msg_PreMessage - DD DWord Ptr Msg_PostMessage - -MessageHeader DW 10 - DB "Message Editor (Shift-F9)", 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -O1_MIDIOutputScreen DW 9 - DW Near Ptr IdleFunctionList - DW Near Ptr MIDIOutKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr MIDIOutputHeader - DW Near Ptr MIDIOutputMainConfigText - DW Near Ptr MIDIOutputSFxConfigText - DW Near Ptr MIDIOutputMainConfigBox - DW Near Ptr MIDIOutputSFxConfigBox - DW Near Ptr MIDIOutputZxxConfigBox ; 8 - DW Near Ptr MIDIStartInput ; 9 - DW Near Ptr MIDIStopInput ; 10 - DW Near Ptr MIDITickInput ; 11 - DW Near Ptr MIDINoteOnInput ; 12 - DW Near Ptr MIDINoteOffInput ; 13 - DW Near Ptr MIDIChangeVolumeInput ; 14 - DW Near Ptr MIDIChangePanInput ; 15 - DW Near Ptr MIDIBankSelectInput ; 16 - DW Near Ptr MIDIProgramChangeInput ; 17 - DW Near Ptr MIDISF0Input - DW Near Ptr MIDISF1Input - DW Near Ptr MIDISF2Input - DW Near Ptr MIDISF3Input - DW Near Ptr MIDISF4Input - DW Near Ptr MIDISF5Input - DW Near Ptr MIDISF6Input - DW Near Ptr MIDISF7Input - DW Near Ptr MIDISF8Input - DW Near Ptr MIDISF9Input - DW Near Ptr MIDISFAInput - DW Near Ptr MIDISFBInput - DW Near Ptr MIDISFCInput - DW Near Ptr MIDISFDInput - DW Near Ptr MIDISFEInput - DW Near Ptr MIDISFFInput ; 33 - DW Near Ptr MIDIZ1Input - DW Near Ptr MIDIZ2Input - DW Near Ptr MIDIZ3Input - DW Near Ptr MIDIZ4Input - DW Near Ptr MIDIZ5Input - DW Near Ptr MIDIZ6Input - DW Near Ptr MIDIZ7Input - DW Near Ptr MIDIZxxNumbering - DW 0 - -MIDIOutputHeader DW 10 - DB "MIDI Output Configuration", 0 - -MIDIZxxNumbering DW 8 - DD DWord Ptr F_ShowMIDIZxxInput - -MIDIOutKeyList DB 0 - DW 1C8h - DD DWord Ptr F_MIDI_Up - - DB 0 - DW 1D0h - DD DWord Ptr F_MIDI_Down - - DB 0 - DW 1C9h - DD DWord Ptr F_MIDI_PgUp - - DB 0 - DW 1D1h - DD DWord Ptr F_MIDI_PgDn - - DB 5 - DW Offset GlobalKeyChain - -MIDIOutputMainConfigText DW 1 - DB 2, 13 - DB 20h - DB 0FFh, 4, " MIDI Start", 13 - DB 0FFh, 5, " MIDI Stop", 13 - DB 0FFh, 5, " MIDI Tick", 13 - DB 0FFh, 7, " Note On", 13 - DB 0FFh, 6, " Note Off", 13 - DB " Change Volume", 13 - DB 0FFh, 4, " Change Pan", 13 - DB " Bank Select", 13 - DB "Program Change", 13 - DB 13 - DB 13 - DB " Macro", 13 - DB " Setup", 0 - -MIDIOutputSFxConfigText DW 1 - DB 13, 24 - DB 20h - DB "SF0", 13 - DB "SF1", 13 - DB "SF2", 13 - DB "SF3", 13 - DB "SF4", 13 - DB "SF5", 13 - DB "SF6", 13 - DB "SF7", 13 - DB "SF8", 13 - DB "SF9", 13 - DB "SFA", 13 - DB "SFB", 13 - DB "SFC", 13 - DB "SFD", 13 - DB "SFE", 13 - DB "SFF", 0 - -MIDIOutputMainConfigBox DW 0 - DB 16, 12, 60, 22 - DB 27 - -MIDIOutputSFxConfigBox DW 0 - DB 16, 23, 60, 40 - DB 27 - -MIDIOutputZxxConfigBox DW 0 - DB 16, 41, 60, 49 - DB 27 - - -MIDIStartInput DW 16 - DB 17, 13 - DW 7, 0 - DW 32 - DD 0 - DW 9, 10, 0FFFFh, 0FFFFh - -MIDIStopInput DW 16 - DB 17, 14 - DW 7, 20h - DW 32 - DD 0 - DW 9, 11, 0FFFFh, 0FFFFh - -MIDITickInput DW 16 - DB 17, 15 - DW 7, 40h - DW 32 - DD 0 - DW 10, 12, 0FFFFh, 0FFFFh - -MIDINoteOnInput DW 16 - DB 17, 16 - DW 7, 60h - DW 32 - DD 0 - DW 11, 13, 0FFFFh, 0FFFFh - -MIDINoteOffInput DW 16 - DB 17, 17 - DW 7, 80h - DW 32 - DD 0 - DW 12, 14, 0FFFFh, 0FFFFh - -MIDIChangeVolumeInput DW 16 - DB 17, 18 - DW 7, 0A0h - DW 32 - DD 0 - DW 13, 15, 0FFFFh, 0FFFFh - -MIDIChangePanInput DW 16 - DB 17, 19 - DW 7, 0C0h - DW 32 - DD 0 - DW 14, 16, 0FFFFh, 0FFFFh - -MIDIBankSelectInput DW 16 - DB 17, 20 - DW 7, 0E0h - DW 32 - DD 0 - DW 15, 17, 0FFFFh, 0FFFFh - -MIDIProgramChangeInput DW 16 - DB 17, 21 - DW 7, 100h - DW 32 - DD 0 - DW 16, 18, 0FFFFh, 0FFFFh - -MIDISF0Input DW 16 - DB 17, 24 - DW 7, 120h - DW 32 - DD 0 - DW 17, 19, 0FFFFh, 0FFFFh - -MIDISF1Input DW 16 - DB 17, 25 - DW 7, 140h - DW 32 - DD 0 - DW 18, 20, 0FFFFh, 0FFFFh - -MIDISF2Input DW 16 - DB 17, 26 - DW 7, 160h - DW 32 - DD 0 - DW 19, 21, 0FFFFh, 0FFFFh - -MIDISF3Input DW 16 - DB 17, 27 - DW 7, 180h - DW 32 - DD 0 - DW 20, 22, 0FFFFh, 0FFFFh - -MIDISF4Input DW 16 - DB 17, 28 - DW 7, 1A0h - DW 32 - DD 0 - DW 21, 23, 0FFFFh, 0FFFFh - -MIDISF5Input DW 16 - DB 17, 29 - DW 7, 1C0h - DW 32 - DD 0 - DW 22, 24, 0FFFFh, 0FFFFh - -MIDISF6Input DW 16 - DB 17, 30 - DW 7, 1E0h - DW 32 - DD 0 - DW 23, 25, 0FFFFh, 0FFFFh - -MIDISF7Input DW 16 - DB 17, 31 - DW 7, 200h - DW 32 - DD 0 - DW 24, 26, 0FFFFh, 0FFFFh - -MIDISF8Input DW 16 - DB 17, 32 - DW 7, 220h - DW 32 - DD 0 - DW 25, 27, 0FFFFh, 0FFFFh - -MIDISF9Input DW 16 - DB 17, 33 - DW 7, 240h - DW 32 - DD 0 - DW 26, 28, 0FFFFh, 0FFFFh - -MIDISFAInput DW 16 - DB 17, 34 - DW 7, 260h - DW 32 - DD 0 - DW 27, 29, 0FFFFh, 0FFFFh - -MIDISFBInput DW 16 - DB 17, 35 - DW 7, 280h - DW 32 - DD 0 - DW 28, 30, 0FFFFh, 0FFFFh - -MIDISFCInput DW 16 - DB 17, 36 - DW 7, 2A0h - DW 32 - DD 0 - DW 29, 31, 0FFFFh, 0FFFFh - -MIDISFDInput DW 16 - DB 17, 37 - DW 7, 2C0h - DW 32 - DD 0 - DW 30, 32, 0FFFFh, 0FFFFh - -MIDISFEInput DW 16 - DB 17, 38 - DW 7, 2E0h - DW 32 - DD 0 - DW 31, 33, 0FFFFh, 0FFFFh - -MIDISFFInput DW 16 - DB 17, 39 - DW 7, 300h - DW 32 - DD 0 - DW 32, 34, 0FFFFh, 0FFFFh - -MIDIZ1Input DW 16 - DB 17, 42 - DW 7, 8320h - DW 32 - DD 0 - DW 0FFFFh, 35, 0FFFFh, 0FFFFh - -MIDIZ2Input DW 16 - DB 17, 43 - DW 7, 8340h - DW 32 - DD 0 - DW 34, 36, 0FFFFh, 0FFFFh - -MIDIZ3Input DW 16 - DB 17, 44 - DW 7, 8360h - DW 32 - DD 0 - DW 35, 37, 0FFFFh, 0FFFFh - -MIDIZ4Input DW 16 - DB 17, 45 - DW 7, 8380h - DW 32 - DD 0 - DW 36, 38, 0FFFFh, 0FFFFh - -MIDIZ5Input DW 16 - DB 17, 46 - DW 7, 83A0h - DW 32 - DD 0 - DW 37, 39, 0FFFFh, 0FFFFh - -MIDIZ6Input DW 16 - DB 17, 47 - DW 7, 83C0h - DW 32 - DD 0 - DW 38, 40, 0FFFFh, 0FFFFh - -MIDIZ7Input DW 16 - DB 17, 48 - DW 7, 83E0h - DW 32 - DD 0 - DW 39, 0FFFFh, 0FFFFh, 0FFFFh - -O1_MIDIScreen DW 7 - DW Near Ptr MIDIIdleList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader - DW Near Ptr FillHeader - DW Near Ptr MIDIHeader - DW Near Ptr ShowMIDIInput - DW Near Ptr MIDIOptionsBox ; 5 - DW Near Ptr MIDIOptions ; 6 - DW Near Ptr ProgramChangeToggle ; 7 - DW Near Ptr Program1Toggle ; 8 - DW Near Ptr RecordNoteOffToggle ; 9 - DW Near Ptr RecordVelocityToggle ; 10 - DW Near Ptr RecordAfterTouchToggle ; 11 - DW Near Ptr MIDITranslateBox ; 12 - DW Near Ptr MIDIAmplificationTB ; 13 - DW Near Ptr MIDICentralNoteTB ; 14 - DW Near Ptr MIDIOutputButton ; 15 - DW Near Ptr MIDISaveConfigButton ; 16 - DW Near Ptr MIDINoteOffCut ; 17 - DW Near Ptr MIDIPitchBox ; 18 - DW Near Ptr MIDIPitchToggle ; 19 - DW Near Ptr MIDIPWDInput ; 20 - DW Near Ptr MIDIEmbedBox - DW NEar Ptr MIDIEmbedToggle - DW Near Ptr SetHelpContext13 - DW 0 - -MIDIHeader DW 10 - DB "MIDI Screen (Shift-F1)", 0 - -MIDIPitchToggle DW 17 - DB 25, 27 - DW 2 - DW 2Ch ; Offset of 'Flags' - DB 64 - DW 14, 20, 0FFFFh, 0FFFFh - -MIDIEmbedToggle DW 17 - DB 25, 31 - DW 2 - DW 2Ch ; Offset of 'Flags' - DB 128 - DW 20, 15, 0FFFFh, 0FFFFh - -MIDIPWDInput DW 14 - DB 25, 28 - DW 0, 32 - DW 3, 35h - DW 19, 22, 0FFFFh, 0FFFFh - DW 0FFFFh, 0FFFFh ; PgUp/PgDn - DW 25 - -MIDIOutputButton DW 2 - DW 22, 16, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 1 - DD DWord Ptr O1_MIDIOutputScreen - DW 0, 0, 0 - DB 2, 34, 32, 36 - DB 8 - DB 0 - DB " MIDI Output Configuration", 0 - -MIDISaveConfigButton DW 2 - DW 15, 0FFFFh, 0FFFFh, 0FFFFh - DW 0 - DW 0, 0 - DW 2 - DD DWord Ptr Music_SaveMIDIConfig - DW 0, 0, 0 - DB 2, 37, 32, 39 - DB 8 - DB 0 - DB " Save Output Configuration", 0 - -ShowMIDIInput DW 8 -MIDIIdleList DD DWord Ptr K_ShowMIDIInput - DD DWord Ptr IdleUpdateInfoLine - DD 0 - -MIDIOptionsBox DW 0 - DB 24, 14, 30, 21 - DB 27 - -MIDITranslateBox DW 0 - DB 24, 22, 51, 25 - DB 27 - -MIDIPitchBox DW 0 - DB 24, 26, 51, 29 - DB 27 - -MIDIEmbedBox DW 0 - DB 24, 30, 51, 32 - DB 27 - -MIDIOptions DW 1 - DB 7, 15 - DB 20h - DB 0FFh, 4, " Tick quantize", 13 - DB " Base Program 1", 13 - DB " Record Note-Off", 13 - DB " Record Velocity", 13 - DB "Record Aftertouch", 13 - DB 0FFh, 5, " Cut note off", 13 - DB 13 - DB 13 - DB 0FFh, 4, " Amplification", 13 - DB " C-5 Note-value", 13 - DB 13 - DB 13 - DB "Output MIDI pitch", 13 - DB "Pitch wheel depth", 13 - DB 13 - DB 13 - DB " Embed MIDI data", 0 - -ProgramChangeToggle DW 17 - DB 25, 15 - DW 1, Offset CentraliseCursor - DB 8 - DW 0FFFFh, 8, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -Program1Toggle DW 17 - DB 25, 16 - DW 1, Offset CentraliseCursor - DB 16 - DW 7, 9, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -RecordNoteOffToggle DW 17 - DB 25, 17 - DW 1, Offset CentraliseCursor - DB 32 - DW 8, 10, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -RecordVelocityToggle DW 17 - DB 25, 18 - DW 1, Offset CentraliseCursor - DB 64 - DW 9, 11, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -RecordAfterTouchToggle DW 17 - DB 25, 19 - DW 1, Offset CentraliseCursor - DB 128 - DW 10, 17, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -MIDINoteOffCut DW 17 - DB 25, 20 - DW 1, Offset Flags - DB 2 - DW 11, 13, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -MIDIAmplificationTB DW 9 - DB 25, 23 - DW 0, 200 - DW 1, Offset MIDIAmplification - DW 17, 14, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - -MIDICentralNoteTB DW 14 - DB 25, 24 - DW 0, 127 - DW 1, Offset MIDICentralNote - DW 13, 19, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh - DW 25 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF TIMERSCREEN - -O1_TimerList DW 5 - DW Near Ptr InfoPageIdleList - DW Near Ptr GlobalKeyList - DW Near Ptr FullScreenBox ; 0 - DW Near Ptr ScreenHeader ; 1 - DW Near Ptr FillHeader ; 2 - DW Near Ptr TimerHeader - DW Near Ptr TimerText ; 4 - DW Near Ptr DrawTimer - DW Near Ptr Divider - DW Near Ptr SetHelpContext0 - DW 0 - -TimerHeader DW 10 - DB "Time Information", 0 - -TimerText DW 1 - DB 2, 13 - DB 20h - DB 0FFh, 4, " Module time:", 13 - DB "Current session:", 13 - DB 13 - DB 0FFh, 5, " Total time:", 0 - -DrawTimer DW 15 - DD DWord Ptr D_DrawTimer - DD DWord Ptr F_Nothing - DD DWord Ptr D_PostTimerList - -Divider DW 1 - DB 1, 18 - DB 20h - DB 0FFh, 78, 09Ah, 0 - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -O1_StereoSampleList DW 2 - DW Near Ptr IdleFunctionList - DW Near Ptr LRKeyList - DW Near Ptr StereoSampleBox ; 0 - DW Near Ptr StereoSampleText - DW Near Ptr StereoButtonLeft ; 2 - DW Near Ptr StereoButtonRight ; 3 - DW 0 - -LRKeyList DB 8 - DW 'L' - DD DWord Ptr F_Return64 - - DB 8 - DW 'R' - DD DWord Ptr F_Return192 - - DB 0FFh - -StereoSampleBox DW 0 - DB 26, 22, 54, 29 - DB 3 - -StereoSampleText DW 1 - DB 30, 24 - DB 20h - DB "Loading Stereo Sample", 0 - -StereoButtonLeft DW 2 - DW 0FFFFh, 0FFFFh, 3, 3 - DW 0 - DW 0, 0 ; Unused - DW 0 ; Return - DW 64 - DW 0, 0, 0, 0 ; Unused - DB 30, 26, 39, 28 - DB 8 - DB 0 - DB " Left", 0 - -StereoButtonRight DW 2 - DW 0FFFFh, 0FFFFh, 2, 2 - DW 0 - DW 0, 0 ; Unused - DW 0 ; Return - DW 64+128 - DW 0, 0, 0, 0 ; Unused - DB 40, 26, 50, 28 - DB 8 - DB 0 - DB " Right", 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -O1_ShowTime DW 2 - DW 0 - DW Near Ptr ESCReturnList - DW Near Ptr NBMBox - DW Near Ptr ShowTime - DW Near Ptr OKButton - DW Near Ptr SongLengthText - DW 0 - -SongLengthText DW 1 - DB 27, 27 - DB 20h - DB "Total song time: ", 0 - -ShowTime DW 8 - DD Music_ShowTime - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF SPECTRUMANALYSER -O1_FourierDisplay DW 0 -; DW Near Ptr FourierIdleList - DW Near Ptr InfoPageIdleList - DW Near Ptr FourierKeyList - DW Near Ptr FourierDisplay - DW 0 - -;FourierIdleList DD DWord Ptr Fourier_IdleList -; DD 0 - -FourierKeyList DB 1 - DW '-' - DD DWord Ptr DisplayMinus - - DB 1 - DW '+' - DD DWord Ptr DisplayPlus - - DB 0 - DW 13Fh - DD DWord Ptr Glbl_Ctrl_F5 - - DB 1 - DW 'p' - DD DWord Ptr Fourier_ChangePalette - - DB 5 - DW Near Ptr PlayCommandChain - -FourierDisplay DW 15 - DD DWord Ptr Fourier_PreDrawScreen - DD DWord Ptr Fourier_DrawScreen - DD DWord Ptr Fourier_PostFunction - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -EndS - -End + Jumps + +include switch.inc + + Extrn D_SaveInstrument:Far + Extrn D_LSCheckLoopValues:Far + Extrn D_LSCheckSusLoopValues:Far + + Extrn D_PreLoadSampleWindow:Far + Extrn D_DrawLoadSampleWindow:Far + Extrn D_PostLoadSampleWindow:Far + + Extrn D_LSDrawDriveWindow:Far + Extrn D_LSPreDriveWindow:Far + Extrn D_LSPostDriveWindow:Far + + Extrn D_LIDrawDriveWindow:Far + Extrn D_LIPreDriveWindow:Far + Extrn D_LIPostDriveWindow:Far + + Extrn D_SaveSample:Far + Extrn D_SaveRawSample:Far + Extrn D_SaveST3Sample:Far + + Extrn D_GetFormatType:Far + + Extrn D_SlowSampleSort:Far + Extrn D_SlowInstrumentSort:Far + Extrn D_SaveDirectoryConfiguration:Far + Extrn D_LoadSampleNames:Far + Extrn D_LoadSongNames:Far + Extrn D_DrawFileWindow:Far + Extrn D_DrawDirectoryWindow:Far + Extrn D_DrawDriveWindow:Far + Extrn D_PreFileWindow:Far + Extrn D_SaveModule:Far + Extrn D_PostFileLoadWindow:Far + Extrn D_PostFileSaveWindow:Far + Extrn D_PreDirectoryWindow:Far + Extrn D_PostDirectoryWindow:Far + Extrn D_PostViewSampleLibrary:Far + Extrn D_PreDriveWindow:Far + Extrn D_PostDriveWindow:Far + Extrn D_PostSaveDriveWindow:Far + Extrn D_NewDirectory:Far + Extrn D_NewSpecifier:Far + +IF TUTORIAL +ELSE + Extrn D_LoadXM:Far + Extrn D_LoadS3M:Far + Extrn D_LoadMOD:Far + Extrn D_LoadIT:Far + Extrn D_LoadMTM:Far + Extrn D_Load669:Far +ENDIF + Extrn D_DrawHeader:Far + Extrn D_SaveIT:Far + Extrn D_SaveS3M:Far + Extrn D_SaveSong:Far + Extrn Quit:Far + + Extrn D_DrawLoadInstrument:Far + Extrn D_PreLoadInstrument:Far + Extrn D_PostLoadInstrument:Far + Extrn D_LoadInstrumentNames:Far + Extrn D_ViewInstrument:Far + +IF EMSDEBUG + + Extrn E_DumpEMSMemory:Far + +ENDIF + + Extrn LSWindow_Up:Far + Extrn LSWindow_Down:Far + + Extrn SongDirectory:Byte + Extrn FileSpecifier:Byte + + Extrn F_InstrumentButtonHandler:Far + + + Extrn F_DrawHeader:Far + Extrn F_Return0:Far + Extrn F_Return1:Far + Extrn F_ShowChannels:Far + Extrn F_RedrawScreen:Far + Extrn F_GotoEmptyList:Far + Extrn F_DrawSMCChannels:Far + Extrn F_Nothing:Far + Extrn F_CalculateLength:Far + + Extrn F_MainMenu:Far + Extrn F_Help:Far ; Menu functions + Extrn F_ViewVariables:Far + Extrn F_ViewOrderPan:Far + Extrn F_ViewPattern:Far + + Extrn F_FileMenu:Far + Extrn F_FileLoad:Far + Extrn F_FileNew:Far + Extrn F_FileSaveCurrent:Far + Extrn F_FileSaveAs:Far + Extrn F_FileDOSShell:Far + Extrn F_FileQuit:Far + + Extrn F_PlaybackMenu:Far + Extrn F_InfoPage:Far + Extrn F_PlaySong:Far + Extrn F_PlayPattern:Far + Extrn F_PlayOrder:Far + Extrn F_PlayMark:Far + Extrn F_Stop:Far + Extrn F_ReinitSoundCard:Far + Extrn F_DriverScreen:Far + Extrn F_CalculateLength:Far + + Extrn F_MessageEditor:Far + Extrn F_SampleMenu:Far + Extrn F_SampleList:Far + Extrn F_SampleLibrary:Far + Extrn F_ReloadGravis:Far + + Extrn F_Return64:Far + Extrn F_Return192:Far + + Extrn F_InstrumentMenu:Far + Extrn F_InstrumentList:Far + Extrn F_InstrumentLibrary:Far + + Extrn F_ShowMIDIZxxInput:Far + Extrn F_MIDI_Up:Far, F_MIDI_Down:Far + Extrn F_MIDI_PgUp:Far, F_MIDI_PgDn:Far + +IF SPECTRUMANALYSER + Extrn Fourier_Start:Far + Extrn Fourier_PreDrawScreen:Far + Extrn Fourier_DrawScreen:Far + Extrn Fourier_PostFunction:Far + Extrn Fourier_IdleList:Far + Extrn Fourier_ChangePalette:Far +ENDIF + + Extrn K_DrawTables:Far + Extrn K_ResetKeyboardTables:Far + Extrn K_ShowMIDIInput:Far + + Extrn PEFunction_IncreaseOctave:Far + Extrn PEFunction_DecreaseOctave:Far + + Extrn Glbl_DriverScreen:Far + Extrn Glbl_Ctrl_F1:Far + Extrn Glbl_Ctrl_F3:Far + Extrn Glbl_Ctrl_F4:Far + Extrn Glbl_Ctrl_F5:Far + Extrn Glbl_Ctrl_F12:Far + Extrn Glbl_F8:Far + Extrn Glbl_F9:Far + Extrn Glbl_F10:Far + Extrn Glbl_F11:Far + Extrn Glbl_F12:Far + Extrn Glbl_F2:Far + Extrn Glbl_F3:Far + Extrn Glbl_F4:Far + Extrn Glbl_F5:Far + Extrn Glbl_F6:Far + Extrn PE_F7:Far ; Global... + Extrn Glbl_Shift_F1:Far + Extrn Glbl_Shift_F6:Far + Extrn Glbl_Shift_F9:Far + Extrn Glbl_Alt_F1:Far + Extrn Glbl_Alt_F2:Far + Extrn Glbl_Alt_F3:Far + Extrn Glbl_Alt_F4:Far + Extrn Glbl_Alt_F5:Far + Extrn Glbl_Alt_F6:Far + Extrn Glbl_Alt_F7:Far + Extrn Glbl_Alt_F8:Far + Extrn Glbl_LoadSample:Far + Extrn Glbl_LoadInstrument:Far + Extrn Glbl_LeftBrace:Far + Extrn Glbl_RightBrace:Far + Extrn Glbl_LeftSquareBracket:Far + Extrn Glbl_RightSquareBracket:Far + +IF NETWORKENABLED + Extrn Network_DriverScreen:Far + Extrn Network_DrawDriverScreen:Far + Extrn Network_PreDriverScreen:Far + Extrn Network_PostDriverScreen:Far + + Public O1_LoadNetworkDriver +ENDIF + +IF TIMERSCREEN + Extrn Glbl_TimerScreen:Far + Extrn D_DrawTimer:Far, D_PostTimerList:Far +ENDIF + + Extrn H_HelpESC:Far + Extrn H_Help:Far + Extrn H_DrawHelp:Far + + Extrn H_HelpUp:Far + Extrn H_HelpDown:Far + Extrn H_HelpPgUp:Far + Extrn H_HelpPgDn:Far + + Extrn I_SelectScreen:Far + Extrn I_InstrumentListSpace:Far + Extrn I_InstrumentListNoteOff:Far + Extrn I_AmplifySample:Far + Extrn I_GetInstrumentScreen:Far + Extrn I_SampleButtonHandler:Far + Extrn I_CalculateC5Speed:Far + Extrn I_PrintC5Frequency:Far + + Extrn I_DoubleSampleSpeed:Far + Extrn I_HalveSampleSpeed:Far + Extrn I_SampleSpeedSemiUp:Far + Extrn I_SampleSpeedSemiDown:Far + + Extrn I_PlaySample:Far + Extrn I_PlayNote:Far + + Extrn I_DrawPitchPanCenter:Far + Extrn I_PrePitchPanCenter:Far + Extrn I_PostPitchPanCenter:Far + + Extrn I_IncreasePlayChannel:Far + Extrn I_DecreasePlayChannel:Far + + Extrn I_DeleteInstrument:Far + Extrn I_ReverseSample:Far + Extrn I_InvertSample:Far + Extrn I_CutSampleBeforeLoop:Far + Extrn I_ConvertSample:Far + Extrn I_DeleteSample:Far + Extrn I_CutSample:Far + Extrn I_ExchangeSamples:Far + Extrn I_SwapSamples:Far + Extrn I_ReplaceSample:Far + Extrn I_ReplaceInstrument:Far + Extrn I_SwapInstruments:Far + Extrn I_ResizeSample:Far + Extrn I_ResizeSampleNoInt:Far + Extrn I_UpdateInstrument:Far + Extrn I_ToggleSampleQuality:Far + Extrn I_CopyInstrument:Far + Extrn I_CenterSample:Far + Extrn I_ScaleInstrumentVolumes:Far + Extrn I_ScaleSampleVolumes:Far + + Extrn I_DrawInstrumentWindow:Far + Extrn I_PreInstrumentWindow:Far + Extrn I_PostInstrumentWindow:Far + Extrn I_ToggleMultiChannel:Far + + Extrn I_DrawNoteWindow:Far + Extrn I_PreNoteWindow:Far + Extrn I_PostNoteWindow:Far + + Extrn I_DrawEnvelope:Far + Extrn I_PreEnvelope:Far + Extrn I_PostEnvelope:Far + + Extrn I_ShowSampleInfo:Far + Extrn I_SampleUp:Far + Extrn I_SampleDown:Far + Extrn I_CheckLoopValues:Far + Extrn I_CheckSusLoopValues:Far + + Extrn I_DrawSampleList:Far + Extrn I_PreSampleList:Far + Extrn I_PostSampleList:Far + Extrn I_IdleUpdateEnvelope:Far + + Extrn Msg_DrawMessage:Far + Extrn Msg_PreMessage:Far + Extrn Msg_PostMessage:Far + + Extrn Music_SoundCardLoadAllSamples:Far + Extrn Music_ReinitSoundCard:Far + Extrn Music_SaveMIDIConfig:Far + Extrn Music_ShowAutodetectSoundcard:Far + Extrn Music_ToggleOrderUpdate:Far + + Extrn PE_FillHeader:Far + Extrn PE_SetCommandCursor:Far + Extrn PE_DrawPatternEdit:Far + Extrn PE_PrePatternEdit:Far + Extrn PE_PostPatternEdit:Far + + Extrn PEFunction_DrawUndo:Far + Extrn PEFunction_PreUndo:Far + Extrn PEFunction_PostUndo:Far + + Extrn S_UpdateScreen:Far + Extrn S_RestoreScreen:Far + + Extrn DrawDisplayData:Far + Extrn PostDisplayData:Far + Extrn DisplayUpdateScreen:Far + + Extrn BaseOctave + Extrn SkipValue + Extrn RowHiLight1 + Extrn RowHiLight2 + Extrn NumberOfRows:Word + Extrn Amplification + Extrn InstrumentAmplification + Extrn FastVolumeAmplification + Extrn SampleAmplification + Extrn CommandToValue + Extrn MultiChannelInfo + Extrn SampleNumberInput:Byte + Extrn SongDirectory:Byte + Extrn SampleDirectory:Byte + Extrn InstrumentDirectory:Byte + + Extrn IdleUpdateInfoLine:Far + Extrn DOSShell:Far + + Extrn I_ExchangeInstruments:Far + + Extrn F_ConfigButtonSetup:Far + Extrn F_SetControlInstrument:Far + Extrn F_SetControlSample:Far + Extrn F_SetMono:Far + Extrn F_SetStereo:Far + Extrn F_SetAmiga:Far + Extrn F_SetLinear:Far + + Extrn F_NewSong:Far + + Extrn AddressInput:Byte + Extrn NewSampleSize:Word + Extrn ThumbStringEnter:Byte + Extrn SampleName:Byte + +If MEMORYDEBUG + + Extrn F_PostDebug:Far + Extrn Glbl_Debug:Far + Extrn F_DrawDebug:Far + Extrn F_DebugUp:Far + Extrn F_DebugDown:Far + Extrn F_DebugPgUp:Far + Extrn F_DebugPgDn:Far + Extrn F_DebugStringInput:Far + Global O1_DebugList + +ENDIF + + Extrn PaletteDefs:Byte + + Extrn S_UsePresetPalette:Far + Extrn DisplayMinus:Far + Extrn DisplayPlus:Far + Extrn PatternSetLength, PatternLengthStart, PatternLengthEnd + + Extrn MouseToggle:Far + Extrn Refresh:Far + + Extrn MIDI_SetInstrument:Far, CentraliseCursor + Extrn MIDI_PlayNote:Far, MIDI_NoteOff:Far, MIDI_PlaySample:Far + Extrn MIDICentralNote, MIDIAmplification + + Extrn Music_TimeSong:Far, Music_ShowTime:Far + Extrn Flags + + Extrn Music_ToggleSoloInstrument:Far + Extrn Music_ToggleSoloSample:Far + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + + Global O1_MIDIScreen + Global O1_LongMessageList + Global O1_MessageList + Global O1_ConfirmNoSave + + Global O1_MainMenu + Global O1_PlayBackMenu + Global O1_SampleMenu + Global O1_FileMenu + Global O1_InstrumentMenu + + Global O1_EditSampleName + + Global O1_AutoDetectList + + Global O1_ShowTime + Global O1_SampleCenterList + Global O1_ConfirmClearMessage + Global O1_SampleAmplificationList + Global O1_EnableInstrumentMode + Global O1_OutOfSoundCardMemoryList + Global O1_OutOfSamplesList + Global O1_NewSongList + Global O1_InitInstrument + Global O1_ThumbStringList + Global O1_ConfigureITList + Global O1_OrderVolumeList + Global O1_HelpList + Global O1_OrderPanningList + Global O1_PatternEditList + Global O1_PEConfigList + Global O1_OutOfMemoryList + Global O1_OutOfSoundCardMemoryList + Global O1_SwapOutOfRangeList + Global O1_OverlapBlockList + Global O1_NoBlockMarkedList + Global O1_NoBlockDataList + Global O1_GetAmpList + Global O1_GetInstrumentAmpList + Global O1_GetFastAmpList + +IF SHOWPATTERNLENGTH + Global O1_ShowPatternLengthList +ENDIF + + Global O1_C5FrequencyList + +IF SPECTRUMANALYSER + Global O1_FourierDisplay +ENDIF + Global O1_EMSWarningMessage +IF NETWORKENABLED + Global O1_NetworkErrorList +ENDIF + Global O1_TemplateErrorList + Global O1_PatternTooLongList + Global O1_SampleList + Global O1_LoadModuleList + Global O1_SaveModuleList + Global O1_SaveS3MList + Global O1_LoadS3MList + Global O1_LoadXMList + Global O1_LoadMODList + Global O1_Load669List + Global O1_LoadMTMList + Global O1_LoadITList + Global O1_SaveITList + Global O1_EmptyList + Global O1_ConfirmOverWriteList + Global O1_UnableToSaveList + Global O1_ConfirmQuit + Global O1_SelectMultiChannel + Global O1_ConfirmDelete + Global O1_ConfirmDelete2 + Global O1_ConfirmDelete3 + Global O1_ConfirmDeleteSample + Global O1_ConfirmDeleteInstrument + Global O1_ConfirmCutSample + Global O1_ConfirmConvertList + Global O1_ConfirmConvert2List + Global O1_ExchangeSampleList + Global O1_ExchangeInstrumentList + Global O1_ReplaceSampleList + Global O1_ReplaceInstrumentList + Global O1_LoadSampleList + Global O1_ConfirmSaveRenameList + Global O1_ConfirmResaveList + Global O1_ConfirmDiscardList + Global O1_InitialiseInstrumentList + Global O1_SwapSampleList + Global O1_SwapInstrumentList + Global O1_ResizeSampleList + Global O1_KeyboardList + Global O1_DisplayList + Global O1_FullDisplayList + Global O1_ViewSampleLibrary + Global O1_ConfigurePaletteList + Global O1_LoadInstrumentList + Global O1_ViewInstrumentLibrary + Global O1_ConfirmDeleteInstrument + Global O1_CopyInstrumentList + + Global O1_CrashRecovery + + Global O1_UndoList + + Global O1_InstrumentListGeneral + Global O1_InstrumentListVolume + Global O1_InstrumentListPanning + Global O1_InstrumentListPitch + Global O1_SetPatternLength + + Global O1_StereoSampleList + Global O1_PatternSizeMismatchList + + Global PatternLength + Global HelpKeyValue, OrderKeyValue + Global GlobalKeyList:Byte + Global LogoCharacter:Word + Global EMSErrorValue, EMSErrorValue2 + Global EMSErrorValue3, EMSErrorValue4 + Global EMSErrorValue5, EMSErrorValue6 + Global EMSErrorValue7, EMSErrorValue8 + +IF TIMERSCREEN + Public O1_TimerList +ENDIF + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Object1 BYTE Public 'Data' + +O1_AutoDetectList DW 6 + DW 0 + DW Near Ptr ESCContinueList + DW Near Ptr AboutBox + DW Near Ptr ImpulseLogo + DW Near Ptr AutoMiniBox + DW Near Ptr AboutText + DW Near Ptr AutoDetectText + DW Near Ptr CallAutoDetect + DW Near Ptr AutoContinueButton + DW 0 + +ESCContinueList DB 0 ; ESC + DW 101h + DD Glbl_F2 + + DB 0FFh + +O1_OrderPanningList DW 10 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr FillHeader ; 2 + DW Near Ptr OrderandPanningMsg ; 3 + DW Near Ptr OrderBox ; 4 + DW Near Ptr PanBox1 ; 5 + DW Near Ptr PanBox2 ; 6 + DW Near Ptr ShowChannelMsgs ; 7 + DW Near Ptr PanText1 ; 8 + DW Near Ptr PanText2 ; 9 + DW Near Ptr OrderList ; 10 + DW Near Ptr Channel1 ; 11 + DW Near Ptr Channel2 ; 12 + DW Near Ptr Channel3 ; 13 + DW Near Ptr Channel4 ; 14 + DW Near Ptr Channel5 ; 15 + DW Near Ptr Channel6 ; 16 + DW Near Ptr Channel7 ; 17 + DW Near Ptr Channel8 ; 18 + DW Near Ptr Channel9 ; 19 + DW Near Ptr Channel10 ; 20 + DW Near Ptr Channel11 ; 21 + DW Near Ptr Channel12 ; 22 + DW Near Ptr Channel13 ; 23 + DW Near Ptr Channel14 ; 24 + DW Near Ptr Channel15 ; 25 + DW Near Ptr Channel16 ; 26 + DW Near Ptr Channel17 + DW Near Ptr Channel18 + DW Near Ptr Channel19 + DW Near Ptr Channel20 + DW Near Ptr Channel21 + DW Near Ptr Channel22 + DW Near Ptr Channel23 + DW Near Ptr Channel24 + DW Near Ptr Channel25 + DW Near Ptr Channel26 + DW Near Ptr Channel27 + DW Near Ptr Channel28 + DW Near Ptr Channel29 + DW Near Ptr Channel30 + DW Near Ptr Channel31 + DW Near Ptr Channel32 + DW Near Ptr Channel33 + DW Near Ptr Channel34 + DW Near Ptr Channel35 + DW Near Ptr Channel36 + DW Near Ptr Channel37 + DW Near Ptr Channel38 + DW Near Ptr Channel39 + DW Near Ptr Channel40 + DW Near Ptr Channel41 + DW Near Ptr Channel42 + DW Near Ptr Channel43 + DW Near Ptr Channel44 + DW Near Ptr Channel45 + DW Near Ptr Channel46 + DW Near Ptr Channel47 + DW Near Ptr Channel48 + DW Near Ptr Channel49 + DW Near Ptr Channel50 + DW Near Ptr Channel51 + DW Near Ptr Channel52 + DW Near Ptr Channel53 + DW Near Ptr Channel54 + DW Near Ptr Channel55 + DW Near Ptr Channel56 + DW Near Ptr Channel57 + DW Near Ptr Channel58 + DW Near Ptr Channel59 + DW Near Ptr Channel60 + DW Near Ptr Channel61 + DW Near Ptr Channel62 + DW Near Ptr Channel63 + DW Near Ptr Channel64 + DW Near Ptr SetHelpContext0 + DW 0 + +O1_HelpList DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr HelpKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr FillHeader ; 2 + DW Near Ptr HelpMsg ; 3 + DW Near Ptr HelpBox ; 4 + DW Near Ptr ShowHelp ; 5 + DW Near Ptr HelpDoneButton ; 6 + DW 0 + +O1_PatternEditList DW 3 + DW Near Ptr InfoPageIdleList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr PatternEditMsg ; 2 + DW Near Ptr PatternEdit ; 3 + DW Near Ptr FillHeader ; 4 + DW Near Ptr SetHelpContext1 ; 5 + DW 0 + +O1_PEConfigList DW 14 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCF2&ReturnList + DW Near Ptr PEConfigBox ; 0 + DW Near Ptr PEConfigText ; 1 + DW Near Ptr PEConfigBsOctText ; 2 + DW Near Ptr PEConfigSkipValueText ; 3 + DW Near Ptr PEConfigRHLMinorText ; 4 + DW Near Ptr PEConfigRHLMajorText ;5 + DW Near Ptr PEConfigMaxRowsText ; 6 + DW Near Ptr PEConfigCommandCursor ; 7 + DW Near Ptr PECBox1 + DW Near Ptr PECBox2 + DW Near Ptr PECBox3 + DW Near Ptr PECBox4 + DW Near Ptr PECBox5 + DW Near Ptr PEConfigDoneButton ; 13 + DW Near Ptr PETBBaseOctave ; 14 + DW Near Ptr PETBSkipValue ; 15 + DW Near Ptr PETBRHLMinor ; 16 + DW Near Ptr PETBRHLMajor ; 17 + DW Near Ptr PETBMaxRow ; 18 + DW Near Ptr PECLinkButton ; 19 + DW Near Ptr PECSplitButton ; 20 + DW Near Ptr FillHeader + DW 0 + +O1_SetPatternLength DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr ESC&ReturnList + DW Near Ptr SetPatternLengthBox ; 0 + DW Near Ptr SetPatternLengthHeader + DW Near Ptr SetPatternLengthThumbBox1 + DW Near Ptr SetPatternLengthThumbBox2 + DW Near Ptr SetPatternLengthThumbBar ; 4 + DW Near Ptr SetPatternLengthStart ; 5 + DW Near Ptr SetPatternLengthEnd ; 6 + DW Near Ptr SetPatternLengthOKButton ; 7 + DW Near Ptr SetPatternLengthText + DW 0 + +SetPatternLengthBox DW 0 + DB 15, 19, 65, 33 + DB 3 + +SetPatternLengthHeader DW 1 + DB 31, 21 + DB 20h + DB "Set Pattern Length", 0 + +SetPatternLengthText DW 1 + DB 19, 24 + DB 20h + DB "Pattern Length", 13 + DB 13 + DB 13 + DB " Start Pattern", 13 + DB " End Pattern", 0 + +SetPatternLengthThumbBox1 DW 0 + DB 33, 23, 56, 25 + DB 25 + +SetPatternLengthThumbBox2 DW 0 + DB 33, 26, 60, 29 + DB 25 + +SetPatternLengthThumbBar DW 9 + DB 34, 24 + DW 32, 200 + DW 1, Offset PatternSetLength + DW 0FFFFh, 5, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +SetPatternLengthStart DW 9 + DB 34, 27 + DW 0, 199 + DW 1, Offset PatternLengthStart + DW 4, 6, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +SetPatternLengthEnd DW 9 + DB 34, 28 + DW 0, 199 + DW 1, Offset PatternLengthEnd + DW 5, 7, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh + +SetPatternLengthOKButton DW 2 + DW 6, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 0 + DW 1 ; Returns 1 + DW 0, 0, 0, 0 + DB 35, 30, 44, 32 + DB 8 + DB 0 + DB " OK", 0 + +OKCancelList DB 8 ; 'O' + DW 'O' + DD DWord Ptr F_Return1 + + DB 8 ; 'C' + DW 'C' + DD DWord Ptr F_Return0 + + DB 8 ; 'Y' + DW 'Y' + DD DWord Ptr F_Return1 + + DB 8 ; 'N' + DW 'N' + DD DWord Ptr F_Return0 + +ESCReturnList DB 0 + DW 101h + DD DWord Ptr F_Return0 + + DB 5 + DW Near Ptr ChainMIDICommands + +O1_NoBlockMarkedList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr NBMText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_OutOfSoundCardMemoryList DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr OOSoundCardMemoryText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_OutOfMemoryList DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr OOMText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_PatternSizeMismatchList DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr PSMText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_LongMessageList DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr LongMsgText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_OutOfSamplesList DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr OOSText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_OverlapBlockList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr OLBText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_SwapOutOfRangeList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr SOORText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_NoBlockDataList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr NBDText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_PatternTooLongList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr PatternTooLongText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_GetAmpList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr AmpExtraKeyList + DW Near Ptr AmpBox ; 0 + DW Near Ptr AmpText ; 1 + DW Near Ptr AmpTBBox ; 2 + DW Near Ptr AmpTB ; 3 + DW Near Ptr ConfirmOKButton ; 4 + DW Near Ptr ConfirmCancelButton ; 5 + DW Near Ptr FillHeader + DW 0 + +O1_GetInstrumentAmpList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr AmpExtraKeyList + DW Near Ptr AmpBox ; 0 + DW Near Ptr AmpText ; 1 + DW Near Ptr AmpTBBox ; 2 + DW Near Ptr InstrumentAmpTB ; 3 + DW Near Ptr ConfirmOKButton ; 4 + DW Near Ptr ConfirmCancelButton ; 5 + DW Near Ptr FillHeader + DW 0 + +O1_GetFastAmpList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr AmpExtraKeyList + DW Near Ptr AmpBox ; 0 + DW Near Ptr AmpText ; 1 + DW Near Ptr FastAmpTBBox ; 2 + DW Near Ptr FastAmpTB ; 3 + DW Near Ptr ConfirmOKButton ; 4 + DW Near Ptr ConfirmCancelButton ; 5 + DW Near Ptr FillHeader + DW 0 + +O1_SampleAmplificationList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESC&ReturnList + DW Near Ptr SampleAmpBox + DW Near Ptr SampleAmpText ; 1 + DW Near Ptr SampleAmpTBBox ; 2 + DW Near Ptr SampleAmpTB ; 3 + DW Near Ptr ConfirmOKButton ; 4 + DW Near Ptr ConfirmCancelButton ; 5 + DW Near Ptr FillHeader + DW 0 + +IF SHOWPATTERNLENGTH + +O1_ShowPatternLengthList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr PatternLengthText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +ENDIF + +O1_C5FrequencyList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr C5FrequencyText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +O1_EMSWarningMessage DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr EMSErrorBox + DW Near Ptr EMSErrorText + DW Near Ptr OKButton + DW Near Ptr FillHeader + DW 0 + +IF NETWORKENABLED +O1_NetworkErrorList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr TemplateErrorBox + DW Near Ptr NetworkErrorText + DW Near Ptr TemplateOKButton + DW Near Ptr FillHeader + DW 0 +ENDIF + +O1_TemplateErrorList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr TemplateErrorBox + DW Near Ptr TemplateErrorText + DW Near Ptr TemplateOKButton + DW Near Ptr FillHeader + DW 0 + +O1_CrashRecovery DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr CrashRecoveryBox + DW Near Ptr CrashRecoveryText + DW Near Ptr CrashRecoveryOKButton + DW 0 + +O1_LoadSampleList DW 15 + DW Near Ptr SampleNameLoader + DW Near Ptr LoadSampleKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr LoadSampleHeader ; 2 + DW Near Ptr FillHeader ; 3 + DW Near Ptr LoadSampleBox + DW Near Ptr DriveSampleBox + DW Near Ptr LSInfoBox + DW Near Ptr LSInfoText + DW Near Ptr LSWaveFormBox + DW Near Ptr LSParametersBox + DW Near Ptr LSParametersText ; 10 + DW Near Ptr LSParametersVolBox ; 11 + DW Near Ptr LSParametersVibBox + DW Near Ptr LSFileInfoBox + DW Near Ptr LSFileInfoText + DW Near Ptr LoadSampleWindow ; 15 + DW Near Ptr LSDriveWindow ; 16 + DW Near Ptr LSFileNameInput ; 17 + DW Near Ptr LSSpeedInput + DW Near Ptr LSLoopToggle ; 19 + DW Near Ptr LSLoopBeginInput + DW Near Ptr LSLoopEndInput + DW Near Ptr LSSusLoopToggle ; 22 + DW Near Ptr LSSusLoopBeginInput + DW Near Ptr LSSusLoopEndInput + DW Near Ptr LSDefaultVolumeInput ; 25 + DW Near Ptr LSGlobalVolumeInput ; 26 + DW Near Ptr LSVibratoSpeedInput ; 27 + DW Near Ptr LSVibratoDepthInput ; 28 + DW Near Ptr LSVibratoRateInput ; 29 + DW Near Ptr SetHelpContext6 + DW 0 + +O1_ViewSampleLibrary DW 15 + DW Near Ptr SampleNameLoader + DW Near Ptr LoadSampleKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr ViewSampleHeader ; 2 + DW Near Ptr FillHeader ; 3 + DW Near Ptr LoadSampleBox + DW Near Ptr DriveSampleBox + DW Near Ptr LSInfoBox + DW Near Ptr LSInfoText + DW Near Ptr LSWaveFormBox + DW Near Ptr LSParametersBox + DW Near Ptr LSParametersText ; 10 + DW Near Ptr LSParametersVolBox ; 11 + DW Near Ptr LSParametersVibBox + DW Near Ptr LSFileInfoBox + DW Near Ptr LSFileInfoText + DW Near Ptr ViewSampleWindow ; 15 + DW Near Ptr LSDriveWindow ; 16 + DW Near Ptr LSFileNameInput ; 17 + DW Near Ptr LSSpeedInput + DW Near Ptr LSLoopToggle ; 19 + DW Near Ptr LSLoopBeginInput + DW Near Ptr LSLoopEndInput + DW Near Ptr LSSusLoopToggle ; 22 + DW Near Ptr LSSusLoopBeginInput + DW Near Ptr LSSusLoopEndInput + DW Near Ptr LSDefaultVolumeInput ; 25 + DW Near Ptr LSGlobalVolumeInput ; 26 + DW Near Ptr LSVibratoSpeedInput ; 27 + DW Near Ptr LSVibratoDepthInput ; 28 + DW Near Ptr LSVibratoRateInput ; 29 + DW Near Ptr SetHelpContext6 + DW 0 + + +LSFileNameInput DW 16 + DB 64, 13 + DW 3, 4 + DW 13 + DD 0 + DW 0FFFFh, 18, 25, 16 + +LSSpeedInput DW 18 + DB 64, 14 + DW 1, 3Ch + DD 0 + DW 17, 19, 25, 16 + +LSLoopToggle DW 17 + DB 64, 15 + DW 3, 12h + DB 16 + DW 18, 20, 25, 16 + +LSLoopBeginInput DW 18 + DB 64, 16 + DW 1, 34h + DD DWord Ptr D_LSCheckLoopValues + DW 19, 21, 25, 16 + +LSLoopEndInput DW 18 + DB 64, 17 + DW 1, 38h + DD DWord Ptr D_LSCheckLoopValues + DW 20, 22, 25, 16 + +LSSusLoopToggle DW 17 + DB 64, 18 + DW 3, 12h + DB 32 + DW 21, 23, 25, 16 + +LSSusLoopBeginInput DW 18 + DB 64, 19 + DW 1, 40h + DD DWord Ptr D_LSCheckSusLoopValues + DW 22, 24, 25, 16 + +LSSusLoopEndInput DW 18 + DB 64, 20 + DW 1, 44h + DD DWord Ptr D_LSCheckSusLoopValues + DW 23, 25, 25, 16 + +LSDefaultVolumeInput DW 9 + DB 63, 33 + DW 0, 64 + DW 5, 13h + DW 24, 26, 15, 17 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +LSGlobalVolumeInput DW 9 + DB 63, 34 + DW 0, 64 + DW 5, 11h + DW 25, 27, 15, 17 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +LSVibratoSpeedInput DW 9 + DB 63, 37 + DW 0, 64 + DW 5, 4Ch + DW 26, 28, 15, 17 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +LSVibratoDepthInput DW 14 + DB 63, 38 + DW 0, 32 + DW 5, 4Dh + DW 27, 29, 15, 17 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + DW 8 + +LSVibratoRateInput DW 14 + DB 63, 39 + DW 0, 255 + DW 5, 4Eh + DW 28, 0FFFFh, 15, 17 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + DW 8 + +SampleNameLoader DD DWord Ptr D_LoadSampleNames +IdleFunctionList DD DWord Ptr IdleUpdateInfoLine + DD 0 + +IdleInstrumentList DD DWord Ptr IdleUpdateInfoLine + DD DWord Ptr I_IdleUpdateEnvelope + DD 0 + +LoadSampleHeader DW 10 + DB "Load Sample", 0 + +ViewSampleHeader DW 10 + DB "Sample Library (Ctrl-F3)", 0 + +LoadSampleBox DW 0 + DB 5, 12, 44, 48 + DB 27 + +DriveSampleBox DW 0 + DB 45, 12, 54, 23 + DB 27 + +LSInfoBox DW 0 + DB 63, 12, 77, 23 + DB 27 + +LSInfoText DW 1 + DB 55, 13 + DB 20h + DB "Filename", 13 + DB " Speed", 13 + DB " Loop", 13 + DB " LoopBeg", 13 + DB " LoopEnd", 13 + DB " SusLoop", 13 + DB " SusLBeg", 13 + DB " SusLEnd", 13 + DB " Quality", 13 + DB " Length" + DB 0 + +LSWaveFormBox DW 0 + DB 45, 24, 77, 29 + DB 27 + +LSParametersBox DW 0 + DB 45, 30, 77, 42 + DB 9 + +LSParametersText DW 1 + DB 48, 33 + DB 20h + DB "Default Volume", 13 + DB " Global Volume", 13 + DB 13 + DB 13 + DB " Vibrato Speed", 13 + DB " Vibrato Depth", 13 + DB " Vibrato Rate" + DB 0 + +LSParametersVolBox DW 0 + DB 62, 32, 72, 35 + DB 25 + +LSParametersVibBox DW 0 + DB 62, 36, 72, 40 + DB 25 + +LSFileInfoBox DW 0 + DB 52, 43, 77, 48 + DB 27 + +LSFileInfoText DW 1 + DB 46, 44 + DB 20h + DB "Format", 13 + DB " Size", 13 + DB " Date", 13 + DB " Time" + DB 0 + +LoadSampleWindow DW 15 + DD DWord Ptr D_DrawLoadSampleWindow + DD DWord Ptr D_PreLoadSampleWindow + DD DWord Ptr D_PostLoadSampleWindow + +ViewSampleWindow DW 15 + DD DWord Ptr D_DrawLoadSampleWindow + DD DWord Ptr D_PreLoadSampleWindow + DD DWord Ptr D_PostViewSampleLibrary + +LSDriveWindow DW 15 + DD DWord Ptr D_LSDrawDriveWindow + DD DWord Ptr D_LSPreDriveWindow + DD DWord Ptr D_LSPostDriveWindow + +O1_SampleList DW 28 + DW Near Ptr IdleFunctionList + DW Near Ptr SampleGlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr SampleListHeader + DW Near Ptr SampleListBox + DW Near Ptr InstDVBox + DW Near Ptr InstDVText + DW Near Ptr InstDVTBBox + DW Near Ptr InstDVTB ; 7 + DW Near Ptr InstGVBox + DW Near Ptr InstGVText + DW Near Ptr InstGVTBBox + DW Near Ptr InstGVTB ; 11 + DW Near Ptr InstVSBox + DW Near Ptr InstVSText + DW Near Ptr InstVSTBBox + DW Near Ptr InstVSTB ; 15 + DW Near Ptr InstVDBox + DW Near Ptr InstVDText + DW Near Ptr InstVDTBBox + DW Near Ptr InstVDTB ; 19 + DW Near Ptr InstVRBox + DW Near Ptr InstVRText + DW Near Ptr InstVRTBBox + DW Near Ptr InstVRTB ; 23 + DW Near Ptr InstVWBox + DW Near Ptr InstVWText + DW Near Ptr InstParamBox + DW Near Ptr InstParamText + DW Near Ptr SampleList ; 28 + DW Near Ptr InstFileName ; 29 + DW Near Ptr InstSpeed + DW Near Ptr InstLoopToggle + DW Near Ptr InstLoopBegin + DW Near Ptr InstLoopEnd + DW Near Ptr InstSusLoopToggle + DW Near Ptr InstSusLoopBegin + DW Near Ptr InstSusLoopEnd ;36 + DW Near Ptr InstVibSine ; 37 + DW Near Ptr InstVibRamp ; 38 + DW Near Ptr InstVibSquare ; 39 + DW Near Ptr InstVibRandom ; 40 + DW Near Ptr InstWaveFormBox ; 41 + DW Near Ptr InstWaveFormText ; 42 + DW Near Ptr InstDPBox ; 43 + DW Near Ptr InstDPText + DW Near Ptr InstDPTBBox + DW Near Ptr InstDPToggle ; 46 + DW Near Ptr InstDPTB ; 47 + DW Near Ptr InstFillInfo + DW Near Ptr FillHeader + DW Near Ptr SetHelpContext2 + DW 0 + +O1_LoadModuleList DW 12 + DW Near Ptr SongNameModuleLoader + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr LoadModuleText + DW Near Ptr FileBox + DW Near Ptr DirBox ; 5 + DW Near Ptr DriveBox + DW Near Ptr SearchBox + DW Near Ptr FileInfoBox + DW Near Ptr FileNameBox + DW Near Ptr SearchText ; 10 + DW Near Ptr FileText + DW Near Ptr FileWindow ; 12 + DW Near Ptr DirectoryWindow + DW Near Ptr DriveWindow + DW Near Ptr FileNamePrompt ; 15 + DW Near Ptr SongDirectoryPrompt + DW Near Ptr SetHelpContext3 + DW 0 + +O1_SaveModuleList DW 15 + DW Near Ptr SongNameModuleLoader + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SaveModuleText + DW Near Ptr FileBox + DW Near Ptr DirBox ; 5 + DW Near Ptr DriveBox + DW Near Ptr SearchBox + DW Near Ptr FileInfoBox + DW Near Ptr FileNameBox + DW Near Ptr SearchText ; 10 + DW Near Ptr FileText + DW Near Ptr FileSaveWindow ; 12 + DW Near Ptr DirectoryWindow + DW Near Ptr SaveDriveWindow + DW Near Ptr FileNameSavePrompt ; 15 + DW Near Ptr SongDirectoryPrompt + DW Near Ptr ITFormatButton ; 17 + DW Near Ptr S3MFormatButton ; 18 + DW Near Ptr OldITFormatButton ; 19 +IF DDCOMPRESS + DW Near Ptr IT215FormatButton ; 20 +ENDIF + DW 0 + +IF NETWORKENABLED +O1_LoadNetworkDriver DW 6 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SaveModuleText + DW Near Ptr LoadNetworkText + DW Near Ptr LoadNetworkBox + DW Near Ptr LoadNetworkFunctions + DW 0 +ENDIF + +O1_SaveITList DW 7 + DW Near Ptr IdleFunctionGotoEmpty + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SaveModuleText + DW Near Ptr LoadBox + DW Near Ptr SaveITModuleText + DW Near Ptr DirectScreen ; 6 + DW Near Ptr SaveIT ; 7 + DW 0 + +O1_SaveS3MList DW 7 + DW Near Ptr IdleFunctionGotoEmpty + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr SaveModuleText + DW Near Ptr LoadBox + DW Near Ptr SaveS3MModuleText + DW Near Ptr DirectScreen ; 6 + DW Near Ptr SaveS3M ; 7 + DW 0 + +IF TUTORIAL +ELSE + +O1_LoadS3MList DW 7 + DW Near Ptr IdleFunctionGotoEmpty + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr LoadModuleText + DW Near Ptr LoadBox + DW Near Ptr LoadS3MModuleText + DW Near Ptr DirectScreen ; 6 + DW Near Ptr LoadS3M ; 7 + DW 0 + +O1_LoadXMList DW 7 + DW Near Ptr IdleFunctionGotoEmpty + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr LoadModuleText + DW Near Ptr LoadBox + DW Near Ptr LoadXMModuleText + DW Near Ptr DirectScreen ; 6 + DW Near Ptr LoadXM ; 7 + DW 0 + +O1_LoadMTMList DW 7 + DW Near Ptr IdleFunctionGotoEmpty + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr LoadModuleText + DW Near Ptr LoadBox + DW Near Ptr LoadMTMModuleText + DW Near Ptr DirectScreen ; 6 + DW Near Ptr LoadMTM ; 7 + DW 0 + +O1_LoadMODList DW 7 + DW Near Ptr IdleFunctionGotoEmpty + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr LoadModuleText + DW Near Ptr LoadBox + DW Near Ptr LoadMODModuleText + DW Near Ptr DirectScreen ; 6 + DW Near Ptr LoadMOD ; 7 + DW 0 + +O1_Load669List DW 7 + DW Near Ptr IdleFunctionGotoEmpty + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr LoadModuleText + DW Near Ptr LoadBox + DW Near Ptr Load669ModuleText + DW Near Ptr DirectScreen ; 6 + DW Near Ptr Load669 ; 7 + DW 0 + +O1_LoadITList DW 7 + DW Near Ptr IdleFunctionGotoEmpty + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr LoadModuleText + DW Near Ptr LoadBox + DW Near Ptr LoadITModuleText + DW Near Ptr DirectScreen ; 6 + DW Near Ptr LoadIT ; 7 + DW 0 +ENDIF + +O1_EmptyList DW 0 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyList + DW Near Ptr InDirectScreen ; 0 + DW Near Ptr FullScreenBox ; 1 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr NoText + DW 0 + +ITFormatButton DW 2 + DW 0FFFFh, 18, 14, 15 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr D_GetFormatType + DW 0 + DW 0, 0 + DB 69, 12, 77, 14 + DB 8 + DB 0 + DB " IT214", 0 + +S3MFormatButton DW 2 + DW 17, 19, 14, 15 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr D_GetFormatType + DW 1 + DW 0, 0 + DB 69, 15, 77, 17 + DB 8 + DB 0 + DB " S3M", 0 + +IF DDCOMPRESS + +OldITFormatButton DW 2 + DW 18, 20, 14, 15 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr D_GetFormatType + DW 2 + DW 0, 0 + DB 69, 18, 77, 20 + DB 8 + DB 0 + DB " IT2xx", 0 + +IT215FormatButton DW 2 + DW 19, 15, 14, 15 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr D_GetFormatType + DW 3 + DW 0, 0 + DB 69, 21, 77, 23 + DB 8 + DB 0 + DB " IT215", 0 + + +ELSE + +OldITFormatButton DW 2 + DW 18, 15, 14, 15 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr D_GetFormatType + DW 2 + DW 0, 0 + DB 69, 18, 77, 20 + DB 8 + DB 0 + DB " IT2xx", 0 +ENDIF + + +NoText DW 10 + DB 0 + +LoadBox DW 0 + DB 1, 12, 78, 48 + DB 27 + +SaveITModuleText DW 1 + DB 3, 14 + DB 2h + DB "Saving Impulse 2 Module", 13 + DB 0FFh, 23, 129, 0 + +SaveS3MModuleText DW 1 + DB 3, 14 + DB 2h + DB "Saving Scream Tracker 3 Module", 13 + DB 0FFh, 30, 129, 0 + +LoadS3MModuleText DW 1 + DB 3, 14 + DB 2h + DB "Scream Tracker III Module", 13 + DB 0FFh, 25, 129, 0 + +LoadXMModuleText DW 1 + DB 3, 14 + DB 2h + DB "Fast Tracker II Module", 13 + DB 0FFh, 22, 129, 0 + +LoadMTMModuleText DW 1 + DB 3, 14 + DB 2h + DB "MultiTracker Module", 13 + DB 0FFh, 19, 129, 0 + +LoadMODModuleText DW 1 + DB 3, 14 + DB 2h + DB "MOD Format Module", 13 + DB 0FFh, 17, 129, 0 + +Load669ModuleText DW 1 + DB 3, 14 + DB 2h + DB "Composer 669 Module", 13 + DB 0FFh, 19, 129, 0 + +LoadITModuleText DW 1 + DB 3, 14 + DB 2h + DB "Impulse Tracker Module", 13 + DB 0FFh, 22, 129, 0 + +IdleFunctionGotoEmpty DD DWord Ptr F_GotoEmptyList + DD 0 + +IF TUTORIAL +ELSE + +LoadMOD DW 15 + DD DWord Ptr F_Return0 + DD DWord Ptr D_LoadMOD + DD DWord Ptr F_GotoEmptyList + +Load669 DW 15 + DD DWord Ptr F_Return0 + DD DWord Ptr D_Load669 + DD DWord Ptr F_GotoEmptyList + +LoadS3M DW 15 + DD DWord Ptr F_Return0 + DD DWord Ptr D_LoadS3M + DD DWord Ptr F_GotoEmptyList + +LoadXM DW 15 + DD DWord Ptr F_Return0 + DD DWord Ptr D_LoadXM + DD DWord Ptr F_GotoEmptyList + +LoadMTM DW 15 + DD DWord Ptr F_Return0 + DD DWord Ptr D_LoadMTM + DD DWord Ptr F_GotoEmptyList + +LoadIT DW 15 + DD DWord Ptr F_Return0 + DD DWord Ptr D_LoadIT + DD DWord Ptr F_GotoEmptyList + +ENDIF + +SaveIT DW 15 + DD DWord Ptr F_Return0 + DD DWord Ptr D_SaveIT + DD DWord Ptr F_GotoEmptyList + +SaveS3M DW 15 + DD DWord Ptr F_Return0 + DD DWord Ptr D_SaveS3M + DD DWord Ptr F_GotoEmptyList + +FileNamePrompt DW 16 + DB 13, 46 + DW 0 ; Disk segment + DW Offset FileSpecifier + DW 64 ; Length + DD D_NewSpecifier + DW 12, 16, 16, 14 + +FileNameSavePrompt DW 16 + DB 13, 46 + DW 0 ; Disk segment + DW Offset FileSpecifier + DW 64 ; Length + DD D_SaveModule + DW 12, 16, 16, 14 + +SongDirectoryPrompt DW 16 + DB 13, 47 + DW 0 + DW Offset SongDirectory + DW 64 + DD D_NewDirectory + DW 15, 12, 12, 15 + +SongNameModuleLoader Label DWord + DD DWord Ptr D_LoadSongNames + DD DWord Ptr IdleUpdateInfoLine + DD 0 + +FileWindow DW 15 + DD DWord Ptr D_DrawFileWindow + DD DWord Ptr D_PreFileWindow + DD DWord Ptr D_PostFileLoadWindow + +FileSaveWindow DW 15 + DD DWord Ptr D_DrawFileWindow + DD DWord Ptr D_PreFileWindow + DD DWord Ptr D_PostFileSaveWindow + +DirectoryWindow DW 15 + DD DWord Ptr D_DrawDirectoryWindow + DD DWord Ptr D_PreDirectoryWindow + DD DWord Ptr D_PostDirectoryWindow + +DriveWindow DW 15 + DD DWord Ptr D_DrawDriveWindow + DD DWord Ptr D_PreDriveWindow + DD DWord Ptr D_PostDriveWindow + +SaveDriveWindow DW 15 + DD DWord Ptr D_DrawDriveWindow + DD DWord Ptr D_PreDriveWindow + DD DWord Ptr D_PostSaveDriveWindow + +IF NETWORKENABLED +LoadNetworkText DW 10 + DB "Load Network Driver", 0 + +LoadNetworkBox DW 0 + DB 1, 12, 78, 49 + DB 27 + +LoadNetworkFunctions DW 15 + DD DWord Ptr Network_DrawDriverScreen + DD DWord Ptr Network_PreDriverScreen + DD DWord Ptr Network_PostDriverScreen + +ENDIF + +LoadModuleText DW 10 + DB "Load Module (F9)", 0 + +SaveModuleText DW 10 + DB "Save Module (F10)", 0 + +FileBox DW 0 + DB 2, 12, 41, 44 + DB 27 + +DirBox DW 0 + DB 43, 12, 56, 34 + DB 27 + +DriveBox DW 0 + DB 58, 12, 67, 34 + DB 27 + +SearchBox DW 0 + DB 50, 36, 77, 38 + DB 27 + +FileInfoBox DW 0 + DB 50, 39, 77, 44 + DB 27 + +FileNameBox DW 0 + DB 12, 45, 77, 48 + DB 27 + +SearchText DW 1 + DB 44, 37 + DB 20h + DB "Search", 13 + DB 13 + DB 13 + DB "Format", 13 + DB " Size", 13 + DB " Date", 13 + DB " Time", 0 + +FileText DW 1 + DB 3, 46 + DB 20h + DB " Filename", 13 + DB "Directory", 0 + +SampleListHeader DW 10 + DB "Sample List (F3)", 0 + +InstFillInfo DW 8 + DD DWord Ptr I_ShowSampleInfo + +InstFileName DW 16 + DB 64, 13 + DW 1 + DW 4 + DW 13 + DD 0 + DW 0FFFFh, 30, 28, 7 + +InstSpeed DW 18 + DB 64, 14 + DW 0 + DW 3Ch + DD DWord Ptr I_PlaySample + DW 29, 31, 28, 7 + +InstLoopToggle DW 17 + DB 64, 15 + DW 0 + DW 12h + DB 16 + DW 30, 32, 28, 7 + +InstLoopBegin DW 18 + DB 64, 16 + DW 0 + DW 34h + DD DWord Ptr I_CheckLoopValues + DW 31, 33, 28, 7 + +InstLoopEnd DW 18 + DB 64, 17 + DW 0 + DW 38h + DD DWord Ptr I_CheckLoopValues + DW 32, 34, 28, 7 + +InstSusLoopToggle DW 17 + DB 64, 18 + DW 0 + DW 12h + DB 32 + DW 33, 35, 28, 7 + +InstSusLoopBegin DW 18 + DB 64, 19 + DW 0 + DW 40h + DD DWord Ptr I_CheckSusLoopValues + DW 34, 36, 28, 7 + +InstSusLoopEnd DW 18 + DB 64, 20 + DW 0 + DW 44h + DD DWord Ptr I_CheckSusLoopValues + DW 35, 37, 28, 7 + +SetHelpContext0 DW 11 + DW 0 + +SetHelpContext1 DW 11 + DW 1 + +SetHelpContext2 DW 11 + DW 2 + +SetHelpContext3 DW 11 + DW 3 + +SetHelpContext4 DW 11 + DW 4 + +SetHelpContext5 DW 11 + DW 5 + +SetHelpContext6 DW 11 + DW 6 + +SetHelpContext7 DW 11 + DW 7 + +SetHelpContext8 DW 11 + DW 8 + +SetHelpContext9 DW 11 + DW 9 + +SetHelpContext10 DW 11 + DW 10 + +SetHelpContext11 DW 11 + DW 11 + +SetHelpContext12 DW 11 + DW 12 + +SetHelpContext13 DW 11 + DW 13 + +SampleListBox DW 0 + DB 4, 12, 35, 48 + DB 27 + +InstDVBox DW 0 + DB 36, 12, 53, 18 + DB 9 + +InstDVTBBox DW 0 + DB 37, 15, 47, 17 + DB 9 + +InstDVTB DW 9 + DB 38, 16 + DW 0, 64 + DW 2, 13h + DW 0FFFFh, 11, 29, 28 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +InstGVTBBox DW 0 + DB 37, 22, 47, 24 + DB 9 + +InstGVTB DW 9 + DB 38, 23 + DW 0, 64 + DW 2, 11h + DW 7, 46, 29, 28 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +InstDPTBBox DW 0 + DB 37, 29, 47, 32 + DB 25 + +InstDPToggle DW 17 + DB 38, 30 + DW 0, 2Fh + DB 80h + DW 11, 47, 29, 28 + +InstDPTB DW 9 + DB 38, 31 + DW 0, 64 + DW 2, 2Fh + DW 46, 15, 29, 28 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +InstVSTBBox DW 0 + DB 37, 38, 47, 40 + DB 9 + +InstVSTB DW 9 + DB 38, 39 + DW 0, 64 + DW 2, 4Ch + DW 47, 19, 37, 28 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +InstVDTBBox DW 0 + DB 37, 45, 47, 47 + DB 9 + +InstVDTB DW 14 + DB 38, 46 + DW 0, 32 + DW 2, 4Dh + DW 15, 0FFFFh, 23, 28 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + DW 8 + +InstVRTBBox DW 0 + DB 55, 45, 72, 47 + DB 9 + +InstVRTB DW 14 + DB 56, 46 + DW 0, 255 + DW 2, 4Eh + DW 39, 0FFFFh, 28, 19 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + DW 15 + +InstGVBox DW 0 + DB 36, 19, 53, 25 + DB 9 + +InstDPBox DW 0 + DB 36, 26, 53, 33 + DB 9 + +InstVSBox DW 0 + DB 36, 35, 53, 41 + DB 9 + +InstVDBox DW 0 + DB 36, 42, 53, 48 + DB 9 + +InstVRBox DW 0 + DB 54, 42, 77, 48 + DB 9 + +InstParamBox DW 0 + DB 63, 12, 77, 24 + DB 27 + +InstVWBox DW 0 + DB 54, 31, 77, 41 + DB 9 + +InstDVText DW 1 + DB 38, 14 + DB 20h + DB "Default Volume", 0 + +InstGVText DW 1 + DB 38, 21 + DB 20h + DB "Global Volume", 0 + +InstDPText DW 1 + DB 39, 28 + DB 20h + DB "Default Pan", 0 + +InstVSText DW 1 + DB 38, 37 + DB 20h + DB "Vibrato Speed", 0 + +InstVDText DW 1 + DB 38, 44 + DB 20h + DB "Vibrato Depth", 0 + +InstVRText DW 1 + DB 60, 44 + DB 20h + DB "Vibrato Rate", 0 + +InstVWText DW 1 + DB 58, 33 + DB 20h + DB "Vibrato Waveform", 0 + +InstParamText DW 1 + DB 55, 13 + DB 20h + DB "Filename", 13 + DB " Speed", 13 + DB " Loop", 13 + DB " LoopBeg", 13 + DB " LoopEnd", 13 + DB " SusLoop", 13 + DB " SusLBeg", 13 + DB " SusLEnd", 13 + DB 0FFh, 8, ' ', 0FEh, 21h, 146, 0FEh, 3, 0FFh, 13, 154, 0FEh, 20h, 13 + DB " Quality", 13 + DB " Length" + DB 0 + +InstVibSine DW 2 + DW 36, 39, 15, 38 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr I_SampleButtonHandler + DW 0, 4Fh, 0 + DB 56, 35, 65, 37 + DB 8 + DB 0 + DB " ", 185, 186, 0 + +InstVibRamp DW 2 + DW 36, 40, 37, 28 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr I_SampleButtonHandler + DW 1, 4Fh, 0 + DB 66, 35, 75, 37 + DB 8 + DB 0 + DB " ", 189, 190, 0 + +InstVibSquare DW 2 + DW 37, 23, 15, 40 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr I_SampleButtonHandler + DW 2, 4Fh, 0 + DB 56, 38, 65, 40 + DB 8 + DB 0 + DB " ", 187, 188, 0 + +InstVibRandom DW 2 + DW 38, 23, 39, 28 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr I_SampleButtonHandler + DW 3, 4Fh, 0 + DB 66, 38, 75, 40 + DB 8 + DB 0 + DB " Random", 0 + +InstWaveFormBox DW 0 + DB 54, 25, 77, 30 + DB 9 + +InstWaveFormText DW 1 + DB 55, 26 + DB 0Dh + DB 1, 2, 3, 4, 5, 6, 7, 8, 9, 0FFh, 1, 10, 11 + DB 12, 0FFh, 1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 13 + DB 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 + DB 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 13 + DB 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55 + DB 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 13 + DB 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77 + DB 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88 + DB 0 + +SampleList DW 15 + DD DWord Ptr I_DrawSampleList + DD DWord Ptr I_PreSampleList + DD DWord Ptr I_PostSampleList + +EMSErrorText DW 1 + DB 27, 26 + DB 20h + DB "Crash warning: EMS error", 13 + DB " Debug: ", 0FDh, "Xh, ", 0FDh, "D, ", 0FDh, "D, ", 0FDh, "X", 13 + DB 0FFh, 8, " " + DB 0FDh, "X:" + DB 0FDh, "X:" + DB 0FDh, "X:" + DB 0FDh, "X", 0 +EMSErrorValue7 DW 0 +EMSErrorValue6 DW 0 +EMSErrorValue5 DW 0 +EMSErrorValue4 DW 0 +EMSErrorValue8 DW 0 +EMSErrorValue3 DW 0 +EMSErrorValue2 DW 0 +EMSErrorValue DW 0 + +EMSErrorBox DW 0 + DB 25, 24, 54, 32 + DB 3 + +TemplateErrorBox DW 0 + DB 20, 23, 59, 34 + DB 3 + +TemplateErrorText DW 1 + DB 24, 25 + DB 20h + DB 0FFh, 9, " Template Error", 13, 13 + DB "No note in the top left position", 13 + DB " of the clipboard on which to", 13 + DB 0FFh, 7, " base translations.", 0 + +IF NETWORKENABLED +NetworkErrorText DW 1 + DB 23, 25 + DB 20h + DB 0FFh, 10, " Network Error", 13, 13 + DB "This function is not available in", 13 + DB " multi-composer mode. Disconnect", 13 + DB " from network mode to enable.", 0 +ENDIF + +CrashRecoveryBox DW 0 + DB 20, 19, 60, 30 + DB 3 + +CrashRecoveryText DW 1 + DB 22, 21 + DB 20h + DB 0FFh, 12, " Crash Recovery", 13, 13 + DB " Please save your work under a", 13 + DB " different filename, reboot your", 13 + DB "computer and rerun Impulse Tracker as", 13 + DB " the system is likely to be unstable", 0 + +IF SHOWPATTERNLENGTH + +PatternLengthText DW 1 + DB 27, 27 + DB 20h + DB "Pattern is ", 0FDh, 'D', " bytes long", 0 +PatternLength DW 0 + +ENDIF + +C5FrequencyText DW 8 + DD DWord Ptr I_PrintC5Frequency + +AmpExtraKeyList Label + DB 1 + DW 2400h ; Alt-J + DD DWord Ptr F_Return1 + + DB 0 ; ESC + DW 101h + DD DWord Ptr F_Return0 + + DB 0 ; Enter + DW 11Ch + DD DWord Ptr F_Return1 + + DB 0FFh + +AmpBox DW 0 + DB 22, 25, 57, 35 + DB 3 + +SampleAmpBox DW 0 + DB 9, 25, 69, 35 + DB 3 + +AmpText DW 1 + DB 27, 27 + DB " Volume Amplification %", 0 + +SampleAmpText DW 1 + DB 27, 27 + DB " Sample Amplification %", 0 + +AmpTBBox DW 0 + DB 25, 29, 52, 31 + DB 25 + +FastAmpTBBox DW 0 + DB 32, 29, 44, 31 + DB 25 + +SampleAmpTBBox DW 0 + DB 12, 29, 64, 31 + DB 25 + +AmpTB DW 9 + DB 26, 30 + DW 0, 200 + DW 1, Offset Amplification + DW 4, 4, 4, 4 + DW 0FFFFh, 0FFFFh + +InstrumentAmpTB DW 9 + DB 26, 30 + DW 0, 200 + DW 8, Offset InstrumentAmplification + DW 4, 4, 4, 4 + DW 0FFFFh, 0FFFFh + +FastAmpTB DW 9 + DB 33, 30 + DW 10, 90 + DW 1, Offset FastVolumeAmplification + DW 4, 4, 4, 4 + DW 0FFFFh, 0FFFFh + +SampleAmpTB DW 9 + DB 13, 30 + DW 0, 400 + DW 8, Offset SampleAmplification + DW 4, 4, 4, 4 + DW 0FFFFh, 0FFFFh + + +ConfirmOKButton DW 2 + DW 3, 3, 5, 5 + DW 0 + DW 0, 0 + DW 0 + DW 1 ; Returns 1 + DW 0, 0, 0, 0 + DB 30, 32, 39, 34 + DB 8 + DB 0 + DB " OK", 0 + +ConfirmCancelButton DW 2 + DW 3, 3, 4, 4 + DW 0 + DW 0, 0 + DW 0 + DW 0 ; Returns 0 + DW 0, 0, 0, 0 + DB 40, 32, 49, 34 + DB 8 + DB 0 + DB " Cancel", 0 + +PatternTooLongText DW 1 + DB 28, 27 + DB 20h + DB "Pattern data exceeds 64k", 0 + +NBDText DW 1 + DB 30, 27 + DB 20h + DB "No data in clipboard", 0 + +OOSoundCardMemoryText DW 1 + DB 27, 27 + DB 20h + DB "Insufficient Soundcard RAM", 0 + +OOSText DW 1 + DB 31, 27 + DB 20h + DB "Too many samples!", 0 + + +OOMText DW 1 + DB 30, 27 + DB 20h + DB "Insufficient memory", 0 + +PSMText DW 1 + DB 27, 26 + DB 20h + DB " Crash Warning:", 13 + DB " Pattern Size Mismatch", 13 + DB "Fix: Remove corrupted data", 0 + +LongMsgText DW 1 + DB 29, 27 + DB 20h + DB "Song message too long!", 0 + +OLBText DW 1 + DB 30, 27 + DB 20h + DB "Swap blocks overlap", 0 + +SOORText DW 1 + DB 30, 27 + DB 20h + DB "Out of pattern range", 0 + +NBMBox DW 0 + DB 25, 25, 54, 32 + DB 3 + +NBMText DW 1 + DB 31, 27 + DB 20h + DB "No block is marked", 0 + +OKButton DW 2 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 0 + DW 0 ; Returns 0 + DW 0, 0, 0, 0 + DB 35, 29, 44, 31 + DB 8 + DB 0 + DB " OK", 0 + + +CrashRecoveryOKButton DW 2 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 0 + DW 0 ; Returns 0 + DW 0, 0, 0, 0 + DB 35, 27, 44, 29 + DB 8 + DB 0 + DB " OK", 0 + + +TemplateOKButton DW 2 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 0 + DW 0 ; Returns 0 + DW 0, 0, 0, 0 + DB 35, 31, 44, 33 + DB 8 + DB 0 + DB " OK", 0 + + +PECLinkButton DW 2 + DW 18, 13, 20, 20 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr PE_SetCommandCursor + DW 1 + DW 0 + DW 0 + DB 39, 37, 50, 39 + DB 8 + DB 0 + DB " Link", 0 + +PECSplitButton DW 2 + DW 18, 13, 19, 19 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr PE_SetCommandCursor + DW 0 + DW 0 + DW 0 + DB 51, 37, 63, 39 + DB 8 + DB 0 + DB " Split", 0 + + +PECBox1 DW 0 + DB 39, 22, 42, 24 + DB 9 + +PECBox2 DW 0 + DB 39, 25, 43, 27 + DB 9 + +PECBox3 DW 0 + DB 39, 28, 45, 30 + DB 9 + +PECBox4 DW 0 + DB 39, 31, 57, 33 + DB 9 + +PECBox5 DW 0 + DB 39, 34, 62, 36 + DB 9 + +PEConfigBox DW 0 + DB 10, 18, 69, 43 + DB 3 + +PEConfigText DW 1 + DB 28, 19 + DB 20h + DB "Pattern Editor Options", 0 + +PEConfigBsOctText DW 1 + DB 28, 23 + DB 20h + DB "Base octave", 0 + +PEConfigSkipValueText DW 1 + DB 28, 26 + DB 20h + DB "Cursor step", 0 + +PEConfigRHLMinorText DW 1 + DB 22, 29 + DB 20h + DB "Row hilight minor", 0 + +PEConfigRHLMajorText DW 1 + DB 22, 32 + DB 20h + DB "Row hilight major", 0 + +PEConfigMaxRowsText DW 1 + DB 14, 35 + DB 20h + DB "Number of rows in pattern", 0 + +PEConfigCommandCursor DW 1 + DB 18, 38 + DB 20h + DB "Command/Value columns", 0 + +PEConfigDoneButton DW 2 + DW 19, 14, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 0 + DW 0 ; Returns 0 + DW 0, 0, 0, 0 + DB 34, 40, 45, 42 + DB 8 + DB 0 + DB " Done", 0 + +PETBBaseOctave DW 9 + DB 40, 23 + DW 0, 8 + DW 1, Offset BaseOctave + DW 13, 15, 15, 13 + DW 0FFFFh, 0FFFFh + +PETBSkipValue DW 9 + DB 40, 26 + DW 0, 16 + DW 1, Offset SkipValue + DW 14, 16, 16, 14 + DW 0FFFFh, 0FFFFh + +PETBRHLMinor DW 9 + DB 40, 29 + DW 0, 32 + DW 1, Offset RowHiLight1 + DW 15, 17, 17, 15 + DW 0FFFFh, 0FFFFh + +PETBRHLMajor DW 9 + DB 40, 32 + DW 0, 128 + DW 1, Offset RowHiLight2 + DW 16, 18, 18, 16 + DW 0FFFFh, 0FFFFh + +PETBMaxRow DW 9 + DB 40, 35 + DW 32, 200 + DW 1, Offset NumberOfRows + DW 17, 19, 19, 17 + DW 0FFFFh, 0FFFFh + +PatternEdit DW 15 + DD DWord Ptr PE_DrawPatternEdit + DD DWord Ptr PE_PrePatternEdit + DD DWord Ptr PE_PostPatternEdit + +PatternEditMsg DW 10 + DB "Pattern Editor (F2)", 0 + +HelpKeyList DB 0 + DW 1C8h + DD DWord Ptr H_HelpUp + + DB 0 + DW 1D0h + DD DWord Ptr H_HelpDown + + DB 0 + DW 1C9h + DD DWord Ptr H_HelpPgUp + + DB 0 + DW 1D1h + DD DWord Ptr H_HelpPgDn + + DB 0 + DW 101h + DD DWord Ptr H_HelpESC + + DB 5 + DW Offset GlobalKeyChain + +ShowHelp DW 8 + DD DWord Ptr H_DrawHelp + +HelpBox DW 0 + DB 1, 12, 78, 45 + DW 27 + +HelpMsg DW 10 + DB "Help", 0 + +HelpDoneButton DW 2 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr H_HelpESC + DW 0, 0, 0 + DB 34, 46, 45, 48 + DB 8 + DB 0 + DB " Done", 0 + +SetHelpOrderPanning DW 11 + DW 0 + +OrderBox DW 0 + DB 5, 14, 9, 47 + DB 27 + +OrderList DW 12 + DB 2, 15 + DW 32 + DW 11, 43 + +ShowChannelMsgs DW 8 + DD DWord Ptr F_ShowChannels + +FillHeader DW 8 + DD DWord Ptr PE_FillHeader + +PanBox1 DW 0 + DB 30, 14, 40, 47 + DB 15 + +PanBox2 DW 0 + DB 64, 14, 74, 47 + DB 15 + +PanText1 DW 1 + DB 30, 14 + DB 23h + DB 146, 0FEh, 30h, "L M R", 0FEh, 23h, 145, 0 + +PanText2 DW 1 + DB 64, 14 + DB 23h + DB 146, 0FEh, 30h, "L M R", 0FEh, 23h, 145, 0 + +VolumeText1 DW 1 + DB 30, 14 + DB 23h + DB 146, 0FEh, 30h, " Volumes ", 0FEh, 23h, 145, 0 + +VolumeText2 DW 1 + DB 64, 14 + DB 23h + DB 146, 0FEh, 30h, " Volumes ", 0FEh, 23h, 145, 0 + + +Channel1 DW 9 ; Object 9 + DB 31, 15 ; x,y + DW 0, 64 ; Ranges + DW 0, 0 ; Pan/Channel 1 + DW 11, 12, 43, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 19 ; PgUp/PgDn + +Channel2 DW 9 + DB 31, 16 + DW 0, 64 + DW 0, 1 ; Pan/Channel 2 + DW 11, 13, 44, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 20 ; PgUp/PgDn + +Channel3 DW 9 ; Object 9 + DB 31, 17 ; x,y + DW 0, 64 ; Ranges + DW 0, 2 ; Pan/Channel 3 + DW 12, 14, 45, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 21 ; PgUp/PgDn + +Channel4 DW 9 + DB 31, 18 + DW 0, 64 + DW 0, 3 ; Pan/Channel 4 + DW 13, 15, 46, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 22 ; PgUp/PgDn + +Channel5 DW 9 ; Object 9 + DB 31, 19 ; x,y + DW 0, 64 ; Ranges + DW 0, 4 ; Pan/Channel 5 + DW 14, 16, 47, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 23 ; PgUp/PgDn + +Channel6 DW 9 + DB 31, 20 + DW 0, 64 + DW 0, 5 ; Pan/Channel 6 + DW 15, 17, 48, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 24 ; PgUp/PgDn + +Channel7 DW 9 ; Object 9 + DB 31, 21 ; x,y + DW 0, 64 ; Ranges + DW 0, 6 ; Pan/Channel 7 + DW 16, 18, 49, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 25 ; PgUp/PgDn + +Channel8 DW 9 + DB 31, 22 + DW 0, 64 + DW 0, 7 ; Pan/Channel 8 + DW 17, 19, 50, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 26 ; PgUp/PgDn + +Channel9 DW 9 ; Object 9 + DB 31, 23 ; x,y + DW 0, 64 ; Ranges + DW 0, 8 ; Pan/Channel 9 + DW 18, 20, 51, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 27 ; PgUp/PgDn + +Channel10 DW 9 + DB 31, 24 + DW 0, 64 + DW 0, 9 ; Pan/Channel 10 + DW 19, 21, 52, 10 ; Up/Down/Tab/Shift-Tab + DW 12, 28 ; PgUp/PgDn + +Channel11 DW 9 ; Object 9 + DB 31, 25 ; x,y + DW 0, 64 ; Ranges + DW 0, 10 ; Pan/Channel 11 + DW 20, 22, 53, 10 ; Up/Down/Tab/Shift-Tab + DW 13, 29 ; PgUp/PgDn + +Channel12 DW 9 + DB 31, 26 + DW 0, 64 + DW 0, 11 ; Pan/Channel 12 + DW 21, 23, 54, 10 ; Up/Down/Tab/Shift-Tab + DW 14, 30 ; PgUp/PgDn + +Channel13 DW 9 ; Object 9 + DB 31, 27 ; x,y + DW 0, 64 ; Ranges + DW 0, 12 ; Pan/Channel 13 + DW 22, 24, 55, 10 ; Up/Down/Tab/Shift-Tab + DW 15, 31 ; PgUp/PgDn + +Channel14 DW 9 + DB 31, 28 + DW 0, 64 + DW 0, 13 ; Pan/Channel 14 + DW 23, 25, 56, 10 ; Up/Down/Tab/Shift-Tab + DW 16, 32 ; PgUp/PgDn + +Channel15 DW 9 ; Object 9 + DB 31, 29 ; x,y + DW 0, 64 ; Ranges + DW 0, 14 ; Pan/Channel 15 + DW 24, 26, 57, 10 ; Up/Down/Tab/Shift-Tab + DW 17, 33 ; PgUp/PgDn + +Channel16 DW 9 + DB 31, 30 + DW 0, 64 + DW 0, 15 ; Pan/Channel 16 + DW 25, 27, 58, 10 ; Up/Down/Tab/Shift-Tab + DW 18, 34 ; PgUp/PgDn + +Channel17 DW 9 ; Object 9 + DB 31, 31 ; x,y + DW 0, 64 ; Ranges + DW 0, 16 ; Pan/Channel 17 + DW 26, 28, 59, 10 ; Up/Down/Tab/Shift-Tab + DW 19, 35 ; PgUp/PgDn + +Channel18 DW 9 + DB 31, 32 + DW 0, 64 + DW 0, 17 ; Pan/Channel 18 + DW 27, 29, 60, 10 ; Up/Down/Tab/Shift-Tab + DW 20, 36 ; PgUp/PgDn + +Channel19 DW 9 ; Object 9 + DB 31, 33 ; x,y + DW 0, 64 ; Ranges + DW 0, 18 ; Pan/Channel 19 + DW 28, 30, 61, 10 ; Up/Down/Tab/Shift-Tab + DW 21, 37 ; PgUp/PgDn + +Channel20 DW 9 + DB 31, 34 + DW 0, 64 + DW 0, 19 ; Pan/Channel 20 + DW 29, 31, 62, 10 ; Up/Down/Tab/Shift-Tab + DW 22, 38 ; PgUp/PgDn + +Channel21 DW 9 ; Object 9 + DB 31, 35 ; x,y + DW 0, 64 ; Ranges + DW 0, 20 ; Pan/Channel 21 + DW 30, 32, 63, 10 ; Up/Down/Tab/Shift-Tab + DW 23, 39 ; PgUp/PgDn + +Channel22 DW 9 + DB 31, 36 + DW 0, 64 + DW 0, 21 ; Pan/Channel 22 + DW 31, 33, 64, 10 ; Up/Down/Tab/Shift-Tab + DW 24, 40 ; PgUp/PgDn + +Channel23 DW 9 ; Object 9 + DB 31, 37 ; x,y + DW 0, 64 ; Ranges + DW 0, 22 ; Pan/Channel 23 + DW 32, 34, 65, 10 ; Up/Down/Tab/Shift-Tab + DW 25, 41 ; PgUp/PgDn + +Channel24 DW 9 + DB 31, 38 + DW 0, 64 + DW 0, 23 ; Pan/Channel 24 + DW 33, 35, 66, 10 ; Up/Down/Tab/Shift-Tab + DW 26, 42 ; PgUp/PgDn + +Channel25 DW 9 ; Object 9 + DB 31, 39 ; x,y + DW 0, 64 ; Ranges + DW 0, 24 ; Pan/Channel 25 + DW 34, 36, 67, 10 ; Up/Down/Tab/Shift-Tab + DW 27, 43 ; PgUp/PgDn + +Channel26 DW 9 + DB 31, 40 + DW 0, 64 + DW 0, 25 ; Pan/Channel 26 + DW 35, 37, 68, 10 ; Up/Down/Tab/Shift-Tab + DW 28, 44 ; PgUp/PgDn + +Channel27 DW 9 ; Object 9 + DB 31, 41 ; x,y + DW 0, 64 ; Ranges + DW 0, 26 ; Pan/Channel 27 + DW 36, 38, 69, 10 ; Up/Down/Tab/Shift-Tab + DW 29, 45 ; PgUp/PgDn + +Channel28 DW 9 + DB 31, 42 + DW 0, 64 + DW 0, 27 ; Pan/Channel 28 + DW 37, 39, 70, 10 ; Up/Down/Tab/Shift-Tab + DW 30, 46 ; PgUp/PgDn + +Channel29 DW 9 ; Object 9 + DB 31, 43 ; x,y + DW 0, 64 ; Ranges + DW 0, 28 ; Pan/Channel 29 + DW 38, 40, 71, 10 ; Up/Down/Tab/Shift-Tab + DW 31, 47 ; PgUp/PgDn + +Channel30 DW 9 + DB 31, 44 + DW 0, 64 + DW 0, 29 ; Pan/Channel 30 + DW 39, 41, 72, 10 ; Up/Down/Tab/Shift-Tab + DW 32, 48 ; PgUp/PgDn + +Channel31 DW 9 ; Object 9 + DB 31, 45 ; x,y + DW 0, 64 ; Ranges + DW 0, 30 ; Pan/Channel 31 + DW 40, 42, 73, 10 ; Up/Down/Tab/Shift-Tab + DW 33, 49 ; PgUp/PgDn + +Channel32 DW 9 + DB 31, 46 + DW 0, 64 + DW 0, 31 ; Pan/Channel 32 + DW 41, 43, 74, 10 ; Up/Down/Tab/Shift-Tab + DW 34, 50 ; PgUp/PgDn + +Channel33 DW 9 ; Object 9 + DB 65, 15 ; x,y + DW 0, 64 ; Ranges + DW 0, 32 ; Pan/Channel 33 + DW 42, 44, 10, 11 ; Up/Down/Tab/Shift-Tab + DW 35, 51 ; PgUp/PgDn + +Channel34 DW 9 + DB 65, 16 + DW 0, 64 + DW 0, 33 ; Pan/Channel 34 + DW 43, 45, 10, 12 ; Up/Down/Tab/Shift-Tab + DW 36, 52 ; PgUp/PgDn + +Channel35 DW 9 ; Object 9 + DB 65, 17 ; x,y + DW 0, 64 ; Ranges + DW 0, 34 ; Pan/Channel 35 + DW 44, 46, 10, 13 ; Up/Down/Tab/Shift-Tab + DW 37, 53 ; PgUp/PgDn + +Channel36 DW 9 + DB 65, 18 + DW 0, 64 + DW 0, 35 ; Pan/Channel 36 + DW 45, 47, 10, 14 ; Up/Down/Tab/Shift-Tab + DW 38, 54 ; PgUp/PgDn + +Channel37 DW 9 ; Object 9 + DB 65, 19 ; x,y + DW 0, 64 ; Ranges + DW 0, 36 ; Pan/Channel 37 + DW 46, 48, 10, 15 ; Up/Down/Tab/Shift-Tab + DW 39, 55 ; PgUp/PgDn + +Channel38 DW 9 + DB 65, 20 + DW 0, 64 + DW 0, 37 ; Pan/Channel 38 + DW 47, 49, 10, 16 ; Up/Down/Tab/Shift-Tab + DW 40, 56 ; PgUp/PgDn + +Channel39 DW 9 ; Object 9 + DB 65, 21 ; x,y + DW 0, 64 ; Ranges + DW 0, 38 ; Pan/Channel 39 + DW 48, 50, 10, 17 ; Up/Down/Tab/Shift-Tab + DW 41, 57 ; PgUp/PgDn + +Channel40 DW 9 + DB 65, 22 + DW 0, 64 + DW 0, 39 ; Pan/Channel 40 + DW 49, 51, 10, 18 ; Up/Down/Tab/Shift-Tab + DW 42, 58 ; PgUp/PgDn + +Channel41 DW 9 ; Object 9 + DB 65, 23 ; x,y + DW 0, 64 ; Ranges + DW 0, 40 ; Pan/Channel 41 + DW 50, 52, 10, 19 ; Up/Down/Tab/Shift-Tab + DW 43, 59 ; PgUp/PgDn + +Channel42 DW 9 + DB 65, 24 + DW 0, 64 + DW 0, 41 ; Pan/Channel 42 + DW 51, 53, 10, 20 ; Up/Down/Tab/Shift-Tab + DW 44, 60 ; PgUp/PgDn + +Channel43 DW 9 ; Object 9 + DB 65, 25 ; x,y + DW 0, 64 ; Ranges + DW 0, 42 ; Pan/Channel 43 + DW 52, 54, 10, 21 ; Up/Down/Tab/Shift-Tab + DW 45, 61 ; PgUp/PgDn + +Channel44 DW 9 + DB 65, 26 + DW 0, 64 + DW 0, 43 ; Pan/Channel 44 + DW 53, 55, 10, 22 ; Up/Down/Tab/Shift-Tab + DW 46, 62 ; PgUp/PgDn + +Channel45 DW 9 ; Object 9 + DB 65, 27 ; x,y + DW 0, 64 ; Ranges + DW 0, 44 ; Pan/Channel 45 + DW 54, 56, 10, 23 ; Up/Down/Tab/Shift-Tab + DW 47, 63 ; PgUp/PgDn + +Channel46 DW 9 + DB 65, 28 + DW 0, 64 + DW 0, 45 ; Pan/Channel 46 + DW 55, 57, 10, 24 ; Up/Down/Tab/Shift-Tab + DW 48, 64 ; PgUp/PgDn + +Channel47 DW 9 ; Object 9 + DB 65, 29 ; x,y + DW 0, 64 ; Ranges + DW 0, 46 ; Pan/Channel 47 + DW 56, 58, 10, 25 ; Up/Down/Tab/Shift-Tab + DW 49, 65 ; PgUp/PgDn + +Channel48 DW 9 + DB 65, 30 + DW 0, 64 + DW 0, 47 ; Pan/Channel 48 + DW 57, 59, 10, 26 ; Up/Down/Tab/Shift-Tab + DW 50, 66 ; PgUp/PgDn + +Channel49 DW 9 ; Object 9 + DB 65, 31 ; x,y + DW 0, 64 ; Ranges + DW 0, 48 ; Pan/Channel 49 + DW 58, 60, 10, 27 ; Up/Down/Tab/Shift-Tab + DW 51, 67 ; PgUp/PgDn + +Channel50 DW 9 + DB 65, 32 + DW 0, 64 + DW 0, 49 ; Pan/Channel 50 + DW 59, 61, 10, 28 ; Up/Down/Tab/Shift-Tab + DW 52, 68 ; PgUp/PgDn + +Channel51 DW 9 ; Object 9 + DB 65, 33 ; x,y + DW 0, 64 ; Ranges + DW 0, 50 ; Pan/Channel 51 + DW 60, 62, 10, 29 ; Up/Down/Tab/Shift-Tab + DW 53, 69 ; PgUp/PgDn + +Channel52 DW 9 + DB 65, 34 + DW 0, 64 + DW 0, 51 ; Pan/Channel 52 + DW 61, 63, 10, 30 ; Up/Down/Tab/Shift-Tab + DW 54, 70 ; PgUp/PgDn + +Channel53 DW 9 ; Object 9 + DB 65, 35 ; x,y + DW 0, 64 ; Ranges + DW 0, 52 ; Pan/Channel 53 + DW 62, 64, 10, 31 ; Up/Down/Tab/Shift-Tab + DW 55, 71 ; PgUp/PgDn + +Channel54 DW 9 + DB 65, 36 + DW 0, 64 + DW 0, 53 ; Pan/Channel 54 + DW 63, 65, 10, 32 ; Up/Down/Tab/Shift-Tab + DW 56, 72 ; PgUp/PgDn + +Channel55 DW 9 ; Object 9 + DB 65, 37 ; x,y + DW 0, 64 ; Ranges + DW 0, 54 ; Pan/Channel 55 + DW 64, 66, 10, 33 ; Up/Down/Tab/Shift-Tab + DW 57, 73 ; PgUp/PgDn + +Channel56 DW 9 + DB 65, 38 + DW 0, 64 + DW 0, 55 ; Pan/Channel 56 + DW 65, 67, 10, 34 ; Up/Down/Tab/Shift-Tab + DW 58, 74 ; PgUp/PgDn + +Channel57 DW 9 ; Object 9 + DB 65, 39 ; x,y + DW 0, 64 ; Ranges + DW 0, 56 ; Pan/Channel 57 + DW 66, 68, 10, 35 ; Up/Down/Tab/Shift-Tab + DW 59, 74 ; PgUp/PgDn + +Channel58 DW 9 + DB 65, 40 + DW 0, 64 + DW 0, 57 ; Pan/Channel 58 + DW 67, 69, 10, 36 ; Up/Down/Tab/Shift-Tab + DW 60, 74 ; PgUp/PgDn + +Channel59 DW 9 ; Object 9 + DB 65, 41 ; x,y + DW 0, 64 ; Ranges + DW 0, 58 ; Pan/Channel 59 + DW 68, 70, 10, 37 ; Up/Down/Tab/Shift-Tab + DW 61, 74 ; PgUp/PgDn + +Channel60 DW 9 + DB 65, 42 + DW 0, 64 + DW 0, 59 ; Pan/Channel 60 + DW 69, 71, 10, 38 ; Up/Down/Tab/Shift-Tab + DW 62, 74 ; PgUp/PgDn + +Channel61 DW 9 ; Object 9 + DB 65, 43 ; x,y + DW 0, 64 ; Ranges + DW 0, 60 ; Pan/Channel 61 + DW 70, 72, 10, 39 ; Up/Down/Tab/Shift-Tab + DW 63, 74 ; PgUp/PgDn + +Channel62 DW 9 + DB 65, 44 + DW 0, 64 + DW 0, 61 ; Pan/Channel 62 + DW 71, 73, 10, 40 ; Up/Down/Tab/Shift-Tab + DW 64, 74 ; PgUp/PgDn + +Channel63 DW 9 ; Object 9 + DB 65, 45 ; x,y + DW 0, 64 ; Ranges + DW 0, 62 ; Pan/Channel 63 + DW 72, 74, 10, 41 ; Up/Down/Tab/Shift-Tab + DW 65, 74 ; PgUp/PgDn + +Channel64 DW 9 + DB 65, 46 + DW 0, 64 + DW 0, 63 ; Pan/Channel 64 + DW 73, 74, 10, 42 ; Up/Down/Tab/Shift-Tab + DW 66, 74 ; PgUp/PgDn + +OrderAndPanningMsg DW 10 + DB "Order List and Panning (F11)", 0 + +OrderAndVolumeMsg DW 10 + DB "Order List and Channel Volume (F11)", 0 + +FullScreenBox DW 0 + DB 0, 0, 79, 49 + DB 4 + +ScreenHeader DW 8 + DD DWord Ptr F_DrawHeader + +CallAutoDetect DW 8 + DD DWord Ptr Music_ShowAutoDetectSoundCard + +AutoMiniBox DW 0 + DB 25, 25, 55, 30 + DB 0 + +AutoDetectText DW 1 + DB 32, 26 + DB 20h + DB "Sound Card Setup", 0 + +LoadSampleKeyList DB 0 + DW 101h ; ESC + DD DWord Ptr Glbl_F3 + +ViewSampleKeyList Label + DB 0 + DW 1C9h ; PgUp + DD DWord Ptr LSWindow_Up + + DB 0 + DW 1D1h ; PgDn + DD DWord Ptr LSWindow_Down + + DB 1 ; Alt + DW 1F00h ; 'S' + DD DWord Ptr D_SlowSampleSort + + DB 5 ; Chain to... + DW Offset GlobalKeyList + + +LoadInstrumentKeyList DB 0 + DW 101h ; ESC + DD DWord Ptr Glbl_F4 + + DB 1 ; Alt + DW 1F00h ; 'S' + DD DWord Ptr D_SlowInstrumentSort + + DB 5 + DW Offset GlobalKeyList + +GlobalKeyList DB 0 ; F1 +HelpKeyValue DW 13Bh + DD DWord Ptr H_Help + +GlobalKeyChain: + DB 3 ; Ctrl... + DW 13Bh ; F1 + DD DWord Ptr Glbl_Ctrl_F1 + + DB 0 ; F2 + DW 13Ch + DD DWord Ptr Glbl_F2 + + DB 0 ; F3 + DW 13Dh + DD DWord Ptr Glbl_F3 + + DB 3 ; Ctrl... + DW 13Dh ; F3 + DD DWord Ptr Glbl_Ctrl_F3 + + DB 0 ; F4 + DW 13Eh + DD DWord Ptr Glbl_F4 + + DB 3 ; Ctrl... + DW 13Eh ; F4 + DD DWord Ptr Glbl_Ctrl_F4 + + DB 0 ; F5 + DW 13Fh + DD DWord Ptr Glbl_F5 + + DB 1 + DW 12h ; Ctrl 'R' + DD DWord Ptr Glbl_F9 + + DB 1 + DW 0Ch ; Ctrl 'L' + DD DWord Ptr Glbl_F9 + + DB 0 ; F9 + DW 142h + DD DWord Ptr Glbl_F8 + + DB 0 ; F9 + DW 143h + DD DWord Ptr Glbl_F9 + + DB 6 ; F9 + DW 143h + DD DWord Ptr Glbl_Shift_F9 + + DB 1 + DW 17h ; Ctrl 'W' + DD DWord Ptr Glbl_F10 + + DB 0 ; F10 + DW 144h + DD DWord Ptr Glbl_F10 + + DB 0 ; F11 +OrderKeyValue DW 157h + DD DWord Ptr Glbl_F11 + + DB 0 ; F12 + DW 158h + DD DWord Ptr Glbl_F12 + + DB 3 ; Ctrl.. + DW 158h ; F1 + DD DWord Ptr Glbl_Ctrl_F12 + + DB 0 ; ESC + DW 101h + DD DWord Ptr F_MainMenu + + DB 1 + DW 04h ; Ctrl 'D' + DD DWord Ptr DOSShell + + DB 1 + DW 05h ; Ctrl 'E' + DD DWord Ptr Refresh + + DB 1 + DW 13h ; Ctrl 'S' + DD DWord Ptr D_SaveSong + + DB 1 + DW 11h ; Ctrl 'Q' + DD DWord Ptr Quit + + DB 1 + DW 0Dh ; Ctrl 'M' + DD DWord Ptr MouseToggle + + DB 1 + DW 0Eh ; Ctrl 'N' + DD DWord Ptr F_NewSong + + DB 1 + DW 7h ; Ctrl 'G' + DD DWord Ptr Music_SoundCardLoadAllSamples + + DB 1 + DW 9 ; Ctrl 'I' + DD DWord Ptr Music_ReinitSoundCard + + DB 1 + DW 16 ; Ctrl 'P' + DD DWord Ptr Music_TimeSong + +IF MEMORYDEBUG + DB 0 + DW 15B7h ; Right shift+Ctrl+Printscreen + DD DWord Ptr Glbl_Debug +ENDIF + + DB 2 ; Alt.. + DW 13Bh ; F1 + DD DWord Ptr Glbl_Alt_F1 + + DB 2 ; Alt.. + DW 13Ch ; F2 + DD DWord Ptr Glbl_Alt_F2 + + DB 2 ; Alt.. + DW 13Dh ; F3 + DD DWord Ptr Glbl_Alt_F3 + + DB 2 ; Alt.. + DW 13Eh ; F4 + DD DWord Ptr Glbl_Alt_F4 + + DB 2 ; Alt.. + DW 13Fh ; F5 + DD DWord Ptr Glbl_Alt_F5 + + DB 2 ; Alt.. + DW 140h ; F6 + DD DWord Ptr Glbl_Alt_F6 + + DB 2 ; Alt.. + DW 141h ; F7 + DD DWord Ptr Glbl_Alt_F7 + + DB 2 ; Alt.. + DW 142h ; F8 + DD DWord Ptr Glbl_Alt_F8 + + DB 2 ; Alt.. + DW 157h ; F11 + DD DWord Ptr Music_ToggleOrderUpdate + +IF NETWORKENABLED + DB 6 ; Shift + DW 101h ; ESC + DD DWord Ptr Network_DriverScreen +ENDIF + + DB 6 ; Shift F1 + DW 13Bh + DD DWord Ptr Glbl_Shift_F1 + + DB 6 ; Shift F5 + DW 13Fh + DD DWord Ptr Glbl_DriverScreen + +IF TIMERSCREEN + DB 0 ; Left shift, left+right alt + DW 73C6h ; Right ctrl + Pause + DD DWord Ptr Glbl_TimerScreen +ENDIF + +IF EMSDEBUG + DB 0 ; Left shift, Left alt, right alt + DW 6329h ; + ~ + DD DWord Ptr E_DumpEMSMemory +ENDIF + +PlayCommandChain: + DB 3 ; Ctrl... + DW 13Fh ; F5 + DD DWord Ptr Glbl_Ctrl_F5 + + DB 0 ; F6 + DW 140h + DD DWord Ptr Glbl_F6 + + DB 6 ; F6 + DW 140h + DD DWord Ptr Glbl_Shift_F6 + + DB 0 + DW 141h ; F7 + DD DWord Ptr PE_F7 + + DB 3 ; Ctrl + DW 1CBh ; Left + DD DWord Ptr DisplayMinus + + DB 3 ; Ctrl + DW 1CDh ; Right + DD DWord Ptr DisplayPlus + + DB 0 + DW 1B5h + DD DWord Ptr PEFunction_DecreaseOctave + + DB 0 + DW 137h + DD DWord Ptr PEFunction_IncreaseOctave + + DB 6 + DW 1B5h + DD DWord Ptr PEFunction_DecreaseOctave + + DB 6 + DW 137h + DD DWord Ptr PEFunction_IncreaseOctave + + DB 1 + DW '{' + DD DWord Ptr Glbl_LeftBrace + + DB 1 + DW '}' + DD DWord Ptr Glbl_RightBrace + + DB 1 + DW '[' + DD DWord Ptr Glbl_LeftSquareBracket + + DB 1 + DW ']' + DD DWord Ptr Glbl_RightSquareBracket + +ChainMIDICommands: + DB 9 ; MIDI Message + DW 08000h + DD DWord Ptr MIDI_NoteOff + + DB 9 ; MIDI Message + DW 09000h + DD DWord Ptr MIDI_PlayNote + + DB 9 ; MIDI Message + DW 0C000h + DD DWord Ptr MIDI_SetInstrument + + DB 0FFh ; End of list + +ESCExitList DB 0 ; ESC + DW 101h + DD DWord Ptr F_Return0 + + DB 5 + DW Near Ptr ChainMIDICommands + +SampleGlobalKeyList Label +IF ENABLESOLO + DB 1 + DW '`' + DD DWord Ptr Music_ToggleSoloSample +ENDIF + + DB 0 + DW 1C9h + DD DWord Ptr I_SampleUp + + DB 0 + DW 1D1h + DD DWord Ptr I_SampleDown + + DB 1 + DW '<' + DD DWord Ptr I_DecreasePlayChannel + + DB 1 + DW '>' + DD DWord Ptr I_IncreasePlayChannel + + DB 1 + DW ',' + DD DWord Ptr I_DecreasePlayChannel + + DB 1 + DW '.' + DD DWord Ptr I_IncreasePlayChannel + + DB 1 + DW 1E00h ; Alt 'A' + DD DWord Ptr I_ConvertSample + + DB 1 + DW 3000h ; Alt 'B' + DD DWord Ptr I_CutSampleBeforeLoop + + DB 1 + DW 2000h ; Alt 'D' + DD DWord Ptr I_DeleteSample + + DB 1 + DW 1200h ; Alt 'E' + DD DWord Ptr I_ResizeSample + + DB 1 + DW 2100h ; Alt 'F' + DD DWord Ptr I_ResizeSampleNoInt + + DB 1 + DW 2200h ; Alt 'G' + DD DWord Ptr I_ReverseSample + + DB 1 + DW 2300h ; Alt 'H' + DD DWord Ptr I_CenterSample + + DB 1 + DW 1700h ; Alt 'I' + DD DWord Ptr I_InvertSample + + DB 1 ; Alt 'J' + DW 2400h + DD DWord Ptr I_ScaleSampleVolumes + + DB 1 + DW 2600h ; Alt 'L' + DD DWord Ptr I_CutSample + + DB 1 + DW 3200h ; Alt 'M' + DD DWord Ptr I_AmplifySample + + DB 1 + DW 3100h ; Alt 'N' + DD DWord Ptr I_ToggleMultiChannel + + DB 1 + DW 1800h ; Alt 'O' + DD DWord Ptr D_SaveSample + + DB 1 + DW 1000h ; Alt 'Q' + DD DWord Ptr I_ToggleSampleQuality + + DB 1 + DW 1300h ; Alt 'R' + DD DWord Ptr I_ReplaceSample + + DB 1 + DW 1F00h ; Alt 'S' + DD DWord Ptr I_SwapSamples + + DB 1 + DW 1400h ; Alt 'T' + DD DWord Ptr D_SaveST3Sample + + DB 1 + DW 1100h ; Alt 'W' + DD DWord Ptr D_SaveRawSample + + DB 1 + DW 2D00h ; Alt 'X' + DD DWord Ptr I_ExchangeSamples + + DB 1 ; Alt 'Y' + DW 1500h + DD DWord Ptr I_CalculateC5Speed + + + DB 2 ; Alt... + DW 14Eh ; Grey plus + DD DWord Ptr I_DoubleSampleSpeed + + DB 2 ; Alt... + DW 14Ah ; Grey minus + DD DWord Ptr I_HalveSampleSpeed + + DB 3 + DW 14Eh + DD DWord Ptr I_SampleSpeedSemiUp + + DB 3 + DW 14Ah + DD DWord Ptr I_SampleSpeedSemiDown + + DB 9 + DW 9000h + DD DWord Ptr MIDI_PlaySample + + DB 0 ; Enter... to load sample! + DW 11Ch + DD DWord Ptr Glbl_LoadSample + + DB 5 + DW Offset GlobalKeyList + +ScreenBox DW 0 ; Object type 0 + DB 0, 0, 79, 49 ; Coordinates + DB 7 ; Box style + +AboutBox DW 0 ; Object type 0 + DB 11, 16, 68, 34 ; Coordinates + DB 0 ; Box style + +AboutText DW 1 ; Object type 1 + DB 24, 19 + DB 02Bh + DB 0FFh, 1, 0, 4, 8, 0FFh, 8, 55, 37, 41, 0FFh, 5, 55, 56, 58, 62, 66, 0FFh, 6, 55, 88, 92, 13 + DB 1, 5, 9, 12, 15, 18, 22, 25, 28, 31, 34, 38, 42, 45, 48, 51, 55, 55, 57, 59, 63, 67, 70, 73, 76, 79, 82, 85, 89, 93, 96, 99, 102, 105, 13 + DB 2, 6, 0FFh, 1, 10, 0FFh, 1, 13, 16, 19, 23, 26, 29, 32, 35, 39, 43, 46, 49, 52, 54, 55, 55, 60, 64, 68, 71, 74, 77, 80, 83, 86, 90, 94, 97, 100, 103, 106, 13 + DB 3, 7, 11, 14, 17, 20, 24, 27, 30, 33, 36, 40, 44, 47, 50, 53, 55, 55, 55, 61, 65, 69, 72, 75, 78, 81, 84, 87, 91, 95, 98, 101, 104, 107, 13 + DB 0FFh, 5, 55, 21, 0 +; DB 0FEh, 20h +; DB " http://www.citenet.net/noise/it", 0 + +AutoContinueButton DW 2 ; Object type 2 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 ; Button usage type + DW 0, 0 ; ???? + DW 4 ; New List + DD DWord Ptr Glbl_F9 + DW 0, 0, 0 ; ???? + DB 32, 31, 47, 33 ; Left/Top/Right/Bottom + DB 8 ; Box initial style + DB 0 ; Button Up + DB " Continue", 0 + +UpdateScreen DW 8 + DD DWord Ptr S_UpdateScreen + +Exit DW 4 ; Object type 4 + DW 0 ; Return value + +DirectScreen DW 5 ; Object type 5 + DB 1 + +InDirectScreen DW 5 ; Object type 5 + DB 0 + +ImpulseLogo DW 6 ; Object type 6 +LogoCharacter DW 256 ; First char to define + DW 108 + DB 0, 0, 0, 0, 1, 7, 15, 31 ; 0 + DB 63, 127, 127, 254, 252, 255, 255, 126 ; 1 + DB 24, 0, 0, 0, 0, 0, 0, 0 ; 2 + DB 0, 1, 3, 3, 3, 1, 0, 0 ; 3 + DB 7, 31, 63, 255, 255, 254, 248, 240 ; 4 + DB 192, 128, 0, 1, 1, 131, 3, 7 ; 5 + DB 7, 15, 14, 30, 60, 60, 120, 240 ; 6 + DB 240, 224, 224, 224, 224, 192, 0, 0 ; 7 + DB 240, 240, 248, 248, 248, 120, 56, 120 ; 8 + DB 112, 240, 240, 224, 224, 192, 192, 131 ; 9 + DB 7, 15, 31, 31, 62, 60, 61, 63 ; 10 + DB 63, 63, 62, 28, 8, 0, 0, 0 ; 11 + DB 0, 0, 0, 0, 0, 0, 193, 227 ; 12 + DB 199, 223, 191, 127, 247, 239, 207, 159 ; 13 + DB 31, 31, 63, 60, 24, 0, 0, 0 ; 14 + DB 0, 0, 0, 0, 0, 240, 240, 240 ; 15 + DB 241, 227, 239, 223, 191, 251, 247, 231 ; 16 + DB 159, 159, 31, 31, 14, 0, 0, 0 ; 17 + DB 0, 0, 0, 0, 0, 48, 112, 248 ; 18 + DB 248, 240, 224, 192, 193, 131, 7, 30 ; 19 + DB 252, 240, 225, 131, 3, 7, 7, 15 ; 20 + DB 15, 30, 30, 28, 8, 0, 0, 0 ; 21 + DB 0, 0, 0, 1, 3, 3, 7, 15 ; 22 + DB 31, 63, 127, 255, 191, 190, 124, 126 ; 23 + DB 255, 255, 255, 255, 199, 128, 128, 0 ; 24 + DB 60, 124, 248, 240, 224, 192, 135, 159 ; 25 + DB 127, 255, 223, 143, 30, 60, 56, 113 ; 26 + DB 255, 255, 252, 240, 192, 0, 0, 0 ; 27 + DB 0, 0, 0, 0, 0, 0, 128, 129 ; 28 + DB 131, 135, 15, 15, 30, 60, 124, 253 ; 29 + DB 191, 31, 31, 14, 0, 0, 0, 0 ; 30 + DB 0, 0, 0, 0, 0, 112, 248, 240 ; 31 + DB 225, 195, 135, 15, 31, 63, 127, 255 ; 32 + DB 239, 223, 159, 15, 14, 0, 0, 0 ; 33 + DB 0, 0, 0, 0, 24, 56, 124, 248 ; 34 + DB 248, 241, 225, 193, 129, 131, 15, 31 ; 35 + DB 249, 241, 225, 192, 0, 0, 0, 0 ; 36 + DB 0, 0, 0, 0, 0, 0, 1, 3 ; 37 + DB 7, 15, 30, 61, 57, 123, 119, 254 ; 38 + DB 252, 248, 240, 224, 192, 192, 192, 225 ; 39 + DB 247, 255, 254, 252, 0, 0, 0, 0 ; 40 + DB 0, 0, 24, 56, 120, 248, 248, 240 ; 41 + DB 112, 96, 224, 192, 192, 128, 0, 1 ; 42 + DB 3, 7, 14, 28, 56, 112, 248, 252 ; 43 + DB 255, 127, 63, 31, 7, 0, 0, 0 ; 44 + DB 0, 0, 0, 48, 120, 120, 248, 248 ; 45 + DB 252, 124, 124, 120, 120, 112, 241, 231 ; 46 + DB 142, 252, 248, 224, 128, 0, 0, 0 ; 47 + DB 0, 0, 0, 0, 0, 0, 3, 7 ; 48 + DB 15, 30, 60, 63, 127, 254, 252, 60 ; 49 + DB 126, 63, 63, 31, 6, 0, 0, 0 ; 50 + DB 0, 0, 0, 0, 60, 254, 254, 222 ; 51 + DB 30, 60, 248, 224, 128, 1, 7, 14 ; 52 + DB 124, 248, 224, 192, 0, 0, 0, 0 ; 53 + DB 0, 0, 0, 0, 128, 128, 0, 0 ; 54 + DB 0, 0, 0, 0, 0, 0, 0, 0 ; 55 + DB 0, 0, 7, 31, 63, 127, 127, 255 ; 56 + DB 255, 252, 127, 0, 0, 0, 0, 0 ; 57 + DB 3, 255, 255, 255, 255, 255, 255, 252 ; 58 + DB 128, 0, 0, 0, 0, 0, 0, 0 ; 59 + DB 0, 0, 0, 1, 1, 3, 3, 7 ; 60 + DB 7, 15, 31, 31, 31, 30, 0, 0 ; 61 + DB 255, 255, 255, 255, 255, 255, 255, 0 ; 62 + DB 0, 1, 3, 7, 7, 15, 31, 62 ; 63 + DB 60, 124, 248, 248, 240, 240, 224, 224 ; 64 + DB 192, 192, 128, 128, 0, 0, 0, 0 ; 65 + DB 128, 224, 240, 240, 248, 248, 248, 112 ; 66 + DB 240, 224, 192, 192, 128, 6, 15, 31 ; 67 + DB 63, 127, 127, 112, 33, 97, 195, 131 ; 68 + DB 7, 7, 7, 3, 1, 0, 0, 0 ; 69 + DB 0, 0, 0, 0, 0, 0, 252, 254 ; 70 + DB 254, 252, 248, 240, 224, 193, 195, 199 ; 71 + DB 223, 253, 240, 224, 128, 0, 0, 0 ; 72 + DB 0, 0, 0, 0, 0, 0, 0, 3 ; 73 + DB 15, 31, 63, 124, 248, 240, 225, 195 ; 74 + DB 199, 254, 252, 120, 48, 0, 0, 0 ; 75 + DB 0, 0, 0, 0, 0, 31, 255, 255 ; 76 + DB 255, 255, 191, 63, 126, 252, 248, 184 ; 77 + DB 63, 127, 127, 126, 124, 48, 0, 0 ; 78 + DB 0, 0, 0, 0, 0, 0, 128, 128 ; 79 + DB 129, 3, 7, 15, 15, 31, 62, 126 ; 80 + DB 239, 207, 143, 7, 3, 0, 0, 0 ; 81 + DB 0, 0, 0, 0, 0, 15, 63, 255 ; 82 + DB 255, 255, 238, 204, 0, 0, 0, 3 ; 83 + DB 15, 255, 254, 248, 224, 0, 0, 0 ; 84 + DB 0, 0, 0, 0, 0, 193, 195, 131 ; 85 + DB 135, 15, 15, 31, 63, 127, 255, 255 ; 86 + DB 190, 60, 28, 24, 0, 0, 0, 0 ; 87 + DB 0, 0, 0, 0, 0, 1, 3, 7 ; 88 + DB 15, 31, 63, 126, 252, 248, 240, 227 ; 89 + DB 199, 223, 188, 112, 225, 199, 254, 252 ; 90 + DB 252, 126, 127, 63, 31, 0, 0, 0 ; 91 + DB 0, 12, 60, 124, 248, 248, 240, 224 ; 92 + DB 192, 128, 0, 0, 0, 48, 248, 248 ; 93 + DB 248, 120, 241, 225, 195, 3, 15, 31 ; 94 + DB 59, 243, 227, 129, 0, 0, 0, 0 ; 95 + DB 0, 0, 0, 0, 1, 15, 31, 62 ; 96 + DB 120, 241, 231, 239, 252, 240, 192, 192 ; 97 + DB 227, 255, 255, 252, 112, 0, 0, 0 ; 98 + DB 0, 0, 0, 0, 192, 240, 241, 243 ; 99 + DB 231, 207, 143, 14, 12, 28, 56, 112 ; 100 + DB 225, 193, 1, 0, 0, 0, 0, 0 ; 101 + DB 0, 0, 0, 0, 0, 192, 255, 255 ; 102 + DB 255, 255, 254, 60, 120, 112, 240, 241 ; 103 + DB 247, 255, 252, 248, 96, 0, 0, 0 ; 104 + DB 0, 0, 0, 0, 0, 0, 0, 128 ; 105 + DB 128, 0, 0, 0, 0, 0, 0, 192 ; 106 + DB 192, 0, 0, 0, 0, 0, 0, 0 ; 107 + +O1_ConfirmConvertList DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmConvertSampleText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmConvert2List DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmConvertSampleText + DW Near Ptr ConfirmConvertYesButton + DW Near Ptr ConfirmConvertNoButton + DW 0 + +O1_SampleCenterList DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmCenterSampleText + DW Near Ptr ConfirmConvertYesButton + DW Near Ptr ConfirmConvertNoButton + DW 0 + +O1_EnableInstrumentMode DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr EnableInstrumentModeText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + + +O1_InitInstrument DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr InitInstrumentText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmInitialiseNoButton + DW 0 + +O1_ConfirmOverWriteList DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmOverWriteText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_InitialiseInstrumentList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmInitialiseText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmInitialiseNoButton + DW 0 + +O1_ConfirmDelete DW 4 + DW Near Ptr SongNameModuleLoader + DW Near Ptr OKCancelList + DW Near Ptr DrawFileNameWindow + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmDeleteText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmDelete2 DW 4 + DW Near Ptr SampleNameLoader + DW Near Ptr OKCancelList + DW Near Ptr DrawLoadSampleWindow + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmDeleteText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmDelete3 DW 4 + DW Near Ptr InstrumentNameLoader + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmDeleteText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + + +O1_ConfirmSaveRenameList DW 3 + DW Near Ptr SampleNameLoader + DW Near Ptr OKCancelList + DW Near Ptr DrawLoadSampleWindow + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmSaveRenameText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmResaveList DW 3 + DW Near Ptr SampleNameLoader + DW Near Ptr OKCancelList + DW Near Ptr DrawLoadSampleWindow + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmResaveText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmDiscardList DW 3 + DW Near Ptr SampleNameLoader + DW Near Ptr OKCancelList + DW Near Ptr DrawLoadSampleWindow + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmDiscardText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmCutSample DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmCutSampleText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmDeleteSample DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmDeleteSampleText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmDeleteInstrument DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmDeleteInstrumentText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmClearMessage DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmClearMessageText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_ConfirmNoSave DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmNoSaveBox + DW Near Ptr ConfirmNoSaveMessage + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +EmptyObject DW 8 + DD DWord Ptr F_Nothing + +DrawFileNameWindow DW 8 + DD DWord Ptr D_DrawFileWindow + +DrawLoadSampleWindow DW 8 + DD DWord Ptr D_DrawLoadSampleWindow + +DrawLoadInstrumentWindow DW 8 + DD DWord Ptr D_DrawLoadInstrument + +ConfirmOverWriteBox DW 0 ; Box Object + DB 26, 25, 54, 32 + DB 3 + +ConfirmNosaveBox DW 0 ; Box Object + DB 20, 25, 60, 32 + DB 3 + +EnableInstrumentModeText DW 1 + DB 29, 27 + DB 20h + DB "Enable Instrument mode?", 0 + +ConfirmCenterSampleText DW 1 + DB 31, 27 + DB 20h + DB "Centralise sample?", 0 + +ConfirmOverWriteText DW 1 + DB 33, 27 + DB 20h + DB "Overwrite file?", 0 + +ConfirmDeleteText DW 1 + DB 35, 27 + DB 20h + DB "Delete file?", 0 + +ConfirmDeleteSampleText DW 1 + DB 34, 27 + DB 20h + DB "Delete sample?", 0 + +ConfirmDeleteInstrumentText DW 1 + DB 32, 27 + DB 20h + DB "Delete instrument?", 0 + +ConfirmClearMessageText DW 1 + DB 31, 27 + DB 20h + DB "Clear song message?", 0 + +ConfirmNoSaveMessage DW 1 + DB 23, 27 + DB 20h + DB "Current module not saved. Proceed?", 0 + +ConfirmSaveRenameText DW 1 + DB 31, 27 + DB 20h + DB "Save/Rename sample?", 0 + +ConfirmDiscardText DW 1 + DB 33, 27 + DB 20h + DB "Discard changes?", 0 + +ConfirmResaveText DW 1 + DB 35, 27 + DB 20h + DB "Save sample?", 0 + +InitInstrumentText DW 1 + DB 29, 27 + DB 20h + DB "Create host instrument?", 0 + +ConfirmConvertSampleText DW 1 + DB 33, 27 + DB 20h + DB "Convert sample?", 0 + +ConfirmInitialiseText DW 1 + DB 29, 27 + DB 20h + DB "Initialise instruments?", 0 + +ConfirmCutSampleText DW 1 + DB 35, 27 + DB 20h + DB "Cut sample?", 0 + +ConfirmQuitText DW 1 + DB 30, 27 + DB 20h + DB "Exit Impulse Tracker?", 0 + +ConfirmOverWriteOKButton DW 2 + DW 0FFFFh, 0FFFFh, 4, 4 + DW 0 + DW 0, 0 + DW 0 + DW 1 ; Return OK to overwrite + DW 0, 0, 0, 0 + DB 30, 29, 39, 31 + DB 8 + DB 0 + DB " OK", 0 + +ConfirmOverWriteCancelButton DW 2 + DW 0FFFFh, 0FFFFh, 3, 3 + DW 0 + DW 0, 0 + DW 0 + DW 0 ; Returns 0 + DW 0, 0, 0, 0 + DB 41, 29, 50, 31 + DB 8 + DB 0 + DB " Cancel", 0 + +ConfirmConvertYesButton DW 2 + DW 0FFFFh, 0FFFFh, 4, 4 + DW 0 + DW 0, 0 + DW 0 + DW 1 ; Return 1 + DW 0, 0, 0, 0 + DB 29, 29, 39, 31 + DB 8 + DB 0 + DB " Yes", 0 + +ConfirmConvertNoButton DW 2 + DW 0FFFFh, 0FFFFh, 3, 3 + DW 0 + DW 0, 0 + DW 0 + DW 2 ; Returns 2 + DW 0, 0, 0, 0 + DB 41, 29, 50, 31 + DB 8 + DB 0 + DB " No", 0 + +ConfirmInitialiseNoButton DW 2 + DW 0FFFFh, 0FFFFh, 3, 3 + DW 0 + DW 0, 0 + DW 0 + DW 0 ; Returns 0 + DW 0, 0, 0, 0 + DB 41, 29, 50, 31 + DB 8 + DB 0 + DB " No", 0 + +O1_UnableToSaveList DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr UnableToSaveText + DW Near Ptr NoSaveOKButton + DW 0 + +UnableToSaveText DW 1 + DB 31, 27 + DB 20h + DB "Unable to save file", 0 + +NoSaveOKButton DW 2 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 0 + DW 1 + DW 0, 0, 0, 0 + DB 36, 29, 45, 31 + DB 8 + DB 0 + DB " OK", 0 + +O1_ConfirmQuit DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr EmptyObject + DW Near Ptr ConfirmOverWriteBox + DW Near Ptr ConfirmQuitText + DW Near Ptr ConfirmOverWriteOKButton + DW Near Ptr ConfirmOverWriteCancelButton + DW 0 + +O1_SelectMultiChannel DW 7 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr SMCBox ; 0 + DW Near Ptr SMCText ; 1 + DW Near Ptr SMCInBox1 ; 2 + DW Near Ptr SMCInBox2 ; 3 + DW Near Ptr SMCInBox3 ; 4 + DW Near Ptr SMCInBox4 ; 5 + DW Near Ptr SMCDrawChannel ; 6 + DW Near Ptr SMCChannel00Toggle ; 7 + DW Near Ptr SMCChannel01Toggle + DW Near Ptr SMCChannel02Toggle + DW Near Ptr SMCChannel03Toggle + DW Near Ptr SMCChannel04Toggle + DW Near Ptr SMCChannel05Toggle + DW Near Ptr SMCChannel06Toggle + DW Near Ptr SMCChannel07Toggle + DW Near Ptr SMCChannel08Toggle + DW Near Ptr SMCChannel09Toggle + DW Near Ptr SMCChannel10Toggle + DW Near Ptr SMCChannel11Toggle + DW Near Ptr SMCChannel12Toggle + DW Near Ptr SMCChannel13Toggle + DW Near Ptr SMCChannel14Toggle + DW Near Ptr SMCChannel15Toggle + DW Near Ptr SMCChannel16Toggle + DW Near Ptr SMCChannel17Toggle + DW Near Ptr SMCChannel18Toggle + DW Near Ptr SMCChannel19Toggle + DW Near Ptr SMCChannel20Toggle + DW Near Ptr SMCChannel21Toggle + DW Near Ptr SMCChannel22Toggle + DW Near Ptr SMCChannel23Toggle + DW Near Ptr SMCChannel24Toggle + DW Near Ptr SMCChannel25Toggle + DW Near Ptr SMCChannel26Toggle + DW Near Ptr SMCChannel27Toggle + DW Near Ptr SMCChannel28Toggle + DW Near Ptr SMCChannel29Toggle + DW Near Ptr SMCChannel30Toggle + DW Near Ptr SMCChannel31Toggle + DW Near Ptr SMCChannel32Toggle + DW Near Ptr SMCChannel33Toggle + DW Near Ptr SMCChannel34Toggle + DW Near Ptr SMCChannel35Toggle + DW Near Ptr SMCChannel36Toggle + DW Near Ptr SMCChannel37Toggle + DW Near Ptr SMCChannel38Toggle + DW Near Ptr SMCChannel39Toggle + DW Near Ptr SMCChannel40Toggle + DW Near Ptr SMCChannel41Toggle + DW Near Ptr SMCChannel42Toggle + DW Near Ptr SMCChannel43Toggle + DW Near Ptr SMCChannel44Toggle + DW Near Ptr SMCChannel45Toggle + DW Near Ptr SMCChannel46Toggle + DW Near Ptr SMCChannel47Toggle + DW Near Ptr SMCChannel48Toggle + DW Near Ptr SMCChannel49Toggle + DW Near Ptr SMCChannel50Toggle + DW Near Ptr SMCChannel51Toggle + DW Near Ptr SMCChannel52Toggle + DW Near Ptr SMCChannel53Toggle + DW Near Ptr SMCChannel54Toggle + DW Near Ptr SMCChannel55Toggle + DW Near Ptr SMCChannel56Toggle + DW Near Ptr SMCChannel57Toggle + DW Near Ptr SMCChannel58Toggle + DW Near Ptr SMCChannel59Toggle + DW Near Ptr SMCChannel60Toggle + DW Near Ptr SMCChannel61Toggle + DW Near Ptr SMCChannel62Toggle + DW Near Ptr SMCChannel63Toggle ; 70 + DW Near Ptr SMCOKButton ; 71 + DW 0 + +SMCBox DW 0 + DB 7, 18, 72, 42 + DB 3 + +SMCInBox1 DW 0 + DB 19, 21, 23, 38 + DB 27 + +SMCInBox2 DW 0 + DB 35, 21, 39, 38 + DB 27 + +SMCInBox3 DW 0 + DB 51, 21, 55, 38 + DB 27 + +SMCInBox4 DW 0 + DB 67, 21, 71, 38 + DB 27 + +SMCText DW 1 + DB 29, 19 + DB 23h + DB "Multichannel Selection", 0 + +SMCDrawChannel DW 8 + DD DWord Ptr F_DrawSMCChannels + +SMCChannel00Toggle DW 17 + DB 20, 22 + DW 1 + DW Offset MultiChannelInfo+00 + DB 1 + DW 71, 8, 23, 55 + +SMCChannel01Toggle DW 17 + DB 20, 23 + DW 1 + DW Offset MultiChannelInfo+01 + DB 1 + DW 7, 9, 24, 56 + +SMCChannel02Toggle DW 17 + DB 20, 24 + DW 1 + DW Offset MultiChannelInfo+02 + DB 1 + DW 8, 10, 25, 57 + +SMCChannel03Toggle DW 17 + DB 20, 25 + DW 1 + DW Offset MultiChannelInfo+03 + DB 1 + DW 9, 11, 26, 58 + +SMCChannel04Toggle DW 17 + DB 20, 26 + DW 1 + DW Offset MultiChannelInfo+04 + DB 1 + DW 10, 12, 27, 59 + +SMCChannel05Toggle DW 17 + DB 20, 27 + DW 1 + DW Offset MultiChannelInfo+05 + DB 1 + DW 11, 13, 28, 60 + +SMCChannel06Toggle DW 17 + DB 20, 28 + DW 1 + DW Offset MultiChannelInfo+06 + DB 1 + DW 12, 14, 29, 61 + +SMCChannel07Toggle DW 17 + DB 20, 29 + DW 1 + DW Offset MultiChannelInfo+07 + DB 1 + DW 13, 15, 30, 62 + +SMCChannel08Toggle DW 17 + DB 20, 30 + DW 1 + DW Offset MultiChannelInfo+08 + DB 1 + DW 14, 16, 31, 63 + +SMCChannel09Toggle DW 17 + DB 20, 31 + DW 1 + DW Offset MultiChannelInfo+09 + DB 1 + DW 15, 17, 32, 64 + +SMCChannel10Toggle DW 17 + DB 20, 32 + DW 1 + DW Offset MultiChannelInfo+10 + DB 1 + DW 16, 18, 33, 65 + +SMCChannel11Toggle DW 17 + DB 20, 33 + DW 1 + DW Offset MultiChannelInfo+11 + DB 1 + DW 17, 19, 34, 66 + +SMCChannel12Toggle DW 17 + DB 20, 34 + DW 1 + DW Offset MultiChannelInfo+12 + DB 1 + DW 18, 20, 35, 67 + +SMCChannel13Toggle DW 17 + DB 20, 35 + DW 1 + DW Offset MultiChannelInfo+13 + DB 1 + DW 19, 21, 36, 68 + +SMCChannel14Toggle DW 17 + DB 20, 36 + DW 1 + DW Offset MultiChannelInfo+14 + DB 1 + DW 20, 22, 37, 69 + +SMCChannel15Toggle DW 17 + DB 20, 37 + DW 1 + DW Offset MultiChannelInfo+15 + DB 1 + DW 21, 71, 38, 70 + +SMCChannel16Toggle DW 17 + DB 36, 22 + DW 1 + DW Offset MultiChannelInfo+16 + DB 1 + DW 71, 24, 39, 7 + +SMCChannel17Toggle DW 17 + DB 36, 23 + DW 1 + DW Offset MultiChannelInfo+17 + DB 1 + DW 23, 25, 40, 8 + +SMCChannel18Toggle DW 17 + DB 36, 24 + DW 1 + DW Offset MultiChannelInfo+18 + DB 1 + DW 24, 26, 41, 9 + +SMCChannel19Toggle DW 17 + DB 36, 25 + DW 1 + DW Offset MultiChannelInfo+19 + DB 1 + DW 25, 27, 42, 10 + +SMCChannel20Toggle DW 17 + DB 36, 26 + DW 1 + DW Offset MultiChannelInfo+20 + DB 1 + DW 26, 28, 43, 11 + +SMCChannel21Toggle DW 17 + DB 36, 27 + DW 1 + DW Offset MultiChannelInfo+21 + DB 1 + DW 27, 29, 44, 12 + +SMCChannel22Toggle DW 17 + DB 36, 28 + DW 1 + DW Offset MultiChannelInfo+22 + DB 1 + DW 28, 30, 45, 13 + +SMCChannel23Toggle DW 17 + DB 36, 29 + DW 1 + DW Offset MultiChannelInfo+23 + DB 1 + DW 29, 31, 46, 14 + +SMCChannel24Toggle DW 17 + DB 36, 30 + DW 1 + DW Offset MultiChannelInfo+24 + DB 1 + DW 30, 32, 47, 15 + +SMCChannel25Toggle DW 17 + DB 36, 31 + DW 1 + DW Offset MultiChannelInfo+25 + DB 1 + DW 31, 33, 48, 16 + +SMCChannel26Toggle DW 17 + DB 36, 32 + DW 1 + DW Offset MultiChannelInfo+26 + DB 1 + DW 32, 34, 49, 17 + +SMCChannel27Toggle DW 17 + DB 36, 33 + DW 1 + DW Offset MultiChannelInfo+27 + DB 1 + DW 33, 35, 50, 18 + +SMCChannel28Toggle DW 17 + DB 36, 34 + DW 1 + DW Offset MultiChannelInfo+28 + DB 1 + DW 34, 36, 51, 19 + +SMCChannel29Toggle DW 17 + DB 36, 35 + DW 1 + DW Offset MultiChannelInfo+29 + DB 1 + DW 35, 37, 52, 20 + +SMCChannel30Toggle DW 17 + DB 36, 36 + DW 1 + DW Offset MultiChannelInfo+30 + DB 1 + DW 36, 38, 53, 21 + +SMCChannel31Toggle DW 17 + DB 36, 37 + DW 1 + DW Offset MultiChannelInfo+31 + DB 1 + DW 37, 71, 54, 22 + +SMCChannel32Toggle DW 17 + DB 52, 22 + DW 1 + DW Offset MultiChannelInfo+32 + DB 1 + DW 71, 40, 55, 23 + +SMCChannel33Toggle DW 17 + DB 52, 23 + DW 1 + DW Offset MultiChannelInfo+33 + DB 1 + DW 39, 41, 56, 24 + +SMCChannel34Toggle DW 17 + DB 52, 24 + DW 1 + DW Offset MultiChannelInfo+34 + DB 1 + DW 40, 42, 57, 25 + +SMCChannel35Toggle DW 17 + DB 52, 25 + DW 1 + DW Offset MultiChannelInfo+35 + DB 1 + DW 41, 43, 58, 26 + +SMCChannel36Toggle DW 17 + DB 52, 26 + DW 1 + DW Offset MultiChannelInfo+36 + DB 1 + DW 42, 44, 59, 27 + +SMCChannel37Toggle DW 17 + DB 52, 27 + DW 1 + DW Offset MultiChannelInfo+37 + DB 1 + DW 43, 45, 60, 28 + +SMCChannel38Toggle DW 17 + DB 52, 28 + DW 1 + DW Offset MultiChannelInfo+38 + DB 1 + DW 44, 46, 61, 29 + +SMCChannel39Toggle DW 17 + DB 52, 29 + DW 1 + DW Offset MultiChannelInfo+39 + DB 1 + DW 45, 47, 62, 30 + +SMCChannel40Toggle DW 17 + DB 52, 30 + DW 1 + DW Offset MultiChannelInfo+40 + DB 1 + DW 46, 48, 63, 31 + +SMCChannel41Toggle DW 17 + DB 52, 31 + DW 1 + DW Offset MultiChannelInfo+41 + DB 1 + DW 47, 49, 64, 32 + +SMCChannel42Toggle DW 17 + DB 52, 32 + DW 1 + DW Offset MultiChannelInfo+42 + DB 1 + DW 48, 50, 65, 33 + +SMCChannel43Toggle DW 17 + DB 52, 33 + DW 1 + DW Offset MultiChannelInfo+43 + DB 1 + DW 49, 51, 66, 34 + +SMCChannel44Toggle DW 17 + DB 52, 34 + DW 1 + DW Offset MultiChannelInfo+44 + DB 1 + DW 50, 52, 67, 35 + +SMCChannel45Toggle DW 17 + DB 52, 35 + DW 1 + DW Offset MultiChannelInfo+45 + DB 1 + DW 51, 53, 68, 36 + +SMCChannel46Toggle DW 17 + DB 52, 36 + DW 1 + DW Offset MultiChannelInfo+46 + DB 1 + DW 52, 54, 69, 37 + +SMCChannel47Toggle DW 17 + DB 52, 37 + DW 1 + DW Offset MultiChannelInfo+47 + DB 1 + DW 53, 71, 70, 38 + +SMCChannel48Toggle DW 17 + DB 68, 22 + DW 1 + DW Offset MultiChannelInfo+48 + DB 1 + DW 71, 56, 7, 39 + +SMCChannel49Toggle DW 17 + DB 68, 23 + DW 1 + DW Offset MultiChannelInfo+49 + DB 1 + DW 55, 57, 8, 40 + +SMCChannel50Toggle DW 17 + DB 68, 24 + DW 1 + DW Offset MultiChannelInfo+50 + DB 1 + DW 56, 58, 9, 41 + +SMCChannel51Toggle DW 17 + DB 68, 25 + DW 1 + DW Offset MultiChannelInfo+51 + DB 1 + DW 57, 59, 10, 42 + +SMCChannel52Toggle DW 17 + DB 68, 26 + DW 1 + DW Offset MultiChannelInfo+52 + DB 1 + DW 58, 60, 11, 43 + +SMCChannel53Toggle DW 17 + DB 68, 27 + DW 1 + DW Offset MultiChannelInfo+53 + DB 1 + DW 59, 61, 12, 44 + +SMCChannel54Toggle DW 17 + DB 68, 28 + DW 1 + DW Offset MultiChannelInfo+54 + DB 1 + DW 60, 62, 13, 45 + +SMCChannel55Toggle DW 17 + DB 68, 29 + DW 1 + DW Offset MultiChannelInfo+55 + DB 1 + DW 61, 63, 14, 46 + +SMCChannel56Toggle DW 17 + DB 68, 30 + DW 1 + DW Offset MultiChannelInfo+56 + DB 1 + DW 62, 64, 15, 47 + +SMCChannel57Toggle DW 17 + DB 68, 31 + DW 1 + DW Offset MultiChannelInfo+57 + DB 1 + DW 63, 65, 16, 48 + +SMCChannel58Toggle DW 17 + DB 68, 32 + DW 1 + DW Offset MultiChannelInfo+58 + DB 1 + DW 64, 66, 17, 49 + +SMCChannel59Toggle DW 17 + DB 68, 33 + DW 1 + DW Offset MultiChannelInfo+59 + DB 1 + DW 65, 67, 18, 50 + +SMCChannel60Toggle DW 17 + DB 68, 34 + DW 1 + DW Offset MultiChannelInfo+60 + DB 1 + DW 66, 68, 19, 51 + +SMCChannel61Toggle DW 17 + DB 68, 35 + DW 1 + DW Offset MultiChannelInfo+61 + DB 1 + DW 67, 69, 20, 52 + +SMCChannel62Toggle DW 17 + DB 68, 36 + DW 1 + DW Offset MultiChannelInfo+62 + DB 1 + DW 68, 70, 21, 53 + +SMCChannel63Toggle DW 17 + DB 68, 37 + DW 1 + DW Offset MultiChannelInfo+63 + DB 1 + DW 69, 71, 22, 54 + +SMCOKButton DW 2 + DW 22, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 0 + DW 0 + DW 0, 0, 0, 0 + DB 35, 39, 44, 41 + DB 8 + DB 0 + DB " OK ", 0 + +O1_ExchangeSampleList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr ExchangeSampleBox + DW Near Ptr ExchangeSampleText + DW Near Ptr ExchangeSampleInputBox + DW Near Ptr ExchangeSampleInput ; 3 + DW Near Ptr CancelExchangeButton ; 4 + DW 0 + +O1_ReplaceSampleList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr ExchangeSampleBox + DW Near Ptr ReplaceSampleText + DW Near Ptr ExchangeSampleInputBox + DW Near Ptr ExchangeSampleInput ; 3 + DW Near Ptr CancelExchangeButton ; 4 + DW 0 + +O1_ReplaceInstrumentList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr ExchangeSampleBox + DW Near Ptr ReplaceInstrumentText + DW Near Ptr ExchangeSampleInputBox + DW Near Ptr ExchangeSampleInput ; 3 + DW Near Ptr CancelExchangeButton ; 4 + DW 0 + +O1_SwapSampleList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr ExchangeSampleBox + DW Near Ptr SwapSampleText + DW Near Ptr ExchangeSampleInputBox + DW Near Ptr ExchangeSampleInput ; 3 + DW Near Ptr CancelExchangeButton ; 4 + DW 0 + +O1_SwapInstrumentList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr ExchangeSampleBox + DW Near Ptr SwapInstrumentText + DW Near Ptr ExchangeSampleInputBox + DW Near Ptr ExchangeSampleInput ; 3 + DW Near Ptr CancelExchangeButton ; 4 + DW 0 + +O1_CopyInstrumentList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr ExchangeSampleBox + DW Near Ptr CopyInstrumentText + DW Near Ptr ExchangeSampleInputBox + DW Near Ptr ExchangeSampleInput ; 3 + DW Near Ptr CancelExchangeButton ; 4 + DW 0 + +O1_ExchangeInstrumentList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr OKCancelList + DW Near Ptr ExchangeSampleBox + DW Near Ptr ExchangeInstrumentText + DW Near Ptr ExchangeSampleInputBox + DW Near Ptr ExchangeSampleInput ; 3 + DW Near Ptr CancelExchangeButton ; 4 + DW 0 + +O1_ResizeSampleList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESC&ReturnList + DW Near Ptr ResizeSampleBox ; 0 + DW Near Ptr ResizeSampleText ; 1 + DW Near Ptr ResizeSampleInputBox ; 2 + DW Near Ptr ResizeSampleInput ; 3 + DW Near Ptr CancelExchangeButton + DW 0 + +ESCF2&ReturnList DB 0 + DW 13Ch + DD DWord Ptr F_Return0 + +ESC&ReturnList DB 0 + DW 101h + DD DWord Ptr F_Return0 + + DB 0 + DW 11Ch + DD DWord Ptr F_Return1 + + DB 5 + DW Near Ptr ChainMIDICommands + +ExchangeSampleBox DW 0 + DB 26, 23, 54, 32 + DB 3 + +ExchangeSampleText DW 1 + DB 30, 25 + DB 20h + DB "Exchange sample with:", 13 + DB 13 + DB 0FFh, 5, " Sample", 0 + +ResizeSampleBox DW 0 + DB 26, 22, 54, 32 + DB 3 + +ResizeSampleText DW 1 + DB 31, 24 + DB 23h + DB " Resize Sample", 13, 13 + DB 13, 0FEh, 20h + DB "New Length", 0 + +ResizeSampleInputBox DW 0 + DB 41, 26, 49, 28 + DB 27 + +ResizeSampleInput DW 18 + DB 42, 27 + DW 2 + DW Offset NewSampleSize + DD 0 + DW 0FFFFh, 4, 4, 0FFFFh + +SwapSampleText DW 1 + DB 32, 25 + DB 20h + DB "Swap sample with:", 13 + DB 13 + DB " Sample", 0 + +SwapInstrumentText DW 1 + DB 29, 25 + DB 20h + DB "Swap instrument with:", 13 + DB 13 + DB " Instrument", 0 + +CopyInstrumentText DW 1 + DB 31, 25 + DB 20h + DB " Copy instrument:", 13 + DB 13 + DB "Instrument", 0 + +ReplaceSampleText DW 1 + DB 30, 25 + DB 20h + DB "Replace sample with:", 13 + DB 13 + DB 0FFh, 5, " Sample", 0 + +ReplaceInstrumentText DW 1 + DB 28, 25 + DB 20h + DB "Replace instrument with:", 13 + DB 13 + DB " Instrument", 0 + +ExchangeInstrumentText DW 1 + DB 28, 25 + DB 20h + DB "Exchange instrument with:", 13 + DB 13 + DB " Instrument", 0 + +ExchangeSampleInputBox DW 0 + DB 41, 26, 45, 28 + DB 27 + +ExchangeSampleInput DW 16 + DB 42, 27 + DW 2 + DW Offset SampleNumberInput + DW 3 + DD DWord Ptr F_Return1 + DW 0FFFFh, 4, 4, 0FFFFh + +CancelExchangeButton DW 2 + DW 3, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 0 + DW 0 ; Returns 0 + DW 0, 0, 0, 0 + DB 35, 29, 44, 31 + DB 8 + DB 0 + DB " Cancel", 0 + + +O1_OrderVolumeList DW 10 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr FillHeader ; 2 + DW Near Ptr OrderandVolumeMsg ; 3 + DW Near Ptr OrderBox ; 4 + DW Near Ptr PanBox1 ; 5 + DW Near Ptr PanBox2 ; 6 + DW Near Ptr ShowChannelMsgs ; 7 + DW Near Ptr VolumeText1 ; 8 + DW Near Ptr VolumeText2 ; 9 + DW Near Ptr OrderList ; 10 + DW Near Ptr ChannelVol1 ; 11 + DW Near Ptr ChannelVol2 ; 12 + DW Near Ptr ChannelVol3 ; 13 + DW Near Ptr ChannelVol4 ; 14 + DW Near Ptr ChannelVol5 ; 15 + DW Near Ptr ChannelVol6 ; 16 + DW Near Ptr ChannelVol7 ; 17 + DW Near Ptr ChannelVol8 ; 18 + DW Near Ptr ChannelVol9 ; 19 + DW Near Ptr ChannelVol10 ; 20 + DW Near Ptr ChannelVol11 ; 21 + DW Near Ptr ChannelVol12 ; 22 + DW Near Ptr ChannelVol13 ; 23 + DW Near Ptr ChannelVol14 ; 24 + DW Near Ptr ChannelVol15 ; 25 + DW Near Ptr ChannelVol16 ; 26 + DW Near Ptr ChannelVol17 + DW Near Ptr ChannelVol18 + DW Near Ptr ChannelVol19 + DW Near Ptr ChannelVol20 + DW Near Ptr ChannelVol21 + DW Near Ptr ChannelVol22 + DW Near Ptr ChannelVol23 + DW Near Ptr ChannelVol24 + DW Near Ptr ChannelVol25 + DW Near Ptr ChannelVol26 + DW Near Ptr ChannelVol27 + DW Near Ptr ChannelVol28 + DW Near Ptr ChannelVol29 + DW Near Ptr ChannelVol30 + DW Near Ptr ChannelVol31 + DW Near Ptr ChannelVol32 + DW Near Ptr ChannelVol33 + DW Near Ptr ChannelVol34 + DW Near Ptr ChannelVol35 + DW Near Ptr ChannelVol36 + DW Near Ptr ChannelVol37 + DW Near Ptr ChannelVol38 + DW Near Ptr ChannelVol39 + DW Near Ptr ChannelVol40 + DW Near Ptr ChannelVol41 + DW Near Ptr ChannelVol42 + DW Near Ptr ChannelVol43 + DW Near Ptr ChannelVol44 + DW Near Ptr ChannelVol45 + DW Near Ptr ChannelVol46 + DW Near Ptr ChannelVol47 + DW Near Ptr ChannelVol48 + DW Near Ptr ChannelVol49 + DW Near Ptr ChannelVol50 + DW Near Ptr ChannelVol51 + DW Near Ptr ChannelVol52 + DW Near Ptr ChannelVol53 + DW Near Ptr ChannelVol54 + DW Near Ptr ChannelVol55 + DW Near Ptr ChannelVol56 + DW Near Ptr ChannelVol57 + DW Near Ptr ChannelVol58 + DW Near Ptr ChannelVol59 + DW Near Ptr ChannelVol60 + DW Near Ptr ChannelVol61 + DW Near Ptr ChannelVol62 + DW Near Ptr ChannelVol63 + DW Near Ptr ChannelVol64 ; 74 + DW Near Ptr SetHelpContext4 + DW 0 + +ChannelVol1 DW 9 ; Object 9 + DB 31, 15 ; x,y + DW 0, 64 ; Ranges + DW 4, 0+64 ; Volume/Channel 1 + DW 11, 12, 43, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 19 ; PgUp/PgDn + +ChannelVol2 DW 9 + DB 31, 16 + DW 0, 64 + DW 4, 1+64 ; Volume/Channel 2 + DW 11, 13, 44, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 20 ; PgUp/PgDn + +ChannelVol3 DW 9 ; Object 9 + DB 31, 17 ; x,y + DW 0, 64 ; Ranges + DW 4, 2+64 ; Volume/Channel 3 + DW 12, 14, 45, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 21 ; PgUp/PgDn + +ChannelVol4 DW 9 + DB 31, 18 + DW 0, 64 + DW 4, 3+64 ; Volume/Channel 4 + DW 13, 15, 46, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 22 ; PgUp/PgDn + +ChannelVol5 DW 9 ; Object 9 + DB 31, 19 ; x,y + DW 0, 64 ; Ranges + DW 4, 4+64 ; Volume/Channel 5 + DW 14, 16, 47, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 23 ; PgUp/PgDn + +ChannelVol6 DW 9 + DB 31, 20 + DW 0, 64 + DW 4, 5+64 ; Volume/Channel 6 + DW 15, 17, 48, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 24 ; PgUp/PgDn + +ChannelVol7 DW 9 ; Object 9 + DB 31, 21 ; x,y + DW 0, 64 ; Ranges + DW 4, 6+64 ; Volume/Channel 7 + DW 16, 18, 49, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 25 ; PgUp/PgDn + +ChannelVol8 DW 9 + DB 31, 22 + DW 0, 64 + DW 4, 7+64 ; Volume/Channel 8 + DW 17, 19, 50, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 26 ; PgUp/PgDn + +ChannelVol9 DW 9 ; Object 9 + DB 31, 23 ; x,y + DW 0, 64 ; Ranges + DW 4, 8+64 ; Volume/Channel 9 + DW 18, 20, 51, 10 ; Up/Down/Tab/Shift-Tab + DW 11, 27 ; PgUp/PgDn + +ChannelVol10 DW 9 + DB 31, 24 + DW 0, 64 + DW 4, 9+64 ; Volume/Channel 10 + DW 19, 21, 52, 10 ; Up/Down/Tab/Shift-Tab + DW 12, 28 ; PgUp/PgDn + +ChannelVol11 DW 9 ; Object 9 + DB 31, 25 ; x,y + DW 0, 64 ; Ranges + DW 4, 10+64 ; Volume/Channel 11 + DW 20, 22, 53, 10 ; Up/Down/Tab/Shift-Tab + DW 13, 29 ; PgUp/PgDn + +ChannelVol12 DW 9 + DB 31, 26 + DW 0, 64 + DW 4, 11+64 ; Volume/Channel 12 + DW 21, 23, 54, 10 ; Up/Down/Tab/Shift-Tab + DW 14, 30 ; PgUp/PgDn + +ChannelVol13 DW 9 ; Object 9 + DB 31, 27 ; x,y + DW 0, 64 ; Ranges + DW 4, 12+64 ; Volume/Channel 13 + DW 22, 24, 55, 10 ; Up/Down/Tab/Shift-Tab + DW 15, 31 ; PgUp/PgDn + +ChannelVol14 DW 9 + DB 31, 28 + DW 0, 64 + DW 4, 13+64 ; Volume/Channel 14 + DW 23, 25, 56, 10 ; Up/Down/Tab/Shift-Tab + DW 16, 32 ; PgUp/PgDn + +ChannelVol15 DW 9 ; Object 9 + DB 31, 29 ; x,y + DW 0, 64 ; Ranges + DW 4, 14+64 ; Volume/Channel 15 + DW 24, 26, 57, 10 ; Up/Down/Tab/Shift-Tab + DW 17, 33 ; PgUp/PgDn + +ChannelVol16 DW 9 + DB 31, 30 + DW 0, 64 + DW 4, 15+64 ; Volume/Channel 16 + DW 25, 27, 58, 10 ; Up/Down/Tab/Shift-Tab + DW 18, 34 ; PgUp/PgDn + +ChannelVol17 DW 9 ; Object 9 + DB 31, 31 ; x,y + DW 0, 64 ; Ranges + DW 4, 16+64 ; Volume/Channel 17 + DW 26, 28, 59, 10 ; Up/Down/Tab/Shift-Tab + DW 19, 35 ; PgUp/PgDn + +ChannelVol18 DW 9 + DB 31, 32 + DW 0, 64 + DW 4, 17+64 ; Volume/Channel 18 + DW 27, 29, 60, 10 ; Up/Down/Tab/Shift-Tab + DW 20, 36 ; PgUp/PgDn + +ChannelVol19 DW 9 ; Object 9 + DB 31, 33 ; x,y + DW 0, 64 ; Ranges + DW 4, 18+64 ; Volume/Channel 19 + DW 28, 30, 61, 10 ; Up/Down/Tab/Shift-Tab + DW 21, 37 ; PgUp/PgDn + +ChannelVol20 DW 9 + DB 31, 34 + DW 0, 64 + DW 4, 19+64 ; Volume/Channel 20 + DW 29, 31, 62, 10 ; Up/Down/Tab/Shift-Tab + DW 22, 38 ; PgUp/PgDn + +ChannelVol21 DW 9 ; Object 9 + DB 31, 35 ; x,y + DW 0, 64 ; Ranges + DW 4, 20+64 ; Volume/Channel 21 + DW 30, 32, 63, 10 ; Up/Down/Tab/Shift-Tab + DW 23, 39 ; PgUp/PgDn + +ChannelVol22 DW 9 + DB 31, 36 + DW 0, 64 + DW 4, 21+64 ; Volume/Channel 22 + DW 31, 33, 64, 10 ; Up/Down/Tab/Shift-Tab + DW 24, 40 ; PgUp/PgDn + +ChannelVol23 DW 9 ; Object 9 + DB 31, 37 ; x,y + DW 0, 64 ; Ranges + DW 4, 22+64 ; Volume/Channel 23 + DW 32, 34, 65, 10 ; Up/Down/Tab/Shift-Tab + DW 25, 41 ; PgUp/PgDn + +ChannelVol24 DW 9 + DB 31, 38 + DW 0, 64 + DW 4, 23+64 ; Volume/Channel 24 + DW 33, 35, 66, 10 ; Up/Down/Tab/Shift-Tab + DW 26, 42 ; PgUp/PgDn + +ChannelVol25 DW 9 ; Object 9 + DB 31, 39 ; x,y + DW 0, 64 ; Ranges + DW 4, 24+64 ; Volume/Channel 25 + DW 34, 36, 67, 10 ; Up/Down/Tab/Shift-Tab + DW 27, 43 ; PgUp/PgDn + +ChannelVol26 DW 9 + DB 31, 40 + DW 0, 64 + DW 4, 25+64 ; Volume/Channel 26 + DW 35, 37, 68, 10 ; Up/Down/Tab/Shift-Tab + DW 28, 44 ; PgUp/PgDn + +ChannelVol27 DW 9 ; Object 9 + DB 31, 41 ; x,y + DW 0, 64 ; Ranges + DW 4, 26+64 ; Volume/Channel 27 + DW 36, 38, 69, 10 ; Up/Down/Tab/Shift-Tab + DW 29, 45 ; PgUp/PgDn + +ChannelVol28 DW 9 + DB 31, 42 + DW 0, 64 + DW 4, 27+64 ; Volume/Channel 28 + DW 37, 39, 70, 10 ; Up/Down/Tab/Shift-Tab + DW 30, 46 ; PgUp/PgDn + +ChannelVol29 DW 9 ; Object 9 + DB 31, 43 ; x,y + DW 0, 64 ; Ranges + DW 4, 28+64 ; Volume/Channel 29 + DW 38, 40, 71, 10 ; Up/Down/Tab/Shift-Tab + DW 31, 47 ; PgUp/PgDn + +ChannelVol30 DW 9 + DB 31, 44 + DW 0, 64 + DW 4, 29+64 ; Volume/Channel 30 + DW 39, 41, 72, 10 ; Up/Down/Tab/Shift-Tab + DW 32, 48 ; PgUp/PgDn + +ChannelVol31 DW 9 ; Object 9 + DB 31, 45 ; x,y + DW 0, 64 ; Ranges + DW 4, 30+64 ; Volume/Channel 31 + DW 40, 42, 73, 10 ; Up/Down/Tab/Shift-Tab + DW 33, 49 ; PgUp/PgDn + +ChannelVol32 DW 9 + DB 31, 46 + DW 0, 64 + DW 4, 31+64 ; Volume/Channel 32 + DW 41, 43, 74, 10 ; Up/Down/Tab/Shift-Tab + DW 34, 50 ; PgUp/PgDn + +ChannelVol33 DW 9 ; Object 9 + DB 65, 15 ; x,y + DW 0, 64 ; Ranges + DW 4, 32+64 ; Volume/Channel 33 + DW 42, 44, 10, 11 ; Up/Down/Tab/Shift-Tab + DW 35, 51 ; PgUp/PgDn + +ChannelVol34 DW 9 + DB 65, 16 + DW 0, 64 + DW 4, 33+64 ; Volume/Channel 34 + DW 43, 45, 10, 12 ; Up/Down/Tab/Shift-Tab + DW 36, 52 ; PgUp/PgDn + +ChannelVol35 DW 9 ; Object 9 + DB 65, 17 ; x,y + DW 0, 64 ; Ranges + DW 4, 34+64 ; Volume/Channel 35 + DW 44, 46, 10, 13 ; Up/Down/Tab/Shift-Tab + DW 37, 53 ; PgUp/PgDn + +ChannelVol36 DW 9 + DB 65, 18 + DW 0, 64 + DW 4, 35+64 ; Volume/Channel 36 + DW 45, 47, 10, 14 ; Up/Down/Tab/Shift-Tab + DW 38, 54 ; PgUp/PgDn + +ChannelVol37 DW 9 ; Object 9 + DB 65, 19 ; x,y + DW 0, 64 ; Ranges + DW 4, 36+64 ; Volume/Channel 37 + DW 46, 48, 10, 15 ; Up/Down/Tab/Shift-Tab + DW 39, 55 ; PgUp/PgDn + +ChannelVol38 DW 9 + DB 65, 20 + DW 0, 64 + DW 4, 37+64 ; Volume/Channel 38 + DW 47, 49, 10, 16 ; Up/Down/Tab/Shift-Tab + DW 40, 56 ; PgUp/PgDn + +ChannelVol39 DW 9 ; Object 9 + DB 65, 21 ; x,y + DW 0, 64 ; Ranges + DW 4, 38+64 ; Volume/Channel 39 + DW 48, 50, 10, 17 ; Up/Down/Tab/Shift-Tab + DW 41, 57 ; PgUp/PgDn + +ChannelVol40 DW 9 + DB 65, 22 + DW 0, 64 + DW 4, 39+64 ; Volume/Channel 40 + DW 49, 51, 10, 18 ; Up/Down/Tab/Shift-Tab + DW 42, 58 ; PgUp/PgDn + +ChannelVol41 DW 9 ; Object 9 + DB 65, 23 ; x,y + DW 0, 64 ; Ranges + DW 4, 40+64 ; Volume/Channel 41 + DW 50, 52, 10, 19 ; Up/Down/Tab/Shift-Tab + DW 43, 59 ; PgUp/PgDn + +ChannelVol42 DW 9 + DB 65, 24 + DW 0, 64 + DW 4, 41+64 ; Volume/Channel 42 + DW 51, 53, 10, 20 ; Up/Down/Tab/Shift-Tab + DW 44, 60 ; PgUp/PgDn + +ChannelVol43 DW 9 ; Object 9 + DB 65, 25 ; x,y + DW 0, 64 ; Ranges + DW 4, 42+64 ; Volume/Channel 43 + DW 52, 54, 10, 21 ; Up/Down/Tab/Shift-Tab + DW 45, 61 ; PgUp/PgDn + +ChannelVol44 DW 9 + DB 65, 26 + DW 0, 64 + DW 4, 43+64 ; Volume/Channel 44 + DW 53, 55, 10, 22 ; Up/Down/Tab/Shift-Tab + DW 46, 62 ; PgUp/PgDn + +ChannelVol45 DW 9 ; Object 9 + DB 65, 27 ; x,y + DW 0, 64 ; Ranges + DW 4, 44+64 ; Volume/Channel 45 + DW 54, 56, 10, 23 ; Up/Down/Tab/Shift-Tab + DW 47, 63 ; PgUp/PgDn + +ChannelVol46 DW 9 + DB 65, 28 + DW 0, 64 + DW 4, 45+64 ; Volume/Channel 46 + DW 55, 57, 10, 24 ; Up/Down/Tab/Shift-Tab + DW 48, 64 ; PgUp/PgDn + +ChannelVol47 DW 9 ; Object 9 + DB 65, 29 ; x,y + DW 0, 64 ; Ranges + DW 4, 46+64 ; Volume/Channel 47 + DW 56, 58, 10, 25 ; Up/Down/Tab/Shift-Tab + DW 49, 65 ; PgUp/PgDn + +ChannelVol48 DW 9 + DB 65, 30 + DW 0, 64 + DW 4, 47+64 ; Volume/Channel 48 + DW 57, 59, 10, 26 ; Up/Down/Tab/Shift-Tab + DW 50, 66 ; PgUp/PgDn + +ChannelVol49 DW 9 ; Object 9 + DB 65, 31 ; x,y + DW 0, 64 ; Ranges + DW 4, 48+64 ; Volume/Channel 49 + DW 58, 60, 10, 27 ; Up/Down/Tab/Shift-Tab + DW 51, 67 ; PgUp/PgDn + +ChannelVol50 DW 9 + DB 65, 32 + DW 0, 64 + DW 4, 49+64 ; Volume/Channel 50 + DW 59, 61, 10, 28 ; Up/Down/Tab/Shift-Tab + DW 52, 68 ; PgUp/PgDn + +ChannelVol51 DW 9 ; Object 9 + DB 65, 33 ; x,y + DW 0, 64 ; Ranges + DW 4, 50+64 ; Volume/Channel 51 + DW 60, 62, 10, 29 ; Up/Down/Tab/Shift-Tab + DW 53, 69 ; PgUp/PgDn + +ChannelVol52 DW 9 + DB 65, 34 + DW 0, 64 + DW 4, 51+64 ; Volume/Channel 52 + DW 61, 63, 10, 30 ; Up/Down/Tab/Shift-Tab + DW 54, 70 ; PgUp/PgDn + +ChannelVol53 DW 9 ; Object 9 + DB 65, 35 ; x,y + DW 0, 64 ; Ranges + DW 4, 52+64 ; Volume/Channel 53 + DW 62, 64, 10, 31 ; Up/Down/Tab/Shift-Tab + DW 55, 71 ; PgUp/PgDn + +ChannelVol54 DW 9 + DB 65, 36 + DW 0, 64 + DW 4, 53+64 ; Volume/Channel 54 + DW 63, 65, 10, 32 ; Up/Down/Tab/Shift-Tab + DW 56, 72 ; PgUp/PgDn + +ChannelVol55 DW 9 ; Object 9 + DB 65, 37 ; x,y + DW 0, 64 ; Ranges + DW 4, 54+64 ; Volume/Channel 55 + DW 64, 66, 10, 33 ; Up/Down/Tab/Shift-Tab + DW 57, 73 ; PgUp/PgDn + +ChannelVol56 DW 9 + DB 65, 38 + DW 0, 64 + DW 4, 55+64 ; Volume/Channel 56 + DW 65, 67, 10, 34 ; Up/Down/Tab/Shift-Tab + DW 58, 74 ; PgUp/PgDn + +ChannelVol57 DW 9 ; Object 9 + DB 65, 39 ; x,y + DW 0, 64 ; Ranges + DW 4, 56+64 ; Volume/Channel 57 + DW 66, 68, 10, 35 ; Up/Down/Tab/Shift-Tab + DW 59, 74 ; PgUp/PgDn + +ChannelVol58 DW 9 + DB 65, 40 + DW 0, 64 + DW 4, 57+64 ; Volume/Channel 58 + DW 67, 69, 10, 36 ; Up/Down/Tab/Shift-Tab + DW 60, 74 ; PgUp/PgDn + +ChannelVol59 DW 9 ; Object 9 + DB 65, 41 ; x,y + DW 0, 64 ; Ranges + DW 4, 58+64 ; Volume/Channel 59 + DW 68, 70, 10, 37 ; Up/Down/Tab/Shift-Tab + DW 61, 74 ; PgUp/PgDn + +ChannelVol60 DW 9 + DB 65, 42 + DW 0, 64 + DW 4, 59+64 ; Volume/Channel 60 + DW 69, 71, 10, 38 ; Up/Down/Tab/Shift-Tab + DW 62, 74 ; PgUp/PgDn + +ChannelVol61 DW 9 ; Object 9 + DB 65, 43 ; x,y + DW 0, 64 ; Ranges + DW 4, 60+64 ; Volume/Channel 61 + DW 70, 72, 10, 39 ; Up/Down/Tab/Shift-Tab + DW 63, 74 ; PgUp/PgDn + +ChannelVol62 DW 9 + DB 65, 44 + DW 0, 64 + DW 4, 61+64 ; Volume/Channel 62 + DW 71, 73, 10, 40 ; Up/Down/Tab/Shift-Tab + DW 64, 74 ; PgUp/PgDn + +ChannelVol63 DW 9 ; Object 9 + DB 65, 45 ; x,y + DW 0, 64 ; Ranges + DW 4, 62+64 ; Volume/Channel 63 + DW 72, 74, 10, 41 ; Up/Down/Tab/Shift-Tab + DW 65, 74 ; PgUp/PgDn + +ChannelVol64 DW 9 + DB 65, 46 + DW 0, 64 + DW 4, 63+64 ; Volume/Channel 64 + DW 73, 74, 10, 42 ; Up/Down/Tab/Shift-Tab + DW 66, 74 ; PgUp/PgDn + +O1_ConfigureITList DW 14 ; Song name input + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr FillHeader ; 2 + DW Near Ptr ConfigureListHeader + DW Near Ptr DivisionLine + DW Near Ptr SongVarText1 + DW Near Ptr SongNameBox + DW Near Ptr InitialSpeedBox + DW Near Ptr VolumeBox + DW Near Ptr SongVarText2 + DW Near Ptr LinkCommandGToggle ; 10 + DW Near Ptr DirectoryText1 + DW Near Ptr DirectoryText2 + DW Near Ptr DirectoryInputBox + DW Near Ptr SongNameInput ; 14 + DW Near Ptr InitialTempoInput ; 15 + DW Near Ptr InitialSpeedInput ; 16 + DW Near Ptr GlobalVolumeInput ; 17 + DW Near Ptr MixingVolumeInput ; 18 + DW Near Ptr SeparationInput ; 19 + DW Near Ptr OldEffectsModeToggle ; 20 + DW Near Ptr ConfigSetupButtons ; 21 + DW Near Ptr ControlInstrumentButton ; 22 + DW Near Ptr ControlSampleButton ; 23 + DW Near Ptr PlayBackStereoButton ; 24 + DW Near Ptr PlayBackMonoButton ; 25 + DW Near Ptr SlideLinearButton ; 26 + DW Near Ptr SlideAmigaButton ; 27 + DW Near Ptr SongDirectoryInput ; 28 + DW Near Ptr SampleDirectoryInput ; 29 + DW Near Ptr InstrumentDirectoryInput ; 30 + DW Near Ptr SaveDirectoryConfigButton ; 31 + DW Near Ptr LinkCommandGToggle ; 32 + DW Near Ptr SetHelpContext5 + DW 0 + +ConfigureListHeader DW 10 + DB "Song Variables & Directory Configuration (F12)", 0 + +DivisionLine DW 1 + DB 1, 39 + DB 21h + DB 0FFh, 78, 129, 0 + +SongVarText1 DW 1 + DB 33, 13 + DB 23h + DB "Song Variables", 0 + +SongNameBox DW 0 + DB 16, 15, 43, 17 + DB 25 + +InitialSpeedBox DW 0 + DB 16, 18, 50, 21 + DB 9 + +VolumeBox DW 0 + DB 16, 22, 34, 28 + DB 25 + +SongVarText2 DW 1 + DB 2, 16 + DB 20h + DB 0FFh, 5, " Song Name", 13 + DB 13 + DB 13 + DB " Initial Tempo", 13 + DB " Initial Speed", 13 + DB 13 + DB 13 + DB " Global Volume", 13 + DB " Mixing Volume", 13 + DB 0FFh, 4, " Separation", 13 + DB " Old Effects", 13 + DB "Compatible Gxx", 13 + DB 13 + DB 13 + DB 0FFh, 7, " Control", 13 + DB 13 + DB 13 + DB 0FFh, 6, " Playback", 13 + DB 13 + DB 13 + DB " Pitch Slides" + DB 0 + +DirectoryText1 DW 1 + DB 34, 40 + DB 23h + DB "Directories", 0 + +DirectoryText2 DW 1 + DB 2, 42 + DB 20h + DB 0FFh, 4, " Module", 13 + DB 0FFh, 4, " Sample", 13 + DB "Instrument", 13 + DB 0 + +DirectoryInputBox DW 0 + DB 12, 41, 78, 45 + DB 27 + +SongNameInput DW 16 + DB 17, 16 + DW 4, 4 ; Song seg, Song name + DW 26 + DD 0 + DW 0FFFFh, 15, 15, 0FFFFh + +InitialTempoInput DW 14 + DB 17, 19 + DW 31, 255 + DW 3, 33h ; Init. Tempo=Music:33h + DW 14, 16, 16, 14 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + DW 32 + +InitialSpeedInput DW 14 + DB 17, 20 + DW 1, 255 + DW 3, 32h ; Init. Tempo=Music:33h + DW 15, 17, 17, 15 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + DW 32 + +GlobalVolumeInput DW 9 + DB 17, 23 + DW 0, 128 + DW 3, 30h + DW 16, 18, 18, 16 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +MixingVolumeInput DW 9 + DB 17, 24 + DW 0, 128 + DW 3, 31h + DW 17, 19, 19, 17 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +SeparationInput DW 9 + DB 17, 25 + DW 0, 128 + DW 3, 34h + DW 18, 20, 20, 18 + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + +OldEffectsModeToggle DW 17 + DB 17, 26 + DW 2 + DW 2Ch ; Offset of 'Flags' + DB 16 + DW 19, 10, 10, 19 + +LinkCommandGToggle DW 17 + DB 17, 27 + DW 2 + DW 2Ch ; Offset of 'Flags' + DB 32 + DW 20, 22, 22, 20 + +ConfigSetupButtons DW 8 + DD DWord Ptr F_ConfigButtonSetup + +ControlInstrumentButton DW 2 + DW 10, 24, 23, 23 + DW 0 + DW 0, 0 ; Empty Data... + DW 2 ; Call Function + DD DWord Ptr F_SetControlInstrument + DW 0, 0, 0 ; Empty data... + DB 16, 29, 30, 31 + DB 8 + DB 0 + DB " Instruments", 0 + +ControlSampleButton DW 2 + DW 10, 25, 22, 22 + DW 0 + DW 0, 0 ; Empty Data... + DW 2 ; Call Function + DD DWord Ptr F_SetControlSample + DW 0, 0, 0 ; Empty data... + DB 31, 29, 45, 31 + DB 8 + DB 0 + DB " Samples", 0 + +PlayBackStereoButton DW 2 + DW 22, 26, 25, 25 + DW 0 + DW 0, 0 ; Empty Data... + DW 2 ; Call Function + DD DWord Ptr F_SetStereo + DW 0, 0, 0 ; Empty data... + DB 16, 32, 30, 34 + DB 8 + DB 0 + DB " Stereo", 0 + +PlayBackMonoButton DW 2 + DW 23, 27, 24, 24 + DW 0 + DW 0, 0 ; Empty Data... + DW 2 ; Call Function + DD DWord Ptr F_SetMono + DW 0, 0, 0 ; Empty data... + DB 31, 32, 45, 34 + DB 8 + DB 0 + DB " Mono", 0 + +SlideLinearButton DW 2 + DW 24, 28, 27, 27 + DW 0 + DW 0, 0 ; Empty Data... + DW 2 ; Call Function + DD DWord Ptr F_SetLinear + DW 0, 0, 0 ; Empty data... + DB 16, 35, 30, 37 + DB 8 + DB 0 + DB " Linear", 0 + +SlideAmigaButton DW 2 + DW 25, 28, 26, 26 + DW 0 + DW 0, 0 ; Empty Data... + DW 2 ; Call Function + DD DWord Ptr F_SetAmiga + DW 0, 0, 0 ; Empty data... + DB 31, 35, 45, 37 + DB 8 + DB 0 + DB " Amiga", 0 + + + +SongDirectoryInput DW 16 + DB 13, 42 + DW 0, Offset SongDirectory + DW 65 + DD 0 + DW 26, 29, 29, 26 + +SampleDirectoryInput DW 16 + DB 013, 43 + DW 0, Offset SampleDirectory + DW 65 + DD 0 + DW 28, 30, 30, 28 + +InstrumentDirectoryInput DW 16 + DB 13, 44 + DW 0, Offset InstrumentDirectory + DW 65 + DD 0 + DW 29, 31, 31, 29 + +SaveDirectoryConfigButton DW 2 + DW 30, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 ; Press... no data reqd + DW 2 + DD DWord Ptr D_SaveDirectoryConfiguration + DW 0, 0, 0 ; Unused data.. + DB 27, 46, 52, 48 + DB 8 ; Thin box up + DB 0 ; Button up + DB " Save all Preferences", 0 + +O1_KeyboardList DW 8 + DW Near Ptr IdleKeyboardFunctionList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr FillHeader ; 2 + DW Near Ptr KeyboardHeader ; 3 + DW Near Ptr KeyboardBox1 ; 4 + DW Near Ptr KeyboardBox2 ; 5 + DW Near Ptr KeyboardText1 ; 6 + DW Near Ptr KeyboardText2 ; 7 + DW Near Ptr KBClearTableButton ; 8 + DW Near Ptr KBDrawTables + DW Near Ptr SetHelpContext8 + DW 0 + +IdleKeyboardFunctionList DD DWord Ptr IdleUpdateInfoLine + DD DWord Ptr K_DrawTables + DD 0 + +KBDrawTables DW 8 + DD DWord Ptr K_DrawTables + +KeyboardHeader DW 10 + DB "Keyboard Information (Ctrl-F1)", 0 + +KeyboardBox1 DW 0 + DB 1, 14, 25, 47 + DB 27 + +KeyboardBox2 DW 0 + DB 28, 14, 52, 47 + DB 27 + +KeyboardText1 DW 1 + DB 2, 13 + DB 20h + DB "Keyboard Queue", 0 + +KeyboardText2 DW 1 + DB 29, 13 + DB 20h + DB "Keypress Table", 0 + +KBClearTableButton DW 2 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 2 + DD DWord Ptr K_ResetKeyboardTables + DW 0, 0, 0 + DB 53, 14, 77, 16 + DB 8 + DB 0 + DB " Clear Keyboard Tables", 0 + + +O1_InstrumentListGeneral DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr InstrumentGlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr InstrumentListHeader ; 2 + DW Near Ptr InstrumentNameBox ; 3 + DW Near Ptr InstrumentWindow ; 4 + DW Near Ptr GInstrumentGeneralButton ; 5 + DW Near Ptr GInstrumentVolumeButton ; 6 + DW Near Ptr GInstrumentPanningButton ; 7 + DW Near Ptr GInstrumentPitchButton ; 8 + DW Near Ptr InstrumentTranslateBox ; 9 + DW Near Ptr InstrumentNoteWindow ; 10 + DW Near Ptr InstrumentFileDivision + DW Near Ptr InstrumentDCTDivision + DW Near Ptr InstrumentGeneralNNAText + DW Near Ptr InstrumentGeneralDCTText + DW Near Ptr InstrumentGeneralFileNameText ; 15 + DW Near Ptr NNAButtonCut ; 16 + DW Near Ptr NNAButtonContinue ; 17 + DW Near Ptr NNAButtonOff ;18 + DW Near Ptr NNAButtonFade ; 19 + DW Near Ptr DCTButtonOff ; 20 + DW Near Ptr DCTButtonNote ; 21 + DW Near Ptr DCTButtonSample ; 22 + DW Near Ptr DCTButtonInstrument ; 23 + DW Near Ptr DCAButtonCut ; 24 + DW Near Ptr DCAButtonOff ; 25 + DW Near Ptr DCAButtonFade ; 26 + DW Near Ptr InstrumentFilenameBox ; 27 + DW Near Ptr InstrumentFilename ; 28 + DW Near Ptr InstrumentNNADivision + DW Near Ptr FillHeader + DW Near Ptr SetHelpContext7 + DW 0 + +InstrumentDCTDivision DW 1 + DB 44, 30 + DB 20h + DB 0FFh, 35, 134, 0 + +InstrumentFileDivision DW 1 + DB 44, 45 + DB 20h + DB 0FFh, 35, 154, 0 + +InstrumentNNADivision DW 1 + DB 44, 15 + DB 20h + DB 0FFh, 35, 134, 0 + +NNAButtonCut DW 2 + DW 6, 17, 10, 4 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 0 ; Set to 0 + DW 11h + DW 0 ; Unused + DB 45, 18, 77, 20, 8 + DB 0 + DB " Note Cut", 0 + +NNAButtonContinue DW 2 + DW 16, 18, 10, 4 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 1 ; Set to 1 + DW 11h + DW 0 ; Unused + DB 45, 21, 77, 23, 8 + DB 0 + DB " Continue", 0 + +NNAButtonOff DW 2 + DW 17, 19, 10, 4 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 2 + DW 11h + DW 0 ; Unused + DB 45, 24, 77, 26, 8 + DB 0 + DB " Note Off", 0 + +NNAButtonFade DW 2 + DW 18, 20, 10, 4 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 3 + DW 11h + DW 0 ; Unused + DB 45, 27, 77, 29, 8 + DB 0 + DB " Note Fade", 0 + +DCTButtonOff DW 2 + DW 19, 21, 10, 24 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 0 ; Set to 0 + DW 12h + DW 0 ; Unused + DB 45, 33, 60, 35, 8 + DB 0 + DB " Disabled", 0 + +DCTButtonNote DW 2 + DW 20, 22, 10, 25 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 1 + DW 12h + DW 0 ; Unused + DB 45, 36, 60, 38, 8 + DB 0 + DB " Note", 0 + +DCTButtonSample DW 2 + DW 21, 23, 10, 26 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 2 + DW 12h + DW 0 ; Unused + DB 45, 39, 60, 41, 8 + DB 0 + DB " Sample", 0 + +DCTButtonInstrument DW 2 + DW 22, 28, 10, 0FFFFh + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 3 + DW 12h + DW 0 ; Unused + DB 45, 42, 60, 44, 8 + DB 0 + DB " Instrument", 0 + +DCAButtonCut DW 2 + DW 19, 25, 20, 4 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 0 ; Set to 0 + DW 13h + DW 0 ; Unused + DB 61, 33, 77, 35, 8 + DB 0 + DB " Note Cut", 0 + +DCAButtonOff DW 2 + DW 24, 26, 21, 4 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 1 ; Set to 0 + DW 13h + DW 0 ; Unused + DB 61, 36, 77, 38, 8 + DB 0 + DB " Note Off", 0 + +DCAButtonFade DW 2 + DW 25, 28, 22, 4 + DW 0 + DW 0, 0 + DW 5 + DD DWord Ptr F_InstrumentButtonHandler + DW 2 ; Set to 0 + DW 13h + DW 0 ; Unused + DB 61, 39, 77, 41, 8 + DB 0 + DB " Note Fade", 0 + + +InstrumentGeneralNNAText DW 1 + DB 54, 17 + DB 20h + DB "New Note Action", 0 + +InstrumentGeneralDCTText DW 1 + DB 47, 32 + DB 20h + DB "Duplicate Check Type & Action", 0 + +InstrumentGeneralFileNameText DW 1 + DB 47, 47 + DB 20h + DB "Filename", 0 + +InstrumentFilenameBox DW 0 + DB 55, 46, 73, 48 + DB 27 + +InstrumentFileName DW 16 + DB 56, 47 + DW 6, 4 + DW 13 + DD 0 + DW 22, 0FFFFh, 4, 10 + +GInstrumentGeneralButton DW 2 + DW 0FFFFh, 10, 4, 6 + DW 0, 0, 0 + DW 6 + DD I_GetInstrumentScreen + DW 0 + DD I_SelectScreen + DB 31, 12, 41, 14 + DB 8, 0 + DB " General", 0 + +GInstrumentVolumeButton DW 2 + DW 0FFFFh, 16, 5, 7 + DW 0, 0, 0 + DW 6 + DD I_GetInstrumentScreen + DW 1 + DD I_SelectScreen + DB 43, 12, 53, 14 + DB 8, 0 + DB " Volume", 0 + +GInstrumentPanningButton DW 2 + DW 0FFFFh, 16, 6, 8 + DW 0, 0, 0 + DW 6 + DD I_GetInstrumentScreen + DW 2 + DD I_SelectScreen + DB 55, 12, 65, 14 + DB 8, 0 + DB " Panning", 0 + +GInstrumentPitchButton DW 2 + DW 0FFFFh, 16, 7, 4 + DW 0, 0, 0 + DW 6 + DD I_GetInstrumentScreen + DW 3 + DD I_SelectScreen + DB 67, 12, 77, 14 + DB 8, 0 + DB " Pitch", 0 + + +O1_InstrumentListVolume DW 4 + DW Near Ptr IdleInstrumentList + DW Near Ptr InstrumentGlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr InstrumentListHeader ; 2 + DW Near Ptr InstrumentNameBox ; 3 + DW Near Ptr InstrumentWindow ; 4 + DW Near Ptr VInstrumentGeneralButton ; 5 + DW Near Ptr VInstrumentVolumeButton ; 6 + DW Near Ptr VInstrumentPanningButton ; 7 + DW Near Ptr VInstrumentPitchButton ; 8 + DW Near Ptr InstrumentEnvelopeBox ; 9 + DW Near Ptr InstrumentEnvelope ; 10 + DW Near Ptr InstrumentVEBox ; 11 + DW Near Ptr InstrumentVELBox ; 12 + DW Near Ptr InstrumentVESLBox ; 13 + DW Near Ptr InstrumentVEText ; 14 + DW Near Ptr InstrumentVELText ; 15 + DW Near Ptr InstrumentVESLText ; 16 + DW Near Ptr InstrumentVEToggle ; 17 + DW Near Ptr InstrumentVELToggle ; 18 + DW Near Ptr InstrumentVELBeg ; 19 + DW Near Ptr InstrumentVELEnd ; 20 + DW Near Ptr InstrumentVESLToggle ; 21 + DW Near Ptr InstrumentVESLBeg ; 22 + DW Near Ptr InstrumentVESLEnd ; 23 + DW Near Ptr InstrumentGlobalVolumeBox ; 24 + DW Near Ptr InstrumentGlobalVolumeText ; 25 + DW Near Ptr InstrumentVolume2 ; 26 + DW Near Ptr InstrumentFadeOut2 ; 27 + DW Near Ptr InstrumentRandomVolBox ; 28 + DW Near Ptr InstrumentRandomVolBar ; 29 + DW Near Ptr InstrumentVECToggle ; 30 + DW Near Ptr FillHeader + DW Near Ptr SetHelpContext7 + DW 0 + +InstrumentVEBox DW 0 + DB 53, 27, 63, 30 + DB 27 + +InstrumentVEText DW 1 + DB 38, 28 + DB 20h + DB "Volume Envelope", 13 + DB " Carry", 0 + +InstrumentVEToggle DW 17 + DB 54, 28 + DW 4, 130h + DB 1 + DW 10, 30, 4, 4 + +InstrumentVECToggle DW 17 + DB 54, 29 + DW 4, 130h + DB 8 + DW 17, 18, 4, 4 + +InstrumentVELBox DW 0 + DB 53, 31, 63, 35 + DB 27 + +InstrumentVELToggle DW 17 + DB 54, 32 + DW 4, 130h + DB 2 + DW 30, 19, 4, 4 + +InstrumentVELBeg DW 13 + DB 54, 33 + DW 0, 132h + DD 0 + DW 18, 20, 4, 4 + +InstrumentVELEnd DW 13 + DB 54, 34 + DW 0, 133h + DD 0 + DW 19, 21, 4, 4 + +InstrumentVELText DW 1 + DB 40, 32 + DB 20h + DB "Envelope Loop", 13 + DB " Loop Begin", 13 + DB 0FFh, 5, " Loop End", 0 + +InstrumentVESLBox DW 0 + DB 53, 36, 63, 40 + DB 27 + +InstrumentVESLText DW 1 + DB 40, 37 + DB 20h + DB " Sustain Loop", 13 + DB "SusLoop Begin", 13 + DB " SusLoop End", 0 + +InstrumentVESLToggle DW 17 + DB 54, 37 + DW 4, 130h + DB 4 + DW 20, 22, 4, 4 + +InstrumentVESLBeg DW 13 + DB 54, 38 + DW 0, 134h + DD 0 + DW 21, 23, 4, 4 + +InstrumentVESLEnd DW 13 + DB 54, 39 + DW 0, 135h + DD 0 + DW 22, 26, 4, 4 + +InstrumentEnvelopeBox DW 0 + DB 31, 17, 77, 26 + DB 27 + +InstrumentGlobalVolumeBox DW 0 + DB 53, 41, 71, 44 + DB 27 + +InstrumentGlobalVolumeText DW 1 + DB 39, 42 + DB 20h + DB " Global Volume", 13 + DB 0FFh, 7, " Fadeout", 13 + DB 13 + DB 13 + DB "Volume Swing %", 0 + +InstrumentRandomVolBox DW 0 + DB 53, 45, 71, 47 + DB 27 + +InstrumentRandomVolBar DW 14 + DB 54, 46 + DW 0, 100 + DW 6, 1Ah + DW 27, 0FFFFh, 4, 4 + DW 0FFFFh, 0FFFFh + DW 16 + +InstrumentVolume2 DW 9 + DB 54, 42 + DW 0, 128 + DW 6, 18h + DW 23, 27, 4, 4 + DW 0FFFFh, 0FFFFh + +InstrumentFadeOut2 DW 14 + DB 54, 43 + DW 0, 256 + DW 6, 14h + DW 26, 29, 4, 4 + DW 0FFFFh, 0FFFFh + DW 16 + +InstrumentEnvelope DW 15 + DD DWord Ptr I_DrawEnvelope + DD DWord Ptr I_PreEnvelope + DD DWord Ptr I_PostEnvelope + +VInstrumentGeneralButton DW 2 + DW 0FFFFh, 10, 4, 6 + DW 0, 0, 0 + DW 6 + DD I_GetInstrumentScreen + DW 0 + DD I_SelectScreen + DB 31, 12, 41, 14 + DB 8, 0 + DB " General", 0 + +VInstrumentVolumeButton DW 2 + DW 0FFFFh, 10, 5, 7 + DW 0, 0, 0 + DW 6 + DD I_GetInstrumentScreen + DW 1 + DD I_SelectScreen + DB 43, 12, 53, 14 + DB 8, 0 + DB " Volume", 0 + +VInstrumentPanningButton DW 2 + DW 0FFFFh, 10, 6, 8 + DW 0, 0, 0 + DW 6 + DD I_GetInstrumentScreen + DW 2 + DD I_SelectScreen + DB 55, 12, 65, 14 + DB 8, 0 + DB " Panning", 0 + +VInstrumentPitchButton DW 2 + DW 0FFFFh, 10, 7, 4 + DW 0, 0, 0 + DW 6 + DD I_GetInstrumentScreen + DW 3 + DD I_SelectScreen + DB 67, 12, 77, 14 + DB 8, 0 + DB " Pitch", 0 + +O1_InstrumentListPanning DW 4 + DW Near Ptr IdleInstrumentList + DW Near Ptr InstrumentGlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr InstrumentListHeader ; 2 + DW Near Ptr InstrumentNameBox ; 3 + DW Near Ptr InstrumentWindow ; 4 + DW Near Ptr VInstrumentGeneralButton ; 5 + DW Near Ptr VInstrumentVolumeButton ; 6 + DW Near Ptr VInstrumentPanningButton ; 7 + DW Near Ptr VInstrumentPitchButton ; 8 + DW Near Ptr InstrumentEnvelopeBox ; 9 + DW Near Ptr InstrumentEnvelope ; 10 + DW Near Ptr InstrumentVEBox ; 11 + DW Near Ptr InstrumentVELBox ; 12 + DW Near Ptr InstrumentVESLBox ; 13 + DW Near Ptr InstrumentPanText ; 14 + DW Near Ptr InstrumentVELText ; 15 + DW Near Ptr InstrumentVESLText ; 16 + DW Near Ptr InstrumentPanToggle ; 17 + DW Near Ptr InstrumentPanLToggle ; 18 + DW Near Ptr InstrumentPanLBeg ; 19 + DW Near Ptr InstrumentPanLEnd ; 20 + DW Near Ptr InstrumentPanSLToggle ; 21 + DW Near Ptr InstrumentPanSLBeg ; 22 + DW Near Ptr InstrumentPanSLEnd ; 23 + DW Near Ptr InstrumentDefaultPanBox ; 24 + DW Near Ptr InstrumentDefaultPanText ; 25 + DW Near Ptr InstrumentDefaultPanToggle ; 26 + DW Near Ptr InstrumentDefaultPanValue ; 27 + DW Near Ptr InstrumentPitchPanCenter ; 28 + DW Near Ptr InstrumentPitchPanSeparation ; 29 + DW Near Ptr InstrumentPanSwing ; 30 + DW Near Ptr InstrumentPanBoxFiller + DW Near Ptr InstrumentPanCToggle ; 32 + DW Near Ptr FillHeader + DW Near Ptr SetHelpContext7 + DW 0 + +InstrumentPanBoxFiller DW 1 + DB 54, 44 + DB 2 + DB 0FFh, 9, 09Ah, 0 + +InstrumentPanText DW 1 + DB 37, 28 + DB 20h + DB "Panning Envelope", 13 + DB " Carry", 0 + +InstrumentPanToggle DW 17 + DB 54, 28 + DW 4, 182h + DB 1 + DW 10, 32, 4, 4 + +InstrumentPanCToggle DW 17 + DB 54, 29 + DW 4, 182h + DB 8 + DW 17, 18, 4, 4 + +InstrumentPanLToggle DW 17 + DB 54, 32 + DW 4, 182h + DB 2 + DW 32, 19, 4, 4 + +InstrumentPanLBeg DW 13 + DB 54, 33 + DW 0, 184h + DD 0 + DW 18, 20, 4, 4 + +InstrumentPanLEnd DW 13 + DB 54, 34 + DW 0, 185h + DD 0 + DW 19, 21, 4, 4 + +InstrumentPanSLToggle DW 17 + DB 54, 37 + DW 4, 182h + DB 4 + DW 20, 22, 4, 4 + +InstrumentPanSLBeg DW 13 + DB 54, 38 + DW 0, 186h + DD 0 + DW 21, 23, 4, 4 + +InstrumentPanSLEnd DW 13 + DB 54, 39 + DW 0, 187h + DD 0 + DW 22, 26, 4, 4 + +InstrumentDefaultPanBox DW 0 + DB 53, 41, 63, 48 + DB 27 + +InstrumentDefaultPanText DW 1 + DB 33, 42 + DB 20h + DB 0FFh, 9, " Default Pan", 13 + DB 0FFh, 11, " Pan Value", 13, 13 + DB 0FFh, 4, " Pitch-Pan Center", 13 + DB "Pitch-Pan Separation", 13 + DB 0FFh, 11, " Pan swing", 0 + +InstrumentDefaultPanToggle DW 17 + DB 54, 42 + DW 4, 19h + DB 80h + DW 23, 27, 4, 4 + +InstrumentDefaultPanValue DW 9 + DB 54, 43 + DW 0, 64 + DW 6, 19h + DW 26, 28, 4, 4 + DW 0FFFFh, 0FFFFh + +InstrumentPitchPanCenter DW 15 + DD DWord Ptr I_DrawPitchPanCenter + DD DWord Ptr I_PrePitchPanCenter + DD DWord Ptr I_PostPitchPanCenter + +InstrumentPitchPanSeparation DW 9 + DB 54, 46 + DW -32, 32 + DW 6, 16h + DW 28, 30, 4, 4 + DW 0FFFFh, 0FFFFh + +InstrumentPanSwing DW 9 + DB 54, 47 + DW 0, 64 + DW 6, 1Bh + DW 29, 0FFFFh, 4, 4 + DW 0FFFFh, 0FFFFh + +O1_InstrumentListPitch DW 4 + DW Near Ptr IdleInstrumentList + DW Near Ptr InstrumentGlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr InstrumentListHeader ; 2 + DW Near Ptr InstrumentNameBox ; 3 + DW Near Ptr InstrumentWindow ; 4 + DW Near Ptr VInstrumentGeneralButton ; 5 + DW Near Ptr VInstrumentVolumeButton ; 6 + DW Near Ptr VInstrumentPanningButton ; 7 + DW Near Ptr VInstrumentPitchButton ; 8 + DW Near Ptr InstrumentEnvelopeBox ; 9 + DW Near Ptr InstrumentEnvelope ; 10 + DW Near Ptr InstrumentVEBox ; 11 + DW Near Ptr InstrumentVELBox ; 12 + DW Near Ptr InstrumentVESLBox ; 13 + DW Near Ptr InstrumentPitchText ; 14 + DW Near Ptr InstrumentVELText ; 15 + DW Near Ptr InstrumentVESLText ; 16 + DW Near Ptr InstrumentPitchToggle ; 17 + DW Near Ptr InstrumentPitchLToggle ; 18 + DW Near Ptr InstrumentPitchLBeg ; 19 + DW Near Ptr InstrumentPitchLEnd ; 20 + DW Near Ptr InstrumentPitchSLToggle ; 21 + DW Near Ptr InstrumentPitchSLBeg ; 22 + DW Near Ptr InstrumentPitchSLEnd ; 23 + DW Near Ptr InstrumentMIDIBox1 ; 24 + DW Near Ptr InstrumentMIDIChannel ; 25 + DW Near Ptr InstrumentMIDIProgram ; 26 + DW Near Ptr InstrumentMIDIBank1 ; 27 + DW Near Ptr InstrumentMIDIBank2 ; 28 + DW Near Ptr InstrumentPitchCToggle ; 29 +IF FILTERENVELOPES + DW Near Ptr InstrumentFilterCutoff ; 30 + DW Near Ptr InstrumentFilterResonance ; 31 +ENDIF + DW Near Ptr InstrumentMIDIText + DW Near Ptr FillHeader + DW Near Ptr SetHelpContext7 + DW 0 + +InstrumentMIDIText DW 1 + DB 36, 42 + DB 20h + +IF FILTERENVELOPES + DB "Default Cutoff", 13 + DB "Default Resonance", 13 +ENDIF + DB "MIDI Channel", 13 + DB "MIDI Program", 13 + DB "MIDI Bank Low", 13 + DB "MIDI Bank High", 0 + +InstrumentPitchText DW 1 + DB 35, 28 + DB 20h + DB "Frequency Envelope", 13 + DB " Carry", 0 + +InstrumentPitchToggle DW 17 + DB 54, 28 + DW 4, 1D4h + DB 1 + DW 10, 29, 4, 4 + +InstrumentPitchCToggle DW 17 + DB 54, 29 + DW 4, 1D4h + DB 8 + DW 17, 18, 4, 4 + +InstrumentPitchLToggle DW 17 + DB 54, 32 + DW 4, 1D4h + DB 2 + DW 29, 19, 4, 4 + +InstrumentPitchLBeg DW 13 + DB 54, 33 + DW 0, 1D6h + DD 0 + DW 18, 20, 4, 4 + +InstrumentPitchLEnd DW 13 + DB 54, 34 + DW 0, 1D7h + DD 0 + DW 19, 21, 4, 4 + +InstrumentPitchSLToggle DW 17 + DB 54, 37 + DW 4, 1D4h + DB 4 + DW 20, 22, 4, 4 + +InstrumentPitchSLBeg DW 13 + DB 54, 38 + DW 0, 1D8h + DD 0 + DW 21, 23, 4, 4 + +InstrumentPitchSLEnd DW 13 + DB 54, 39 + DW 0, 1D9h + DD 0 +IF FILTERENVELOPES + DW 22, 30, 4, 4 +ELSE + DW 22, 25, 4, 4 +ENDIF + +InstrumentMIDIChannel DW 14 +IF FILTERENVELOPES + DB 54, 44 +ELSE + DB 54, 42 +ENDIF + DW 0, 17 + DW 6, 3Ch +IF FILTERENVELOPES + DW 30, 26, 4, 4 +ELSE + DW 23, 26, 4, 4 +ENDIF + + DW 0FFFFh, 0FFFFh + DW 16 + +InstrumentFilterCutoff DW 14 + DB 54, 42 + DW 0, 127 + DW 6, 3Ah + DW 23, 31, 4, 4 + DW 0FFFFh, 0FFFFh + DW 16 + +InstrumentFilterResonance DW 14 + DB 54, 43 + DW 0, 127 + DW 6, 3Bh + DW 30, 25, 4, 4 + DW 0FFFFh, 0FFFFh + DW 16 + +InstrumentMIDIProgram DW 14 +IF FILTERENVELOPES + DB 54, 45 +ELSE + DB 54, 43 +ENDIF + DW -1, 127 + DW 6, 3Dh + DW 25, 27, 4, 4 + DW 0FFFFh, 0FFFFh + DW 16 + +InstrumentMIDIBank1 DW 14 +IF FILTERENVELOPES + DB 54, 46 +ELSE + DB 54, 44 +ENDIF + DW -1, 127 + DW 6, 3Eh + DW 26, 28, 4, 4 + DW 0FFFFh, 0FFFFh + DW 16 + +InstrumentMIDIBank2 DW 14 +IF FILTERENVELOPES + DB 54, 47 +ELSE + DB 54, 45 +ENDIF + DW -1, 127 + DW 6, 3Fh + DW 27, 0FFFFh, 4, 4 + DW 0FFFFh, 0FFFFh + DW 16 + +InstrumentListHeader DW 10 + DB "Instrument List (F4)", 0 + +InstrumentNameBox DW 0 + DB 4, 12, 30, 48 + DB 27 + +InstrumentTranslateBox DW 0 + DB 31, 15, 42, 48 + DB 27 + +InstrumentMIDIBox1 DW 0 +IF FILTERENVELOPES + DB 53, 41, 71, 48 +ELSE + DB 53, 41, 71, 46 +ENDIF + DB 27 + +InstrumentWindow DW 15 + DD DWord Ptr I_DrawInstrumentWindow + DD DWord Ptr I_PreInstrumentWindow + DD DWord Ptr I_PostInstrumentWindow + +InstrumentNoteWindow DW 15 + DD DWord Ptr I_DrawNoteWindow + DD DWord Ptr I_PreNoteWindow + DD DWord Ptr I_PostNoteWindow + +InstrumentGlobalKeyList Label +IF ENABLESOLO + DB 1 + DW '`' + DD DWord Ptr Music_ToggleSoloInstrument +ENDIF + + DB 3 ; Ctrl + DW 1C9h + DD DWord Ptr I_SampleUp + + DB 3 ; Ctrl. + DW 1D1h + DD DWord Ptr I_SampleDown + + DB 0 + DW 1C9h + DD DWord Ptr I_SampleUp + + DB 0 + DW 1D1h + DD DWord Ptr I_SampleDown + + DB 1 + DW '<' + DD DWord Ptr I_DecreasePlayChannel + + DB 1 + DW '>' + DD DWord Ptr I_IncreasePlayChannel + + DB 1 + DW ',' + DD DWord Ptr I_DecreasePlayChannel + + DB 1 + DW '.' + DD DWord Ptr I_IncreasePlayChannel + + DB 1 + DW 2000h ; Alt 'D' + DD DWord Ptr I_DeleteInstrument + + DB 1 + DW 1300h ; Alt 'R' + DD DWord Ptr I_ReplaceInstrument + + DB 1 + DW 1F00h ; Alt 'S' + DD DWord Ptr I_SwapInstruments + + DB 1 + DW 1800h ; Alt 'O' + DD DWord Ptr D_SaveInstrument + + DB 1 + DW 1900h ; Alt 'P' + DD DWord Ptr I_CopyInstrument + + DB 1 + DW 1600h ; Alt 'U' + DD DWord Ptr I_UpdateInstrument + + DB 1 ; Alt 'J' + DW 2400h + DD DWord Ptr I_ScaleInstrumentVolumes + + DB 1 + DW 2D00h ; Alt 'X' + DD DWord Ptr I_ExchangeInstruments + + DB 1 + DW 3100h ; Alt 'N' + DD DWord Ptr I_ToggleMultiChannel + + DB 0 + DW 139h + DD DWord Ptr I_InstrumentListSpace + + DB 0 + DW 039h + DD DWord Ptr I_InstrumentListNoteOff + + DB 0 ; Enter... to load sample! + DW 11Ch + DD DWord Ptr Glbl_LoadInstrument + + DB 4 ; Always call function + DW 0 + DD DWord Ptr I_PlayNote + + DB 5 + DW Offset GlobalKeyList + +O1_DisplayList DW 4 + DW Near Ptr InfoPageIdleList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr FillHeader ; 2 + DW Near Ptr DisplayHeader ; 3 + DW Near Ptr DisplayObject ; 4 + DW Near Ptr SetHelpContext9 + DW 0 + +O1_FullDisplayList DW 1 + DW Near Ptr InfoPageIdleList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr DisplayObject ; 1 + DW Near Ptr SetHelpContext9 + DW 0 + +InfoPageIdleList Label DWord + DD DWord Ptr DisplayUpdateScreen + DD 0 + +DisplayHeader DW 10 + DB "Info Page (F5)", 0 + +DisplayObject DW 15 + DD DWord Ptr DrawDisplayData + DD DWord Ptr F_Nothing + DD DWord Ptr PostDisplayData + +O1_ThumbStringList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESC&ReturnList + DW Near Ptr ThumbBox + DW Near Ptr ThumbInputText + DW Near Ptr ThumbInputBox + DW Near Ptr ThumbInput + DW 0 + +ThumbBox DW 0 + DB 29, 24, 50, 28 + DB 3 + +ThumbInputText DW 1 + DB 32, 26 + DB 23h + DB "Enter Value", 0 + +ThumbInputBox DW 0 + DB 43, 25, 48, 27 + DB 27 + +ThumbInput DW 16 + DB 44, 26 + DW 5, Offset ThumbStringEnter + DW 4 + DD 0 ; No function + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +O1_NewSongList DW 11 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr NewSongBox ; 0 + DW Near Ptr NewSongText ; 1 + DW Near Ptr NewSongText2 ; 2 + DW Near Ptr KeepPatternButton ; 3 + DW Near Ptr ClearPatternButton ; 4 + DW Near Ptr KeepSampleButton ; 5 + DW Near Ptr ClearSampleButton ; 6 + DW Near Ptr KeepInstrumentButton ; 7 + DW Near Ptr ClearInstrumentButton ; 8 + DW Near Ptr KeepOrderListButton ; 9 + DW Near Ptr ClearOrderListButton ; 10 + DW Near Ptr NewSongOKButton ; 11 + DW Near Ptr NewSongCancelButton ; 12 + + DW 0 + +NewSongBox DW 0 + DB 21, 20, 58, 38 + DB 3 + +NewSongText DW 1 + DB 36, 21 + DB 23h + DB "New Song", 0 + +NewSongText2 DW 1 + DB 23, 24 + DB 20h + DB " Patterns", 13 + DB 13 + DB 13 + DB 0FFh, 4, " Samples", 13 + DB 13 + DB 13 + DB "Instruments", 13 + DB 13 + DB 13 + DB " Order List", 0 + +KeepPatternButton DW 2 + DW 0FFFFh, 5, 4, 4 + DW 2 + DW 3, 4 + DW 3 ; Set var! + DW 3, 0 + DW 0, 0, 0 + DB 34, 23, 43, 25 + DB 8 + DB 0 + DB " Keep", 0 + +ClearPatternButton DW 2 + DW 4, 6, 3, 3 + DW 2 + DW 3, 4 + DW 3 + DW 3, 1 ; Clear pattern flag + DW 0, 0, 0 + DB 44, 23, 54, 25 + DB 8 + DB 3 ; Default to down + DB " Clear", 0 + +KeepSampleButton DW 2 + DW 3, 7, 6, 6 + DW 2 + DW 5, 6 + DW 3 ; Set var! + DW 4, 0 + DW 0, 0, 0 + DB 34, 26, 43, 28 + DB 8 + DB 0 + DB " Keep", 0 + +ClearSampleButton DW 2 + DW 4, 8, 5, 5 + DW 2 + DW 5, 6 + DW 3 + DW 4, 1 ; Clear pattern flag + DW 0, 0, 0 + DB 44, 26, 54, 28 + DB 8 + DB 3 ; Default to down + DB " Clear", 0 + +KeepInstrumentButton DW 2 + DW 5, 9, 8, 8 + DW 2 + DW 7, 8 + DW 3 ; Set var! + DW 5, 0 + DW 0, 0, 0 + DB 34, 29, 43, 31 + DB 8 + DB 0 + DB " Keep", 0 + +ClearInstrumentButton DW 2 + DW 6, 10, 7, 7 + DW 2 + DW 7, 8 + DW 3 + DW 5, 1 ; Clear pattern flag + DW 0, 0, 0 + DB 44, 29, 54, 31 + DB 8 + DB 3 ; Default to down + DB " Clear", 0 + +KeepOrderListButton DW 2 + DW 7, 11, 10, 10 + DW 2 + DW 9, 10 + DW 3 ; Set var! + DW 6, 0 + DW 0, 0, 0 + DB 34, 32, 43, 34 + DB 8 + DB 0 + DB " Keep", 0 + +ClearOrderListButton DW 2 + DW 8, 12, 9, 9 + DW 2 + DW 9, 10 + DW 3 + DW 6, 1 ; Clear pattern flag + DW 0, 0, 0 + DB 44, 32, 54, 34 + DB 8 + DB 3 ; Default to down + DB " Clear", 0 + +NewSongOKButton DW 2 + DW 9, 0FFFFh, 12, 12 + DW 0 ; Press. + DW 0, 0 + DW 0 ; Return value. + DW 1 ; Return OK. + DW 0, 0, 0, 0 + DB 27, 35, 38, 37 + DB 8 + DB 0 + DB " OK", 0 + +NewSongCancelButton DW 2 + DW 9, 0FFFFh, 11, 11 + DW 0 + DW 0, 0 + DW 0 + DW 0 + DW 0, 0, 0, 0 + DB 40, 35, 51, 37 + DB 8 + DB 0 + DB " Cancel", 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +O1_MainMenu DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr MainMenuBox1 ; 0 + DW Near Ptr MainMenuBox2 ; 1 + DW Near Ptr MainMenuText ; 2 + DW Near Ptr MainMenuFile ; 3 + DW Near Ptr MainMenuPlayBack ; 4 + DW Near Ptr MainMenuViewPatterns ; 5 + DW Near Ptr MainMenuViewSamples ; 6 + DW Near Ptr MainMenuViewInstruments; 7 + DW Near Ptr MainMenuViewOrderPan ; 8 + DW Near Ptr MainMenuViewVariables ; 9 + DW Near Ptr MainMenuMessage + DW Near Ptr MainMenuHelp ; 11 + + DW 0 + +MainMenuBox1 DW 0 + DB 6, 14, 38, 46 + DB 3 + +MainMenuBox2 DW 0 + DB 7, 15, 37, 45 + DB 0 + +MainMenuText DW 1 + DB 12, 16 + DB 23h + DB "Main Menu", 0 + +MainMenuFile DW 2 + DW 0FFFFh, 4, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 2 + DD DWord Ptr F_FileMenu + DW 0, 0, 0 + DB 8, 18, 36, 20 + DB 28 + DB 0 + DB " File Menu...", 0 + +MainMenuPlayBack DW 2 + DW 3, 5, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 2 + DD DWord Ptr F_PlayBackMenu + DW 0, 0, 0 + DB 8, 21, 36, 23 + DB 28 + DB 0 + DB " Playback Menu...", 0 + +MainMenuViewPatterns DW 2 + DW 4, 6, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 ; Jump to function + DD DWord Ptr F_ViewPattern + DW 0, 0, 0 + DB 8, 24, 36, 26 + DB 28 + DB 0 + DB " View Patterns (F2)", 0 + +MainMenuViewSamples DW 2 + DW 5, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 2 + DD DWord Ptr F_SampleMenu + DW 0, 0, 0 + DB 8, 27, 36, 29 + DB 28 + DB 0 + DB " Sample Menu...", 0 + +MainMenuViewInstruments DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 2 + DD DWord Ptr F_InstrumentMenu + DW 0, 0, 0 + DB 8, 30, 36, 32 + DB 28 + DB 0 + DB " Instrument Menu...", 0 + +MainMenuViewOrderPan DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_ViewOrderPan + DW 0, 0, 0 + DB 8, 33, 36, 35 + DB 28 + DB 0 + DB " View Orders/Panning (F11)", 0 + +MainMenuViewVariables DW 2 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_ViewVariables + DW 0, 0, 0 + DB 8, 36, 36, 38 + DB 28 + DB 0 + DB " View Variables (F12)", 0 + +MainMenuMessage DW 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_MessageEditor + DW 0, 0, 0 + DB 8, 39, 36, 41 + DB 28 + DB 0 + DB " Message Editor (Shift-F9)", 0 + +MainMenuHelp DW 2 + DW 10, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_Help + DW 0, 0, 0 + DB 8, 42, 36, 44 + DB 28 + DB 0 + DB " Help! (F1)", 0 + +O1_FileMenu DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr FileBox1 ; 0 + DW Near Ptr FileBox2 ; 1 + DW Near Ptr FileMenuText ; 2 + DW Near Ptr FileLoad ; 3 + DW Near Ptr FileNew + DW Near Ptr FileSaveCurrent + DW Near Ptr FileSaveAs + DW Near Ptr FileDOSShell + DW Near Ptr FileQuit + DW 0 + +FileBox1 DW 0 + DB 25, 16, 54, 39 + DB 1 + +FileBox2 DW 0 + DB 26, 17, 53, 38 + DB 0 + +FileMenuText DW 1 + DB 30, 18 + DB 23h + DB "File Menu", 0 + +FileLoad DW 2 + DW 0FFFFh, 4, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_FileLoad + DW 0, 0, 0 + DB 27, 20, 52, 22 + DB 28 + DB 0 + DB " Load... (F9)", 0 + +FileNew DW 2 + DW 3, 5, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_FileNew + DW 0, 0, 0 + DB 27, 23, 52, 25 + DB 28 + DB 0 + DB " New... (Ctrl-N)", 0 + +FileSaveCurrent DW 2 + DW 4, 6, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_FileSaveCurrent + DW 0, 0, 0 + DB 27, 26, 52, 28 + DB 28 + DB 0 + DB " Save Current (Ctrl-S)", 0 + +FileSaveAs DW 2 + DW 5, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_FileSaveAs + DW 0, 0, 0 + DB 27, 29, 52, 31 + DB 28 + DB 0 + DB " Save As... (F10)", 0 + +FileDOSShell DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_FileDOSShell + DW 0, 0, 0 + DB 27, 32, 52, 34 + DB 28 + DB 0 + DB " Shell to DOS (Ctrl-D)", 0 + +FileQuit DW 2 + DW 7, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_FileQuit + DW 0, 0, 0 + DB 27, 35, 52, 37 + DB 28 + DB 0 + DB " Quit (Ctrl-Q)", 0 + +O1_PlayBackMenu DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr PlayBackBox1 ; 0 + DW Near Ptr PlayBackBox2 ; 1 + DW Near Ptr PlayBackText ; 2 + DW Near Ptr PlayBackShowInfoPage ; 3 + DW Near Ptr PlayBackSong ; 4 + DW Near Ptr PlayBackPattern ; 5 + DW Near Ptr PlayBackOrder ; 6 + DW Near Ptr PlayBackMark ; 7 + DW Near Ptr PlayBackStop ; 8 + DW Near Ptr PlayBackReinit ; 9 + DW Near Ptr PlayBackDriverScreen ; 10 + DW Near Ptr PlayBackCalculateLength ; 11 + DW 0 + +PlayBackBox1 DW 0 + DB 25, 16, 59, 48 + DB 1 + +PlayBackBox2 DW 0 + DB 26, 17, 58, 47 + DB 0 + +PlayBackText DW 1 + DB 31, 18 + DB 23h + DB "Playback Menu", 0 + +PlayBackShowInfoPage DW 2 + DW 0FFFFh, 4, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_InfoPage + DW 0, 0, 0 + DB 27, 20, 57, 22 + DB 28 + DB 0 + DB " Show Infopage (F5)", 0 + +PlayBackSong DW 2 + DW 3, 5, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_PlaySong + DW 0, 0, 0 + DB 27, 23, 57, 25 + DB 28 + DB 0 + DB " Play Song (Ctrl-F5)", 0 + +PlayBackPattern DW 2 + DW 4, 6, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_PlayPattern + DW 0, 0, 0 + DB 27, 26, 57, 28 + DB 28 + DB 0 + DB " Play Pattern (F6)", 0 + +PlayBackOrder DW 2 + DW 5, 7, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_PlayOrder + DW 0, 0, 0 + DB 27, 29, 57, 31 + DB 28 + DB 0 + DB " Play from Order (Shift-F6)", 0 + +PlayBackMark DW 2 + DW 6, 8, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_PlayMark + DW 0, 0, 0 + DB 27, 32, 57, 34 + DB 28 + DB 0 + DB " Play from Mark/Cursor (F7)", 0 + +PlayBackStop DW 2 + DW 7, 9, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_Stop + DW 0, 0, 0 + DB 27, 35, 57, 37 + DB 28 + DB 0 + DB " Stop (F8)", 0 + +PlayBackReinit DW 2 + DW 8, 10, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_ReinitSoundCard + DW 0, 0, 0 + DB 27, 38, 57, 40 + DB 28 + DB 0 + DB " Reinit Soundcard (Ctrl-I)", 0 + +PlayBackDriverScreen DW 2 + DW 9, 11, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_DriverScreen + DW 0, 0, 0 + DB 27, 41, 57, 43 + DB 28 + DB 0 + DB " Driver Screen (Shift-F5)", 0 + +PlayBackCalculateLength DW 2 + DW 10, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_CalculateLength + DW 0, 0, 0 + DB 27, 44, 57, 46 + DB 28 + DB 0 + DB " Calculate Length (Ctrl-P)", 0 + + +O1_SampleMenu DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr SampleBox1 ; 0 + DW Near Ptr SampleBox2 ; 1 + DW Near Ptr SampleText ; 2 + DW Near Ptr SampleMenuList ; 3 + DW Near Ptr SampleLibrary ; 4 + DW Near Ptr ReloadGravis ; 5 + + DW 0 + +SampleBox1 DW 0 + DB 25, 23, 57, 37 + DB 1 + + +SampleBox2 DW 0 + DB 26, 24, 56, 36 + DB 0 + +SampleText DW 1 + DB 30, 25 + DB 23h + DB "Sample Menu", 0 + +SampleMenuList DW 2 + DW 0FFFFh, 4, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_SampleList + DW 0, 0, 0 + DB 27, 27, 55, 29 + DB 28 + DB 0 + DB " Sample List (F3)", 0 + +SampleLibrary DW 2 + DW 3, 5, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_SampleLibrary + DW 0, 0, 0 + DB 27, 30, 55, 32 + DB 28 + DB 0 + DB " Sample Library (Ctrl-F3)", 0 + +ReloadGravis DW 2 + DW 4, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_ReloadGravis + DW 0, 0, 0 + DB 27, 33, 55, 35 + DB 28 + DB 0 + DB " Reload Soundcard (Ctrl-G)", 0 + +O1_InstrumentMenu DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCReturnList + DW Near Ptr InstrumentBox1 ; 0 + DW Near Ptr InstrumentBox2 ; 1 + DW Near Ptr InstrumentText ; 2 + DW Near Ptr InstrumentMenuList ; 3 + DW Near Ptr InstrumentLibrary ; 4 + DW 0 + +InstrumentBox1 DW 0 + DB 20, 23, 56, 34 + DB 1 + + +InstrumentBox2 DW 0 + DB 21, 24, 55, 33 + DB 0 + +InstrumentText DW 1 + DB 25, 25 + DB 23h + DB "Instrument Menu", 0 + +InstrumentMenuList DW 2 + DW 0FFFFh, 4, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_InstrumentList + DW 0, 0, 0 + DB 22, 27, 54, 29 + DB 28 + DB 0 + DB " Instrument List (F4)", 0 + +InstrumentLibrary DW 2 + DW 3, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 4 + DD DWord Ptr F_InstrumentLibrary + DW 0, 0, 0 + DB 22, 30, 54, 32 + DB 28 + DB 0 + DB " Instrument Library (Ctrl-F4)", 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +O1_EditSampleName DW 3 + DW IdleFunctionList + DW ESCReturnList + DW EditSampleNameBox ; 0 + DW EditSampleNameText ; 1 + DW EditSampleNameInputBox ; 2 + DW EditSampleNameInput ;3 + DW 0 + +EditSampleNameBox DW 0 + DB 23, 25, 56, 31 + DB 3 + +EditSampleNameText DW 1 + DB 32, 26 + DB 23h + DB "Edit Sample Name", 0 + +EditSampleNameInputBox DW 0 + DB 26, 28, 53, 30 + DB 27 + +EditSampleNameInput DW 16 + DB 27, 29 + DW 0, Offset SampleName + DW 26 + DD DWord Ptr F_Return1 + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF MEMORYDEBUG + +O1_DebugList DW 5 + DW Near Ptr IdleDebugFunctionList + DW Near Ptr DebugKeyList + DW Near Ptr FullScreenBox + DW Near Ptr ScreenHeader + DW Near Ptr DebugBox + DW Near Ptr DebugText + DW Near Ptr DebugInputBox + DW Near Ptr DebugAddressInput + DW Near Ptr DebugInfo + DW Near Ptr FillHeader + DW Near Ptr DebugHeader + DW 0 + + +DebugInfo DW 8 +IdleDebugFunctionList DD DWord Ptr F_DrawDebug + DD DWord Ptr IdleUpdateInfoLine + DD 0 + +DebugKeyList Label + DB 4 + DW 0 + DD DWord Ptr F_PostDebug + + DB 0 + DW 1C8h + DD DWord Ptr F_DebugUp + + DB 0 + DW 1D0h + DD DWord Ptr F_DebugDown + + DB 0 + DW 1C9h + DD DWord Ptr F_DebugPgUp + + DB 0 + DW 1D1h + DD DWord Ptr F_DebugPgDn + + DB 5 + DW Offset GlobalKeyList + + +DebugBox DW 0 + DB 1, 14, 78, 45 + DB 27 + +DebugText DW 1 + DB 4, 47 + DB 20h + DB "Address", 0 + +DebugInputBox DW 0 + DB 11, 46, 30, 48 + DB 25 + +DebugAddressInput DW 16 + DB 12, 47 + DW 5, Offset AddressInput + DW 18 + DD DWord Ptr F_DebugStringInput + DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +DebugHeader DW 10 + DB "Debug", 0 + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +O1_ConfigurePaletteList DW 53 + DW IdleFunctionList + DW GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr FillHeader ; 2 + DW Near Ptr ConfigurePaletteHeader ; 3 + DW Near Ptr SetHelpContext10 + DW Near Ptr PaletteColourBorder1 + DW Near Ptr PaletteColourBorder2 + DW Near Ptr PaletteColourBorder3 + DW Near Ptr PaletteColourBorder4 + DW Near Ptr PaletteColourBorder5 + DW Near Ptr PaletteColourBorder6 ; 10 + DW Near Ptr PaletteColourBorder7 + DW Near Ptr PaletteColourBorder8 + DW Near Ptr PaletteColourBorder9 + DW Near Ptr PaletteColourBorder10 + DW Near Ptr PaletteColourBorder11 + DW Near Ptr PaletteColourBorder12 + DW Near Ptr PaletteColourBorder13 + DW Near Ptr PaletteColourBorder14 + DW Near Ptr PaletteColourBorder15 + DW Near Ptr PaletteColourBorder16 ; 20 + DW Near Ptr PaletteColourBox1 + DW Near Ptr PaletteColourBox2 + DW Near Ptr PaletteColourBox3 + DW Near Ptr PaletteColourBox4 + DW Near Ptr PaletteColourBox5 + DW Near Ptr PaletteColourBox6 + DW Near Ptr PaletteColourBox7 + DW Near Ptr PaletteColourBox8 + DW Near Ptr PaletteColourBox9 + DW Near Ptr PaletteColourBox10 ; 30 + DW Near Ptr PaletteColourBox11 + DW Near Ptr PaletteColourBox12 + DW Near Ptr PaletteColourBox13 + DW Near Ptr PaletteColourBox14 + DW Near Ptr PaletteColourBox15 + DW Near Ptr PaletteColourBox16 + DW Near Ptr PaletteInputBox1 + DW Near Ptr PaletteInputBox2 + DW Near Ptr PaletteInputBox3 + DW Near Ptr PaletteInputBox4 ; 40 + DW Near Ptr PaletteInputBox5 + DW Near Ptr PaletteInputBox6 + DW Near Ptr PaletteInputBox7 + DW Near Ptr PaletteInputBox8 + DW Near Ptr PaletteInputBox9 + DW Near Ptr PaletteInputBox10 + DW Near Ptr PaletteInputBox11 + DW Near Ptr PaletteInputBox12 + DW Near Ptr PaletteInputBox13 + DW Near Ptr PaletteInputBox14 ; 50 + DW Near Ptr PaletteInputBox15 + DW Near Ptr PaletteInputBox16 + DW Near Ptr Colour0RedInput ; 53 + DW Near Ptr Colour0GreenInput + DW Near Ptr Colour0BlueInput + DW Near Ptr Colour1RedInput ; 56 + DW Near Ptr Colour1GreenInput + DW Near Ptr Colour1BlueInput + DW Near Ptr Colour2RedInput + DW Near Ptr Colour2GreenInput ; 60 + DW Near Ptr Colour2BlueInput + DW Near Ptr Colour3RedInput + DW Near Ptr Colour3GreenInput + DW Near Ptr Colour3BlueInput + DW Near Ptr Colour4RedInput + DW Near Ptr Colour4GreenInput + DW Near Ptr Colour4BlueInput + DW Near Ptr Colour5RedInput + DW Near Ptr Colour5GreenInput + DW Near Ptr Colour5BlueInput ; 70 + DW Near Ptr Colour6RedInput + DW Near Ptr Colour6GreenInput + DW Near Ptr Colour6BlueInput + DW Near Ptr Colour7RedInput ; 74 + DW Near Ptr Colour7GreenInput + DW Near Ptr Colour7BlueInput + DW Near Ptr Colour8RedInput + DW Near Ptr Colour8GreenInput + DW Near Ptr Colour8BlueInput + DW Near Ptr Colour9RedInput ; 80 + DW Near Ptr Colour9GreenInput + DW Near Ptr Colour9BlueInput + DW Near Ptr Colour10RedInput + DW Near Ptr Colour10GreenInput + DW Near Ptr Colour10BlueInput + DW Near Ptr Colour11RedInput + DW Near Ptr Colour11GreenInput + DW Near Ptr Colour11BlueInput + DW Near Ptr Colour12RedInput + DW Near Ptr Colour12GreenInput ; 90 + DW Near Ptr Colour12BlueInput + DW Near Ptr Colour13RedInput + DW Near Ptr Colour13GreenInput + DW Near Ptr Colour13BlueInput + DW Near Ptr Colour14RedInput + DW Near Ptr Colour14GreenInput + DW Near Ptr Colour14BlueInput + DW Near Ptr Colour15RedInput + DW Near Ptr Colour15GreenInput + DW Near Ptr Colour15BlueInput ; 100 + DW Near Ptr PredefinedPaletteMsg + DW Near Ptr PredefinedPalette1 + DW Near Ptr PredefinedPalette2 + DW Near Ptr PredefinedPalette3 + DW Near Ptr PredefinedPalette4 + DW Near Ptr PredefinedPalette5 + DW Near Ptr PredefinedPalette6 + DW Near Ptr PredefinedPalette7 + DW 0 + +ConfigurePaletteHeader DW 10 + DB "Palette Configuration (Ctrl-F12)", 0 + +PaletteColourBorder1 DW 0 + DB 2, 13, 8, 17 + DB 11 + +PaletteColourBorder2 DW 0 + DB 2, 18, 8, 22 + DB 11 + +PaletteColourBorder3 DW 0 + DB 2, 23, 8, 27 + DB 11 + +PaletteColourBorder4 DW 0 + DB 2, 28, 8, 32 + DB 11 + +PaletteColourBorder5 DW 0 + DB 2, 33, 8, 37 + DB 11 + +PaletteColourBorder6 DW 0 + DB 2, 38, 8, 42 + DB 11 + +PaletteColourBorder7 DW 0 + DB 2, 43, 8, 47 + DB 11 + +PaletteColourBorder8 DW 0 + DB 29, 13, 35, 17 + DB 11 + +PaletteColourBorder9 DW 0 + DB 29, 18, 35, 22 + DB 11 + +PaletteColourBorder10 DW 0 + DB 29, 23, 35, 27 + DB 11 + +PaletteColourBorder11 DW 0 + DB 29, 28, 35, 32 + DB 11 + +PaletteColourBorder12 DW 0 + DB 29, 33, 35, 37 + DB 11 + +PaletteColourBorder13 DW 0 + DB 29, 38, 35, 42 + DB 11 + +PaletteColourBorder14 DW 0 + DB 29, 43, 35, 47 + DB 11 + +PaletteColourBorder15 DW 0 + DB 56, 13, 62, 17 + DB 11 + +PaletteColourBorder16 DW 0 + DB 56, 18, 62, 22 + DB 11 + +PaletteColourBox1 DW 1 + DB 3, 14 + DB 00h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox2 DW 1 + DB 3, 19 + DB 10h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox3 DW 1 + DB 3, 24 + DB 20h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox4 DW 1 + DB 3, 29 + DB 30h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox5 DW 1 + DB 3, 34 + DB 40h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox6 DW 1 + DB 3, 39 + DB 50h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox7 DW 1 + DB 3, 44 + DB 60h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox8 DW 1 + DB 30, 14 + DB 70h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox9 DW 1 + DB 30, 19 + DB 80h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox10 DW 1 + DB 30, 24 + DB 90h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox11 DW 1 + DB 30, 29 + DB 0A0h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox12 DW 1 + DB 30, 34 + DB 0B0h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox13 DW 1 + DB 30, 39 + DB 0C0h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox14 DW 1 + DB 30, 44 + DB 0D0h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox15 DW 1 + DB 57, 14 + DB 0E0h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteColourBox16 DW 1 + DB 57, 19 + DB 0F0h + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 13 + DB 0FFh, 5, " ", 0 + +PaletteInputBox1 DW 0 + DB 9, 13, 19, 17 + DB 27 + +PaletteInputBox2 DW 0 + DB 9, 18, 19, 22 + DB 27 + +PaletteInputBox3 DW 0 + DB 9, 23, 19, 27 + DB 27 + +PaletteInputBox4 DW 0 + DB 9, 28, 19, 32 + DB 27 + +PaletteInputBox5 DW 0 + DB 9, 33, 19, 37 + DB 27 + +PaletteInputBox6 DW 0 + DB 9, 38, 19, 42 + DB 27 + +PaletteInputBox7 DW 0 + DB 9, 43, 19, 47 + DB 27 + +PaletteInputBox8 DW 0 + DB 36, 13, 46, 17 + DB 27 + +PaletteInputBox9 DW 0 + DB 36, 18, 46, 22 + DB 27 + +PaletteInputBox10 DW 0 + DB 36, 23, 46, 27 + DB 27 + +PaletteInputBox11 DW 0 + DB 36, 28, 46, 32 + DB 27 + +PaletteInputBox12 DW 0 + DB 36, 33, 46, 37 + DB 27 + +PaletteInputBox13 DW 0 + DB 36, 38, 46, 42 + DB 27 + +PaletteInputBox14 DW 0 + DB 36, 43, 46, 47 + DB 27 + +PaletteInputBox15 DW 0 + DB 63, 13, 73, 17 + DB 27 + +PaletteInputBox16 DW 0 + DB 63, 18, 73, 22 + DB 27 + +Colour0RedInput DW 9 + DB 10, 14 + DW 0, 63 + DW 7, Offset PaletteDefs + DW 0FFFFh, 54, 74, 95, 0FFFFh, 56 + +Colour0GreenInput DW 9 + DB 10, 15 + DW 0, 63 + DW 7, Offset PaletteDefs+1 + DW 53, 55, 75, 96, 0FFFFh, 57 + +Colour0BlueInput DW 9 + DB 10, 16 + DW 0, 63 + DW 7, Offset PaletteDefs+2 + DW 54, 56, 76, 97, 0FFFFh, 58 + +Colour1RedInput DW 9 + DB 10, 19 + DW 0, 63 + DW 7, Offset PaletteDefs+3 + DW 55, 57, 77, 98, 53, 59 + +Colour1GreenInput DW 9 + DB 10, 20 + DW 0, 63 + DW 7, Offset PaletteDefs+4 + DW 56, 58, 78, 99, 54, 60 + +Colour1BlueInput DW 9 + DB 10, 21 + DW 0, 63 + DW 7, Offset PaletteDefs+5 + DW 57, 59, 79, 100, 55, 61 + +Colour2RedInput DW 9 + DB 10, 24 + DW 0, 63 + DW 7, Offset PaletteDefs+6 + DW 58, 60, 80, 0FFFFh, 56, 62 + +Colour2GreenInput DW 9 + DB 10, 25 + DW 0, 63 + DW 7, Offset PaletteDefs+7 + DW 59, 61, 81, 0FFFFh, 57, 63 + +Colour2BlueInput DW 9 + DB 10, 26 + DW 0, 63 + DW 7, Offset PaletteDefs+8 + DW 60, 62, 82, 0FFFFh, 58, 64 + +Colour3RedInput DW 9 + DB 10, 29 + DW 0, 63 + DW 7, Offset PaletteDefs+9 + DW 61, 63, 83, 0FFFFh, 59, 65 + +Colour3GreenInput DW 9 + DB 10, 30 + DW 0, 63 + DW 7, Offset PaletteDefs+10 + DW 62, 64, 84, 0FFFFh, 60, 66 + +Colour3BlueInput DW 9 + DB 10, 31 + DW 0, 63 + DW 7, Offset PaletteDefs+11 + DW 63, 65, 85, 0FFFFh, 61, 67 + +Colour4RedInput DW 9 + DB 10, 34 + DW 0, 63 + DW 7, Offset PaletteDefs+12 + DW 64, 66, 86, 0FFFFh, 62, 68 + +Colour4GreenInput DW 9 + DB 10, 35 + DW 0, 63 + DW 7, Offset PaletteDefs+13 + DW 65, 67, 87, 0FFFFh, 63, 69 + +Colour4BlueInput DW 9 + DB 10, 36 + DW 0, 63 + DW 7, Offset PaletteDefs+14 + DW 66, 68, 88, 0FFFFh, 64, 70 + +Colour5RedInput DW 9 + DB 10, 39 + DW 0, 63 + DW 7, Offset PaletteDefs+15 + DW 67, 69, 89, 0FFFFh, 65, 71 + +Colour5GreenInput DW 9 + DB 10, 40 + DW 0, 63 + DW 7, Offset PaletteDefs+16 + DW 68, 70, 90, 0FFFFh, 66, 72 + +Colour5BlueInput DW 9 + DB 10, 41 + DW 0, 63 + DW 7, Offset PaletteDefs+17 + DW 69, 71, 91, 0FFFFh, 67, 73 + +Colour6RedInput DW 9 + DB 10, 44 + DW 0, 63 + DW 7, Offset PaletteDefs+18 + DW 70, 72, 92, 0FFFFh, 68, 74 + +Colour6GreenInput DW 9 + DB 10, 45 + DW 0, 63 + DW 7, Offset PaletteDefs+19 + DW 71, 73, 93, 0FFFFh, 69, 75 + +Colour6BlueInput DW 9 + DB 10, 46 + DW 0, 63 + DW 7, Offset PaletteDefs+20 + DW 72, 74, 94, 0FFFFh, 70, 76 + +Colour7RedInput DW 9 + DB 37, 14 + DW 0, 63 + DW 7, Offset PaletteDefs+21 + DW 73, 75, 95, 53, 71, 77 + +Colour7GreenInput DW 9 + DB 37, 15 + DW 0, 63 + DW 7, Offset PaletteDefs+22 + DW 74, 76, 96, 54, 72, 78 + +Colour7BlueInput DW 9 + DB 37, 16 + DW 0, 63 + DW 7, Offset PaletteDefs+23 + DW 75, 77, 97, 55, 73, 79 + +Colour8RedInput DW 9 + DB 37, 19 + DW 0, 63 + DW 7, Offset PaletteDefs+24 + DW 76, 78, 98, 56, 74, 80 + +Colour8GreenInput DW 9 + DB 37, 20 + DW 0, 63 + DW 7, Offset PaletteDefs+25 + DW 77, 79, 99, 57, 75, 81 + +Colour8BlueInput DW 9 + DB 37, 21 + DW 0, 63 + DW 7, Offset PaletteDefs+26 + DW 78, 80, 100, 58, 76, 82 + +Colour9RedInput DW 9 + DB 37, 24 + DW 0, 63 + DW 7, Offset PaletteDefs+27 + DW 79, 81, 102, 59, 77, 83 + +Colour9GreenInput DW 9 + DB 37, 25 + DW 0, 63 + DW 7, Offset PaletteDefs+28 + DW 80, 82, 102, 60, 78, 84 + +Colour9BlueInput DW 9 + DB 37, 26 + DW 0, 63 + DW 7, Offset PaletteDefs+29 + DW 81, 83, 102, 61, 79, 85 + +Colour10RedInput DW 9 + DB 37, 29 + DW 0, 63 + DW 7, Offset PaletteDefs+30 + DW 82, 84, 102, 62, 80, 86 + +Colour10GreenInput DW 9 + DB 37, 30 + DW 0, 63 + DW 7, Offset PaletteDefs+31 + DW 83, 85, 102, 63, 81, 87 + +Colour10BlueInput DW 9 + DB 37, 31 + DW 0, 63 + DW 7, Offset PaletteDefs+32 + DW 84, 86, 102, 64, 82, 88 + +Colour11RedInput DW 9 + DB 37, 34 + DW 0, 63 + DW 7, Offset PaletteDefs+33 + DW 85, 87, 102, 65, 83, 89 + +Colour11GreenInput DW 9 + DB 37, 35 + DW 0, 63 + DW 7, Offset PaletteDefs+34 + DW 86, 88, 102, 66, 84, 90 + +Colour11BlueInput DW 9 + DB 37, 36 + DW 0, 63 + DW 7, Offset PaletteDefs+35 + DW 87, 89, 102, 67, 85, 91 + +Colour12RedInput DW 9 + DB 37, 39 + DW 0, 63 + DW 7, Offset PaletteDefs+36 + DW 88, 90, 102, 68, 86, 92 + +Colour12GreenInput DW 9 + DB 37, 40 + DW 0, 63 + DW 7, Offset PaletteDefs+37 + DW 89, 91, 102, 69, 87, 93 + +Colour12BlueInput DW 9 + DB 37, 41 + DW 0, 63 + DW 7, Offset PaletteDefs+38 + DW 90, 92, 102, 70, 88, 94 + +Colour13RedInput DW 9 + DB 37, 44 + DW 0, 63 + DW 7, Offset PaletteDefs+39 + DW 91, 93, 102, 71, 89, 95 + +Colour13GreenInput DW 9 + DB 37, 45 + DW 0, 63 + DW 7, Offset PaletteDefs+40 + DW 92, 94, 102, 72, 90, 96 + +Colour13BlueInput DW 9 + DB 37, 46 + DW 0, 63 + DW 7, Offset PaletteDefs+41 + DW 93, 95, 102, 73, 91, 97 + +Colour14RedInput DW 9 + DB 64, 14 + DW 0, 63 + DW 7, Offset PaletteDefs+42 + DW 94, 96, 53, 74, 92, 98 + +Colour14GreenInput DW 9 + DB 64, 15 + DW 0, 63 + DW 7, Offset PaletteDefs+43 + DW 95, 97, 54, 75, 93, 99 + +Colour14BlueInput DW 9 + DB 64, 16 + DW 0, 63 + DW 7, Offset PaletteDefs+44 + DW 96, 98, 55, 76, 94, 100 + +Colour15RedInput DW 9 + DB 64, 19 + DW 0, 63 + DW 7, Offset PaletteDefs+45 + DW 97, 99, 56, 77, 95, 102 + +Colour15GreenInput DW 9 + DB 64, 20 + DW 0, 63 + DW 7, Offset PaletteDefs+46 + DW 98, 100, 57, 78, 96, 102 + +Colour15BlueInput DW 9 + DB 64, 21 + DW 0, 63 + DW 7, Offset PaletteDefs+47 + DW 99, 102, 58, 79, 97, 102 + +PredefinedPaletteMsg DW 1 + DB 57, 25 + DB 20h + DB "Predefined Palettes", 0 + +PredefinedPalette1 DW 2 + DW 100, 103, 82, 61 + DW 0 + DW 0, 0 + DW 4 ; Jump to function + DD DWord Ptr S_UsePresetPalette + DW 0 ; First palette + DW 0, 0 ; Unused data + DB 55, 27, 77, 29 + DB 8 + DB 0 + DB " Light Blue", 0 + +PredefinedPalette2 DW 2 + DW 102, 104, 85, 64 + DW 0 + DW 0, 0 + DW 4 ; Jump to function + DD DWord Ptr S_UsePresetPalette + DW 1 ; First palette + DW 0, 0 ; Unused data + DB 55, 30, 77, 32 + DB 8 + DB 0 + DB " Gold", 0 + +PredefinedPalette3 DW 2 + DW 103, 105, 86, 65 + DW 0 + DW 0, 0 + DW 4 ; Jump to function + DD DWord Ptr S_UsePresetPalette + DW 2 ; First palette + DW 0, 0 ; Unused data + DB 55, 33, 77, 35 + DB 8 + DB 0 + DB " Camouflage", 0 + +PredefinedPalette4 DW 2 + DW 104, 106, 88, 67 + DW 0 + DW 0, 0 + DW 4 ; Jump to function + DD DWord Ptr S_UsePresetPalette + DW 3 + DW 0, 0 ; Unused data + DB 55, 36, 77, 38 + DB 8 + DB 0 + DB " Midnight Tracking", 0 + +PredefinedPalette5 DW 2 + DW 105, 107, 90, 69 + DW 0 + DW 0, 0 + DW 4 ; Jump to function + DD DWord Ptr S_UsePresetPalette + DW 4 + DW 0, 0 ; Unused data + DB 55, 39, 77, 41 + DB 8 + DB 0 + DB " Pine Colours", 0 + +PredefinedPalette6 DW 2 + DW 106, 108, 91, 70 + DW 0 + DW 0, 0 + DW 4 ; Jump to function + DD DWord Ptr S_UsePresetPalette + DW 5 + DW 0, 0 ; Unused data + DB 55, 42, 77, 44 + DB 8 + DB 0 + DB " Soundtracker", 0 + +PredefinedPalette7 DW 2 + DW 107, 0FFFFh, 94, 73 + DW 0 + DW 0, 0 + DW 4 ; Jump to function + DD DWord Ptr S_UsePresetPalette + DW 6 + DW 0, 0 ; Unused data + DB 55, 45, 77, 47 + DB 8 + DB 0 + DB " Volcanic", 0 + +O1_LoadInstrumentList DW 5 + DW Near Ptr InstrumentNameLoader ; Idlekey + DW Near Ptr LoadInstrumentKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr LoadInstrumentHeader ; 2 + DW Near Ptr FillHeader ; 3 + DW Near Ptr LoadInstrumentWindow + DW Near Ptr LoadInstrument ; 5 + DW Near Ptr LoadInstrumentDriveWindow + DW Near Ptr LoadInstrumentDrive + DW Near Ptr SetHelpContext11 + DW 0 + +LoadInstrumentDriveWindow DW 0 + DB 63, 15, 72, 48 + DB 27 + +LoadInstrumentDrive DW 15 + DD DWord Ptr D_LIDrawDriveWindow + DD DWord Ptr D_LIPreDriveWindow + DD DWord Ptr D_LIPostDriveWindow + +O1_ViewInstrumentLibrary DW 5 + DW Near Ptr InstrumentNameLoader ; Idlekey + DW Near Ptr LoadInstrumentKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr InstrumentLibraryHeader ; 2 + DW Near Ptr FillHeader ; 3 + DW Near Ptr LoadInstrumentWindow + DW Near Ptr ViewInstrument ; 5 + DW Near Ptr LoadInstrumentDriveWindow + DW Near Ptr LoadInstrumentDrive + DW Near Ptr SetHelpContext11 + DW 0 + +LoadInstrumentHeader DW 10 + DB "Load Instrument", 0 + +InstrumentLibraryHeader DW 10 + DB "Instrument Library (Ctrl-F4)", 0 + +LoadInstrumentWindow DW 0 + DB 5, 12, 62, 48 + DB 27 + +LoadInstrument DW 15 + DD DWord Ptr D_DrawLoadInstrument + DD DWord Ptr D_PreLoadInstrument + DD DWord Ptr D_PostLoadInstrument + +ViewInstrument DW 15 + DD DWord Ptr D_DrawLoadInstrument + DD DWord Ptr D_PreLoadInstrument + DD DWord Ptr D_ViewInstrument + +InstrumentNameLoader DD DWord Ptr D_LoadInstrumentNames + DD DWord Ptr IdleUpdateInfoLine + DD 0 + +O1_UndoList DW 3 + DW Near Ptr IdleFunctionList + DW Near Ptr ESCExitList + DW Near Ptr UndoBox1 + DW Near Ptr UndoBox2 + DW Near Ptr UndoText + DW Near Ptr UndoSelector + DW 0 + +UndoBox1 DW 0 + DB 16, 21, 63, 36 + DB 3 + +UndoBox2 DW 0 + DB 19, 23, 60, 34 + DB 27 + +UndoText DW 1 + DB 38, 22 + DB 23h + DB "Undo", 0 + +UndoSelector DW 15 + DD DWord Ptr PEFunction_DrawUndo + DD DWord Ptr PEFunction_PreUndo + DD DWord Ptr PEFunction_PostUndo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +O1_MessageList DW 4 + DW Near Ptr IdleFunctionList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr MessageBox + DW Near Ptr MessageObject + DW Near Ptr MessageHeader + DW Near Ptr SetHelpContext12 + DW 0 + +MessageBox DW 0 + DB 1, 12, 78, 48 + DB 27 + +MessageObject DW 15 + DD DWord Ptr Msg_DrawMessage + DD DWord Ptr Msg_PreMessage + DD DWord Ptr Msg_PostMessage + +MessageHeader DW 10 + DB "Message Editor (Shift-F9)", 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +O1_MIDIOutputScreen DW 9 + DW Near Ptr IdleFunctionList + DW Near Ptr MIDIOutKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr MIDIOutputHeader + DW Near Ptr MIDIOutputMainConfigText + DW Near Ptr MIDIOutputSFxConfigText + DW Near Ptr MIDIOutputMainConfigBox + DW Near Ptr MIDIOutputSFxConfigBox + DW Near Ptr MIDIOutputZxxConfigBox ; 8 + DW Near Ptr MIDIStartInput ; 9 + DW Near Ptr MIDIStopInput ; 10 + DW Near Ptr MIDITickInput ; 11 + DW Near Ptr MIDINoteOnInput ; 12 + DW Near Ptr MIDINoteOffInput ; 13 + DW Near Ptr MIDIChangeVolumeInput ; 14 + DW Near Ptr MIDIChangePanInput ; 15 + DW Near Ptr MIDIBankSelectInput ; 16 + DW Near Ptr MIDIProgramChangeInput ; 17 + DW Near Ptr MIDISF0Input + DW Near Ptr MIDISF1Input + DW Near Ptr MIDISF2Input + DW Near Ptr MIDISF3Input + DW Near Ptr MIDISF4Input + DW Near Ptr MIDISF5Input + DW Near Ptr MIDISF6Input + DW Near Ptr MIDISF7Input + DW Near Ptr MIDISF8Input + DW Near Ptr MIDISF9Input + DW Near Ptr MIDISFAInput + DW Near Ptr MIDISFBInput + DW Near Ptr MIDISFCInput + DW Near Ptr MIDISFDInput + DW Near Ptr MIDISFEInput + DW Near Ptr MIDISFFInput ; 33 + DW Near Ptr MIDIZ1Input + DW Near Ptr MIDIZ2Input + DW Near Ptr MIDIZ3Input + DW Near Ptr MIDIZ4Input + DW Near Ptr MIDIZ5Input + DW Near Ptr MIDIZ6Input + DW Near Ptr MIDIZ7Input + DW Near Ptr MIDIZxxNumbering + DW 0 + +MIDIOutputHeader DW 10 + DB "MIDI Output Configuration", 0 + +MIDIZxxNumbering DW 8 + DD DWord Ptr F_ShowMIDIZxxInput + +MIDIOutKeyList DB 0 + DW 1C8h + DD DWord Ptr F_MIDI_Up + + DB 0 + DW 1D0h + DD DWord Ptr F_MIDI_Down + + DB 0 + DW 1C9h + DD DWord Ptr F_MIDI_PgUp + + DB 0 + DW 1D1h + DD DWord Ptr F_MIDI_PgDn + + DB 5 + DW Offset GlobalKeyChain + +MIDIOutputMainConfigText DW 1 + DB 2, 13 + DB 20h + DB 0FFh, 4, " MIDI Start", 13 + DB 0FFh, 5, " MIDI Stop", 13 + DB 0FFh, 5, " MIDI Tick", 13 + DB 0FFh, 7, " Note On", 13 + DB 0FFh, 6, " Note Off", 13 + DB " Change Volume", 13 + DB 0FFh, 4, " Change Pan", 13 + DB " Bank Select", 13 + DB "Program Change", 13 + DB 13 + DB 13 + DB " Macro", 13 + DB " Setup", 0 + +MIDIOutputSFxConfigText DW 1 + DB 13, 24 + DB 20h + DB "SF0", 13 + DB "SF1", 13 + DB "SF2", 13 + DB "SF3", 13 + DB "SF4", 13 + DB "SF5", 13 + DB "SF6", 13 + DB "SF7", 13 + DB "SF8", 13 + DB "SF9", 13 + DB "SFA", 13 + DB "SFB", 13 + DB "SFC", 13 + DB "SFD", 13 + DB "SFE", 13 + DB "SFF", 0 + +MIDIOutputMainConfigBox DW 0 + DB 16, 12, 60, 22 + DB 27 + +MIDIOutputSFxConfigBox DW 0 + DB 16, 23, 60, 40 + DB 27 + +MIDIOutputZxxConfigBox DW 0 + DB 16, 41, 60, 49 + DB 27 + + +MIDIStartInput DW 16 + DB 17, 13 + DW 7, 0 + DW 32 + DD 0 + DW 9, 10, 0FFFFh, 0FFFFh + +MIDIStopInput DW 16 + DB 17, 14 + DW 7, 20h + DW 32 + DD 0 + DW 9, 11, 0FFFFh, 0FFFFh + +MIDITickInput DW 16 + DB 17, 15 + DW 7, 40h + DW 32 + DD 0 + DW 10, 12, 0FFFFh, 0FFFFh + +MIDINoteOnInput DW 16 + DB 17, 16 + DW 7, 60h + DW 32 + DD 0 + DW 11, 13, 0FFFFh, 0FFFFh + +MIDINoteOffInput DW 16 + DB 17, 17 + DW 7, 80h + DW 32 + DD 0 + DW 12, 14, 0FFFFh, 0FFFFh + +MIDIChangeVolumeInput DW 16 + DB 17, 18 + DW 7, 0A0h + DW 32 + DD 0 + DW 13, 15, 0FFFFh, 0FFFFh + +MIDIChangePanInput DW 16 + DB 17, 19 + DW 7, 0C0h + DW 32 + DD 0 + DW 14, 16, 0FFFFh, 0FFFFh + +MIDIBankSelectInput DW 16 + DB 17, 20 + DW 7, 0E0h + DW 32 + DD 0 + DW 15, 17, 0FFFFh, 0FFFFh + +MIDIProgramChangeInput DW 16 + DB 17, 21 + DW 7, 100h + DW 32 + DD 0 + DW 16, 18, 0FFFFh, 0FFFFh + +MIDISF0Input DW 16 + DB 17, 24 + DW 7, 120h + DW 32 + DD 0 + DW 17, 19, 0FFFFh, 0FFFFh + +MIDISF1Input DW 16 + DB 17, 25 + DW 7, 140h + DW 32 + DD 0 + DW 18, 20, 0FFFFh, 0FFFFh + +MIDISF2Input DW 16 + DB 17, 26 + DW 7, 160h + DW 32 + DD 0 + DW 19, 21, 0FFFFh, 0FFFFh + +MIDISF3Input DW 16 + DB 17, 27 + DW 7, 180h + DW 32 + DD 0 + DW 20, 22, 0FFFFh, 0FFFFh + +MIDISF4Input DW 16 + DB 17, 28 + DW 7, 1A0h + DW 32 + DD 0 + DW 21, 23, 0FFFFh, 0FFFFh + +MIDISF5Input DW 16 + DB 17, 29 + DW 7, 1C0h + DW 32 + DD 0 + DW 22, 24, 0FFFFh, 0FFFFh + +MIDISF6Input DW 16 + DB 17, 30 + DW 7, 1E0h + DW 32 + DD 0 + DW 23, 25, 0FFFFh, 0FFFFh + +MIDISF7Input DW 16 + DB 17, 31 + DW 7, 200h + DW 32 + DD 0 + DW 24, 26, 0FFFFh, 0FFFFh + +MIDISF8Input DW 16 + DB 17, 32 + DW 7, 220h + DW 32 + DD 0 + DW 25, 27, 0FFFFh, 0FFFFh + +MIDISF9Input DW 16 + DB 17, 33 + DW 7, 240h + DW 32 + DD 0 + DW 26, 28, 0FFFFh, 0FFFFh + +MIDISFAInput DW 16 + DB 17, 34 + DW 7, 260h + DW 32 + DD 0 + DW 27, 29, 0FFFFh, 0FFFFh + +MIDISFBInput DW 16 + DB 17, 35 + DW 7, 280h + DW 32 + DD 0 + DW 28, 30, 0FFFFh, 0FFFFh + +MIDISFCInput DW 16 + DB 17, 36 + DW 7, 2A0h + DW 32 + DD 0 + DW 29, 31, 0FFFFh, 0FFFFh + +MIDISFDInput DW 16 + DB 17, 37 + DW 7, 2C0h + DW 32 + DD 0 + DW 30, 32, 0FFFFh, 0FFFFh + +MIDISFEInput DW 16 + DB 17, 38 + DW 7, 2E0h + DW 32 + DD 0 + DW 31, 33, 0FFFFh, 0FFFFh + +MIDISFFInput DW 16 + DB 17, 39 + DW 7, 300h + DW 32 + DD 0 + DW 32, 34, 0FFFFh, 0FFFFh + +MIDIZ1Input DW 16 + DB 17, 42 + DW 7, 8320h + DW 32 + DD 0 + DW 0FFFFh, 35, 0FFFFh, 0FFFFh + +MIDIZ2Input DW 16 + DB 17, 43 + DW 7, 8340h + DW 32 + DD 0 + DW 34, 36, 0FFFFh, 0FFFFh + +MIDIZ3Input DW 16 + DB 17, 44 + DW 7, 8360h + DW 32 + DD 0 + DW 35, 37, 0FFFFh, 0FFFFh + +MIDIZ4Input DW 16 + DB 17, 45 + DW 7, 8380h + DW 32 + DD 0 + DW 36, 38, 0FFFFh, 0FFFFh + +MIDIZ5Input DW 16 + DB 17, 46 + DW 7, 83A0h + DW 32 + DD 0 + DW 37, 39, 0FFFFh, 0FFFFh + +MIDIZ6Input DW 16 + DB 17, 47 + DW 7, 83C0h + DW 32 + DD 0 + DW 38, 40, 0FFFFh, 0FFFFh + +MIDIZ7Input DW 16 + DB 17, 48 + DW 7, 83E0h + DW 32 + DD 0 + DW 39, 0FFFFh, 0FFFFh, 0FFFFh + +O1_MIDIScreen DW 7 + DW Near Ptr MIDIIdleList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader + DW Near Ptr FillHeader + DW Near Ptr MIDIHeader + DW Near Ptr ShowMIDIInput + DW Near Ptr MIDIOptionsBox ; 5 + DW Near Ptr MIDIOptions ; 6 + DW Near Ptr ProgramChangeToggle ; 7 + DW Near Ptr Program1Toggle ; 8 + DW Near Ptr RecordNoteOffToggle ; 9 + DW Near Ptr RecordVelocityToggle ; 10 + DW Near Ptr RecordAfterTouchToggle ; 11 + DW Near Ptr MIDITranslateBox ; 12 + DW Near Ptr MIDIAmplificationTB ; 13 + DW Near Ptr MIDICentralNoteTB ; 14 + DW Near Ptr MIDIOutputButton ; 15 + DW Near Ptr MIDISaveConfigButton ; 16 + DW Near Ptr MIDINoteOffCut ; 17 + DW Near Ptr MIDIPitchBox ; 18 + DW Near Ptr MIDIPitchToggle ; 19 + DW Near Ptr MIDIPWDInput ; 20 + DW Near Ptr MIDIEmbedBox + DW NEar Ptr MIDIEmbedToggle + DW Near Ptr SetHelpContext13 + DW 0 + +MIDIHeader DW 10 + DB "MIDI Screen (Shift-F1)", 0 + +MIDIPitchToggle DW 17 + DB 25, 27 + DW 2 + DW 2Ch ; Offset of 'Flags' + DB 64 + DW 14, 20, 0FFFFh, 0FFFFh + +MIDIEmbedToggle DW 17 + DB 25, 31 + DW 2 + DW 2Ch ; Offset of 'Flags' + DB 128 + DW 20, 15, 0FFFFh, 0FFFFh + +MIDIPWDInput DW 14 + DB 25, 28 + DW 0, 32 + DW 3, 35h + DW 19, 22, 0FFFFh, 0FFFFh + DW 0FFFFh, 0FFFFh ; PgUp/PgDn + DW 25 + +MIDIOutputButton DW 2 + DW 22, 16, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 1 + DD DWord Ptr O1_MIDIOutputScreen + DW 0, 0, 0 + DB 2, 34, 32, 36 + DB 8 + DB 0 + DB " MIDI Output Configuration", 0 + +MIDISaveConfigButton DW 2 + DW 15, 0FFFFh, 0FFFFh, 0FFFFh + DW 0 + DW 0, 0 + DW 2 + DD DWord Ptr Music_SaveMIDIConfig + DW 0, 0, 0 + DB 2, 37, 32, 39 + DB 8 + DB 0 + DB " Save Output Configuration", 0 + +ShowMIDIInput DW 8 +MIDIIdleList DD DWord Ptr K_ShowMIDIInput + DD DWord Ptr IdleUpdateInfoLine + DD 0 + +MIDIOptionsBox DW 0 + DB 24, 14, 30, 21 + DB 27 + +MIDITranslateBox DW 0 + DB 24, 22, 51, 25 + DB 27 + +MIDIPitchBox DW 0 + DB 24, 26, 51, 29 + DB 27 + +MIDIEmbedBox DW 0 + DB 24, 30, 51, 32 + DB 27 + +MIDIOptions DW 1 + DB 7, 15 + DB 20h + DB 0FFh, 4, " Tick quantize", 13 + DB " Base Program 1", 13 + DB " Record Note-Off", 13 + DB " Record Velocity", 13 + DB "Record Aftertouch", 13 + DB 0FFh, 5, " Cut note off", 13 + DB 13 + DB 13 + DB 0FFh, 4, " Amplification", 13 + DB " C-5 Note-value", 13 + DB 13 + DB 13 + DB "Output MIDI pitch", 13 + DB "Pitch wheel depth", 13 + DB 13 + DB 13 + DB " Embed MIDI data", 0 + +ProgramChangeToggle DW 17 + DB 25, 15 + DW 1, Offset CentraliseCursor + DB 8 + DW 0FFFFh, 8, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +Program1Toggle DW 17 + DB 25, 16 + DW 1, Offset CentraliseCursor + DB 16 + DW 7, 9, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +RecordNoteOffToggle DW 17 + DB 25, 17 + DW 1, Offset CentraliseCursor + DB 32 + DW 8, 10, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +RecordVelocityToggle DW 17 + DB 25, 18 + DW 1, Offset CentraliseCursor + DB 64 + DW 9, 11, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +RecordAfterTouchToggle DW 17 + DB 25, 19 + DW 1, Offset CentraliseCursor + DB 128 + DW 10, 17, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +MIDINoteOffCut DW 17 + DB 25, 20 + DW 1, Offset Flags + DB 2 + DW 11, 13, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +MIDIAmplificationTB DW 9 + DB 25, 23 + DW 0, 200 + DW 1, Offset MIDIAmplification + DW 17, 14, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + +MIDICentralNoteTB DW 14 + DB 25, 24 + DW 0, 127 + DW 1, Offset MIDICentralNote + DW 13, 19, 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh + DW 25 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF TIMERSCREEN + +O1_TimerList DW 5 + DW Near Ptr InfoPageIdleList + DW Near Ptr GlobalKeyList + DW Near Ptr FullScreenBox ; 0 + DW Near Ptr ScreenHeader ; 1 + DW Near Ptr FillHeader ; 2 + DW Near Ptr TimerHeader + DW Near Ptr TimerText ; 4 + DW Near Ptr DrawTimer + DW Near Ptr Divider + DW Near Ptr SetHelpContext0 + DW 0 + +TimerHeader DW 10 + DB "Time Information", 0 + +TimerText DW 1 + DB 2, 13 + DB 20h + DB 0FFh, 4, " Module time:", 13 + DB "Current session:", 13 + DB 13 + DB 0FFh, 5, " Total time:", 0 + +DrawTimer DW 15 + DD DWord Ptr D_DrawTimer + DD DWord Ptr F_Nothing + DD DWord Ptr D_PostTimerList + +Divider DW 1 + DB 1, 18 + DB 20h + DB 0FFh, 78, 09Ah, 0 + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +O1_StereoSampleList DW 2 + DW Near Ptr IdleFunctionList + DW Near Ptr LRKeyList + DW Near Ptr StereoSampleBox ; 0 + DW Near Ptr StereoSampleText + DW Near Ptr StereoButtonLeft ; 2 + DW Near Ptr StereoButtonRight ; 3 + DW 0 + +LRKeyList DB 8 + DW 'L' + DD DWord Ptr F_Return64 + + DB 8 + DW 'R' + DD DWord Ptr F_Return192 + + DB 0FFh + +StereoSampleBox DW 0 + DB 26, 22, 54, 29 + DB 3 + +StereoSampleText DW 1 + DB 30, 24 + DB 20h + DB "Loading Stereo Sample", 0 + +StereoButtonLeft DW 2 + DW 0FFFFh, 0FFFFh, 3, 3 + DW 0 + DW 0, 0 ; Unused + DW 0 ; Return + DW 64 + DW 0, 0, 0, 0 ; Unused + DB 30, 26, 39, 28 + DB 8 + DB 0 + DB " Left", 0 + +StereoButtonRight DW 2 + DW 0FFFFh, 0FFFFh, 2, 2 + DW 0 + DW 0, 0 ; Unused + DW 0 ; Return + DW 64+128 + DW 0, 0, 0, 0 ; Unused + DB 40, 26, 50, 28 + DB 8 + DB 0 + DB " Right", 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +O1_ShowTime DW 2 + DW 0 + DW Near Ptr ESCReturnList + DW Near Ptr NBMBox + DW Near Ptr ShowTime + DW Near Ptr OKButton + DW Near Ptr SongLengthText + DW 0 + +SongLengthText DW 1 + DB 27, 27 + DB 20h + DB "Total song time: ", 0 + +ShowTime DW 8 + DD Music_ShowTime + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF SPECTRUMANALYSER +O1_FourierDisplay DW 0 +; DW Near Ptr FourierIdleList + DW Near Ptr InfoPageIdleList + DW Near Ptr FourierKeyList + DW Near Ptr FourierDisplay + DW 0 + +;FourierIdleList DD DWord Ptr Fourier_IdleList +; DD 0 + +FourierKeyList DB 1 + DW '-' + DD DWord Ptr DisplayMinus + + DB 1 + DW '+' + DD DWord Ptr DisplayPlus + + DB 0 + DW 13Fh + DD DWord Ptr Glbl_Ctrl_F5 + + DB 1 + DW 'p' + DD DWord Ptr Fourier_ChangePalette + + DB 5 + DW Near Ptr PlayCommandChain + +FourierDisplay DW 15 + DD DWord Ptr Fourier_PreDrawScreen + DD DWord Ptr Fourier_DrawScreen + DD DWord Ptr Fourier_PostFunction + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +EndS + +End diff --git a/IT_PE.ASM b/it_pe.s similarity index 96% rename from IT_PE.ASM rename to it_pe.s index cba174d..7d32c69 100644 --- a/IT_PE.ASM +++ b/it_pe.s @@ -1,12312 +1,12312 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ PatternEdit module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386 - -include switch.inc - -include network.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Segment Object1 BYTE Public 'Data' -EndS - -Segment Disk BYTE Public 'Code' -EndS - -Segment Inst BYTE Public 'Code' - Extrn InstrumentEdit:Byte - Extrn NodeHeld:Byte -EndS - - Extrn E_GetFreeEMS:Far - Extrn E_UnInitEMS:Far - Extrn E_ReleaseEMS:Far - Extrn E_AllocateEMS:Far - Extrn E_MapAvailableEMSMemory:Far - Extrn E_GetEMSPageFrame:Far - - Extrn Glbl_F2:Far, Glbl_F6:Far - Extrn Glbl_GetHeaderMode:Far - Extrn Glbl_LeftBrace:Far, Glbl_RightBrace:Far - Extrn Glbl_LeftSquareBracket:Far, Glbl_RightSquareBracket:Far - - Extrn I_ClearTables:Far - - Extrn K_UnInitKeyBoard:Far - Extrn K_SetScrollLock:Far - Extrn K_IsKeyDown:Far - - Extrn M_FunctionHandler:Far - Extrn M_Object1List:Far - Extrn M_FunctionDivider:Far - - Extrn Music_PlayPartSong:Far - Extrn Music_GetSongSegment:Far - Extrn Music_UnInitMusic:Far - Extrn Music_ReleasePattern:Far - Extrn Music_AllocatePattern:Far - Extrn Music_GetPattern:Far - Extrn Music_GetInstrumentMode:Far - Extrn Music_UpdatePatternOffset:Far - Extrn Music_PlayNote:Far - Extrn Music_InitMixTable:Far - Extrn Music_InitMuteTable:Far - Extrn Music_InitStereo:Far - Extrn Music_ToggleChannel:Far - Extrn Music_SoloChannel:Far - Extrn Music_GetPlayMode:Far - Extrn Music_PlayPattern:Far - Extrn Music_GetLastChannel:Far - Extrn Music_SetNextOrder:Far - Extrn Music_NextOrder:Far - Extrn Music_LastOrder:Far - Extrn Music_Stop:Far - - Extrn Music_UnmuteAll:Far - - Extrn Music_SoundCardLoadSample:Far - Extrn Music_SoundCardLoadAllSamples:Far - Extrn Music_GetDisplayVariables:Far - - Extrn Network_UpdatePattern:Far - - Extrn FileName:Byte - - Extrn O1_ConfirmNoSave:Far - Extrn O1_NoBlockMarkedList:Far - Extrn O1_SwapOutOfRangeList:Far - Extrn O1_OverlapBlockList:Far - Extrn O1_OutOfMemoryList:Far - Extrn O1_NoBlockDataList:Far - Extrn O1_GetAmpList:Far - Extrn O1_GetFastAmpList:Far - -IF SHOWPATTERNLENGTH - Extrn O1_ShowPatternLengthList:Far -ENDIF - - Extrn O1_TemplateErrorList:Far - Extrn O1_PatternTooLongList:Far - Extrn O1_SelectMultiChannel:Far - Extrn O1_UndoList:Far - Extrn O1_SetPatternLength:Far - Extrn O1_PatternSizeMismatchList:Far - - Extrn S_UnInitScreen:Far - Extrn S_DrawBox:Far - Extrn S_DrawString:Far - Extrn S_GetDestination:Far - Extrn S_SaveScreen:Far - Extrn S_RestoreScreen:Far - Extrn S_SetDirectMode:Far - Extrn S_DrawSmallBox:Far - Extrn S_InvertCursor:Far - - Extrn PatternLength - - Extrn UpdateInfoLine:Far - Extrn SetInfoLine:Far - Extrn MouseUpdateDisable:Far - Extrn UpdateWAVEForm:Far - - Extrn MIDI_AllocateChannel:Far, MIDI_FindChannel:Far - Extrn Music_GetDelay:Far, MIDI_GetChannel:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global PE_ClearUndoBuffer:Far - - Global PE_ShowOrder:Far - Global PE_NewPattern:Far - - Global PE_InitPatternEdit:Far - Global PE_UnInitPatternEdit:Far - Global PE_DrawOrderList:Far - Global PE_FillHeader:Far - Global PE_PreOrderList:Far - Global PE_PostOrderList:Far - Global PE_ConvAX2Num:Far - Global PE_GetCurrentPattern:Far - Global PE_GetMaxPattern:Far - Global PE_FillSpeedTempo:Far - - Global PE_SetPatternModified:Far - Global PE_GetLastInstrument:Far - Global PE_DrawPatternEdit:Far - Global PE_PrePatternEdit:Far - Global PE_PostPatternEdit:Far - Global PE_SetCommandCursor:Far - Global PEFunction_IncreaseOctave:Far - Global PEFunction_DecreaseOctave:Far - - Global PE_F7:Far - - Global PE_GetPatternConfigOffset:Far - - Global PE_SwapInstruments:Far - Global PE_GetMaxOrder:Far - Global PE_GotoPattern:Far - Global PECheckModified:Far - - Global PE_TranslateXMPattern:Far - Global PE_TranslateS3MPattern:Far - Global PE_TranslateMODPattern:Far - Global PE_TranslateMTMPattern:Far - Global PE_Translate669Pattern:Far - Global PE_ResetOrderPattern:Far - Global PEFunction_OutOfMemoryMessage:Far - Global PE_UpdateInstruments:Far - - Global PEFunction_DrawUndo:Far - Global PEFunction_PreUndo:Far - Global PEFunction_PostUndo:Far - Global PEResetModified:Far - - Global PE_SaveCurrentPattern:Far - Global PE_RestoreCurrentPattern:Far - Global PEFunction_StoreCurrentPattern:Far - - Global BaseOctave - Global SkipValue - Global RowHiLight1:Byte - Global RowHiLight2:Byte - Global MaxRow:Word - Global NumberOfRows:Word - Global Amplification - Global FastVolumeAmplification - Global CommandToValue:Byte - Global LastInstrument:Byte - Public MultiChannelInfo - Public PatternDataArea - Public Order, CentraliseCursor - Public PatternSetLength, PatternLengthStart, PatternLengthEnd - Public MIDI_SetInstrument, PE_TranslateMIDI - Public MIDIAmplification, MIDICentralNote, PE_RestoreMIDINote - Public PE_InsertInstrument, PE_DeleteInstrument - Public Flags, Modified, PatternModified - - Public LastKeyBoard1, PatternNumber - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Pattern WORD Public 'Code' USE16 - Assume CS:Pattern, DS:Nothing - -CREATENEWLOGFILE EQU 0 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -NONOTE EQU 0FDh -MAXNOTE EQU 119 - -;PatternSize DW 0 -;PatternEnd DW 0 -PatternDataArea DW PatternData - -TempVariableArea DW 0 -TempVariableArea2 DW 0 -TempVariableArea3 DW 0 -TempVariableArea4 DW 0 -TempVariableArea5 DW 0 -TempVariableArea6 DW 0 - -TopOrder DW 0 -Order DW 0 -OrderCursor DW 0 -PatternNumber DW 0 -TopRow DW 0 -Row DW 0 -MaxRow DW 63 -NumberOfRows DW 64 - -LeftChannel DW 0 -Channel DW 0 -MIDIChannel DW 0 -PatternCursor DW 0 -BaseOctave DW 4 -SkipValue DW 1 -MultiChannelInfo DB 64 Dup (0) -BlockMark DW 0 ; 0 if no block marked, 1 if block is marked -BlockLeft DW 0 -BlockTop DW 0 -BlockRight DW 0 -BlockBottom DW 0 -BlockDataArea DW 0 -BlockAnchorChannel DW 0 -BlockAnchorRow DW 0 -BlockReset DW 0 -LastKeyBoard1 DW 0, 0 -LastKeyBoard2 DW 0, 0 -LastKeyBoard3 DW 0, 0 - -EmptyRow DB 64 Dup ( NONOTE, 0, 0FFh, 0, 0 ) - -KeyBoardTable DW 12Ch, 0, 11Fh, 1, 12Dh, 2, 120h, 3, 12Eh, 4 - DW 12Fh, 5, 122h, 6, 130h, 7, 123h, 8, 131h, 9 - DW 124h, 10, 132h, 11, 110h, 12, 103h, 13, 111h, 14 - DW 104h, 15, 112h, 16, 113h, 17, 106h, 18, 114h, 19 - DW 107h, 20, 115h, 21, 108h, 22, 116h, 23, 117h, 24 - DW 10Ah, 25, 118h, 26, 10Bh, 27, 119h, 28 - DW 0FFFFh - -MODPeriodTable DW 1712, 1616, 1525, 1440, 1357, 1281 ; Octave 0 - DW 1209, 1141, 1077, 1017, 961, 907 - DW 856, 808, 762, 720, 678, 640 ; Octave 1 - DW 604, 570, 538, 508, 480, 453 - DW 428, 404, 381, 360, 339, 320 ; Octave 2 - DW 302, 285, 269, 254, 240, 226 - DW 214, 202, 190, 180, 170, 160 ; Octave 3 - DW 151, 143, 135, 127, 120, 113 - DW 107, 101, 95, 90, 85, 80 ; Octave 4 - DW 75, 71, 67, 63, 60, 56 - DW 53, 50, 47, 45, 42, 40 ; Octave 5 - DW 37, 35, 33, 31, 30, 28 - -Amplification DW 100 - -PlayMarkPattern DW 0 -PlayMarkRow DW 0 -PlayMarkOn DB 0 -VolumePan DB 0 - -UndoBuffer DW 20 Dup (0) ; Word for segment, word for - ; type: - -UndoBufferTypes Label Word - DW Offset UndoBufferType0, Offset UndoBufferType1 - DW Offset UndoBufferType2, Offset UndoBufferType3 - DW Offset UndoBufferType4, Offset UndoBufferType5 - DW Offset UndoBufferType6, Offset UndoBufferType7 - DW Offset UndoBufferType8, Offset UndoBufferType9 - DW Offset UndoBufferType10, Offset UndoBufferType11 - DW Offset UndoBufferType12, Offset UndoBufferType13 - DW Offset UndoBufferType14, Offset UndoBufferType15 - DW Offset UndoBufferType16, Offset UndoBufferType17 - DW Offset UndoBufferType18, Offset UndoBufferType19 - DW Offset UndoBufferType20, Offset UndoBufferType21 - DW Offset UndoBufferType22 - -UndoBufferType0 DB "Empty", 0 -UndoBufferType1 DB "Undo revert pattern data (Alt-BkSpace)", 0 -UndoBufferType2 DB "Undo transposition up", 0FFh, 10, " (Alt-Q)", 0 -UndoBufferType3 DB "Undo transposition down", 0FFh, 8, " (Alt-A)", 0 -UndoBufferType4 DB "Undo block length double", 0FFh, 7, " (Alt-F)", 0 -UndoBufferType5 DB "Undo block length halve", 0FFh, 8, " (Alt-G)", 0 -UndoBufferType6 DB "Undo volume amplification", 0FFh, 6, " (Alt-J)", 0 -UndoBufferType7 DB "Undo volume or panning slide (Alt-K)", 0 -UndoBufferType8 DB "Recover volumes/pannings", 0FFh, 5, " (2*Alt-K)", 0 -UndoBufferType9 DB "Replace mixed data", 0FFh, 13, " (Alt-M)", 0 -UndoBufferType10 DB "Replace overwritten data", 0FFh, 7, " (Alt-O)", 0 -UndoBufferType11 DB "Undo paste data", 0FFh, 16, " (Alt-P)", 0 -UndoBufferType12 DB "Undo set sample/instrument", 0FFh, 5, " (Alt-S)", 0 -UndoBufferType13 DB "Undo set volume/panning", 0FFh, 8, " (Alt-V)", 0 -UndoBufferType14 DB "Replace extra volumes/pannings (Alt-W)", 0 -UndoBufferType15 DB "Undo effect data slide", 0FFh, 9, " (Alt-X)", 0 -UndoBufferType16 DB "Recover effects/effect data (2*Alt-X)", 0 -UndoBufferType17 DB "Undo swap block", 0FFh, 16, " (Alt-Y)", 0 -UndoBufferType18 DB "Undo block cut", 0FFh, 17, " (Alt-Z)", 0 -UndoBufferType19 DB "Remove inserted row(s)", 0FFh, 4, " (Alt-Insert)", 0 -UndoBufferType20 DB "Replace deleted row(s)", 0FFh, 4, " (Alt-Delete)", 0 -UndoBufferType21 DB "Redo", 0FFh, 28, " (Undo)", 0 -UndoBufferType22 DB "Pattern ", 0FDh, "D", 0 - -SelectUndo DW 0 -ShiftPressed DB 0 -NoteEntered DB 0 - -PreviewNote DB 0, 0, 0FFh, 0, 0 - -Modified DB 0 ; } Order important -PatternModified DB 0 ; } - -MIDIPlayTrigger DB 0 ; 0 = nothing, 1 = play - ; pattern, 2 = play song. - -CompleteMsg DB 0FDh, "D% Complete", 0 -Template DB 0 -TemplateMsg1 DB "Template, Overwrite", 0 -TemplateMsg2 DB "Template, Mix - Pattern data precedence", 0 -TemplateMsg3 DB "Template, Mix - Clipboard data precedence", 0 -TemplateMsg4 DB "Template, Notes only", 0 -TriggerMsg1 DB "No MIDI Trigger", 0 -TriggerMsg2 DB "Pattern MIDI Trigger", 0 -TriggerMsg3 DB "Song MIDI Trigger", 0 -NextOrderMsg DB "Playing order ", 0FDh, "D next", 0 -CursorStepMSg DB "Cursor step set to ", 0FDh, "D", 0 - -EncodingInfo DB 384 Dup (0) -PatternSetLength DW 64 -PatternLengthStart DW 0 -PatternLengthEnd DW 0 -TempData DB 320 Dup (0) - -PEFunctions Label Word - DB 0 - DW 11Ch ; Enter - DW Offset PEFunction_PickUp - -IF SHOWPATTERNLENGTH - DB 0 - DW 111Ch ; Right Ctrl+Enter - DW Offset PE_ShowPatternLength -ENDIF - - DB 1 - DW '{' - DW Near Ptr PE_LeftBrace - - DB 1 - DW '}' - DW Near Ptr PE_RightBrace - - DB 1 - DW '[' - DW Near Ptr PE_LeftSquareBracket - - DB 1 - DW ']' - DW Near Ptr PE_RightSquareBracket - - DB 0 - DW 1C8h - DW Offset PEFunction_Up - - DB 0 - DW 1D0h - DW Offset PEFunction_Down - - DB 0 - DW 1CBh - DW Offset PEFunction_Left - - DB 0 - DW 1CDh - DW Offset PEFunction_Right - - DB 0 - DW 1C9h - DW PEFunction_PgUp - - DB 0 - DW 1D1h - DW PEFunction_PgDn - - DB 2 - DW 1C7h - DW Offset PEFunction_Alt_Home - - DB 2 - DW 1CFh - DW Offset PEFunction_Alt_End - - DB 0 - DW 1C7h - DW Offset PEFunction_Home - - DB 0 - DW 1CFh - DW Offset PEFunction_End - - DB 3 - DW 1C9h - DW PEFunction_Ctrl_PgUp - - DB 3 - DW 1D1h - DW PEFunction_Ctrl_PgDn - - DB 2 ; Alt... - DW 1CBh ; Left Arrow - DW Offset PEFunction_AltLeft - - DB 2 ; Alt... - DW 1CDh ; Right Arrow - DW Offset PEFunction_AltRight - - DB 3 ; Ctrl... - DW 1CBh ; Left Arrow - DW Offset PEFunction_ViewLeft - - DB 3 - DW 1CDh - DW Offset PEFunction_ViewRight - - DB 2 ; Alt... - DW 1C8h ; Up Arrow - DW Offset PEFunction_AltUp - - DB 2 - DW 1D0h - DW Offset PEFunction_AltDown - - DB 3 - DW 1C7h - DW Offset PEFunction_Ctrl_Home - - DB 3 - DW 1CFh - DW Offset PEFunction_Ctrl_End - - DB 4 - DW 1C8h - DW Offset PEFunction_Up - - DB 4 - DW 1D0h - DW Offset PEFunction_Down - - DB 4 - DW 1CBh - DW Offset PEFunction_AltLeft - - DB 4 - DW 1CDh - DW Offset PEFunction_AltRight - - DB 4 - DW 1C9h - DW PEFunction_ShiftPgUp - - DB 4 - DW 1D1h - DW PEFunction_ShiftPgDn - - DB 4 - DW 1C7h - DW Offset PEFunction_Home - - DB 4 - DW 1CFh - DW Offset PEFunction_End - - DB 4 - DW 12Ah - DW Offset PEFunction_Press_Shift - - DB 4 - DW 136h - DW Offset PEFunction_Press_Shift - - DB 0 - DW 2Ah - DW Offset PEFunction_Release_Shift - - DB 0 - DW 36h - DW Offset PEFunction_Release_Shift - - DB 0 - DW 10Fh - DW Offset PEFunction_Tab - - DB 4 - DW 10Fh - DW Offset PEFunction_ShiftTab - - DB 1 - DW ',' - DW Offset PEFunction_SetMask - - DB 0 - DW 1D2h - DW Offset PEFunction_Insert - - DB 0 - DW 1D3h ; Delete - DW Offset PEFunction_Delete - - DB 2 ; Alt... - DW 1D2h ; Insert - DW Offset PEFunction_RowInsert - - DB 2 ; Alt... - DW 1D3h ; Delete - DW Offset PEFunction_RowDelete - - DB 3 ; Ctrl... - DW 1D2h ; Insert - DW Offset PEFunction_RollDown - - DB 3 ; Ctrl... - DW 1D3h ; Delete - DW Offset PEFunction_RollUp - - DB 0 - DW 10Eh - DW Offset PEFunction_BackSpace - - DB 3 ; Ctrl... - DW 10Eh ; Backspace - DW Offset PEFunction_Undo - - DB 1 - DW '<' - DW Offset PEFunction_DecreaseInstrument - - DB 1 - DW '>' - DW Offset PEFunction_IncreaseInstrument - - DB 1 - DW ';' - DW Offset PEFunction_DecreaseInstrument - - DB 1 - DW "'" - DW Offset PEFunction_IncreaseInstrument - - DB 3 ; Ctrl - DW 1C8h - DW Offset PEFunction_DecreaseInstrument - - DB 3 - DW 1D0h - DW Offset PEFunction_IncreaseInstrument - - DB 1 - DW 3000h ; Alt 'B' - DW Offset PEFunction_MarkBeginBlock - - DB 1 - DW 3100h ; Alt 'N' - DW Offset PEFunction_ToggleMultiChannel - - DB 1 - DW 1200h ; Alt 'E' - DW Offset PEFunction_MarkEndBlock - - DB 1 - DW 1600h ; Alt 'U' - DW Offset PEFunction_UnMarkBlock - - DB 1 - DW 1700h ; Alt 'I' - DW Offset PEFunction_ToggleTemplate - - DB 1 - DW ':' - DW Offset PEFunction_TemplateOff - - DB 1 - DW 2000h ; Alt 'D' - DW Offset PEFunction_AltD - - DB 1 - DW 1F00h ; Alt 'S' - DW Offset PEFunction_AltS - - DB 1 - DW 2500h ; Alt 'K' - DW Offset PEFunction_AltK - - DB 1 - DW 2C00h ; Alt 'Z' - DW Offset PEFunction_WipeBlock - - DB 1 - DW 2600h ; Alt 'L' - DW Offset PEFunction_AltL - - DB 1 - DW 1800h ; Alt 'O' - DW Offset PEFunction_BlockOverwrite - - DB 1 - DW 1900h ; Alt 'P' - DW Offset PEFunction_BlockPaste - - DB 1 - DW 2E00h ; Alt 'C' - DW Offset PEFunction_BlockCopy - - DB 1 - DW 3h ; Ctrl 'C' - DW Offset PEFunction_ToggleCentralise - - DB 0 - DW 146h ; Scroll Lock - DW Offset PEFunction_ToggleTrace - - DB 2 ; Alt Scroll Lock - DW 146h - DW Offset MIDIInputToggle - - DB 1 - DW 3200h ; Alt 'M' - DW Offset PEFunction_BlockMix - - DB 1 - DW 1000h ; Alt 'Q' - DW Offset PEFunction_SemiUp - - DB 1 - DW 1E00h ; Alt 'A' - DW Offset PEFunction_SemiDown - - DB 1 - DW 2D00h ; Alt 'X' - DW Offset PEFunction_WipeCommands - - DB 1 - DW 2400h ; Alt 'J' - DW Offset PEFunction_VolumeAmp - - DB 1 ; Ctrl... - DW 0Ah ; 'J' - DW Offset ToggleFastVolume - - DB 1 - DW 2F00h ; Alt 'V' - DW Offset PEFunction_BlockVolume - - DB 1 - DW 1100h ; Alt 'W' - DW Offset PEFunction_WipeExcessVolumes - - DB 1 - DW 1400h ; Alt 'T' - DW Offset PEFunction_ViewTrack - - DB 1 ; Ctrl... - DW 14h ; 'T' - DW Offset PEFunction_ToggleTracking - - DB 1 ; Ctrl... - DW 8h ; 'H' - DW Offset PEFunction_ToggleRowHilight - - DB 1 - DW 2300h ; Alt 'H' - DW Offset PEFunction_ToggleDivision - - DB 1 - DW 1300h ; Alt 'R' - DW Offset PEFunction_ClearViews - - DB 1 - DW 1500h ; Alt 'Y' - DW Offset PEFunction_BlockSwap - - DB 1 - DW 2200h ; Alt 'G' - DW Offset PEFunction_BlockHalve - - DB 1 - DW 2100h ; Alt 'F' - DW Offset PEFunction_BlockDouble - -; DB 0 -; DW 14Eh ; Grey Plus -; DW Offset PEFunction_NextPattern -; -; DB 0 -; DW 14Ah ; Grey Minus -; DW Offset PEFunction_LastPattern - - DB 4 ; Shift - DW 14Eh - DW Offset PEFunction_Next4Patterns - - DB 4 - DW 14Ah - DW Offset PEFunction_Last4Patterns - - DB 3 ; Ctrl.. - DW 14Eh ; Grey Plus - DW Offset PEFunction_NextOrderPattern - - DB 3 ; Ctrl.. - DW 14Ah ; Grey Minus - DW Offset PEFunction_LastOrderPattern - - DB 1 - DW '+' - DW Offset PEFunction_NextPattern - - DB 1 - DW '-' - DW Offset PEFunction_LastPattern - - DB 3 ; Ctrl - DW 141h ; F7 - DW Offset PEFunction_SetPlayMark - - DB 2 - DW 10Bh - DW Offset PEFunction_Alt0 - - DB 2 ; Alt Backspace - DW 10Eh - DW Offset PEFunction_RestoreData - - DB 2 ; Alt.. - DW 11Ch ; Enter - DW Offset PEFunction_StoreCurrentPattern - - DB 0 - DW 0B02h ; Left-Shift, Left-Ctrl '1' - DW Offset PEFunction_Ctrl_Shift1 - - DB 0 - DW 0B03h ; Left-Shift, Left-Ctrl '2' - DW Offset PEFunction_Ctrl_Shift2 - - DB 0 - DW 0B04h ; Left-Shift, Left-Ctrl '3' - DW Offset PEFunction_Ctrl_Shift3 - - DB 0 - DW 0B05h ; Left-Shift, Left-Ctrl '4' - DW Offset PEFunction_Ctrl_Shift4 - - DB 3 ; Ctrl.. - DW 10Bh ; '0' - DW Offset PEFunction_Ctrl0 - - DB 3 ; Ctrl... - DW 102h ; '1' - DW Offset PEFunction_Ctrl1 - - DB 3 ; Ctrl... - DW 103h ; '2' - DW Offset PEFunction_Ctrl2 - - DB 3 ; Ctrl... - DW 104h ; '3' - DW Offset PEFunction_Ctrl3 - - DB 3 ; Ctrl... - DW 105h ; '4' - DW Offset PEFunction_Ctrl4 - - DB 3 ; Ctrl... - DW 106h ; '5' - DW Offset PEFunction_Ctrl5 - - DB 1 - DW '\' - DW Offset PEFunction_Alt_F9 - - DB 0 - DW 135h - DW Offset PEFunction_MuteNext - - DB 1 - DW '?' - DW Offset PEFunction_MutePrevious - - DB 2 ; Alt - DW 143h ; F9 - DW Offset PEFunction_Alt_F9 - - DB 1 - DW '|' - DW Offset PEFunction_SoloGotoNext - - DB 2 ; Alt \ - DW 12Bh - DW Offset PEFunction_UnmuteAll - - DB 2 ; Alt - DW 144h ; F10 - DW Offset PEFunction_Alt_F10 - - DB 3 ; Ctrl - DW 140h ; F6 - DW Offset PE_PlayCurrentPosition - - DB 3 ; Ctrl - DW 13Ch ; F2 - DW Offset PE_SetPatternLength - - DB 1 ; Ctrl 'V' - DW 16h - DW Offset PE_ToggleDefaultVolume - - DB 1 ; Ctrl 'Z' - DW 1Ah - DW Offset PE_CycleMIDIPlayTrigger - - DB 6 ; MIDI message - DW 8000h - DW Offset PE_MIDINoteOff - - DB 6 ; MIDI message - DW 9000h - DW Offset PE_MIDINote - - DB 6 ; MIDI message - DW 0A000h - DW Offset PE_MIDIAftertouch - - DB 0FFh - -CursorPositions DB 0, 2, 4, 5, 7, 8, 10, 11, 12 - DB 0, 2, 3, 4, 5, 6, 7, 8, 9 - DB 0, 2, 3, 3, 4, 4, 5, 6, 6 - - DB 20h, 2, 1, 2, 1, 2, 0, 1, 2 - DB 10h, 1, 0, 1, 0, 1, 0, 1, 1 - -MaskChange DB 0, 0, 1, 1, 2, 2, 4, 4, 4 -ChannelMsg DB " Channel xx ", 0 -ChannelMsg2 DB "Channel xx", 0 -ChannelMsg3 DB " Chnl xx", 0 -ChannelMsg4 DB " xx", 0 -ChannelMsg5 DB "xx", 0 -ChannelMsg6 DB "Ch xx", 0 -ChannelMsg7 DB "Chnl xx", 0 - -NoteNames Label Byte - DB "C-C#D-D#E-F-F#G-G#A-A#B-" ; Cmaj -StartChannelEdit DW 5 - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ -; Don't change order of variables within here!!!! - -KeySignature DW 0 -NumChannelsEdit DW 5 - -RowHiLight1 DB 4 -RowHiLight2 DB 16 - -EditMask DB 3 ; Bit 0 = ins - ; Bit 1 = vol - ; Bit 2 = commands -ViewDivision DB 1 -ViewWidth DW 0 -ViewChannels DW 100 Dup (0FFFFh) ; Contains channel/viewmethod -ViewChannelTracking DB 0 -CommandToValue DB 0 -CentraliseCursor DB 0E8h ; Bit 0 = centralise cursor - ; Bit 1 = hilight row - ; Bit 2 = fast volume changes - ; Bit 3 = Record tick base - ; Bit 4 = Program base 1 - ; Bit 5 = Record note off - ; Bit 6 = Record velocity - ; Bit 7 = Record aftertouch -MIDIAmplification DB 100 -MIDICentralNote DB 60 -FastVolumeAmplification DW 67 -Flags DB 0 ; Extra flags - ; Bit 0 = display defaults. - ; Bit 1 = Record note cuts. - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -ViewMethodInfo Label - DW Offset ViewFull - DW 13 ; Width - - DW Offset ViewCompress - DW 10 ; Width - - DW Offset ViewAllSmall - DW 7 - - DW Offset ViewNote - DW 3 - - DW Offset ViewTiny - DW 2 - -EmptyData DB 253, 0, 255, 0, 0 - -TempNumbers DB 3 Dup (0) - -ErrorMsg DB "Unable to allocate memory for pattern edit area.", 13, 10 - DB "Sorry, more conventional memory is required to run this program.", 13, 10, "$" - -ViewChannelTrackingMsg DB "View-Channel cursor tracking enabled", 0 -NoViewChannelTrackingMsg DB "View-Channel cursor tracking disabled", 0 -CentraliseCursorMsg DB "Centralise cursor enabled", 0 -NoCentraliseCursorMsg DB "Centralise cursor disabled", 0 -TraceMsg DB "Playback tracing enabled", 0 -NoTraceMsg DB "Playback tracing disabled", 0 -PanningControlSetMsg DB "Panning control set", 0 -VolumeControlSetMsg DB "Volume control set", 0 -NoRowHilightMsg DB "Row hilight disabled", 0 -RowHilightMsg DB "Row hilight enabled", 0 -NoFastVolumeMsg DB "Alt-I / Alt-J fast volume changes disabled", 0 -FastVolumeMsg DB "Alt-I / Alt-J fast volume changes enabled", 0 -FastVolumeNotEnabledMsg DB "Alt-I / Alt-J fast volume changes not enabled", 0 -DefaultVolumeOn DB "Default volumes enabled", 0 -DefaultVolumeOff DB "Default volumes disabled", 0 -MIDIInputDisabledMsg DB "MIDI Input Disabled", 0 -MIDIInputEnabledMsg DB "MIDI Input Enabled", 0 -MIDIInputEnabled DB 1 - -LastNote DB 60 -LastInstrument DB 1 -LastVolume DB 0FFh -LastCommand DB 0 -LastCommandValue DB 0 -TracePlayback DB 0 - -OrderListKeys Label - -IF ORDERSORT - DB 1 - DW 1300h ; Alt-R - DW Offset PE_PostOrderListReorder -ENDIF - - DB 0 - DW 10Fh - DW Offset PE_PostOrderList20 - - DB 1 - DW 0F00h - DW Offset PE_PostOrderList21 - - DB 3 ; Ctrl-F7 - DW 141h - DW Offset PE_PostOrderListNextOrder - - DB 1 ; Spacebar - DW ' ' - DW Offset PE_PostOrderListNextOrder - - DB 0 - DW 1C8h ; Up - DW Offset PE_PostOrderList1 - - DB 0 - DW 1D0h ; Down - DW Offset PE_PostOrderList3 - - DB 0 - DW 1C9h ; PgUp - DW Offset PE_PostOrderList4 - - DB 0 - DW 1D1h ; PgDn - DW Offset PE_PostOrderList6 - - DB 0 - DW 1CBh ; Left - DW Offset PE_PostOrderList7 - - DB 0 - DW 1CDh ; Right - DW Offset PE_PostOrderList9 - - DB 5 - DW 'G' - DW Offset PE_PostOrderList24 - - DB 1 - DW '-' - DW Offset PE_PostOrderList16 - - DB 1 - DW '+' - DW Offset PE_PostOrderList17 - - DB 0 - DW 1D3h ; Insert - DW Offset PE_PostOrderList18 - - DB 0 - DW 1D2h ; Delete - DW Offset PE_PostOrderList19 - - DB 0 - DW 1CFh ; End - DW PE_PostOrderListEndKey - - DB 0 - DW 1C7h - DW PE_PostOrderListHomeKey - - DB 5 - DW 'N' - DW PE_PostOrderList22 - - DB 0FFh - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc PE_ConvAX2Num Far ; ES:DI points to screen - ; CH = colour - ; AX = number - - Push AX - Push BX - Push DX - - Mov BX, 10 - - And AX, AX - JNS PE_ConvAX2Num1 - - Mov Byte Ptr [ES:DI], '-' - Inc DI - Neg AX - Mov [ES:DI], CH - Inc DI - Jmp PE_ConvAX2Num2 - -PE_ConvAX2Num1: - Xor DX, DX - Div BX - Add DL, '0' - Mov DH, CH - Mov [ES:DI+4], DX - -PE_ConvAX2Num2: - Xor DX, DX - Div BX - Add DL, '0' - Mov DH, CH - Mov [ES:DI+2], DX - - Xor DX, DX - Div BX - Add DL, '0' - Mov DH, CH - Mov [ES:DI], DX - - Pop DX - Pop BX - Pop AX - - Ret - -EndP PE_ConvAX2Num - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_ConvHexAL Near - - Cmp AL, 10 - SBB AL, 69h - DAS - StosW - - Ret - -EndP PE_ConvHexAL - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_GetMaxOrder Far ; Returns AX with max order - - Push CX - Push ES - Push DI - - Call Music_GetSongSegment - Mov ES, AX - Mov DI, 256 - Mov CX, 257 - Mov AL, 0FFh - RepNE ScasB - Mov AX, 256 - Sub AX, CX - - And AX, AX - JZ PE_GetMaxOrder1 - - Dec AX - -PE_GetMaxOrder1: - Pop DI - Pop ES - Pop CX - - Ret - -EndP PE_GetMaxOrder - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ClearEncodingInfo ; Encoding info - ; 1.Mask, 2.Instrument, 3.Volume, 4.Cmd - ; 5.CmdVal, 6.Note - - Push CS - Pop ES - - Mov DI, Offset EncodingInfo - - Mov CX, 64 - -ClearEncodingInfo1: - Mov AX, NONOTE*100h ; Mask&Note - StosW - Mov AH, 0FFh ; Ins&Vol - StosW - Xor AX, AX ; Cmd&Value - StosW - - Loop ClearEncodingInfo1 - - Ret - -EndP ClearEncodingInfo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF ORDERSORT - -Proc PE_PostOrderListSwapPatterns ; Given BX = pattern 1 - ; DX = Pattern 2 - - PushA - - Mov AX, CS:PatternNumber - - Cmp AX, BX - JNE PE_PostOrderListSwapPatterns1 - Mov AX, DX - Jmp PE_PostOrderLIstSwapPatterns2 - -PE_PostOrderListSwapPatterns1: - Cmp AX, DX - JNE PE_PostOrderListSwapPatterns2 - Mov AX, BX - -PE_PostOrderListSwapPatterns2: - Mov CS:PatternNumber, AX - -; Search through order list and swap BX with DX - - Mov SI, 100h - Mov CX, SI - -PE_PostOrderListSwapPatterns3: - LodsB - - Cmp AL, BL - JNE PE_PostOrderListSwapPatterns4 - - Mov [SI-1], DL - Jmp PE_PostOrderListSwapPatterns5 - -PE_PostOrderListSwapPatterns4: - Cmp AL, DL - JNE PE_PostOrderListSwapPatterns5 - - Mov [SI-1], BL - -PE_PostOrderListSwapPatterns5: - Loop PE_PostOrderListSwapPatterns3 - -; Now swap memory references to patterns. - - LEA BX, [EBX*4+63912] - LEA DI, [EDX*4+63912] - - Mov EAX, [BX] - XChg EAX, [DI] - Mov [BX], EAX - -; Finished! - - PopA - Ret - -EndP PE_PostOrderListSwapPatterns - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PostOrderListReorder Far - - EnsureNoNetwork - - Call Music_Stop - - Call Music_GetSongSegment - Mov DS, AX ; DS:100h = order list. - ; DS:63912 (4) = pattern data - Mov SI, 100h - Xor DX, DX ; DX = min pattern - Mov CX, SI - Xor BX, BX - -PE_PostOrderListReorder1: - LodsB - Cmp AL, 200 - JAE PE_PostOrderListReorder2 - - Cmp AL, DL - JB PE_PostOrderListReorder2 - JE PE_PostOrderListReorder3 - - Mov BL, AL - Call PE_PostOrderListSwapPatterns - -PE_PostOrderListReorder3: - Inc DX - -PE_PostOrderListReorder2: - Loop PE_PostOrderListReorder1 - -PE_PostOrderListReorderExit: - Mov AX, 1 - Ret - -EndP PE_PostOrderListReorder - Assume DS:Nothing - -ENDIF ; ORDERSORT - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_ResetOrderPattern Far - - Push CS - Pop DS - Assume DS:Pattern - - Xor AX, AX - Mov Order, AX - Mov OrderCursor, AX - Mov Channel, AX - Mov PatternCursor, AX - Mov LastInstrument, 1 - Mov PlayMarkOn, 0 - - Mov BX, AX - - Call Music_GetSongSegment - Mov ES, AX - MovZX AX, Byte Ptr [ES:BX+256] - - Cmp AX, 199 - JBE PE_ResetOrderPattern1 - - Xor AX, AX - -PE_ResetOrderPattern1: - Mov PatternNumber, AX - Call NewPattern - Mov Word Ptr [CS:Modified], 0 - - Call Music_InitMixTable ; Here 'cos it's called - ; on file loading. - Call Music_InitMuteTable ; ditto. - Call Music_InitStereo - Call Music_SoundCardLoadAllSamples - Call PE_ClearUndoBuffer - - Mov AX, Inst - Mov DS, AX - Assume DS:Inst - Mov NodeHeld, 0 - Mov InstrumentEdit, 0 - - Ret - -EndP PE_ResetOrderPattern - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_GetMaxPattern Far ; Assumes DS:SongData - - Push CX - Push DS - Push SI - Push DI - - Call Music_GetSongSegment - Mov DS, AX - - Mov SI, 63912 - - Xor AX, AX - Xor DI, DI - Mov CX, 200 - -PE_GetMaxPattern1: - Cmp Word Ptr [SI], 0 - JE PE_GetMaxPattern2 - - Mov AX, DI - -PE_GetMaxPattern2: - Inc DI - Add SI, 4 - Loop PE_GetMaxPattern1 - - Pop DI - Pop SI - Pop DS - Pop CX - Ret - -EndP PE_GetMaxPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_FillHeader Far - - Call Music_GetSongSegment - Mov DS, AX - Call S_GetDestination - Mov SI, 4 - Mov DI, (12+3*80)*2 - Mov CX, 25 - Mov AH, 5 - -PE_FillHeader1: - LodsB - Cmp AL, 226 - JB PE_FillHeader14 - - Mov AL, ' ' - -PE_FillHeader14: - StosW - Loop PE_FillHeader1 - - Push DS - - Mov AX, Disk - Mov DS, AX - Mov SI, Offset FileName - Mov DI, (12+4*80)*2 - Mov AH, 5 - -PE_FillHeader11: - LodsB - StosW - And AL, AL - JNZ PE_FillHeader11 - - Pop DS - - Mov CH, AH - Mov AX, Order - Mov DI, (12+5*80)*2 - Call PE_ConvAX2Num - - Call PE_GetMaxOrder - Mov DI, (16+5*80)*2 - Call PE_ConvAX2Num - - Mov AX, PatternNumber - Mov DI, (12+6*80)*2 - Call PE_ConvAX2Num - - Call PE_GetMaxPattern - Mov DI, (16+6*80)*2 - Call PE_ConvAX2Num - - Mov AX, Row - Mov DI, (12+7*80)*2 - Call PE_ConvAX2Num - - Mov AX, MaxRow - Mov DI, (16+7*80)*2 - Call PE_ConvAX2Num - - Call Glbl_GetHeaderMode - ; AL = inst - ; AH = mode. - Mov DI, (50+3*80)*2 - And AL, AL - JNZ PE_FillHeader6 - - Mov AX, 5*256+'.' - StosW - StosW - ScasW -; Add DI, 2 - Mov AL, '.' - Mov CX, 25 - Rep StosW - Jmp PE_FillHeader7 - -PE_FillHeader6: - Push AX - - Mov DL, 10 - Xor AH, AH - Mov CX, AX - Div DL - Add AX, 3030h - Mov DL, AH - Mov AH, 5 - StosW - Mov AL, DL - StosW - ScasW -; Add DI, 2 - - Pop AX - - Dec CX - And AH, AH ; CX = ins number - JZ PE_FillHeader8 - - ; Complex instrument mode - Mov AX, 554 - Mul CX - Add AX, 544 - Jmp PE_FillHeader9 - -PE_FillHeader8: ; Simple instrument mode - Mov AX, 80 - Mul CX - Add AX, 55932 - -PE_FillHeader9: - Mov SI, AX - Mov CX, 25 - Mov AH, 5 - -PE_FillHeader10: - LodsB - Cmp AL, 226 - JB PE_FillHeader13 - - Mov AL, ' ' - -PE_FillHeader13: - StosW - Loop PE_FillHeader10 - -PE_FillHeader7: -; Mov AL, LastVolume - - Call PE_FillSpeedTempo - -; Cmp AL, 0FFh -; JNE PE_FillHeader4 -; -; Mov AX, 5*256+'.' -; StosW -; StosW -; Jmp PE_FillHeader5 -; -;PE_FillHeader4: -; Xor AH, AH -; Mov CL, 10 -; Div CL -; Add AX, 3030h -; Mov DL, AH -; Mov AH, 5 -; StosW -; Mov AL, DL -; StosW - -PE_FillHeader5: - Mov AX, BaseOctave - Add AL, '0' - Mov AH, 5 - Mov [ES:((50+5*80)*2)], AX - -; Mov AH, 48h -; Mov BX, 0FFFFh -; Int 21h -; Mov AX, BX -; Mov CX, 2006h -; ShR AX, CL -; Mov DI, (71+6*80)*2 -; Call PE_ConvAX2Num -; -; Call E_GetFreeEMS -; Xor DX, DX -; Mov BX, 1000 -; Div BX -; -; Add AL, '0' -; Mov AH, CH -; Mov [ES:(70+7*80)*2], AX -; Mov AX, DX -; Mov DI, (71+7*80)*2 -; Call PE_ConvAX2Num - - -; Call K_GetCaps -; Mov AH, 21h -; And AL, AL -; JZ PE_FillHeader2 -; -; Mov AH, 23h -; -;PE_FillHeader2: -; Mov DI, (75+10*80)*2 -; Mov SI, Offset CapsMsg -; Mov CX, 4 -; -;PE_FillHeader3: -; SegCS LodsB -; StosW -; Loop PE_FillHeader3 - - Call UpdateInfoLine - - Ret - -EndP PE_FillHeader - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_FillSpeedTempo Far - - Call S_GetDestination - - Call Music_GetDisplayVariables ; AX = current speed. - Mov CH, 5 - Mov DI, (50+4*80)*2 - Call PE_ConvAX2Num - - Mov AX, BX - Mov DI, (54+4*80)*2 - Call PE_ConvAX2Num - - Ret - -EndP PE_FillSpeedTempo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_DrawOrderList Far - - Mov AL, 80 - Mul Byte Ptr [SI+3] - Add AL, [SI+2] - AdC AH, 0 - Add AX, AX - Mov DI, AX - Mov CX, [SI+4] - - Push CS - Pop DS - Assume DS:Pattern - - Mov AX, TopOrder ; Bounds checking... - Mov BX, Order - Cmp AX, BX - JBE PE_DrawOrderList1 - - Mov AX, BX - -PE_DrawOrderList1: - Mov DX, AX - Add DX, CX - Cmp DX, BX - JA PE_DrawOrderList2 - - LEA AX, [BX+1] - Sub AX, CX - -PE_DrawOrderList2: - Mov TopOrder, AX - Mov BX, AX - - Call S_GetDestination - Push CX - Push DI - -PE_DrawOrderList3: - Push CX - - Mov CH, 20h - Call PE_ConvAX2Num - - Add DI, 160 - Inc AX - - Pop CX - Loop PE_DrawOrderList3 - - Pop DI - Pop CX - Add DI, 8 ; BX = toporder, DI = order area - - Call Music_GetSongSegment - Mov DS, AX - Add BX, 256 - -PE_DrawOrderList4: - Push CX - - Mov CH, 2 - MovZX AX, Byte Ptr [BX] - Cmp AX, 0FEh - JB PE_DrawOrderList5 - - Mov CL, '-' - Cmp AL, 0FEh - JNE PE_DrawOrderList7 - - Mov CL, '+' - -PE_DrawOrderList7: - Mov AX, CX - StosW - StosW - StosW - Sub DI, 6 - - Jmp PE_DrawOrderList6 - - -PE_DrawOrderList5: - Call PE_ConvAX2Num - -PE_DrawOrderList6: - Pop CX - Inc BX - Add DI, 160 - Loop PE_DrawOrderList4 - - Call Music_GetPlayMode - Cmp AX, 2 - JNE PE_DrawOrderList8 - - Jmp PE_ShowOrder - -PE_DrawOrderList8: - Ret - -EndP PE_DrawOrderList - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PreOrderList Far - - Mov AL, 80 - Mov BX, Order - Sub BX, TopOrder - Add BL, [SI+3] - Mul BL - Add AL, [SI+2] - AdC AH, 0 - Add AX, 4 - Add AX, OrderCursor - Add AX, AX - Mov DI, AX - - Call S_GetDestination - Inc DI - Mov Byte Ptr [ES:DI], 30h - - Ret - -EndP PE_PreOrderList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc NetworkOrderList Near - -IF NETWORKENABLED - Call Network_GetSendQueue - JZ NetworkOrderList1 - - Mov AX, NETWORK_SONGDATAOBJECT*100h ; Destination ALL - StosW - Mov AX, 256 - StosW - StosW - -NetworkOrderList1: - Call Network_FinishedSendQueue -ENDIF - Ret - -EndP NetworkOrderList - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PostOrderList Far - - Push ES - Pop DS - Mov SI, [BX] - - Push BX - - Mov AL, 80 - Mov BX, Order - Sub BX, TopOrder - Add BL, [SI+3] - Mul BL - Add AL, [SI+2] - AdC AH, 0 - Add AX, 4 - - Pop BX - -; Push ES -; Push DI - - Push CS - Pop DS - Assume DS:Pattern - - Push ES - Pop FS - - Call Music_GetSongSegment - Mov ES, AX - - Mov SI, Offset OrderListKeys - Call M_FunctionDivider - Mov AX, Order - JC PE_NoKeyFound - - Jmp [SI] - -PE_NoKeyFound: - Test CH, Not 1 - JNZ PE_PostOrderList10 - - Cmp DX, '0' - JB PE_PostOrderList10 - - Cmp DX, '9' - JBE PE_PostOrderList11 - -PE_PostOrderList10: - Xor AX, AX - Ret - -PE_PostOrderListNextOrder: - Call Music_GetPlayMode - Cmp AX, 2 - JNE PE_PostOrderListNextOrderEnd - - Mov AX, Order - Mov SI, Offset NextOrderMsg - Call SetInfoLine - - Call Music_SetNextOrder - -PE_PostOrderListNextOrderEnd: - Mov AX, 1 - Ret - -PE_PostOrderListHomeKey: - Mov Order, 0 - Jmp PE_PostOrderList2 - -PE_PostOrderListEndKey: - Call Music_GetSongSegment - Mov DS, AX - Mov SI, 100h - -PE_PostOrderListEndKeyLoop: - LodsB - Cmp AL, 0FFh - JE PE_postOrderListEndKeyLoopEnd - - Cmp SI, 100h+255 - JBE PE_PostOrderListEndKeyLoop - -PE_PostOrderListEndKeyLoopEnd: - Sub SI, 101h - Mov CS:Order, SI - - Jmp PE_PostOrderList2 - -PE_PostOrderList20: - Push FS - Pop DS - Mov SI, [BX] - - Mov AX, [SI+6] - Mov [DI], AX - Jmp PE_PostOrderList2 - -PE_PostOrderList21: - Push FS - Pop DS - Mov SI, [BX] - - Mov AX, [SI+8] - Mov [DI], AX - Jmp PE_PostOrderList2 - -PE_PostOrderList1: ; Up - And AX, AX - JZ PE_PostOrderList2 - - Dec AX - Mov Order, AX - -PE_PostOrderList2: - Mov AX, 1 - Ret - -PE_PostOrderList3b: - Call NetworkOrderList - -PE_PostOrderList3: ; Down - Cmp AX, 255 - JAE PE_PostOrderList2 - Inc AX - Mov Order, AX - Jmp PE_PostOrderList2 - -PE_PostOrderList4: ; PgUp - Sub AX, 16 - JNS PE_PostOrderList5 - - Xor AX, AX - -PE_PostOrderList5: - Mov Order, AX - Jmp PE_PostOrderList2 - -PE_PostOrderList6: ; PgDn - Add AX, 16 - And AH, AH - JZ PE_PostOrderList5 - - Mov AX, 255 - Jmp PE_PostOrderList5 - -PE_PostOrderList7: ; Left - Mov AX, OrderCursor - Dec AX - JNS PE_PostOrderList8 - - Mov AX, 2 - -PE_PostOrderList8: - Mov OrderCursor, AX - Jmp PE_PostOrderList2 - -PE_PostOrderList9: ; Right - Mov AX, OrderCursor - Inc AX - Cmp AX, 2 - JBE PE_PostOrderList8 - - Xor AX, AX - Jmp PE_PostOrderList8 - -PE_PostOrderList11: - Mov SI, AX - MovZX AX, Byte Ptr [ES:SI+256] ; AX = pattern number - Cmp AL, 199 - JBE PE_PostOrderList15 - - Xor AL, AL - -PE_PostOrderList15: ; Number - Mov CL, 10 - Div CL - Mov [TempNumbers+2], AH - Xor AH, AH - Div CL - Mov [TempNumbers+1], AH - Xor AH, AH - Div CL - Mov [TempNumbers], AH - - Mov BX, OrderCursor - Sub DX, '0' - Mov TempNumbers[BX], DL - - Mov AL, [TempNumbers] - Mul CL - Add AL, [TempNumbers+1] - Mul CL - Add AL, [TempNumbers+2] - - Cmp AX, 199 - JBE PE_PostOrderList12 - - Mov AX, 199 - -PE_PostOrderList12: - Mov [ES:SI+256], AL - Call NetworkOrderList - - Inc BX - Cmp BX, 2 - JBE PE_PostOrderList13 - - Cmp SI, 255 - JE PE_PostOrderList2 - - Xor BX, BX - Inc Order - -PE_PostOrderList13: - Mov OrderCursor, BX - Jmp PE_PostOrderList2 - - -PE_PostOrderList16: ; '-' - Mov SI, AX - Mov Byte Ptr [ES:SI+256], 0FFh - Mov OrderCursor, 0 - - Jmp PE_PostOrderList3b - -PE_PostOrderList17: ; '+' - Mov SI, AX - Mov Byte Ptr [ES:SI+256], 0FEh - Mov OrderCursor, 0 - - Jmp PE_PostOrderList3b - -PE_PostOrderList18: ; Del - Mov SI, AX - Add SI, 256 - Mov DI, SI - Inc SI - - Push ES - Pop DS - - Mov CX, 512 - Sub CX, SI - Rep MovsB - Mov AL, 0FFh - StosB - - Call NetworkOrderList - Jmp PE_PostOrderList2 - -PE_PostOrderList19: ; Ins - Mov CX, 255 - Mov DI, 511 - Mov SI, DI - Sub CX, AX - Dec SI - - Push ES - Pop DS - - StD - Rep MovsB - ClD - Mov AL, 0FFh - StosB - - Call NetworkOrderList - Jmp PE_PostOrderList2 - -PE_PostOrderList22: - Mov SI, Order - And SI, SI - JZ PE_PostOrderList23 - - Mov AL, [ES:SI+255] - Cmp AL, 198 - JA PE_PostOrderList23 - - Inc AX - Mov [ES:SI+256], AL - - Mov AX, SI - Jmp PE_PostOrderList3b - -PE_PostOrderList23: - Xor AX, AX - Ret - -PE_PostOrderList24: ; 'G' - Mov BX, AX - MovZX AX, Byte Ptr [ES:BX+256] - Cmp AL, 200 - JAE PE_PostOrderList23 - - Jmp PE_GotoPattern2 - -EndP PE_PostOrderList - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_UnInitPatternEdit Far - - Mov AX, CS:BlockDataArea - And AX, AX - JZ PE_UnInitPatternEdit1 - - Mov ES, AX - Mov AH, 49h - Int 21h - -PE_UnInitPatternEdit1: - Call PE_ClearUndoBuffer - - Ret - -EndP PE_UnInitPatternEdit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_ClearPatternData - - Push CX DX DS SI ES DI - - Push CS - Pop DS - Assume DS:Pattern - - Mov ES, PatternDataArea - Xor DI, DI - - Mov DX, 200 - -PE_ClearPatternData1: - Mov CX, 320/4 - Mov SI, Offset EmptyRow - Rep MovsD - - Dec DX - JNZ PE_ClearPatternData1 - - Pop DI ES SI DS DX CX - Ret - -EndP PE_ClearPatternData - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_InitPatternEdit Far - - Trace " - Initialising pattern data area" - - Call PE_ClearPatternData - Ret - -EndP PE_InitPatternEdit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include it_pe_v.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_DrawPatternEdit Far - - Push CS - Pop DS - Assume DS:Pattern - - Cmp TracePlayback, 0 - JE PE_TraceOff - - Call Music_GetPlayMode ; AX = playmode - ; BX = current row - ; CX = current pattern - ; DX = order. - Cmp AX, 1 - JB PE_TraceOff - JE PE_NoTraceOrder - - Mov Order, DX - -PE_NoTraceOrder: - Cmp BX, Row - JE PE_SetMIDIChannel - - Mov AX, Channel - Mov MIDIChannel, AX - - Mov Row, BX - -PE_SetMIDIChannel: - Cmp CX, PatternNumber - JE PE_TraceOff - - Push CX ; Pattern number - Push CS - Push Offset PE_TraceTurnOffError - - Cmp PatternModified, 0 - JE PE_NoStoreRequired - - Call PEFunction_StorePattern - -PE_NoStoreRequired: - Pop AX - Pop AX - Pop AX - - Mov PatternNumber, AX - Call NewPattern - Jmp PE_TraceOff - -PE_TraceTurnOffError: - Pop AX - -PE_TraceTurnOff: - Mov CS:TracePlayback, 0 - -PE_TraceOff: - Push CS - Pop DS - - Call S_GetDestination - Mov AL, Template - Cmp AL, 1 - JB PE_DrawPAtternEdit30 - - Mov SI, Offset TemplateMsg1 - JE PE_DrawPatternEdit31 - - Mov SI, Offset TemplateMsg2 - Cmp AL, 3 - JB PE_DrawPatternEdit31 - - Mov SI, Offset TemplateMsg3 - JE PE_DrawPatternEdit31 - - Mov SI, Offset TemplateMsg4 - -PE_DrawPatternEdit31: - Mov DI, (2+12*80)*2 - Mov AH, 23h - Call S_DrawString - -PE_DrawPatternEdit30: - Test CentraliseCursor, 1 - JZ PE_NoCentraliseCursor - - Call PE_CentraliseCursor - -PE_NoCentraliseCursor: - Mov AX, MaxRow - Cmp AX, Row - JAE PE_DrawPatternEdit27 - - Mov Row, AX - -PE_DrawPatternEdit27: - Mov BX, BlockTop - Cmp BX, AX - JLE PE_DrawPatternEdit28 - - Mov BlockTop, AX - -PE_DrawPatternEdit28: - Mov BX, BlockBottom - Cmp BX, AX - JLE PE_DrawPatternEdit29 - - Mov BlockBottom, AX - -PE_DrawPatternEdit29: - Mov BX, ViewWidth - Test BX, BX - JZ PE_DrawPatternEdit1 - - Mov CX, 3 - Cmp NumChannelsEdit, 0 - JE PE_DrawPatternEditNoEditChannels - - Xor CX, CX - -PE_DrawPatternEditNoEditChannels: - Mov AX, 1 - Add AX, CX - Push AX - Push 14 - Mov AX, BX - Add AX, CX - Push AX - Push 47 - Push 27 - Call S_DrawBox - Add SP, 10 - -PE_DrawPatternEdit1: - Cmp NumChannelsEdit, 0 - JE PE_DrawPatternEdit34 - - Mov CX, 4 - Add CX, BX - Push CX - Mov AX, 14 - Push AX - Mul NumChannelsEdit - Add AX, CX - Push AX - Push 47 - Push 27 - Call S_DrawBox - Add SP, 10 - - Mov AX, LeftChannel - Mov CX, Channel - - Cmp AX, CX - JLE PE_DrawPatternEdit21 - - Mov AX, CX - -PE_DrawPatternEdit21: - Mov DX, AX - Add DX, NumChannelsEdit - Cmp DX, CX - JG PE_DrawPatternEdit22 - - Mov AX, CX - Sub AX, NumChannelsEdit - Inc AX - -PE_DrawPatternEdit22: - Mov LeftChannel, AX - ; Channel markers. - Mov DX, AX ; DL = left channel - Mov AX, 5+14*80 - Add AX, ViewWidth - Add AX, AX - Mov DI, AX - Mov DH, 10 - - Mov CX, NumChannelsEdit - -PE_DrawPatternEdit23: - Push CX - - MovZX AX, DL - Inc AX - Div DH - Add AX, 3030h - Mov SI, Offset ChannelMsg - Mov [SI+9], AX - - Push DS - Push SI - - Call Music_GetSongSegment - Mov DS, AX - - Mov SI, DX - And SI, 0FFh - Add SI, 40h - Mov AH, 13h - Test Byte Ptr [SI], 80h - JZ PE_DrawPatternEdit32 - - Mov AH, 10h - -PE_DrawPatternEdit32: - Pop SI - Pop DS - - Mov CX, 12 - -PE_DrawPatternEdit24: - LodsB - StosW - Loop PE_DrawPatternEdit24 - - Pop CX - Add DI, 4 - Inc DX - Loop PE_DrawPatternEdit23 - -PE_DrawPatternEdit34: - Cmp ViewChannelTracking, 0 - JE PE_DrawPatternEditNormal - - ; OK.. using view windows ONLY. - ; now to perform scrolling if necessary. - Mov SI, Offset ViewChannels - Mov DL, [SI] - - Cmp DL, 0FFh - JE PE_DrawPatternEditNormal - - Mov DH, DL ; DL = min channel, DH = max channel - Mov CX, Channel ; Also check - -PE_DrawPatternViewChannelOnly1: - LodsW - - Cmp AL, CL - JE PE_DrawPatternEditNormalJP - - Cmp AL, 0FFh - JE PE_DrawPatternViewChannelOnly2 - - Cmp AL, DL - JB PE_DrawPatternViewChannelOnly3 - - Cmp AL, DH - JA PE_DrawPatternViewChannelOnly4 - - Jmp PE_DrawPatternViewChannelOnly1 - -PE_DrawPatternViewChannelOnly3: - Mov DL, AL - Jmp PE_DrawPatternViewChannelOnly1 - -PE_DrawPatternViewChannelOnly4: - Mov DH, AL - Jmp PE_DrawPatternViewChannelOnly1 - -PE_DrawPatternEditNormalJP: - Jmp PE_DrawPatternEditNormal - -PE_DrawPatternViewChannelOnly2: ; OK.. so channel is not in list, - ; DL = min channel, DH = max channel. - Mov CH, CL - Sub CH, DH ; CH = curchannel-maxchannel - - Cmp DH, CL - JBE PE_DrawPatternViewChannelOnly5 - - Mov CH, CL - Sub CH, DL - -PE_DrawPatternViewChannelOnly5: ; CH = modifier. - - Mov SI, Offset ViewChannels - -PE_DrawPatternViewChannelOnly6: - LodsW - Cmp AL, 0FFh - JE PE_DrawPatternEditNormal - - Add AL, CH - JS PE_DrawPatternViewChannelOnly7 - - Cmp AL, 63 - JBE PE_DrawPatternViewChannelOnly8 - - Mov AL, 63 - Jmp PE_DrawPatternViewChannelOnly8 - -PE_DrawPatternViewChannelOnly7: - Xor AL, AL - -PE_DrawPatternViewChannelOnly8: - Mov [SI-2], AL - Jmp PE_DrawPatternViewChannelOnly6 - -PE_DrawPatternEditNormal: - Mov AX, TopRow - Mov CX, Row - - Cmp AX, CX - JLE PE_DrawPatternEdit2 - - Mov AX, CX ; if row < toprow, toprow = row - -PE_DrawPatternEdit2: - LEA DX, [EAX+32] - Cmp DX, CX - JG PE_DrawPatternEdit3 - - LEA AX, [ECX-31] - -PE_DrawPatternEdit3: - Mov TopRow, AX - - Mov CX, MaxRow - Sub CX, 31 - Cmp AX, CX - JBE PE_DrawPatternEdit35 - - Mov TopRow, CX - Mov AX, CX - -PE_DrawPatternEdit35: - Mov DI, (1+15*80)*2 - Cmp NumChannelsEdit, 0 - JNE PE_DrawPatternEditAllView - - Xor BX, BX - -PE_DrawPatternEditAllView: - LEA DI, [EDI+EBX*2] - - Xor BX, BX - Cmp PlayMarkOn, 0 - JE PE_DrawPlayMark - - Mov CX, PlayMarkPattern - Cmp CX, PatternNumber - JNE PE_DrawPlayMark - - Mov BX, 1 ; Check to draw playmark - -PE_DrawPlayMark: - Push DI - - Mov DX, 32 - -PE_DrawPatternEdit4: - Push DI - - Mov CH, 20h - And BX, BX - JZ PE_DrawPatternEditRowNumber - - Cmp AX, PlayMarkRow - JNE PE_DrawPatternEditRowNumber - - Mov CH, 0B0h - -PE_DrawPatternEditRowNumber: - Call PE_ConvAX2Num - - Pop DI - Inc AX - Add DI, 160 - - Dec DX - JNZ PE_DrawPatternEdit4 - - Mov BX, Offset NoteNames ; CS:BX points to notenames - - Push DS - ; Viewing columns... - Mov SI, Offset ViewChannels - Mov DI, (15*80+2)*2 - Cmp NumChannelsEdit, 0 - JNE PE_DrawviewColumnStart - - Add DI, 6 - -PE_DrawViewColumnStart: - LodsW - Cmp AL, 0FFh - JE PE_DrawViewColumn2 - -PE_DrawViewColumn1: - ; AL = channel, AH = view method. - Mov DL, AL - MovZX CX, AH - LEA BP, [ViewMethodInfo+ECX*4] - - Push DS - Push SI - Push ES - Push DI - Push BP - - Mov SI, 5 - Xor AH, AH - Push DX - Mul SI - Mov SI, AX - Mov AX, 320 - Mov CX, TopRow - Mul CX - Pop DX - Mov DS, PatternDataArea - Add SI, AX ; DS:SI points to appropriate data. - ; CS:BX points to note type. - ; ES:DI points to screen area. - ; DL = Channel number - ; CX = Row number - - Call [Near Ptr CS:BP] - - Pop BP - Pop DI - Pop ES - Pop SI - Pop DS - - LodsW - Cmp AL, 0FFh - JE PE_DrawViewColumn2 - - Push AX - - Mov CX, [CS:BP+2] - Add DI, CX - Add DI, CX - - Cmp ViewDivision, 0 - JE PE_DrawViewColumn4 - - Mov CX, 32 - Push DI - - Mov AX, 2A8h - -PE_DrawViewColumn3: - StosW - Add DI, 158 - Loop PE_DrawViewColumn3 - - Pop DI - StosW ; Just to do: Add DI, 2 - -PE_DrawViewColumn4: - Pop AX - Jmp PE_DrawViewColumn1 - -PE_DrawViewColumn2: - Pop DS - Pop DI - Add DI, 8 - - Cmp NumChannelsEdit, 0 - JE PE_DrawPatternHilightRow - -PE_DrawPatternEdit33: - Mov AX, 320 - Mov BP, TopRow - Mul BP - Mov SI, AX - Mov AX, 5 - Mul LeftChannel - Add SI, AX ; SI contains offset to channel data - Mov DX, NumChannelsEdit - - Mov CX, 32 ; 32 rows - Mov DS, PatternDataArea - Assume DS:Nothing - -PE_DrawPatternEdit5: - Push CX - Push DX - Push SI - Push DI - Push BP - - Mov CX, 60Ch - - Mov AX, BP - Cmp RowHiLight2, 0 - JZ PE_DrawPatternEdit8 - Div RowHiLight2 - And AH, AH - JNZ PE_DrawPatternEdit8 - - Mov CH, 0E6h - Jmp PE_DrawPatternEdit6 - -PE_DrawPatternEdit8: - Mov AX, BP - Cmp RowHiLight1, 0 - JZ PE_DrawPatternEdit6 - Div RowHiLight1 - And AH, AH - JNZ PE_DrawPatternEdit6 - - Mov CH, 0F6h - -PE_DrawPatternEdit6: ; CH = colour, CL = 12 (for division) - Push CX - Push DX - - Cmp CS:BlockMark, 0 - JE PE_DrawPatternEdit25 - - Cmp BP, CS:BlockTop - JB PE_DrawPatternEdit25 - - Cmp BP, CS:BlockBottom - JA PE_DrawPatternEdit25 - - Mov AX, CS:LeftChannel - Add AX, CS:NumChannelsEdit - Sub AX, DX - - Cmp AX, CS:BlockLeft - JB PE_DrawPatternEdit25 - - Cmp AX, CS:BlockRight - JA PE_DrawPatternEdit25 - - Test CH, 80h - JZ PE_DrawPatternEdit26 - - Mov CH, 93h - Jmp PE_DrawPatternHilight1 - -PE_DrawPatternEdit26: - Mov CH, 83h - Jmp PE_DrawPatternHilight1 - -PE_DrawPatternEdit25: - Cmp BP, Row - JNE PE_DrawPatternHilight1 - - Test CentraliseCursor, 2 - JZ PE_DrawPatternHilight1 - - Mov CH, 016h - -PE_DrawPatternHilight1: - LodsB - - Call Draw_3Note - - Mov AL, 20h - StosW ; Note->Instrument space - - Mov DL, 10 - LodsB - - Call Draw_2Instrument - - Mov AL, 20h - StosW - - LodsB - Cmp AL, 0FFh - JNE PE_DrawPattern16 - - Test CS:Flags, 1 - JZ PE_DrawPatternNoDefaultVolume - - Cmp Byte Ptr [SI-3], MAXNOTE - JA PE_DrawPatternNoDefaultVolume - Cmp Byte Ptr [SI-2], 0 - JE PE_DrawPatternNoDefaultVolume - - Sub DI, 2 - Mov AL, 191 - StosW - - Push BX - - Call Music_GetSongSegment - Mov FS, AX - Mov BL, [SI-2] ; Sample/Instrument - And BX, 0FFh - Add BX, BX - - Test Byte Ptr [FS:2Ch], 4 ; Sample mode? - JZ DefaultVolumeSample - -DefaultVolumeInstrument: - Push DI - - Mov BX, [FS:64710+BX] ; Instrument pointer - Mov DI, [SI-3] - And DI, 0FFh ; DI = Note - Add DI, DI - Mov BX, [FS:BX+DI+41h] ; BL = sample - - Pop DI - And BX, 0FFh - Add BX, BX - JZ DefaultVolumeNoSample - -DefaultVolumeSample: - Mov BX, [FS:64910+BX] ; Sample - Mov AL, [FS:BX+13h] ; Default volume - - Pop BX - Mov DL, 10 - Xor AH, AH - Div DL - Add AX, '00' - Mov DH, AH - Mov AH, CH - StosW - Mov AL, DH - StosW - Mov AL, 192 - StosW - Jmp PE_DrawPatternEffect - -DefaultVolumeNoSample: - Pop BX - - Mov AH, CH - Mov AL, 173 ; Replace with default volume - StosW - StosW - Mov AL, 192 - StosW - Jmp PE_DrawPatternEffect - -PE_DrawPatternNoDefaultVolume: - Mov AL, 173 ; '.' - StosW - StosW - Jmp PE_DrawPattern17 - -PE_DrawPattern16: - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC PE_DrawPatternNoVEffect - - Test AL, 80h - JZ PE_DrawPatternVEffect1 - - Add AH, 60 - -PE_DrawPatternVEffect1: - Mov AL, AH - Xor AH, AH - Div DL - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov DH, AH - Mov AH, CH - StosW - Mov AL, DH - StosW - - Jmp PE_DrawPattern17 - -PE_DrawPatternNoVEffect: - Mov CL, CH - - Test AL, 80h - JZ PE_DrawPatternNoPan - - And CL, 0F0h - Or CL, 2 - And AL, 7Fh ; Filter out panning stuff. - - -PE_DrawPatternNoPan: - Xor AH, AH - Div DL - ; AH = units, AL = tens - Mov DH, AH - Mov AH, CL - Add AL, '0' - StosW - Mov AL, DH - Add AL, '0' - StosW - - Mov AH, CH - -PE_DrawPattern17: - Mov AL, 20h - StosW - -PE_DrawPatternEffect: - LodsB - Add AL, 64 - Cmp AL, 64 - JNE PE_DrawPattern18 - - Mov AL, '.' - -PE_DrawPattern18: - StosW - LodsB ; Commandvalue - Mov DH, AL - ShR AL, 4 - - Call PE_ConvHexAL - - Mov AL, DH - And AL, 15 - Call PE_ConvHexAL - - Pop DX - Pop CX - Dec DX - JZ PE_DrawPatternEdit9 - - And AX, 0F000h - Or AX, 2A8h - Cmp AH, 80h - JB PE_DrawDiv1 - Cmp AH, 0A0h - JAE PE_DrawDiv1 - - Mov AX, 2A8h - -PE_DrawDiv1: - StosW - Jmp PE_DrawPatternEdit6 - -PE_DrawPatternEdit9: - Pop BP - Pop DI - Pop SI - Pop DX - Pop CX - Add DI, 160 ; Screen - Add SI, 320 ; PatternData - Inc BP ; Row - Loop PE_DrawPatternEdit5 - -PE_DrawPatternHilightRow: - Call Music_GetPlayMode - Test AX, AX - JZ PE_DrawPattern40 - - Cmp CX, CS:PatternNumber - JNE PE_DrawPattern40 - - Sub BX, CS:TopRow - JC PE_DrawPattern40 - Cmp BL, 32 - JAE PE_DrawPattern40 - Mov AL, 80 - Mul BL - - Mov DI, AX - Add DI, 1+15*80 - Cmp CS:NumChannelsEdit, 0 - JE PE_DrawPattern41 - - Add DI, CS:ViewWidth - -PE_DrawPattern41: - Add DI, DI - - Push ES - Pop DS - - Mov CL, 3 - -PE_DrawPattern42: - Inc DI - Mov AL, [DI] - And AL, 0F0h - Or AL, 3 - StosB - - Dec CL - JNZ PE_DrawPattern42 - -PE_DrawPattern40: - Ret - -EndP PE_DrawPatternEdit - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PrePatternEdit Far - - Push CS - Pop DS - Assume DS:Pattern - - Cmp NumChannelsEdit, 0 - JNE PE_PrePatternEdit18 - - Ret - -PE_PrePatternEdit18: - Call S_GetDestination - - Mov AX, 80 - Mov BX, 15 - Add BX, Row - Sub BX, TopRow - Mul BL - Add AX, ViewWidth - Add AX, 5 - Mov BX, PatternCursor - Add AL, [CursorPositions+BX] - AdC AH, 0 - Mov DI, AX - Mov AL, 14 - Mov BX, Channel - Sub BX, LeftChannel - Mul BL - Add DI, AX - Add DI, DI - Inc DI - Mov Byte Ptr [ES:DI], 30h - - Mov DI, 8+47*80 - Add DI, ViewWidth - Add DI, DI - Mov SI, LeftChannel - Mov DX, NumChannelsEdit - -PE_PrePatternEdit16: - Cmp [MultiChannelInfo+SI], 0 ; Put the 'M's in. - JE PE_PrePatternEdit17 - - Mov Byte Ptr [ES:DI], 172 - -PE_PrePatternEdit17: - Inc SI - Add DI, 28 - Dec DX - JNZ PE_PrePatternEdit16 - - Mov DI, 5+47*80 - Add DI, ViewWidth - Mov AL, 14 - Mov BX, Channel - Sub BX, LeftChannel - Mul BL - Add DI, AX - Add DI, DI ; Points to bottom of channel. - - Mov DX, 1 - Cmp Template, 0 - JE PE_PrePatternEditLoop -; Test CL, CL -; JZ PE_PrePatternEditLoop - Cmp BlockDataArea, 0 - JE PE_PrePatternEditLoop - - Mov FS, BlockDataArea - Mov AX, [FS:0] ; Block width - Mov DX, NumChannelsEdit - Add DX, LeftChannel - Sub DX, Channel - Cmp DX, AX - JB PE_PrePatternEditLoop - - Mov DX, AX - -PE_PrePatternEditLoop: - Push DI - - Mov AX, 23A9h - Mov CX, PatternCursor - Mov CH, EditMask - - Test CL, CL - JZ PE_PrePatternEdit1 - - Mov AL, 0AAh - -PE_PrePatternEdit1: - StosW - StosW - StosW -; Add DI, 2 - ScasW - - Test CH, 1 - JZ PE_PrePatternEdit2 - - StosW - StosW - Jmp PE_PrePatternEdit3 - -PE_PrePatternEdit2: - Add DI, 4 - -PE_PrePatternEdit3: -; Add DI, 2 - ScasW - - Test CH, 2 - JZ PE_PrePatternEdit4 - - StosW - StosW - Jmp PE_PrePatternEdit5 - -PE_PrePatternEdit4: - Add DI, 4 - -PE_PrePatternEdit5: -; Add DI, 2 - ScasW - - Test CH, 4 - JZ PE_PrePatternEdit6 - - StosW - StosW - StosW - -PE_PrePatternEdit6: - Pop DI ; Mark in the actual channels - Mov AL, 0A9h - Test CL, CL - JNZ PE_PrePatternEdit7 - - Mov AL, 0ABh - StosW - StosW - StosW - - Add DI, 22 - Dec DX - JNZ PE_PrePatternEditLoop - - Ret - -PE_PrePatternEdit7: - Cmp CL, 1 - JA PE_PrePatternEdit8 - - Mov AL, 0ABh - Add DI, 4 - StosW - Ret - -PE_PrePatternEdit8: - Cmp CL, 3 - JA PE_PrePatternEdit10 - - Test CH, 1 - JZ PE_PrePatternEdit9 - - Mov AL, 0ABh - -PE_PrePatternEdit9: - Add DI, 8 - StosW - StosW - Ret - -PE_PrePatternEdit10: - Cmp CL, 5 - JA PE_PrePatternEdit12 - - Test CH, 2 - JZ PE_PrePatternEdit11 - - Mov AL, 0ABh - -PE_PrePatternEdit11: - - Add DI, 14 - StosW - StosW - Ret - -PE_PrePatternEdit12: - Cmp CL, 6 - JA PE_PrePatternEdit14 - - Test CH, 4 - JZ PE_PrePatternEdit13 - - Mov AL, 0ABh - -PE_PrePatternEdit13: - Add DI, 20 - StosW - Ret - -PE_PrePatternEdit14: - Test CH, 4 - JZ PE_PrePatternEdit15 - - Mov AL, 0ABh - -PE_PrePatternEdit15: - Add DI, 22 - StosW - StosW - Ret - -EndP PE_PrePatternEdit - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetPatternOffset - - Assume DS:Pattern - - Push AX - Push BX - Push DX - - Mov AX, 64 - Mul Row - Add AX, Channel - Mov BX, 5 - Mul BX - Mov DI, AX - Mov ES, PatternDataArea - - Pop DX - Pop BX - Pop AX - Ret - -EndP GetPatternOffset - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc NetworkPatternBlock Near ; CL = width, CH = Height, BL = Channel, BH = Row - -IF NETWORKENABLED - Call Network_GetSendQueue - JZ PE_GotoNextInputNoNetwork - - Mov AX, NETWORK_PARTIALPATTERNOBJECT*100h ; Destination ALL - StosW - Mov AL, Byte Ptr PatternNumber - StosB - Mov AX, BX - StosW - Mov AX, CX - StosW - -PE_GotoNextInputNoNetwork: - Call Network_FinishedSendQueue - - Ret -ENDIF - -EndP NetworkPatternBlock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc NetworkPartialPattern Near ; CL = width, CH = Height - -IF NETWORKENABLED - Push BX - Mov BL, Byte Ptr Channel - Mov BH, Byte Ptr Row - Call NetworkPatternBlock - Pop BX -ENDIF - Ret - -EndP NetworkPartialPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc NetworkBlock Near - -IF NETWORKENABLED - Mov BL, Byte Ptr BlockLeft - Mov BH, Byte Ptr BlockTop - Mov CL, Byte Ptr BlockRight - Mov CH, Byte Ptr BlockBottom - Sub CX, BX - Add CX, 101h - Call NetworkPatternBlock -ENDIF - Ret - -EndP NetworkBlock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -PatternCursorJumpTable DW Offset PE_PatternCursorPos0 - DW Offset PE_PatternCursorPos1 - DW Offset PE_PatternCursorPos2 - DW Offset PE_PatternCursorPos3 - DW Offset PE_PatternCursorPos4 - DW Offset PE_PatternCursorPos5 - DW Offset PE_PatternCursorPos6 - DW Offset PE_PatternCursorPos7 - DW Offset PE_PatternCursorPos8 - -Proc PE_PostPatternEdit Far - - Push CS - Pop DS - Assume DS:Pattern - - Test CH, 1 - JZ PE_PostPatternEdit17 - - Mov EAX, [DWord Ptr LastKeyBoard1] - Mov EBX, [DWord Ptr LastKeyBoard2] - - Mov [DWord Ptr LastKeyBoard2], EAX - Mov [DWord Ptr LastKeyBoard3], EBX - - Mov [LastKeyBoard1], CX - Mov [LastKeyBoard1+2], DX - -PE_PostPatternEdit17: - Mov AL, CH - Mov SI, Offset PEFunctions - And AL, 6 - Mov ShiftPressed, AL - - Test CH, 6 - PushF - Call M_FunctionDivider - JC PE_PostPatternEdit1 - - PopF - JNZ PE_PostPatternEditShift - -PE_PostPatternEditNotShift: - Jmp [SI] - -PE_PostPatternEditShift: - Cmp Byte Ptr [SI-3], 6 ; MIDI message - JE PE_PostPatternEditNotshift - - Mov AX, [SI-2] - - Cmp AX, 10Fh ; Shift Tab - JE PE_PostPatternEditNotShift - - Cmp AX, '?' - JE PE_PostPatternEditNotShift - - Cmp AX, '|' - JE PE_PostPatternEditNotShift - - Push [Row] - Push [Channel] - - Push CS - - Call [SI] - - Push CS - Pop DS - -; Mov CX, BlockAnchorRow -; Mov DX, BlockAnchorChannel - Pop DX - Pop CX - - Cmp CX, Row - JNE PE_PostPatternEditShift1 - - Cmp DX, Channel - JE PE_PostPatternEditShift2 - -PE_PostPatternEditShift1: - Cmp BlockReset, 0 - JE PE_PostPatternEditShift3 - - Mov BlockReset, 0 - Mov BlockMark, 0 - -PE_PostPatternEditShift3: - ; Set block marks. - Mov AX, BlockAnchorChannel - Mov BX, BlockAnchorRow - - Push CS - Call PEFunction_MarkBeginBlockChain - Jmp PEFunction_MarkEndBlock - -PE_PostPatternEditShift2: - Mov AX, 1 - Ret - -PE_PostPatternEdit1: - PopF - Test CH, 60h - JNZ PE_PostPatternEdit6 - - Call GetPatternOffset - Mov BX, PatternCursor - Add BX, BX - Jmp [PatternCursorJumpTable+BX] - -PE_PostPatternEdit6: - Mov AX, CX - And AX, 1FFh - Cmp AX, 10Ah - JA PE_PostPatternEdit7 - - Cmp AX, 102h - JB PE_PostPatternEdit7 - ; Alt-1 -> Alt-9 - Sub AX, 101h -; Dec AL -; Dec AH - Mov SkipValue, AX - - Mov SI, Offset CursorStepMsg - Call SetInfoLine - - Mov AX, 1 - Ret - -PE_PostPatternEdit7: - Xor AX, AX - Ret - -EndP PE_PostPatternEdit - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl_PgUp Far - - Mov Row, 0 - - Mov AX, 1 - Ret - -EndP PEFunction_Ctrl_PgUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl_PgDn Far - - Mov AX, MaxRow - Mov Row, AX - - Mov AX, 1 - Ret - -EndP PEFunction_Ctrl_PgDn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Up Far - - Mov BX, SkipValue - And BX, BX - JNZ PEFunction_Up2 - - Mov BX, 1 - -PEFunction_Up2: - Mov AX, Row - Sub AX, BX - JS PEFunction_Up1 - - Mov Row, AX - -PEFunction_Up1: - Mov AX, 1 - Ret - -EndP PEFunction_Up - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Down Far - - Push CS - Pop DS - - Mov BX, SkipValue - And BX, BX - JNZ PEFunction_Down2 - - Mov BX, 1 - -PEFunction_Down2: - Mov AX, Row - Add AX, BX - Cmp AX, MaxRow - JA PEFunction_Down1 - - Mov Row, AX - -PEFunction_Down1: - Mov AX, 1 - Ret - -EndP PEFunction_Down - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Left Far - - Mov CX, PatternCursor - Mov BX, Channel - Dec CX - JNS PEFunction_Left1 - - Mov CX, 8 - Dec BX - JS PEFunction_Left2 - - Mov Channel, BX - - Cmp CommandToValue, 0 - JE PEFunction_Left1 - - Call GetPatternOffset -; Mov ES, PatternDataArea -; Mov AX, 64 -; Mul Row -; Add AX, BX -; Mov DX, 5 -; Mul DX -; Mov DI, AX - Cmp Word Ptr [ES:DI+3], 0 - JNE PEFunction_Left1 - - Mov CX, 6 - -PEFunction_Left1: - Mov PatternCursor, CX - -PEFunction_Left2: - Mov AX, 1 - Ret - -EndP PEFunction_Left - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Right Far ; If there is no - ; command value... skip! - - Mov CX, PatternCursor - Mov BX, Channel - Inc CX - Cmp CX, 6 - JBE PEFunction_Right1 - - Cmp CommandToValue, 0 - JE PEFunction_Right4 - - Call GetPatternOffset -; Mov ES, PatternDataArea -; Mov AX, 64 -; Mul Row -; Add AX, Channel -; Mov DX, 5 -; Mul DX -; Mov DI, AX - Cmp Word Ptr [ES:DI+3], 0 - JE PEFunction_Right3 - -PEFunction_Right4: - Cmp CX, 9 - JB PEFunction_Right1 - -PEFunction_Right3: - Xor CX, CX - Inc BX - Cmp BX, 64 - JAE PEFunction_Right2 - -PEFunction_Right1: - Mov PatternCursor, CX - Mov Channel, BX - -PEFunction_Right2: - Mov AX, 1 - Ret - -EndP PEFunction_Right - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Press_Shift Far - - Mov AX, Channel - Mov BX, Row - - Mov BlockAnchorChannel, AX - Mov BlockAnchorRow, BX - Mov BlockReset, 1 - Mov NoteEntered, 0 - - Xor AX, AX - Ret - -EndP PEFunction_Press_Shift - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Release_Shift Far - - Cmp NoteEntered, 0 - JE PEFunction_Release_Shift1 - - Mov AX, BlockAnchorChannel - Mov BX, BlockAnchorRow - - Mov Channel, AX - Mov Row, BX - - Call PE_GotoNextInput - -PEFunction_Release_Shift1: - Xor AX, AX - Ret - -EndP PEFunction_Release_Shift - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Alt_Home Far - Mov BL, RowHilight1 - Jmp PEFunction_PgUpChain - -Proc PEFunction_PgUp Far - - Mov BL, RowHiLight2 - -PEFunction_PgUpChain: - Mov AX, Row - Mov CX, MaxRow - Mov DX, SkipValue - And DX, 0FFh - JNZ PEFunction_PgUp3 - - Mov DL, 1 - -PEFunction_PgUp3: - And BX, 0FFh - - JNZ PEFunction_PgUp2 - - Mov BX, 16 - -PEFunction_PgUp2: - Sub CX, DX ; Sub maxrow, skipvalue - Cmp CX, AX - JAE PEFunction_PgUp4 - - Dec AX - Div BL - Mul BL - Jmp PEFunction_PgUp1 - -PEFunction_PgUp4: - Sub AX, BX - JNS PEFunction_PgUp1 - - Xor AX, AX - -PEFunction_PgUp1: - Mov Row, AX - - Mov AX, 1 - Ret - -EndP PEFunction_PgUp - -EndP PEFunction_Alt_Home - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_CentraliseCursor - - Mov AX, Row - Sub AX, 16 - JNC PE_CentraliseCursor1 - - Xor AX, AX - -PE_CentraliseCursor1: - Mov TopRow, AX - Ret - -EndP PE_CentraliseCursor - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -Proc PEFunction_Alt_End Far - Mov BL, RowHilight1 - Jmp PEFunction_PgDnChain - -Proc PEFunction_PgDn Far - - Mov BL, RowHiLight2 - -PEFunction_PgDnChain: - Mov AX, Row - And BX, 0FFh - JNZ PEFunction_PgDn2 - - Mov BX, 16 - -PEFunction_PgDn2: - Add AX, BX - Cmp AX, MaxRow - JBE PEFunction_PgDn1 - - Mov AX, MaxRow - -PEFunction_PgDn1: - Mov Row, AX - - Mov AX, 1 - Ret - -EndP PEFunction_PgDn - -EndP PEFunction_Alt_End - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ShiftPgUp Far - - Call PEFunction_PgUp - Call PE_CentraliseCursor - - Mov AX, 1 - Ret - -EndP PEFunction_ShiftPgUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ShiftPgDn Far - - Call PEFunction_PgDn - Call PE_CentraliseCursor - - Mov AX, 1 - Ret - -EndP PEFunction_ShiftPgDn - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Home Far - - Cmp PatternCursor, 0 - JE PEFunction_Home1 - - Mov PatternCursor, 0 - Jmp PEFunction_Home3 - -PEFunction_Home1: - Cmp Channel, 0 - JE PEFunction_Home2 - - Mov Channel, 0 - Jmp PEFunction_Home3 - -PEFunction_Home2: - Mov Row, 0 - -PEFunction_Home3: - Mov AX, 1 - Ret - -EndP PEFunction_Home - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_End Far - - Cmp PatternCursor, 8 - JE PEFunction_End1 - - Mov PatternCursor, 8 - Jmp PEFunction_End3 - -PEFunction_End1: - Call Music_GetLastChannel - - Cmp Channel, AX - JE PEFunction_End2 - - Mov Channel, AX - Jmp PEFunction_End3 - -PEFunction_End2: - Mov AX, MaxRow - Mov Row, AX - -PEFunction_End3: - Mov AX, 1 - Ret - -EndP PEFunction_End - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Tab Far - - Mov AX, Channel - Cmp AX, 63 - JAE PEFunction_Tab1 - - Mov PatternCursor, 0 - Inc Channel - -PEFunction_Tab1: - Mov AX, 1 - Ret - -EndP PEFunction_Tab - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ShiftTab Far - - Cmp PatternCursor, 0 - JNE PEFunction_ShiftTab2 - - Mov AX, Channel - And AX, AX - JZ PEFunction_ShiftTab1 - - Dec Channel - -PEFunction_ShiftTab2: - Mov PatternCursor, 0 - -PEFunction_ShiftTab1: - Mov AX, 1 - Ret - -EndP PEFunction_ShiftTab - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_SetMask Far - - Mov BX, PatternCursor - Mov AL, [MaskChange+BX] - Xor EditMask, AL - - Mov AX, 1 - Ret - -EndP PEFunction_SetMask - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ToggleMultiChannel Far - - Mov BX, Channel - Xor [MultiChannelInfo+BX], 1 - - Cmp [Word Ptr LastKeyBoard2+2], 3100h - JNE PEFunction_ToggleMultiChannel1 - - Mov CX, 7 - Add CX, Channel - Mov DI, Offset O1_SelectMultiChannel - Call M_Object1List - -PEFunction_ToggleMultiChannel1: - Mov AX, 1 - Ret - -EndP PEFunction_ToggleMultiChannel - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BackSpace Far - - Xor CX, CX - - Mov AX, Row - Mov BX, Channel - Sub AX, SkipValue - JS PEFunction_BackSpace3 - - Mov Row, AX - Cmp [MultiChannelInfo+BX], 0 - JE PEFunction_BackSpace5 - - Mov DX, BX - -PEFunction_BackSpace1: - Dec BX - JNS PEFunction_BackSpace4 - - And AX, AX - JZ PEFunction_BackSpace3 - - Inc CX - -PEFunction_BackSpace4: - And BX, 63 - Cmp BX, DX - JE PEFunction_BackSpace2 - - Cmp [MultiChannelInfo+BX], 0 - JE PEFunction_BackSpace1 - -PEFunction_BackSpace2: - Mov Channel, BX - Cmp SkipValue, 0 - JNE PEFunction_BackSpace3 - - And CX, CX - JZ PEFunction_BackSpace3 - - And AX, AX - JZ PEFunction_BackSpace3 - - Dec Row - Jmp PEFunction_BackSpace3 - -PEFunction_BackSpace5: ; AX = row - Cmp SkipValue, 0 - JNE PEFunction_BackSpace3 - - Mov BX, Channel - Dec BX - JNS PEFunction_BackSpace6 - - And AX, AX - JZ PEFunction_BackSpace3 - Dec AX - -PEFunction_BackSpace6: - And BX, 63 - Mov Row, AX - Mov Channel, BX - -PEFunction_BackSpace3: - Mov AX, 1 - Ret - -EndP PEFunction_BackSpace - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_PickUp Far - - Cmp Template, 4 - JE PEFunction_PickUp2 - - Mov Template, 0 ; Turn off templates - -PEFunction_PickUp2: - Call GetPatternOffset - Mov EAX, [ES:DI] - - Test AH, AH - JNZ PEFunction_PickUp1 - - Mov AH, LastInstrument - -PEFunction_PickUp1: - Mov DWord Ptr [LastNote], EAX - Mov AL, [ES:DI+4] - Mov LastCommandValue, AL - - Mov AX, 1 - Ret - -EndP PEFunction_PickUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos1 Far - - Test CL, CL - JZ PE_PatternCursorPos1_1 - - Cmp DX, '0' - JB PE_PatternCursorPos1_1 - - Cmp DX, '9' - JA PE_PatternCursorPos1_1 - - Mov AL, [ES:DI] - Cmp AL, 120 - JA PE_PatternCursorPos1_2 - - AAM 12 ; AH = octave, AL = note - Mov AH, DL - Sub AH, '0' - AAD 12 - StosB - -PE_PatternCursorPos1_2: - Mov CX, 101h - Call NetworkPartialPattern - - Jmp PE_GotoNextInput - -PE_PatternCursorPos1_1: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos0 Far - - Test CL, CL - JZ PE_PatternCursorPos0_4 - - Push CX - Mov SI, Offset KeyBoardTable - - And CH, Not 6 ; Remove shift mask. - -PE_PatternCursorPos0_1: - LodsW - Cmp AX, 0FFFFh - JE PE_PatternCursorPos0_3 - - Cmp AX, CX - JNE PE_PatternCursorPos0_2 - - Pop CX - - Mov BX, 3Ah - Call K_IsKeyDown - JNZ PE_PatternCursorPreview - - Jmp PE_NewNote - -PE_PatternCursorPreview: - Mov AX, 12 - Mul BaseOctave - Mov BX, AX - LodsW - Add AX, BX - - Mov SI, Offset PreviewNote - - Cmp AX, MAXNOTE - JA PE_PatternCursorPos0_4 - - Mov AH, LastInstrument - Mov [SI], AX - - Mov AX, CS:Channel - Mov DH, 32 - Call Music_PlayNote - - Xor AX, AX - Ret - -PE_PatternCursorPos0_2: - LodsW ; Add SI, 2 - Jmp PE_PatternCursorPos0_1 - -PE_PatternCursorPos0_3: - Pop CX - - Mov AL, NONOTE - Cmp DX, '.' - JE WipeNote - - Inc AX - Cmp DX, '1' - JE WipeNote - Cmp DX, '!' - JE WipeNote - - Inc AX - Cmp DX, '`' - JE WipeNote - Cmp DX, '~' - JE WipeNote - - Cmp DX, ' ' - JE NoteSpace - - Cmp DX, '4' - JE PEFunction_PlayCurrentNote - Cmp DX, '$' - JE PEFunction_PlayCurrentNote - - Cmp DX, '8' - JE PEFunction_PlayCurrentRow - -PE_PatternCursorPos0_4: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc NoteSpace Far - - Mov AL, LastNote - Jmp PE_NewNote4 - -EndP NoteSpace - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc WipeNote Far - - Mov AH, EditMask - - Mov BP, 1 - Cmp Template, 0 - JE WipeNote4 - - Cmp BlockDataArea, 0 - JE WipeNote4 - - Mov FS, BlockDataArea - Cmp Word Ptr [FS:2], 1 - JNE WipeNote4 - - Mov BP, [FS:0] - -WipeNote4: - Mov CX, BP - Mov CH, 1 - Call NetworkPartialPattern - -WipeNote5: - Mov [ES:DI], AL - Mov LastNote, AL - Test AH, 1 - JZ WipeNote1 - - Mov Byte Ptr [ES:DI+1], 0 - -WipeNote1: - Test AH, 2 - JZ WipeNote2 - - Mov Byte Ptr [ES:DI+2], 0FFh - -WipeNote2: - Test AH, 4 - JZ WipeNote3 - - Mov Word Ptr [ES:DI+3], 0 - -WipeNote3: - Add DI, 5 - Dec BP - JNZ WipeNote5 - -IF CHORDENTRY - Cmp ShiftPressed, 0 - JE PE_GotoNextInput - - Push SkipValue - Mov SkipValue, 0 - Mov NoteEntered, 1 - - Call PE_GotoNextInput - Pop SkipValue - - Mov AX, 1 - Ret -ELSE - Jmp PE_GotoNextInput -ENDIF - -EndP WipeNote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_GotoNextInput Far - - - Mov CX, PatternCursor - And CX, CX - JZ PE_GotoNextInput4 - - Cmp CX, 1 - JE PE_GotoNextInput4 - - Cmp CX, 2 - JNE PE_GotoNextInput5 - -PE_GotoNextInput7: - Inc PatternCursor - Jmp PE_GotoNextInput3 - -PE_GotoNextInput5: - Cmp CX, 3 - JNE PE_GotoNextInput6 - -PE_GotoNextInput8: - Dec PatternCursor - Jmp PE_GotoNextInput4 - -PE_GotoNextInput6: - Cmp CX, 4 - JE PE_GotoNextInput7 - - Cmp CX, 5 - JE PE_GotoNextInput8 - - Cmp CX, 6 - JNE PE_GotoNextInput9 - - Cmp CommandToValue, 0 - JZ PE_GotoNextInput4 - - Jmp PE_GotoNextInput7 - -PE_GotoNextInput9: - Cmp CX, 7 - JE PE_GotoNextInput7 - - Cmp CommandToValue, 0 - JE PE_GotoNextInput8 - - Sub PatternCursor, 2 - -PE_GotoNextInput4: - Mov AX, Row - Mov BX, Channel - Add AX, SkipValue - Cmp AX, MaxRow - JA PE_GotoNextInput3 - - Mov Row, AX - Cmp PatternCursor, 0 - JNE PE_GotoNextInput10 - - Cmp [MultiChannelInfo+BX], 0 - JE PE_GotoNextInput10 - - Mov DX, BX - Xor CX, CX - -PE_GotoNextInput1: - Inc BX - Cmp BX, 63 - JBE PE_GotoNextInput11 - - Inc CX - -PE_GotoNextInput11: - And BX, 63 - Cmp DX, BX - JE PE_GotoNextInput2 - - Cmp [MultiChannelInfo+BX], 0 - JE PE_GotoNextInput1 - -PE_GotoNextInput2: - Mov Channel, BX - Cmp SkipValue, 0 - JNE PE_GotoNextInput3 - - And CX, CX - JZ PE_GotoNextInput3 - - Mov Word Ptr [Modified], 101h - - Jmp PEFunction_Down - -PE_GotoNextInput10: - Cmp SkipValue, 0 - JNE PE_GotoNextInput3 - - Mov AX, Channel - Mov CX, Row - Inc AX - Cmp AX, 63 - JBE PE_GotoNextInput12 - Cmp CX, MaxRow - JAE PE_GotoNextInput3 - - Inc CX - -PE_GotoNextInput12: - And AX, 63 - Mov Row, CX - Mov Channel, AX - -PE_GotoNextInput3: - Mov Word Ptr [Modified], 101h - - Mov AX, 1 - Ret - -EndP PE_GotoNextInput - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TemplateSetup - - Mov AH, AL - Push AX - - Mov BX, Channel - Mov AX, 320 - Mov BP, MaxRow - Inc BP - Mul BP - Mov BP, AX ; BP = max offset. - - Mov AX, 64 - Mul Row - Add AX, BX - Mov CX, 5 - Mul CX - - Mov DI, AX ; DI = pattern offset. - Mov ES, PatternDataArea - Mov DS, BlockDataArea - Xor SI, SI - - LodsW - Mov DX, AX ; DX = width - LodsW - Mov CX, AX ; CX = height - - Pop AX ; AH = note. - Sub AH, [DS:4] - - Ret - -EndP TemplateSetup - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TemplateOverwrite ; AX = note - - Push DS - Push ES - - Call TemplateSetup - -PE_TemplateOverWrite1: - Push BX - Push CX - Push DI - - Mov CX, DX - -PE_TemplateOverWrite2: - Cmp BX, 64 - JAE PE_TemplateOverWrite3 - - LodsB - Cmp AL, MAXNOTE - JA PE_TemplateOverWrite6 - - Add AL, AH - Cmp AL, MAXNOTE - JBE PE_TemplateOverWrite6 - - Mov AL, NONOTE - -PE_TemplateOverWrite6: - StosB - MovsW - MovsW - Jmp PE_TemplateOverWrite4 - -PE_TemplateOverWrite3: - Add SI, 5 - Add DI, 5 - -PE_TemplateOverWrite4: - Inc BX - Loop PE_TemplateOverWrite2 - - Pop DI - Pop CX - Pop BX - Add DI, 320 - Cmp DI, BP - JAE PE_TemplateOverWrite5 - - Loop PE_TemplateOverWrite1 - -PE_TemplateOverWrite5: - Pop ES - Pop DS - Ret - -EndP PE_TemplateOverWrite - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TemplateMixPattern ; AX = note - - Push DS - Push ES - - Call TemplateSetup - -PE_TemplateMixPattern1: - Push BX - Push CX - Push DI - - Mov CX, DX - -PE_TemplateMixPattern2: - Cmp BX, 64 - JAE PE_TemplateMixPattern3 - - Mov AL, [DS:SI] - Cmp AL, MAXNOTE - JA PE_TemplateMixPattern6 - - Add AL, AH - Cmp AL, MAXNOTE - JBE PE_TemplateMixPattern6 - - Mov AL, NONOTE - -PE_TemplateMixPattern6: - Cmp Byte Ptr [ES:DI], NONOTE - JNE PE_TemplateMixPattern7 - - Mov [ES:DI], AL - -PE_TemplateMixPattern7: - Cmp Byte Ptr [ES:DI+1], 0 - JNE PE_TemplateMixPattern8 - - Mov AL, [DS:SI+1] - Mov [ES:DI+1], AL - -PE_TemplateMixPattern8: - Cmp Byte Ptr [ES:DI+2], 0FFh - JNE PE_TemplateMixPattern9 - - Mov AL, [DS:SI+2] - Mov [ES:DI+2], AL - -PE_TemplateMixPattern9: - Cmp Word Ptr [ES:DI+3], 0 - JNE PE_TemplateMixPattern3 - - Push AX - Mov AX, [DS:SI+3] - Mov [ES:DI+3], AX - Pop AX - -PE_TemplateMixPattern3: - Add SI, 5 - Add DI, 5 - -PE_TemplateMixPattern4: - Inc BX - Loop PE_TemplateMixPattern2 - - Pop DI - Pop CX - Pop BX - Add DI, 320 - Cmp DI, BP - JAE PE_TemplateMixPattern5 - - Loop PE_TemplateMixPattern1 - -PE_TemplateMixPattern5: - Pop ES - Pop DS - Ret - -EndP PE_TemplateMixPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TemplateMixClipBoard ; AX = note - - Push DS - Push ES - - Call TemplateSetup - -PE_TemplateMixClipBoard1: - Push BX - Push CX - Push DI - - Mov CX, DX - -PE_TemplateMixClipBoard2: - Cmp BX, 64 - JAE PE_TemplateMixClipBoard3 - - Mov AL, [DS:SI] - Cmp AL, MAXNOTE - JA PE_TemplateMixClipBoard6 - - Add AL, AH - Cmp AL, MAXNOTE - JBE PE_TemplateMixClipBoard6 - - Mov AL, NONOTE - -PE_TemplateMixClipBoard6: - Cmp Byte Ptr [DS:SI], NONOTE - JE PE_TemplateMixClipBoard7 - - Mov [ES:DI], AL - -PE_TemplateMixClipBoard7: - Cmp Byte Ptr [DS:SI+1], 0 - JE PE_TemplateMixClipBoard8 - - Mov AL, [DS:SI+1] - Mov [ES:DI+1], AL - -PE_TemplateMixClipBoard8: - Cmp Byte Ptr [DS:SI+2], 0FFh - JE PE_TemplateMixClipBoard9 - - Mov AL, [DS:SI+2] - Mov [ES:DI+2], AL - -PE_TemplateMixClipBoard9: - Cmp Word Ptr [DS:SI+3], 0 - JE PE_TemplateMixClipBoard3 - - Push AX - Mov AX, [DS:SI+3] - Mov [ES:DI+3], AX - Pop AX - -PE_TemplateMixClipBoard3: - Add SI, 5 - Add DI, 5 - -PE_TemplateMixClipBoard4: - Inc BX - Loop PE_TemplateMixClipBoard2 - - Pop DI - Pop CX - Pop BX - Add DI, 320 - Cmp DI, BP - JAE PE_TemplateMixClipBoard5 - - Loop PE_TemplateMixClipBoard1 - -PE_TemplateMixClipBoard5: - Pop ES - Pop DS - Ret - -EndP PE_TemplateMixClipBoard - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TemplateNotesOnly - - Push DS - Push ES - - Call TemplateSetup - -PE_TemplateNotesOnly1: - Push BP - Push BX - Push CX - Push DI - - Mov CX, DX - Mov BP, Word Ptr [CS:EditMask] - -PE_TemplateNotesOnly2: - Cmp BX, 64 - JAE PE_TemplateNotesOnly3 - - Or BP, 8 - Mov AL, [SI] - Cmp AL, MAXNOTE - JA PE_TemplateNotesOnly7 - - Add AL, AH - And BP, Not 8 - Cmp AL, MAXNOTE - JA PE_TemplateNotesOnly3 - -PE_TemplateNotesOnly7: - Mov [ES:DI], AL - - Test BP, 8 - JNZ PE_TemplateNotesOnly3 - Test BP, 1 - JZ PE_TemplateNotesOnly5 - - Mov AL, CS:LastInstrument - Mov [ES:DI+1], AL - -PE_TemplateNotesOnly5: - Test BP, 2 - JZ PE_TemplateNotesOnly6 - - Mov AL, CS:LastVolume - Mov [ES:DI+2], AL - -PE_TemplateNotesOnly6: - Test BP, 4 - JZ PE_TemplateNotesOnly3 - - Mov AX, [Word Ptr CS:LastCommand] - Mov [ES:DI+3], AX - -PE_TemplateNotesOnly3: - Add SI, 5 - Add DI, 5 - - Inc BX - Loop PE_TemplateNotesOnly2 - - Pop DI - Pop CX - Pop BX - Pop BP - - Add DI, 320 - Cmp DI, BP - JAE PE_TemplateNotesOnly4 - - Loop PE_TemplateNotesOnly1 - -PE_TemplateNotesOnly4: - Pop ES - Pop DS - - Ret - -EndP PE_TemplateNotesOnly - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_Template Far ; AX = note. - - Mov BX, BlockDataArea - Test BX, BX - JZ PEFunction_NoBlockData - - Mov ES, BX - Cmp Byte Ptr [ES:4], 119 - JBE PE_Template3 - - Mov DI, Offset O1_TemplateErrorList - Mov CX, 2 - Call M_Object1List - - Mov AX, 1 - Ret - -PE_Template3: - Mov Word Ptr [Modified], 101h - - Mov BL, Template - Cmp BL, 2 - JE PE_Template1 - JA PE_Template2 - - Call PE_TemplateOverWrite - Jmp PE_Template4 - -PE_Template1: - Call PE_TemplateMixPattern - Jmp PE_Template4 - -PE_Template2: - Cmp BL, 4 - JE PE_Template6 - - Call PE_TemplateMixClipBoard - Jmp PE_Template4 - -PE_Template6: - Call PE_TemplateNotesOnly - -PE_Template4: ; Play notes, if clipboard height = 1 - Mov CL, [ES:0] - Mov CH, [ES:2] - Call NetworkPartialPattern - - Cmp Word Ptr [ES:2], 1 ; height - JNE PE_TemplateNoPlay - - Mov AX, 64 - Mul Row - Add AX, Channel - Mov DX, 5 - Mul DX - Mov SI, AX - - Mov CX, [ES:0] ; CX = Width - Mov AX, Channel - Push DS - Mov DS, PatternDataArea - Mov DH, 32 - -PE_TemplatePlay: - Call Music_PlayNote - - Add SI, 5 - Inc AX - Dec CX - JNZ PE_TemplatePlay - - Pop DS - -PE_TemplateNoPlay: - Cmp SkipValue, 0 - JNE PE_GotoNextInput - - Mov AX, Row - Mov BX, MaxRow - Add AX, [ES:2] - Cmp AX, BX - JBE PE_Template5 - - Mov AX, BX - -PE_Template5: - Mov Row, AX - - Mov AX, 1 - Ret - -EndP PE_Template - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_NewNote Far - - Mov AX, 12 - Mul BaseOctave - Mov BX, AX - LodsW - Add AX, BX - - Cmp AX, MAXNOTE - JBE PE_NewNote5 - - Mov AX, 1 - Ret - -PE_NewNote5: - Cmp Template, 0 - JNE PE_Template - -PE_NewNote4: - Mov AH, EditMask - - Mov SI, DI - - Mov LastNote, AL - StosB - - Test AH, 1 - JZ PE_NewNote1 - - Mov AL, LastInstrument - Mov [ES:DI], AL - -PE_NewNote1: - Test AH, 2 - JZ PE_NewNote2 - - Mov AL, LastVolume - Mov [ES:DI+1], AL - -PE_NewNote2: - Test AH, 4 - JZ PE_NewNote3 - - Mov AL, LastCommand - Mov AH, LastCommandValue - Mov [ES:DI+2], AX - -PE_NewNote3: ; Play routine reqd here... - Push DS - - Push ES - Pop DS ; DS = patterndatasegment - - Mov AX, CS:Channel - Mov DH, 32 - Call Music_PlayNote - - Pop DS - - Mov CX, 101h - Call NetworkPartialPattern - -IF CHORDENTRY - Cmp ShiftPressed, 0 - JE PE_GotoNextInput - - Push SkipValue - Mov SkipValue, 0 - Mov NoteEntered, 1 - - Call PE_GotoNextInput - Pop SkipValue - - Mov AX, 1 - Ret -ELSE - Jmp PE_GotoNextInput -ENDIF - -EndP PE_NewNote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Delete Far - - Mov Word Ptr [Modified], 101h - - Mov AX, 320 - Mul MaxRow - - Call GetPatternOffset - - Mov BP, 1 - Cmp Template, 0 - JE PEFunction_Delete3 - - Cmp PatternCursor, 0 - JNE PEFunction_Delete3 - - Cmp BlockDataArea, 0 - JE PEFunction_Delete3 - - Mov FS, BlockDataArea - Cmp Word Ptr [FS:2], 1 - JNE PEFunction_Delete3 - - Mov BP, [FS:0] - -PEFunction_Delete3: - Mov CX, BP - Mov CH, Byte Ptr MaxRow - Sub CH, Byte Ptr Row - Inc CH - Call NetworkPartialPattern - - Push AX DI - - Mov SI, DI - Push ES - Pop DS ; DS:SI and ES:DI point to pat - - Add SI, 320 - Mov DX, 315 - -PEFunction_Delete1: - Cmp DI, AX - JAE PEFunction_Delete2 - - Mov CX, 5 - Rep MovsB - Add SI, DX - Add DI, DX - Jmp PEFunction_Delete1 - -PEFunction_Delete2: - Mov AX, NONOTE - StosW - Mov AL, 0FFh - StosB - Xor AX, AX - StosW - - Pop DI AX - Add DI, 5 - - Dec BP - JNZ PEFunction_Delete3 - - Mov AX, 1 - Ret - -EndP PEFunction_Delete - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Insert Far - - Mov BP, 1 - Cmp Template, 0 - JE PEFunction_Insert3 - - Cmp PatternCursor, 0 - JNE PEFunction_Insert3 - - Cmp BlockDataArea, 0 - JE PEFunction_Insert3 - - Mov FS, BlockDataArea - Cmp Word Ptr [FS:2], 1 - JNE PEFunction_Insert3 - - Mov BP, [FS:0] - -PEFunction_Insert3: - Mov Word Ptr [Modified], 101h - - Mov CX, BP - Mov CH, Byte Ptr MaxRow - Sub CH, Byte Ptr Row - Inc CH - Call NetworkPartialPattern - - Mov AX, 64 - Mul MaxRow - Add AX, Channel - Mov BX, 5 - Mul BX - Mov SI, AX - Call GetPatternOffset - Push ES - Pop DS - Mov BX, DI - Mov DX, -325 - -PEFunction_Insert4: - Push SI - - Mov DI, SI - Sub SI, 320 - -PEFunction_Insert1: - Cmp DI, BX - JBE PEFunction_Insert2 - - Mov CX, 5 - Rep MovsB - Add SI, DX - Add DI, DX - Jmp PEFunction_Insert1 - -PEFunction_Insert2: - Mov AX, NONOTE - StosW - Mov AL, 0FFh - StosB - Xor AX, AX - StosW - - Pop SI - Add SI, 5 - Add BX, 5 - - Dec BP - JNZ PEFunction_Insert4 - - Mov AX, 1 - Ret - -EndP PEFunction_Insert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_RowDelete Far - - Cmp Byte Ptr LastKeyBoard2, 0D3h - JE PEFunction_RowDelete2 - - Mov DI, 20 - Call PE_AddToUndoBuffer - -PEFunction_RowDelete2: - Mov AX, 320 - Mul Row - Mov DI, AX - - Mov CX, MaxRow - Sub CX, Row - Mov AX, 320 - Mul CX - Mov CX, AX - - Mov DS, PatternDataArea - Push DS - Pop ES - Mov SI, DI - Add SI, 320 - Rep MovsB - - Mov DX, 64 - - Push CS - Pop DS - -PEFunction_RowDelete1: - Mov CX, 5 - Mov SI, Offset EmptyData - Rep MovsB - - Dec DX - JNZ PEFunction_RowDelete1 - - Mov BL, 0 - Mov BH, Byte Ptr Row - Mov CL, 64 - Mov CH, Byte Ptr MaxRow - Sub CH, Byte Ptr Row - Inc CH - Call NetworkPatternBlock - - Mov AX, 1 - Ret - -EndP PEFunction_RowDelete - - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_RowInsert Far - - Cmp Byte Ptr LastKeyBoard2, 0D2h - JE PEFunction_RowInsert2 - - Mov DI, 19 - Call PE_AddToUndoBuffer - -PEFunction_RowInsert2: - Mov AX, 320 - Mul MaxRow - Add AX, 63*5 - Mov DI, AX - - Mov CX, MaxRow - Sub CX, Row - Mov AX, 320 - Mul CX - Mov CX, AX - - Mov DS, PatternDataArea - Push DS - Pop ES - Mov SI, DI - Sub SI, 320 - StD - Rep MovsB - ClD - - Push CS - Pop DS - - Mov AX, 320 - Mul Row - Mov DI, AX - - Mov DX, 64 - - -PEFunction_RowInsert1: - Mov CX, 5 - Mov SI, Offset EmptyData - Rep MovsB - - Dec DX - JNZ PEFunction_RowInsert1 - - Mov BL, 0 - Mov BH, Byte Ptr Row - Mov CL, 64 - Mov CH, Byte Ptr MaxRow - Sub CH, BH - Inc CH - Call NetworkPatternBlock - - Mov AX, 1 - Ret - -EndP PEFunction_RowInsert - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_DecreaseInstrument Far - - Sub LastInstrument, 1 - AdC LastInstrument, 0 - - Mov AX, 1 - Ret - -EndP PEFunction_DecreaseInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_IncreaseInstrument Far - - Cmp LastInstrument, 99 - AdC LastInstrument, 0 - - Mov AX, 1 - Ret - -EndP PEFunction_IncreaseInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_DecreaseOctave Far - - Push CS - Pop DS - - Sub BaseOctave, 1 - AdC BaseOctave, 0 - - Mov AX, 1 - Ret - -EndP PEFunction_DecreaseOctave - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_IncreaseOctave Far - - Push CS - Pop DS - - Cmp BaseOctave, 9 - AdC BaseOctave, 0 - - Mov AX, 1 - Ret - -EndP PEFunction_IncreaseOctave - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos2 Far ; Tens column of ins. - - Test CL, CL - JZ PE_PatternCursorPos2_1 - - Mov BX, Offset PE_GotoNextInput4 - Mov AL, LastInstrument - Cmp DX, ' ' - JE PE_PatternCursorPos2_2 - - Xor AL, AL - Cmp DX, '.' - JE PE_PatternCursorPos2_2 - - Cmp DX, '0' - JB PE_PatternCursorPos2_1 - - Cmp DX, '9' - JA PE_PatternCursorPos2_1 - - MovZX AX, Byte Ptr [ES:DI+1] - Mov CL, 10 - Div CL - ; AH = units/AL = tens - Mov BL, AH - Mov AL, DL - Sub AL, '0' - - Mul CL - Add AL, BL - - Mov BX, Offset PE_GotoNextInput - - Mov LastInstrument, AL - -PE_PatternCursorPos2_2: - Mov [ES:DI+1], AL - - Mov CX, 101h - Call NetworkPartialPattern - - Jmp BX - -PE_PatternCursorPos2_1: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos3 Far ; Unit column of ins. - - Test CL, CL - JZ PE_PatternCursorPos3_1 - - Mov BX, Offset PE_GotoNextInput4 - Mov AL, LastInstrument - Cmp DX, ' ' - JE PE_PatternCursorPos3_2 - - Xor AL, AL - Cmp DX, '.' - JE PE_PatternCursorPos3_2 - - Cmp DX, '0' - JB PE_PatternCursorPos3_1 - - Cmp DX, '9' - JA PE_PatternCursorPos3_1 - - MovZX AX, Byte Ptr [ES:DI+1] - Mov CL, 10 - Div CL - ; AH = units/AL = tens - Mul CL - Sub DL, '0' - Add AL, DL - - Mov BX, Offset PE_GotoNextInput - Mov LastInstrument, AL - -PE_PatternCursorPos3_2: - Mov [ES:DI+1], AL - - Mov CX, 101h - Call NetworkPartialPattern - - Jmp BX - -PE_PatternCursorPos3_1: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos4 Far ; Tens column of vol. - - Test CL, CL - JZ PE_PatternCursorPos4_1 - - Cmp DX, '`' - JE PE_VolumePan - - Mov BX, Offset PE_GotoNextInput4 - Mov AL, LastVolume - Cmp DX, ' ' - JE PE_PatternCursorPos4_9 - - Mov AL, 0FFh - Cmp DX, '.' - JE PE_PatternCursorPos4_9 - - Mov BX, Offset PE_GotoNextInput - Mov AL, [ES:DI+2] - Cmp AL, 255 - JNE PE_PatternCursorPos4_2 - - Xor AL, AL - -PE_PatternCursorPos4_2: - And AX, 7Fh - Cmp AL, 65 - JB PE_PatternCursorPos4_4 - - Sub AL, 65 - -PE_PatternCursorPos4_4: - Cmp DX, '0' - JB PE_PatternCursorPos4_5 - - Cmp DX, '9' - JA PE_PatternCursorPos4_5 - - Mov CL, 10 - Div CL - ; AH = units/AL = tens - Mov DH, AH - Mov AL, DL - Sub AL, '0' - - Mul CL - Add AL, DH - - Cmp AL, 64 - JBE PE_PatternCursorPos4_3 - - Mov AL, 64 - -PE_PatternCursorPos4_3: - Or AL, VolumePan ; Panning flag. - -PE_PatternCursorPos4_9: - Mov [ES:DI+2], AL - Mov LastVolume, AL - - Mov CX, 101h - Call NetworkPartialPattern - - Jmp BX - -PE_PatternCursorPos4_5: - Cmp DX, 'A' - JB PE_PatternCursorPos4_6 - Cmp DX, 'H' - JA PE_PatternCursorPos4_6 - Sub DX, 'A' - Jmp PE_PatternCursorPos4_7 - -PE_PatternCursorPos4_6: - Cmp DX, 'a' - JB PE_PatternCursorPos4_1 - Cmp DX, 'h' - JA PE_PatternCursorPos4_1 - - Sub DX, 'a' - -PE_PatternCursorPos4_7: - Mov CL, 10 - Div CL - Mov CH, AH - Mov AL, DL - Mul CL ; AL = tens. - - Cmp AL, 60 - JB PE_PatternCursorPos4_8 - - Add AL, 128-60 - -PE_PatternCursorPos4_8: - Add AL, 65 - Add AL, CH - Jmp PE_PatternCursorPos4_9 - -PE_PatternCursorPos4_1: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_VolumePan Far - - Xor VolumePan, 80h - Mov SI, Offset PanningControlSetMsg - - JNZ PE_VolumePan1 - - Mov SI, Offset VolumeControlSetMsg - -PE_VolumePan1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP PE_VolumePan - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos5 Far ; Unit column of vol. - - Test CL, CL - JZ PE_PatternCursorPos5_1 - - Cmp DX, '`' - JE PE_VolumePan - - Mov BX, Offset PE_GotoNextInput4 - Mov AL, LastVolume - Cmp DX, ' ' - JE PE_PatternCursorPos5_6 - - Mov AL, 0FFh - Cmp DX, '.' - JE PE_PatternCursorPos5_6 - - Mov BX, Offset PE_GotoNextInput - Cmp DX, '0' - JB PE_PatternCursorPos5_1 - - Cmp DX, '9' - JA PE_PatternCursorPos5_1 - - Mov AL, [ES:DI+2] - Cmp AL, 255 - JNE PE_PatternCursorPos5_2 - - Xor AL, AL - -PE_PatternCursorPos5_2: - And AX, 7Fh - Cmp AL, 65 - JB PE_PatternCursorPos5_4 - - Sub AL, 65 - -PE_PatternCursorPos5_4: - Mov CL, 10 - Div CL - ; AH = units/AL = tens - Mul CL - Sub DL, '0' - Add AL, DL - - Mov AH, [ES:DI+2] - Cmp AH, 255 - JE PE_PatternCursorPos5_5 - And AH, 7Fh - Cmp AH, 64 - JBE PE_PatternCursorPos5_5 - - Add AL, 65 - Test Byte Ptr [ES:DI+2], 80h - JZ PE_PatternCursorPos5_6 - Add AL, 128 - Jmp PE_PatternCursorPos5_6 - -PE_PatternCursorPos5_5: - Cmp AL, 64 - JBE PE_PatternCursorPos5_3 - - Mov AL, 64 - -PE_PatternCursorPos5_3: - Or AL, VolumePan - -PE_PatternCursorPos5_6: - Mov [ES:DI+2], AL - Mov LastVolume, AL - - Mov CX, 101h - Call NetworkPartialPattern - - Jmp BX - -PE_PatternCursorPos5_1: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos6 Far - - Test CL, CL - JZ PE_PatternCursorPos6_2 - - Mov AL, LastCommand - Cmp DX, ' ' - JE PE_PatternCursorPos6_3 - - Xor AL, AL - Cmp DX, '.' - JE PE_PatternCursorPos6_3 - - Mov AX, DX - - Cmp AX, 'a' - JB PE_PatternCursorPos6_1 - - Cmp AX, 'z' - JA PE_PatternCursorPos6_1 - - Sub AX, 32 - -PE_PatternCursorPos6_1: - Cmp AX, 'A' - JB PE_PatternCursorPos6_2 - - Cmp AX, 'Z' - JA PE_PatternCursorPos6_2 - - Sub AL, '@' - -PE_PatternCursorPos6_3: - Mov LastCommand, AL - Mov [ES:DI+3], AL - - Mov CX, 101h - Call NetworkPartialPattern - - Jmp PE_GotoNextInput - -PE_PatternCursorPos6_2: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos6 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos7 Far - - Test CL, CL - JZ PE_PatternCursorPos7_3 - - Mov BX, Offset PE_GotoNextInput4 - Xor AL, AL - Cmp DX, '.' - JE PE_PatternCursorPos7_5 - - Mov AL, LastCommandValue - Cmp DX, ' ' - JE PE_PatternCursorPos7_5 - - Mov BX, Offset PE_GotoNextInput - Mov AX, DX - Cmp AX, 'a' - JB PE_PatternCursorPos7_1 - - Cmp AX, 'f' - JA PE_PatternCursorPos7_1 - - Sub AX, 32 - -PE_PatternCursorPos7_1: - Cmp AX, 'A' - JB PE_PatternCursorPos7_2 - - Cmp AX, 'F' - JA PE_PatternCursorPos7_2 - - Sub AX, 'A'-10 - Jmp PE_PatternCursorPos7_4 - -PE_PatternCursorPos7_2: - Cmp AX, '0' - JB PE_PatternCursorPos7_3 - - Cmp AX, '9' - JA PE_PatternCursorPos7_3 - - Sub AX, '0' - -PE_PatternCursorPos7_4: - Mov AH, AL - Mov AL, [ES:DI+4] - SHL AH, 4 - And AL, 0Fh - Or AL, AH - -PE_PatternCursorPos7_5: - Mov [ES:DI+4], AL - Mov LastCommandValue, AL - - Mov CX, 101h - Call NetworkPartialPattern - - Jmp BX - -PE_PatternCursorPos7_3: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos7 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PatternCursorPos8 Far - - Test CL, CL - JZ PE_PatternCursorPos8_3 - - Mov BX, Offset PE_GotoNextInput4 - Xor AH, AH - Cmp DX, '.' - JE PE_PatternCursorPos8_5 - - Mov AH, LastCommandValue - Cmp DX, ' ' - JE PE_PatternCursorPos8_5 - - Mov BX, Offset PE_GotoNextInput - Mov AX, DX - Cmp AX, 'a' - JB PE_PatternCursorPos8_1 - - Cmp AX, 'f' - JA PE_PatternCursorPos8_1 - - Sub AX, 32 - -PE_PatternCursorPos8_1: - Cmp AX, 'A' - JB PE_PatternCursorPos8_2 - - Cmp AX, 'F' - JA PE_PatternCursorPos8_2 - - Sub AX, 'A'-10 - Jmp PE_PatternCursorPos8_4 - -PE_PatternCursorPos8_2: - Cmp AX, '0' - JB PE_PatternCursorPos7_3 - - Cmp AX, '9' - JA PE_PatternCursorPos7_3 - - Sub AX, '0' - -PE_PatternCursorPos8_4: - Mov AH, [ES:DI+4] - And AH, 0F0h - Or AH, AL - -PE_PatternCursorPos8_5: - Mov [ES:DI+4], AH - Mov LastCommandValue, AH - - Mov CX, 101h - Call NetworkPartialPattern - - Jmp BX - -PE_PatternCursorPos8_3: - Xor AX, AX - Ret - -EndP PE_PatternCursorPos8 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_SetCommandCursor Far - - Push CS - Pop ES - Mov DI, Offset CommandToValue -; Mov AL, [SI+24] -; Mov CS:CommandToValue, AL - - Ret - -EndP PE_SetCommandCursor - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_MarkBeginBlock Far - - Mov AX, Channel - Mov BX, Row - -PEFunction_MarkBeginBlockChain: - Cmp BlockMark, 0 - JNE PEFunction_MarkBeginBlock1 - - Mov BlockMark, 1 - Mov BlockLeft, AX - Mov BlockRight, AX - Mov BlockTop, BX - Mov BlockBottom, BX - Jmp PEFunction_MarkBeginBlock5 - -PEFunction_MarkBeginBlock1: - Cmp AX, BlockRight - JBE PEFunction_MarkBeginBlock2 - - Mov CX, BlockRight - Mov BlockRight, AX - Mov BlockLeft, CX - Jmp PEFunction_MarkBeginBlock3 - -PEFunction_MarkBeginBlock2: - Mov BlockLeft, AX - -PEFunction_MarkBeginBlock3: - Cmp BX, BlockBottom - JBE PEFunction_MarkBeginBlock4 - - Mov CX, BlockBottom - Mov BlockBottom, BX - Mov BlockTop, CX - Jmp PEFunction_MarkBeginBlock5 - -PEFunction_MarkBeginBlock4: - Mov BlockTop, BX - -PEFunction_MarkBeginBlock5: - Mov AX, 1 - Ret - -EndP PEFunction_MarkBeginBlock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_MarkEndBlock Far - - Mov AX, Channel - Mov BX, Row - -PEFunction_MarkEndChain: - Cmp BlockMark, 0 - JNE PEFunction_MarkEndBlock1 - - Mov BlockMark, 1 - Mov BlockLeft, AX - Mov BlockRight, AX - Mov BlockTop, BX - Mov BlockBottom, BX - Jmp PEFunction_MarkEndBlock5 - -PEFunction_MarkEndBlock1: - Cmp AX, BlockLeft - JAE PEFunction_MarkEndBlock2 - - Mov CX, BlockLeft - Mov BlockLeft, AX - Mov BlockRight, CX - Jmp PEFunction_MarkEndBlock3 - -PEFunction_MarkEndBlock2: - Mov BlockRight, AX - -PEFunction_MarkEndBlock3: - Cmp BX, BlockTop - JAE PEFunction_MarkEndBlock4 - - Mov CX, BlockTop - Mov BlockTop, BX - Mov BlockBottom, CX - Jmp PEFunction_MarkEndBlock5 - -PEFunction_MarkEndBlock4: - Mov BlockBottom, BX - -PEFunction_MarkEndBlock5: - Mov AX, 1 - Ret - -EndP PEFunction_MarkEndBlock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_AltD Far - - Mov AX, Channel - Mov BX, Row - MovZX DX, RowHiLight2 - - Cmp Word Ptr [LastKeyBoard2+2], 2000h - JNE PEFunction_AltD1 - ; OK, at least 1 Alt-D already.. - ; Now double length... - Mov DX, BlockBottom - Sub DX, BlockTop - Inc DX - Add DX, DX - Add DX, BlockTop - Dec DX - Cmp DX, MaxRow - JBE PEFunction_AltD3 - - Mov DX, MaxRow - -PEFunction_AltD3: - Mov BlockBottom, DX - Jmp PEFunction_AltD4 - -PEFunction_AltD1: - Dec DX - Mov BlockTop, BX - Mov BlockLeft, AX - Mov BlockRight, AX - - Add BX, DX - Cmp BX, MaxRow - JBE PEFunction_AltD2 - - Mov BX, MaxRow - -PEFunction_AltD2: - Mov BlockBottom, BX - Mov BlockMark, 1 - -PEFunction_AltD4: - Mov AX, 1 - Ret - -EndP PEFunction_AltD - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_AltS Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Cmp [Word Ptr LastKeyBoard2+2], 1F00h - JE PEFunction_AltS5 - Call NetworkBlock - - Mov DI, 12 - Call PE_AddToUndoBuffer - -PEFunction_AltS5: - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - - Mov SI, AX - Inc SI - - Mov AH, LastInstrument - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - - Mov DS, PatternDataArea - -PEFunction_AltS1: - Push SI - Push CX - - Mov CX, DX - -PEFunction_AltS2: - Cmp Byte Ptr [SI], 0 - JE PEFunction_AltS3 - - Mov [SI], AH - -PEFunction_AltS3: - Add SI, 5 - Loop PEFunction_AltS2 - - Pop CX - Pop SI - Add SI, 320 - Loop PEFunction_AltS1 - -PEFunction_AltS4: - Mov AX, 1 - Ret - -EndP PEFunction_AltS - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEGetVolume ; Given DL = note, DH = instrument - ; Returns DL, Carry if none - - Push AX BX DI DS - - Cmp DL, MAXNOTE - JA PEGetVolumeError - - Call Music_GetSongSegment - Mov DS, AX - - Mov BL, DH - And BX, 0FFh - JZ PEGetVolumeError - Add BX, BX - - Test Byte Ptr [DS:2Ch], 4 - JZ PEGetVolumeSample - - Mov DI, DX - Mov BX, [DS:64710+BX] - And DI, 0FFh ; Note - Add DI, DI - Mov BX, [DS:BX+DI+41h] - And BX, 0FFh ; BX = sample - JZ PEGetVolumeError - Add BX, BX - -PEGetVolumeSample: - Mov BX, [DS:64910+BX] - Mov DL, [BX+13h] - - DB 85h ; -PEGetVolumeError: ; - StC ; - -PEGetVolumeEnd: - Pop DS DI BX AX - Ret - -EndP PEGetVolume - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_AltK Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Cmp [Word Ptr LastKeyBoard2+2], 2500h - JNE PEFunction_AltK7 - - Cmp [Word Ptr LastKeyBoard3+2], 2500h - JE PEFunction_AltK11 - - Mov DI, 8 - Call PE_AddToUndoBuffer - Call NetworkBlock - - ; OK.. wipe volume data... - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov DI, AX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - - Mov ES, PatternDataArea -; Add DI, 2 - ScasW - - Mov AL, 0FFh - -PEFunction_AltK12: - Push CX - Push DI - - Mov CX, DX - -PEFunction_AltK13: - StosB - Add DI, 4 - Loop PEFunction_AltK13 - - Pop DI - Pop CX - Add DI, 320 - Loop PEFunction_AltK12 - -PEFunction_AltK11: - Mov AX, 1 - Ret - -PEFunction_AltK7: - Mov DI, 7 - Call PE_AddToUndoBuffer - Call NetworkBlock - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov SI, AX - - Mov AX, 64 - Mul BlockBottom - Add AX, BlockLeft - Mul BX - Mov DI, AX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov CX, BlockBottom - Sub CX, BlockTop - JZ PEFunction_AltK2 ; CX contains number of rows - -; Add SI, 2 -; Add DI, 2 - LodsW - ScasW - Mov DS, PatternDataArea - -PEFunction_AltK1: - Push CX - Push DX - Push SI - -; AltK6 = don't slide. - - MovZX AX, Byte Ptr [DI] - Cmp AL, 0FFh - JNE PEFunction_KVolume1 - - Mov DX, [DI-2] - Call PEGetVolume - JC PEFunction_AltK6 - MovZX AX, DL - -PEFunction_KVolume1: - MovZX BX, Byte Ptr [SI] - Cmp BL, 0FFh - JNE PEFunction_KVolume2 - - Mov DX, [SI-2] - Call PEGetVolume - JC PEFunction_AltK6 - MovZX BX, DL - -PEFunction_KVolume2: ; Now BOTH AL and BL are pan - ; Or BOTH AL and BL are volume - Mov DL, AL - Mov DH, BL - - And DX, 7F7Fh - Cmp DL, 64 - JA PEFunction_AltK6 - Cmp DH, 64 - JA PEFunction_AltK6 - - Mov DL, AL - Mov DH, BL - - And DX, 8080h - JZ PEFunction_AltK14 - Cmp DX, 8080h - JNE PEFunction_AltK6 - -PEFunction_AltK14: - Mov [DI], AL - Mov [SI], BL - - Sub AX, BX ; AX = change. - JS PEFunction_AltK4 - - Div CL - Mov BH, AL - Xor AL, AL - Div CL - Mov BL, AL - - Xor AL, AL - Jmp PEFunction_AltK5 - - -PEFunction_AltK4: - Neg AX - Div CL - Mov BH, AL - Xor AL, AL - Div CL - Mov BL, AL - Neg BX - - Mov AL, 0FFh - -PEFunction_AltK5: - Mov AH, [SI] - -PEFunction_AltK3: - Mov [SI], AH - - Add AX, BX - Add SI, 320 - Loop PEFunction_AltK3 - -PEFunction_AltK6: - Pop SI - Pop DX - Pop CX - Add SI, 5 - Add DI, 5 - Dec DX - JNZ PEFunction_AltK1 - -PEFunction_AltK2: - Mov AX, 1 - Ret - -EndP PEFunction_AltK - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_AltL Far - - Call Music_GetLastChannel ; AX = max channel. - Mov BX, MaxRow - - Cmp [Word Ptr LastKeyBoard2+2], 2600h - JNE PEFunction_AltL1 - - Xor CX, CX - Cmp CX, BlockTop - JNE PEFunction_AltL2 - Cmp CX, BlockLeft - JNE PEFunction_AltL2 - Cmp BlockRight, AX - JNE PEFunction_AltL2 - Cmp BX, BlockBottom - JNE PEFunction_AltL2 - Jmp PEFunction_AltL1 - -PEFunction_AltL2: - Xor CX, CX - Mov BlockTop, CX - Mov BlockLeft, CX - Mov BlockRight, AX - Mov BlockBottom, BX - Jmp PEFunction_AltL3 - -PEFunction_AltL1: - Mov AX, Channel - Mov BlockTop, 0 - Mov BlockLeft, AX - Mov BlockRight, AX - Mov BlockBottom, BX - -PEFunction_AltL3: - Mov BlockMark, 1 - - Mov AX, 1 - Ret - -EndP PEFunction_AltL - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_WipeBlock Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Cmp [Word Ptr LastKeyBoard2+2], 2C00h - JE PEFunction_WipeBlock1 - - Mov DI, 18 - Call PE_AddToUndoBuffer - Call NetworkBlock - - Cmp Template, 0 - JNE PEFunction_WipeBlock4 - - Push DS - Call PEFunction_BlockCopy - Pop DS - -PEFunction_WipeBlock4: - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov DI, AX - - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov ES, PatternDataArea - -PEFunction_WipeBlock2: - Push DI - Push CX - - Mov CX, DX - -PEFunction_WipeBlock3: - Mov AX, NONOTE - StosW - Mov AL, 0FFh - StosB - Xor AX, AX - StosW - Loop PEFunction_WipeBlock3 - - Pop CX - Pop DI - Add DI, 320 - Loop PEFunction_WipeBlock2 - -PEFunction_WipeBlock1: - Mov AX, 1 - Ret - -EndP PEFunction_WipeBlock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_RollUp Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov SI, AX - - Mov BP, BlockBottom - Sub BP, BlockTop - JZ PEFunction_RollUpEnd - - Call NetworkBlock - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - Mov AX, 5 - Mul DX - - Mov CX, AX - - Push CS - Pop ES - Mov DI, Offset TempData - Mov DS, PatternDataArea - - Push SI - Rep MovsB - Pop DI - - Push DS - Pop ES - LEA SI, [DI+320] - -PEFunction_RollUp1: - Push SI - Push DI - - Mov CX, AX - Rep MovsB - - Pop DI - Pop SI - Add SI, 320 - Add DI, 320 - - Dec BP - JNZ PEFunction_RollUp1 - - Push CS - Pop DS - Mov SI, Offset TempData - Mov CX, AX - Rep MovsB - -PEFunction_RollUpEnd: - Mov AX, 1 - Ret - -EndP PEFunction_RollUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_RollDown Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Mov AX, 64 - Mul BlockBottom - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov SI, AX - - Mov BP, BlockBottom - Sub BP, BlockTop - JZ PEFunction_RollDownEnd - - Call NetworkBlock - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - Mov AX, 5 - Mul DX - - Mov CX, AX - - Push CS - Pop ES - Mov DI, Offset TempData - Mov DS, PatternDataArea - - Push SI - Rep MovsB - Pop DI - - Push DS - Pop ES - LEA SI, [DI-320] - -PEFunction_RollDown1: - Push SI - Push DI - - Mov CX, AX - Rep MovsB - - Pop DI - Pop SI - Sub SI, 320 - Sub DI, 320 - - Dec BP - JNZ PEFunction_RollDown1 - - Push CS - Pop DS - Mov SI, Offset TempData - Mov CX, AX - Rep MovsB - -PEFunction_RollDownEnd: - Mov AX, 1 - Ret - -EndP PEFunction_RollDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BlockHalve Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Mov DI, 5 - Call PE_AddToUndoBuffer - - Mov BL, Byte Ptr BlockLeft - Mov BH, Byte Ptr BlockTop - Mov CH, Byte Ptr MaxRow - Mov CL, Byte Ptr BlockRight - Sub CX, BX - Add CX, 101h - Call NetworkPatternBlock - - Mov AX, 320 - Mul BlockTop - Mov BX, AX - Mov AX, 5 - Mul BlockLeft - Add BX, AX - Mov SI, BX - Mov DI, BX - - Mov DX, BlockBottom - Sub DX, BlockTop - Inc DX - - Mov CX, BlockRight - Sub CX, BlockLeft - Inc CX - - Mov AX, BlockTop - - Mov DS, PatternDataArea - Push DS - Pop ES - -PEFunction_BlockHalve1: - Push AX - Push CX - Push DX - Push SI - Push DI - - Cmp AX, CS:MaxRow - JBE PEFunction_BlockHalve3 - -PEFunction_BlockHalve2: - Mov AX, NONOTE - StosW - Mov AL, 0FFh - StosB - Xor AX, AX - StosW - Loop PEFunction_BlockHalve2 - - Jmp PEFunction_BlockHalve4 - -PEFunction_BlockHalve3: - Mov AX, 5 - Mul CX - Mov CX, AX - Rep MovsB - -PEFunction_BlockHalve4: - - Pop DI - Pop SI - Pop DX - Pop CX - Pop AX - Add SI, 640 - Add DI, 320 - Add AX, 2 - Dec DX - JNZ PEFunction_BlockHalve1 - - Mov AX, 1 - Ret - -EndP PEFunction_BlockHalve - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BlockDouble Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Mov DI, 4 - Call PE_AddToUndoBuffer - - Mov BL, Byte Ptr BlockLeft - Mov BH, Byte Ptr BlockTop - Mov CH, Byte Ptr MaxRow - Mov CL, Byte Ptr BlockRight - Sub CX, BX - Add CX, 101h - Call NetworkPatternBlock - - Mov AX, 320 - Mov CX, BlockBottom - Mul CX - Mov SI, AX - Add CX, CX ; CX = 2*number of rows+2*top - Sub CX, BlockTop ; CX = 2*number of rows+top - Inc CX - Mov AX, 320 - Mul CX - Mov DI, AX - - Push CX ; CX = output row. - - Mov CX, BlockRight - Sub CX, BlockLeft - Inc CX - - Mov AX, 5 - Mul BlockLeft - Add SI, AX - Add DI, AX - - Pop DX ; DX = output row - - Mov DS, PatternDataArea - Push DS - Pop ES - -PEFunction_BlockDouble1: - Push DI - - Cmp DX, CS:MaxRow - JA PEFunction_BlockDouble2 - ; Empty stuff now.. - Push CX - -PEFunction_BlockDouble4: - Mov AX, NONOTE - StosW - Mov AL, 0FFh - StosB - Xor AX, AX - StosW - Loop PEFunction_BlockDouble4 - - Pop CX - -PEFunction_BlockDouble2: - Pop DI - Sub DI, 320 - Dec DX - - Push SI - Push DI - Cmp DX, CS:MaxRow - JA PEFunction_BlockDouble3 - - Push CX - Push DX - - Mov AX, 5 - Mul CX - Mov CX, AX - Rep MovsB - - Pop DX - Pop CX - -PEFunction_BlockDouble3: - Pop DI - Pop SI - Sub SI, 320 - Sub DI, 320 - - Cmp DX, CS:BlockTop - JBE PEFunction_BlockDouble5 - - Dec DX - Jmp PEFunction_BlockDouble1 - -PEFunction_BlockDouble5: - Mov AX, 1 - Ret - -EndP PEFunction_BlockDouble - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BlockSwap Far ; Alt-H... sorry. - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - ; Check that boundaries - ; are OK.. - - ; 1. Check that vertices of new block - ; don't lie in old block. - ; 2. Check that 2nd block < channels - ; and 2nd block < maxrow. - - Mov AX, Channel - Mov BX, Row - Call Near Ptr PEFunction_BlockSwap1 - Add AX, BlockRight - Sub AX, BlockLeft - Call Near Ptr PEFunction_BlockSwap1 - Add BX, BlockBottom - Sub BX, BlockTop - Call Near Ptr PEFunction_BlockSwap1 - Mov AX, Channel - Call Near Ptr PEFunction_BlockSwap1 - Jmp PEFunction_BlockSwap3 - -PEFunction_BlockSwap1: - Cmp AX, BlockLeft - JB PEFunction_BlockSwap2 - Cmp AX, BlockRight - JA PEFunction_BlockSwap2 - - Cmp BX, BlockTop - JB PEFunction_BlockSwap2 - Cmp BX, BlockBottom - JA PEFunction_BlockSwap2 - - ; Uh oh... cursor is in block. - - Mov DI, Offset O1_OverlapBlockList - Mov CX, 2 - Call M_Object1List - - Pop AX ; Clear stack - Mov AX, 1 - RetF - -PEFunction_BlockSwap2: - RetN - -PEFunction_BlockSwap3: - Mov DI, 17 - Call PE_AddToUndoBuffer - Call NetworkBlock - - Mov BL, Byte Ptr Channel - Mov BH, Byte Ptr Row - Mov CL, Byte Ptr BlockRight - Mov CH, Byte Ptr BlockBottom - Sub CL, Byte Ptr BlockLeft - Sub CH, Byte Ptr BlockTop - Add CX, 101h - Call NetworkPatternBlock - - - Mov AX, Channel - Mov BX, Row - - Mov CX, BlockRight - Sub CX, BlockLeft - Inc CX ; CX = block width. - Add AX, CX - Cmp AX, 64 - JA PEFunction_BlockSwap4 - - Mov DX, BlockBottom - Sub DX, BlockTop ; DX = block height-1. - Add BX, DX - Cmp BX, MaxRow - JBE PEFunction_BlockSwap5 - -PEFunction_BlockSwap4: - Mov DI, Offset O1_SwapOutOfRangeList - Mov CX, 2 - Call M_Object1List - - Mov AX, 1 - Ret - -PEFunction_BlockSwap5: ; Do swap. - Mov AX, 320 - Mul BlockTop - Mov BX, AX - Mov AX, 5 - Mul BlockLeft - Add BX, AX - Mov SI, BX ; SI = "marked" block - - Call GetPatternOffset ; DI = implied block -; Mov AX, 320 -; Mul Row -; Mov BX, AX -; Mov AX, 5 -; Mul Channel -; Add BX, AX -; Mov SI, BX ; SI = implied block. - - Mov CX, BlockRight - Sub CX, BlockLeft - Inc CX ; CX = width of block. - Mov AX, 5 - Mul CX - Mov CX, AX - - Mov DX, BlockBottom - Sub DX, BlockTop - Inc DX ; DX = height of block - -; Mov ES, PatternDataArea - Push ES - Pop DS - -PEFunction_BlockSwap6: - Push CX - Push DX - Push SI - Push DI - -PEFunction_BlockSwap7: - Mov AL, [DS:DI] - MovsB - Mov [DS:SI-1], AL - Loop PEFunction_BlockSwap7 - - Pop DI - Pop SI - Pop DX - Pop CX - Add SI, 320 - Add DI, 320 - Dec DX - JNZ PEFunction_BlockSwap6 - - Mov AX, 1 - Ret - -EndP PEFunction_BlockSwap - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BlockCopy Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Mov AX, BlockDataArea - And AX, AX - JZ PEFunction_BlockCopy1 - - Mov ES, AX - Mov AH, 49h - Int 21h - -PEFunction_BlockCopy1: - Mov AX, BlockBottom - Sub AX, BlockTop - Inc AX - - Mov BX, BlockRight - Sub BX, BlockLeft - Inc BX - Mul BX - Mov BX, 5 - Mul BX - ; AX = size of block - Mov BX, AX - Add BX, 19 ; + space for width/height - ShR BX, 4 - Mov AH, 48h - Int 21h - JNC PEFunction_BlockCopy2 - - Jmp PEFunction_OutOfMemoryMessage - -PEFunction_BlockCopy2: - Mov BlockDataArea, AX - Xor DI, DI - Mov ES, AX - - Mov AX, BlockRight - Sub AX, BlockLeft - Inc AX - StosW - Mov BX, 5 - Mul BX - Mov DX, AX ; DX = width*5 - - Mov AX, BlockBottom - Sub AX, BlockTop - Inc AX - StosW - Mov CX, AX ; CX = height - - Push DX - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mul BX - Mov SI, AX - - Pop DX - Mov DS, PatternDataArea - -PEFunction_BlockCopy3: - Push SI - Push CX - - Mov CX, DX - Rep MovsB - - Pop CX - Pop SI - Add SI, 320 - Loop PEFunction_BlockCopy3 - - Mov AX, 1 - Ret - -EndP PEFunction_BlockCopy - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_NoBlockMarkedMessage Far - - Mov DI, Offset O1_NoBlockMarkedList - Mov CX, 2 - Call M_Object1List - - Mov AX, 1 - Ret - -EndP PEFunction_NoBlockMarkedMessage - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_OutOfMemoryMessage Far - - Call PE_FillHeader - Call S_SaveScreen - - Mov DI, Offset O1_OutOfMemoryList - Mov CX, 2 - Call M_Object1List - - Call S_RestoreScreen - - Mov AX, 1 - Ret - -EndP PEFunction_OutOfMemoryMessage - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_NoBlockData Far - - Mov DI, Offset O1_NoBlockDataList - Mov CX, 2 - Call M_Object1List - - Mov AX, 1 - Ret - -EndP PEFunction_NoBlockData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BlockOverWrite Far - - Mov AX, BlockDataArea - And AX, AX - JZ PEFunction_NoBlockData - - Cmp [Word Ptr LastKeyBoard2+2], 1800h - JE PEFunction_BlockOverWrite5 - - Mov DI, 10 - Call PE_AddToUndoBuffer - - Mov ES, AX - Mov CL, [ES:0] - Mov CH, [ES:2] - Call NetworkPartialPattern - -PEFunction_BlockOverWrite6: - - Mov BP, MaxRow - Mov BX, Row - Mov CX, Channel - - Call GetPatternOffset - - Mov DS, AX - - Mov SI, 4 ; DS:SI points to block - - Mov AX, CX - Mov DX, [DS:0] - Mov CX, [DS:2] ; DX = width, CX = height - -PEFunction_BlockOverWrite1: - Push AX - Push CX - Push DX - Push DI - -PEFunction_BlockOverWrite2: - Cmp AX, 63 - JA PEFunction_BlockOverWrite3 - - Mov CX, 5 - Rep MovsB - - Jmp PEFunction_BlockOverWrite4 - -PEFunction_BlockOverWrite3: - Add SI, 5 - -PEFunction_BlockOverWrite4: - Inc AX ; AX = channel - Dec DX - JNZ PEFunction_BlockOverWrite2 - - Pop DI - Pop DX - Pop CX - Pop AX - Add DI, 320 - Inc BX - Cmp BX, BP - JA PEFunction_BlockOverWrite5 - - Loop PEFunction_BlockOverWrite1 - -PEFunction_BlockOverWrite5: - Mov AX, 1 - Ret - -EndP PEFunction_BlockOverWrite - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BlockPaste Far - - Mov AX, BlockDataArea - And AX, AX - JZ PEFunction_NoBlockData - - Cmp [Word Ptr LastKeyBoard2+2], 1900h - JE PEFunction_BlockPaste6 - - Mov DI, 11 - Call PE_AddToUndoBuffer - -PEFunction_BlockPaste6: - Push DS - Mov BP, MaxRow - - Mov ES, AX - - Mov CH, Byte Ptr MaxRow - Sub CH, Byte Ptr Row - Inc CH - Mov CL, [ES:0] - Call NetworkPartialPattern - - Mov BX, [ES:0] ; width - Mov CX, [ES:2] ; height - -; Condition: -; If Row == 0 && Channel == 0 && height > MaxRow && width > 1, then set maxrow = height - Cmp CX, BP - JB PEFunction_BlockPaste7 - - Mov AX, Channel - Or AX, Row - JNZ PEFunction_BlockPaste7 - - Cmp BX, 1 - JBE PEFunction_BlockPaste7 - - Mov BP, CX - Dec BP - Mov MaxRow, BP - -PEFunction_BlockPaste7: - Mov AX, 64 - Mul BP - Add AX, Channel - Mov DX, 5 - Mul DX - Mov SI, AX - Mov DI, AX - - Mov AX, 320 - Mul CX - Add DI, AX ; DI has destination... - - Mov AX, Channel - Mov DS, PatternDataArea - Push DS - Pop ES - -PEFunction_BlockPaste1: - Push AX - Push CX - Push SI - Push DI - - Mov AX, CS:Row - Add AX, CX - Mov DX, BP - Add DX, CX - -PEFunction_BlockPaste5: - Cmp DX, BP - JA PEFunction_BlockPaste3 - - Mov CX, 5 - Rep MovsB - Sub SI, 325 - Sub DI, 325 - - Jmp PEFunction_BlockPaste4 - -PEFunction_BlockPaste3: - Sub SI, 320 - Sub DI, 320 - -PEFunction_BlockPaste4: - Dec DX - Cmp DX, AX - JAE PEFunction_BlockPaste5 - - Pop DI - Pop SI - Pop CX - Pop AX - - Add SI, 5 - Add DI, 5 - Inc AX - Cmp AX, 63 - JA PEFunction_BlockPaste2 - - Dec BX - JNZ PEFunction_BlockPaste1 - -PEFunction_BlockPaste2: - Pop DS - - Mov AX, BlockDataArea - Jmp PEFunction_BlockOverWrite6 - -EndP PEFunction_BlockPaste - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_SecondBlockMix Far - - Mov BP, MaxRow - Mov BX, Row - Mov CX, Channel - - Call GetPatternOffset - - Mov DS, BlockDataArea - - Mov SI, 4 ; DS:SI points to block - - Mov AX, CX - - Mov CL, [DS:0] - Mov CH, [DS:2] - Call NetworkPartialPattern - - Mov DX, [DS:0] - Mov CX, [DS:2] ; DX = width, CX = height - -PEFunction_SecondBlockMix1: - Push AX - Push CX - Push DX - Push DI - -PEFunction_SecondBlockMix2: - Cmp AX, 63 - JA PEFunction_SecondBlockMix3 - - Cmp Byte Ptr [ES:DI], NONOTE ; Note - JNE PEFunction_SecondBlockMix7 - - Mov CL, [DS:SI] - Mov [ES:DI], CL - -PEFunction_SecondBlockMix7: - Inc SI - Inc DI - - Cmp Byte Ptr [ES:DI], 0 ; Instrument - JNE PEFunction_SecondBlockMix8 - - Mov CL, [DS:SI] - Mov [ES:DI], CL - -PEFunction_SecondBlockMix8: - Inc SI - Inc DI - - Cmp Byte Ptr [ES:DI], 0FFh ; Volume - JNE PEFunction_SecondBlockMix9 - - Mov CL, [DS:SI] - Mov [ES:DI], CL - -PEFunction_SecondBlockMix9: - Inc SI - Inc DI - - Cmp Byte Ptr [ES:DI], 0 ; Command - JNE PEFunction_SecondBlockMix10 - - Mov CL, [DS:SI] - Mov [ES:DI], CL - -PEFunction_SecondBlockMix10: - Inc SI - Inc DI - - Cmp Byte Ptr [ES:DI], 0 ; Commandvalue - JNE PEFunction_SecondBlockMix11 - - Mov CL, [DS:SI] - Mov [ES:DI], CL - -PEFunction_SecondBlockMix11: - Inc SI - Inc DI - Jmp PEFunction_SecondBlockMix4 - -PEFunction_SecondBlockMix3: - Add SI, 5 - -PEFunction_SecondBlockMix4: - Inc AX ; AX = channel - Dec DX - JNZ PEFunction_SecondBlockMix2 - - Pop DI - Pop DX - Pop CX - Pop AX - Add DI, 320 - Inc BX - Cmp BX, BP - JA PEFunction_SecondBlockMix5 - - Loop PEFunction_SecondBlockMix1 - -PEFunction_SecondBlockMix5: - Mov AX, 1 - Ret - -EndP PEFunction_SecondBlockMix - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BlockMix Far - - Cmp BlockDataArea, 0 - JE PEFunction_NoBlockData - - Cmp [Word Ptr LastKeyBoard2+2], 3200h - JNE PEFunction_BlockMix1 - - Cmp [Word Ptr LastKeyboard3+2], 3200h - JE PEFunction_BlockMix6 - - Jmp PEFunction_SecondBlockMix - -PEFunction_BlockMix1: - Mov DI, 9 - Call PE_AddToUndoBuffer - Call NetworkBlock - - Mov BP, MaxRow - Mov BX, Row - Mov CX, Channel - - Call GetPatternOffset - - Mov DS, BlockDataArea - Mov SI, 4 ; DS:SI points to block - - Mov AX, CX - - Mov CL, [DS:0] - Mov CH, [DS:2] - Call NetworkPartialPattern - - Mov DX, [DS:0] - Mov CX, [DS:2] ; DX = width, CX = height - -PEFunction_BlockMix2: - Push AX - Push CX - Push DX - Push DI - -PEFunction_BlockMix3: - Cmp AX, 63 - JA PEFunction_BlockMix4 - - Cmp DWord Ptr [ES:DI], NONOTE + 0FF0000h - JNE PEFunction_BlockMix7 - Cmp Byte Ptr [ES:DI+4], 0 - JNE PEFunction_BlockMix7 - - Mov CX, 5 - Rep MovsB - - Jmp PEFunction_BlockMix5 - -PEFunction_BlockMix7: - Add DI, 5 - -PEFunction_BlockMix4: - Add SI, 5 - -PEFunction_BlockMix5: - Inc AX ; AX = channel - Dec DX - JNZ PEFunction_BlockMix3 - - Pop DI - Pop DX - Pop CX - Pop AX - Add DI, 320 - Inc BX - Cmp BX, BP - JA PEFunction_BlockMix6 - - Loop PEFunction_BlockMix2 - -PEFunction_BlockMix6: - Mov AX, 1 - Ret - -EndP PEFunction_BlockMix - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_UnMarkBlock Far - - Cmp BlockMark, 0 - JZ PEFunction_UnMarkBlock1 - - Mov BlockMark, 0 - Jmp PEFunction_UnMarkBlock2 - -PEFunction_UnMarkBlock1: - Mov AX, BlockDataArea - And AX, AX - JZ PEFunction_NoBlockData - - Mov ES, AX - Mov AH, 49h - Int 21h - - Mov BlockDataArea, 0 -PEFunction_UnMarkBlock2: - Mov AX, 1 - Ret - -EndP PEFunction_UnMarkBlock - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_SemiUp Far - - Cmp [Word Ptr LastKeyBoard2+2], 1000h - JE PEFunction_SemiUp6 - - Mov DI, 2 - Call PE_AddToUndoBuffer - -PEFunction_SemiUp6: - Cmp BlockMark, 0 - JNE PEFunction_SemiUp4 - - Mov CX, 101h - Call NetworkPartialPattern - - Mov AX, 64 - Mul Row - Add AX, Channel - Mov BX, 5 - Mul BX - Mov SI, AX - Mov CX, 1 - Mov DX, CX - Jmp PEFunction_SemiUp5 - -PEFunction_SemiUp4: - Call NetworkBlock - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX ; AX = start offset - - Mov SI, AX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - -PEFunction_SemiUp5: - Mov DS, PatternDataArea - -PEFunction_SemiUp1: - Push DX - Push SI - -PEFunction_SemiUp2: - Cmp Byte Ptr [SI], 119 - JAE PEFunction_SemiUp3 - - Inc Byte Ptr [SI] - -PEFunction_SemiUp3: - Add SI, 5 - Dec DX - JNZ PEFunction_SemiUp2 - - Pop SI - Pop DX - Add SI, 320 - Loop PEFunction_SemiUp1 - - Mov AX, 1 - Ret - -EndP PEFunction_SemiUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_SemiDown Far - - Cmp [Word Ptr LastKeyBoard2+2], 1E00h - JE PEFunction_SemiDown6 - - Mov DI, 3 - Call PE_AddToUndoBuffer - -PEFunction_SemiDown6: - Cmp BlockMark, 0 - JNE PEFunction_SemiDown4 - - Mov CX, 101h - Call NetworkPartialPattern - - Mov AX, 64 - Mul Row - Add AX, Channel - Mov BX, 5 - Mul BX - Mov SI, AX - Mov CX, 1 - Mov DX, CX - Jmp PEFunction_SemiDown5 - -PEFunction_SemiDown4: - Call NetworkBlock - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX ; AX = start offset - - Mov SI, AX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - -PEFunction_SemiDown5: - Mov DS, PatternDataArea - -PEFunction_SemiDown1: - Push DX - Push SI - -PEFunction_SemiDown2: - Cmp Byte Ptr [SI], 0 - JLE PEFunction_SemiDown3 - - Dec Byte Ptr [SI] - -PEFunction_SemiDown3: - Add SI, 5 - Dec DX - JNZ PEFunction_SemiDown2 - - Pop SI - Pop DX - Add SI, 320 - Loop PEFunction_SemiDown1 - - Mov AX, 1 - Ret - -EndP PEFunction_SemiDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_SlideCommand Far - - Mov DI, 15 - Call PE_AddToUndoBuffer - Call NetworkBlock - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov SI, AX - - Mov AX, 64 - Mul BlockBottom - Add AX, BlockLeft - Mul BX - Mov DI, AX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov CX, BlockBottom - Sub CX, BlockTop - JZ PEFunction_AltX2 ; CX contains number of rows - - Add SI, 4 - Add DI, 4 - Mov DS, PatternDataArea - -PEFunction_AltX1: - Push CX - Push DX - Push SI - - MovZX AX, Byte Ptr [DI] - MovZX BX, Byte Ptr [SI] - Sub AX, BX ; AX = change. - JS PEFunction_AltX4 - - Div CL - Mov BH, AL - Xor AL, AL - Div CL - Mov BL, AL - - Xor AL, AL - Jmp PEFunction_AltX5 - - -PEFunction_AltX4: - Neg AX - Div CL - Mov BH, AL - Xor AL, AL - Div CL - Mov BL, aL - Neg BX - - Mov AL, 0FFh - -PEFunction_AltX5: - Mov AH, [SI] - -PEFunction_AltX3: - Mov [SI], AH - - Add AX, BX - Add SI, 320 - Loop PEFunction_AltX3 - - Pop SI - Pop DX - Pop CX - Add SI, 5 - Add DI, 5 - Dec DX - JNZ PEFunction_AltX1 - -PEFunction_AltX2: - Mov AX, 1 - Ret - -EndP PEFunction_SlideCommand - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_WipeCommands Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Cmp [Word Ptr LastKeyBoard2+2], 2D00h - JE PEFunction_WipeCommands4 - - Jmp PEFunction_SlideCommand - -PEFunction_WipeCommands4: - Cmp [Word Ptr LastKeyBoard3+2], 2D00h - JE PEFunction_WipeCommands6 - - Mov DI, 16 - Call PE_AddToUndoBuffer - Call NetworkBlock - -PEFunction_WipeCommands6: - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov DI, AX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - - Mov ES, PatternDataArea - Add DI, 3 - - Xor AX, AX - -PEFunction_WipeCommands2: - Push CX - Push DI - - Mov CX, DX - -PEFunction_WipeCommands3: - StosW - Add DI, 3 - Loop PEFunction_WipeCommands3 - - Pop DI - Pop CX - Add DI, 320 - Loop PEFunction_WipeCommands2 - -PEFunction_WipeCommands1: - Mov AX, 1 - Ret - -EndP PEFunction_WipeCommands - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_VolumeAmp Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Test CentraliseCursor, 4 - JZ PENoFast1 - - Mov AX, FastVolumeAmplification - Mov Amplification, AX - Jmp PEFastVolumeAmp - -PENoFast1: - Cmp Amplification, 200 - JBE PENoFast2 - - Mov Amplification, 200 - -PENoFast2: - Push DS - - Mov DI, Offset O1_GetAmpList - Mov CX, 3 - Call M_Object1List - - Pop DS - - Cmp DX, 1 - JNE PEFunction_VolumeAmp1 - -PEFastVolumeAmp: - Mov DI, 6 - Call PE_AddToUndoBuffer - Call NetworkBlock - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov SI, AX - - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov BP, Amplification - Mov BX, 100 -; Mov BH, 100 ; For division - - Mov DS, PatternDataArea - Add SI, 2 - - Call Music_GetSongSegment - Mov ES, AX - -PEFunction_VolumeAmp2: - Push CX - Push DX - Push SI - - Mov CX, DX - -PEFunction_VolumeAmp3: - Mov AL, [SI] - Cmp AL, 0FFh - JNE PEFunction_VolumeAmp6 - - Mov DI, [SI-1] - And DI, 0FFh - JZ PEFunction_VolumeAmp4 - ; OK.. find whether inst/sample - ; then get default vol. - Call Music_GetInstrumentMode - JZ PEFunction_VolumeAmp7 - - Add DI, DI - Mov DI, [ES:64712+DI-2] - Mov AL, [SI-2] - And AX, 0FFh - JZ PEFunction_VolumeAmp4 - Add AX, AX - Add DI, AX - Mov DI, [ES:DI+41h] - And DI, 0FFh - JZ PEFunction_VolumeAmp4 - -PEFunction_VolumeAmp7: - Dec DI - Add DI, DI - Mov DI, [ES:64912+DI] - Mov AL, [ES:DI+13h] - -PEFunction_VolumeAmp6: - Cmp AL, 64 - JA PEFunction_VolumeAmp4 - - Xor AH, AH - Push DX - - Mul BP - Div BX - - Pop DX - - Cmp AX, 64 - JBE PEFunction_VolumeAmp5 - - Mov AL, 64 - -PEFunction_VolumeAmp5: - Mov [SI], AL - -PEFunction_VolumeAmp4: - Add SI, 5 - Loop PEFunction_VolumeAmp3 - - Pop SI - Pop DX - Pop CX - Add SI, 320 - Loop PEFunction_VolumeAmp2 - -PEFunction_VolumeAmp1: - Mov AX, 1 - Ret - -EndP PEFunction_VolumeAmp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc GetPatternLength - - Push AX - Push BX - Push CX - Push DS - Push SI - Push ES - Push DI - - Call ClearEncodingInfo - ; OK, masks are reset. - - Mov CX, CS:MaxRow - Inc CX - Mov DX, CX ; DX = count of bytes. - ; End of row bytes added. - - Mov DS, CS:PatternDataArea - Xor SI, SI ; SI = pattern area. - - Mov DI, Offset EncodingInfo ; ES:DI points to encoding info - -GetPatternLength1: - Push CX - Push DI - - Mov CX, 64 - -GetPatternLength2: - Cmp Word Ptr [SI], NONOTE - JNE GetPatternLength4 - Cmp Byte Ptr [SI+2], 0FFh - JNE GetPatternLength4 - Cmp Word Ptr [SI+3], 0 - JE GetPatternLength3 - -GetPatternLength4: - Inc DX ; 1 byte for channel - ; indication - JZ GetPatternLength13 - ; AH will be mask - MovZX AX, Byte Ptr [SI] ; Note - Cmp AL, NONOTE - JE GetPatternLength5 - Cmp AL, [ES:DI+1] ; 5 is note. - JE GetPatternLength12 - - Mov [ES:DI+1], AL - Inc DX - JZ GetPatternLength13 - Or AH, 1 - Jmp GetPatternLength5 - -GetPatternLength12: - Or AH, 16 - -GetPatternLength5: - Mov AL, [SI+1] ; Instrument - And AL, AL - JZ GetPatternLength7 - - Cmp AL, [ES:DI+2] - JE GetPatternLength6 - - Mov [ES:DI+2], AL - Inc DX - JZ GetPatternLength13 - Or AH, 2 - Jmp GetPatternLength7 - -GetPatternLength6: - Or AH, 32 - -GetPatternLength7: - Mov AL, [SI+2] ; Volume - Cmp AL, 0FFh - JE GetPatternLength8 - - Cmp AL, [ES:DI+3] - JE GetPatternLength9 - - Mov [ES:DI+3], AL - Inc DX - JZ GetPatternLength13 - Or AH, 4 - Jmp GetPatternLength8 - -GetPatternLength9: - Or AH, 64 - -GetPatternLength8: - Mov BX, [SI+3] - And BX, BX - JZ GetPatternLength11 - Cmp BX, [ES:DI+4] - JE GetPatternLength10 - - Mov [ES:DI+4], BX - - Inc DX - JZ GetPatternLength13 - Inc DX - JZ GetPatternLength13 - Or AH, 8 - - Jmp GetPatternLength11 - -GetPatternLength10: - Or AH, 128 - -GetPatternLength11: - Cmp AH, [ES:DI] - JE GetPatternLength3 - - Inc DX - JZ GetPatternLength13 - Mov [ES:DI], AH - -GetPatternLength3: - - Add SI, 5 - Add DI, 6 - Loop GetPatternLength2 - - Pop DI - Pop CX - Loop GetPatternLength1 - - Pop DI - Pop ES - Pop SI - Pop DS - Pop CX - Pop BX - Pop AX - - Ret - -GetPatternLength13: - Mov DI, Offset O1_PatternTooLongList - Mov CX, 2 - Call M_Object1List - - Add SP, 22 ; yes! - Mov AX, 1 - RetF - -EndP GetPatternLength - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -IF SHOWPATTERNLENGTH - -Proc PE_ShowPatternLength Far - - Push AX ; Just for stack length.. - Call GetPatternLength - Pop AX - - Mov AX, Object1 - Push AX - Mov DS, AX - Mov AX, Offset O1_ShowPatternLengthList - Push AX - Mov SI, Offset PatternLength - Mov [SI], DX - Call M_FunctionHandler - - Mov AX, 1 - Ret - -EndP PE_ShowPatternLength - -ENDIF - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -DecodePatternBytes DW 0 -DecodePatternOffset DW 0 - -Proc DecodePattern ; DS:SI points to pattern info to decode - - PushA - Push DS - Push ES - -; Call ClearEncodingInfo ; Should be unnecess. - - - Push CS - Pop ES - Mov BX, Offset EncodingInfo - - LodsW ; AX = number of bytes - Mov CS:DecodePatternBytes, AX - LodsW ; AX = maxrow - Mov CX, AX - Dec AX - Mov CS:MaxRow, AX - LodsW - LodsW - - Mov CS:DecodePatternOffset, SI - - Call PE_ClearPatternData - - Mov ES, CS:PatternDataArea - Xor DI, DI - -DecodePattern1: - Push CX - -DecodePattern5: - LodsB ; AL = channel byte. - Test AL, AL - JZ DecodePattern2 - - Push BX - Push DI - - Mov CX, AX - Dec CX - And CX, 63 - - ; DI = DI + Channel*5 - ; BX = EncodingInfo + Channel*6 - - LEA BX, [ECX*4+ECX] - LEA DI, [DI+BX] - LEA BX, [EBX+ECX+EncodingInfo] - - Test AL, 128 - JZ DecodePattern3 - - Mov DL, [SI] - Inc SI - - Mov [CS:BX], DL - Jmp DecodePattern4 - -DecodePattern3: - Mov DL, [CS:BX] ; DL = mask - -DecodePattern4: - Test DL, 1 - JZ DecodePattern13 - - LodsB - - Mov [ES:DI], AL - Mov [CS:BX+1], AL - Jmp DecodePattern6 - -DecodePattern13: - Test DL, 16 - JZ DecodePattern6 - - Mov AL, [CS:BX+1] - Mov [ES:DI], AL - -DecodePattern6: - Test DL, 2 - JZ DecodePattern7 - - LodsB - - Mov [ES:DI+1], AL - Mov [CS:BX+2], AL - Jmp DecodePattern8 - -DecodePattern7: - Test DL, 32 - JZ DecodePattern8 - - Mov AL, [CS:BX+2] - Mov [ES:DI+1], AL - -DecodePattern8: - Test DL, 4 - JZ DecodePattern9 - - LodsB - - Mov [ES:DI+2], AL - Mov [CS:BX+3], AL - Jmp DecodePattern10 - -DecodePattern9: - Test DL, 64 - JZ DecodePattern10 - - Mov AL, [CS:BX+3] - Mov [ES:DI+2], AL - -DecodePattern10: - Test DL, 8 - JZ DecodePattern11 - - LodsW - - Mov [ES:DI+3], AX - Mov [CS:BX+4], AX - Jmp DecodePattern12 - -DecodePattern11: - Test DL, 128 - JZ DecodePattern12 - - Mov AX, [CS:BX+4] - Mov [ES:DI+3], AX - -DecodePattern12: - Pop DI - Pop BX - Jmp DecodePattern5 - -DecodePattern2: - Pop CX - Add DI, 320 - Loop DecodePattern1 - - Sub SI, CS:DecodePatternOffset - Cmp SI, CS:DecodePatternBytes - JE DecodePatternEnd - - Mov CX, 0FFFFh - Mov DI, Offset O1_PatternSizeMismatchList - Call M_Object1List - -DecodePatternEnd: - Pop ES - Pop DS - PopA - - Call Music_UpdatePatternOffset - - Ret - -EndP DecodePattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc EncodePattern ; ES:DI points to area to deposit data - ; DX = length of data - - Push AX - Push BX - Push CX - Push DX - Push DS - Push SI - - Push ES - Push DI - - Call ClearEncodingInfo - - Pop DI - Pop ES - - Mov BX, Offset EncodingInfo - - Mov AX, DX - StosW - - Mov CX, CS:MaxRow - Inc CX - - Mov AX, CX - StosW - - Xor AX, AX - StosW - StosW ; This is the header. - - Xor SI, SI - Mov DS, CS:PatternDataArea - -EncodePattern1: - Push BX - Push CX - - Xor DX, DX ; DL = channelnumber - ; DH is used as mask val. - Mov CX, 64 - -EncodePattern2: - Cmp Word Ptr [SI], NONOTE - JNE EncodePattern3 - Cmp Byte Ptr [SI+2], 0FFh - JNE EncodePattern8 - Cmp Word Ptr [SI+3], 0 - JE EncodePattern4 - Jmp EncodePattern10 - -EncodePattern3: - Mov AL, [SI] - Cmp AL, NONOTE - JE EncodePattern5 - Cmp AL, [CS:BX+1] ; 1=note - JE EncodePattern6 - - Mov [CS:BX+1], AL - Or DH, 1 - Jmp EncodePattern5 - -EncodePattern6: - Or DH, 16 - -EncodePattern5: - Mov AL, [SI+1] - And AL, AL - JZ EncodePattern8 - Cmp AL, [CS:BX+2] ; 2=ins - JE EncodePattern7 - - Mov [CS:BX+2], AL - Or DH, 2 - Jmp EncodePattern8 - -EncodePattern7: - Or DH, 32 - -EncodePattern8: - Mov AL, [SI+2] - Cmp AL, 0FFh - JE EncodePattern10 - Cmp AL, [CS:BX+3] ; 3=vol - JE EncodePattern9 - - Mov [CS:BX+3], AL - Or DH, 4 - Jmp EncodePattern10 - -EncodePattern9: - Or DH, 64 - -EncodePattern10: - Mov AX, [SI+3] - Test AX, AX - JZ EncodePattern12 - Cmp AX, [CS:BX+4] ; 4=effect - JE EncodePattern11 - - Mov [CS:BX+4], AX - Or DH, 8 - Jmp EncodePattern12 - -EncodePattern11: - Or DH, 128 - -EncodePattern12: - Mov AL, DL - Inc AX - - Cmp [CS:BX], DH ; 0 = mask - JE EncodePattern13 - - Mov [CS:BX], DH - Or AL, 128 ; read another mask... - StosB - Mov AL, DH - StosB - Jmp EncodePattern14 - -EncodePattern13: - StosB - -EncodePattern14: - Test DH, 1 - JZ EncodePattern15 - - Mov AL, [SI] - StosB - -EncodePattern15: - Test DH, 2 - JZ EncodePattern16 - - Mov AL, [SI+1] - StosB - -EncodePattern16: - Test DH, 4 - JZ EncodePattern17 - - Mov AL, [SI+2] - StosB - -EncodePattern17: - Test DH, 8 - JZ EncodePattern18 - - Mov AX, [SI+3] - StosW - -EncodePattern18: - Xor DH, DH - -EncodePattern4: - Add SI, 5 - Add BX, 6 - Inc DX - Loop EncodePattern2 - - Pop CX - Pop BX - Xor AL, AL - StosB - Loop EncodePattern1 - - Pop SI - Pop DS - Pop DX - Pop CX - Pop BX - Pop AX - Ret - -EndP EncodePattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_StorePattern - -IF NETWORKENABLED - Cmp PatternModified, 0 - JE PEFunction_StorePattern5 - - Mov AX, PatternNumber - ShL AX, 8 - Add AX, NETWORK_ENTIREPATTERNOBJECT - Call Network_AddWordToQueue - -PEFunction_StorePattern5: -ENDIF - - Mov AX, PatternNumber - Mov SI, AX - Call Music_ReleasePattern - - Call GetPatternLength - Cmp DX, 64 - JNE PEFunction_StorePattern1 - Cmp CS:MaxRow, 63 - JE PEFunction_StorePattern2 - -PEFunction_StorePattern1: - Add DX, 8 - JC PEFunction_StorePattern4 - - ClI - - Call Music_AllocatePattern - Mov AX, ES - And AX, AX - JZ PEFunction_StorePattern3 - Sub DX, 8 - Call EncodePattern - - StI - -PEFunction_StorePattern2: - Ret - -PEFunction_StorePattern3: - StI - - Add SP, 2 - Jmp PEFunction_OutOfMemoryMessage - -PEFunction_StorePattern4: - Mov DI, Offset O1_PatternTooLongList - Mov CX, 2 - Call M_Object1List - - Pop AX - Mov AX, 1 - RetF - -EndP PEFunction_StorePattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_StoreCurrentPattern Far - - Push CS - Pop DS - Call PEFunction_StorePattern - - Mov AX, 1 - Ret - -EndP PEFunction_StoreCurrentPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc NewPattern ; Reqs. AX = pattern - -IF NETWORKENABLED - Call Network_UpdatePattern -ENDIF - Call Music_GetPattern - Call DecodePattern - - Mov CS:PatternModified, 0 - Mov AH, CS:Byte Ptr PatternNumber - Mov AL, 22 - Mov DI, AX -; Mov DI, 22 - Call PE_AddToUndoBuffer - - Ret - -EndP NewPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_GotoPattern Far ; AX = pattern. - - Push CS - Pop DS - - Mov Row, BX - Mov Channel, CX - -PE_GotoPattern2: - Cmp PatternModified, 0 - JE PE_GotoPattern1 - - Mov TempVariableArea, AX - Call PEFunction_StorePattern - Mov AX, TempVariableArea - -PE_GotoPattern1: - Mov PatternNumber, AX - Call NewPattern - - Jmp Glbl_F2 - -EndP PE_GotoPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -include pe_trans.inc - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_NextPattern Far - - Cmp TracePlayback, 0 - JE PEFunction_NextPatternNoTrace - - Call Music_GetPlayMode - Cmp AX, 1 - JE PEFunction_NextPattern1 - JB PEFunction_NextPatternNoTrace - - Call Music_NextOrder - Jmp PEFunction_NextPattern1 - -PEFunction_NextPatternNoTrace: - Cmp PatternNumber, 199 - JAE PEFunction_NextPattern1 - - Cmp PatternModified, 0 - JE PEFunction_NextPattern2 - - Call PEFunction_StorePattern - -PEFunction_NextPattern2: - Inc PatternNumber - Mov AX, PatternNumber - - Call NewPattern - -PEFunction_NextPattern1: - Mov AX, 1 - Ret - -EndP PEFunction_NextPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_LastPattern Far - - Cmp TracePlayback, 0 - JE PEFunction_LastPatternNoTrace - - Call Music_GetPlayMode - Cmp AX, 1 - JE PEFunction_LastPattern1 - JB PEFunction_LastPatternNoTrace - - Call Music_LastOrder - Jmp PEFunction_LastPattern1 - -PEFunction_LastPatternNoTrace: - Cmp PatternNumber, 0 - JE PEFunction_LastPattern1 - - Cmp PatternModified, 0 - JE PEFunction_LastPattern2 - - Call PEFunction_StorePattern - -PEFunction_LastPattern2: - Dec PatternNumber - Mov AX, PatternNumber - - Call NewPattern - -PEFunction_LastPattern1: - Mov AX, 1 - Ret - -EndP PEFunction_LastPattern -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Next4Patterns Far - - Cmp PatternModified, 0 - JE PEFunction_Next4Patterns2 - - Call PEFunction_StorePattern - -PEFunction_Next4Patterns2: - Mov AX, PatternNumber - Add AX, 4 - Cmp AX, 199 - JBE PEFunction_Next4Patterns1 - - Mov AX, 199 - -PEFunction_Next4Patterns1: - Mov PatternNumber, AX - - Call NewPattern - - Mov AX, 1 - Ret - -EndP PEFunction_Next4Patterns - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Last4Patterns Far - - Cmp PatternModified, 0 - JE PEFunction_Last4Patterns2 - - Call PEFunction_StorePattern - -PEFunction_Last4Patterns2: - Mov AX, PatternNumber - Sub AX, 4 - JNS PEFunction_Last4Patterns1 - - Xor AX, AX - -PEFunction_Last4Patterns1: - Mov PatternNumber, AX - - Call NewPattern - - Mov AX, 1 - Ret - -EndP PEFunction_Last4Patterns - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_LastOrderPattern Far - - Cmp PatternModified, 0 - JE PEFunction_LastOrderPattern3 - - Call PEFunction_StorePattern - -PEFunction_LastOrderPattern3: - Call Music_GetSongSegment - Mov ES, AX - - Mov BX, Order - And BX, BX - JZ PEFunction_LastOrderPattern2 - - Cmp Byte Ptr [ES:BX+0FFh], 200 - JAE PEFunction_LastOrderPattern2 - - Dec BX - Mov Order, BX - -PEFunction_LastOrderPattern2: - MovZX AX, Byte Ptr [ES:BX+0100h] - Cmp AL, 200 - JAE PEFunction_LastOrderPattern1 - - Mov PatternNumber, AX - - Call NewPattern - -PEFunction_LastOrderPattern1: - Mov AX, 1 - Ret - -EndP PEFunction_LastOrderPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_NextOrderPattern Far - - Cmp PatternModified, 0 - JE PEFunction_NextOrderPattern3 - - Call PEFunction_StorePattern - -PEFunction_NextOrderPattern3: - Mov BX, Order - - Cmp BX, 0FFh - JAE PEFunction_NextOrderPattern1 - - Call Music_GetSongSegment - Mov ES, AX - Cmp Byte Ptr [ES:BX+101h], 200 - JAE PEFunction_NextOrderPattern2 - - Inc BX - Mov Order, BX - -PEFunction_NextOrderPattern2: - MovZX AX, Byte Ptr [ES:BX+100h] - Cmp AL, 200 - JAE PEFunction_NextOrderPattern1 - - Mov PatternNumber, AX - - Call NewPattern - -PEFunction_NextOrderPattern1: - Mov AX, 1 - Ret - -EndP PEFunction_NextOrderPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Alt0 Far - - Xor AX, AX - Mov SkipValue, AX - Mov SI, Offset CursorStepMsg - Call SetInfoLine - - Inc AX - - Ret - -EndP PEFunction_Alt0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_BlockVolume Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Cmp [Word Ptr LastKeyBoard2], 2F00h - JE PEFunction_BlockVolume3 - - Mov DI, 13 - Call PE_AddToUndoBuffer - Call NetworkBlock - -PEFunction_BlockVolume3: - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - - Mov SI, AX - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov AL, LastVolume - - Mov DS, PatternDataArea - Add SI, 2 - -PEFunction_BlockVolume1: - Push CX - Push SI - - Mov CX, DX - -PEFunction_BlockVolume2: - Mov [SI], AL - - Add SI, 5 - Loop PEFunction_BlockVolume2 - - Pop SI - Pop CX - Add SI, 320 - Loop PEFunction_BlockVolume1 - - Mov AX, 1 - Ret - -EndP PEFunction_BlockVolume - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_WipeExcessVolumes Far - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - Cmp [Word Ptr LastKeyBoard2+2], 1100h - JE PEFunction_WipeExcessVolumesEnd - - Mov DI, 14 - Call PE_AddToUndoBuffer - Call NetworkBlock - - Mov AX, 64 - Mul BlockTop - Add AX, BlockLeft - Mov BX, 5 - Mul BX - Mov SI, AX - - Mov CX, BlockBottom - Sub CX, BlockTop - Inc CX - - Mov DX, BlockRight - Sub DX, BlockLeft - Inc DX - - Mov DS, PatternDataArea - Mov AL, 0FFh - -PEFunction_WipeExcessVolumes1: - Push CX - Push SI - - Mov CX, DX - -PEFunction_WipeExcessVolumes2: - Cmp Byte Ptr [SI+1], 0 - JNE PEFunction_WipeExcessVolumes3 - - Cmp Byte Ptr [SI], NONOTE - JAE PEFunction_WipeExcessVolumes4 - -PEFunction_WipeExcessVolumes3: - Add SI, 5 - Loop PEFunction_WipeExcessVolumes2 - - Pop SI - Pop CX - Add SI, 320 - Loop PEFunction_WipeExcessVolumes1 - -PEFunction_WipeExcessVolumesEnd: - Mov AX, 1 - Ret - -PEFunction_WipeExcessVolumes4: - Mov [SI+2], AL - Jmp PEFunction_WipeExcessVolumes3 - -EndP PEFunction_WipeExcessVolumes - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_PlayCurrentNote Far - - Mov AX, 64 - Mul Row - Add AX, Channel - Mov BX, 5 - Mul BX - Mov SI, AX - Mov AX, Channel - Mov DS, PatternDataArea - Mov DH, 32 - Call Music_PlayNote - -IF CHORDENTRY - Push CS - Pop DS - - Cmp ShiftPressed, 0 - JE PE_GotoNextInput - - Push SkipValue - Mov SkipValue, 0 - Mov NoteEntered, 1 - - Call PE_GotoNextInput - Pop SkipValue - - Mov AX, 1 - Ret -ELSE - Jmp PEFunction_Down -ENDIF - -EndP PEFunction_PlayCurrentNote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_PlayCurrentRow Far - - Mov CX, 64 - Mov DS, PatternDataArea - - Mov AX, 320 - Mul CS:Row - Mov SI, AX - Xor AX, AX - -PEFunction_PlayCurrentRow1: -; Push CX - -; Dec CX -; Mov AX, 64 -; Mul CS:Row -; Add AX, CX -; Mov BX, 5 -; Mul BX -; Mov SI, AX -; Mov AX, CX - Xor DH, DH - Call Music_PlayNote - -; Pop CX - Inc AX - Add SI, 5 - Loop PEFunction_PlayCurrentRow1 - - Jmp PEFunction_Down - -EndP PEFunction_PlayCurrentRow - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_RestoreData Far - -; Mov PatternModified, 0 - - Cmp Byte Ptr LastKeyBoard2, 0Eh - JE PEFunction_RestoreData1 - - Mov DI, 1 - Call PE_AddToUndoBuffer - -PEFunction_RestoreData1: - Mov AX, PatternNumber - - Call Music_GetPattern - Call DecodePattern - - Xor BX, BX - Mov CL, 64 - Mov CH, Byte Ptr [CS:MaxRow] - Inc CH - Call NetworkPatternBlock - - Mov AX, 1 - Ret - - Ret - -EndP PEFunction_RestoreData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_ToggleDefaultVolume Far - - Xor Flags, 1 - Mov SI, Offset DefaultVolumeOn - Test Flags, 1 - JNZ PEFunction_ToggleDefaultVolume1 - - Mov SI, Offset DefaultVolumeOff - -PEFunction_ToggleDefaultVolume1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP PE_ToggleDefaultVolume - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ToggleTemplate Far - - Test CentraliseCursor, 4 - JZ ToggleTemplate2 - - Cmp BlockMark, 0 - JE PEFunction_NoBlockMarkedMessage - - ; Amplification = 1/(FastVolumeAmplification/100) - ; = 10050/FastvolumeAmplification - Mov AX, 10050 - Xor DX, DX - Div FastVolumeAmplification - Mov Amplification, AX - Jmp PEFastVolumeAmp - -ToggleTemplate2: - Mov AL, Template - Inc AX - Cmp AL, 4 - JBE PEFunction_ToggleTemplate1 - -Proc PEFunction_TemplateOff Far - - Xor AL, AL - -PEFunction_ToggleTemplate1: - Mov Template, AL - - Mov AX, 1 - Ret - -EndP PEFunction_TemplateOff - -EndP PEFunction_ToggleTemplate - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_GetCurrentPattern Far - - Mov AX, CS:PatternNumber - Mov BX, CS:MaxRow - Inc BX - Mov DS, CS:PatternDataArea - - Ret - -EndP PE_GetCurrentPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_CheckWidth - - Xor DX, DX ; Time to work out width - Xor CX, CX ; Count of channels. - Mov SI, Offset ViewChannels - -PE_CheckWidth1: - LodsW - Cmp AL, 0FFh - JE PE_CheckWidth2 - - MovZX BX, AH - ShL BX, 2 - Add DX, [ViewMethodInfo+BX+2] - Inc CX - Jmp PE_CheckWidth1 - -PE_CheckWidth2: - And CX, CX - JZ PE_CheckWidth3 - - Add DX, 2 - - Cmp ViewDivision, 0 - JE PE_CheckWidth3 - - Dec CX - Add DX, CX - -PE_CheckWidth3: - Cmp DX, 76 ; Too big to fit screen? - JAE PE_CheckWidth5 - - Mov ViewWidth, DX - Xor AX, AX - Cmp DX, 74 - JAE PE_CheckWidth4 - - Mov AX, 74 - Sub AX, DX - Mov BL, 14 - Div BL - Xor AH, AH - -PE_CheckWidth4: - Mov NumChannelsEdit, AX - - DB 85h ; -PE_CheckWidth5: ; - StC ; - Ret - -EndP PE_CheckWidth - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ViewTrack Far - - Mov DX, Channel - Mov SI, Offset ViewChannels - -PEFunction_ViewTrack2: - LodsW - Cmp AL, 0FFh ; No more in list?? - JE PEFunction_ViewTrack1 - - Cmp AL, DL - JNE PEFunction_ViewTrack2 - -PEFunction_ViewTrack1: - Sub SI, 2 - - Mov CX, AX ; Store old value. - Mov AL, DL - Inc AH - Cmp AH, 4 ; Number of view methods - JBE PEFunction_ViewTrack3 - - LodsW - -PEFunction_ViewTrack8: - LodsW - Mov [SI-4], AX - Cmp AX, 0FFFFh - JNE PEFunction_ViewTrack8 - - Jmp PEFunction_ViewTrack9 - -PEFunction_ViewTrack3: - Mov [SI], AX ; Update... - -PEFunction_ViewTrack9: - Push CX - Push SI - - Call PE_CheckWidth - JC PEFunction_ViewTrack7 - - Add SP, 4 - Mov AX, 1 - Ret - -PEFunction_ViewTrack7: - Pop SI - Pop CX - Mov AX, [SI] - Inc AH - Cmp AH, 4 ; Number of view methods - JE PEFunction_ViewTrack10 - - Mov [SI], AX - - Jmp PEFunction_ViewTrack9 - -PEFunction_ViewTrack10: - Mov [SI], CX - - Mov AX, 1 - Ret - -EndP PEFunction_ViewTrack - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ClearViews Far - - Push CS - Pop ES - Mov DI, Offset ViewChannels - Mov CX, 100 - Mov AX, 0FFFFh - Rep StosW - - Mov ViewWidth, 0 - Mov AX, StartChannelEdit - Mov NumChannelsEdit, AX - Mov ViewChannelTracking, 0 - - Mov AX, 1 - Ret - -EndP PEFunction_ClearViews - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_SelectColour Near - - MovZX AX, CL ; AL = row number - - Mov CH, 0E6h - Cmp CS:RowHilight2, 0 - JE PE_SelectColour4 - Div CS:RowHilight2 - And AH, AH - JZ PE_SelectColour1 - -PE_SelectColour4: - MovZX AX, CL - Mov CH, 0F6h - Cmp CS:RowHilight1, 0 - JE PE_SelectColour5 - Div CS:RowHiLight1 - And AH, AH - JZ PE_SelectColour1 - -PE_SelectColour5: - Mov CH, 6 - -PE_SelectColour1: ; Check for block, CL = rownum, BP = ch - MovZX AX, CL ; AX = row number - Cmp CS:BlockMark, 0 - JE PE_SelectColour3 - Cmp BP, CS:BlockLeft - JB PE_SelectColour3 - Cmp BP, CS:BlockRight - JA PE_SelectColour3 - Cmp AX, CS:BlockTop - JB PE_SelectColour3 - Cmp AX, CS:BlockBottom - JA PE_SelectColour3 - - Test CH, 80h - JZ PE_SelectColour2 - - Mov CH, 96h - Ret - -PE_SelectColour2: - Mov CH, 86h - Ret - -PE_SelectColour3: - Cmp AX, CS:Row - JNE PE_SelectColour6 - - Test CS:CentraliseCursor, 2 - JZ PE_SelectColour6 - - Mov CH, 16h - -PE_SelectColour6: - Ret - -EndP PE_SelectColour - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_HilightCursor Near - - Mov AX, [ES:DI] - And AH, 8 - Or AH, 30h - StosW - - Ret - -EndP PE_HilightCursor - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_HilightView Near - - Mov AX, 1 - Cmp CS:Template, 0 - JE PE_HilightView1 - - Cmp CS:ShiftPressed, 0 - JNE PE_HilightView1 - - Cmp CS:PatternCursor, 0 - JNE PE_HilightView1 - - Cmp CS:BlockDataArea, 0 - JE PE_HilightView1 - - Mov FS, CS:BlockDataArea - Mov AX, [FS:0] - -PE_HilightView1: - Mov CX, CS:Channel - Cmp DX, CX - JB PE_HilightViewEnd - Add CX, AX - Cmp DX, CX - JAE PE_HilightViewEnd - - Sub DI, (32*160) - Mov AL, 160 - Mov CX, CS:Row - Sub CX, CS:TopRow - Mul CL - Add DI, AX - Add BP, CS:PatternCursor - - Mov CL, Byte Ptr [CS:BP] - Mov AX, CX - And AX, 0Fh - - Add AX, AX - Add DI, AX - - Mov DX, [ES:DI] - Test DH, 8 - JNZ PE_HilightView4 - Cmp DL, 184 - JE PE_HilightView4 - Cmp DL, 226 - JB PE_HilightView2 - Cmp DL, 246 - JAE PE_HilightView2 - -PE_HilightView4: - Mov AH, 0Fh ; mask value - Cmp CL, Byte Ptr [CS:BP+1] - JE PE_HilightView3 - - Mov AH, 0F0h - -PE_HilightView3: - Call S_InvertCursor - - Mov AX, 246+3000h - StosW - -PE_HilightViewEnd: - Ret - -PE_HilightView2: - Mov AX, [ES:DI] - Mov AH, 30h - StosW - - Sub CL, 10h - JNC PE_HilightView2 - - Ret - -EndP PE_HilightView - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_GetChannelColour ; Puts colour in AH - ; Param: BP = channel - - Push DS - - Call Music_GetSongSegment - Mov DS, AX - - Mov AH, 13h - Test Byte Ptr [DS:BP+40h], 80h - JZ PE_GetChannelColour1 - - Mov AH, 10h - -PE_GetChannelColour1: - Pop DS - - Ret - -EndP PE_GetChannelColour - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ViewCommon - - Push DS - Push ES - Push DI - - Mov BP, DX - And BP, 0FFh - - Push CS - Pop DS - MovZX AX, DL - Inc AX - Mov DX, 0A0Ch - Div DH -; Mov DL, 10 -; Div DL - - Add AX, 3030h - Mov [SI+BX], AX - Sub DI, 160 - Call PE_GetChannelColour - Call S_DrawString - - Pop DI - Pop ES - Pop DS - -; Mov DX, 0A0Ch ; DH = 10, DL = 12 (for div.) - - Mov CH, 32 - - Ret - -EndP ViewCommon - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - - -Proc ViewFull ; DS:SI = pattern data - ; ES:DI = screen pointer - ; CS:BX = note data - ; CX = row number - ; DL = channel number. - - Push SI - Push BX - - Mov SI, Offset ChannelMsg - Mov BX, 9 - Call ViewCommon - - Pop BX - Pop SI - -ViewFull1: - Push CX - Push DX - Push DI - - Call PE_SelectColour - - LodsB - Call Draw_3Note - Mov AL, 20h - StosW - - LodsB ; Instrument - Call Draw_2Instrument - Mov AL, 20h - StosW - - LodsB ; Volume - Cmp AL, 0FFh - JNE ViewFull8 - - Mov AL, 173 - StosW - StosW - - Jmp ViewFull9 - -ViewFull8: - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC ViewFullNoVEffect - - Test AL, 80h - JZ ViewFullVEffect1 - - Add AH, 60 - -ViewFullVEffect1: - Mov AL, AH - Xor AH, AH - Div DH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov CL, AH - Mov AH, CH - StosW - Mov AL, CL - StosW - - Jmp ViewFull9 - -ViewFullNoVEffect: - Mov DL, CH - - Test AL, 80h - JZ ViewFull12 - - And DL, 0F0h - Or DL, 2 - And AL, 7Fh ; Filter out panning stuff. - -ViewFull12: - Xor AH, AH - Div DH - Add AX, 3030h - Mov CL, AH - Mov AH, DL - StosW - Mov AL, CL - StosW - - Mov AH, CH - -ViewFull9: - Mov AL, 20h - StosW - - LodsB ; Command - And AL, AL - JNZ ViewFull10 - - Mov AL, '.' - StosW - Jmp ViewFull11 - -ViewFull10: - Add AL, '@' - StosW - -ViewFull11: - LodsB ; Command value - - AAM 16 ; AH = High nibble, AL = low nibble - Mov CL, AL - Mov AL, AH - Mov AH, CH - Call PE_ConvHexAL - - Mov AL, CL - Call PE_ConvHexAL - - Add SI, 315 - Pop DI - Add DI, 160 - Pop DX - Pop CX - Inc CX - Dec CH - JNZ ViewFull1 - - Mov DX, BP - Mov BP, Offset CursorPositions - Jmp PE_HilightView - -EndP ViewFull - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ViewCompress ; DS:SI = pattern data - ; ES:DI = screen pointer - ; CS:BX = note data - ; CX = row number - ; DL = channel number. - - Push SI - Push BX - - Mov SI, Offset ChannelMsg2 - Mov BX, 8 - Call ViewCommon - - Pop BX - Pop SI - -ViewCompress1: - Push CX - Push DX - Push DI - - Call PE_SelectColour - - LodsB - - Call Draw_3Note - - LodsB ; Instrument - Sub CH, 4 - Call Draw_2Instrument - Add CH, 4 - - LodsB ; Volume - Mov AH, CH - - Cmp AL, 0FFh - JNE ViewCompress8 - - Mov AL, 173 - StosW - StosW - - Jmp ViewCompress9 - -ViewCompress8: - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC ViewCompressNoVEffect - - Test AL, 80h - JZ ViewCompressVEffect1 - - Add AH, 60 - -ViewCompressVEffect1: - Mov AL, AH - Xor AH, AH - Div DH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov CL, AH - Mov AH, CH - StosW - Mov AL, CL - StosW - - Jmp ViewCompress9 - -ViewCompressNoVEffect: - Mov DL, CH - - Test AL, 80h - JZ ViewCompress12 - - And DL, 0F0h - Or DL, 2 - And AL, 7Fh ; Filter out panning stuff. - -ViewCompress12: - Xor AH, AH - Div DH - Add AX, 3030h - Mov CL, AH - Mov AH, DL - StosW - Mov AL, CL - StosW - Mov AH, CH - -ViewCompress9: - LodsB ; Command - Sub AH, 4 - And AL, AL - JNZ ViewCompress10 - - Mov AL, '.' - StosW - Jmp ViewCompress11 - -ViewCompress10: - Add AL, '@' - StosW - -ViewCompress11: - LodsB ; Command value - AAM 16 ; AH = High nibble, AL = low nibble - Mov CL, AL - Mov AL, AH - Mov AH, CH - Sub AH, 4 - Call PE_ConvHexAL - - Mov AL, CL - Call PE_ConvHexAL - - Add SI, 315 - Pop DI - Add DI, 160 - Pop DX - Pop CX - Inc CX - Dec CH - JNZ ViewCompress1 - - Mov DX, BP - Mov BP, Offset CursorPositions+9 - Jmp PE_HilightView - -EndP ViewCompress - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ViewAllSmall ; DS:SI = pattern data - ; ES:DI = screen pointer - ; CS:BX = note data - ; CX = row number - ; DL = channel number. - - Push SI - Push BX - - Mov SI, Offset ChannelMsg7 - Mov BX, 5 - Call ViewCommon - - Pop BX - Pop SI - -ViewAllSmall1: - Push CX - Push DI - - Call PE_SelectColour - - LodsB - Call Draw_3Note - - LodsB ; Instrument - And AL, AL - JNZ ViewAllSmall6 - - Mov AL, 184 - Sub AH, 4 - StosW - Jmp ViewAllSmall7 - -ViewAllSmall6: - Xor AH, AH - Div DH - ShL AL, 4 - Or AL, AH - Mov AH, CH - Add AH, 4 - StosW - -ViewAllSmall7: - LodsB ; Volume - Cmp AL, 0FFh - JNE ViewAllSmall8 - - Mov AL, 184 - Mov AH, CH - StosW - - Jmp ViewAllSmall9 - -ViewAllSmall8: - Mov CL, CH - Add CL, 6 - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC ViewAllSmallNoVEffect - - Test AL, 80h - JZ ViewAllSmallVEffect1 - - Mov AL, AH - Add AL, 226 - Mov AH, CH - StosW - Jmp ViewAllSmall9 - -ViewAllSmallVEffect1: - Mov AL, AH - Mov AH, 0 - Div DH - ; AL = effect, AH = num - Add AL, 0Ah - ShL AL, 4 - Or AL, AH - Mov AH, CL - StosW - - Jmp ViewAllSmall9 - -ViewAllSmallNoVEffect: - Test AL, 80h - JZ ViewAllSmall12 - - Sub CL, 2 - And AL, 7Fh ; Filter out panning stuff. - -ViewAllSmall12: - Xor AH, AH - Div DH - ShL AL, 4 - Or AL, AH - Mov AH, CL - StosW - -ViewAllSmall9: - LodsB ; Command - Mov AH, CH - Sub AH, 4 - - And AL, AL - JNZ ViewAllSmall10 - - Mov AL, '.' - StosW - Jmp ViewAllSmall11 - -ViewAllSmall10: - Add AL, '@' - StosW - -ViewAllSmall11: - LodsB ; Command value - Add AH, 8 - StosW - - Add SI, 315 - Pop DI - Add DI, 160 - Pop CX - Inc CX - Dec CH - JNZ ViewAllSmall1 - - Mov DX, BP - Mov BP, Offset CursorPositions+18 - Jmp PE_HilightView - -EndP ViewAllSmall - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ViewNote ; DS:SI = pattern data - ; ES:DI = screen pointer - ; CS:BX = note data - ; CX = row number - ; DL = channel number. - - Push SI - Push BX - - Mov SI, Offset ChannelMsg4 - Mov BX, 1 - Call ViewCommon - - Pop BX - Pop SI - -ViewNote1: - Push CX - Push SI - Push DI - - Call PE_SelectColour - - LodsB - Cmp AL, NONOTE - JE ViewNote4 - - Call Draw_3Note - Jmp ViewNoteEnd - -ViewNote4: - LodsB - - Test AL, AL - JZ ViewNote5 - - Push AX - - Mov AH, CH - Mov AL, 20h - StosW - - Pop AX - - Call Draw_2Instrument - Jmp ViewNoteEnd - -ViewNote5: ; Volume - LodsB - Cmp AL, 0FFh - JE ViewNote6 - - Push AX - Mov AH, CH - Sub AH, 4 - Mov AL, 20h - StosW - Pop AX - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC ViewNoteNoVEffect - - Test AL, 80h - JZ ViewNoteVEffect1 - - Add AH, 60 - -ViewNoteVEffect1: - Mov AL, AH - Xor AH, AH - Div DH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov CL, AH - Mov AH, CH - StosW - Mov AL, CL - StosW - - Jmp ViewNoteEnd - -ViewNoteNoVEffect: - Mov CL, CH - Sub CL, 4 - - Test AL, 80h - JZ ViewNote25 - - Dec CX - And AL, 7Fh - -ViewNote25: - Xor AH, AH - Div DH - Add AX, 3030h - XChg CL, AH - StosW - Mov AL, CL - StosW - - Jmp ViewNoteEnd - -ViewNote6: - LodsW - And AX, AX - JZ ViewNote11 - - Mov CL, AH - And AL, AL - JZ ViewNote7 - - Add AL, '@' - Jmp ViewNote8 - -ViewNote7: - Mov AL, '.' - -ViewNote8: - Mov AH, CH - Sub AH, 4 - StosW - - Mov AL, CL - AAM 16 ; AH = High nibble, AL = low nibble - Mov CL, AL - Mov AL, AH - Mov AH, CH - Sub AH, 4 - Call PE_ConvHexAL - - Mov AL, CL - Call PE_ConvHexAL - - Jmp ViewNoteEnd - -ViewNote11: ; Nothing to show except dots... - Mov AH, CH - Mov AL, 173 - StosW - StosW - StosW - -ViewNoteEnd: - - Pop DI - Add DI, 160 - Pop SI - Add SI, 320 - Pop CX - Inc CX - Dec CH - JNZ ViewNote1 - - Cmp BP, CS:Channel - JE ViewNote12 - - Mov DX, BP - Mov BP, Offset CursorPositions+27 - Jmp PE_HilightView - - Ret - -ViewNote12: - Push DI - - Sub SI, (320*32) - Sub DI, (32*160) - Mov AL, 160 - Mov DX, CS:Row - Sub DX, CS:TopRow - - Mul DL - Add DI, AX - Add AX, AX - Add SI, AX - - Mov CX, CS:Row - Call PE_SelectColour ; CH = colour. - - Mov DX, CS:PatternCursor - -ViewNote13: - LodsB - Cmp DL, 1 - JA ViewNote16 - - Cmp AL, NONOTE - JNE ViewNote15 - - Mov AH, CH - Mov AL, 173 - StosW - StosW - StosW - -ViewNote15: - Jmp ViewNoteEndHilight - -ViewNote16: - LodsB - Cmp DL, 3 - JA ViewNote19 - - Mov DH, AL - - Mov AH, CH - Mov AL, 20h - StosW - And DH, DH - JZ ViewNote17 - - MovZX AX, DH - Mov DH, 10 - Div DH - - Add AX, 3030h - Mov DH, AH - Mov AH, CH - StosW - Mov AL, DH - StosW - Jmp ViewNoteEndHilight - -ViewNote17: - Mov AL, 173 - StosW - StosW - Jmp ViewNoteEndHilight - -ViewNote19: - LodsB - Cmp DL, 5 - JA ViewNote22 - - Mov DH, AL - - Mov AH, CH - Sub AH, 4 - Mov AL, 20h - StosW - - Cmp DH, 0FFh - JE ViewNote20 - - Mov AH, DH - And AH, 7Fh - Sub AH, 65 - JC ViewNoteNoVEffect2 - - Test DH, 80h - JZ ViewNoteVEffect2 - - Add AH, 60 - -ViewNoteVEffect2: - Mov AL, AH - Xor AH, AH - Mov DH, 10 - Div DH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov CL, AH - Mov AH, CH - StosW - Mov AL, CL - StosW - - Jmp ViewNoteEndHilight - -ViewNoteNoVEffect2: - Sub CH, 4 - - Test DH, 80h - JZ ViewNote26 - - Dec CH - And DH, 7Fh - -ViewNote26: - MovZX AX, DH - Mov DH, 10 - Div DH - - Add AX, 3030h - XChg CH, AH - StosW - Mov AL, CH - StosW - Jmp ViewNoteEndHilight - -ViewNote20: - Mov AL, 173 - StosW - StosW - Jmp ViewNoteEndHilight - -ViewNote22: - LodsB - Mov AH, CH - Sub AH, 4 - And AL, AL - JNZ ViewNote23 - - Mov AL, '.' - Jmp ViewNote24 - -ViewNote23: - Add AL, '@' - -ViewNote24: - Mov AH, CH - Sub AH, 4 - StosW - - LodsB - AAM 16 ; AH = High nibble, AL = low nibble - Mov CL, AL - Mov AL, AH - Mov AH, CH - Sub AH, 4 - Call PE_ConvHexAL - - Mov AL, CL - Call PE_ConvHexAL - -ViewNoteEndHilight: - Pop DI - - Mov DX, BP - Mov BP, Offset CursorPositions+27 - Jmp PE_HilightView - - -EndP ViewNote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ViewTiny ; DS:SI = pattern data - ; ES:DI = screen pointer - ; CS:BX = note data - ; CX = row number - ; DL = channel number. - - Push SI - Push BX - - Mov SI, Offset ChannelMsg5 - Mov BX, 0 - Call ViewCommon - - Pop BX - Pop SI - -ViewTiny1: - Push CX - Push SI - Push DI - - Call PE_SelectColour - - LodsB - Cmp AL, NONOTE - JE ViewTiny4 - - Call Draw_2Note - Jmp ViewTinyEnd - -ViewTiny4: - LodsB - Test AL, AL - JZ ViewTiny5 - - Call Draw_2Instrument - Jmp ViewTinyEnd - -ViewTiny5: ; Volume - LodsB - Cmp AL, 0FFh - JE ViewTiny6 - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC ViewTinyNoVEffect - - Test AL, 80h - JZ ViewTinyVEffect1 - - Add AH, 60 - -ViewTinyVEffect1: - Mov AL, AH - Xor AH, AH - Div DH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov CL, AH - Mov AH, CH - StosW - Mov AL, CL - StosW - - Jmp ViewTinyEnd - -ViewtinyNoVEffect: - Mov CL, CH - Sub CL, 4 - - Test AL, 80h - JZ ViewTiny27 - - Dec CX - And AL, 7Fh - -ViewTiny27: - Xor AH, AH - Div DH - Add AX, 3030h - XChg AH, CL - StosW - Mov AL, CL - StosW - - Jmp ViewTinyEnd - -ViewTiny6: - LodsW - And AX, AX - JZ ViewTiny11 - - Mov CL, AH - And AL, AL - JZ ViewTiny7 - - Add AL, '@' - Jmp ViewTiny8 - -ViewTiny7: - Mov AL, '.' - -ViewTiny8: - Mov AH, CH - Sub AH, 4 - StosW - Add AH, 8 - Mov AL, CL - StosW - - Jmp ViewTinyEnd - -ViewTiny11: ; Nothing to show except dots... - Mov AH, CH - Mov AL, 173 - StosW - StosW - -ViewTinyEnd: - - Pop DI - Pop SI - Pop CX - - Add DI, 160 - Inc CX - Add SI, 320 - - Dec CH - JNZ ViewTiny1 - - Cmp BP, CS:Channel - JE ViewTiny14 - - Mov DX, BP - Mov BP, Offset CursorPositions+36 - Jmp PE_HilightView - -ViewTiny14: - Push DI - - Sub SI, (32*320) - Sub DI, (32*160) - Mov AL, 160 - Mov CX, CS:Row - Sub CX, CS:TopRow - Mul CL - Add DI, AX - Add AX, AX - Add SI, AX - - Mov CX, CS:Row - Call PE_SelectColour ; CH = colour. - - Mov DX, CS:PatternCursor - LodsB - Cmp DL, 1 - JA ViewTiny17 - - Cmp AL, NONOTE - JE ViewTinyDots - - Jmp ViewTinyEndHilight - -ViewTiny17: - LodsB ; Instrument - Cmp DL, 3 - JA ViewTiny20 - - And AL, AL - JZ ViewTinyDots - - Mov DH, 10 - Xor AH, AH - Div DH - Add AX, 3030h - Mov DH, AH - Mov AH, CH - StosW - Mov AL, DH - StosW - Jmp ViewTinyEndHilight - -ViewTiny20: - LodsB ; Volume - Cmp DL, 5 - JA ViewTiny23 - - Cmp AL, 0FFh - JE ViewTiny21 - - Mov AH, AL - And AH, 7Fh - Sub AH, 65 - JC ViewTinyNoVEffect2 - - Test AL, 80h - JZ ViewTinyVEffect2 - - Add AH, 60 - -ViewTinyVEffect2: - Mov AL, AH - Xor AH, AH - Mov DH, 10 - Div DH - ; AL = effect, AH = num - Add AX, 'A'+'0'*256 - Mov CL, AH - Mov AH, CH - StosW - Mov AL, CL - StosW - - Jmp ViewTinyEndHilight - -ViewTinyNoVEffect2: - Sub CH, 4 - Test AL, 80h - JZ ViewTiny28 - - Dec CH - And AL, 7Fh - -ViewTiny28: - Mov DH, 10 - Xor AH, AH - Div DH - Add AX, 3030h - XChg CH, AH - StosW - Mov AL, CH - StosW - Jmp ViewTinyEndHilight - -ViewTiny21: - Sub CH, 4 - -ViewTinyDots: - Mov AH, CH - Mov AL, 173 - StosW - StosW - Jmp ViewTinyEndHilight - -ViewTiny23: - LodsB ; CommandValue. - And AL, AL - JNZ ViewTiny24 - - Mov AL, '.' - Jmp ViewTiny25 - -ViewTiny24: - Add AL, '@' - -ViewTiny25: - Mov AH, CH - Sub AH, 4 - StosW - - Add AH, 8 - LodsB - StosW - -ViewTinyEndHilight: - Pop DI - - Mov DX, BP - Mov BP, Offset CursorPositions+36 - Jmp PE_HilightView - -EndP ViewTiny - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ToggleDivision Far - - Xor ViewDivision, 1 - - Call PE_CheckWidth - JC PEFunction_ToggleDivision1 - - Mov AX, 1 - Ret - -PEFunction_ToggleDivision1: - Xor ViewDivision, 1 - - Mov AX, 1 - Ret - -EndP PEFunction_ToggleDivision - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl0 Far - - Mov AX, 0 - Jmp PE_FastView - -EndP PEFunction_Ctrl0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl1 Far - - Mov AX, 1 - Jmp PE_FastView - -EndP PEFunction_Ctrl1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl2 Far - - Mov AX, 2 - Jmp PE_FastView - -EndP PEFunction_Ctrl2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl3 Far - - Mov AX, 3 - Jmp PE_FastView - -EndP PEFunction_Ctrl3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl4 Far - - Mov AX, 4 - Jmp PE_FastView - -EndP PEFunction_Ctrl4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl5 Far - - Mov AX, 5 - Jmp PE_FastView - -EndP PEFunction_Ctrl5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_QuickViewSetup Far ; CX = num with div - ; BX = num without div - ; AH = type. - Cmp ViewDivision, 0 - JNE PEFunction_QuickViewSetup1 - - Mov CX, BX - Mov BX, 100 - Sub BX, CX - -PEFunction_QuickViewSetup1: - Push CS - Pop ES - Mov DI, Offset ViewChannels - -PEFunction_QuickViewSetup3: - StosW - - Inc AL - Loop PEFunction_QuickViewSetup3 - - Mov CX, BX - Mov AX, 0FFFFh - Rep StosW - - Call PE_CheckWidth - - Cmp ViewChannelTracking, 0 - JNE PEFunction_QuickViewSetup2 - - Call PEFunction_ToggleTracking - -PEFunction_QuickViewSetup2: - - Mov AX, 1 - Ret - -EndP PEFunction_QuickViewSetup - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl_Shift1 Far - - Mov AX, 100h - Mov BX, 7 - Mov CX, 6 - Jmp PEFunction_QuickViewSetup - -EndP PEFunction_Ctrl_Shift1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl_Shift2 Far - - Mov AX, 200h - Mov BX, 10 - Mov CX, 9 - Jmp PEFunction_QuickViewSetup - -EndP PEFunction_Ctrl_Shift2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl_Shift3 Far - - Mov AX, 300h - Mov BX, 24 - Mov CX, 18 - Jmp PEFunction_QuickViewSetup - -EndP PEFunction_Ctrl_Shift3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl_Shift4 Far - - Mov AX, 400h - Mov BX, 36 - Mov CX, 24 - Jmp PEFunction_QuickViewSetup - -EndP PEFunction_Ctrl_Shift4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_FastView Far - - Dec AX ; AL = viewmethod - Mov CL, AL - Mov BX, Channel - Mov SI, Offset ViewChannels - - Cmp CL, 0FFh - JE PE_FastView4 - -PE_FastView1: - LodsW - Cmp AL, 0FFh - JE PE_FastView2 - - Cmp AL, BL - JE PE_FastView2 - Jmp PE_FastView1 - -PE_FastView2: - Sub SI, 2 - Push AX - Push SI - - Mov AL, BL - Mov AH, CL - Mov [SI], AX - - Call PE_CheckWidth - JC PE_FastView3 - - Add SP, 4 - Mov AX, 1 - Ret - -PE_FastView3: - Pop SI - Pop AX - Mov [SI], AX - - Mov AX, 1 - Ret - -PE_FastView4: - LodsW - Cmp AL, 0FFh - JE PE_FastView6 - - Cmp AL, BL - JNE PE_FastView4 - -PE_FastView5: - LodsW - Mov [SI-4], AX - Cmp AX, 0FFFFh - JNE PE_FastView5 - - Call PE_CheckWidth - -PE_FastView6: - Mov AX, 1 - Ret - -EndP PE_FastView - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ViewLeft Far - ; First find current channel. - Mov DX, Channel - Mov SI, Offset ViewChannels - -PEFunction_ViewLeft1: - LodsW - Cmp AL, 0FFh - JE PEFunction_ViewLeft2 - - Cmp AL, DL - JNE PEFunction_ViewLeft1 - - Cmp SI, Offset ViewChannels+2 - JE PEFunction_ViewLeft2 - - Mov DL, [SI-4] - Mov Channel, DX - -PEFunction_ViewLeft2: ; Else decrease channel - Mov AX, 1 - Ret - -EndP PEFunction_ViewLeft - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ViewRight Far - - Mov DX, Channel - Mov SI, Offset ViewChannels - -PEFunction_ViewRight1: - LodsW - Cmp AL, 0FFh - JE PEFunction_ViewRight2 - - Cmp AL, DL - JNE PEFunction_ViewRight1 - - LodsW - Cmp AL, 0FFh - JE PEFunction_ViewRight2 - - Xor AH, AH - Mov Channel, AX - -PEFunction_ViewRight2: - Mov AX, 1 - Ret - -EndP PEFunction_ViewRight - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_AltRight Far - - Mov AX, Channel - Inc AX - Cmp AX, 64 - JAE PEFunction_AltRight1 - - Mov Channel, AX - -PEFunction_AltRight1: - Mov AX, 1 - Ret - -EndP PEFunction_AltRight - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_AltLeft Far - - Mov AX, Channel - And AX, AX - JZ PEFunction_AltLeft1 - - Dec AX - Mov Channel, AX - -PEFunction_AltLeft1: - Mov AX, 1 - Ret - -EndP PEFunction_AltLeft - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl_Home Far - - Mov AX, Row - Sub AL, 1 - AdC AL, 0 - Mov Row, AX - - Mov AX, 1 - Ret - -EndP PEFunction_Ctrl_Home - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Ctrl_End Far - - Mov AX, Row - Cmp AX, MaxRow - AdC AX, 0 - Mov Row, AX - - Mov AX, 1 - Ret - -EndP PEFunction_Ctrl_End - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_AltUp Far - - Mov AX, TopRow - Mov BX, Row - Test AX, AX - JZ PEFunction_AltUp1 - - Dec AX - Mov TopRow, AX - Sub BX, AX - Cmp BX, 32 - JB PEFunction_AltUp1 - - Dec Row - -PEFunction_AltUp1: - Mov AX, 1 - Ret - -EndP PEFunction_AltUp - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_AltDown Far - - Mov AX, TopRow - Mov BX, MaxRow - - Inc AX - Sub BX, AX - Cmp BX, 31 - JB PEFunction_AltDown1 - - Mov TopRow, AX - Cmp AX, Row - JBE PEFunction_AltDown1 - - Mov Row, AX - -PEFunction_AltDown1: - Mov AX, 1 - Ret - -EndP PEFunction_AltDown - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_GetLastInstrument Far - - MovZX BX, [CS:LastInstrument] - Dec BX - Ret - -EndP PE_GetLastInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_SwapInstruments Far ; DH/DL = instruments - ; to swap. - Call Music_GetSongSegment - Mov DS, AX - Push CS - Pop DS - Assume DS:Pattern - - Mov TempVariableArea2, DX - Mov AX, PatternNumber - Mov TempVariableArea, AX - Call PEFunction_StorePattern - - Call PE_GetMaxPattern - Inc AX - Mov TempVariableArea4, AX ; 1=OldPattern - ; 2=Instrument swap - ; 3=Current pattern - ; 4=Max pattern - - ; OK... - Mov AL, 1 - Call S_SetDirectMode - - ; Draw Box first... - Call S_DrawSmallBox - - Mov TempVariableArea3, 0 - Assume DS:Nothing - -PE_SwapInstruments1: ; Draw % Complete on screen first - Mov AX, 100 - Mul TempVariableArea3 - Div TempVariableArea4 ; AX = percentage - - Push AX - - Push CS - Pop DS - Assume DS:Pattern - - Mov SI, Offset CompleteMsg - Mov DI, (34+26*80)*2 - Mov AH, 20h - Call S_DrawString - Add SP, 2 ; OK message is on screen. - - - Mov AX, TempVariableArea3 - Mov PatternNumber, AX - Assume DS:Nothing - - Call Music_GetPattern - Call DecodePattern ; Next pattern should be in mem - - Mov AX, MaxRow - Inc AX - Mov CX, 64 - Mul CX - ; AX = number of "blocks" - Mov CX, AX - Mov DX, TempVariableArea2 - - Mov DS, PatternDataArea - Mov SI, 1 - -PE_SwapInstruments3: - Mov AL, [SI] - Cmp AL, DL - JNE PE_SwapInstruments4 - - Mov AL, DH - And AL, 7Fh - Mov [SI], AL - Jmp PE_SwapInstruments5 - -PE_SwapInstruments4: - Test DH, 80h - JNZ PE_SwapInstruments5 - - Cmp AL, DH - JNE PE_SwapInstruments5 - - Mov [SI], DL - -PE_SwapInstruments5: - Add SI, 5 - Loop PE_SwapInstruments3 - - Push CS - Pop DS - - Mov AX, TempVariableArea3 - Call PEFunction_StorePattern - ; OK.. onto next pattern - - Mov AX, TempVariableArea3 - Inc AX - Cmp AX, TempVariableArea4 - JAE PE_SwapInstruments2 - - Mov TempVariableArea3, AX - Jmp PE_SwapInstruments1 - -PE_SwapInstruments2: - Mov AL, 0 - Call S_SetDirectMode - - Push CS - Pop DS - Assume DS:Pattern - - Mov AX, TempVariableArea - Mov PatternNumber, AX - Call Music_GetPattern - Call DecodePattern - - Ret - -EndP PE_SwapInstruments - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_InsertInstrument Far ; DL = instrument - - Push CS - Pop DS - Assume DS:Pattern - - Mov TempVariableArea2, DX - Mov AX, PatternNumber - Mov TempVariableArea, AX - Call PEFunction_StorePattern - - Call PE_GetMaxPattern - Inc AX - Mov TempVariableArea4, AX ; 1=OldPattern - ; 2=Instrument swap - ; 3=Current pattern - ; 4=Max pattern - - ; OK... - Mov AL, 1 - Call S_SetDirectMode - - ; Draw Box first... - Call S_DrawSmallBox - - Mov TempVariableArea3, 0 - Assume DS:Nothing - -PE_InsertInstrument1: ; Draw % Complete on screen first - Mov AX, 100 - Mul TempVariableArea3 - Div TempVariableArea4 ; AX = percentage - - Push AX - - Push CS - Pop DS - Assume DS:Pattern - - Mov SI, Offset CompleteMsg - Mov DI, (34+26*80)*2 - Mov AH, 20h - Call S_DrawString - Add SP, 2 ; OK message is on screen. - - - Mov AX, TempVariableArea3 - Mov PatternNumber, AX - Assume DS:Nothing - - Call Music_GetPattern - Call DecodePattern ; Next pattern should be in mem - - Mov AX, MaxRow - Inc AX - Mov CX, 64 - Mul CX - ; AX = number of "blocks" - Mov CX, AX - Mov DX, TempVariableArea2 - - Mov DS, PatternDataArea - Mov SI, 1 - -PE_InsertInstrument3: - Cmp [SI], DL - JB PE_InsertInstrument4 - - Cmp Byte Ptr [SI], 99 - JAE PE_InsertInstrument4 - - Inc Byte Ptr [SI] - -PE_InsertInstrument4: - Add SI, 5 - Loop PE_InsertInstrument3 - - Push CS - Pop DS - - Mov AX, TempVariableArea3 - Call PEFunction_StorePattern - ; OK.. onto next pattern - - Mov AX, TempVariableArea3 - Inc AX - Cmp AX, TempVariableArea4 - JAE PE_InsertInstrument2 - - Mov TempVariableArea3, AX - Jmp PE_InsertInstrument1 - -PE_InsertInstrument2: - Mov AL, 0 - Call S_SetDirectMode - - Push CS - Pop DS - Assume DS:Pattern - - Mov AX, TempVariableArea - Mov PatternNumber, AX - Call Music_GetPattern - Call DecodePattern - - Ret - -EndP PE_InsertInstrument - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_DeleteInstrument Far ; DL = instrument - - Push CS - Pop DS - Assume DS:Pattern - - Mov TempVariableArea2, DX - Mov AX, PatternNumber - Mov TempVariableArea, AX - Call PEFunction_StorePattern - - Call PE_GetMaxPattern - Inc AX - Mov TempVariableArea4, AX ; 1=OldPattern - ; 2=Instrument swap - ; 3=Current pattern - ; 4=Max pattern - - ; OK... - Mov AL, 1 - Call S_SetDirectMode - - ; Draw Box first... - Call S_DrawSmallBox - - Mov TempVariableArea3, 0 - Assume DS:Nothing - -PE_DeleteInstrument1: ; Draw % Complete on screen first - Mov AX, 100 - Mul TempVariableArea3 - Div TempVariableArea4 ; AX = percentage - - Push AX - - Push CS - Pop DS - Assume DS:Pattern - - Mov SI, Offset CompleteMsg - Mov DI, (34+26*80)*2 - Mov AH, 20h - Call S_DrawString - Add SP, 2 ; OK message is on screen. - - - Mov AX, TempVariableArea3 - Mov PatternNumber, AX - Assume DS:Nothing - - Call Music_GetPattern - Call DecodePattern ; Next pattern should be in mem - - Mov AX, MaxRow - Inc AX - Mov CX, 64 - Mul CX - ; AX = number of "blocks" - Mov CX, AX - Mov DX, TempVariableArea2 - - Mov DS, PatternDataArea - Mov SI, 1 - -PE_DeleteInstrument3: - Cmp [SI], DL - JB PE_DeleteInstrument4 - - Dec Byte Ptr [SI] - -PE_DeleteInstrument4: - Add SI, 5 - Loop PE_DeleteInstrument3 - - Push CS - Pop DS - - Mov AX, TempVariableArea3 - Call PEFunction_StorePattern - ; OK.. onto next pattern - - Mov AX, TempVariableArea3 - Inc AX - Cmp AX, TempVariableArea4 - JAE PE_DeleteInstrument2 - - Mov TempVariableArea3, AX - Jmp PE_DeleteInstrument1 - -PE_DeleteInstrument2: - Mov AL, 0 - Call S_SetDirectMode - - Push CS - Pop DS - Assume DS:Pattern - - Mov AX, TempVariableArea - Mov PatternNumber, AX - Call Music_GetPattern - Call DecodePattern - - Ret - -EndP PE_DeleteInstrument - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_UpdateInstruments Far ; ES:DI = instrument table - ; DL = instrument number - Push CS - Pop DS - Assume DS:Pattern - - Mov Byte Ptr TempVariableArea2, DL - Mov AX, PatternNumber - Mov TempVariableArea, AX - Mov TempVariableArea5, ES - Mov TempVariableArea6, DI - Call PEFunction_StorePattern - - Call PE_GetMaxPattern - Inc AX - Mov TempVariableArea4, AX ; 1=OldPattern - ; 2=Instrument - ; 3=Current pattern - ; 4=Max pattern - ; 5=ES - ; 6=DI - - Mov AL, 1 - Call S_SetDirectMode - - ; Draw Box first... - Call S_DrawSmallBox - - Mov TempVariableArea3, 0 - Assume DS:Nothing - -PE_UpdateInstruments1: ; Draw % Complete on screen first - Mov AX, 100 - Mul TempVariableArea3 - Div TempVariableArea4 ; AX = percentage - - Push AX - - Push CS - Pop DS - Assume DS:Pattern - - Mov SI, Offset CompleteMsg - Mov DI, (34+26*80)*2 - Mov AH, 20h - Call S_DrawString - Pop AX ; Remove AX from stack - - Mov AX, TempVariableArea3 - Mov PatternNumber, AX - Assume DS:Nothing - - Call Music_GetPattern - Call DecodePattern ; Next pattern should be in mem - - Mov AX, MaxRow - Inc AX - Mov CX, 64 - Mul CX - ; AX = number of "blocks" - Mov CX, AX - Mov BL, CS:Byte Ptr TempVariableArea2 - Mov ES, CS:TempVariableArea5 - - Mov DS, PatternDataArea - Xor SI, SI - -PE_UpdateInstruments3: - LodsW - Cmp AL, NONOTE - JAE PE_UpdateInstrument4 - - And AH, AH ; AH = instrument - JZ PE_UpdateInstrument4 - - Xor DX, DX - Mov DI, CS:TempVariableArea6 - -PE_UpdateInstrument5: - Cmp AX, [ES:DI] - JE PE_UpdateInstrument7 - -; Add DI, 2 - ScasW - Inc DX ; Not it... - Cmp DX, 120 - JB PE_UpdateInstrument5 - - Jmp PE_UpdateInstrument4 - -PE_UpdateInstrument7: - Mov DH, BL - Mov [DS:SI-2], DX - - -PE_UpdateInstrument4: - Add SI, 3 - Loop PE_UpdateInstruments3 - - Push CS - Pop DS - - Mov AX, TempVariableArea3 - Call PEFunction_StorePattern - ; OK.. onto next pattern - - Mov AX, TempVariableArea3 - Inc AX - Cmp AX, TempVariableArea4 - JAE PE_UpdateInstruments2 - - Mov TempVariableArea3, AX - Jmp PE_UpdateInstruments1 - -PE_UpdateInstruments2: - Mov AL, 0 - Call S_SetDirectMode - - Push CS - Pop DS - Assume DS:Pattern - - Mov AX, TempVariableArea - Mov PatternNumber, AX - Call Music_GetPattern - Call DecodePattern - - Ret - -EndP PE_UpdateInstruments - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Alt_F9 Far - Assume DS:Pattern - - Mov AX, Channel - Call Music_ToggleChannel - - Mov AX, 1 - Ret - -EndP PEFunction_Alt_F9 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_MuteNext Far - Assume DS:Pattern - - Call PEFunction_Alt_F9 - Jmp PEFunction_Tab - -EndP PEFunction_MuteNext - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_MutePrevious Far - Assume DS:Pattern - - Sub Channel, 1 - AdC Channel, 0 - Jmp PEFunction_Alt_F9 - -EndP PEFunction_MutePrevious - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Alt_F10 Far - Assume DS:Pattern - - Mov AX, Channel - Call Music_SoloChannel - - Mov AX, 1 - Ret - -EndP PEFunction_Alt_F10 - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_SoloGotoNext Far - - Call PEFunction_Alt_F10 - Jmp PEFunction_Tab - -EndP PEFunction_SoloGotoNext - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_UnmuteAll Far - - Call Music_UnmuteAll - - Mov AX, 1 - Ret - -EndP PEFunction_UnmuteAll - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_ShowOrder Far ; DX = order. - - Call S_GetDestination - Mov CX, 32 - - Mov DI, (2+15*80)*2+1 - Mov BX, TopOrder - -PE_ShowOrder1: - Mov AL, 23h - Cmp BX, DX - JE PE_ShowOrder2 - - Mov AL, 20h - -PE_ShowOrder2: - StosB - Inc DI - StosB - Inc DI - StosB - - Add DI, 155 - Inc BX - Loop PE_ShowOrder1 - - Ret - -EndP PE_ShowOrder - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_PlayCurrentPosition Far - Assume DS:Pattern - - Call I_ClearTables - - Mov AX, PatternNumber - Mov BX, MaxRow - Inc BX - Mov CX, Row - - Call Music_PlayPattern - - Mov AX, 1 - Ret - -EndP PE_PlayCurrentPosition - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_SetPlayMark Far - Assume DS:Pattern - - Cmp PlayMarkOn, 1 ; If on.. - JNE PEFunction_SetPlayMarkNew - - Mov AX, PatternNumber - Cmp AX, PlayMarkPattern - JNE PEFunction_SetPlayMarkNew - - Mov AX, Row - Cmp AX, PlayMarkRow - JNe PEFunction_SetPlayMarkNew - - Mov PlayMarkOn, 0 - Jmp PEFunction_SetPlayMarkEnd - -PEFunction_SetPlayMarkNew: - Mov PlayMarkOn, 1 - Mov AX, PatternNumber - Mov PlayMarkPattern, AX - Mov AX, Row - Mov PlayMarkRow, AX - -PEFunction_SetPlayMarkEnd: - Mov AX, 1 - Ret - -EndP PEFunction_SetPlayMark - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_F7 Far ; If no mark is set, use - ; current pattern & row - Call I_ClearTables - - Push CS - Pop DS - Assume DS:Pattern - - Mov CX, PatternNumber - Mov BX, Row - - Cmp PlayMarkOn, 1 - JNE PE_F7_1 - - Mov CX, PlayMarkPattern - Mov BX, PlayMarkRow - -PE_F7_1: - Mov SI, Order - - Call Music_GetSongSegment - Mov ES, AX - - Cmp CL, [ES:SI+100h] - JNE PE_F7_3 - - Mov AX, SI - Jmp PE_F7_4 - -PE_F7_3: - Mov AL, CL ; AL = pattern. - Mov DI, 100h - Mov CX, 256 - - RepNE ScasB - JNE PE_F7_2 - - Mov AX, DI - Sub AX, 101h ; AX = order. - -PE_F7_4: - Call Music_PlayPartSong - - Mov AX, 1 - Ret - -PE_F7_2: - Mov CX, BX - - Mov AX, PatternNumber - Mov BX, MaxRow - Inc BX - Call Music_PlayPattern - - Mov AX, 1 - Ret - -EndP PE_F7 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ToggleTracking Far - Assume DS:Pattern - - Mov SI, Offset NoViewChannelTrackingMsg - Xor ViewChannelTracking, 1 - JZ PEFunction_ToggleTracking1 - - Mov SI, Offset ViewChannelTrackingMsg - -PEFunction_ToggleTracking1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP PEFunction_ToggleTracking - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ToggleRowHilight Far - Assume DS:Pattern - - Mov SI, Offset NoRowHilightMsg - Xor CentraliseCursor, 2 - Test CentraliseCursor, 2 - JZ PEFunction_ToggleRowHilight1 - - Mov SI, Offset RowHilightMsg - -PEFunction_ToggleRowHilight1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP PEFunction_ToggleRowHilight - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ToggleCentralise Far - Assume DS:Pattern - - Mov SI, Offset NoCentraliseCursorMsg - Xor CentraliseCursor, 1 - Test CentraliseCursor, 1 - JZ PEFunction_ToggleCentralise1 - - Mov SI, Offset CentraliseCursorMsg - -PEFunction_ToggleCentralise1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP PEFunction_ToggleCentralise - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_ToggleTrace Far - Assume DS:Pattern - - Mov SI, Offset NoTraceMsg - Xor TracePlayback, 1 - JZ PEFunction_ToggleTrace1 - - Mov SI, Offset TraceMsg - -PEFunction_ToggleTrace1: - Call SetInfoLine - - Mov AL, TracePlayback - Call K_SetScrollLock - - Mov AX, 1 - Ret - -EndP PEFunction_ToggleTrace - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_GetPatternConfigOffset Far - - Push CS - Pop DS - - Mov DX, Offset KeySignature - - Ret - -EndP PE_GetPatternConfigOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseUndoMemory - - Test AX, AX - JZ ReleaseUndoMemoryEnd - - Push AX - And AH, 0F0h - Cmp AH, 0A0h - Pop AX - JE ReleaseUndoMemoryEMS - -ReleaseUndoMemoryConventional: - Push ES - - Mov ES, AX - Mov AH, 49h - Int 21h - - Pop ES - Ret - -ReleaseUndoMemoryEMS: - And AX, 0FFFh - Call E_ReleaseEMS - -ReleaseUndoMemoryEnd: - Ret - -EndP ReleaseUndoMemory - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_AddToUndoBuffer Far ; 1) Release oldest data. - ; 2) Shift all stuff down. - ; 3) Store newest data. - - ; Parameter: DI = buffer TYPE. - - PushA - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Pattern - - Mov AX, DI - Cmp AL, 22 - JE PE_NotModified - - Mov Word Ptr [Modified], 101h - -PE_NotModified: - ; Error maintenance... sorta - Push CS - Push Offset PE_AddToUndoBufferEnd - Push AX ; Just for stack alignment - - Call GetPatternLength ; Get's pattern length in DX - - Add SP, 6 - ; For GetPatternLength's error stuff.. - - Add DX, 8 - JNC PE_AddToUndoBuffer3 - - Mov DI, Offset O1_PatternTooLongList - Mov CX, 2 - Call M_Object1List - Jmp PE_AddToUndoBufferEnd - -PE_AddToUndoBuffer3: -; ClC ; Carry already not set to get here - for - ; Non essential EMS allocation - MovZX EAX, DX - Call E_AllocateEMS - Test AX, AX - JZ PE_AddToUndoBuffer1 ; No EMS allocated? - - Call E_MapAvailableEMSMemory - - Or AH, 0A0h ; EMS tag - Push AX - Call E_GetEMSPageFrame - Push AX - Jmp PE_AddToUndoBuffer4 - -PE_AddToUndoBuffer1: - Mov BX, DX ; BX = length of pattern. - Add BX, 15 - RCR BX, 1 - ShR BX, 3 - - Mov AH, 48h - Int 21h - JC PE_AddToUndoBufferEnd - - Push AX ; Handle - Push AX ; Memory region - -PE_AddToUndoBuffer4: - Mov SI, Offset UndoBuffer+36 - Mov AX, [SI] - Call ReleaseUndoMemory - - Mov CX, 9 - -PE_AddToUndoBuffer2: - Mov EAX, [SI-4] - Mov [SI], EAX - - Sub SI, 4 - Loop PE_AddToUndoBuffer2 - - Pop ES - Pop AX - - Mov [SI], AX - Mov [SI+2], DI - - Sub DX, 8 - Xor DI, DI ; ES:DI points to data, DX = length - - Call EncodePattern - -PE_AddToUndoBufferEnd: - Pop ES - Pop DS - PopA - - Ret - -EndP PE_AddToUndoBuffer - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_ClearUndoBuffer Far - - Push EAX - Push CX - Push DS - Push SI - - Push CS - Pop DS - Assume DS:Pattern - - Mov CX, 10 - Mov SI, Offset UndoBuffer - -PE_ClearUndoBuffer1: - Mov AX, [SI] - Call ReleaseUndoMemory - - Xor EAX, EAX - Mov [SI], EAX - - Add SI, 4 - - Loop PE_ClearUndoBuffer1 - - Pop SI - Pop DS - Pop CX - Pop EAX - - Ret - -EndP PE_ClearUndoBuffer - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_Undo Far - - Mov SelectUndo, 0 - - Mov DI, Offset O1_UndoList - Mov CX, 3 - Call M_Object1List - - Mov AX, 1 - Ret - -EndP PEFunction_Undo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_DrawUndo Far - - Assume DS:Pattern - Push CS - Pop DS - - Call S_GetDestination - Mov CX, 10 - Mov DI, (21+24*80)*2 - Mov BX, Offset UndoBuffer+2 - -PEFunction_DrawUndo1: - Push DI - - Mov SI, [BX] - Mov AX, SI - And SI, 0FFh - Add SI, SI - - MovZX AX, AH - - Push AX - Mov SI, [UndoBufferTypes+SI] - Mov AH, 2 - Call S_DrawString - Pop AX - - Add BX, 4 - Pop DI - Add DI, 160 - Loop PEFunction_DrawUndo1 - - Ret - -EndP PEFunction_DrawUndo - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_PreUndo Far - - Push CS - Pop DS - Assume DS:Pattern - - Call S_GetDestination - Mov AX, 160 - Mul SelectUndo - Add AX, (20+24*80)*2+1 - Mov DI, AX - - Mov CX, 40 - Mov AL, 30h - -PEFunction_PreUndo1: - StosB - Inc DI - Loop PEFunction_PreUndo1 - - Ret - -EndP PEFunction_PreUndo - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEFunction_PostUndo Far - - Push CS - Pop DS - Assume DS:Pattern - - Mov BX, SelectUndo - - Cmp CX, 1C8h - JE PEFunction_PostUndoUp - - Cmp CX, 1D0h - JE PEFunction_PostUndoDown - - Cmp CX, 11Ch ; Enter - JE PEFunction_PostUndoEnter - - Xor AX, AX - Ret - -PEFunction_PostUndoUp: - Sub BL, 1 - AdC BL, 0 - Jmp PEFunction_PostUndoShift - -PEFunction_PostUndoDown: - Cmp BX, 8 - JA PEFunction_PostUndoShift - - Inc BX - -PEFunction_PostUndoShift: - Mov SelectUndo, BX - - Mov AX, 1 - Ret - -PEFunction_PostUndoEnter: - ShL BX, 2 - Add BX, Offset UndoBuffer - - Mov CX, [BX+2] - JCXZ PEFunction_PostUndoEnd - - Push Word Ptr [BX] - - Mov DI, 21 - Call PE_AddToUndoBuffer - - Pop AX - Mov CH, AH - And CH, 0F0h - Cmp CH, 0A0h - JNE PEFunction_PostUndoEnterEnd - -PEFunction_PostUndoEMS: - And AX, 0FFFh - Call E_MapAvailableEMSMemory - Call E_GetEMSPageFrame - -PEFunction_PostUndoEnterEnd: - Mov DS, AX - Assume DS:Nothing - Xor SI, SI - Call DecodePattern - - Xor BX, BX - Mov CL, 64 - Mov CH, Byte Ptr [CS:MaxRow] - Inc CH - Call NetworkPatternBlock - -PEFunction_PostUndoEnd: - Mov AX, 4 - Ret - -EndP PEFunction_PostUndo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ToggleFastVolume Far - Assume DS:Pattern - - Mov SI, Offset NoFastVolumeMsg - Xor CentraliseCursor, 4 - Test CentraliseCursor, 4 - JZ ToggleFastVolume3 - - Push DS - - Mov DI, Offset O1_GetFastAmpList - Mov CX, 3 - Call M_Object1List - - Pop DS - - Cmp DX, 1 - JNE ToggleFastVolume2 - - Mov SI, Offset FastVolumeMsg - Jmp ToggleFastVolume3 - -ToggleFastVolume2: - And CentraliseCursor, Not 4 - Mov SI, Offset FastVolumeNotEnabledMsg - -ToggleFastVolume3: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP ToggleFastVolume - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PECheckModified Far - - Cmp CS:Modified, 0 - JE PECheckModified1 - - Mov CX, 4 - Mov DI, Offset O1_ConfirmNoSave - Call M_Object1List - - And DX, DX - JNZ PECheckModified1 - - Add SP, 4 - - Mov AX, 1 - -PECheckModified1: - Ret - -EndP PECheckModified - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PEResetModified Far - - Mov CS:Modified, 0 - - Ret - -EndP PEResetModified - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_SetPatternLength Far - Assume DS:Pattern - -; Mov AX, MaxRow -; Inc AX -; Mov PatternSetLength, AX - Mov AX, PatternNumber - Mov PatternLengthStart, AX - Mov PatternLengthEnd, AX - - Assume DS:Nothing - - Mov CX, 4 - Mov DI, Offset O1_SetPatternLength - Call M_Object1List - - Test DX, DX - JZ PE_SetPatternLength2 - - Push CS - Pop DS - Assume DS:Pattern - - Call PEFunction_StorePattern - - Mov AX, PatternNumber - Mov TempVariableArea, AX - - Mov AX, PatternLengthStart - Mov TempVariableArea2, AX - -PE_SetPatternLength3: - Mov AX, TempVariableArea2 - Cmp AX, PatternLengthEnd - JA PE_SetPatternLength4 - - Mov PatternNumber, AX - Assume DS:Nothing - - Call Music_GetPattern - Call DecodePattern ; Next pattern should be in mem - - Push CS - Pop DS - Assume DS:Pattern - - Mov AX, PatternSetLength - Mov PatternModified, 1 - Dec AX - Mov MaxRow, AX - Call PEFunction_StorePattern - - Inc TempVariableArea2 - Jmp PE_SetPatternLength3 - -PE_SetPatternLength4: ; Cleanup - Mov AX, TempVariableArea - Mov PatternNumber, AX - Call Music_GetPattern - Call DecodePattern - -PE_SetPatternLength2: - Mov AX, 1 - Ret - -EndP PE_SetPatternLength - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_LeftBrace Far - - Jmp Glbl_LeftBrace - -EndP PE_LeftBrace - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_RightBrace Far - - Jmp Glbl_RightBrace - -EndP PE_RightBrace - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_LeftSquareBracket Far - - Jmp Glbl_LeftSquareBracket - -EndP PE_LeftSquareBracket - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_RightSquareBracket Far - - Jmp Glbl_RightSquareBracket - -EndP PE_RightSquareBracket - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDI_SetInstrument Far - - Test Byte Ptr CS:CentraliseCursor, 16 - JZ MIDI_SetInstrument2 - - Inc DX - -MIDI_SetInstrument2: - Cmp DX, 99 - JA MIDI_SetInstrument1 - - Mov CS:LastInstrument, DL - - Test DL, DL - JZ MIDI_SetInstrument1 - - Call UpdateWAVEForm - -MIDI_SetInstrument1: - Mov AX, 1 - Ret - -EndP MIDI_SetInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_MIDIAfterTouch Far - Assume DS:Pattern - - Cmp MIDIInputEnabled, 0 - JNE PE_MIDIAfterTouch2 - - Xor AX, AX - Ret - -PE_MIDIAfterTouch2: - Test CentraliseCursor, 128 - - MovZX BX, DL - Call MIDI_GetChannel - ; Returns AX - Sub AL, 1 - JC PE_MIDIAfterTouch1 -; Cmp AL, 0FFh -; JE PE_MIDIAfterTouch1 - - Call PE_TranslateMIDI - ; DL = note, DH = volume - - Mov AH, 5 - Mul AL - Mov SI, AX - Mov BL, DH - Mov AX, 320 - Mul Row - Mov Word Ptr [Modified], 101h - Add SI, AX - Mov DS, PatternDataArea - Assume DS:Nothing - Cmp SI, 64000 - JAE PE_MIDIAfterTouch1 - - Mov [SI+2], BL - -PE_MIDIAfterTouch1: - Mov AX, 1 - Ret - -EndP PE_MIDIAfterTouch - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_MIDINoteOff Far - Assume DS:Pattern - - Cmp MIDIInputEnabled, 0 - JNE PE_MIDINoteOff1 - - Xor AX, AX - Ret - -PE_MIDINoteOff1: - MovSX BX, DL - Call MIDI_FindChannel ; Returns AX - Cmp AL, 0FFh - JE PE_MIDINoteOff2 - - Test CentraliseCursor, 32 - JZ PE_MIDINoteOff2 ; Dont' record note-offs - - Cmp TracePlayback, 0 - JE PE_MIDINoteOff2 - - Push AX - Mov AX, Row - Call Music_GetDelay ; DX = delay value - ; CX = playmode - Pop AX - - Test CX, CX - JZ PE_MIDINoteOff2 - - Push DX - Push AX - - Mov AH, 5 - Mul AH - Mov SI, AX - Mov AX, 320 - Mul Row - Add SI, AX - Cmp SI, 64000 - JAE PE_MIDINoteOff3 - - Mov DS, PatternDataArea - Assume DS:Nothing - - Cmp Word Ptr [SI], NONOTE - JE PE_MIDINoteOff4 - ; check next spot. - Mov AX, Row - Cmp AX, MaxRow - JAE PE_MIDINoteOff3 ; Already at end of pattern - - Add SI, 320 ; Try very next spot. - Cmp SI, 64000 - JAE PE_MIDINoteOff3 - - Xor DX, DX ; Tick 0 - Cmp Word Ptr [SI], NONOTE - JNE PE_MIDINoteOff3 - -PE_MIDINoteOff4: - Mov BX, 0FFh - - Mov [SI+2], BX - Mov [SI+4], BH - Test [CS:Flags], 2 - JZ PE_MIDINoteOffCut - - Dec BX - -PE_MIDINoteOffCut: - Mov [SI], BX - - Mov Word Ptr [CS:Modified], 101h - - Pop AX - Mov DL, 32 - Call Music_PlayNote - Pop DX - - Test CS:CentraliseCursor, 8 - JZ PE_MIDINoteOff2 - - Mov [SI+3], DX - -PE_MIDINoteOff2: - Mov AX, 1 - Ret - -PE_MIDINoteOff3: - Pop AX - Pop AX - Mov AX, 1 - Ret - -EndP PE_MIDINoteOff - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_MIDINote Far - Assume DS:Pattern - - Cmp MIDIInputEnabled, 0 - JNE PE_MIDINote6 - - Xor AX, AX - Ret - -PE_MIDINote6: - Push DX - Call Music_GetLastChannel - Mov DI, AX - Pop DX - - Call PE_TranslateMIDI - JC PE_MIDINote1 ; Note out of range? - JZ PE_MIDINoteOff1 ; Note off? - - Mov BL, DH - Test CentraliseCursor, 64 - JNZ PE_MIDINote3 - - Mov BL, LastVolume - Test EditMask, 2 - JNZ PE_MIDINote3 - - Mov BL, 0FFh - -PE_MIDINote3: - ; If TracePlayback = 1 *AND* Playmode > 1, then - ; Basechannel = MIDIChannel, else - ; Basechannel = Channel - Push DX - - Mov AX, Row - Call Music_GetDelay ; CX = playmode - ; DX = delay value - PushA - - Cmp MIDIPlayTrigger, 1 - JB PE_MIDINoteTriggerEnd - JA MIDIPlayTriggerSong - -MIDIPlayTriggerPattern: - Mov Row, 0 - - Call Glbl_F6 - Jmp PE_MIDINoteTriggerCleanup - -MIDIPlayTriggerSong: - - Call PE_F7 - -PE_MIDINoteTriggerCleanup: - Push CS - Pop DS - - Mov AX, Channel - Mov MIDIChannel, AX - - Mov TracePlayback, 1 - Mov MIDIPlayTrigger, 0 - -PE_MIDINoteTriggerEnd: - PopA - - Mov AX, Channel - Test CX, CX - JZ PE_MIDINote2 - - Cmp TracePlayback, 0 - JE PE_MIDINote2 - - Mov AX, MIDIChannel - -PE_MIDINote2: - Pop CX ; CX = note/volume - Xor CH, CH - Test EditMask, 1 - JZ PE_MIDINote4 - - Mov CH, LastInstrument - -PE_MIDINote4: - - XChg CX, DX - ; CX = delay - ; DX = note/ins - - Push DX - Call PE_RestoreMIDINote - Call MIDI_AllocateChannel ; Returns AX = channel to use - Pop DX - - XChg CX, DX - - Push DX - Push AX - - Inc AX - Cmp AX, 63 - JA PE_MIDINote5 - - Mov MIDIChannel, AX -PE_MIDINote5: - Dec AX - - Mov AH, 5 - Mul AH - Mov SI, AX - Mov AX, 320 - Mul Row - Add SI, AX - - Pop AX - Cmp SI, 64000 - JAE PE_MIDINote1 - - Mov DS, PatternDataArea - Assume DS:Nothing - - Mov [SI], CX - Mov [SI+2], BL - Mov Word Ptr [SI+3], 0 - - Mov DH, 32 - Call Music_PlayNote - Pop DX - - Mov Word Ptr [CS:Modified], 101h - - Test CS:CentraliseCursor, 8 - JZ PE_MIDINote1 - - Mov [SI+3], DX - -PE_MIDINote1: - Mov AX, 1 - Ret - -EndP PE_MIDINote - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TranslateMIDI Far - ; Given DL = 0->127, return DL = 0->127 - ; Given DH = 0->127, return DH=0->64 - - ; Apply note swing. Return carry - ; if note out of range. - - ; Apply volume swing. Return zero - ; flag set if note off. - Push AX - - Test DH, DH - JZ PE_TranslateMIDIVolumeEnd - - MovSX BX, DL - MovSX AX, CS:MIDICentralNote - Add AX, BX - Sub AX, 60 - JS PE_TranslateMIDIError1 - -PE_TranslateMIDIPitch1: - Cmp AX, 119 - JBE PE_TranslateMIDIPitch2 - -PE_TranslateMIDIError1: - StC - Pop AX - Ret - -PE_TranslateMIDIPitch2: - Mov DL, AL - ; OK.. pitch done. - Mov AL, DH - Mul CS:MIDIAmplification - ; AX = (Volume*VolumeAmp) - ; = 0->127*200 - ; = 0->25400 - ; Req AX = 0->128 - ; ie. Div AX 198.4 - ; or Mul AX, 331 - ; >> 16 - - Mov BL, DL ; Note - Mov DX, 331 - Mul DX - Mov DH, DL - Mov DL, BL - Cmp DH, 64 - JB PS_TranslateMIDIVolume1 - - Mov DH, 64 - -PS_TranslateMIDIVolume1: - Test DL, DL ; Clear zero flag + carry. - -PE_TranslateMIDIVolumeEnd: - Pop AX - Ret - -EndP PE_TranslateMIDI - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_RestoreMIDINote Far - - Add DL, 60 - Sub DL, CS:MIDICentralNote - - Ret - -EndP PE_RestoreMIDINote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_CycleMIDIPlayTrigger Far - Assume DS:Pattern - - Mov AL, MIDIPlayTrigger - Inc AX - Cmp AL, 2 - JBE PE_CycleMIDIPlayTrigger1 - - Xor AL, AL - Mov SI, Offset TriggerMsg1 - Jmp PE_CycleMIDIPlayTriggerEnd - -PE_CycleMIDIPlayTrigger1: - Mov SI, Offset TriggerMsg2 - Cmp AL, 1 - JE PE_CycleMIDIPlayTriggerEnd - - Mov SI, Offset TriggerMsg3 - -PE_CycleMIDIPlayTriggerEnd: - Mov MIDIPlayTrigger, AL - - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP PE_CycleMIDIPlayTrigger - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc MIDIInputToggle Far ; Ctrl-Scroll Lock - Assume DS:Pattern - - Mov SI, Offset MIDIInputEnabledMsg - Xor MIDIInputEnabled, 1 - JNZ MIDIInputToggle1 - Mov SI, Offset MIDIInputDisabledMsg - -MIDIInputToggle1: - Call SetInfoLine - - Mov AX, 1 - Ret - -EndP MIDIInputToggle - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_SetPatternModified Far - - Mov Word Ptr [CS:Modified], 101h - Ret - -EndP PE_SetPatternModified - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_SaveCurrentPattern Far - - PushAD - Push DS - Push ES - - Call PEFunction_StoreCurrentPattern - - Mov AX, 0FFFFh - XChg AX, CS:PatternNumber - Mov Word Ptr CS:TempNumbers, AX - - Call Music_UpdatePatternOffset - - Pop ES - Pop DS - PopAD - Ret - -EndP PE_SaveCurrentPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_RestoreCurrentPattern Far - - PushAD - Push DS - Push ES - Mov AX, Word Ptr CS:TempNumbers - Mov CS:PatternNumber, AX - Call Music_GetPattern - Call DecodePattern - Pop ES - Pop DS - PopAD - Ret - -EndP PE_RestoreCurrentPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_NewPattern Far - - Mov AX, CS:PatternNumber - Call Music_GetPattern - Call DecodePattern - - Mov CS:PatternModified, 0 - Ret - -EndP PE_NewPattern - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment PatternData PARA Public 'Data' - DB 64000 Dup (?) -EndS - - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PatternEdit module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386 + +include switch.inc + +include network.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Segment Object1 BYTE Public 'Data' +EndS + +Segment Disk BYTE Public 'Code' +EndS + +Segment Inst BYTE Public 'Code' + Extrn InstrumentEdit:Byte + Extrn NodeHeld:Byte +EndS + + Extrn E_GetFreeEMS:Far + Extrn E_UnInitEMS:Far + Extrn E_ReleaseEMS:Far + Extrn E_AllocateEMS:Far + Extrn E_MapAvailableEMSMemory:Far + Extrn E_GetEMSPageFrame:Far + + Extrn Glbl_F2:Far, Glbl_F6:Far + Extrn Glbl_GetHeaderMode:Far + Extrn Glbl_LeftBrace:Far, Glbl_RightBrace:Far + Extrn Glbl_LeftSquareBracket:Far, Glbl_RightSquareBracket:Far + + Extrn I_ClearTables:Far + + Extrn K_UnInitKeyBoard:Far + Extrn K_SetScrollLock:Far + Extrn K_IsKeyDown:Far + + Extrn M_FunctionHandler:Far + Extrn M_Object1List:Far + Extrn M_FunctionDivider:Far + + Extrn Music_PlayPartSong:Far + Extrn Music_GetSongSegment:Far + Extrn Music_UnInitMusic:Far + Extrn Music_ReleasePattern:Far + Extrn Music_AllocatePattern:Far + Extrn Music_GetPattern:Far + Extrn Music_GetInstrumentMode:Far + Extrn Music_UpdatePatternOffset:Far + Extrn Music_PlayNote:Far + Extrn Music_InitMixTable:Far + Extrn Music_InitMuteTable:Far + Extrn Music_InitStereo:Far + Extrn Music_ToggleChannel:Far + Extrn Music_SoloChannel:Far + Extrn Music_GetPlayMode:Far + Extrn Music_PlayPattern:Far + Extrn Music_GetLastChannel:Far + Extrn Music_SetNextOrder:Far + Extrn Music_NextOrder:Far + Extrn Music_LastOrder:Far + Extrn Music_Stop:Far + + Extrn Music_UnmuteAll:Far + + Extrn Music_SoundCardLoadSample:Far + Extrn Music_SoundCardLoadAllSamples:Far + Extrn Music_GetDisplayVariables:Far + + Extrn Network_UpdatePattern:Far + + Extrn FileName:Byte + + Extrn O1_ConfirmNoSave:Far + Extrn O1_NoBlockMarkedList:Far + Extrn O1_SwapOutOfRangeList:Far + Extrn O1_OverlapBlockList:Far + Extrn O1_OutOfMemoryList:Far + Extrn O1_NoBlockDataList:Far + Extrn O1_GetAmpList:Far + Extrn O1_GetFastAmpList:Far + +IF SHOWPATTERNLENGTH + Extrn O1_ShowPatternLengthList:Far +ENDIF + + Extrn O1_TemplateErrorList:Far + Extrn O1_PatternTooLongList:Far + Extrn O1_SelectMultiChannel:Far + Extrn O1_UndoList:Far + Extrn O1_SetPatternLength:Far + Extrn O1_PatternSizeMismatchList:Far + + Extrn S_UnInitScreen:Far + Extrn S_DrawBox:Far + Extrn S_DrawString:Far + Extrn S_GetDestination:Far + Extrn S_SaveScreen:Far + Extrn S_RestoreScreen:Far + Extrn S_SetDirectMode:Far + Extrn S_DrawSmallBox:Far + Extrn S_InvertCursor:Far + + Extrn PatternLength + + Extrn UpdateInfoLine:Far + Extrn SetInfoLine:Far + Extrn MouseUpdateDisable:Far + Extrn UpdateWAVEForm:Far + + Extrn MIDI_AllocateChannel:Far, MIDI_FindChannel:Far + Extrn Music_GetDelay:Far, MIDI_GetChannel:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global PE_ClearUndoBuffer:Far + + Global PE_ShowOrder:Far + Global PE_NewPattern:Far + + Global PE_InitPatternEdit:Far + Global PE_UnInitPatternEdit:Far + Global PE_DrawOrderList:Far + Global PE_FillHeader:Far + Global PE_PreOrderList:Far + Global PE_PostOrderList:Far + Global PE_ConvAX2Num:Far + Global PE_GetCurrentPattern:Far + Global PE_GetMaxPattern:Far + Global PE_FillSpeedTempo:Far + + Global PE_SetPatternModified:Far + Global PE_GetLastInstrument:Far + Global PE_DrawPatternEdit:Far + Global PE_PrePatternEdit:Far + Global PE_PostPatternEdit:Far + Global PE_SetCommandCursor:Far + Global PEFunction_IncreaseOctave:Far + Global PEFunction_DecreaseOctave:Far + + Global PE_F7:Far + + Global PE_GetPatternConfigOffset:Far + + Global PE_SwapInstruments:Far + Global PE_GetMaxOrder:Far + Global PE_GotoPattern:Far + Global PECheckModified:Far + + Global PE_TranslateXMPattern:Far + Global PE_TranslateS3MPattern:Far + Global PE_TranslateMODPattern:Far + Global PE_TranslateMTMPattern:Far + Global PE_Translate669Pattern:Far + Global PE_ResetOrderPattern:Far + Global PEFunction_OutOfMemoryMessage:Far + Global PE_UpdateInstruments:Far + + Global PEFunction_DrawUndo:Far + Global PEFunction_PreUndo:Far + Global PEFunction_PostUndo:Far + Global PEResetModified:Far + + Global PE_SaveCurrentPattern:Far + Global PE_RestoreCurrentPattern:Far + Global PEFunction_StoreCurrentPattern:Far + + Global BaseOctave + Global SkipValue + Global RowHiLight1:Byte + Global RowHiLight2:Byte + Global MaxRow:Word + Global NumberOfRows:Word + Global Amplification + Global FastVolumeAmplification + Global CommandToValue:Byte + Global LastInstrument:Byte + Public MultiChannelInfo + Public PatternDataArea + Public Order, CentraliseCursor + Public PatternSetLength, PatternLengthStart, PatternLengthEnd + Public MIDI_SetInstrument, PE_TranslateMIDI + Public MIDIAmplification, MIDICentralNote, PE_RestoreMIDINote + Public PE_InsertInstrument, PE_DeleteInstrument + Public Flags, Modified, PatternModified + + Public LastKeyBoard1, PatternNumber + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Pattern WORD Public 'Code' USE16 + Assume CS:Pattern, DS:Nothing + +CREATENEWLOGFILE EQU 0 +include debug.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +NONOTE EQU 0FDh +MAXNOTE EQU 119 + +;PatternSize DW 0 +;PatternEnd DW 0 +PatternDataArea DW PatternData + +TempVariableArea DW 0 +TempVariableArea2 DW 0 +TempVariableArea3 DW 0 +TempVariableArea4 DW 0 +TempVariableArea5 DW 0 +TempVariableArea6 DW 0 + +TopOrder DW 0 +Order DW 0 +OrderCursor DW 0 +PatternNumber DW 0 +TopRow DW 0 +Row DW 0 +MaxRow DW 63 +NumberOfRows DW 64 + +LeftChannel DW 0 +Channel DW 0 +MIDIChannel DW 0 +PatternCursor DW 0 +BaseOctave DW 4 +SkipValue DW 1 +MultiChannelInfo DB 64 Dup (0) +BlockMark DW 0 ; 0 if no block marked, 1 if block is marked +BlockLeft DW 0 +BlockTop DW 0 +BlockRight DW 0 +BlockBottom DW 0 +BlockDataArea DW 0 +BlockAnchorChannel DW 0 +BlockAnchorRow DW 0 +BlockReset DW 0 +LastKeyBoard1 DW 0, 0 +LastKeyBoard2 DW 0, 0 +LastKeyBoard3 DW 0, 0 + +EmptyRow DB 64 Dup ( NONOTE, 0, 0FFh, 0, 0 ) + +KeyBoardTable DW 12Ch, 0, 11Fh, 1, 12Dh, 2, 120h, 3, 12Eh, 4 + DW 12Fh, 5, 122h, 6, 130h, 7, 123h, 8, 131h, 9 + DW 124h, 10, 132h, 11, 110h, 12, 103h, 13, 111h, 14 + DW 104h, 15, 112h, 16, 113h, 17, 106h, 18, 114h, 19 + DW 107h, 20, 115h, 21, 108h, 22, 116h, 23, 117h, 24 + DW 10Ah, 25, 118h, 26, 10Bh, 27, 119h, 28 + DW 0FFFFh + +MODPeriodTable DW 1712, 1616, 1525, 1440, 1357, 1281 ; Octave 0 + DW 1209, 1141, 1077, 1017, 961, 907 + DW 856, 808, 762, 720, 678, 640 ; Octave 1 + DW 604, 570, 538, 508, 480, 453 + DW 428, 404, 381, 360, 339, 320 ; Octave 2 + DW 302, 285, 269, 254, 240, 226 + DW 214, 202, 190, 180, 170, 160 ; Octave 3 + DW 151, 143, 135, 127, 120, 113 + DW 107, 101, 95, 90, 85, 80 ; Octave 4 + DW 75, 71, 67, 63, 60, 56 + DW 53, 50, 47, 45, 42, 40 ; Octave 5 + DW 37, 35, 33, 31, 30, 28 + +Amplification DW 100 + +PlayMarkPattern DW 0 +PlayMarkRow DW 0 +PlayMarkOn DB 0 +VolumePan DB 0 + +UndoBuffer DW 20 Dup (0) ; Word for segment, word for + ; type: + +UndoBufferTypes Label Word + DW Offset UndoBufferType0, Offset UndoBufferType1 + DW Offset UndoBufferType2, Offset UndoBufferType3 + DW Offset UndoBufferType4, Offset UndoBufferType5 + DW Offset UndoBufferType6, Offset UndoBufferType7 + DW Offset UndoBufferType8, Offset UndoBufferType9 + DW Offset UndoBufferType10, Offset UndoBufferType11 + DW Offset UndoBufferType12, Offset UndoBufferType13 + DW Offset UndoBufferType14, Offset UndoBufferType15 + DW Offset UndoBufferType16, Offset UndoBufferType17 + DW Offset UndoBufferType18, Offset UndoBufferType19 + DW Offset UndoBufferType20, Offset UndoBufferType21 + DW Offset UndoBufferType22 + +UndoBufferType0 DB "Empty", 0 +UndoBufferType1 DB "Undo revert pattern data (Alt-BkSpace)", 0 +UndoBufferType2 DB "Undo transposition up", 0FFh, 10, " (Alt-Q)", 0 +UndoBufferType3 DB "Undo transposition down", 0FFh, 8, " (Alt-A)", 0 +UndoBufferType4 DB "Undo block length double", 0FFh, 7, " (Alt-F)", 0 +UndoBufferType5 DB "Undo block length halve", 0FFh, 8, " (Alt-G)", 0 +UndoBufferType6 DB "Undo volume amplification", 0FFh, 6, " (Alt-J)", 0 +UndoBufferType7 DB "Undo volume or panning slide (Alt-K)", 0 +UndoBufferType8 DB "Recover volumes/pannings", 0FFh, 5, " (2*Alt-K)", 0 +UndoBufferType9 DB "Replace mixed data", 0FFh, 13, " (Alt-M)", 0 +UndoBufferType10 DB "Replace overwritten data", 0FFh, 7, " (Alt-O)", 0 +UndoBufferType11 DB "Undo paste data", 0FFh, 16, " (Alt-P)", 0 +UndoBufferType12 DB "Undo set sample/instrument", 0FFh, 5, " (Alt-S)", 0 +UndoBufferType13 DB "Undo set volume/panning", 0FFh, 8, " (Alt-V)", 0 +UndoBufferType14 DB "Replace extra volumes/pannings (Alt-W)", 0 +UndoBufferType15 DB "Undo effect data slide", 0FFh, 9, " (Alt-X)", 0 +UndoBufferType16 DB "Recover effects/effect data (2*Alt-X)", 0 +UndoBufferType17 DB "Undo swap block", 0FFh, 16, " (Alt-Y)", 0 +UndoBufferType18 DB "Undo block cut", 0FFh, 17, " (Alt-Z)", 0 +UndoBufferType19 DB "Remove inserted row(s)", 0FFh, 4, " (Alt-Insert)", 0 +UndoBufferType20 DB "Replace deleted row(s)", 0FFh, 4, " (Alt-Delete)", 0 +UndoBufferType21 DB "Redo", 0FFh, 28, " (Undo)", 0 +UndoBufferType22 DB "Pattern ", 0FDh, "D", 0 + +SelectUndo DW 0 +ShiftPressed DB 0 +NoteEntered DB 0 + +PreviewNote DB 0, 0, 0FFh, 0, 0 + +Modified DB 0 ; } Order important +PatternModified DB 0 ; } + +MIDIPlayTrigger DB 0 ; 0 = nothing, 1 = play + ; pattern, 2 = play song. + +CompleteMsg DB 0FDh, "D% Complete", 0 +Template DB 0 +TemplateMsg1 DB "Template, Overwrite", 0 +TemplateMsg2 DB "Template, Mix - Pattern data precedence", 0 +TemplateMsg3 DB "Template, Mix - Clipboard data precedence", 0 +TemplateMsg4 DB "Template, Notes only", 0 +TriggerMsg1 DB "No MIDI Trigger", 0 +TriggerMsg2 DB "Pattern MIDI Trigger", 0 +TriggerMsg3 DB "Song MIDI Trigger", 0 +NextOrderMsg DB "Playing order ", 0FDh, "D next", 0 +CursorStepMSg DB "Cursor step set to ", 0FDh, "D", 0 + +EncodingInfo DB 384 Dup (0) +PatternSetLength DW 64 +PatternLengthStart DW 0 +PatternLengthEnd DW 0 +TempData DB 320 Dup (0) + +PEFunctions Label Word + DB 0 + DW 11Ch ; Enter + DW Offset PEFunction_PickUp + +IF SHOWPATTERNLENGTH + DB 0 + DW 111Ch ; Right Ctrl+Enter + DW Offset PE_ShowPatternLength +ENDIF + + DB 1 + DW '{' + DW Near Ptr PE_LeftBrace + + DB 1 + DW '}' + DW Near Ptr PE_RightBrace + + DB 1 + DW '[' + DW Near Ptr PE_LeftSquareBracket + + DB 1 + DW ']' + DW Near Ptr PE_RightSquareBracket + + DB 0 + DW 1C8h + DW Offset PEFunction_Up + + DB 0 + DW 1D0h + DW Offset PEFunction_Down + + DB 0 + DW 1CBh + DW Offset PEFunction_Left + + DB 0 + DW 1CDh + DW Offset PEFunction_Right + + DB 0 + DW 1C9h + DW PEFunction_PgUp + + DB 0 + DW 1D1h + DW PEFunction_PgDn + + DB 2 + DW 1C7h + DW Offset PEFunction_Alt_Home + + DB 2 + DW 1CFh + DW Offset PEFunction_Alt_End + + DB 0 + DW 1C7h + DW Offset PEFunction_Home + + DB 0 + DW 1CFh + DW Offset PEFunction_End + + DB 3 + DW 1C9h + DW PEFunction_Ctrl_PgUp + + DB 3 + DW 1D1h + DW PEFunction_Ctrl_PgDn + + DB 2 ; Alt... + DW 1CBh ; Left Arrow + DW Offset PEFunction_AltLeft + + DB 2 ; Alt... + DW 1CDh ; Right Arrow + DW Offset PEFunction_AltRight + + DB 3 ; Ctrl... + DW 1CBh ; Left Arrow + DW Offset PEFunction_ViewLeft + + DB 3 + DW 1CDh + DW Offset PEFunction_ViewRight + + DB 2 ; Alt... + DW 1C8h ; Up Arrow + DW Offset PEFunction_AltUp + + DB 2 + DW 1D0h + DW Offset PEFunction_AltDown + + DB 3 + DW 1C7h + DW Offset PEFunction_Ctrl_Home + + DB 3 + DW 1CFh + DW Offset PEFunction_Ctrl_End + + DB 4 + DW 1C8h + DW Offset PEFunction_Up + + DB 4 + DW 1D0h + DW Offset PEFunction_Down + + DB 4 + DW 1CBh + DW Offset PEFunction_AltLeft + + DB 4 + DW 1CDh + DW Offset PEFunction_AltRight + + DB 4 + DW 1C9h + DW PEFunction_ShiftPgUp + + DB 4 + DW 1D1h + DW PEFunction_ShiftPgDn + + DB 4 + DW 1C7h + DW Offset PEFunction_Home + + DB 4 + DW 1CFh + DW Offset PEFunction_End + + DB 4 + DW 12Ah + DW Offset PEFunction_Press_Shift + + DB 4 + DW 136h + DW Offset PEFunction_Press_Shift + + DB 0 + DW 2Ah + DW Offset PEFunction_Release_Shift + + DB 0 + DW 36h + DW Offset PEFunction_Release_Shift + + DB 0 + DW 10Fh + DW Offset PEFunction_Tab + + DB 4 + DW 10Fh + DW Offset PEFunction_ShiftTab + + DB 1 + DW ',' + DW Offset PEFunction_SetMask + + DB 0 + DW 1D2h + DW Offset PEFunction_Insert + + DB 0 + DW 1D3h ; Delete + DW Offset PEFunction_Delete + + DB 2 ; Alt... + DW 1D2h ; Insert + DW Offset PEFunction_RowInsert + + DB 2 ; Alt... + DW 1D3h ; Delete + DW Offset PEFunction_RowDelete + + DB 3 ; Ctrl... + DW 1D2h ; Insert + DW Offset PEFunction_RollDown + + DB 3 ; Ctrl... + DW 1D3h ; Delete + DW Offset PEFunction_RollUp + + DB 0 + DW 10Eh + DW Offset PEFunction_BackSpace + + DB 3 ; Ctrl... + DW 10Eh ; Backspace + DW Offset PEFunction_Undo + + DB 1 + DW '<' + DW Offset PEFunction_DecreaseInstrument + + DB 1 + DW '>' + DW Offset PEFunction_IncreaseInstrument + + DB 1 + DW ';' + DW Offset PEFunction_DecreaseInstrument + + DB 1 + DW "'" + DW Offset PEFunction_IncreaseInstrument + + DB 3 ; Ctrl + DW 1C8h + DW Offset PEFunction_DecreaseInstrument + + DB 3 + DW 1D0h + DW Offset PEFunction_IncreaseInstrument + + DB 1 + DW 3000h ; Alt 'B' + DW Offset PEFunction_MarkBeginBlock + + DB 1 + DW 3100h ; Alt 'N' + DW Offset PEFunction_ToggleMultiChannel + + DB 1 + DW 1200h ; Alt 'E' + DW Offset PEFunction_MarkEndBlock + + DB 1 + DW 1600h ; Alt 'U' + DW Offset PEFunction_UnMarkBlock + + DB 1 + DW 1700h ; Alt 'I' + DW Offset PEFunction_ToggleTemplate + + DB 1 + DW ':' + DW Offset PEFunction_TemplateOff + + DB 1 + DW 2000h ; Alt 'D' + DW Offset PEFunction_AltD + + DB 1 + DW 1F00h ; Alt 'S' + DW Offset PEFunction_AltS + + DB 1 + DW 2500h ; Alt 'K' + DW Offset PEFunction_AltK + + DB 1 + DW 2C00h ; Alt 'Z' + DW Offset PEFunction_WipeBlock + + DB 1 + DW 2600h ; Alt 'L' + DW Offset PEFunction_AltL + + DB 1 + DW 1800h ; Alt 'O' + DW Offset PEFunction_BlockOverwrite + + DB 1 + DW 1900h ; Alt 'P' + DW Offset PEFunction_BlockPaste + + DB 1 + DW 2E00h ; Alt 'C' + DW Offset PEFunction_BlockCopy + + DB 1 + DW 3h ; Ctrl 'C' + DW Offset PEFunction_ToggleCentralise + + DB 0 + DW 146h ; Scroll Lock + DW Offset PEFunction_ToggleTrace + + DB 2 ; Alt Scroll Lock + DW 146h + DW Offset MIDIInputToggle + + DB 1 + DW 3200h ; Alt 'M' + DW Offset PEFunction_BlockMix + + DB 1 + DW 1000h ; Alt 'Q' + DW Offset PEFunction_SemiUp + + DB 1 + DW 1E00h ; Alt 'A' + DW Offset PEFunction_SemiDown + + DB 1 + DW 2D00h ; Alt 'X' + DW Offset PEFunction_WipeCommands + + DB 1 + DW 2400h ; Alt 'J' + DW Offset PEFunction_VolumeAmp + + DB 1 ; Ctrl... + DW 0Ah ; 'J' + DW Offset ToggleFastVolume + + DB 1 + DW 2F00h ; Alt 'V' + DW Offset PEFunction_BlockVolume + + DB 1 + DW 1100h ; Alt 'W' + DW Offset PEFunction_WipeExcessVolumes + + DB 1 + DW 1400h ; Alt 'T' + DW Offset PEFunction_ViewTrack + + DB 1 ; Ctrl... + DW 14h ; 'T' + DW Offset PEFunction_ToggleTracking + + DB 1 ; Ctrl... + DW 8h ; 'H' + DW Offset PEFunction_ToggleRowHilight + + DB 1 + DW 2300h ; Alt 'H' + DW Offset PEFunction_ToggleDivision + + DB 1 + DW 1300h ; Alt 'R' + DW Offset PEFunction_ClearViews + + DB 1 + DW 1500h ; Alt 'Y' + DW Offset PEFunction_BlockSwap + + DB 1 + DW 2200h ; Alt 'G' + DW Offset PEFunction_BlockHalve + + DB 1 + DW 2100h ; Alt 'F' + DW Offset PEFunction_BlockDouble + +; DB 0 +; DW 14Eh ; Grey Plus +; DW Offset PEFunction_NextPattern +; +; DB 0 +; DW 14Ah ; Grey Minus +; DW Offset PEFunction_LastPattern + + DB 4 ; Shift + DW 14Eh + DW Offset PEFunction_Next4Patterns + + DB 4 + DW 14Ah + DW Offset PEFunction_Last4Patterns + + DB 3 ; Ctrl.. + DW 14Eh ; Grey Plus + DW Offset PEFunction_NextOrderPattern + + DB 3 ; Ctrl.. + DW 14Ah ; Grey Minus + DW Offset PEFunction_LastOrderPattern + + DB 1 + DW '+' + DW Offset PEFunction_NextPattern + + DB 1 + DW '-' + DW Offset PEFunction_LastPattern + + DB 3 ; Ctrl + DW 141h ; F7 + DW Offset PEFunction_SetPlayMark + + DB 2 + DW 10Bh + DW Offset PEFunction_Alt0 + + DB 2 ; Alt Backspace + DW 10Eh + DW Offset PEFunction_RestoreData + + DB 2 ; Alt.. + DW 11Ch ; Enter + DW Offset PEFunction_StoreCurrentPattern + + DB 0 + DW 0B02h ; Left-Shift, Left-Ctrl '1' + DW Offset PEFunction_Ctrl_Shift1 + + DB 0 + DW 0B03h ; Left-Shift, Left-Ctrl '2' + DW Offset PEFunction_Ctrl_Shift2 + + DB 0 + DW 0B04h ; Left-Shift, Left-Ctrl '3' + DW Offset PEFunction_Ctrl_Shift3 + + DB 0 + DW 0B05h ; Left-Shift, Left-Ctrl '4' + DW Offset PEFunction_Ctrl_Shift4 + + DB 3 ; Ctrl.. + DW 10Bh ; '0' + DW Offset PEFunction_Ctrl0 + + DB 3 ; Ctrl... + DW 102h ; '1' + DW Offset PEFunction_Ctrl1 + + DB 3 ; Ctrl... + DW 103h ; '2' + DW Offset PEFunction_Ctrl2 + + DB 3 ; Ctrl... + DW 104h ; '3' + DW Offset PEFunction_Ctrl3 + + DB 3 ; Ctrl... + DW 105h ; '4' + DW Offset PEFunction_Ctrl4 + + DB 3 ; Ctrl... + DW 106h ; '5' + DW Offset PEFunction_Ctrl5 + + DB 1 + DW '\' + DW Offset PEFunction_Alt_F9 + + DB 0 + DW 135h + DW Offset PEFunction_MuteNext + + DB 1 + DW '?' + DW Offset PEFunction_MutePrevious + + DB 2 ; Alt + DW 143h ; F9 + DW Offset PEFunction_Alt_F9 + + DB 1 + DW '|' + DW Offset PEFunction_SoloGotoNext + + DB 2 ; Alt \ + DW 12Bh + DW Offset PEFunction_UnmuteAll + + DB 2 ; Alt + DW 144h ; F10 + DW Offset PEFunction_Alt_F10 + + DB 3 ; Ctrl + DW 140h ; F6 + DW Offset PE_PlayCurrentPosition + + DB 3 ; Ctrl + DW 13Ch ; F2 + DW Offset PE_SetPatternLength + + DB 1 ; Ctrl 'V' + DW 16h + DW Offset PE_ToggleDefaultVolume + + DB 1 ; Ctrl 'Z' + DW 1Ah + DW Offset PE_CycleMIDIPlayTrigger + + DB 6 ; MIDI message + DW 8000h + DW Offset PE_MIDINoteOff + + DB 6 ; MIDI message + DW 9000h + DW Offset PE_MIDINote + + DB 6 ; MIDI message + DW 0A000h + DW Offset PE_MIDIAftertouch + + DB 0FFh + +CursorPositions DB 0, 2, 4, 5, 7, 8, 10, 11, 12 + DB 0, 2, 3, 4, 5, 6, 7, 8, 9 + DB 0, 2, 3, 3, 4, 4, 5, 6, 6 + + DB 20h, 2, 1, 2, 1, 2, 0, 1, 2 + DB 10h, 1, 0, 1, 0, 1, 0, 1, 1 + +MaskChange DB 0, 0, 1, 1, 2, 2, 4, 4, 4 +ChannelMsg DB " Channel xx ", 0 +ChannelMsg2 DB "Channel xx", 0 +ChannelMsg3 DB " Chnl xx", 0 +ChannelMsg4 DB " xx", 0 +ChannelMsg5 DB "xx", 0 +ChannelMsg6 DB "Ch xx", 0 +ChannelMsg7 DB "Chnl xx", 0 + +NoteNames Label Byte + DB "C-C#D-D#E-F-F#G-G#A-A#B-" ; Cmaj +StartChannelEdit DW 5 + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ +; Don't change order of variables within here!!!! + +KeySignature DW 0 +NumChannelsEdit DW 5 + +RowHiLight1 DB 4 +RowHiLight2 DB 16 + +EditMask DB 3 ; Bit 0 = ins + ; Bit 1 = vol + ; Bit 2 = commands +ViewDivision DB 1 +ViewWidth DW 0 +ViewChannels DW 100 Dup (0FFFFh) ; Contains channel/viewmethod +ViewChannelTracking DB 0 +CommandToValue DB 0 +CentraliseCursor DB 0E8h ; Bit 0 = centralise cursor + ; Bit 1 = hilight row + ; Bit 2 = fast volume changes + ; Bit 3 = Record tick base + ; Bit 4 = Program base 1 + ; Bit 5 = Record note off + ; Bit 6 = Record velocity + ; Bit 7 = Record aftertouch +MIDIAmplification DB 100 +MIDICentralNote DB 60 +FastVolumeAmplification DW 67 +Flags DB 0 ; Extra flags + ; Bit 0 = display defaults. + ; Bit 1 = Record note cuts. + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +ViewMethodInfo Label + DW Offset ViewFull + DW 13 ; Width + + DW Offset ViewCompress + DW 10 ; Width + + DW Offset ViewAllSmall + DW 7 + + DW Offset ViewNote + DW 3 + + DW Offset ViewTiny + DW 2 + +EmptyData DB 253, 0, 255, 0, 0 + +TempNumbers DB 3 Dup (0) + +ErrorMsg DB "Unable to allocate memory for pattern edit area.", 13, 10 + DB "Sorry, more conventional memory is required to run this program.", 13, 10, "$" + +ViewChannelTrackingMsg DB "View-Channel cursor tracking enabled", 0 +NoViewChannelTrackingMsg DB "View-Channel cursor tracking disabled", 0 +CentraliseCursorMsg DB "Centralise cursor enabled", 0 +NoCentraliseCursorMsg DB "Centralise cursor disabled", 0 +TraceMsg DB "Playback tracing enabled", 0 +NoTraceMsg DB "Playback tracing disabled", 0 +PanningControlSetMsg DB "Panning control set", 0 +VolumeControlSetMsg DB "Volume control set", 0 +NoRowHilightMsg DB "Row hilight disabled", 0 +RowHilightMsg DB "Row hilight enabled", 0 +NoFastVolumeMsg DB "Alt-I / Alt-J fast volume changes disabled", 0 +FastVolumeMsg DB "Alt-I / Alt-J fast volume changes enabled", 0 +FastVolumeNotEnabledMsg DB "Alt-I / Alt-J fast volume changes not enabled", 0 +DefaultVolumeOn DB "Default volumes enabled", 0 +DefaultVolumeOff DB "Default volumes disabled", 0 +MIDIInputDisabledMsg DB "MIDI Input Disabled", 0 +MIDIInputEnabledMsg DB "MIDI Input Enabled", 0 +MIDIInputEnabled DB 1 + +LastNote DB 60 +LastInstrument DB 1 +LastVolume DB 0FFh +LastCommand DB 0 +LastCommandValue DB 0 +TracePlayback DB 0 + +OrderListKeys Label + +IF ORDERSORT + DB 1 + DW 1300h ; Alt-R + DW Offset PE_PostOrderListReorder +ENDIF + + DB 0 + DW 10Fh + DW Offset PE_PostOrderList20 + + DB 1 + DW 0F00h + DW Offset PE_PostOrderList21 + + DB 3 ; Ctrl-F7 + DW 141h + DW Offset PE_PostOrderListNextOrder + + DB 1 ; Spacebar + DW ' ' + DW Offset PE_PostOrderListNextOrder + + DB 0 + DW 1C8h ; Up + DW Offset PE_PostOrderList1 + + DB 0 + DW 1D0h ; Down + DW Offset PE_PostOrderList3 + + DB 0 + DW 1C9h ; PgUp + DW Offset PE_PostOrderList4 + + DB 0 + DW 1D1h ; PgDn + DW Offset PE_PostOrderList6 + + DB 0 + DW 1CBh ; Left + DW Offset PE_PostOrderList7 + + DB 0 + DW 1CDh ; Right + DW Offset PE_PostOrderList9 + + DB 5 + DW 'G' + DW Offset PE_PostOrderList24 + + DB 1 + DW '-' + DW Offset PE_PostOrderList16 + + DB 1 + DW '+' + DW Offset PE_PostOrderList17 + + DB 0 + DW 1D3h ; Insert + DW Offset PE_PostOrderList18 + + DB 0 + DW 1D2h ; Delete + DW Offset PE_PostOrderList19 + + DB 0 + DW 1CFh ; End + DW PE_PostOrderListEndKey + + DB 0 + DW 1C7h + DW PE_PostOrderListHomeKey + + DB 5 + DW 'N' + DW PE_PostOrderList22 + + DB 0FFh + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc PE_ConvAX2Num Far ; ES:DI points to screen + ; CH = colour + ; AX = number + + Push AX + Push BX + Push DX + + Mov BX, 10 + + And AX, AX + JNS PE_ConvAX2Num1 + + Mov Byte Ptr [ES:DI], '-' + Inc DI + Neg AX + Mov [ES:DI], CH + Inc DI + Jmp PE_ConvAX2Num2 + +PE_ConvAX2Num1: + Xor DX, DX + Div BX + Add DL, '0' + Mov DH, CH + Mov [ES:DI+4], DX + +PE_ConvAX2Num2: + Xor DX, DX + Div BX + Add DL, '0' + Mov DH, CH + Mov [ES:DI+2], DX + + Xor DX, DX + Div BX + Add DL, '0' + Mov DH, CH + Mov [ES:DI], DX + + Pop DX + Pop BX + Pop AX + + Ret + +EndP PE_ConvAX2Num + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_ConvHexAL Near + + Cmp AL, 10 + SBB AL, 69h + DAS + StosW + + Ret + +EndP PE_ConvHexAL + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_GetMaxOrder Far ; Returns AX with max order + + Push CX + Push ES + Push DI + + Call Music_GetSongSegment + Mov ES, AX + Mov DI, 256 + Mov CX, 257 + Mov AL, 0FFh + RepNE ScasB + Mov AX, 256 + Sub AX, CX + + And AX, AX + JZ PE_GetMaxOrder1 + + Dec AX + +PE_GetMaxOrder1: + Pop DI + Pop ES + Pop CX + + Ret + +EndP PE_GetMaxOrder + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ClearEncodingInfo ; Encoding info + ; 1.Mask, 2.Instrument, 3.Volume, 4.Cmd + ; 5.CmdVal, 6.Note + + Push CS + Pop ES + + Mov DI, Offset EncodingInfo + + Mov CX, 64 + +ClearEncodingInfo1: + Mov AX, NONOTE*100h ; Mask&Note + StosW + Mov AH, 0FFh ; Ins&Vol + StosW + Xor AX, AX ; Cmd&Value + StosW + + Loop ClearEncodingInfo1 + + Ret + +EndP ClearEncodingInfo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF ORDERSORT + +Proc PE_PostOrderListSwapPatterns ; Given BX = pattern 1 + ; DX = Pattern 2 + + PushA + + Mov AX, CS:PatternNumber + + Cmp AX, BX + JNE PE_PostOrderListSwapPatterns1 + Mov AX, DX + Jmp PE_PostOrderLIstSwapPatterns2 + +PE_PostOrderListSwapPatterns1: + Cmp AX, DX + JNE PE_PostOrderListSwapPatterns2 + Mov AX, BX + +PE_PostOrderListSwapPatterns2: + Mov CS:PatternNumber, AX + +; Search through order list and swap BX with DX + + Mov SI, 100h + Mov CX, SI + +PE_PostOrderListSwapPatterns3: + LodsB + + Cmp AL, BL + JNE PE_PostOrderListSwapPatterns4 + + Mov [SI-1], DL + Jmp PE_PostOrderListSwapPatterns5 + +PE_PostOrderListSwapPatterns4: + Cmp AL, DL + JNE PE_PostOrderListSwapPatterns5 + + Mov [SI-1], BL + +PE_PostOrderListSwapPatterns5: + Loop PE_PostOrderListSwapPatterns3 + +; Now swap memory references to patterns. + + LEA BX, [EBX*4+63912] + LEA DI, [EDX*4+63912] + + Mov EAX, [BX] + XChg EAX, [DI] + Mov [BX], EAX + +; Finished! + + PopA + Ret + +EndP PE_PostOrderListSwapPatterns + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PostOrderListReorder Far + + EnsureNoNetwork + + Call Music_Stop + + Call Music_GetSongSegment + Mov DS, AX ; DS:100h = order list. + ; DS:63912 (4) = pattern data + Mov SI, 100h + Xor DX, DX ; DX = min pattern + Mov CX, SI + Xor BX, BX + +PE_PostOrderListReorder1: + LodsB + Cmp AL, 200 + JAE PE_PostOrderListReorder2 + + Cmp AL, DL + JB PE_PostOrderListReorder2 + JE PE_PostOrderListReorder3 + + Mov BL, AL + Call PE_PostOrderListSwapPatterns + +PE_PostOrderListReorder3: + Inc DX + +PE_PostOrderListReorder2: + Loop PE_PostOrderListReorder1 + +PE_PostOrderListReorderExit: + Mov AX, 1 + Ret + +EndP PE_PostOrderListReorder + Assume DS:Nothing + +ENDIF ; ORDERSORT + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_ResetOrderPattern Far + + Push CS + Pop DS + Assume DS:Pattern + + Xor AX, AX + Mov Order, AX + Mov OrderCursor, AX + Mov Channel, AX + Mov PatternCursor, AX + Mov LastInstrument, 1 + Mov PlayMarkOn, 0 + + Mov BX, AX + + Call Music_GetSongSegment + Mov ES, AX + MovZX AX, Byte Ptr [ES:BX+256] + + Cmp AX, 199 + JBE PE_ResetOrderPattern1 + + Xor AX, AX + +PE_ResetOrderPattern1: + Mov PatternNumber, AX + Call NewPattern + Mov Word Ptr [CS:Modified], 0 + + Call Music_InitMixTable ; Here 'cos it's called + ; on file loading. + Call Music_InitMuteTable ; ditto. + Call Music_InitStereo + Call Music_SoundCardLoadAllSamples + Call PE_ClearUndoBuffer + + Mov AX, Inst + Mov DS, AX + Assume DS:Inst + Mov NodeHeld, 0 + Mov InstrumentEdit, 0 + + Ret + +EndP PE_ResetOrderPattern + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_GetMaxPattern Far ; Assumes DS:SongData + + Push CX + Push DS + Push SI + Push DI + + Call Music_GetSongSegment + Mov DS, AX + + Mov SI, 63912 + + Xor AX, AX + Xor DI, DI + Mov CX, 200 + +PE_GetMaxPattern1: + Cmp Word Ptr [SI], 0 + JE PE_GetMaxPattern2 + + Mov AX, DI + +PE_GetMaxPattern2: + Inc DI + Add SI, 4 + Loop PE_GetMaxPattern1 + + Pop DI + Pop SI + Pop DS + Pop CX + Ret + +EndP PE_GetMaxPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_FillHeader Far + + Call Music_GetSongSegment + Mov DS, AX + Call S_GetDestination + Mov SI, 4 + Mov DI, (12+3*80)*2 + Mov CX, 25 + Mov AH, 5 + +PE_FillHeader1: + LodsB + Cmp AL, 226 + JB PE_FillHeader14 + + Mov AL, ' ' + +PE_FillHeader14: + StosW + Loop PE_FillHeader1 + + Push DS + + Mov AX, Disk + Mov DS, AX + Mov SI, Offset FileName + Mov DI, (12+4*80)*2 + Mov AH, 5 + +PE_FillHeader11: + LodsB + StosW + And AL, AL + JNZ PE_FillHeader11 + + Pop DS + + Mov CH, AH + Mov AX, Order + Mov DI, (12+5*80)*2 + Call PE_ConvAX2Num + + Call PE_GetMaxOrder + Mov DI, (16+5*80)*2 + Call PE_ConvAX2Num + + Mov AX, PatternNumber + Mov DI, (12+6*80)*2 + Call PE_ConvAX2Num + + Call PE_GetMaxPattern + Mov DI, (16+6*80)*2 + Call PE_ConvAX2Num + + Mov AX, Row + Mov DI, (12+7*80)*2 + Call PE_ConvAX2Num + + Mov AX, MaxRow + Mov DI, (16+7*80)*2 + Call PE_ConvAX2Num + + Call Glbl_GetHeaderMode + ; AL = inst + ; AH = mode. + Mov DI, (50+3*80)*2 + And AL, AL + JNZ PE_FillHeader6 + + Mov AX, 5*256+'.' + StosW + StosW + ScasW +; Add DI, 2 + Mov AL, '.' + Mov CX, 25 + Rep StosW + Jmp PE_FillHeader7 + +PE_FillHeader6: + Push AX + + Mov DL, 10 + Xor AH, AH + Mov CX, AX + Div DL + Add AX, 3030h + Mov DL, AH + Mov AH, 5 + StosW + Mov AL, DL + StosW + ScasW +; Add DI, 2 + + Pop AX + + Dec CX + And AH, AH ; CX = ins number + JZ PE_FillHeader8 + + ; Complex instrument mode + Mov AX, 554 + Mul CX + Add AX, 544 + Jmp PE_FillHeader9 + +PE_FillHeader8: ; Simple instrument mode + Mov AX, 80 + Mul CX + Add AX, 55932 + +PE_FillHeader9: + Mov SI, AX + Mov CX, 25 + Mov AH, 5 + +PE_FillHeader10: + LodsB + Cmp AL, 226 + JB PE_FillHeader13 + + Mov AL, ' ' + +PE_FillHeader13: + StosW + Loop PE_FillHeader10 + +PE_FillHeader7: +; Mov AL, LastVolume + + Call PE_FillSpeedTempo + +; Cmp AL, 0FFh +; JNE PE_FillHeader4 +; +; Mov AX, 5*256+'.' +; StosW +; StosW +; Jmp PE_FillHeader5 +; +;PE_FillHeader4: +; Xor AH, AH +; Mov CL, 10 +; Div CL +; Add AX, 3030h +; Mov DL, AH +; Mov AH, 5 +; StosW +; Mov AL, DL +; StosW + +PE_FillHeader5: + Mov AX, BaseOctave + Add AL, '0' + Mov AH, 5 + Mov [ES:((50+5*80)*2)], AX + +; Mov AH, 48h +; Mov BX, 0FFFFh +; Int 21h +; Mov AX, BX +; Mov CX, 2006h +; ShR AX, CL +; Mov DI, (71+6*80)*2 +; Call PE_ConvAX2Num +; +; Call E_GetFreeEMS +; Xor DX, DX +; Mov BX, 1000 +; Div BX +; +; Add AL, '0' +; Mov AH, CH +; Mov [ES:(70+7*80)*2], AX +; Mov AX, DX +; Mov DI, (71+7*80)*2 +; Call PE_ConvAX2Num + + +; Call K_GetCaps +; Mov AH, 21h +; And AL, AL +; JZ PE_FillHeader2 +; +; Mov AH, 23h +; +;PE_FillHeader2: +; Mov DI, (75+10*80)*2 +; Mov SI, Offset CapsMsg +; Mov CX, 4 +; +;PE_FillHeader3: +; SegCS LodsB +; StosW +; Loop PE_FillHeader3 + + Call UpdateInfoLine + + Ret + +EndP PE_FillHeader + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_FillSpeedTempo Far + + Call S_GetDestination + + Call Music_GetDisplayVariables ; AX = current speed. + Mov CH, 5 + Mov DI, (50+4*80)*2 + Call PE_ConvAX2Num + + Mov AX, BX + Mov DI, (54+4*80)*2 + Call PE_ConvAX2Num + + Ret + +EndP PE_FillSpeedTempo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_DrawOrderList Far + + Mov AL, 80 + Mul Byte Ptr [SI+3] + Add AL, [SI+2] + AdC AH, 0 + Add AX, AX + Mov DI, AX + Mov CX, [SI+4] + + Push CS + Pop DS + Assume DS:Pattern + + Mov AX, TopOrder ; Bounds checking... + Mov BX, Order + Cmp AX, BX + JBE PE_DrawOrderList1 + + Mov AX, BX + +PE_DrawOrderList1: + Mov DX, AX + Add DX, CX + Cmp DX, BX + JA PE_DrawOrderList2 + + LEA AX, [BX+1] + Sub AX, CX + +PE_DrawOrderList2: + Mov TopOrder, AX + Mov BX, AX + + Call S_GetDestination + Push CX + Push DI + +PE_DrawOrderList3: + Push CX + + Mov CH, 20h + Call PE_ConvAX2Num + + Add DI, 160 + Inc AX + + Pop CX + Loop PE_DrawOrderList3 + + Pop DI + Pop CX + Add DI, 8 ; BX = toporder, DI = order area + + Call Music_GetSongSegment + Mov DS, AX + Add BX, 256 + +PE_DrawOrderList4: + Push CX + + Mov CH, 2 + MovZX AX, Byte Ptr [BX] + Cmp AX, 0FEh + JB PE_DrawOrderList5 + + Mov CL, '-' + Cmp AL, 0FEh + JNE PE_DrawOrderList7 + + Mov CL, '+' + +PE_DrawOrderList7: + Mov AX, CX + StosW + StosW + StosW + Sub DI, 6 + + Jmp PE_DrawOrderList6 + + +PE_DrawOrderList5: + Call PE_ConvAX2Num + +PE_DrawOrderList6: + Pop CX + Inc BX + Add DI, 160 + Loop PE_DrawOrderList4 + + Call Music_GetPlayMode + Cmp AX, 2 + JNE PE_DrawOrderList8 + + Jmp PE_ShowOrder + +PE_DrawOrderList8: + Ret + +EndP PE_DrawOrderList + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PreOrderList Far + + Mov AL, 80 + Mov BX, Order + Sub BX, TopOrder + Add BL, [SI+3] + Mul BL + Add AL, [SI+2] + AdC AH, 0 + Add AX, 4 + Add AX, OrderCursor + Add AX, AX + Mov DI, AX + + Call S_GetDestination + Inc DI + Mov Byte Ptr [ES:DI], 30h + + Ret + +EndP PE_PreOrderList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc NetworkOrderList Near + +IF NETWORKENABLED + Call Network_GetSendQueue + JZ NetworkOrderList1 + + Mov AX, NETWORK_SONGDATAOBJECT*100h ; Destination ALL + StosW + Mov AX, 256 + StosW + StosW + +NetworkOrderList1: + Call Network_FinishedSendQueue +ENDIF + Ret + +EndP NetworkOrderList + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PostOrderList Far + + Push ES + Pop DS + Mov SI, [BX] + + Push BX + + Mov AL, 80 + Mov BX, Order + Sub BX, TopOrder + Add BL, [SI+3] + Mul BL + Add AL, [SI+2] + AdC AH, 0 + Add AX, 4 + + Pop BX + +; Push ES +; Push DI + + Push CS + Pop DS + Assume DS:Pattern + + Push ES + Pop FS + + Call Music_GetSongSegment + Mov ES, AX + + Mov SI, Offset OrderListKeys + Call M_FunctionDivider + Mov AX, Order + JC PE_NoKeyFound + + Jmp [SI] + +PE_NoKeyFound: + Test CH, Not 1 + JNZ PE_PostOrderList10 + + Cmp DX, '0' + JB PE_PostOrderList10 + + Cmp DX, '9' + JBE PE_PostOrderList11 + +PE_PostOrderList10: + Xor AX, AX + Ret + +PE_PostOrderListNextOrder: + Call Music_GetPlayMode + Cmp AX, 2 + JNE PE_PostOrderListNextOrderEnd + + Mov AX, Order + Mov SI, Offset NextOrderMsg + Call SetInfoLine + + Call Music_SetNextOrder + +PE_PostOrderListNextOrderEnd: + Mov AX, 1 + Ret + +PE_PostOrderListHomeKey: + Mov Order, 0 + Jmp PE_PostOrderList2 + +PE_PostOrderListEndKey: + Call Music_GetSongSegment + Mov DS, AX + Mov SI, 100h + +PE_PostOrderListEndKeyLoop: + LodsB + Cmp AL, 0FFh + JE PE_postOrderListEndKeyLoopEnd + + Cmp SI, 100h+255 + JBE PE_PostOrderListEndKeyLoop + +PE_PostOrderListEndKeyLoopEnd: + Sub SI, 101h + Mov CS:Order, SI + + Jmp PE_PostOrderList2 + +PE_PostOrderList20: + Push FS + Pop DS + Mov SI, [BX] + + Mov AX, [SI+6] + Mov [DI], AX + Jmp PE_PostOrderList2 + +PE_PostOrderList21: + Push FS + Pop DS + Mov SI, [BX] + + Mov AX, [SI+8] + Mov [DI], AX + Jmp PE_PostOrderList2 + +PE_PostOrderList1: ; Up + And AX, AX + JZ PE_PostOrderList2 + + Dec AX + Mov Order, AX + +PE_PostOrderList2: + Mov AX, 1 + Ret + +PE_PostOrderList3b: + Call NetworkOrderList + +PE_PostOrderList3: ; Down + Cmp AX, 255 + JAE PE_PostOrderList2 + Inc AX + Mov Order, AX + Jmp PE_PostOrderList2 + +PE_PostOrderList4: ; PgUp + Sub AX, 16 + JNS PE_PostOrderList5 + + Xor AX, AX + +PE_PostOrderList5: + Mov Order, AX + Jmp PE_PostOrderList2 + +PE_PostOrderList6: ; PgDn + Add AX, 16 + And AH, AH + JZ PE_PostOrderList5 + + Mov AX, 255 + Jmp PE_PostOrderList5 + +PE_PostOrderList7: ; Left + Mov AX, OrderCursor + Dec AX + JNS PE_PostOrderList8 + + Mov AX, 2 + +PE_PostOrderList8: + Mov OrderCursor, AX + Jmp PE_PostOrderList2 + +PE_PostOrderList9: ; Right + Mov AX, OrderCursor + Inc AX + Cmp AX, 2 + JBE PE_PostOrderList8 + + Xor AX, AX + Jmp PE_PostOrderList8 + +PE_PostOrderList11: + Mov SI, AX + MovZX AX, Byte Ptr [ES:SI+256] ; AX = pattern number + Cmp AL, 199 + JBE PE_PostOrderList15 + + Xor AL, AL + +PE_PostOrderList15: ; Number + Mov CL, 10 + Div CL + Mov [TempNumbers+2], AH + Xor AH, AH + Div CL + Mov [TempNumbers+1], AH + Xor AH, AH + Div CL + Mov [TempNumbers], AH + + Mov BX, OrderCursor + Sub DX, '0' + Mov TempNumbers[BX], DL + + Mov AL, [TempNumbers] + Mul CL + Add AL, [TempNumbers+1] + Mul CL + Add AL, [TempNumbers+2] + + Cmp AX, 199 + JBE PE_PostOrderList12 + + Mov AX, 199 + +PE_PostOrderList12: + Mov [ES:SI+256], AL + Call NetworkOrderList + + Inc BX + Cmp BX, 2 + JBE PE_PostOrderList13 + + Cmp SI, 255 + JE PE_PostOrderList2 + + Xor BX, BX + Inc Order + +PE_PostOrderList13: + Mov OrderCursor, BX + Jmp PE_PostOrderList2 + + +PE_PostOrderList16: ; '-' + Mov SI, AX + Mov Byte Ptr [ES:SI+256], 0FFh + Mov OrderCursor, 0 + + Jmp PE_PostOrderList3b + +PE_PostOrderList17: ; '+' + Mov SI, AX + Mov Byte Ptr [ES:SI+256], 0FEh + Mov OrderCursor, 0 + + Jmp PE_PostOrderList3b + +PE_PostOrderList18: ; Del + Mov SI, AX + Add SI, 256 + Mov DI, SI + Inc SI + + Push ES + Pop DS + + Mov CX, 512 + Sub CX, SI + Rep MovsB + Mov AL, 0FFh + StosB + + Call NetworkOrderList + Jmp PE_PostOrderList2 + +PE_PostOrderList19: ; Ins + Mov CX, 255 + Mov DI, 511 + Mov SI, DI + Sub CX, AX + Dec SI + + Push ES + Pop DS + + StD + Rep MovsB + ClD + Mov AL, 0FFh + StosB + + Call NetworkOrderList + Jmp PE_PostOrderList2 + +PE_PostOrderList22: + Mov SI, Order + And SI, SI + JZ PE_PostOrderList23 + + Mov AL, [ES:SI+255] + Cmp AL, 198 + JA PE_PostOrderList23 + + Inc AX + Mov [ES:SI+256], AL + + Mov AX, SI + Jmp PE_PostOrderList3b + +PE_PostOrderList23: + Xor AX, AX + Ret + +PE_PostOrderList24: ; 'G' + Mov BX, AX + MovZX AX, Byte Ptr [ES:BX+256] + Cmp AL, 200 + JAE PE_PostOrderList23 + + Jmp PE_GotoPattern2 + +EndP PE_PostOrderList + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_UnInitPatternEdit Far + + Mov AX, CS:BlockDataArea + And AX, AX + JZ PE_UnInitPatternEdit1 + + Mov ES, AX + Mov AH, 49h + Int 21h + +PE_UnInitPatternEdit1: + Call PE_ClearUndoBuffer + + Ret + +EndP PE_UnInitPatternEdit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_ClearPatternData + + Push CX DX DS SI ES DI + + Push CS + Pop DS + Assume DS:Pattern + + Mov ES, PatternDataArea + Xor DI, DI + + Mov DX, 200 + +PE_ClearPatternData1: + Mov CX, 320/4 + Mov SI, Offset EmptyRow + Rep MovsD + + Dec DX + JNZ PE_ClearPatternData1 + + Pop DI ES SI DS DX CX + Ret + +EndP PE_ClearPatternData + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_InitPatternEdit Far + + Trace " - Initialising pattern data area" + + Call PE_ClearPatternData + Ret + +EndP PE_InitPatternEdit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include it_pe_v.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_DrawPatternEdit Far + + Push CS + Pop DS + Assume DS:Pattern + + Cmp TracePlayback, 0 + JE PE_TraceOff + + Call Music_GetPlayMode ; AX = playmode + ; BX = current row + ; CX = current pattern + ; DX = order. + Cmp AX, 1 + JB PE_TraceOff + JE PE_NoTraceOrder + + Mov Order, DX + +PE_NoTraceOrder: + Cmp BX, Row + JE PE_SetMIDIChannel + + Mov AX, Channel + Mov MIDIChannel, AX + + Mov Row, BX + +PE_SetMIDIChannel: + Cmp CX, PatternNumber + JE PE_TraceOff + + Push CX ; Pattern number + Push CS + Push Offset PE_TraceTurnOffError + + Cmp PatternModified, 0 + JE PE_NoStoreRequired + + Call PEFunction_StorePattern + +PE_NoStoreRequired: + Pop AX + Pop AX + Pop AX + + Mov PatternNumber, AX + Call NewPattern + Jmp PE_TraceOff + +PE_TraceTurnOffError: + Pop AX + +PE_TraceTurnOff: + Mov CS:TracePlayback, 0 + +PE_TraceOff: + Push CS + Pop DS + + Call S_GetDestination + Mov AL, Template + Cmp AL, 1 + JB PE_DrawPAtternEdit30 + + Mov SI, Offset TemplateMsg1 + JE PE_DrawPatternEdit31 + + Mov SI, Offset TemplateMsg2 + Cmp AL, 3 + JB PE_DrawPatternEdit31 + + Mov SI, Offset TemplateMsg3 + JE PE_DrawPatternEdit31 + + Mov SI, Offset TemplateMsg4 + +PE_DrawPatternEdit31: + Mov DI, (2+12*80)*2 + Mov AH, 23h + Call S_DrawString + +PE_DrawPatternEdit30: + Test CentraliseCursor, 1 + JZ PE_NoCentraliseCursor + + Call PE_CentraliseCursor + +PE_NoCentraliseCursor: + Mov AX, MaxRow + Cmp AX, Row + JAE PE_DrawPatternEdit27 + + Mov Row, AX + +PE_DrawPatternEdit27: + Mov BX, BlockTop + Cmp BX, AX + JLE PE_DrawPatternEdit28 + + Mov BlockTop, AX + +PE_DrawPatternEdit28: + Mov BX, BlockBottom + Cmp BX, AX + JLE PE_DrawPatternEdit29 + + Mov BlockBottom, AX + +PE_DrawPatternEdit29: + Mov BX, ViewWidth + Test BX, BX + JZ PE_DrawPatternEdit1 + + Mov CX, 3 + Cmp NumChannelsEdit, 0 + JE PE_DrawPatternEditNoEditChannels + + Xor CX, CX + +PE_DrawPatternEditNoEditChannels: + Mov AX, 1 + Add AX, CX + Push AX + Push 14 + Mov AX, BX + Add AX, CX + Push AX + Push 47 + Push 27 + Call S_DrawBox + Add SP, 10 + +PE_DrawPatternEdit1: + Cmp NumChannelsEdit, 0 + JE PE_DrawPatternEdit34 + + Mov CX, 4 + Add CX, BX + Push CX + Mov AX, 14 + Push AX + Mul NumChannelsEdit + Add AX, CX + Push AX + Push 47 + Push 27 + Call S_DrawBox + Add SP, 10 + + Mov AX, LeftChannel + Mov CX, Channel + + Cmp AX, CX + JLE PE_DrawPatternEdit21 + + Mov AX, CX + +PE_DrawPatternEdit21: + Mov DX, AX + Add DX, NumChannelsEdit + Cmp DX, CX + JG PE_DrawPatternEdit22 + + Mov AX, CX + Sub AX, NumChannelsEdit + Inc AX + +PE_DrawPatternEdit22: + Mov LeftChannel, AX + ; Channel markers. + Mov DX, AX ; DL = left channel + Mov AX, 5+14*80 + Add AX, ViewWidth + Add AX, AX + Mov DI, AX + Mov DH, 10 + + Mov CX, NumChannelsEdit + +PE_DrawPatternEdit23: + Push CX + + MovZX AX, DL + Inc AX + Div DH + Add AX, 3030h + Mov SI, Offset ChannelMsg + Mov [SI+9], AX + + Push DS + Push SI + + Call Music_GetSongSegment + Mov DS, AX + + Mov SI, DX + And SI, 0FFh + Add SI, 40h + Mov AH, 13h + Test Byte Ptr [SI], 80h + JZ PE_DrawPatternEdit32 + + Mov AH, 10h + +PE_DrawPatternEdit32: + Pop SI + Pop DS + + Mov CX, 12 + +PE_DrawPatternEdit24: + LodsB + StosW + Loop PE_DrawPatternEdit24 + + Pop CX + Add DI, 4 + Inc DX + Loop PE_DrawPatternEdit23 + +PE_DrawPatternEdit34: + Cmp ViewChannelTracking, 0 + JE PE_DrawPatternEditNormal + + ; OK.. using view windows ONLY. + ; now to perform scrolling if necessary. + Mov SI, Offset ViewChannels + Mov DL, [SI] + + Cmp DL, 0FFh + JE PE_DrawPatternEditNormal + + Mov DH, DL ; DL = min channel, DH = max channel + Mov CX, Channel ; Also check + +PE_DrawPatternViewChannelOnly1: + LodsW + + Cmp AL, CL + JE PE_DrawPatternEditNormalJP + + Cmp AL, 0FFh + JE PE_DrawPatternViewChannelOnly2 + + Cmp AL, DL + JB PE_DrawPatternViewChannelOnly3 + + Cmp AL, DH + JA PE_DrawPatternViewChannelOnly4 + + Jmp PE_DrawPatternViewChannelOnly1 + +PE_DrawPatternViewChannelOnly3: + Mov DL, AL + Jmp PE_DrawPatternViewChannelOnly1 + +PE_DrawPatternViewChannelOnly4: + Mov DH, AL + Jmp PE_DrawPatternViewChannelOnly1 + +PE_DrawPatternEditNormalJP: + Jmp PE_DrawPatternEditNormal + +PE_DrawPatternViewChannelOnly2: ; OK.. so channel is not in list, + ; DL = min channel, DH = max channel. + Mov CH, CL + Sub CH, DH ; CH = curchannel-maxchannel + + Cmp DH, CL + JBE PE_DrawPatternViewChannelOnly5 + + Mov CH, CL + Sub CH, DL + +PE_DrawPatternViewChannelOnly5: ; CH = modifier. + + Mov SI, Offset ViewChannels + +PE_DrawPatternViewChannelOnly6: + LodsW + Cmp AL, 0FFh + JE PE_DrawPatternEditNormal + + Add AL, CH + JS PE_DrawPatternViewChannelOnly7 + + Cmp AL, 63 + JBE PE_DrawPatternViewChannelOnly8 + + Mov AL, 63 + Jmp PE_DrawPatternViewChannelOnly8 + +PE_DrawPatternViewChannelOnly7: + Xor AL, AL + +PE_DrawPatternViewChannelOnly8: + Mov [SI-2], AL + Jmp PE_DrawPatternViewChannelOnly6 + +PE_DrawPatternEditNormal: + Mov AX, TopRow + Mov CX, Row + + Cmp AX, CX + JLE PE_DrawPatternEdit2 + + Mov AX, CX ; if row < toprow, toprow = row + +PE_DrawPatternEdit2: + LEA DX, [EAX+32] + Cmp DX, CX + JG PE_DrawPatternEdit3 + + LEA AX, [ECX-31] + +PE_DrawPatternEdit3: + Mov TopRow, AX + + Mov CX, MaxRow + Sub CX, 31 + Cmp AX, CX + JBE PE_DrawPatternEdit35 + + Mov TopRow, CX + Mov AX, CX + +PE_DrawPatternEdit35: + Mov DI, (1+15*80)*2 + Cmp NumChannelsEdit, 0 + JNE PE_DrawPatternEditAllView + + Xor BX, BX + +PE_DrawPatternEditAllView: + LEA DI, [EDI+EBX*2] + + Xor BX, BX + Cmp PlayMarkOn, 0 + JE PE_DrawPlayMark + + Mov CX, PlayMarkPattern + Cmp CX, PatternNumber + JNE PE_DrawPlayMark + + Mov BX, 1 ; Check to draw playmark + +PE_DrawPlayMark: + Push DI + + Mov DX, 32 + +PE_DrawPatternEdit4: + Push DI + + Mov CH, 20h + And BX, BX + JZ PE_DrawPatternEditRowNumber + + Cmp AX, PlayMarkRow + JNE PE_DrawPatternEditRowNumber + + Mov CH, 0B0h + +PE_DrawPatternEditRowNumber: + Call PE_ConvAX2Num + + Pop DI + Inc AX + Add DI, 160 + + Dec DX + JNZ PE_DrawPatternEdit4 + + Mov BX, Offset NoteNames ; CS:BX points to notenames + + Push DS + ; Viewing columns... + Mov SI, Offset ViewChannels + Mov DI, (15*80+2)*2 + Cmp NumChannelsEdit, 0 + JNE PE_DrawviewColumnStart + + Add DI, 6 + +PE_DrawViewColumnStart: + LodsW + Cmp AL, 0FFh + JE PE_DrawViewColumn2 + +PE_DrawViewColumn1: + ; AL = channel, AH = view method. + Mov DL, AL + MovZX CX, AH + LEA BP, [ViewMethodInfo+ECX*4] + + Push DS + Push SI + Push ES + Push DI + Push BP + + Mov SI, 5 + Xor AH, AH + Push DX + Mul SI + Mov SI, AX + Mov AX, 320 + Mov CX, TopRow + Mul CX + Pop DX + Mov DS, PatternDataArea + Add SI, AX ; DS:SI points to appropriate data. + ; CS:BX points to note type. + ; ES:DI points to screen area. + ; DL = Channel number + ; CX = Row number + + Call [Near Ptr CS:BP] + + Pop BP + Pop DI + Pop ES + Pop SI + Pop DS + + LodsW + Cmp AL, 0FFh + JE PE_DrawViewColumn2 + + Push AX + + Mov CX, [CS:BP+2] + Add DI, CX + Add DI, CX + + Cmp ViewDivision, 0 + JE PE_DrawViewColumn4 + + Mov CX, 32 + Push DI + + Mov AX, 2A8h + +PE_DrawViewColumn3: + StosW + Add DI, 158 + Loop PE_DrawViewColumn3 + + Pop DI + StosW ; Just to do: Add DI, 2 + +PE_DrawViewColumn4: + Pop AX + Jmp PE_DrawViewColumn1 + +PE_DrawViewColumn2: + Pop DS + Pop DI + Add DI, 8 + + Cmp NumChannelsEdit, 0 + JE PE_DrawPatternHilightRow + +PE_DrawPatternEdit33: + Mov AX, 320 + Mov BP, TopRow + Mul BP + Mov SI, AX + Mov AX, 5 + Mul LeftChannel + Add SI, AX ; SI contains offset to channel data + Mov DX, NumChannelsEdit + + Mov CX, 32 ; 32 rows + Mov DS, PatternDataArea + Assume DS:Nothing + +PE_DrawPatternEdit5: + Push CX + Push DX + Push SI + Push DI + Push BP + + Mov CX, 60Ch + + Mov AX, BP + Cmp RowHiLight2, 0 + JZ PE_DrawPatternEdit8 + Div RowHiLight2 + And AH, AH + JNZ PE_DrawPatternEdit8 + + Mov CH, 0E6h + Jmp PE_DrawPatternEdit6 + +PE_DrawPatternEdit8: + Mov AX, BP + Cmp RowHiLight1, 0 + JZ PE_DrawPatternEdit6 + Div RowHiLight1 + And AH, AH + JNZ PE_DrawPatternEdit6 + + Mov CH, 0F6h + +PE_DrawPatternEdit6: ; CH = colour, CL = 12 (for division) + Push CX + Push DX + + Cmp CS:BlockMark, 0 + JE PE_DrawPatternEdit25 + + Cmp BP, CS:BlockTop + JB PE_DrawPatternEdit25 + + Cmp BP, CS:BlockBottom + JA PE_DrawPatternEdit25 + + Mov AX, CS:LeftChannel + Add AX, CS:NumChannelsEdit + Sub AX, DX + + Cmp AX, CS:BlockLeft + JB PE_DrawPatternEdit25 + + Cmp AX, CS:BlockRight + JA PE_DrawPatternEdit25 + + Test CH, 80h + JZ PE_DrawPatternEdit26 + + Mov CH, 93h + Jmp PE_DrawPatternHilight1 + +PE_DrawPatternEdit26: + Mov CH, 83h + Jmp PE_DrawPatternHilight1 + +PE_DrawPatternEdit25: + Cmp BP, Row + JNE PE_DrawPatternHilight1 + + Test CentraliseCursor, 2 + JZ PE_DrawPatternHilight1 + + Mov CH, 016h + +PE_DrawPatternHilight1: + LodsB + + Call Draw_3Note + + Mov AL, 20h + StosW ; Note->Instrument space + + Mov DL, 10 + LodsB + + Call Draw_2Instrument + + Mov AL, 20h + StosW + + LodsB + Cmp AL, 0FFh + JNE PE_DrawPattern16 + + Test CS:Flags, 1 + JZ PE_DrawPatternNoDefaultVolume + + Cmp Byte Ptr [SI-3], MAXNOTE + JA PE_DrawPatternNoDefaultVolume + Cmp Byte Ptr [SI-2], 0 + JE PE_DrawPatternNoDefaultVolume + + Sub DI, 2 + Mov AL, 191 + StosW + + Push BX + + Call Music_GetSongSegment + Mov FS, AX + Mov BL, [SI-2] ; Sample/Instrument + And BX, 0FFh + Add BX, BX + + Test Byte Ptr [FS:2Ch], 4 ; Sample mode? + JZ DefaultVolumeSample + +DefaultVolumeInstrument: + Push DI + + Mov BX, [FS:64710+BX] ; Instrument pointer + Mov DI, [SI-3] + And DI, 0FFh ; DI = Note + Add DI, DI + Mov BX, [FS:BX+DI+41h] ; BL = sample + + Pop DI + And BX, 0FFh + Add BX, BX + JZ DefaultVolumeNoSample + +DefaultVolumeSample: + Mov BX, [FS:64910+BX] ; Sample + Mov AL, [FS:BX+13h] ; Default volume + + Pop BX + Mov DL, 10 + Xor AH, AH + Div DL + Add AX, '00' + Mov DH, AH + Mov AH, CH + StosW + Mov AL, DH + StosW + Mov AL, 192 + StosW + Jmp PE_DrawPatternEffect + +DefaultVolumeNoSample: + Pop BX + + Mov AH, CH + Mov AL, 173 ; Replace with default volume + StosW + StosW + Mov AL, 192 + StosW + Jmp PE_DrawPatternEffect + +PE_DrawPatternNoDefaultVolume: + Mov AL, 173 ; '.' + StosW + StosW + Jmp PE_DrawPattern17 + +PE_DrawPattern16: + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC PE_DrawPatternNoVEffect + + Test AL, 80h + JZ PE_DrawPatternVEffect1 + + Add AH, 60 + +PE_DrawPatternVEffect1: + Mov AL, AH + Xor AH, AH + Div DL + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov DH, AH + Mov AH, CH + StosW + Mov AL, DH + StosW + + Jmp PE_DrawPattern17 + +PE_DrawPatternNoVEffect: + Mov CL, CH + + Test AL, 80h + JZ PE_DrawPatternNoPan + + And CL, 0F0h + Or CL, 2 + And AL, 7Fh ; Filter out panning stuff. + + +PE_DrawPatternNoPan: + Xor AH, AH + Div DL + ; AH = units, AL = tens + Mov DH, AH + Mov AH, CL + Add AL, '0' + StosW + Mov AL, DH + Add AL, '0' + StosW + + Mov AH, CH + +PE_DrawPattern17: + Mov AL, 20h + StosW + +PE_DrawPatternEffect: + LodsB + Add AL, 64 + Cmp AL, 64 + JNE PE_DrawPattern18 + + Mov AL, '.' + +PE_DrawPattern18: + StosW + LodsB ; Commandvalue + Mov DH, AL + ShR AL, 4 + + Call PE_ConvHexAL + + Mov AL, DH + And AL, 15 + Call PE_ConvHexAL + + Pop DX + Pop CX + Dec DX + JZ PE_DrawPatternEdit9 + + And AX, 0F000h + Or AX, 2A8h + Cmp AH, 80h + JB PE_DrawDiv1 + Cmp AH, 0A0h + JAE PE_DrawDiv1 + + Mov AX, 2A8h + +PE_DrawDiv1: + StosW + Jmp PE_DrawPatternEdit6 + +PE_DrawPatternEdit9: + Pop BP + Pop DI + Pop SI + Pop DX + Pop CX + Add DI, 160 ; Screen + Add SI, 320 ; PatternData + Inc BP ; Row + Loop PE_DrawPatternEdit5 + +PE_DrawPatternHilightRow: + Call Music_GetPlayMode + Test AX, AX + JZ PE_DrawPattern40 + + Cmp CX, CS:PatternNumber + JNE PE_DrawPattern40 + + Sub BX, CS:TopRow + JC PE_DrawPattern40 + Cmp BL, 32 + JAE PE_DrawPattern40 + Mov AL, 80 + Mul BL + + Mov DI, AX + Add DI, 1+15*80 + Cmp CS:NumChannelsEdit, 0 + JE PE_DrawPattern41 + + Add DI, CS:ViewWidth + +PE_DrawPattern41: + Add DI, DI + + Push ES + Pop DS + + Mov CL, 3 + +PE_DrawPattern42: + Inc DI + Mov AL, [DI] + And AL, 0F0h + Or AL, 3 + StosB + + Dec CL + JNZ PE_DrawPattern42 + +PE_DrawPattern40: + Ret + +EndP PE_DrawPatternEdit + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PrePatternEdit Far + + Push CS + Pop DS + Assume DS:Pattern + + Cmp NumChannelsEdit, 0 + JNE PE_PrePatternEdit18 + + Ret + +PE_PrePatternEdit18: + Call S_GetDestination + + Mov AX, 80 + Mov BX, 15 + Add BX, Row + Sub BX, TopRow + Mul BL + Add AX, ViewWidth + Add AX, 5 + Mov BX, PatternCursor + Add AL, [CursorPositions+BX] + AdC AH, 0 + Mov DI, AX + Mov AL, 14 + Mov BX, Channel + Sub BX, LeftChannel + Mul BL + Add DI, AX + Add DI, DI + Inc DI + Mov Byte Ptr [ES:DI], 30h + + Mov DI, 8+47*80 + Add DI, ViewWidth + Add DI, DI + Mov SI, LeftChannel + Mov DX, NumChannelsEdit + +PE_PrePatternEdit16: + Cmp [MultiChannelInfo+SI], 0 ; Put the 'M's in. + JE PE_PrePatternEdit17 + + Mov Byte Ptr [ES:DI], 172 + +PE_PrePatternEdit17: + Inc SI + Add DI, 28 + Dec DX + JNZ PE_PrePatternEdit16 + + Mov DI, 5+47*80 + Add DI, ViewWidth + Mov AL, 14 + Mov BX, Channel + Sub BX, LeftChannel + Mul BL + Add DI, AX + Add DI, DI ; Points to bottom of channel. + + Mov DX, 1 + Cmp Template, 0 + JE PE_PrePatternEditLoop +; Test CL, CL +; JZ PE_PrePatternEditLoop + Cmp BlockDataArea, 0 + JE PE_PrePatternEditLoop + + Mov FS, BlockDataArea + Mov AX, [FS:0] ; Block width + Mov DX, NumChannelsEdit + Add DX, LeftChannel + Sub DX, Channel + Cmp DX, AX + JB PE_PrePatternEditLoop + + Mov DX, AX + +PE_PrePatternEditLoop: + Push DI + + Mov AX, 23A9h + Mov CX, PatternCursor + Mov CH, EditMask + + Test CL, CL + JZ PE_PrePatternEdit1 + + Mov AL, 0AAh + +PE_PrePatternEdit1: + StosW + StosW + StosW +; Add DI, 2 + ScasW + + Test CH, 1 + JZ PE_PrePatternEdit2 + + StosW + StosW + Jmp PE_PrePatternEdit3 + +PE_PrePatternEdit2: + Add DI, 4 + +PE_PrePatternEdit3: +; Add DI, 2 + ScasW + + Test CH, 2 + JZ PE_PrePatternEdit4 + + StosW + StosW + Jmp PE_PrePatternEdit5 + +PE_PrePatternEdit4: + Add DI, 4 + +PE_PrePatternEdit5: +; Add DI, 2 + ScasW + + Test CH, 4 + JZ PE_PrePatternEdit6 + + StosW + StosW + StosW + +PE_PrePatternEdit6: + Pop DI ; Mark in the actual channels + Mov AL, 0A9h + Test CL, CL + JNZ PE_PrePatternEdit7 + + Mov AL, 0ABh + StosW + StosW + StosW + + Add DI, 22 + Dec DX + JNZ PE_PrePatternEditLoop + + Ret + +PE_PrePatternEdit7: + Cmp CL, 1 + JA PE_PrePatternEdit8 + + Mov AL, 0ABh + Add DI, 4 + StosW + Ret + +PE_PrePatternEdit8: + Cmp CL, 3 + JA PE_PrePatternEdit10 + + Test CH, 1 + JZ PE_PrePatternEdit9 + + Mov AL, 0ABh + +PE_PrePatternEdit9: + Add DI, 8 + StosW + StosW + Ret + +PE_PrePatternEdit10: + Cmp CL, 5 + JA PE_PrePatternEdit12 + + Test CH, 2 + JZ PE_PrePatternEdit11 + + Mov AL, 0ABh + +PE_PrePatternEdit11: + + Add DI, 14 + StosW + StosW + Ret + +PE_PrePatternEdit12: + Cmp CL, 6 + JA PE_PrePatternEdit14 + + Test CH, 4 + JZ PE_PrePatternEdit13 + + Mov AL, 0ABh + +PE_PrePatternEdit13: + Add DI, 20 + StosW + Ret + +PE_PrePatternEdit14: + Test CH, 4 + JZ PE_PrePatternEdit15 + + Mov AL, 0ABh + +PE_PrePatternEdit15: + Add DI, 22 + StosW + StosW + Ret + +EndP PE_PrePatternEdit + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetPatternOffset + + Assume DS:Pattern + + Push AX + Push BX + Push DX + + Mov AX, 64 + Mul Row + Add AX, Channel + Mov BX, 5 + Mul BX + Mov DI, AX + Mov ES, PatternDataArea + + Pop DX + Pop BX + Pop AX + Ret + +EndP GetPatternOffset + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc NetworkPatternBlock Near ; CL = width, CH = Height, BL = Channel, BH = Row + +IF NETWORKENABLED + Call Network_GetSendQueue + JZ PE_GotoNextInputNoNetwork + + Mov AX, NETWORK_PARTIALPATTERNOBJECT*100h ; Destination ALL + StosW + Mov AL, Byte Ptr PatternNumber + StosB + Mov AX, BX + StosW + Mov AX, CX + StosW + +PE_GotoNextInputNoNetwork: + Call Network_FinishedSendQueue + + Ret +ENDIF + +EndP NetworkPatternBlock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc NetworkPartialPattern Near ; CL = width, CH = Height + +IF NETWORKENABLED + Push BX + Mov BL, Byte Ptr Channel + Mov BH, Byte Ptr Row + Call NetworkPatternBlock + Pop BX +ENDIF + Ret + +EndP NetworkPartialPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc NetworkBlock Near + +IF NETWORKENABLED + Mov BL, Byte Ptr BlockLeft + Mov BH, Byte Ptr BlockTop + Mov CL, Byte Ptr BlockRight + Mov CH, Byte Ptr BlockBottom + Sub CX, BX + Add CX, 101h + Call NetworkPatternBlock +ENDIF + Ret + +EndP NetworkBlock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +PatternCursorJumpTable DW Offset PE_PatternCursorPos0 + DW Offset PE_PatternCursorPos1 + DW Offset PE_PatternCursorPos2 + DW Offset PE_PatternCursorPos3 + DW Offset PE_PatternCursorPos4 + DW Offset PE_PatternCursorPos5 + DW Offset PE_PatternCursorPos6 + DW Offset PE_PatternCursorPos7 + DW Offset PE_PatternCursorPos8 + +Proc PE_PostPatternEdit Far + + Push CS + Pop DS + Assume DS:Pattern + + Test CH, 1 + JZ PE_PostPatternEdit17 + + Mov EAX, [DWord Ptr LastKeyBoard1] + Mov EBX, [DWord Ptr LastKeyBoard2] + + Mov [DWord Ptr LastKeyBoard2], EAX + Mov [DWord Ptr LastKeyBoard3], EBX + + Mov [LastKeyBoard1], CX + Mov [LastKeyBoard1+2], DX + +PE_PostPatternEdit17: + Mov AL, CH + Mov SI, Offset PEFunctions + And AL, 6 + Mov ShiftPressed, AL + + Test CH, 6 + PushF + Call M_FunctionDivider + JC PE_PostPatternEdit1 + + PopF + JNZ PE_PostPatternEditShift + +PE_PostPatternEditNotShift: + Jmp [SI] + +PE_PostPatternEditShift: + Cmp Byte Ptr [SI-3], 6 ; MIDI message + JE PE_PostPatternEditNotshift + + Mov AX, [SI-2] + + Cmp AX, 10Fh ; Shift Tab + JE PE_PostPatternEditNotShift + + Cmp AX, '?' + JE PE_PostPatternEditNotShift + + Cmp AX, '|' + JE PE_PostPatternEditNotShift + + Push [Row] + Push [Channel] + + Push CS + + Call [SI] + + Push CS + Pop DS + +; Mov CX, BlockAnchorRow +; Mov DX, BlockAnchorChannel + Pop DX + Pop CX + + Cmp CX, Row + JNE PE_PostPatternEditShift1 + + Cmp DX, Channel + JE PE_PostPatternEditShift2 + +PE_PostPatternEditShift1: + Cmp BlockReset, 0 + JE PE_PostPatternEditShift3 + + Mov BlockReset, 0 + Mov BlockMark, 0 + +PE_PostPatternEditShift3: + ; Set block marks. + Mov AX, BlockAnchorChannel + Mov BX, BlockAnchorRow + + Push CS + Call PEFunction_MarkBeginBlockChain + Jmp PEFunction_MarkEndBlock + +PE_PostPatternEditShift2: + Mov AX, 1 + Ret + +PE_PostPatternEdit1: + PopF + Test CH, 60h + JNZ PE_PostPatternEdit6 + + Call GetPatternOffset + Mov BX, PatternCursor + Add BX, BX + Jmp [PatternCursorJumpTable+BX] + +PE_PostPatternEdit6: + Mov AX, CX + And AX, 1FFh + Cmp AX, 10Ah + JA PE_PostPatternEdit7 + + Cmp AX, 102h + JB PE_PostPatternEdit7 + ; Alt-1 -> Alt-9 + Sub AX, 101h +; Dec AL +; Dec AH + Mov SkipValue, AX + + Mov SI, Offset CursorStepMsg + Call SetInfoLine + + Mov AX, 1 + Ret + +PE_PostPatternEdit7: + Xor AX, AX + Ret + +EndP PE_PostPatternEdit + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl_PgUp Far + + Mov Row, 0 + + Mov AX, 1 + Ret + +EndP PEFunction_Ctrl_PgUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl_PgDn Far + + Mov AX, MaxRow + Mov Row, AX + + Mov AX, 1 + Ret + +EndP PEFunction_Ctrl_PgDn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Up Far + + Mov BX, SkipValue + And BX, BX + JNZ PEFunction_Up2 + + Mov BX, 1 + +PEFunction_Up2: + Mov AX, Row + Sub AX, BX + JS PEFunction_Up1 + + Mov Row, AX + +PEFunction_Up1: + Mov AX, 1 + Ret + +EndP PEFunction_Up + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Down Far + + Push CS + Pop DS + + Mov BX, SkipValue + And BX, BX + JNZ PEFunction_Down2 + + Mov BX, 1 + +PEFunction_Down2: + Mov AX, Row + Add AX, BX + Cmp AX, MaxRow + JA PEFunction_Down1 + + Mov Row, AX + +PEFunction_Down1: + Mov AX, 1 + Ret + +EndP PEFunction_Down + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Left Far + + Mov CX, PatternCursor + Mov BX, Channel + Dec CX + JNS PEFunction_Left1 + + Mov CX, 8 + Dec BX + JS PEFunction_Left2 + + Mov Channel, BX + + Cmp CommandToValue, 0 + JE PEFunction_Left1 + + Call GetPatternOffset +; Mov ES, PatternDataArea +; Mov AX, 64 +; Mul Row +; Add AX, BX +; Mov DX, 5 +; Mul DX +; Mov DI, AX + Cmp Word Ptr [ES:DI+3], 0 + JNE PEFunction_Left1 + + Mov CX, 6 + +PEFunction_Left1: + Mov PatternCursor, CX + +PEFunction_Left2: + Mov AX, 1 + Ret + +EndP PEFunction_Left + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Right Far ; If there is no + ; command value... skip! + + Mov CX, PatternCursor + Mov BX, Channel + Inc CX + Cmp CX, 6 + JBE PEFunction_Right1 + + Cmp CommandToValue, 0 + JE PEFunction_Right4 + + Call GetPatternOffset +; Mov ES, PatternDataArea +; Mov AX, 64 +; Mul Row +; Add AX, Channel +; Mov DX, 5 +; Mul DX +; Mov DI, AX + Cmp Word Ptr [ES:DI+3], 0 + JE PEFunction_Right3 + +PEFunction_Right4: + Cmp CX, 9 + JB PEFunction_Right1 + +PEFunction_Right3: + Xor CX, CX + Inc BX + Cmp BX, 64 + JAE PEFunction_Right2 + +PEFunction_Right1: + Mov PatternCursor, CX + Mov Channel, BX + +PEFunction_Right2: + Mov AX, 1 + Ret + +EndP PEFunction_Right + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Press_Shift Far + + Mov AX, Channel + Mov BX, Row + + Mov BlockAnchorChannel, AX + Mov BlockAnchorRow, BX + Mov BlockReset, 1 + Mov NoteEntered, 0 + + Xor AX, AX + Ret + +EndP PEFunction_Press_Shift + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Release_Shift Far + + Cmp NoteEntered, 0 + JE PEFunction_Release_Shift1 + + Mov AX, BlockAnchorChannel + Mov BX, BlockAnchorRow + + Mov Channel, AX + Mov Row, BX + + Call PE_GotoNextInput + +PEFunction_Release_Shift1: + Xor AX, AX + Ret + +EndP PEFunction_Release_Shift + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Alt_Home Far + Mov BL, RowHilight1 + Jmp PEFunction_PgUpChain + +Proc PEFunction_PgUp Far + + Mov BL, RowHiLight2 + +PEFunction_PgUpChain: + Mov AX, Row + Mov CX, MaxRow + Mov DX, SkipValue + And DX, 0FFh + JNZ PEFunction_PgUp3 + + Mov DL, 1 + +PEFunction_PgUp3: + And BX, 0FFh + + JNZ PEFunction_PgUp2 + + Mov BX, 16 + +PEFunction_PgUp2: + Sub CX, DX ; Sub maxrow, skipvalue + Cmp CX, AX + JAE PEFunction_PgUp4 + + Dec AX + Div BL + Mul BL + Jmp PEFunction_PgUp1 + +PEFunction_PgUp4: + Sub AX, BX + JNS PEFunction_PgUp1 + + Xor AX, AX + +PEFunction_PgUp1: + Mov Row, AX + + Mov AX, 1 + Ret + +EndP PEFunction_PgUp + +EndP PEFunction_Alt_Home + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_CentraliseCursor + + Mov AX, Row + Sub AX, 16 + JNC PE_CentraliseCursor1 + + Xor AX, AX + +PE_CentraliseCursor1: + Mov TopRow, AX + Ret + +EndP PE_CentraliseCursor + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +Proc PEFunction_Alt_End Far + Mov BL, RowHilight1 + Jmp PEFunction_PgDnChain + +Proc PEFunction_PgDn Far + + Mov BL, RowHiLight2 + +PEFunction_PgDnChain: + Mov AX, Row + And BX, 0FFh + JNZ PEFunction_PgDn2 + + Mov BX, 16 + +PEFunction_PgDn2: + Add AX, BX + Cmp AX, MaxRow + JBE PEFunction_PgDn1 + + Mov AX, MaxRow + +PEFunction_PgDn1: + Mov Row, AX + + Mov AX, 1 + Ret + +EndP PEFunction_PgDn + +EndP PEFunction_Alt_End + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ShiftPgUp Far + + Call PEFunction_PgUp + Call PE_CentraliseCursor + + Mov AX, 1 + Ret + +EndP PEFunction_ShiftPgUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ShiftPgDn Far + + Call PEFunction_PgDn + Call PE_CentraliseCursor + + Mov AX, 1 + Ret + +EndP PEFunction_ShiftPgDn + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Home Far + + Cmp PatternCursor, 0 + JE PEFunction_Home1 + + Mov PatternCursor, 0 + Jmp PEFunction_Home3 + +PEFunction_Home1: + Cmp Channel, 0 + JE PEFunction_Home2 + + Mov Channel, 0 + Jmp PEFunction_Home3 + +PEFunction_Home2: + Mov Row, 0 + +PEFunction_Home3: + Mov AX, 1 + Ret + +EndP PEFunction_Home + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_End Far + + Cmp PatternCursor, 8 + JE PEFunction_End1 + + Mov PatternCursor, 8 + Jmp PEFunction_End3 + +PEFunction_End1: + Call Music_GetLastChannel + + Cmp Channel, AX + JE PEFunction_End2 + + Mov Channel, AX + Jmp PEFunction_End3 + +PEFunction_End2: + Mov AX, MaxRow + Mov Row, AX + +PEFunction_End3: + Mov AX, 1 + Ret + +EndP PEFunction_End + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Tab Far + + Mov AX, Channel + Cmp AX, 63 + JAE PEFunction_Tab1 + + Mov PatternCursor, 0 + Inc Channel + +PEFunction_Tab1: + Mov AX, 1 + Ret + +EndP PEFunction_Tab + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ShiftTab Far + + Cmp PatternCursor, 0 + JNE PEFunction_ShiftTab2 + + Mov AX, Channel + And AX, AX + JZ PEFunction_ShiftTab1 + + Dec Channel + +PEFunction_ShiftTab2: + Mov PatternCursor, 0 + +PEFunction_ShiftTab1: + Mov AX, 1 + Ret + +EndP PEFunction_ShiftTab + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_SetMask Far + + Mov BX, PatternCursor + Mov AL, [MaskChange+BX] + Xor EditMask, AL + + Mov AX, 1 + Ret + +EndP PEFunction_SetMask + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ToggleMultiChannel Far + + Mov BX, Channel + Xor [MultiChannelInfo+BX], 1 + + Cmp [Word Ptr LastKeyBoard2+2], 3100h + JNE PEFunction_ToggleMultiChannel1 + + Mov CX, 7 + Add CX, Channel + Mov DI, Offset O1_SelectMultiChannel + Call M_Object1List + +PEFunction_ToggleMultiChannel1: + Mov AX, 1 + Ret + +EndP PEFunction_ToggleMultiChannel + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BackSpace Far + + Xor CX, CX + + Mov AX, Row + Mov BX, Channel + Sub AX, SkipValue + JS PEFunction_BackSpace3 + + Mov Row, AX + Cmp [MultiChannelInfo+BX], 0 + JE PEFunction_BackSpace5 + + Mov DX, BX + +PEFunction_BackSpace1: + Dec BX + JNS PEFunction_BackSpace4 + + And AX, AX + JZ PEFunction_BackSpace3 + + Inc CX + +PEFunction_BackSpace4: + And BX, 63 + Cmp BX, DX + JE PEFunction_BackSpace2 + + Cmp [MultiChannelInfo+BX], 0 + JE PEFunction_BackSpace1 + +PEFunction_BackSpace2: + Mov Channel, BX + Cmp SkipValue, 0 + JNE PEFunction_BackSpace3 + + And CX, CX + JZ PEFunction_BackSpace3 + + And AX, AX + JZ PEFunction_BackSpace3 + + Dec Row + Jmp PEFunction_BackSpace3 + +PEFunction_BackSpace5: ; AX = row + Cmp SkipValue, 0 + JNE PEFunction_BackSpace3 + + Mov BX, Channel + Dec BX + JNS PEFunction_BackSpace6 + + And AX, AX + JZ PEFunction_BackSpace3 + Dec AX + +PEFunction_BackSpace6: + And BX, 63 + Mov Row, AX + Mov Channel, BX + +PEFunction_BackSpace3: + Mov AX, 1 + Ret + +EndP PEFunction_BackSpace + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_PickUp Far + + Cmp Template, 4 + JE PEFunction_PickUp2 + + Mov Template, 0 ; Turn off templates + +PEFunction_PickUp2: + Call GetPatternOffset + Mov EAX, [ES:DI] + + Test AH, AH + JNZ PEFunction_PickUp1 + + Mov AH, LastInstrument + +PEFunction_PickUp1: + Mov DWord Ptr [LastNote], EAX + Mov AL, [ES:DI+4] + Mov LastCommandValue, AL + + Mov AX, 1 + Ret + +EndP PEFunction_PickUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos1 Far + + Test CL, CL + JZ PE_PatternCursorPos1_1 + + Cmp DX, '0' + JB PE_PatternCursorPos1_1 + + Cmp DX, '9' + JA PE_PatternCursorPos1_1 + + Mov AL, [ES:DI] + Cmp AL, 120 + JA PE_PatternCursorPos1_2 + + AAM 12 ; AH = octave, AL = note + Mov AH, DL + Sub AH, '0' + AAD 12 + StosB + +PE_PatternCursorPos1_2: + Mov CX, 101h + Call NetworkPartialPattern + + Jmp PE_GotoNextInput + +PE_PatternCursorPos1_1: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos0 Far + + Test CL, CL + JZ PE_PatternCursorPos0_4 + + Push CX + Mov SI, Offset KeyBoardTable + + And CH, Not 6 ; Remove shift mask. + +PE_PatternCursorPos0_1: + LodsW + Cmp AX, 0FFFFh + JE PE_PatternCursorPos0_3 + + Cmp AX, CX + JNE PE_PatternCursorPos0_2 + + Pop CX + + Mov BX, 3Ah + Call K_IsKeyDown + JNZ PE_PatternCursorPreview + + Jmp PE_NewNote + +PE_PatternCursorPreview: + Mov AX, 12 + Mul BaseOctave + Mov BX, AX + LodsW + Add AX, BX + + Mov SI, Offset PreviewNote + + Cmp AX, MAXNOTE + JA PE_PatternCursorPos0_4 + + Mov AH, LastInstrument + Mov [SI], AX + + Mov AX, CS:Channel + Mov DH, 32 + Call Music_PlayNote + + Xor AX, AX + Ret + +PE_PatternCursorPos0_2: + LodsW ; Add SI, 2 + Jmp PE_PatternCursorPos0_1 + +PE_PatternCursorPos0_3: + Pop CX + + Mov AL, NONOTE + Cmp DX, '.' + JE WipeNote + + Inc AX + Cmp DX, '1' + JE WipeNote + Cmp DX, '!' + JE WipeNote + + Inc AX + Cmp DX, '`' + JE WipeNote + Cmp DX, '~' + JE WipeNote + + Cmp DX, ' ' + JE NoteSpace + + Cmp DX, '4' + JE PEFunction_PlayCurrentNote + Cmp DX, '$' + JE PEFunction_PlayCurrentNote + + Cmp DX, '8' + JE PEFunction_PlayCurrentRow + +PE_PatternCursorPos0_4: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc NoteSpace Far + + Mov AL, LastNote + Jmp PE_NewNote4 + +EndP NoteSpace + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc WipeNote Far + + Mov AH, EditMask + + Mov BP, 1 + Cmp Template, 0 + JE WipeNote4 + + Cmp BlockDataArea, 0 + JE WipeNote4 + + Mov FS, BlockDataArea + Cmp Word Ptr [FS:2], 1 + JNE WipeNote4 + + Mov BP, [FS:0] + +WipeNote4: + Mov CX, BP + Mov CH, 1 + Call NetworkPartialPattern + +WipeNote5: + Mov [ES:DI], AL + Mov LastNote, AL + Test AH, 1 + JZ WipeNote1 + + Mov Byte Ptr [ES:DI+1], 0 + +WipeNote1: + Test AH, 2 + JZ WipeNote2 + + Mov Byte Ptr [ES:DI+2], 0FFh + +WipeNote2: + Test AH, 4 + JZ WipeNote3 + + Mov Word Ptr [ES:DI+3], 0 + +WipeNote3: + Add DI, 5 + Dec BP + JNZ WipeNote5 + +IF CHORDENTRY + Cmp ShiftPressed, 0 + JE PE_GotoNextInput + + Push SkipValue + Mov SkipValue, 0 + Mov NoteEntered, 1 + + Call PE_GotoNextInput + Pop SkipValue + + Mov AX, 1 + Ret +ELSE + Jmp PE_GotoNextInput +ENDIF + +EndP WipeNote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_GotoNextInput Far + + + Mov CX, PatternCursor + And CX, CX + JZ PE_GotoNextInput4 + + Cmp CX, 1 + JE PE_GotoNextInput4 + + Cmp CX, 2 + JNE PE_GotoNextInput5 + +PE_GotoNextInput7: + Inc PatternCursor + Jmp PE_GotoNextInput3 + +PE_GotoNextInput5: + Cmp CX, 3 + JNE PE_GotoNextInput6 + +PE_GotoNextInput8: + Dec PatternCursor + Jmp PE_GotoNextInput4 + +PE_GotoNextInput6: + Cmp CX, 4 + JE PE_GotoNextInput7 + + Cmp CX, 5 + JE PE_GotoNextInput8 + + Cmp CX, 6 + JNE PE_GotoNextInput9 + + Cmp CommandToValue, 0 + JZ PE_GotoNextInput4 + + Jmp PE_GotoNextInput7 + +PE_GotoNextInput9: + Cmp CX, 7 + JE PE_GotoNextInput7 + + Cmp CommandToValue, 0 + JE PE_GotoNextInput8 + + Sub PatternCursor, 2 + +PE_GotoNextInput4: + Mov AX, Row + Mov BX, Channel + Add AX, SkipValue + Cmp AX, MaxRow + JA PE_GotoNextInput3 + + Mov Row, AX + Cmp PatternCursor, 0 + JNE PE_GotoNextInput10 + + Cmp [MultiChannelInfo+BX], 0 + JE PE_GotoNextInput10 + + Mov DX, BX + Xor CX, CX + +PE_GotoNextInput1: + Inc BX + Cmp BX, 63 + JBE PE_GotoNextInput11 + + Inc CX + +PE_GotoNextInput11: + And BX, 63 + Cmp DX, BX + JE PE_GotoNextInput2 + + Cmp [MultiChannelInfo+BX], 0 + JE PE_GotoNextInput1 + +PE_GotoNextInput2: + Mov Channel, BX + Cmp SkipValue, 0 + JNE PE_GotoNextInput3 + + And CX, CX + JZ PE_GotoNextInput3 + + Mov Word Ptr [Modified], 101h + + Jmp PEFunction_Down + +PE_GotoNextInput10: + Cmp SkipValue, 0 + JNE PE_GotoNextInput3 + + Mov AX, Channel + Mov CX, Row + Inc AX + Cmp AX, 63 + JBE PE_GotoNextInput12 + Cmp CX, MaxRow + JAE PE_GotoNextInput3 + + Inc CX + +PE_GotoNextInput12: + And AX, 63 + Mov Row, CX + Mov Channel, AX + +PE_GotoNextInput3: + Mov Word Ptr [Modified], 101h + + Mov AX, 1 + Ret + +EndP PE_GotoNextInput + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TemplateSetup + + Mov AH, AL + Push AX + + Mov BX, Channel + Mov AX, 320 + Mov BP, MaxRow + Inc BP + Mul BP + Mov BP, AX ; BP = max offset. + + Mov AX, 64 + Mul Row + Add AX, BX + Mov CX, 5 + Mul CX + + Mov DI, AX ; DI = pattern offset. + Mov ES, PatternDataArea + Mov DS, BlockDataArea + Xor SI, SI + + LodsW + Mov DX, AX ; DX = width + LodsW + Mov CX, AX ; CX = height + + Pop AX ; AH = note. + Sub AH, [DS:4] + + Ret + +EndP TemplateSetup + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TemplateOverwrite ; AX = note + + Push DS + Push ES + + Call TemplateSetup + +PE_TemplateOverWrite1: + Push BX + Push CX + Push DI + + Mov CX, DX + +PE_TemplateOverWrite2: + Cmp BX, 64 + JAE PE_TemplateOverWrite3 + + LodsB + Cmp AL, MAXNOTE + JA PE_TemplateOverWrite6 + + Add AL, AH + Cmp AL, MAXNOTE + JBE PE_TemplateOverWrite6 + + Mov AL, NONOTE + +PE_TemplateOverWrite6: + StosB + MovsW + MovsW + Jmp PE_TemplateOverWrite4 + +PE_TemplateOverWrite3: + Add SI, 5 + Add DI, 5 + +PE_TemplateOverWrite4: + Inc BX + Loop PE_TemplateOverWrite2 + + Pop DI + Pop CX + Pop BX + Add DI, 320 + Cmp DI, BP + JAE PE_TemplateOverWrite5 + + Loop PE_TemplateOverWrite1 + +PE_TemplateOverWrite5: + Pop ES + Pop DS + Ret + +EndP PE_TemplateOverWrite + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TemplateMixPattern ; AX = note + + Push DS + Push ES + + Call TemplateSetup + +PE_TemplateMixPattern1: + Push BX + Push CX + Push DI + + Mov CX, DX + +PE_TemplateMixPattern2: + Cmp BX, 64 + JAE PE_TemplateMixPattern3 + + Mov AL, [DS:SI] + Cmp AL, MAXNOTE + JA PE_TemplateMixPattern6 + + Add AL, AH + Cmp AL, MAXNOTE + JBE PE_TemplateMixPattern6 + + Mov AL, NONOTE + +PE_TemplateMixPattern6: + Cmp Byte Ptr [ES:DI], NONOTE + JNE PE_TemplateMixPattern7 + + Mov [ES:DI], AL + +PE_TemplateMixPattern7: + Cmp Byte Ptr [ES:DI+1], 0 + JNE PE_TemplateMixPattern8 + + Mov AL, [DS:SI+1] + Mov [ES:DI+1], AL + +PE_TemplateMixPattern8: + Cmp Byte Ptr [ES:DI+2], 0FFh + JNE PE_TemplateMixPattern9 + + Mov AL, [DS:SI+2] + Mov [ES:DI+2], AL + +PE_TemplateMixPattern9: + Cmp Word Ptr [ES:DI+3], 0 + JNE PE_TemplateMixPattern3 + + Push AX + Mov AX, [DS:SI+3] + Mov [ES:DI+3], AX + Pop AX + +PE_TemplateMixPattern3: + Add SI, 5 + Add DI, 5 + +PE_TemplateMixPattern4: + Inc BX + Loop PE_TemplateMixPattern2 + + Pop DI + Pop CX + Pop BX + Add DI, 320 + Cmp DI, BP + JAE PE_TemplateMixPattern5 + + Loop PE_TemplateMixPattern1 + +PE_TemplateMixPattern5: + Pop ES + Pop DS + Ret + +EndP PE_TemplateMixPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TemplateMixClipBoard ; AX = note + + Push DS + Push ES + + Call TemplateSetup + +PE_TemplateMixClipBoard1: + Push BX + Push CX + Push DI + + Mov CX, DX + +PE_TemplateMixClipBoard2: + Cmp BX, 64 + JAE PE_TemplateMixClipBoard3 + + Mov AL, [DS:SI] + Cmp AL, MAXNOTE + JA PE_TemplateMixClipBoard6 + + Add AL, AH + Cmp AL, MAXNOTE + JBE PE_TemplateMixClipBoard6 + + Mov AL, NONOTE + +PE_TemplateMixClipBoard6: + Cmp Byte Ptr [DS:SI], NONOTE + JE PE_TemplateMixClipBoard7 + + Mov [ES:DI], AL + +PE_TemplateMixClipBoard7: + Cmp Byte Ptr [DS:SI+1], 0 + JE PE_TemplateMixClipBoard8 + + Mov AL, [DS:SI+1] + Mov [ES:DI+1], AL + +PE_TemplateMixClipBoard8: + Cmp Byte Ptr [DS:SI+2], 0FFh + JE PE_TemplateMixClipBoard9 + + Mov AL, [DS:SI+2] + Mov [ES:DI+2], AL + +PE_TemplateMixClipBoard9: + Cmp Word Ptr [DS:SI+3], 0 + JE PE_TemplateMixClipBoard3 + + Push AX + Mov AX, [DS:SI+3] + Mov [ES:DI+3], AX + Pop AX + +PE_TemplateMixClipBoard3: + Add SI, 5 + Add DI, 5 + +PE_TemplateMixClipBoard4: + Inc BX + Loop PE_TemplateMixClipBoard2 + + Pop DI + Pop CX + Pop BX + Add DI, 320 + Cmp DI, BP + JAE PE_TemplateMixClipBoard5 + + Loop PE_TemplateMixClipBoard1 + +PE_TemplateMixClipBoard5: + Pop ES + Pop DS + Ret + +EndP PE_TemplateMixClipBoard + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TemplateNotesOnly + + Push DS + Push ES + + Call TemplateSetup + +PE_TemplateNotesOnly1: + Push BP + Push BX + Push CX + Push DI + + Mov CX, DX + Mov BP, Word Ptr [CS:EditMask] + +PE_TemplateNotesOnly2: + Cmp BX, 64 + JAE PE_TemplateNotesOnly3 + + Or BP, 8 + Mov AL, [SI] + Cmp AL, MAXNOTE + JA PE_TemplateNotesOnly7 + + Add AL, AH + And BP, Not 8 + Cmp AL, MAXNOTE + JA PE_TemplateNotesOnly3 + +PE_TemplateNotesOnly7: + Mov [ES:DI], AL + + Test BP, 8 + JNZ PE_TemplateNotesOnly3 + Test BP, 1 + JZ PE_TemplateNotesOnly5 + + Mov AL, CS:LastInstrument + Mov [ES:DI+1], AL + +PE_TemplateNotesOnly5: + Test BP, 2 + JZ PE_TemplateNotesOnly6 + + Mov AL, CS:LastVolume + Mov [ES:DI+2], AL + +PE_TemplateNotesOnly6: + Test BP, 4 + JZ PE_TemplateNotesOnly3 + + Mov AX, [Word Ptr CS:LastCommand] + Mov [ES:DI+3], AX + +PE_TemplateNotesOnly3: + Add SI, 5 + Add DI, 5 + + Inc BX + Loop PE_TemplateNotesOnly2 + + Pop DI + Pop CX + Pop BX + Pop BP + + Add DI, 320 + Cmp DI, BP + JAE PE_TemplateNotesOnly4 + + Loop PE_TemplateNotesOnly1 + +PE_TemplateNotesOnly4: + Pop ES + Pop DS + + Ret + +EndP PE_TemplateNotesOnly + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_Template Far ; AX = note. + + Mov BX, BlockDataArea + Test BX, BX + JZ PEFunction_NoBlockData + + Mov ES, BX + Cmp Byte Ptr [ES:4], 119 + JBE PE_Template3 + + Mov DI, Offset O1_TemplateErrorList + Mov CX, 2 + Call M_Object1List + + Mov AX, 1 + Ret + +PE_Template3: + Mov Word Ptr [Modified], 101h + + Mov BL, Template + Cmp BL, 2 + JE PE_Template1 + JA PE_Template2 + + Call PE_TemplateOverWrite + Jmp PE_Template4 + +PE_Template1: + Call PE_TemplateMixPattern + Jmp PE_Template4 + +PE_Template2: + Cmp BL, 4 + JE PE_Template6 + + Call PE_TemplateMixClipBoard + Jmp PE_Template4 + +PE_Template6: + Call PE_TemplateNotesOnly + +PE_Template4: ; Play notes, if clipboard height = 1 + Mov CL, [ES:0] + Mov CH, [ES:2] + Call NetworkPartialPattern + + Cmp Word Ptr [ES:2], 1 ; height + JNE PE_TemplateNoPlay + + Mov AX, 64 + Mul Row + Add AX, Channel + Mov DX, 5 + Mul DX + Mov SI, AX + + Mov CX, [ES:0] ; CX = Width + Mov AX, Channel + Push DS + Mov DS, PatternDataArea + Mov DH, 32 + +PE_TemplatePlay: + Call Music_PlayNote + + Add SI, 5 + Inc AX + Dec CX + JNZ PE_TemplatePlay + + Pop DS + +PE_TemplateNoPlay: + Cmp SkipValue, 0 + JNE PE_GotoNextInput + + Mov AX, Row + Mov BX, MaxRow + Add AX, [ES:2] + Cmp AX, BX + JBE PE_Template5 + + Mov AX, BX + +PE_Template5: + Mov Row, AX + + Mov AX, 1 + Ret + +EndP PE_Template + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_NewNote Far + + Mov AX, 12 + Mul BaseOctave + Mov BX, AX + LodsW + Add AX, BX + + Cmp AX, MAXNOTE + JBE PE_NewNote5 + + Mov AX, 1 + Ret + +PE_NewNote5: + Cmp Template, 0 + JNE PE_Template + +PE_NewNote4: + Mov AH, EditMask + + Mov SI, DI + + Mov LastNote, AL + StosB + + Test AH, 1 + JZ PE_NewNote1 + + Mov AL, LastInstrument + Mov [ES:DI], AL + +PE_NewNote1: + Test AH, 2 + JZ PE_NewNote2 + + Mov AL, LastVolume + Mov [ES:DI+1], AL + +PE_NewNote2: + Test AH, 4 + JZ PE_NewNote3 + + Mov AL, LastCommand + Mov AH, LastCommandValue + Mov [ES:DI+2], AX + +PE_NewNote3: ; Play routine reqd here... + Push DS + + Push ES + Pop DS ; DS = patterndatasegment + + Mov AX, CS:Channel + Mov DH, 32 + Call Music_PlayNote + + Pop DS + + Mov CX, 101h + Call NetworkPartialPattern + +IF CHORDENTRY + Cmp ShiftPressed, 0 + JE PE_GotoNextInput + + Push SkipValue + Mov SkipValue, 0 + Mov NoteEntered, 1 + + Call PE_GotoNextInput + Pop SkipValue + + Mov AX, 1 + Ret +ELSE + Jmp PE_GotoNextInput +ENDIF + +EndP PE_NewNote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Delete Far + + Mov Word Ptr [Modified], 101h + + Mov AX, 320 + Mul MaxRow + + Call GetPatternOffset + + Mov BP, 1 + Cmp Template, 0 + JE PEFunction_Delete3 + + Cmp PatternCursor, 0 + JNE PEFunction_Delete3 + + Cmp BlockDataArea, 0 + JE PEFunction_Delete3 + + Mov FS, BlockDataArea + Cmp Word Ptr [FS:2], 1 + JNE PEFunction_Delete3 + + Mov BP, [FS:0] + +PEFunction_Delete3: + Mov CX, BP + Mov CH, Byte Ptr MaxRow + Sub CH, Byte Ptr Row + Inc CH + Call NetworkPartialPattern + + Push AX DI + + Mov SI, DI + Push ES + Pop DS ; DS:SI and ES:DI point to pat + + Add SI, 320 + Mov DX, 315 + +PEFunction_Delete1: + Cmp DI, AX + JAE PEFunction_Delete2 + + Mov CX, 5 + Rep MovsB + Add SI, DX + Add DI, DX + Jmp PEFunction_Delete1 + +PEFunction_Delete2: + Mov AX, NONOTE + StosW + Mov AL, 0FFh + StosB + Xor AX, AX + StosW + + Pop DI AX + Add DI, 5 + + Dec BP + JNZ PEFunction_Delete3 + + Mov AX, 1 + Ret + +EndP PEFunction_Delete + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Insert Far + + Mov BP, 1 + Cmp Template, 0 + JE PEFunction_Insert3 + + Cmp PatternCursor, 0 + JNE PEFunction_Insert3 + + Cmp BlockDataArea, 0 + JE PEFunction_Insert3 + + Mov FS, BlockDataArea + Cmp Word Ptr [FS:2], 1 + JNE PEFunction_Insert3 + + Mov BP, [FS:0] + +PEFunction_Insert3: + Mov Word Ptr [Modified], 101h + + Mov CX, BP + Mov CH, Byte Ptr MaxRow + Sub CH, Byte Ptr Row + Inc CH + Call NetworkPartialPattern + + Mov AX, 64 + Mul MaxRow + Add AX, Channel + Mov BX, 5 + Mul BX + Mov SI, AX + Call GetPatternOffset + Push ES + Pop DS + Mov BX, DI + Mov DX, -325 + +PEFunction_Insert4: + Push SI + + Mov DI, SI + Sub SI, 320 + +PEFunction_Insert1: + Cmp DI, BX + JBE PEFunction_Insert2 + + Mov CX, 5 + Rep MovsB + Add SI, DX + Add DI, DX + Jmp PEFunction_Insert1 + +PEFunction_Insert2: + Mov AX, NONOTE + StosW + Mov AL, 0FFh + StosB + Xor AX, AX + StosW + + Pop SI + Add SI, 5 + Add BX, 5 + + Dec BP + JNZ PEFunction_Insert4 + + Mov AX, 1 + Ret + +EndP PEFunction_Insert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_RowDelete Far + + Cmp Byte Ptr LastKeyBoard2, 0D3h + JE PEFunction_RowDelete2 + + Mov DI, 20 + Call PE_AddToUndoBuffer + +PEFunction_RowDelete2: + Mov AX, 320 + Mul Row + Mov DI, AX + + Mov CX, MaxRow + Sub CX, Row + Mov AX, 320 + Mul CX + Mov CX, AX + + Mov DS, PatternDataArea + Push DS + Pop ES + Mov SI, DI + Add SI, 320 + Rep MovsB + + Mov DX, 64 + + Push CS + Pop DS + +PEFunction_RowDelete1: + Mov CX, 5 + Mov SI, Offset EmptyData + Rep MovsB + + Dec DX + JNZ PEFunction_RowDelete1 + + Mov BL, 0 + Mov BH, Byte Ptr Row + Mov CL, 64 + Mov CH, Byte Ptr MaxRow + Sub CH, Byte Ptr Row + Inc CH + Call NetworkPatternBlock + + Mov AX, 1 + Ret + +EndP PEFunction_RowDelete + + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_RowInsert Far + + Cmp Byte Ptr LastKeyBoard2, 0D2h + JE PEFunction_RowInsert2 + + Mov DI, 19 + Call PE_AddToUndoBuffer + +PEFunction_RowInsert2: + Mov AX, 320 + Mul MaxRow + Add AX, 63*5 + Mov DI, AX + + Mov CX, MaxRow + Sub CX, Row + Mov AX, 320 + Mul CX + Mov CX, AX + + Mov DS, PatternDataArea + Push DS + Pop ES + Mov SI, DI + Sub SI, 320 + StD + Rep MovsB + ClD + + Push CS + Pop DS + + Mov AX, 320 + Mul Row + Mov DI, AX + + Mov DX, 64 + + +PEFunction_RowInsert1: + Mov CX, 5 + Mov SI, Offset EmptyData + Rep MovsB + + Dec DX + JNZ PEFunction_RowInsert1 + + Mov BL, 0 + Mov BH, Byte Ptr Row + Mov CL, 64 + Mov CH, Byte Ptr MaxRow + Sub CH, BH + Inc CH + Call NetworkPatternBlock + + Mov AX, 1 + Ret + +EndP PEFunction_RowInsert + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_DecreaseInstrument Far + + Sub LastInstrument, 1 + AdC LastInstrument, 0 + + Mov AX, 1 + Ret + +EndP PEFunction_DecreaseInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_IncreaseInstrument Far + + Cmp LastInstrument, 99 + AdC LastInstrument, 0 + + Mov AX, 1 + Ret + +EndP PEFunction_IncreaseInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_DecreaseOctave Far + + Push CS + Pop DS + + Sub BaseOctave, 1 + AdC BaseOctave, 0 + + Mov AX, 1 + Ret + +EndP PEFunction_DecreaseOctave + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_IncreaseOctave Far + + Push CS + Pop DS + + Cmp BaseOctave, 9 + AdC BaseOctave, 0 + + Mov AX, 1 + Ret + +EndP PEFunction_IncreaseOctave + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos2 Far ; Tens column of ins. + + Test CL, CL + JZ PE_PatternCursorPos2_1 + + Mov BX, Offset PE_GotoNextInput4 + Mov AL, LastInstrument + Cmp DX, ' ' + JE PE_PatternCursorPos2_2 + + Xor AL, AL + Cmp DX, '.' + JE PE_PatternCursorPos2_2 + + Cmp DX, '0' + JB PE_PatternCursorPos2_1 + + Cmp DX, '9' + JA PE_PatternCursorPos2_1 + + MovZX AX, Byte Ptr [ES:DI+1] + Mov CL, 10 + Div CL + ; AH = units/AL = tens + Mov BL, AH + Mov AL, DL + Sub AL, '0' + + Mul CL + Add AL, BL + + Mov BX, Offset PE_GotoNextInput + + Mov LastInstrument, AL + +PE_PatternCursorPos2_2: + Mov [ES:DI+1], AL + + Mov CX, 101h + Call NetworkPartialPattern + + Jmp BX + +PE_PatternCursorPos2_1: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos3 Far ; Unit column of ins. + + Test CL, CL + JZ PE_PatternCursorPos3_1 + + Mov BX, Offset PE_GotoNextInput4 + Mov AL, LastInstrument + Cmp DX, ' ' + JE PE_PatternCursorPos3_2 + + Xor AL, AL + Cmp DX, '.' + JE PE_PatternCursorPos3_2 + + Cmp DX, '0' + JB PE_PatternCursorPos3_1 + + Cmp DX, '9' + JA PE_PatternCursorPos3_1 + + MovZX AX, Byte Ptr [ES:DI+1] + Mov CL, 10 + Div CL + ; AH = units/AL = tens + Mul CL + Sub DL, '0' + Add AL, DL + + Mov BX, Offset PE_GotoNextInput + Mov LastInstrument, AL + +PE_PatternCursorPos3_2: + Mov [ES:DI+1], AL + + Mov CX, 101h + Call NetworkPartialPattern + + Jmp BX + +PE_PatternCursorPos3_1: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos4 Far ; Tens column of vol. + + Test CL, CL + JZ PE_PatternCursorPos4_1 + + Cmp DX, '`' + JE PE_VolumePan + + Mov BX, Offset PE_GotoNextInput4 + Mov AL, LastVolume + Cmp DX, ' ' + JE PE_PatternCursorPos4_9 + + Mov AL, 0FFh + Cmp DX, '.' + JE PE_PatternCursorPos4_9 + + Mov BX, Offset PE_GotoNextInput + Mov AL, [ES:DI+2] + Cmp AL, 255 + JNE PE_PatternCursorPos4_2 + + Xor AL, AL + +PE_PatternCursorPos4_2: + And AX, 7Fh + Cmp AL, 65 + JB PE_PatternCursorPos4_4 + + Sub AL, 65 + +PE_PatternCursorPos4_4: + Cmp DX, '0' + JB PE_PatternCursorPos4_5 + + Cmp DX, '9' + JA PE_PatternCursorPos4_5 + + Mov CL, 10 + Div CL + ; AH = units/AL = tens + Mov DH, AH + Mov AL, DL + Sub AL, '0' + + Mul CL + Add AL, DH + + Cmp AL, 64 + JBE PE_PatternCursorPos4_3 + + Mov AL, 64 + +PE_PatternCursorPos4_3: + Or AL, VolumePan ; Panning flag. + +PE_PatternCursorPos4_9: + Mov [ES:DI+2], AL + Mov LastVolume, AL + + Mov CX, 101h + Call NetworkPartialPattern + + Jmp BX + +PE_PatternCursorPos4_5: + Cmp DX, 'A' + JB PE_PatternCursorPos4_6 + Cmp DX, 'H' + JA PE_PatternCursorPos4_6 + Sub DX, 'A' + Jmp PE_PatternCursorPos4_7 + +PE_PatternCursorPos4_6: + Cmp DX, 'a' + JB PE_PatternCursorPos4_1 + Cmp DX, 'h' + JA PE_PatternCursorPos4_1 + + Sub DX, 'a' + +PE_PatternCursorPos4_7: + Mov CL, 10 + Div CL + Mov CH, AH + Mov AL, DL + Mul CL ; AL = tens. + + Cmp AL, 60 + JB PE_PatternCursorPos4_8 + + Add AL, 128-60 + +PE_PatternCursorPos4_8: + Add AL, 65 + Add AL, CH + Jmp PE_PatternCursorPos4_9 + +PE_PatternCursorPos4_1: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_VolumePan Far + + Xor VolumePan, 80h + Mov SI, Offset PanningControlSetMsg + + JNZ PE_VolumePan1 + + Mov SI, Offset VolumeControlSetMsg + +PE_VolumePan1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP PE_VolumePan + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos5 Far ; Unit column of vol. + + Test CL, CL + JZ PE_PatternCursorPos5_1 + + Cmp DX, '`' + JE PE_VolumePan + + Mov BX, Offset PE_GotoNextInput4 + Mov AL, LastVolume + Cmp DX, ' ' + JE PE_PatternCursorPos5_6 + + Mov AL, 0FFh + Cmp DX, '.' + JE PE_PatternCursorPos5_6 + + Mov BX, Offset PE_GotoNextInput + Cmp DX, '0' + JB PE_PatternCursorPos5_1 + + Cmp DX, '9' + JA PE_PatternCursorPos5_1 + + Mov AL, [ES:DI+2] + Cmp AL, 255 + JNE PE_PatternCursorPos5_2 + + Xor AL, AL + +PE_PatternCursorPos5_2: + And AX, 7Fh + Cmp AL, 65 + JB PE_PatternCursorPos5_4 + + Sub AL, 65 + +PE_PatternCursorPos5_4: + Mov CL, 10 + Div CL + ; AH = units/AL = tens + Mul CL + Sub DL, '0' + Add AL, DL + + Mov AH, [ES:DI+2] + Cmp AH, 255 + JE PE_PatternCursorPos5_5 + And AH, 7Fh + Cmp AH, 64 + JBE PE_PatternCursorPos5_5 + + Add AL, 65 + Test Byte Ptr [ES:DI+2], 80h + JZ PE_PatternCursorPos5_6 + Add AL, 128 + Jmp PE_PatternCursorPos5_6 + +PE_PatternCursorPos5_5: + Cmp AL, 64 + JBE PE_PatternCursorPos5_3 + + Mov AL, 64 + +PE_PatternCursorPos5_3: + Or AL, VolumePan + +PE_PatternCursorPos5_6: + Mov [ES:DI+2], AL + Mov LastVolume, AL + + Mov CX, 101h + Call NetworkPartialPattern + + Jmp BX + +PE_PatternCursorPos5_1: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos6 Far + + Test CL, CL + JZ PE_PatternCursorPos6_2 + + Mov AL, LastCommand + Cmp DX, ' ' + JE PE_PatternCursorPos6_3 + + Xor AL, AL + Cmp DX, '.' + JE PE_PatternCursorPos6_3 + + Mov AX, DX + + Cmp AX, 'a' + JB PE_PatternCursorPos6_1 + + Cmp AX, 'z' + JA PE_PatternCursorPos6_1 + + Sub AX, 32 + +PE_PatternCursorPos6_1: + Cmp AX, 'A' + JB PE_PatternCursorPos6_2 + + Cmp AX, 'Z' + JA PE_PatternCursorPos6_2 + + Sub AL, '@' + +PE_PatternCursorPos6_3: + Mov LastCommand, AL + Mov [ES:DI+3], AL + + Mov CX, 101h + Call NetworkPartialPattern + + Jmp PE_GotoNextInput + +PE_PatternCursorPos6_2: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos6 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos7 Far + + Test CL, CL + JZ PE_PatternCursorPos7_3 + + Mov BX, Offset PE_GotoNextInput4 + Xor AL, AL + Cmp DX, '.' + JE PE_PatternCursorPos7_5 + + Mov AL, LastCommandValue + Cmp DX, ' ' + JE PE_PatternCursorPos7_5 + + Mov BX, Offset PE_GotoNextInput + Mov AX, DX + Cmp AX, 'a' + JB PE_PatternCursorPos7_1 + + Cmp AX, 'f' + JA PE_PatternCursorPos7_1 + + Sub AX, 32 + +PE_PatternCursorPos7_1: + Cmp AX, 'A' + JB PE_PatternCursorPos7_2 + + Cmp AX, 'F' + JA PE_PatternCursorPos7_2 + + Sub AX, 'A'-10 + Jmp PE_PatternCursorPos7_4 + +PE_PatternCursorPos7_2: + Cmp AX, '0' + JB PE_PatternCursorPos7_3 + + Cmp AX, '9' + JA PE_PatternCursorPos7_3 + + Sub AX, '0' + +PE_PatternCursorPos7_4: + Mov AH, AL + Mov AL, [ES:DI+4] + SHL AH, 4 + And AL, 0Fh + Or AL, AH + +PE_PatternCursorPos7_5: + Mov [ES:DI+4], AL + Mov LastCommandValue, AL + + Mov CX, 101h + Call NetworkPartialPattern + + Jmp BX + +PE_PatternCursorPos7_3: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos7 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PatternCursorPos8 Far + + Test CL, CL + JZ PE_PatternCursorPos8_3 + + Mov BX, Offset PE_GotoNextInput4 + Xor AH, AH + Cmp DX, '.' + JE PE_PatternCursorPos8_5 + + Mov AH, LastCommandValue + Cmp DX, ' ' + JE PE_PatternCursorPos8_5 + + Mov BX, Offset PE_GotoNextInput + Mov AX, DX + Cmp AX, 'a' + JB PE_PatternCursorPos8_1 + + Cmp AX, 'f' + JA PE_PatternCursorPos8_1 + + Sub AX, 32 + +PE_PatternCursorPos8_1: + Cmp AX, 'A' + JB PE_PatternCursorPos8_2 + + Cmp AX, 'F' + JA PE_PatternCursorPos8_2 + + Sub AX, 'A'-10 + Jmp PE_PatternCursorPos8_4 + +PE_PatternCursorPos8_2: + Cmp AX, '0' + JB PE_PatternCursorPos7_3 + + Cmp AX, '9' + JA PE_PatternCursorPos7_3 + + Sub AX, '0' + +PE_PatternCursorPos8_4: + Mov AH, [ES:DI+4] + And AH, 0F0h + Or AH, AL + +PE_PatternCursorPos8_5: + Mov [ES:DI+4], AH + Mov LastCommandValue, AH + + Mov CX, 101h + Call NetworkPartialPattern + + Jmp BX + +PE_PatternCursorPos8_3: + Xor AX, AX + Ret + +EndP PE_PatternCursorPos8 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_SetCommandCursor Far + + Push CS + Pop ES + Mov DI, Offset CommandToValue +; Mov AL, [SI+24] +; Mov CS:CommandToValue, AL + + Ret + +EndP PE_SetCommandCursor + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_MarkBeginBlock Far + + Mov AX, Channel + Mov BX, Row + +PEFunction_MarkBeginBlockChain: + Cmp BlockMark, 0 + JNE PEFunction_MarkBeginBlock1 + + Mov BlockMark, 1 + Mov BlockLeft, AX + Mov BlockRight, AX + Mov BlockTop, BX + Mov BlockBottom, BX + Jmp PEFunction_MarkBeginBlock5 + +PEFunction_MarkBeginBlock1: + Cmp AX, BlockRight + JBE PEFunction_MarkBeginBlock2 + + Mov CX, BlockRight + Mov BlockRight, AX + Mov BlockLeft, CX + Jmp PEFunction_MarkBeginBlock3 + +PEFunction_MarkBeginBlock2: + Mov BlockLeft, AX + +PEFunction_MarkBeginBlock3: + Cmp BX, BlockBottom + JBE PEFunction_MarkBeginBlock4 + + Mov CX, BlockBottom + Mov BlockBottom, BX + Mov BlockTop, CX + Jmp PEFunction_MarkBeginBlock5 + +PEFunction_MarkBeginBlock4: + Mov BlockTop, BX + +PEFunction_MarkBeginBlock5: + Mov AX, 1 + Ret + +EndP PEFunction_MarkBeginBlock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_MarkEndBlock Far + + Mov AX, Channel + Mov BX, Row + +PEFunction_MarkEndChain: + Cmp BlockMark, 0 + JNE PEFunction_MarkEndBlock1 + + Mov BlockMark, 1 + Mov BlockLeft, AX + Mov BlockRight, AX + Mov BlockTop, BX + Mov BlockBottom, BX + Jmp PEFunction_MarkEndBlock5 + +PEFunction_MarkEndBlock1: + Cmp AX, BlockLeft + JAE PEFunction_MarkEndBlock2 + + Mov CX, BlockLeft + Mov BlockLeft, AX + Mov BlockRight, CX + Jmp PEFunction_MarkEndBlock3 + +PEFunction_MarkEndBlock2: + Mov BlockRight, AX + +PEFunction_MarkEndBlock3: + Cmp BX, BlockTop + JAE PEFunction_MarkEndBlock4 + + Mov CX, BlockTop + Mov BlockTop, BX + Mov BlockBottom, CX + Jmp PEFunction_MarkEndBlock5 + +PEFunction_MarkEndBlock4: + Mov BlockBottom, BX + +PEFunction_MarkEndBlock5: + Mov AX, 1 + Ret + +EndP PEFunction_MarkEndBlock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_AltD Far + + Mov AX, Channel + Mov BX, Row + MovZX DX, RowHiLight2 + + Cmp Word Ptr [LastKeyBoard2+2], 2000h + JNE PEFunction_AltD1 + ; OK, at least 1 Alt-D already.. + ; Now double length... + Mov DX, BlockBottom + Sub DX, BlockTop + Inc DX + Add DX, DX + Add DX, BlockTop + Dec DX + Cmp DX, MaxRow + JBE PEFunction_AltD3 + + Mov DX, MaxRow + +PEFunction_AltD3: + Mov BlockBottom, DX + Jmp PEFunction_AltD4 + +PEFunction_AltD1: + Dec DX + Mov BlockTop, BX + Mov BlockLeft, AX + Mov BlockRight, AX + + Add BX, DX + Cmp BX, MaxRow + JBE PEFunction_AltD2 + + Mov BX, MaxRow + +PEFunction_AltD2: + Mov BlockBottom, BX + Mov BlockMark, 1 + +PEFunction_AltD4: + Mov AX, 1 + Ret + +EndP PEFunction_AltD + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_AltS Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Cmp [Word Ptr LastKeyBoard2+2], 1F00h + JE PEFunction_AltS5 + Call NetworkBlock + + Mov DI, 12 + Call PE_AddToUndoBuffer + +PEFunction_AltS5: + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + + Mov SI, AX + Inc SI + + Mov AH, LastInstrument + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + + Mov DS, PatternDataArea + +PEFunction_AltS1: + Push SI + Push CX + + Mov CX, DX + +PEFunction_AltS2: + Cmp Byte Ptr [SI], 0 + JE PEFunction_AltS3 + + Mov [SI], AH + +PEFunction_AltS3: + Add SI, 5 + Loop PEFunction_AltS2 + + Pop CX + Pop SI + Add SI, 320 + Loop PEFunction_AltS1 + +PEFunction_AltS4: + Mov AX, 1 + Ret + +EndP PEFunction_AltS + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEGetVolume ; Given DL = note, DH = instrument + ; Returns DL, Carry if none + + Push AX BX DI DS + + Cmp DL, MAXNOTE + JA PEGetVolumeError + + Call Music_GetSongSegment + Mov DS, AX + + Mov BL, DH + And BX, 0FFh + JZ PEGetVolumeError + Add BX, BX + + Test Byte Ptr [DS:2Ch], 4 + JZ PEGetVolumeSample + + Mov DI, DX + Mov BX, [DS:64710+BX] + And DI, 0FFh ; Note + Add DI, DI + Mov BX, [DS:BX+DI+41h] + And BX, 0FFh ; BX = sample + JZ PEGetVolumeError + Add BX, BX + +PEGetVolumeSample: + Mov BX, [DS:64910+BX] + Mov DL, [BX+13h] + + DB 85h ; +PEGetVolumeError: ; + StC ; + +PEGetVolumeEnd: + Pop DS DI BX AX + Ret + +EndP PEGetVolume + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_AltK Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Cmp [Word Ptr LastKeyBoard2+2], 2500h + JNE PEFunction_AltK7 + + Cmp [Word Ptr LastKeyBoard3+2], 2500h + JE PEFunction_AltK11 + + Mov DI, 8 + Call PE_AddToUndoBuffer + Call NetworkBlock + + ; OK.. wipe volume data... + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov DI, AX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + + Mov ES, PatternDataArea +; Add DI, 2 + ScasW + + Mov AL, 0FFh + +PEFunction_AltK12: + Push CX + Push DI + + Mov CX, DX + +PEFunction_AltK13: + StosB + Add DI, 4 + Loop PEFunction_AltK13 + + Pop DI + Pop CX + Add DI, 320 + Loop PEFunction_AltK12 + +PEFunction_AltK11: + Mov AX, 1 + Ret + +PEFunction_AltK7: + Mov DI, 7 + Call PE_AddToUndoBuffer + Call NetworkBlock + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov SI, AX + + Mov AX, 64 + Mul BlockBottom + Add AX, BlockLeft + Mul BX + Mov DI, AX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov CX, BlockBottom + Sub CX, BlockTop + JZ PEFunction_AltK2 ; CX contains number of rows + +; Add SI, 2 +; Add DI, 2 + LodsW + ScasW + Mov DS, PatternDataArea + +PEFunction_AltK1: + Push CX + Push DX + Push SI + +; AltK6 = don't slide. + + MovZX AX, Byte Ptr [DI] + Cmp AL, 0FFh + JNE PEFunction_KVolume1 + + Mov DX, [DI-2] + Call PEGetVolume + JC PEFunction_AltK6 + MovZX AX, DL + +PEFunction_KVolume1: + MovZX BX, Byte Ptr [SI] + Cmp BL, 0FFh + JNE PEFunction_KVolume2 + + Mov DX, [SI-2] + Call PEGetVolume + JC PEFunction_AltK6 + MovZX BX, DL + +PEFunction_KVolume2: ; Now BOTH AL and BL are pan + ; Or BOTH AL and BL are volume + Mov DL, AL + Mov DH, BL + + And DX, 7F7Fh + Cmp DL, 64 + JA PEFunction_AltK6 + Cmp DH, 64 + JA PEFunction_AltK6 + + Mov DL, AL + Mov DH, BL + + And DX, 8080h + JZ PEFunction_AltK14 + Cmp DX, 8080h + JNE PEFunction_AltK6 + +PEFunction_AltK14: + Mov [DI], AL + Mov [SI], BL + + Sub AX, BX ; AX = change. + JS PEFunction_AltK4 + + Div CL + Mov BH, AL + Xor AL, AL + Div CL + Mov BL, AL + + Xor AL, AL + Jmp PEFunction_AltK5 + + +PEFunction_AltK4: + Neg AX + Div CL + Mov BH, AL + Xor AL, AL + Div CL + Mov BL, AL + Neg BX + + Mov AL, 0FFh + +PEFunction_AltK5: + Mov AH, [SI] + +PEFunction_AltK3: + Mov [SI], AH + + Add AX, BX + Add SI, 320 + Loop PEFunction_AltK3 + +PEFunction_AltK6: + Pop SI + Pop DX + Pop CX + Add SI, 5 + Add DI, 5 + Dec DX + JNZ PEFunction_AltK1 + +PEFunction_AltK2: + Mov AX, 1 + Ret + +EndP PEFunction_AltK + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_AltL Far + + Call Music_GetLastChannel ; AX = max channel. + Mov BX, MaxRow + + Cmp [Word Ptr LastKeyBoard2+2], 2600h + JNE PEFunction_AltL1 + + Xor CX, CX + Cmp CX, BlockTop + JNE PEFunction_AltL2 + Cmp CX, BlockLeft + JNE PEFunction_AltL2 + Cmp BlockRight, AX + JNE PEFunction_AltL2 + Cmp BX, BlockBottom + JNE PEFunction_AltL2 + Jmp PEFunction_AltL1 + +PEFunction_AltL2: + Xor CX, CX + Mov BlockTop, CX + Mov BlockLeft, CX + Mov BlockRight, AX + Mov BlockBottom, BX + Jmp PEFunction_AltL3 + +PEFunction_AltL1: + Mov AX, Channel + Mov BlockTop, 0 + Mov BlockLeft, AX + Mov BlockRight, AX + Mov BlockBottom, BX + +PEFunction_AltL3: + Mov BlockMark, 1 + + Mov AX, 1 + Ret + +EndP PEFunction_AltL + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_WipeBlock Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Cmp [Word Ptr LastKeyBoard2+2], 2C00h + JE PEFunction_WipeBlock1 + + Mov DI, 18 + Call PE_AddToUndoBuffer + Call NetworkBlock + + Cmp Template, 0 + JNE PEFunction_WipeBlock4 + + Push DS + Call PEFunction_BlockCopy + Pop DS + +PEFunction_WipeBlock4: + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov DI, AX + + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov ES, PatternDataArea + +PEFunction_WipeBlock2: + Push DI + Push CX + + Mov CX, DX + +PEFunction_WipeBlock3: + Mov AX, NONOTE + StosW + Mov AL, 0FFh + StosB + Xor AX, AX + StosW + Loop PEFunction_WipeBlock3 + + Pop CX + Pop DI + Add DI, 320 + Loop PEFunction_WipeBlock2 + +PEFunction_WipeBlock1: + Mov AX, 1 + Ret + +EndP PEFunction_WipeBlock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_RollUp Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov SI, AX + + Mov BP, BlockBottom + Sub BP, BlockTop + JZ PEFunction_RollUpEnd + + Call NetworkBlock + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + Mov AX, 5 + Mul DX + + Mov CX, AX + + Push CS + Pop ES + Mov DI, Offset TempData + Mov DS, PatternDataArea + + Push SI + Rep MovsB + Pop DI + + Push DS + Pop ES + LEA SI, [DI+320] + +PEFunction_RollUp1: + Push SI + Push DI + + Mov CX, AX + Rep MovsB + + Pop DI + Pop SI + Add SI, 320 + Add DI, 320 + + Dec BP + JNZ PEFunction_RollUp1 + + Push CS + Pop DS + Mov SI, Offset TempData + Mov CX, AX + Rep MovsB + +PEFunction_RollUpEnd: + Mov AX, 1 + Ret + +EndP PEFunction_RollUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_RollDown Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Mov AX, 64 + Mul BlockBottom + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov SI, AX + + Mov BP, BlockBottom + Sub BP, BlockTop + JZ PEFunction_RollDownEnd + + Call NetworkBlock + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + Mov AX, 5 + Mul DX + + Mov CX, AX + + Push CS + Pop ES + Mov DI, Offset TempData + Mov DS, PatternDataArea + + Push SI + Rep MovsB + Pop DI + + Push DS + Pop ES + LEA SI, [DI-320] + +PEFunction_RollDown1: + Push SI + Push DI + + Mov CX, AX + Rep MovsB + + Pop DI + Pop SI + Sub SI, 320 + Sub DI, 320 + + Dec BP + JNZ PEFunction_RollDown1 + + Push CS + Pop DS + Mov SI, Offset TempData + Mov CX, AX + Rep MovsB + +PEFunction_RollDownEnd: + Mov AX, 1 + Ret + +EndP PEFunction_RollDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BlockHalve Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Mov DI, 5 + Call PE_AddToUndoBuffer + + Mov BL, Byte Ptr BlockLeft + Mov BH, Byte Ptr BlockTop + Mov CH, Byte Ptr MaxRow + Mov CL, Byte Ptr BlockRight + Sub CX, BX + Add CX, 101h + Call NetworkPatternBlock + + Mov AX, 320 + Mul BlockTop + Mov BX, AX + Mov AX, 5 + Mul BlockLeft + Add BX, AX + Mov SI, BX + Mov DI, BX + + Mov DX, BlockBottom + Sub DX, BlockTop + Inc DX + + Mov CX, BlockRight + Sub CX, BlockLeft + Inc CX + + Mov AX, BlockTop + + Mov DS, PatternDataArea + Push DS + Pop ES + +PEFunction_BlockHalve1: + Push AX + Push CX + Push DX + Push SI + Push DI + + Cmp AX, CS:MaxRow + JBE PEFunction_BlockHalve3 + +PEFunction_BlockHalve2: + Mov AX, NONOTE + StosW + Mov AL, 0FFh + StosB + Xor AX, AX + StosW + Loop PEFunction_BlockHalve2 + + Jmp PEFunction_BlockHalve4 + +PEFunction_BlockHalve3: + Mov AX, 5 + Mul CX + Mov CX, AX + Rep MovsB + +PEFunction_BlockHalve4: + + Pop DI + Pop SI + Pop DX + Pop CX + Pop AX + Add SI, 640 + Add DI, 320 + Add AX, 2 + Dec DX + JNZ PEFunction_BlockHalve1 + + Mov AX, 1 + Ret + +EndP PEFunction_BlockHalve + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BlockDouble Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Mov DI, 4 + Call PE_AddToUndoBuffer + + Mov BL, Byte Ptr BlockLeft + Mov BH, Byte Ptr BlockTop + Mov CH, Byte Ptr MaxRow + Mov CL, Byte Ptr BlockRight + Sub CX, BX + Add CX, 101h + Call NetworkPatternBlock + + Mov AX, 320 + Mov CX, BlockBottom + Mul CX + Mov SI, AX + Add CX, CX ; CX = 2*number of rows+2*top + Sub CX, BlockTop ; CX = 2*number of rows+top + Inc CX + Mov AX, 320 + Mul CX + Mov DI, AX + + Push CX ; CX = output row. + + Mov CX, BlockRight + Sub CX, BlockLeft + Inc CX + + Mov AX, 5 + Mul BlockLeft + Add SI, AX + Add DI, AX + + Pop DX ; DX = output row + + Mov DS, PatternDataArea + Push DS + Pop ES + +PEFunction_BlockDouble1: + Push DI + + Cmp DX, CS:MaxRow + JA PEFunction_BlockDouble2 + ; Empty stuff now.. + Push CX + +PEFunction_BlockDouble4: + Mov AX, NONOTE + StosW + Mov AL, 0FFh + StosB + Xor AX, AX + StosW + Loop PEFunction_BlockDouble4 + + Pop CX + +PEFunction_BlockDouble2: + Pop DI + Sub DI, 320 + Dec DX + + Push SI + Push DI + Cmp DX, CS:MaxRow + JA PEFunction_BlockDouble3 + + Push CX + Push DX + + Mov AX, 5 + Mul CX + Mov CX, AX + Rep MovsB + + Pop DX + Pop CX + +PEFunction_BlockDouble3: + Pop DI + Pop SI + Sub SI, 320 + Sub DI, 320 + + Cmp DX, CS:BlockTop + JBE PEFunction_BlockDouble5 + + Dec DX + Jmp PEFunction_BlockDouble1 + +PEFunction_BlockDouble5: + Mov AX, 1 + Ret + +EndP PEFunction_BlockDouble + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BlockSwap Far ; Alt-H... sorry. + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + ; Check that boundaries + ; are OK.. + + ; 1. Check that vertices of new block + ; don't lie in old block. + ; 2. Check that 2nd block < channels + ; and 2nd block < maxrow. + + Mov AX, Channel + Mov BX, Row + Call Near Ptr PEFunction_BlockSwap1 + Add AX, BlockRight + Sub AX, BlockLeft + Call Near Ptr PEFunction_BlockSwap1 + Add BX, BlockBottom + Sub BX, BlockTop + Call Near Ptr PEFunction_BlockSwap1 + Mov AX, Channel + Call Near Ptr PEFunction_BlockSwap1 + Jmp PEFunction_BlockSwap3 + +PEFunction_BlockSwap1: + Cmp AX, BlockLeft + JB PEFunction_BlockSwap2 + Cmp AX, BlockRight + JA PEFunction_BlockSwap2 + + Cmp BX, BlockTop + JB PEFunction_BlockSwap2 + Cmp BX, BlockBottom + JA PEFunction_BlockSwap2 + + ; Uh oh... cursor is in block. + + Mov DI, Offset O1_OverlapBlockList + Mov CX, 2 + Call M_Object1List + + Pop AX ; Clear stack + Mov AX, 1 + RetF + +PEFunction_BlockSwap2: + RetN + +PEFunction_BlockSwap3: + Mov DI, 17 + Call PE_AddToUndoBuffer + Call NetworkBlock + + Mov BL, Byte Ptr Channel + Mov BH, Byte Ptr Row + Mov CL, Byte Ptr BlockRight + Mov CH, Byte Ptr BlockBottom + Sub CL, Byte Ptr BlockLeft + Sub CH, Byte Ptr BlockTop + Add CX, 101h + Call NetworkPatternBlock + + + Mov AX, Channel + Mov BX, Row + + Mov CX, BlockRight + Sub CX, BlockLeft + Inc CX ; CX = block width. + Add AX, CX + Cmp AX, 64 + JA PEFunction_BlockSwap4 + + Mov DX, BlockBottom + Sub DX, BlockTop ; DX = block height-1. + Add BX, DX + Cmp BX, MaxRow + JBE PEFunction_BlockSwap5 + +PEFunction_BlockSwap4: + Mov DI, Offset O1_SwapOutOfRangeList + Mov CX, 2 + Call M_Object1List + + Mov AX, 1 + Ret + +PEFunction_BlockSwap5: ; Do swap. + Mov AX, 320 + Mul BlockTop + Mov BX, AX + Mov AX, 5 + Mul BlockLeft + Add BX, AX + Mov SI, BX ; SI = "marked" block + + Call GetPatternOffset ; DI = implied block +; Mov AX, 320 +; Mul Row +; Mov BX, AX +; Mov AX, 5 +; Mul Channel +; Add BX, AX +; Mov SI, BX ; SI = implied block. + + Mov CX, BlockRight + Sub CX, BlockLeft + Inc CX ; CX = width of block. + Mov AX, 5 + Mul CX + Mov CX, AX + + Mov DX, BlockBottom + Sub DX, BlockTop + Inc DX ; DX = height of block + +; Mov ES, PatternDataArea + Push ES + Pop DS + +PEFunction_BlockSwap6: + Push CX + Push DX + Push SI + Push DI + +PEFunction_BlockSwap7: + Mov AL, [DS:DI] + MovsB + Mov [DS:SI-1], AL + Loop PEFunction_BlockSwap7 + + Pop DI + Pop SI + Pop DX + Pop CX + Add SI, 320 + Add DI, 320 + Dec DX + JNZ PEFunction_BlockSwap6 + + Mov AX, 1 + Ret + +EndP PEFunction_BlockSwap + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BlockCopy Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Mov AX, BlockDataArea + And AX, AX + JZ PEFunction_BlockCopy1 + + Mov ES, AX + Mov AH, 49h + Int 21h + +PEFunction_BlockCopy1: + Mov AX, BlockBottom + Sub AX, BlockTop + Inc AX + + Mov BX, BlockRight + Sub BX, BlockLeft + Inc BX + Mul BX + Mov BX, 5 + Mul BX + ; AX = size of block + Mov BX, AX + Add BX, 19 ; + space for width/height + ShR BX, 4 + Mov AH, 48h + Int 21h + JNC PEFunction_BlockCopy2 + + Jmp PEFunction_OutOfMemoryMessage + +PEFunction_BlockCopy2: + Mov BlockDataArea, AX + Xor DI, DI + Mov ES, AX + + Mov AX, BlockRight + Sub AX, BlockLeft + Inc AX + StosW + Mov BX, 5 + Mul BX + Mov DX, AX ; DX = width*5 + + Mov AX, BlockBottom + Sub AX, BlockTop + Inc AX + StosW + Mov CX, AX ; CX = height + + Push DX + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mul BX + Mov SI, AX + + Pop DX + Mov DS, PatternDataArea + +PEFunction_BlockCopy3: + Push SI + Push CX + + Mov CX, DX + Rep MovsB + + Pop CX + Pop SI + Add SI, 320 + Loop PEFunction_BlockCopy3 + + Mov AX, 1 + Ret + +EndP PEFunction_BlockCopy + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_NoBlockMarkedMessage Far + + Mov DI, Offset O1_NoBlockMarkedList + Mov CX, 2 + Call M_Object1List + + Mov AX, 1 + Ret + +EndP PEFunction_NoBlockMarkedMessage + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_OutOfMemoryMessage Far + + Call PE_FillHeader + Call S_SaveScreen + + Mov DI, Offset O1_OutOfMemoryList + Mov CX, 2 + Call M_Object1List + + Call S_RestoreScreen + + Mov AX, 1 + Ret + +EndP PEFunction_OutOfMemoryMessage + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_NoBlockData Far + + Mov DI, Offset O1_NoBlockDataList + Mov CX, 2 + Call M_Object1List + + Mov AX, 1 + Ret + +EndP PEFunction_NoBlockData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BlockOverWrite Far + + Mov AX, BlockDataArea + And AX, AX + JZ PEFunction_NoBlockData + + Cmp [Word Ptr LastKeyBoard2+2], 1800h + JE PEFunction_BlockOverWrite5 + + Mov DI, 10 + Call PE_AddToUndoBuffer + + Mov ES, AX + Mov CL, [ES:0] + Mov CH, [ES:2] + Call NetworkPartialPattern + +PEFunction_BlockOverWrite6: + + Mov BP, MaxRow + Mov BX, Row + Mov CX, Channel + + Call GetPatternOffset + + Mov DS, AX + + Mov SI, 4 ; DS:SI points to block + + Mov AX, CX + Mov DX, [DS:0] + Mov CX, [DS:2] ; DX = width, CX = height + +PEFunction_BlockOverWrite1: + Push AX + Push CX + Push DX + Push DI + +PEFunction_BlockOverWrite2: + Cmp AX, 63 + JA PEFunction_BlockOverWrite3 + + Mov CX, 5 + Rep MovsB + + Jmp PEFunction_BlockOverWrite4 + +PEFunction_BlockOverWrite3: + Add SI, 5 + +PEFunction_BlockOverWrite4: + Inc AX ; AX = channel + Dec DX + JNZ PEFunction_BlockOverWrite2 + + Pop DI + Pop DX + Pop CX + Pop AX + Add DI, 320 + Inc BX + Cmp BX, BP + JA PEFunction_BlockOverWrite5 + + Loop PEFunction_BlockOverWrite1 + +PEFunction_BlockOverWrite5: + Mov AX, 1 + Ret + +EndP PEFunction_BlockOverWrite + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BlockPaste Far + + Mov AX, BlockDataArea + And AX, AX + JZ PEFunction_NoBlockData + + Cmp [Word Ptr LastKeyBoard2+2], 1900h + JE PEFunction_BlockPaste6 + + Mov DI, 11 + Call PE_AddToUndoBuffer + +PEFunction_BlockPaste6: + Push DS + Mov BP, MaxRow + + Mov ES, AX + + Mov CH, Byte Ptr MaxRow + Sub CH, Byte Ptr Row + Inc CH + Mov CL, [ES:0] + Call NetworkPartialPattern + + Mov BX, [ES:0] ; width + Mov CX, [ES:2] ; height + +; Condition: +; If Row == 0 && Channel == 0 && height > MaxRow && width > 1, then set maxrow = height + Cmp CX, BP + JB PEFunction_BlockPaste7 + + Mov AX, Channel + Or AX, Row + JNZ PEFunction_BlockPaste7 + + Cmp BX, 1 + JBE PEFunction_BlockPaste7 + + Mov BP, CX + Dec BP + Mov MaxRow, BP + +PEFunction_BlockPaste7: + Mov AX, 64 + Mul BP + Add AX, Channel + Mov DX, 5 + Mul DX + Mov SI, AX + Mov DI, AX + + Mov AX, 320 + Mul CX + Add DI, AX ; DI has destination... + + Mov AX, Channel + Mov DS, PatternDataArea + Push DS + Pop ES + +PEFunction_BlockPaste1: + Push AX + Push CX + Push SI + Push DI + + Mov AX, CS:Row + Add AX, CX + Mov DX, BP + Add DX, CX + +PEFunction_BlockPaste5: + Cmp DX, BP + JA PEFunction_BlockPaste3 + + Mov CX, 5 + Rep MovsB + Sub SI, 325 + Sub DI, 325 + + Jmp PEFunction_BlockPaste4 + +PEFunction_BlockPaste3: + Sub SI, 320 + Sub DI, 320 + +PEFunction_BlockPaste4: + Dec DX + Cmp DX, AX + JAE PEFunction_BlockPaste5 + + Pop DI + Pop SI + Pop CX + Pop AX + + Add SI, 5 + Add DI, 5 + Inc AX + Cmp AX, 63 + JA PEFunction_BlockPaste2 + + Dec BX + JNZ PEFunction_BlockPaste1 + +PEFunction_BlockPaste2: + Pop DS + + Mov AX, BlockDataArea + Jmp PEFunction_BlockOverWrite6 + +EndP PEFunction_BlockPaste + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_SecondBlockMix Far + + Mov BP, MaxRow + Mov BX, Row + Mov CX, Channel + + Call GetPatternOffset + + Mov DS, BlockDataArea + + Mov SI, 4 ; DS:SI points to block + + Mov AX, CX + + Mov CL, [DS:0] + Mov CH, [DS:2] + Call NetworkPartialPattern + + Mov DX, [DS:0] + Mov CX, [DS:2] ; DX = width, CX = height + +PEFunction_SecondBlockMix1: + Push AX + Push CX + Push DX + Push DI + +PEFunction_SecondBlockMix2: + Cmp AX, 63 + JA PEFunction_SecondBlockMix3 + + Cmp Byte Ptr [ES:DI], NONOTE ; Note + JNE PEFunction_SecondBlockMix7 + + Mov CL, [DS:SI] + Mov [ES:DI], CL + +PEFunction_SecondBlockMix7: + Inc SI + Inc DI + + Cmp Byte Ptr [ES:DI], 0 ; Instrument + JNE PEFunction_SecondBlockMix8 + + Mov CL, [DS:SI] + Mov [ES:DI], CL + +PEFunction_SecondBlockMix8: + Inc SI + Inc DI + + Cmp Byte Ptr [ES:DI], 0FFh ; Volume + JNE PEFunction_SecondBlockMix9 + + Mov CL, [DS:SI] + Mov [ES:DI], CL + +PEFunction_SecondBlockMix9: + Inc SI + Inc DI + + Cmp Byte Ptr [ES:DI], 0 ; Command + JNE PEFunction_SecondBlockMix10 + + Mov CL, [DS:SI] + Mov [ES:DI], CL + +PEFunction_SecondBlockMix10: + Inc SI + Inc DI + + Cmp Byte Ptr [ES:DI], 0 ; Commandvalue + JNE PEFunction_SecondBlockMix11 + + Mov CL, [DS:SI] + Mov [ES:DI], CL + +PEFunction_SecondBlockMix11: + Inc SI + Inc DI + Jmp PEFunction_SecondBlockMix4 + +PEFunction_SecondBlockMix3: + Add SI, 5 + +PEFunction_SecondBlockMix4: + Inc AX ; AX = channel + Dec DX + JNZ PEFunction_SecondBlockMix2 + + Pop DI + Pop DX + Pop CX + Pop AX + Add DI, 320 + Inc BX + Cmp BX, BP + JA PEFunction_SecondBlockMix5 + + Loop PEFunction_SecondBlockMix1 + +PEFunction_SecondBlockMix5: + Mov AX, 1 + Ret + +EndP PEFunction_SecondBlockMix + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BlockMix Far + + Cmp BlockDataArea, 0 + JE PEFunction_NoBlockData + + Cmp [Word Ptr LastKeyBoard2+2], 3200h + JNE PEFunction_BlockMix1 + + Cmp [Word Ptr LastKeyboard3+2], 3200h + JE PEFunction_BlockMix6 + + Jmp PEFunction_SecondBlockMix + +PEFunction_BlockMix1: + Mov DI, 9 + Call PE_AddToUndoBuffer + Call NetworkBlock + + Mov BP, MaxRow + Mov BX, Row + Mov CX, Channel + + Call GetPatternOffset + + Mov DS, BlockDataArea + Mov SI, 4 ; DS:SI points to block + + Mov AX, CX + + Mov CL, [DS:0] + Mov CH, [DS:2] + Call NetworkPartialPattern + + Mov DX, [DS:0] + Mov CX, [DS:2] ; DX = width, CX = height + +PEFunction_BlockMix2: + Push AX + Push CX + Push DX + Push DI + +PEFunction_BlockMix3: + Cmp AX, 63 + JA PEFunction_BlockMix4 + + Cmp DWord Ptr [ES:DI], NONOTE + 0FF0000h + JNE PEFunction_BlockMix7 + Cmp Byte Ptr [ES:DI+4], 0 + JNE PEFunction_BlockMix7 + + Mov CX, 5 + Rep MovsB + + Jmp PEFunction_BlockMix5 + +PEFunction_BlockMix7: + Add DI, 5 + +PEFunction_BlockMix4: + Add SI, 5 + +PEFunction_BlockMix5: + Inc AX ; AX = channel + Dec DX + JNZ PEFunction_BlockMix3 + + Pop DI + Pop DX + Pop CX + Pop AX + Add DI, 320 + Inc BX + Cmp BX, BP + JA PEFunction_BlockMix6 + + Loop PEFunction_BlockMix2 + +PEFunction_BlockMix6: + Mov AX, 1 + Ret + +EndP PEFunction_BlockMix + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_UnMarkBlock Far + + Cmp BlockMark, 0 + JZ PEFunction_UnMarkBlock1 + + Mov BlockMark, 0 + Jmp PEFunction_UnMarkBlock2 + +PEFunction_UnMarkBlock1: + Mov AX, BlockDataArea + And AX, AX + JZ PEFunction_NoBlockData + + Mov ES, AX + Mov AH, 49h + Int 21h + + Mov BlockDataArea, 0 +PEFunction_UnMarkBlock2: + Mov AX, 1 + Ret + +EndP PEFunction_UnMarkBlock + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_SemiUp Far + + Cmp [Word Ptr LastKeyBoard2+2], 1000h + JE PEFunction_SemiUp6 + + Mov DI, 2 + Call PE_AddToUndoBuffer + +PEFunction_SemiUp6: + Cmp BlockMark, 0 + JNE PEFunction_SemiUp4 + + Mov CX, 101h + Call NetworkPartialPattern + + Mov AX, 64 + Mul Row + Add AX, Channel + Mov BX, 5 + Mul BX + Mov SI, AX + Mov CX, 1 + Mov DX, CX + Jmp PEFunction_SemiUp5 + +PEFunction_SemiUp4: + Call NetworkBlock + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX ; AX = start offset + + Mov SI, AX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + +PEFunction_SemiUp5: + Mov DS, PatternDataArea + +PEFunction_SemiUp1: + Push DX + Push SI + +PEFunction_SemiUp2: + Cmp Byte Ptr [SI], 119 + JAE PEFunction_SemiUp3 + + Inc Byte Ptr [SI] + +PEFunction_SemiUp3: + Add SI, 5 + Dec DX + JNZ PEFunction_SemiUp2 + + Pop SI + Pop DX + Add SI, 320 + Loop PEFunction_SemiUp1 + + Mov AX, 1 + Ret + +EndP PEFunction_SemiUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_SemiDown Far + + Cmp [Word Ptr LastKeyBoard2+2], 1E00h + JE PEFunction_SemiDown6 + + Mov DI, 3 + Call PE_AddToUndoBuffer + +PEFunction_SemiDown6: + Cmp BlockMark, 0 + JNE PEFunction_SemiDown4 + + Mov CX, 101h + Call NetworkPartialPattern + + Mov AX, 64 + Mul Row + Add AX, Channel + Mov BX, 5 + Mul BX + Mov SI, AX + Mov CX, 1 + Mov DX, CX + Jmp PEFunction_SemiDown5 + +PEFunction_SemiDown4: + Call NetworkBlock + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX ; AX = start offset + + Mov SI, AX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + +PEFunction_SemiDown5: + Mov DS, PatternDataArea + +PEFunction_SemiDown1: + Push DX + Push SI + +PEFunction_SemiDown2: + Cmp Byte Ptr [SI], 0 + JLE PEFunction_SemiDown3 + + Dec Byte Ptr [SI] + +PEFunction_SemiDown3: + Add SI, 5 + Dec DX + JNZ PEFunction_SemiDown2 + + Pop SI + Pop DX + Add SI, 320 + Loop PEFunction_SemiDown1 + + Mov AX, 1 + Ret + +EndP PEFunction_SemiDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_SlideCommand Far + + Mov DI, 15 + Call PE_AddToUndoBuffer + Call NetworkBlock + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov SI, AX + + Mov AX, 64 + Mul BlockBottom + Add AX, BlockLeft + Mul BX + Mov DI, AX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov CX, BlockBottom + Sub CX, BlockTop + JZ PEFunction_AltX2 ; CX contains number of rows + + Add SI, 4 + Add DI, 4 + Mov DS, PatternDataArea + +PEFunction_AltX1: + Push CX + Push DX + Push SI + + MovZX AX, Byte Ptr [DI] + MovZX BX, Byte Ptr [SI] + Sub AX, BX ; AX = change. + JS PEFunction_AltX4 + + Div CL + Mov BH, AL + Xor AL, AL + Div CL + Mov BL, AL + + Xor AL, AL + Jmp PEFunction_AltX5 + + +PEFunction_AltX4: + Neg AX + Div CL + Mov BH, AL + Xor AL, AL + Div CL + Mov BL, aL + Neg BX + + Mov AL, 0FFh + +PEFunction_AltX5: + Mov AH, [SI] + +PEFunction_AltX3: + Mov [SI], AH + + Add AX, BX + Add SI, 320 + Loop PEFunction_AltX3 + + Pop SI + Pop DX + Pop CX + Add SI, 5 + Add DI, 5 + Dec DX + JNZ PEFunction_AltX1 + +PEFunction_AltX2: + Mov AX, 1 + Ret + +EndP PEFunction_SlideCommand + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_WipeCommands Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Cmp [Word Ptr LastKeyBoard2+2], 2D00h + JE PEFunction_WipeCommands4 + + Jmp PEFunction_SlideCommand + +PEFunction_WipeCommands4: + Cmp [Word Ptr LastKeyBoard3+2], 2D00h + JE PEFunction_WipeCommands6 + + Mov DI, 16 + Call PE_AddToUndoBuffer + Call NetworkBlock + +PEFunction_WipeCommands6: + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov DI, AX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + + Mov ES, PatternDataArea + Add DI, 3 + + Xor AX, AX + +PEFunction_WipeCommands2: + Push CX + Push DI + + Mov CX, DX + +PEFunction_WipeCommands3: + StosW + Add DI, 3 + Loop PEFunction_WipeCommands3 + + Pop DI + Pop CX + Add DI, 320 + Loop PEFunction_WipeCommands2 + +PEFunction_WipeCommands1: + Mov AX, 1 + Ret + +EndP PEFunction_WipeCommands + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_VolumeAmp Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Test CentraliseCursor, 4 + JZ PENoFast1 + + Mov AX, FastVolumeAmplification + Mov Amplification, AX + Jmp PEFastVolumeAmp + +PENoFast1: + Cmp Amplification, 200 + JBE PENoFast2 + + Mov Amplification, 200 + +PENoFast2: + Push DS + + Mov DI, Offset O1_GetAmpList + Mov CX, 3 + Call M_Object1List + + Pop DS + + Cmp DX, 1 + JNE PEFunction_VolumeAmp1 + +PEFastVolumeAmp: + Mov DI, 6 + Call PE_AddToUndoBuffer + Call NetworkBlock + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov SI, AX + + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov BP, Amplification + Mov BX, 100 +; Mov BH, 100 ; For division + + Mov DS, PatternDataArea + Add SI, 2 + + Call Music_GetSongSegment + Mov ES, AX + +PEFunction_VolumeAmp2: + Push CX + Push DX + Push SI + + Mov CX, DX + +PEFunction_VolumeAmp3: + Mov AL, [SI] + Cmp AL, 0FFh + JNE PEFunction_VolumeAmp6 + + Mov DI, [SI-1] + And DI, 0FFh + JZ PEFunction_VolumeAmp4 + ; OK.. find whether inst/sample + ; then get default vol. + Call Music_GetInstrumentMode + JZ PEFunction_VolumeAmp7 + + Add DI, DI + Mov DI, [ES:64712+DI-2] + Mov AL, [SI-2] + And AX, 0FFh + JZ PEFunction_VolumeAmp4 + Add AX, AX + Add DI, AX + Mov DI, [ES:DI+41h] + And DI, 0FFh + JZ PEFunction_VolumeAmp4 + +PEFunction_VolumeAmp7: + Dec DI + Add DI, DI + Mov DI, [ES:64912+DI] + Mov AL, [ES:DI+13h] + +PEFunction_VolumeAmp6: + Cmp AL, 64 + JA PEFunction_VolumeAmp4 + + Xor AH, AH + Push DX + + Mul BP + Div BX + + Pop DX + + Cmp AX, 64 + JBE PEFunction_VolumeAmp5 + + Mov AL, 64 + +PEFunction_VolumeAmp5: + Mov [SI], AL + +PEFunction_VolumeAmp4: + Add SI, 5 + Loop PEFunction_VolumeAmp3 + + Pop SI + Pop DX + Pop CX + Add SI, 320 + Loop PEFunction_VolumeAmp2 + +PEFunction_VolumeAmp1: + Mov AX, 1 + Ret + +EndP PEFunction_VolumeAmp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetPatternLength + + Push AX + Push BX + Push CX + Push DS + Push SI + Push ES + Push DI + + Call ClearEncodingInfo + ; OK, masks are reset. + + Mov CX, CS:MaxRow + Inc CX + Mov DX, CX ; DX = count of bytes. + ; End of row bytes added. + + Mov DS, CS:PatternDataArea + Xor SI, SI ; SI = pattern area. + + Mov DI, Offset EncodingInfo ; ES:DI points to encoding info + +GetPatternLength1: + Push CX + Push DI + + Mov CX, 64 + +GetPatternLength2: + Cmp Word Ptr [SI], NONOTE + JNE GetPatternLength4 + Cmp Byte Ptr [SI+2], 0FFh + JNE GetPatternLength4 + Cmp Word Ptr [SI+3], 0 + JE GetPatternLength3 + +GetPatternLength4: + Inc DX ; 1 byte for channel + ; indication + JZ GetPatternLength13 + ; AH will be mask + MovZX AX, Byte Ptr [SI] ; Note + Cmp AL, NONOTE + JE GetPatternLength5 + Cmp AL, [ES:DI+1] ; 5 is note. + JE GetPatternLength12 + + Mov [ES:DI+1], AL + Inc DX + JZ GetPatternLength13 + Or AH, 1 + Jmp GetPatternLength5 + +GetPatternLength12: + Or AH, 16 + +GetPatternLength5: + Mov AL, [SI+1] ; Instrument + And AL, AL + JZ GetPatternLength7 + + Cmp AL, [ES:DI+2] + JE GetPatternLength6 + + Mov [ES:DI+2], AL + Inc DX + JZ GetPatternLength13 + Or AH, 2 + Jmp GetPatternLength7 + +GetPatternLength6: + Or AH, 32 + +GetPatternLength7: + Mov AL, [SI+2] ; Volume + Cmp AL, 0FFh + JE GetPatternLength8 + + Cmp AL, [ES:DI+3] + JE GetPatternLength9 + + Mov [ES:DI+3], AL + Inc DX + JZ GetPatternLength13 + Or AH, 4 + Jmp GetPatternLength8 + +GetPatternLength9: + Or AH, 64 + +GetPatternLength8: + Mov BX, [SI+3] + And BX, BX + JZ GetPatternLength11 + Cmp BX, [ES:DI+4] + JE GetPatternLength10 + + Mov [ES:DI+4], BX + + Inc DX + JZ GetPatternLength13 + Inc DX + JZ GetPatternLength13 + Or AH, 8 + + Jmp GetPatternLength11 + +GetPatternLength10: + Or AH, 128 + +GetPatternLength11: + Cmp AH, [ES:DI] + JE GetPatternLength3 + + Inc DX + JZ GetPatternLength13 + Mov [ES:DI], AH + +GetPatternLength3: + + Add SI, 5 + Add DI, 6 + Loop GetPatternLength2 + + Pop DI + Pop CX + Loop GetPatternLength1 + + Pop DI + Pop ES + Pop SI + Pop DS + Pop CX + Pop BX + Pop AX + + Ret + +GetPatternLength13: + Mov DI, Offset O1_PatternTooLongList + Mov CX, 2 + Call M_Object1List + + Add SP, 22 ; yes! + Mov AX, 1 + RetF + +EndP GetPatternLength + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +IF SHOWPATTERNLENGTH + +Proc PE_ShowPatternLength Far + + Push AX ; Just for stack length.. + Call GetPatternLength + Pop AX + + Mov AX, Object1 + Push AX + Mov DS, AX + Mov AX, Offset O1_ShowPatternLengthList + Push AX + Mov SI, Offset PatternLength + Mov [SI], DX + Call M_FunctionHandler + + Mov AX, 1 + Ret + +EndP PE_ShowPatternLength + +ENDIF + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +DecodePatternBytes DW 0 +DecodePatternOffset DW 0 + +Proc DecodePattern ; DS:SI points to pattern info to decode + + PushA + Push DS + Push ES + +; Call ClearEncodingInfo ; Should be unnecess. + + + Push CS + Pop ES + Mov BX, Offset EncodingInfo + + LodsW ; AX = number of bytes + Mov CS:DecodePatternBytes, AX + LodsW ; AX = maxrow + Mov CX, AX + Dec AX + Mov CS:MaxRow, AX + LodsW + LodsW + + Mov CS:DecodePatternOffset, SI + + Call PE_ClearPatternData + + Mov ES, CS:PatternDataArea + Xor DI, DI + +DecodePattern1: + Push CX + +DecodePattern5: + LodsB ; AL = channel byte. + Test AL, AL + JZ DecodePattern2 + + Push BX + Push DI + + Mov CX, AX + Dec CX + And CX, 63 + + ; DI = DI + Channel*5 + ; BX = EncodingInfo + Channel*6 + + LEA BX, [ECX*4+ECX] + LEA DI, [DI+BX] + LEA BX, [EBX+ECX+EncodingInfo] + + Test AL, 128 + JZ DecodePattern3 + + Mov DL, [SI] + Inc SI + + Mov [CS:BX], DL + Jmp DecodePattern4 + +DecodePattern3: + Mov DL, [CS:BX] ; DL = mask + +DecodePattern4: + Test DL, 1 + JZ DecodePattern13 + + LodsB + + Mov [ES:DI], AL + Mov [CS:BX+1], AL + Jmp DecodePattern6 + +DecodePattern13: + Test DL, 16 + JZ DecodePattern6 + + Mov AL, [CS:BX+1] + Mov [ES:DI], AL + +DecodePattern6: + Test DL, 2 + JZ DecodePattern7 + + LodsB + + Mov [ES:DI+1], AL + Mov [CS:BX+2], AL + Jmp DecodePattern8 + +DecodePattern7: + Test DL, 32 + JZ DecodePattern8 + + Mov AL, [CS:BX+2] + Mov [ES:DI+1], AL + +DecodePattern8: + Test DL, 4 + JZ DecodePattern9 + + LodsB + + Mov [ES:DI+2], AL + Mov [CS:BX+3], AL + Jmp DecodePattern10 + +DecodePattern9: + Test DL, 64 + JZ DecodePattern10 + + Mov AL, [CS:BX+3] + Mov [ES:DI+2], AL + +DecodePattern10: + Test DL, 8 + JZ DecodePattern11 + + LodsW + + Mov [ES:DI+3], AX + Mov [CS:BX+4], AX + Jmp DecodePattern12 + +DecodePattern11: + Test DL, 128 + JZ DecodePattern12 + + Mov AX, [CS:BX+4] + Mov [ES:DI+3], AX + +DecodePattern12: + Pop DI + Pop BX + Jmp DecodePattern5 + +DecodePattern2: + Pop CX + Add DI, 320 + Loop DecodePattern1 + + Sub SI, CS:DecodePatternOffset + Cmp SI, CS:DecodePatternBytes + JE DecodePatternEnd + + Mov CX, 0FFFFh + Mov DI, Offset O1_PatternSizeMismatchList + Call M_Object1List + +DecodePatternEnd: + Pop ES + Pop DS + PopA + + Call Music_UpdatePatternOffset + + Ret + +EndP DecodePattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc EncodePattern ; ES:DI points to area to deposit data + ; DX = length of data + + Push AX + Push BX + Push CX + Push DX + Push DS + Push SI + + Push ES + Push DI + + Call ClearEncodingInfo + + Pop DI + Pop ES + + Mov BX, Offset EncodingInfo + + Mov AX, DX + StosW + + Mov CX, CS:MaxRow + Inc CX + + Mov AX, CX + StosW + + Xor AX, AX + StosW + StosW ; This is the header. + + Xor SI, SI + Mov DS, CS:PatternDataArea + +EncodePattern1: + Push BX + Push CX + + Xor DX, DX ; DL = channelnumber + ; DH is used as mask val. + Mov CX, 64 + +EncodePattern2: + Cmp Word Ptr [SI], NONOTE + JNE EncodePattern3 + Cmp Byte Ptr [SI+2], 0FFh + JNE EncodePattern8 + Cmp Word Ptr [SI+3], 0 + JE EncodePattern4 + Jmp EncodePattern10 + +EncodePattern3: + Mov AL, [SI] + Cmp AL, NONOTE + JE EncodePattern5 + Cmp AL, [CS:BX+1] ; 1=note + JE EncodePattern6 + + Mov [CS:BX+1], AL + Or DH, 1 + Jmp EncodePattern5 + +EncodePattern6: + Or DH, 16 + +EncodePattern5: + Mov AL, [SI+1] + And AL, AL + JZ EncodePattern8 + Cmp AL, [CS:BX+2] ; 2=ins + JE EncodePattern7 + + Mov [CS:BX+2], AL + Or DH, 2 + Jmp EncodePattern8 + +EncodePattern7: + Or DH, 32 + +EncodePattern8: + Mov AL, [SI+2] + Cmp AL, 0FFh + JE EncodePattern10 + Cmp AL, [CS:BX+3] ; 3=vol + JE EncodePattern9 + + Mov [CS:BX+3], AL + Or DH, 4 + Jmp EncodePattern10 + +EncodePattern9: + Or DH, 64 + +EncodePattern10: + Mov AX, [SI+3] + Test AX, AX + JZ EncodePattern12 + Cmp AX, [CS:BX+4] ; 4=effect + JE EncodePattern11 + + Mov [CS:BX+4], AX + Or DH, 8 + Jmp EncodePattern12 + +EncodePattern11: + Or DH, 128 + +EncodePattern12: + Mov AL, DL + Inc AX + + Cmp [CS:BX], DH ; 0 = mask + JE EncodePattern13 + + Mov [CS:BX], DH + Or AL, 128 ; read another mask... + StosB + Mov AL, DH + StosB + Jmp EncodePattern14 + +EncodePattern13: + StosB + +EncodePattern14: + Test DH, 1 + JZ EncodePattern15 + + Mov AL, [SI] + StosB + +EncodePattern15: + Test DH, 2 + JZ EncodePattern16 + + Mov AL, [SI+1] + StosB + +EncodePattern16: + Test DH, 4 + JZ EncodePattern17 + + Mov AL, [SI+2] + StosB + +EncodePattern17: + Test DH, 8 + JZ EncodePattern18 + + Mov AX, [SI+3] + StosW + +EncodePattern18: + Xor DH, DH + +EncodePattern4: + Add SI, 5 + Add BX, 6 + Inc DX + Loop EncodePattern2 + + Pop CX + Pop BX + Xor AL, AL + StosB + Loop EncodePattern1 + + Pop SI + Pop DS + Pop DX + Pop CX + Pop BX + Pop AX + Ret + +EndP EncodePattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_StorePattern + +IF NETWORKENABLED + Cmp PatternModified, 0 + JE PEFunction_StorePattern5 + + Mov AX, PatternNumber + ShL AX, 8 + Add AX, NETWORK_ENTIREPATTERNOBJECT + Call Network_AddWordToQueue + +PEFunction_StorePattern5: +ENDIF + + Mov AX, PatternNumber + Mov SI, AX + Call Music_ReleasePattern + + Call GetPatternLength + Cmp DX, 64 + JNE PEFunction_StorePattern1 + Cmp CS:MaxRow, 63 + JE PEFunction_StorePattern2 + +PEFunction_StorePattern1: + Add DX, 8 + JC PEFunction_StorePattern4 + + ClI + + Call Music_AllocatePattern + Mov AX, ES + And AX, AX + JZ PEFunction_StorePattern3 + Sub DX, 8 + Call EncodePattern + + StI + +PEFunction_StorePattern2: + Ret + +PEFunction_StorePattern3: + StI + + Add SP, 2 + Jmp PEFunction_OutOfMemoryMessage + +PEFunction_StorePattern4: + Mov DI, Offset O1_PatternTooLongList + Mov CX, 2 + Call M_Object1List + + Pop AX + Mov AX, 1 + RetF + +EndP PEFunction_StorePattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_StoreCurrentPattern Far + + Push CS + Pop DS + Call PEFunction_StorePattern + + Mov AX, 1 + Ret + +EndP PEFunction_StoreCurrentPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc NewPattern ; Reqs. AX = pattern + +IF NETWORKENABLED + Call Network_UpdatePattern +ENDIF + Call Music_GetPattern + Call DecodePattern + + Mov CS:PatternModified, 0 + Mov AH, CS:Byte Ptr PatternNumber + Mov AL, 22 + Mov DI, AX +; Mov DI, 22 + Call PE_AddToUndoBuffer + + Ret + +EndP NewPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_GotoPattern Far ; AX = pattern. + + Push CS + Pop DS + + Mov Row, BX + Mov Channel, CX + +PE_GotoPattern2: + Cmp PatternModified, 0 + JE PE_GotoPattern1 + + Mov TempVariableArea, AX + Call PEFunction_StorePattern + Mov AX, TempVariableArea + +PE_GotoPattern1: + Mov PatternNumber, AX + Call NewPattern + + Jmp Glbl_F2 + +EndP PE_GotoPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +include pe_trans.inc + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_NextPattern Far + + Cmp TracePlayback, 0 + JE PEFunction_NextPatternNoTrace + + Call Music_GetPlayMode + Cmp AX, 1 + JE PEFunction_NextPattern1 + JB PEFunction_NextPatternNoTrace + + Call Music_NextOrder + Jmp PEFunction_NextPattern1 + +PEFunction_NextPatternNoTrace: + Cmp PatternNumber, 199 + JAE PEFunction_NextPattern1 + + Cmp PatternModified, 0 + JE PEFunction_NextPattern2 + + Call PEFunction_StorePattern + +PEFunction_NextPattern2: + Inc PatternNumber + Mov AX, PatternNumber + + Call NewPattern + +PEFunction_NextPattern1: + Mov AX, 1 + Ret + +EndP PEFunction_NextPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_LastPattern Far + + Cmp TracePlayback, 0 + JE PEFunction_LastPatternNoTrace + + Call Music_GetPlayMode + Cmp AX, 1 + JE PEFunction_LastPattern1 + JB PEFunction_LastPatternNoTrace + + Call Music_LastOrder + Jmp PEFunction_LastPattern1 + +PEFunction_LastPatternNoTrace: + Cmp PatternNumber, 0 + JE PEFunction_LastPattern1 + + Cmp PatternModified, 0 + JE PEFunction_LastPattern2 + + Call PEFunction_StorePattern + +PEFunction_LastPattern2: + Dec PatternNumber + Mov AX, PatternNumber + + Call NewPattern + +PEFunction_LastPattern1: + Mov AX, 1 + Ret + +EndP PEFunction_LastPattern +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Next4Patterns Far + + Cmp PatternModified, 0 + JE PEFunction_Next4Patterns2 + + Call PEFunction_StorePattern + +PEFunction_Next4Patterns2: + Mov AX, PatternNumber + Add AX, 4 + Cmp AX, 199 + JBE PEFunction_Next4Patterns1 + + Mov AX, 199 + +PEFunction_Next4Patterns1: + Mov PatternNumber, AX + + Call NewPattern + + Mov AX, 1 + Ret + +EndP PEFunction_Next4Patterns + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Last4Patterns Far + + Cmp PatternModified, 0 + JE PEFunction_Last4Patterns2 + + Call PEFunction_StorePattern + +PEFunction_Last4Patterns2: + Mov AX, PatternNumber + Sub AX, 4 + JNS PEFunction_Last4Patterns1 + + Xor AX, AX + +PEFunction_Last4Patterns1: + Mov PatternNumber, AX + + Call NewPattern + + Mov AX, 1 + Ret + +EndP PEFunction_Last4Patterns + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_LastOrderPattern Far + + Cmp PatternModified, 0 + JE PEFunction_LastOrderPattern3 + + Call PEFunction_StorePattern + +PEFunction_LastOrderPattern3: + Call Music_GetSongSegment + Mov ES, AX + + Mov BX, Order + And BX, BX + JZ PEFunction_LastOrderPattern2 + + Cmp Byte Ptr [ES:BX+0FFh], 200 + JAE PEFunction_LastOrderPattern2 + + Dec BX + Mov Order, BX + +PEFunction_LastOrderPattern2: + MovZX AX, Byte Ptr [ES:BX+0100h] + Cmp AL, 200 + JAE PEFunction_LastOrderPattern1 + + Mov PatternNumber, AX + + Call NewPattern + +PEFunction_LastOrderPattern1: + Mov AX, 1 + Ret + +EndP PEFunction_LastOrderPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_NextOrderPattern Far + + Cmp PatternModified, 0 + JE PEFunction_NextOrderPattern3 + + Call PEFunction_StorePattern + +PEFunction_NextOrderPattern3: + Mov BX, Order + + Cmp BX, 0FFh + JAE PEFunction_NextOrderPattern1 + + Call Music_GetSongSegment + Mov ES, AX + Cmp Byte Ptr [ES:BX+101h], 200 + JAE PEFunction_NextOrderPattern2 + + Inc BX + Mov Order, BX + +PEFunction_NextOrderPattern2: + MovZX AX, Byte Ptr [ES:BX+100h] + Cmp AL, 200 + JAE PEFunction_NextOrderPattern1 + + Mov PatternNumber, AX + + Call NewPattern + +PEFunction_NextOrderPattern1: + Mov AX, 1 + Ret + +EndP PEFunction_NextOrderPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Alt0 Far + + Xor AX, AX + Mov SkipValue, AX + Mov SI, Offset CursorStepMsg + Call SetInfoLine + + Inc AX + + Ret + +EndP PEFunction_Alt0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_BlockVolume Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Cmp [Word Ptr LastKeyBoard2], 2F00h + JE PEFunction_BlockVolume3 + + Mov DI, 13 + Call PE_AddToUndoBuffer + Call NetworkBlock + +PEFunction_BlockVolume3: + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + + Mov SI, AX + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov AL, LastVolume + + Mov DS, PatternDataArea + Add SI, 2 + +PEFunction_BlockVolume1: + Push CX + Push SI + + Mov CX, DX + +PEFunction_BlockVolume2: + Mov [SI], AL + + Add SI, 5 + Loop PEFunction_BlockVolume2 + + Pop SI + Pop CX + Add SI, 320 + Loop PEFunction_BlockVolume1 + + Mov AX, 1 + Ret + +EndP PEFunction_BlockVolume + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_WipeExcessVolumes Far + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + Cmp [Word Ptr LastKeyBoard2+2], 1100h + JE PEFunction_WipeExcessVolumesEnd + + Mov DI, 14 + Call PE_AddToUndoBuffer + Call NetworkBlock + + Mov AX, 64 + Mul BlockTop + Add AX, BlockLeft + Mov BX, 5 + Mul BX + Mov SI, AX + + Mov CX, BlockBottom + Sub CX, BlockTop + Inc CX + + Mov DX, BlockRight + Sub DX, BlockLeft + Inc DX + + Mov DS, PatternDataArea + Mov AL, 0FFh + +PEFunction_WipeExcessVolumes1: + Push CX + Push SI + + Mov CX, DX + +PEFunction_WipeExcessVolumes2: + Cmp Byte Ptr [SI+1], 0 + JNE PEFunction_WipeExcessVolumes3 + + Cmp Byte Ptr [SI], NONOTE + JAE PEFunction_WipeExcessVolumes4 + +PEFunction_WipeExcessVolumes3: + Add SI, 5 + Loop PEFunction_WipeExcessVolumes2 + + Pop SI + Pop CX + Add SI, 320 + Loop PEFunction_WipeExcessVolumes1 + +PEFunction_WipeExcessVolumesEnd: + Mov AX, 1 + Ret + +PEFunction_WipeExcessVolumes4: + Mov [SI+2], AL + Jmp PEFunction_WipeExcessVolumes3 + +EndP PEFunction_WipeExcessVolumes + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_PlayCurrentNote Far + + Mov AX, 64 + Mul Row + Add AX, Channel + Mov BX, 5 + Mul BX + Mov SI, AX + Mov AX, Channel + Mov DS, PatternDataArea + Mov DH, 32 + Call Music_PlayNote + +IF CHORDENTRY + Push CS + Pop DS + + Cmp ShiftPressed, 0 + JE PE_GotoNextInput + + Push SkipValue + Mov SkipValue, 0 + Mov NoteEntered, 1 + + Call PE_GotoNextInput + Pop SkipValue + + Mov AX, 1 + Ret +ELSE + Jmp PEFunction_Down +ENDIF + +EndP PEFunction_PlayCurrentNote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_PlayCurrentRow Far + + Mov CX, 64 + Mov DS, PatternDataArea + + Mov AX, 320 + Mul CS:Row + Mov SI, AX + Xor AX, AX + +PEFunction_PlayCurrentRow1: +; Push CX + +; Dec CX +; Mov AX, 64 +; Mul CS:Row +; Add AX, CX +; Mov BX, 5 +; Mul BX +; Mov SI, AX +; Mov AX, CX + Xor DH, DH + Call Music_PlayNote + +; Pop CX + Inc AX + Add SI, 5 + Loop PEFunction_PlayCurrentRow1 + + Jmp PEFunction_Down + +EndP PEFunction_PlayCurrentRow + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_RestoreData Far + +; Mov PatternModified, 0 + + Cmp Byte Ptr LastKeyBoard2, 0Eh + JE PEFunction_RestoreData1 + + Mov DI, 1 + Call PE_AddToUndoBuffer + +PEFunction_RestoreData1: + Mov AX, PatternNumber + + Call Music_GetPattern + Call DecodePattern + + Xor BX, BX + Mov CL, 64 + Mov CH, Byte Ptr [CS:MaxRow] + Inc CH + Call NetworkPatternBlock + + Mov AX, 1 + Ret + + Ret + +EndP PEFunction_RestoreData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_ToggleDefaultVolume Far + + Xor Flags, 1 + Mov SI, Offset DefaultVolumeOn + Test Flags, 1 + JNZ PEFunction_ToggleDefaultVolume1 + + Mov SI, Offset DefaultVolumeOff + +PEFunction_ToggleDefaultVolume1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP PE_ToggleDefaultVolume + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ToggleTemplate Far + + Test CentraliseCursor, 4 + JZ ToggleTemplate2 + + Cmp BlockMark, 0 + JE PEFunction_NoBlockMarkedMessage + + ; Amplification = 1/(FastVolumeAmplification/100) + ; = 10050/FastvolumeAmplification + Mov AX, 10050 + Xor DX, DX + Div FastVolumeAmplification + Mov Amplification, AX + Jmp PEFastVolumeAmp + +ToggleTemplate2: + Mov AL, Template + Inc AX + Cmp AL, 4 + JBE PEFunction_ToggleTemplate1 + +Proc PEFunction_TemplateOff Far + + Xor AL, AL + +PEFunction_ToggleTemplate1: + Mov Template, AL + + Mov AX, 1 + Ret + +EndP PEFunction_TemplateOff + +EndP PEFunction_ToggleTemplate + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_GetCurrentPattern Far + + Mov AX, CS:PatternNumber + Mov BX, CS:MaxRow + Inc BX + Mov DS, CS:PatternDataArea + + Ret + +EndP PE_GetCurrentPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_CheckWidth + + Xor DX, DX ; Time to work out width + Xor CX, CX ; Count of channels. + Mov SI, Offset ViewChannels + +PE_CheckWidth1: + LodsW + Cmp AL, 0FFh + JE PE_CheckWidth2 + + MovZX BX, AH + ShL BX, 2 + Add DX, [ViewMethodInfo+BX+2] + Inc CX + Jmp PE_CheckWidth1 + +PE_CheckWidth2: + And CX, CX + JZ PE_CheckWidth3 + + Add DX, 2 + + Cmp ViewDivision, 0 + JE PE_CheckWidth3 + + Dec CX + Add DX, CX + +PE_CheckWidth3: + Cmp DX, 76 ; Too big to fit screen? + JAE PE_CheckWidth5 + + Mov ViewWidth, DX + Xor AX, AX + Cmp DX, 74 + JAE PE_CheckWidth4 + + Mov AX, 74 + Sub AX, DX + Mov BL, 14 + Div BL + Xor AH, AH + +PE_CheckWidth4: + Mov NumChannelsEdit, AX + + DB 85h ; +PE_CheckWidth5: ; + StC ; + Ret + +EndP PE_CheckWidth + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ViewTrack Far + + Mov DX, Channel + Mov SI, Offset ViewChannels + +PEFunction_ViewTrack2: + LodsW + Cmp AL, 0FFh ; No more in list?? + JE PEFunction_ViewTrack1 + + Cmp AL, DL + JNE PEFunction_ViewTrack2 + +PEFunction_ViewTrack1: + Sub SI, 2 + + Mov CX, AX ; Store old value. + Mov AL, DL + Inc AH + Cmp AH, 4 ; Number of view methods + JBE PEFunction_ViewTrack3 + + LodsW + +PEFunction_ViewTrack8: + LodsW + Mov [SI-4], AX + Cmp AX, 0FFFFh + JNE PEFunction_ViewTrack8 + + Jmp PEFunction_ViewTrack9 + +PEFunction_ViewTrack3: + Mov [SI], AX ; Update... + +PEFunction_ViewTrack9: + Push CX + Push SI + + Call PE_CheckWidth + JC PEFunction_ViewTrack7 + + Add SP, 4 + Mov AX, 1 + Ret + +PEFunction_ViewTrack7: + Pop SI + Pop CX + Mov AX, [SI] + Inc AH + Cmp AH, 4 ; Number of view methods + JE PEFunction_ViewTrack10 + + Mov [SI], AX + + Jmp PEFunction_ViewTrack9 + +PEFunction_ViewTrack10: + Mov [SI], CX + + Mov AX, 1 + Ret + +EndP PEFunction_ViewTrack + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ClearViews Far + + Push CS + Pop ES + Mov DI, Offset ViewChannels + Mov CX, 100 + Mov AX, 0FFFFh + Rep StosW + + Mov ViewWidth, 0 + Mov AX, StartChannelEdit + Mov NumChannelsEdit, AX + Mov ViewChannelTracking, 0 + + Mov AX, 1 + Ret + +EndP PEFunction_ClearViews + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_SelectColour Near + + MovZX AX, CL ; AL = row number + + Mov CH, 0E6h + Cmp CS:RowHilight2, 0 + JE PE_SelectColour4 + Div CS:RowHilight2 + And AH, AH + JZ PE_SelectColour1 + +PE_SelectColour4: + MovZX AX, CL + Mov CH, 0F6h + Cmp CS:RowHilight1, 0 + JE PE_SelectColour5 + Div CS:RowHiLight1 + And AH, AH + JZ PE_SelectColour1 + +PE_SelectColour5: + Mov CH, 6 + +PE_SelectColour1: ; Check for block, CL = rownum, BP = ch + MovZX AX, CL ; AX = row number + Cmp CS:BlockMark, 0 + JE PE_SelectColour3 + Cmp BP, CS:BlockLeft + JB PE_SelectColour3 + Cmp BP, CS:BlockRight + JA PE_SelectColour3 + Cmp AX, CS:BlockTop + JB PE_SelectColour3 + Cmp AX, CS:BlockBottom + JA PE_SelectColour3 + + Test CH, 80h + JZ PE_SelectColour2 + + Mov CH, 96h + Ret + +PE_SelectColour2: + Mov CH, 86h + Ret + +PE_SelectColour3: + Cmp AX, CS:Row + JNE PE_SelectColour6 + + Test CS:CentraliseCursor, 2 + JZ PE_SelectColour6 + + Mov CH, 16h + +PE_SelectColour6: + Ret + +EndP PE_SelectColour + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_HilightCursor Near + + Mov AX, [ES:DI] + And AH, 8 + Or AH, 30h + StosW + + Ret + +EndP PE_HilightCursor + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_HilightView Near + + Mov AX, 1 + Cmp CS:Template, 0 + JE PE_HilightView1 + + Cmp CS:ShiftPressed, 0 + JNE PE_HilightView1 + + Cmp CS:PatternCursor, 0 + JNE PE_HilightView1 + + Cmp CS:BlockDataArea, 0 + JE PE_HilightView1 + + Mov FS, CS:BlockDataArea + Mov AX, [FS:0] + +PE_HilightView1: + Mov CX, CS:Channel + Cmp DX, CX + JB PE_HilightViewEnd + Add CX, AX + Cmp DX, CX + JAE PE_HilightViewEnd + + Sub DI, (32*160) + Mov AL, 160 + Mov CX, CS:Row + Sub CX, CS:TopRow + Mul CL + Add DI, AX + Add BP, CS:PatternCursor + + Mov CL, Byte Ptr [CS:BP] + Mov AX, CX + And AX, 0Fh + + Add AX, AX + Add DI, AX + + Mov DX, [ES:DI] + Test DH, 8 + JNZ PE_HilightView4 + Cmp DL, 184 + JE PE_HilightView4 + Cmp DL, 226 + JB PE_HilightView2 + Cmp DL, 246 + JAE PE_HilightView2 + +PE_HilightView4: + Mov AH, 0Fh ; mask value + Cmp CL, Byte Ptr [CS:BP+1] + JE PE_HilightView3 + + Mov AH, 0F0h + +PE_HilightView3: + Call S_InvertCursor + + Mov AX, 246+3000h + StosW + +PE_HilightViewEnd: + Ret + +PE_HilightView2: + Mov AX, [ES:DI] + Mov AH, 30h + StosW + + Sub CL, 10h + JNC PE_HilightView2 + + Ret + +EndP PE_HilightView + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_GetChannelColour ; Puts colour in AH + ; Param: BP = channel + + Push DS + + Call Music_GetSongSegment + Mov DS, AX + + Mov AH, 13h + Test Byte Ptr [DS:BP+40h], 80h + JZ PE_GetChannelColour1 + + Mov AH, 10h + +PE_GetChannelColour1: + Pop DS + + Ret + +EndP PE_GetChannelColour + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ViewCommon + + Push DS + Push ES + Push DI + + Mov BP, DX + And BP, 0FFh + + Push CS + Pop DS + MovZX AX, DL + Inc AX + Mov DX, 0A0Ch + Div DH +; Mov DL, 10 +; Div DL + + Add AX, 3030h + Mov [SI+BX], AX + Sub DI, 160 + Call PE_GetChannelColour + Call S_DrawString + + Pop DI + Pop ES + Pop DS + +; Mov DX, 0A0Ch ; DH = 10, DL = 12 (for div.) + + Mov CH, 32 + + Ret + +EndP ViewCommon + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + + +Proc ViewFull ; DS:SI = pattern data + ; ES:DI = screen pointer + ; CS:BX = note data + ; CX = row number + ; DL = channel number. + + Push SI + Push BX + + Mov SI, Offset ChannelMsg + Mov BX, 9 + Call ViewCommon + + Pop BX + Pop SI + +ViewFull1: + Push CX + Push DX + Push DI + + Call PE_SelectColour + + LodsB + Call Draw_3Note + Mov AL, 20h + StosW + + LodsB ; Instrument + Call Draw_2Instrument + Mov AL, 20h + StosW + + LodsB ; Volume + Cmp AL, 0FFh + JNE ViewFull8 + + Mov AL, 173 + StosW + StosW + + Jmp ViewFull9 + +ViewFull8: + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC ViewFullNoVEffect + + Test AL, 80h + JZ ViewFullVEffect1 + + Add AH, 60 + +ViewFullVEffect1: + Mov AL, AH + Xor AH, AH + Div DH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov CL, AH + Mov AH, CH + StosW + Mov AL, CL + StosW + + Jmp ViewFull9 + +ViewFullNoVEffect: + Mov DL, CH + + Test AL, 80h + JZ ViewFull12 + + And DL, 0F0h + Or DL, 2 + And AL, 7Fh ; Filter out panning stuff. + +ViewFull12: + Xor AH, AH + Div DH + Add AX, 3030h + Mov CL, AH + Mov AH, DL + StosW + Mov AL, CL + StosW + + Mov AH, CH + +ViewFull9: + Mov AL, 20h + StosW + + LodsB ; Command + And AL, AL + JNZ ViewFull10 + + Mov AL, '.' + StosW + Jmp ViewFull11 + +ViewFull10: + Add AL, '@' + StosW + +ViewFull11: + LodsB ; Command value + + AAM 16 ; AH = High nibble, AL = low nibble + Mov CL, AL + Mov AL, AH + Mov AH, CH + Call PE_ConvHexAL + + Mov AL, CL + Call PE_ConvHexAL + + Add SI, 315 + Pop DI + Add DI, 160 + Pop DX + Pop CX + Inc CX + Dec CH + JNZ ViewFull1 + + Mov DX, BP + Mov BP, Offset CursorPositions + Jmp PE_HilightView + +EndP ViewFull + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ViewCompress ; DS:SI = pattern data + ; ES:DI = screen pointer + ; CS:BX = note data + ; CX = row number + ; DL = channel number. + + Push SI + Push BX + + Mov SI, Offset ChannelMsg2 + Mov BX, 8 + Call ViewCommon + + Pop BX + Pop SI + +ViewCompress1: + Push CX + Push DX + Push DI + + Call PE_SelectColour + + LodsB + + Call Draw_3Note + + LodsB ; Instrument + Sub CH, 4 + Call Draw_2Instrument + Add CH, 4 + + LodsB ; Volume + Mov AH, CH + + Cmp AL, 0FFh + JNE ViewCompress8 + + Mov AL, 173 + StosW + StosW + + Jmp ViewCompress9 + +ViewCompress8: + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC ViewCompressNoVEffect + + Test AL, 80h + JZ ViewCompressVEffect1 + + Add AH, 60 + +ViewCompressVEffect1: + Mov AL, AH + Xor AH, AH + Div DH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov CL, AH + Mov AH, CH + StosW + Mov AL, CL + StosW + + Jmp ViewCompress9 + +ViewCompressNoVEffect: + Mov DL, CH + + Test AL, 80h + JZ ViewCompress12 + + And DL, 0F0h + Or DL, 2 + And AL, 7Fh ; Filter out panning stuff. + +ViewCompress12: + Xor AH, AH + Div DH + Add AX, 3030h + Mov CL, AH + Mov AH, DL + StosW + Mov AL, CL + StosW + Mov AH, CH + +ViewCompress9: + LodsB ; Command + Sub AH, 4 + And AL, AL + JNZ ViewCompress10 + + Mov AL, '.' + StosW + Jmp ViewCompress11 + +ViewCompress10: + Add AL, '@' + StosW + +ViewCompress11: + LodsB ; Command value + AAM 16 ; AH = High nibble, AL = low nibble + Mov CL, AL + Mov AL, AH + Mov AH, CH + Sub AH, 4 + Call PE_ConvHexAL + + Mov AL, CL + Call PE_ConvHexAL + + Add SI, 315 + Pop DI + Add DI, 160 + Pop DX + Pop CX + Inc CX + Dec CH + JNZ ViewCompress1 + + Mov DX, BP + Mov BP, Offset CursorPositions+9 + Jmp PE_HilightView + +EndP ViewCompress + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ViewAllSmall ; DS:SI = pattern data + ; ES:DI = screen pointer + ; CS:BX = note data + ; CX = row number + ; DL = channel number. + + Push SI + Push BX + + Mov SI, Offset ChannelMsg7 + Mov BX, 5 + Call ViewCommon + + Pop BX + Pop SI + +ViewAllSmall1: + Push CX + Push DI + + Call PE_SelectColour + + LodsB + Call Draw_3Note + + LodsB ; Instrument + And AL, AL + JNZ ViewAllSmall6 + + Mov AL, 184 + Sub AH, 4 + StosW + Jmp ViewAllSmall7 + +ViewAllSmall6: + Xor AH, AH + Div DH + ShL AL, 4 + Or AL, AH + Mov AH, CH + Add AH, 4 + StosW + +ViewAllSmall7: + LodsB ; Volume + Cmp AL, 0FFh + JNE ViewAllSmall8 + + Mov AL, 184 + Mov AH, CH + StosW + + Jmp ViewAllSmall9 + +ViewAllSmall8: + Mov CL, CH + Add CL, 6 + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC ViewAllSmallNoVEffect + + Test AL, 80h + JZ ViewAllSmallVEffect1 + + Mov AL, AH + Add AL, 226 + Mov AH, CH + StosW + Jmp ViewAllSmall9 + +ViewAllSmallVEffect1: + Mov AL, AH + Mov AH, 0 + Div DH + ; AL = effect, AH = num + Add AL, 0Ah + ShL AL, 4 + Or AL, AH + Mov AH, CL + StosW + + Jmp ViewAllSmall9 + +ViewAllSmallNoVEffect: + Test AL, 80h + JZ ViewAllSmall12 + + Sub CL, 2 + And AL, 7Fh ; Filter out panning stuff. + +ViewAllSmall12: + Xor AH, AH + Div DH + ShL AL, 4 + Or AL, AH + Mov AH, CL + StosW + +ViewAllSmall9: + LodsB ; Command + Mov AH, CH + Sub AH, 4 + + And AL, AL + JNZ ViewAllSmall10 + + Mov AL, '.' + StosW + Jmp ViewAllSmall11 + +ViewAllSmall10: + Add AL, '@' + StosW + +ViewAllSmall11: + LodsB ; Command value + Add AH, 8 + StosW + + Add SI, 315 + Pop DI + Add DI, 160 + Pop CX + Inc CX + Dec CH + JNZ ViewAllSmall1 + + Mov DX, BP + Mov BP, Offset CursorPositions+18 + Jmp PE_HilightView + +EndP ViewAllSmall + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ViewNote ; DS:SI = pattern data + ; ES:DI = screen pointer + ; CS:BX = note data + ; CX = row number + ; DL = channel number. + + Push SI + Push BX + + Mov SI, Offset ChannelMsg4 + Mov BX, 1 + Call ViewCommon + + Pop BX + Pop SI + +ViewNote1: + Push CX + Push SI + Push DI + + Call PE_SelectColour + + LodsB + Cmp AL, NONOTE + JE ViewNote4 + + Call Draw_3Note + Jmp ViewNoteEnd + +ViewNote4: + LodsB + + Test AL, AL + JZ ViewNote5 + + Push AX + + Mov AH, CH + Mov AL, 20h + StosW + + Pop AX + + Call Draw_2Instrument + Jmp ViewNoteEnd + +ViewNote5: ; Volume + LodsB + Cmp AL, 0FFh + JE ViewNote6 + + Push AX + Mov AH, CH + Sub AH, 4 + Mov AL, 20h + StosW + Pop AX + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC ViewNoteNoVEffect + + Test AL, 80h + JZ ViewNoteVEffect1 + + Add AH, 60 + +ViewNoteVEffect1: + Mov AL, AH + Xor AH, AH + Div DH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov CL, AH + Mov AH, CH + StosW + Mov AL, CL + StosW + + Jmp ViewNoteEnd + +ViewNoteNoVEffect: + Mov CL, CH + Sub CL, 4 + + Test AL, 80h + JZ ViewNote25 + + Dec CX + And AL, 7Fh + +ViewNote25: + Xor AH, AH + Div DH + Add AX, 3030h + XChg CL, AH + StosW + Mov AL, CL + StosW + + Jmp ViewNoteEnd + +ViewNote6: + LodsW + And AX, AX + JZ ViewNote11 + + Mov CL, AH + And AL, AL + JZ ViewNote7 + + Add AL, '@' + Jmp ViewNote8 + +ViewNote7: + Mov AL, '.' + +ViewNote8: + Mov AH, CH + Sub AH, 4 + StosW + + Mov AL, CL + AAM 16 ; AH = High nibble, AL = low nibble + Mov CL, AL + Mov AL, AH + Mov AH, CH + Sub AH, 4 + Call PE_ConvHexAL + + Mov AL, CL + Call PE_ConvHexAL + + Jmp ViewNoteEnd + +ViewNote11: ; Nothing to show except dots... + Mov AH, CH + Mov AL, 173 + StosW + StosW + StosW + +ViewNoteEnd: + + Pop DI + Add DI, 160 + Pop SI + Add SI, 320 + Pop CX + Inc CX + Dec CH + JNZ ViewNote1 + + Cmp BP, CS:Channel + JE ViewNote12 + + Mov DX, BP + Mov BP, Offset CursorPositions+27 + Jmp PE_HilightView + + Ret + +ViewNote12: + Push DI + + Sub SI, (320*32) + Sub DI, (32*160) + Mov AL, 160 + Mov DX, CS:Row + Sub DX, CS:TopRow + + Mul DL + Add DI, AX + Add AX, AX + Add SI, AX + + Mov CX, CS:Row + Call PE_SelectColour ; CH = colour. + + Mov DX, CS:PatternCursor + +ViewNote13: + LodsB + Cmp DL, 1 + JA ViewNote16 + + Cmp AL, NONOTE + JNE ViewNote15 + + Mov AH, CH + Mov AL, 173 + StosW + StosW + StosW + +ViewNote15: + Jmp ViewNoteEndHilight + +ViewNote16: + LodsB + Cmp DL, 3 + JA ViewNote19 + + Mov DH, AL + + Mov AH, CH + Mov AL, 20h + StosW + And DH, DH + JZ ViewNote17 + + MovZX AX, DH + Mov DH, 10 + Div DH + + Add AX, 3030h + Mov DH, AH + Mov AH, CH + StosW + Mov AL, DH + StosW + Jmp ViewNoteEndHilight + +ViewNote17: + Mov AL, 173 + StosW + StosW + Jmp ViewNoteEndHilight + +ViewNote19: + LodsB + Cmp DL, 5 + JA ViewNote22 + + Mov DH, AL + + Mov AH, CH + Sub AH, 4 + Mov AL, 20h + StosW + + Cmp DH, 0FFh + JE ViewNote20 + + Mov AH, DH + And AH, 7Fh + Sub AH, 65 + JC ViewNoteNoVEffect2 + + Test DH, 80h + JZ ViewNoteVEffect2 + + Add AH, 60 + +ViewNoteVEffect2: + Mov AL, AH + Xor AH, AH + Mov DH, 10 + Div DH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov CL, AH + Mov AH, CH + StosW + Mov AL, CL + StosW + + Jmp ViewNoteEndHilight + +ViewNoteNoVEffect2: + Sub CH, 4 + + Test DH, 80h + JZ ViewNote26 + + Dec CH + And DH, 7Fh + +ViewNote26: + MovZX AX, DH + Mov DH, 10 + Div DH + + Add AX, 3030h + XChg CH, AH + StosW + Mov AL, CH + StosW + Jmp ViewNoteEndHilight + +ViewNote20: + Mov AL, 173 + StosW + StosW + Jmp ViewNoteEndHilight + +ViewNote22: + LodsB + Mov AH, CH + Sub AH, 4 + And AL, AL + JNZ ViewNote23 + + Mov AL, '.' + Jmp ViewNote24 + +ViewNote23: + Add AL, '@' + +ViewNote24: + Mov AH, CH + Sub AH, 4 + StosW + + LodsB + AAM 16 ; AH = High nibble, AL = low nibble + Mov CL, AL + Mov AL, AH + Mov AH, CH + Sub AH, 4 + Call PE_ConvHexAL + + Mov AL, CL + Call PE_ConvHexAL + +ViewNoteEndHilight: + Pop DI + + Mov DX, BP + Mov BP, Offset CursorPositions+27 + Jmp PE_HilightView + + +EndP ViewNote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ViewTiny ; DS:SI = pattern data + ; ES:DI = screen pointer + ; CS:BX = note data + ; CX = row number + ; DL = channel number. + + Push SI + Push BX + + Mov SI, Offset ChannelMsg5 + Mov BX, 0 + Call ViewCommon + + Pop BX + Pop SI + +ViewTiny1: + Push CX + Push SI + Push DI + + Call PE_SelectColour + + LodsB + Cmp AL, NONOTE + JE ViewTiny4 + + Call Draw_2Note + Jmp ViewTinyEnd + +ViewTiny4: + LodsB + Test AL, AL + JZ ViewTiny5 + + Call Draw_2Instrument + Jmp ViewTinyEnd + +ViewTiny5: ; Volume + LodsB + Cmp AL, 0FFh + JE ViewTiny6 + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC ViewTinyNoVEffect + + Test AL, 80h + JZ ViewTinyVEffect1 + + Add AH, 60 + +ViewTinyVEffect1: + Mov AL, AH + Xor AH, AH + Div DH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov CL, AH + Mov AH, CH + StosW + Mov AL, CL + StosW + + Jmp ViewTinyEnd + +ViewtinyNoVEffect: + Mov CL, CH + Sub CL, 4 + + Test AL, 80h + JZ ViewTiny27 + + Dec CX + And AL, 7Fh + +ViewTiny27: + Xor AH, AH + Div DH + Add AX, 3030h + XChg AH, CL + StosW + Mov AL, CL + StosW + + Jmp ViewTinyEnd + +ViewTiny6: + LodsW + And AX, AX + JZ ViewTiny11 + + Mov CL, AH + And AL, AL + JZ ViewTiny7 + + Add AL, '@' + Jmp ViewTiny8 + +ViewTiny7: + Mov AL, '.' + +ViewTiny8: + Mov AH, CH + Sub AH, 4 + StosW + Add AH, 8 + Mov AL, CL + StosW + + Jmp ViewTinyEnd + +ViewTiny11: ; Nothing to show except dots... + Mov AH, CH + Mov AL, 173 + StosW + StosW + +ViewTinyEnd: + + Pop DI + Pop SI + Pop CX + + Add DI, 160 + Inc CX + Add SI, 320 + + Dec CH + JNZ ViewTiny1 + + Cmp BP, CS:Channel + JE ViewTiny14 + + Mov DX, BP + Mov BP, Offset CursorPositions+36 + Jmp PE_HilightView + +ViewTiny14: + Push DI + + Sub SI, (32*320) + Sub DI, (32*160) + Mov AL, 160 + Mov CX, CS:Row + Sub CX, CS:TopRow + Mul CL + Add DI, AX + Add AX, AX + Add SI, AX + + Mov CX, CS:Row + Call PE_SelectColour ; CH = colour. + + Mov DX, CS:PatternCursor + LodsB + Cmp DL, 1 + JA ViewTiny17 + + Cmp AL, NONOTE + JE ViewTinyDots + + Jmp ViewTinyEndHilight + +ViewTiny17: + LodsB ; Instrument + Cmp DL, 3 + JA ViewTiny20 + + And AL, AL + JZ ViewTinyDots + + Mov DH, 10 + Xor AH, AH + Div DH + Add AX, 3030h + Mov DH, AH + Mov AH, CH + StosW + Mov AL, DH + StosW + Jmp ViewTinyEndHilight + +ViewTiny20: + LodsB ; Volume + Cmp DL, 5 + JA ViewTiny23 + + Cmp AL, 0FFh + JE ViewTiny21 + + Mov AH, AL + And AH, 7Fh + Sub AH, 65 + JC ViewTinyNoVEffect2 + + Test AL, 80h + JZ ViewTinyVEffect2 + + Add AH, 60 + +ViewTinyVEffect2: + Mov AL, AH + Xor AH, AH + Mov DH, 10 + Div DH + ; AL = effect, AH = num + Add AX, 'A'+'0'*256 + Mov CL, AH + Mov AH, CH + StosW + Mov AL, CL + StosW + + Jmp ViewTinyEndHilight + +ViewTinyNoVEffect2: + Sub CH, 4 + Test AL, 80h + JZ ViewTiny28 + + Dec CH + And AL, 7Fh + +ViewTiny28: + Mov DH, 10 + Xor AH, AH + Div DH + Add AX, 3030h + XChg CH, AH + StosW + Mov AL, CH + StosW + Jmp ViewTinyEndHilight + +ViewTiny21: + Sub CH, 4 + +ViewTinyDots: + Mov AH, CH + Mov AL, 173 + StosW + StosW + Jmp ViewTinyEndHilight + +ViewTiny23: + LodsB ; CommandValue. + And AL, AL + JNZ ViewTiny24 + + Mov AL, '.' + Jmp ViewTiny25 + +ViewTiny24: + Add AL, '@' + +ViewTiny25: + Mov AH, CH + Sub AH, 4 + StosW + + Add AH, 8 + LodsB + StosW + +ViewTinyEndHilight: + Pop DI + + Mov DX, BP + Mov BP, Offset CursorPositions+36 + Jmp PE_HilightView + +EndP ViewTiny + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ToggleDivision Far + + Xor ViewDivision, 1 + + Call PE_CheckWidth + JC PEFunction_ToggleDivision1 + + Mov AX, 1 + Ret + +PEFunction_ToggleDivision1: + Xor ViewDivision, 1 + + Mov AX, 1 + Ret + +EndP PEFunction_ToggleDivision + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl0 Far + + Mov AX, 0 + Jmp PE_FastView + +EndP PEFunction_Ctrl0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl1 Far + + Mov AX, 1 + Jmp PE_FastView + +EndP PEFunction_Ctrl1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl2 Far + + Mov AX, 2 + Jmp PE_FastView + +EndP PEFunction_Ctrl2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl3 Far + + Mov AX, 3 + Jmp PE_FastView + +EndP PEFunction_Ctrl3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl4 Far + + Mov AX, 4 + Jmp PE_FastView + +EndP PEFunction_Ctrl4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl5 Far + + Mov AX, 5 + Jmp PE_FastView + +EndP PEFunction_Ctrl5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_QuickViewSetup Far ; CX = num with div + ; BX = num without div + ; AH = type. + Cmp ViewDivision, 0 + JNE PEFunction_QuickViewSetup1 + + Mov CX, BX + Mov BX, 100 + Sub BX, CX + +PEFunction_QuickViewSetup1: + Push CS + Pop ES + Mov DI, Offset ViewChannels + +PEFunction_QuickViewSetup3: + StosW + + Inc AL + Loop PEFunction_QuickViewSetup3 + + Mov CX, BX + Mov AX, 0FFFFh + Rep StosW + + Call PE_CheckWidth + + Cmp ViewChannelTracking, 0 + JNE PEFunction_QuickViewSetup2 + + Call PEFunction_ToggleTracking + +PEFunction_QuickViewSetup2: + + Mov AX, 1 + Ret + +EndP PEFunction_QuickViewSetup + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl_Shift1 Far + + Mov AX, 100h + Mov BX, 7 + Mov CX, 6 + Jmp PEFunction_QuickViewSetup + +EndP PEFunction_Ctrl_Shift1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl_Shift2 Far + + Mov AX, 200h + Mov BX, 10 + Mov CX, 9 + Jmp PEFunction_QuickViewSetup + +EndP PEFunction_Ctrl_Shift2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl_Shift3 Far + + Mov AX, 300h + Mov BX, 24 + Mov CX, 18 + Jmp PEFunction_QuickViewSetup + +EndP PEFunction_Ctrl_Shift3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl_Shift4 Far + + Mov AX, 400h + Mov BX, 36 + Mov CX, 24 + Jmp PEFunction_QuickViewSetup + +EndP PEFunction_Ctrl_Shift4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_FastView Far + + Dec AX ; AL = viewmethod + Mov CL, AL + Mov BX, Channel + Mov SI, Offset ViewChannels + + Cmp CL, 0FFh + JE PE_FastView4 + +PE_FastView1: + LodsW + Cmp AL, 0FFh + JE PE_FastView2 + + Cmp AL, BL + JE PE_FastView2 + Jmp PE_FastView1 + +PE_FastView2: + Sub SI, 2 + Push AX + Push SI + + Mov AL, BL + Mov AH, CL + Mov [SI], AX + + Call PE_CheckWidth + JC PE_FastView3 + + Add SP, 4 + Mov AX, 1 + Ret + +PE_FastView3: + Pop SI + Pop AX + Mov [SI], AX + + Mov AX, 1 + Ret + +PE_FastView4: + LodsW + Cmp AL, 0FFh + JE PE_FastView6 + + Cmp AL, BL + JNE PE_FastView4 + +PE_FastView5: + LodsW + Mov [SI-4], AX + Cmp AX, 0FFFFh + JNE PE_FastView5 + + Call PE_CheckWidth + +PE_FastView6: + Mov AX, 1 + Ret + +EndP PE_FastView + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ViewLeft Far + ; First find current channel. + Mov DX, Channel + Mov SI, Offset ViewChannels + +PEFunction_ViewLeft1: + LodsW + Cmp AL, 0FFh + JE PEFunction_ViewLeft2 + + Cmp AL, DL + JNE PEFunction_ViewLeft1 + + Cmp SI, Offset ViewChannels+2 + JE PEFunction_ViewLeft2 + + Mov DL, [SI-4] + Mov Channel, DX + +PEFunction_ViewLeft2: ; Else decrease channel + Mov AX, 1 + Ret + +EndP PEFunction_ViewLeft + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ViewRight Far + + Mov DX, Channel + Mov SI, Offset ViewChannels + +PEFunction_ViewRight1: + LodsW + Cmp AL, 0FFh + JE PEFunction_ViewRight2 + + Cmp AL, DL + JNE PEFunction_ViewRight1 + + LodsW + Cmp AL, 0FFh + JE PEFunction_ViewRight2 + + Xor AH, AH + Mov Channel, AX + +PEFunction_ViewRight2: + Mov AX, 1 + Ret + +EndP PEFunction_ViewRight + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_AltRight Far + + Mov AX, Channel + Inc AX + Cmp AX, 64 + JAE PEFunction_AltRight1 + + Mov Channel, AX + +PEFunction_AltRight1: + Mov AX, 1 + Ret + +EndP PEFunction_AltRight + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_AltLeft Far + + Mov AX, Channel + And AX, AX + JZ PEFunction_AltLeft1 + + Dec AX + Mov Channel, AX + +PEFunction_AltLeft1: + Mov AX, 1 + Ret + +EndP PEFunction_AltLeft + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl_Home Far + + Mov AX, Row + Sub AL, 1 + AdC AL, 0 + Mov Row, AX + + Mov AX, 1 + Ret + +EndP PEFunction_Ctrl_Home + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Ctrl_End Far + + Mov AX, Row + Cmp AX, MaxRow + AdC AX, 0 + Mov Row, AX + + Mov AX, 1 + Ret + +EndP PEFunction_Ctrl_End + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_AltUp Far + + Mov AX, TopRow + Mov BX, Row + Test AX, AX + JZ PEFunction_AltUp1 + + Dec AX + Mov TopRow, AX + Sub BX, AX + Cmp BX, 32 + JB PEFunction_AltUp1 + + Dec Row + +PEFunction_AltUp1: + Mov AX, 1 + Ret + +EndP PEFunction_AltUp + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_AltDown Far + + Mov AX, TopRow + Mov BX, MaxRow + + Inc AX + Sub BX, AX + Cmp BX, 31 + JB PEFunction_AltDown1 + + Mov TopRow, AX + Cmp AX, Row + JBE PEFunction_AltDown1 + + Mov Row, AX + +PEFunction_AltDown1: + Mov AX, 1 + Ret + +EndP PEFunction_AltDown + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_GetLastInstrument Far + + MovZX BX, [CS:LastInstrument] + Dec BX + Ret + +EndP PE_GetLastInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_SwapInstruments Far ; DH/DL = instruments + ; to swap. + Call Music_GetSongSegment + Mov DS, AX + Push CS + Pop DS + Assume DS:Pattern + + Mov TempVariableArea2, DX + Mov AX, PatternNumber + Mov TempVariableArea, AX + Call PEFunction_StorePattern + + Call PE_GetMaxPattern + Inc AX + Mov TempVariableArea4, AX ; 1=OldPattern + ; 2=Instrument swap + ; 3=Current pattern + ; 4=Max pattern + + ; OK... + Mov AL, 1 + Call S_SetDirectMode + + ; Draw Box first... + Call S_DrawSmallBox + + Mov TempVariableArea3, 0 + Assume DS:Nothing + +PE_SwapInstruments1: ; Draw % Complete on screen first + Mov AX, 100 + Mul TempVariableArea3 + Div TempVariableArea4 ; AX = percentage + + Push AX + + Push CS + Pop DS + Assume DS:Pattern + + Mov SI, Offset CompleteMsg + Mov DI, (34+26*80)*2 + Mov AH, 20h + Call S_DrawString + Add SP, 2 ; OK message is on screen. + + + Mov AX, TempVariableArea3 + Mov PatternNumber, AX + Assume DS:Nothing + + Call Music_GetPattern + Call DecodePattern ; Next pattern should be in mem + + Mov AX, MaxRow + Inc AX + Mov CX, 64 + Mul CX + ; AX = number of "blocks" + Mov CX, AX + Mov DX, TempVariableArea2 + + Mov DS, PatternDataArea + Mov SI, 1 + +PE_SwapInstruments3: + Mov AL, [SI] + Cmp AL, DL + JNE PE_SwapInstruments4 + + Mov AL, DH + And AL, 7Fh + Mov [SI], AL + Jmp PE_SwapInstruments5 + +PE_SwapInstruments4: + Test DH, 80h + JNZ PE_SwapInstruments5 + + Cmp AL, DH + JNE PE_SwapInstruments5 + + Mov [SI], DL + +PE_SwapInstruments5: + Add SI, 5 + Loop PE_SwapInstruments3 + + Push CS + Pop DS + + Mov AX, TempVariableArea3 + Call PEFunction_StorePattern + ; OK.. onto next pattern + + Mov AX, TempVariableArea3 + Inc AX + Cmp AX, TempVariableArea4 + JAE PE_SwapInstruments2 + + Mov TempVariableArea3, AX + Jmp PE_SwapInstruments1 + +PE_SwapInstruments2: + Mov AL, 0 + Call S_SetDirectMode + + Push CS + Pop DS + Assume DS:Pattern + + Mov AX, TempVariableArea + Mov PatternNumber, AX + Call Music_GetPattern + Call DecodePattern + + Ret + +EndP PE_SwapInstruments + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_InsertInstrument Far ; DL = instrument + + Push CS + Pop DS + Assume DS:Pattern + + Mov TempVariableArea2, DX + Mov AX, PatternNumber + Mov TempVariableArea, AX + Call PEFunction_StorePattern + + Call PE_GetMaxPattern + Inc AX + Mov TempVariableArea4, AX ; 1=OldPattern + ; 2=Instrument swap + ; 3=Current pattern + ; 4=Max pattern + + ; OK... + Mov AL, 1 + Call S_SetDirectMode + + ; Draw Box first... + Call S_DrawSmallBox + + Mov TempVariableArea3, 0 + Assume DS:Nothing + +PE_InsertInstrument1: ; Draw % Complete on screen first + Mov AX, 100 + Mul TempVariableArea3 + Div TempVariableArea4 ; AX = percentage + + Push AX + + Push CS + Pop DS + Assume DS:Pattern + + Mov SI, Offset CompleteMsg + Mov DI, (34+26*80)*2 + Mov AH, 20h + Call S_DrawString + Add SP, 2 ; OK message is on screen. + + + Mov AX, TempVariableArea3 + Mov PatternNumber, AX + Assume DS:Nothing + + Call Music_GetPattern + Call DecodePattern ; Next pattern should be in mem + + Mov AX, MaxRow + Inc AX + Mov CX, 64 + Mul CX + ; AX = number of "blocks" + Mov CX, AX + Mov DX, TempVariableArea2 + + Mov DS, PatternDataArea + Mov SI, 1 + +PE_InsertInstrument3: + Cmp [SI], DL + JB PE_InsertInstrument4 + + Cmp Byte Ptr [SI], 99 + JAE PE_InsertInstrument4 + + Inc Byte Ptr [SI] + +PE_InsertInstrument4: + Add SI, 5 + Loop PE_InsertInstrument3 + + Push CS + Pop DS + + Mov AX, TempVariableArea3 + Call PEFunction_StorePattern + ; OK.. onto next pattern + + Mov AX, TempVariableArea3 + Inc AX + Cmp AX, TempVariableArea4 + JAE PE_InsertInstrument2 + + Mov TempVariableArea3, AX + Jmp PE_InsertInstrument1 + +PE_InsertInstrument2: + Mov AL, 0 + Call S_SetDirectMode + + Push CS + Pop DS + Assume DS:Pattern + + Mov AX, TempVariableArea + Mov PatternNumber, AX + Call Music_GetPattern + Call DecodePattern + + Ret + +EndP PE_InsertInstrument + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_DeleteInstrument Far ; DL = instrument + + Push CS + Pop DS + Assume DS:Pattern + + Mov TempVariableArea2, DX + Mov AX, PatternNumber + Mov TempVariableArea, AX + Call PEFunction_StorePattern + + Call PE_GetMaxPattern + Inc AX + Mov TempVariableArea4, AX ; 1=OldPattern + ; 2=Instrument swap + ; 3=Current pattern + ; 4=Max pattern + + ; OK... + Mov AL, 1 + Call S_SetDirectMode + + ; Draw Box first... + Call S_DrawSmallBox + + Mov TempVariableArea3, 0 + Assume DS:Nothing + +PE_DeleteInstrument1: ; Draw % Complete on screen first + Mov AX, 100 + Mul TempVariableArea3 + Div TempVariableArea4 ; AX = percentage + + Push AX + + Push CS + Pop DS + Assume DS:Pattern + + Mov SI, Offset CompleteMsg + Mov DI, (34+26*80)*2 + Mov AH, 20h + Call S_DrawString + Add SP, 2 ; OK message is on screen. + + + Mov AX, TempVariableArea3 + Mov PatternNumber, AX + Assume DS:Nothing + + Call Music_GetPattern + Call DecodePattern ; Next pattern should be in mem + + Mov AX, MaxRow + Inc AX + Mov CX, 64 + Mul CX + ; AX = number of "blocks" + Mov CX, AX + Mov DX, TempVariableArea2 + + Mov DS, PatternDataArea + Mov SI, 1 + +PE_DeleteInstrument3: + Cmp [SI], DL + JB PE_DeleteInstrument4 + + Dec Byte Ptr [SI] + +PE_DeleteInstrument4: + Add SI, 5 + Loop PE_DeleteInstrument3 + + Push CS + Pop DS + + Mov AX, TempVariableArea3 + Call PEFunction_StorePattern + ; OK.. onto next pattern + + Mov AX, TempVariableArea3 + Inc AX + Cmp AX, TempVariableArea4 + JAE PE_DeleteInstrument2 + + Mov TempVariableArea3, AX + Jmp PE_DeleteInstrument1 + +PE_DeleteInstrument2: + Mov AL, 0 + Call S_SetDirectMode + + Push CS + Pop DS + Assume DS:Pattern + + Mov AX, TempVariableArea + Mov PatternNumber, AX + Call Music_GetPattern + Call DecodePattern + + Ret + +EndP PE_DeleteInstrument + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_UpdateInstruments Far ; ES:DI = instrument table + ; DL = instrument number + Push CS + Pop DS + Assume DS:Pattern + + Mov Byte Ptr TempVariableArea2, DL + Mov AX, PatternNumber + Mov TempVariableArea, AX + Mov TempVariableArea5, ES + Mov TempVariableArea6, DI + Call PEFunction_StorePattern + + Call PE_GetMaxPattern + Inc AX + Mov TempVariableArea4, AX ; 1=OldPattern + ; 2=Instrument + ; 3=Current pattern + ; 4=Max pattern + ; 5=ES + ; 6=DI + + Mov AL, 1 + Call S_SetDirectMode + + ; Draw Box first... + Call S_DrawSmallBox + + Mov TempVariableArea3, 0 + Assume DS:Nothing + +PE_UpdateInstruments1: ; Draw % Complete on screen first + Mov AX, 100 + Mul TempVariableArea3 + Div TempVariableArea4 ; AX = percentage + + Push AX + + Push CS + Pop DS + Assume DS:Pattern + + Mov SI, Offset CompleteMsg + Mov DI, (34+26*80)*2 + Mov AH, 20h + Call S_DrawString + Pop AX ; Remove AX from stack + + Mov AX, TempVariableArea3 + Mov PatternNumber, AX + Assume DS:Nothing + + Call Music_GetPattern + Call DecodePattern ; Next pattern should be in mem + + Mov AX, MaxRow + Inc AX + Mov CX, 64 + Mul CX + ; AX = number of "blocks" + Mov CX, AX + Mov BL, CS:Byte Ptr TempVariableArea2 + Mov ES, CS:TempVariableArea5 + + Mov DS, PatternDataArea + Xor SI, SI + +PE_UpdateInstruments3: + LodsW + Cmp AL, NONOTE + JAE PE_UpdateInstrument4 + + And AH, AH ; AH = instrument + JZ PE_UpdateInstrument4 + + Xor DX, DX + Mov DI, CS:TempVariableArea6 + +PE_UpdateInstrument5: + Cmp AX, [ES:DI] + JE PE_UpdateInstrument7 + +; Add DI, 2 + ScasW + Inc DX ; Not it... + Cmp DX, 120 + JB PE_UpdateInstrument5 + + Jmp PE_UpdateInstrument4 + +PE_UpdateInstrument7: + Mov DH, BL + Mov [DS:SI-2], DX + + +PE_UpdateInstrument4: + Add SI, 3 + Loop PE_UpdateInstruments3 + + Push CS + Pop DS + + Mov AX, TempVariableArea3 + Call PEFunction_StorePattern + ; OK.. onto next pattern + + Mov AX, TempVariableArea3 + Inc AX + Cmp AX, TempVariableArea4 + JAE PE_UpdateInstruments2 + + Mov TempVariableArea3, AX + Jmp PE_UpdateInstruments1 + +PE_UpdateInstruments2: + Mov AL, 0 + Call S_SetDirectMode + + Push CS + Pop DS + Assume DS:Pattern + + Mov AX, TempVariableArea + Mov PatternNumber, AX + Call Music_GetPattern + Call DecodePattern + + Ret + +EndP PE_UpdateInstruments + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Alt_F9 Far + Assume DS:Pattern + + Mov AX, Channel + Call Music_ToggleChannel + + Mov AX, 1 + Ret + +EndP PEFunction_Alt_F9 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_MuteNext Far + Assume DS:Pattern + + Call PEFunction_Alt_F9 + Jmp PEFunction_Tab + +EndP PEFunction_MuteNext + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_MutePrevious Far + Assume DS:Pattern + + Sub Channel, 1 + AdC Channel, 0 + Jmp PEFunction_Alt_F9 + +EndP PEFunction_MutePrevious + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Alt_F10 Far + Assume DS:Pattern + + Mov AX, Channel + Call Music_SoloChannel + + Mov AX, 1 + Ret + +EndP PEFunction_Alt_F10 + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_SoloGotoNext Far + + Call PEFunction_Alt_F10 + Jmp PEFunction_Tab + +EndP PEFunction_SoloGotoNext + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_UnmuteAll Far + + Call Music_UnmuteAll + + Mov AX, 1 + Ret + +EndP PEFunction_UnmuteAll + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_ShowOrder Far ; DX = order. + + Call S_GetDestination + Mov CX, 32 + + Mov DI, (2+15*80)*2+1 + Mov BX, TopOrder + +PE_ShowOrder1: + Mov AL, 23h + Cmp BX, DX + JE PE_ShowOrder2 + + Mov AL, 20h + +PE_ShowOrder2: + StosB + Inc DI + StosB + Inc DI + StosB + + Add DI, 155 + Inc BX + Loop PE_ShowOrder1 + + Ret + +EndP PE_ShowOrder + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_PlayCurrentPosition Far + Assume DS:Pattern + + Call I_ClearTables + + Mov AX, PatternNumber + Mov BX, MaxRow + Inc BX + Mov CX, Row + + Call Music_PlayPattern + + Mov AX, 1 + Ret + +EndP PE_PlayCurrentPosition + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_SetPlayMark Far + Assume DS:Pattern + + Cmp PlayMarkOn, 1 ; If on.. + JNE PEFunction_SetPlayMarkNew + + Mov AX, PatternNumber + Cmp AX, PlayMarkPattern + JNE PEFunction_SetPlayMarkNew + + Mov AX, Row + Cmp AX, PlayMarkRow + JNe PEFunction_SetPlayMarkNew + + Mov PlayMarkOn, 0 + Jmp PEFunction_SetPlayMarkEnd + +PEFunction_SetPlayMarkNew: + Mov PlayMarkOn, 1 + Mov AX, PatternNumber + Mov PlayMarkPattern, AX + Mov AX, Row + Mov PlayMarkRow, AX + +PEFunction_SetPlayMarkEnd: + Mov AX, 1 + Ret + +EndP PEFunction_SetPlayMark + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_F7 Far ; If no mark is set, use + ; current pattern & row + Call I_ClearTables + + Push CS + Pop DS + Assume DS:Pattern + + Mov CX, PatternNumber + Mov BX, Row + + Cmp PlayMarkOn, 1 + JNE PE_F7_1 + + Mov CX, PlayMarkPattern + Mov BX, PlayMarkRow + +PE_F7_1: + Mov SI, Order + + Call Music_GetSongSegment + Mov ES, AX + + Cmp CL, [ES:SI+100h] + JNE PE_F7_3 + + Mov AX, SI + Jmp PE_F7_4 + +PE_F7_3: + Mov AL, CL ; AL = pattern. + Mov DI, 100h + Mov CX, 256 + + RepNE ScasB + JNE PE_F7_2 + + Mov AX, DI + Sub AX, 101h ; AX = order. + +PE_F7_4: + Call Music_PlayPartSong + + Mov AX, 1 + Ret + +PE_F7_2: + Mov CX, BX + + Mov AX, PatternNumber + Mov BX, MaxRow + Inc BX + Call Music_PlayPattern + + Mov AX, 1 + Ret + +EndP PE_F7 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ToggleTracking Far + Assume DS:Pattern + + Mov SI, Offset NoViewChannelTrackingMsg + Xor ViewChannelTracking, 1 + JZ PEFunction_ToggleTracking1 + + Mov SI, Offset ViewChannelTrackingMsg + +PEFunction_ToggleTracking1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP PEFunction_ToggleTracking + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ToggleRowHilight Far + Assume DS:Pattern + + Mov SI, Offset NoRowHilightMsg + Xor CentraliseCursor, 2 + Test CentraliseCursor, 2 + JZ PEFunction_ToggleRowHilight1 + + Mov SI, Offset RowHilightMsg + +PEFunction_ToggleRowHilight1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP PEFunction_ToggleRowHilight + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ToggleCentralise Far + Assume DS:Pattern + + Mov SI, Offset NoCentraliseCursorMsg + Xor CentraliseCursor, 1 + Test CentraliseCursor, 1 + JZ PEFunction_ToggleCentralise1 + + Mov SI, Offset CentraliseCursorMsg + +PEFunction_ToggleCentralise1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP PEFunction_ToggleCentralise + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_ToggleTrace Far + Assume DS:Pattern + + Mov SI, Offset NoTraceMsg + Xor TracePlayback, 1 + JZ PEFunction_ToggleTrace1 + + Mov SI, Offset TraceMsg + +PEFunction_ToggleTrace1: + Call SetInfoLine + + Mov AL, TracePlayback + Call K_SetScrollLock + + Mov AX, 1 + Ret + +EndP PEFunction_ToggleTrace + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_GetPatternConfigOffset Far + + Push CS + Pop DS + + Mov DX, Offset KeySignature + + Ret + +EndP PE_GetPatternConfigOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseUndoMemory + + Test AX, AX + JZ ReleaseUndoMemoryEnd + + Push AX + And AH, 0F0h + Cmp AH, 0A0h + Pop AX + JE ReleaseUndoMemoryEMS + +ReleaseUndoMemoryConventional: + Push ES + + Mov ES, AX + Mov AH, 49h + Int 21h + + Pop ES + Ret + +ReleaseUndoMemoryEMS: + And AX, 0FFFh + Call E_ReleaseEMS + +ReleaseUndoMemoryEnd: + Ret + +EndP ReleaseUndoMemory + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_AddToUndoBuffer Far ; 1) Release oldest data. + ; 2) Shift all stuff down. + ; 3) Store newest data. + + ; Parameter: DI = buffer TYPE. + + PushA + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Pattern + + Mov AX, DI + Cmp AL, 22 + JE PE_NotModified + + Mov Word Ptr [Modified], 101h + +PE_NotModified: + ; Error maintenance... sorta + Push CS + Push Offset PE_AddToUndoBufferEnd + Push AX ; Just for stack alignment + + Call GetPatternLength ; Get's pattern length in DX + + Add SP, 6 + ; For GetPatternLength's error stuff.. + + Add DX, 8 + JNC PE_AddToUndoBuffer3 + + Mov DI, Offset O1_PatternTooLongList + Mov CX, 2 + Call M_Object1List + Jmp PE_AddToUndoBufferEnd + +PE_AddToUndoBuffer3: +; ClC ; Carry already not set to get here - for + ; Non essential EMS allocation + MovZX EAX, DX + Call E_AllocateEMS + Test AX, AX + JZ PE_AddToUndoBuffer1 ; No EMS allocated? + + Call E_MapAvailableEMSMemory + + Or AH, 0A0h ; EMS tag + Push AX + Call E_GetEMSPageFrame + Push AX + Jmp PE_AddToUndoBuffer4 + +PE_AddToUndoBuffer1: + Mov BX, DX ; BX = length of pattern. + Add BX, 15 + RCR BX, 1 + ShR BX, 3 + + Mov AH, 48h + Int 21h + JC PE_AddToUndoBufferEnd + + Push AX ; Handle + Push AX ; Memory region + +PE_AddToUndoBuffer4: + Mov SI, Offset UndoBuffer+36 + Mov AX, [SI] + Call ReleaseUndoMemory + + Mov CX, 9 + +PE_AddToUndoBuffer2: + Mov EAX, [SI-4] + Mov [SI], EAX + + Sub SI, 4 + Loop PE_AddToUndoBuffer2 + + Pop ES + Pop AX + + Mov [SI], AX + Mov [SI+2], DI + + Sub DX, 8 + Xor DI, DI ; ES:DI points to data, DX = length + + Call EncodePattern + +PE_AddToUndoBufferEnd: + Pop ES + Pop DS + PopA + + Ret + +EndP PE_AddToUndoBuffer + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_ClearUndoBuffer Far + + Push EAX + Push CX + Push DS + Push SI + + Push CS + Pop DS + Assume DS:Pattern + + Mov CX, 10 + Mov SI, Offset UndoBuffer + +PE_ClearUndoBuffer1: + Mov AX, [SI] + Call ReleaseUndoMemory + + Xor EAX, EAX + Mov [SI], EAX + + Add SI, 4 + + Loop PE_ClearUndoBuffer1 + + Pop SI + Pop DS + Pop CX + Pop EAX + + Ret + +EndP PE_ClearUndoBuffer + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_Undo Far + + Mov SelectUndo, 0 + + Mov DI, Offset O1_UndoList + Mov CX, 3 + Call M_Object1List + + Mov AX, 1 + Ret + +EndP PEFunction_Undo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_DrawUndo Far + + Assume DS:Pattern + Push CS + Pop DS + + Call S_GetDestination + Mov CX, 10 + Mov DI, (21+24*80)*2 + Mov BX, Offset UndoBuffer+2 + +PEFunction_DrawUndo1: + Push DI + + Mov SI, [BX] + Mov AX, SI + And SI, 0FFh + Add SI, SI + + MovZX AX, AH + + Push AX + Mov SI, [UndoBufferTypes+SI] + Mov AH, 2 + Call S_DrawString + Pop AX + + Add BX, 4 + Pop DI + Add DI, 160 + Loop PEFunction_DrawUndo1 + + Ret + +EndP PEFunction_DrawUndo + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_PreUndo Far + + Push CS + Pop DS + Assume DS:Pattern + + Call S_GetDestination + Mov AX, 160 + Mul SelectUndo + Add AX, (20+24*80)*2+1 + Mov DI, AX + + Mov CX, 40 + Mov AL, 30h + +PEFunction_PreUndo1: + StosB + Inc DI + Loop PEFunction_PreUndo1 + + Ret + +EndP PEFunction_PreUndo + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEFunction_PostUndo Far + + Push CS + Pop DS + Assume DS:Pattern + + Mov BX, SelectUndo + + Cmp CX, 1C8h + JE PEFunction_PostUndoUp + + Cmp CX, 1D0h + JE PEFunction_PostUndoDown + + Cmp CX, 11Ch ; Enter + JE PEFunction_PostUndoEnter + + Xor AX, AX + Ret + +PEFunction_PostUndoUp: + Sub BL, 1 + AdC BL, 0 + Jmp PEFunction_PostUndoShift + +PEFunction_PostUndoDown: + Cmp BX, 8 + JA PEFunction_PostUndoShift + + Inc BX + +PEFunction_PostUndoShift: + Mov SelectUndo, BX + + Mov AX, 1 + Ret + +PEFunction_PostUndoEnter: + ShL BX, 2 + Add BX, Offset UndoBuffer + + Mov CX, [BX+2] + JCXZ PEFunction_PostUndoEnd + + Push Word Ptr [BX] + + Mov DI, 21 + Call PE_AddToUndoBuffer + + Pop AX + Mov CH, AH + And CH, 0F0h + Cmp CH, 0A0h + JNE PEFunction_PostUndoEnterEnd + +PEFunction_PostUndoEMS: + And AX, 0FFFh + Call E_MapAvailableEMSMemory + Call E_GetEMSPageFrame + +PEFunction_PostUndoEnterEnd: + Mov DS, AX + Assume DS:Nothing + Xor SI, SI + Call DecodePattern + + Xor BX, BX + Mov CL, 64 + Mov CH, Byte Ptr [CS:MaxRow] + Inc CH + Call NetworkPatternBlock + +PEFunction_PostUndoEnd: + Mov AX, 4 + Ret + +EndP PEFunction_PostUndo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ToggleFastVolume Far + Assume DS:Pattern + + Mov SI, Offset NoFastVolumeMsg + Xor CentraliseCursor, 4 + Test CentraliseCursor, 4 + JZ ToggleFastVolume3 + + Push DS + + Mov DI, Offset O1_GetFastAmpList + Mov CX, 3 + Call M_Object1List + + Pop DS + + Cmp DX, 1 + JNE ToggleFastVolume2 + + Mov SI, Offset FastVolumeMsg + Jmp ToggleFastVolume3 + +ToggleFastVolume2: + And CentraliseCursor, Not 4 + Mov SI, Offset FastVolumeNotEnabledMsg + +ToggleFastVolume3: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP ToggleFastVolume + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PECheckModified Far + + Cmp CS:Modified, 0 + JE PECheckModified1 + + Mov CX, 4 + Mov DI, Offset O1_ConfirmNoSave + Call M_Object1List + + And DX, DX + JNZ PECheckModified1 + + Add SP, 4 + + Mov AX, 1 + +PECheckModified1: + Ret + +EndP PECheckModified + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PEResetModified Far + + Mov CS:Modified, 0 + + Ret + +EndP PEResetModified + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_SetPatternLength Far + Assume DS:Pattern + +; Mov AX, MaxRow +; Inc AX +; Mov PatternSetLength, AX + Mov AX, PatternNumber + Mov PatternLengthStart, AX + Mov PatternLengthEnd, AX + + Assume DS:Nothing + + Mov CX, 4 + Mov DI, Offset O1_SetPatternLength + Call M_Object1List + + Test DX, DX + JZ PE_SetPatternLength2 + + Push CS + Pop DS + Assume DS:Pattern + + Call PEFunction_StorePattern + + Mov AX, PatternNumber + Mov TempVariableArea, AX + + Mov AX, PatternLengthStart + Mov TempVariableArea2, AX + +PE_SetPatternLength3: + Mov AX, TempVariableArea2 + Cmp AX, PatternLengthEnd + JA PE_SetPatternLength4 + + Mov PatternNumber, AX + Assume DS:Nothing + + Call Music_GetPattern + Call DecodePattern ; Next pattern should be in mem + + Push CS + Pop DS + Assume DS:Pattern + + Mov AX, PatternSetLength + Mov PatternModified, 1 + Dec AX + Mov MaxRow, AX + Call PEFunction_StorePattern + + Inc TempVariableArea2 + Jmp PE_SetPatternLength3 + +PE_SetPatternLength4: ; Cleanup + Mov AX, TempVariableArea + Mov PatternNumber, AX + Call Music_GetPattern + Call DecodePattern + +PE_SetPatternLength2: + Mov AX, 1 + Ret + +EndP PE_SetPatternLength + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_LeftBrace Far + + Jmp Glbl_LeftBrace + +EndP PE_LeftBrace + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_RightBrace Far + + Jmp Glbl_RightBrace + +EndP PE_RightBrace + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_LeftSquareBracket Far + + Jmp Glbl_LeftSquareBracket + +EndP PE_LeftSquareBracket + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_RightSquareBracket Far + + Jmp Glbl_RightSquareBracket + +EndP PE_RightSquareBracket + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDI_SetInstrument Far + + Test Byte Ptr CS:CentraliseCursor, 16 + JZ MIDI_SetInstrument2 + + Inc DX + +MIDI_SetInstrument2: + Cmp DX, 99 + JA MIDI_SetInstrument1 + + Mov CS:LastInstrument, DL + + Test DL, DL + JZ MIDI_SetInstrument1 + + Call UpdateWAVEForm + +MIDI_SetInstrument1: + Mov AX, 1 + Ret + +EndP MIDI_SetInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_MIDIAfterTouch Far + Assume DS:Pattern + + Cmp MIDIInputEnabled, 0 + JNE PE_MIDIAfterTouch2 + + Xor AX, AX + Ret + +PE_MIDIAfterTouch2: + Test CentraliseCursor, 128 + + MovZX BX, DL + Call MIDI_GetChannel + ; Returns AX + Sub AL, 1 + JC PE_MIDIAfterTouch1 +; Cmp AL, 0FFh +; JE PE_MIDIAfterTouch1 + + Call PE_TranslateMIDI + ; DL = note, DH = volume + + Mov AH, 5 + Mul AL + Mov SI, AX + Mov BL, DH + Mov AX, 320 + Mul Row + Mov Word Ptr [Modified], 101h + Add SI, AX + Mov DS, PatternDataArea + Assume DS:Nothing + Cmp SI, 64000 + JAE PE_MIDIAfterTouch1 + + Mov [SI+2], BL + +PE_MIDIAfterTouch1: + Mov AX, 1 + Ret + +EndP PE_MIDIAfterTouch + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_MIDINoteOff Far + Assume DS:Pattern + + Cmp MIDIInputEnabled, 0 + JNE PE_MIDINoteOff1 + + Xor AX, AX + Ret + +PE_MIDINoteOff1: + MovSX BX, DL + Call MIDI_FindChannel ; Returns AX + Cmp AL, 0FFh + JE PE_MIDINoteOff2 + + Test CentraliseCursor, 32 + JZ PE_MIDINoteOff2 ; Dont' record note-offs + + Cmp TracePlayback, 0 + JE PE_MIDINoteOff2 + + Push AX + Mov AX, Row + Call Music_GetDelay ; DX = delay value + ; CX = playmode + Pop AX + + Test CX, CX + JZ PE_MIDINoteOff2 + + Push DX + Push AX + + Mov AH, 5 + Mul AH + Mov SI, AX + Mov AX, 320 + Mul Row + Add SI, AX + Cmp SI, 64000 + JAE PE_MIDINoteOff3 + + Mov DS, PatternDataArea + Assume DS:Nothing + + Cmp Word Ptr [SI], NONOTE + JE PE_MIDINoteOff4 + ; check next spot. + Mov AX, Row + Cmp AX, MaxRow + JAE PE_MIDINoteOff3 ; Already at end of pattern + + Add SI, 320 ; Try very next spot. + Cmp SI, 64000 + JAE PE_MIDINoteOff3 + + Xor DX, DX ; Tick 0 + Cmp Word Ptr [SI], NONOTE + JNE PE_MIDINoteOff3 + +PE_MIDINoteOff4: + Mov BX, 0FFh + + Mov [SI+2], BX + Mov [SI+4], BH + Test [CS:Flags], 2 + JZ PE_MIDINoteOffCut + + Dec BX + +PE_MIDINoteOffCut: + Mov [SI], BX + + Mov Word Ptr [CS:Modified], 101h + + Pop AX + Mov DL, 32 + Call Music_PlayNote + Pop DX + + Test CS:CentraliseCursor, 8 + JZ PE_MIDINoteOff2 + + Mov [SI+3], DX + +PE_MIDINoteOff2: + Mov AX, 1 + Ret + +PE_MIDINoteOff3: + Pop AX + Pop AX + Mov AX, 1 + Ret + +EndP PE_MIDINoteOff + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_MIDINote Far + Assume DS:Pattern + + Cmp MIDIInputEnabled, 0 + JNE PE_MIDINote6 + + Xor AX, AX + Ret + +PE_MIDINote6: + Push DX + Call Music_GetLastChannel + Mov DI, AX + Pop DX + + Call PE_TranslateMIDI + JC PE_MIDINote1 ; Note out of range? + JZ PE_MIDINoteOff1 ; Note off? + + Mov BL, DH + Test CentraliseCursor, 64 + JNZ PE_MIDINote3 + + Mov BL, LastVolume + Test EditMask, 2 + JNZ PE_MIDINote3 + + Mov BL, 0FFh + +PE_MIDINote3: + ; If TracePlayback = 1 *AND* Playmode > 1, then + ; Basechannel = MIDIChannel, else + ; Basechannel = Channel + Push DX + + Mov AX, Row + Call Music_GetDelay ; CX = playmode + ; DX = delay value + PushA + + Cmp MIDIPlayTrigger, 1 + JB PE_MIDINoteTriggerEnd + JA MIDIPlayTriggerSong + +MIDIPlayTriggerPattern: + Mov Row, 0 + + Call Glbl_F6 + Jmp PE_MIDINoteTriggerCleanup + +MIDIPlayTriggerSong: + + Call PE_F7 + +PE_MIDINoteTriggerCleanup: + Push CS + Pop DS + + Mov AX, Channel + Mov MIDIChannel, AX + + Mov TracePlayback, 1 + Mov MIDIPlayTrigger, 0 + +PE_MIDINoteTriggerEnd: + PopA + + Mov AX, Channel + Test CX, CX + JZ PE_MIDINote2 + + Cmp TracePlayback, 0 + JE PE_MIDINote2 + + Mov AX, MIDIChannel + +PE_MIDINote2: + Pop CX ; CX = note/volume + Xor CH, CH + Test EditMask, 1 + JZ PE_MIDINote4 + + Mov CH, LastInstrument + +PE_MIDINote4: + + XChg CX, DX + ; CX = delay + ; DX = note/ins + + Push DX + Call PE_RestoreMIDINote + Call MIDI_AllocateChannel ; Returns AX = channel to use + Pop DX + + XChg CX, DX + + Push DX + Push AX + + Inc AX + Cmp AX, 63 + JA PE_MIDINote5 + + Mov MIDIChannel, AX +PE_MIDINote5: + Dec AX + + Mov AH, 5 + Mul AH + Mov SI, AX + Mov AX, 320 + Mul Row + Add SI, AX + + Pop AX + Cmp SI, 64000 + JAE PE_MIDINote1 + + Mov DS, PatternDataArea + Assume DS:Nothing + + Mov [SI], CX + Mov [SI+2], BL + Mov Word Ptr [SI+3], 0 + + Mov DH, 32 + Call Music_PlayNote + Pop DX + + Mov Word Ptr [CS:Modified], 101h + + Test CS:CentraliseCursor, 8 + JZ PE_MIDINote1 + + Mov [SI+3], DX + +PE_MIDINote1: + Mov AX, 1 + Ret + +EndP PE_MIDINote + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TranslateMIDI Far + ; Given DL = 0->127, return DL = 0->127 + ; Given DH = 0->127, return DH=0->64 + + ; Apply note swing. Return carry + ; if note out of range. + + ; Apply volume swing. Return zero + ; flag set if note off. + Push AX + + Test DH, DH + JZ PE_TranslateMIDIVolumeEnd + + MovSX BX, DL + MovSX AX, CS:MIDICentralNote + Add AX, BX + Sub AX, 60 + JS PE_TranslateMIDIError1 + +PE_TranslateMIDIPitch1: + Cmp AX, 119 + JBE PE_TranslateMIDIPitch2 + +PE_TranslateMIDIError1: + StC + Pop AX + Ret + +PE_TranslateMIDIPitch2: + Mov DL, AL + ; OK.. pitch done. + Mov AL, DH + Mul CS:MIDIAmplification + ; AX = (Volume*VolumeAmp) + ; = 0->127*200 + ; = 0->25400 + ; Req AX = 0->128 + ; ie. Div AX 198.4 + ; or Mul AX, 331 + ; >> 16 + + Mov BL, DL ; Note + Mov DX, 331 + Mul DX + Mov DH, DL + Mov DL, BL + Cmp DH, 64 + JB PS_TranslateMIDIVolume1 + + Mov DH, 64 + +PS_TranslateMIDIVolume1: + Test DL, DL ; Clear zero flag + carry. + +PE_TranslateMIDIVolumeEnd: + Pop AX + Ret + +EndP PE_TranslateMIDI + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_RestoreMIDINote Far + + Add DL, 60 + Sub DL, CS:MIDICentralNote + + Ret + +EndP PE_RestoreMIDINote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_CycleMIDIPlayTrigger Far + Assume DS:Pattern + + Mov AL, MIDIPlayTrigger + Inc AX + Cmp AL, 2 + JBE PE_CycleMIDIPlayTrigger1 + + Xor AL, AL + Mov SI, Offset TriggerMsg1 + Jmp PE_CycleMIDIPlayTriggerEnd + +PE_CycleMIDIPlayTrigger1: + Mov SI, Offset TriggerMsg2 + Cmp AL, 1 + JE PE_CycleMIDIPlayTriggerEnd + + Mov SI, Offset TriggerMsg3 + +PE_CycleMIDIPlayTriggerEnd: + Mov MIDIPlayTrigger, AL + + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP PE_CycleMIDIPlayTrigger + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc MIDIInputToggle Far ; Ctrl-Scroll Lock + Assume DS:Pattern + + Mov SI, Offset MIDIInputEnabledMsg + Xor MIDIInputEnabled, 1 + JNZ MIDIInputToggle1 + Mov SI, Offset MIDIInputDisabledMsg + +MIDIInputToggle1: + Call SetInfoLine + + Mov AX, 1 + Ret + +EndP MIDIInputToggle + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_SetPatternModified Far + + Mov Word Ptr [CS:Modified], 101h + Ret + +EndP PE_SetPatternModified + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_SaveCurrentPattern Far + + PushAD + Push DS + Push ES + + Call PEFunction_StoreCurrentPattern + + Mov AX, 0FFFFh + XChg AX, CS:PatternNumber + Mov Word Ptr CS:TempNumbers, AX + + Call Music_UpdatePatternOffset + + Pop ES + Pop DS + PopAD + Ret + +EndP PE_SaveCurrentPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_RestoreCurrentPattern Far + + PushAD + Push DS + Push ES + Mov AX, Word Ptr CS:TempNumbers + Mov CS:PatternNumber, AX + Call Music_GetPattern + Call DecodePattern + Pop ES + Pop DS + PopAD + Ret + +EndP PE_RestoreCurrentPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_NewPattern Far + + Mov AX, CS:PatternNumber + Call Music_GetPattern + Call DecodePattern + + Mov CS:PatternModified, 0 + Ret + +EndP PE_NewPattern + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment PatternData PARA Public 'Data' + DB 64000 Dup (?) +EndS + + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_PE_V.INC b/it_pe_v.inc similarity index 94% rename from IT_PE_V.INC rename to it_pe_v.inc index b021381..7306b4d 100644 --- a/IT_PE_V.INC +++ b/it_pe_v.inc @@ -1,140 +1,140 @@ -; -; Pattern edit view functions -; - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Draw_3Note Near ; Given AL = note. - - Cmp AL, NONOTE - JB Draw_3Note2 - - Mov CL, AL - Mov AL, 173 ; '.' - JE Draw_3Note1 - - Mov AL, '^' - Cmp CL, 0FEh - JE Draw_3Note1 - - Mov AL, 'Í' - Cmp CL, 0FFh - JE Draw_3Note1 - - Mov AL, '!' - -Draw_3Note1: - Mov AH, CH - StosW - StosW - StosW - - Ret - -Draw_3Note2: - Push SI - - AAM 12 ; AH = octave, AL = note - Mov CL, AH - And AX, 0FFh - LEA SI, [EBX+EAX*2] - - Mov AH, CH - SegCS LodsB - StosW - SegCS LodsB - StosW - Mov AL, CL - Add AL, 30h - StosW - - Pop SI - - Ret - -EndP Draw_3Note - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Draw_2Note Near ; Given AL = note. - - Cmp AL, NONOTE - JB Draw_2Note2 - - Mov DL, AL - Mov AL, 173 ; '.' - JE Draw_2Note1 - - Mov AL, '^' - Cmp DL, 0FEh - JE Draw_2Note1 - - Mov AL, 'Í' - Cmp DL, 0FFh - JE Draw_2Note1 - - Mov AL, '!' - -Draw_2Note1: - Mov AH, CH - StosW - StosW - - Ret - -Draw_2Note2: - Push SI - - AAM 12 ; AH = octave, AL = note - Mov CL, AH - And AX, 0FFh - LEA SI, [EBX+EAX*2] - - SegCS LodsW - Cmp AH, '-' - JNE Draw_2Note3 - - Add AL, 'a'-'A' - -Draw_2Note3: - Mov AH, CH - StosW - Mov AL, CL - Add AL, 30h - StosW - - Pop SI - - Ret - -EndP Draw_2Note - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Draw_2Instrument - - Test AL, AL - JNZ Draw_2Instrument1 - - Mov AL, 173 ; '.' - Mov AH, CH - - StosW - StosW - Ret - -Draw_2Instrument1: - AAM 10 - Add AX, '00' - - Mov CL, AL - Mov AL, AH - Mov AH, CH - StosW - Mov AL, CL - StosW - - Ret - -EndP Draw_2Instrument - +; +; Pattern edit view functions +; + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Draw_3Note Near ; Given AL = note. + + Cmp AL, NONOTE + JB Draw_3Note2 + + Mov CL, AL + Mov AL, 173 ; '.' + JE Draw_3Note1 + + Mov AL, '^' + Cmp CL, 0FEh + JE Draw_3Note1 + + Mov AL, 'Í' + Cmp CL, 0FFh + JE Draw_3Note1 + + Mov AL, '!' + +Draw_3Note1: + Mov AH, CH + StosW + StosW + StosW + + Ret + +Draw_3Note2: + Push SI + + AAM 12 ; AH = octave, AL = note + Mov CL, AH + And AX, 0FFh + LEA SI, [EBX+EAX*2] + + Mov AH, CH + SegCS LodsB + StosW + SegCS LodsB + StosW + Mov AL, CL + Add AL, 30h + StosW + + Pop SI + + Ret + +EndP Draw_3Note + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Draw_2Note Near ; Given AL = note. + + Cmp AL, NONOTE + JB Draw_2Note2 + + Mov DL, AL + Mov AL, 173 ; '.' + JE Draw_2Note1 + + Mov AL, '^' + Cmp DL, 0FEh + JE Draw_2Note1 + + Mov AL, 'Í' + Cmp DL, 0FFh + JE Draw_2Note1 + + Mov AL, '!' + +Draw_2Note1: + Mov AH, CH + StosW + StosW + + Ret + +Draw_2Note2: + Push SI + + AAM 12 ; AH = octave, AL = note + Mov CL, AH + And AX, 0FFh + LEA SI, [EBX+EAX*2] + + SegCS LodsW + Cmp AH, '-' + JNE Draw_2Note3 + + Add AL, 'a'-'A' + +Draw_2Note3: + Mov AH, CH + StosW + Mov AL, CL + Add AL, 30h + StosW + + Pop SI + + Ret + +EndP Draw_2Note + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Draw_2Instrument + + Test AL, AL + JNZ Draw_2Instrument1 + + Mov AL, 173 ; '.' + Mov AH, CH + + StosW + StosW + Ret + +Draw_2Instrument1: + AAM 10 + Add AX, '00' + + Mov CL, AL + Mov AL, AH + Mov AH, CH + StosW + Mov AL, CL + StosW + + Ret + +EndP Draw_2Instrument + diff --git a/IT_S.ASM b/it_s.s similarity index 96% rename from IT_S.ASM rename to it_s.s index a0b9de7..465833b 100644 --- a/IT_S.ASM +++ b/it_s.s @@ -1,1685 +1,1685 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Screen Module ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -include switch.inc - - Jumps - .386 - -Segment Mouse BYTE Public 'Code' - Extrn MouseCharacterGenerationOffset:Word -EndS - - Extrn E_UnInitEMS:Far - Extrn DrawMouse:Far, RestoreMouse:Far, ForceMouseRestore:Far - Extrn RestoreMouseGraphics:Far, NewCharacterSet:Far - Extrn MouseSecondSetEnable:Far, MouseSecondSetDisable:Far - Extrn MouseUpdateEnable:Far, MouseUpdateDisable:Far - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Global S_InitScreen:Far - Global S_SetPalette:Far - Global S_UnInitScreen:Far - Global S_DrawBox:Far - Global S_UpdateScreen:Far - Global S_OverrideVGADetection:Far - Global S_SetDirectMode:Far - Global S_DrawString:Far - Global S_DirectDrawString:Far - Global S_HiLight:Far - Global S_ClearScreen:Far - Global S_GetDestination:Far - Global S_GetGenerationTableOffset:Far - Global S_GenerateCharacters:Far - Global S_SaveScreen:Far - Global S_RestoreScreen:Far - Global S_DefineSmallNumbers:Far - Global S_DefineHiASCII:Far - Global S_DrawSmallBox:Far - Global S_GetPaletteOffset:Far - Global S_SetPalette2:Far - Global S_UsePresetPalette:Far - Global S_InvertCursor:Far - - Global S_SetSequencer:Far, S_ResetSequencer:Far - - Global CharacterGenerationOffset:Word - - Public PaletteDefs - Public S_RedefineCharacters - Public VGAFlags - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Screen BYTE Public 'Code' USE16 - Assume CS:Screen, DS:Screen - -CREATENEWLOGFILE EQU 0 -include debug.inc - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -STORESCREENADDRESS EQU 0BA00h - -NoVGAMsg DB "Sorry, this program requires VGA", 13, 10 - DB "$" - -ScreenDataArea DW ScreenData - -PaletteDefs Label Byte - ; Default to camouflage - DB 0, 0, 0, 31, 22, 17, 45, 37, 30, 58, 58, 50 - DB 44, 0, 21, 63, 63, 21, 17, 38, 18, 19, 3, 6 - DB 8, 21, 0, 6, 29, 11, 14, 39, 29, 55, 58, 56 - DB 40, 40, 40, 35, 5, 21, 22, 16, 15, 13, 12, 11 - -PresetPalettes Label Byte - ; Light Blue palette - DB 0, 0, 0, 10, 25, 45, 30, 40, 55, 51, 58, 63 - DB 63, 21, 21, 21, 63, 21, 44, 44, 44, 22, 22, 22 - DB 0, 0, 32, 0, 0, 42, 30, 40, 55, 51, 58, 63 - DB 44, 44, 44, 21, 63, 21, 18, 16, 15, 12, 11, 10 ; Greyish brown - - ; Gold - DB 0, 0, 0, 20, 17, 10, 41, 36, 21, 63, 55, 33 - DB 63, 21, 21, 18, 53, 18, 38, 37, 36, 22, 22, 22 - DB 0, 0, 32, 0, 0, 42, 41, 36, 21, 48, 49, 46 - DB 44, 44, 44, 21, 50, 21, 18, 16, 15, 12, 11, 10 - - ; Camouflage / Jari Karppinen - DB 0, 0, 0, 31, 22, 17, 45, 37, 30, 58, 58, 50 - DB 44, 0, 21, 63, 63, 21, 17, 38, 18, 19, 3, 6 - DB 8, 21, 0, 6, 29, 11, 14, 39, 29, 55, 58, 56 - DB 40, 40, 40, 35, 5, 21, 22, 16, 15, 13, 12, 11 - - ; Midnight Tracking palette - DB 0, 0, 0, 0, 8, 16, 0, 19, 32, 16, 28, 48 - DB 63, 21, 21, 0, 48, 36, 32, 32, 32, 22, 22, 22 - DB 0, 0, 24, 0, 0, 32, 0, 18, 32, 40, 40, 40 - DB 32, 32, 32, 28, 0, 24, 4, 13, 20, 6, 7, 11 - - Comment ~ - ; Cool Hot Colours - Zoner / EPI / XLM - DB 11, 0, 18, 0, 0, 22, 42, 35, 33, 53, 45, 41 - DB 51, 0, 0, 34, 22, 35, 34, 33, 52, 22, 22, 22 - DB 26, 26, 32, 32, 32, 42, 41, 36, 21, 48, 49, 46 - DB 44, 44, 44, 21, 40, 21, 27, 16, 24, 21, 11, 19 - ~ - - ; Pine colours - Jari Karppinen - DB 0, 0, 0, 2, 16, 13, 21, 32, 29, 51, 58, 63 - DB 63, 34, 0, 52, 51, 33, 42, 41, 33, 31, 22, 22 - DB 12, 10, 16, 18, 0, 24, 30, 40, 55, 58, 58, 33 - DB 44, 44, 44, 49, 39, 21, 13, 15, 14, 14, 11, 14 - - ; Soundtracker - Chris Jarvis - DB 0, 0, 0, 18, 24, 28, 35, 42, 47, 51, 56, 60 - DB 63, 21, 21, 21, 63, 22, 0, 35, 63, 22, 22, 22 - DB 32, 13, 38, 37, 16, 62, 27, 40, 55, 51, 58, 63 - DB 44, 44, 44, 21, 63, 21, 18, 16, 17, 13, 14, 13 - - ; Volcanic - DB 0, 0, 0, 25, 9, 0, 40, 14, 0, 51, 23, 0 - DB 63, 8, 16, 0, 39, 5, 32, 32, 32, 0, 20, 20 - DB 21, 0, 0, 28, 0, 0, 32, 32, 32, 62, 31, 0 - DB 40, 40, 40, 0, 28, 38, 10, 16, 27, 8, 11, 19 - - Comment ~ - ; Atlantic - Delta X / NOiSE - DB 0, 0, 0, 2, 0, 30, 8, 18, 43, 21, 43, 63 - DB 63, 8, 16, 27, 32, 63, 0, 54, 63, 10, 15, 35 - DB 0, 0, 30, 0, 0, 36, 0, 18, 32, 40, 40, 40 - DB 18, 52, 63, 21, 50, 21, 10, 16, 27, 8, 11, 19 - ~ - ; Original Palette -; DB 0, 0, 0, 10, 25, 45, 30, 40, 55, 51, 58, 63 -; DB 63, 21, 21, 21, 63, 21, 44, 44, 44, 22, 22, 22 -; DB 0, 0, 32, 0, 0, 42, 30, 40, 55, 51, 58, 63 -; DB 44, 44, 44, 21, 63, 21, 18, 16, 15, 12, 11, 10 ; Greyish brown - -CharacterDefinitions Label Byte - DB 255, 128, 128, 128, 128, 128, 128, 128 ; 128 - DB 255, 0, 0, 0, 0, 0, 0, 0 ; 129 - DB 255, 1, 1, 1, 1, 1, 1, 1 ; 130 - DB 128, 128, 128, 128, 128, 128, 128, 128 ; 131 - DB 1, 1, 1, 1, 1, 1, 1, 1 ; 132 - DB 128, 128, 128, 128, 128, 128, 128, 255 ; 133 - DB 0, 0, 0, 0, 0, 0, 0, 255 ; 134 - DB 1, 1, 1, 1, 1, 1, 1, 255 ; 135 - DB 128, 0, 0, 0, 0, 0, 0, 0 ; 136 - DB 1, 0, 0, 0, 0, 0, 0, 0 ; 137 - DB 0, 0, 0, 0, 0, 0, 0, 128 ; 138 - DB 0, 0, 0, 0, 0, 0, 0, 1 ; 139 - DB 128, 192, 224, 240, 248, 252, 254,255 ; 140 - DB 255, 127, 63, 31, 15, 7, 3, 1 ; 141 - DB 255, 255, 192, 192, 192, 192, 192, 192 ; 142 - DB 255, 255, 0, 0, 0, 0, 0, 0 ; 143 - DB 255, 255, 3, 3, 3, 3, 3, 3 ; 144 - DB 192, 192, 192, 192, 192, 192, 192, 192 ; 145 - DB 3, 3, 3, 3, 3, 3, 3, 3 ; 146 - DB 192, 192, 192, 192, 192, 192, 255, 255 ; 147 - DB 0, 0, 0, 0, 0, 0, 255, 255 ; 148 - DB 3, 3, 3, 3, 3, 3, 255, 255 ; 149 - DB 192, 192, 0, 0, 0, 0, 0, 0 ; 150 - DB 3, 3, 0, 0, 0, 0, 0, 0 ; 151 - DB 0, 0, 0, 0, 0, 0, 192, 192 ; 152 - DB 0, 0, 0, 0, 0, 0, 3, 3 ; 153 - DB 0, 0, 0, 85, 0, 0, 0, 0 ; 154 -; DB 251, 155, 138, 138, 138, 138, 155, 251 ; 155 -; DB 239, 40, 41, 41, 41, 41, 40, 239 ; 156 -; DB 255, 0, 157, 85, 85, 157, 0, 255 ; 157 -; DB 255, 0, 29, 29, 20, 220, 0, 255 ; 158 -; DB 255, 0, 65, 67, 129, 131, 0, 255 ; 159 -; DB 255, 0, 171, 42, 171, 58, 0, 255 ; 160 -; DB 255, 0, 51, 170, 50, 171, 0, 255 ; 161 -; DB 255, 0, 170, 171, 171, 170, 0, 255 ; 162 -; DB 255, 1, 177, 169, 169, 177, 1, 255 ; 163 - - DB 0, 252, 252, 252, 252, 252, 252, 0 ; 155 - DB 0, 126, 126, 126, 126, 126, 126, 0 ; 156 - DB 0, 63, 63, 63, 63, 63, 63, 0 ; 157 - DB 0, 31, 31, 31, 31, 31, 31, 0 ; 158 - DB 0, 15, 15, 15, 15, 15, 15, 0 ; 159 - DB 0, 7, 7, 7, 7, 7, 7, 0 ; 160 - DB 0, 3, 3, 3, 3, 3, 3, 0 ; 161 - DB 0, 1, 1, 1, 1, 1, 1, 0 ; 162 - DB 0, 128, 128, 128, 128, 128, 128, 0 ; 163 - DB 0, 192, 192, 192, 192, 192, 192, 0 ; 164 - DB 0, 224, 224, 224, 224, 224, 224, 0 ; 165 - DB 0, 240, 240, 240, 240, 240, 240, 0 ; 166 - DB 0, 248, 248, 248, 248, 248, 248, 0 ; 167 - DB 126, 126, 126, 126, 126, 126, 126, 126 ; 168 - DB 255, 255, 0, 24, 60, 126, 255, 0 ; 169 - DB 255, 255, 0, 0, 0, 0, 24, 24 ; 170 - DB 255, 255, 0, 24, 60, 126, 255, 24 ; 171 - DB 255, 255, 0, 66, 102, 90, 66, 66 ; 172 - DB 0, 0, 0, 24, 24, 0, 0, 0 ; 173 - DB 0, 192, 192, 192, 192, 192, 192, 192 ; 174 - DB 0, 216, 216, 216, 216, 216, 216, 216 ; 175 - DB 0, 219, 219, 219, 219, 219, 219, 219 ; 176 - DB 0, 96, 96, 96, 96, 96, 96, 96 ; 177 - DB 0, 108, 108, 108, 108, 108, 108, 108 ; 178 - DB 0, 109, 109, 109, 109, 109, 109, 109 ; 179 - DB 0, 128, 128, 128, 128, 128, 128, 128 ; 180 - DB 0, 176, 176, 176, 176, 176, 176, 176 ; 181 - DB 0, 182, 182, 182, 182, 182, 182, 182 ; 182 - DB 0, 0, 24, 60, 60, 24, 0, 0 ; 183 - DB 0, 0, 0, 66h, 0, 0, 0, 0 ; 184 - DB 0, 1Eh, 21h, 40h, 0, 0, 0, 0 ; 185Sine - DB 0, 0, 0, 82h, 44h, 38h, 0, 0 ; 186 - DB 0, 3Eh, 22h, 22h, 22h, 22h, 63h, 0 ; 187Square - DB 0, 3Eh, 22h, 22h, 22h, 22h, 0E3h, 0 ; 188 - DB 0, 30h, 2Ch, 23h, 20h, 20h, 20h, 0 ; 189RampDown - DB 0, 4, 4, 4, 0C4h, 34h, 0Ch, 0 ; 190 - DB 0, 6, 4, 4, 4, 4, 6, 0 ; 191, Left bracket - DB 0, 0C0h, 40h, 40h, 40h, 40h, 0C0h, 0 ; 192, Right bracket - DB 0, 0, 0, 18h, 18h, 0, 0, 0 ; 193, Notedots - DB 0, 0, 18h, 3Ch, 3Ch, 18h, 0, 0 ; 194 - DB 0, 0, 18h, 3Ch, 3Ch, 18h, 0, 0 ; 195 - DB 0, 0, 3Ch, 3Ch, 3Ch, 3Ch, 0, 0 ; 196 - DB 0, 0, 3Ch, 3Ch, 3Ch, 3Ch, 0, 0 ; 197 - DB 0, 18h, 3Ch, 7Eh, 7Eh, 3Ch, 18h, 0 ; 198 - DB 0, 18h, 3Ch, 7Eh, 7Eh, 3Ch, 18h, 0 ; 199 - DB 0, 3Ch, 7Eh, 7Eh, 7Eh, 7Eh, 3Ch, 0 ; 200 - DB 0, 3Ch, 7Eh, 7Eh, 7Eh, 7Eh, 3Ch, 0 ; 201, end note dots - - Comment & - ; Volume bars - DB 0, 0, 0, 0, 0, 0, 0, 254 - DB 0, 0, 0, 0, 0, 254, 0, 254 - DB 0, 0, 0, 254, 0, 254, 0, 254 - DB 0, 254, 0, 254, 0, 254, 0, 254 - - Comment & - -EndCharacterDefinitions Label Byte - -HexNumeralDefinitions Label Byte - DB 4, 10, 10, 10, 10, 10, 4 ; '0' - DB 0, 4, 12, 4, 4, 4, 4, 14 ; '1' - DB 0, 4, 10, 2, 4, 4, 8, 14 ; '2' - DB 0, 12, 2, 2, 4, 2, 2, 12 ; '3' - DB 0, 10, 10, 10, 14, 2, 2, 2 ; '4' - DB 0, 14, 8, 8, 12, 2, 2, 12 ; '5' - DB 0, 4, 10, 8, 12, 10, 10, 4 ; '6' - DB 0, 14, 2, 2, 2, 2, 2, 2 ; '7' - DB 0, 4, 10, 10, 4, 10, 10, 4 ; '8' - DB 0, 14, 10, 10, 14, 2, 2, 2 ; '9' - DB 0, 4, 10, 10, 14, 10, 10, 10 ; 'A' - DB 0, 12, 10, 10, 12, 10, 10, 12 ; 'B' - DB 0, 6, 8, 8, 8, 8, 8, 6 ; 'C' - DB 0, 12, 10, 10, 10, 10, 10, 12 ; 'D' - DB 0, 14, 8, 8, 12, 8, 8, 14 ; 'E' - DB 0, 14, 8, 8, 12, 8, 8, 8 ; 'F' - DB 0, 6, 8, 8, 10, 10, 10, 6 ; 'G' - DB 0, 10, 10, 10, 14, 10, 10, 10 ; 'H' - - -BoxDefinitions Label Byte - DB 128,21h,129,21h,130,21h,131,21h,32,23h,132,21h,133,21h,134,21h,135,21h - DB 128,23h,129,23h,130,23h,131,23h,32,23h,132,23h,133,23h,134,23h,135,23h - DB 142,21h,143,21h,144,21h,145,21h,32,23h,146,21h,147,21h,148,21h,149,21h - DB 142,23h,143,23h,144,23h,145,23h,32,23h,146,23h,147,23h,148,23h,149,23h - DB 128,23h,129,23h,129,23h,131,23h,32,23h, 32,23h,131,23h, 32,23h, 32,23h - DB 128,21h,129,21h,129,21h,131,21h,32,23h, 32,21h,131,21h, 32,21h, 32,21h - DB 142,23h,143,23h,143,23h,145,23h,32,23h, 32,23h,145,23h, 32,23h, 32,23h - DB 142,21h,143,21h,143,21h,145,21h,32,23h, 32,21h,145,21h, 32,21h, 32,21h - DB 139,23h,134,23h,138,21h,132,23h,32,23h,131,21h,137,21h,129,21h,136,21h - DB 139,21h,134,21h,138,23h,132,21h,32,23h,131,23h,137,23h,129,23h,136,23h - DB 153,23h,148,23h,152,21h,146,23h,32,23h,145,21h,151,21h,143,21h,150,21h - DB 153,21h,148,21h,152,23h,146,21h,32,23h,145,23h,151,23h,143,23h,150,23h ; 11 - DB 139,21h,134,21h,138,21h,132,21h,32, 3h,131,21h,137,21h,129,21h,136,21h - DB 139,23h,134,23h,138,23h,132,23h,32, 3h,131,23h,137,23h,129,23h,136,23h - DB 153,21h,148,21h,152,21h,146,21h,32, 3h,145,21h,151,21h,143,21h,150,21h - DB 153,23h,148,23h,152,23h,146,23h,32, 3h,145,23h,151,23h,143,23h,150,23h - DB 128,21h,129,21h,130,21h,131,21h,32, 3h,132,21h,133,21h,134,21h,135,21h - DB 128,23h,129,23h,130,23h,131,23h,32, 3h,132,23h,133,23h,134,23h,135,23h - DB 142,21h,143,21h,144,21h,145,21h,32, 3h,146,21h,147,21h,148,21h,149,21h - DB 142,23h,143,23h,144,23h,145,23h,32, 3h,146,23h,147,23h,148,23h,149,23h - DB 128,23h,129,23h,129,23h,131,23h,32, 3h, 32,23h,131,23h, 32,23h, 32,23h - DB 128,21h,129,21h,129,21h,131,21h,32, 3h, 32,21h,131,21h, 32,21h, 32,21h - DB 142,23h,143,23h,143,23h,145,23h,32, 3h, 32,23h,145,23h, 32,23h, 32,23h - DB 142,21h,143,21h,143,21h,145,21h,32, 3h, 32,21h,145,21h, 32,21h, 32,21h - DB 139,23h,134,23h,138,21h,132,23h,32, 3h,131,21h,137,21h,129,21h,136,21h - DB 139,21h,134,21h,138,23h,132,21h,32, 3h,131,23h,137,23h,129,23h,136,23h - DB 153,23h,148,23h,152,21h,146,23h,32, 3h,145,21h,151,21h,143,21h,150,21h - DB 153,21h,148,21h,152,21h,146,21h,32, 3h,145,23h,151,21h,143,23h,150,23h ; 27 - DB 128,23h,129,23h,141,21h,131,23h,32,23h,132,21h,140,21h,134,21h,135,21h - DB 128,21h,129,21h,141,21h,131,21h,32,23h,132,23h,140,21h,134,23h,135,23h -IF TUTORIAL - DB 128,13h,129,13h,130,13h,131,13h,32,13h,132,13h,133,13h,134,13h,135,13h -ENDIF - -CharacterGenerationOffset DW 512*32 -VGAFlags DB 0 ; Bit 0 = override VGA detection - ; Bit 1 = PreserveRetrace - ; Bit 2 = Wait for VRetrace -DirectVideo DB 0 -TestBytes DB '®CHARACTERúTEST¯' - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -; InitScreen - Sets up buffer area for screen functions & character generation -; - Sets up 50 line mode -; - Sets up palette -; - Defines basic characters (128->163) -; - AX returns non-zero if error occurs - -Proc S_InitScreen Far - - Push DS - - Push CS - Pop DS - Assume DS:Screen - - Mov DirectVideo, 0 - - Test VGAFlags, 1 - JNZ S_InitScreen4 - - Trace " - VGA Detection" - -; Check for VGA - Mov AX, 1A00h - Int 10h - - Cmp BL, 8 - JGE S_InitScreen5 - - Mov DX, Offset NoVGAMsg - Mov AH, 9 - Int 21h - - Call E_UnInitEMS - - Mov AX, 4C01h ; Return to DOS with errorlevel - Int 21h - -S_InitScreen5: - Trace " - Matrox-error detection" - - Mov AX, 3 - Int 10h - - Mov AX, 1100h - Mov BX, 1001h - Mov CX, 1 - Xor DX, DX - Push CS - Pop ES - Mov BP, Offset TestBytes - Int 10h - - Call S_SetSequencer - - Push 0A000h - Pop ES - - Mov DI, 4000h - Mov SI, Offset TestBytes - - Mov CX, 4 - RepE CmpSD - JE S_InitScreen8 - - Mov CharacterGenerationOffset, 2000h - - Push Mouse - Pop FS - Assume FS:Mouse - - Mov FS:MouseCharacterGenerationOffset, 2000h - Assume FS:Nothing - -S_InitScreen8: - Call S_ResetSequencer - -S_InitScreen4: - Trace " - Screen Mode Setup" - - Call S_Set80x50Mode - - Trace " - Screen Palette Setup" - - Call S_SetPalette - - ; OK.. save all characters above 128 - - Trace " - Character Generation Setup" - - Call S_SetSequencer - - Mov AX, 0A000h - Mov DS, AX - Mov ES, AX - - Mov AX, 16 - Xor SI, SI - Mov DX, 256 - Mov DI, AX - -S_InitScreen6: - Mov CX, 4 - Rep MovsD - - Add SI, AX - Add DI, AX - - Dec DX - JNZ S_InitScreen6 - - Call S_ResetSequencer - - Push CS - Pop DS - - Mov SI, Offset CharacterDefinitions - Mov BX, (EndCharacterDefinitions-CharacterDefinitions+7) / 8 - Mov AX, 128 - Call S_RedefineCharacters - - Call S_UpdateScreen - - Pop DS - Ret - -EndP S_InitScreen - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_SaveScreen Far - - PushF - PushAD - Push DS - Push ES - - ClD - Push 0B800h - Push STORESCREENADDRESS - Pop ES - Pop DS - Xor SI, SI - Xor DI, DI - -IF USE32BITSCREENCOPY - Mov CX, 2000 - Rep MovsD -ELSE - Mov CX, 4000 - Rep MovsW -ENDIF - - Call ForceMouseRestore - - Pop ES - Pop DS - PopAD - PopF - - Ret - -EndP S_SaveScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_RestoreScreen Far - - PushF - PushAD - Push DS - Push ES - - ClD - - Call S_GetDestination - - Push STORESCREENADDRESS - Pop DS - Xor SI, SI - Xor DI, DI -IF USE32BITSCREENCOPY - Mov CX, 2000 - Rep MovsD -ELSE - Mov CX, 4000 - Rep MovsW -ENDIF - - Call ForceMouseRestore - - Pop ES - Pop DS - PopAD - PopF - - Call S_UpdateScreen - - Ret - -EndP S_RestoreScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_Set80x50Mode Far - - Push AX - Push DX - - Mov AX, 3 - Int 10h - - Mov AX, 1112h - Xor BX, BX - Int 10h - - Mov AH, 1 - Mov CH, 20h - Int 10h - - Mov AX, 1003h - Xor BX, BX - Int 10h - - Mov DX, 03C4h ; Character Map - Mov AX, 0403h - Out DX, AX - - Test CS:VGAFlags, 2 - JNZ S_Set80x50Mode1 - - Mov AX, 0101h - Out DX, AX - - Mov DX, 03C2h - Mov AL, 63h - Out DX, AL - - Mov DX, 03DAh - In AL, DX - - Mov DX, 03C0h - Mov AL, 13h - Out DX, AL - Xor AL, AL - Out DX, AL - Mov AL, 32h - Out DX, AL - -S_Set80x50Mode1: - Pop DX - Pop AX - - Ret - -EndP S_Set80x50Mode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_SetPalette2 Far - - PushA - Push DS - - Jmp SP3 - -EndP S_SetPalette2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_SetPalette Far - - PushA - Push DS - - Mov CX, 16 - -SP1: - Mov AX, 1000h - Mov BL, CL - Dec BX - Mov BH, BL -; And BH, 7 - Int 10h - - Loop SP1 - -SP3: - Mov DX, 3C8h - Xor AL, AL - Out DX, AL - - Inc DX - - Mov CX, 16*3 - - Push CS - Pop DS - - Assume DS:Screen - Mov SI, Offset PaletteDefs - -SP2: - LodsB - Out DX, AL - Loop SP2 - - Pop DS - - Assume DS:Nothing - PopA - - Ret - -EndP S_SetPalette - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -SequencerSemaphore DB 0FFh - -Proc S_SetSequencer Far - - Inc [CS:SequencerSemaphore] - JNZ S_SetSequencer1 - - Push AX - Push DX - - Mov DX, 3C4h ; Sequencer - Mov AX, 704h - Out DX, AX - - Mov AX, 402h - Out DX, AX - - Mov DX, 3CEh ; Controller - Mov AX, 204h - Out DX, AX - Mov AX, 5 - Out DX, AX - Mov AX, 406h - Out DX, AX - - Pop DX - Pop AX - -S_SetSequencer1: - Ret - -EndP S_SetSequencer - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_ResetSequencer Far - - Dec [CS:SequencerSemaphore] - JNS S_ResetSequencer1 - - Push AX - Push DX - - Mov DX, 3C4h ; Sequencer - Mov AX, 302h - Out DX, AX - Mov AX, 304h - Out DX, AX - - Mov DX, 3CEh ; Controller - Mov AX, 4 - Out DX, AX - Mov AX, 1005h - Out DX, AX - Mov AX, 0E06h - Out DX, AX - - Pop DX - Pop AX - -S_ResetSequencer1: - Ret - -EndP S_ResetSequencer - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_RedefineCharacters Far - ; DS:SI = Offset to characterdefs - ; BX = Number of characters - ; AX = First character - Push CX - Push DS - Push SI - Push ES - Push DI - - Call MouseUpdateDisable - Call NewCharacterSet - - Mov DI, 0A000h - Mov ES, DI - - Mov DI, AX - Mov CL, 5 - ShL DI, CL - - Cmp AX, 256 - JB RedefineCharacters2 - - Sub DI, 256*32 - Add DI, CS:CharacterGenerationOffset - -RedefineCharacters2: - Call S_SetSequencer - -RedefineCharacters1: - Mov CX, 8 - Rep MovsB - - Add DI, (32-8) - Dec BX - JNZ RedefineCharacters1 - - Call S_ResetSequencer - Call MouseUpdateEnable - - Pop DI - Pop ES - Pop SI - Pop DS - Pop CX - - Ret - -EndP S_RedefineCharacters - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_DefineSmallNumbers Far - - Push DS - Push SI - Push ES - Push DI - - Call MouseUpdateDisable - - Push CS - Pop DS - Mov DI, 0A000h - Mov ES, DI - - Call S_SetSequencer - - Xor DX, DX - Mov DI, CharacterGenerationOffset - -S_DefineSmallNumbers1: - Mov AL, DL - Mov AH, AL - And AX, 0FF0h - ShL AH, 4 - ShR AX, 1 - Mov BL, AH - Xor BH, BH - Mov SI, AX - And SI, 0FFh - Add BX, Offset HexNumeralDefinitions - Add SI, Offset HexNumeralDefinitions - - Mov CH, 8 - -S_DefineSmallNumbers2: - Mov AH, [BX] - Inc BX - LodsB - ShL AL, 4 - Or AL, AH - StosB - Dec CH - JNZ S_DefineSmallNumbers2 - - Inc DX - Add DI, 24 - Cmp DX, 256 - JB S_DefineSmallNumbers1 - - ; Have to define G0->G9,H0->H9 - Mov DH, 2 - Mov BX, Offset HexNumeralDefinitions+16*8 - Mov DI, 226*32 ; start at char 226. - -S_DefineSmallNumbers3: - Mov SI, Offset HexNumeralDefinitions - Mov DL, 10 - -S_DefineSmallNumbers4: - Push BX - - Mov CH, 8 - -S_DefineSmallNumbers5: - Mov AH, [BX] - ShL AH, 4 - Inc BX - LodsB - Or AL, AH - StosB - Dec CH - JNZ S_DefineSmallNumbers5 - - Pop BX - Add DI, 24 - - Dec DL - JNZ S_DefineSmallNumbers4 - - Add BX, 8 - - Dec DH - JNZ S_DefineSmallNumbers3 - - Call S_ResetSequencer - - Pop DI - Pop ES - Pop SI - Pop DS - - Call NewCharacterSet - Call MouseSecondSetDisable - Call MouseUpdateEnable - - Ret - -EndP S_DefineSmallNumbers - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_UnInitScreen Far - - Push ES - - Mov AH, 49h - Mov ES, ScreenDataArea - Int 21h - - Pop ES - - Mov AX, 3 - Int 10h - - Ret - -EndP S_UnInitScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_GetDestination Far - - Mov ES, CS:ScreenDataArea - - Cmp CS:DirectVideo, 0 - JE S_GetDestination1 - - Push AX - Mov AX, 0B800h - Mov ES, AX - Pop AX - -S_GetDestination1: - Ret - -EndP S_GetDestination - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_ClearScreen Far - - Push CX - Push ES - Push DI - - Call S_GetDestination -IF USE32BITSCREENCOPY - Mov CX, 2000 - Mov EAX, 03000300h - Xor DI, DI - Rep StosD -ELSE - Mov CX, 4000 - Mov AX, 300h - Xor DI, DI - Rep StosW -ENDIF - Pop DI - Pop ES - Pop CX - - Ret - -EndP S_ClearScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -; Style - Low byte: Box style number -; - High byte: Flags - Bit 0: Filled box/empty box; on = don't fill - -Proc S_DrawBox Far - ARG Style, Bottom, Right, Top, Left - - Push BP - Mov BP, SP - - PushA - Push DS - Push ES - - Push CS - Pop DS - - Call S_GetDestination - Mov DX, Style ; SI = Box Style - Mov AL, 18 - Mul DL ; AX = Box Style*18 - Mov SI, AX - Add SI, Offset BoxDefinitions - - Mov AX, 80 - Mul Top - Add AX, Left - Add AX, AX - - Mov DI, AX ; ES:DI points to top left - MovsW - - LodsW - Mov CX, Right - Sub CX, Left - Dec CX - Mov DX, CX ; DX = width - - Rep StosW - - MovsW ; OK.... top line drawn - - Mov BX, Bottom - Sub BX, Top - -DrawBox1: - Add DI, 156 - Sub DI, DX - Sub DI, DX - - Dec BX - JZ DrawBox3 - - Push SI - - MovsW - - LodsW - - Test Style, 100h - JNZ DrawBox2 - - Mov CX, DX - Rep StosW - - MovsW - Pop SI - - Jmp DrawBox1 - -DrawBox2: - Add DI, DX - Add DI, DX - - MovsW - - Pop SI - Jmp DrawBox1 - -DrawBox3: - Add SI, 6 - - MovsW - - LodsW - Mov CX, DX - Rep StosW - - MovsW - - Pop ES - Pop DS - PopA - - Pop BP - Ret - -EndP S_DrawBox - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_UpdateScreen Far - - Cmp CS:DirectVideo, 0 - JNE S_UpdateScreen1 - - PushAD - Push DS - Push ES - - Call MouseUpdateDisable ; * - - Mov ES, CS:ScreenDataArea - Call RestoreMouse - Call RestoreMouseGraphics - - - Test CS:VGAFlags, 4 ; Wait for vertical retrace? - JZ S_UpdateScreen2 - - Mov DX, 3DAh - -S_UpdateScreen3: - In AL, DX - Test AL, 8 - JZ S_UpdateScreen3 - -S_UpdateScreen2: - Mov ES, CS:ScreenDataArea - Call DrawMouse - - Xor SI, SI - Xor DI, DI - - Mov DS, CS:ScreenDataArea - Mov CX, 0B800h - Mov ES, CX -IF USE32BITSCREENCOPY - Mov CX, 2000 - Rep MovsD -ELSE - Mov CX, 4000 - Rep MovsW -ENDIF - - Mov ES, CS:ScreenDataArea - Call RestoreMouse - - Call MouseUpdateEnable ; * - - Pop ES - Pop DS - PopAD - -S_UpdateScreen1: - Ret - -EndP S_UpdateScreen - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_SetDirectMode Far - - Cmp CS:DirectVideo, AL - JE S_SetDirectMode2 - - And AL, AL - JZ S_SetDirectMode1 - - Call S_UpdateScreen - Jmp S_SetDirectMode2 - -S_SetDirectMode1: - PushAD - Push DS - Push ES - - Call MouseUpdateDisable - - Mov ES, CS:ScreenDataArea - Mov CX, 0B800h - Mov DS, CX - Xor SI, SI - Xor DI, DI -IF USE32BITSCREENCOPY - Mov CX, 2000 - Rep MovsD -ELSE - Mov CX, 4000 - Rep MovsW -ENDIF - - Call RestoreMouse - - Call MouseUpdateEnable ; * - - Pop ES - Pop DS - PopAD - -S_SetDirectMode2: - Mov CS:DirectVideo, AL - Ret - -EndP S_SetDirectMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_HiLight Far ; DI points to offset - ; AL = colour - ; CX = number of characters - Push ES - Push CX - Push DI - - Call S_GetDestination - -HiLight1: - Inc DI - StosB - Loop HiLight1 - - Pop DI - Pop CX - Pop ES - - Ret - -EndP S_HiLight - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_DirectDrawString Far - - Push BP - Mov BP, SP - Add BP, 6 - - Push AX - Push BX - Push CX - Push DX - Push SI - Push ES - - Mov DX, 0B800h - Mov ES, DX - Mov DX, DI - - Jmp DrawString001 - -EndP S_DirectDrawString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_DrawString Far ; DS:SI points to string - ; DI points to offset - ; AH = colour - - ; 0 = End of string - ; 13 = Next line - ; 10 = Toggle character sets - ; 0FFh, x, n = repeat character n 'x' times - ; 0FEh, x = set colour to x - ; 0FDh, 'D' = show decimal number - ; 0FDh, 'X' = show hex number - ; 0FDh, 'S' = show signed number - ; 0FDh, 'L' = show long number - - - Push BP - Mov BP, SP - Add BP, 6 - - Push AX - Push BX - Push CX - Push DX - Push SI - Push ES - - Call S_GetDestination - - Mov DX, DI - -DrawString001: - LodsB - And AL, AL - JZ DrawString002 - - Cmp AL, 0FDh - JE DrawString007 - - Cmp AL, 13 - JE DrawString003 - - Cmp AL, 10 - JE DrawString004 - - Cmp AL, 0FEh - JAE DrawString005 - - StosW - Jmp DrawString001 - -DrawString002: - Pop ES - Pop SI - Pop DX - Pop CX - Pop BX - Pop AX - Pop BP - - Ret - -DrawString003: ; Next line - Add DX, 160 - Mov DI, DX - Jmp DrawString001 - -DrawString004: ; Toggle character sets - Xor AH, 8h - Jmp DrawString001 - -DrawString005: - Cmp AL, 0FEH - JE DrawString006 - - LodsB ; RepeatCharacters - Mov CL, AL - Xor CH, CH - - LodsB - Rep StosW - Jmp DrawString001 - -DrawString006: - LodsB ; New Colour - Mov AH, AL - Jmp DrawString001 - -DrawString007: - LodsB - Cmp AL, 'D' - JE DrawString008 - - Cmp AL, 'X' - JE DrawString012 - - Cmp AL, 'L' - JE DrawString015 - - Cmp AL, 'S' - JE DrawStringSigned - - Push AX - Mov AL, 0FDh - StosW - Pop AX - StosW - Jmp DrawString001 - -DrawStringSigned: - Push AX - Push BX - Push CX - Push DX - - Mov CH, AH - - Push 0FFFFh - - Mov AX, [BP] - Mov BX, 10 - - And AX, AX - JNS DrawString009 - - Neg AX - Mov CL, '-' - Mov [ES:DI], CX - ScasW -; Add DI, 2 - Jmp DrawString009 - -DrawString008: - Push AX - Push BX - Push CX - Push DX - - Mov CH, AH - - Push 0FFFFh - - Mov AX, [BP] - Mov BX, 10 - -DrawString009: - Xor DX, DX - Div BX - - Push DX - And AX, AX - JNZ DrawString009 - -DrawString010: - Pop AX - Cmp AX, 0FFFFh - JE DrawString011 - - Mov AH, CH - Add AL, '0' - StosW - Jmp DrawString010 - -DrawString011: - Add BP, 2 - - Pop DX - Pop CX - Pop BX - Pop AX - Jmp DrawString001 - -DrawString012: - Push AX - Push BX - Push DX - - Push 0FFFFh - - Mov DX, [BP] - Add BP, 2 - -DrawString013: - Mov AL, DL - And AL, 0Fh - Cmp AL, 10 - SBB AL, 69h - DAS - Push AX - - ShR DX, 4 - JNZ DrawString013 - - Pop AX - -DrawString014: - StosW - - Pop AX - Cmp AX, 0FFFFh - JNE DrawString014 - - Pop DX - Pop BX - Pop AX - Jmp DrawString001 - -DrawString015: - Push EAX - Push EBX - Push ECX - Push EDX - - Mov CH, AH - - Push 0FFFFh - - Mov EAX, [BP] - Mov EBX, 10 - -DrawString016: - Xor EDX, EDX - Div EBX - - Push DX - And EAX, EAX - JNZ DrawString016 - -DrawString017: - Pop AX - Cmp AX, 0FFFFh - JE DrawString018 - - Mov AH, CH - Add AL, '0' - StosW - Jmp DrawString017 - -DrawString018: - Add BP, 4 - - Pop EDX - Pop ECX - Pop EBX - Pop EAX - Jmp DrawString001 - - -EndP S_DrawString - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_GetGenerationTableOffset Far ; returns ES:DI - - Mov ES, CS:ScreenDataArea - Mov DI, 8000 - - Ret - -EndP S_GetGenerationTableOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_GenerateCharacters Far ; AX = starting char. - ; BX = chars per row. - ; CX = number of rows. - PushAD - Push DS - Push ES - - Push AX - Push BX - Push CX - - Call MouseUpdateDisable - Call NewCharacterSet - - Pop CX - Pop BX - Pop AX - - Call MouseSecondSetEnable - - Call S_SetSequencer - - Mov DL, 32 - Mul DL ; AX = starting offset. - Mov DI, AX - Add DI, CharacterGenerationOffset - - Push 0A000h - Pop ES - - Mov DS, CS:ScreenDataArea - Mov SI, 8000 - - Mov DX, BX - -S_GenerateCharacters1: - Push CX - Push SI - -S_GenerateCharacters5: - Push DI - Push SI - Mov CX, 8 - -S_GenerateCharacters4: - Xor AH, AH - Mov BP, 8 - -S_GenerateCharacters2: - LodsB - - ShR AL, 1 - RCL AH, 1 - Dec BP - JNZ S_GenerateCharacters2 - - Mov AL, AH - StosB - - Mov AX, DX - ShL AX, 3 - Add SI, AX ; Add SI, 8*BX - Sub SI, 8 - Loop S_GenerateCharacters4 - - Pop SI - Add SI, 8 - - Pop DI - Add DI, 32 - - Dec BX - JNZ S_GenerateCharacters5 - - Pop SI - Mov BX, DX - - Mov AX, BX - Mov CL, 6 - ShL AX, CL - Add SI, AX - - Pop CX - - Loop S_GenerateCharacters1 ; Rows.. - - Call S_ResetSequencer - - Call MouseUpdateEnable - - Pop ES - Pop DS - PopAD - - Ret - -EndP S_GenerateCharacters - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_DrawSmallBox Far - - Mov AX, 30 - Push AX - Mov AX, 25 - Push AX - Mov AX, 49 - Push AX - Mov AX, 27 - Push AX - Mov AX, 3 - Push AX - Call S_DrawBox - Add SP, 10 - - Ret - -EndP S_DrawSmallBox - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_GetPaletteOffset Far - - Push CS - Pop DS - Mov DX, Offset PaletteDefs - - Ret - -EndP S_GetPaletteOffset - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_UsePresetPalette Far - - Mov AL, 48 - Mul Byte Ptr [DS:SI+22] - Mov SI, AX - - Mov AX, CS - Mov DS, AX - Mov ES, AX - Assume DS:Screen - - Add SI, Offset PresetPalettes - Mov DI, Offset PaletteDefs - Mov CX, 48 - Rep MovsB - - Call S_SetPalette2 - - Mov AX, 1 - Ret - -EndP S_UsePresetPalette - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_DefineHiASCII Far - - Call MouseUpdateDisable - - Call S_SetSequencer - - - Push DS - Push ES - - Mov AX, 0A000h - Mov DS, AX - Mov ES, AX - - Mov AX, 16 - Mov DI, CS:CharacterGenerationOffset - Mov SI, AX - - Xor DX, DX - -S_DefineHIASCII1: - Mov CX, AX - Rep MovsB - - Add SI, AX - Add DI, AX - Dec DL - JNZ S_DefineHIASCII1 - - Pop ES - Pop DS - - Call S_ResetSequencer - - Call NewCharacterSet - Call MouseSecondSetDisable - Call MouseUpdateEnable - - Ret - -EndP S_DefineHiASCII - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc S_InvertCursor Far ; AL = char, AH = mask. - - PushA - Push DS - Push ES - - Mov SI, 0A000h - Mov DS, SI - Mov ES, SI - - Mov SI, DX - And SI, 0FFh - ShL SI, 5 - Test DH, 8 - JZ S_InvertCursor2 - - Add SI, CS:CharacterGenerationOffset - -S_InvertCursor2: - ClI - Call S_SetSequencer - Mov CX, 8 - Mov DI, (246*32) - -S_InvertCursor1: - LodsB - Xor AL, AH - StosB - Loop S_InvertCursor1 - - Call S_ResetSequencer - StI - - Pop ES - Pop DS - PopA - Ret - -EndP S_InvertCursor - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment ScreenData PARA Public 'Data' - DB 1542 * 16 Dup (0) -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Screen Module ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +include switch.inc + + Jumps + .386 + +Segment Mouse BYTE Public 'Code' + Extrn MouseCharacterGenerationOffset:Word +EndS + + Extrn E_UnInitEMS:Far + Extrn DrawMouse:Far, RestoreMouse:Far, ForceMouseRestore:Far + Extrn RestoreMouseGraphics:Far, NewCharacterSet:Far + Extrn MouseSecondSetEnable:Far, MouseSecondSetDisable:Far + Extrn MouseUpdateEnable:Far, MouseUpdateDisable:Far + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Global S_InitScreen:Far + Global S_SetPalette:Far + Global S_UnInitScreen:Far + Global S_DrawBox:Far + Global S_UpdateScreen:Far + Global S_OverrideVGADetection:Far + Global S_SetDirectMode:Far + Global S_DrawString:Far + Global S_DirectDrawString:Far + Global S_HiLight:Far + Global S_ClearScreen:Far + Global S_GetDestination:Far + Global S_GetGenerationTableOffset:Far + Global S_GenerateCharacters:Far + Global S_SaveScreen:Far + Global S_RestoreScreen:Far + Global S_DefineSmallNumbers:Far + Global S_DefineHiASCII:Far + Global S_DrawSmallBox:Far + Global S_GetPaletteOffset:Far + Global S_SetPalette2:Far + Global S_UsePresetPalette:Far + Global S_InvertCursor:Far + + Global S_SetSequencer:Far, S_ResetSequencer:Far + + Global CharacterGenerationOffset:Word + + Public PaletteDefs + Public S_RedefineCharacters + Public VGAFlags + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Screen BYTE Public 'Code' USE16 + Assume CS:Screen, DS:Screen + +CREATENEWLOGFILE EQU 0 +include debug.inc + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +STORESCREENADDRESS EQU 0BA00h + +NoVGAMsg DB "Sorry, this program requires VGA", 13, 10 + DB "$" + +ScreenDataArea DW ScreenData + +PaletteDefs Label Byte + ; Default to camouflage + DB 0, 0, 0, 31, 22, 17, 45, 37, 30, 58, 58, 50 + DB 44, 0, 21, 63, 63, 21, 17, 38, 18, 19, 3, 6 + DB 8, 21, 0, 6, 29, 11, 14, 39, 29, 55, 58, 56 + DB 40, 40, 40, 35, 5, 21, 22, 16, 15, 13, 12, 11 + +PresetPalettes Label Byte + ; Light Blue palette + DB 0, 0, 0, 10, 25, 45, 30, 40, 55, 51, 58, 63 + DB 63, 21, 21, 21, 63, 21, 44, 44, 44, 22, 22, 22 + DB 0, 0, 32, 0, 0, 42, 30, 40, 55, 51, 58, 63 + DB 44, 44, 44, 21, 63, 21, 18, 16, 15, 12, 11, 10 ; Greyish brown + + ; Gold + DB 0, 0, 0, 20, 17, 10, 41, 36, 21, 63, 55, 33 + DB 63, 21, 21, 18, 53, 18, 38, 37, 36, 22, 22, 22 + DB 0, 0, 32, 0, 0, 42, 41, 36, 21, 48, 49, 46 + DB 44, 44, 44, 21, 50, 21, 18, 16, 15, 12, 11, 10 + + ; Camouflage / Jari Karppinen + DB 0, 0, 0, 31, 22, 17, 45, 37, 30, 58, 58, 50 + DB 44, 0, 21, 63, 63, 21, 17, 38, 18, 19, 3, 6 + DB 8, 21, 0, 6, 29, 11, 14, 39, 29, 55, 58, 56 + DB 40, 40, 40, 35, 5, 21, 22, 16, 15, 13, 12, 11 + + ; Midnight Tracking palette + DB 0, 0, 0, 0, 8, 16, 0, 19, 32, 16, 28, 48 + DB 63, 21, 21, 0, 48, 36, 32, 32, 32, 22, 22, 22 + DB 0, 0, 24, 0, 0, 32, 0, 18, 32, 40, 40, 40 + DB 32, 32, 32, 28, 0, 24, 4, 13, 20, 6, 7, 11 + + Comment ~ + ; Cool Hot Colours - Zoner / EPI / XLM + DB 11, 0, 18, 0, 0, 22, 42, 35, 33, 53, 45, 41 + DB 51, 0, 0, 34, 22, 35, 34, 33, 52, 22, 22, 22 + DB 26, 26, 32, 32, 32, 42, 41, 36, 21, 48, 49, 46 + DB 44, 44, 44, 21, 40, 21, 27, 16, 24, 21, 11, 19 + ~ + + ; Pine colours - Jari Karppinen + DB 0, 0, 0, 2, 16, 13, 21, 32, 29, 51, 58, 63 + DB 63, 34, 0, 52, 51, 33, 42, 41, 33, 31, 22, 22 + DB 12, 10, 16, 18, 0, 24, 30, 40, 55, 58, 58, 33 + DB 44, 44, 44, 49, 39, 21, 13, 15, 14, 14, 11, 14 + + ; Soundtracker - Chris Jarvis + DB 0, 0, 0, 18, 24, 28, 35, 42, 47, 51, 56, 60 + DB 63, 21, 21, 21, 63, 22, 0, 35, 63, 22, 22, 22 + DB 32, 13, 38, 37, 16, 62, 27, 40, 55, 51, 58, 63 + DB 44, 44, 44, 21, 63, 21, 18, 16, 17, 13, 14, 13 + + ; Volcanic + DB 0, 0, 0, 25, 9, 0, 40, 14, 0, 51, 23, 0 + DB 63, 8, 16, 0, 39, 5, 32, 32, 32, 0, 20, 20 + DB 21, 0, 0, 28, 0, 0, 32, 32, 32, 62, 31, 0 + DB 40, 40, 40, 0, 28, 38, 10, 16, 27, 8, 11, 19 + + Comment ~ + ; Atlantic - Delta X / NOiSE + DB 0, 0, 0, 2, 0, 30, 8, 18, 43, 21, 43, 63 + DB 63, 8, 16, 27, 32, 63, 0, 54, 63, 10, 15, 35 + DB 0, 0, 30, 0, 0, 36, 0, 18, 32, 40, 40, 40 + DB 18, 52, 63, 21, 50, 21, 10, 16, 27, 8, 11, 19 + ~ + ; Original Palette +; DB 0, 0, 0, 10, 25, 45, 30, 40, 55, 51, 58, 63 +; DB 63, 21, 21, 21, 63, 21, 44, 44, 44, 22, 22, 22 +; DB 0, 0, 32, 0, 0, 42, 30, 40, 55, 51, 58, 63 +; DB 44, 44, 44, 21, 63, 21, 18, 16, 15, 12, 11, 10 ; Greyish brown + +CharacterDefinitions Label Byte + DB 255, 128, 128, 128, 128, 128, 128, 128 ; 128 + DB 255, 0, 0, 0, 0, 0, 0, 0 ; 129 + DB 255, 1, 1, 1, 1, 1, 1, 1 ; 130 + DB 128, 128, 128, 128, 128, 128, 128, 128 ; 131 + DB 1, 1, 1, 1, 1, 1, 1, 1 ; 132 + DB 128, 128, 128, 128, 128, 128, 128, 255 ; 133 + DB 0, 0, 0, 0, 0, 0, 0, 255 ; 134 + DB 1, 1, 1, 1, 1, 1, 1, 255 ; 135 + DB 128, 0, 0, 0, 0, 0, 0, 0 ; 136 + DB 1, 0, 0, 0, 0, 0, 0, 0 ; 137 + DB 0, 0, 0, 0, 0, 0, 0, 128 ; 138 + DB 0, 0, 0, 0, 0, 0, 0, 1 ; 139 + DB 128, 192, 224, 240, 248, 252, 254,255 ; 140 + DB 255, 127, 63, 31, 15, 7, 3, 1 ; 141 + DB 255, 255, 192, 192, 192, 192, 192, 192 ; 142 + DB 255, 255, 0, 0, 0, 0, 0, 0 ; 143 + DB 255, 255, 3, 3, 3, 3, 3, 3 ; 144 + DB 192, 192, 192, 192, 192, 192, 192, 192 ; 145 + DB 3, 3, 3, 3, 3, 3, 3, 3 ; 146 + DB 192, 192, 192, 192, 192, 192, 255, 255 ; 147 + DB 0, 0, 0, 0, 0, 0, 255, 255 ; 148 + DB 3, 3, 3, 3, 3, 3, 255, 255 ; 149 + DB 192, 192, 0, 0, 0, 0, 0, 0 ; 150 + DB 3, 3, 0, 0, 0, 0, 0, 0 ; 151 + DB 0, 0, 0, 0, 0, 0, 192, 192 ; 152 + DB 0, 0, 0, 0, 0, 0, 3, 3 ; 153 + DB 0, 0, 0, 85, 0, 0, 0, 0 ; 154 +; DB 251, 155, 138, 138, 138, 138, 155, 251 ; 155 +; DB 239, 40, 41, 41, 41, 41, 40, 239 ; 156 +; DB 255, 0, 157, 85, 85, 157, 0, 255 ; 157 +; DB 255, 0, 29, 29, 20, 220, 0, 255 ; 158 +; DB 255, 0, 65, 67, 129, 131, 0, 255 ; 159 +; DB 255, 0, 171, 42, 171, 58, 0, 255 ; 160 +; DB 255, 0, 51, 170, 50, 171, 0, 255 ; 161 +; DB 255, 0, 170, 171, 171, 170, 0, 255 ; 162 +; DB 255, 1, 177, 169, 169, 177, 1, 255 ; 163 + + DB 0, 252, 252, 252, 252, 252, 252, 0 ; 155 + DB 0, 126, 126, 126, 126, 126, 126, 0 ; 156 + DB 0, 63, 63, 63, 63, 63, 63, 0 ; 157 + DB 0, 31, 31, 31, 31, 31, 31, 0 ; 158 + DB 0, 15, 15, 15, 15, 15, 15, 0 ; 159 + DB 0, 7, 7, 7, 7, 7, 7, 0 ; 160 + DB 0, 3, 3, 3, 3, 3, 3, 0 ; 161 + DB 0, 1, 1, 1, 1, 1, 1, 0 ; 162 + DB 0, 128, 128, 128, 128, 128, 128, 0 ; 163 + DB 0, 192, 192, 192, 192, 192, 192, 0 ; 164 + DB 0, 224, 224, 224, 224, 224, 224, 0 ; 165 + DB 0, 240, 240, 240, 240, 240, 240, 0 ; 166 + DB 0, 248, 248, 248, 248, 248, 248, 0 ; 167 + DB 126, 126, 126, 126, 126, 126, 126, 126 ; 168 + DB 255, 255, 0, 24, 60, 126, 255, 0 ; 169 + DB 255, 255, 0, 0, 0, 0, 24, 24 ; 170 + DB 255, 255, 0, 24, 60, 126, 255, 24 ; 171 + DB 255, 255, 0, 66, 102, 90, 66, 66 ; 172 + DB 0, 0, 0, 24, 24, 0, 0, 0 ; 173 + DB 0, 192, 192, 192, 192, 192, 192, 192 ; 174 + DB 0, 216, 216, 216, 216, 216, 216, 216 ; 175 + DB 0, 219, 219, 219, 219, 219, 219, 219 ; 176 + DB 0, 96, 96, 96, 96, 96, 96, 96 ; 177 + DB 0, 108, 108, 108, 108, 108, 108, 108 ; 178 + DB 0, 109, 109, 109, 109, 109, 109, 109 ; 179 + DB 0, 128, 128, 128, 128, 128, 128, 128 ; 180 + DB 0, 176, 176, 176, 176, 176, 176, 176 ; 181 + DB 0, 182, 182, 182, 182, 182, 182, 182 ; 182 + DB 0, 0, 24, 60, 60, 24, 0, 0 ; 183 + DB 0, 0, 0, 66h, 0, 0, 0, 0 ; 184 + DB 0, 1Eh, 21h, 40h, 0, 0, 0, 0 ; 185Sine + DB 0, 0, 0, 82h, 44h, 38h, 0, 0 ; 186 + DB 0, 3Eh, 22h, 22h, 22h, 22h, 63h, 0 ; 187Square + DB 0, 3Eh, 22h, 22h, 22h, 22h, 0E3h, 0 ; 188 + DB 0, 30h, 2Ch, 23h, 20h, 20h, 20h, 0 ; 189RampDown + DB 0, 4, 4, 4, 0C4h, 34h, 0Ch, 0 ; 190 + DB 0, 6, 4, 4, 4, 4, 6, 0 ; 191, Left bracket + DB 0, 0C0h, 40h, 40h, 40h, 40h, 0C0h, 0 ; 192, Right bracket + DB 0, 0, 0, 18h, 18h, 0, 0, 0 ; 193, Notedots + DB 0, 0, 18h, 3Ch, 3Ch, 18h, 0, 0 ; 194 + DB 0, 0, 18h, 3Ch, 3Ch, 18h, 0, 0 ; 195 + DB 0, 0, 3Ch, 3Ch, 3Ch, 3Ch, 0, 0 ; 196 + DB 0, 0, 3Ch, 3Ch, 3Ch, 3Ch, 0, 0 ; 197 + DB 0, 18h, 3Ch, 7Eh, 7Eh, 3Ch, 18h, 0 ; 198 + DB 0, 18h, 3Ch, 7Eh, 7Eh, 3Ch, 18h, 0 ; 199 + DB 0, 3Ch, 7Eh, 7Eh, 7Eh, 7Eh, 3Ch, 0 ; 200 + DB 0, 3Ch, 7Eh, 7Eh, 7Eh, 7Eh, 3Ch, 0 ; 201, end note dots + + Comment & + ; Volume bars + DB 0, 0, 0, 0, 0, 0, 0, 254 + DB 0, 0, 0, 0, 0, 254, 0, 254 + DB 0, 0, 0, 254, 0, 254, 0, 254 + DB 0, 254, 0, 254, 0, 254, 0, 254 + + Comment & + +EndCharacterDefinitions Label Byte + +HexNumeralDefinitions Label Byte + DB 4, 10, 10, 10, 10, 10, 4 ; '0' + DB 0, 4, 12, 4, 4, 4, 4, 14 ; '1' + DB 0, 4, 10, 2, 4, 4, 8, 14 ; '2' + DB 0, 12, 2, 2, 4, 2, 2, 12 ; '3' + DB 0, 10, 10, 10, 14, 2, 2, 2 ; '4' + DB 0, 14, 8, 8, 12, 2, 2, 12 ; '5' + DB 0, 4, 10, 8, 12, 10, 10, 4 ; '6' + DB 0, 14, 2, 2, 2, 2, 2, 2 ; '7' + DB 0, 4, 10, 10, 4, 10, 10, 4 ; '8' + DB 0, 14, 10, 10, 14, 2, 2, 2 ; '9' + DB 0, 4, 10, 10, 14, 10, 10, 10 ; 'A' + DB 0, 12, 10, 10, 12, 10, 10, 12 ; 'B' + DB 0, 6, 8, 8, 8, 8, 8, 6 ; 'C' + DB 0, 12, 10, 10, 10, 10, 10, 12 ; 'D' + DB 0, 14, 8, 8, 12, 8, 8, 14 ; 'E' + DB 0, 14, 8, 8, 12, 8, 8, 8 ; 'F' + DB 0, 6, 8, 8, 10, 10, 10, 6 ; 'G' + DB 0, 10, 10, 10, 14, 10, 10, 10 ; 'H' + + +BoxDefinitions Label Byte + DB 128,21h,129,21h,130,21h,131,21h,32,23h,132,21h,133,21h,134,21h,135,21h + DB 128,23h,129,23h,130,23h,131,23h,32,23h,132,23h,133,23h,134,23h,135,23h + DB 142,21h,143,21h,144,21h,145,21h,32,23h,146,21h,147,21h,148,21h,149,21h + DB 142,23h,143,23h,144,23h,145,23h,32,23h,146,23h,147,23h,148,23h,149,23h + DB 128,23h,129,23h,129,23h,131,23h,32,23h, 32,23h,131,23h, 32,23h, 32,23h + DB 128,21h,129,21h,129,21h,131,21h,32,23h, 32,21h,131,21h, 32,21h, 32,21h + DB 142,23h,143,23h,143,23h,145,23h,32,23h, 32,23h,145,23h, 32,23h, 32,23h + DB 142,21h,143,21h,143,21h,145,21h,32,23h, 32,21h,145,21h, 32,21h, 32,21h + DB 139,23h,134,23h,138,21h,132,23h,32,23h,131,21h,137,21h,129,21h,136,21h + DB 139,21h,134,21h,138,23h,132,21h,32,23h,131,23h,137,23h,129,23h,136,23h + DB 153,23h,148,23h,152,21h,146,23h,32,23h,145,21h,151,21h,143,21h,150,21h + DB 153,21h,148,21h,152,23h,146,21h,32,23h,145,23h,151,23h,143,23h,150,23h ; 11 + DB 139,21h,134,21h,138,21h,132,21h,32, 3h,131,21h,137,21h,129,21h,136,21h + DB 139,23h,134,23h,138,23h,132,23h,32, 3h,131,23h,137,23h,129,23h,136,23h + DB 153,21h,148,21h,152,21h,146,21h,32, 3h,145,21h,151,21h,143,21h,150,21h + DB 153,23h,148,23h,152,23h,146,23h,32, 3h,145,23h,151,23h,143,23h,150,23h + DB 128,21h,129,21h,130,21h,131,21h,32, 3h,132,21h,133,21h,134,21h,135,21h + DB 128,23h,129,23h,130,23h,131,23h,32, 3h,132,23h,133,23h,134,23h,135,23h + DB 142,21h,143,21h,144,21h,145,21h,32, 3h,146,21h,147,21h,148,21h,149,21h + DB 142,23h,143,23h,144,23h,145,23h,32, 3h,146,23h,147,23h,148,23h,149,23h + DB 128,23h,129,23h,129,23h,131,23h,32, 3h, 32,23h,131,23h, 32,23h, 32,23h + DB 128,21h,129,21h,129,21h,131,21h,32, 3h, 32,21h,131,21h, 32,21h, 32,21h + DB 142,23h,143,23h,143,23h,145,23h,32, 3h, 32,23h,145,23h, 32,23h, 32,23h + DB 142,21h,143,21h,143,21h,145,21h,32, 3h, 32,21h,145,21h, 32,21h, 32,21h + DB 139,23h,134,23h,138,21h,132,23h,32, 3h,131,21h,137,21h,129,21h,136,21h + DB 139,21h,134,21h,138,23h,132,21h,32, 3h,131,23h,137,23h,129,23h,136,23h + DB 153,23h,148,23h,152,21h,146,23h,32, 3h,145,21h,151,21h,143,21h,150,21h + DB 153,21h,148,21h,152,21h,146,21h,32, 3h,145,23h,151,21h,143,23h,150,23h ; 27 + DB 128,23h,129,23h,141,21h,131,23h,32,23h,132,21h,140,21h,134,21h,135,21h + DB 128,21h,129,21h,141,21h,131,21h,32,23h,132,23h,140,21h,134,23h,135,23h +IF TUTORIAL + DB 128,13h,129,13h,130,13h,131,13h,32,13h,132,13h,133,13h,134,13h,135,13h +ENDIF + +CharacterGenerationOffset DW 512*32 +VGAFlags DB 0 ; Bit 0 = override VGA detection + ; Bit 1 = PreserveRetrace + ; Bit 2 = Wait for VRetrace +DirectVideo DB 0 +TestBytes DB '®CHARACTERúTEST¯' + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +; InitScreen - Sets up buffer area for screen functions & character generation +; - Sets up 50 line mode +; - Sets up palette +; - Defines basic characters (128->163) +; - AX returns non-zero if error occurs + +Proc S_InitScreen Far + + Push DS + + Push CS + Pop DS + Assume DS:Screen + + Mov DirectVideo, 0 + + Test VGAFlags, 1 + JNZ S_InitScreen4 + + Trace " - VGA Detection" + +; Check for VGA + Mov AX, 1A00h + Int 10h + + Cmp BL, 8 + JGE S_InitScreen5 + + Mov DX, Offset NoVGAMsg + Mov AH, 9 + Int 21h + + Call E_UnInitEMS + + Mov AX, 4C01h ; Return to DOS with errorlevel + Int 21h + +S_InitScreen5: + Trace " - Matrox-error detection" + + Mov AX, 3 + Int 10h + + Mov AX, 1100h + Mov BX, 1001h + Mov CX, 1 + Xor DX, DX + Push CS + Pop ES + Mov BP, Offset TestBytes + Int 10h + + Call S_SetSequencer + + Push 0A000h + Pop ES + + Mov DI, 4000h + Mov SI, Offset TestBytes + + Mov CX, 4 + RepE CmpSD + JE S_InitScreen8 + + Mov CharacterGenerationOffset, 2000h + + Push Mouse + Pop FS + Assume FS:Mouse + + Mov FS:MouseCharacterGenerationOffset, 2000h + Assume FS:Nothing + +S_InitScreen8: + Call S_ResetSequencer + +S_InitScreen4: + Trace " - Screen Mode Setup" + + Call S_Set80x50Mode + + Trace " - Screen Palette Setup" + + Call S_SetPalette + + ; OK.. save all characters above 128 + + Trace " - Character Generation Setup" + + Call S_SetSequencer + + Mov AX, 0A000h + Mov DS, AX + Mov ES, AX + + Mov AX, 16 + Xor SI, SI + Mov DX, 256 + Mov DI, AX + +S_InitScreen6: + Mov CX, 4 + Rep MovsD + + Add SI, AX + Add DI, AX + + Dec DX + JNZ S_InitScreen6 + + Call S_ResetSequencer + + Push CS + Pop DS + + Mov SI, Offset CharacterDefinitions + Mov BX, (EndCharacterDefinitions-CharacterDefinitions+7) / 8 + Mov AX, 128 + Call S_RedefineCharacters + + Call S_UpdateScreen + + Pop DS + Ret + +EndP S_InitScreen + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_SaveScreen Far + + PushF + PushAD + Push DS + Push ES + + ClD + Push 0B800h + Push STORESCREENADDRESS + Pop ES + Pop DS + Xor SI, SI + Xor DI, DI + +IF USE32BITSCREENCOPY + Mov CX, 2000 + Rep MovsD +ELSE + Mov CX, 4000 + Rep MovsW +ENDIF + + Call ForceMouseRestore + + Pop ES + Pop DS + PopAD + PopF + + Ret + +EndP S_SaveScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_RestoreScreen Far + + PushF + PushAD + Push DS + Push ES + + ClD + + Call S_GetDestination + + Push STORESCREENADDRESS + Pop DS + Xor SI, SI + Xor DI, DI +IF USE32BITSCREENCOPY + Mov CX, 2000 + Rep MovsD +ELSE + Mov CX, 4000 + Rep MovsW +ENDIF + + Call ForceMouseRestore + + Pop ES + Pop DS + PopAD + PopF + + Call S_UpdateScreen + + Ret + +EndP S_RestoreScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_Set80x50Mode Far + + Push AX + Push DX + + Mov AX, 3 + Int 10h + + Mov AX, 1112h + Xor BX, BX + Int 10h + + Mov AH, 1 + Mov CH, 20h + Int 10h + + Mov AX, 1003h + Xor BX, BX + Int 10h + + Mov DX, 03C4h ; Character Map + Mov AX, 0403h + Out DX, AX + + Test CS:VGAFlags, 2 + JNZ S_Set80x50Mode1 + + Mov AX, 0101h + Out DX, AX + + Mov DX, 03C2h + Mov AL, 63h + Out DX, AL + + Mov DX, 03DAh + In AL, DX + + Mov DX, 03C0h + Mov AL, 13h + Out DX, AL + Xor AL, AL + Out DX, AL + Mov AL, 32h + Out DX, AL + +S_Set80x50Mode1: + Pop DX + Pop AX + + Ret + +EndP S_Set80x50Mode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_SetPalette2 Far + + PushA + Push DS + + Jmp SP3 + +EndP S_SetPalette2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_SetPalette Far + + PushA + Push DS + + Mov CX, 16 + +SP1: + Mov AX, 1000h + Mov BL, CL + Dec BX + Mov BH, BL +; And BH, 7 + Int 10h + + Loop SP1 + +SP3: + Mov DX, 3C8h + Xor AL, AL + Out DX, AL + + Inc DX + + Mov CX, 16*3 + + Push CS + Pop DS + + Assume DS:Screen + Mov SI, Offset PaletteDefs + +SP2: + LodsB + Out DX, AL + Loop SP2 + + Pop DS + + Assume DS:Nothing + PopA + + Ret + +EndP S_SetPalette + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +SequencerSemaphore DB 0FFh + +Proc S_SetSequencer Far + + Inc [CS:SequencerSemaphore] + JNZ S_SetSequencer1 + + Push AX + Push DX + + Mov DX, 3C4h ; Sequencer + Mov AX, 704h + Out DX, AX + + Mov AX, 402h + Out DX, AX + + Mov DX, 3CEh ; Controller + Mov AX, 204h + Out DX, AX + Mov AX, 5 + Out DX, AX + Mov AX, 406h + Out DX, AX + + Pop DX + Pop AX + +S_SetSequencer1: + Ret + +EndP S_SetSequencer + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_ResetSequencer Far + + Dec [CS:SequencerSemaphore] + JNS S_ResetSequencer1 + + Push AX + Push DX + + Mov DX, 3C4h ; Sequencer + Mov AX, 302h + Out DX, AX + Mov AX, 304h + Out DX, AX + + Mov DX, 3CEh ; Controller + Mov AX, 4 + Out DX, AX + Mov AX, 1005h + Out DX, AX + Mov AX, 0E06h + Out DX, AX + + Pop DX + Pop AX + +S_ResetSequencer1: + Ret + +EndP S_ResetSequencer + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_RedefineCharacters Far + ; DS:SI = Offset to characterdefs + ; BX = Number of characters + ; AX = First character + Push CX + Push DS + Push SI + Push ES + Push DI + + Call MouseUpdateDisable + Call NewCharacterSet + + Mov DI, 0A000h + Mov ES, DI + + Mov DI, AX + Mov CL, 5 + ShL DI, CL + + Cmp AX, 256 + JB RedefineCharacters2 + + Sub DI, 256*32 + Add DI, CS:CharacterGenerationOffset + +RedefineCharacters2: + Call S_SetSequencer + +RedefineCharacters1: + Mov CX, 8 + Rep MovsB + + Add DI, (32-8) + Dec BX + JNZ RedefineCharacters1 + + Call S_ResetSequencer + Call MouseUpdateEnable + + Pop DI + Pop ES + Pop SI + Pop DS + Pop CX + + Ret + +EndP S_RedefineCharacters + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_DefineSmallNumbers Far + + Push DS + Push SI + Push ES + Push DI + + Call MouseUpdateDisable + + Push CS + Pop DS + Mov DI, 0A000h + Mov ES, DI + + Call S_SetSequencer + + Xor DX, DX + Mov DI, CharacterGenerationOffset + +S_DefineSmallNumbers1: + Mov AL, DL + Mov AH, AL + And AX, 0FF0h + ShL AH, 4 + ShR AX, 1 + Mov BL, AH + Xor BH, BH + Mov SI, AX + And SI, 0FFh + Add BX, Offset HexNumeralDefinitions + Add SI, Offset HexNumeralDefinitions + + Mov CH, 8 + +S_DefineSmallNumbers2: + Mov AH, [BX] + Inc BX + LodsB + ShL AL, 4 + Or AL, AH + StosB + Dec CH + JNZ S_DefineSmallNumbers2 + + Inc DX + Add DI, 24 + Cmp DX, 256 + JB S_DefineSmallNumbers1 + + ; Have to define G0->G9,H0->H9 + Mov DH, 2 + Mov BX, Offset HexNumeralDefinitions+16*8 + Mov DI, 226*32 ; start at char 226. + +S_DefineSmallNumbers3: + Mov SI, Offset HexNumeralDefinitions + Mov DL, 10 + +S_DefineSmallNumbers4: + Push BX + + Mov CH, 8 + +S_DefineSmallNumbers5: + Mov AH, [BX] + ShL AH, 4 + Inc BX + LodsB + Or AL, AH + StosB + Dec CH + JNZ S_DefineSmallNumbers5 + + Pop BX + Add DI, 24 + + Dec DL + JNZ S_DefineSmallNumbers4 + + Add BX, 8 + + Dec DH + JNZ S_DefineSmallNumbers3 + + Call S_ResetSequencer + + Pop DI + Pop ES + Pop SI + Pop DS + + Call NewCharacterSet + Call MouseSecondSetDisable + Call MouseUpdateEnable + + Ret + +EndP S_DefineSmallNumbers + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_UnInitScreen Far + + Push ES + + Mov AH, 49h + Mov ES, ScreenDataArea + Int 21h + + Pop ES + + Mov AX, 3 + Int 10h + + Ret + +EndP S_UnInitScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_GetDestination Far + + Mov ES, CS:ScreenDataArea + + Cmp CS:DirectVideo, 0 + JE S_GetDestination1 + + Push AX + Mov AX, 0B800h + Mov ES, AX + Pop AX + +S_GetDestination1: + Ret + +EndP S_GetDestination + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_ClearScreen Far + + Push CX + Push ES + Push DI + + Call S_GetDestination +IF USE32BITSCREENCOPY + Mov CX, 2000 + Mov EAX, 03000300h + Xor DI, DI + Rep StosD +ELSE + Mov CX, 4000 + Mov AX, 300h + Xor DI, DI + Rep StosW +ENDIF + Pop DI + Pop ES + Pop CX + + Ret + +EndP S_ClearScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +; Style - Low byte: Box style number +; - High byte: Flags - Bit 0: Filled box/empty box; on = don't fill + +Proc S_DrawBox Far + ARG Style, Bottom, Right, Top, Left + + Push BP + Mov BP, SP + + PushA + Push DS + Push ES + + Push CS + Pop DS + + Call S_GetDestination + Mov DX, Style ; SI = Box Style + Mov AL, 18 + Mul DL ; AX = Box Style*18 + Mov SI, AX + Add SI, Offset BoxDefinitions + + Mov AX, 80 + Mul Top + Add AX, Left + Add AX, AX + + Mov DI, AX ; ES:DI points to top left + MovsW + + LodsW + Mov CX, Right + Sub CX, Left + Dec CX + Mov DX, CX ; DX = width + + Rep StosW + + MovsW ; OK.... top line drawn + + Mov BX, Bottom + Sub BX, Top + +DrawBox1: + Add DI, 156 + Sub DI, DX + Sub DI, DX + + Dec BX + JZ DrawBox3 + + Push SI + + MovsW + + LodsW + + Test Style, 100h + JNZ DrawBox2 + + Mov CX, DX + Rep StosW + + MovsW + Pop SI + + Jmp DrawBox1 + +DrawBox2: + Add DI, DX + Add DI, DX + + MovsW + + Pop SI + Jmp DrawBox1 + +DrawBox3: + Add SI, 6 + + MovsW + + LodsW + Mov CX, DX + Rep StosW + + MovsW + + Pop ES + Pop DS + PopA + + Pop BP + Ret + +EndP S_DrawBox + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_UpdateScreen Far + + Cmp CS:DirectVideo, 0 + JNE S_UpdateScreen1 + + PushAD + Push DS + Push ES + + Call MouseUpdateDisable ; * + + Mov ES, CS:ScreenDataArea + Call RestoreMouse + Call RestoreMouseGraphics + + + Test CS:VGAFlags, 4 ; Wait for vertical retrace? + JZ S_UpdateScreen2 + + Mov DX, 3DAh + +S_UpdateScreen3: + In AL, DX + Test AL, 8 + JZ S_UpdateScreen3 + +S_UpdateScreen2: + Mov ES, CS:ScreenDataArea + Call DrawMouse + + Xor SI, SI + Xor DI, DI + + Mov DS, CS:ScreenDataArea + Mov CX, 0B800h + Mov ES, CX +IF USE32BITSCREENCOPY + Mov CX, 2000 + Rep MovsD +ELSE + Mov CX, 4000 + Rep MovsW +ENDIF + + Mov ES, CS:ScreenDataArea + Call RestoreMouse + + Call MouseUpdateEnable ; * + + Pop ES + Pop DS + PopAD + +S_UpdateScreen1: + Ret + +EndP S_UpdateScreen + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_SetDirectMode Far + + Cmp CS:DirectVideo, AL + JE S_SetDirectMode2 + + And AL, AL + JZ S_SetDirectMode1 + + Call S_UpdateScreen + Jmp S_SetDirectMode2 + +S_SetDirectMode1: + PushAD + Push DS + Push ES + + Call MouseUpdateDisable + + Mov ES, CS:ScreenDataArea + Mov CX, 0B800h + Mov DS, CX + Xor SI, SI + Xor DI, DI +IF USE32BITSCREENCOPY + Mov CX, 2000 + Rep MovsD +ELSE + Mov CX, 4000 + Rep MovsW +ENDIF + + Call RestoreMouse + + Call MouseUpdateEnable ; * + + Pop ES + Pop DS + PopAD + +S_SetDirectMode2: + Mov CS:DirectVideo, AL + Ret + +EndP S_SetDirectMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_HiLight Far ; DI points to offset + ; AL = colour + ; CX = number of characters + Push ES + Push CX + Push DI + + Call S_GetDestination + +HiLight1: + Inc DI + StosB + Loop HiLight1 + + Pop DI + Pop CX + Pop ES + + Ret + +EndP S_HiLight + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_DirectDrawString Far + + Push BP + Mov BP, SP + Add BP, 6 + + Push AX + Push BX + Push CX + Push DX + Push SI + Push ES + + Mov DX, 0B800h + Mov ES, DX + Mov DX, DI + + Jmp DrawString001 + +EndP S_DirectDrawString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_DrawString Far ; DS:SI points to string + ; DI points to offset + ; AH = colour + + ; 0 = End of string + ; 13 = Next line + ; 10 = Toggle character sets + ; 0FFh, x, n = repeat character n 'x' times + ; 0FEh, x = set colour to x + ; 0FDh, 'D' = show decimal number + ; 0FDh, 'X' = show hex number + ; 0FDh, 'S' = show signed number + ; 0FDh, 'L' = show long number + + + Push BP + Mov BP, SP + Add BP, 6 + + Push AX + Push BX + Push CX + Push DX + Push SI + Push ES + + Call S_GetDestination + + Mov DX, DI + +DrawString001: + LodsB + And AL, AL + JZ DrawString002 + + Cmp AL, 0FDh + JE DrawString007 + + Cmp AL, 13 + JE DrawString003 + + Cmp AL, 10 + JE DrawString004 + + Cmp AL, 0FEh + JAE DrawString005 + + StosW + Jmp DrawString001 + +DrawString002: + Pop ES + Pop SI + Pop DX + Pop CX + Pop BX + Pop AX + Pop BP + + Ret + +DrawString003: ; Next line + Add DX, 160 + Mov DI, DX + Jmp DrawString001 + +DrawString004: ; Toggle character sets + Xor AH, 8h + Jmp DrawString001 + +DrawString005: + Cmp AL, 0FEH + JE DrawString006 + + LodsB ; RepeatCharacters + Mov CL, AL + Xor CH, CH + + LodsB + Rep StosW + Jmp DrawString001 + +DrawString006: + LodsB ; New Colour + Mov AH, AL + Jmp DrawString001 + +DrawString007: + LodsB + Cmp AL, 'D' + JE DrawString008 + + Cmp AL, 'X' + JE DrawString012 + + Cmp AL, 'L' + JE DrawString015 + + Cmp AL, 'S' + JE DrawStringSigned + + Push AX + Mov AL, 0FDh + StosW + Pop AX + StosW + Jmp DrawString001 + +DrawStringSigned: + Push AX + Push BX + Push CX + Push DX + + Mov CH, AH + + Push 0FFFFh + + Mov AX, [BP] + Mov BX, 10 + + And AX, AX + JNS DrawString009 + + Neg AX + Mov CL, '-' + Mov [ES:DI], CX + ScasW +; Add DI, 2 + Jmp DrawString009 + +DrawString008: + Push AX + Push BX + Push CX + Push DX + + Mov CH, AH + + Push 0FFFFh + + Mov AX, [BP] + Mov BX, 10 + +DrawString009: + Xor DX, DX + Div BX + + Push DX + And AX, AX + JNZ DrawString009 + +DrawString010: + Pop AX + Cmp AX, 0FFFFh + JE DrawString011 + + Mov AH, CH + Add AL, '0' + StosW + Jmp DrawString010 + +DrawString011: + Add BP, 2 + + Pop DX + Pop CX + Pop BX + Pop AX + Jmp DrawString001 + +DrawString012: + Push AX + Push BX + Push DX + + Push 0FFFFh + + Mov DX, [BP] + Add BP, 2 + +DrawString013: + Mov AL, DL + And AL, 0Fh + Cmp AL, 10 + SBB AL, 69h + DAS + Push AX + + ShR DX, 4 + JNZ DrawString013 + + Pop AX + +DrawString014: + StosW + + Pop AX + Cmp AX, 0FFFFh + JNE DrawString014 + + Pop DX + Pop BX + Pop AX + Jmp DrawString001 + +DrawString015: + Push EAX + Push EBX + Push ECX + Push EDX + + Mov CH, AH + + Push 0FFFFh + + Mov EAX, [BP] + Mov EBX, 10 + +DrawString016: + Xor EDX, EDX + Div EBX + + Push DX + And EAX, EAX + JNZ DrawString016 + +DrawString017: + Pop AX + Cmp AX, 0FFFFh + JE DrawString018 + + Mov AH, CH + Add AL, '0' + StosW + Jmp DrawString017 + +DrawString018: + Add BP, 4 + + Pop EDX + Pop ECX + Pop EBX + Pop EAX + Jmp DrawString001 + + +EndP S_DrawString + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_GetGenerationTableOffset Far ; returns ES:DI + + Mov ES, CS:ScreenDataArea + Mov DI, 8000 + + Ret + +EndP S_GetGenerationTableOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_GenerateCharacters Far ; AX = starting char. + ; BX = chars per row. + ; CX = number of rows. + PushAD + Push DS + Push ES + + Push AX + Push BX + Push CX + + Call MouseUpdateDisable + Call NewCharacterSet + + Pop CX + Pop BX + Pop AX + + Call MouseSecondSetEnable + + Call S_SetSequencer + + Mov DL, 32 + Mul DL ; AX = starting offset. + Mov DI, AX + Add DI, CharacterGenerationOffset + + Push 0A000h + Pop ES + + Mov DS, CS:ScreenDataArea + Mov SI, 8000 + + Mov DX, BX + +S_GenerateCharacters1: + Push CX + Push SI + +S_GenerateCharacters5: + Push DI + Push SI + Mov CX, 8 + +S_GenerateCharacters4: + Xor AH, AH + Mov BP, 8 + +S_GenerateCharacters2: + LodsB + + ShR AL, 1 + RCL AH, 1 + Dec BP + JNZ S_GenerateCharacters2 + + Mov AL, AH + StosB + + Mov AX, DX + ShL AX, 3 + Add SI, AX ; Add SI, 8*BX + Sub SI, 8 + Loop S_GenerateCharacters4 + + Pop SI + Add SI, 8 + + Pop DI + Add DI, 32 + + Dec BX + JNZ S_GenerateCharacters5 + + Pop SI + Mov BX, DX + + Mov AX, BX + Mov CL, 6 + ShL AX, CL + Add SI, AX + + Pop CX + + Loop S_GenerateCharacters1 ; Rows.. + + Call S_ResetSequencer + + Call MouseUpdateEnable + + Pop ES + Pop DS + PopAD + + Ret + +EndP S_GenerateCharacters + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_DrawSmallBox Far + + Mov AX, 30 + Push AX + Mov AX, 25 + Push AX + Mov AX, 49 + Push AX + Mov AX, 27 + Push AX + Mov AX, 3 + Push AX + Call S_DrawBox + Add SP, 10 + + Ret + +EndP S_DrawSmallBox + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_GetPaletteOffset Far + + Push CS + Pop DS + Mov DX, Offset PaletteDefs + + Ret + +EndP S_GetPaletteOffset + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_UsePresetPalette Far + + Mov AL, 48 + Mul Byte Ptr [DS:SI+22] + Mov SI, AX + + Mov AX, CS + Mov DS, AX + Mov ES, AX + Assume DS:Screen + + Add SI, Offset PresetPalettes + Mov DI, Offset PaletteDefs + Mov CX, 48 + Rep MovsB + + Call S_SetPalette2 + + Mov AX, 1 + Ret + +EndP S_UsePresetPalette + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_DefineHiASCII Far + + Call MouseUpdateDisable + + Call S_SetSequencer + + + Push DS + Push ES + + Mov AX, 0A000h + Mov DS, AX + Mov ES, AX + + Mov AX, 16 + Mov DI, CS:CharacterGenerationOffset + Mov SI, AX + + Xor DX, DX + +S_DefineHIASCII1: + Mov CX, AX + Rep MovsB + + Add SI, AX + Add DI, AX + Dec DL + JNZ S_DefineHIASCII1 + + Pop ES + Pop DS + + Call S_ResetSequencer + + Call NewCharacterSet + Call MouseSecondSetDisable + Call MouseUpdateEnable + + Ret + +EndP S_DefineHiASCII + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc S_InvertCursor Far ; AL = char, AH = mask. + + PushA + Push DS + Push ES + + Mov SI, 0A000h + Mov DS, SI + Mov ES, SI + + Mov SI, DX + And SI, 0FFh + ShL SI, 5 + Test DH, 8 + JZ S_InvertCursor2 + + Add SI, CS:CharacterGenerationOffset + +S_InvertCursor2: + ClI + Call S_SetSequencer + Mov CX, 8 + Mov DI, (246*32) + +S_InvertCursor1: + LodsB + Xor AL, AH + StosB + Loop S_InvertCursor1 + + Call S_ResetSequencer + StI + + Pop ES + Pop DS + PopA + Ret + +EndP S_InvertCursor + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment ScreenData PARA Public 'Data' + DB 1542 * 16 Dup (0) +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +End diff --git a/IT_TIMER.INC b/it_timer.inc similarity index 96% rename from IT_TIMER.INC rename to it_timer.inc index 2c4d844..0739d8b 100644 --- a/IT_TIMER.INC +++ b/it_timer.inc @@ -1,90 +1,90 @@ - -Proc GetCurrentTime - - Push DS - Push ES - - Push CS - Pop DS - Assume DS:Disk - - Cmp TimerData, 0 - JE GetCurrentTimeEnd - - Mov ES, TimerData - Mov DI, NumTimerData - ShL DI, 3 - - Mov AH, 2Ah - Int 21h ; Get Date - Mov AX, CX ; Now to get date in yyyyyyym mmmddddd - Sub AX, 1980 - ShL AX, 9 ; Year - Or AL, DL ; Day - Xor DL, DL - ShR DX, 3 - Or AX, DX ; Month - StosW - - Mov AH, 2Ch - Int 21h ; Get time - Mov AX, CX ; Now to get time in hhhhhmmm mmmsssss - ShL AL, 2 ; AX = ...hhhhh mmmmmm.. - ShL AX, 3 ; AX = hhhhhmmm mmm..... - ShR DH, 1 ; DH = ...sssss - Or AL, DH - StosW - -GetCurrentTimeEnd: - Pop ES - Pop DS - Ret - -EndP GetCurrentTime - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc CheckTimerData - Assume DS:Disk - - Cmp TimerData, 0 - JNE CheckTimerData1 - - Mov NumTimerData, 0 - Mov AH, 48h - Mov BX, 1 - Int 21h - JC CheckTimerData1 - - Mov TimerData, AX - Call GetCurrentTime - -CheckTimerData1: - Ret - -EndP CheckTimerData - Assume DS:Nothing - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc ReleaseTimerData - - Mov AX, CS:TimerData - Test AX, AX - JZ ReleaseTimerData1 - - Mov ES, AX - Mov AH, 49h - Int 21h - Xor AX, AX - -ReleaseTimerData1: - Mov CS:TimerData, AX - Mov CS:NumTimerData, AX - - Ret - -EndP ReleaseTimerData - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc GetCurrentTime + + Push DS + Push ES + + Push CS + Pop DS + Assume DS:Disk + + Cmp TimerData, 0 + JE GetCurrentTimeEnd + + Mov ES, TimerData + Mov DI, NumTimerData + ShL DI, 3 + + Mov AH, 2Ah + Int 21h ; Get Date + Mov AX, CX ; Now to get date in yyyyyyym mmmddddd + Sub AX, 1980 + ShL AX, 9 ; Year + Or AL, DL ; Day + Xor DL, DL + ShR DX, 3 + Or AX, DX ; Month + StosW + + Mov AH, 2Ch + Int 21h ; Get time + Mov AX, CX ; Now to get time in hhhhhmmm mmmsssss + ShL AL, 2 ; AX = ...hhhhh mmmmmm.. + ShL AX, 3 ; AX = hhhhhmmm mmm..... + ShR DH, 1 ; DH = ...sssss + Or AL, DH + StosW + +GetCurrentTimeEnd: + Pop ES + Pop DS + Ret + +EndP GetCurrentTime + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc CheckTimerData + Assume DS:Disk + + Cmp TimerData, 0 + JNE CheckTimerData1 + + Mov NumTimerData, 0 + Mov AH, 48h + Mov BX, 1 + Int 21h + JC CheckTimerData1 + + Mov TimerData, AX + Call GetCurrentTime + +CheckTimerData1: + Ret + +EndP CheckTimerData + Assume DS:Nothing + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc ReleaseTimerData + + Mov AX, CS:TimerData + Test AX, AX + JZ ReleaseTimerData1 + + Mov ES, AX + Mov AH, 49h + Int 21h + Xor AX, AX + +ReleaseTimerData1: + Mov CS:TimerData, AX + Mov CS:NumTimerData, AX + + Ret + +EndP ReleaseTimerData + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ diff --git a/IT_TUTE.ASM b/it_tute.s similarity index 97% rename from IT_TUTE.ASM rename to it_tute.s index 40aafb3..db2c0e1 100644 --- a/IT_TUTE.ASM +++ b/it_tute.s @@ -1,519 +1,519 @@ - - Jumps - .386 - -include switch.inc - -IF TUTORIAL - - Extrn S_DrawBox:Far - Extrn S_DrawString:Far - Extrn Music_GetSongSegment:Far - Extrn Music_GetPlayMode:Far - Extrn PE_GetLastInstrument:Far ; Returns BX = LastInst-1 - -Segment Pattern BYTE Public 'Code' - Extrn PatternDataArea:Word - Extrn LastKeyBoard1:Word - Extrn LastKeyBoard2:Word -EndS - -Segment Disk Byte Public 'Code' USE16 - Extrn SamplesInModule:Byte - Extrn InSampleFileName:Byte -EndS - - Public Glbl_TutorialHandler - -Segment Glbl BYTE Public 'Code' USE16 - Assume CS:Glbl, DS:Nothing, GS:Pattern - -Extrn CurrentMode:Byte - -TutorialState DW 0 - - -; TutorialInfo structure: -; DW Offset function -; DB x, y (top left) -; DB x, y (bottom right) -; DB colour -; DB Message, 0 - -TutorialFunctionArray Label Word - DW Offset Tute_State0 - DW Offset Tute_State1 - DW Offset Tute_State2 - DW Offset Tute_State3 - DW Offset Tute_State4 - DW Offset Tute_State5 - DW Offset Tute_State6 - DW Offset Tute_State7 - DW Offset Tute_State8 - DW Offset Tute_State9 - DW Offset Tute_State10 - DW Offset Tute_State1 - DW Offset Tute_State12 - DW Offset Tute_State2 - DW Offset Tute_State14 - DW Offset Tute_State5 - DW Offset Tute_State16 - DW Offset Tute_State9 - DW Offset Tute_State18 - DW Offset Tute_State19 - DW Offset Tute_StateEnd - -MAXTUTESTATE = ($-Offset TutorialFunctionArray)/2 - - -TutorialInfoArray Label Word - DW Offset TutorialDisplayState0 - DW Offset TutorialDisplayState1 - DW Offset TutorialDisplayState2 - DW Offset TutorialDisplayState3 - DW Offset TutorialDisplayState4 - DW Offset TutorialDisplayState5 - DW Offset TutorialDisplayState6 - DW Offset TutorialDisplayState7 - DW Offset TutorialDisplayState8 - DW Offset TutorialDisplayState9 - DW Offset TutorialDisplayState10 - DW Offset TutorialDisplayState11 - DW Offset TutorialDisplayState12 - DW Offset TutorialDisplayState13 - DW Offset TutorialDisplayState14 - DW Offset TutorialDisplayState15 - DW Offset TutorialDisplayState16 - DW Offset TutorialDisplayState17 - DW Offset TutorialDisplayState18 - DW Offset TutorialDisplayState19 - DW Offset TutorialDisplayState20 - DW Offset TutorialDisplayStatexx - -TutorialDisplayState0 DB 0, 40, 79, 49 - DB 0FFh, 20, " Welcome to the Impulse Tracker Tutorial!", 13, 13 - DB "This tutorial was designed to provide you with a basic understanding of how", 13 - DB "this program works. Everything that you learn here is exactly the same as in", 13 - DB "the main program. By the end of this tutorial, you should be able to compose", 13 - DB "your own modules!", 13, 13 - DB "Good luck! (Press Enter to continue)", 0 - -TutorialDisplayState1 DB 0, 0, 79, 4 - DB "This is the load-module screen that Impulse Tracker will normally begin with.", 13 - DB "As we will start a song afresh, switch to the sample list screen by pressing", 13 - DB "F3.", 0 - -TutorialDisplayState2 DB 36, 1, 78, 13 - DB "There are two basic elements to an", 13 - DB "Impulse Tracker module: patterns and", 13 - DB "samples. Samples provide all the 'real'", 13 - DB "sound information to the program. These", 13 - DB "sounds can be instruments, voices, WAV", 13 - DB "files - anything you like! IT understands", 13 - DB "a wide variety of sound files and even", 13 - DB "allows you to take sounds directly from", 13 - DB "other modules. Since there are no samples", 13 - DB "currently loaded, press Enter to switch", 13 - DB "to the load sample screen.", 0 - -TutorialDisplayState3 DB 0, 0, 79, 5 - DB "A file called TUTE.IT was included with this tutorial. You should be able to", 13 - DB "see it highlighted in the listing below. IT will hilight any file that it", 13 - DB "recognises as a sound file. You can also navigate through your directories", 13 - DB "from this menu. Select TUTE.IT and step into it by pressing Enter.", 0 - -TutorialDisplayState4 DB 2, 28, 45, 39 - DB "Here you can see a list of all the samples", 13 - DB "that are contained within TUTE.IT. To have", 13 - DB "a listen to how they sound, press the down", 13 - DB "arrow once to hilight the first sample and", 13 - DB "press 'Q'. Try moving to the other samples", 13 - DB "and playing them. Try pressing 'W', 'E',", 13 - DB "'R'. You will notice that the samples are", 13 - DB "played at a different pitch. Once you've", 13 - DB "heard all of the samples, select the Bass", 13 - DB "Drum and press Enter.", 0 - -TutorialDisplayState5 DB 36, 14, 78, 20 - DB "OK! You have now loaded the Bass Drum", 13 - DB "into memory. This means that you can use", 13 - DB "it in your songs. Lets do that now!", 13, 13 - DB "Press F2 to go to the pattern editor.", 0 - -TutorialDisplayState6 DB 33, 16, 78, 19 - DB "The pattern editor is where you set out the", 13 - DB "notes that you want to play. Press 'Q'", 0 - -TutorialDisplayState7 DB 33, 16, 78, 35 - DB "So what does this mean?", 13, 13 - DB "C-5 01 ", 173, 173, " .00", 13, 13 - DB "C-5 means to play the note C at octave 5.", 13 - DB "01 means to use sample number 1.", 13, 13 - DB "If this doesn't make sense now, don't worry!", 13 - DB "All of this will be explained later in this", 13 - DB "tutorial.", 13, 13 - DB "For now, try to enter a Bass Drum every four", 13 - DB "rows in Channel 1 (ie. on row 4, 8, 12, ...)", 13, 13 - DB "Continue to use 'Q' to enter the notes. The", 13 - DB "arrow keys may be of assistance. If you make", 13 - DB "a mistake, use the '.' key to blank out the", 13 - DB "entry.", 0 - -TutorialDisplayState8 DB 33, 16, 78, 21 - DB "OK, that's enough!", 13, 13 - DB "Lets take a listen to what you've done.", 13 - DB "Press F6 to play what you've entered.", 0 - -TutorialDisplayState9 DB 33, 16, 78, 23 - DB "As the pattern is played to you, you will", 13 - DB "notice that a cursor on the left hand side", 13 - DB "of the screen indicates the current playback", 13 - DB "position. Press F6 to watch that again.", 13, 13 - DB "When you're ready, press F8 to stop playback", 0 - -TutorialDisplayState10 DB 33, 16, 78, 25 - DB "To finish off the task of entering the Bass", 13 - DB "Drum, move up one row to row 16 and press", 13 - DB "Alt-4. This will cause the cursor to step", 13 - DB "4 rows after every note that you enter", 13 - DB "instead of 1.", 13, 13 - DB "Hold down 'Q' until Channel 1 has a Bass", 13 - DB "Drum every 4 rows until row 60.", 0 - -TutorialDisplayState11 DB 33, 16, 78, 21 - DB "Now we'll add in a snare drum. Before we do", 13 - DB "that though, set the cursor step back to", 13 - DB "a single row at a time. Press Alt-1, then", 13 - DB "F3 to go back to the sample list.", 0 - -TutorialDisplayState12 DB 36, 14, 78, 18 - DB "To load a sample into the second sample", 13 - DB "slot, first press the down arrow a single", 13 - DB "time so that sample two is hilighted.", 0 - -TutorialDisplayState13 DB 36, 14, 72, 17 - DB "Now press Enter to call up the Load", 13 - DB "Sample screen.", 0 - -TutorialDisplayState14 DB 7, 25, 42, 28 - DB "Select the Snare Drum and load it", 13 - DB "(by pressing Enter).", 0 - -TutorialDisplayState15 DB 36, 14, 74, 17 - DB "And now return to the Pattern Editor", 13 - DB "(F2)", 0 - -TutorialDisplayState16 DB 36, 16, 78, 24 - DB "Press Ctrl-PgUp to move to the top of", 13 - DB "the pattern and enter a snare drum in", 13 - DB "every 4th row starting at line 2.", 13 - DB 13 - DB "Use C-5 again, and to make it easier, you", 13 - DB "can set the skip to 4 once you've moved", 13 - DB "to line 2.", 0 - -TutorialDisplayState17 DB 34, 16, 78, 19 - DB "Have a listen to what you've just created!", 13 - DB "(Press F6)", 0 - -TutorialDisplayState18 DB 36, 16, 78, 28 - DB "As part of this tutorial, we'll try out", 13 - DB "one of the block functions that IT", 13 - DB "offers. Our goal is to halve the speed", 13 - DB "at which this plays just by modifying", 13 - DB "the pattern data. IT has two functions", 13 - DB "that will automatically halve or double", 13 - DB "the length of a hilighted block.", 13, 13 - DB "First, hilight channel 1.", 13 - DB "Move to the top of the channel first", 13 - DB "by pressing Ctrl-PgUp, then press Alt-L", 0 - -TutorialDisplayState19 DB 36, 16, 78, 26 - DB "Alt-L is a function which will mark the", 13 - DB "entire channel that your cursor is", 13 - DB "currently on. Pressing it twice will", 13 - DB "mark the entire pattern. For now, we", 13 - DB "only need the first channel so you do", 13 - DB "not need to press it a second time.", 13 - DB 13 - DB "Now that the block is marked, press", 13 - DB "Alt-G to actually double the block size!", 0 - -TutorialDisplayState20 DB 36, 16, 78, 33 - DB "Uhhh. Ooops!! That was supposed to be", 13 - DB "Alt-F. No matter - the automatic undo", 13 - DB "in IT will be able to recover our data.", 13 - DB "(Yes, we could just double it twice and", 13 - DB "everything would be perfectly fine, but", 13 - DB "this is meant to teach you about IT,", 13 - DB "right? [smile])", 13 - DB 13 - DB "Whenever you do a block function in IT", 13 - DB "the contents of the entire pattern is", 13 - DB "saved first. IT will store up to 10 of", 13 - DB "these in memory so that you can recover", 13 - DB "from any mistakes that you make.", 13 - DB 13 - DB "Press Ctrl-Backspace to pull up the", 13 - DB "undo menu.", 0 - -TutorialDisplayStatexx DB 33, 16, 78, 21 - DB "Incomplete...", 0 - -TuteFileName DB "TUTE.IT" -BassDrumText DB "Bass Drum" -SnareDrumText DB "Snare Drum" - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State0 - - Cmp AL, 9 - Ret - -EndP Tute_State0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State1 - - Cmp AL, 3 - Ret - -EndP Tute_State1 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State2 - - Cmp AL, 13 - Ret - -EndP Tute_State2 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State3 - - Push Disk - Pop ES - Assume ES:Disk - - Cmp ES:SamplesInModule, 1 - JNE Tute_State3a - - Mov DI, Offset InSampleFileName - Mov SI, Offset TuteFileName - Mov CX, 7 - RepE CmpsB - -Tute_State3a: - Ret - -EndP Tute_State3 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State4 - - Call Music_GetSongSegment - Mov ES, AX - Mov DI, [ES:64912] - Mov SI, Offset BassDrumText - Add DI, 14h - Mov CX, 9 - RepE CmpSB - Ret - -EndP Tute_State4 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State5 - - Cmp AL, 2 - Ret - -EndP Tute_State5 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State6 - - Cmp Word Ptr [FS:0], 13Ch - Ret - -EndP Tute_State6 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State7 - - Cmp Word Ptr [FS:320*16], 13Ch - Ret - -EndP Tute_State7 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State8 - - Call Music_GetPlayMode - Cmp AX, 1 - - Ret - -EndP Tute_State8 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State9 - - Call Music_GetPlayMode - Test AX, AX - Ret - -EndP Tute_State9 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State10 - - Cmp Word Ptr [FS:60*320], 13Ch - Ret - -EndP Tute_State10 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State12 - - Call PE_GetLastInstrument - Cmp BX, 1 - Ret - -EndP Tute_State12 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State14 - - Call Music_GetSongSegment - Mov ES, AX - Mov DI, [ES:64914] - Mov SI, Offset SnareDrumText - Add DI, 14h - Mov CX, 10 - RepE CmpSB - Ret - -EndP Tute_State14 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_StateEnd - - Inc AX ; Ensure zero flag is not set. - Ret - -EndP Tute_StateEnd - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State16 - - Cmp Word Ptr [FS:62*320], 23Ch - Ret - -EndP Tute_State16 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State18 - - Cmp [Word Ptr GS:LastKeyboard1+2], 2600h - Ret - -EndP Tute_State18 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Tute_State19 - - Cmp [Word Ptr GS:LastKeyboard1+2], 2200h - Ret - -EndP Tute_State19 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc Glbl_TutorialHandler Far - - PushAD - Push DS - - Push CS - Pop DS - Assume DS:Glbl - - Push Pattern - Pop GS - - Mov FS, [GS:PatternDataArea] - Assume FS:Nothing - - Mov BX, [TutorialState] - Mov AL, CurrentMode - LEA SI, [EBX+EBX] - - Push BX - Call [TutorialFunctionArray+SI] - Pop BX - JNE Glbl_TutorialHandler1 - - Inc BX - -Glbl_TutorialHandler1: - Mov [TutorialState], BX - - Cmp BX, MAXTUTESTATE - JAE Tute_TuteFinished - - Xor AX, AX - LEA SI, [EBX+EBX] - Mov SI, [TutorialInfoArray+SI] - LodsB - Push AX - LodsB - Push AX - LodsB - Push AX - LodsB - Push AX - Mov AL, 30 - Push AX - - Call S_DrawBox - Add SP, 10 - Mov AL, 80 - Mul Byte Ptr [SI-3] ; y*80 - Add AL, Byte Ptr [SI-4] - AdC AH, 0 - LEA DI, [EAX+EAX] - Add DI, (80+1)*2 - Mov AH, 13h - Call S_DrawString - -Tute_TuteFinished: - Pop DS - PopAD - Ret - -EndP Glbl_TutorialHandler - Assume DS:Nothing, FS:Nothing - -EndS - -ENDIF - -End + + Jumps + .386 + +include switch.inc + +IF TUTORIAL + + Extrn S_DrawBox:Far + Extrn S_DrawString:Far + Extrn Music_GetSongSegment:Far + Extrn Music_GetPlayMode:Far + Extrn PE_GetLastInstrument:Far ; Returns BX = LastInst-1 + +Segment Pattern BYTE Public 'Code' + Extrn PatternDataArea:Word + Extrn LastKeyBoard1:Word + Extrn LastKeyBoard2:Word +EndS + +Segment Disk Byte Public 'Code' USE16 + Extrn SamplesInModule:Byte + Extrn InSampleFileName:Byte +EndS + + Public Glbl_TutorialHandler + +Segment Glbl BYTE Public 'Code' USE16 + Assume CS:Glbl, DS:Nothing, GS:Pattern + +Extrn CurrentMode:Byte + +TutorialState DW 0 + + +; TutorialInfo structure: +; DW Offset function +; DB x, y (top left) +; DB x, y (bottom right) +; DB colour +; DB Message, 0 + +TutorialFunctionArray Label Word + DW Offset Tute_State0 + DW Offset Tute_State1 + DW Offset Tute_State2 + DW Offset Tute_State3 + DW Offset Tute_State4 + DW Offset Tute_State5 + DW Offset Tute_State6 + DW Offset Tute_State7 + DW Offset Tute_State8 + DW Offset Tute_State9 + DW Offset Tute_State10 + DW Offset Tute_State1 + DW Offset Tute_State12 + DW Offset Tute_State2 + DW Offset Tute_State14 + DW Offset Tute_State5 + DW Offset Tute_State16 + DW Offset Tute_State9 + DW Offset Tute_State18 + DW Offset Tute_State19 + DW Offset Tute_StateEnd + +MAXTUTESTATE = ($-Offset TutorialFunctionArray)/2 + + +TutorialInfoArray Label Word + DW Offset TutorialDisplayState0 + DW Offset TutorialDisplayState1 + DW Offset TutorialDisplayState2 + DW Offset TutorialDisplayState3 + DW Offset TutorialDisplayState4 + DW Offset TutorialDisplayState5 + DW Offset TutorialDisplayState6 + DW Offset TutorialDisplayState7 + DW Offset TutorialDisplayState8 + DW Offset TutorialDisplayState9 + DW Offset TutorialDisplayState10 + DW Offset TutorialDisplayState11 + DW Offset TutorialDisplayState12 + DW Offset TutorialDisplayState13 + DW Offset TutorialDisplayState14 + DW Offset TutorialDisplayState15 + DW Offset TutorialDisplayState16 + DW Offset TutorialDisplayState17 + DW Offset TutorialDisplayState18 + DW Offset TutorialDisplayState19 + DW Offset TutorialDisplayState20 + DW Offset TutorialDisplayStatexx + +TutorialDisplayState0 DB 0, 40, 79, 49 + DB 0FFh, 20, " Welcome to the Impulse Tracker Tutorial!", 13, 13 + DB "This tutorial was designed to provide you with a basic understanding of how", 13 + DB "this program works. Everything that you learn here is exactly the same as in", 13 + DB "the main program. By the end of this tutorial, you should be able to compose", 13 + DB "your own modules!", 13, 13 + DB "Good luck! (Press Enter to continue)", 0 + +TutorialDisplayState1 DB 0, 0, 79, 4 + DB "This is the load-module screen that Impulse Tracker will normally begin with.", 13 + DB "As we will start a song afresh, switch to the sample list screen by pressing", 13 + DB "F3.", 0 + +TutorialDisplayState2 DB 36, 1, 78, 13 + DB "There are two basic elements to an", 13 + DB "Impulse Tracker module: patterns and", 13 + DB "samples. Samples provide all the 'real'", 13 + DB "sound information to the program. These", 13 + DB "sounds can be instruments, voices, WAV", 13 + DB "files - anything you like! IT understands", 13 + DB "a wide variety of sound files and even", 13 + DB "allows you to take sounds directly from", 13 + DB "other modules. Since there are no samples", 13 + DB "currently loaded, press Enter to switch", 13 + DB "to the load sample screen.", 0 + +TutorialDisplayState3 DB 0, 0, 79, 5 + DB "A file called TUTE.IT was included with this tutorial. You should be able to", 13 + DB "see it highlighted in the listing below. IT will hilight any file that it", 13 + DB "recognises as a sound file. You can also navigate through your directories", 13 + DB "from this menu. Select TUTE.IT and step into it by pressing Enter.", 0 + +TutorialDisplayState4 DB 2, 28, 45, 39 + DB "Here you can see a list of all the samples", 13 + DB "that are contained within TUTE.IT. To have", 13 + DB "a listen to how they sound, press the down", 13 + DB "arrow once to hilight the first sample and", 13 + DB "press 'Q'. Try moving to the other samples", 13 + DB "and playing them. Try pressing 'W', 'E',", 13 + DB "'R'. You will notice that the samples are", 13 + DB "played at a different pitch. Once you've", 13 + DB "heard all of the samples, select the Bass", 13 + DB "Drum and press Enter.", 0 + +TutorialDisplayState5 DB 36, 14, 78, 20 + DB "OK! You have now loaded the Bass Drum", 13 + DB "into memory. This means that you can use", 13 + DB "it in your songs. Lets do that now!", 13, 13 + DB "Press F2 to go to the pattern editor.", 0 + +TutorialDisplayState6 DB 33, 16, 78, 19 + DB "The pattern editor is where you set out the", 13 + DB "notes that you want to play. Press 'Q'", 0 + +TutorialDisplayState7 DB 33, 16, 78, 35 + DB "So what does this mean?", 13, 13 + DB "C-5 01 ", 173, 173, " .00", 13, 13 + DB "C-5 means to play the note C at octave 5.", 13 + DB "01 means to use sample number 1.", 13, 13 + DB "If this doesn't make sense now, don't worry!", 13 + DB "All of this will be explained later in this", 13 + DB "tutorial.", 13, 13 + DB "For now, try to enter a Bass Drum every four", 13 + DB "rows in Channel 1 (ie. on row 4, 8, 12, ...)", 13, 13 + DB "Continue to use 'Q' to enter the notes. The", 13 + DB "arrow keys may be of assistance. If you make", 13 + DB "a mistake, use the '.' key to blank out the", 13 + DB "entry.", 0 + +TutorialDisplayState8 DB 33, 16, 78, 21 + DB "OK, that's enough!", 13, 13 + DB "Lets take a listen to what you've done.", 13 + DB "Press F6 to play what you've entered.", 0 + +TutorialDisplayState9 DB 33, 16, 78, 23 + DB "As the pattern is played to you, you will", 13 + DB "notice that a cursor on the left hand side", 13 + DB "of the screen indicates the current playback", 13 + DB "position. Press F6 to watch that again.", 13, 13 + DB "When you're ready, press F8 to stop playback", 0 + +TutorialDisplayState10 DB 33, 16, 78, 25 + DB "To finish off the task of entering the Bass", 13 + DB "Drum, move up one row to row 16 and press", 13 + DB "Alt-4. This will cause the cursor to step", 13 + DB "4 rows after every note that you enter", 13 + DB "instead of 1.", 13, 13 + DB "Hold down 'Q' until Channel 1 has a Bass", 13 + DB "Drum every 4 rows until row 60.", 0 + +TutorialDisplayState11 DB 33, 16, 78, 21 + DB "Now we'll add in a snare drum. Before we do", 13 + DB "that though, set the cursor step back to", 13 + DB "a single row at a time. Press Alt-1, then", 13 + DB "F3 to go back to the sample list.", 0 + +TutorialDisplayState12 DB 36, 14, 78, 18 + DB "To load a sample into the second sample", 13 + DB "slot, first press the down arrow a single", 13 + DB "time so that sample two is hilighted.", 0 + +TutorialDisplayState13 DB 36, 14, 72, 17 + DB "Now press Enter to call up the Load", 13 + DB "Sample screen.", 0 + +TutorialDisplayState14 DB 7, 25, 42, 28 + DB "Select the Snare Drum and load it", 13 + DB "(by pressing Enter).", 0 + +TutorialDisplayState15 DB 36, 14, 74, 17 + DB "And now return to the Pattern Editor", 13 + DB "(F2)", 0 + +TutorialDisplayState16 DB 36, 16, 78, 24 + DB "Press Ctrl-PgUp to move to the top of", 13 + DB "the pattern and enter a snare drum in", 13 + DB "every 4th row starting at line 2.", 13 + DB 13 + DB "Use C-5 again, and to make it easier, you", 13 + DB "can set the skip to 4 once you've moved", 13 + DB "to line 2.", 0 + +TutorialDisplayState17 DB 34, 16, 78, 19 + DB "Have a listen to what you've just created!", 13 + DB "(Press F6)", 0 + +TutorialDisplayState18 DB 36, 16, 78, 28 + DB "As part of this tutorial, we'll try out", 13 + DB "one of the block functions that IT", 13 + DB "offers. Our goal is to halve the speed", 13 + DB "at which this plays just by modifying", 13 + DB "the pattern data. IT has two functions", 13 + DB "that will automatically halve or double", 13 + DB "the length of a hilighted block.", 13, 13 + DB "First, hilight channel 1.", 13 + DB "Move to the top of the channel first", 13 + DB "by pressing Ctrl-PgUp, then press Alt-L", 0 + +TutorialDisplayState19 DB 36, 16, 78, 26 + DB "Alt-L is a function which will mark the", 13 + DB "entire channel that your cursor is", 13 + DB "currently on. Pressing it twice will", 13 + DB "mark the entire pattern. For now, we", 13 + DB "only need the first channel so you do", 13 + DB "not need to press it a second time.", 13 + DB 13 + DB "Now that the block is marked, press", 13 + DB "Alt-G to actually double the block size!", 0 + +TutorialDisplayState20 DB 36, 16, 78, 33 + DB "Uhhh. Ooops!! That was supposed to be", 13 + DB "Alt-F. No matter - the automatic undo", 13 + DB "in IT will be able to recover our data.", 13 + DB "(Yes, we could just double it twice and", 13 + DB "everything would be perfectly fine, but", 13 + DB "this is meant to teach you about IT,", 13 + DB "right? [smile])", 13 + DB 13 + DB "Whenever you do a block function in IT", 13 + DB "the contents of the entire pattern is", 13 + DB "saved first. IT will store up to 10 of", 13 + DB "these in memory so that you can recover", 13 + DB "from any mistakes that you make.", 13 + DB 13 + DB "Press Ctrl-Backspace to pull up the", 13 + DB "undo menu.", 0 + +TutorialDisplayStatexx DB 33, 16, 78, 21 + DB "Incomplete...", 0 + +TuteFileName DB "TUTE.IT" +BassDrumText DB "Bass Drum" +SnareDrumText DB "Snare Drum" + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State0 + + Cmp AL, 9 + Ret + +EndP Tute_State0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State1 + + Cmp AL, 3 + Ret + +EndP Tute_State1 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State2 + + Cmp AL, 13 + Ret + +EndP Tute_State2 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State3 + + Push Disk + Pop ES + Assume ES:Disk + + Cmp ES:SamplesInModule, 1 + JNE Tute_State3a + + Mov DI, Offset InSampleFileName + Mov SI, Offset TuteFileName + Mov CX, 7 + RepE CmpsB + +Tute_State3a: + Ret + +EndP Tute_State3 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State4 + + Call Music_GetSongSegment + Mov ES, AX + Mov DI, [ES:64912] + Mov SI, Offset BassDrumText + Add DI, 14h + Mov CX, 9 + RepE CmpSB + Ret + +EndP Tute_State4 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State5 + + Cmp AL, 2 + Ret + +EndP Tute_State5 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State6 + + Cmp Word Ptr [FS:0], 13Ch + Ret + +EndP Tute_State6 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State7 + + Cmp Word Ptr [FS:320*16], 13Ch + Ret + +EndP Tute_State7 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State8 + + Call Music_GetPlayMode + Cmp AX, 1 + + Ret + +EndP Tute_State8 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State9 + + Call Music_GetPlayMode + Test AX, AX + Ret + +EndP Tute_State9 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State10 + + Cmp Word Ptr [FS:60*320], 13Ch + Ret + +EndP Tute_State10 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State12 + + Call PE_GetLastInstrument + Cmp BX, 1 + Ret + +EndP Tute_State12 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State14 + + Call Music_GetSongSegment + Mov ES, AX + Mov DI, [ES:64914] + Mov SI, Offset SnareDrumText + Add DI, 14h + Mov CX, 10 + RepE CmpSB + Ret + +EndP Tute_State14 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_StateEnd + + Inc AX ; Ensure zero flag is not set. + Ret + +EndP Tute_StateEnd + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State16 + + Cmp Word Ptr [FS:62*320], 23Ch + Ret + +EndP Tute_State16 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State18 + + Cmp [Word Ptr GS:LastKeyboard1+2], 2600h + Ret + +EndP Tute_State18 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Tute_State19 + + Cmp [Word Ptr GS:LastKeyboard1+2], 2200h + Ret + +EndP Tute_State19 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc Glbl_TutorialHandler Far + + PushAD + Push DS + + Push CS + Pop DS + Assume DS:Glbl + + Push Pattern + Pop GS + + Mov FS, [GS:PatternDataArea] + Assume FS:Nothing + + Mov BX, [TutorialState] + Mov AL, CurrentMode + LEA SI, [EBX+EBX] + + Push BX + Call [TutorialFunctionArray+SI] + Pop BX + JNE Glbl_TutorialHandler1 + + Inc BX + +Glbl_TutorialHandler1: + Mov [TutorialState], BX + + Cmp BX, MAXTUTESTATE + JAE Tute_TuteFinished + + Xor AX, AX + LEA SI, [EBX+EBX] + Mov SI, [TutorialInfoArray+SI] + LodsB + Push AX + LodsB + Push AX + LodsB + Push AX + LodsB + Push AX + Mov AL, 30 + Push AX + + Call S_DrawBox + Add SP, 10 + Mov AL, 80 + Mul Byte Ptr [SI-3] ; y*80 + Add AL, Byte Ptr [SI-4] + AdC AH, 0 + LEA DI, [EAX+EAX] + Add DI, (80+1)*2 + Mov AH, 13h + Call S_DrawString + +Tute_TuteFinished: + Pop DS + PopAD + Ret + +EndP Glbl_TutorialHandler + Assume DS:Nothing, FS:Nothing + +EndS + +ENDIF + +End diff --git a/IT_VESA.ASM b/it_vesa.s similarity index 97% rename from IT_VESA.ASM rename to it_vesa.s index 4565ddb..e286aac 100644 --- a/IT_VESA.ASM +++ b/it_vesa.s @@ -1,226 +1,226 @@ -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Vesa Module ³ -;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ -;³ Functions provided: ³ -;³ DetectVESA ³ -;³ SetVESAMode ³ -;³ ³ -;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ -;³ DetectVESA ³ -;³ - No parameters required ³ -;³ - Detects the presence of a VESA driver ³ -;³ - Returns carry SET if no VESA driver found ³ -;³ - Returns carry CLEAR if VESA driver found ³ -;³ - All registers preserved ³ -;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ -;³ SetVESAMode ³ -;³ - Requires AX = VESA Mode ³ -;³ - Returns carry SET if VESA Mode isn't supported ³ -;³ - Returns carry CLEAR if VESA mode change OK ³ -;³ - All registers preserved ³ -;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ -;³ VESAGetInfo ³ -;³ - Requires AX = VESA Mode to get information on ³ -;³ - Returns carry SET if VESA Mode isn't supported ³ -;³ - Returns carry clear if information is OK ³ -;³ - Returns ES:DI to Table, all other registers preserved ³ -;³ ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - Jumps - .386P - -include switch.inc - -IF SPECTRUMANALYSER - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Externals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Globals ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -Segment Vesa BYTE Public 'Code' USE16 - Assume CS:Vesa, DS:Nothing - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Variables ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -VESAInformationTable Label -VESASignature DB 4 Dup (0) -VESAVersion DW 0 -VESAOEMStringPrt DD 0 -VESACapabilities DD 0 -VESAVideoModePtr DD 0 -VESATotalMemory DW 0 - DB 256-($-VESAInformationTable) Dup(0) - -VESAModeInformationTable Label - DB 256-($-VESAModeInformationTable) Dup (0) - -ModeInformationStructure Struc - ModeAtributes DW ? - WindowAAtributes DB ? - WindowBAttributes DB ? - WindowGranularity DW ? - WindowSize DW ? - WindowASegment DW ? - WindowBSegment DW ? - WindowFunction DD ? - BytesPerScanLine DW ? - - XResolution DW ? - YResolution DW ? - XCharacterSize DB ? - YCharacterSize DB ? - NumberOfPlanes DB ? - BitsPerPixel DB ? - NumberOfBanks DB ? - MemoryModel DB ? - BankSize DB ? - NumberOfImagePages DB ? - Reserved DB ? - - RedMaskSize DB ? - RedFieldPosition DB ? - GreenMaskSize DB ? - GreenFieldPosition DB ? - BlueMaskSize DB ? - BlueFieldPosition DB ? - RSVDMaskSize DB ? - DirectColourModeInfo DB ? - -ModeInformationStructure EndS - -;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -;³ Functions ³ -;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -Proc VESA_Detect Far -Public VESA_Detect - - PushA - Push ES - - Mov AX, 4F00h - Push CS - Pop ES - Mov DI, Offset VESAInformationTable - Int 10h - - Cmp AX, 4Fh - JNE DetectVESA1 - Cmp [DWord Ptr ES:DI], "ASEV" ; 'VESA' identification - JNE DetectVESA1 - - DB 85h - -DetectVESA1: - StC - - Pop ES - PopA - Ret - -EndP VESA_Detect - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VESA_SetMode Far -Public VESA_SetMode - - PushA - Push DS - Push ES - - Call VESA_GetInfo - JC VESA_SetMode3 - - Mov BX, AX - Mov AX, 4F02h ; Set Mode - Int 10h - Cmp AX, 4Fh - JE VESA_SetMode3 - - StC - -VESA_SetMode3: - Pop ES - Pop DS - PopA - - Mov CX, [VESAModeInformationTable.XResolution] - Mov DX, [VESAModeInformationTable.YResolution] - - Ret - -EndP VESA_SetMode - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VESA_GetInfo -Public VESA_GetInfo - - Push AX - Push CX - - Mov CX, AX - - Push CS - Pop ES - Mov DI, Offset VESAModeInformationTable - Mov AX, 4F01h - Int 10h - - Cmp AX, 4Fh - JE VESA_GetInfo1 - - StC - -VESA_GetInfo1: - Pop CX - Pop AX - - Ret - -EndP VESA_GetInfo - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc VESA_SetBlock Far ; Gives access to a 64kb block -Public VESA_SetBlock ; Given AX = block number. - - PushA - Push AX - - Mov AX, 64 - Xor DX, DX - Div Word Ptr [VESAModeInformationTable.WindowGranularity] - Mov DX, AX - Pop AX - Mul DX - Mov DX, AX - Xor BX, BX - Call DWord Ptr [VESAModeInformationTable.WindowFunction] - - PopA - Ret - -EndP VESA_SetBlock - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -EndS - -;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ - -ENDIF - -End +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Vesa Module ³ +;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ +;³ Functions provided: ³ +;³ DetectVESA ³ +;³ SetVESAMode ³ +;³ ³ +;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ +;³ DetectVESA ³ +;³ - No parameters required ³ +;³ - Detects the presence of a VESA driver ³ +;³ - Returns carry SET if no VESA driver found ³ +;³ - Returns carry CLEAR if VESA driver found ³ +;³ - All registers preserved ³ +;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ +;³ SetVESAMode ³ +;³ - Requires AX = VESA Mode ³ +;³ - Returns carry SET if VESA Mode isn't supported ³ +;³ - Returns carry CLEAR if VESA mode change OK ³ +;³ - All registers preserved ³ +;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ +;³ VESAGetInfo ³ +;³ - Requires AX = VESA Mode to get information on ³ +;³ - Returns carry SET if VESA Mode isn't supported ³ +;³ - Returns carry clear if information is OK ³ +;³ - Returns ES:DI to Table, all other registers preserved ³ +;³ ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + Jumps + .386P + +include switch.inc + +IF SPECTRUMANALYSER + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Externals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Globals ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +Segment Vesa BYTE Public 'Code' USE16 + Assume CS:Vesa, DS:Nothing + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Variables ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +VESAInformationTable Label +VESASignature DB 4 Dup (0) +VESAVersion DW 0 +VESAOEMStringPrt DD 0 +VESACapabilities DD 0 +VESAVideoModePtr DD 0 +VESATotalMemory DW 0 + DB 256-($-VESAInformationTable) Dup(0) + +VESAModeInformationTable Label + DB 256-($-VESAModeInformationTable) Dup (0) + +ModeInformationStructure Struc + ModeAtributes DW ? + WindowAAtributes DB ? + WindowBAttributes DB ? + WindowGranularity DW ? + WindowSize DW ? + WindowASegment DW ? + WindowBSegment DW ? + WindowFunction DD ? + BytesPerScanLine DW ? + + XResolution DW ? + YResolution DW ? + XCharacterSize DB ? + YCharacterSize DB ? + NumberOfPlanes DB ? + BitsPerPixel DB ? + NumberOfBanks DB ? + MemoryModel DB ? + BankSize DB ? + NumberOfImagePages DB ? + Reserved DB ? + + RedMaskSize DB ? + RedFieldPosition DB ? + GreenMaskSize DB ? + GreenFieldPosition DB ? + BlueMaskSize DB ? + BlueFieldPosition DB ? + RSVDMaskSize DB ? + DirectColourModeInfo DB ? + +ModeInformationStructure EndS + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ Functions ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + +Proc VESA_Detect Far +Public VESA_Detect + + PushA + Push ES + + Mov AX, 4F00h + Push CS + Pop ES + Mov DI, Offset VESAInformationTable + Int 10h + + Cmp AX, 4Fh + JNE DetectVESA1 + Cmp [DWord Ptr ES:DI], "ASEV" ; 'VESA' identification + JNE DetectVESA1 + + DB 85h + +DetectVESA1: + StC + + Pop ES + PopA + Ret + +EndP VESA_Detect + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VESA_SetMode Far +Public VESA_SetMode + + PushA + Push DS + Push ES + + Call VESA_GetInfo + JC VESA_SetMode3 + + Mov BX, AX + Mov AX, 4F02h ; Set Mode + Int 10h + Cmp AX, 4Fh + JE VESA_SetMode3 + + StC + +VESA_SetMode3: + Pop ES + Pop DS + PopA + + Mov CX, [VESAModeInformationTable.XResolution] + Mov DX, [VESAModeInformationTable.YResolution] + + Ret + +EndP VESA_SetMode + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VESA_GetInfo +Public VESA_GetInfo + + Push AX + Push CX + + Mov CX, AX + + Push CS + Pop ES + Mov DI, Offset VESAModeInformationTable + Mov AX, 4F01h + Int 10h + + Cmp AX, 4Fh + JE VESA_GetInfo1 + + StC + +VESA_GetInfo1: + Pop CX + Pop AX + + Ret + +EndP VESA_GetInfo + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc VESA_SetBlock Far ; Gives access to a 64kb block +Public VESA_SetBlock ; Given AX = block number. + + PushA + Push AX + + Mov AX, 64 + Xor DX, DX + Div Word Ptr [VESAModeInformationTable.WindowGranularity] + Mov DX, AX + Pop AX + Mul DX + Mov DX, AX + Xor BX, BX + Call DWord Ptr [VESAModeInformationTable.WindowFunction] + + PopA + Ret + +EndP VESA_SetBlock + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +EndS + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +ENDIF + +End diff --git a/main.c b/main.c new file mode 100644 index 0000000..889b688 --- /dev/null +++ b/main.c @@ -0,0 +1,12 @@ +#include +#include +#include + +int main(int argc, char** argv) { + int arglen = 1; // null terminator + for(int i = 0; i < argc; i++) arglen += strlen(argv[i]); + char* args = memset(malloc(arglen * sizeof(char)), 0, arglen); + for(int i = 0; i < argc; i++) strcat(args, argv[i]); + + return printf("pretend this is impulse tracker\n"); // TODO make this impulse tracker +} diff --git a/NETWORK.INC b/network.inc similarity index 97% rename from NETWORK.INC rename to network.inc index 932f279..146e7c5 100644 --- a/NETWORK.INC +++ b/network.inc @@ -1,32 +1,32 @@ -IF NETWORKENABLED - Extrn Network_GetSendQueue:Far - Extrn Network_FinishedSendQueue:Far - Extrn Network_AddWordToQueue:Far - Extrn Network_EnsureNoNetwork:Far - Extrn Network_SendSampleHeader:Far - Extrn Network_SendInstrumentHeader:Far - Extrn Network_QueueSampleData:Far - Extrn Network_SendSongDataInformation:Far - -NETWORK_PARTIALPATTERNOBJECT EQU 0 -NETWORK_ENTIREPATTERNOBJECT EQU 1 -NETWORK_REQUESTPATTERNOBJECT EQU 2 -NETWORK_SONGDATAOBJECT EQU 3 -NETWORK_INSTRUMENTHEADEROBJECT EQU 4 -NETWORK_SAMPLEHEADEROBJECT EQU 5 -NETWORK_SETPATTERNLENGTH EQU 6 -NETWORK_DELETESAMPLEOBJECT EQU 7 - -EnsureNoNetwork EQU Call Network_EnsureNoNetwork -NetworkSendSample EQU Call Network_SendSampleHeader -NetworkSendInstrument EQU Call Network_SendInstrumentHeader - -ELSE - -EnsureNoNetwork EQU ; -NetworkSendSample EQU ; -NetworkSendInstrument EQU ; - -ENDIF - - +IF NETWORKENABLED + Extrn Network_GetSendQueue:Far + Extrn Network_FinishedSendQueue:Far + Extrn Network_AddWordToQueue:Far + Extrn Network_EnsureNoNetwork:Far + Extrn Network_SendSampleHeader:Far + Extrn Network_SendInstrumentHeader:Far + Extrn Network_QueueSampleData:Far + Extrn Network_SendSongDataInformation:Far + +NETWORK_PARTIALPATTERNOBJECT EQU 0 +NETWORK_ENTIREPATTERNOBJECT EQU 1 +NETWORK_REQUESTPATTERNOBJECT EQU 2 +NETWORK_SONGDATAOBJECT EQU 3 +NETWORK_INSTRUMENTHEADEROBJECT EQU 4 +NETWORK_SAMPLEHEADEROBJECT EQU 5 +NETWORK_SETPATTERNLENGTH EQU 6 +NETWORK_DELETESAMPLEOBJECT EQU 7 + +EnsureNoNetwork EQU Call Network_EnsureNoNetwork +NetworkSendSample EQU Call Network_SendSampleHeader +NetworkSendInstrument EQU Call Network_SendInstrumentHeader + +ELSE + +EnsureNoNetwork EQU ; +NetworkSendSample EQU ; +NetworkSendInstrument EQU ; + +ENDIF + + diff --git a/PE_TRANS.INC b/pe_trans.inc similarity index 96% rename from PE_TRANS.INC rename to pe_trans.inc index 78a9771..199a4e0 100644 --- a/PE_TRANS.INC +++ b/pe_trans.inc @@ -1,1703 +1,1703 @@ - -XMVolume DB 0 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TranslateXMNote - - Cmp AL, 96 - JBE TranslateXMNote1 - - Mov AL, 0FFh-11 ; Note off - -TranslateXMNote1: - Add AL, 11 - StosB - Ret - -EndP TranslateXMNote - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -XMEffectG DB 193, 193+4, 193+5, 193+6, 193+6, 193+7, 193+7, 193+8 - DB 193+8, 193+9 - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TranslateXMInstrument - - Cmp AL, 99 - JBE TranslateXMInstrument1 - - Xor AL, AL - - Cmp Byte Ptr [ES:DI-1], 0FFh ; note off? - JE TranslateXMInstrument2 - Mov Byte Ptr [ES:DI-1], 0FDh - Jmp TranslateXMInstrument2 - -TranslateXMInstrument1: - Cmp Byte Ptr [ES:DI-1], 0FFh ; note off? - JNE TranslateXMInstrument2 - - Xor AL, AL - -TranslateXMInstrument2: - StosB - Ret - -EndP TranslateXMInstrument - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TranslateXMVolume - - Push AX - - Mov AH, AL - Mov DX, AX - Mov AL, 0FFh - Cmp AH, 10h ; Nothing - JB TranslateXMVolume1 - - Mov AL, AH - Sub AL, 10h - Cmp AH, 50h ; Volume - JBE TranslateXMVolume1 - - Mov AL, 0FFh - Cmp AH, 60h ; Nothing - JB TranslateXMVolume1 - - Mov AL, AH - And AX, 0F00Fh - - Cmp AL, 9 - JBE TranslateXMVolume2 - - Mov AL, 9 - -TranslateXMVolume2: - Cmp AH, 70h - JAE TranslateXMVolume3 - - Add AL, 95 ; Volume down - Jmp TranslateXMVolume1 - -TranslateXMVolume3: - Cmp AH, 80h - JAE TranslateXMVolume4 - - Add AL, 85 ; volume up - Jmp TranslateXMVolume1 - -TranslateXMVolume4: - Cmp AH, 90h - JAE TranslateXMVolume5 - - Add AL, 75 ; Fine volume down - Jmp TranslateXMVolume1 - -TranslateXMVolume5: - Cmp AH, 0A0h - JAE TranslateXMVolume6 - - Add AL, 65 ; fine volume up - Jmp TranslateXMVolume1 - -TranslateXMVolume6: - Cmp AH, 0B0h - JAE TranslateXMVolume7 - - Mov AL, 0FFh ; Vibrato speed - Jmp TranslateXMVolume1 - -TranslateXMVolume7: - Cmp AH, 0C0h - JAE TranslateXMVolume8 - - Cmp AL, 3 - JBE TranslateXMVolumeH - - Dec AX - -TranslateXMVolumeH: - Add AL, 203 ; Vibrato - Jmp TranslateXMVolume1 - -TranslateXMVolume8: - Cmp AH, 0D0h - JAE TranslateXMVolume9 - - Mov AL, DL - Sub AL, 0C0h - Mov AH, AL - ShL AL, 2 - Or AL, AH ;Panning - Add AL, 128 - Jmp TranslateXMVolume1 - -TranslateXMVolume9: - Cmp AH, 0F0h - JAE TranslateXMVolume10 - - Mov AL, 0FFh ; Pan slide left/right - Jmp TranslateXMVolume1 - -TranslateXMVolume10: ; Porta - Push BX - Mov BX, AX - And BX, 0FFh - Mov AL, [CS:XMEffectG+BX] - Pop BX - -TranslateXMVolume1: - StosB - Pop AX - Ret - -EndP TranslateXMVolume - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TranslateXMEffect ; Given AX = data - - Test AX, AX - JNZ TranslateXMEffect1 - -TranslateXMEffectVol: - Xor AX, AX - Cmp CS:XMVolume, 60h - JB TranslateXMEffectEnd - Mov DH, 0FFh - Jmp TranslateXMEffectVolume - -TranslateXMEffect1: - Cmp AL, 'K'-'A'+0Ah - JNE TranslateXMEffect24 - - Mov AL, [ES:DI-3] - Cmp AL, 0FDh - JNE TranslateXMEffectVol - - Mov Word Ptr [ES:DI-3], 0FFh - Jmp TranslateXMEffectVol - -TranslateXMEffect24: - Cmp AL, 0 - JNE TranslateXMEffect2 - - Mov AL, 'J'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect2: - Cmp AL, 1 - JNE TranslateXMEffect3 - - Mov AL, 'F'-'@' - Test AH, AH - JNZ TranslateXMEffectEnd - Cmp CS:XMVolume, 60h - JB TranslateXMEffectEnd - Mov DH, 105 - Jmp TranslateXMEffectVolume - -TranslateXMEffect3: - Cmp AL, 2 - JNE TranslateXMEffect4 - - Mov AL, 'E'-'@' - Test AH, AH - JNZ TranslateXMEffectEnd - Cmp CS:XMVolume, 60h - JB TranslateXMEffectEnd - Mov DH, 115 - Jmp TranslateXMEffectVolume - -TranslateXMEffect4: - Cmp AL, 3 - JNE TranslateXMEffect5 - - Mov AL, 'G'-'@' - Test AH, AH - JNZ TranslateXMEffectEnd - Cmp CS:XMVolume, 60h - JB TranslateXMEffectEnd - Mov DH, 193 - Jmp TranslateXMEffectVolume - -TranslateXMEffect5: - Cmp AL, 4 - JNE TranslateXMEffect6 - - Mov AL, AH - And AX, 0FF0h - Cmp AH, 4 - JBE TranslateXMEffectH1 - - Dec AH - -TranslateXMEffectH1: - Or AH, AL - Mov AL, 'H'-'@' - Test AH, AH - JNZ TranslateXMEffectEnd - Cmp CS:XMVolume, 60h - JB TranslateXMEffectEnd - Mov DH, 203 - Jmp TranslateXMEffectVolume - -TranslateXMEffect6: - Cmp AL, 5 - JNE TranslateXMEffect7 - - Mov AL, 'L'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect7: - Cmp AL, 6 - JNE TranslateXMEffect8 - - Mov AL, 'K'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect8: - Cmp AL, 7 - JNE TranslateXMEffect9 - - Mov AL, 'R'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect9: - Cmp AL, 8 - JNE TranslateXMEffect10 - - Mov AL, 'X'-'@' - Cmp CS:XMVolume, 60h - JB TranslateXMEffectEnd - Mov DH, AH - ShR DH, 2 - AdC DH, 128 - Jmp TranslateXMEffectVolume - -TranslateXMEffect10: - Cmp AL, 9 - JNE TranslateXMEffect11 - - Mov AL, 'O'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect11: - Cmp AL, 0Ah - JNE TranslateXMEffect12 - - Mov AL, 'D'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect12: - Cmp AL, 0Bh - JNE TranslateXMEffect13 - - Mov AL, 'B'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect13: - Cmp AL, 0Ch - JNE TranslateXMEffect14 - - Mov DH, AH - Cmp DH, 64 - JB TranslateXMEffectVolume - - Mov DH, 64 - -TranslateXMEffectVolume: - Mov AL, CS:XMVolume - Mov AH, AL - And AH, 0Fh - - Cmp AL, 60h - JAE TranslateXMEffectVolume1 - - Xor AX, AX - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume1: - Cmp AL, 70h - JAE TranslateXMEffectVolume2 - - Mov AL, 'D'-'@' - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume2: - Cmp AL, 80h - JAE TranslateXMEffectVolume3 - - Mov AL, 'D'-'@' - ShL AH, 4 - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume3: - Cmp AL, 90h - JAE TranslateXMEffectVolume4 - - Mov AL, 'D'-'@' - Test AH, AH - JZ TranslateXMEffect3Memory - Or AH, 0F0h - Cmp AH, 0FFh - JNE TranslateXMEffect3Memory - - Dec AH - -TranslateXMEffect3Memory: - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume4: - Cmp AL, 0A0h - JAE TranslateXMEffectVolume5 - - Mov AL, 'D'-'@' - Test AH, AH - JZ TranslateXMEffect4Memory - - ShL AH, 4 - Or AH, 0Fh - -TranslateXMEffect4Memory: - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume5: - Cmp AL, 0B0h - JAE TranslateXMEffectVolume6 - - Mov AL, 'H'-'@' - ShL AH, 4 - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume6: - Cmp AL, 0C0h - JAE TranslateXMEffectVolume7 - - Cmp AH, 4 - JBE TranslateXMEffectVolumeH6 - - Dec AH - -TranslateXMEffectVolumeH6: - Mov AL, 'H'-'@' - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume7: - Cmp AL, 0D0h - JAE TranslateXMEffectVolume8 - - Mov AL, 'S'-'@' - Or AH, 80h - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume8: - Cmp AL, 0E0h - JAE TranslateXMEffectVolume9 - - Mov AL, 'P'-'@' - ShL AH, 4 - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume9: - Cmp AL, 0F0h - JAE TranslateXMEffectVolume10 - - Mov AL, 'P'-'@' - Jmp TranslateXMEffectVolumeEnd - -TranslateXMEffectVolume10: - Mov AL, 'G'-'@' - ShL AH, 4 - -TranslateXMEffectVolumeEnd: - Mov [ES:DI-1], DH - StosW - Ret - -TranslateXMEffect14: - Cmp AL, 0Dh - JNE TranslateXMEffect15 - - Mov AL, AH - And AX, 0F00Fh - ShR AH, 1 - Add AL, AH - ShR AH, 2 - Add AH, AL - Mov AL, 'C'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect15: - Cmp AL, 0Eh - JNE TranslateXMEffect16 - - ; 'Multiplex' effect - Mov AL, AH - And AX, 0FF0h - Test AL, AL - JNZ TranslateXMEffectE1 - - Xor AX, AX - Jmp TranslateXMEffectEnd - -TranslateXMEffectE1: - Cmp AL, 10h - JNE TranslateXMEffectE2 - - Test AH, AH - JZ TranslateE1Memory - Or AH, 0F0h - -TranslateE1Memory: - Mov AL, 'F'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectE2: - Cmp AL, 20h - JNE TranslateXMEffectE3 - - Test AH, AH - JZ TranslateE2Memory - Or AH, 0F0h - -TranslateE2Memory: - Mov AL, 'E'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectE3: - Cmp AL, 30h - JNE TranslateXMEffectE4 - - Xor AX, AX - Jmp TranslateXMEffectEnd - -TranslateXMEffectE4: - Cmp AL, 40h - JNE TranslateXMEffectE5 - - Or AH, 30h - Mov AL, 'S'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectE5: - Cmp AL, 50h - JNE TranslateXMEffectE6 - - Xor AX, AX - Jmp TranslateXMEffectEnd - -TranslateXMEffectE6: - Cmp AL, 60h - JNE TranslateXMEffectE7 - - Or AH, 0B0h - Mov AL, 'S'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectE7: - Cmp AL, 70h - JNE TranslateXMEffectE8 - - Or AH, 040h - Mov AL, 'S'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectE8: - Cmp AL, 80h - JNE TranslateXMEffectE9 - - Or AH, 80h - Mov AL, 'S'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectE9: - Cmp AL, 90h - JNE TranslateXMEffectEA - - Mov AL, 'Q'-'@' - Test AH, AH - JNZ TranslateXMEffectEnd - Jmp TranslateXMEffectVol - -TranslateXMEffectEA: - Cmp AL, 0A0h - JNE TranslateXMEffectEB - - Test AH, AH - JZ TranslateXMEAMemory - - ShL AH, 4 - Or AH, 0Fh - -TranslateXMEAMemory: - Mov AL, 'D'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectEB: - Cmp AL, 0B0h - JNE TranslateXMEffectEC - - Test AH, AH - JZ TranslateXMEBMemory - - Or AH, 0F0h - Cmp AH, 0FFh - JNE TranslateXMEBMemory - - Dec AH - -TranslateXMEBMemory: - Mov AL, 'D'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectEC: - Cmp AL, 0C0h - JNE TranslateXMEffectED - - Or AH, 0C0h - Mov AL, 'S'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectED: - Cmp AL, 0D0h - JNE TranslateXMEffectEE - - Or AH, 0D0h - Mov AL, 'S'-'@' - - Jmp TranslateXMEffectEnd - -TranslateXMEffectEE: - Cmp AL, 0E0h - JNE TranslateXMEffectEF - - Or AH, 0E0h - Mov AL, 'S'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffectEF: - Xor AX, AX - Jmp TranslateXMEffectEnd - -TranslateXMEffect16: - Cmp AL, 0Fh - JNE TranslateXMEffect18 - - Mov AL, 'T'-'@' - Cmp AH, 20h - JAE TranslateXMTempo1 - - Mov AL, 'A'-'@' - -TranslateXMTempo1: - Jmp TranslateXMEffectEnd - -TranslateXMEffect18: - Cmp AL, 10h ; 'G'lobal volume - JNE TranslateXMEffect19 - - Mov AL, 'V'-'@' - Cmp AH, 40h - JB TranslateXMEffectV - - Mov AH, 80h - Jmp TranslateXMEffectEnd - -TranslateXMEffectV: - ShL AH, 1 - Jmp TranslateXMEffectEnd - -TranslateXMEffect19: - Cmp AL, 11h ; 'H' - JNE TranslateXMEffect20 - - Mov AL, AH - And AX, 0FF0h - ShL AH, 1 - Cmp AH, 0Fh - JBE TranslateGlobalVolSlide2 - - Mov AH, 0Fh - -TranslateGlobalVolSlide2: - ShL AL, 1 - JNC TranslateGlobalVolSlide1 - - Mov AL, 0F0h - -TranslateGlobalVolSlide1: - Or AH, AL - Mov AL, 'W'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect20: - Cmp AL, 'R'-'A'+0Ah - JNE TranslateXMEffect21 - - Mov AL, 'Q'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect21: - Cmp AL, 'T'-'A'+0Ah - JNE TranslateXMEffect22 - - Mov AL, AH - And AX, 0FF0h - Test AH, AH - JNZ Tremor1 - - Inc AH - -Tremor1: - Test AL, AL - JNZ Tremor2 - - Inc AX -Tremor2: - Or AH, AL - Mov AL, 'I'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect22: - Cmp AL, 'X'-'A'+0Ah - JNE TranslateXMEffect23 - - Mov AL, AH - And AX, 0FF0h - Or AH, 0E0h - Cmp AL, 10h - JE TranslateXMEffectX1 - Cmp AL, 20h - JE TranslateXMEffectX2 - - Xor AX, AX - Jmp TranslateXMEffectEnd - -TranslateXMEffectX1: - Mov AL, 'F'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffectX2: - Mov AL, 'E'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEffect23: - Cmp AL, 'Z'-'A'+0Ah - JNE TranslateXMEffect25 - - Mov AL, 'Z'-'@' - Jmp TranslateXMEffectEnd - -TranslateXMEFfect25: - Jmp TranslateXMEffectVol -; Xor AX, AX - -TranslateXMEffectEnd: - StosW - Ret - -EndP TranslateXMEffect - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TranslateXMPattern Far ; DS:SI points to - ; data, AX = rows - ; CX = channels - ; DX = pattern num - - ; Has to return DS:SI - PushA - Push DS - Push ES - - Dec AX - Mov CS:TempVariableArea3, AX - Cmp AX, 31 - JAE PE_XMLimitRows - - Mov AX, 31 - -PE_XMLimitRows: - Mov CS:MaxRow, AX - Mov CS:PatternNumber, DX ; Pattern number - Mov CS:TempVariableArea2, CX ; Channels - - Call PE_ClearPatternData - - Mov ES, CS:PatternDataArea - Xor DI, DI - Xor AX, AX ; AX = row number - -PE_TranslateXMPattern1: - Push AX - Push DI - - Mov CX, CS:TempVariableArea2 ; CX = channels - -PE_TranslateXMPattern2: - Push CX - - LodsB ; AL = either note or compression - ; control. - Test AL, AL - JS PE_TranslateXMPatternCompressed - - Call TranslateXMNote - LodsB - Call TranslateXMInstrument - LodsB - Mov CS:XMVolume, AL - Call TranslateXMVolume - LodsW - Call TranslateXMEffect - Jmp PE_TranslateXMPattern3 - -PE_TranslateXMPatternCompressed: - Mov CS:XMVolume, 0 - Mov AH, AL - Test AH, 1 - JZ PE_TranslateXMPattern4 - - LodsB - Call TranslateXMNote - Dec DI - -PE_TranslateXMPattern4: - Inc DI - - Test AH, 2 - JZ PE_TranslateXMPattern5 - - LodsB - Call TranslateXMInstrument - Dec DI - -PE_TranslateXMPattern5: - Inc DI - - Test AH, 4 - JZ PE_TranslateXMPattern6 - - LodsB - Mov CS:XMVolume, AL - Call TranslateXMVolume - Dec DI - -PE_TranslateXMPattern6: - Inc DI - - Xor AL, AL - Test AH, 8 - JZ PE_TranslateXMPattern7 - - LodsB - -PE_TranslateXMPattern7: - Test AH, 10h - Mov AH, 0 - JZ PE_TranslateXMPattern8 - - Mov AH, [SI] - Inc SI - -PE_TranslateXMPattern8: - Call TranslateXMEffect - -PE_TranslateXMPattern3: - Pop CX - Dec CX - JNZ PE_TranslateXMPattern2 - - Pop DI - Pop AX - Add DI, 320 ; Next row. - Inc AX - Cmp AX, CS:TempVariableArea3 - JBE PE_TranslateXMPattern1 - - Mov CS:TempVariableArea, SI - - Mov AX, CS:TempVariableArea3 - Cmp AX, CS:MaxRow - JE PE_TranslateXMPatternNoBreak - - Mov DX, 320 - Mul DX - Mov DI, AX - Add DI, 3 - -PE_TranslateXMPatternBreak1: - Cmp Word Ptr [ES:DI], 0 - JE PE_TranslateXMPatternBreak2 - - Add DI, 5 - Jmp PE_TranslateXMPatternBreak1 - -PE_TranslateXMPatternBreak2: - Mov Word Ptr [ES:DI], 'C'-'@' ; Break. - -PE_TranslateXMPatternNoBreak: - Push CS - Pop DS - - Call Far Ptr PE_TranslateS3MPointer8 - - - Pop ES - Pop DS - PopA - - Mov SI, CS:TempVariableArea - - Ret - -EndP PE_TranslateXMPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc TranslateMODCommand ; AL = command - ; AH = command value - ; ES:DI points to - ; command destination - - Test AX, AX - JNZ TranslateMODCommand7 - - StosW - Ret - -TranslateMODCommand7: - Cmp AL, 0 - JNE TranslateMODCommand8 - - Mov AL, 'J'-'@' - StosW - Ret - -TranslateMODCommand8: - Cmp AL, 1 - JNE TranslateMODCommand9 - - Mov AL, 'F'-'@' - Jmp TranslateMODCommand36 - -TranslateMODCommand9: - Cmp AL, 2 - JNE TranslateMODCommand10 - - Mov AL, 'E'-'@' - Jmp TranslateMODCommand36 - -TranslateMODCommand10: - Cmp AL, 3 - JNE TranslateMODCommand11 - - Mov AL, 'G'-'@' - StosW - Ret - -TranslateMODCommand11: - Cmp AL, 4 - JNE TranslateMODCommand12 - - Mov AL, 'H'-'@' - - StosW - Ret - -TranslateMODCommand12: - Cmp AL, 5 - JNE TranslateMODCommand13 - - Mov AL, 'L'-'@' - Test AH, AH - JNZ TranslateMODCommand40 - - Mov AX, 'G'-'@' - -TranslateMODCommand40: - StosW - Ret - -TranslateMODCommand13: - Cmp AL, 6 - JNE TranslateMODCommand14 - - Mov AL, 'K'-'@' - Test AH, AH - JNZ TranslateMODCommand39 - - Mov AX, 'H'-'@' - -TranslateMODCommand39: - StosW - Ret - -TranslateMODCommand14: - Cmp AL, 7 - JNE TranslateMODCommand15 - - Mov AL, 'R'-'@' - StosW - Ret - -TranslateMODCommand15: - Cmp AL, 8 - JNE TranslateMODCommand16 - - Mov AL, 'X'-'@' - Cmp AH, 0A4h - JNE TranslateMODNoSurround - - Mov AX, 'S'-'@'+9100h - -TranslateMODNoSurround: - StosW - Ret - -TranslateMODCommand16: - Cmp AL, 9 - JNE TranslateMODCommand17 - - Mov AL, 'O'-'@' - StosW - Ret - -TranslateMODCommand17: - Cmp AL, 10 - JNE TranslateMODCommand18 - - Mov AL, 'D'-'@' - Test AH, 0Fh - JZ TranslateMODVolumeSlide1 - Test AH, 0F0h - JZ TranslateMODVolumeSlide1 - - And AH, 0F0h - -TranslateMODVolumeSlide1: - Jmp TranslateMODCommand36 - -TranslateMODCommand18: - Cmp AL, 11 - JNE TranslateMODCommand19 - - Mov AL, 'B'-'@' - StosW - Ret - -TranslateMODCommand19: - Cmp AL, 12 - JNE TranslateMODCommand20 - - Cmp AH, 64 - JBE TranslateMODCommand37 - - Mov AH, 64 - -TranslateMODCommand37: - Mov [ES:DI-1], AH - Add DI, 2 - Ret - -TranslateMODCommand20: - Cmp AL, 13 - JNE TranslateMODCommand21 - - Mov AL, AH - And AX, 0F00Fh - ShR AH, 1 ; AH = highnibble*8 - Add AL, AH - - ShR AH, 2 ; AH = highnibble*2 - Add AH, AL - - Mov AL, 'C'-'@' - StosW - Ret - -TranslateMODCommand21: - Cmp AL, 14 - JNE TranslateMODCommand34 - - Mov AL, AH - And AX, 0FF0h - - Cmp AL, 0 - JNE TranslateMODCommand22 - - Test AH, AH - JZ TranslateMODCommand36 - - Mov AL, 'S'-'@' - StosW - Ret - -TranslateMODCommand22: - Cmp AL, 10h - JNE TranslateMODCommand23 - - Test AH, AH - JZ TranslateMODCommand36 - - Mov AL, 'F'-'@' - Or AH, 0F0h - StosW - Ret - -TranslateMODCommand23: - Cmp AL, 20h - JNE TranslateMODCommand24 - - Test AH, AH - JZ TranslateMODCommand36 - - Mov AL, 'E'-'@' - Or AH, 0F0h - StosW - Ret - -TranslateMODCommand24: - Cmp AL, 30h - JNE TranslateMODCommand25 - - Mov AL, 'S'-'@' - Or AH, 010h - StosW - Ret - -TranslateMODCommand25: - Cmp AL, 40h - JNE TranslateMODCommand26 - - Mov AL, 'S'-'@' - Or AH, 030h - StosW - Ret - -TranslateMODCommand26: - Cmp AL, 50h - JNE TranslateMODCommand27 - - Mov AL, 'S'-'@' - Or AH, 020h - StosW - Ret - -TranslateMODCommand27: - Cmp AL, 60h - JNE TranslateMODCommand28 - - Mov AL, 'S'-'@' - Or AH, 0B0h - StosW - Ret - -TranslateMODCommand28: - Cmp AL, 70h - JNE TranslateMODCommand29 - - Mov AL, 'S'-'@' - Or AH, 40h - StosW - Ret - -TranslateMODCommand29: - Cmp AL, 80h - JNE TranslateMODCommand30 - - Or AH, AL - Mov AL, 'S'-'@' - StosW - Ret - -TranslateMODCommand30: - Cmp AL, 90h - JNE TranslateMODCommand31 - - Test AH, AH - JZ TranslateMODCommand36 - - Mov AL, 'Q'-'@' - Jmp TranslateMODCommand36 - -TranslateMODCommand31: - Cmp AL, 0A0h - JNE TranslateMODCommand32 - - And AH, 0Fh - JZ TranslateMODCommand36 - - Mov AL, 'D'-'@' - ShL AH, 4 - Or AH, 0Fh - StosW - Ret - -TranslateMODCommand32: - Cmp AL, 0B0h - JNE TranslateMODCommand33 - - And AH, 0Fh - JZ TranslateMODCommand36 - - Mov AL, 'D'-'@' - Or AH, 0F0h - StosW - Ret - - -TranslateMODCommand33: - Or AH, AL - Mov AL, 'S'-'@' - StosW - Ret - -TranslateMODCommand34: ; Set speed. - Cmp AH, 20h - JA TranslateMODCommand35 - - Mov AL, 'A'-'@' - Jmp TranslateMODCommand36 - -TranslateMODCommand35: - Mov AL, 'T'-'@' - StosW - Ret - -TranslateMODCommand36: - Test AH, AH - JNZ TranslateMODCommand38 - - Xor AX, AX - -TranslateMODCommand38: - StosW - Ret - -EndP TranslateMODCommand - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TranslateMTMPattern Far ; DS:SI points to data - ; DX = pattern no. - PushA - Push DS - Push ES - - Mov CS:MaxRow, 63 - Mov CS:PatternNumber, DX - - Call PE_ClearPatternData - - Mov ES, CS:PatternDataArea - Xor DI, DI - - Mov CX, 32 - -PE_TranslateMTMPattern1: - Push CX - Push DI - - Mov CX, 64 - -PE_TranslateMTMPattern2: - LodsW ; Layout of AX - XChg AH, AL - ; ppppppiiiiiieeee - ; p = pitch val - ; i = ins - ; e = effect - Mov DL, AL - And DL, 0Fh ; DL = effect. - ShR AX, 2 ; AX = 00pppppp iiiiiixx - ShR AL, 2 ; AH = pitch, AL = ins. - XChg AH, AL ; AH = ins. AL =pitch - - Test AL, AL - JZ PE_TranslateMTMPattern3 - - Add AL, 36 ; Middle octave C-5 - Jmp PE_TranslateMTMPattern4 - -PE_TranslateMTMPattern3: - Mov AL, NONOTE - -PE_TranslateMTMPattern4: - StosB ; Pitch. - - Mov AL, AH ; Instrument - Mov AH, 0FFh ; volume - StosW - - LodsB ; DL = effect, AL = effectval. - Mov AH, AL ; AH = AL = effectval. DL = eff. - Mov AL, DL - - Call TranslateMODCommand - - Add DI, 315 - Loop PE_TranslateMTMPattern2 - - Pop DI - Pop CX - Add DI, 5 - Loop PE_TranslateMTMPattern1 - - Push CS - Pop DS - Call Far Ptr PE_TranslateMODPattern1 - - Pop ES - Pop DS - PopA - - Ret - -EndP PE_TranslateMTMPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TranslateMODPattern Far ; DS:SI points to data - ; DX = pattern no. - ; AX = number of channels - PushA - Push DS - Push ES - - Mov CS:MaxRow, 63 - Mov CS:PatternNumber, DX - - Call PE_ClearPatternData - - Mov ES, CS:PatternDataArea - Xor DI, DI - Mov CX, 64 - -PE_TranslateMODPattern2: - Push AX - Push CX - Push DI - - Mov CX, AX - -PE_TranslateMODPattern3: - Mov AL, [DS:SI+1] - Mov AH, [DS:SI] - And AX, 0FFFh ; AX = period of note. - Mov DX, 72 - Xor BX, BX - -PE_TranslateMODPattern4: - Cmp AX, [CS:MODPeriodTable+BX] - JAE PE_TranslateMODPattern5 - - Add BX, 2 - Dec DX - JNZ PE_TranslateMODPattern4 - - Inc DI - Jmp PE_TranslateMODPattern6 - -PE_TranslateMODPattern5: - ShR BX, 1 ; BL = note. - Mov AL, BL - Add AL, 36 ; For C5 as central note. - StosB - -PE_TranslateMODPattern6: - Mov AL, [DS:SI] - Mov AH, [DS:SI+2] - ShR AH, 4 - And AL, 0F0h - Or AL, AH - StosB ; Sample stored. - - Inc DI ; Points to effect/commandvalue - - Mov AH, [DS:SI+3] - Mov AL, [DS:SI+2] - And AL, 0Fh ; AL = effect, AH = param. - - Call TranslateMODCommand - - Add SI, 4 - Loop PE_TranslateMODPattern3 - - Pop DI - Pop CX - Pop AX - Add DI, 320 - Loop PE_TranslateMODPattern2 - - Push CS - Pop DS - Call Far Ptr PE_TranslateMODPattern1 - - Pop ES - Pop DS - PopA - - Ret - -PE_TranslateMODPattern1: - Call PEFunction_StorePattern - - RetF - -EndP PE_TranslateMODPattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_Translate669Pattern Far - - PushA ; DS:0 points to data - Push DS ; CL = Maxrow - Push ES ; AH = Starting tempo - ; BP = PatternNumber - Mov Byte Ptr [CS:MaxRow], CL - Mov [CS:PatternNumber], BP - - Call PE_ClearPatternData - - Mov ES, CS:PatternDataArea - Cmp CL, 31 - JAE Pattern669Rows - - Mov [CS:MaxRow], 31 - - Mov AL, 5 - Mul CL - Mov DI, AX - ShL DI, 6 - - Mov Word Ptr [ES:DI+8*5+3], 'C'-'@' - -Pattern669Rows: - Xor DI, DI - - Mov AL, 'A'-'@' - Mov [ES:DI+8*5+3], AX ; Tempo setting - Inc CL - Xor SI, SI - - Xor EAX, EAX - Mov BP, Offset EncodingInfo - Mov [CS:BP], EAX - Mov [CS:BP+4], EAX - Mov [CS:BP+8], EAX - Mov [CS:BP+12], EAX - -Translate669Pattern1: - Mov CH, 8 - -Translate669Pattern2: - LodsW - Cmp AL, 0FEh - JB Translate669Pattern4 - JE Translate669Pattern3 - - Add DI, 3 - Jmp Translate669Pattern5 - -Translate669Pattern3: - Add DI, 2 - ShR AX, 6 - And AL, 3Ch - StosB - Jmp Translate669Pattern5 - -Translate669Pattern4: - Mov DX, AX ; Note - - And AX, 0F003h - ShL AL, 4 - ShR AH, 4 - Or AH, AL - Inc AH - Mov AL, DL - ShR AL, 2 - Add AL, 36 - StosW - - Mov AL, DH ; Volume - ShL AL, 2 - And AL, 3Ch - StosB - - Mov Word Ptr [CS:BP], 0 - -Translate669Pattern5: - LodsB - - Cmp AL, 0FFh - JE Translate669NoEffect - - Mov AH, AL - And AX, 00FF0h - -Translate669EffectA: ; Portamento Up - Cmp AL, 0 - JNE Translate669EffectB - - Mov AL, 'F'-'@' - Mov [CS:BP], AX - Jmp Translate669EffectEnd - -Translate669EffectB: ; Portamento down - Cmp AL, 10h - JNE Translate669EffectC - - Mov AL, 'E'-'@' - Mov [CS:BP], AX - Jmp Translate669EffectEnd - -Translate669EffectC: ; Portamento to - Cmp AL, 20h - JNE Translate669EffectD - - Mov AL, 'G'-'@' - Mov [CS:BP], AX - Jmp Translate669EffectEnd - -Translate669EffectD: ; Frequency Adjust - Cmp AL, 30h - JNE Translate669EffectE - - Mov AX, ('E'-'@')+0F100h - Mov Word Ptr [CS:BP], 0 - Jmp Translate669EffectEnd - -Translate669EffectE: ; Vibrato - Cmp AL, 40h - JNE Translate669EffectF - - Mov AL, 'H'-'@' - Or AH, 80h - Mov [CS:BP], AX - Jmp Translate669EffectEnd - -Translate669EffectF: - Cmp AL, 50h - JNE Translate669NoEffect - - Mov AL, 'A'-'@' - Mov Word Ptr [CS:BP], 0 - Jmp Translate669EffectEnd - -Translate669NoEffect: - Mov AX, [CS:BP] - -Translate669EffectEnd: - StosW - - Add BP, 2 - - Dec CH - JNZ Translate669Pattern2 - - Add DI, 320-8*5 - Mov BP, Offset EncodingInfo - - Dec CL - JNZ Translate669Pattern1 - - Push CS - Pop DS - - Call Far Ptr PE_TranslateS3MPointer8 - - Pop ES - Pop DS - PopA - - Ret - -EndP PE_Translate669Pattern - -;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - -Proc PE_TranslateS3MPattern Far ; DS:SI points to data. - ; DX = pattern no. - PushA - Push DS - Push ES - - Mov CS:MaxRow, 63 - Mov CS:PatternNumber, DX - - Call PE_ClearPatternData - - Mov ES, CS:PatternDataArea - Xor DI, DI - Mov CX, 64 - -PE_TranslateS3MPattern1: - Push DI - -PE_TranslateS3MPattern2: - LodsB - Test AL, AL - JNZ PE_TranslateS3MPattern3 - - Pop DI - Add DI, 320 - - Loop PE_TranslateS3MPattern1 - - Push CS - Pop DS - - Call Far Ptr PE_TranslateS3MPointer8 - - Pop ES - Pop DS - PopA - - Ret - -PE_TranslateS3MPointer8: - Call PEFunction_StorePattern - - RetF - -PE_TranslateS3MPattern3: - Push DI - Mov BH, AL - And AL, 31 - Mov AH, 5 - Mul AH ; DI+AX = offset. - Add DI, AX - Test BH, 32 - JZ PE_TranslateS3MPattern6 - - LodsB -; Cmp AL, 0FFH -; JE PE_TranslateS3MPattern5 - Cmp AL, 0FEh - JE PE_TranslateS3MPattern4 - Cmp AL, 07Fh - JA PE_TranslateS3MPattern5 - - Mov BL, AL - And BL, 0Fh - ShR AL, 4 - Mov AH, 12 - Mul AH - Add AL, BL - Add AL, 12 ; C5 is now central octave - Mov [ES:DI], AL ; Note - Jmp PE_TranslateS3MPattern5 - -PE_TranslateS3MPattern4: - Mov Byte Ptr [ES:DI], 0FEh - -PE_TranslateS3MPattern5: - LodsB ; Instrument - Cmp AL, 99 - JBE PE_TranslateS3MPattern13 - - Xor AL, AL - -PE_TranslateS3MPattern13: - Mov [ES:DI+1], AL - -PE_TranslateS3MPattern6: - Test BH, 64 - JZ PE_TranslateS3MPattern7 - - LodsB ; Volume - Cmp AL, 64 - JBE PE_TranslateS3MPattern12 - Cmp AL, 0FFh - JE PE_TranslateS3MPattern12 - - Mov AL, 64 - -PE_TranslateS3MPattern12: - Mov [ES:DI+2], AL - -PE_TranslateS3MPattern7: - Test BH, 128 - JZ PE_TranslateS3MPattern8 - - LodsW - Cmp AL, 'C'-'@' - JNE PE_TranslateS3MPattern9 - - Mov AL, AH - And AX, 0F00Fh - ShR AH, 1 - Add AL, AH - ShR AH, 2 - Add AH, AL - Mov AL, 'C'-'@' - Jmp PE_TranslateS3MPattern10 - -PE_TranslateS3MPattern9: - Cmp AL, 'V'-'@' - JNE PE_TranslateS3MPattern11 - - Jmp PE_TranslateS3MPattern14 - -PE_TranslateS3MPattern11: - Cmp AL, 'X'-'@' - JNE PE_TranslateS3MPattern15 - - Cmp AH, 0A4h - JNE PE_TranslateS3MPattern14 - - Mov AX, 'S'-'@'+9100h - Jmp PE_TranslateS3MPattern10 - -PE_TranslateS3MPattern14: - ShL AH, 1 - JNC PE_TranslateS3MPattern10 - - Mov AH, 0FFh - Jmp PE_TranslateS3MPattern10 - -PE_TranslateS3MPattern15: - Cmp AL, 'D'-'@' - JNE PE_TranslateS3MPattern10 - Test AL, 0Fh - JZ PE_TranslateS3MPattern10 - Test AL, 0F0h - JZ PE_TranslateS3MPattern10 - - Mov BL, AH - Mov BH, AH - And BX, 0FF0h - Cmp BH, 0Fh - JE PE_TranslateS3MPattern10 - Cmp BL, 0F0h - JE PE_TranslateS3MPattern10 - - And AH, 0Fh - -PE_TranslateS3MPattern10: - Mov [ES:DI+3], AX - -PE_TranslateS3MPattern8: - Pop DI - - Jmp PE_TranslateS3MPattern2 - -EndP PE_TranslateS3MPattern - - + +XMVolume DB 0 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TranslateXMNote + + Cmp AL, 96 + JBE TranslateXMNote1 + + Mov AL, 0FFh-11 ; Note off + +TranslateXMNote1: + Add AL, 11 + StosB + Ret + +EndP TranslateXMNote + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +XMEffectG DB 193, 193+4, 193+5, 193+6, 193+6, 193+7, 193+7, 193+8 + DB 193+8, 193+9 + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TranslateXMInstrument + + Cmp AL, 99 + JBE TranslateXMInstrument1 + + Xor AL, AL + + Cmp Byte Ptr [ES:DI-1], 0FFh ; note off? + JE TranslateXMInstrument2 + Mov Byte Ptr [ES:DI-1], 0FDh + Jmp TranslateXMInstrument2 + +TranslateXMInstrument1: + Cmp Byte Ptr [ES:DI-1], 0FFh ; note off? + JNE TranslateXMInstrument2 + + Xor AL, AL + +TranslateXMInstrument2: + StosB + Ret + +EndP TranslateXMInstrument + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TranslateXMVolume + + Push AX + + Mov AH, AL + Mov DX, AX + Mov AL, 0FFh + Cmp AH, 10h ; Nothing + JB TranslateXMVolume1 + + Mov AL, AH + Sub AL, 10h + Cmp AH, 50h ; Volume + JBE TranslateXMVolume1 + + Mov AL, 0FFh + Cmp AH, 60h ; Nothing + JB TranslateXMVolume1 + + Mov AL, AH + And AX, 0F00Fh + + Cmp AL, 9 + JBE TranslateXMVolume2 + + Mov AL, 9 + +TranslateXMVolume2: + Cmp AH, 70h + JAE TranslateXMVolume3 + + Add AL, 95 ; Volume down + Jmp TranslateXMVolume1 + +TranslateXMVolume3: + Cmp AH, 80h + JAE TranslateXMVolume4 + + Add AL, 85 ; volume up + Jmp TranslateXMVolume1 + +TranslateXMVolume4: + Cmp AH, 90h + JAE TranslateXMVolume5 + + Add AL, 75 ; Fine volume down + Jmp TranslateXMVolume1 + +TranslateXMVolume5: + Cmp AH, 0A0h + JAE TranslateXMVolume6 + + Add AL, 65 ; fine volume up + Jmp TranslateXMVolume1 + +TranslateXMVolume6: + Cmp AH, 0B0h + JAE TranslateXMVolume7 + + Mov AL, 0FFh ; Vibrato speed + Jmp TranslateXMVolume1 + +TranslateXMVolume7: + Cmp AH, 0C0h + JAE TranslateXMVolume8 + + Cmp AL, 3 + JBE TranslateXMVolumeH + + Dec AX + +TranslateXMVolumeH: + Add AL, 203 ; Vibrato + Jmp TranslateXMVolume1 + +TranslateXMVolume8: + Cmp AH, 0D0h + JAE TranslateXMVolume9 + + Mov AL, DL + Sub AL, 0C0h + Mov AH, AL + ShL AL, 2 + Or AL, AH ;Panning + Add AL, 128 + Jmp TranslateXMVolume1 + +TranslateXMVolume9: + Cmp AH, 0F0h + JAE TranslateXMVolume10 + + Mov AL, 0FFh ; Pan slide left/right + Jmp TranslateXMVolume1 + +TranslateXMVolume10: ; Porta + Push BX + Mov BX, AX + And BX, 0FFh + Mov AL, [CS:XMEffectG+BX] + Pop BX + +TranslateXMVolume1: + StosB + Pop AX + Ret + +EndP TranslateXMVolume + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TranslateXMEffect ; Given AX = data + + Test AX, AX + JNZ TranslateXMEffect1 + +TranslateXMEffectVol: + Xor AX, AX + Cmp CS:XMVolume, 60h + JB TranslateXMEffectEnd + Mov DH, 0FFh + Jmp TranslateXMEffectVolume + +TranslateXMEffect1: + Cmp AL, 'K'-'A'+0Ah + JNE TranslateXMEffect24 + + Mov AL, [ES:DI-3] + Cmp AL, 0FDh + JNE TranslateXMEffectVol + + Mov Word Ptr [ES:DI-3], 0FFh + Jmp TranslateXMEffectVol + +TranslateXMEffect24: + Cmp AL, 0 + JNE TranslateXMEffect2 + + Mov AL, 'J'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect2: + Cmp AL, 1 + JNE TranslateXMEffect3 + + Mov AL, 'F'-'@' + Test AH, AH + JNZ TranslateXMEffectEnd + Cmp CS:XMVolume, 60h + JB TranslateXMEffectEnd + Mov DH, 105 + Jmp TranslateXMEffectVolume + +TranslateXMEffect3: + Cmp AL, 2 + JNE TranslateXMEffect4 + + Mov AL, 'E'-'@' + Test AH, AH + JNZ TranslateXMEffectEnd + Cmp CS:XMVolume, 60h + JB TranslateXMEffectEnd + Mov DH, 115 + Jmp TranslateXMEffectVolume + +TranslateXMEffect4: + Cmp AL, 3 + JNE TranslateXMEffect5 + + Mov AL, 'G'-'@' + Test AH, AH + JNZ TranslateXMEffectEnd + Cmp CS:XMVolume, 60h + JB TranslateXMEffectEnd + Mov DH, 193 + Jmp TranslateXMEffectVolume + +TranslateXMEffect5: + Cmp AL, 4 + JNE TranslateXMEffect6 + + Mov AL, AH + And AX, 0FF0h + Cmp AH, 4 + JBE TranslateXMEffectH1 + + Dec AH + +TranslateXMEffectH1: + Or AH, AL + Mov AL, 'H'-'@' + Test AH, AH + JNZ TranslateXMEffectEnd + Cmp CS:XMVolume, 60h + JB TranslateXMEffectEnd + Mov DH, 203 + Jmp TranslateXMEffectVolume + +TranslateXMEffect6: + Cmp AL, 5 + JNE TranslateXMEffect7 + + Mov AL, 'L'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect7: + Cmp AL, 6 + JNE TranslateXMEffect8 + + Mov AL, 'K'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect8: + Cmp AL, 7 + JNE TranslateXMEffect9 + + Mov AL, 'R'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect9: + Cmp AL, 8 + JNE TranslateXMEffect10 + + Mov AL, 'X'-'@' + Cmp CS:XMVolume, 60h + JB TranslateXMEffectEnd + Mov DH, AH + ShR DH, 2 + AdC DH, 128 + Jmp TranslateXMEffectVolume + +TranslateXMEffect10: + Cmp AL, 9 + JNE TranslateXMEffect11 + + Mov AL, 'O'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect11: + Cmp AL, 0Ah + JNE TranslateXMEffect12 + + Mov AL, 'D'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect12: + Cmp AL, 0Bh + JNE TranslateXMEffect13 + + Mov AL, 'B'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect13: + Cmp AL, 0Ch + JNE TranslateXMEffect14 + + Mov DH, AH + Cmp DH, 64 + JB TranslateXMEffectVolume + + Mov DH, 64 + +TranslateXMEffectVolume: + Mov AL, CS:XMVolume + Mov AH, AL + And AH, 0Fh + + Cmp AL, 60h + JAE TranslateXMEffectVolume1 + + Xor AX, AX + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume1: + Cmp AL, 70h + JAE TranslateXMEffectVolume2 + + Mov AL, 'D'-'@' + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume2: + Cmp AL, 80h + JAE TranslateXMEffectVolume3 + + Mov AL, 'D'-'@' + ShL AH, 4 + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume3: + Cmp AL, 90h + JAE TranslateXMEffectVolume4 + + Mov AL, 'D'-'@' + Test AH, AH + JZ TranslateXMEffect3Memory + Or AH, 0F0h + Cmp AH, 0FFh + JNE TranslateXMEffect3Memory + + Dec AH + +TranslateXMEffect3Memory: + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume4: + Cmp AL, 0A0h + JAE TranslateXMEffectVolume5 + + Mov AL, 'D'-'@' + Test AH, AH + JZ TranslateXMEffect4Memory + + ShL AH, 4 + Or AH, 0Fh + +TranslateXMEffect4Memory: + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume5: + Cmp AL, 0B0h + JAE TranslateXMEffectVolume6 + + Mov AL, 'H'-'@' + ShL AH, 4 + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume6: + Cmp AL, 0C0h + JAE TranslateXMEffectVolume7 + + Cmp AH, 4 + JBE TranslateXMEffectVolumeH6 + + Dec AH + +TranslateXMEffectVolumeH6: + Mov AL, 'H'-'@' + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume7: + Cmp AL, 0D0h + JAE TranslateXMEffectVolume8 + + Mov AL, 'S'-'@' + Or AH, 80h + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume8: + Cmp AL, 0E0h + JAE TranslateXMEffectVolume9 + + Mov AL, 'P'-'@' + ShL AH, 4 + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume9: + Cmp AL, 0F0h + JAE TranslateXMEffectVolume10 + + Mov AL, 'P'-'@' + Jmp TranslateXMEffectVolumeEnd + +TranslateXMEffectVolume10: + Mov AL, 'G'-'@' + ShL AH, 4 + +TranslateXMEffectVolumeEnd: + Mov [ES:DI-1], DH + StosW + Ret + +TranslateXMEffect14: + Cmp AL, 0Dh + JNE TranslateXMEffect15 + + Mov AL, AH + And AX, 0F00Fh + ShR AH, 1 + Add AL, AH + ShR AH, 2 + Add AH, AL + Mov AL, 'C'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect15: + Cmp AL, 0Eh + JNE TranslateXMEffect16 + + ; 'Multiplex' effect + Mov AL, AH + And AX, 0FF0h + Test AL, AL + JNZ TranslateXMEffectE1 + + Xor AX, AX + Jmp TranslateXMEffectEnd + +TranslateXMEffectE1: + Cmp AL, 10h + JNE TranslateXMEffectE2 + + Test AH, AH + JZ TranslateE1Memory + Or AH, 0F0h + +TranslateE1Memory: + Mov AL, 'F'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectE2: + Cmp AL, 20h + JNE TranslateXMEffectE3 + + Test AH, AH + JZ TranslateE2Memory + Or AH, 0F0h + +TranslateE2Memory: + Mov AL, 'E'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectE3: + Cmp AL, 30h + JNE TranslateXMEffectE4 + + Xor AX, AX + Jmp TranslateXMEffectEnd + +TranslateXMEffectE4: + Cmp AL, 40h + JNE TranslateXMEffectE5 + + Or AH, 30h + Mov AL, 'S'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectE5: + Cmp AL, 50h + JNE TranslateXMEffectE6 + + Xor AX, AX + Jmp TranslateXMEffectEnd + +TranslateXMEffectE6: + Cmp AL, 60h + JNE TranslateXMEffectE7 + + Or AH, 0B0h + Mov AL, 'S'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectE7: + Cmp AL, 70h + JNE TranslateXMEffectE8 + + Or AH, 040h + Mov AL, 'S'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectE8: + Cmp AL, 80h + JNE TranslateXMEffectE9 + + Or AH, 80h + Mov AL, 'S'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectE9: + Cmp AL, 90h + JNE TranslateXMEffectEA + + Mov AL, 'Q'-'@' + Test AH, AH + JNZ TranslateXMEffectEnd + Jmp TranslateXMEffectVol + +TranslateXMEffectEA: + Cmp AL, 0A0h + JNE TranslateXMEffectEB + + Test AH, AH + JZ TranslateXMEAMemory + + ShL AH, 4 + Or AH, 0Fh + +TranslateXMEAMemory: + Mov AL, 'D'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectEB: + Cmp AL, 0B0h + JNE TranslateXMEffectEC + + Test AH, AH + JZ TranslateXMEBMemory + + Or AH, 0F0h + Cmp AH, 0FFh + JNE TranslateXMEBMemory + + Dec AH + +TranslateXMEBMemory: + Mov AL, 'D'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectEC: + Cmp AL, 0C0h + JNE TranslateXMEffectED + + Or AH, 0C0h + Mov AL, 'S'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectED: + Cmp AL, 0D0h + JNE TranslateXMEffectEE + + Or AH, 0D0h + Mov AL, 'S'-'@' + + Jmp TranslateXMEffectEnd + +TranslateXMEffectEE: + Cmp AL, 0E0h + JNE TranslateXMEffectEF + + Or AH, 0E0h + Mov AL, 'S'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffectEF: + Xor AX, AX + Jmp TranslateXMEffectEnd + +TranslateXMEffect16: + Cmp AL, 0Fh + JNE TranslateXMEffect18 + + Mov AL, 'T'-'@' + Cmp AH, 20h + JAE TranslateXMTempo1 + + Mov AL, 'A'-'@' + +TranslateXMTempo1: + Jmp TranslateXMEffectEnd + +TranslateXMEffect18: + Cmp AL, 10h ; 'G'lobal volume + JNE TranslateXMEffect19 + + Mov AL, 'V'-'@' + Cmp AH, 40h + JB TranslateXMEffectV + + Mov AH, 80h + Jmp TranslateXMEffectEnd + +TranslateXMEffectV: + ShL AH, 1 + Jmp TranslateXMEffectEnd + +TranslateXMEffect19: + Cmp AL, 11h ; 'H' + JNE TranslateXMEffect20 + + Mov AL, AH + And AX, 0FF0h + ShL AH, 1 + Cmp AH, 0Fh + JBE TranslateGlobalVolSlide2 + + Mov AH, 0Fh + +TranslateGlobalVolSlide2: + ShL AL, 1 + JNC TranslateGlobalVolSlide1 + + Mov AL, 0F0h + +TranslateGlobalVolSlide1: + Or AH, AL + Mov AL, 'W'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect20: + Cmp AL, 'R'-'A'+0Ah + JNE TranslateXMEffect21 + + Mov AL, 'Q'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect21: + Cmp AL, 'T'-'A'+0Ah + JNE TranslateXMEffect22 + + Mov AL, AH + And AX, 0FF0h + Test AH, AH + JNZ Tremor1 + + Inc AH + +Tremor1: + Test AL, AL + JNZ Tremor2 + + Inc AX +Tremor2: + Or AH, AL + Mov AL, 'I'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect22: + Cmp AL, 'X'-'A'+0Ah + JNE TranslateXMEffect23 + + Mov AL, AH + And AX, 0FF0h + Or AH, 0E0h + Cmp AL, 10h + JE TranslateXMEffectX1 + Cmp AL, 20h + JE TranslateXMEffectX2 + + Xor AX, AX + Jmp TranslateXMEffectEnd + +TranslateXMEffectX1: + Mov AL, 'F'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffectX2: + Mov AL, 'E'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEffect23: + Cmp AL, 'Z'-'A'+0Ah + JNE TranslateXMEffect25 + + Mov AL, 'Z'-'@' + Jmp TranslateXMEffectEnd + +TranslateXMEFfect25: + Jmp TranslateXMEffectVol +; Xor AX, AX + +TranslateXMEffectEnd: + StosW + Ret + +EndP TranslateXMEffect + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TranslateXMPattern Far ; DS:SI points to + ; data, AX = rows + ; CX = channels + ; DX = pattern num + + ; Has to return DS:SI + PushA + Push DS + Push ES + + Dec AX + Mov CS:TempVariableArea3, AX + Cmp AX, 31 + JAE PE_XMLimitRows + + Mov AX, 31 + +PE_XMLimitRows: + Mov CS:MaxRow, AX + Mov CS:PatternNumber, DX ; Pattern number + Mov CS:TempVariableArea2, CX ; Channels + + Call PE_ClearPatternData + + Mov ES, CS:PatternDataArea + Xor DI, DI + Xor AX, AX ; AX = row number + +PE_TranslateXMPattern1: + Push AX + Push DI + + Mov CX, CS:TempVariableArea2 ; CX = channels + +PE_TranslateXMPattern2: + Push CX + + LodsB ; AL = either note or compression + ; control. + Test AL, AL + JS PE_TranslateXMPatternCompressed + + Call TranslateXMNote + LodsB + Call TranslateXMInstrument + LodsB + Mov CS:XMVolume, AL + Call TranslateXMVolume + LodsW + Call TranslateXMEffect + Jmp PE_TranslateXMPattern3 + +PE_TranslateXMPatternCompressed: + Mov CS:XMVolume, 0 + Mov AH, AL + Test AH, 1 + JZ PE_TranslateXMPattern4 + + LodsB + Call TranslateXMNote + Dec DI + +PE_TranslateXMPattern4: + Inc DI + + Test AH, 2 + JZ PE_TranslateXMPattern5 + + LodsB + Call TranslateXMInstrument + Dec DI + +PE_TranslateXMPattern5: + Inc DI + + Test AH, 4 + JZ PE_TranslateXMPattern6 + + LodsB + Mov CS:XMVolume, AL + Call TranslateXMVolume + Dec DI + +PE_TranslateXMPattern6: + Inc DI + + Xor AL, AL + Test AH, 8 + JZ PE_TranslateXMPattern7 + + LodsB + +PE_TranslateXMPattern7: + Test AH, 10h + Mov AH, 0 + JZ PE_TranslateXMPattern8 + + Mov AH, [SI] + Inc SI + +PE_TranslateXMPattern8: + Call TranslateXMEffect + +PE_TranslateXMPattern3: + Pop CX + Dec CX + JNZ PE_TranslateXMPattern2 + + Pop DI + Pop AX + Add DI, 320 ; Next row. + Inc AX + Cmp AX, CS:TempVariableArea3 + JBE PE_TranslateXMPattern1 + + Mov CS:TempVariableArea, SI + + Mov AX, CS:TempVariableArea3 + Cmp AX, CS:MaxRow + JE PE_TranslateXMPatternNoBreak + + Mov DX, 320 + Mul DX + Mov DI, AX + Add DI, 3 + +PE_TranslateXMPatternBreak1: + Cmp Word Ptr [ES:DI], 0 + JE PE_TranslateXMPatternBreak2 + + Add DI, 5 + Jmp PE_TranslateXMPatternBreak1 + +PE_TranslateXMPatternBreak2: + Mov Word Ptr [ES:DI], 'C'-'@' ; Break. + +PE_TranslateXMPatternNoBreak: + Push CS + Pop DS + + Call Far Ptr PE_TranslateS3MPointer8 + + + Pop ES + Pop DS + PopA + + Mov SI, CS:TempVariableArea + + Ret + +EndP PE_TranslateXMPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc TranslateMODCommand ; AL = command + ; AH = command value + ; ES:DI points to + ; command destination + + Test AX, AX + JNZ TranslateMODCommand7 + + StosW + Ret + +TranslateMODCommand7: + Cmp AL, 0 + JNE TranslateMODCommand8 + + Mov AL, 'J'-'@' + StosW + Ret + +TranslateMODCommand8: + Cmp AL, 1 + JNE TranslateMODCommand9 + + Mov AL, 'F'-'@' + Jmp TranslateMODCommand36 + +TranslateMODCommand9: + Cmp AL, 2 + JNE TranslateMODCommand10 + + Mov AL, 'E'-'@' + Jmp TranslateMODCommand36 + +TranslateMODCommand10: + Cmp AL, 3 + JNE TranslateMODCommand11 + + Mov AL, 'G'-'@' + StosW + Ret + +TranslateMODCommand11: + Cmp AL, 4 + JNE TranslateMODCommand12 + + Mov AL, 'H'-'@' + + StosW + Ret + +TranslateMODCommand12: + Cmp AL, 5 + JNE TranslateMODCommand13 + + Mov AL, 'L'-'@' + Test AH, AH + JNZ TranslateMODCommand40 + + Mov AX, 'G'-'@' + +TranslateMODCommand40: + StosW + Ret + +TranslateMODCommand13: + Cmp AL, 6 + JNE TranslateMODCommand14 + + Mov AL, 'K'-'@' + Test AH, AH + JNZ TranslateMODCommand39 + + Mov AX, 'H'-'@' + +TranslateMODCommand39: + StosW + Ret + +TranslateMODCommand14: + Cmp AL, 7 + JNE TranslateMODCommand15 + + Mov AL, 'R'-'@' + StosW + Ret + +TranslateMODCommand15: + Cmp AL, 8 + JNE TranslateMODCommand16 + + Mov AL, 'X'-'@' + Cmp AH, 0A4h + JNE TranslateMODNoSurround + + Mov AX, 'S'-'@'+9100h + +TranslateMODNoSurround: + StosW + Ret + +TranslateMODCommand16: + Cmp AL, 9 + JNE TranslateMODCommand17 + + Mov AL, 'O'-'@' + StosW + Ret + +TranslateMODCommand17: + Cmp AL, 10 + JNE TranslateMODCommand18 + + Mov AL, 'D'-'@' + Test AH, 0Fh + JZ TranslateMODVolumeSlide1 + Test AH, 0F0h + JZ TranslateMODVolumeSlide1 + + And AH, 0F0h + +TranslateMODVolumeSlide1: + Jmp TranslateMODCommand36 + +TranslateMODCommand18: + Cmp AL, 11 + JNE TranslateMODCommand19 + + Mov AL, 'B'-'@' + StosW + Ret + +TranslateMODCommand19: + Cmp AL, 12 + JNE TranslateMODCommand20 + + Cmp AH, 64 + JBE TranslateMODCommand37 + + Mov AH, 64 + +TranslateMODCommand37: + Mov [ES:DI-1], AH + Add DI, 2 + Ret + +TranslateMODCommand20: + Cmp AL, 13 + JNE TranslateMODCommand21 + + Mov AL, AH + And AX, 0F00Fh + ShR AH, 1 ; AH = highnibble*8 + Add AL, AH + + ShR AH, 2 ; AH = highnibble*2 + Add AH, AL + + Mov AL, 'C'-'@' + StosW + Ret + +TranslateMODCommand21: + Cmp AL, 14 + JNE TranslateMODCommand34 + + Mov AL, AH + And AX, 0FF0h + + Cmp AL, 0 + JNE TranslateMODCommand22 + + Test AH, AH + JZ TranslateMODCommand36 + + Mov AL, 'S'-'@' + StosW + Ret + +TranslateMODCommand22: + Cmp AL, 10h + JNE TranslateMODCommand23 + + Test AH, AH + JZ TranslateMODCommand36 + + Mov AL, 'F'-'@' + Or AH, 0F0h + StosW + Ret + +TranslateMODCommand23: + Cmp AL, 20h + JNE TranslateMODCommand24 + + Test AH, AH + JZ TranslateMODCommand36 + + Mov AL, 'E'-'@' + Or AH, 0F0h + StosW + Ret + +TranslateMODCommand24: + Cmp AL, 30h + JNE TranslateMODCommand25 + + Mov AL, 'S'-'@' + Or AH, 010h + StosW + Ret + +TranslateMODCommand25: + Cmp AL, 40h + JNE TranslateMODCommand26 + + Mov AL, 'S'-'@' + Or AH, 030h + StosW + Ret + +TranslateMODCommand26: + Cmp AL, 50h + JNE TranslateMODCommand27 + + Mov AL, 'S'-'@' + Or AH, 020h + StosW + Ret + +TranslateMODCommand27: + Cmp AL, 60h + JNE TranslateMODCommand28 + + Mov AL, 'S'-'@' + Or AH, 0B0h + StosW + Ret + +TranslateMODCommand28: + Cmp AL, 70h + JNE TranslateMODCommand29 + + Mov AL, 'S'-'@' + Or AH, 40h + StosW + Ret + +TranslateMODCommand29: + Cmp AL, 80h + JNE TranslateMODCommand30 + + Or AH, AL + Mov AL, 'S'-'@' + StosW + Ret + +TranslateMODCommand30: + Cmp AL, 90h + JNE TranslateMODCommand31 + + Test AH, AH + JZ TranslateMODCommand36 + + Mov AL, 'Q'-'@' + Jmp TranslateMODCommand36 + +TranslateMODCommand31: + Cmp AL, 0A0h + JNE TranslateMODCommand32 + + And AH, 0Fh + JZ TranslateMODCommand36 + + Mov AL, 'D'-'@' + ShL AH, 4 + Or AH, 0Fh + StosW + Ret + +TranslateMODCommand32: + Cmp AL, 0B0h + JNE TranslateMODCommand33 + + And AH, 0Fh + JZ TranslateMODCommand36 + + Mov AL, 'D'-'@' + Or AH, 0F0h + StosW + Ret + + +TranslateMODCommand33: + Or AH, AL + Mov AL, 'S'-'@' + StosW + Ret + +TranslateMODCommand34: ; Set speed. + Cmp AH, 20h + JA TranslateMODCommand35 + + Mov AL, 'A'-'@' + Jmp TranslateMODCommand36 + +TranslateMODCommand35: + Mov AL, 'T'-'@' + StosW + Ret + +TranslateMODCommand36: + Test AH, AH + JNZ TranslateMODCommand38 + + Xor AX, AX + +TranslateMODCommand38: + StosW + Ret + +EndP TranslateMODCommand + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TranslateMTMPattern Far ; DS:SI points to data + ; DX = pattern no. + PushA + Push DS + Push ES + + Mov CS:MaxRow, 63 + Mov CS:PatternNumber, DX + + Call PE_ClearPatternData + + Mov ES, CS:PatternDataArea + Xor DI, DI + + Mov CX, 32 + +PE_TranslateMTMPattern1: + Push CX + Push DI + + Mov CX, 64 + +PE_TranslateMTMPattern2: + LodsW ; Layout of AX + XChg AH, AL + ; ppppppiiiiiieeee + ; p = pitch val + ; i = ins + ; e = effect + Mov DL, AL + And DL, 0Fh ; DL = effect. + ShR AX, 2 ; AX = 00pppppp iiiiiixx + ShR AL, 2 ; AH = pitch, AL = ins. + XChg AH, AL ; AH = ins. AL =pitch + + Test AL, AL + JZ PE_TranslateMTMPattern3 + + Add AL, 36 ; Middle octave C-5 + Jmp PE_TranslateMTMPattern4 + +PE_TranslateMTMPattern3: + Mov AL, NONOTE + +PE_TranslateMTMPattern4: + StosB ; Pitch. + + Mov AL, AH ; Instrument + Mov AH, 0FFh ; volume + StosW + + LodsB ; DL = effect, AL = effectval. + Mov AH, AL ; AH = AL = effectval. DL = eff. + Mov AL, DL + + Call TranslateMODCommand + + Add DI, 315 + Loop PE_TranslateMTMPattern2 + + Pop DI + Pop CX + Add DI, 5 + Loop PE_TranslateMTMPattern1 + + Push CS + Pop DS + Call Far Ptr PE_TranslateMODPattern1 + + Pop ES + Pop DS + PopA + + Ret + +EndP PE_TranslateMTMPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TranslateMODPattern Far ; DS:SI points to data + ; DX = pattern no. + ; AX = number of channels + PushA + Push DS + Push ES + + Mov CS:MaxRow, 63 + Mov CS:PatternNumber, DX + + Call PE_ClearPatternData + + Mov ES, CS:PatternDataArea + Xor DI, DI + Mov CX, 64 + +PE_TranslateMODPattern2: + Push AX + Push CX + Push DI + + Mov CX, AX + +PE_TranslateMODPattern3: + Mov AL, [DS:SI+1] + Mov AH, [DS:SI] + And AX, 0FFFh ; AX = period of note. + Mov DX, 72 + Xor BX, BX + +PE_TranslateMODPattern4: + Cmp AX, [CS:MODPeriodTable+BX] + JAE PE_TranslateMODPattern5 + + Add BX, 2 + Dec DX + JNZ PE_TranslateMODPattern4 + + Inc DI + Jmp PE_TranslateMODPattern6 + +PE_TranslateMODPattern5: + ShR BX, 1 ; BL = note. + Mov AL, BL + Add AL, 36 ; For C5 as central note. + StosB + +PE_TranslateMODPattern6: + Mov AL, [DS:SI] + Mov AH, [DS:SI+2] + ShR AH, 4 + And AL, 0F0h + Or AL, AH + StosB ; Sample stored. + + Inc DI ; Points to effect/commandvalue + + Mov AH, [DS:SI+3] + Mov AL, [DS:SI+2] + And AL, 0Fh ; AL = effect, AH = param. + + Call TranslateMODCommand + + Add SI, 4 + Loop PE_TranslateMODPattern3 + + Pop DI + Pop CX + Pop AX + Add DI, 320 + Loop PE_TranslateMODPattern2 + + Push CS + Pop DS + Call Far Ptr PE_TranslateMODPattern1 + + Pop ES + Pop DS + PopA + + Ret + +PE_TranslateMODPattern1: + Call PEFunction_StorePattern + + RetF + +EndP PE_TranslateMODPattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_Translate669Pattern Far + + PushA ; DS:0 points to data + Push DS ; CL = Maxrow + Push ES ; AH = Starting tempo + ; BP = PatternNumber + Mov Byte Ptr [CS:MaxRow], CL + Mov [CS:PatternNumber], BP + + Call PE_ClearPatternData + + Mov ES, CS:PatternDataArea + Cmp CL, 31 + JAE Pattern669Rows + + Mov [CS:MaxRow], 31 + + Mov AL, 5 + Mul CL + Mov DI, AX + ShL DI, 6 + + Mov Word Ptr [ES:DI+8*5+3], 'C'-'@' + +Pattern669Rows: + Xor DI, DI + + Mov AL, 'A'-'@' + Mov [ES:DI+8*5+3], AX ; Tempo setting + Inc CL + Xor SI, SI + + Xor EAX, EAX + Mov BP, Offset EncodingInfo + Mov [CS:BP], EAX + Mov [CS:BP+4], EAX + Mov [CS:BP+8], EAX + Mov [CS:BP+12], EAX + +Translate669Pattern1: + Mov CH, 8 + +Translate669Pattern2: + LodsW + Cmp AL, 0FEh + JB Translate669Pattern4 + JE Translate669Pattern3 + + Add DI, 3 + Jmp Translate669Pattern5 + +Translate669Pattern3: + Add DI, 2 + ShR AX, 6 + And AL, 3Ch + StosB + Jmp Translate669Pattern5 + +Translate669Pattern4: + Mov DX, AX ; Note + + And AX, 0F003h + ShL AL, 4 + ShR AH, 4 + Or AH, AL + Inc AH + Mov AL, DL + ShR AL, 2 + Add AL, 36 + StosW + + Mov AL, DH ; Volume + ShL AL, 2 + And AL, 3Ch + StosB + + Mov Word Ptr [CS:BP], 0 + +Translate669Pattern5: + LodsB + + Cmp AL, 0FFh + JE Translate669NoEffect + + Mov AH, AL + And AX, 00FF0h + +Translate669EffectA: ; Portamento Up + Cmp AL, 0 + JNE Translate669EffectB + + Mov AL, 'F'-'@' + Mov [CS:BP], AX + Jmp Translate669EffectEnd + +Translate669EffectB: ; Portamento down + Cmp AL, 10h + JNE Translate669EffectC + + Mov AL, 'E'-'@' + Mov [CS:BP], AX + Jmp Translate669EffectEnd + +Translate669EffectC: ; Portamento to + Cmp AL, 20h + JNE Translate669EffectD + + Mov AL, 'G'-'@' + Mov [CS:BP], AX + Jmp Translate669EffectEnd + +Translate669EffectD: ; Frequency Adjust + Cmp AL, 30h + JNE Translate669EffectE + + Mov AX, ('E'-'@')+0F100h + Mov Word Ptr [CS:BP], 0 + Jmp Translate669EffectEnd + +Translate669EffectE: ; Vibrato + Cmp AL, 40h + JNE Translate669EffectF + + Mov AL, 'H'-'@' + Or AH, 80h + Mov [CS:BP], AX + Jmp Translate669EffectEnd + +Translate669EffectF: + Cmp AL, 50h + JNE Translate669NoEffect + + Mov AL, 'A'-'@' + Mov Word Ptr [CS:BP], 0 + Jmp Translate669EffectEnd + +Translate669NoEffect: + Mov AX, [CS:BP] + +Translate669EffectEnd: + StosW + + Add BP, 2 + + Dec CH + JNZ Translate669Pattern2 + + Add DI, 320-8*5 + Mov BP, Offset EncodingInfo + + Dec CL + JNZ Translate669Pattern1 + + Push CS + Pop DS + + Call Far Ptr PE_TranslateS3MPointer8 + + Pop ES + Pop DS + PopA + + Ret + +EndP PE_Translate669Pattern + +;ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + +Proc PE_TranslateS3MPattern Far ; DS:SI points to data. + ; DX = pattern no. + PushA + Push DS + Push ES + + Mov CS:MaxRow, 63 + Mov CS:PatternNumber, DX + + Call PE_ClearPatternData + + Mov ES, CS:PatternDataArea + Xor DI, DI + Mov CX, 64 + +PE_TranslateS3MPattern1: + Push DI + +PE_TranslateS3MPattern2: + LodsB + Test AL, AL + JNZ PE_TranslateS3MPattern3 + + Pop DI + Add DI, 320 + + Loop PE_TranslateS3MPattern1 + + Push CS + Pop DS + + Call Far Ptr PE_TranslateS3MPointer8 + + Pop ES + Pop DS + PopA + + Ret + +PE_TranslateS3MPointer8: + Call PEFunction_StorePattern + + RetF + +PE_TranslateS3MPattern3: + Push DI + Mov BH, AL + And AL, 31 + Mov AH, 5 + Mul AH ; DI+AX = offset. + Add DI, AX + Test BH, 32 + JZ PE_TranslateS3MPattern6 + + LodsB +; Cmp AL, 0FFH +; JE PE_TranslateS3MPattern5 + Cmp AL, 0FEh + JE PE_TranslateS3MPattern4 + Cmp AL, 07Fh + JA PE_TranslateS3MPattern5 + + Mov BL, AL + And BL, 0Fh + ShR AL, 4 + Mov AH, 12 + Mul AH + Add AL, BL + Add AL, 12 ; C5 is now central octave + Mov [ES:DI], AL ; Note + Jmp PE_TranslateS3MPattern5 + +PE_TranslateS3MPattern4: + Mov Byte Ptr [ES:DI], 0FEh + +PE_TranslateS3MPattern5: + LodsB ; Instrument + Cmp AL, 99 + JBE PE_TranslateS3MPattern13 + + Xor AL, AL + +PE_TranslateS3MPattern13: + Mov [ES:DI+1], AL + +PE_TranslateS3MPattern6: + Test BH, 64 + JZ PE_TranslateS3MPattern7 + + LodsB ; Volume + Cmp AL, 64 + JBE PE_TranslateS3MPattern12 + Cmp AL, 0FFh + JE PE_TranslateS3MPattern12 + + Mov AL, 64 + +PE_TranslateS3MPattern12: + Mov [ES:DI+2], AL + +PE_TranslateS3MPattern7: + Test BH, 128 + JZ PE_TranslateS3MPattern8 + + LodsW + Cmp AL, 'C'-'@' + JNE PE_TranslateS3MPattern9 + + Mov AL, AH + And AX, 0F00Fh + ShR AH, 1 + Add AL, AH + ShR AH, 2 + Add AH, AL + Mov AL, 'C'-'@' + Jmp PE_TranslateS3MPattern10 + +PE_TranslateS3MPattern9: + Cmp AL, 'V'-'@' + JNE PE_TranslateS3MPattern11 + + Jmp PE_TranslateS3MPattern14 + +PE_TranslateS3MPattern11: + Cmp AL, 'X'-'@' + JNE PE_TranslateS3MPattern15 + + Cmp AH, 0A4h + JNE PE_TranslateS3MPattern14 + + Mov AX, 'S'-'@'+9100h + Jmp PE_TranslateS3MPattern10 + +PE_TranslateS3MPattern14: + ShL AH, 1 + JNC PE_TranslateS3MPattern10 + + Mov AH, 0FFh + Jmp PE_TranslateS3MPattern10 + +PE_TranslateS3MPattern15: + Cmp AL, 'D'-'@' + JNE PE_TranslateS3MPattern10 + Test AL, 0Fh + JZ PE_TranslateS3MPattern10 + Test AL, 0F0h + JZ PE_TranslateS3MPattern10 + + Mov BL, AH + Mov BH, AH + And BX, 0FF0h + Cmp BH, 0Fh + JE PE_TranslateS3MPattern10 + Cmp BL, 0F0h + JE PE_TranslateS3MPattern10 + + And AH, 0Fh + +PE_TranslateS3MPattern10: + Mov [ES:DI+3], AX + +PE_TranslateS3MPattern8: + Pop DI + + Jmp PE_TranslateS3MPattern2 + +EndP PE_TranslateS3MPattern + + diff --git a/switch.inc b/switch.inc new file mode 100644 index 0000000..ac7f62c --- /dev/null +++ b/switch.inc @@ -0,0 +1,32 @@ +TRACKERVERSION equ 217h; Still have to change text in IT.ASM, IT_F.ASM + +TRACEENABLED equ 0 +TUTORIAL equ 0 +EMSUSE41 equ 0 +SHOWVERSION equ 0 +SHOWREGISTERNAME equ 1 +USE32BITSCREENCOPY equ 0 +SORTENABLED equ 1 +DDCOMPRESS equ 1 +ORDERSORT equ 1 +FILTERENVELOPES equ 1 +CHORDENTRY equ 1 +SPECTRUMANALYSER equ 1 +SAVESAMPLEWAV equ 1 +ENABLEPRESETENVELOPES equ 1 +ENABLESOLO equ 1 +DEFAULTFORMAT equ 3 ; 0 equ IT214, 1 equ S3M, 2 equ IT2xx, 3 equ IT215 +USEFPUCODE equ 1 ; For IT_MUSIC, this will change from LUT to FPU code +OLDDRIVER equ 0 +MUSICDEBUG equ 0 +EMSDEBUG equ 0 +MEMORYDEBUG equ 0 +ENABLEINT3 equ 0 ; For debugging. +TIMERSCREEN equ 1 +NETWORKENABLED equ 1 +SHOWPATTERNLENGTH equ 0 + +%if TUTORIAL + SORTENABLED equ 1 + DDCOMPRESS equ 1 +%endif diff --git a/USERNAME.INC b/username.inc similarity index 100% rename from USERNAME.INC rename to username.inc diff --git a/WAVSWITC.INC b/wavswitc.inc similarity index 94% rename from WAVSWITC.INC rename to wavswitc.inc index c3512e9..b01b3ae 100644 --- a/WAVSWITC.INC +++ b/wavswitc.inc @@ -1,22 +1,22 @@ - -REGISTERED = 1 - -VOLUMERAMP = 1 -DOUBLEVOLUME = 0 -DITHEROUTPUT = 1 - -USECLICKFADETHRESHHOLD= 0 -CLICKFADETHRESHHOLD = 4096 - -RAMPSPEED = 8 -RAMPCOMPENSATE = 255 - -CUBICINTERPOLATION = 1 -QUADRATICINTERPOLATION = 0 -LINEARINTERPOLATION = 0 -POINTSAMPLED = 0 - -INTELOPTIMISED = 0 - -FileID DW 0 - + +REGISTERED = 1 + +VOLUMERAMP = 1 +DOUBLEVOLUME = 0 +DITHEROUTPUT = 1 + +USECLICKFADETHRESHHOLD= 0 +CLICKFADETHRESHHOLD = 4096 + +RAMPSPEED = 8 +RAMPCOMPENSATE = 255 + +CUBICINTERPOLATION = 1 +QUADRATICINTERPOLATION = 0 +LINEARINTERPOLATION = 0 +POINTSAMPLED = 0 + +INTELOPTIMISED = 0 + +FileID DW 0 +