+Vorticon Posted October 13, 2022 Share Posted October 13, 2022 Hi. I'm working on minimizing the loading time of a large program with the use of the XB prescan directives !@P- and !@P+ and I'm having issues with the SUB sections of the code. I'm using the GOTO method as outlined in the XB manual's addendum where I set up a GOTO statement to where I want the prescan to stop in the program, then list all the variables and CALL statements used in the program followed by a !@P- just prior. According to the documentation, calls to user SUBs can also be listed in that section, but when I do that then I get a subprogram not found error. The only way to avoid that is to include the SUBs in the prescan by adding a @!P+ just before the first SUB. This does make program loading time somewhat longer. The confusing part is that in the section of the documentation where the standard use of the prescan directives is first discussed, it does state that user SUBs should be preceded by a !@P+. Since all my user SUBs have parameters, could that be the issue? Would the GOTO method only work for SUBs without parameters (kind of defeats the purpose of using SUBs then...)? Here's the code snippet in question: // Kroll & Prumni // By Walid Maalouli // Player movement and colonization phase // Version 10.12.22 // ************ // Data section // ************ // Planets Coordinates planets: DATA 9,11,19,19,17,25,15,37,27,23,33,6,37,36,48,17,49,22,49,42,56,8,60,36 // Prescan section GOTO initialize DIM HLIST(8),ELISTX(6),ELISTY(6),DLIST(12),MVX(10),MVY(10) X GX GY CURX CURY UCOUNT STATUS I KFT KCR KTR KCO KMB PFT PCR PTR PCO KHCOUNT PHCOUNT PHASE TURN SIDE MBOX Y T$ K MKEY HPOS VPOS C MX MY CSEL UID MIS DIRFLAG DIR DX DY OC DAM HSPC MVT BGND DSTX DSTY SY SX UX UY WX WY C$ PHASE$ MP OBSFLAG PX PY HX HY MC RX RY HCOUNT CCNT TCNT TDIR TBGND STATUSFLAG TYPE OFFSET COUNTF TKCO TPCO S$ S1$ SAD BYTE S D DELTA CALL INIT::CALL LOAD::CALL LINK::CALL PEEK CALL SCREEN::CALL CLEAR::CALL COLOR::CALL SPRITE::CALL LOCATE CALL GCHAR::CALL HCHAR::CALL KEY DEF ARCSIN(X)=ATN(X/SQR(1-X^2)) !@P- // ************** // Initialization // ************** initialize: Quote Link to comment Share on other sites More sharing options...
RXB Posted October 13, 2022 Share Posted October 13, 2022 Hmm this is not Extended Basic is it? Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted October 13, 2022 Author Share Posted October 13, 2022 13 minutes ago, RXB said: Hmm this is not Extended Basic is it? Come on Rich. Is this better for you? 100 DATA 9,11,19,19,17,25,15,37,27,23,33,6,37,36,48,17,49,22,49,42,56,8,60,36 110 GOTO 990 120 DIM HLIST(8),ELISTX(6),ELISTY(6),DLIST(12),MVX(10),MVY(10) 130 X 140 GX 150 GY 160 CURX 170 CURY 180 UCOUNT 190 STATUS 200 I 210 KFT 220 KCR 230 KTR 240 KCO 250 KMB 260 PFT 270 PCR 280 PTR 290 PCO 300 KHCOUNT 310 PHCOUNT 320 PHASE 330 TURN 340 SIDE 350 MBOX 360 Y 370 T$ 380 K 390 MKEY 400 HPOS 410 VPOS 420 C 430 MX 440 MY 450 CSEL 460 UID 470 MIS 480 DIRFLAG 490 DIR 500 DX 510 DY 520 OC 530 DAM 540 HSPC 550 MVT 560 BGND 570 DSTX 580 DSTY 590 SY 600 SX 610 UX 620 UY 630 WX 640 WY 650 C$ 660 PHASE$ 670 MP 680 OBSFLAG 690 PX 700 PY 710 HX 720 HY 730 MC 740 RX 750 RY 760 HCOUNT 770 CCNT 780 TCNT 790 TDIR 800 TBGND 810 STATUSFLAG 820 TYPE 830 OFFSET 840 COUNTF 850 TKCO 860 TPCO 870 S$ 880 S1$ 890 SAD 900 BYTE 910 S 920 D 930 DELTA 940 CALL INIT::CALL LOAD::CALL LINK::CALL PEEK 950 CALL SCREEN::CALL CLEAR::CALL COLOR::CALL SPRITE::CALL LOCATE 960 CALL GCHAR::CALL HCHAR::CALL KEY 970 DEF ARCSIN(X)=ATN(X/SQR(1-X^2)) 980 !@P- 990 RANDOMIZE Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted October 13, 2022 Share Posted October 13, 2022 Difficult to tell from just the snippet. I just ran some tests and things behaved as expected. How are you trying to call your SUB? If I leave out the CALL to a SUB in the pre-scan, my test program runs fine. If I include it, the program runs fine, also. I have a SUB called TESTY. In my pre-scan area I have CALL CLEAR::CALL TESTY::CALL SCREEN and everything is fine. BTW, you can put variables on the same line, something like X::Y::Z::A::B::C, for the pre-scanned area. 1 Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted October 13, 2022 Share Posted October 13, 2022 Here is another quick test. Remind, again, that line 11 does not need to include the CALL to my SUB, likely because the definition of TESTY is pre-scanned. 10 GOTO 100 11 CALL TESTY :: CALL CLEAR 12 X :: Y :: Z :: ABC 100 !@P- 101 X,Y,Z=12 :: PRINT X;Y;Z 102 ABC=123 :: PRINT ABC 103 CALL TESTY(ABC) 105 STOP 199 !@P+ 200 SUB TESTY(TT) 201 PRINT "ABC*3 =";TT*3 202 SUBEND 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted October 13, 2022 Share Posted October 13, 2022 27 minutes ago, OLD CS1 said: Difficult to tell from just the snippet. I just ran some tests and things behaved as expected. How are you trying to call your SUB? If I leave out the CALL to a SUB in the pre-scan, my test program runs fine. If I include it, the program runs fine, also. I have a SUB called TESTY. In my pre-scan area I have CALL CLEAR::CALL TESTY::CALL SCREEN and everything is fine. BTW, you can put variables on the same line, something like X::Y::Z::A::B::C, for the pre-scanned area. Yea I thought the same thing about the variable on each line number seemed really odd considering you can use also do :: that will save more memory. 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted October 13, 2022 Share Posted October 13, 2022 You can also do this: 10 GOTO 100 11 TESTY :: CLEAR 12 X :: Y :: Z :: ABC 100 !@P- 101 X,Y,Z=12 :: PRINT X;Y;Z 102 ABC=123 :: PRINT ABC 103 CALL TESTY(ABC) 105 STOP 199 !@P+ 200 SUB TESTY(TT) 201 PRINT "TT*3 =";TT*3 202 SUBEND You do not need the CALL for just a PRESCAN as like variable it looks for any name including call names. You are skipping those lines anyway so not a issue. I can show you the GPL source code and Assembly ROMs source code on how this works if you want. Quote Link to comment Share on other sites More sharing options...
MikeV Posted October 13, 2022 Share Posted October 13, 2022 4 hours ago, Vorticon said: Hi. I'm working on minimizing the loading time of a large program with the use of the XB prescan directives !@P- and !@P+ and I'm having issues with the SUB sections of the code. I never had much luck implementing the XB prescan myself, always a glitch with something or other. Because of this I began to routinely use J. Peter Hoddie's, Pre-Scan-It! and have never had an issue since. (It's a smart program.) I do not recall the specifics re user defined SUN ROUTINES, so it may not be of value to you. 2 Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted October 13, 2022 Author Share Posted October 13, 2022 1 hour ago, OLD CS1 said: Here is another quick test. Remind, again, that line 11 does not need to include the CALL to my SUB, likely because the definition of TESTY is pre-scanned. 10 GOTO 100 11 CALL TESTY :: CALL CLEAR 12 X :: Y :: Z :: ABC 100 !@P- 101 X,Y,Z=12 :: PRINT X;Y;Z 102 ABC=123 :: PRINT ABC 103 CALL TESTY(ABC) 105 STOP 199 !@P+ 200 SUB TESTY(TT) 201 PRINT "TT*3 =";TT*3 202 SUBEND Ah OK I see where I went wrong. When I included my SUBs calls in the prescan area, I was not adding a !@P+ before the SUB section at the end of the program. Thanks for clarifying that. The manual sucks at explaining this properly. Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted October 13, 2022 Author Share Posted October 13, 2022 1 hour ago, RXB said: Yea I thought the same thing about the variable on each line number seemed really odd considering you can use also do :: that will save more memory. Yes indeed. I had just copied and pasted the variable list from the TICodEd IDE for quick testing. And actually, a comma between them will do just fine. No need for a double colon. Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted October 13, 2022 Author Share Posted October 13, 2022 50 minutes ago, MikeV said: I never had much luck implementing the XB prescan myself, always a glitch with something or other. Because of this I began to routinely use J. Peter Hoddie's, Pre-Scan-It! and have never had an issue since. (It's a smart program.) I do not recall the specifics re user defined SUN ROUTINES, so it may not be of value to you. I've heard of that program but never used it. The main difficulty with doing this manually is making sure ALL the variables and CALL statements are included in the prescan area. It's easy to miss some in large programs, and this is where TICodEd can be of tremendous help since it does keep a list of all variables used as well as the corresponding line number(s) where they appear. Extremely handy for debugging. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted October 13, 2022 Share Posted October 13, 2022 23 minutes ago, Vorticon said: And actually, a comma between them will do just fine. No need for a double colon. Oh, yeah, forgot about that. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.