News: 11 March 2016 - Forum Rules

Author Topic: Need help with this CHR-RAM Tile Shift (Code and Picture inside)  (Read 1810 times)


  • Sr. Member
  • ****
  • Posts: 287
    • View Profile
    • My YouTube Channel: RetroRainZX85
I'm hacking this game, and I'm trying to do some parallax scrolling.  But I'm running into some problems, as the code is not working.  I was wondering if anyone could point out the errors in my code?  Thanks.

Code: [Select]
LDA $2002
BPL Vblank ; Wait for Vblank.

LDA #$00
STA $2006
LDA #$80
STA $2006 ; Set $2006 to PPU Tile $08 on the left side of the PPU.

LDA $2007 ; Dummy Read.  First read doesn't read anything, hence the dummy read.

LDX #$00 ; Set X to #$00.
LDA $2007 ; Read first of 16 bytes of PPU tile $08.
ROR ; Rotate bit to the right (Shifting the tile to the right).
INX ; Increment Loop Counter.
CPX #$10 ; Check to see if loop has reached the end.
BNE Loop ; If loop is not finished continue on with it.
        LDA #$00
        STA $2006
        STA $2006       ; Clear internal VRAM address before returning.
RTS ; Return from Sub-routine.


  • Hero Member
  • *****
  • Posts: 2763
    • View Profile
Re: Need help with this CHR-RAM Tile Shift (Code and Picture inside)
« Reply #1 on: June 28, 2013, 05:30:42 pm »
There is at least 3 things that might be wrong.

First of all, you are loading from $2007, you do a ROR operation on it, and discard the result (you don't store it anywhere). How could this work in the 1st place ? You need to write something write to $2007 for the change to be effective !

Then, 2nd problem, ROL and ROR does a 9-bit rotation, with the carry bit. What ROR does it :

Cin -> word -> Cout

Which is probably not what you want. Instead you'd want to do :
Code: [Select]
lda $2007
lsr A
ror A

[write something back to $2006]

sta $2007

3rd problem : Are you running this code during VBlank ? If you are, then fine, otherwise, it will never work as VRAM can't be accessed. (lda $2007 and sta $2007 will do Bad Things (TM). More seriously, this means doing so will have a completely unpredictable result, will mess the scrolling showing garbage on screen, etc, etc... ).