xzerix Posted March 5, 2012 Share Posted March 5, 2012 Hi all, is there a quick way of loading a block of 1024bytes in Atari BASIC? So far I'm using: 1000 CHSET=152*256:POKE 106,152:GRAPHICS 0 1010 OPEN #1,4,0,"D:MYFONT.FNT" 1020 FOR I=0 TO 1023 1030 GET #1,J:POKE CHSET+I,J 1040 NEXT I 1050 POKE 756,152 Which takes an age.... I'm guessing I should be GETing 1024 bytes at a time and not 1 byte 1024 times? Thanks... Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 5, 2012 Share Posted March 5, 2012 (edited) I want to do something similar with USR routines and I haven't found a solution yet. I want to store the length of the USR routine in the first two bytes of the file, followed by the actual USR code. I wanted to GET the first two bytes and then just READ the rest but I haven't found anything that lets me do that in standard Atari BASIC. Turbo BASIC lists BPUT and BGET but Turbo BASIC only works on XL/XE machines. http://www.atariarch.../12/02/0007.php <edit> OSS's BASIC XL and BASIC XE also support BGET and BPUT. http://www.atariarch.../05/10/0018.php I have BASIC XL so I will probably just write two versions. One SLOW version for Atari BASIC and another for BASIC XL, BASIC XE, and Turbo BASIC You should also look at RGET and RPUT. Edited March 5, 2012 by JamesD Quote Link to comment Share on other sites More sharing options...
+MrFish Posted March 5, 2012 Share Posted March 5, 2012 BASIC Turbocharger includes fast machine language load routines for character sets and micropainter files. The disks also include source files which could be used to create more general purpose routines. I've included a text file, which has a partial listing of the contents of the disks. BASIC Turbocharger.zip Quote Link to comment Share on other sites More sharing options...
+CharlieChaplin Posted March 5, 2012 Share Posted March 5, 2012 Hmm, I am no programmer, but afaik somewhere in my collection I have some tools that can convert fonts into DATA lines and then Data lines into a string. And I guess a string can be read in much faster than Data-lines or an external font... But as said before, I am no programmer... -Andreas Koch. Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 5, 2012 Share Posted March 5, 2012 The BASIC XL manual can be downloaded from this page if you decide to take that route: http://www.8bitclassics.com/Shop/vmchk/Atari/XL/Cartridges/amax-basicxl-Atari-BASIC-XL-Programming-Language.html Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 5, 2012 Share Posted March 5, 2012 Hi all, is there a quick way of loading a block of 1024bytes in Atari BASIC? So far I'm using: 1000 CHSET=152*256:POKE 106,152:GRAPHICS 0 1010 OPEN #1,4,0,"D:MYFONT.FNT" 1020 FOR I=0 TO 1023 1030 GET #1,J:POKE CHSET+I,J 1040 NEXT I 1050 POKE 756,152 Which takes an age.... I'm guessing I should be GETing 1024 bytes at a time and not 1 byte 1024 times? Thanks... Using BGET (at least I think this would be it, I haven't tested any code using BGET yet): 1000 CHSET=152*256:POKE 106,152:GRAPHICS 0 1010 OPEN #1,4,0,"D:MYFONT.FNT" 1020 BGET #1,CHSET,1024 1030 CLOSE #1 1040 POKE 756,152 Quote Link to comment Share on other sites More sharing options...
+Eyvind Bernhardsen Posted March 5, 2012 Share Posted March 5, 2012 is there a quick way of loading a block of 1024bytes in Atari BASIC? Yes, for certain values of "in Atari BASIC". There's a well-known machine language subroutine which translates to ATASCII as "hhh*LVd" (where the * and d are inverse video). Try replacing lines 1020-1040 in your program with these: 1020 POKE 852,0:POKE 853,152:REM Put low and high address bytes in IOCB #1 1030 POKE 856,0:POKE 857,4:REM Ditto for low and high length bytes 1040 POKE 850,7:I=USR(ADR("hhh*LVd"),16):REM * and d are inverse video, 7 is the "get" command, 16 is IOCB #1 Please let me know if this works, it's completely untested 1 Quote Link to comment Share on other sites More sharing options...
xzerix Posted March 6, 2012 Author Share Posted March 6, 2012 Wow. Pure BASIC, under emulation on Altirra took 804 Jiffies. (so 804/50=16.08 seconds). This method? FOUR (=0.08 seconds). Not sure how well it'll work with real hardware but it's gotta be good. is there a quick way of loading a block of 1024bytes in Atari BASIC? Yes, for certain values of "in Atari BASIC". There's a well-known machine language subroutine which translates to ATASCII as "hhh*LVd" (where the * and d are inverse video). Try replacing lines 1020-1040 in your program with these: 1020 POKE 852,0:POKE 853,152:REM Put low and high address bytes in IOCB #1 1030 POKE 856,0:POKE 857,4:REM Ditto for low and high length bytes 1040 POKE 850,7:I=USR(ADR("hhh*LVd"),16):REM * and d are inverse video, 7 is the "get" command, 16 is IOCB #1 Please let me know if this works, it's completely untested 1 Quote Link to comment Share on other sites More sharing options...
xzerix Posted March 6, 2012 Author Share Posted March 6, 2012 Thanks to eveyone who replied... Mr Fish, I have a lot of code to play around with here BASIC Turbocharger includes fast machine language load routines for character sets and micropainter files. The disks also include source files which could be used to create more general purpose routines. I've included a text file, which has a partial listing of the contents of the disks. BASIC Turbocharger.zip Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 6, 2012 Share Posted March 6, 2012 Wow. Pure BASIC, under emulation on Altirra took 804 Jiffies. (so 804/50=16.08 seconds). This method? FOUR (=0.08 seconds). Not sure how well it'll work with real hardware but it's gotta be good. If you have fast I/O enabled it might not be so fast on real hardware, but then the looped version will be even worse. Well worth the code change I'd say. What I can't understand is why they wouldn't build in another mode when that's already in the ROM. But I guess maybe they were out of ROM space. Quote Link to comment Share on other sites More sharing options...
Fox-1 / mnx Posted March 6, 2012 Share Posted March 6, 2012 BPUT and BGET are not available in Atari BASIC. Of course with mentioned tricks it's doable. When using Sparta-Dos one can use the XIO#40 / XIO#41 commands to load/save blocks of data. Quote Link to comment Share on other sites More sharing options...
+Eyvind Bernhardsen Posted March 6, 2012 Share Posted March 6, 2012 (edited) Wow. Pure BASIC, under emulation on Altirra took 804 Jiffies. (so 804/50=16.08 seconds). This method? FOUR (=0.08 seconds). Well, it'll take longer on a real machine, but only because it takes time to find and read a file from disk. Since this is the programming forum I thought I'd translate the string: PLA PLA PLA TAX JMP $E456 ; CIOV The PLAs gets rid of the argument count and the high-order byte of the argument, leaving the low-order byte (16 in the above example, representing IOCB #1) in the accumulator. TAX transfers that value to the X register where it needs to be, and finally JMP $E456 jumps to CIO and lets the OS do the heavy lifting using the values POKEd into IOCB #1 earlier. So elegant. If there's only one thing that makes the Atari OS stand out from other OSes of its time, it's CIO. Edited March 6, 2012 by Eyvind Bernhardsen Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 6, 2012 Share Posted March 6, 2012 ... I have BASIC XL so I will probably just write two versions. One SLOW version for Atari BASIC and another for BASIC XL, BASIC XE, and Turbo BASIC ... BPUT and BGET are not available in Atari BASIC. Of course with mentioned tricks it's doable. When using Sparta-Dos one can use the XIO#40 / XIO#41 commands to load/save blocks of data. I guess I wasn't obvious about BPUT and BGET not being in ATARI BASIC. Quote Link to comment Share on other sites More sharing options...
Synthpopalooza Posted March 7, 2012 Share Posted March 7, 2012 (edited) This may help out. I have a BASIC utility called CONVERT.BAS that will take any file, for example a font file, binary file, or screen file, and convert it into string assignments or DATA statements in a .LST file which can then be merged with your BASIC program. The thread is linked here: http://www.atariage...._1#entry1813361 The real advantage is if you convert your font file into string assignments. It will automatically store the font into a string called S$ (which is 1024 bytes long) and provide the code that loads the string into RAM, below RAMTOP. This is done by messing around with the string offset and making the String point to RAMTOP. Any operations on the string immediately reflect RAMTOP, so the entire font file is loaded into RAM almost instantaneously. Allowances are also made in the code for CHR$(34) and CHR$(155) in the string assignments as well. When you run the program, you will want to select String assignments, and reply "N" when it asks you if the file is a binary file. If you reply "Y" the first six bytes of the file are automatically stripped. Hope this helps! Edited March 7, 2012 by Synthpopalooza Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 8, 2012 Share Posted March 8, 2012 (edited) is there a quick way of loading a block of 1024bytes in Atari BASIC? Yes, for certain values of "in Atari BASIC". There's a well-known machine language subroutine which translates to ATASCII as "hhh*LVd" (where the * and d are inverse video). Try replacing lines 1020-1040 in your program with these: 1020 POKE 852,0:POKE 853,152:REM Put low and high address bytes in IOCB #1 1030 POKE 856,0:POKE 857,4:REM Ditto for low and high length bytes 1040 POKE 850,7:I=USR(ADR("hhh*LVd"),16):REM * and d are inverse video, 7 is the "get" command, 16 is IOCB #1 Please let me know if this works, it's completely untested 2nd attempt. It took a little while but I finally found a page documenting some of this. http://www.atariarchives.org/alp/chapter_9.php Edited March 8, 2012 by JamesD Quote Link to comment Share on other sites More sharing options...
Gury Posted May 6, 2021 Share Posted May 6, 2021 Here is Atari BASIC demo with loading character set instantly (bold characters): 10 REM ****************************** 20 REM LOAD CHARACTER SET FROM FILE 30 REM ****************************** 40 CHRAM=PEEK(106)-4 50 POKE 106,CHRAM 60 GRAPHICS 0 70 FOR I=0 TO 255 80 IF I>32 AND I<125 THEN ? CHR$(I); 90 NEXT I 100 REM LOAD FONT SET FROM FILE 110 OPEN #1,4,0,"H1:BOLD.FNT" 120 REM PREPARE CIO FOR FASTER FILE LOAD 130 X=16:DIM ML$(7) 140 ML$="hhh*LV*":ML$(4,4)=CHR$(170):ML$(7,7)=CHR$(228) 150 ICCOM=834:ICBADR=836:ICBLEN=840 160 REM High and low address for IOCB #1 170 POKE ICBADR+X+1,CHRAM:POKE ICBADR+X,0 180 POKE ICBLEN+X+1,4:POKE ICBLEN+X,0 190 REM CALL CIO (7 = "get" command, 16 = IOCB #1) 200 POKE ICCOM+X,7:A=USR(ADR(ML$),X) 210 CLOSE #1 220 REM MODIFY CHARACTER SET POINTER 230 POKE 756,CHRAM The listing is prepared for display on any text editor, that's the reason the machine language code in ML$ string is modified a little to eliminate the need for inverse characters. FONTLOAD.BAS BOLD.FNT 4 Quote Link to comment Share on other sites More sharing options...
ascrnet Posted May 6, 2021 Share Posted May 6, 2021 On 3/5/2012 at 7:07 PM, Eyvind Bernhardsen said: Yes, for certain values of "in Atari BASIC". There's a well-known machine language subroutine which translates to ATASCII as "hhh*LVd" (where the * and d are inverse video). Try replacing lines 1020-1040 in your program with these: you reminded me of another version that they use in the pirate's treasure stage copier. PLA LDX #$30 JMP $E456 always caught my attention as a child, today thanks to all the information the mystery is solved. ? 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.