-
Notifications
You must be signed in to change notification settings - Fork 0
/
greenman5.bas
307 lines (255 loc) · 8.02 KB
/
greenman5.bas
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
REM this code is licenced under the GNU Public Licence see www.gnu.org for details
REM Copyright Jeff Davies Nov 2002
CHDIR "programs\greenman\greenman"
DECLARE SUB loadscreenmap ()
DECLARE SUB screenmap ()
DECLARE SUB flippage ()
DECLARE SUB repaint ()
REM **************************** INITIALISE *****************************
PRINT "Use 4,6 for left/right use 8/2 for up/down, press Enter to continue."
INPUT a$
OPTION BASE 0
DIM SHARED vpage, apage AS INTEGER
vpage = 1
apage = 0
SCREEN 9, 0, apage, vpage
REM **************** LOAD SCREEN MAP -> THIS HAS A CHARACTER FOR *******
REM ******************** EVERY 20 BY 20 BLOCK **************************
REM ***************** SCREEN 640 x 350 => 32 x 17 **********************
REM ******************** CONTAINS "A" TO "Z" ***************************
DIM SHARED sm$(16)
DIM SHARED x, y AS INTEGER
loadscreenmap
REM **************************** WORK OUT SIZE FOR ARRAY **************
xmaxx = 20
ymax = 20
reqdsize = 4 + INT(((xmaxx - 0 + 1) * (1) + 7) / 8) * 4 * ((ymax - 0) + 1)
REM **************************** LOAD PLAYER GRAPHIC *****************
REDIM graphic(reqdsize + 1)
DEF SEG = VARSEG(graphic(0))
BLOAD "spr\homer.spr", VARPTR(graphic(0))
DEF SEG
REM **************************** LOAD SCREENMAP GRAPHICS *****************
REDIM SHARED sma(reqdsize + 1)
DEF SEG = VARSEG(sma(0))
BLOAD "spr\sma.spr", VARPTR(sma(0))
DEF SEG
REDIM SHARED smb(reqdsize + 1)
DEF SEG = VARSEG(smb(0))
BLOAD "spr\smb.spr", VARPTR(smb(0))
DEF SEG
REDIM SHARED smc(reqdsize + 1)
DEF SEG = VARSEG(smc(0))
BLOAD "spr\smc.spr", VARPTR(smc(0))
DEF SEG
REDIM SHARED smd(reqdsize + 1)
DEF SEG = VARSEG(smd(0))
BLOAD "spr\smd.spr", VARPTR(smd(0))
DEF SEG
ON ERROR GOTO errorhandler
REDIM SHARED sme(reqdsize + 1)
DEF SEG = VARSEG(sme(0))
BLOAD "spr\apple.spr", VARPTR(sme(0))
DEF SEG
REDIM SHARED smf(reqdsize + 1)
DEF SEG = VARSEG(smf(0))
BLOAD "spr\banana.spr", VARPTR(smf(0))
DEF SEG
REDIM SHARED smg(reqdsize + 1)
DEF SEG = VARSEG(smg(0))
BLOAD "spr\rocket.spr", VARPTR(smg(0))
DEF SEG
REDIM SHARED smh(reqdsize + 1)
DEF SEG = VARSEG(smh(0))
BLOAD "spr\castle.spr", VARPTR(smh(0))
DEF SEG
REDIM SHARED smi(reqdsize + 1)
DEF SEG = VARSEG(smi(0))
BLOAD "spr\smi.spr", VARPTR(smi(0))
DEF SEG
REDIM SHARED smj(reqdsize + 1)
DEF SEG = VARSEG(smj(0))
BLOAD "spr\smj.spr", VARPTR(smj(0))
DEF SEG
ON ERROR GOTO 0
screenmap
REM ***************** DRAW INITIAL PLAYER *****************************
x = 0
y = 0
PUT (x, y), graphic(0), PSET
REM ******* FLIP THE PAGE ********
vpage = 0
apage = 1
SCREEN 9, 0, apage, vpage
PCOPY vpage, apage
REM ********* GAME LOOP ************************************************
WHILE a$ <> "q"
a$ = LCASE$(INKEY$)
IF a$ <> "" THEN
SELECT CASE a$
REM ****************** LEFT ***************
CASE "4":
IF x > 0 THEN
this$ = UCASE$(MID$(sm$(y), x + 1 - 1, 1))
IF this$ = "E" OR this$ = "F" OR this$ = "G" OR this$ = "H" THEN this$ = "B"
IF this$ = "B" THEN
repaint
x = x - 1
PUT (x * 20, y * 20), graphic(0), PSET
END IF
END IF
REM ****************** RIGHT **************
CASE "6":
IF x < 30 THEN
this$ = UCASE$(MID$(sm$(y), x + 1 + 1, 1))
IF this$ = "E" OR this$ = "F" OR this$ = "G" OR this$ = "H" THEN this$ = "B"
IF this$ = "B" THEN
repaint
x = x + 1
PUT (x * 20, y * 20), graphic(0), PSET
END IF
END IF
REM ****************** UP *****************
CASE "8":
IF y > 0 THEN
this$ = UCASE$(MID$(sm$(y - 1), x + 1, 1))
IF this$ = "E" OR this$ = "F" OR this$ = "G" OR this$ = "H" THEN this$ = "B"
IF this$ = "B" THEN
repaint
y = y - 1
PUT (x * 20, y * 20), graphic(0), PSET
END IF
END IF
REM ****************** DOWN ***************
CASE "2":
IF y < 15 THEN
this$ = UCASE$(MID$(sm$(y + 1), x + 1, 1))
IF this$ = "E" OR this$ = "F" OR this$ = "G" OR this$ = "H" THEN this$ = "B"
IF this$ = "B" THEN
repaint
y = y + 1
PUT (x * 20, y * 20), graphic(0), PSET
END IF
END IF
CASE "R":
screenmap
PUT (x * 20, y * 20), graphic(0), PSET
REM ****************** SPACE BAR ***************
CASE " ", CHR$(13):
this$ = UCASE$(MID$(sm$(y), x + 1, 1))
SELECT CASE this$
CASE "E":
REM apple
CHDIR "c:\mario"
SHELL "c:\mario\df.exe"
CHDIR "c:\qb"
CASE "F":
REM banana
CHDIR "c:\jill"
SHELL "c:\jill\jill.exe"
CHDIR "c:\qb"
CASE "G":
REM rocket
CHDIR "c:\keen"
SHELL "c:\keen\keen1.exe"
CHDIR "c:\qb"
CASE "H":
REM castle
CHDIR "c:\fun23"
SHELL "c:\fun23\fun23.exe"
CHDIR "c:\qb"
END SELECT
SCREEN 0
CLS
SCREEN 9
CLS
SCREEN 9, 0, 1, 0
CLS
loadscreenmap
screenmap
PUT (x * 20, y * 20), graphic(0), PSET
PCOPY 1, 0
apage = 1
vpage = 0
END SELECT
flippage
END IF
WEND
SCREEN 0
END
errorhandler:
RESUME NEXT
SUB flippage
REM ******** FLIP THE PAGE **************
IF vpage = 0 THEN
vpage = 1
apage = 0
ELSE
vpage = 0
apage = 1
END IF
SCREEN 9, 0, apage, vpage
PCOPY vpage, apage
END SUB
SUB loadscreenmap
OPEN "screen.map" FOR INPUT AS 1
FOR x1 = 0 TO 16
LINE INPUT #1, sm$(x1)
NEXT x1
CLOSE 1
END SUB
SUB repaint
this$ = UCASE$(MID$(sm$(y), x + 1, 1))
SELECT CASE this$
CASE "A":
PUT (x * 20, y * 20), sma(0), PSET
CASE "B":
PUT (x * 20, y * 20), smb(0), PSET
CASE "C":
PUT (x * 20, y * 20), smc(0), PSET
CASE "D":
PUT (x * 20, y * 20), smd(0), PSET
CASE "E":
PUT (x * 20, y * 20), sme(0), PSET
CASE "F":
PUT (x * 20, y * 20), smf(0), PSET
CASE "G":
PUT (x * 20, y * 20), smg(0), PSET
CASE "H":
PUT (x * 20, y * 20), smh(0), PSET
CASE "I":
PUT (x * 20, y * 20), smi(0), PSET
CASE "J":
PUT (x * 20, y * 20), smj(0), PSET
END SELECT
END SUB
SUB screenmap
REM **************** DRAW SCREEN GRAPHICS *****************************
FOR y1 = 0 TO 15
FOR x1 = 0 TO 30
this$ = UCASE$(MID$(sm$(y1), x1 + 1, 1))
SELECT CASE this$
CASE "A":
PUT (x1 * 20, y1 * 20), sma(0), PSET
CASE "B":
PUT (x1 * 20, y1 * 20), smb(0), PSET
CASE "C":
PUT (x1 * 20, y1 * 20), smc(0), PSET
CASE "D":
PUT (x1 * 20, y1 * 20), smd(0), PSET
CASE "E":
PUT (x1 * 20, y1 * 20), sme(0), PSET
CASE "F":
PUT (x1 * 20, y1 * 20), smf(0), PSET
CASE "G":
PUT (x1 * 20, y1 * 20), smg(0), PSET
CASE "H":
PUT (x1 * 20, y1 * 20), smh(0), PSET
CASE "I":
PUT (x1 * 20, y1 * 20), smi(0), PSET
CASE "J":
PUT (x1 * 20, y1 * 20), smj(0), PSET
END SELECT
NEXT x1
NEXT y1
END SUB