Debian Codegraph @

terps/scott/scott.h

raw symbols SCIP
1 /*
2 * SCOTT FREE
3 *
4 * A free Scott Adams style adventure interpreter
5 *
6 * Copyright:
7 * This software is placed under the GNU license.
8 *
9 * Statement:
10 * Everything in this program has been deduced or obtained solely
11 * from published material. No game interpreter code has been
12 * disassembled, only published BASIC sources (PC-SIG, and Byte Dec
13 * 1980) have been used.
14 */
15
16 /*
17 * Controlling block
18 */
19
20 #ifndef scott_h
21 #define scott_h
22
23 #include <stdint.h>
24 #include <stdio.h>
25
26 #include "debugprint.h"
27 #include "scottdefines.h"
28
29 // clang-format off
30
31 #define LIGHT_SOURCE 9 /* Always 9 how odd */
32 #define CARRIED 255 /* Carried */
33 #define DESTROYED 0 /* Destroyed */
34 #define DARKBIT 15
35 #define LIGHTOUTBIT 16 /* Light gone out */
36
37 // clang-format on
38
39 #define GLK_BUFFER_ROCK 1
40 #define GLK_STATUS_ROCK 1010
41 #define GLK_GRAPHICS_ROCK 1020
42
43 typedef struct {
44 short Unknown;
45 short NumItems;
46 short NumActions;
47 short NumWords; /* Smaller of verb/noun is padded to same size */
48 short NumRooms;
49 short MaxCarry;
50 short PlayerRoom;
51 short Treasures;
52 short WordLength;
53 short LightTime;
54 short NumMessages;
55 short TreasureRoom;
56 } Header;
57
58 typedef struct {
59 unsigned short Vocab;
60 unsigned short Condition[5];
61 unsigned short Subcommand[2];
62 } Action;
63
64 typedef struct {
65 char *Text;
66 short Exits[6];
67 uint8_t Image;
68 } Room;
69
70 typedef struct {
71 char *Text;
72 /* PORTABILITY WARNING: THESE TWO MUST BE 8 BIT VALUES. */
73 uint8_t Location;
74 uint8_t InitialLoc;
75 char *AutoGet;
76 uint8_t Flag;
77 uint8_t Image;
78 } Item;
79
80 typedef struct {
81 short Version;
82 short AdventureNumber;
83 short Unknown;
84 } Tail;
85
86 // clang-format off
87
88 #define YOUARE 0x1 /* You are not I am */
89 #define SCOTTLIGHT 0x2 /* Authentic Scott Adams light messages */
90 #define DEBUGGING 0x4 /* Info from database load */
91 #define TRS80_STYLE 0x8 /* Display in style used on TRS-80 */
92 #define PREHISTORIC_LAMP 0x10 /* Destroy the lamp (very old databases) */
93 #define SPECTRUM_STYLE 0x20 /* Display in style used on ZX Spectrum */
94 #define TI994A_STYLE 0x40 /* Display in style used on TI-99/4A */
95 #define NO_DELAYS 0x80 /* Skip all pauses */
96 #define FORCE_PALETTE_ZX 0x100 /* Force ZX Spectrum image palette */
97 #define FORCE_PALETTE_C64 0x200 /* Force CBM 64 image palette */
98 #define FORCE_INVENTORY 0x400 /* Inventory in upper window always on */
99 #define FORCE_INVENTORY_OFF 0x800 /* Inventory in upper window always off */
100 #define PC_STYLE 0x1000 /* Display in style used on IBM PC (MS-DOS) */
101 #define FLICKER_ON 0x2000 /* Flicker room description like some original games */
102
103 // clang-format on
104
105 #define MAX_GAMEFILE_SIZE 250000
106
107 /* Anything used by the other source files goes here */
108
109 #include "glk.h"
110
111 #define MyLoc (GameHeader.PlayerRoom)
112
113 #define CurrentGame (Game->gameID)
114
115 void Output(const char *a);
116 void OutputNumber(int a);
117 void Display(winid_t w, const char *fmt, ...)
118 #ifdef __GNUC__
119 __attribute__((__format__(__printf__, 2, 3)))
120 #endif
121 ;
122 void HitEnter(void);
123 void Look(void);
124 void DrawRoomImage(void);
125 void ListInventory(int upper);
126 void Delay(float seconds);
127 void DrawImage(int image);
128 void OpenGraphicsWindow(void);
129 size_t GetFileLength(FILE *in);
130 void *MemAlloc(int size);
131 GameIDType LoadDatabase(FILE *f, int loud);
132 void CloseGraphicsWindow(void);
133 void Updates(event_t ev);
134 int PerformExtraCommand(int extra_stop_time);
135 const char *MapSynonym(int noun);
136 void Fatal(const char *x);
137 void DrawBlack(void);
138 uint8_t *SeekToPos(uint8_t *buf, int offset);
139 int CountCarried(void);
140 int RandomPercent(int n);
141 void DoneIt(void);
142 void SaveGame(void);
143 void PrintNoun(void);
144 int PrintScore(void);
145 void MoveItemAToLocOfItemB(int itemA, int itemB);
146 void GoTo(int loc);
147 void GoToStoredLoc(void);
148 void SwapLocAndRoomflag(int index);
149 void SwapItemLocations(int itemA, int itemB);
150 void PutItemAInRoomB(int itemA, int roomB);
151 void SwapCounters(int index);
152 void PrintMessage(int index);
153 void PlayerIsDead(void);
154 void UpdateSettings(void);
155 winid_t FindGlkWindowWithRock(glui32 rock);
156 void OpenTopWindow(void);
157 void SetDark(void);
158 void SetLight(void);
159 void SetBitFlag(int bit);
160 void ClearBitFlag(int bit);
161
162 extern struct GameInfo *Game;
163 extern Header GameHeader;
164 extern Room *Rooms;
165 extern Item *Items;
166 extern Action *Actions;
167 extern const char **Verbs, **Nouns, **Messages;
168 extern const char *title_screen;
169 extern winid_t Bottom, Top, Graphics;
170 extern const char *sys[];
171 extern const char *system_messages[];
172 extern uint8_t *entire_file;
173 extern size_t file_length;
174 extern int file_baseline_offset;
175 extern int split_screen;
176 extern long BitFlags;
177 extern int LightRefill;
178 extern int Counters[];
179 extern int AnimationFlag;
180 extern int SavedRoom;
181 extern int AutoInventory;
182 extern int WeAreBigEndian;
183 extern int CurrentCounter;
184 extern int RoomSaved[];
185 extern int Options;
186 extern int StopTime;
187 extern int should_look_in_transcript;
188 extern int ImageWidth;
189 extern int ImageHeight;
190 extern const char *game_file;
191 extern int showing_inventory;
192 extern MachineType CurrentSys;
193 extern int lastwasnewline;
194 extern int showing_closeup;
195 extern int last_image_index;
196
197 #endif /* scott_h */