Re: [stella] What I've got so far

Subject: Re: [stella] What I've got so far
From: emooney@xxxxxxxxxxxxxxxx (Erik Mooney)
Date: Thu, 08 Jul 1999 00:44:16 GMT
>Okay, gang.  Here's what I've got.

We love novices!  All tender and chewy...      oops, was that out loud? :)

>     First up, supposing I use a BEQ, writing it as:
>     BEQ  #0
>     (I believe #0 means numeric value zero, right?)  Does the computer
>check the last value to be changed against the value or location I list
>after the BEQ command, like if I Decrement X (DCX?), or does it compare
>the X, Y, and A registers all against the value after the BEQ?

Hoooold on there pardner.  BEQ looks a certain bit in the flags register
(called the zero flag), and branches (jumps) if that bit is set.  Just
about every mathematical operation, as well as load and transfer
instructions, either sets or clears the zero flag depending on its
results.  The operand provided to BEQ is the offset to the address to jump
to if the branch condition (zero flag set) is met.  (you'll almost always
want to use a label there and let the assembler handle it.)

So if your code is
LDA #2
STA $85
CMP $85  ;compares the contents of A with the contents of $85; it's equal
BEQ label1
DEX
label1: [more code]

since the CMP resulted in equality (which sets the zero flag), the BEQ
will branch to label1.

>     I don't have the commands handy, but I recall commands that
>allowed me to INCrement or DECrement things held in actual memory

INC $97 will increment the byte at memory location 97 (hex).

>     WSYNC
>     VBLANK
>     During this VBLANK, I put a couple of commands--nothing heavy.  I
>then VBLANK again, start the next command, etc.  I do this thirty-seven
>times, breaking up the commands to fit within the VBLANK times.

Look at Nick Bensema's How to Draw a Playfield for how to set up a timer
to do some counting for you, so your code doesn't need to catch every
WSYNC in there.

>     Next, I start drawing the screen.  Assuming I can DEC a value in
>memory location and compare that instead of constantly shifting the
>values into and out of the X or Y registers, I do this:
>     LDX  #192
>     STX  LINECNT
>     Draw screen commands here.
>     DEC  LINECNT
>     BEQ  #0

Not quite.  When DEC executes, it automatically sets the zero flag based
on the result of the decrement.  And you need a label for the BEQ to
branch to; it should probably be right before "Draw screen commands here."

>     Erik Mooney wrote that during the first set of VBLANK commands, I
>have time for 800-1000 commands.  A FAQ I boosted off the 'Net says I
>have time for 80-100.  Did someone misplace a zero, or are both answers
>correct and I'll discover how to do both with practice?

I think both are correct in a way.  There is the VSYNC period, which lasts
three scanlines, during which you can do about 80-100 commands.  Then
there is the VBLANK period, during which you can do about 800-1000
commands.

>     What color is produced by VBLANK?  If I need extra time to
>complete game calculations, like in the Columns example about a month
>ago, can I start VBLANKing as soon as I draw the last part of the
>screen needed, buying myself a little more time to work on things?

Yep!  You can do whatever you want during any scanline.

>     To save time, I'm envisioning in the mental flowchart I came up
>with then starting the VBLANK after VSYNC with checking for a joystick
>input.  If none, it just bounces through to the screen drawing part. 

Assuming there's no other way for stuff to change from frame to frame
(counters for sound effects possibly), yes.

>     Am I getting closer, or am I getting all this royally wrong?

You're getting closer, yeah, but sloooow down, grasshopper! :)  Get a good
grip on 6502 assembly and on Nick's How to Draw a Playfield before you go
trying to write what for the 2600 is a fairly complex game.

>Before I forget:  that FAQ I got off the 'Net says the Atari 2600 has
>6K available.  If my math can be relied on, starting from $F000 to
>$FFFF is 4,096, or exactly 4K of memory.  Where is this extra 2K?

The 2600 has *8* K of address space.  However, the first 4K is occupied by
the TIA registers and RIOT RAM and ports.  The 2600 normally has 4k for
cart address space... I dunno what that FAQ is thinking.

>     Oh, and does anyone know where I can find a freeware program that
>converts numbers into hex, decimal, and binary?  I've been using Base
>10 for so long, this takes some adjusting.

If you're in any Windows >= 2.0, it has a built-in calculator somewhere
under Accessories that'll do this.

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

Current Thread