Gury Posted May 2, 2021 Share Posted May 2, 2021 Is this syntax for relocating and modifying character set familiar to you? 10 ORIGINAL=57344 . . 60 FOR I=0 TO 1023 70 POKE CHSET+I,PEEK(ORIGINAL+I) 80 NEXT I But then... waiting, waiting, waiting... Hey, it is finally done! Do you want faster routine to do this operation? In slice of a second and in pure Atari BASIC? The solution is presented in the book Assembly Language Programming for the Atari Computers by Mark Chasin. Here it is (real listing with all offsets with Atari defaulted to margin of 2 characters in text mode 0), with some modifications by me to modify characters A, H and !: 0 REM ******************************* 1 REM FAST SUBROUTINE TO RELOCATE THE CHARACTER SET 2 REM FROM THE BOOK ASSEMBLY LANGUAGE PROGRAMMING FOR THE ATARI COMPUTERS 3 REM AUTHOR: MARK CHASIN 4 REM LINK: https://ksquiggle.neocitie s.org/alp.htm 5 REM ******************************* 10 GOSUB 20000:REM SET UP MACHINE LANG UAGE ROUTINE 20 ORIG=PEEK(106):REM TOP OF RAM 30 CHSET=(ORIG-4)*256:REM PLACE FOR RE LOCATED CHARACTER SET 40 POKE 106,ORIG-8:REM MAKE ROOM FOR I T 50 GRAPHICS 0:REM SET UP NEW DISPLAY L IST 60 X=USR(ADR(TRANSFER$),57344,CHSET,4) :REM TRANSFER THE WHOLE SET 70 REM MODIFIED CHARACTERS 75 RESTORE 30000 80 FOR I=0 TO 7:READ CHAR:POKE CHSET+I +40*8,CHAR:NEXT I 82 FOR I=0 TO 7:READ CHAR:POKE CHSET+I +33*8,CHAR:NEXT I 84 FOR I=0 TO 7:READ CHAR:POKE CHSET+I +1*8,CHAR:NEXT I 90 POKE 756,ORIG-4 100 END 19990 REM MACHINE LANGUAGE ROUTINE 20000 DIM TRANSFER$(33):REM SET IT UP AS A STRING 20010 FOR I=1 TO 33:REM SET UP THE STR ING 20020 READ A:REM GET A BYTE 20030 TRANSFER$(I,I)=CHR$(A):REM STUFF IT INTO THE STRING 20040 NEXT I:REM REPEAT UNTIL STRING I S DONE 20050 RETURN :REM ALL DONE, GO BACK 20060 DATA 104,104,133,205,104,133,204 ,104,133,207 20070 DATA 104,133,206,104,104,170,160 ,0,177,204 20080 DATA 145,206,136,208,249,230,205 ,230,207,202 20090 DATA 208,242,96 30000 REM DATA FOR MODIFIED CHARACTERS 30010 DATA 60,126,129,102,66,36,24,0 30020 DATA 255,129,129,129,129,129,129 ,255 30030 DATA 24,36,189,189,231,165,60,10 2 Below are the source code listings in tokenized and listed form. FASTSET.LST FASTSET.BAS 4 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted May 2, 2021 Share Posted May 2, 2021 Can be made even quicker if you do:- DIM a$(40) size of your DATA statements A$="SKJAHKHGUUIEGIEaIIdEIIerwthaytueivieir" or whatever your DATA statement values are then simply X=USR(ADR(A$),57344,CHSET,4) 1 Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 2, 2021 Share Posted May 2, 2021 Familiar, yep. When I couldn't be bothered incorporating an asm routine, a loop near the start of the program was the next best thing. You can speed it up a bit by using a bit of optimisation. 100 ST=57344-NC : FOR A=NC TO NC+1023 : POKE A,PEEK(ST+A) : NEXT A Reduces the operations within the loop to speed it up a bit. In theory also you could use hacked/relocated strings to do the copy although the amount of program code needed, you may as well just use assembly. In theory you could probably also use the internal Basic move routines with a stub of code that calls them though you'd probably not save much space. Quote Link to comment Share on other sites More sharing options...
Preppie Posted May 2, 2021 Share Posted May 2, 2021 or in FastBasic: move &font,chrset,1024 ? 1 Quote Link to comment Share on other sites More sharing options...
Gury Posted May 2, 2021 Author Share Posted May 2, 2021 This topic debate is reserved just for Atari BASIC examples :) And only solutions with workable examples count. The example I posted is the fastest I found, it runs in less than a second, with whole character set copied to new address (vs usual 13 - 15 seconds). It is workable example, which can be used also for other uses, for example clearing specific block of memory with specific character, etc. 3 Quote Link to comment Share on other sites More sharing options...
+David_P Posted May 2, 2021 Share Posted May 2, 2021 11 hours ago, TGB1718 said: Can be made even quicker if you do:- DIM a$(40) size of your DATA statements A$="SKJAHKHGUUIEGIEaIIdEIIerwthaytueivieir" or whatever your DATA statement values are then simply X=USR(ADR(A$),57344,CHSET,4) You don't have to define and fill a string; you could just say RELOCATE=ADR("SKJAHKHGUUIEGIEaIIdEIIerwthaytueivieir") X=USR(RELOCATE,57344,CHSET,4) Of course, this assume that the ML routine has no internal absolute references. Quote Link to comment Share on other sites More sharing options...
Xuel Posted May 5, 2021 Share Posted May 5, 2021 Here's an example of manipulating BASIC's variable value table as @Rybags suggested: 10 DIM A$(1024):DIM B$(1024) 20 A$(1024)="X" 30 STARP=PEEK(140)+PEEK(141)*256 40 SRC=57344-STARP 50 DST=32768-STARP 60 VVTP=PEEK(134)+PEEK(135)*256 70 POKE VVTP+3,INT(SRC/256) 80 POKE VVTP+2,SRC-(PEEK(VVTP+3)*256) 90 POKE VVTP+11,INT(DST/256) 100 POKE VVTP+10,DST-(PEEK(VVTP+11)*256) 110 B$=A$ This relies on A$ and B$ being the first variables defined, so it will only work if typed or ENTERed after a NEW. Then you could SAVE and LOAD. This copies the character set at $E000 to $8000 pretty much instantly, but still slower than you can achieve with assembly language. 5 Quote Link to comment Share on other sites More sharing options...
Preppie Posted May 5, 2021 Share Posted May 5, 2021 That's a nifty little trick there. Quote Link to comment Share on other sites More sharing options...
Gury Posted May 5, 2021 Author Share Posted May 5, 2021 Indeed it is nice trick modifying Atari BASIC's variable value table, which can be used for several things to speed up BASIC programs. But still, the assembly language example on top is still the fastest and after all, it is easy to use, no need for proper care of entering BASIC program. Out of the box... Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 5, 2021 Share Posted May 5, 2021 I developed a trick for the string relocation that didn't need you to force as first declared or check the name table to ensure you have the right one. Just set the string length to a known unique value first up then chain through the table and you'll find it. 1 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.