What am I doing wrong? [message #167479] |
Sat, 19 August 2006 15:40 |
|
Originally posted by: pacman_6502
I wrote a quick routine that is suposed to slide a hires sprite over to
the right 1 pixel, with the last pixel rotating back around to the
left. The problem is that the last pixel is not getting rotated back to
the left side and 2 lines near the bottom are getting pixels out of now
where. I am confused where I went wrong?
Here is the code:
SLIDE_RT subroutine
ldx #21 ; Loop counter
ldy #0 ; Sprite data offset
..loop
lda (sprptr+2),y ; Shift last pixel to carry.
lsr
lda (sprptr),y
ror
sta (sprptr),y
iny
lda (sprptr),y
ror
sta (sprptr),y
iny
lda (sprptr),y
ror
sta (sprptr),y
iny
dex
bne .loop
rts
I am sure it is something very simple I am missing, but I am just not
seeing it?
|
|
|
Re: What am I doing wrong? [message #167480 is a reply to message #167479] |
Sat, 19 August 2006 15:56 |
CIP
Messages: 19 Registered: February 2005
Karma: 0
|
Junior Member |
|
|
pacman_6502 wrote:
> I wrote a quick routine that is suposed to slide a hires sprite over to
> the right 1 pixel, with the last pixel rotating back around to the
> left. The problem is that the last pixel is not getting rotated back to
> the left side and 2 lines near the bottom are getting pixels out of now
> where. I am confused where I went wrong?
>
> Here is the code:
>
> SLIDE_RT subroutine
>
> ldx #21 ; Loop counter
> ldy #0 ; Sprite data offset
> .loop
> lda (sprptr+2),y ; Shift last pixel to carry.
> lsr
>
> lda (sprptr),y
> ror
> sta (sprptr),y
> iny
> lda (sprptr),y
> ror
> sta (sprptr),y
> iny
> lda (sprptr),y
> ror
> sta (sprptr),y
> iny
>
> dex
> bne .loop
>
> rts
>
> I am sure it is something very simple I am missing, but I am just not
> seeing it?
If you do a lsr or ror the bit that is shifted out is going in to the carry
not to the other side of the byte
Greetings Richard
|
|
|
Re: What am I doing wrong? [message #167483 is a reply to message #167480] |
Sat, 19 August 2006 16:46 |
|
Originally posted by: pacman_6502
Hi Richard,
CIP wrote:
> If you do a lsr or ror the bit that is shifted out is going in to the carry
> not to the other side of the byte
>
> Greetings Richard
An ROR should shift what is already in the carry to the other side of
the byte?
The first LSR I am using is supposed to set up the carry to hold the
last pixel bit of a sprite line so that it can be rotated in with the
first ROR.
|
|
|
Re: What am I doing wrong? [message #167489 is a reply to message #167479] |
Sat, 19 August 2006 20:25 |
Glenn Holmer
Messages: 314 Registered: February 2013
Karma: 0
|
Senior Member |
|
|
pacman_6502 wrote:
> I wrote a quick routine that is suposed to slide a hires sprite over to
> the right 1 pixel, with the last pixel rotating back around to the
> left. The problem is that the last pixel is not getting rotated back to
> the left side and 2 lines near the bottom are getting pixels out of now
> where. I am confused where I went wrong?
> lda (sprptr+2),y ; Shift last pixel to carry.
Are you sure you mean to be adding to the base address here?
--
Glenn Holmer (Q-Link: ShadowM)
http://www.lyonlabs.org/commodore/c64.html
|
|
|
Re: What am I doing wrong? [message #167491 is a reply to message #167479] |
Sat, 19 August 2006 21:48 |
Anton Treuenfels
Messages: 105 Registered: December 2011
Karma: 0
|
Senior Member |
|
|
"pacman_6502" <pacman_6502@yahoo.com> wrote in message
news:1156016458.075944.55640@75g2000cwc.googlegroups.com...
> I wrote a quick routine that is suposed to slide a hires sprite over to
> the right 1 pixel, with the last pixel rotating back around to the
> left. The problem is that the last pixel is not getting rotated back to
> the left side and 2 lines near the bottom are getting pixels out of now
> where. I am confused where I went wrong?
>
> Here is the code:
>
> SLIDE_RT subroutine
>
> ldx #21 ; Loop counter
> ldy #0 ; Sprite data offset
> .loop
> lda (sprptr+2),y ; Shift last pixel to carry.
> lsr
>
> lda (sprptr),y
> ror
> sta (sprptr),y
> iny
> lda (sprptr),y
> ror
> sta (sprptr),y
> iny
> lda (sprptr),y
> ror
> sta (sprptr),y
> iny
>
> dex
> bne .loop
>
> rts
>
> I am sure it is something very simple I am missing, but I am just not
> seeing it?
If the idea is to rotate all 24 pixels of each row to the right one pixel
with the rightmost pixel coming around to the left edge of the same row, I
think you may be forgetting that you have to drop the Y-register back to
index that first byte of each row. Something like this:
ldx #21
ldy #0
loop: lda (sprptr),y ; left row byte
lsr
iny
lda (sprptr),y ; middle row byte
ror
sta (sprptr),y
iny
lda (sprptr),y ; right row byte
ror
sta (sprptr),y
dey
dey
lda (sprptr),y ; left row byte
ror
sta (sprptr),y
iny ; next row's left row byte
iny
iny
dex
bne loop
rts
- Anton Treuenfels
|
|
|
|
Re: What am I doing wrong? [message #167493 is a reply to message #167491] |
Sat, 19 August 2006 23:59 |
|
Originally posted by: pacman_6502
Anton Treuenfels wrote:
> If the idea is to rotate all 24 pixels of each row to the right one pixel
> with the rightmost pixel coming around to the left edge of the same row, I
> think you may be forgetting that you have to drop the Y-register back to
> index that first byte of each row. Something like this:
>
> ldx #21
> ldy #0
>
> loop: lda (sprptr),y ; left row byte
> lsr
> iny
> lda (sprptr),y ; middle row byte
> ror
> sta (sprptr),y
> iny
> lda (sprptr),y ; right row byte
> ror
> sta (sprptr),y
> dey
> dey
> lda (sprptr),y ; left row byte
> ror
> sta (sprptr),y
> iny ; next row's left row byte
> iny
> iny
>
> dex
> bne loop
> rts
>
> - Anton Treuenfels
Thanks Anton. I have it working flawlessley now.
|
|
|