Compucolor.org – Virtual Media

Listing of file='TTRL13.BAS;01' on disk='vmedia/BASIC_language_11-15-sector.ccvf'

100 REM COPYRIGHT (C) BY COMPUCOLOR 1980
105 REM BY KLH 7/17/80 REV 1.1
110 CLEAR 1000:ADR= 256* PEEK (32941)+ PEEK (32940)
115 IF ADR> 65484THEN PLOT 1
120 A2= 256* PEEK (ADR+ 50)+ PEEK (ADR+ 49):IF A2< > ADRTHEN PLOT 1
125 Q$= CHR$ (34):POKE ADR+ 41,3:POKE ADR+ 42,3
130 POKE ADR+ 44,1:POKE ADR+ 45,1
135 PLOT 6,0,12,3,20,7:PRINT "  THE FLAG STRUCTURE  
140 PRINT "
   AS WE BECOME A LITTLE MORE INVOLVED WITH HOW THE COMPUCOLOR
145 PRINT :PRINT " WORKS, IT'S TIME TO DEAL WITH A QUESTION THAT MAY HAVE CROSSED
150 PRINT :PRINT "   YOUR MIND AT TIMES; HOW DOES THE COMPUTER REMEMBER ALL THE
155 PRINT :PRINT " DIFFERENT THINGS IT IS DOING? THE ANSWER IS THERE IS A SYSTEM
160 PRINT :PRINT "WHICH KEEPS TRACK OF EVERYTHING HAPPENING WITH 32 MAGIC NUMBERS.
165 PRINT TAB( 11)"THIS SYSTEM IS CALLED THE FLAG STRUCTURE.
170 GOSUB 590
175 PLOT 3,4,4:PRINT "THE PHRASE FLAG STRUCTURE SOUNDS SLIGHTLY OMINOUS, BUT IT
180 PRINT :PRINT "  ISN'T SOMETHING THAT SHOULD SCARE YOU ENOUGH TO SWEAR OFF ANY
185 PRINT :PRINT "  FUTURE PROGRAMMING. IT IS A SIMPLE SYSTEM, AS YOU SHALL SEE.
190 PRINT :PRINT " IN CRT RAM THERE ARE CERTAIN LOCATIONS THAT ARE USED BY BASIC,
195 PRINT :PRINT "FCS, AND THE CRT SOFTWARE. THESE LOCATIONS ARE KEPT UPDATED WITH
200 PRINT "   FLAG VALUES, AND IN THIS WAY EACH PART OF THE SYSTEM KNOWS
205 PRINT :PRINT TAB( 6)"WHAT IT HAS BEEN DOING AND WHAT IT NEEDS TO DO NEXT.
210 PRINT :PRINT "  IN ROM THERE IS A FLAG TABLE. THIS TABLE HAS 32 ADDRESSES IN
215 PRINT :PRINT "ROM THAT CORRESPONDS TO THE 32 FLAG VALUES. BY GETTING THE FLAG
220 PRINT :PRINT "VALUE FROM ANY ONE OF THE CRT RAM LOCATIONS, THE NEXT PROCESS TO
225 PRINT "   BE PERFORMED IS FOUND. BECAUSE THE FLAGS CAUSE A CHANGE OF
230 PRINT :PRINT "  STATE INSIDE THE COMPUCOLOR, IT IS CALLED A "Q$"STATE MACHINE"Q$".
235 GOSUB 590:PLOT 3,4,8
240 PRINT "LET US LOOK AT THIS EXAMPLE: BASIC HAS A VALUE TO OUTPUT,
245 PRINT :PRINT "   BUT NEEDS TO KNOW WHERE TO OUTPUT. BY LOOKING AT THE BASIC
250 PRINT :PRINT "OUTPUT FLAG (33265), IT SEES THAT OUTPUT GOES TO VALUE 0 OF THE
255 PRINT :PRINT TAB( 4)"FLAG TABLE, WHICH IS THE SYSTEM DISPLAY ROUTINE. THE CODE
260 PRINT :PRINT " STARTING AT THE LOCATION REFERRED TO IN THE FLAG TABLE IS RUN,
265 PRINT :PRINT "	AND BASIC CONTINUES EXECUTING ITS BASIC PROGRAM.
270 GOSUB 590
275 PLOT 3,19,2:PRINT "THESE ARE THE FLAG VALUES:
280 PRINT "
0	SYSTEM DISPLAY ROUTINE
285 PRINT "1	BLIND CURSOR MODE DISPLAY ROUTINE
290 PRINT "2	GRAPHICS MODE (POINT PLOT)
295 PRINT "3	EXPECTING VISIBLE X CURSOR ADDRESS (TO 5)
300 PRINT "4	COLOR PAD PLOT MODE (NON-COLOR DISPLAYED BY 0)
305 PRINT "5	EXPECTING VISIBLE Y CURSOR ADDRESS (TO 0)
310 PRINT "6	EXPECTING VISIBLE CCI CODE (TO 0)
315 PRINT "7	EXPECTING BLIND CURSOR X ADDRESS (TO 8)
320 PRINT "8	EXPECTING BLIND CURSOR Y ADDRESS (TO 9)
325 PRINT "9	EXPECTING BLIND CCI CODE (TO 1)
330 PRINT "12	GARBAGE DUMP (ALL CHARACTERS IGNORED)
335 PRINT "13	FCS INPUT ROUTINE
340 PRINT "14	SERIAL PORT OUTPUT
345 PRINT "18	EXPECTING BAUD RATE 0-7 (TO 0)
350 PRINT "23	BASIC INPUT ROUTINE
355 PRINT "25	EXPECTING FILL SCREEN CHARACTER (TO 0)
360 PRINT "27	EXPECTING ESCAPE SEQUENCE (TO 0,4,13,18,23,25)
365 PRINT "OTHERS	TO USER INPUT FLAG JUMP VECTOR (ADDRESSES 33221-33223)
370 PRINT :PRINT TAB( 3)"NOTE THAT SOME OF THE FLAGS POINT TO ONE ANOTHER, SUCH AS
375 PRINT "  THE VISIBLE CURSOR ADDRESS FLAGS (PLOT 3,X,Y). WHEN YOU DO A
380 PRINT "  PLOT 3,31,15 FROM BASIC THE FLAG VALUE IN 33265 CHANGES TO 3
385 PRINT " WHEN IT FINDS THE 3. NEXT IT CHANGES TO 5 AFTER THE X VALUE IS
390 PRINT "	PROCESSED, AND BACK TO 0 WHEN THE Y VALUE IS USED.
395 GOSUB 590
400 PLOT 3,5,9:PRINT "NOW THAT YOU KNOW ALL THIS, FURTHER QUESTIONS MIGHT BE
405 PRINT :PRINT "  RAISED, LIKE "Q$"WHAT DO I DO WITH THIS?"Q$". THE MAIN USE IS TO BE
410 PRINT :PRINT " IN FULL CONTROL OF WHERE BASIC, FCS, AND THE CRT SOFTWARE SEND
415 PRINT :PRINT TAB( 11)"THEIR OUTPUT. LET'S TAKE A COMMON EXAMPLE;
420 PRINT :PRINT TAB( 21)"USING THE SERIAL PORT.":GOSUB 590:PLOT 3,3,5
425 PRINT "SUPPOSE YOU WISH TO SEND BASIC'S OUTPUT TO THE RS-232, AND
430 PRINT :PRINT "   TO TAKE INPUT FROM THERE ALSO. BY POKING A 14 IN THE BASIC
435 PRINT :PRINT "OUTPUT FLAG, AND A 23 IN THE INPUT PORT FLAG, IT IS VERY EASILY
440 PRINT :PRINT " DONE (14 FOR THE PORT, AND 23 FOR BASIC INPUT). THIS PROCEDURE
445 PRINT :PRINT " WILL ALLOW INPUT FROM THE PORT AND KEYBOARD. TO INPUT FROM THE
450 PRINT :PRINT " PORT ONLY, THE ADDRESS OF THE INPUT PORT FLAG SHOULD BE POKED
455 PRINT :PRINT "  INTO LOCATIONS 33280 (LOW) AND 33281 (HIGH). THESE LOCATIONS
460 PRINT :PRINT "   HOLD THE ADDRESS OF BASIC'S INPUT FLAG (NORMALLY THEY POINT

