Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Piatok, 19. apríl 2024

Súbor: [Platon] / games / _shared / standart.c (stiahnutie)

Revízia 1.5, Tue Apr 6 09:54:16 2004 UTC (20 years ago) by nepto


Zmeny od 1.4: +11 -3 [lines]

Headers update:
    - switch to standard/classic Platon SDG source header
    - bumped copyright year to 2004
    - changelog dates reformatted to new format YYYY-MM-DD

/*
 * games/_shared/ - shared routines for games
 *
 * standart.c - standard MS-Dos subroutines library
 * ____________________________________________________________
 *
 * Developed by Ondrej Jombik <nepto@platon.sk>
 * Copyright (c) 1997-2000 Condy software inc.
 * Copyright (c) 2001-2004 Platon SDG, http://platon.sk/
 * All rights reserved.
 *
 * See README file for more information about this software.
 * See COPYING file for license information.
 *
 * Download the latest version from
 * http://platon.sk/projects/games/
 */

/* $Platon: games/_shared/standart.c,v 1.4 2003/10/21 10:23:43 nepto Exp $ */

/* NOTE: incorrect "standart" word in filename is kept
   from historical reasons; correct word is "standard" */

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
#include <alloc.h>
#include <time.h>
#include <stdarg.h>

#include <typedef.h>

#include "standart.h"

/* IMPLEMENTATION */

#include "stshared.c"

void wait(double sec)
{
    clock_t start = clock();
    clock_t total = max(1, sec * CLOCKS_PER_SEC);
    while (clock() - start < total)
        ;
}

WORD wround(double a)
{
    return(((a-(WORD)a)<.5)?(WORD)a:((WORD)a)+1);
}

int iround(double a)
{
    return(((a-(int)a)<.5)?(int)a:((int)a)+1);
}

void printfxy(BYTE x,BYTE y,const char *format,...)
{
    va_list ag;
    gotoxy(x,y);
    va_start(ag,format);
    vprintf(format,ag);
    va_end(ag);
}

void*fileloadfrom(char*s,long from)
{
    FILE*f=fopen(s,"rb");
    void*p;long dlzka;
    if((f==NULL)||
            (fseek(f,0L,SEEK_END))||
            ((dlzka=ftell(f))==-1L)||
            ((dlzka-=from)<0)||
            (fseek(f,from,SEEK_SET)))return(NULL);
    if((p=malloc((size_t)dlzka))!=NULL)if(fread(p,(size_t)dlzka,1,f)!=1)return(NULL);
    if(fclose(f)==EOF)return(NULL);
    return(p);
}

void far*_fileload(char*s)
{
    FILE*f=fopen(s,"rb");
    void far*p;long dlzka;
    if(f==NULL)return(NULL);
    fseek(f,0L,SEEK_END);
    dlzka=ftell(f);
    rewind(f);
    if((p=farmalloc((size_t)dlzka))!=NULL)fread((void*)p,(size_t)dlzka,1,f);
    fclose(f);
    return(p);
}


Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok