All pastes #210715 Raw Edit

Untitled

public text v1 · immutable
#210715 ·published 2006-10-19 23:15 UTC
rendered paste body
#include <tigcclib.h>
#include "makeext.h"

#define FILE_NAME "gwtdata"		//8 char file name max, lowercase
#define FILE_TYPE {0,'G','W','T','D',0,OTH_TAG} //{0,'a','b','c','d',0,OTH_TAG} where abcd are letters of new file type

void _main(void)
{
	const char filetype[] = FILE_TYPE;
	HANDLE data;
	MULTI_EXPR *ptr;
	HSym h;
		if((h=SymAdd(SYMSTR(FILE_NAME))).folder)
		{
			if((data=HeapAlloc(2+sizeof(DATA)+sizeof(filetype))))
			{
				ptr=HeapDeref(data);
				ptr->Size=EXTsize+sizeof(filetype);
				
				memcpy(ptr->Expr, ALLEXT, sizeof(ALLEXT));
				
				memcpy(ptr->Expr+EXTsize, filetype, sizeof(filetype));
				DerefSym(h)->handle=data;
				EM_moveSymToExtMem(SYMSTR(FILE_NAME), HS_NULL);
				ST_helpMsg("Writing successful!");
				ngetchx();
			}
			else
			{
				ST_helpMsg("Writing failed!");
				SymDel(SYMSTR(FILE_NAME));
				ngetchx();
			}
		}
	return;
}

=============makeext.h=============
#include "gwtactics.h"

#define EXTsize (sizeof(DATA)+sizeof(DATA2))  //for writing file size in sym entry, just list all sizeof(DATA#) in the ()
#define ALLEXT (DATA, DATA2)									//Allows for all data to be written at once, just list all the DATA# defines in the ()

//DATA defines for writing (see above)
#define DATA HUDlr
#define DATA2 spriteGundam
#define DATA3 spriteWeapons

//Char offsets for data.  Used by main and other functions.
#define raHUDleft 0
#define raHUDright SIDEHUDH*NUM_LAYERS
#define raGsprites sizeof(HUDlr)