[stella] FWD: help with Indirect Indexed Addressing

Subject: [stella] FWD: help with Indirect Indexed Addressing
From: KirkIsrael@xxxxxxxxxxxxx
Date: 8 Sep 2003 03:22:30 -0000
Sorry if this is a repost...it didn't seem to go through? 


Aargh, this is maddening. 

On my way to something like skipdraw, I realized that I was going 
through too much logic to figure if I should draw the wingup or the 
wingdown graphic, I needed to set a 2 byte pointer to current graphics 
frame in the VBLANK.   

I just started with P0: 
I set up a 2 byte variable: 

pointerP0Graphic ds 2 

In my initialization I set up the second byte of that 
with the page I'm putting all the graphics on: 

LDA #>GraphicsPage ;grab the hight byte of the graphic location 
STA pointerP0Graphic+1 

later, I either do 
LDA #<WingUpGraphic+1 ;add in the low byte of the graphic location 
STA pointerP0Graphic 
or 
LDA #<WingDownGraphic+1 ;add in the low byte of the graphic location 
STA pointerP0Graphic 

Now, I'm pretty sure that that's all correct, because I 
can put that graphic inplace of the score, on its just about 
what I expect: 


LDA (pointerP0Graphic),Y 
; LDA (pointerP0Score),Y 
STA GRP0 

It flaps and looks ok, just a little truncated, which makes 
sense. 

Now, for now I'm using a byte, p0DrawBuffer to buffer, and then 
putting that in GRP0 at the begining of the line. So my logic has 
P0VisibleLine counting down from 8 to 0, showing which line is visible. 

LDA #00 
;if the p0VisibleLine is non zero, 
;we're drawing it 
LDX p0VisibleLine 
BEQ FinishPlayer0 ;we're done drawing 
DEC p0VisibleLine   
LDA (pointerP0Graphic),X ;what's wrong with this??? 
;LDA #%10011001 
FinishPlayer0 
STA p0DrawBuffer 


Now, because I can put the pointerP0Graphic into score, 
I think I'm setting it right.  And that commented out LDA #%10011001 
when restored, shows that the Accumlator->P0DrawBuffer ->GRP0 
is working fine, because if I uncomment it I see that pattern. 
Commented, GRP0 seems to be random garbage that varies even 
with P1 flapping, so I don't know where the heck LDA (pointerP0Graphic),X 
is getting its data from... 

Is there some gotcha to use Indirect Indexing with the X 
register I'm missing? It's driving me nuts, because it seems 
to be isolated to that line... 

Full source and binary at the top of http://alienbill.com/joustpong/ 

Doggone it.  I thought I was doing well to. 

-- 
KirkIsrael@xxxxxxxxxxxxx    http://kisrael.com
"The desires of the heart are as crooked as corkscrews." --W.H.Auden


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


Current Thread