Jump to content
IGNORED

GET and PUT source (Compute magazine) (software sprites for ATARI BASIC)


JamesD

Recommended Posts

Yep, no DIV or MOD but they're not exactly widespread.

AND is common though but Atari Basic only uses AND/OR/NOT in a simple boolean mode.

 

The common way of doing such things is:

 

H = INT(A/256) : L = A-H*256

 

I suppose if you had widespread need to get hi/lo bytes throughout a program you could do it in a couple of USR routines.

 

MOD256$ = " pla / pla / pla / sta $d4 / lda #0 / sta $d5 / rts "

DIV256$ = "pla / pla / tax / pla / stx $d5 / lda #0 / sta $d4 / rts "

I'm used to DIV and MOD from the TRS-80 CoCo.

Actually, I think AND is simple boolean mode on all the BASICs I've used. Been a long time since I've used BASIC.

Link to comment
Share on other sites

Correction for the AND mistake above. Use BASIC XL etc...

1000 OPEN #1,4,0,"D:GETPUT.USR": GET #1,LENL : GET #1,LENH :REM LET LEN =LENL + (256*LENH)
1010 LET ADDRL = ADR(GP$) MOD 256: LET ADDRH = ADR(GP$) DIV 256
1020 POKE 852,ADDRL:POKE 853,ADDRH:REM Put low and high address bytes in IOCB #1
1030 POKE 856,LENL:POKE 857,LENH: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
1050 CLOSE #1:RETURN

 

And for ATARI BASIC (still works in other versions btw).

1000 OPEN #1,4,0,"D:GETPUT.USR": GET #1,LENL : GET #1,LENH :REM LET LEN =LENL + (256*LENH)
1010 LET ADDRH = INT(ADR(GP$) / 256) : LET ADDRL = ADR(GP$) - (ADDRH * 256) 
1020 POKE 852,ADDRL:POKE 853,ADDRH:REM Put low and high address bytes in IOCB #1
1030 POKE 856,LENL:POKE 857,LENH: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
1050 CLOSE #1:RETURN

Link to comment
Share on other sites

This was the quickest way I could think of to implement the code to calculate the LSB and MSB of the length of the USR routine automatically.

It uses DIV and MOD which just about every BASIC other than standard ATARI BASIC supports.

Actually, I was referring to BASIC XL, BASIC XE, etc... and as it tuns out DIV and MOD is not even part of Extended Color Basic on the CoCo either. It has been a long time!

Link to comment
Share on other sites

I tried to get this to work on an emulator but I'm having some issues with the emulator I'll have to work out before I can finish testing it.

1000 REM READ USR ROUTINE FROM DATA AND WRITE TO DISK WITH HIGH SPEED I/O
1001 LET LENU = 244 : LET LENH = INT(LENU/256):LET LENL = LENU - LENH
1002 DIM GP$(LENU) : FOR I = 1 TO LENU : READ CODE : GP$(I,I)=CHR$(CODE) : NEXT I
1003 LET ADDRH = INT(ADR(GP$)/256) : LET ADDRL = INT(ADR(GP$)) - ADDRH
1004 OPEN #1,8,0,"D1:GETPUT.USR"
1005 PUT #1,LENL : PUT #1,LENH : REM LENGTH OF USR ROUTINE
1007 POKE 852,ADDRL : POKE 853,ADDRH : REM Put low and high address bytes in IOCB #1
1008 POKE 856,LENL : POKE 857,LENH : REM Ditto for low and high length bytes
1009 POKE 850,11:I=USR(ADR("hhh*LVd"),16):REM * and d are inverse video, 11 is the "PUT" command, 16 is IOCB #1
1010 CLOSE #1:RETURN

Edited by JamesD
Link to comment
Share on other sites

1003 LET ADDRH = INT(ADR(GP$)/256) : LET ADDRL = INT(ADR(GP$)) - ADDRH

should be

1003 LET ADDRH = INT(ADR(GP$)/256) : LET ADDRL = INT(ADR(GP$)) - ADDRH * 256

Thanks, I forgot that.

"LET" is optional, most people never use it.

Hallelujah! I was only including it because I saw it in some other code and figured it was mandatory on the Atari. I never understood why it wasn't just dropped from BASIC altogether.

Link to comment
Share on other sites

  • 1 year later...
  • 4 weeks later...

If anyone wants to use JamesD's/Compute's work above, I have included a link to this code ready to load and ready to save a little typing :) I changed the variables GET and PUT in the code to GT and PT, to avoid confusion on my part in some stuff I am working on. The only other (also very, very minor) changes are the +16 on line 30 - GRAPHICS 7+16 and JamesD's name to the attribution text screen.

 

https://drive.google.com/file/d/0B4qhA5OPZrPUS2RZenFwb2xzeWc/edit?usp=sharing

Link to comment
Share on other sites

If anyone wants to use JamesD's/Compute's work above, I have included a link to this code ready to load and ready to save a little typing :) I changed the variables GET and PUT in the code to GT and PT, to avoid confusion on my part in some stuff I am working on. The only other (also very, very minor) changes are the +16 on line 30 - GRAPHICS 7+16 and JamesD's name to the attribution text screen.

I didn't write it, no need to credit me. I appreciate the thought though.
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...