1 ' GRAFTRAX as a subroutine 9/21/84 10 DEFINT A-Z 20 GOSUB 300 ' draw some graphics for demo. not needed in your program. 30 ' Make sure variables used in this routine are defined BEFORE they are used, 32 ' in other words, put lines 60-110 in early in your program. 34 ' Integer variable descriptors, i.e. variable% should be used 36 ' if a DEFINT statement is not present. 38 ' 40 ' ****************** SETUP **** use lines 60-120 in your program. 42 ' 60 DATA &h55,&H8b,&Hec,&H8b,&H76,&H06,&H8b,&H1c,&H8b 70 DATA &He3,&Hcd,&H05,&H8b,&He5,&H5d,&Hca,&H02,&H00 80 X%=0 : Y%=0 : Z%=0 : GRAFTRAX%=0 : GRSEG!=0 : A$="" 90 DIM STACK%(50),CG%(10) 100 DEF SEG : Y% = VARPTR(CG%(0)) 110 FOR X% = 0 TO 17 : READ Z% : POKE X% + Y% ,Z% : NEXT ' poke into an array 120 DEF SEG=0 : X%=PEEK(&H16) : Y%=PEEK(&H17) : DEF SEG : GRSEG!=X%+(256*Y%) 121 ' 122 ' GRSEG is the segment where DOS put GRAFTRAX.COM 123 ' 124 ' ***************** END of SETUP ******************************** 125 ' 130 INPUT "(s)mall or (L)ARGE or (e)nd";A$ : A$=LEFT$(A$,1) : IF A$="" THEN END 135 IF A$="e" OR A$="E" THEN COLOR 7,0 : END 140 IF A$="l" OR A$="L" OR A$="2" THEN X% = 2 ELSE X% = 1 145 GOSUB 160 : GOTO 130 147 ' 150 ' ******** ACTUAL ROUTINE - use in your program. ********** 151 ' 152 ' This is the code to use GRAFTRAX as a subroutine. 153 ' 154 ' The POKE in 170 sets which routine to do, can be POKEd once and 155 ' left alone until a different size picture is needed. 156 ' 160 DEF SEG = GRSEG! 170 POKE &H10D,X% ' X%=1 for small, 2 for LARGE. 175 ' %H10d is a variable in GRAFTRAX.COM 180 DEF SEG 190 GRAFTRAX% = VARPTR(CG%(0)) : Y% = VARPTR(STACK%(50)) ' stack builds DOWN. 200 CALL GRAFTRAX%(Y%) ' y% is a pointer to a temporary stack, 205 ' since BASIC only leaves 16 bytes. 210 RETURN 222 ' 224 ' ************************************************************* 226 ' 300 ' Get some graphics going for demo. 305 ' 310 KEY OFF 320 SCREEN 1,0 330 COLOR 1,0 : CLS 340 CIRCLE (160,100),50,3 : CIRCLE (160,100),75,3 : PAINT (160,100),1,3 : PAINT(160,40),2,3 ' draw some graphics 350 RETURN