RSS Bot #1 Posted January 22, 2019 Sunday I posted a LINES.ACT to the blog and Youtube. http://atariage.com/forums/blog/528/entry-15444-demo-in-action/ It’s a fun little program I use to test programming languages and retro-computers. It originated on the TI-99 Mini-Memory as a demo program. So far I have converted the program to Atari BASIC, Atari MicroSoft BASIC, Atari Action!, Tandy CoCo2 BASIC, TI-99/4a TML enhanced ExBASIC and (and I have it somewhere but can’t find it for now) TMS9900 assembler. I’ll post the various conversions (and others as I make them) in the future. Today though, I am going to use the program to introduce graphics in Action! by comparing the two languages. There’s a lot similarities between the two computer languages and I’m sure this is by design. Here is the Atari BASIC program: 10 REM "H2:LINES.BAS" 20 GRAPHICS 7+16 40 X1=9:Y1=12:X2=40:Y2=30:Z=1 50 A=5:B=5:C=5:D=5 100 COLOR Z 110 PLOT X1,Y1 120 DRAWTO X2,Y2 124 IF A>1 AND RND(0)<0.1 THEN A=INT(RND(0)*3)+2 127 IF D>1 AND RND(0)<0.1 THEN D=INT(RND(0)*3)+2 130 X1=X1+A:Y1=Y1-B 140 X2=X2-C:Y2=Y2+D 150 IF Y1<6 OR Y1>88 THEN B=-B 155 IF Y2<6 OR Y2>88 THEN D=-D 160 IF X1<6 OR X1>154 THEN A=-A 165 IF X2<6 OR X2>154 THEN C=-C 190 IF RND(0)<0.05 THEN Z=INT(RND(0)*3)+1 200 T=T+1:IF T>150 THEN T=0:GRAPHICS 7+16 1200 GOTO 100 Here is Action! ; "H:LINES.ACT" PROC MAIN() BYTE Y1, Y2, Z, T INT A, B, C, D CARD X1, X2 ;INTL VAR X1=9 Y1=12 X2=40 Y2=30 Z=1 T=0 A=5 B=5 C=5 D=5 GRAPHICS(7+16) ;INFIN LOOP DO COLOR=Z PLOT(X1,Y1) DRAWTO(X2,Y2) IF A>1 AND RAND(0)<10 THEN A=RAND(3)+2 FI IF D>1 AND RAND(0)<10 THEN D=RAND(3)+2 FI X1=X1+A Y1=Y1-B X2=X2-C Y2=Y2+D IF Y1<6 OR Y1>88 THEN B=-B FI IF Y2<6 OR Y2>88 THEN D=-D FI IF X1<6 OR X1>154 THEN A=-A FI IF X2<6 OR X2>154 THEN C=-C FI IF RAND(0)<5 THEN Z=RAND(3)+1 FI T=T+1 IF T>150 THEN T=0 GRAPHICS(7+16) FI OD RETURN If anyone is wondering, and I doubt anyone is but I’m going to tell you anyway ‘cuz, the first line of any program I write is always the location, name and version (if any) of that program. It helps me to remember the name, version and where to put the program when saving. The ‘H:’ is my virtual HD I use in Altirra and with APE (I change t to D8:) on my 800xl. H: is the location of my Atari software on my M$ OneDrive. I use onedrive so I can easily jump between computers and always have a current file to work with. Plus onedrive is a safe location with generational backups. Aren’t you glad I told you that? Note: I’m not going to go into how the BASIC graphic commands work in this post. I have assumed you are familiar with Atari BASIC before you started the tutorial. I should have mentioned it before but you know what they say about assume. I also will not be going into any review of what we have already covered in Action! Reread the old post if you have any questions or drop me a comment. I love comments. By reading and agreeing to subsection A, paragraph 18 through 197 of this agreement you have just committed you immortal soul to the great god Mongo subject to eternal torment and... oh wait, that’s my standard software EULA, my bad. Lets compare the to programs now! Atari BASIC 20 GRAPHICS 7+16 40 X1=9:Y1=12:X2=40:Y2=30:Z=1 50 A=5:B=5:C=5:D=5 Action! PROC MAIN() BYTE Y1, Y2, Z, T INT A, B, C, D CARD X1, X2 ;INTL VAR X1=9 Y1=12 X2=40 Y2=30 Z=1 T=0 A=5 B=5 C=5 D=5 GRAPHICS(7+16) Now let’s look at both. In BASIC the 1st line is establishing the graphics mode of 7+16; medium resolution with 4 colors. Action! we start off with the standard beginning for an Action program MAIN(). Establishing which graphics mode won’t come later. I have tried setting the graphics mode before setting the variables and it usually produced a error. Now in BASIC we now set the intial variable values. In Action! we establish the types of variables, BYTE, INT or CARD, before we set the intial values. Why do we have to do go through the extra step of establishing the variable types Action! and not in BASIC? I mean isn’t programming all about doing as little as possible when typing in a program (after all that’s why they created object oriented programming)? Well, here’s why. In Atari BASIC all numeric variables are in the form of what is known as BCD (binary coded decimal) which gives you very accurate decimal numbers that most people use. Therefore all the numeric variables are the same, which is one reason that BASIC doesn’t need to establish the type, it already knows what it is. Another is that before the program starts BASIC scans the program and finds all the variables and then creates a table for future use doing the program. It is therefore establishing the variables for you. Then why doesn’t Action! just use BSD like Atari BASIC and call it a day? Well, for one, BCD is slow, very slow due to the need to process decimal number accurately. Try figuring SIN or COS in BASIC for a plotting program and you’ll see what I mean. On top of the natural slowness of BCD BASIC’s pre-scanning to create the variable table also takes up time. Slow is bad. Plus BCD numbers takes up a lot of more memory compared to BYTE, INT or CARD. Atari BASIC BCD takes up 6 bytes of memory for each number, in contrast BYTE only takes up one byte of memory and INT & CARD only takes up two. In a 64k enviroment that could mean a lot. More program: BASIC: 100 COLOR Z 110 PLOT X1,Y1 120 DRAWTO X2,Y2 Action! ;INFIN LOOP DO COLOR=Z PLOT(X1,Y1) DRAWTO(X2,Y2) We start the loop in BASIC and Action! BASIC we use the dreaded 1200 GOTO 100 to loop back and create an infinite loop and in Action! we DO with no condition for the same kind of infinite loop. Only way to stop both loops is reset. 100 COLOR Z and COLOR=Z do the same thing in both languages as well as 110 PLOT X1,Y1 , PLOT(X1,Y1) and 120 DRAWTO X2,Y2 , DRAWTO(X2,Y2). just be mindful of the differences of how they are typed in. More BASIC: 124 IF A>1 AND RND(0)<0.1 THEN A=INT(RND(0)*3)+2 Action! IF A>1 AND RAND(0)<10 THEN A=RAND(3)+2 FI These lines I want to point out the random command. As you well know BASIC RND(0) will produce a number between 0 and 1. Action! RAND(0) produces and number between 0 and 255 (if the (0) is used. If you set a number in the parentheses such as RAND(3) you will get a whole number between 0 and that number, in this case 0-3. Very handy being able to set the range. Note the spelling RAND(x). I kept wanting to type RND(x) in Action! and got errors. Side rant here, I wanted to verify how the RAND(x)command worked so I went to the Action! manual. Well, that Action! manual is really, really pathetic. it looks like they shoved together a bunch of their notes into a spiral bound and called it done. My Action! manual doesn’t have an index! How do you find anything without and index?! Also, there is no main glossary but several sectional glossaries spread out through the book. And some of the commands have examples and some, well “figa it out for yosef”. Rest of the program is familiar territory so I won’t go over it. Before I leave, The Action! version of this program only turned out to be about twice as fast as standard BASIC. I was a little disappointed at first, I had hope a lot faster than Atari BASIC but Atari graphics commands tend to be rather quick as compared to other computers of the era so I guess that is OK. Next time we’ll look at some more on Action! graphics. Till then, HLO http://atariage.com/forums/blog/528/entry-15453-learning-action-part-4-graphics-demo/ Share this post Link to post Share on other sites