-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.c
More file actions
129 lines (114 loc) · 2.79 KB
/
Copy pathcode.c
File metadata and controls
129 lines (114 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* ScottCom -- Compiles adventures into the Scott Adams format.
* Copyright (C) 1985-1996 Bjorn Gustavsson
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: code.c,v 1.2 1996/10/17 04:02:35 bjorn Exp $
*
*/
#include "scottcom.h"
#include "adams.h"
static int OurAddress = DYNAMIC_AREA;
int Here(void)
{
return OurAddress;
}
void SetHere(int n)
{
OurAddress = n;
}
/*
*----------------------------------------------------------------------
*
* RangeCheck --
*
* This procedure makes sure that an integer is in the
* range min <= value < max. If the integer is outside
* the range, error() will be called to produce an error
* message.
*
* Results:
* Returns value, adjusted to be within range.
*
*----------------------------------------------------------------------
*/
int
RangeCheck(
char* name, /* Name of value to be check */
/* (used for the error message). */
int value, /* The value to check. */
int min, /* The minimum allowed value. */
int max /* The maximum (value must be < max). */
)
{
if (min <= value && value < max)
return value;
sprintf(err_sbuf, "the value of '%s' must be at least %d and less than %d",
name, min, max);
error(err_sbuf);
return value < min ? min : max-1;
}
/* set/clear flag */
void actflag(int op, int flag)
{
if (flag == 0)
action0(0xe3+op);
else if (flag == 15)
action0(0xdf+op);
else
action1(0xe1+op, flag);
}
void acttimer(int op, int n)
{
if (n == 1)
action0(0xf2+op);
else
action1(0xf6+op, n);
}
static int CurrentTimer = 0;
int GetNextTimer(void)
{
if(CurrentTimer > 15)
{
error("too many timers defined.");
return -1;
}
return CurrentTimer++;
}
static int CurrentRoomReg = 0;
int GetNextRoomReg(void)
{
if(CurrentRoomReg > 15)
{
error("too many room registers defined.");
return -1;
}
return CurrentRoomReg++;
}
/****************************
Flags
*****************************/
static int CurrentFlag = 0;
int GetNextFlag(void) /* get next available flag */
{
if (CurrentFlag == 15)
CurrentFlag = 17;
if (CurrentFlag >= 32) {
error("too many flags defined");
return -1;
}
return CurrentFlag++;
}