Auto Scroll eats player

Raftronaut

Member
Mugi,

I am not sure I know how to check where the shooter module is grabbing the tile collisions from.
Other than: project -> Settings -> Script settings -> tile collisions

If that is the case, it is pointing to GameEngineData\Routines\Basic\ModuleScripts\MainScripts\TileCollision4_1_0

This is the script saturdayxiii posted earlier as a quick fix, which I had already put in place

Am I understanding your question correctly?
 

Mugi

Member
yeah, it's literally the same file that comes with the shooter module, and with the scrolling platformer module too for that matter (no idea why joe has to put 20 copies of the same file allover, it's confusing lol)
but then i've no idea why it would break anything.

i guess i'll have to actually make a shooter game to further play with this lol.
 
Sorry for the delay, I just got to try this now.

I got it working, or at least straight on. Pressing into the floor, and presumably the ceiling still does a really weird wrap around thing, but I guess it's a step in the right direction... or least a direction.

Mugi's code only edited the part of the Tilecollision code that uses gravity. The simple shooter module is a space shooter, so no gravity here. Here's the code I used to replace the "don'tUseGravity" section around line 110, so now it points to the new macros. Be aware I erased the comments here for readability, you may or may not still want them in your own file.
Code:
dontUseGravity:

	CheckPotentialPosition
	CheckPlayerCameraPositionHorizontal
    JSR updateHorizontalPosition
    CheckPotentialPosition
    CheckPlayerCameraPositionVertical
    JSR updateVerticalPosition
	
     JMP DoneWithTileChecksAndUpdatePosition
 

Raftronaut

Member
Ok, carving out more time to look into this. I am still getting some incredibly odd behavior from my game once I got these scripts working.

Listing the steps I took to get here:

Edited GameEngineData\Routines\Basic\ModuleScripts\MainScripts\ScrollingPlatformer\TileCollisions.asm with Mugi's script replacement

Deleted CheckPlayerCameraPosition.asm MACRO and added Macros for CheckPlayerCameraPositionHorizontal.asm AND CheckPlayerCameraPositionVertical.asm.

*** got saturdayxiii's unknown label error messages as shown in the thread.

Edited tile collisions with MUGI's scrollingshooter tilecollisions.asm and confirmed my script settings in project settings was pointing to the correct Asm file.

****lost all controller input

Edited the tile collision code with Saturdayxiii's "don't use gravity patch"

*** controller inputs are now working, getting seeming random screen wrap glitches. Character warps into screen edge and all sorts of chaos ensues (see video for random screen warps and wraps)

Any suggestions as to where to take this from here?

