delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/27/17:23:00

Posted-Date: Tue, 27 Jan 1998 16:19:45 -0600 (CST)
Message-ID: <34CE787B.7F72@sparc.isl.net>
Date: Tue, 27 Jan 1998 16:15:23 -0800
From: DE Stewart <interced AT sparc DOT isl DOT net>
Reply-To: interced AT sparc DOT isl DOT net
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: DJGPP MEMORY....

hey, go32-v2 printf 4,260 or something kb(I know, we only got 8 megs o
ram.)  and then it printed 131,128 or so kb of swap space.   I don't use
windows 95, in fact I have no windows running when I'm doing my
programs.
I use CWSDPMI ...    i don't know whats up with symify... here's some
code, i tried to isolate it as much as possible:

void get_name(char *name, void (*function)(), int x, int y, char color)
{
        int scancode;
        char ch;
        int done = FALSE;
        int index = 0;

        clear_keybuf();             /* don't want extra stuff :-) */
        while(!done)        /* terminate input with <return> */
        {
                scancode = readkey();
                if( ((scancode >> 8) == KEY_BACKSPACE) && index>0)
                        name[--index] = ' ';   /* are we trying to
erase? */

                else if( (scancode >> 8) == KEY_ENTER)
                        done = 1;             /* are we done? */

                else                     /* if not then...*/
                {
                ch = (char)(scancode & 0xff); /* convert scancode to
ASCII */
                name[index++] = ch;
                }

        function();          /* call our received function */
        textout(page.active_page, font, name, x, y, color);  /* print
text */
        page_change();       /* do the mode-x stuff */
}

}

/* FUNCTION: int allocate_map_memory()
 *      This function allocates neccessary memory for a map(i.e. world,
town,
 *      cave, etc.)
 *      Returns 1 on successful, and it returns 0 and the error in
error_msg
 *      if unsuccessful.
*/
int allocate_map_memory(int x_screens, int y_screens)
{
long index;

_current_map = malloc(sizeof(map_tile)*x_screens*y_screens*300);
if(!_current_map)
        {
                strcpy(error_msg,"Error: not enough memory");/* out of
mem?*/

                return 0;
        }

for(index=0; index<x_screens*y_screens*300; index++)
{
_current_map[index].frames[0] = 0;    /* set ids in first layer to blank
*/
_current_map[index].frames[1] = 0;
_current_map[index].frames[2] = 0;
_current_map[index].frames[3] = 0;
_current_map[index].frames[4] = 0;
_current_map[index].flags_events_bits = 0;  /* clear the flags & events
*/
}
return 1;
}


/* FUNCTION: int new_map()
 *      Creates a new map for the _current_map variable.
 *      Returns 1 on successful, else 0 with error_msg.
*/
long access_id;

int new_map()
{
FILE *the_nfo;
char temp_name[100] = "";

/*for(y=0; y<10; y++)
        for(index=0; index<100; index++)
                pcxfile_names[y][index] = NULL;*/

show_mouse(NULL);
page_change();
clear(page.active_page);
textout(page.active_page, font, "Enter nfo filename(no extension!):", 0,
0,
        50);
page_change();
clear(page.active_page);

get_name(map_name, qwe2, 0, 20, 50);              /* get the file name
*/
show_mouse(page.active_page);    /* the program freezes somewhere after
here*/

strcpy(temp_name, map_name);                      /* make a copy */
strcat(temp_name, ".nfo");                      /* add the "nfo"
extension */

if((the_nfo=fopen(temp_name, "rb")) == NULL)
        {
        strcpy(error_msg, "Error opening file!!!");
        return 0;
        }
fread(&access_id, sizeof(access_id), 1, the_nfo);   /* read the access #
*/

if(access_id != 1947682581)        /* is this a ".nfo" file?? */
        {
        strcpy(error_msg, "File is not a nfo file!!");
        return 0;
        }
fread(&map_ysize, sizeof(map_ysize), 1, the_nfo);  /* read y size */
fread(&map_xsize, sizeof(map_xsize), 1, the_nfo);  /* read x size */
fread(&map_number, sizeof(map_number), 1, the_nfo); /* read map number
*/

fclose(the_nfo);        /* close the file */

if(!allocate_map_memory(map_xsize, map_ysize)) return 0;  /* problem? */

return 1;
}


thanx.    

                          Greg S.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019