Debian Codegraph @

terps/level9/level9.h

raw symbols SCIP
1 /***********************************************************************\
2 *
3 * Level 9 interpreter
4 * Version 5.2
5 * Copyright (c) 1996-2025 Glen Summers and contributors.
6 * Contributions from David Kinder, Alan Staniforth, Simon Baldwin,
7 * Dieter Baron and Andreas Scherrer.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
22 *
23 \***********************************************************************/
24
25 #include <stdint.h>
26
27 typedef uint8_t L9BYTE;
28 typedef uint16_t L9UINT16;
29 typedef uint32_t L9UINT32;
30 typedef int L9BOOL;
31
32 #ifndef FALSE
33 #define FALSE 0
34 #define TRUE 1
35 #endif
36
37 #define LISTAREASIZE 0x800
38 #define STACKSIZE 1024
39 #define V1FILESIZE 0x600
40
41 #ifndef MAX_PATH
42 #define MAX_PATH 256
43 #endif
44
45 typedef struct
46 {
47 L9UINT32 Id;
48 L9UINT16 codeptr,stackptr,listsize,stacksize,filenamesize,checksum;
49 L9UINT16 vartable[256];
50 L9BYTE listarea[LISTAREASIZE];
51 L9UINT16 stack[STACKSIZE];
52 char filename[MAX_PATH];
53 } GameState;
54
55 typedef enum
56 {
57 NO_BITMAPS,
58 AMIGA_BITMAPS,
59 PC1_BITMAPS,
60 PC2_BITMAPS,
61 C64_BITMAPS,
62 BBC_BITMAPS,
63 CPC_BITMAPS,
64 MAC_BITMAPS,
65 ST1_BITMAPS,
66 ST2_BITMAPS,
67 } BitmapType;
68
69 typedef struct
70 {
71 L9BYTE red, green, blue;
72 } Colour;
73
74 typedef struct
75 {
76 L9UINT16 width, height;
77 L9BYTE* bitmap;
78 Colour palette[32];
79 L9UINT16 npalette;
80 } Bitmap;
81
82 #define MAX_BITMAP_WIDTH 512
83 #define MAX_BITMAP_HEIGHT 218
84
85 #if defined(_Windows) || defined(__MSDOS__) || defined (_WIN32) || defined (__WIN32__)
86 #define L9WORD(x) (*(L9UINT16*)(x))
87 #define L9SETWORD(x,val) (*(L9UINT16*)(x)=(L9UINT16)val)
88 #define L9SETDWORD(x,val) (*(L9UINT32*)(x)=val)
89 #else
90 #define L9WORD(x) (*(x) + ((*(x+1))<<8))
91 #define L9SETWORD(x,val) *(x)=(L9BYTE) val; *(x+1)=(L9BYTE)(val>>8);
92 #define L9SETDWORD(x,val) *(x)=(L9BYTE)val; *(x+1)=(L9BYTE)(val>>8); *(x+2)=(L9BYTE)(val>>16); *(x+3)=(L9BYTE)(val>>24);
93 #endif
94
95 #if defined(_Windows) && !defined(__WIN32__)
96 #include <alloc.h>
97 #define malloc farmalloc
98 #define calloc farcalloc
99 #define free farfree
100 #endif
101
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105
106 /* routines provided by os dependent code */
107 void os_printchar(char c);
108 L9BOOL os_input(char* ibuff, int size);
109 char os_readchar(int millis);
110 L9BOOL os_stoplist(void);
111 void os_flush(void);
112 L9BOOL os_save_file(L9BYTE* Ptr, int Bytes);
113 L9BOOL os_load_file(L9BYTE* Ptr, int* Bytes, int Max);
114 L9BOOL os_get_game_file(char* NewName, int Size);
115 void os_set_filenumber(char* NewName, int Size, int n);
116 void os_graphics(int mode);
117 void os_cleargraphics(void);
118 void os_setcolour(int colour, int index);
119 void os_drawline(int x1, int y1, int x2, int y2, int colour1, int colour2);
120 void os_fill(int x, int y, int colour1, int colour2);
121 void os_show_bitmap(int pic, int x, int y);
122 FILE* os_open_script_file(void);
123 L9BOOL os_find_file(char* NewName);
124
125 /* routines provided by level9 interpreter */
126 L9BOOL LoadGame(char* filename, char* picname);
127 L9BOOL RunGame(void);
128 void StopGame(void);
129 void RestoreGame(char* filename);
130 void FreeMemory(void);
131 void GetPictureSize(int* width, int* height);
132 L9BOOL RunGraphics(void);
133
134 /* bitmap routines provided by level9 interpreter */
135 BitmapType DetectBitmaps(char* dir);
136 Bitmap* DecodeBitmap(char* dir, BitmapType type, int num, int x, int y);
137
138 #ifdef __cplusplus
139 }
140 #endif