[/https://youtu.be/Dl0BdrnXJaw]
 

Mugi

Member
how are your screen settings set for each screen,
also how are your player objects edge reactions,
and then, how are your boundshandler assemblies.

wrap around basically means your boundshandlers are null and "edge stops player" is not working for god knows what reason. (god i love the music in that game lol.)
 

Raftronaut

Member
Mugi said:
how are your screen settings set for each screen,
also how are your player objects edge reactions,
and then, how are your boundshandler assemblies.

wrap around basically means your boundshandlers are null and "edge stops player" is not working for god knows what reason. (god i love the music in that game lol.)

Screen settings have the following flags checked:
Screen scrolls right, Autoscroll, and Edge stops player

Player object are set to solid edge reaction NULL and edge object reaction NULL as well.

I am completely unfamiliar with boundshandler assemblies, care to explain?
 

Mugi

Member
boundshandlers are 4 scripts defined in script settings that define what actually happens when you touch screen edges.
removing those effectively makes the screen just wrap around itself, they should be loaded by default from Routines\Basic\ModuleScripts\MainScripts\BoundsHandlers\
 

Raftronaut

Member
Now that the forums are back I am back on the hunt to solve this problem once again.

Putting together my laundry list here for my next NM session. I'll search for the boundshandlers and post the script here when I can!
 

Raftronaut

Member
Mugi said:
boundshandlers are 4 scripts defined in script settings that define what actually happens when you touch screen edges.
removing those effectively makes the screen just wrap around itself, they should be loaded by default from Routines\Basic\ModuleScripts\MainScripts\BoundsHandlers\


Mugi! I am STILL struggling with this issue. Just got back into the project with the forums being up again. Found my bounds handler scripts in project settings. Here is the script for 'handle left bounds'. I am not sure what to look for as far indicators as to what is going wrong. Any thoughts??!?

Can the X coordinate be changed here to limit the access it has to get pulled into the seem of the left bounds?

Code:
	LDA screenFlags
	AND #%00000010
	BEQ +
	
	;LDA screenFlags
	;AND #%00000100 ;; left bounds autoscrolling right
	;BEQ +
	LDA #$00
	STA Object_x_lo,x
	STA Object_h_speed_lo,x
	STA Object_h_speed_hi,x
	; for auto scrolling, use xScroll instead of xPrev? 
	;LDA xScroll
	LDA xPrev
	STA xHold_lo
	STA Object_x_hi,x
	STA xHold_hi
;	LDA xScroll_hi
;	STA Object_scroll,x
;	STA nt_hold


	JMP doneWithUpdateLeftScreen
	
+
	
	LDA #BOUNDS_RIGHT
	SEC
	SBC Object_right,x
	SEC 
	SBC #$02

	STA xHold_hi
	STA newX
	STA Object_x_hi,x
	
	LDA Object_y_hi,x
	STA newY
	
		LDA #$00
	STA xHold_lo
	STA yHold_lo

;;; check if side triggers change screen...for instance, if hurt, wouldn't, and would instead return *solid*

	
	LDA Object_scroll,x
			sec
			sbc #$01
			STA Object_scroll,x
			STA currentNametable
			STA newScreen
			STA currentScreen ;currentScreen
			STA xScroll_hi
			
			clc
			adc #$01
			STA rightNametable
			SEC
			SBC #$02
			STA leftNametable
			
			LDA Object_scroll,x
			AND #%00000001
			STA showingNametable
			
			
			LDA #$01
			STA screen_transition_type
			
		;LDA warpMap
			;CLC
			;ADC #$01
			;STA update_screen_details
			
			;;; update screen details will not change with left, right, up or down movement
			;;; unless the edge of a map should take you to the other map or something.
			;;; warpMap variable is used solely to hold whether the warp-out is to overworld or underworld.
			

		
	LDA #$01
	STA tile_solidity		
	LDA #$00
	STA gameHandler
		LDA #%11000000
				;7 = active
				;6 = 8 or 16 px tiles
			ORA #GS_MainGame
			ORA #%01000000
			STA update_screen

doneWithUpdateLeftScreen:
 

Raftronaut

Member
saturdayxiii said:
Sorry for the delay, I just got to try this now.

I got it working, or at least straight on. Pressing into the floor, and presumably the ceiling still does a really weird wrap around thing, but I guess it's a step in the right direction... or least a direction.

Mugi's code only edited the part of the Tilecollision code that uses gravity. The simple shooter module is a space shooter, so no gravity here. Here's the code I used to replace the "don'tUseGravity" section around line 110, so now it points to the new macros. Be aware I erased the comments here for readability, you may or may not still want them in your own file.
Code:
dontUseGravity:

	CheckPotentialPosition
	CheckPlayerCameraPositionHorizontal
    JSR updateHorizontalPosition
    CheckPotentialPosition
    CheckPlayerCameraPositionVertical
    JSR updateVerticalPosition
	
     JMP DoneWithTileChecksAndUpdatePosition

I am still struggling with this glitch, did you manage to find a solution? This last edit to the tilecollision.asm is raising all sorts of hell on the boundshandlers, causing player to respawn in the screen edge after death, getting stopped by null tiles behaving as solids (i've triple checked my screen collisions)

This is the one MAJOR roadbloack I have to finishing version 2.0 of my demo and would greatly like to see it resolved if possible. If you have any insight I would be forever grateful!
 

Mugi

Member
Sorry i really havent had time to look into this.... between juggling with real life issues and my own game's development i cant seem to even have time to eat nowadays...
 

Raftronaut

Member
I deleted the CheckPlayerCameraPosition.asm macro, I replaced with the CheckPlayerCameraPositionHorizontal and CheckPlayerCameraPositionVertical , then deleted and replaced the TileCollision_4_1_0.

Like I said in previous posts, all hell broke loose in the collision detection. This bug is driving me bananas. :shock:
Desperate for help at this point

CheckPlayerCameraPositionHorizontal:
Code:
MACRO CheckPlayerCameraPositionHorizontal
	CPX player1_object
    BEQ notdoneWithCameraCheckHorizontal
	JMP doneWithCameraCheckHorizontal
notdoneWithCameraCheckHorizontal:
	LDA gameHandler
	AND #%10000000
	BNE gameIsActive
	JMP doneWithCameraCheckHorizontal
gameIsActive:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; let's check to see if we're against the leftmost edge.
	LDA xScroll_hi
	BNE + ; not on screen 0
	;; is on screen zero
	LDA Object_h_speed_lo,x
	CLC
	ADC #$00
	LDA Object_h_speed_hi,x
	ADC #$00
	BPL + ;; not moving left.
	LDA Object_scroll,x
	BNE +
	LDA xScroll
	CMP xHold_hi
	BCS leftOfCameraForPlayer
	JMP checkRightEdge
+
    LDA nt_hold
    CMP xScroll_hi
    BCC leftOfCameraForPlayer
	;BEQ leftOfCameraForPlayer
    BNE checkRightEdge
    LDA xHold_hi
    CMP xScroll
    BCC leftOfCameraForPlayer
	;BEQ leftOfCameraForPlayer
    JMP checkRightEdge
leftOfCameraForPlayer:
    ;;; dont update position
    JMP doScrollingLeftBounds
checkRightEdge:
    LDA xScroll_hi
    CLC
    ADC #$01
    STA temp
    
    LDA xScroll
    SEC
    SBC Object_right,x
    STA temp1
    LDA temp
    SBC #$00
    STA temp

    CMP nt_hold
    BCC rightOfCameraEdgeForPlayer
	;BEQ rightOfCameraEdgeForPlayer
    BNE doneWithCameraCheckHorizontal
    LDA temp1
    CMP xHold_hi
    BCC rightOfCameraEdgeForPlayer
	;BEQ rightOfCameraEdgeForPlayer
    JMP doneWithCameraCheckHorizontal
rightOfCameraEdgeForPlayer:
    JMP doScrollingRightBounds
  
doScrollingLeftBounds:
    ;;; enter what should happen at bounds for player.
	;;; an RTS here will result in skipping position update.
	JSR doLeftBounds_player
    RTS    
    
doScrollingRightBounds:
    ;;; enter what should happen at bounds for player.
	;;; an RTS here will result in skipping position update.
	JSR doRightBounds_player
    RTS

doneWithCameraCheckHorizontal:
    ENDM

CheckPlayerCameraPositionVertical:
Code:
MACRO CheckPlayerCameraPositionVertical
	CPX player1_object
    BEQ notdoneWithVerticalCameraCheck
	JMP doneWithVerticalCameraCheck
notdoneWithVerticalCameraCheck:
	LDA gameHandler
	AND #%10000000
	BNE gameIsActiveCheckVertical
	JMP doneWithVerticalCameraCheck
gameIsActiveCheckVertical:

;;;;; TOP CHECK
	LDA Object_y_hi,x
	CLC
	ADC #$7F
	STA temp
	LDA Object_y_lo,x
	CLC
	ADC Object_v_speed_lo,x
	LDA temp
	ADC Object_v_speed_hi,x
	BVC notAtBoundsTop
	LDA #$00
	STA xScroll
	JSR doTopBounds_player
	RTS
;;;;; BOTTOM CHECK
notAtBoundsTop:
	LDA Object_y_lo,x
	CLC
	ADC Object_v_speed_lo,x
	LDA Object_y_hi,x
	ADC Object_v_speed_hi,x
	ADC Object_bottom,x
	CMP #BOUNDS_BOTTOM
	BCS atBottomBounds
	JMP doneWithVerticalCameraCheck
atBottomBounds:
	LDA #$00
	STA xScroll
	JSR doBottomBounds_player
	RTS

doneWithVerticalCameraCheck:
    ENDM

TileCollision_4_1_0:
Code:
HandleTileCollision:
    ;;;;;ASSUMES vulnerability bit 000x0000, if one, skips collision.
    ;;;;;Six collision points. 
    ;;;;;All collision points checked and registered for all objects.
    ;;;; a solid in any of the points will result in negating all others.
    
        ;;; There are 6 ram variables, collisionPoint0 - collisionPoint5.
        ;;; collisionPoint0 = top left
        ;;; collisionPoint1 = top right
        ;;; collisionPoint2 = bottom right
        ;;; collisionPoint3 = bottom left.
        ;;; collisionPoint4 = mid left
        ;;; collisionPoint5 = mid right.
    
    TXA 
    STA currentObject
    TYA
    STA tempy

	LDA npc_collision
	AND #%11111101
	LDA #$00
	STA npc_collision
	LDA navFlag
	AND #%11111110
	STA navFlag
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; EXPLANATION:
;; In this basic module, both non gravity and gravity scripts are loaded.
;; Under most circumstances, a user will likely make use of one or the other,
;; as they each take up a good chunk of data.  But the benefit of including both is that
;; a platforming game with gravity is just a simple bit flip in the screen flags.
    
    
    LDA screenFlags
    AND #%00100000
    BNE useGravity
    JMP dontUseGravity
useGravity:
	LDA Object_vulnerability,x
	AND #%00100000
	BEQ useGravity2
	LDA Object_physics_byte,x
	AND #%00000010
	BNE useGravity2
	JMP dontUseGravity
useGravity2:

;;;;;;===================================================
;;;;;;***************************************************
;;;;;; TILE COLLISION FOR SCROLLING PLATFORMERS:
;;;;;; For scrolling platformers we will use three types of collision detection:
;;;;;;          1. A routine to check under our feet to determine
;;;;;;              whether or not you are standing on a solid object.

                    ;;; This function will check under neath the object's feet
                    ;;; by arg0 pixels.
                    ;;; it will update bit 0 of the Object_physics_byte.
                    ;;; If that bit is 0, it means the place is free.
                    ;;; If that bit is 1, it means the place is solid.
    ;**********************
       CheckUnderObject #$01

;;;;;;
;;;;;;          2. A routine that checks to see if the potential position leaves you
;;;;;;              with your 'bottom' or 'top' in a solid object, in which case it ejects pixel perfect
;;;;;;              to that tile.

                    ;;; This function checks the POTENTIAL vertical position.
                    ;;; If it results in a point in a solid object, it appropriately
                    ;;; ejects and places the object directly against the point
                    ;;; of collision.
    ; **********************
     CheckForVerticalEjection 

  
;;;;;; Better check for any vertical updates now, or else
;;;;;; a horizontal collision could cancel out the required
;;;;;; bounds update
    CheckPlayerCameraPositionVertical


;;;;;;
;;;;;;          3. A routine which checks horizontal motion to see if the potential position
;;;;;;              sees a solid collision, in which case it can not move.
 
                    ;;; This function checks potential horizontal position.
                    ;;; without factoring in vertical motion.  If it sees a solid,
                    ;;; it skips motion.
    ; ***********************
      CheckForHorizontalCollision
    
;;;; This is the end of scrolling platform physics.  It automatically jumps to the proper place.  
;;;; Otherwise, if there was no collision, we jump to updating the position.
    ;; we only need to update horizontal position
    
  

    CheckPlayerCameraPositionHorizontal
;;;; if it turns out we were outside of the camera bounds, the macro
;;;; has RTSed out of this routine, so the hoziontal position will
;;;; never be updated.
   
     JSR updateHorizontalPosition
   
     JMP DoneWithTileChecksAndUpdatePosition
;;;;;;;;;;;;;==============================================  


dontUseGravity:

	CheckPotentialPosition
	CheckPlayerCameraPositionHorizontal
    JSR updateHorizontalPosition
    CheckPotentialPosition
    CheckPlayerCameraPositionVertical
    JSR updateVerticalPosition
	
     JMP DoneWithTileChecksAndUpdatePosition

     JMP DoneWithTileChecksAndUpdatePosition
   
   
   

;;; NO POINTS WERE SOLID    
    ;;;; update hold
DoneWithTileChecksAndUpdatePosition:
   ldx currentObject
    RTS
    
HandleSolidCollision:
	LDA screenFlags
	AND #%00000100 ;; is it autoscrolling?
	BEQ + ;; not autoscrolling
	;;; is auto scrolling
	CPX player1_object
	BNE +
	JSR CheckAutoScrollLeftEdge
	RTS 
+ ;; not auto scrolling.

	LDA xPrev
	STA xHold_hi
	LDA yPrev
	STA yHold_hi
    TYA
    STA tempy
    LDA Object_edge_action,x
    LSR
    LSR
    LSR
    LSR
    BEQ doNothingAtSolid
    TAY
    
    LDA AI_ReactionTable_Lo,y
    STA temp16
    LDA AI_ReactionTable_Hi,y
    STA temp16+1
    
    JSR doReactionTrampolineSolid
    JMP pastReactionTrampolineSolid
doReactionTrampolineSolid:
    JMP (temp16) ;;; this now does the action
            ;; and when it hits the RTS in that action,
            ;; it will jump back to the last JSR it saw,
            ;; which was doNewActionTrampoline...which will immediately
            ;; jump to pastDoNewActionTrampoline.
pastReactionTrampolineSolid:
    ;LDA #$00
    ;STA xHold_lo

doNothingAtSolid:
    ;;;;;;;;;;; Do solid reaction type.
    LDY tempy
    LDX currentObject
    RTS
    
    
ejectUp:
    LDA tileY
    and #%00001111;We can only be 0 to 15 pixels in any given wall
    sta temp
 
    lda Object_y_hi,x
    clc;Subtract one plus that so we're a pixel out of the wall rather than one pixel in it.
    SBC temp
    STA Object_y_hi,x
    LDA #$00
    STA yHold_lo
    STA Object_v_speed_hi,x
    STA Object_v_speed_lo,x
    RTS
    
ejectDown:

    lda tileY
    and #%00001111;we can only be 0 to 15 pixels in any given wall
    eor #%00001111;If we're at position 15 in the tile, we only want to eject 0 (+1) so flip the bits
    sec;Will add the extra one to the position so that we're a pixel out of the wall
    adc Object_y_hi,x;rather than one pixel in it.
    sta Object_y_hi,x
    
    LDA #$00
    STA yHold_lo
    STA Object_v_speed_hi,x
    STA Object_v_speed_lo,x
	
	;;; check the top two collision points to see if is it a prize block.
	LDA collisionPoint0
	CMP #COL_INDEX_PRIZE_BLOCK
	BEQ +
	JMP ++ 
+
	LDA Object_x_hi,x
	CLC
	ADC Object_left,x
	STA tileX
	JMP +++
++
	LDA collisionPoint1
	CMP #COL_INDEX_PRIZE_BLOCK
	BEQ +
	JMP ++
+
	LDA Object_x_hi,x
	CLC
	ADC Object_right,x
	STA tileX
+++


	
	LDA gameHandler
	ORA #%00010000
	STA gameHandler
	;;;;; check other head-hit type objects here.
	;; change collision data.
	;; should still have the correct coordinates in tileX and tileY
	ChangeTileAtCollision #$00, #TILE_INDEX_PRIZE_OFF
	
	TXA
	PHA
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	SEC
	SBC #$12 ;; a bit more than the height of it.
	STA temp1
	LDA Object_scroll,x
	STA temp2
	CreateObject temp, temp1, #OBJ_PRIZE, #$00, temp2
	LDA #$00
	SEC
	SBC #$04
	STA Object_v_speed_hi,x
	
	PLA
	TAX
	
++
    RTS
    
    
    

CheckForCollision:

    ;;;; commonly, we won't want to waste cycling 6 times through this for each object when
    ;;;; all points are at no collision.  If by chance we NEED the zero type collision to do something, 
    ;;;; we can comment out the zero type check in this next line.  But most games are going to have
    ;;;; at least one "blank tile" that does nothing, and most games will use zero for this.
	
	;;;; Another conundrum is that a collision could take place in the current or new nametable.
	;;;; if this collision is of type that draws from screen data (for instance, NPC data or warp data), it could
	;;;; be problematic, as all variables handling these things are loaded with the current collision tables data.
	;;;; tempCol ends up being 0 or 1 based on which collision table this should be referencing.
	
    STA temp
    BNE notZeroTypeCollision
    JMP zeroTypeCollision
notZeroTypeCollision:
    LDA #$00
    STA tile_solidity
DoCheckPointsLoop:
    LDA temp
    TAY
    LDA tileTypeBehaviorLo,y
    STA temp16
    LDA tileTypeBehaviorHi,y
    STA temp16+1
    JSR UseTileTypeTrampoline
    JMP pastTileTypeTrampoline
UseTileTypeTrampoline:
    JMP (temp16)
pastTileTypeTrampoline:
DontCheckTileType0:

    
zeroTypeCollision:
    ldx currentObject
    RTS
    
    
    
    
DetermineCollisionTable:
    LDA tempCol
    BNE colPointInDifferentTable
    ;;;; the collision point is in the current collision table.
    LDA Object_scroll,x
    AND #%00000001
    BNE isInOddTable
    JMP isInEvenTable
colPointInDifferentTable:
    ;;; the collision point to be checked is in the NEXT collision table.
    LDA Object_scroll,x
    AND #%00000001
    BNE isInEvenTable
    JMP isInOddTable
	

isInEvenTable:
    LDA collisionTable,y
    RTS
isInOddTable:
    LDA collisionTable2,y

    RTS


    
    
updateHorizontalPosition:
    LDA xHold_lo
    STA Object_x_lo,x
    LDA xHold_hi
    STA Object_x_hi,x
    LDA nt_hold
	CMP Object_scroll,x
	BEQ justUpdateScroll
	LDA #$01
	STA update_screen_data_flag
	LDA nt_hold
justUpdateScroll:
    STA Object_scroll,x
    
    RTS
    
updateVerticalPosition:
    LDA yHold_lo
    STA Object_y_lo,x
    LDA yHold_hi
    STA Object_y_hi,x   
    RTS
 

Raftronaut

Member
Mugi said:
Sorry i really havent had time to look into this.... between juggling with real life issues and my own game's development i cant seem to even have time to eat nowadays...

No worries! The trail went cold for me when the forums went down in April, I switched gears and started working on other aspects, many of which are done and ready to go, but I can't button anything up until I can resolve this one.
 

baardbi

Well-known member
This works great Mugi. I can finally go from screen to screen vertically (and touching solid tiles) without problems. However... I also use the wall grab system you made, and when I go to a screen on the left the player clings to the edge of the screen like it was a "wall grab tile". It looks like the invisible wall problem has come back to haunt me.

Here's a video of the problem:

[media]https://www.youtube.com/watch?v=-crChIs3hRQ[/media]

I haven't included any code in this post because I'm not sure what to post... :oops: :lol:

PS! I have deleted the CheckPlayerCameraPosition.asm and added the CheckPlayerCameraPositionHorizontal.asm and CheckPlayerCameraPositionVertical.asm.
 
Top Bottom