465 PRINT "  TO THE KEYBOARD FLAG). SIMILARLY, TO SEND BASIC'S OUTPUT BACK
470 PRINT :PRINT "  TO THE SCREEN, A 0 MUST BE POKED IN 33265. BASIC WILL RESET
475 PRINT :PRINT TAB( 6)"THE FLAG OF THE LOCATION POINTED TO BY 33280-33281.
480 GOSUB 590
485 PLOT 3,2,7:PRINT "SINCE THE PORT IS A VERY IMPORTANT THING ON YOUR COMPUCOLOR,
490 PRINT :PRINT " HERE ARE SOME OTHER FLAG LOCATIONS THAT CAN BE USED TO "Q$"TALK"Q$"
495 PRINT :PRINT TAB( 7)"TO THE SERIAL PORT FROM BASIC, FCS, OR THE CRT MODE.
500 PRINT :PRINT :PRINT "		33247 : KEYBOARD FLAG
505 PRINT "		33249 : FCS INPUT FLAG
510 PRINT "		33251 : INPUT PORT FLAG
515 PRINT "		33265 : BASIC OUTPUT FLAG
520 PRINT "		33273 : LIST OUTPUT FLAG
525 PRINT "	  33280-33281 : POINTS TO BASIC'S INPUT FLAG LOCATION
530 GOSUB 590
535 PRINT "  THIS CONCLUDES TUTORIAL THIRTEEN. DO YOU WISH TO REVIEW THIS

540 INPUT "			LESSON (YES/NO)? ";ZZ$:IF LEFT$ (ZZ$,1)= "Y"THEN 135:REM 
545 IF LEFT$ (ZZ$,1)< > "N"THEN PLOT 28,11:GOTO 540
550 PRINT :PRINT "GO AHEAD AND TRY SOME OF WHAT HAS BEEN DISCUSSED IN THIS LESSON
555 PRINT "  (EVEN THOUGH I COULD DELAY YOU, BUT I'M IN A VERY GOOD MOOD
560 PRINT "   NOW) AND WHEN YOU'RE READY FOR TUTORIAL FOURTEEN HIT AUTO.
565 POKE ADR+ 41,4:POKE ADR+ 42,4:POKE ADR+ 44,0:POKE ADR+ 45,0:PLOT 27,11
570 POKE 33434,0:POKE 33435,0:END
575 IF ZZ$= "MENU"THEN LOAD ZZ$:RUN 170
580 IF PEEK (33278)< > 1THEN RETURN
585 PLOT 1
590 PRINT :INPUT "		    HIT RETURN TO CONTINUE: ";ZZ$:PLOT 12:GOTO 575