I've been messing around with the powerful ZX BASIC on the '81 and came up with this little routine:
Code: Select all
1 REM TELETYPE ROUTINE BY SHAUN BEBBINGTON IN 2010. THIS IS FREEWARE SO USE IT AND IMPROVE IT ;-)**
2 FAST
3 LET A=16514
4 LET X=PI-PI
5 LET Y=X
6 LET N=X
7 SLOW
8 IF PEEK A=VAL "216" THEN GOTO VAL "17"
9 PRINT AT X,Y;CHR$ PEEK A;CHR$ 177
10 IF Y<=VAL "31" THEN LET Y=Y+(PI/PI)
11 IF Y=VAL "32" THEN LET N=PI/PI
12 IF N=VAL "1" THEN LET X=X+(PI/PI)
13 IF N=VAL "1" THEN LEY Y=PI-PI
14 LET N=PI-PI
15 LET A=A+(PI/PI)
16 GOTO VAL "8"
17 STOP
18 REM PUT THE REST OF YOUR CODE HERE IF YOU LIKE :-)
Okay, here is what it does. Firstly, there is no DATA statement, so what we're doing is storing what we want to write to the screen in a REM statement. This is basically where each character is, so what we need to do is read each character and then write it to the screen.
So, line 2 goes into FAST mode - you don't need to do this, it's just something I do when declaring variables and so on before I do anything more like write to the screen or such like. Line 3 sets up an integer called A and this is the location in memory where the start of the text is directly after the REM statement in line 1.
Line 4, 5 and 6 sets up the integers that we're going to use later on. PI-PI will always be zero, so it just makes X, Y and N equal to this.
Line 7 goes back to slow mode so that we'll see what's happening inside the TV screen (or virtual tele).
Line 8 checks wether or not we've reached the end of the text held in the REM statement in line 1. If so, it jumps to line 17 (end of program).
Line 9 PRINTs the byte held in the pointer in the A variable, followed by a familiar character (you'll see the relevance) and AT the location X (row) and Y (column).
Lin 10 checks if Y is smaller to or equal to 31, if so, it increases this variable by one as PI/PI is equal to 1. Then line 11 will check if Y has reached the end of the row and sets up a condition in N to tell the program to increment X by one and put Y back to zero (first column).
As we've already tested the condition N, we can return this to zero and also increase A by one. This then loops back around until the end of the text is reached by SHIFT and H (**).
From line 17, you can do what you like.
Have a play with it and see what you can make it do. For instance, you could add a condition in which the text is not output to the screen unless a key is being pressed, or something else.
Edit: Oops! Spotted a bug which was *ahem* deliberate, so I've fixed it
Regards,
Shaun.