A scrolltext in GFA Basic



By The Beast
beast_typhoon@hotmail.com



This modest article especially addresses himself to beginners in GFA (hey yes, it remains some again!) already having some notions as well as to those that are interested by the programming of demos oldschool. For them new, a scrolltext is simply a text that parades while using a melting, the most often to the Degas format. I propose you to program a horizontal scrolltext with a melting in 16x16, the all in 16 colors.



Opinion to graphists


Before entering in the quick of the topic, I would want to address me to graphists that draw meltings. Most meltings that I saw start with the 26 letters of the alphabet and end up very well numbers, either by the punctuation. It is necessary to know that he/it is very more convenient for a coder to have characters of melting in the order of the ASCII characters of the ST It goes from the character 32 (space) at 91 (the Z if I am not mistaken). What gives this:

     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
Don't forget that there is the character " space " rightly before the exclamation point. Well that some meltings only include letters, the vital minimum is nevertheless to have letters, numbers and a minimum of punctuation (point, comma, dash, exclamation point, point of questioning, colon, the two parentheses and the apostrophe). If the graphist doesn't want to draw all characters, it must let a white instead.



The principle


Before spending to the commented source, I am going to explain you on the whole MY way to make a scrolltext. I know well that this is not THE best way to proceed, but she/it walks and she/it is fast enough. That makes a small tip of time that I program in GFA and I never made only one scrolltext. I wanted to make a scrolltext that moves by not of 4 pixels, so that this is not too slow, nor too fast. Every character to display must be cut in slices of 4 pixels of large. Every slice is displayed there where one wants that the scrolltext begins, and then one baffles the part of the screen that must welcome the scroll to display the following piece. And so forth. I use the physical screen and the logical screen (see the excellent article of Exyl to know more).


I use the RC_COPY instruction, that is a powerful instruction in GFA. Best is again to use BMOVE, but it is less convenient to put in work. But then, avoid GET and PUT, these instructions take too many times machine.



The printout of the scrolltext


You should normally recover the extensively commented printout, his/her/its inline (melting) as well as the version compiled in an archive coming with the Toxic Mag.


     '
     ' Scrolltext en 16x16 - aout/septembre 1999
     ' Par The Beast/Typhoon pour le Toxic Mag 18
     ' Fonctionne en ST basse
     '
     RESERVE 5000
     INLINE fonte%,7520


The font in question is well a Degas picture of 32 KB but I cut up it with NeoChrome Master so that it takes less room. You know, I saved 25 KB practically. If you prefer to use the picture of melting origin, here is what it would have been necessary to put:

INLINE image%,32034
fonte%=image%+34
~XBIOS(6,L:image%+2)
The last line, it is for the palette of color (to see farther). One continues:


     @start
     DO
       @texte("[[[[[[[[[[[[[[[[[[[[[[[[ ATTENTION HERE IS A SCROLLTEXT FOR CRAPTALKING ! ",320,100)
     LOOP UNTIL PEEK(&HFFFFFC02)=57
     @fin


Note that you can change the text as well as the position of the scrolltext (stay up to only use of them capitals). There is for the main part of the program, there is not big thing to add. Let's see procedures now...



Procedure " start "


     PROCEDURE start
       old_phy%=XBIOS(2)
       old_log%=XBIOS(3)
       palette%=MALLOC(32)
       super%=GEMDOS(32,L:0)
       BMOVE &HFFFF8240,palette%,32


Here, one stocks addresses of the screens physics and logical to restore them at the end of the program. The palette is protected. To note that all the programs turns in supervisor.


       ecran1%=MALLOC(32256)
       buffer1%=AND(ADD(ecran1%,256),&HFFFFFF00)
       ecran2%=MALLOC(32256)
       buffer2%=AND(ADD(ecran2%,256),&HFFFFFF00)


There, it is a little particular. Know that on STF, the memory screen cannot be place wherever, it must be to a multiple address of 256. This is not the case on STE, what permits to have some thinner scrollings. The second line makes so that it variable ecran1% tip on a multiple address of 256. I encourage you briskly to make this. For in to know more, report yourselves to the article of Exyl in this issue.


       ~XBIOS(5,L:ecran2%,L:ecran1%,W:-1)
       CLS
       BMOVE ecran2%,ecran1%,32000


One declares the two screens and one cleans them to big strokes of CLS.


       pal$=SPACE$(32)
       pal$=MKI$(&H0)+MKI$(&HF0F)+MKI$(&H577)+MKI$(&H467)
            +MKI$(&H356)+MKI$(&H245)+MKI$(&H134)+MKI$(&H23)
            +MKI$(&H12)+MKI$(&H464)+MKI$(&H353)+MKI$(&H242)
            +MKI$(&H131)+MKI$(&H20)+MKI$(&H10)+MKI$(&H677)
         ~XBIOS(6,L:V:pal$)
     RETURN


