Re: [stella] zero-read

Subject: Re: [stella] zero-read
From: "Andrew Davie" <adavie@xxxxxxxxxxxxx>
Date: Sun, 11 Feb 2001 21:04:49 +1100

> From: "Erik Mooney" <emooney@xxxxxxxxxxxxxxxx>
> I suppose you want zeropage, because if that wasn't a requirement, you
> could just use a ROM location.  And I suppose you don't just want to
> dedicate one byte of RAM to the task of holding 0.  And I'm not quite sure
> why an immediate LDA #00 wouldn't work.  But here goes anyway:


Thanks Erik, just what I needed.

Your assumptions are essentially correct.  I *HAD* one byte of RAM allocated
for this task (a guaranteed 0), but I figured this was wasteful.  The code
below shows what I'm doing...  I use x (the line index) to lookup the
address of the variable containing the data for a line.  Some lines
("GUARANTEED0READ) require 0-byte data.  With this setup (below), I don't
need to reserve a byte of precious RAM - provided I can find a location
(GUARANTEED0READ) which returns 0.

The "lda 0,y" loads the data from the correct data area for each line being
drawn (or, 0).

----------------------------------------------------

        ldy TargetIndex,x       ; 3
        lda 0,y    ; 4
        sta TargetL             ; 3


TargetIndex

        ; Points to the correct line in the TargetDisplay playfield
        ; Indexed by the scanline (0-18) being drawn.

        ; This allows the single kernel to draw the entire playfield (!)

        .byte GUARANTEED0READ,GUARANTEED0READ,GUARANTEED0READ     ; 0
blank
        .byte TargetDisplay+0,TargetDisplay+0,TargetDisplay+0     ; 1
top row target
        .byte TargetDisplay+0,TargetDisplay+0,TargetDisplay+0     ; 2
top row target
        .byte TargetDisplay+1,TargetDisplay+1,TargetDisplay+1     ; 3
top middle row target
        .byte TargetDisplay+1,TargetDisplay+1,TargetDisplay+1     ; 4
top middle row target
        .byte TargetDisplay+2,TargetDisplay+2,TargetDisplay+2     ; 5
bottom middle row target
        .byte TargetDisplay+2,TargetDisplay+2,TargetDisplay+2     ; 6
bottom middle row target
        .byte TargetDisplay+3,TargetDisplay+3,TargetDisplay+3     ; 7
bottom row target
        .byte TargetDisplay+3,TargetDisplay+3,TargetDisplay+3     ; 8
bottom row target
        .byte GUARANTEED0READ,GUARANTEED0READ,GUARANTEED0READ     ; 9
blank
        .byte GUARANTEED0READ,GUARANTEED0READ,GUARANTEED0READ     ; 10
"
        .byte GUARANTEED0READ,GUARANTEED0READ,GUARANTEED0READ     ; 11
"
        .byte GUARANTEED0READ,GUARANTEED0READ,GUARANTEED0READ     ; 12
"
        .byte GUARANTEED0READ,GUARANTEED0READ,GUARANTEED0READ     ; 13
"
        .byte GUARANTEED0READ,GUARANTEED0READ,GUARANTEED0READ     ; 14
"
        .byte TargetDisplay+4,TargetDisplay+4,TargetDisplay+4     ; 15
cube sliding on bottom
        .byte TargetDisplay+4,TargetDisplay+4,TargetDisplay+4     ; 16
"
        .byte TargetDisplay+4,TargetDisplay+4,TargetDisplay+4     ; 17
"
        .byte TargetDisplay+4,TargetDisplay+4,TargetDisplay+4     ; 18
"

----------------------------------------------------

I can put a CXCLR just before the ldy, so that'll do nicely.
Thanks again.

Cheers
A

--
 _  _  _| _ _        _| _    * _                               _  ,
(_|| )(_|( (/_\/\/  (_|(_|\/(_(/_                           ,~' L_|\
                                                         ,-'        \
see my Museum of Soviet Calculators at                  (            \
http://www.taswegian.com/MOSCOW/soviet.html              \    __     /
                                                          L,~'  "\__/
                                                              @--> v

----- Original Message -----
From: "Erik Mooney" <emooney@xxxxxxxxxxxxxxxx>
To: <stella@xxxxxxxxxxx>
Sent: Sunday, February 11, 2001 8:39 PM
Subject: Re: [stella] zero-read


> On Sun, 11 Feb 2001 11:47:57 +1100, you wrote:
>
> >I need a register location which, upon read, is ALWAYS guaranteed 0.
> >Can anybody suggest any/the best register or location to use?
> >Thanks
> >A
>
> I suppose you want zeropage, because if that wasn't a requirement, you
> could just use a ROM location.  And I suppose you don't just want to
> dedicate one byte of RAM to the task of holding 0.  And I'm not quite sure
> why an immediate LDA #00 wouldn't work.  But here goes anyway:
>
> The collision registers map to $x0 through $x7, the paddles are at $x8 -
> $xB, and the joystick button inputs are at $xC and $xD, for all values of
> x 0-7.  I _think_ $xE and $xF always return $FF, but I'm not sure.
>
> If you can do a CXCLR (clear all collision collision latches) closely
> before this routine so that you can ensure that no collisions of any one
> particular type will occur between the CXCLR and this routine, you can use
> that collision register.  (example: $x4 contains the collision latches for
> missile 0 - playfield and missile 0 - ball.  You can use $x4 to always
> return 0 upon read, if you can ensure that such a collision will not
> happen between a STA CXCLR instruction and this routine, which will be
> true if either you're not using missile 0, you're not using PF or ball, or
> you're in vblank.)
>
> -
> Archives (includes files) at http://www.biglist.com/lists/stella/archives/
> Unsub & more at http://www.biglist.com/lists/stella/
>


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

Current Thread