1
/***********************************************************************\
5
* Copyright (c) 1996 Glen Summers
6
* Copyright (c) 2002,2003 Glen Summers and David Kinder
7
* Copyright (c) 2005,2007 Glen Summers, David Kinder, Alan Staniforth,
8
* Simon Baldwin and Dieter Baron
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
24
\***********************************************************************/
29
typedef unsigned char L9BYTE;
31
#error "Can't find an 8-bit integer type"
35
typedef unsigned short L9UINT16;
37
typedef unsigned int L9UINT16;
39
#error "Can't find a 16-bit integer type"
42
#if INT_MAX==0x7fffffff
43
typedef unsigned int L9UINT32;
44
#elif LONG_MAX==0x7fffffff
45
typedef unsigned long L9UINT32;
47
#error "Can't find a 32-bit integer type"
57
#define LISTAREASIZE 0x800
58
#define STACKSIZE 1024
59
#define V1FILESIZE 0x600
68
L9UINT16 codeptr,stackptr,listsize,stacksize,filenamesize,checksum;
69
L9UINT16 vartable[256];
70
L9BYTE listarea[LISTAREASIZE];
71
L9UINT16 stack[STACKSIZE];
72
char filename[MAX_PATH];
91
L9BYTE red, green, blue;
96
L9UINT16 width, height;
102
#define MAX_BITMAP_WIDTH 512
103
#define MAX_BITMAP_HEIGHT 216
105
#if defined(_Windows) || defined(__MSDOS__) || defined (_WIN32) || defined (__WIN32__)
106
#define L9WORD(x) (*(L9UINT16*)(x))
107
#define L9SETWORD(x,val) (*(L9UINT16*)(x)=(L9UINT16)val)
108
#define L9SETDWORD(x,val) (*(L9UINT32*)(x)=val)
110
#define L9WORD(x) (*(x) + ((*(x+1))<<8))
111
#define L9SETWORD(x,val) *(x)=(L9BYTE) val; *(x+1)=(L9BYTE)(val>>8);
112
#define L9SETDWORD(x,val) *(x)=(L9BYTE)val; *(x+1)=(L9BYTE)(val>>8); *(x+2)=(L9BYTE)(val>>16); *(x+3)=(L9BYTE)(val>>24);
115
#if defined(_Windows) && !defined(__WIN32__)
117
#define malloc farmalloc
118
#define calloc farcalloc
126
/* routines provided by os dependent code */
127
void os_printchar(char c);
128
L9BOOL os_input(char* ibuff, int size);
129
char os_readchar(int millis);
130
L9BOOL os_stoplist(void);
132
L9BOOL os_save_file(L9BYTE* Ptr, int Bytes);
133
L9BOOL os_load_file(L9BYTE* Ptr, int* Bytes, int Max);
134
L9BOOL os_get_game_file(char* NewName, int Size);
135
void os_set_filenumber(char* NewName, int Size, int n);
136
void os_graphics(int mode);
137
void os_cleargraphics(void);
138
void os_setcolour(int colour, int index);
139
void os_drawline(int x1, int y1, int x2, int y2, int colour1, int colour2);
140
void os_fill(int x, int y, int colour1, int colour2);
141
void os_show_bitmap(int pic, int x, int y);
143
/* routines provided by level9 interpreter */
144
L9BOOL LoadGame(char* filename, char* picname);
145
L9BOOL RunGame(void);
147
void RestoreGame(char* filename);
148
void FreeMemory(void);
149
void GetPictureSize(int* width, int* height);
150
L9BOOL RunGraphics(void);
151
void SetScaleGraphics(L9BOOL scale);
153
/* bitmap routines provided by level9 interpreter */
154
#ifdef BITMAP_DECODER
155
BitmapType DetectBitmaps(char* dir);
156
Bitmap* DecodeBitmap(char* dir, BitmapType type, int num, int x, int y);
159
#ifdef NEED_STRICMP_PROTOTYPE
160
int stricmp(const char* str1, const char* str2);
161
int strnicmp(const char* str1, const char* str2, size_t n);