-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAIN.BAS
98 lines (78 loc) · 2.76 KB
/
MAIN.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
TYPE Position
x AS INTEGER
y AS INTEGER
END TYPE
DECLARE SUB printRow (row$, textPosition AS Position)
DECLARE FUNCTION selectAndPrintChar (char$, startPos AS Position)
DECLARE FUNCTION printChar (asciiArt$(), startPos AS Position)
REM $INCLUDE: 'ALPHABET.BI'
'** Data block 1 *****************
textHeight% = 2
'*********************************
DIM startPos(textHeight%) AS Position
DIM text(textHeight%) AS STRING
'** Data block 2 *****************
text(0) = "Ruhrpott"
text(1) = "Metaller"
startPos(0).x = 3
startPos(1).x = 7
startPosY% = 4
COLOR 10 'Light green
'*********************************
CLS
FOR numRow% = 0 TO textHeight% - 1
startPos(numRow%).y = startPosY% + charHeight * numRow%
CALL printRow(text(numRow%), startPos(numRow%))
NEXT numRow%
SLEEP
FUNCTION printChar (asciiArt$(), startPos AS Position)
'Save the y position because it is passed by reference
startPosY% = startPos.y
FOR asciiArtRowNumber% = 0 TO charHeight - 1
LOCATE startPos.y, startPos.x
PRINT asciiArt$(asciiArtRowNumber%)
startPos.y = startPos.y + 1
NEXT
'Write the y position back
startPos.y = startPosY%
printChar = LEN(asciiArt$(0))
END FUNCTION
SUB printRow (row$, startPos AS Position)
widthText% = LEN(row$)
FOR numChar% = 0 TO widthText% - 1
char$ = MID$(row$, numChar% + 1, 1)
widthChar% = selectAndPrintChar(char$, startPos)
startPos.x = startPos.x + widthChar% + 2
NEXT
END SUB
FUNCTION selectAndPrintChar (char$, startPos AS Position)
SELECT CASE char$
CASE "a"
widthChar% = printChar(lowercaseA(), startPos)
CASE "e"
widthChar% = printChar(lowercaseE(), startPos)
CASE "h"
widthChar% = printChar(lowercaseH(), startPos)
CASE "l"
widthChar% = printChar(lowercaseL(), startPos)
CASE "M"
widthChar% = printChar(uppercaseM(), startPos)
CASE "o"
widthChar% = printChar(lowercaseO(), startPos)
CASE "p"
widthChar% = printChar(lowercaseP(), startPos)
CASE "R"
widthChar% = printChar(uppercaseR(), startPos)
CASE "r"
widthChar% = printChar(lowercaseR(), startPos)
CASE "o"
widthChar% = printChar(lowercaseO(), startPos)
CASE "u"
widthChar% = printChar(lowercaseU(), startPos)
CASE "t"
widthChar% = printChar(lowercaseT(), startPos)
CASE ELSE
widthChar% = 0
END SELECT
selectAndPrintChar = widthChar%
END FUNCTION