Jump to content
Sign in to follow this  
Cafeman

AND ORA using indirect addressing questions.

Recommended Posts

http://www.6502.buss...ruction-set/and

 

I thought I could replace code like this:

 

Ptr1 = $50 ;zero page low byte

Ptr2 = $51 ; zero page hi byte

 

ldy #$02
lda (Ptr1),y							   ; 5 cycles
AND #%11111100							 ;2 cycles
sta (Ptr1),y							   ; 6 cycles, total each group = 13 cycles each

 

 

 

with this, saving cycles. Doesn't seem to work. Can I use AND to take the contents of the accumulator and directly mask it to memory in this way?

Ptr1 is on zero page as is the next byte, Ptr2.

 

ldy #$02
lda #%11111100			 ; 2 cycles
AND (Ptr1),y			   ; 5 cycles, total each group = 7 cycles each

Share this post


Link to post
Share on other sites

http://www.6502.buss...ruction-set/and

 

I thought I could replace code like this:

 

Ptr1 = $50 ;zero page low byte

Ptr2 = $51 ; zero page hi byte

 

ldy #$02
lda (Ptr1),y							   ; 5 cycles
AND #%11111100							 ;2 cycles
sta (Ptr1),y							   ; 6 cycles, total each group = 13 cycles each

 

 

 

with this, saving cycles. Doesn't seem to work. Can I use AND to take the contents of the accumulator and directly mask it to memory in this way?

Ptr1 is on zero page as is the next byte, Ptr2.

 

ldy #$02
lda #%11111100			 ; 2 cycles
AND (Ptr1),y			   ; 5 cycles, total each group = 7 cycles each

 

Your "AND (Ptr1),y" changes the content of the accumulator (A) only, doesn't write back the result to memory.. you still need to write the result of the operation with a "sta (Ptr1),y" .. is that your question?

 

The only instructions that modify memory are sta, stx, sty, inc, dec, asl, lsr, rol, ror

  • Like 1

Share this post


Link to post
Share on other sites

While we're talking about this, is there any more efficient way to grab the missile byte (which holds pixels for missiles 3,2,1, and 0 left-to-right) and store a pixel (actually I'm wiping out the pixel in this code) only in missile 0 , than this way:

 

AfterSwordHandleHPOS
ldy #$02 ;start 2 pixels down from actual sword body
lda (Ptr1),y ;5200 5 cycles
AND #%11111100 ;pad1 ;5200 2 cycles
sta (Ptr1),y ;5200 6 cycles, total each group = 13 cycles each
;
iny
lda (Ptr1),y
AND #%11111100 ;pad2
sta (Ptr1),y
;
iny
lda (Ptr1),y
AND #%11111100 ;pad3
sta (Ptr1),y
;
iny
lda (Ptr1),y
AND #%11111100 ;pad4 rwltst 11/29/04
sta (Ptr1),y
;
iny

Edited by Cafeman

Share this post


Link to post
Share on other sites

I devised a way of doing players which would work for missiles with some modification.

 

Generally you need to wipe the previous and draw the current incarnation. But in almost all cases there's overlap, so there's waste by just doing a 2-step process.

 

But, you can speed it up with a little bit of creative work.

 

Compare the current vs previous position. If current > previous, then that means you need to wipe some bytes before the current. If previous > current then the wipe has to occur after the current is drawn.

 

So, you do that compare, then draw the current missile. From the comparison earlier you can calculate what wipe operation needs doing.

 

Additionally with missiles, you could save some more cycles if you're drawing all 4 of them. The first missile you draw, you don't need to worry about preserving the existing contents, since the other missiles are being redrawn anyway.

 

But it's a tradeoff - another way to save cycles is to just not redraw an object if no Y movement or animation needs doing. So the method you chose should be dependant on what behaviour the objects normally have.

Share this post


Link to post
Share on other sites

sounds like there isn't a better way. I thought I was onto something wonderful , but I was wrong. Oh well, it works. I did fix a bug from the 5200 version that I never knew existed - the sword handle is a missile, and the secret dots are another missile. It was possible to wipe out the secret dot if you dragged the sword to that screen and got too close. that could explain why some people had trouble finding the dots. Well, in the XE version (AdvII) the secret dots change with each game variation and it was a lot more noticeable so I caught it, fixed it.

 

Thanks all.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...