Jump to content

Recommended Posts

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)

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...