JamesD Posted March 9, 2012 Author Share Posted March 9, 2012 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. Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 9, 2012 Author Share Posted March 9, 2012 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 Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 9, 2012 Author Share Posted March 9, 2012 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. Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 9, 2012 Share Posted March 9, 2012 If you can edit the first post I think you can change it - ie, report it asking for an edit grant. 1 Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 9, 2012 Author Share Posted March 9, 2012 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! Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 10, 2012 Author Share Posted March 10, 2012 (edited) 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 March 10, 2012 by JamesD Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 11, 2012 Share Posted March 11, 2012 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. Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 11, 2012 Author Share Posted March 11, 2012 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. Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 11, 2012 Share Posted March 11, 2012 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. Quote Link to comment Share on other sites More sharing options...
777ismyname Posted February 27, 2014 Share Posted February 27, 2014 My apologies for resurrecting an old thread....but thank JamesD for posting this code! A cursory search led me here and this fits my needs to a tee for a Turbo Basic XL project I'm working on. What little assembler I learned in the early 80's has long since left me. 1 Quote Link to comment Share on other sites More sharing options...
777ismyname Posted March 26, 2014 Share Posted March 26, 2014 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 Quote Link to comment Share on other sites More sharing options...
JamesD Posted March 29, 2014 Author Share Posted March 29, 2014 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. Quote Link to comment Share on other sites More sharing options...
777ismyname Posted April 3, 2014 Share Posted April 3, 2014 You put a bit of work in it in any case. The assembly stuff I could not do. There is one typo in the file I attached, though it doesn't affect the running of the program - it does cause the intended graphical shape to be off. 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.