Re: [stella] Phase Two

Subject: Re: [stella] Phase Two
From: emooney@xxxxxxxxxxxxxxxx (Erik Mooney)
Date: Mon, 22 Feb 1999 04:54:00 GMT
>and when I finally get everything more or less together, I'm going to
>try to program a solitaire game, figuring that would be a good "test"
>to see if I grasp everything (or I'm I high?).  Before I do, I have

If you mean solitaire as in a card game, that's definitely a reach for
your first game.  Start with the basics - a playfield picture, a simple
movable sprite.

>1)  What is a "sprite"?  From the hype around my SMS, NES, Genesis,
>and SNES, I was under the impression that a sprite is like a
>Colorforms sticker, an image that the computer can move around over
>the background.  If that's right, how can the Atari, which, from my
>preliminary reading, needs to draw the entire screen, have sprites? 
>Does it have sprites, or are they things that act like them?  How much
>of this do I have wrong?

Once you're sure you understand the scanline-drawing concept, the sprites
fall into place pretty easily.  The Atari's sprites work this way: You
execute the instructions to position the sprite at a certain position.
The sprite will now remain at that position forever until you move it
again.  During every scanline, the sprite will display whatever graphics
are in its graphics register (GRP0 or GRP1) at that instant.  That make
sense?

The scanline concept is the very core of 2600 coding - make sure you have
that completely understood.

>2)  I'm having trouble grasping the concept of cycle counting.  Is
>this how it works?  The actual image the Atari draws is larger than
>the TV screen.  The first forty lines don't appear, and while these
>are being drawn out, since they only need a single color like black
>and nothing pertinent to the game, this is where you have the CPU
>doing calculations regarding the game (movements, calculations, etc.).
> The next 192 lines are where the picture is drawn, and since the
>computer has to read the info, this is where you leave it alone to do
>its job.  The next thirty lines are blank like the top forty, and more
>game decisions can be made here.  How can you tell how much time you
>have to do these things?  Do some commands take more time to execute
>than others, and if they do, how long so that you can make it do the
>calculations without disrupting the flow of the scan?

You tell how much time you have by doing math.  There are 76 CPU cycles
available during each scanline.  The above-the-screen area (referred to
as VBLANK) has 40 lines, so you have 40 * 76 = 3,040 CPU cycles there.
In the thirty lines below the TV picture (referred to as overscan), you
have 30 * 76 = 2,280 cycles.

Each instruction takes a certain number of cycles to execute.  A good
6502 reference will tell you how many cycles each instruction needs.

(If you've never programmed in assembly before, or at least have a LOT of
high-level programming experience, the 2600 really isn't a good place to
start.)

As for those 192 lines, no you do not leave the graphics chip (aka TIA
aka Stella) alone during this time.  During each and every one of those
192 lines, you need to give the TIA the data it needs to display that
scanline.  The TIA has absolutely no concept of a two-dimensional screen.
Its entire universe is one 228-pixel wide strip, with the first 68 of
those pixels being off the left side of the screen and the remaining 160
being displayable.  It just keeps drawing that same strip over and over,
moving down slightly on the TV screen between draws.  Every scanline, you
must feed data to the TIA so it knows what to display for that scanline.

>3)  Please explain the concept of MHZ to me.  From what I understand,
>a hertz is a single cycle, so a megaHertz would be a million cycles. 
>The TV screen, according to the Stella manual, draws the picture sixty
>times a second.  That makes sixty hertz, right?  How do the "clock
>counts" work with the hertz, then?  How many clock counts in a hertz?
>Who knows?  With all these questions I'm asking, I may someday have
>enough that I can write the tutorial people are dreaming about.

The TV screen draws the picture at 60 hertz, correct.  There are 262
scanlines within that picture, so it draws 15,720 scanlines per second,
or 15,720 Hz.  The 6507 CPU runs at 1.194 MHz, so that means you get that
frequency / 15720 = 76 CPU cycles for every scanline.

--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread