IGNORED

# Pointer multiplication at start of block.

## Recommended Posts

As I've been reading examples I've noticed that whenever a new block of memory is set aside for use, you always start writing at a point determined by the starting address multipled by 256. This is true for both PM and character sets.

PM Example from Action!

PMTOP = RAMTOP - 8
PMBASE = PMTOP
MYPMBASE = PMTOP * 256

None of the books or tutorials I've been reading have ever explained why they do this. I'm figuring either it's supposed to be so obvious that they don't need to explain it, or they don't understand themselves.

Does this have something to do with the memory block having to start on a kiltobyte boundary?

Thank!

##### Share on other sites

For character sets and PMG, there are certain requirements for this alignment. The requirements are described in the documentation for the respective hardware - GTIA, ANTIC.

Sometimes it is just done for convenience. If your custom block begins at a page boundary, you can use just one byte to point to that block.

##### Share on other sites

In basic you'd have something like this:

`200 A = PEEK (106) - 8 : POKE 54279, A : PMBASE = 256*A`

PM space aligns on a 1k block - this serves as an optimization of sorts.  You'll find this often on the Atari.  For example font tables have to align on a 1k block.

Your example reserves 2k of ram for single line resolution player/missile graphics.  A neat hack is that you can use the first 768 bytes of this block for other reasons.

##### Share on other sites

• 2 weeks later...

Finally figured this out, Mapping The Atari is your friend!

RAMTOP is not a memory location, it's a page reference. Specifically where the Atari thinks the last page of memory is. Pages are 256 bytes long, so you multiply by it to the get the address.

What does puzzle me is the RAMTOP-8 part, specifically the -8, I've seen other programs that use -16. I'm assuming this number can be larger depending on how much RAM you have installed?

##### Share on other sites

An example of the extra space (if -16 is use) could be reserving space for a character set or sets.

I also thought that programs usually also re-poke the new RAMTOP value back?

This makes sense as you then issue a GRAPHICS command to create the display list and screen data such that your reserved area isn't shared.

##### Share on other sites

4 hours ago, kensu said:

What does puzzle me is the RAMTOP-8 part, specifically the -8

@damosan quoted, the -8 is generally used to reserve a 2K block of memory for Player Missile graphics in single line resolution.

it saves a safe place to put your players.

##### Share on other sites

Display lists can also be a bit tricky, if they cross over a 1K boundary, they need a JMP instruction. I usually hack around in assembler, put different functionality in different include files, but I try and have the display list in the first include file, otherwise it can creep over a 1K boundary (as I add code to other files). You can get some weird bugs/effects otherwise.

## 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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.