123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "eurodefs.h"
- #include "euro_fxd.h"
- #include "euro_sym.h"
- #include "euro_def.h"
- #include "euro_var.h"
- #include "mallocx.h"
- //********************************************************************************************************************************
- void DeAllocateMemory( BYTE* MemAlloc )
- {
- if ( MemAlloc != 0 )
- freex( MemAlloc );
- if ( EUROverbose != 0 )
- {
- printf ("þ Memory check: %d\n",get_mem_info() );
- fflush(stdout);
- }
- }
- //********************************************************************************************************************************
- void Euro96_MemoryInitialise()
- {
- TexturePageMemHandle = 0;
- TextStringMemHandle = 0;
- }
- //********************************************************************************************************************************
- void AllocateDisplayBuffers()
- {
- EuroPseudoBuffer = (BYTE *) mallocx( 307200);
- if ( EuroPseudoBuffer == 0 )
- {
- printf ("þ Unable to allocate memory for Pseudo buffer.\n");
- fflush(stdout);
- }
- else
- {
- if ( EUROverbose != 0 )
- {
- printf ("þ Memory allocated for Pseudo buffer.\n");
- fflush(stdout);
- printf ("þ Memory check: %d\n",get_mem_info() );
- fflush(stdout);
- }
- }
- EuroBackgroundBuffer = (BYTE *) mallocx( 307200);
- if ( EuroBackgroundBuffer == 0 )
- {
- printf ("þ Unable to allocate memory for Background buffer.\n");
- fflush(stdout);
- }
- else
- {
- if ( EUROverbose != 0 )
- {
- printf ("þ Memory allocated for Background buffer.\n");
- fflush(stdout);
- printf ("þ Memory check: %d\n",get_mem_info() );
- fflush(stdout);
- }
- }
- }
- //********************************************************************************************************************************
- void DeAllocateDisplayBuffers()
- {
- if ( EuroBackgroundBuffer != 0 )
- {
- DeAllocateMemory(EuroBackgroundBuffer);
- if ( EUROverbose != 0 )
- {
- printf ("þ Memory for Background buffer DeAllocated.\n");
- printf ("þ Memory check: %d\n",get_mem_info() );
- fflush(stdout);
- }
- }
- else
- {
- printf ("þ ERROR.. Unable to deAllocate memory for Background Buffer (This could cause a crash).\n");
- fflush(stdout);
- }
-
- if ( EuroPseudoBuffer != 0 )
- {
- DeAllocateMemory(EuroPseudoBuffer);
- if ( EUROverbose != 0 )
- {
- printf ("þ Memory for Pseudo buffer DeAllocated.\n");
- fflush(stdout);
- printf ("þ Memory check: %d\n",get_mem_info() );
- fflush(stdout);
- }
- }
- else
- {
- printf ("þ ERROR.. Unable to deAllocate memory for Pseudo Buffer (This could cause a crash).\n");
- fflush(stdout);
- }
- }
- //********************************************************************************************************************************
- BYTE* AllocateTexturePageMemory( unsigned char NoOfTexturePages, texture_info *texture )
- {
- unsigned int size = texture->page_width*texture->page_height*NoOfTexturePages;
- TexturePages = (BYTE *) mallocx( size );
-
- if ( TexturePages==0 )
- {
- printf ("þ ERROR.. Unable to reserve memory for Texture Pages (This could cause a crash).\n");
- fflush(stdout);
- TexturePagesAvailable = 0;
- }
-
- else
- TexturePagesAvailable = NoOfTexturePages;
- if ( EUROverbose != 0 )
- {
- printf ("þ Memory allocated for Texture Pages.\n");
- fflush(stdout);
- printf ("þ Memory check: %d\n",get_mem_info() );
- fflush(stdout);
- }
- return ( TexturePages );
- }
- //********************************************************************************************************************************
- void DeAllocateTexturePages()
- {
- if ( TexturePageMemHandle != 0 )
- {
- DeAllocateMemory(TexturePageMemHandle);
- if ( EUROverbose != 0 )
- {
- printf ("þ Memory for Texture Pages DeAllocated.\n");
- fflush(stdout);
- printf ("þ Memory check: %d\n",get_mem_info() );
- fflush(stdout);
- }
- }
- else
-
- {
- printf ("þ ERROR.. Unable to deAllocate memory for Texture Pages (This could cause a crash).\n");
- fflush(stdout);
- }
- }
- //********************************************************************************************************************************
- BYTE* AllocateTextStringMemory()
- {
- TextStrings = (BYTE *) mallocx( TEXT_STRING_BUFFER_LEN );
-
- if ( TextStrings==0 )
- {
- printf ("þ Unable to allocate memory for Text buffer.\n");
- fflush(stdout);
- }
- else
- {
- printf ("þ Memory allocated for Text buffer.\n");
- fflush(stdout);
- {
- if ( EUROverbose != 0 )
- printf ("þ Memory check: %d\n",get_mem_info() );
- fflush(stdout);
- }
- }
- return ( TextStrings );
- }
- //********************************************************************************************************************************
- //
- //int DisplayFree()
- // {
- // int M8;
- // int buff[20];
- // union REGS regs;
- // struct SREGS sregs;
- //
- // memset(&sregs,0,sizeof(sregs)); //clr sregs
- // regs.x.eax=0x500; //DPMI get free mem info
- // sregs.es=FP_SEG(buff); //Gets SELECTOR in fact.
- // regs.x.edi=FP_OFF(buff); //offset from selector.
- // int386x(0x31,®s,®s,&sregs); //Get free memory info
- //
- // M8=( (buff[7]*4096) >= MEM8 );
- //
- // if (setup.verbose!=0)
- // {
- // printf("\nLargest block: %d\n",buff[0]);
- // printf("Total free : %d\n\n",buff[7]*4096);
- // if (M8)
- // puts("Initialising 8 meg game");
- // else
- // {
- // puts("Initialising 4 meg game");
- // printf("Need to free %d more bytes to run 8 meg version\n",MEM8-(buff[7]*4096) );
- // }
- // }
- // return (M8);
- // }
- //
- //********************************************************************************************************************************
|