Initial commit
This commit is contained in:
332
LIB386/LIB_SYS/ADELINE.C
Normal file
332
LIB386/LIB_SYS/ADELINE.C
Normal file
@@ -0,0 +1,332 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <process.h>
|
||||
|
||||
#include "f:\projet\lib386\lib_sys\adeline.h"
|
||||
#include "f:\projet\lib386\lib_sys\lib_sys.h"
|
||||
|
||||
#include "f:\projet\lib386\lib_midi\lib_midi.h"
|
||||
#include "f:\projet\lib386\lib_samp\lib_wave.h"
|
||||
#include "f:\projet\lib386\lib_mix\lib_mix.h"
|
||||
#include "f:\projet\lib386\lib_svga\lib_svga.h"
|
||||
|
||||
|
||||
char Driver[_MAX_PATH] ;
|
||||
|
||||
// timer proc for ail_lib
|
||||
|
||||
HTIMER HandleTimer ;
|
||||
|
||||
void NewProc08() ; // dans timer.asm
|
||||
|
||||
extern UBYTE VESA_Error ;
|
||||
|
||||
char PathConfigFile[_MAX_PATH] ;
|
||||
|
||||
char *Adeline="ADELINE" ;
|
||||
|
||||
char MidiFM = 1 ;
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
Ûßßßß ÛßßßÛ ÛÛÜ Û Ûßßßß Û Ûßßßß
|
||||
ÛÛ ÛÛ Û ÛÛßÛÛ ÛÛßß ÛÛ ÛÛ ßÛ
|
||||
ßßßßß ßßßßß ßß ß ßß ßß ßßßßß
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
WORD GiveIndexTab( UBYTE **tab, UBYTE *identificateur )
|
||||
{
|
||||
UBYTE **ptr ;
|
||||
WORD i = 0 ;
|
||||
|
||||
while( *tab[0] != 0 )
|
||||
{
|
||||
if( !stricmp( *tab, identificateur ) )
|
||||
{
|
||||
return i ;
|
||||
}
|
||||
tab++ ;
|
||||
i++ ;
|
||||
}
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
void InitAdelineSystem( char *name, LONG inits )
|
||||
{
|
||||
char **ptridentifier ;
|
||||
LONG *ptrvar ;
|
||||
char *ptr, *midiptr=NULL ;
|
||||
char *defname ;
|
||||
char *rien="" ;
|
||||
|
||||
printf( "\nCopyright (c) Adeline Software International 1994, All Rights Reserved.\n\n" );
|
||||
|
||||
*PathConfigFile = 0 ;
|
||||
|
||||
if (!inits) return ;
|
||||
|
||||
if (inits & INIT_VESA)
|
||||
inits |= INIT_SVGA ;
|
||||
|
||||
defname = getenv(Adeline) ;
|
||||
|
||||
if ((inits & ~(INIT_MCGA | INIT_VESA | INIT_SVGA)) OR (inits == INIT_SVGA))
|
||||
{
|
||||
if(!*name)
|
||||
{
|
||||
printf("Error: Empty configuration filename. Go kill the programmer! (Tell him to talk to Serge as well...)\n\n");
|
||||
exit(1);
|
||||
}
|
||||
if(!FileSize( defname ))
|
||||
{
|
||||
if (defname)
|
||||
{
|
||||
printf( "Warning: Cannot find configuration file %s as defined in the environment.\n", defname) ;
|
||||
printf( " Using local configuration file %s.\n\n", name ) ;
|
||||
}
|
||||
if(!FileSize( name ))
|
||||
{
|
||||
printf( "Error: Cannot find configuration file %s.\n\n", name ) ;
|
||||
exit( 1 ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
name = defname ;
|
||||
|
||||
printf("Please wait, loading drivers using %s...\n\n", name );
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FileSize( defname ))
|
||||
name = defname ;
|
||||
}
|
||||
|
||||
strcpy(PathConfigFile, name);
|
||||
|
||||
//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú
|
||||
// midi device
|
||||
|
||||
|
||||
if(inits & INIT_MIDI)
|
||||
{
|
||||
printf("Initialising Midi device. Please wait...\n\n");
|
||||
|
||||
midiptr = Def_ReadString( name, "MidiExec" ) ;
|
||||
if( midiptr )
|
||||
if ((*midiptr!=0) AND stricmp(midiptr, "NoExec"))
|
||||
{
|
||||
spawnl(P_WAIT, midiptr, midiptr, NULL);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
ptr = Def_ReadString( name, "MidiDriver" ) ;
|
||||
if( !ptr )
|
||||
{
|
||||
printf( "Warning %s: 'MidiDriver' missing\n", name ) ;
|
||||
ptr = rien ;
|
||||
}
|
||||
|
||||
if (stricmp(ptr, "NoMidi"))
|
||||
strcpy( Driver, ptr ) ;
|
||||
else
|
||||
Driver[0]=0 ;
|
||||
|
||||
if( Driver[0] != 0 ) /* si driver midi */
|
||||
{
|
||||
|
||||
if( !InitMidiDLL( Driver ) ) exit( 1 ) ;
|
||||
|
||||
AskMidiVars( &ptridentifier, &ptrvar ) ;
|
||||
|
||||
while( **ptridentifier )
|
||||
{
|
||||
if (!Def_ReadValue2( name, *ptridentifier, ptrvar++ ))
|
||||
{
|
||||
printf( "Error %s: '%s' missing\n", name, *ptridentifier ) ;
|
||||
exit( 1 ) ;
|
||||
}
|
||||
|
||||
ptridentifier++ ;
|
||||
}
|
||||
|
||||
if( !InitMidi() ) exit( 1 ) ;
|
||||
}
|
||||
|
||||
ptr = Def_ReadString( name, "MidiType" ) ;
|
||||
if( !ptr )
|
||||
{
|
||||
printf( "Warning %s: 'MidiType' missing\n", name ) ;
|
||||
ptr = rien ;
|
||||
}
|
||||
|
||||
if (*ptr) MidiFM = !stricmp(ptr, "FM") ;
|
||||
}
|
||||
|
||||
//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú
|
||||
// svga device
|
||||
|
||||
if(inits & INIT_SVGA)
|
||||
{
|
||||
printf("Initialising SVGA device. Please wait...\n\n");
|
||||
|
||||
if(!(inits & INIT_VESA))
|
||||
{
|
||||
ptr = Def_ReadString( name, "SvgaDriver" ) ;
|
||||
if( !ptr )
|
||||
{
|
||||
printf( "Warning %s: 'SvgaDriver' missing\n", name ) ;
|
||||
ptr = rien ;
|
||||
}
|
||||
|
||||
if ((stricmp( ptr, "VESA" )) AND (*ptr) )
|
||||
{
|
||||
strcpy( Driver, ptr ) ;
|
||||
if( !SvgaInitDLL( Driver ) ) exit( 1 ) ;
|
||||
}
|
||||
else
|
||||
printf( "Built-in VESA Super VGA Driver\n\n" ) ;
|
||||
|
||||
}
|
||||
}
|
||||
else if (inits & INIT_MCGA)
|
||||
printf( "Built-in MCGA Driver\n\n" ) ;
|
||||
|
||||
//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú
|
||||
// mixer device
|
||||
|
||||
if(inits & INIT_MIXER)
|
||||
{
|
||||
printf("Initialising Mixer device. Please wait...\n\n");
|
||||
|
||||
ptr = Def_ReadString( name, "MixerDriver" ) ;
|
||||
if( !ptr )
|
||||
{
|
||||
printf( "Warning %s: 'MixerDriver' missing\n", name ) ;
|
||||
ptr = rien ;
|
||||
}
|
||||
|
||||
if (stricmp(ptr, "NoMixer"))
|
||||
strcpy( Driver, ptr ) ;
|
||||
else
|
||||
Driver[0]=0 ;
|
||||
|
||||
if( Driver[0] != 0 ) /* si driver wave */
|
||||
{
|
||||
|
||||
if( !MixerInitDLL( Driver ) ) exit( 1 ) ;
|
||||
|
||||
MixerAskVars( &ptridentifier, &ptrvar ) ;
|
||||
|
||||
while( **ptridentifier )
|
||||
{
|
||||
if (!Def_ReadValue2( name, *ptridentifier, ptrvar++ ))
|
||||
{
|
||||
printf( "Error %s: '%s' missing\n", name, *ptridentifier ) ;
|
||||
exit( 1 ) ;
|
||||
}
|
||||
ptridentifier++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú
|
||||
// wave device
|
||||
|
||||
if(inits & INIT_WAVE)
|
||||
{
|
||||
printf("Initialising Wave device. Please wait...\n\n");
|
||||
|
||||
ptr = Def_ReadString( name, "WaveExec" ) ;
|
||||
if( ptr )
|
||||
if ((*ptr!=0) AND stricmp(ptr, "NoExec") AND stricmp(ptr, midiptr))
|
||||
{
|
||||
spawnl(P_WAIT, ptr, ptr, NULL);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
ptr = Def_ReadString( name, "WaveDriver" ) ;
|
||||
if( !ptr )
|
||||
{
|
||||
printf( "Warning %s: 'WaveDriver' missing\n", name ) ;
|
||||
ptr = rien ;
|
||||
}
|
||||
|
||||
if (stricmp(ptr, "NoWave"))
|
||||
strcpy( Driver, ptr ) ;
|
||||
else
|
||||
Driver[0]=0 ;
|
||||
|
||||
if( Driver[0] != 0 ) /* si driver wave */
|
||||
{
|
||||
|
||||
if( !WaveInitDLL( Driver ) ) exit( 1 ) ;
|
||||
|
||||
WaveAskVars( &ptridentifier, &ptrvar ) ;
|
||||
|
||||
while( **ptridentifier )
|
||||
{
|
||||
if (!Def_ReadValue2( name, *ptridentifier, ptrvar++ ))
|
||||
{
|
||||
printf( "Error %s: '%s' missing\n", name, *ptridentifier ) ;
|
||||
exit( 1 ) ;
|
||||
}
|
||||
ptridentifier++;
|
||||
}
|
||||
|
||||
if( !InitWave() ) exit( 1 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú
|
||||
// system etc
|
||||
|
||||
InitSystem() ;
|
||||
if (inits & INIT_SVGA)
|
||||
InitGraphSvga() ;
|
||||
else if (inits & INIT_MCGA)
|
||||
InitGraphMcga() ;
|
||||
|
||||
if (VESA_Error)
|
||||
{
|
||||
printf( "Error: SVGA card BIOS does not support VESA extensions.\n") ;
|
||||
printf( " Please refer to your SVGA card documentation for installing VESA driver.\n") ;
|
||||
exit( 1 ) ;
|
||||
}
|
||||
|
||||
InitKeyboard() ;
|
||||
|
||||
//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú
|
||||
// init Timer (TimerRef et NbF) selon midi install‚e ou non
|
||||
|
||||
if( Midi_Driver_Enable )
|
||||
{
|
||||
HandleTimer = AIL_register_timer( NewProc08 ) ;
|
||||
AIL_set_timer_frequency( HandleTimer, 50 ) ;
|
||||
AIL_start_timer( HandleTimer ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitTimer() ;
|
||||
}
|
||||
|
||||
// InitSample() ;
|
||||
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
void ClearAdelineSystem()
|
||||
{
|
||||
// ClearSample() ;
|
||||
|
||||
if( !Midi_Driver_Enable ) ClearTimer() ;
|
||||
ClearKeyboard() ;
|
||||
ClearGraphSvga() ;
|
||||
ClearSystem() ;
|
||||
ClearWave();
|
||||
ClearMidi();
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
51
LIB386/LIB_SYS/ADELINE.H
Normal file
51
LIB386/LIB_SYS/ADELINE.H
Normal file
@@ -0,0 +1,51 @@
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
ÛßßßÛ ÛßßßÜ Ûßßßß Û Û ÛÛÜ Û Ûßßßß
|
||||
ÛÛßßÛ ÛÛ Û ÛÛßß ÛÛ ÛÛ ÛÛßÛÛ ÛÛßß
|
||||
ßß ß ßßßß ßßßßß ßßßßß ßß ßß ß ßßßßß 386
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
#define ULONG unsigned long int
|
||||
#define LONG signed long int
|
||||
#define UWORD unsigned short int
|
||||
#define WORD signed short int
|
||||
#define UBYTE unsigned char
|
||||
#define BYTE signed char
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
#define AND &&
|
||||
#define OR ||
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
95
LIB386/LIB_SYS/BUFFER_A.ASM
Normal file
95
LIB386/LIB_SYS/BUFFER_A.ASM
Normal file
@@ -0,0 +1,95 @@
|
||||
;----------------------------------------------------------------------------
|
||||
;' BUFFER_A.ASM 386
|
||||
;' (c) Adeline 1993
|
||||
;----------------------------------------------------------------------------
|
||||
.386p
|
||||
|
||||
.model SMALL, SYSCALL
|
||||
|
||||
.data
|
||||
|
||||
.code
|
||||
|
||||
public NoLanguage MovMem
|
||||
public NoLanguage RazMem
|
||||
public NoLanguage CompBuf
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
MovMem proc uses esi edi,\
|
||||
pts:DWORD, ptd:DWORD, nb:DWORD
|
||||
|
||||
mov esi, pts
|
||||
mov edi, ptd
|
||||
mov eax, nb
|
||||
|
||||
mov ecx, eax
|
||||
shr ecx, 2
|
||||
rep movsd
|
||||
mov ecx, eax
|
||||
and ecx, 3
|
||||
rep movsb
|
||||
ret
|
||||
MovMem endp
|
||||
;----------------------------------------------------------------------------
|
||||
RazMem proc uses edi,\
|
||||
buffer:DWORD, longueur:DWORD
|
||||
|
||||
mov edi, buffer
|
||||
mov ecx, longueur
|
||||
mov edx, ecx
|
||||
shr ecx, 2
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
mov ecx, edx
|
||||
and ecx, 11b
|
||||
rep stosb
|
||||
ret
|
||||
RazMem endp
|
||||
;----------------------------------------------------------------------------
|
||||
CompBuf proc uses esi edi,\
|
||||
pt0:DWORD, pt1:DWORD, nb0:DWORD
|
||||
|
||||
mov esi, pt0
|
||||
mov edi, pt1
|
||||
mov eax, nb0
|
||||
|
||||
mov ecx, eax
|
||||
shr ecx, 2
|
||||
rep cmpsd
|
||||
jne NoGood
|
||||
|
||||
mov ecx, eax
|
||||
and ecx, 3
|
||||
rep cmpsb
|
||||
jne NoGood
|
||||
|
||||
mov eax, 1
|
||||
ret
|
||||
NoGood:
|
||||
xor eax, eax
|
||||
ret
|
||||
CompBuf endp
|
||||
;----------------------------------------------------------------------------
|
||||
; The
|
||||
End
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
13
LIB386/LIB_SYS/BUILD.BAT
Normal file
13
LIB386/LIB_SYS/BUILD.BAT
Normal file
@@ -0,0 +1,13 @@
|
||||
call watcom10
|
||||
|
||||
pkunzip -o obj >NUL
|
||||
wmake
|
||||
pkzip -m obj *.obj >NUL
|
||||
|
||||
call watcom9
|
||||
|
||||
pkunzip -o obj9 >NUL
|
||||
wmake WATCOM9=yes
|
||||
pkzip -m obj9 *.obj >NUL
|
||||
|
||||
call watcom10
|
||||
113
LIB386/LIB_SYS/DEFINES.H
Normal file
113
LIB386/LIB_SYS/DEFINES.H
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "\projet\lib386\lib_sys\adeline.h"
|
||||
#include "\projet\lib386\lib_sys\lib_sys.h"
|
||||
#include "\projet\lib386\lib_svga\lib_svga.h"
|
||||
#include "\projet\lib386\lib_3D\lib_3D.h"
|
||||
#include "\projet\lib386\lib_menu\lib_menu.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
ÛßßßÜ Ûßßßß Ûßßßß Û ÛÛÜ Û Ûßßßß ÛÛßßß
|
||||
ÛÛ Û ÛÛßß ÛÛßß ÛÛ ÛÛßÛÛ ÛÛßß ßßßßÛ
|
||||
ßßßß ßßßßß ßß ßß ßß ß ßßßßß ßßßßß
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
|
||||
#define SIZE_BRICK_XZ 512
|
||||
#define SIZE_BRICK_Y 256
|
||||
#define DEMI_BRICK_XZ 256
|
||||
#define DEMI_BRICK_Y 128
|
||||
|
||||
|
||||
/*---------------- OBJECTS ------------------*/
|
||||
|
||||
#define MAX_OBJETS 10
|
||||
|
||||
#define SIZE_PERSO_NAME 32
|
||||
|
||||
#define MAX_ANIMS 100
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* life tool */
|
||||
|
||||
UBYTE Name[SIZE_PERSO_NAME+1] ;
|
||||
UBYTE File3D[_MAX_PATH] ;
|
||||
|
||||
/* game infos */
|
||||
|
||||
WORD *PtrObj ;
|
||||
|
||||
WORD PosObjX ;
|
||||
WORD PosObjY ;
|
||||
WORD PosObjZ ;
|
||||
|
||||
WORD Alpha ;
|
||||
WORD Beta ;
|
||||
WORD Gamma ;
|
||||
|
||||
WORD Move ;
|
||||
UBYTE Col;
|
||||
UBYTE dummy ;
|
||||
|
||||
WORD AnimMasterRot ;
|
||||
WORD AnimStepBeta ;
|
||||
|
||||
WORD AnimStepX ;
|
||||
WORD AnimStepY ;
|
||||
WORD AnimStepZ ;
|
||||
|
||||
WORD StartAnim ;
|
||||
WORD Anim ;
|
||||
WORD Frame ;
|
||||
WORD FlagAnim ;
|
||||
WORD NextAnim ;
|
||||
} T_OBJET ;
|
||||
typedef struct
|
||||
{
|
||||
WORD Z ;
|
||||
WORD NumObj ; } T_SORT ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD NumObj ;
|
||||
WORD x0 ;
|
||||
WORD y0 ;
|
||||
WORD x1 ;
|
||||
WORD y1 ; } T_OBJ_SELECT ;
|
||||
|
||||
/*---------------- divers ------------------*/
|
||||
|
||||
#define Rnd(n) (rand()%n)
|
||||
|
||||
#define NUM_PERSO 0
|
||||
|
||||
#define ISO 1
|
||||
#define PCX 2
|
||||
|
||||
/*---------------- FlagInfos ------------------*/
|
||||
|
||||
#define INFO_SCREEN_BOX 1
|
||||
#define INFO_DRAW_ZV 2
|
||||
#define INFO_COOR 4
|
||||
#define INFO_FRAME_SPEED 8
|
||||
|
||||
/*---------------- InitAnim ------------------*/
|
||||
|
||||
#define ANIM_REPEAT 0
|
||||
#define ANIM_THEN 1
|
||||
#define ANIM_ALL_THEN 2
|
||||
|
||||
/*---------------- Script: defines ------------------*/
|
||||
|
||||
#define NO_MOVE 0
|
||||
#define MOVE_MANUAL 1
|
||||
#define MOVE_FOLLOW 2
|
||||
#define MOVE_GOTO 3
|
||||
|
||||
/*---------------- The End: error ------------------*/
|
||||
|
||||
#define FILE_NOT_FOUND 0
|
||||
#define NOT_ENOUGH_MEM 1
|
||||
#define PROGRAM_OK 2
|
||||
639
LIB386/LIB_SYS/DEF_FILE.C
Normal file
639
LIB386/LIB_SYS/DEF_FILE.C
Normal file
@@ -0,0 +1,639 @@
|
||||
/*
|
||||
DEF_FILE (c) Adeline 1993
|
||||
|
||||
*/
|
||||
|
||||
#include "\projet\lib386\lib_sys\adeline.h"
|
||||
#include "\projet\lib386\lib_sys\lib_sys.h"
|
||||
|
||||
#include <i86.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
ÛßßßÜ Ûßßßß Ûßßßß Ûßßßß Û Û Ûßßßß
|
||||
ÛÛ Û ÛÛßß ÛÛßß ÛÛßß ÛÛ ÛÛ ÛÛßß
|
||||
ßßßß ßßßßß ßß ßßßßß ßß ßß ßßßßß ßßßßß
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
UBYTE DefString[256] ;
|
||||
UBYTE DefValue[50] ;
|
||||
LONG DefHandle ;
|
||||
//LONG DefHandleC ;
|
||||
//LONG DefModeCopy = FALSE ;
|
||||
UBYTE *PtrDef ;
|
||||
UBYTE *OrgPtrDef ;
|
||||
UBYTE *EndPtrDef ;
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
#ifdef OCAZOU
|
||||
void NextLine()
|
||||
{
|
||||
UBYTE c ;
|
||||
|
||||
do /* saute cr/lf espace */
|
||||
{
|
||||
if( Read( DefHandle, &c, 1L ) == 0L ) return ;
|
||||
|
||||
if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ;
|
||||
}
|
||||
while( c >= 32 ) ;
|
||||
}
|
||||
#endif
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*
|
||||
LONG ReadWord()
|
||||
{
|
||||
UBYTE *ptr ;
|
||||
UBYTE c ;
|
||||
|
||||
ptr = DefString ;
|
||||
|
||||
do // saute cr/lf espace
|
||||
{
|
||||
if( Read( DefHandle, &c, 1L ) == 0L ) return FALSE ;
|
||||
|
||||
if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ;
|
||||
}
|
||||
while( c <= 32 ) ;
|
||||
|
||||
do // lit mot
|
||||
{
|
||||
*ptr++ = c ;
|
||||
if( Read( DefHandle, &c, 1L ) == 0L ) c = 26 ;
|
||||
else
|
||||
if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ;
|
||||
}
|
||||
while( c > 32 ) ;
|
||||
|
||||
*ptr++ = 0 ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
*/
|
||||
|
||||
LONG PtrDefReadWord()
|
||||
{
|
||||
UBYTE *ptr ;
|
||||
UBYTE c ;
|
||||
|
||||
ptr = DefString ;
|
||||
|
||||
do /* saute cr/lf espace */
|
||||
{
|
||||
c = *PtrDef++ ;
|
||||
if( PtrDef >= EndPtrDef ) return FALSE ;
|
||||
}
|
||||
while( c <= 32 ) ;
|
||||
|
||||
do /* lit mot */
|
||||
{
|
||||
*ptr++ = c ;
|
||||
c = *PtrDef++ ;
|
||||
if( PtrDef >= EndPtrDef ) c = 26 ;
|
||||
}
|
||||
while( c > 32 ) ;
|
||||
|
||||
*ptr++ = 0 ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
LONG PtrDefReadIdent()
|
||||
{
|
||||
UBYTE *ptr ;
|
||||
UBYTE c ;
|
||||
|
||||
ptr = DefString ;
|
||||
|
||||
do /* saute cr/lf espace */
|
||||
{
|
||||
c = *PtrDef++ ;
|
||||
if( PtrDef >= EndPtrDef ) return FALSE ;
|
||||
}
|
||||
while( c <= 32 ) ;
|
||||
|
||||
do /* lit mot */
|
||||
{
|
||||
*ptr++ = c ;
|
||||
c = *PtrDef++ ;
|
||||
if( PtrDef >= EndPtrDef ) c = 26 ;
|
||||
}
|
||||
while( (c >= 32) AND (c != ':') ) ;
|
||||
|
||||
while ( *--ptr == 32 ) ;
|
||||
|
||||
*(ptr+1) = 0 ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
/*
|
||||
LONG ReadString()
|
||||
{
|
||||
UBYTE *ptr ;
|
||||
UBYTE c ;
|
||||
|
||||
ptr = DefString ;
|
||||
|
||||
do // saute cr/lf espace
|
||||
{
|
||||
if( Read( DefHandle, &c, 1L ) == 0L ) return FALSE ;
|
||||
}
|
||||
while( c <= 32 ) ;
|
||||
|
||||
do // lit phrase jusqu'a CR/LF
|
||||
{
|
||||
*ptr++ = c ;
|
||||
if( Read( DefHandle, &c, 1L ) == 0L ) c = 13 ;
|
||||
}
|
||||
while( c != 13 ) ;
|
||||
Read( DefHandle, &c, 1L ) ; // lit LF ou rien si fin
|
||||
|
||||
*ptr++ = 0 ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
*/
|
||||
void PtrDefReadString()
|
||||
{
|
||||
UBYTE *ptr ;
|
||||
UBYTE c ;
|
||||
|
||||
ptr = DefString ;
|
||||
|
||||
*ptr = 0 ;
|
||||
|
||||
do // saute espace / tab
|
||||
{
|
||||
c = *PtrDef++ ;
|
||||
if(( PtrDef >= EndPtrDef ) OR
|
||||
( c == 13 ) OR
|
||||
( c == 10 ) )
|
||||
return;
|
||||
}
|
||||
while( c <= 32 ) ;
|
||||
|
||||
do /* lit phrase jusqu'a CR/LF */
|
||||
{
|
||||
*ptr++ = c ;
|
||||
c = *PtrDef++ ;
|
||||
if( PtrDef >= EndPtrDef ) c = 13 ;
|
||||
}
|
||||
while( c >= 32 ) ;
|
||||
|
||||
while ( *--ptr == 32 ) ;
|
||||
|
||||
// PtrDef++ ; /* lit LF ou rien si fin */
|
||||
|
||||
*(ptr+1) = 0 ;
|
||||
}
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*
|
||||
LONG ReadThisString()
|
||||
{
|
||||
UBYTE *ptr ;
|
||||
UBYTE c ;
|
||||
|
||||
ptr = DefString ;
|
||||
|
||||
do // saute espace
|
||||
{
|
||||
if( Read( DefHandle, &c, 1L ) == 0L )
|
||||
{
|
||||
*ptr = 0 ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
while( c == 32 ) ;
|
||||
|
||||
if( c > 31 )
|
||||
{
|
||||
do // lit phrase jusqu'a CR/LF
|
||||
{
|
||||
*ptr++ = c ;
|
||||
if( Read( DefHandle, &c, 1L ) == 0L ) c = 13 ;
|
||||
}
|
||||
while( c != 13 ) ;
|
||||
}
|
||||
Read( DefHandle, &c, 1L ) ; // lit LF ou rien si fin
|
||||
|
||||
*ptr++ = 0 ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
*/
|
||||
|
||||
LONG PtrDefReadThisString()
|
||||
{
|
||||
UBYTE *ptr ;
|
||||
UBYTE c ;
|
||||
|
||||
ptr = DefString ;
|
||||
|
||||
do // saute espace
|
||||
{
|
||||
c = *PtrDef++ ;
|
||||
if( PtrDef >= EndPtrDef ) return FALSE ;
|
||||
}
|
||||
while( c == 32 ) ;
|
||||
|
||||
if( c>31 ) // on a pu lire un cr
|
||||
{
|
||||
do // lit phrase jusqu'a CR/LF
|
||||
{
|
||||
*ptr++ = c ;
|
||||
c = *PtrDef++ ;
|
||||
if( PtrDef >= EndPtrDef ) c = 13 ;
|
||||
}
|
||||
while( c != 13 ) ;
|
||||
}
|
||||
|
||||
PtrDef++ ; // lit LF ou rien si fin
|
||||
|
||||
*ptr++ = 0 ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*
|
||||
LONG SearchIdentificator( UBYTE *identificateur )
|
||||
{
|
||||
while( ReadWord() )
|
||||
{
|
||||
if( DefString[strlen(DefString)-1] == ':' )
|
||||
{
|
||||
DefString[strlen(DefString)-1] = 0 ;
|
||||
if( !strnicmp( identificateur,
|
||||
DefString,
|
||||
strlen( identificateur ) ) )
|
||||
{
|
||||
return TRUE ; // identificateur trouve
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
*/
|
||||
|
||||
LONG PtrDefSearchIdentificator( UBYTE *identificateur )
|
||||
{
|
||||
while( PtrDefReadIdent() )
|
||||
{
|
||||
/* if( DefString[strlen(DefString)-1] == ':' )
|
||||
{
|
||||
DefString[strlen(DefString)-1] = 0 ;
|
||||
*/
|
||||
if( !stricmp( identificateur, DefString ) )
|
||||
{
|
||||
return TRUE ; // identificateur trouve
|
||||
}
|
||||
// }
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
/*
|
||||
UBYTE *Def_ReadString( UBYTE *deffic, UBYTE *identificateur )
|
||||
{
|
||||
DefHandle = OpenRead( deffic ) ;
|
||||
if( !DefHandle ) return 0L ;
|
||||
|
||||
if( SearchIdentificator( identificateur ) )
|
||||
{
|
||||
if( ReadThisString() )
|
||||
{
|
||||
Close( DefHandle ) ;
|
||||
return DefString ;
|
||||
}
|
||||
}
|
||||
Close( DefHandle ) ;
|
||||
return 0L ;
|
||||
}
|
||||
*/
|
||||
|
||||
UBYTE *Def_ReadString( UBYTE *deffic, UBYTE *identificateur )
|
||||
{
|
||||
OrgPtrDef = PtrDef = LoadMalloc( deffic ) ;
|
||||
if( !PtrDef ) return 0 ;
|
||||
EndPtrDef = PtrDef + LoadMallocFileSize ;
|
||||
|
||||
if( PtrDefSearchIdentificator( identificateur ) )
|
||||
{
|
||||
PtrDefReadString() ;
|
||||
Free( OrgPtrDef ) ;
|
||||
return DefString ;
|
||||
}
|
||||
Free( OrgPtrDef ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*
|
||||
LONG Def_ReadValue( UBYTE *deffic, UBYTE *identificateur )
|
||||
{
|
||||
LONG i ;
|
||||
LONG handle ;
|
||||
LONG value ;
|
||||
UBYTE c ;
|
||||
|
||||
DefHandle = OpenRead( deffic ) ;
|
||||
if( !DefHandle ) return -1L ;
|
||||
|
||||
if( SearchIdentificator( identificateur ) )
|
||||
{
|
||||
if( ReadWord() )
|
||||
{
|
||||
Close( DefHandle ) ;
|
||||
|
||||
c =DefString[strlen(DefString)-1]&~32 ;
|
||||
if( c == 'H' )
|
||||
{
|
||||
// hexa
|
||||
value = 0 ;
|
||||
for( i=0; i<strlen(DefString)-1; i++ )
|
||||
{
|
||||
c = DefString[i] ;
|
||||
if( c <= '9' ) c -= '0' ;
|
||||
else c = (c&~32) - 'A' + 10 ;
|
||||
value = value*16 + c ;
|
||||
}
|
||||
return value ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// deci
|
||||
return atoi( DefString ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
Close( DefHandle ) ;
|
||||
return -1L ;
|
||||
}
|
||||
*/
|
||||
|
||||
LONG Def_ReadValue( UBYTE *deffic, UBYTE *identificateur )
|
||||
{
|
||||
LONG i ;
|
||||
LONG value ;
|
||||
UBYTE c ;
|
||||
|
||||
OrgPtrDef = PtrDef = LoadMalloc( deffic ) ;
|
||||
if( !PtrDef ) return -1 ;
|
||||
EndPtrDef = PtrDef + LoadMallocFileSize ;
|
||||
|
||||
if( PtrDefSearchIdentificator( identificateur ) )
|
||||
{
|
||||
if( PtrDefReadWord() )
|
||||
{
|
||||
Free( OrgPtrDef ) ;
|
||||
c =DefString[strlen(DefString)-1]&~32 ;
|
||||
if( c == 'H' )
|
||||
{
|
||||
// hexa
|
||||
value = 0 ;
|
||||
for( i=0; i<strlen(DefString)-1; i++ )
|
||||
{
|
||||
c = DefString[i] ;
|
||||
if( c <= '9' ) c -= '0' ;
|
||||
else c = (c&~32) - 'A' + 10 ;
|
||||
value = value*16 + c ;
|
||||
}
|
||||
return value ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// deci
|
||||
return atoi( DefString ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
Free( OrgPtrDef ) ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*
|
||||
LONG Def_ReadValue2( UBYTE *deffic, UBYTE *identificateur, LONG *result )
|
||||
{
|
||||
LONG i ;
|
||||
LONG handle ;
|
||||
LONG value ;
|
||||
UBYTE c ;
|
||||
|
||||
DefHandle = OpenRead( deffic ) ;
|
||||
if( !DefHandle ) return FALSE ;
|
||||
|
||||
if( SearchIdentificator( identificateur ) )
|
||||
{
|
||||
if( ReadWord() )
|
||||
{
|
||||
Close( DefHandle ) ;
|
||||
|
||||
c =DefString[strlen(DefString)-1]&~32 ;
|
||||
if( c == 'H' )
|
||||
{
|
||||
// hexa
|
||||
value = 0 ;
|
||||
for( i=0; i<strlen(DefString)-1; i++ )
|
||||
{
|
||||
c = DefString[i] ;
|
||||
if( c <= '9' ) c -= '0' ;
|
||||
else c = (c&~32) - 'A' + 10 ;
|
||||
value = value*16 + c ;
|
||||
}
|
||||
*result = value;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// deci
|
||||
*result = atoi( DefString ) ;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Close( DefHandle ) ;
|
||||
return FALSE;
|
||||
}
|
||||
*/
|
||||
|
||||
LONG Def_ReadValue2( UBYTE *deffic, UBYTE *identificateur, LONG *result )
|
||||
{
|
||||
LONG i ;
|
||||
LONG value ;
|
||||
UBYTE c ;
|
||||
|
||||
OrgPtrDef = PtrDef = LoadMalloc( deffic ) ;
|
||||
if( !PtrDef ) return FALSE ;
|
||||
EndPtrDef = PtrDef + LoadMallocFileSize ;
|
||||
|
||||
if( PtrDefSearchIdentificator( identificateur ) )
|
||||
{
|
||||
if( PtrDefReadWord() )
|
||||
{
|
||||
Free( OrgPtrDef ) ;
|
||||
|
||||
c =DefString[strlen(DefString)-1]&~32 ;
|
||||
if( c == 'H' )
|
||||
{
|
||||
// hexa
|
||||
value = 0 ;
|
||||
for( i=0; i<strlen(DefString)-1; i++ )
|
||||
{
|
||||
c = DefString[i] ;
|
||||
if( c <= '9' ) c -= '0' ;
|
||||
else c = (c&~32) - 'A' + 10 ;
|
||||
value = value*16 + c ;
|
||||
}
|
||||
*result = value;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// deci
|
||||
*result = atoi( DefString ) ;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Free( OrgPtrDef ) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
/*
|
||||
LONG Def_WriteString( UBYTE *deffic, UBYTE *identificateur, UBYTE *string )
|
||||
{
|
||||
UBYTE crlf[] = { 13, 10, 0 } ;
|
||||
|
||||
DefHandleC = OpenWrite( "c:\\__tempo.def" ) ;
|
||||
if( !DefHandleC ) return FALSE ;
|
||||
DefHandle = OpenRead( deffic ) ;
|
||||
if( DefHandle )
|
||||
{
|
||||
DefModeCopy = TRUE ;
|
||||
if( SearchIdentificator( identificateur ) ) // copie jusqu'a identificateur
|
||||
{
|
||||
ReadString() ; // saute string
|
||||
// ReadThisString() ; // saute string
|
||||
|
||||
Write( DefHandleC, string, strlen( string ) ) ;
|
||||
Write( DefHandleC, crlf, 2L ) ;
|
||||
|
||||
while( ReadWord() ) ; // copie le reste
|
||||
|
||||
DefModeCopy = FALSE ;
|
||||
Close( DefHandle ) ;
|
||||
Close( DefHandleC ) ;
|
||||
|
||||
// Delete( deffic ) ;
|
||||
// rename( "c:\\__tempo.def", deffic ) ;
|
||||
if( Copy( "c:\\__tempo.def", deffic ) )
|
||||
{
|
||||
Delete( "c:\\__tempo.def" ) ;
|
||||
}
|
||||
|
||||
DefModeCopy = FALSE ;
|
||||
return TRUE ;
|
||||
}
|
||||
Close( DefHandle ) ;
|
||||
}
|
||||
// creation ou ident pas trouve ecrit tout
|
||||
Write( DefHandleC, identificateur, strlen(identificateur) ) ;
|
||||
Write( DefHandleC, ": ", 2L ) ;
|
||||
Write( DefHandleC, string, strlen( string ) ) ;
|
||||
Write( DefHandleC, crlf, 2L ) ;
|
||||
|
||||
Close( DefHandleC ) ;
|
||||
|
||||
// Delete( deffic ) ;
|
||||
if( Copy( "c:\\__tempo.def", deffic ) )
|
||||
{
|
||||
Delete( "c:\\__tempo.def" ) ;
|
||||
}
|
||||
|
||||
DefModeCopy = FALSE ;
|
||||
return TRUE ;
|
||||
}
|
||||
*/
|
||||
|
||||
LONG Def_WriteString( UBYTE *deffic, UBYTE *identificateur, UBYTE *string )
|
||||
{
|
||||
WORD crlf = 0x0A0D ;
|
||||
|
||||
OrgPtrDef = PtrDef = LoadMalloc( deffic ) ;
|
||||
|
||||
if( PtrDef ) // fichier existe
|
||||
{
|
||||
EndPtrDef = PtrDef + LoadMallocFileSize ;
|
||||
|
||||
DefHandle = OpenWrite( deffic ) ;
|
||||
if( !DefHandle ) return FALSE ;
|
||||
|
||||
if( PtrDefSearchIdentificator( identificateur ) )
|
||||
{
|
||||
// ecrit d‚but fichier
|
||||
Write( DefHandle, OrgPtrDef, PtrDef-OrgPtrDef ) ;
|
||||
|
||||
// ecrit parametre
|
||||
Write( DefHandle, " ", 1 ) ;
|
||||
Write( DefHandle, string, strlen( string ) ) ;
|
||||
Write( DefHandle, &crlf, 2 ) ;
|
||||
|
||||
PtrDefReadThisString() ; // lit ancien parametre
|
||||
|
||||
// fin du fichier
|
||||
Write( DefHandle, PtrDef, EndPtrDef-PtrDef ) ;
|
||||
Close( DefHandle ) ;
|
||||
Free( OrgPtrDef ) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//identificateur pas trouv‚
|
||||
|
||||
// ecrit tout fichier
|
||||
Write( DefHandle, OrgPtrDef, LoadMallocFileSize ) ;
|
||||
|
||||
Free( OrgPtrDef ) ;
|
||||
}
|
||||
else // fichier n'existe pas
|
||||
{
|
||||
DefHandle = OpenWrite( deffic ) ;
|
||||
if( !DefHandle ) return FALSE ;
|
||||
}
|
||||
|
||||
// ecrit identificateur
|
||||
Write( DefHandle, identificateur, strlen(identificateur) ) ;
|
||||
Write( DefHandle, ": ", 2 ) ;
|
||||
// ecrit parametre string
|
||||
Write( DefHandle, string, strlen( string ) ) ;
|
||||
Write( DefHandle, &crlf, 2 ) ;
|
||||
|
||||
Close( DefHandle ) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
LONG Def_WriteValue( UBYTE *deffic, UBYTE *identificateur, LONG value )
|
||||
{
|
||||
itoa( value, DefValue, 10 ) ;
|
||||
return Def_WriteString( deffic, identificateur, DefValue ) ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
15
LIB386/LIB_SYS/DIVERS.C
Normal file
15
LIB386/LIB_SYS/DIVERS.C
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <i86.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "adeline.h"
|
||||
#include "lib_sys.h"
|
||||
|
||||
char ItoaTempoString[40] ; /* c'est 17 le max je crois */
|
||||
|
||||
char *Itoa( LONG value )
|
||||
{
|
||||
return itoa( value, ItoaTempoString, 10 ) ;
|
||||
}
|
||||
80
LIB386/LIB_SYS/DLL.H
Normal file
80
LIB386/LIB_SYS/DLL.H
Normal file
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// 386FX file & DLL loader functions/equates
|
||||
//
|
||||
|
||||
#ifndef DLL_H
|
||||
#define DLL_H
|
||||
|
||||
//
|
||||
// MetaWare support
|
||||
//
|
||||
|
||||
#ifdef __HIGHC__
|
||||
#define cdecl _CC(_REVERSE_PARMS | _NEAR_CALL)
|
||||
#pragma Global_aliasing_convention("_%r");
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef FILE_ERRS
|
||||
#define FILE_ERRS
|
||||
|
||||
#define NO_ERROR 0
|
||||
#define IO_ERROR 1
|
||||
#define OUT_OF_MEMORY 2
|
||||
#define FILE_NOT_FOUND 3
|
||||
#define CANT_WRITE_FILE 4
|
||||
#define CANT_READ_FILE 5
|
||||
#define DISK_FULL 6
|
||||
|
||||
#endif
|
||||
|
||||
// #ifndef TYPEDEFS
|
||||
// #define TYPEDEFS
|
||||
|
||||
// typedef unsigned char UBYTE;
|
||||
// typedef unsigned short UWORD;
|
||||
// typedef unsigned long ULONG;
|
||||
// typedef char BYTE;
|
||||
// typedef short WORD;
|
||||
// typedef long LONG;
|
||||
|
||||
// #endif
|
||||
|
||||
//
|
||||
// DLL loader flags & functions
|
||||
//
|
||||
|
||||
#define DLLSRC_FILE 0 // *source is filename string
|
||||
#define DLLSRC_MEM 1 // *source is pointer to DLL image in memory
|
||||
#define DLLMEM_USER 2 // *dll -> output memory block alloc'd by user
|
||||
#define DLLMEM_ALLOC 4 // *dll = don't care; allocate & return output mem
|
||||
|
||||
ULONG cdecl DLL_size(void *source, ULONG flags);
|
||||
void * cdecl DLL_load(void *source, ULONG flags, void *dll);
|
||||
|
||||
//
|
||||
// File functions
|
||||
//
|
||||
|
||||
LONG cdecl FILE_error(void);
|
||||
LONG cdecl FILE_size(BYTE *filename);
|
||||
void * cdecl FILE_read(BYTE *filename, void *dest);
|
||||
LONG cdecl FILE_write(BYTE *filename, void *buf, ULONG len);
|
||||
LONG cdecl FILE_append(BYTE *filename, void *buf, ULONG len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// MetaWare support
|
||||
//
|
||||
|
||||
#ifdef __HIGHC__
|
||||
#pragma Global_aliasing_convention();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
639
LIB386/LIB_SYS/DLLLOAD.C
Normal file
639
LIB386/LIB_SYS/DLLLOAD.C
Normal file
@@ -0,0 +1,639 @@
|
||||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛ DLLLOAD.C ÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛ 32-bit DLL driver loader ÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛ V1.00 of 16-Aug-92: Initial version for Watcom C ÛÛ
|
||||
//ÛÛ V1.01 of 1-May-93: Zortech C++ v3.1 compatibility added ÛÛ
|
||||
//ÛÛ V1.02 of 16-Nov-93: Metaware High C/C++ v3.1 compatibility added ÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛ Project: 386FX Sound & Light(TM) ÛÛ
|
||||
//ÛÛ Author: John Lemberger ÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛ C source compatible with Watcom C386 v9.0 or later ÛÛ
|
||||
//ÛÛ Zortech C++ v3.1 or later ÛÛ
|
||||
//ÛÛ MetaWare High C/C++ v3.1 or later ÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛ Copyright (C) 1991-1993 Miles Design, Inc. ÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛ Miles Design, Inc. ÛÛ
|
||||
//ÛÛ 6702 Cat Creek Trail ÛÛ
|
||||
//ÛÛ Austin, TX 78731 ÛÛ
|
||||
//ÛÛ (512) 345-2642 / FAX (512) 338-9630 / BBS (512) 454-9990 ÛÛ
|
||||
//ÛÛ ÛÛ
|
||||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||||
|
||||
#include <dos.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <sys\types.h>
|
||||
#include <sys\stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "adeline.h"
|
||||
#include "lib_sys.h"
|
||||
|
||||
//
|
||||
// Entry table types
|
||||
//
|
||||
|
||||
#define UNUSED_ENTRY 0
|
||||
#define BIT16_ENTRY 1
|
||||
#define CALL_GATE 2
|
||||
#define BIT32_ENTRY 3
|
||||
#define FORWARDER_ENTRY 4
|
||||
#define PARAMETER_TYPING 0x80
|
||||
|
||||
//
|
||||
// Fixup record source
|
||||
//
|
||||
|
||||
#define BYTE_FIXUP 0x00
|
||||
#define BIT16_SELECTOR 0x02
|
||||
#define BIT16_POINTER 0x03
|
||||
#define BIT16_OFFSET 0x05
|
||||
#define BIT32_POINTER 0x06
|
||||
#define BIT32_OFFSET 0x07
|
||||
#define BIT32_RELATIVE 0x08
|
||||
#define FIXUP_ALIAS 0x10
|
||||
#define SRC_LIST_FLAG 0x20
|
||||
|
||||
//
|
||||
// Fixup record flags
|
||||
//
|
||||
|
||||
#define INT_REF 0x00
|
||||
#define IMP_REF_BY_ORD 0x01
|
||||
#define IMP_REF_BY_NAME 0x02
|
||||
#define INT_REF_ENTRY_TBL 0x03
|
||||
#define ADDITIVE_FIXUP 0x04
|
||||
#define BIT32_TARGET 0x10
|
||||
#define BIT32_ADDITIVE 0x20
|
||||
#define BIT16_OBJECT 0x40
|
||||
#define BIT8_ORDINAL 0x80
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG lxbw;
|
||||
ULONG format_level;
|
||||
ULONG cpu_os_type;
|
||||
ULONG module_version;
|
||||
ULONG module_flags;
|
||||
ULONG module_num_of_pages;
|
||||
ULONG eip_object_num;
|
||||
ULONG eip;
|
||||
ULONG esp_object_num;
|
||||
ULONG esp;
|
||||
ULONG page_size;
|
||||
ULONG page_offset_shift;
|
||||
ULONG fixup_section_size;
|
||||
ULONG fixup_section_chksum;
|
||||
ULONG loader_section_size;
|
||||
ULONG loader_section_chksum;
|
||||
ULONG object_table_off;
|
||||
ULONG num_objects_in_module;
|
||||
ULONG object_page_table_off;
|
||||
ULONG object_iter_pages_off;
|
||||
ULONG resource_table_off;
|
||||
ULONG num_resource_table_entries;
|
||||
ULONG resident_name_table_off;
|
||||
ULONG entry_table_off;
|
||||
ULONG module_directives_off;
|
||||
ULONG num_module_directives;
|
||||
ULONG fixup_page_table_off;
|
||||
ULONG fixup_record_table_off;
|
||||
ULONG import_module_table_off;
|
||||
ULONG num_import_mod_entries;
|
||||
ULONG import_proc_table_off;
|
||||
ULONG per_page_chksum_off;
|
||||
ULONG data_pages_off;
|
||||
ULONG num_preload_pages;
|
||||
ULONG nonres_name_table_off;
|
||||
ULONG nonres_name_table_len;
|
||||
ULONG nonres_name_table_chksum;
|
||||
ULONG auto_ds_object_num;
|
||||
ULONG debug_info_off;
|
||||
ULONG debug_info_len;
|
||||
ULONG numinstance_preload;
|
||||
ULONG numinstance_demand;
|
||||
ULONG heapsize;
|
||||
}
|
||||
LX_header_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG virtual_size;
|
||||
ULONG reloc_base_addr;
|
||||
ULONG object_flags;
|
||||
ULONG page_table_index;
|
||||
ULONG num_page_table_entries;
|
||||
ULONG reserved_space;
|
||||
}
|
||||
object_table_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG page_data_offset;
|
||||
UWORD data_size;
|
||||
UWORD flags;
|
||||
}
|
||||
object_page_table_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UWORD type_id;
|
||||
UWORD name_id;
|
||||
ULONG resource_size;
|
||||
UWORD object;
|
||||
ULONG offset;
|
||||
}
|
||||
resource_table_struct;
|
||||
|
||||
static LONG disk_err = 0;
|
||||
|
||||
#undef min
|
||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
/**********************************************************/
|
||||
static void *cdecl DLL_read(ULONG src, ULONG srcoff, ULONG flags,
|
||||
void *dest, ULONG length)
|
||||
{
|
||||
if (flags & DLLSRC_MEM)
|
||||
{
|
||||
memcpy(dest,(BYTE *) src+srcoff,length);
|
||||
return (void *) (srcoff+length);
|
||||
}
|
||||
else
|
||||
{
|
||||
lseek(src,(ULONG) srcoff,SEEK_SET); // get LX header offset
|
||||
read(src,dest,length);
|
||||
|
||||
return (void *) (srcoff+length);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************/
|
||||
ULONG cdecl DLL_size(void *source, ULONG flags)
|
||||
{
|
||||
BYTE cword[]=" \0";
|
||||
void *src_ptr;
|
||||
LX_header_struct LX_hdr;
|
||||
object_table_struct object_table;
|
||||
ULONG lx;
|
||||
ULONG i;
|
||||
ULONG LX_offset;
|
||||
ULONG module_size=0;
|
||||
|
||||
if (flags & DLLSRC_MEM)
|
||||
lx=(ULONG) source;
|
||||
else
|
||||
{
|
||||
lx=open((BYTE *) source,O_RDONLY | O_BINARY);
|
||||
|
||||
if (lx==-1) // error opening file?
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Get LX header offset
|
||||
//
|
||||
|
||||
src_ptr=DLL_read(lx, 0x03c, flags, &LX_offset, 4);
|
||||
|
||||
//
|
||||
// Check for valid LX marker
|
||||
//
|
||||
|
||||
src_ptr=DLL_read(lx,LX_offset, flags, cword, 2);
|
||||
if (strcmp(cword,"LX"))
|
||||
{
|
||||
//
|
||||
// Error: Invalid LX file
|
||||
//
|
||||
|
||||
close(lx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Read LX header (Tables not included)
|
||||
//
|
||||
|
||||
src_ptr=DLL_read(lx,LX_offset, flags, &LX_hdr, sizeof(LX_hdr));
|
||||
|
||||
//
|
||||
// Read object table; calculate memory needed
|
||||
//
|
||||
|
||||
src_ptr=(void *)(LX_offset+LX_hdr.object_table_off);
|
||||
|
||||
for(i=0;i<LX_hdr.num_objects_in_module;i++)
|
||||
{
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr, flags, &object_table, sizeof(object_table));
|
||||
module_size+=object_table.virtual_size;
|
||||
}
|
||||
|
||||
if (!(flags & DLLSRC_MEM))
|
||||
{
|
||||
close(lx);
|
||||
}
|
||||
|
||||
// Add slack for paragraph alignment of each DATA Object
|
||||
//
|
||||
module_size += 15 * LX_hdr.num_objects_in_module;
|
||||
|
||||
return module_size;
|
||||
}
|
||||
|
||||
/**********************************************************/
|
||||
void *cdecl DLL_load(void *source, ULONG flags, void *dll)
|
||||
{
|
||||
LX_header_struct LX_hdr;
|
||||
void *src_ptr;
|
||||
void *object_table_pos,*object_page_table_pos,*fixup_page_table_pos;
|
||||
object_table_struct object_table;
|
||||
object_page_table_struct object_page_table;
|
||||
BYTE cword[]=" \0";
|
||||
UBYTE *dll_ptr;
|
||||
UBYTE *object_ptr[10],*page_ptr[100];
|
||||
UBYTE src,fix_flags,f_object;
|
||||
UBYTE *trg_val;
|
||||
UWORD srcoff,trgoff;
|
||||
ULONG read_size, dll_size;
|
||||
ULONG i,j,lx,page_count=0;
|
||||
ULONG LX_offset;
|
||||
ULONG *fix_src_ptr;
|
||||
ULONG page_offset,next_page_offset;
|
||||
|
||||
if (flags & DLLSRC_MEM)
|
||||
lx=(ULONG) source;
|
||||
else
|
||||
{
|
||||
lx=open((BYTE *) source,O_RDONLY | O_BINARY);
|
||||
if (lx==-1) // error opening file?
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate memory if not done by caller
|
||||
//
|
||||
|
||||
dll_size=DLL_size(source,flags);
|
||||
|
||||
if (flags & DLLMEM_ALLOC)
|
||||
{
|
||||
dll=DosMalloc(dll_size, NULL);
|
||||
|
||||
if (dll==NULL)
|
||||
{
|
||||
if (!(flags & DLLSRC_MEM))
|
||||
close(lx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
memset(dll,0,dll_size);
|
||||
|
||||
dll_ptr=dll;
|
||||
|
||||
//
|
||||
// Get LX header offset
|
||||
//
|
||||
|
||||
src_ptr=DLL_read(lx, 0x03c, flags, &LX_offset, 4);
|
||||
|
||||
//
|
||||
// Check for valid LX marker
|
||||
//
|
||||
|
||||
src_ptr=DLL_read(lx,LX_offset, flags, cword, 2);
|
||||
if (strcmp(cword,"LX"))
|
||||
{
|
||||
//
|
||||
// Error: Invalid LX file
|
||||
//
|
||||
|
||||
if (!(flags & DLLSRC_MEM))
|
||||
close(lx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Read LX header (Tables not included)
|
||||
//
|
||||
|
||||
src_ptr=DLL_read(lx,LX_offset, flags, &LX_hdr, sizeof(LX_hdr));
|
||||
|
||||
//
|
||||
// Read object table
|
||||
//
|
||||
|
||||
src_ptr=(void *)(LX_offset+LX_hdr.object_table_off);
|
||||
|
||||
for(i=0;i<LX_hdr.num_objects_in_module;i++)
|
||||
{
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,
|
||||
&object_table, sizeof(object_table));
|
||||
|
||||
//
|
||||
// Read in object page entries
|
||||
//
|
||||
|
||||
object_table_pos=src_ptr;
|
||||
|
||||
src_ptr=(void *)(LX_offset+LX_hdr.object_page_table_off);
|
||||
for (j=0;j<object_table.num_page_table_entries;j++)
|
||||
{
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,
|
||||
&object_page_table,sizeof(object_page_table));
|
||||
|
||||
//
|
||||
// Read page data into DLL buffer
|
||||
//
|
||||
|
||||
if (j==0) // Do if this is a new object
|
||||
{
|
||||
//
|
||||
// If this is the data object, paragraph-align it,
|
||||
// unless this is the first object in the file, then
|
||||
// the user is responsible for allocating a paragraph aligned
|
||||
// memory block. JL & JM 12/30/93
|
||||
//
|
||||
// Modification made because UltraSound drivers did not load
|
||||
// properly
|
||||
|
||||
if (object_table.object_flags & 0x02 &&
|
||||
object_table.object_flags & 0x01)
|
||||
{
|
||||
if ((ULONG) dll_ptr & 0x0f && i!=0)
|
||||
dll_ptr += (0x10-((ULONG) dll & 0x0f));
|
||||
}
|
||||
object_ptr[i+1]=dll_ptr; // Save object start position
|
||||
}
|
||||
|
||||
page_ptr[page_count++] = dll_ptr; // Save the page start position
|
||||
object_page_table_pos = src_ptr; // Save place in table
|
||||
|
||||
read_size = min(object_table.virtual_size-(dll_ptr-object_ptr[i+1]),
|
||||
object_page_table.data_size);
|
||||
|
||||
src_ptr=(void *)(
|
||||
(object_page_table.page_data_offset << LX_hdr.page_offset_shift)
|
||||
+LX_hdr.data_pages_off);
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,dll_ptr,read_size);
|
||||
|
||||
dll_ptr += read_size;
|
||||
|
||||
src_ptr=(void *)object_page_table_pos; // Restore place in table
|
||||
}
|
||||
|
||||
src_ptr=(void *)object_table_pos; // Restore place in table
|
||||
}
|
||||
|
||||
//
|
||||
// Read fixup page table and perform fixups
|
||||
//
|
||||
|
||||
src_ptr = (void *) (LX_offset+LX_hdr.fixup_page_table_off);
|
||||
src_ptr = DLL_read(lx,(ULONG) src_ptr,flags,
|
||||
&page_offset,sizeof(page_offset));
|
||||
|
||||
for(i=0;i<LX_hdr.module_num_of_pages;i++)
|
||||
{
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,
|
||||
&next_page_offset,sizeof(next_page_offset));
|
||||
|
||||
if (page_offset!=next_page_offset)
|
||||
{
|
||||
|
||||
//
|
||||
// Read object page entries
|
||||
//
|
||||
|
||||
fixup_page_table_pos=src_ptr;
|
||||
|
||||
src_ptr=(void *)(page_offset+LX_offset+LX_hdr.fixup_record_table_off);
|
||||
do
|
||||
{
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,
|
||||
&src,1);
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,
|
||||
&fix_flags,1);
|
||||
|
||||
if (!(src&BIT32_OFFSET))
|
||||
{
|
||||
//
|
||||
// Error: Non-32-bit offset fixup in table
|
||||
//
|
||||
|
||||
if (!(flags & DLLSRC_MEM))
|
||||
close(lx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((fix_flags & ADDITIVE_FIXUP) && !(fix_flags & BIT32_ADDITIVE))
|
||||
{
|
||||
//
|
||||
// Error: Non-32-bit additive in table
|
||||
//
|
||||
|
||||
if (!(flags & DLLSRC_MEM))
|
||||
close(lx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (src & SRC_LIST_FLAG)
|
||||
{
|
||||
//
|
||||
// Error: Fixup list type not supported
|
||||
//
|
||||
|
||||
if (!(flags & DLLSRC_MEM))
|
||||
close(lx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,
|
||||
&srcoff,2);
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,
|
||||
&f_object,1);
|
||||
src_ptr=DLL_read(lx,(ULONG)src_ptr,flags,
|
||||
&trgoff,2);
|
||||
|
||||
//
|
||||
// Perform fixup (if positive offset)
|
||||
//
|
||||
|
||||
if ( (ULONG) srcoff <= LX_hdr.page_size )
|
||||
{
|
||||
fix_src_ptr=(ULONG *)(page_ptr[i]+srcoff);
|
||||
trg_val=object_ptr[f_object]+trgoff;
|
||||
|
||||
*fix_src_ptr=(ULONG)trg_val;
|
||||
}
|
||||
}
|
||||
|
||||
} while(src_ptr < (void *)(next_page_offset+LX_offset+LX_hdr.fixup_record_table_off));
|
||||
|
||||
src_ptr=(void *)fixup_page_table_pos;
|
||||
}
|
||||
|
||||
page_offset=next_page_offset;
|
||||
|
||||
}
|
||||
if (!(flags & DLLSRC_MEM))
|
||||
close(lx);
|
||||
|
||||
return dll;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
LONG cdecl FILE_error(void)
|
||||
{
|
||||
return disk_err;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
LONG cdecl FILE_size(BYTE *filename)
|
||||
{
|
||||
LONG handle;
|
||||
LONG len;
|
||||
|
||||
disk_err = 0;
|
||||
|
||||
handle = open(filename,O_RDONLY | O_BINARY);
|
||||
if (handle==-1)
|
||||
{
|
||||
disk_err = FILE_NOT_FOUND;
|
||||
return -1L;
|
||||
}
|
||||
|
||||
len = filelength(handle);
|
||||
if (len==-1L) disk_err = CANT_READ_FILE;
|
||||
|
||||
close(handle);
|
||||
return len;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
void * cdecl FILE_read(BYTE *filename, void *dest)
|
||||
{
|
||||
LONG i,handle;
|
||||
LONG len;
|
||||
BYTE *buf, *mem;
|
||||
|
||||
disk_err = 0;
|
||||
|
||||
len = FILE_size(filename);
|
||||
if (len==-1L)
|
||||
{
|
||||
disk_err = FILE_NOT_FOUND;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf = mem = (dest==NULL)? Malloc(len) : dest;
|
||||
|
||||
if (buf==NULL)
|
||||
{
|
||||
disk_err = OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle = open(filename,O_RDONLY | O_BINARY);
|
||||
if (handle==-1)
|
||||
{
|
||||
Free(mem);
|
||||
disk_err = FILE_NOT_FOUND;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i = read(handle,buf,len);
|
||||
|
||||
if (i != len)
|
||||
{
|
||||
Free(mem);
|
||||
disk_err = CANT_READ_FILE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
close(handle);
|
||||
return mem;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
LONG cdecl FILE_write(BYTE *filename, void *buf, ULONG len)
|
||||
{
|
||||
LONG i,handle;
|
||||
|
||||
disk_err = 0;
|
||||
|
||||
handle = open(filename,O_CREAT | O_RDWR | O_TRUNC | O_BINARY,
|
||||
S_IREAD | S_IWRITE);
|
||||
if (handle==-1)
|
||||
{
|
||||
disk_err = CANT_WRITE_FILE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = write(handle,buf,len);
|
||||
if (i == -1)
|
||||
{
|
||||
disk_err = CANT_WRITE_FILE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (i != len)
|
||||
{
|
||||
disk_err = DISK_FULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
close(handle);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
LONG cdecl FILE_append(BYTE *filename, void *buf, ULONG len)
|
||||
{
|
||||
LONG i,handle;
|
||||
|
||||
disk_err = 0;
|
||||
|
||||
handle = open(filename,O_APPEND | O_RDWR | O_BINARY);
|
||||
if (handle==-1)
|
||||
{
|
||||
disk_err = FILE_NOT_FOUND;
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = write(handle,buf,len);
|
||||
if (i == -1)
|
||||
{
|
||||
disk_err = CANT_WRITE_FILE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (i != len)
|
||||
{
|
||||
disk_err = DISK_FULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
close(handle);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
69
LIB386/LIB_SYS/EXPAND.ASM
Normal file
69
LIB386/LIB_SYS/EXPAND.ASM
Normal file
@@ -0,0 +1,69 @@
|
||||
.386P
|
||||
.MODEL SMALL, SYSCALL
|
||||
|
||||
.CODE
|
||||
|
||||
public NoLanguage Expand
|
||||
|
||||
;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
|
||||
|
||||
Expand PROC USES ESI EDI EBX EBP,\
|
||||
src:DWORD, dest:DWORD, count:DWORD ; COUNT devrait etre un DWORD !!!
|
||||
|
||||
mov esi, src
|
||||
mov edi, dest
|
||||
mov ebp, count ; compteur pour savoir si on a fini...
|
||||
; et puis j'ai plus besoin de lire
|
||||
; d'autre parametres... d'ou BP !
|
||||
; BP = decomp size
|
||||
boucle:
|
||||
mov dx, 8 ; 1 octet info pour 8 data de 8 ou
|
||||
; 16 bits (ca depend du bit...)
|
||||
lodsb
|
||||
mov bx, ax ; octet d'info dans bl
|
||||
next:
|
||||
shr bx, 1 ; ca va plus vite de d‚caler bx ou
|
||||
; bl ? (Vrai question, chef)
|
||||
jnc copie ; chaque bit indique la nature de
|
||||
; ce qui suit
|
||||
|
||||
movsb ; ici un octet de data a recopier
|
||||
dec ebp ; 1 de moins
|
||||
jz termine ; si c'est fini, c'est fini
|
||||
dec dx ; 1 bit de moins
|
||||
jnz next ; s'il en reste on continu
|
||||
jmp boucle ; sinon on lit un octet d'info de plus
|
||||
|
||||
copie: ; ici on a 16 bits formant un offset
|
||||
; (sur 12 bits) et une longueur ; (sur 4 bits)
|
||||
lodsw ; on lit donc cette donnee
|
||||
movzx ecx, ax
|
||||
mov eax, ecx
|
||||
and ecx, 0Fh ; on recupere la longueur dans cx
|
||||
inc ecx ; on ajuste car pas de copie de
|
||||
inc ecx ; bloc de longeur < 2 (d'ou gain...)
|
||||
sub ebp, ecx ; il restera ca en moins a faire
|
||||
shr eax, 4 ;
|
||||
; on recupere l'offset
|
||||
not eax ; en fait c'est un decalage en
|
||||
; arriŠre - 1 (not ax = -ax - 1)
|
||||
add eax, edi ; par rapport … di (ax = di - ax - 1)
|
||||
xchg eax, esi ; on sauve si tout en lui donnant
|
||||
; l'ofset calcule
|
||||
rep movsb ; on fait la recopie
|
||||
|
||||
mov esi, eax ; restore si
|
||||
or ebp, ebp ; il en reste ?
|
||||
jz termine ; ...
|
||||
dec dx ; il reste des bits d'info ?
|
||||
jnz next ; ...
|
||||
jmp boucle ; ...
|
||||
termine: ; c'est fini... Quoi ?!!! deja ?!!!
|
||||
; c'est con cette methode de
|
||||
; compression ! Mais ca marche !
|
||||
ret
|
||||
|
||||
Expand ENDP
|
||||
|
||||
|
||||
end
|
||||
184
LIB386/LIB_SYS/FILES.C
Normal file
184
LIB386/LIB_SYS/FILES.C
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
FILES (c) Adeline 1993
|
||||
|
||||
Functions:
|
||||
|
||||
- OpenRead
|
||||
- OpenWrite
|
||||
- OpenReadWrite
|
||||
- Read
|
||||
- Write
|
||||
- Close
|
||||
- Seek
|
||||
- Delete
|
||||
- FileSize
|
||||
- AddExt
|
||||
*/
|
||||
|
||||
#include <i86.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "adeline.h"
|
||||
#include "lib_sys.h"
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
LONG OpenRead( char *name )
|
||||
{
|
||||
int handle ;
|
||||
|
||||
if ( _dos_open( name, O_RDONLY, &handle )) handle = 0 ;
|
||||
return(handle) ;
|
||||
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
LONG OpenWrite( char *name )
|
||||
{
|
||||
int handle ;
|
||||
|
||||
if ( _dos_creat( name, _A_NORMAL, &handle )) handle = 0 ;
|
||||
return(handle) ;
|
||||
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
LONG OpenReadWrite( char *name )
|
||||
{
|
||||
int handle ;
|
||||
|
||||
if ( _dos_open( name, O_RDWR, &handle )) handle = 0 ;
|
||||
return(handle) ;
|
||||
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
ULONG Read( LONG handle, void *buffer, ULONG lenread )
|
||||
{
|
||||
ULONG howmuch ;
|
||||
|
||||
if ( lenread == 0xFFFFFFFFL ) /* -1L */
|
||||
lenread = 16000000L ;/* Ca Accelere !! */
|
||||
_dos_read( handle, buffer, lenread, (unsigned int *)&howmuch ) ;
|
||||
return( howmuch ) ;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
ULONG Write( LONG handle, void *buffer, ULONG lenwrite )
|
||||
{
|
||||
ULONG howmuch ;
|
||||
|
||||
_dos_write( handle, buffer, lenwrite, (unsigned int *)&howmuch ) ;
|
||||
return( howmuch ) ;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void Close( LONG handle )
|
||||
{
|
||||
_dos_close( handle ) ;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
LONG Seek( LONG handle, LONG position, LONG mode )
|
||||
{
|
||||
return(lseek( handle, position, mode )) ;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
LONG Delete( char *name )
|
||||
{
|
||||
if ( remove( name )) return(0) ;
|
||||
return(1) ;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
ULONG FileSize( char *name )
|
||||
{
|
||||
int handle ;
|
||||
ULONG fsize ;
|
||||
|
||||
handle = OpenRead( name ) ;
|
||||
if ( handle == 0 ) return(0) ;
|
||||
|
||||
fsize = Seek( handle, 0, SEEK_END );
|
||||
|
||||
Close( handle ) ;
|
||||
return( fsize ) ;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
void AddExt( char *path, char *ext )
|
||||
{
|
||||
// Version Loran
|
||||
|
||||
|
||||
/*
|
||||
char *pt ;
|
||||
pt = path ;
|
||||
while(( *pt != '.' ) AND ( *pt != 0 )) pt++ ;
|
||||
*pt = 0 ;
|
||||
strcat( path, ext ) ;
|
||||
*/
|
||||
|
||||
|
||||
char drive[_MAX_DRIVE] ;
|
||||
char dir[_MAX_DIR] ;
|
||||
char name[_MAX_FNAME] ;
|
||||
char oldext[_MAX_EXT] ;
|
||||
|
||||
_splitpath( path, drive, dir, name, oldext ) ;
|
||||
|
||||
// makepath rajoute le point si necessaire
|
||||
|
||||
// oldext[0] = '.' ;
|
||||
// if (*ext == '.' ) ext++ ;
|
||||
// strcpy(oldext+1, ext);
|
||||
// _makepath( path, drive, dir, name, oldext ) ;
|
||||
|
||||
|
||||
_makepath( path, drive, dir, name, ext ) ;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
LONG Copy( UBYTE *sname, UBYTE *dname )
|
||||
{
|
||||
ULONG n, size ;
|
||||
LONG shandle ;
|
||||
LONG dhandle ;
|
||||
UBYTE c ;
|
||||
|
||||
size = FileSize( sname ) ;
|
||||
if( !size ) return 0L ;
|
||||
|
||||
shandle = OpenRead( sname ) ;
|
||||
if( !shandle ) return 0L ;
|
||||
|
||||
dhandle = OpenWrite( dname ) ;
|
||||
if( !dhandle )
|
||||
{
|
||||
Close( shandle ) ;
|
||||
return 0L ;
|
||||
}
|
||||
|
||||
for( n=0; n<size; n++ )
|
||||
{
|
||||
Read( shandle, &c, 1L ) ;
|
||||
if( Write( dhandle, &c, 1L ) != 1L )
|
||||
{
|
||||
Close( shandle ) ;
|
||||
Close( dhandle ) ;
|
||||
return 0L ;
|
||||
}
|
||||
}
|
||||
|
||||
Close( shandle ) ;
|
||||
Close( dhandle ) ;
|
||||
|
||||
return 1L ;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
LONG CopyBak( UBYTE *name )
|
||||
{
|
||||
UBYTE string[256] ;
|
||||
|
||||
strcpy( string, name ) ;
|
||||
AddExt( string, ".BAK" ) ;
|
||||
return Copy( name, string ) ;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
110
LIB386/LIB_SYS/FILES_A.ASM
Normal file
110
LIB386/LIB_SYS/FILES_A.ASM
Normal file
@@ -0,0 +1,110 @@
|
||||
;----------------------------------------------------------------------------
|
||||
;' FILES_A.ASM 386
|
||||
;' (c) Adeline 1994
|
||||
;----------------------------------------------------------------------------
|
||||
.386p
|
||||
|
||||
.model SMALL, SYSCALL
|
||||
|
||||
.data
|
||||
|
||||
.code
|
||||
|
||||
public NoLanguage Touch
|
||||
extrn NoLanguage OpenRead:PROC
|
||||
extrn NoLanguage Close:PROC
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
Touch proc ,\
|
||||
filename:DWORD
|
||||
local handle:DWORD
|
||||
local time:WORD
|
||||
local date:WORD
|
||||
|
||||
mov [time], 0
|
||||
mov [date], 0
|
||||
|
||||
;----------------------' Open
|
||||
|
||||
push filename
|
||||
call OpenRead
|
||||
add esp, 4
|
||||
mov [handle], eax
|
||||
|
||||
;----------------------' Read Time and Date
|
||||
|
||||
mov ah, 2Ch
|
||||
int 21h
|
||||
|
||||
xor ax, ax
|
||||
mov al, dh
|
||||
shr al, 1
|
||||
mov byte ptr [time],al ;' Secondes / 2
|
||||
|
||||
xor ax, ax
|
||||
mov al, cl
|
||||
shl ax, 5
|
||||
or [time], ax ;' Minutes
|
||||
|
||||
xor ax, ax
|
||||
mov al, ch
|
||||
shl ax, 11
|
||||
or [time], ax ;' Heure
|
||||
|
||||
mov ah, 2Ah
|
||||
int 21h
|
||||
|
||||
mov byte ptr [date],dl ;' Jour
|
||||
|
||||
xor ax, ax
|
||||
mov al, dh
|
||||
shl ax, 5
|
||||
or [date], ax ;' Mois
|
||||
|
||||
xor ax, ax
|
||||
sub cx, 1980
|
||||
mov al, cl
|
||||
shl ax, 9
|
||||
or [date], ax ;' Ann‚e
|
||||
|
||||
;----------------------' Change time and date for this file
|
||||
|
||||
mov ah, 57h
|
||||
mov al, 1
|
||||
mov bx, word ptr [handle]
|
||||
mov cx, [time]
|
||||
mov dx, [date]
|
||||
int 21h
|
||||
|
||||
;----------------------' Close file
|
||||
|
||||
push [handle]
|
||||
call Close
|
||||
add esp, 4
|
||||
ret
|
||||
|
||||
Touch endp
|
||||
;----------------------------------------------------------------------------
|
||||
; The
|
||||
End
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
43
LIB386/LIB_SYS/HARDERR.ASM
Normal file
43
LIB386/LIB_SYS/HARDERR.ASM
Normal file
@@ -0,0 +1,43 @@
|
||||
;/*ヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘ*
|
||||
; ロロソ ロロソ ロロロロロロソ ロロロロロロソ ロロロロロソ ロロロロロロソ ロロロロロロソ ロロロロロロソ
|
||||
; ロロウ ロロウ ロロレトロロウ ロロレトロロウ ロロレトロロソ ロロレトトトル ロロレトロロウ ロロレトロロウ
|
||||
; ロロロロロロウ ロロロロロロウ ロロロロロロウ ロロウ ロロウ ロロロロロソ ロロロロロロウ ロロロロロロウ
|
||||
; ロロレトロロウ ロロレトロロウ ロロレロロレル ロロウ ロロウ ロロレトトル ロロレロロレル ロロレロロレル
|
||||
; ロロウ ロロウ ロロウ ロロウ ロロウタロロソ ロロロロロレル ロロロロロロソ ロロウタロロソ ロロウタロロソ
|
||||
; タトル タトル タトル タトル タトル タトル タトトトトル タトトトトトル タトル タトル タトル タトル
|
||||
; *ヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘ*/
|
||||
;
|
||||
;/*トトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト*/
|
||||
.386p
|
||||
|
||||
.model SMALL, SYSCALL
|
||||
|
||||
|
||||
;/*トトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト*/
|
||||
.DATA
|
||||
|
||||
;/*ヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘ*/
|
||||
|
||||
.CODE
|
||||
|
||||
public NoLanguage NewInt24
|
||||
|
||||
;/*ヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘ*/
|
||||
|
||||
NewInt24 PROC FAR
|
||||
|
||||
mov al, 1
|
||||
iret
|
||||
|
||||
NewInt24 endp
|
||||
|
||||
;/*ヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘヘ*/
|
||||
; The
|
||||
End
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
45
LIB386/LIB_SYS/HQR.ASM
Normal file
45
LIB386/LIB_SYS/HQR.ASM
Normal file
@@ -0,0 +1,45 @@
|
||||
.386P
|
||||
.MODEL SMALL, SYSCALL
|
||||
|
||||
.CODE
|
||||
|
||||
public NoLanguage HQR_GiveIndex
|
||||
|
||||
HQR_GiveIndex proc ,\
|
||||
index:DWORD, nbindex:DWORD, ptrlist:DWORD
|
||||
|
||||
mov ecx, nbindex
|
||||
or ecx, ecx
|
||||
jz not_found
|
||||
|
||||
mov edx, ecx
|
||||
shl edx, 1 ; edx = ecx * 2
|
||||
mov eax, ecx
|
||||
shl eax, 4 ; eax = ecx * 16
|
||||
sub eax, edx ; eax = ecx * 14 T_HQR_BLOC
|
||||
|
||||
mov edx, ptrlist
|
||||
add edx, eax
|
||||
|
||||
mov eax, index
|
||||
|
||||
ALIGN 4
|
||||
se0:
|
||||
REPT 8
|
||||
sub edx, 14 ; sizeof( T_HQR_BLOC )
|
||||
cmp word ptr[edx], ax
|
||||
jz found
|
||||
dec ecx
|
||||
jz not_found
|
||||
ENDM
|
||||
jmp se0
|
||||
|
||||
not_found: xor eax, eax
|
||||
ret
|
||||
|
||||
found: mov eax, edx
|
||||
ret
|
||||
|
||||
HQR_GiveIndex endp
|
||||
|
||||
end
|
||||
175
LIB386/LIB_SYS/HQ_MEM.C
Normal file
175
LIB386/LIB_SYS/HQ_MEM.C
Normal file
@@ -0,0 +1,175 @@
|
||||
#include <i86.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "\projet\lib386\lib_sys\adeline.h"
|
||||
#include "\projet\lib386\lib_sys\lib_sys.h"
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
Û Û ÛßßßÛ ÛÜ ÜÛ Ûßßßß ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ Û Üß
|
||||
ÛÛßßÛ ÛÛ ÜÛ ÛÛß Û ÛÛßß ÛÛß Û ÛÛ Û ÛÛßÛß ÛÛß
|
||||
ßß ß ßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßß ß ßß
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
ULONG Size_HQM_Memory = 0 ;
|
||||
ULONG Size_HQM_Free = 0 ;
|
||||
UBYTE *Ptr_HQM_Memory = 0 ;
|
||||
UBYTE *Ptr_HQM_Next = 0 ;
|
||||
|
||||
typedef struct { ULONG Id ;
|
||||
ULONG Size ;
|
||||
void **Ptr ; } HQM_HEADER ;
|
||||
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
// Init le buffer global
|
||||
|
||||
LONG HQM_Init_Memory( ULONG size )
|
||||
{
|
||||
if( !Ptr_HQM_Memory )
|
||||
{
|
||||
Ptr_HQM_Memory = Malloc( size + 500 ) ; // recover area
|
||||
if( Ptr_HQM_Memory )
|
||||
{
|
||||
Size_HQM_Memory = size ;
|
||||
Size_HQM_Free = size ;
|
||||
Ptr_HQM_Next = Ptr_HQM_Memory ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
// free le buffer global
|
||||
|
||||
void HQM_Clear_Memory()
|
||||
{
|
||||
if( Ptr_HQM_Memory )
|
||||
{
|
||||
Free( Ptr_HQM_Memory ) ;
|
||||
Size_HQM_Free = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
// alloue un bloc de memoire
|
||||
|
||||
LONG HQM_Alloc( ULONG size, void **ptr )
|
||||
{
|
||||
if( !Ptr_HQM_Memory )
|
||||
{
|
||||
*ptr = 0 ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
if( size <= (Size_HQM_Free + sizeof( HQM_HEADER )) )
|
||||
{
|
||||
*ptr = Ptr_HQM_Next + sizeof( HQM_HEADER ) ;
|
||||
|
||||
((HQM_HEADER*)Ptr_HQM_Next)->Id = 0x12345678 ;
|
||||
((HQM_HEADER*)Ptr_HQM_Next)->Size = size ;
|
||||
((HQM_HEADER*)Ptr_HQM_Next)->Ptr = ptr ;
|
||||
|
||||
Ptr_HQM_Next += size + sizeof( HQM_HEADER ) ;
|
||||
Size_HQM_Free -= size + sizeof( HQM_HEADER ) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
*ptr = 0 ;
|
||||
return FALSE ; // pas assez de place
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
// free tous les blocs dans le buffer global
|
||||
|
||||
void HQM_Free_All()
|
||||
{
|
||||
if( Ptr_HQM_Memory )
|
||||
{
|
||||
Ptr_HQM_Next = Ptr_HQM_Memory ;
|
||||
Size_HQM_Free = Size_HQM_Memory ;
|
||||
}
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
// resize le dernier bloc de memoire
|
||||
|
||||
void HQM_Shrink_Last( void *ptr, ULONG newsize )
|
||||
{
|
||||
HQM_HEADER *ptrh ;
|
||||
ULONG deltasize ;
|
||||
|
||||
if( !Ptr_HQM_Memory ) return ;
|
||||
|
||||
ptrh = (HQM_HEADER*)((UBYTE*)ptr - sizeof( HQM_HEADER )) ;
|
||||
|
||||
if( ptrh->Id != 0x12345678 ) return ; // erreur grave
|
||||
|
||||
deltasize = ptrh->Size - newsize ;
|
||||
|
||||
ptrh->Size -= deltasize ;
|
||||
|
||||
Ptr_HQM_Next -= deltasize ;
|
||||
Size_HQM_Free += deltasize ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
// libere un bloc de memoire et bouche le trou (remap les ptrs)
|
||||
|
||||
void HQM_Free( void *ptr )
|
||||
{
|
||||
HQM_HEADER *ptrh ;
|
||||
UBYTE *ptrs, *ptrd, *ptrm ;
|
||||
ULONG delsize, movesize ;
|
||||
|
||||
if( !Ptr_HQM_Memory ) return ;
|
||||
|
||||
ptrs = ptrd = (UBYTE*)ptr - sizeof( HQM_HEADER ) ;
|
||||
|
||||
ptrh = (HQM_HEADER*)ptrd ;
|
||||
if( ptrh->Id != 0x12345678 ) return ; // erreur grave
|
||||
|
||||
delsize = sizeof( HQM_HEADER ) + ptrh->Size ;
|
||||
ptrs = ptrd + delsize ;
|
||||
movesize = (ULONG)(Ptr_HQM_Next - ptrs) ;
|
||||
|
||||
ptrm = ptrs ;
|
||||
while( ptrm < Ptr_HQM_Next )
|
||||
{
|
||||
ptrh = (HQM_HEADER*)ptrm ;
|
||||
*(UBYTE*)(ptrh->Ptr) = *(UBYTE*)(ptrh->Ptr) - delsize ;
|
||||
ptrm += ptrh->Size + sizeof( HQM_HEADER ) ;
|
||||
}
|
||||
|
||||
memmove( ptrd, ptrs, movesize ) ;
|
||||
|
||||
Ptr_HQM_Next -= delsize ;
|
||||
Size_HQM_Free += delsize ;
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
// test la coh‚rence du buffer global
|
||||
|
||||
LONG HQM_Check()
|
||||
{
|
||||
HQM_HEADER *ptrh ;
|
||||
UBYTE *ptr ;
|
||||
|
||||
if( !Ptr_HQM_Memory ) return FALSE ;
|
||||
|
||||
ptr = Ptr_HQM_Memory ;
|
||||
|
||||
while( ptr < Ptr_HQM_Next )
|
||||
{
|
||||
ptrh = (HQM_HEADER*)ptr ;
|
||||
|
||||
if( ptrh->Id != 0x12345678 ) return FALSE ;
|
||||
|
||||
ptr += ptrh->Size + sizeof( HQM_HEADER ) ;
|
||||
}
|
||||
return TRUE ;
|
||||
}
|
||||
629
LIB386/LIB_SYS/HQ_RESS.C
Normal file
629
LIB386/LIB_SYS/HQ_RESS.C
Normal file
@@ -0,0 +1,629 @@
|
||||
#include <i86.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "adeline.h"
|
||||
#include "lib_sys.h"
|
||||
#include "\projet\lib386\lib_samp\lib_wave.h"
|
||||
|
||||
#define RECOVER_AREA 500
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
Û Û ÛßßßÛ ÛßßßÛ Ûßßßß ÛÛßßß ÛÛßßß ÛßßßÛ Û Û ÛßßßÛ Ûßßßß Ûßßßß
|
||||
ÛÛßßÛ ÛÛ ÜÛ ÛÛßÛß ÛÛßß ßßßßÛ ßßßßÛ ÛÛ Û ÛÛ Û ÛÛßÛß ÛÛ ÛÛßß
|
||||
ßß ß ßßßß ßßßßß ßß ß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ß ßßßßß ßßßßß
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
WORD HQR_Flag = FALSE ;
|
||||
|
||||
typedef struct { ULONG SizeFile ;
|
||||
ULONG CompressedSizeFile ;
|
||||
WORD CompressMethod ; /* 0 stored */
|
||||
/* 1 LZS */
|
||||
} T_HEADER ;
|
||||
|
||||
void Expand( void *ptrsourcecomp, void *ptrblocdest, ULONG sizefile ) ;
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
Û Û ÛßßßÛ ÛßßßÛ Û ÛßßßÛ ÛßßßÛ ÛßßßÜ
|
||||
ÛÛßßÛ ÛÛ ÜÛ ÛÛßÛß ÛÛ ÛÛ Û ÛÛßßÛ ÛÛ Û
|
||||
ßß ß ßßßß ßß ß ßßßßß ßßßßß ßßßßß ßß ß ßßßß
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
void *LoadMalloc_HQR( UBYTE *name, UWORD index )
|
||||
{
|
||||
LONG handle ;
|
||||
UWORD nbbloc ;
|
||||
ULONG buffer ;
|
||||
ULONG seekindex ;
|
||||
UBYTE *ptrbloc ;
|
||||
UBYTE *ptrdecomp ;
|
||||
T_HEADER header ;
|
||||
|
||||
handle = OpenRead( name ) ;
|
||||
if( !handle ) return 0L ;
|
||||
|
||||
Read( handle, &buffer, 4L ) ;
|
||||
nbbloc = (UWORD)(buffer / 4L) ;
|
||||
|
||||
if( index >= nbbloc )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0L ;
|
||||
}
|
||||
|
||||
Seek( handle, index * 4L, SEEK_START ) ;
|
||||
Read( handle, &seekindex, 4L ) ;
|
||||
|
||||
Seek( handle, seekindex, SEEK_START ) ;
|
||||
Read( handle, &header, sizeof( header ) ) ;
|
||||
|
||||
ptrbloc = Malloc( header.SizeFile + RECOVER_AREA ) ;
|
||||
if( !ptrbloc )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0L ;
|
||||
}
|
||||
|
||||
switch( header.CompressMethod )
|
||||
{
|
||||
case 0: /* Stored */
|
||||
Read( handle, ptrbloc, header.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
case 1: /* LZS */
|
||||
ptrdecomp = ptrbloc + header.SizeFile - header.CompressedSizeFile + RECOVER_AREA ;
|
||||
Read( handle, ptrdecomp, header.CompressedSizeFile ) ;
|
||||
Expand( ptrdecomp, ptrbloc, header.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
Free( ptrbloc ) ;
|
||||
Close( handle ) ;
|
||||
return 0L ; /* UnKnown version */
|
||||
}
|
||||
|
||||
Mshrink( ptrbloc, header.SizeFile ) ;
|
||||
Close( handle ) ;
|
||||
|
||||
return ptrbloc ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
ULONG Load_HQR( UBYTE *name, void *ptrdest, UWORD index )
|
||||
{
|
||||
LONG handle ;
|
||||
UWORD nbbloc ;
|
||||
ULONG buffer ;
|
||||
ULONG seekindex ;
|
||||
UBYTE *ptrdecomp ;
|
||||
T_HEADER header ;
|
||||
|
||||
handle = OpenRead( name ) ;
|
||||
if( !handle ) return 0L ;
|
||||
|
||||
Read( handle, &buffer, 4L ) ;
|
||||
nbbloc = (UWORD)(buffer / 4L) ;
|
||||
|
||||
if( index >= nbbloc )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0L ;
|
||||
}
|
||||
|
||||
Seek( handle, index * 4L, SEEK_START ) ;
|
||||
Read( handle, &seekindex, 4L ) ;
|
||||
|
||||
Seek( handle, seekindex, SEEK_START ) ;
|
||||
Read( handle, &header, sizeof( header ) ) ;
|
||||
|
||||
switch( header.CompressMethod )
|
||||
{
|
||||
case 0: /* Stored */
|
||||
Read( handle, ptrdest, header.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
case 1: /* LZS */
|
||||
ptrdecomp = (UBYTE*)ptrdest + header.SizeFile - header.CompressedSizeFile + RECOVER_AREA ;
|
||||
Read( handle, ptrdecomp, header.CompressedSizeFile ) ;
|
||||
Expand( ptrdecomp, ptrdest, header.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
Close( handle ) ;
|
||||
return 0L ; /* UnKnown version */
|
||||
}
|
||||
|
||||
Close( handle ) ;
|
||||
|
||||
return header.SizeFile ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
ULONG Size_HQR( char *name, UWORD index )
|
||||
{
|
||||
ULONG handle ;
|
||||
UWORD nbbloc ;
|
||||
ULONG buffer ;
|
||||
ULONG seekindex ;
|
||||
UBYTE *ptrdecomp ;
|
||||
T_HEADER header ;
|
||||
|
||||
handle = OpenRead( name ) ;
|
||||
if( !handle ) return 0 ;
|
||||
|
||||
Read( handle, &buffer, 4 ) ;
|
||||
nbbloc = (UWORD)(buffer / 4) ;
|
||||
|
||||
if( index >= nbbloc )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
Seek( handle, index * 4, SEEK_START ) ;
|
||||
Read( handle, &seekindex, 4 ) ;
|
||||
|
||||
if( seekindex )
|
||||
{
|
||||
Seek( handle, seekindex, SEEK_START ) ;
|
||||
Read( handle, &header, sizeof( T_HEADER ) ) ;
|
||||
|
||||
Close( handle ) ;
|
||||
|
||||
return header.SizeFile ;
|
||||
}
|
||||
else
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
Û Û ÛßßßÛ ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ Û Û ÛßßßÛ Ûßßßß
|
||||
ÛÛßßÛ ÛÛ ÜÛ ÛÛßÛß ÛÛß Û ÛÛßßÛ ÛÛ ÛÛ ÛÛ Û ÛÛ
|
||||
ßß ß ßßßß ßß ß ßßßßß ßß ß ßß ß ßßßßß ßßßßß ßßßßß ßßßßß
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
T_HQR_HEADER *HQR_Init_Ressource( char *hqrname,
|
||||
ULONG maxsize,
|
||||
UWORD maxindex )
|
||||
{
|
||||
T_HQR_HEADER *header ;
|
||||
void *buffer ;
|
||||
|
||||
if( !FileSize( hqrname ) ) return 0 ; // fichier ok ?
|
||||
|
||||
header = Malloc( sizeof(T_HQR_HEADER)
|
||||
+
|
||||
sizeof(T_HQR_BLOC) * maxindex ) ;
|
||||
|
||||
if( !header ) return 0 ; // mem ok ?
|
||||
|
||||
buffer = Malloc( maxsize + RECOVER_AREA ) ;
|
||||
if( !buffer ) return 0 ; // mem ok ?
|
||||
|
||||
strcpy( header->Name, hqrname ) ;
|
||||
header->MaxSize =
|
||||
header->FreeSize = maxsize ;
|
||||
header->MaxIndex = maxindex ;
|
||||
header->NbIndex = 0 ;
|
||||
header->Buffer = buffer ;
|
||||
|
||||
return header ; // header
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
void HQR_Reset_Ressource( T_HQR_HEADER *header )
|
||||
{
|
||||
header->FreeSize = header->MaxSize ;
|
||||
header->NbIndex = 0 ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
LONG HQR_Change_Ressource( T_HQR_HEADER *header, char *newhqrname )
|
||||
{
|
||||
if( !FileSize( newhqrname ) ) return FALSE ; // fichier ok ?
|
||||
|
||||
strcpy( header->Name, newhqrname ) ;
|
||||
|
||||
header->FreeSize = header->MaxSize ;
|
||||
header->NbIndex = 0 ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
void HQR_Free_Ressource( T_HQR_HEADER *header )
|
||||
{
|
||||
if( header )
|
||||
{
|
||||
Free( header->Buffer ) ;
|
||||
Free( header ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
UWORD HQR_Del_Bloc( T_HQR_HEADER *header, WORD index )
|
||||
{
|
||||
UWORD n ;
|
||||
T_HQR_BLOC *ptrbloc ;
|
||||
ULONG delsize ;
|
||||
UBYTE *ptr, *ptrs, *ptrd ;
|
||||
|
||||
ptr = (UBYTE*)(header) + sizeof(T_HQR_HEADER) ;
|
||||
ptrbloc = (T_HQR_BLOC*)(ptr) ;
|
||||
delsize = ptrbloc[index].Size ;
|
||||
|
||||
if( index < (header->NbIndex-1) )
|
||||
{
|
||||
// shift buffer
|
||||
ptrd = header->Buffer + ptrbloc[index].Offset ;
|
||||
ptrs = ptrd + delsize ;
|
||||
memmove(ptrd,
|
||||
ptrs,
|
||||
((header->Buffer+header->MaxSize) - ptrs) ) ;
|
||||
|
||||
// shift index table
|
||||
|
||||
ptrd = (UBYTE*)&ptrbloc[index] ;
|
||||
ptrs = ptrd + sizeof( T_HQR_BLOC ) ;
|
||||
memmove(ptrd,
|
||||
ptrs,
|
||||
(header->MaxIndex - (index + 1))*sizeof(T_HQR_BLOC) ) ;
|
||||
|
||||
// shift index value
|
||||
|
||||
for(n=index; n<(header->NbIndex-1); n++ )
|
||||
{
|
||||
ptrbloc[n].Offset -= delsize ;
|
||||
}
|
||||
}
|
||||
|
||||
header->NbIndex-- ;
|
||||
header->FreeSize += delsize ;
|
||||
|
||||
return delsize ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
void *HQR_Get( T_HQR_HEADER *header, WORD index )
|
||||
{
|
||||
UWORD n, oldest ;
|
||||
ULONG time, testtime ;
|
||||
UBYTE *ptr ;
|
||||
T_HQR_BLOC *ptrbloc ;
|
||||
ULONG size ;
|
||||
ULONG offset ;
|
||||
|
||||
// ressources
|
||||
ULONG handle ;
|
||||
UWORD nbbloc ;
|
||||
ULONG buffer ;
|
||||
ULONG seekindex ;
|
||||
UBYTE *ptrdecomp ;
|
||||
T_HEADER lzssheader ;
|
||||
|
||||
if( index < 0 ) return 0 ;
|
||||
|
||||
if( (ptrbloc = HQR_GiveIndex(
|
||||
index,
|
||||
header->NbIndex,
|
||||
(UBYTE*)header+sizeof(T_HQR_HEADER) )) != 0 )
|
||||
{ // existing index
|
||||
ptrbloc->Time = TimerRef ;
|
||||
|
||||
HQR_Flag = FALSE ; // marque non chargement ressource
|
||||
|
||||
return( header->Buffer + ptrbloc->Offset ) ;
|
||||
}
|
||||
else // need load
|
||||
{
|
||||
// SaveTimer() ;
|
||||
size = Size_HQR( header->Name, index ) ;
|
||||
|
||||
// load and expand hqr bloc
|
||||
|
||||
handle = OpenRead( header->Name ) ;
|
||||
if( !handle ) return 0 ;
|
||||
|
||||
Read( handle, &buffer, 4 ) ;
|
||||
nbbloc = (UWORD)(buffer / 4) ;
|
||||
|
||||
if( index >= nbbloc )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
Seek( handle, index * 4, SEEK_START ) ;
|
||||
Read( handle, &seekindex, 4 ) ;
|
||||
|
||||
if( !seekindex )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
Seek( handle, seekindex, SEEK_START ) ;
|
||||
Read( handle, &lzssheader, sizeof( T_HEADER ) ) ;
|
||||
|
||||
// taille decompacte
|
||||
size = lzssheader.SizeFile ;
|
||||
|
||||
if( !size )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
// gestion m‚moire
|
||||
|
||||
time = TimerRef ;
|
||||
|
||||
ptr = (UBYTE*)(header) + sizeof(T_HQR_HEADER) ;
|
||||
ptrbloc = (T_HQR_BLOC*)(ptr) ;
|
||||
|
||||
// check if enough space for bloc or index
|
||||
|
||||
while( (size > header->FreeSize) OR (header->NbIndex >= header->MaxIndex) )
|
||||
{
|
||||
// delete oldest bloc
|
||||
oldest = 0 ;
|
||||
testtime = 0 ;
|
||||
|
||||
for( n=0; n<header->NbIndex; n++ )
|
||||
{
|
||||
if( (time-ptrbloc[n].Time) > testtime )
|
||||
{
|
||||
testtime = time - ptrbloc[oldest].Time ;
|
||||
oldest = n ;
|
||||
}
|
||||
}
|
||||
HQR_Del_Bloc( header, oldest ) ;
|
||||
}
|
||||
|
||||
// space size ok, load it
|
||||
|
||||
ptr = header->Buffer + header->MaxSize - header->FreeSize ;
|
||||
|
||||
// Load_HQR( header->Name, ptr, index ) ;
|
||||
|
||||
switch( lzssheader.CompressMethod )
|
||||
{
|
||||
case 0: /* Stored */
|
||||
Read( handle, ptr, lzssheader.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
case 1: /* LZS */
|
||||
ptrdecomp = (UBYTE*)ptr + lzssheader.SizeFile - lzssheader.CompressedSizeFile + RECOVER_AREA ;
|
||||
Read( handle, ptrdecomp, lzssheader.CompressedSizeFile ) ;
|
||||
Expand( ptrdecomp, ptr, lzssheader.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
Close( handle ) ;
|
||||
return 0 ; /* UnKnown version */
|
||||
}
|
||||
|
||||
Close( handle ) ;
|
||||
|
||||
HQR_Flag = TRUE ; // indicate loaded
|
||||
|
||||
ptrbloc[header->NbIndex].Index = index ;
|
||||
ptrbloc[header->NbIndex].Time = TimerRef ;
|
||||
ptrbloc[header->NbIndex].Offset = header->MaxSize - header->FreeSize ;
|
||||
ptrbloc[header->NbIndex].Size = size ;
|
||||
|
||||
header->NbIndex++ ;
|
||||
header->FreeSize -= size ;
|
||||
|
||||
// RestoreTimer() ;
|
||||
|
||||
return ptr ;
|
||||
}
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
UWORD HQR_Del_Bloc_Sample( T_HQR_HEADER *header, WORD index )
|
||||
{
|
||||
UWORD n ;
|
||||
T_HQR_BLOC *ptrbloc ;
|
||||
ULONG delsize ;
|
||||
UBYTE *ptr, *ptrs, *ptrd ;
|
||||
|
||||
ptr = (UBYTE*)(header) + sizeof(T_HQR_HEADER) ;
|
||||
ptrbloc = (T_HQR_BLOC*)(ptr) ;
|
||||
delsize = ptrbloc[index].Size ;
|
||||
|
||||
if( index < (header->NbIndex-1) )
|
||||
{
|
||||
// shift buffer
|
||||
ptrd = header->Buffer + ptrbloc[index].Offset ;
|
||||
ptrs = ptrd + delsize ;
|
||||
/* memmove(ptrd,
|
||||
ptrs,
|
||||
((header->Buffer+header->MaxSize) - ptrs) ) ;
|
||||
*/
|
||||
WaveMove(ptrd,
|
||||
ptrs,
|
||||
((header->Buffer+header->MaxSize) - ptrs) ) ;
|
||||
|
||||
// shift index table
|
||||
|
||||
ptrd = (UBYTE*)&ptrbloc[index] ;
|
||||
ptrs = ptrd + sizeof( T_HQR_BLOC ) ;
|
||||
memmove(ptrd,
|
||||
ptrs,
|
||||
(header->MaxIndex - (index + 1))*sizeof(T_HQR_BLOC) ) ;
|
||||
|
||||
// shift index value
|
||||
|
||||
for(n=index; n<(header->NbIndex-1); n++ )
|
||||
{
|
||||
ptrbloc[n].Offset -= delsize ;
|
||||
}
|
||||
}
|
||||
|
||||
header->NbIndex-- ;
|
||||
header->FreeSize += delsize ;
|
||||
|
||||
return delsize ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
void *HQR_GetSample( T_HQR_HEADER *header, WORD index )
|
||||
{
|
||||
UWORD n, oldest ;
|
||||
ULONG time, testtime ;
|
||||
UBYTE *ptr ;
|
||||
T_HQR_BLOC *ptrbloc ;
|
||||
ULONG size ;
|
||||
ULONG offset ;
|
||||
|
||||
// ressources
|
||||
ULONG handle ;
|
||||
UWORD nbbloc ;
|
||||
ULONG buffer ;
|
||||
ULONG seekindex ;
|
||||
UBYTE *ptrdecomp ;
|
||||
T_HEADER lzssheader ;
|
||||
|
||||
if( index < 0 ) return 0 ;
|
||||
|
||||
if( (ptrbloc = HQR_GiveIndex(
|
||||
index,
|
||||
header->NbIndex,
|
||||
(UBYTE*)header+sizeof(T_HQR_HEADER) )) != 0 )
|
||||
{ // existing index
|
||||
ptrbloc->Time = TimerRef ;
|
||||
|
||||
HQR_Flag = FALSE ; // marque non chargement ressource
|
||||
|
||||
return( header->Buffer + ptrbloc->Offset ) ;
|
||||
}
|
||||
else // need load
|
||||
{
|
||||
// SaveTimer() ;
|
||||
size = Size_HQR( header->Name, index ) ;
|
||||
|
||||
// load and expand hqr bloc
|
||||
|
||||
handle = OpenRead( header->Name ) ;
|
||||
if( !handle ) return 0 ;
|
||||
|
||||
Read( handle, &buffer, 4 ) ;
|
||||
nbbloc = (UWORD)(buffer / 4) ;
|
||||
|
||||
if( index >= nbbloc )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
Seek( handle, index * 4, SEEK_START ) ;
|
||||
Read( handle, &seekindex, 4 ) ;
|
||||
|
||||
if( !seekindex )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
Seek( handle, seekindex, SEEK_START ) ;
|
||||
Read( handle, &lzssheader, sizeof( T_HEADER ) ) ;
|
||||
|
||||
// taille decompacte
|
||||
size = lzssheader.SizeFile ;
|
||||
|
||||
if( !size )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
// gestion m‚moire
|
||||
|
||||
time = TimerRef ;
|
||||
|
||||
ptr = (UBYTE*)(header) + sizeof(T_HQR_HEADER) ;
|
||||
ptrbloc = (T_HQR_BLOC*)(ptr) ;
|
||||
|
||||
// check if enough space for bloc or index
|
||||
|
||||
while( (size > header->FreeSize) OR (header->NbIndex >= header->MaxIndex) )
|
||||
{
|
||||
// delete oldest bloc
|
||||
oldest = 0 ;
|
||||
testtime = 0 ;
|
||||
|
||||
for( n=0; n<header->NbIndex; n++ )
|
||||
{
|
||||
if( (time-ptrbloc[n].Time) > testtime )
|
||||
{
|
||||
testtime = time - ptrbloc[oldest].Time ;
|
||||
oldest = n ;
|
||||
}
|
||||
}
|
||||
// m‚thode violente (attendre r‚flexions d‚sagr‚ables...)
|
||||
WaveStopOne( ptrbloc[oldest].Index ) ;
|
||||
|
||||
HQR_Del_Bloc_Sample( header, oldest ) ;
|
||||
}
|
||||
|
||||
// space size ok, load it
|
||||
|
||||
ptr = header->Buffer + header->MaxSize - header->FreeSize ;
|
||||
|
||||
// Load_HQR( header->Name, ptr, index ) ;
|
||||
|
||||
switch( lzssheader.CompressMethod )
|
||||
{
|
||||
case 0: /* Stored */
|
||||
Read( handle, ptr, lzssheader.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
case 1: /* LZS */
|
||||
ptrdecomp = (UBYTE*)ptr + lzssheader.SizeFile - lzssheader.CompressedSizeFile + RECOVER_AREA ;
|
||||
Read( handle, ptrdecomp, lzssheader.CompressedSizeFile ) ;
|
||||
Expand( ptrdecomp, ptr, lzssheader.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
Close( handle ) ;
|
||||
return 0 ; /* UnKnown version */
|
||||
}
|
||||
|
||||
Close( handle ) ;
|
||||
|
||||
HQR_Flag = TRUE ; // indicate loaded
|
||||
|
||||
ptrbloc[header->NbIndex].Index = index ;
|
||||
ptrbloc[header->NbIndex].Time = TimerRef ;
|
||||
ptrbloc[header->NbIndex].Offset = header->MaxSize - header->FreeSize ;
|
||||
ptrbloc[header->NbIndex].Size = size ;
|
||||
|
||||
header->NbIndex++ ;
|
||||
header->FreeSize -= size ;
|
||||
|
||||
// RestoreTimer() ;
|
||||
|
||||
return ptr ;
|
||||
}
|
||||
}
|
||||
|
||||
72
LIB386/LIB_SYS/HQ_R_M.C
Normal file
72
LIB386/LIB_SYS/HQ_R_M.C
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "\projet\lib386\lib_sys\adeline.h"
|
||||
#include "\projet\lib386\lib_sys\lib_sys.h"
|
||||
|
||||
#define RECOVER_AREA 500
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
typedef struct { ULONG SizeFile ;
|
||||
ULONG CompressedSizeFile ;
|
||||
WORD CompressMethod ; /* 0 stored */
|
||||
/* 1 LZS */
|
||||
} T_HEADER ;
|
||||
|
||||
void Expand( void *ptrsourcecomp, void *ptrblocdest, ULONG sizefile ) ;
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
LONG HQRM_Load( UBYTE *name, UWORD index, void **ptrptr )
|
||||
{
|
||||
LONG handle ;
|
||||
UWORD nbbloc ;
|
||||
ULONG buffer ;
|
||||
ULONG seekindex ;
|
||||
// UBYTE *ptrbloc ;
|
||||
UBYTE *ptrdecomp ;
|
||||
T_HEADER header ;
|
||||
|
||||
handle = OpenRead( name ) ;
|
||||
if( !handle ) return FALSE ;
|
||||
|
||||
Read( handle, &buffer, 4L ) ;
|
||||
nbbloc = (UWORD)(buffer / 4L) ;
|
||||
|
||||
if( index >= nbbloc ) return FALSE ;
|
||||
|
||||
Seek( handle, index * 4L, SEEK_START ) ;
|
||||
Read( handle, &seekindex, 4L ) ;
|
||||
|
||||
Seek( handle, seekindex, SEEK_START ) ;
|
||||
Read( handle, &header, sizeof( header ) ) ;
|
||||
|
||||
if( !HQM_Alloc( header.SizeFile, ptrptr ) ) // il y a deja 500 de plus
|
||||
{
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
switch( header.CompressMethod )
|
||||
{
|
||||
case 0: /* Stored */
|
||||
Read( handle, *ptrptr, header.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
case 1: /* LZS */
|
||||
ptrdecomp = (UBYTE*)(*ptrptr) + header.SizeFile - header.CompressedSizeFile + RECOVER_AREA ;
|
||||
Read( handle, ptrdecomp, header.CompressedSizeFile ) ;
|
||||
Expand( ptrdecomp, *ptrptr, header.SizeFile ) ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
HQM_Free( *ptrptr ) ;
|
||||
return FALSE ; /* UnKnown version */
|
||||
}
|
||||
|
||||
Close( handle ) ;
|
||||
|
||||
return header.SizeFile ;
|
||||
}
|
||||
|
||||
124
LIB386/LIB_SYS/KEYB.C
Normal file
124
LIB386/LIB_SYS/KEYB.C
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
#include "\projet\lib386\lib_sys\adeline.h"
|
||||
#include "\projet\lib386\lib_sys\lib_sys.h"
|
||||
#include "\projet\lib386\lib_svga\lib_svga.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dos.h>
|
||||
#include <i86.h>
|
||||
|
||||
extern UWORD Old_PM09_Sel ;
|
||||
extern ULONG Old_PM09_Off ;
|
||||
|
||||
#ifdef KEYB_REAL
|
||||
UWORD Old_RM09_Seg ;
|
||||
ULONG Old_RM09_Off ;
|
||||
#endif
|
||||
|
||||
extern void __interrupt NewIntPM09(void) ;
|
||||
|
||||
//#define int15
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
void InitKeyboard()
|
||||
{
|
||||
union REGS r ;
|
||||
struct SREGS sr ;
|
||||
void far *fh ;
|
||||
void *ptrealproc ;
|
||||
|
||||
/*----- Save Old Protected Mode Vector 09 ------*/
|
||||
#ifdef int15
|
||||
r.x.eax = 0x3515 ;/* Function 35h, for Int 9 */
|
||||
#else
|
||||
r.x.eax = 0x3509 ;/* Function 35h, for Int 9 */
|
||||
#endif
|
||||
sr.ds = sr.es = 0 ;/* Security (kill the cat) */
|
||||
int386x( 0x21, &r, &r, &sr ) ;/* Call Int 21 */
|
||||
Old_PM09_Sel = (UWORD)sr.es ;/* ES:EBX=Old Interrupt 09 */
|
||||
Old_PM09_Off = r.x.ebx ;
|
||||
|
||||
#ifdef KEYB_REAL
|
||||
/*----- Save Old Real Mode Vector 09 -----------*/
|
||||
r.x.eax = 0x0200 ;/* DPMI Get Real Mode Vect */
|
||||
r.h.bl = 0x09 ;/* Interrupt Number */
|
||||
int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
Old_RM09_Seg = (UWORD)r.x.ecx ;/* CX:DX=Old Interrupt 09 */
|
||||
Old_RM09_Off = (UWORD)r.x.edx ;
|
||||
|
||||
/*----- Create 128 Byte under First Meg for NewIntRM09 in Real Mode ----*/
|
||||
ptrealproc = DosMalloc(512) ;/* Prog will be copied here*/
|
||||
memcpy( ptrealproc, (void*)NewIntRM09, 512 ) ;
|
||||
#endif
|
||||
/*----- Install New Protected Vector 09 --------*/
|
||||
#ifdef int15
|
||||
r.x.eax = 0x2515 ;/* Function 25h for int 09 */
|
||||
#else
|
||||
r.x.eax = 0x2509 ;/* Function 25h for int 09 */
|
||||
#endif
|
||||
fh = (void far*)NewIntPM09 ;/* Get far Pointer */
|
||||
r.x.edx = FP_OFF( fh ) ;/* Get Offset */
|
||||
sr.ds = FP_SEG( fh ) ;/* Get Segment */
|
||||
sr.es = 0 ;/* Security ( ... ) */
|
||||
int386x( 0x21, &r, &r, &sr ) ;/* Invoke DPMI */
|
||||
|
||||
#ifdef KEYB_REAL
|
||||
/*----- Install New Real Vector 09 -------------*/
|
||||
r.x.eax = 0x0201 ;/* DPMI Set Real Mode Vect */
|
||||
r.h.bl = 0x09 ;/* Interrupt Number */
|
||||
r.x.ecx = GetRealSeg(ptrealproc);/* Get Segment of ptreal */
|
||||
r.x.edx = GetRealOff(ptrealproc);/* Get Offset of ptreal */
|
||||
int386( 0x31, &r, &r ) ;
|
||||
#endif
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
void ClearKeyboard()
|
||||
{
|
||||
union REGS r ;
|
||||
struct SREGS sr ;
|
||||
|
||||
/*----- Restore Old Protected Vector 09 --------*/
|
||||
#ifdef int15
|
||||
r.x.eax = 0x2515 ;/* Set Vector Interupt PM09*/
|
||||
#else
|
||||
r.x.eax = 0x2509 ;/* Set Vector Interupt PM09*/
|
||||
#endif
|
||||
r.x.edx = Old_PM09_Off ;/* Adr Old Interrupt 09 */
|
||||
sr.ds = Old_PM09_Sel ;
|
||||
sr.es = 0 ;/* ... (...) */
|
||||
int386x( 0x21, &r, &r, &sr ) ;/* Invoke int 21 */
|
||||
|
||||
#ifdef KEYB_REAL
|
||||
/*----- Restore Old Real Vector 08--------------*/
|
||||
r.x.eax = 0x0201 ;/* DPMI Set Real Mode Vect */
|
||||
r.h.bl = 0x09 ;/* Interrupt Number 09 */
|
||||
r.x.ecx = (ULONG)Old_RM09_Seg ;/* Old Segment Interrupt */
|
||||
r.x.edx = (ULONG)Old_RM09_Off ;/* Old Offset Interrupt */
|
||||
int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
#endif
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
436
LIB386/LIB_SYS/KEYBOARD.ASM
Normal file
436
LIB386/LIB_SYS/KEYBOARD.ASM
Normal file
@@ -0,0 +1,436 @@
|
||||
;/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
; Û Üß Ûßßßß Û Üß ÛßßÛ ÛßßßÛ ÛßßßÛ ÛßßßÛ ÛßßßÜ
|
||||
; ÛÛßÜ ÛÛßß ÛÛß ÛÛßßÛ ÛÛ Û ÛÛßßÛ ÛÛßÛß ÛÛ Û
|
||||
; ßß ß ßßßßß ßß ßßßßß ßßßßß ßß ß ßß ß ßßßß
|
||||
; *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
;
|
||||
;/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
.386p
|
||||
|
||||
.model SMALL, SYSCALL
|
||||
|
||||
KB_DATA equ 60H
|
||||
|
||||
;int15 equ 1
|
||||
|
||||
;/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
.DATA
|
||||
|
||||
public NoLanguage Key
|
||||
public NoLanguage _Key
|
||||
public NoLanguage Joy
|
||||
public NoLanguage Fire
|
||||
public NoLanguage FuncKey
|
||||
public NoLanguage AsciiMode
|
||||
public NoLanguage Old_PM09_Off
|
||||
public NoLanguage Old_PM09_Sel
|
||||
|
||||
|
||||
NoAscii db 0
|
||||
|
||||
Key dw 00
|
||||
_Key dw 00
|
||||
FuncKey dw 00
|
||||
Joy dw 00
|
||||
Fire dw 00
|
||||
AsciiMode dw 00
|
||||
|
||||
|
||||
NB_SPECIAL_KEY equ 29
|
||||
|
||||
TabSpecialKey db 72 ; UP
|
||||
db 80 ; DOWN
|
||||
db 75 ; LEFT
|
||||
db 77 ; RIGHT Joy
|
||||
db 71 ; UP LEFT
|
||||
db 73 ; UP RIGHT
|
||||
db 81 ; DOWN RIGHT
|
||||
db 79 ; DOWN LEFT
|
||||
|
||||
db 57 ; space
|
||||
db 28 ; return
|
||||
db 29 ; CTRL
|
||||
db 56 ; ALT
|
||||
db 83 ; SUPPR
|
||||
db 42 ; SHIFT_LEFT
|
||||
db 54 ; SHIFT_RIGHT
|
||||
|
||||
db 59 ; F1
|
||||
db 60 ; F2
|
||||
db 61 ; F3
|
||||
db 62 ; F4
|
||||
db 63 ; F5
|
||||
db 64 ; F6
|
||||
db 65 ; F7
|
||||
db 66 ; F8
|
||||
db 67 ; F9
|
||||
db 68 ; F10
|
||||
db 87 ; F11
|
||||
db 88 ; F12
|
||||
|
||||
db 42
|
||||
db 0 ; ??? code cursor
|
||||
|
||||
comment @
|
||||
|
||||
TabSpecialCount db 00 ; UP
|
||||
db 00 ; DOWN
|
||||
db 00 ; LEFT
|
||||
db 00 ; RIGHT Joy
|
||||
db 00 ; UP LEFT
|
||||
db 00 ; UP RIGHT
|
||||
db 00 ; DOWN RIGHT
|
||||
db 00 ; DOWN LEFT
|
||||
|
||||
db 00 ; space
|
||||
db 00 ; return
|
||||
db 00 ; CTRL
|
||||
db 00 ; ALT
|
||||
db 00 ; SUPPR
|
||||
db 00 ; SHIFT_LEFT
|
||||
db 00 ; SHIFT_RIGHT
|
||||
|
||||
db 00 ; F1
|
||||
db 00 ; F2
|
||||
db 00 ; F3
|
||||
db 00 ; F4
|
||||
db 00 ; F5
|
||||
db 00 ; F6
|
||||
db 00 ; F7
|
||||
db 00 ; F8
|
||||
db 00 ; F9
|
||||
db 00 ; F10
|
||||
db 00 ; F11
|
||||
db 00 ; F12
|
||||
|
||||
db 00
|
||||
db 00 ; ??? code cursor
|
||||
|
||||
@
|
||||
|
||||
TabSpecialFunc db 0,1 ; J_UP
|
||||
db 0,2 ; J_DOWN
|
||||
db 0,4 ; J_LEFT
|
||||
db 0,8 ; J_RIGHT Joy
|
||||
db 0,1+4 ; UP LEFT
|
||||
db 0,1+8 ; UP RIGHT
|
||||
db 0,2+8 ; DOWN RIGHT
|
||||
db 0,2+4 ; DOWN LEFT
|
||||
|
||||
db 1,1 ; Fire
|
||||
db 1,2 ; return
|
||||
db 1,4 ; ctrl
|
||||
db 1,8 ; alt
|
||||
db 1,16 ; suppr ; attention cas 224
|
||||
db 1,32 ; shift left
|
||||
db 1,32 ; shift right
|
||||
|
||||
db 2,1 ; F1
|
||||
db 2,2 ; F2
|
||||
db 2,4 ; F3
|
||||
db 2,8 ; F4
|
||||
db 2,16 ; F5
|
||||
db 2,32 ; F6
|
||||
db 2,64 ; F7
|
||||
db 2,128 ; F8
|
||||
db 3,1 ; F9
|
||||
db 3,2 ; F10
|
||||
db 3,4 ; F11
|
||||
db 3,8 ; F12
|
||||
|
||||
db 255,0 ; oublie 42
|
||||
db 255,0 ; oublie 0
|
||||
|
||||
Old_Int_09 dd 0000
|
||||
|
||||
Old_PM09_Off dd 0000
|
||||
Old_PM09_Sel dw 00
|
||||
|
||||
|
||||
FlagExtendScan db 0
|
||||
|
||||
;/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
.CODE
|
||||
|
||||
public NoLanguage NewIntPM09
|
||||
public NoLanguage GetAscii
|
||||
public NoLanguage ClearAsciiBuffer
|
||||
|
||||
;/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
NewIntPM09 PROC FAR
|
||||
|
||||
push eax
|
||||
push ecx
|
||||
push ebx
|
||||
push edi
|
||||
push ds
|
||||
push es
|
||||
|
||||
ifdef int15
|
||||
jnc back15
|
||||
|
||||
cmp ah, 4Fh
|
||||
jne back15
|
||||
endif
|
||||
|
||||
cld
|
||||
|
||||
mov cx, DGROUP
|
||||
mov ds, cx
|
||||
mov es, cx
|
||||
|
||||
comment @
|
||||
; peut etre une bonne idee mais plante le clavier sur plein de pc
|
||||
mov al, 0ADh
|
||||
out 64h, al ; disable keyboard
|
||||
@
|
||||
|
||||
ifdef int15
|
||||
|
||||
mov ah, al
|
||||
|
||||
else
|
||||
|
||||
once_again:
|
||||
in al, KB_DATA
|
||||
mov ah, al
|
||||
|
||||
endif
|
||||
|
||||
mov byte ptr[_Key], ah
|
||||
|
||||
cmp al, 224 ; code etendu
|
||||
jz doextend
|
||||
|
||||
and al, 127 ; al scancode
|
||||
|
||||
cmp al, 2Ah ; shift ?
|
||||
jnz noshift
|
||||
|
||||
cmp [FlagExtendScan], 1 ; extended shift say goodbye
|
||||
jz exit
|
||||
|
||||
noshift: mov ecx, NB_SPECIAL_KEY
|
||||
mov edi, offset TabSpecialKey
|
||||
repne scasb
|
||||
jnz nospecial
|
||||
|
||||
mov ebx, NB_SPECIAL_KEY-1
|
||||
sub ebx, ecx
|
||||
|
||||
comment @
|
||||
lea ecx, [TabSpecialCount + ebx]
|
||||
mov al, [ecx]
|
||||
|
||||
test ah, 128
|
||||
jnz decr
|
||||
|
||||
inc al
|
||||
jmp ok1
|
||||
|
||||
decr: or al, al
|
||||
jz keyup
|
||||
dec al
|
||||
jz keyup
|
||||
|
||||
keydown: and ah, 127
|
||||
jmp ok1
|
||||
keyup: or ah, 128
|
||||
ok1: mov [ecx], al
|
||||
mov al, ah
|
||||
@
|
||||
|
||||
mov bx, word ptr[ TabSpecialFunc + ebx*2 ]
|
||||
|
||||
ni0: or bl, bl
|
||||
jnz ni1
|
||||
|
||||
; code touche pour Joy CODE BL 0 : Joy
|
||||
|
||||
test ah, 128
|
||||
jnz relache0
|
||||
|
||||
or byte ptr[ Joy ], bh
|
||||
jmp exit
|
||||
|
||||
relache0: not bh
|
||||
and byte ptr[ Joy ], bh
|
||||
jmp exit
|
||||
|
||||
doextend: mov [FlagExtendScan], 1
|
||||
jmp exit2
|
||||
|
||||
; code touche pour Fire CODE BL 1 : Fire
|
||||
|
||||
ni1: dec bl
|
||||
jnz ni2
|
||||
|
||||
test ah, 128
|
||||
jnz relache1
|
||||
|
||||
or byte ptr[ Fire ], bh
|
||||
|
||||
cmp byte ptr[ Fire ], 4 + 8 + 16 ; ctrl alt suppr
|
||||
jnz exit
|
||||
|
||||
reset: mov eax, 472h
|
||||
mov word ptr[eax], 1234h ; don'check mem but reset it
|
||||
|
||||
push 0FFFFh
|
||||
push 00000h
|
||||
retf
|
||||
|
||||
relache1: not bh
|
||||
and byte ptr[ Fire ], bh
|
||||
jmp short exit
|
||||
|
||||
ni2: dec bl
|
||||
jnz ni3
|
||||
|
||||
; code touche pour FuncKey CODE BL 2 : FuncKey 1-8
|
||||
|
||||
test ah, 128
|
||||
jnz relache2
|
||||
|
||||
or byte ptr[ FuncKey ], bh
|
||||
jmp short nospecial
|
||||
|
||||
relache2: not bh
|
||||
and byte ptr[ FuncKey ], bh
|
||||
jmp short nospecial
|
||||
|
||||
ni3: dec bl
|
||||
jnz ni4
|
||||
|
||||
; code touche pour FuncKey CODE BL 3 : FuncKey 9-12
|
||||
|
||||
test ah, 128
|
||||
jnz relache3
|
||||
|
||||
or byte ptr[ FuncKey+1 ], bh
|
||||
jmp short nospecial
|
||||
|
||||
relache3: not bh
|
||||
and byte ptr[ FuncKey+1 ],bh
|
||||
jmp short nospecial
|
||||
|
||||
ni4: jmp short exit ; CODE BL 255 : oublie token
|
||||
|
||||
nospecial: test ah, 128
|
||||
jnz relache5
|
||||
|
||||
mov byte ptr[ Key ], al
|
||||
jmp short exit
|
||||
|
||||
relache5: mov byte ptr[ Key ], 0
|
||||
|
||||
exit: mov [FlagExtendScan], 0
|
||||
|
||||
exit2:
|
||||
|
||||
ifdef int15
|
||||
|
||||
cmp byte ptr[ AsciiMode ], 0
|
||||
jne back15
|
||||
|
||||
and dword ptr[esp+8*4], 0FFFFFFFEh
|
||||
back15:
|
||||
pop es
|
||||
pop ds
|
||||
pop edi
|
||||
pop ebx
|
||||
pop ecx
|
||||
pop eax
|
||||
iret
|
||||
|
||||
else
|
||||
|
||||
in al, 64h
|
||||
test al, 1
|
||||
jnz once_again
|
||||
|
||||
cmp byte ptr[ AsciiMode ], 0
|
||||
jnz ascii
|
||||
|
||||
;--------------
|
||||
mov al, 20H
|
||||
out 20H, al
|
||||
|
||||
comment @
|
||||
; peut etre une bonne idee mais plante le clavier sur plein de pc
|
||||
mov al, 0AEh
|
||||
out 64h, al ; enable keyboard
|
||||
@
|
||||
pop es
|
||||
pop ds
|
||||
pop edi
|
||||
pop ebx
|
||||
pop ecx
|
||||
pop eax
|
||||
iretd
|
||||
|
||||
ascii:
|
||||
comment @
|
||||
; peut etre une bonne idee mais plante le clavier sur plein de pc
|
||||
mov al, 0AEh
|
||||
out 64h, al ; enable keyboard
|
||||
@
|
||||
xor eax, eax
|
||||
mov ecx, [Old_PM09_Off]
|
||||
mov ax, [Old_PM09_Sel]
|
||||
|
||||
xchg ecx, [esp+4*4]
|
||||
xchg eax, [esp+5*4]
|
||||
|
||||
pop es
|
||||
pop ds
|
||||
pop edi
|
||||
pop ebx
|
||||
retf
|
||||
|
||||
endif
|
||||
|
||||
NewIntPM09 endp
|
||||
|
||||
;/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
GetAscii proc
|
||||
|
||||
mov ah, 1
|
||||
int 16h
|
||||
jz nokey
|
||||
mov ah, 0
|
||||
int 16h
|
||||
ret
|
||||
|
||||
nokey: xor ax, ax
|
||||
ret
|
||||
|
||||
GetAscii endp
|
||||
|
||||
;/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
ClearAsciiBuffer proc
|
||||
|
||||
cab0: mov ah, 1
|
||||
int 16h
|
||||
jz nokey1
|
||||
mov ah, 0
|
||||
int 16h
|
||||
jmp cab0
|
||||
nokey1: ret
|
||||
|
||||
ClearAsciiBuffer endp
|
||||
|
||||
;/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
; The
|
||||
End
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
23
LIB386/LIB_SYS/LIB_SYS.ASH
Normal file
23
LIB386/LIB_SYS/LIB_SYS.ASH
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; LIB_SYS.ASH
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
extrn NoLanguage TimerRef:DWORD
|
||||
extrn NoLanguage NbFramePerSecond:WORD
|
||||
extrn NoLanguage WaitNbTicks:WORD
|
||||
extrn NoLanguage CmptFrame:WORD
|
||||
extrn NoLanguage Cmpt_18:WORD
|
||||
|
||||
;TIMERREF equ 0
|
||||
;NBFRAMEPERSECOND equ 4
|
||||
;WAITNBTICKS equ 6
|
||||
;CMPTFRAME equ 8
|
||||
;CMPT_18 equ 10
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
346
LIB386/LIB_SYS/LIB_SYS.H
Normal file
346
LIB386/LIB_SYS/LIB_SYS.H
Normal file
@@ -0,0 +1,346 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
|
||||
Û Üß Ûßßßß Û Üß ÛßßÛ ÛßßßÛ ÛßßßÛ ÛßßßÛ ÛßßßÜ
|
||||
ÛÛßÜ ÛÛßß ÛÛß ÛÛßßÛ ÛÛ Û ÛÛßßÛ ÛÛßÛß ÛÛ Û
|
||||
ßß ß ßßßßß ßß ßßßßß ßßßßß ßß ß ßß ß ßßßß
|
||||
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
#ifdef WATCOM9
|
||||
#pragma library ("f:\projet\lib386\lib_sys\lb9_sys.lib");
|
||||
#else
|
||||
#pragma library ("f:\projet\lib386\lib_sys\lib_sys.lib");
|
||||
#endif
|
||||
|
||||
#include "f:\projet\lib386\lib_sys\dll.h"
|
||||
|
||||
extern volatile UWORD Key ; /* scan code keyboard */
|
||||
|
||||
#define K_ESC 1
|
||||
|
||||
#define K_F1 59
|
||||
#define K_F2 60
|
||||
#define K_F3 61
|
||||
#define K_F4 62
|
||||
#define K_F5 63
|
||||
#define K_F6 64
|
||||
#define K_F7 65
|
||||
#define K_F8 66
|
||||
#define K_F9 67
|
||||
#define K_F10 68
|
||||
#define K_F11 87
|
||||
#define K_F12 88
|
||||
|
||||
|
||||
#define K_PLUS 78
|
||||
#define K_MOINS 74
|
||||
#define K_BACKSPACE 14
|
||||
#define K_TAB 15
|
||||
#define K_NUMLOCK 69
|
||||
|
||||
#define K_A 16
|
||||
#define K_B 48
|
||||
#define K_C 46
|
||||
#define K_D 32
|
||||
#define K_E 18
|
||||
#define K_F 33
|
||||
#define K_G 34
|
||||
#define K_H 35
|
||||
#define K_I 23
|
||||
#define K_J 36
|
||||
#define K_K 37
|
||||
#define K_L 38
|
||||
#define K_M 39
|
||||
#define K_N 49
|
||||
#define K_O 24
|
||||
#define K_P 25
|
||||
#define K_Q 30
|
||||
#define K_R 19
|
||||
#define K_S 31
|
||||
#define K_T 20
|
||||
#define K_U 22
|
||||
#define K_V 47
|
||||
#define K_W 44
|
||||
#define K_X 45
|
||||
#define K_Y 21
|
||||
#define K_Z 17
|
||||
|
||||
#define K_1 2
|
||||
#define K_2 3
|
||||
#define K_3 4
|
||||
#define K_4 5
|
||||
#define K_5 6
|
||||
#define K_6 7
|
||||
#define K_7 8
|
||||
#define K_8 9
|
||||
#define K_9 10
|
||||
#define K_10 11
|
||||
|
||||
extern volatile UWORD FuncKey ; /* mask bit touches fonctions */
|
||||
|
||||
#define FK_F1 1
|
||||
#define FK_F2 2
|
||||
#define FK_F3 4
|
||||
#define FK_F4 8
|
||||
#define FK_F5 16
|
||||
#define FK_F6 32
|
||||
#define FK_F7 64
|
||||
#define FK_F8 128
|
||||
#define FK_F9 256
|
||||
#define FK_F10 512
|
||||
#define FK_F11 1024
|
||||
#define FK_F12 2048
|
||||
|
||||
extern volatile UWORD Joy ; /* emulation cursor key */
|
||||
|
||||
#define J_UP 1
|
||||
#define J_DOWN 2
|
||||
#define J_LEFT 4
|
||||
#define J_RIGHT 8
|
||||
|
||||
extern volatile UWORD Fire ; /* emulation touches fire */
|
||||
|
||||
#define F_SPACE 1
|
||||
#define F_RETURN 2
|
||||
#define F_CTRL 4
|
||||
#define F_ALT 8
|
||||
#define F_SUPPR 16
|
||||
#define F_SHIFT 32
|
||||
|
||||
void InitKeyboard(void) ; /* init de Key Joy Fire */
|
||||
void ClearKeyboard(void) ;
|
||||
|
||||
UWORD GetAscii(void) ; /* retourne code ascii dos */
|
||||
void ClearAsciiBuffer(void) ; /* vide buffer dos */
|
||||
|
||||
extern UWORD AsciiMode ; /* TRUE/FALSE gestion buffer keyboard */
|
||||
|
||||
#define A_F1 0x3B00
|
||||
#define A_F2 0x3C00
|
||||
#define A_F3 0x3D00
|
||||
#define A_F4 0x3E00
|
||||
#define A_F5 0x3F00
|
||||
#define A_F6 0x4000
|
||||
#define A_F7 0x4100
|
||||
#define A_F8 0x4200
|
||||
#define A_F9 0x4300
|
||||
#define A_F10 0x4400
|
||||
|
||||
#define A_ESC 0x011B
|
||||
|
||||
#define A_UP 0x4800
|
||||
#define A_DOWN 0x5000
|
||||
#define A_LEFT 0x4B00
|
||||
#define A_RIGHT 0x4D00
|
||||
|
||||
#define A_HOME 0x4700
|
||||
#define A_END 0x4F00
|
||||
#define A_PGUP 0x4900
|
||||
#define A_PGDN 0x5100
|
||||
|
||||
#define A_SPACE 0x3920
|
||||
#define A_RETURN 0x1C0D
|
||||
|
||||
#define A_N_PLUS 0x4E2B
|
||||
#define A_N_MOINS 0x4A2D
|
||||
|
||||
#define A_BACKSPACE 0x0E08
|
||||
#define A_SUPPR 0x5300
|
||||
|
||||
#define A_CARRE 0x29FD
|
||||
|
||||
#define A_1 0x226
|
||||
#define A_2 0x382
|
||||
#define A_3 0x422
|
||||
#define A_4 0x527
|
||||
#define A_5 0x628
|
||||
#define A_6 0x77D
|
||||
#define A_7 0x88A
|
||||
#define A_8 0x95F
|
||||
#define A_9 0xA87
|
||||
#define A_0 0xB85
|
||||
|
||||
#define A_A 0x1061
|
||||
#define A_B 0x3062
|
||||
#define A_C 0x2e63
|
||||
#define A_D 0x2064
|
||||
#define A_E 0x1265
|
||||
#define A_F 0x2166
|
||||
#define A_G 0x2267
|
||||
#define A_H 0x2368
|
||||
#define A_I 0x1769
|
||||
#define A_J 0x246a
|
||||
#define A_K 0x256b
|
||||
#define A_L 0x266c
|
||||
#define A_M 0x276d
|
||||
#define A_N 0x316e
|
||||
#define A_O 0x186f
|
||||
#define A_P 0x1970
|
||||
#define A_Q 0x1e71
|
||||
#define A_R 0x1372
|
||||
#define A_S 0x1f73
|
||||
#define A_T 0x1474
|
||||
#define A_U 0x1675
|
||||
#define A_V 0x2f76
|
||||
#define A_W 0x2c77
|
||||
#define A_X 0x2d78
|
||||
#define A_Y 0x1579
|
||||
#define A_Z 0x117a
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define SEEK_START 0
|
||||
#define SEEK_CURRENT 1
|
||||
#define SEEK_END 2
|
||||
|
||||
#define Rnd(n) (rand()%n)
|
||||
|
||||
#define GetRealSeg(p) ((((ULONG)(p)) >> 4) & 0xFFFF )
|
||||
#define GetRealOff(p) (((ULONG)(p)) & 0xF )
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* FILES.C */
|
||||
void AddExt( char *name, char *ext ) ;
|
||||
LONG OpenRead( char *name ) ;
|
||||
LONG OpenWrite( char *name ) ;
|
||||
LONG OpenReadWrite( char *name ) ;
|
||||
ULONG Read( LONG handle, void *buffer, ULONG lenread ) ;
|
||||
ULONG Write( LONG handle, void *buffer, ULONG lenwrite ) ;
|
||||
void Close( LONG handle ) ;
|
||||
LONG Seek( LONG handle, LONG position,LONG mode ) ;
|
||||
LONG Delete( char *name ) ;
|
||||
ULONG FileSize( char *name ) ;
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* LOADSAVE.C */
|
||||
ULONG Load( char *name, void *buffer ) ;
|
||||
ULONG Save( char *name,void *buffer, ULONG size ) ;
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* MALLOC.C */
|
||||
|
||||
extern LONG ModeTraceMalloc ;
|
||||
|
||||
void *DosMalloc( LONG size, ULONG *handle ) ;
|
||||
void DosFree( ULONG handle ) ;
|
||||
|
||||
void *SmartMalloc( LONG lenalloc ) ;
|
||||
void *Malloc( LONG lenalloc ) ;
|
||||
|
||||
void Free( void *buffer ) ;
|
||||
void *Mshrink( void *buffer, ULONG taille ) ;
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* LOADMALL.C */
|
||||
|
||||
extern ULONG LoadMallocFileSize ;
|
||||
|
||||
void *LoadMalloc( char *name ) ;
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* TIMER.C */
|
||||
|
||||
/*
|
||||
extern UBYTE *BufferGlobal ;
|
||||
|
||||
#define TimerRef (*((ULONG *)(BufferGlobal+0)))
|
||||
#define NbFramePerSecond (*((UWORD *)(BufferGlobal+4)))
|
||||
#define WaitNbTicks (*((UWORD *)(BufferGlobal+6)))
|
||||
#define CmptFrame (*((UWORD *)(BufferGlobal+8)))
|
||||
#define Cmpt_18 (*((UWORD *)(BufferGlobal+10)))
|
||||
*/
|
||||
|
||||
extern volatile ULONG TimerSystem ;
|
||||
extern volatile ULONG TimerRef ;
|
||||
extern UWORD NbFramePerSecond ;
|
||||
extern UWORD WaitNbTicks ;
|
||||
extern UWORD CmptFrame ;
|
||||
extern UWORD Cmpt_18 ;
|
||||
|
||||
void SetTimer( WORD divisor ) ;
|
||||
WORD GetTimer() ;
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* DEF_FILE.C */
|
||||
|
||||
LONG Def_WriteString( UBYTE *deffic, UBYTE *indentificateur, UBYTE *string ) ;
|
||||
LONG Def_WriteValue( UBYTE *deffic, UBYTE *indentificateur, LONG value ) ;
|
||||
|
||||
UBYTE *Def_ReadString( UBYTE *deffic, UBYTE *indentificateur ) ;
|
||||
LONG Def_ReadValue( UBYTE *deffic, UBYTE *indentificateur ) ;
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* BUFFER_A.ASM */
|
||||
void RazMem( void *pt, ULONG size ) ;
|
||||
void MovMem( void *pt0, void *pt1, ULONG size ) ;
|
||||
LONG CompBuf( void *pt0, void *pt1, ULONG size ) ;
|
||||
|
||||
char *Itoa( LONG value ) ;
|
||||
|
||||
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* HQ_Ressource */
|
||||
|
||||
extern WORD HQR_Flag ; // flag de load done par HQR_Get
|
||||
|
||||
|
||||
typedef struct { char Name[128] ;
|
||||
ULONG MaxSize ;
|
||||
ULONG FreeSize ;
|
||||
UWORD MaxIndex ;
|
||||
UWORD NbIndex ;
|
||||
UBYTE *Buffer ; } T_HQR_HEADER ;
|
||||
|
||||
typedef struct { UWORD Index ;
|
||||
ULONG Offset ;
|
||||
ULONG Size ;
|
||||
ULONG Time ; } T_HQR_BLOC ;
|
||||
|
||||
void *LoadMalloc_HQR( UBYTE *name, UWORD index ) ;
|
||||
ULONG Load_HQR( UBYTE *name, void *ptrdest, UWORD index ) ;
|
||||
ULONG Size_HQR( char *name, UWORD index ) ;
|
||||
|
||||
T_HQR_HEADER *HQR_Init_Ressource( char *hqrname,
|
||||
ULONG maxsize,
|
||||
UWORD maxindex ) ;
|
||||
|
||||
LONG HQR_Change_Ressource( T_HQR_HEADER *header, char *newhqrname ) ;
|
||||
void HQR_Reset_Ressource( T_HQR_HEADER *header ) ;
|
||||
void HQR_Free_Ressource( T_HQR_HEADER *header ) ;
|
||||
|
||||
void *HQR_Get( T_HQR_HEADER *header, UWORD index ) ;
|
||||
void *HQR_GetSample( T_HQR_HEADER *header, UWORD index ) ;
|
||||
|
||||
UWORD HQR_Del_Bloc( T_HQR_HEADER *header, WORD index ) ;
|
||||
UWORD HQR_Del_Bloc_Sample( T_HQR_HEADER *header, WORD index ) ;
|
||||
T_HQR_BLOC *HQR_GiveIndex( UWORD index, UWORD nbindex, void *ptrlist ) ;
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* HQ_MEM.C */
|
||||
|
||||
extern ULONG Size_HQM_Memory ;
|
||||
extern ULONG Size_HQM_Free ;
|
||||
|
||||
LONG HQM_Init_Memory( ULONG size ) ;
|
||||
void HQM_Clear_Memory() ;
|
||||
LONG HQM_Alloc( ULONG size, void **ptr ) ;
|
||||
void HQM_Free_All() ;
|
||||
void HQM_Free( void *ptr ) ;
|
||||
LONG HQM_Check() ;
|
||||
void HQM_Shrink_Last( void *ptr, ULONG newsize ) ;
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* HQ_R_M.C */
|
||||
|
||||
LONG HQRM_Load( UBYTE *name, UWORD index, void **ptrptr ) ;
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* ADELINE.C */
|
||||
|
||||
#define INIT_SVGA 1
|
||||
#define INIT_WAVE 2
|
||||
#define INIT_MIDI 4
|
||||
#define INIT_MIXER 8
|
||||
#define INIT_VESA 16
|
||||
#define INIT_MCGA 32
|
||||
|
||||
void InitAdelineSystem( char *name, LONG inits ) ;
|
||||
void ClearAdelineSystem() ;
|
||||
|
||||
extern char PathConfigFile[] ;
|
||||
extern char MidiFM ;
|
||||
39
LIB386/LIB_SYS/LIB_SYS.MAK
Normal file
39
LIB386/LIB_SYS/LIB_SYS.MAK
Normal file
@@ -0,0 +1,39 @@
|
||||
# name the compiler
|
||||
!ifdef %HOME
|
||||
CC = c:\compil\watcom10\binb\wcc386
|
||||
WL = c:\compil\watcom10\binb\wlib
|
||||
!else
|
||||
CC = f:\compil\watcom10\binb\wcc386
|
||||
WL = f:\compil\watcom10\binb\wlib
|
||||
!endif
|
||||
|
||||
ASMFLAGS = /m2 /mx /z /p /q /t /jMASM51 /jQUIRKS
|
||||
CFLAGS = /oaxet /zp2 /s /4s /x /c /l=dos4g /zq
|
||||
LIBFLAGS = /c /q /b /n
|
||||
|
||||
OBJETS1 = FILES.obj MALLOC.obj LOADMALL.obj LOADSAVE.obj DEF_FILE.obj
|
||||
OBJETS2 = System.obj Timer_a.obj Timer.obj Buffer_A.obj DIVERS.obj
|
||||
OBJETS3 = Keyb.obj Keyboard.obj Expand.obj HQ_ress.obj hqr.obj
|
||||
OBJETS4 = DllLoad.obj Adeline.obj HQ_mem.obj HQ_r_m.obj
|
||||
|
||||
LIB = LIB_SYS
|
||||
|
||||
$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4)
|
||||
|
||||
@echo $(OBJETS1) > clibmak.rsp
|
||||
@echo $(OBJETS2) >> clibmak.rsp
|
||||
@echo $(OBJETS3) >> clibmak.rsp
|
||||
@echo $(OBJETS4) >> clibmak.rsp
|
||||
|
||||
@$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp
|
||||
@del clibmak.rsp
|
||||
@prntitre G "$(LIB)"
|
||||
|
||||
.asm.obj:
|
||||
@PRNTITRE M "$*.ASM"
|
||||
@TASM $(ASMFLAGS) $*;
|
||||
|
||||
.c.obj:
|
||||
@PRNTITRE M "$*.C"
|
||||
@$( $(CFLAGS) $*
|
||||
|
||||
48
LIB386/LIB_SYS/LOADMALL.C
Normal file
48
LIB386/LIB_SYS/LOADMALL.C
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
MALLOC (c) Adeline 1993
|
||||
|
||||
Functions:
|
||||
|
||||
- Malloc
|
||||
- Free
|
||||
- Mshrink
|
||||
*/
|
||||
|
||||
#include <i86.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "adeline.h"
|
||||
#include "lib_sys.h"
|
||||
|
||||
ULONG LoadMallocFileSize ;
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
void *LoadMalloc( char *name )
|
||||
{
|
||||
LONG handle ;
|
||||
ULONG sizer ;
|
||||
void *pt ;
|
||||
|
||||
LoadMallocFileSize = FileSize( name ) ;
|
||||
if ( !LoadMallocFileSize ) return( 0 ) ;
|
||||
|
||||
pt = Malloc( LoadMallocFileSize ) ;
|
||||
if ( pt == 0 ) return( 0 ) ;
|
||||
|
||||
handle = OpenRead( name ) ;
|
||||
if ( !handle) return( 0 ) ;
|
||||
|
||||
sizer = Read( handle, pt, LoadMallocFileSize );
|
||||
if ( sizer != LoadMallocFileSize )
|
||||
{
|
||||
Close( handle ) ;
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
Close( handle ) ;
|
||||
return( pt ) ;
|
||||
}
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
58
LIB386/LIB_SYS/LOADSAVE.C
Normal file
58
LIB386/LIB_SYS/LOADSAVE.C
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
LOADSAVE (c) Adeline 1993
|
||||
|
||||
Functions:
|
||||
|
||||
- Load
|
||||
- Save
|
||||
*/
|
||||
|
||||
#include <i86.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "adeline.h"
|
||||
#include "lib_sys.h"
|
||||
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
ULONG Load( char *name, void *buffer )
|
||||
{
|
||||
LONG handle ;
|
||||
ULONG size ;
|
||||
|
||||
size = FileSize( name ) ;
|
||||
if ( !size ) return(0L) ;
|
||||
|
||||
handle = OpenRead( name ) ;
|
||||
if ( handle )
|
||||
{
|
||||
size = Read( handle, buffer, size ) ;
|
||||
Close( handle ) ;
|
||||
return( size ) ;
|
||||
}
|
||||
return( 0L );
|
||||
}
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
ULONG Save( char *name, void *buffer, ULONG size )
|
||||
{
|
||||
LONG handle ;
|
||||
ULONG nbwrote ;
|
||||
|
||||
handle = OpenWrite( name ) ;
|
||||
if( handle )
|
||||
{
|
||||
nbwrote = Write( handle, buffer, size ) ;
|
||||
Close( handle ) ;
|
||||
if( nbwrote != size ) return FALSE ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
60
LIB386/LIB_SYS/MAKEFILE
Normal file
60
LIB386/LIB_SYS/MAKEFILE
Normal file
@@ -0,0 +1,60 @@
|
||||
# name the compiler
|
||||
!ifdef %HOME
|
||||
!ifeq WATCOM9 yes
|
||||
CC = c:\compil\watcom\bin\wcc386p
|
||||
WL = c:\compil\watcom\binb\wlib
|
||||
!else
|
||||
CC = c:\compil\watcom10\binb\wcc386
|
||||
WL = c:\compil\watcom10\binb\wlib
|
||||
!endif
|
||||
!else
|
||||
!ifeq WATCOM9 yes
|
||||
CC = f:\compil\watcom\bin\wcc386p
|
||||
WL = f:\compil\watcom\binb\wlib
|
||||
!else
|
||||
CC = f:\compil\watcom10\binb\wcc386
|
||||
WL = f:\compil\watcom10\binb\wlib
|
||||
!endif
|
||||
!endif
|
||||
|
||||
ASM = ml
|
||||
|
||||
!ifeq WATCOM9 yes
|
||||
CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9
|
||||
!else
|
||||
CFLAGS = /oeaxt /zp2 /5s /zq /s
|
||||
!endif
|
||||
LFLAGS = /c /q /b /n
|
||||
#AFLAGS = /m2 /mx /z /p /q /t /jMASM51 /jQUIRKS
|
||||
AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=;
|
||||
|
||||
.SILENT
|
||||
|
||||
OBJETS1 = FILES.obj MALLOC.obj LOADMALL.obj LOADSAVE.obj DEF_FILE.obj
|
||||
OBJETS2 = System.obj Timer_a.obj Timer.obj Buffer_A.obj DIVERS.obj
|
||||
OBJETS3 = Keyb.obj Keyboard.obj Expand.obj HQ_ress.obj hqr.obj
|
||||
OBJETS4 = DllLoad.obj Adeline.obj HQ_mem.obj HQ_r_m.obj Files_A.obj
|
||||
|
||||
!ifeq WATCOM9 yes
|
||||
LIB = LB9_SYS
|
||||
!else
|
||||
LIB = LIB_SYS
|
||||
!endif
|
||||
|
||||
$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4)
|
||||
@echo $(OBJETS1) > clibmak.rsp
|
||||
@echo $(OBJETS2) >> clibmak.rsp
|
||||
@echo $(OBJETS3) >> clibmak.rsp
|
||||
@echo $(OBJETS4) >> clibmak.rsp
|
||||
|
||||
@$(WL) $(LFLAGS) $(LIB) @clibmak.rsp
|
||||
@del clibmak.rsp
|
||||
@prntitre G "$(LIB)"
|
||||
|
||||
.c.obj :
|
||||
PRNTITRE M "$*.C"
|
||||
$(CC) $^& $(CFLAGS)
|
||||
|
||||
.asm.obj :
|
||||
PRNTITRE M "$*.ASM"
|
||||
$(ASM) $(AFLAGS) $^&.ASM
|
||||
326
LIB386/LIB_SYS/MALLOC.C
Normal file
326
LIB386/LIB_SYS/MALLOC.C
Normal file
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
MALLOC (c) Adeline 1993
|
||||
|
||||
Functions:
|
||||
|
||||
- Malloc
|
||||
- Free
|
||||
- Mshrink
|
||||
*/
|
||||
|
||||
#include <i86.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "adeline.h"
|
||||
#include "lib_sys.h"
|
||||
|
||||
struct meminfo {
|
||||
unsigned LargestBlockAvail;
|
||||
unsigned MaxUnlockedPage;
|
||||
unsigned LargestLockablePage;
|
||||
unsigned LinAddrSpace;
|
||||
unsigned NumFreePagesAvail;
|
||||
unsigned NumPhysicalPagesFree;
|
||||
unsigned TotalPhysicalPages;
|
||||
unsigned FreeLinAddrSpace;
|
||||
unsigned SizeOfPageFile;
|
||||
unsigned Reserved[3];
|
||||
} MemInfo;
|
||||
|
||||
#define DPMI_INT 0x31
|
||||
|
||||
|
||||
// #define DEBUG_MALLOC 1
|
||||
|
||||
#ifdef DEBUG_MALLOC
|
||||
LONG ModeTraceMalloc = FALSE ;
|
||||
#endif
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* Special, Allocate Memory Under First Meg */
|
||||
void *DosMalloc( LONG size, ULONG *handle )
|
||||
{
|
||||
|
||||
/* union REGS r ;
|
||||
|
||||
r.x.eax = 0x0100 ;// Function allocate Dos Memory
|
||||
r.x.ebx =(size+15)>>4 ;// Number off Paragraphs Requested
|
||||
int386( 0x31, &r, &r ) ;// Invoke DPMI
|
||||
if( r.x.cflag )
|
||||
return(0) ;// Failed
|
||||
return( (void*)((r.x.eax & 0xFFFF) << 4 )) ;// Ok, Take this!
|
||||
*/
|
||||
union REGS r ;
|
||||
ULONG strat ;
|
||||
ULONG addr ;
|
||||
|
||||
#ifdef jhjkhjkhjlk
|
||||
r.x.eax = 0x5800 ;
|
||||
int386( 0x21, &r, &r ) ;
|
||||
strat = r.x.eax ;/* Save DOS alloc strategie */
|
||||
|
||||
r.x.eax = 0x5801 ;
|
||||
r.x.ebx = 1 ;/* Low mem, best fit */
|
||||
int386( 0x21, &r, &r ) ;/* Set alloc strategie */
|
||||
#endif
|
||||
r.x.eax = 0x0100 ;/* Function allocate Dos Memory */
|
||||
if (size == -1)
|
||||
r.x.ebx = -1 ;/*Number off Paragraphs Requested */
|
||||
else
|
||||
r.x.ebx =(size+15)>>4;/*Number off Paragraphs Requested */
|
||||
int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
|
||||
addr = 0 ;
|
||||
if (size == -1)
|
||||
{
|
||||
if( r.x.cflag )
|
||||
addr = (r.x.ebx & 0xFFFF) << 4 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !r.x.cflag )
|
||||
{
|
||||
if (handle) *handle = r.x.edx & 0xFFFF;/* DPMI selector*/
|
||||
addr = (r.x.eax & 0xFFFF) << 4;/* Ok, Take this! */
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef hjhkjhlhjk
|
||||
r.x.eax = 0x5801 ;
|
||||
r.x.ebx = strat ;/* Odl startegie */
|
||||
int386( 0x21, &r, &r ) ;/* Set alloc strategie */
|
||||
#endif
|
||||
return((void *)addr) ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
/* Special, Free Allocated Memory Under First Meg */
|
||||
void DosFree( ULONG handle )
|
||||
{
|
||||
union REGS r ;
|
||||
|
||||
r.x.eax = 0x0101 ;/* Function allocate Dos Memory */
|
||||
r.x.edx = handle ;/* DPMI Selector */
|
||||
int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
#ifdef DEBUG_MALLOC
|
||||
|
||||
LONG mymalloc( LONG lenalloc, void **memptr )
|
||||
{
|
||||
union REGS regs ;
|
||||
struct SREGS sregs ;
|
||||
UBYTE *ptr ;
|
||||
|
||||
lenalloc+=16;
|
||||
regs.x.eax = 0x00000501 ;
|
||||
regs.x.ebx = lenalloc>>16 ;
|
||||
regs.x.ecx = lenalloc & 0xFFFF ;
|
||||
sregs.es = 0 ;
|
||||
sregs.ds = 0 ;
|
||||
sregs.fs = 0 ;
|
||||
sregs.gs = 0 ;
|
||||
int386x( DPMI_INT, ®s, ®s, &sregs ) ;
|
||||
|
||||
if( regs.x.cflag )
|
||||
{
|
||||
*memptr = NULL ;
|
||||
return regs.x.eax ;
|
||||
}
|
||||
|
||||
ptr=(UBYTE *)((regs.x.ebx<<16) | (regs.x.ecx & 0xFFFF));
|
||||
|
||||
*(WORD*)(ptr+0)=(WORD)regs.x.esi ;
|
||||
*(WORD*)(ptr+2)=(WORD)regs.x.edi ;
|
||||
|
||||
*memptr=(void*)(ptr+16) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
LONG myfree( void *ptr )
|
||||
{
|
||||
union REGS regs ;
|
||||
struct SREGS sregs ;
|
||||
UBYTE *ptrh ;
|
||||
|
||||
ptrh = ptr ;
|
||||
ptrh -= 16 ;
|
||||
|
||||
regs.x.esi = *(WORD*)(ptrh+0) ;
|
||||
regs.x.edi = *(WORD*)(ptrh+2) ;
|
||||
regs.x.eax = 0x00000502 ;
|
||||
sregs.es = 0 ;
|
||||
sregs.ds = 0 ;
|
||||
sregs.fs = 0 ;
|
||||
sregs.gs = 0 ;
|
||||
int386x( DPMI_INT, ®s, ®s, &sregs ) ;
|
||||
|
||||
return regs.x.cflag ? regs.x.eax : 0 ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
void *SmartMalloc( LONG lenalloc )
|
||||
{
|
||||
union REGS r ;
|
||||
ULONG strat ;
|
||||
ULONG addr ;
|
||||
|
||||
#ifdef jhghhlk
|
||||
r.x.eax = 0x5800 ;
|
||||
int386( 0x21, &r, &r ) ;
|
||||
strat = r.x.eax ;/* Save DOS alloc strategie */
|
||||
|
||||
r.x.eax = 0x5801 ;
|
||||
r.x.ebx = 0x81 ;/* UMB first then Low mem, best fit*/
|
||||
int386( 0x21, &r, &r ) ;/* Set alloc strategie */
|
||||
#endif
|
||||
r.x.eax = 0x0100 ;/* Function allocate Dos Memory */
|
||||
r.x.ebx =(lenalloc+15)>>4;/*Number off Paragraphs Requested */
|
||||
int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
|
||||
if( !r.x.cflag )
|
||||
addr = (r.x.eax & 0xFFFF) << 4;/* Ok, Take this! */
|
||||
else
|
||||
addr = (ULONG)malloc( lenalloc );
|
||||
#ifdef hjgkgjk
|
||||
r.x.eax = 0x5801 ;
|
||||
r.x.ebx = strat ;/* Odl startegie */
|
||||
int386( 0x21, &r, &r ) ;/* Set alloc strategie */
|
||||
#endif
|
||||
return((void *)addr) ;
|
||||
}
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
void *Malloc( LONG lenalloc )
|
||||
{
|
||||
union REGS regs ;
|
||||
struct SREGS sregs ;
|
||||
void *ptr ;
|
||||
FILE *fh ;
|
||||
ULONG size, error ;
|
||||
|
||||
if ( lenalloc != -1 )
|
||||
{
|
||||
#ifdef DEBUG_MALLOC
|
||||
if( ModeTraceMalloc )
|
||||
{
|
||||
fh = fopen( "c:\\malloc.lst","a+t" ) ;
|
||||
if( fh != NULL )
|
||||
{
|
||||
regs.x.eax = 0x00000500 ;
|
||||
sregs.es = FP_SEG( &MemInfo ) ;
|
||||
sregs.ds = 0 ;
|
||||
regs.x.edi = FP_OFF( &MemInfo ) ;
|
||||
int386x( DPMI_INT, ®s, ®s, &sregs ) ;
|
||||
size = MemInfo.LargestBlockAvail ;
|
||||
|
||||
fprintf( fh, "Mem: %d\n", size ) ;
|
||||
}
|
||||
|
||||
error = mymalloc(lenalloc, &ptr) ;
|
||||
// ptr = malloc( lenalloc ) ;
|
||||
|
||||
if( fh != NULL )
|
||||
{
|
||||
fprintf( fh, "Malloc: %d bytes at %X to %X\n", lenalloc, ptr, (LONG)ptr+lenalloc ) ;
|
||||
if( error )
|
||||
fprintf( fh, "Error: %X\n", error ) ;
|
||||
|
||||
regs.x.eax = 0x00000500 ;
|
||||
sregs.es = FP_SEG( &MemInfo ) ;
|
||||
sregs.ds = 0 ;
|
||||
regs.x.edi = FP_OFF( &MemInfo ) ;
|
||||
int386x( DPMI_INT, ®s, ®s, &sregs ) ;
|
||||
size = MemInfo.LargestBlockAvail ;
|
||||
|
||||
fprintf( fh, "Mem: %d\n", size ) ;
|
||||
|
||||
fclose( fh ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ptr = malloc( lenalloc ) ;
|
||||
}
|
||||
|
||||
return( ptr ) ;
|
||||
|
||||
}
|
||||
regs.x.eax = 0x00000500 ;
|
||||
sregs.es = FP_SEG( &MemInfo ) ;
|
||||
sregs.ds = 0 ;
|
||||
regs.x.edi = FP_OFF( &MemInfo ) ;
|
||||
|
||||
int386x( DPMI_INT, ®s, ®s, &sregs ) ;
|
||||
|
||||
return( (void *)MemInfo.LargestBlockAvail ) ;
|
||||
}
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
void Free( void *buffer )
|
||||
{
|
||||
union REGS regs ;
|
||||
struct SREGS sregs ;
|
||||
void *ptr ;
|
||||
FILE *fh ;
|
||||
ULONG size, error ;
|
||||
|
||||
#ifdef DEBUG_MALLOC
|
||||
if( ModeTraceMalloc )
|
||||
{
|
||||
fh = fopen( "c:\\malloc.lst","a+t" ) ;
|
||||
if( fh != NULL )
|
||||
{
|
||||
regs.x.eax = 0x00000500 ;
|
||||
sregs.es = FP_SEG( &MemInfo ) ;
|
||||
sregs.ds = 0 ;
|
||||
regs.x.edi = FP_OFF( &MemInfo ) ;
|
||||
int386x( DPMI_INT, ®s, ®s, &sregs ) ;
|
||||
size = MemInfo.LargestBlockAvail ;
|
||||
|
||||
fprintf( fh, "Mem: %d\n", size ) ;
|
||||
}
|
||||
|
||||
error = myfree( buffer ) ;
|
||||
// free( buffer ) ;
|
||||
|
||||
if( fh != NULL )
|
||||
{
|
||||
fprintf( fh, "Free: %X\n", buffer ) ;
|
||||
if( error )
|
||||
fprintf( fh, "Error: %X\n", error ) ;
|
||||
|
||||
regs.x.eax = 0x00000500 ;
|
||||
sregs.es = FP_SEG( &MemInfo ) ;
|
||||
sregs.ds = 0 ;
|
||||
regs.x.edi = FP_OFF( &MemInfo ) ;
|
||||
int386x( DPMI_INT, ®s, ®s, &sregs ) ;
|
||||
size = MemInfo.LargestBlockAvail ;
|
||||
|
||||
fprintf( fh, "Mem: %d\n", size ) ;
|
||||
|
||||
fclose( fh ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
free( buffer ) ;
|
||||
}
|
||||
}
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
void *Mshrink( void *buffer, ULONG taille )
|
||||
{
|
||||
return _expand( buffer, (size_t)taille ) ;
|
||||
}
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
60
LIB386/LIB_SYS/SYSTEM.C
Normal file
60
LIB386/LIB_SYS/SYSTEM.C
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "\projet\lib386\lib_sys\adeline.h"
|
||||
#include "\projet\lib386\lib_sys\lib_sys.h"
|
||||
#include "\projet\lib386\lib_svga\lib_svga.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dos.h>
|
||||
#include <i86.h>
|
||||
|
||||
|
||||
//extern void __interrupt NewInt24(void) ;
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void InitSystem()
|
||||
{
|
||||
// union REGS r ;
|
||||
// struct SREGS sr ;
|
||||
// void far *fh ;
|
||||
|
||||
/*----- Install New Protected Vector 24 --------*/
|
||||
// r.x.eax = 0x2524 ;/* Function 25h for int 24 */
|
||||
// fh = (void far*)NewInt24 ;/* Get far Pointer */
|
||||
// r.x.edx = FP_OFF( fh ) ;/* Get Offset */
|
||||
// sr.ds = FP_SEG( fh ) ;/* Get Segment */
|
||||
// sr.es = 0 ;/* Security ( ... ) */
|
||||
// int386x( 0x21, &r, &r, &sr ) ;/* Invoke DOS 21h */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void ClearSystem()
|
||||
{
|
||||
// Inutile de restorer l'int 24h
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
112
LIB386/LIB_SYS/TIMER.C
Normal file
112
LIB386/LIB_SYS/TIMER.C
Normal file
@@ -0,0 +1,112 @@
|
||||
#include "\projet\lib386\lib_sys\adeline.h"
|
||||
#include "\projet\lib386\lib_sys\lib_sys.h"
|
||||
#include "\projet\lib386\lib_svga\lib_svga.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dos.h>
|
||||
#include <i86.h>
|
||||
|
||||
|
||||
#define DIVISOR 23864 /* 1193180 / 50 */
|
||||
#define FREQUENCE 50 /* 1193180 / 23864 */
|
||||
|
||||
|
||||
#define OLD_DIVISOR 0xFFFF
|
||||
|
||||
|
||||
extern void __interrupt NewIntPM08(void) ;
|
||||
|
||||
ULONG Old_PM08_Off ;
|
||||
UWORD Old_PM08_Sel ;
|
||||
|
||||
//UWORD Old_RM08_Off ;
|
||||
//UWORD Old_RM08_Seg ;
|
||||
|
||||
|
||||
//UWORD Old_RMF2_Off ;
|
||||
//UWORD Old_RMF2_Seg ;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
void InitTimer()
|
||||
{
|
||||
union REGS r ;
|
||||
struct SREGS sr ;
|
||||
void far *fh ;
|
||||
|
||||
/*----- Save Old Real Mode Vector F2 -----------*/
|
||||
// r.x.eax = 0x0200 ;/* DPMI Get Real Mode Vect */
|
||||
// r.h.bl = 0xF2 ;/* Interrupt Number */
|
||||
// int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
// Old_RMF2_Seg = (UWORD)r.x.ecx ;/* CX:DX=Old Interrupt F2 */
|
||||
// Old_RMF2_Off = (UWORD)r.x.edx ;
|
||||
|
||||
/*----- Save Old Real Mode Vector 08 -----------*/
|
||||
// r.x.eax = 0x0200 ;/* DPMI Get Real Mode Vect */
|
||||
// r.h.bl = 0x08 ;/* Interrupt Number */
|
||||
// int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
// Old_RM08_Seg = (UWORD)r.x.ecx ;/* CX:DX=Old Interrupt 08 */
|
||||
// Old_RM08_Off = (UWORD)r.x.edx ;
|
||||
|
||||
/*----- Install it as New Real Vector F2 -------*/
|
||||
// r.x.eax = 0x0201 ;/* DPMI Set Real Mode Vect */
|
||||
// r.h.bl = 0xF2 ;/* Interrupt Number */
|
||||
// int386( 0x31, &r, &r ) ;
|
||||
|
||||
/*----- Save Old Protected Mode Vector 08 ------*/
|
||||
r.x.eax = 0x3508 ;/* Function 35h, for Int 08*/
|
||||
sr.ds = sr.es = 0 ;/* Security (kill the cat) */
|
||||
int386x( 0x21, &r, &r, &sr ) ;/* Call Int 21 */
|
||||
Old_PM08_Sel = (UWORD)sr.es ;/* ES:EBX=Old Interrupt 08 */
|
||||
Old_PM08_Off = r.x.ebx ;
|
||||
|
||||
/*----- Install New Protected Vector 08 --------*/
|
||||
r.x.eax = 0x2508 ;/* Function 25h for int 08 */
|
||||
fh = (void far*)NewIntPM08 ;/* Get far Pointer */
|
||||
r.x.edx = FP_OFF( fh ) ;/* Get Offset */
|
||||
sr.ds = FP_SEG( fh ) ;/* Get Segment */
|
||||
sr.es = 0 ;/* Security ( ... ) */
|
||||
int386x( 0x21, &r, &r, &sr ) ;/* Invoke DPMI */
|
||||
|
||||
/*----- It's Ok, Now I can accelerate Timer 08 */
|
||||
|
||||
SetTimer( DIVISOR ) ;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
void ClearTimer()
|
||||
{
|
||||
union REGS r ;
|
||||
struct SREGS sr ;
|
||||
|
||||
/*----- Ok, it's finish, stop running... -------*/
|
||||
|
||||
SetTimer( OLD_DIVISOR ) ;
|
||||
|
||||
/*----- Restore Old Protected Vector 08 --------*/
|
||||
r.x.eax = 0x2508 ;/* Set Vector Interupt PM08*/
|
||||
r.x.edx = Old_PM08_Off ;/* Adr Old Interrupt 08 */
|
||||
sr.ds = Old_PM08_Sel ;
|
||||
sr.es = 0 ;/* ... (...) */
|
||||
int386x( 0x21, &r, &r, &sr ) ;/* Invoke int 21 */
|
||||
|
||||
/*----- Restore Old Real Mode Vector 08 -----------*/
|
||||
// r.x.eax = 0x0200 ;/* DPMI Get Real Mode Vect */
|
||||
// r.h.bl = 0xF2 ;/* Interrupt Number */
|
||||
// int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
|
||||
// r.x.eax = 0x0201 ;/* DPMI Set Real Mode Vect */
|
||||
// r.h.bl = 0x08 ;/* Interrupt Number */
|
||||
// int386( 0x31, &r, &r ) ;
|
||||
|
||||
/*----- Restore Old Real Mode Vector F2 -----------*/
|
||||
// r.x.eax = 0x0201 ;/* DPMI Get Real Mode Vect */
|
||||
// r.h.bl = 0xF2 ;/* Interrupt Number */
|
||||
// r.x.ecx = Old_RMF2_Seg ;/* CX:DX=Old Interrupt F2 */
|
||||
// r.x.edx = Old_RMF2_Off ;
|
||||
// int386( 0x31, &r, &r ) ;/* Invoke DPMI */
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
179
LIB386/LIB_SYS/TIMER_A.ASM
Normal file
179
LIB386/LIB_SYS/TIMER_A.ASM
Normal file
@@ -0,0 +1,179 @@
|
||||
;----------------------------------------------------------------------------
|
||||
; TIMER_A.ASM 386
|
||||
; (c) Adeline 1993
|
||||
;----------------------------------------------------------------------------
|
||||
.386p
|
||||
|
||||
.model SMALL, SYSCALL
|
||||
|
||||
.data
|
||||
|
||||
DIVISOR equ 23864 ; 1193180 (Base Freq) / 50
|
||||
FREQUENCE equ 50 ; 1193180 (Base Freq) / 23864
|
||||
|
||||
public NoLanguage TimerSystem
|
||||
public NoLanguage TimerRef
|
||||
public NoLanguage NbFramePerSecond
|
||||
public NoLanguage WaitNbTicks
|
||||
public NoLanguage CmptFrame
|
||||
public NoLanguage Cmpt_18
|
||||
|
||||
TimerRef dd 0000
|
||||
NbFramePerSecond dw 00
|
||||
WaitNbTicks dw 1
|
||||
CmptFrame dw 00
|
||||
Cmpt_18 dw 00
|
||||
TimerSystem dd 0000
|
||||
|
||||
.data
|
||||
|
||||
extrn NoLanguage Old_PM08_Sel:WORD
|
||||
extrn NoLanguage Old_PM08_Off:DWORD
|
||||
|
||||
.code
|
||||
|
||||
public NoLanguage SetTimer
|
||||
public NoLanguage NewIntPM08
|
||||
public NoLanguage NewProc08
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
SetTimer proc ,\
|
||||
counter:DWORD
|
||||
|
||||
cli
|
||||
|
||||
mov ecx, counter
|
||||
mov al, 36h
|
||||
out 43h, al
|
||||
mov al, cl
|
||||
out 40h, al
|
||||
mov al, ch
|
||||
out 40h, al
|
||||
|
||||
sti
|
||||
ret
|
||||
SetTimer endp
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
comment @
|
||||
|
||||
NewIntPM08 proc far
|
||||
|
||||
push eax
|
||||
push ds
|
||||
|
||||
mov ax, DGROUP
|
||||
mov ds, ax
|
||||
|
||||
inc dword ptr [TimerSystem]
|
||||
inc dword ptr [TimerRef]
|
||||
|
||||
dec word ptr [WaitNbTicks]
|
||||
jnz short noevaluate
|
||||
|
||||
mov word ptr [WaitNbTicks], FREQUENCE
|
||||
|
||||
mov ax, word ptr [CmptFrame]
|
||||
mov word ptr [NbFramePerSecond], ax
|
||||
|
||||
mov word ptr [CmptFrame], 0
|
||||
noevaluate:
|
||||
add word ptr [Cmpt_18], DIVISOR
|
||||
jc short oldint08
|
||||
|
||||
mov al, 20h
|
||||
out 20h, al
|
||||
|
||||
pop ds
|
||||
pop eax
|
||||
iretd
|
||||
oldint08:
|
||||
pop ds
|
||||
pop eax
|
||||
|
||||
int 0F2h ; old int08
|
||||
|
||||
iretd
|
||||
|
||||
NewIntPM08 endp
|
||||
|
||||
@
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
NewIntPM08 proc far
|
||||
|
||||
push eax
|
||||
push ecx
|
||||
push ds
|
||||
|
||||
mov ax, DGROUP
|
||||
mov ds, ax
|
||||
|
||||
inc dword ptr [TimerSystem]
|
||||
inc dword ptr [TimerRef]
|
||||
|
||||
dec word ptr [WaitNbTicks]
|
||||
jnz short noevaluate
|
||||
|
||||
mov word ptr [WaitNbTicks], FREQUENCE
|
||||
|
||||
mov ax, word ptr [CmptFrame]
|
||||
mov word ptr [NbFramePerSecond], ax
|
||||
|
||||
mov word ptr [CmptFrame], 0
|
||||
noevaluate:
|
||||
add word ptr [Cmpt_18], DIVISOR
|
||||
jc short oldint08
|
||||
|
||||
mov al, 20h
|
||||
out 20h, al
|
||||
|
||||
pop ds
|
||||
pop ecx
|
||||
pop eax
|
||||
iretd
|
||||
oldint08:
|
||||
xor eax, eax
|
||||
mov ecx, [Old_PM08_Off]
|
||||
mov ax, [Old_PM08_Sel]
|
||||
|
||||
xchg ecx, [esp+4]
|
||||
xchg eax, [esp+8]
|
||||
|
||||
pop ds
|
||||
retf
|
||||
|
||||
NewIntPM08 endp
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
|
||||
NewProc08 proc
|
||||
|
||||
push eax
|
||||
push ds
|
||||
|
||||
mov ax, DGROUP
|
||||
mov ds, ax
|
||||
|
||||
inc dword ptr [TimerRef]
|
||||
inc dword ptr [TimerSystem]
|
||||
|
||||
dec word ptr [WaitNbTicks]
|
||||
jnz short noevaluate
|
||||
|
||||
mov word ptr [WaitNbTicks], FREQUENCE
|
||||
mov ax, word ptr [CmptFrame]
|
||||
mov word ptr [NbFramePerSecond], ax
|
||||
mov word ptr [CmptFrame], 0
|
||||
noevaluate:
|
||||
|
||||
pop ds
|
||||
pop eax
|
||||
|
||||
ret
|
||||
|
||||
NewProc08 endp
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; The
|
||||
End
|
||||
69
LIB386/LIB_SYS/WINBOX.H
Normal file
69
LIB386/LIB_SYS/WINBOX.H
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
#define SELECT_NO_FLAG 0
|
||||
#define SELECT_SHOW_EXT 1
|
||||
|
||||
#define NO_FLAG 0
|
||||
#define FLAG_PUSHED 0x0001
|
||||
#define FLAG_RED 0x0002
|
||||
#define FLAG_NO_PUSH 0x0004
|
||||
#define FLAG_CENTRE 0x0100
|
||||
#define FLAG_CONTOUR 0x0200
|
||||
|
||||
typedef struct { WORD X1 ; /* size/pos pixel box */
|
||||
WORD Y1 ;
|
||||
WORD X2 ;
|
||||
WORD Y2 ;
|
||||
|
||||
WORD Handle ; /* info retourn‚e si != -1 */
|
||||
WORD Flags ; /* texte centr‚... */
|
||||
|
||||
UBYTE *PtrString ;
|
||||
|
||||
} T_CLICK_BOX ;
|
||||
|
||||
|
||||
typedef struct { WORD NbBox ;
|
||||
WORD MaxBox ;
|
||||
WORD LastClicked ;
|
||||
WORD LastSelected ;
|
||||
T_CLICK_BOX *PtrMallocList ;
|
||||
|
||||
WORD Largeur ; /* en caractere */
|
||||
WORD Hauteur ;
|
||||
|
||||
WORD X1 ;
|
||||
WORD Y1 ;
|
||||
WORD X2 ;
|
||||
WORD Y2 ;
|
||||
|
||||
WORD Flags ;
|
||||
|
||||
} T_MENU ;
|
||||
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
|
||||
WORD OpenMenu( T_MENU *ptrmenu,
|
||||
WORD largeur, WORD hauteur,
|
||||
WORD maxbox ) ;
|
||||
|
||||
WORD AddButton( T_MENU *ptrmenu,
|
||||
WORD handle,
|
||||
WORD x1, WORD y1,
|
||||
WORD largeur, WORD hauteur,
|
||||
WORD flags,
|
||||
UBYTE *ptrstring ) ;
|
||||
|
||||
void DrawMenu( T_MENU *ptrmenu, WORD x1, WORD y1 ) ;
|
||||
|
||||
WORD GereMenu( T_MENU *ptrmenu, WORD flagwaitclick ) ;
|
||||
|
||||
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
|
||||
|
||||
void ChangeButtonFlags( T_MENU *ptrmenu, WORD handle, WORD flags, WORD flagaff ) ;
|
||||
WORD GetButtonFlags( T_MENU *ptrmenu, WORD handle ) ;
|
||||
|
||||
void ChangeButtonString( T_MENU *ptrmenu, WORD handle, UBYTE *string, WORD flagaff ) ;
|
||||
UBYTE* GetButtonString( T_MENU *ptrmenu, WORD handle ) ;
|
||||
|
||||
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
|
||||
Reference in New Issue
Block a user