2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "save.h"
|
|
|
|
#include <stdio.h>
|
2019-11-13 20:06:48 +00:00
|
|
|
//#include <fcntl.h>
|
|
|
|
//#include <sys/stat.h>
|
|
|
|
//#include <io.h>
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
int savegame(int nSlot)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
char filename[92];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nSlot < 0 || nSlot >= 10) {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
sprintf(filename, "save%1d.gam", nSlot);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int hFile = open(filename, 609, 128);
|
|
|
|
if (hFile != -1)
|
|
|
|
{
|
2019-08-26 03:59:14 +00:00
|
|
|
#if 0 // TODO
|
2019-08-31 07:47:15 +00:00
|
|
|
write(hFile, &numsectors, sizeof(numsectors));
|
|
|
|
write(hFile, sector, sizeof(SECTOR) * numsectors);
|
|
|
|
write(hFile, &numwalls, sizeof(numwalls));
|
|
|
|
write(hFile, wall, sizeof(WALL) * numwalls);
|
|
|
|
write(hFile, sprite, sizeof(SPRITE) * kMaxSprites);
|
|
|
|
write(hFile, headspritesect, sizeof(headspritesect));
|
|
|
|
write(hFile, prevspritesect, sizeof(prevspritesect));
|
|
|
|
write(hFile, nextspritesect, sizeof(nextspritesect));
|
|
|
|
write(hFile, headspritestat, sizeof(headspritestat));
|
|
|
|
write(hFile, prevspritestat, sizeof(prevspritestat));
|
|
|
|
write(hFile, nextspritestat, sizeof(nextspritestat));
|
|
|
|
write(hFile, startumost, sizeof(startumost));
|
|
|
|
write(hFile, startdmost, sizeof(startdmost));
|
|
|
|
write(hFile, &brightness, 2);
|
|
|
|
write(hFile, &visibility, 4);
|
|
|
|
write(hFile, ¶llaxtype, 1);
|
|
|
|
write(hFile, ¶llaxyoffs, 4);
|
|
|
|
write(hFile, pskyoff, 512);
|
|
|
|
write(hFile, &pskybits, 2);
|
|
|
|
write(hFile, &inita, 2);
|
|
|
|
write(hFile, &initsect, 2);
|
|
|
|
write(hFile, &initx, 4);
|
|
|
|
write(hFile, &inity, 4);
|
|
|
|
write(hFile, &initz, 4);
|
|
|
|
write(hFile, &levelnum, 2);
|
2019-08-26 03:59:14 +00:00
|
|
|
#endif
|
2019-08-31 07:47:15 +00:00
|
|
|
close(hFile);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return 1; // CHECKME
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int loadgame(int nSlot)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
char filename[92];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nSlot < 0 || nSlot >= 10) {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
sprintf(filename, "save%1d.gam", nSlot);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int hFile = open(filename, 514, 256);
|
|
|
|
if (hFile != -1)
|
|
|
|
{
|
2019-08-26 03:59:14 +00:00
|
|
|
#if 0 // TODO
|
2019-08-31 07:47:15 +00:00
|
|
|
read(hFile, &numsectors, sizeof(numsectors));
|
|
|
|
read(hFile, sector, sizeof(SECTOR) * numsectors);
|
|
|
|
read(hFile, &numwalls, sizeof(numwalls));
|
|
|
|
read(hFile, wall, sizeof(WALL) * numwalls);
|
|
|
|
read(hFile, sprite, sizeof(SPRITE) * kMaxSprites);
|
|
|
|
read(hFile, headspritesect, sizeof(headspritesect));
|
|
|
|
read(hFile, prevspritesect, sizeof(prevspritesect));
|
|
|
|
read(hFile, nextspritesect, sizeof(nextspritesect));
|
|
|
|
read(hFile, headspritestat, sizeof(headspritestat));
|
|
|
|
read(hFile, prevspritestat, sizeof(prevspritestat));
|
|
|
|
read(hFile, nextspritestat, sizeof(nextspritestat));
|
|
|
|
read(hFile, startumost, sizeof(startumost));
|
|
|
|
read(hFile, startdmost, sizeof(startdmost));
|
|
|
|
read(hFile, &brightness, 2);
|
|
|
|
read(hFile, &visibility, 4);
|
|
|
|
read(hFile, ¶llaxtype, 1);
|
|
|
|
read(hFile, ¶llaxyoffs, 4);
|
|
|
|
read(hFile, pskyoff, 512);
|
|
|
|
read(hFile, &pskybits, 2);
|
|
|
|
read(hFile, &inita, 2);
|
|
|
|
read(hFile, &initsect, 2);
|
|
|
|
read(hFile, &initx, 4);
|
|
|
|
read(hFile, &inity, 4);
|
|
|
|
read(hFile, &initz, 4);
|
|
|
|
read(hFile, &levelnum, 2);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
lPlayerXVel = 0;
|
|
|
|
lPlayerYVel = 0;
|
|
|
|
nPlayerDAng = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
#endif
|
2019-08-31 07:47:15 +00:00
|
|
|
close(hFile);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return 1; // CHECKME
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|