Jump to content
IGNORED

I can't draw a square :(


Recommended Posts

I'm working my way through the Compute First Book of Atari Graphics. I think I understand what's going on, but when I try to put in this line:

 

10 GRAPHICS 6 + 16:COLOR 1:PLOT 5,5:DRAWTO 10,5:DRAWTO 10,10:DRAWTO 5,10:DRAWTO 5,5

 

It draws a small square with no left side and then immediately brings me back to the READY prompt. I'm using Altirra. What am I doing wrong?

Link to comment
Share on other sites

When you add +16 to graphics mode it tells the computer to not put a graphics zero window at the bottom of the screen. Since your program is done after line 10 it has to print a 'ready' message somewhere so it make a new graphics 0 screen and prints 'ready' after erasing your graphics 6 screen. Do what Nukey Shay said above and see what happens.

 

I added that to your program and it drew a complete square.

 

Allan

Link to comment
Share on other sites

Or you could just remove the +16 from the gfx mode so a 4-line text window stays present. Or use 20 GR.6+32 so the screen adds the text window when done without erasing the screen. IIRC POKE 87,0 could be used to fool the interpreter that you are in GR.0 so text is dumped onscreen as bitpatterns (lol).

Link to comment
Share on other sites

Mapping the Atari would probably be your best bet. It's available online.

 

The POKE command simply sets a value in a particular memory location. So, knowing what the particular memory location is used for will tell you what the poke does. A simple example, would be :

 

POKE 710,96

 

That will turn the screen purple, because memory location 710 holds the background colour in Graphics mode 0.

Link to comment
Share on other sites

The POKE X,Y instruction is really only doing one thing: altering a memory location you specify (X) to hold the value you specify (Y). Just as your Basic program can use variables (like FOR I = 1 to 10), the Basic language itself is also a program running in the background which uses it's own variables. Basic instructions can be replaced by a single POKE...like using POKE 710,C instead of SETCOLOR 2,X,Y (X*16+Y=C)...but most use multiple variables (a DRAWTO equivalent needs two for the origin, two for the destination, two for the step values in order to connect the dots). Most of them can only be altered via POKE within the Basic language, since they have no keyword built-in to do it (like POKE 756,X to specify what memory page the character set bitmaps exist at). Try Atari Magazines or Atari Archives for starters.

Edited by Nukey Shay
Link to comment
Share on other sites

So POKE commands are like shortcuts? That makes sense, but what about the 96 in your example?

The 96 is the value that will go into memory location 710. It is interpreted as Colour #6, darkest of the 8 (16 in other Graphics modes) available brightnesses.

 

Keep in mind, that 96 has no intrinsic meaning. Each memory location can and usually will interpret the value it holds differently, according to the bit of hardware that the location controls.

Link to comment
Share on other sites

After looking at the other posts in this forum, it's clear I'm an ant among giants when it comes to A8 programming, so I'll just keep posting questions here in order not to clutter the forum.

 

In Graphics 3, I'm trying to use the Atari Color Numbers found in Compute's Book of Atari Graphics to draw colored lines.

 

Here's my code:

 

10 COLOR 0:PLOT 1,1:DRAWTO 5,1

 

Color 0 is supposed to be grey, but it's not showing up. Color 1 is gold, just as the book says, but color 2 shows up green (in the book it says it's supposed to be orange.) What am I doing wrong?

Link to comment
Share on other sites

I don't understand. How can I multiply 0 by 16? It seems like there's a pattern:

 

0-black (or blank)

 

 

0 x 16 == 0. Add the luminance value 0 to 15... and the numbers you get are 0...15.

The next color ( 1 ) x 16 == 16. Add the luminance value 0 to 15 and the numbers you get are 16 to 31.

and so forth.

 

(Technically, outside of GTIA mode 9, only the even luminance values 0, 2, 4, 6, 8, 10, 12, 14 are valid. the lowest bit is ignored, so 15 is the same luminance value as 14..)

Link to comment
Share on other sites

Best way to think about POKE is that it circumvents the BASIC environment and allows you direct access to "behind the scenes" memory. It's useful in BASIC because there are limitations on what BASIC keywords can do but you can easily crash the system with a wrong poke too.

 

Once you learn assembly programming, you get a much better grasp on what's actually going on in the background.

Link to comment
Share on other sites

Ok, I think I've got it. Please let me know if this is right.

 

I want to plot a gray point. I need to tell the computer that a COLOR 1 is gray. I type

 

SETCOLOR 0(this number is telling the computer I want to set the color for the point, not the background, text window, etc),0(this is the color from the color table--in this case, gray),5(this is how bright I want the gray to be)

 

and then COLOR 1:PLOT 1,1

 

I know that works, but I want to make sure I understand why it works.

Edited by BoatofCar
Link to comment
Share on other sites

EVERYTHING on the screen for Atari playfield graphics is colored by indirection.

 

COLOR 1 simply says draw pixels with a specific bit pattern in memory that is then output to the screen. This has nothing to do with the actual color that is seen on the screen.

 

The pixels corresponding to playfield COLOR 1 are assigned a color by a color register. SETCOLOR (OR POKE) define the color in the color register. So, by using SETCOLOR/POKE you can make COLOR 1 pixels red, green, blue, etc, pick one of 128 possible color values.

Link to comment
Share on other sites

I'm sorry guys, I still don't get it. I want to draw a white dot next to a red dot.

 

10 GRAPHICS 3

20 POKE 708,15 (I understand this now!)

30 COLOR 1:PLOT 1,1

40 POKE 710, 53 (Here's the red dot in COLOR 2 if I did the math right)

50 COLOR 2:PLOT 2,1

 

This gives me white dot and the normal COLOR 2 light green dot. How can I use POKE or SETCOLOR to change the value of COLOR 2? I apologize if it spells it out in the books, I just don't see it :(

Link to comment
Share on other sites

For now, always use SETCOLOR to keep things is BASIC. SETCOLOR will essentially do the POKE for you.

 

In GR. 3, you have 4 colors- 3 different drawing colors and a background color.

 

Use SETCOLOR 1-3(,x,x) to set the 3 drawing colors. Use SETCOLOR 4,x,x to set the background.

Use COLOR 1-3 to set the current drawing color to one of the colors you set with SETCOLOR. If you do not set the colors, they are orange (1), green (2), and blue (3). The selected drawing color remains until you use the COLOR command again. If you use a SETCOLOR command after drawing, all pixels on the screen of that color value will change to the new color. In other words, if you draw in COLOR 1 and then change COLOR 1, all pixels of color 1 will change.

 

So, SETCOLOR is similar to filling paint buckets with color to use (except for the fact that changing what's in the buckets also changes the paint you've already applied). COLOR is like picking up one of the brushes from a bucket. Getting more than 3 foreground colors requires more programming work.

Link to comment
Share on other sites

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