Jump to content

Photo

HLO projects - Learning Action!


No replies to this topic

#1 RSS Bot OFFLINE  

RSS Bot

    Quadrunner

  • 9,112 posts

Posted Fri Jan 11, 2019 6:48 PM

I, finally, am getting around to learning Action! My goal is to learn Action! to create a sequel to my Atari 2600 game 'Parsec 2600' on the Atari 8-bit.
Anyway, the best way I have found to learn something is to teach others while I'm learning it. So, here it goes.
Action! is a cross between 'C', Pascal with a little bit of Assembler thrown in for good measure. It's fast and a lot simpler to learn than Assembler. The
Action cartridge compiles to Assembler for maximum speed (you still need the Action! runtime for the default modules).
Action! includes it's own editor, which is fairly powerful for the era and the compile is fairly fast.
 
Before you start into the lessons i would familiarize yourself with the Editor and Monitor. I won't be going into that as the book is fairly complete.
Now my 1st program.
 
PROC main()
 
  BYTE i,j  ;byte 1-256
  Print("Give me a number:")
  i=InputB() ;input byte
  j=i+2
  PrintBE(j) ;
Return
 
this little program just takes a number you input and prints it on the screen.
 
Now lets break it down piece by piece.
 
PROC main()
 
.
.
.
.
Return
 
 
As in 'C' and other languages, every program is a procedure. A procedure is like a GOSUB in BASIC. What you are doing is calling your program (PROCedure) from the Atari OS then RETURNing back to the Atari OS when finished. In reality you are doing the same thing in BASIC from the Editor.
 
PROC means it's a procedure.
main is the name of the procedure. In Action! you can call the MAIN procedure whatever you want (unlike 'C'). I use MAIN as I'm familiar with 'C'
 
main() - the () are for sending parameters (more on that when we talk about PROCedures in full.)
 
Return - you always end a procedure (and FUNCtion) with a return as in BASIC.
 
 
BYTE i,j  ;byte 1-256
  - You have to declare you variables in Action! before you use them. this defines 2 variables I,J as byte type.
 
The types of variables are:
BYTE - this is a number between 0-256. It's an 8 bit number.
CARD - this is a number between 0-65535. It's a 16 bit or 2 byte number.
INT - this is a number between -32768 and +32767. It's a signed 2 byte number.
 
As with BASIC you can't enter large numbers and do complex math. This is one of the ways Action! is able to get it's speed. It's not tied to the slow
Atari floating point package.
 
Your numbers can be in decimal form (65535) or Hexadecimal form ($FFFF).
For you BASIC learners note $ designates a hex number NOT a string.
 
Print("Give me a number:")
  - this prints the string, Give me a number: on the screen. As with 'C' almost everything is a procedure. Print("...") is a Procedure. There are different versions of 'Print' that act in different ways. We'll get into that in another lesson.
 
i=InputB() ;input byte
- This is the procedure to input a byte from the screen The 'B' at the end of input designates a byte.
Since it is a byte you can't input any number >256 or negative. If you put in a number >256 or negative, it just loops around.
InputB could be typed inputb, INPUTB or InPutB since the Action! compiler does not recognize case.
 
j=i+2
 - simply add 2 to byte variable i from InputB and send to variable J. You can add, subtract, multiple and divide in Action just like BASIC. (...) are accepted for complex calculation. Note though, if you divide your answer will always be a whole number. 7/2 is 3 not 3.5.
MOD will give the remainder in division. Example: 13 MOD 5 = 3, since 13/5 is 2 with a remainder of 3.
 
PrintBE(j)
 - this prints the output of J to the screen. B, again means byte and E will get EOL.
 
;
 - semi-colons are remarks. 
 
Next time we'll look at IF THEN and more on printing.
 
til then, HLO
 
 
 
  
 
 



http://atariage.com/...earning-action/




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users