smilehero65
Well-known member
Even though parallax scrolling became a hallmark of the 16-bit era, NES devs were already experimenting with this effect. Despite the hardware not supporting multiple layers, they found multiple workarounds to make this work. One of them was moving sprites at half the speed of the camera to create the illusion of depth.

We can easily make this neat effect in NESMaker!
(Big thanks to SciNEStist, whose help was the main reason I came up with this code!)

We can easily make this neat effect in NESMaker!
(Big thanks to SciNEStist, whose help was the main reason I came up with this code!)
1) We will go to either:

- doSpritePreDraw.asm (if we want to draw the sprites in front of the object's sprites)
- doSpritePostdraw.asm (if we want to draw the sprites behind the object's sprites)
2) Paste the following code:
Code:
; ----------------------------------------
; Make sprites move half the camera speed
; ----------------------------------------
LDA camX
LSR A
STA temp3
;;Store sprite tile
LDA #$23
STA tempz
;;Store sprite attribute
LDA #%00000001
STA tempA
;%10000000 = Flipped vertically
;%01000000 = Flipped horizontally
;%00100000 = Display sprite behind the background tiles
;%00000011 = What sprite palette to use
;%00000000 = Sprite palette 0
;%00000001 = Sprite palette 1
;%00000010 = Sprite palette 2
;%00000011 = Sprite palette 3
;;We will draw 8 sprites that
;;are scattered around the
;;screen
; -----------------------------
; Sprite 1
; -----------------------------
LDA #$08
SEC
SBC temp3
STA temp1
LDA camScreen
AND #%00000001
BEQ +NoComp1
LDA temp1
SEC
SBC #128
STA temp1
+NoComp1
DrawSprite temp1, #$10, tempz, tempA
; -----------------------------
; Sprite 2
; -----------------------------
LDA #$28
SEC
SBC temp3
STA temp1
LDA camScreen
AND #%00000001
BEQ +NoComp2
LDA temp1
SEC
SBC #128
STA temp1
+NoComp2
DrawSprite temp1, #$30, tempz, tempA
; -----------------------------
; Sprite 3
; -----------------------------
LDA #$48
SEC
SBC temp3
STA temp1
LDA camScreen
AND #%00000001
BEQ +NoComp3
LDA temp1
SEC
SBC #128
STA temp1
+NoComp3
DrawSprite temp1, #$18, tempz, tempA
; -----------------------------
; Sprite 4
; -----------------------------
LDA #$68
SEC
SBC temp3
STA temp1
LDA camScreen
AND #%00000001
BEQ +NoComp4
LDA temp1
SEC
SBC #128
STA temp1
+NoComp4
DrawSprite temp1, #$50, tempz, tempA
; -----------------------------
; Sprite 5
; -----------------------------
LDA #$88
SEC
SBC temp3
STA temp1
LDA camScreen
AND #%00000001
BEQ +NoComp5
LDA temp1
SEC
SBC #128
STA temp1
+NoComp5
DrawSprite temp1, #$08, tempz, tempA
; -----------------------------
; Sprite 6
; -----------------------------
LDA #$A8
SEC
SBC temp3
STA temp1
LDA camScreen
AND #%00000001
BEQ +NoComp6
LDA temp1
SEC
SBC #128
STA temp1
+NoComp6
DrawSprite temp1, #$40, tempz, tempA
; -----------------------------
; Sprite 7
; -----------------------------
LDA #$C8
SEC
SBC temp3
STA temp1
LDA camScreen
AND #%00000001
BEQ +NoComp7
LDA temp1
SEC
SBC #128
STA temp1
+NoComp7
DrawSprite temp1, #$28, tempz, tempA
; -----------------------------
; Sprite 8
; -----------------------------
LDA #$E8
SEC
SBC temp3
STA temp1
LDA camScreen
AND #%00000001
BEQ +NoComp8
LDA temp1
SEC
SBC #128
STA temp1
+NoComp8
DrawSprite temp1, #$60, tempz, tempA
DONE!
Now you have a very neat little effect that can easily make your game look neat.
LIMITATIONS:
- We can only make simple backgrounds like starry nights or little clouds in the sky
- We still have the 64 sprite limit at the time, so be careful.
~ EXTRA ~
If you want to go further with parallaxing, baardbi has a tutorial on how to make a static sprite to simulate a sun in the background.
Make a sunset (or whatever) in the background 4.5.9
If you want a sunset (like Rygar) or something else to be static in the background while the screen scrolls I made a simple script that will help you do that. This script will show a 2x2 sprite in the background (behind normal tiles). By default the sprite graphic is one sprite tile flipped...
Last edited:
