Jump to content

Photo

Loading Data in BASIC


14 replies to this topic

#1 xzerix OFFLINE  

xzerix

    Space Invader

  • 38 posts

Posted Mon Mar 5, 2012 12:17 PM

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...

#2 JamesD OFFLINE  

JamesD

    River Patroller

  • 4,797 posts

Posted Mon Mar 5, 2012 1:08 PM

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 by JamesD, Mon Mar 5, 2012 1:29 PM.


#3 MrFish OFFLINE  

MrFish

    River Patroller

  • 2,297 posts
  • Serious Computerist
  • Location:$02F5 - $02F9

Posted Mon Mar 5, 2012 1:33 PM

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.

Attached File  BASIC Turbocharger.zip   185.17KB   81 downloads

#4 CharlieChaplin OFFLINE  

CharlieChaplin

    Stargunner

  • 1,800 posts

Posted Mon Mar 5, 2012 1:42 PM

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.

#5 JamesD OFFLINE  

JamesD

    River Patroller

  • 4,797 posts

Posted Mon Mar 5, 2012 2:15 PM

The BASIC XL manual can be downloaded from this page if you decide to take that route:
http://www.8bitclass...g-Language.html

#6 JamesD OFFLINE  

JamesD

    River Patroller

  • 4,797 posts

Posted Mon Mar 5, 2012 2:57 PM

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


#7 Eyvind Bernhardsen OFFLINE  

Eyvind Bernhardsen

    Space Invader

  • 33 posts

Posted Mon Mar 5, 2012 4:07 PM

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 :)

#8 xzerix OFFLINE  

xzerix

    Space Invader

  • Topic Starter
  • 38 posts

Posted Tue Mar 6, 2012 8:52 AM

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. :thumbsup:


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 :)



#9 xzerix OFFLINE  

xzerix

    Space Invader

  • Topic Starter
  • 38 posts

Posted Tue Mar 6, 2012 8:55 AM

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.

Attached File  BASIC Turbocharger.zip   185.17KB   81 downloads



#10 JamesD OFFLINE  

JamesD

    River Patroller

  • 4,797 posts

Posted Tue Mar 6, 2012 11:10 AM

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. :thumbsup:

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.

#11 Fox-1 / mnx OFFLINE  

Fox-1 / mnx

    Stargunner

  • 1,188 posts
  • What is your Alternate Reality?
  • Location:NL, Earth 2.0

Posted Tue Mar 6, 2012 2:45 PM

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.

#12 Eyvind Bernhardsen OFFLINE  

Eyvind Bernhardsen

    Space Invader

  • 33 posts

Posted Tue Mar 6, 2012 2:57 PM

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 by Eyvind Bernhardsen, Tue Mar 6, 2012 2:58 PM.


#13 JamesD OFFLINE  

JamesD

    River Patroller

  • 4,797 posts

Posted Tue Mar 6, 2012 5:12 PM

...
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.

#14 Synthpopalooza OFFLINE  

Synthpopalooza

    Dragonstomper

  • 990 posts
  • Location:knoxville, TN

Posted Tue Mar 6, 2012 6:41 PM

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 by Synthpopalooza, Tue Mar 6, 2012 6:46 PM.


#15 JamesD OFFLINE  

JamesD

    River Patroller

  • 4,797 posts

Posted Thu Mar 8, 2012 12:44 PM


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.atariarch...p/chapter_9.php

Edited by JamesD, Thu Mar 8, 2012 12:46 PM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users