Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Commodore » Commodore 8-bit » What am I doing wrong?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
What am I doing wrong? [message #167479] Sat, 19 August 2006 15:40 Go to next message
Anonymous
Karma:
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 Go to previous messageGo to next message
CIP is currently offline  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 Go to previous messageGo to next message
Anonymous
Karma:
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 Go to previous messageGo to next message
Glenn Holmer is currently offline  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 Go to previous messageGo to next message
Anton Treuenfels is currently offline  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 #167492 is a reply to message #167489] Sat, 19 August 2006 23:57 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: pacman_6502

Glenn Holmer wrote:

> Are you sure you mean to be adding to the base address here?

I can't believe I missed that. That was the problem. Thanks a lot for
your help.
Re: What am I doing wrong? [message #167493 is a reply to message #167491] Sat, 19 August 2006 23:59 Go to previous message
Anonymous
Karma:
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.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problem with 1571 disk drive .... help!! :)
Next Topic: Commodore FTP Sites Listing -- Last update 24 Jun 2006
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Apr 20 00:15:44 EDT 2024

Total time taken to generate the page: 0.05388 seconds