pigeonaut
Member
So I have been searching all over the forums & discord and have pieced together an ALMOST working tile-based background HUD for the scrolling module! I think I just need some help with updating the "scrolling loading seam" to ignore the HUD tiles at the top of the screen.
Here's how to set it up so far:
Step 1: I had to first modify the following scripts:
- In NMI.asm I added this chunk of code at about line 188 in order to check for sprite 0:
- In doDrawSprite_PlatformBase.asm I added this chunk of code to the top to actually draw out the sprite 0:
Step 2:
- Populate the following 'sprite 0' hud values in the nesmaker UI:
Step 3:
- Make sure you have a cube at the bottom right corner in your 'GameObjectTiles.bmp' tilesheet:
Step 4:
- This is super important! Make sure that you start your game on an even (including 0) space on your overworld!
Step 5:
- Make sure you have a HUD asset at the bottom right corner of your HUD. This is so that sprite 0 can collide with a background tile. If sprite 0 doesn't collide with a non-transparent background tile, the game will glitch out! I used the red orb for my hud asset:
Here are the resources that have helped me create this HUD so far, please check them out:
-
View: https://youtu.be/o7m4gxhgX0U
- http://www.nesmakers.com/index.php?threads/sprite-zero-detection.6973/
The HUD will follow the player as expected! However, the issue I am having now is that as I move and scroll to the next screen on my right, the HUD will get eaten by blank tiles. I am pretty sure this is because the scrolling seam overwrites the HUD tiles. I just need to find a way to have the seam updater INGNORE these top 2 rows of HUD tiles and the HUD should work like it did in 4.1.x!
I have been messing around in the doUpdateScrollColumn.asm and the doUpdateCamera.asm scripts but have not found a solution yet. But I think I am looking in the right place?
Has anyone ever modified the 'scroll seam column updater' thing before? Can anyone share any project code that might relate to this issue, such as parallax scrolling or animated tiles?
Thanks for reading!!!
Here's how to set it up so far:
Step 1: I had to first modify the following scripts:
- In NMI.asm I added this chunk of code at about line 188 in order to check for sprite 0:
Code:
LDA camX
STA $2005 ;reset scroll values to zero
LDA camY
STA $2005 ;reset scroll values to zero
;;;;;;;;;;my chunk of code! Start sprite 0 stuff;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LDA $0200 ;; OAM slot 0 [sprite-0]
CMP #SPRITE_ZERO_Y ;; check if sprite-0 is at a specific Y-coordinate
;; [I have a variable for this, you can just use a static number]
BNE skipSprite0Check
;;;; Do whatever exception conditionals for sprite-0 detection here:
BIT $2002 ;; reset $2005 / $2006 latch if it's in an unknown state
LDA #$00
STA $2005 ;; set initial scroll positions
STA $2005
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LDA #%10010000 ;; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
STA $2000 ;; start with nametable = 0 for status bar
LDA #%00011110 ;; enable sprites, enable background, no clipping on left side
STA $2001
WaitNotSprite0:
BIT $2002
BVS WaitNotSprite0 ;; wait until out of vBlank
WaitSprite0:
BIT $2002
BMI skipSprite0Check ;; if vBlank is detected, we missed the sprite 0 hit somehow.
;; jump out of the loop in that case. [safety net]
BVC WaitSprite0 ;; wait until sprite 0 is hit
LDX #01 ;hBlankTimer ;; I have a variable for my hBlank timer. You can also use a static number.
WaitScanline: ;; wait until the electron beam is in hBlank
DEX
BNE WaitScanline
LDA camX ;; Do scroll updates
STA $2005
LDA camY ;; This method cannot create a split y-axis scroll, but we'll set the Y position anyway.
STA $2005
LDA soft2001
STA $2001
skipSprite0Check:
;;;;;;;;;;;;;end of my chunk of code sprite zero stuff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
skipNMIstuff:
INC vBlankTimer
INC randomSeed
- In doDrawSprite_PlatformBase.asm I added this chunk of code to the top to actually draw out the sprite 0:
Code:
;; sprite drawing routine.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; For horizontal scrolling games, extra attention has to be taken to draw
;;; sprites off screen if they are no longer in the camera render area.
;;; sprite pre draw
;;;; DRAW SPRITE ZERO FOR SPRITE ZERO HIT
LDA gameState
CMP #GS_MainGame
BNE + ;dont draw sprite zero
;DrawSprite #$f8, #$1e, #$7F, #%00000000, spriteOffset
;248 30 127 bit 5 = priority
DrawSprite #SPRITE_ZERO_X, #SPRITE_ZERO_Y, #SPRITE_ZERO_INDEX, #%00100000, spriteOffset
UpdateSpritePointer
;dont draw sprite zero.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
.include SCR_DRAW_SPRITE_HUD
;;
LDA gameHandler
AND #%01000000
BEQ doDrawThisSprite
JMP doneDrawingThisSprite
doDrawThisSprite:
Step 2:
- Populate the following 'sprite 0' hud values in the nesmaker UI:
Step 3:
- Make sure you have a cube at the bottom right corner in your 'GameObjectTiles.bmp' tilesheet:
Step 4:
- This is super important! Make sure that you start your game on an even (including 0) space on your overworld!
Step 5:
- Make sure you have a HUD asset at the bottom right corner of your HUD. This is so that sprite 0 can collide with a background tile. If sprite 0 doesn't collide with a non-transparent background tile, the game will glitch out! I used the red orb for my hud asset:
Here are the resources that have helped me create this HUD so far, please check them out:
-
- http://www.nesmakers.com/index.php?threads/sprite-zero-detection.6973/
The HUD will follow the player as expected! However, the issue I am having now is that as I move and scroll to the next screen on my right, the HUD will get eaten by blank tiles. I am pretty sure this is because the scrolling seam overwrites the HUD tiles. I just need to find a way to have the seam updater INGNORE these top 2 rows of HUD tiles and the HUD should work like it did in 4.1.x!
I have been messing around in the doUpdateScrollColumn.asm and the doUpdateCamera.asm scripts but have not found a solution yet. But I think I am looking in the right place?
Has anyone ever modified the 'scroll seam column updater' thing before? Can anyone share any project code that might relate to this issue, such as parallax scrolling or animated tiles?
Thanks for reading!!!