9
Single-line Resolution
So far we have been dealing strictly with double-line resolution. Since double-line resolution is easier to handle and takes less memory. I'll continue to use it for most of the examples in this book. But our little player is so cute in single-line resolution! I just couldn't resist introducing him to you.
Be sure to save copies of the previous double-line resolution programs, since future programs will be based on them--not on the program in this chapter. In fact, I suggest you just read over this chapter without typing in any of the examples. Then after you've mastered double-line resolution, come back and try out the program in this chapter. (Whatever. You'll do it your way, anyway.)
At the end of this chapter is a complete listing of a program that does essentially the same thing as the program in the previous chapter--the only difference is that it is in single-line resolution. The program is called SLRES.SAV--short for "single-line resolution." Here is a summary of the changes you'll need to make to MISSILE.SAV to produce SLRES.SAV:
LINE 11000
This is the "filler" line that makes sure that PM memory starts on a 2K boundary. The only change is that while the number 1024 appeared in the previous program, 2048 appears in this program (1024=1K: 2048=2K).
LINE 11010
In the previous program I had a string called BUFFER$ dimensioned to 384 bytes. Well, in single-line resolution, this string needs to be twice as many bytes: 384*2 or 768.
Instead of dimensioning BUFFER$ to 768 bytes, I broke it down into three strings of 256 bytes each: ERASE$, FILLER3$, and FILLER4$. (Notice that it works out to be the same thing since 3*256=768.) Also, notice that each of the other strings are now 256 bytes long instead of 128--the way they were in double-line resolution. And notice that I omitted the dimensioning of PLAYER1$, PLAYER2$, and PLAYER3$.
LINES 11020 THROUGH 11040
Here I am setting ERASE$ to binary zeros. Notice the RETURN at the end of line 1040. I broke the PMG setup routine into two parts. (For some unknown reason BASIC likes it better this way.)
Lines 11045 through 11095 make up the next part of the PMG setup. I made these lines into another subroutine, which is called immediately after the subroutine starting at line 11000. (See the "executive" subroutine beginning at line 2000, which calls the various setup routines.)
LINES 11045 AND 11047
Here I am initializing MISSILES$ and PLAYER0$ in a slightly different way. This is necessary because of an apparent bug in Atari BASIC. It seems that a statement such as MISSILES$=ERASE$ won't work if MISSILES$ is 256 bytes or more.
In the previous program, line 335 contained the statement MISSILES$=BUFFER$, which served to "erase" data from the missile memory area. (Actually it fills MISSILES$ with zeros.) I had to take this statement out when converting the program to single-line resolution. That's because of the apparent bug in Atari BASIC that I just mentioned.
So to accomplish vertical missile movement, I had to find another way to erase the missile. I did that by rewriting lines 11070 and 11330.
LINES 11070 AND 11330
At line 11070 I dimensioned the missile image string to 13, instead of 1. Why? Because I wanted to have the missile erase itself with trailing zeros during vertical movement.
Notice the zeros in the missile image data at line 11330. These zeros erase the missile as it moves vertically. Using this arrangement, I found that I didn't need the statement "MISSILES$=ERASE$" at line 335.
LINE 11085
This is important. Here I specify single resolution by adding 16 to the 46 that is to be poked into location 559. the direct memory access control register. I'll explain this more later. (See the "Odds and Ends" chapter if you can't wait.)
LINES 5 THROUGH 14
Here I use SY to adjust Y0, where previously I used SP. SY refers to "speed of Y (up/down) movement." In single-line resolution, remember, there are twice as many vertical locations. So to get approximately the same vertical speed, we have to move the player 2 bytes instead of just 1. Consequently, SY is initialized to 2 in line 10070 and SP is still initialized to 1. Horizontal movement is no different in single- versus double-line resolution.
A similar change could also be made for the missile coordinate adjustment routine at lines 60 through 75. When you get this program running, notice how the missiles don't go exactly as you might expect when you fire them in a diagonal direction. That's because in single-line resolution there are about 224 vertical positions, but only 150 horizontal ones.
LINE 10070
In line 10070 I initialized SY to 2 as I just mentioned.
LINE 315
To line 315 I added:
MY0S=MY0
MY0S is short for MY0SAVE. Here I am saving the vertical coordinate for the missile. Notice that I am doing this when the missile's vertical coordinate is first set. I use this saved value later in the error correction routine (which begins at line 3000) to help me erase the missile from the screen.
LINES 3000 THROUGH 3080
The error correction routine at lines 3000 through 3080 needed quite an overhaul because of the differences in vertical coordinates in single-line resolution. Also the manner in which I erase a missile is different. I now need to reference specific bytes in MISSILES$ when erasing the missile. I can no longer merely code MISSILES$=BUFFER$ to set the missile memory area to zeros. Again, this is necessary because of an apparent bug in Atari BASIC.
That does it. The complete listing for firing missiles in single-line resolution follows. To make the required changes easy to see, I have circled them. Notice that in line 2, I made a comment to myself that I saved the program on disk 30. I suggest you revise this REM statement so it reminds you where you saved the program. In the next chapter, we'll put our player in a maze and add collision detection!
SLRES.BAS
Download (Saved BASIC)
Download / View (Listed BASIC)
Return to Table of Contents | Previous Chapter | Next Chapter