There, one installs the palette. This last not being present in the INLINE file, I added him to the hand. NeoChrome Master also has an option to save the palette under shape of source collector, easily reusable in GFA.



The procedures " texte " and " obtenir "


     PROCEDURE texte(txt$,posx&,posy&)
       longueur%=LEN(txt$)
       FOR i&=1 TO longueur%
         ch&=ASC(MID$(txt$,i&,1))
         @obtenir(ch&)


After having calculated the length of the text, one searches for the ASCII code of every character, one after him other, and one is going to ask to get his/her/its equivalent in melting. Another method consists in the room of every character in a picture in order to win a little times machine (I didn't make him because I am not sure that it saves so of time plots).


         FOR j&=1 TO 4
           RC_COPY fonte%,x&+(j&*4)-4,y&,4,15 TO ecran1%,posx&-4,posy&


Letters are displayed by not of 4 pixels. One cuts all characters by slices of 4. Every character making 16 pixels of long, it is necessary to make 4 carvings therefore by character. Every block is displayed thus in tip of screen, ready to be displaced to let room to the next one.


           IF PEEK(&HFFFFFC02)=56
             CARD{&HFFFF8240}=&H404
           ENDIF
           VSYNC
           CARD{&HFFFF8240}=&H0


If one presses the ALTERNATE key, the color of the bottom becomes purple, otherwise it remains crotchet. On the whole, it is a technique that serves to visualize the time plots occupied by the routine. To note that CARD is very faster than SETCOLOR.


           RC_COPY ecran1%,4,posy&,posx&-4,15 TO ecran2%,0,posy&
           SWAP ecran1%,ecran2%
           ~XBIOS(5,L:ecran1%,L:ecran2%,W:-1)


One displaces a spunk (that is 4 pixels) toward her left all already displayed characters. Note good that the copy makes himself in the second screen. He/it is sufficient to put a tiny stroke of XBIOS 5 then and the tour is played! With this method, one can only use a melting of 32x32 maximum; bus with a melting of 64x64 and more, bugs in the graphic display appear. It would be necessary to use BMOVE, a few more complicated to put in work, then.


         NEXT j&
         EXIT IF PEEK(&HFFFFFC02)=57


The scrolltext can be interrupted while pushing on SPACE.


       NEXT i&
     RETURN
     PROCEDURE obtenir(ch&)
       IF ch&<=51            ! code ASCII inférieur ou égal à 51
         x&=(ch&-32)*16
         y&=0
       ELSE IF ch&=>72       ! code ASCII supérieur ou égal à 72
         x&=(ch&-72)*16
         y&=32
       ELSE                  ! code ASCII compris entre 50 et 71
         x&=(ch&-52)*16
         y&=16
       ENDIF
     RETURN


This last lines have for goal to determine coordinates of every melting character. The variable xes & and of it & are going to indicate to the routine of scrolltext thus where to find characters of which she/it has need.



The procedure " fin "


     PROCEDURE fin
       CLS
       ~XBIOS(5,L:old_log%,L:old_phy%,W:-1)
       BMOVE palette%,&HFFFF8240,32
       ~GEMDOS(32,L:super%)
       ~MFREE(ecran2%)
       ~MFREE(ecran1%)
       ~MFREE(palette%)
       RESERVE
       EDIT
     RETURN


This under-routine serves to give back the hand to the operating system of the possible the own way. In the order: cleaning of the screen, restitution of the logical screen and the physical screen, restoration of the palette and cleaning of the memory. Not to forget no more to put back itself/themselves in fashion user. Finished!



Limits


I tried this routine on a Falcon and a STE. I have nevertheless noticed a very unpleasant thing: if you start this small program in the file AUTO since a STE (and maybe since a STF also), that rows! A scrolltext in 16x16 is going to nearly take 80% of the time plots, whereas since the GEM desktop, he/it is not going to use some that 10% about. To what is this due? I am not some sure, but I believe that there is a history of blitter behind all that. But but then, that passes nickel on Falcon, that it is in AUTO or since the desktop.



Hasta the vista, baby!


I finished some for this time. If you want to improve routines of scrolltext, don't hesitate to send me your compiled programs or, if you agree, your sources (I will put them in the next Toxic, with your authorization). But attention, not of routines in collector in a INLINE! All must be made in GFA! And it is not instructions of the CARD style or POKE to displace the scrolltext of cheats it since that's equal to a MOVE instruction in assembler ! 8 -)




Edito Rubriques habituelles Planè Atari Internet Techniques et programmation Interviews Jeux Vidéo Humour Musique Chroniques, etc. Divers