forked from RetroBattlestations/HalloweenBoogaloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPM_MBasic.txt
91 lines (91 loc) · 3.22 KB
/
CPM_MBasic.txt
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
100 REM BASIC Week 2: Halloween Boogaloo
110 REM http://reddit.com/r/RetroBattlestations
120 REM written by FozzTexx
130 REM port for CP/M MBasic 5.21 by "CallMeLightningJunior"
135 REM cursor positioning for Visual 200 terminal
140 REM ----
200 REM Clear screen and setup variables
210 GOSUB 3010
220 CL = 80:RW = 24:REM Columns and Rows of screen
300 REM Load background and draw on screen
310 GOSUB 1510
320 NR = SR:WD = SC:WX = -2
330 X = 2:KF = X + WD:IF RND(1) > .5 THEN X = CL - WD - 2:KF = 0
340 Y = RW - NR:KW = CL - WD - 4
350 GOSUB 2010
500 REM Load sprites into variables
510 GOSUB 1510:BT$(0) = SP$:BE$ = SE$:BC = SC
520 GOSUB 1510:BT$(1) = SP$
530 GOSUB 1510:WT$ = SP$:WE$ = SE$:WW = SC:WH = SR
600 REM Animation
610 NB = 3:WX = -2
620 FOR I = 1 TO NB
630 BX(I) = INT(RND(1) * (KW - BC)):BY(I) = INT(RND(1) * ((RW - 4 - NR / 2) / NB)) * NB + I + 1
640 BW(I) = INT(RND(1) * 2):BF(I) = INT(RND(1) * 9)
650 NEXT I
660 FOR I = 1 TO NB
670 Y = INT(BF(I) / 3):X = INT((BF(I) / 3 - Y) * 3 + .05)
680 X = X + BX(I) + KF :Y = Y + BY(I):SP$ = BE$:GOSUB 2010
710 BW(I) = BW(I) + 1:IF BW(I) > 1 THEN BW(I) = 0
720 BF(I) = INT(RND(1) * 9)
730 Y = INT(BF(I) / 3):X = INT((BF(I) / 3 - Y) * 3 + .05)
740 X = X + BX(I) + KF :Y = Y + BY(I):SP$ = BT$(BW(I)):GOSUB 2010
750 IF WX = -1 THEN SP$ = WE$:X = 0:Y = 0:GOSUB 2010:WX = -2
760 IF WX >= 0 THEN SP$ = WT$:X = WX:Y = 0:GOSUB 2010:WX = WX - 1
769 REM remove random witch delay -- I wanted to be sure to see this
770 REM IF WX = -2 AND WH + NR < RW AND RND(1) * 50 < 2 THEN WX = CL - WW - 1
771 IF WX = -2 THEN WX = CL - WW - 1
780 NEXT I
790 GOTO 660
1000 REM Position cursor at X,Y
1005 REM for Visual 200 terminal -- ESC "Y" row + 32 col + 32
1010 PRINT CHR$(27);"Y";CHR$(Y+32);CHR$(X+32);
1020 RETURN
1500 REM Load a sprite from DATA into a string
1510 SP$ = "":SE$ = "":SR = 0:SC = 0
1520 READ T$,S$:IF LEN(SP$) > 0 THEN SP$ = SP$ + CHR$(13)
1530 SP$ = SP$ + S$:SR = SR + 1:IF LEN(S$) > SC THEN SC = LEN(S$)
1540 BL$ = "":FOR I = 1 TO LEN(S$):BL$ = BL$ + " ":NEXT I
1550 IF LEN(SE$) > 0 THEN SE$ = SE$ + CHR$(13)
1560 SE$ = SE$ + BL$
1570 IF T$ <> "SE" THEN GOTO 1520
1580 RETURN
2010 SE = 1:SB = 1
2020 SE = INSTR(SB, SP$, CHR$(13))
2030 IF SE = 0 THEN SE = LEN(SP$) + 1
2040 GOSUB 1010
2050 PRINT MID$(SP$, SB, SE - SB): REM newline needed after print to avoid some drawing artifacts
2060 IF SE >= LEN(SP$) THEN RETURN
2070 IF ASC(MID$(SP$, SE)) = 13 THEN SE = SE + 1
2080 SB = SE:Y = Y + 1:GOTO 2020
3000 REM Clear screen
3005 REM couldn't get cleaner way to work, so just line feeds
3010 FOR I = 1 TO 24
3020 PRINT CHR$(10);
3030 NEXT I
3040 RETURN
5000 DATA SP," ^"
5010 DATA SP," / \"
5020 DATA SP," //|\\"
5030 DATA SP," / -+- \"
5040 DATA SP," / \|/ \"
5050 DATA SP," /_________\"
5060 DATA SP," | ___ |"
5070 DATA SP," || | ||::::"
5080 DATA SP," /\ |-+-||IIII"
5090 DATA SP," / \|_|_|| \"
5100 DATA SP," / [] \ |_____"
5110 DATA SP,"/_____ | +-+|"
5120 DATA SP," | +--+ | |+||"
5130 DATA SP," | | | | +-+|"
5140 DATA SP," | |o | |____|"
5150 DATA SE," |___|__|_|"
5160 DATA SE,"^v^"
5170 DATA SE,"-v-"
5180 DATA SP," , "
5190 DATA SP," _/(_ "
5200 DATA SP," {\\ "
5210 DATA SP," /;_) "
5220 DATA SP,"=='/ <===<<< "
5230 DATA SP," \__\ "
5240 DATA SE," `` "