| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- ;
- ; Command & Conquer Red Alert(tm)
- ; Copyright 2025 Electronic Arts Inc.
- ;
- ; This program is free software: you can redistribute it and/or modify
- ; it under the terms of the GNU General Public License as published by
- ; the Free Software Foundation, either version 3 of the License, or
- ; (at your option) any later version.
- ;
- ; This program is distributed in the hope that it will be useful,
- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ; GNU General Public License for more details.
- ;
- ; You should have received a copy of the GNU General Public License
- ; along with this program. If not, see <http://www.gnu.org/licenses/>.
- ;
- ;****************************************************************************
- ;*
- ;* Copyright (c) 1994, HMI, INC. All Rights Reserved
- ;*
- ;*---------------------------------------------------------------------------
- ;*
- ;* FILE
- ;* soscodec.asm
- ;*
- ;* DESCRIPTION
- ;* HMI SOS ADPCM compression/decompression.
- ;*
- ;* PROGRAMMER
- ;* Nick Skrepetos
- ;* Denzil E. Long, Jr. (Fixed bugs, rewrote for watcom)
- ;* Bill Petro (Added stereo support)
- ;* DATE
- ;* Febuary 15, 1995
- ;*
- ;*---------------------------------------------------------------------------
- ;*
- ;* PUBLIC
- ;*
- ;****************************************************************************
- IDEAL
- P386
- MODEL USE32 FLAT
- LOCALS ??
- DPMI_INTR equ 31h
- IF_LOCKED_PM_CODE equ 1h ; Locked PM code for DPMI.
- IF_LOCKED_PM_DATA equ 2h ; Locked PM code for DPMI.
- STRUC sCompInfo
- lpSource DD ? ;Compressed data pointer
- lpDest DD ? ;Uncompressed data pointer
- dwCompSize DD ? ;Compressed size
- dwUnCompSize DD ? ;Uncompressed size
- dwSampleIndex DD ? ;Index into sample
- dwPredicted DD ? ;Next predicted value
- dwDifference DD ? ;Difference from last sample
- wCodeBuf DW ? ;Holds 2 nibbles for decompression
- wCode DW ? ;Current 4 bit code
- wStep DW ? ;Step value in table
- wIndex DW ? ;Index into step table
- dwSampleIndex2 DD ? ;Index into sample
- dwPredicted2 DD ? ;Next predicted value
- dwDifference2 DD ? ;Difference from last sample
- wCodeBuf2 DW ? ;Holds 2 nibbles for decompression
- wCode2 DW ? ;Current 4 bit code
- wStep2 DW ? ;Step value in table
- wIndex2 DW ? ;Index into step table
- wBitSize DW ? ;Bit size for decompression
- wChannels DW ? ;number of channels
- ENDS sCompInfo
- DATASEG
- InitFlags DD 0 ; Flags to indicate what has been initialized.
- LABEL LockedDataStart BYTE
- ;* Index table for stepping into step table
- wCODECIndexTab DW -1,-1,-1,-1,2,4,6,8
- DW -1,-1,-1,-1,2,4,6,8
- ;Lookup table of replacement values
- ;The actual sound value is replaced with an index to lookup in this table
- ;The index only takes up a nibble(4bits) and represents an int(16bits)
- ;Essentially:
- ;Get a value
- ;compare it with the value before it
- ;find closest value in table and store the index into the table
- ;if i'm going down then negitize it
- ;go to next byte.
- ;Theory for stereo:
- ;1)handle stereo and mono in two seperate loops. cleaner...
- ;start at byte 0 and skip every other byte(or word) both write and read
- ;when we get done
- ; set start byte to 1 and do it again
- ;This table essentialy round off to closes values in 3 distinct bands
- ; precalculated and optimized(i guess) for human hearing.
- wCODECStepTab DW 7, 8, 9, 10, 11, 12, 13,14
- DW 16, 17, 19, 21, 23, 25, 28, 31
- DW 34, 37, 41, 45, 50, 55, 60, 66
- DW 73, 80, 88, 97, 107, 118, 130, 143
- DW 157, 173, 190, 209, 230, 253, 279, 307
- DW 337, 371, 408, 449, 494, 544, 598, 658
- DW 724, 796, 876, 963, 1060, 1166, 1282, 1411
- DW 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024
- DW 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484
- DW 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899
- DW 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794
- DW 32767
- ;dwCODECByteIndex DD 0 ; this is when to stop compressing
- ;dwCODECTempStep DD 0 ; tempory storage for step value
- ;wCODECMask DW 0 ; Current mask
- LABEL LockedDataEnd BYTE
- CODESEG
- LABEL LockedCodeStart BYTE
- ;****************************************************************************
- ;*
- ;* NAME
- ;* sosCODECInitStream - Initialize compression stream.
- ;*
- ;* SYNOPSIS
- ;* sosCODECInitStream(CompInfo)
- ;*
- ;* void sosCODECInitStream(_SOS_COMPRESS_INFO *);
- ;*
- ;* FUNCTION
- ;* Initialize compression stream for compression and decompression.
- ;*
- ;* INPUTS
- ;* CompInfo - Compression information structure.
- ;*
- ;* RESULT
- ;* NONE
- ;*
- ;****************************************************************************
- GLOBAL C sosCODECInitStream:NEAR
- PROC sosCODECInitStream C NEAR
- ARG sSOSInfo:NEAR PTR
- mov eax,[sSOSInfo]
- mov [(sCompInfo eax).wIndex],0 ; starting index 0
- mov [(sCompInfo eax).wStep],7 ; start with a step of 7
- mov [(sCompInfo eax).dwPredicted],0 ; no predicted value
- mov [(sCompInfo eax).dwSampleIndex],0 ;start at head of index
- mov [(sCompInfo eax).wIndex2],0 ; starting index 0
- mov [(sCompInfo eax).wStep2],7 ; start with a step of 7
- mov [(sCompInfo eax).dwPredicted2],0 ; no predicted value
- mov [(sCompInfo eax).dwSampleIndex2],0 ;start at head of index
- ret
- ENDP sosCODECInitStream
- ;****************************************************************************
- ;*
- ;* NAME
- ;* sosCODECDecompressData - Decompress audio data.
- ;*
- ;* SYNOPSIS
- ;* Size = sosCODECDecompressData(CompInfo, NumBytes)
- ;*
- ;* long sosCODECDecompressData(_SOS_COMPRESS_INFO *, long);
- ;*
- ;* FUNCTION
- ;* Decompress data from a 4:1 ADPCM compressed stream. The number of
- ;* bytes decompressed is returned.
- ;*
- ;* INPUTS
- ;* CompInfo - Compress information structure.
- ;* NumBytes - Number of bytes to compress.
- ;*
- ;* RESULT
- ;* Size - Size of decompressed data.
- ;*
- ;****************************************************************************
- GLOBAL C General_sosCODECDecompressData:NEAR
- PROC General_sosCODECDecompressData C NEAR
- ARG sSOSInfo:NEAR PTR
- ARG wBytes:DWORD
- local dwCODECBytesProcessed:dword ;bytes to decompress
- local dwCODECByteIndex:dword ;this is when to stop compressing
- ; these need to be local if the function is to be reenterant
- push esi
- push edi
- push ebx
- push ecx
- push edx
- ;*---------------------------------------------------------------------------
- ;* Initialize
- ;*---------------------------------------------------------------------------
- mov ebx,[sSOSInfo]
- mov eax,[wBytes]
- mov [dwCODECBytesProcessed],eax
- mov [(sCompInfo ebx).dwSampleIndex],0 ;start at head of index
- mov [(sCompInfo ebx).dwSampleIndex2],0 ;start at head of index
- ;Check for 16 bit decompression
- cmp [(sCompInfo ebx).wBitSize],16
- jne short ??skipByteDivide
- shr eax,1 ;Divide size by two
- ??skipByteDivide:
- mov [dwCODECByteIndex],eax
- mov esi,[(sCompInfo ebx).lpSource]
- mov edi,[(sCompInfo ebx).lpDest]
- cmp [(sCompInfo ebx).wChannels],2 ;stereo check
- je ??mainloopl ;do left side first
- ; Determine if sample index is even or odd. This will determine
- ; if we need to get a new token or not.
- ;---------------------------------------------------------------------------
- ;Main Mono Loop
- ;---------------------------------------------------------------------------
- ??mainloop:
- test [(sCompInfo ebx).dwSampleIndex],1 ;odd ??
- je short ??fetchToken ; if so get new token
- xor eax,eax ;else shift int codebuf
- mov ax,[(sCompInfo ebx).wCodeBuf] ;ored with Code
- shr eax,4
- and eax,000Fh
- mov [(sCompInfo ebx).wCode],ax
- jmp short ??calcDifference
- ??fetchToken:
- xor eax,eax ;get a new token
- mov al,[esi] ;put in codebuf
- mov [(sCompInfo ebx).wCodeBuf],ax
- inc esi
- and eax,000Fh
- mov [(sCompInfo ebx).wCode],ax ;and then code
- ??calcDifference:
- mov [(sCompInfo ebx).dwDifference],0 ;reset diff
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wStep] ;cx is step value
- test eax,4 ;Check for wCode & 4
- je short ??no4
- add [(sCompInfo ebx).dwDifference],ecx ;Add wStep
- ??no4:
- test eax,2 ;Check for wCode & 2
- je short ??no2
- mov edx,ecx ;Add wStep >> 1
- shr edx,1
- add [(sCompInfo ebx).dwDifference],edx
- ??no2:
- test eax,1 ;Check for wCode & 1
- je short ??no1
- mov edx,ecx ;Add wStep >> 2
- shr edx,2
- add [(sCompInfo ebx).dwDifference],edx
- ??no1:
- mov edx,ecx ;Add in wStep >> 3
- shr edx,3
- add [(sCompInfo ebx).dwDifference],edx
- test eax,8 ;Check for wCode & 8
- je short ??no8
- neg [(sCompInfo ebx).dwDifference] ;Negate diff
- ??no8:
- ; add difference to predicted value.
- mov eax,[(sCompInfo ebx).dwPredicted]
- add eax,[(sCompInfo ebx).dwDifference]
- ; make sure there is no under or overflow.
- cmp eax,7FFFh
- jl short ??noOverflow
- mov eax,7FFFh
- ??noOverflow:
- cmp eax,0FFFF8000h
- jg short ??noUnderflow
- mov eax,0FFFF8000h
- ??noUnderflow:
- mov [(sCompInfo ebx).dwPredicted],eax
- cmp [(sCompInfo ebx).wBitSize],16
- jne short ??output8Bit
- mov [edi],ax ;Output 16bit sample
- add edi,2
- jmp short ??adjustIndex
- ??output8Bit:
- ; output 8 bit sample
- xor ah,80h
- mov [edi],ah
- inc edi
- ??adjustIndex:
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wCode]
- xor eax,eax
- shl ecx,1
- mov ax,[wCODECIndexTab + ecx]
- add [(sCompInfo ebx).wIndex],ax ;check if wIndex < 0
- cmp [(sCompInfo ebx).wIndex],8000h
- jb short ??checkOverflow
- mov [(sCompInfo ebx).wIndex],0 ;reset index to zero
- jmp short ??adjustStep
- ??checkOverflow:
- cmp [(sCompInfo ebx).wIndex],88 ;check if wIndex > 88
- jbe short ??adjustStep
- mov [(sCompInfo ebx).wIndex],88 ;reset index to 88
- ??adjustStep:
- ; fetch wIndex so we can fetch new step value
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wIndex]
- xor eax,eax
- shl ecx,1
- mov ax,[wCODECStepTab + ecx]
- ; advance index and store step value
- add [(sCompInfo ebx).dwSampleIndex],1
- mov [(sCompInfo ebx).wStep],ax
- ; decrement bytes processed and loop back.
- dec [dwCODECByteIndex]
- jne ??mainloop
- jmp ??exitout
- ;--------------------------------------------------------------------------
- ;Left Channel Start
- ;--------------------------------------------------------------------------
- ??mainloopl:
- test [(sCompInfo ebx).dwSampleIndex],1
- je short ??fetchTokenl
- xor eax,eax
- mov ax,[(sCompInfo ebx).wCodeBuf]
- shr eax,4
- and eax,000Fh
- mov [(sCompInfo ebx).wCode],ax
- jmp short ??calcDifferencel
- ??fetchTokenl:
- xor eax,eax
- mov al,[esi]
- mov [(sCompInfo ebx).wCodeBuf],ax
- add esi,2 ;2 for stereo
- and eax,000Fh
- mov [(sCompInfo ebx).wCode],ax
- ??calcDifferencel:
- ; reset difference
- mov [(sCompInfo ebx).dwDifference],0
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wStep]
- test eax,4 ;Check for wCode & 4
- je short ??no4l
- add [(sCompInfo ebx).dwDifference],ecx ;Add wStep
- ??no4l:
- test eax,2 ;Check for wCode & 2
- je short ??no2l
- mov edx,ecx ;Add wStep >> 1
- shr edx,1
- add [(sCompInfo ebx).dwDifference],edx
- ??no2l:
- test eax,1 ;Check for wCode & 1
- je short ??no1l
- mov edx,ecx ;Add wStep >> 2
- shr edx,2
- add [(sCompInfo ebx).dwDifference],edx
- ??no1l:
- mov edx,ecx ;Add in wStep >> 3
- shr edx,3
- add [(sCompInfo ebx).dwDifference],edx
- test eax,8 ;Check for wCode & 8
- je short ??no8l
- neg [(sCompInfo ebx).dwDifference] ;Negate diff
- ??no8l:
- ; add difference to predicted value.
- mov eax,[(sCompInfo ebx).dwPredicted]
- add eax,[(sCompInfo ebx).dwDifference]
- ; make sure there is no under or overflow.
- cmp eax,7FFFh
- jl short ??noOverflowl
- mov eax,7FFFh
- ??noOverflowl:
- cmp eax,0FFFF8000h
- jg short ??noUnderflowl
- mov eax,0FFFF8000h
- ??noUnderflowl:
- mov [(sCompInfo ebx).dwPredicted],eax
- cmp [(sCompInfo ebx).wBitSize],16
- jne short ??output8Bitl
- mov [edi],ax ;Output 16bit sample
- add edi,4 ;4 for stereo
- jmp short ??adjustIndexl
- ??output8Bitl:
- ; output 8 bit sample
- xor ah,80h
- mov [edi],ah
- add edi,2 ;2 for stereo
- ??adjustIndexl:
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wCode]
- xor eax,eax
- shl ecx,1
- mov ax,[wCODECIndexTab + ecx]
- add [(sCompInfo ebx).wIndex],ax
- ; check if wIndex < 0
- cmp [(sCompInfo ebx).wIndex],8000h
- jb short ??checkOverflowl
- mov [(sCompInfo ebx).wIndex],0
- jmp short ??adjustStepl ;reset index to zero
- ??checkOverflowl:
- cmp [(sCompInfo ebx).wIndex],88 ; check if wIndex > 88
- jbe short ??adjustStepl
- mov [(sCompInfo ebx).wIndex],88 ; reset index to 88
- ??adjustStepl:
- ; fetch wIndex so we can fetch new step value
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wIndex]
- xor eax,eax
- shl ecx,1
- mov ax,[wCODECStepTab + ecx]
- ; advance index and store step value
- add [(sCompInfo ebx).dwSampleIndex],1
- mov [(sCompInfo ebx).wStep],ax
- ; decrement bytes processed and loop back.
- sub [dwCODECByteIndex],2
- jne ??mainloopl
- ;----------------------------------------------------------------------------
- ; Right Side Setup
- ;----------------------------------------------------------------------------
- mov eax,[wBytes]
- mov [dwCODECBytesProcessed],eax
- mov esi,[(sCompInfo ebx).lpSource]
- mov edi,[(sCompInfo ebx).lpDest]
- inc esi ; skip left channel
- inc edi ; skip left channel
- cmp [(sCompInfo ebx).wBitSize],16 ;16 bit ??
- je short ??doByteDivide
- mov [dwCODECByteIndex],eax
- jmp short ??mainloopr
- ??doByteDivide:
- shr eax,1 ;Divide size by two
- inc edi ; 16 bit so skip 1 more
- mov [dwCODECByteIndex],eax
- ;--------------------------------------------------------------------------
- ;Right Channel Start
- ;--------------------------------------------------------------------------
- ??mainloopr:
- test [(sCompInfo ebx).dwSampleIndex2],1
- je short ??fetchTokenr
- xor eax,eax
- mov ax,[(sCompInfo ebx).wCodeBuf2]
- shr eax,4
- and eax,000Fh
- mov [(sCompInfo ebx).wCode2],ax
- jmp short ??calcDifferencer
- ??fetchTokenr:
- xor eax,eax
- mov al,[esi]
- mov [(sCompInfo ebx).wCodeBuf2],ax
- add esi,2 ;2 for stereo
- and eax,000Fh
- mov [(sCompInfo ebx).wCode2],ax
- ??calcDifferencer:
- ; reset difference
- mov [(sCompInfo ebx).dwDifference2],0
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wStep2]
- test eax,4 ;Check for wCode & 4
- je short ??no4r
- add [(sCompInfo ebx).dwDifference2],ecx ;Add wStep
- ??no4r:
- test eax,2 ;Check for wCode & 2
- je short ??no2r
- mov edx,ecx ;Add wStep >> 1
- shr edx,1
- add [(sCompInfo ebx).dwDifference2],edx
- ??no2r:
- test eax,1 ;Check for wCode & 1
- je short ??no1r
- mov edx,ecx ;Add wStep >> 2
- shr edx,2
- add [(sCompInfo ebx).dwDifference2],edx
- ??no1r:
- mov edx,ecx ;Add in wStep >> 3
- shr edx,3
- add [(sCompInfo ebx).dwDifference2],edx
- test eax,8 ;Check for wCode & 8
- je short ??no8r
- neg [(sCompInfo ebx).dwDifference2] ;Negate diff
- ??no8r:
- ; add difference to predicted value.
- mov eax,[(sCompInfo ebx).dwPredicted2]
- add eax,[(sCompInfo ebx).dwDifference2]
- cmp eax,7FFFh
- jl short ??noOverflowr
- mov eax,7FFFh
- ??noOverflowr:
- cmp eax,0FFFF8000h
- jg short ??noUnderflowr
- mov eax,0FFFF8000h
- ??noUnderflowr:
- mov [(sCompInfo ebx).dwPredicted2],eax
- cmp [(sCompInfo ebx).wBitSize],16
- jne short ??output8Bitr
- mov [edi],ax ;Output 16bit sample
- add edi,4 ;4 for stereo ***
- jmp short ??adjustIndexr
- ??output8Bitr:
- ; output 8 bit sample
- xor ah,80h
- mov [edi],ah
- add edi,2 ;2 for stereo
- ??adjustIndexr:
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wCode2]
- xor eax,eax
- shl ecx,1
- mov ax,[wCODECIndexTab + ecx]
- add [(sCompInfo ebx).wIndex2],ax
- ; check if wIndex < 0
- cmp [(sCompInfo ebx).wIndex2],8000h
- jb short ??checkOverflowr
- ; reset index to zero
- mov [(sCompInfo ebx).wIndex2],0
- jmp short ??adjustStepr
- ??checkOverflowr:
- ; check if wIndex > 88
- cmp [(sCompInfo ebx).wIndex2],88
- jbe short ??adjustStepr
- mov [(sCompInfo ebx).wIndex2],88 ; reset index to 88
- ??adjustStepr:
- ; fetch wIndex so we can fetch new step value
- xor ecx,ecx
- mov cx,[(sCompInfo ebx).wIndex2]
- xor eax,eax
- shl ecx,1
- mov ax,[wCODECStepTab + ecx]
- ; advance index and store step value
- add [(sCompInfo ebx).dwSampleIndex2],1
- mov [(sCompInfo ebx).wStep2],ax
- ; decrement bytes processed and loop back.
- sub [dwCODECByteIndex],2
- jne ??mainloopr
- ??exitout:
- ; don't think we need this but just in case i'll leave it here!!
- ; mov [(sCompInfo ebx).lpSource],esi
- ; mov [(sCompInfo ebx).lpDest],edi
- ; set up return value for number of bytes processed.
- mov eax,[dwCODECBytesProcessed]
- pop edx
- pop ecx
- pop ebx
- pop edi
- pop esi
- ret
- ENDP General_sosCODECDecompressData
- LABEL LockedCodeEnd BYTE
- ;***************************************************************************
- ;* sosCODEC_LOCK -- locks the JLB audio decompression code *
- ;* *
- ;* INPUT: none *
- ;* *
- ;* OUTPUT: BOOL true is lock sucessful, false otherwise *
- ;* *
- ;* PROTO: BOOL sosCODEC_Lock(void); *
- ;* *
- ;* HISTORY: *
- ;* 06/26/1995 PWG : Created. *
- ;*=========================================================================*
- GLOBAL C sosCODEC_Lock:NEAR
- PROC sosCODEC_Lock C NEAR USES ebx ecx edx esi edi
- ;
- ; Lock the code that is used by the sos decompression method.
- ;
- mov eax,0600h ; function number.
- mov ecx,OFFSET LockedCodeStart ; ecx must have start of memory.
- mov edi,OFFSET LockedCodeEnd ; edi will have size of region in bytes.
- shld ebx,ecx,16
- sub edi, ecx
- shld esi,edi,16
- int DPMI_INTR ; do call.
- jc ??error
- or [InitFlags], IF_LOCKED_PM_CODE
- ;
- ; Lock the data used by the sos decompression method.
- ;
- mov eax,0600h ; function number.
- mov ecx,OFFSET LockedDataStart ; ecx must have start of memory.
- mov edi,OFFSET LockedDataEnd ; edi will have size of region in bytes.
- shld ebx,ecx,16
- sub edi, ecx
- shld esi,edi,16
- int DPMI_INTR ; do call.
- jc ??error ; eax = 8 if mem err, eax = 9 if invalid mem region.
- or [InitFlags], IF_LOCKED_PM_DATA
- mov eax,1
- jmp ??exit
- ??error:
- xor eax,eax
- ??exit:
- ret
- ENDP sosCODEC_Lock
- ;***************************************************************************
- ;* DECOMPRESS_FRAME_UNLOCK -- Unlocks the JLB audio compression code *
- ;* *
- ;* INPUT: none *
- ;* *
- ;* OUTPUT: BOOL true is unlock sucessful, false otherwise *
- ;* *
- ;* PROTO: BOOL sosCODEC_Unlock(void); *
- ;* *
- ;* HISTORY: *
- ;* 06/26/1995 PWG : Created. *
- ;*=========================================================================*
- GLOBAL C sosCODEC_Unlock:NEAR
- PROC sosCODEC_Unlock C NEAR USES ebx ecx edx esi edi
- test [InitFlags],IF_LOCKED_PM_CODE
- jz ??code_not_locked
- mov eax , 0601h
- mov ecx,OFFSET LockedCodeStart ; ecx must have start of memory.
- mov edi,OFFSET LockedCodeEnd ; edx will have size of region in bytes.
- sub edi,ecx ; - figure size.
- shld ebx , ecx , 16
- shld esi , edi , 16
- int DPMI_INTR ; do call.
- jc ??error
- ??code_not_locked:
- test [InitFlags],IF_LOCKED_PM_DATA
- jz ??data_not_locked
- mov ax,0601h ; set es to descriptor of data.
- mov ecx,OFFSET LockedDataStart ; ecx must have start of memory.
- mov edi,OFFSET LockedDataEnd ; edx will have size of region in bytes.
- sub edi,ecx ; - figure size.
- shld ebx , ecx , 16
- shld esi , edi , 16
- int DPMI_INTR ; do call.
- jc ??error ; eax = 8 if mem err, eax = 9 if invalid mem region.
- ??data_not_locked:
- mov [InitFlags],0
- mov eax,1
- jmp ??exit
- ??error:
- xor eax,eax
- ??exit:
- ret
- ENDP sosCODEC_Unlock
- END
|