Jump to content



0

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


33 replies to this topic

#26 JamesD OFFLINE  

JamesD

    River Patroller

  • 3,014 posts

Posted Fri Mar 9, 2012 8:28 AM

View PostRybags, on Fri Mar 9, 2012 1:27 AM, said:

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.

#27 JamesD OFFLINE  

JamesD

    River Patroller

  • 3,014 posts

Posted Fri Mar 9, 2012 8:35 AM

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


#28 JamesD OFFLINE  

JamesD

    River Patroller

  • 3,014 posts

Posted Fri Mar 9, 2012 10:18 AM

Is there a way to change the title of this thread so people know it's software sprites for BASIC before they open it? That probably would have avoided the initial confusion.

#29 Rybags OFFLINE  

Rybags

    Quadrunner

  • 10,314 posts
  • Location:Australia

Posted Fri Mar 9, 2012 10:35 AM

If you can edit the first post I think you can change it - ie, report it asking for an edit grant.

#30 JamesD OFFLINE  

JamesD

    River Patroller

  • 3,014 posts

Posted Fri Mar 9, 2012 10:37 AM

View PostJamesD, on Fri Mar 9, 2012 1:17 AM, said:

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!

#31 JamesD OFFLINE  

JamesD

    River Patroller

  • 3,014 posts

Posted Sat Mar 10, 2012 4:53 PM

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, Sat Mar 10, 2012 4:53 PM.


#32 Rybags OFFLINE  

Rybags

    Quadrunner

  • 10,314 posts
  • Location:Australia

Posted Sat Mar 10, 2012 7:12 PM

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
"LET" is optional, most people never use it.

#33 JamesD OFFLINE  

JamesD

    River Patroller

  • 3,014 posts

Posted Sat Mar 10, 2012 9:16 PM

View PostRybags, on Sat Mar 10, 2012 7:12 PM, said:

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.

Quote

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

#34 Rybags OFFLINE  

Rybags

    Quadrunner

  • 10,314 posts
  • Location:Australia

Posted Sat Mar 10, 2012 9:24 PM

It's the same in terms of memory use (implied LET uses a byte as well).

It can be "useful" in some cases where the variable name starts with a reserved name (e.g. statement or function name), but you're better off trying not to use reserved words.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users