0 REM Typewriter DAZTYPE.BAS.txt

1 REM SetUp the DAZZLER for Sketching Color Lines
2 DZOP "I"     : REM Initialize DAZZLER
3 DZOP "Z"     : REM Clear Screen

4 INPUT "Black & White (0) or Color (1) Text";TXT
5 DZOP "C", TXT   : REM Set Color Mode Black & White
6 INPUT "What Color Text (17 - 23)";TC

20 GOSUB 1000                          : REM Clear the screen before displaying the message
30 Y = 240                             : REM Set starting Y position
40 FOR J = 0 TO 7                      : REM Line Count
50 Y = Y - 25                          : REM Move Y up for each new line
60 X = 0                               : REM Starting X position on the screen

70 INPUT "Enter your message: ", MSG$  : REM Get the input message

80 FOR I = 1 TO LEN(MSG$)              : REM Loop through each character in the message
90   CH$ = MID$(MSG$, I, 1)            : REM Get the current character
100   CH = ASC(CH$)                    : REM Convert the character to its ASCII code
110   IF CH >= 32 AND CH <= 127 THEN GOSUB 2000  : REM Only display characters in ASCII range 32-127 (includes numbers, comma, and period)
120   REM Adjust the spacing based on character width
130   IF CH$ = "I" OR CH$ = "L" OR CH$ = "J" THEN X = X + 14             : REM Narrow letters, less space
140   IF CH$ = "M" OR CH$ = "W" THEN X = X + 28                          : REM Wide letters, more space
150   IF CH$ <> "I" AND CH$ <> "L" AND CH$ <> "J" AND CH$ <> "M" AND CH$ <> "W" THEN X = X + 20 : REM Normal letters
160   IF X > 255 THEN X = 0 : Y = Y - 25 : IF Y < 0 THEN GOTO 3000       : REM Move to next line if X exceeds width, stop if Y exceeds screen height
170 NEXT I
180 NEXT J

200 FOR PAUSE = 0 TO 5000 : NEXT PAUSE
210 GOTO 20

1000 REM *** Clear the Screen Routine ***
1010 DZOP "Z"  : REM Set color to black
1020 RETURN

2000 REM *** Subroutine to display a character ***
2010 DZOP "C", TC    : REM Set color to yellow (19)
2020 IF X < 0 OR X > 255 OR Y < 0 OR Y > 255 THEN RETURN                 : REM Check X, Y bounds
2030 DZOP "P", X, Y  : REM Move to position X, Y
2040 DZOP "C", CH    : REM Display the character using its ASCII code
2050 RETURN

3000 REM *** Halt program if text goes beyond the screen ***
3010 PRINT "Reached end of screen. Program halted."
3020 END
