Jess Ragan Posted July 22 Share Posted July 22 I don't understand these two commands. First, what exactly does OUT do, and what use could it be in a program? Second, how is VARPTR used? Evidently it's handy for animation, but how would one take advantage of it? Quote Link to comment https://forums.atariage.com/topic/369799-using-out-and-varptr-in-cvbasic/ Share on other sites More sharing options...
+nanochess Posted July 22 Share Posted July 22 The INP function and the OUT statement allow you to send data directly to the I/O ports (an addressing space separated from the memory space). You could read the controllers using this, but in fact, there is never a need to use INP and OUT in your programs, except of course if you want to interface with a new peripheral. Which at this point of time could be the SPO-256 Speech Synthetizer board I've seen lately. VARPTR is useful to do direct memory access chores. For example, you can have an array: ' Equivalent code c = memory_data(0) #pointer = VARPTR memory_data(0) c = PEEK(#pointer) memory_data: DATA 1,2,3,4,5 This is so you get a grasp of how VARPTR works, it returns the address of the item at the right of the VARPTR. You can write data using POKE (if it is a variable) and PEEK to read data from it. Another use of VARPTR is when using DEFINE SPRITE. For example, let us suppose you have used fully the 64 sprites definitions to create your great game, and then you have the idea of putting a victory dance. ' Let us run through the 200 frames of the victory dance FOR dance = 0 TO 199 DEFINE SPRITE 0, 1, VARPTR dance_sprite(dance * 32) WAIT WAIT NEXT dance Of course, I'm missing the SPRITE statement, and the dance_sprite data where the player has 200 sprites of 16x16 pixels, and congratulations, you have exceeded the 64 sprite definition limit. The 32 constant is the size in bytes of a 16x16 pixels sprite definition. If you are animating a bigger sprite, for example, 32x32 pixels then it would change accordingly. For example, DEFINE SPRITE 0, 4, VARPTR dance_sprite(dance * 128) Quote Link to comment https://forums.atariage.com/topic/369799-using-out-and-varptr-in-cvbasic/#findComment-5504358 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.