6 Advanced Graphics Techniques

Protecting Memory For P/M And Character Sets

Fred Pinho


Redefined character sets and player/missile graphics both require protected memory. This article shows how to avoid memory conflicts.

Other articles in this book explain how to properly locate either a redefined character set or player/missile data. But what if you want to use both at the same time? You can't use the formulas given in these articles directly, because the two data sets will interfere with each other. To simplify matters, I've prepared the table below. It will allow you to position both your P/M and character data so that they won't clash.

Note that the two sets of data are stored in memory below the display list. Because of this, a couple of cautions are in order:

1. Be careful when changing graphics modes. If you go to a graphics mode requiring increased display memory, you could overwrite your P/M data. It's probably best to locate your data to accommodate the graphics mode with the largest memory requirement. To help, I've included the memory requirements for each graphics mode.

2. You have to watch your BASIC program to insure that it doesn't expand into your data-storage area.

In your reading, you'll come across other methods of storing these data sets (above a lowered RAMTOP, in a string, etc.). However, these methods have some serious limitations of their own. The method given here is straightforward and easy to trouble-shoot.

The table gives the offset from RAMTOP (in pages) needed to properly locate each data set. Note that a page is a fancy way of describing a block of 256 data bytes. Also, the offset is subtracted from RAMTOP to get the proper memory location. I've given an example of use of the table below:

Desired: GRAPHICS 7
         Single-Line Player/Missile Graphics
         Redefined Full Character Set
Code:
10 PM=PEEK(106-32:REM Calculate page setback for player/missile data
20 POKE 54279,PM:REM Set page number of PMBASE
30 PMBASE=256*PM:REM Calculate memory location of PMBASE
40 CHRSTART=256*(PM-4):REM Calculate page offset for new character set
50 POKE 756,CHRSTART:REM Set CHBASE to point to new character set location

From here, you can go on to implement the player/missile system and your redefined character set as described elsewhere in this book. May all your missiles be on target.

Simultaneous Positioning Of Player/Missile And Redefined Character Set Data in Memory.

  Memery required for
Display Data + Display List
Player/Missile Data
Locate PMBASE at the
indicated offset (in pages)
from RAMTOP
Relocation of full character
set beneath player/missile data
Relocate at the indicated
offset (in pages) from RAMTOP
Graphics
mode
Total
Bytes
As
whole pages
Double-line
resolution
Single-line
resolution
Character set
with
double-line P/M
Character set
with
single-line P/M
0
1
2
3
4
5
6
7
8
992
674
424
434
694
1174
2174
4190
8112
4
3
2
2
3
5
9
17
32
8
8
8
8
8
12
16
24
36
16
16
16
16
16
16
24
32
40
12
12
12
12
12
16
20
28
40
20
20
20
20
20
20
28
36
44

Notes:
A. General

B. Player/Missile

Double-Line
resolution
Single-Line
resolution
Offset from any other data 1K 2K
Boundary location for PMBASE 1K 2K

C. Character-Set


Return to Table of Contents | Previous Section | Next Section