Sudden crash [MazeBase 4.5.9]

BITVADER

Member
I'm suffering from a sudden game crash.
View: https://youtu.be/HANoZ_vlkEY

It seems that the behavior when "myLives" is zero is strange, but the result is different when touching the monster and when touching the pain tile.
Similar code, but when you touch the pain tile and "my Lives" goes to zero, you get the desired result.
TXA
PHA
LDA gameHandler
AND #%10000000
BEQ +canHurtPlayer
JMP +skipHurt
+canHurtPlayer:
TXA
STA temp
GetActionStep temp
CMP #$07
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
GetActionStep temp
CMP #$06
BNE +PsHurt
JMP +skipHurt
+PsHurt
DEC myLives

PlaySong #song_index_MISS
UpdateHudElement #$01
LDA myLives
BNE +notZeroLives
;;;zero lives
ChangeActionStep player1_object, #$06
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
; LDA xPrev
; STA Object_x_hi,x
; LDA yPrev
; STA Object_y_hi,x
StopMoving temp, #$FF, #$00

;;WarpToScreen warpToMap, #$47, #$01
;; JMP RESET
RTS
+notZeroLives

ChangeActionStep player1_object, #$07
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
; LDA xPrev
; STA Object_x_hi,x
; LDA yPrev
; STA Object_y_hi,x
StopMoving temp, #$FF, #$00




+skipHurt
PLA
TAX
”PlayerHurt_MaseBase.asm”

;;; Simple Reset
;; check to see if object colliding is a player.
;; if not, do not reset.

CPX player1_object
BEQ +doHurtRecoil
JMP +dontHurtRecoil
+doHurtRecoil
TXA
STA temp
GetActionStep temp
CMP #$07
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
GetActionStep temp
CMP #$06
BNE +PsHurt
JMP +skipHurt
+PsHurt
DEC myLives

;;StopSound
PlaySong #song_index_MISS
ChangeTileAtCollision #$02, #$00
UpdateHudElement #$01
LDA myLives
BNE +notZeroLives
;;;zero lives
ChangeActionStep player1_object, #$06
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
; LDA xPrev
; STA Object_x_hi,x
; LDA yPrev
; STA Object_y_hi,x
StopMoving temp, #$FF, #$00

;;WarpToScreen warpToMap, #$47, #$01
;; JMP RESET
RTS
+notZeroLives

ChangeActionStep player1_object, #$07
;;StopSound
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
LDA xPrev
STA Object_x_hi,x
LDA yPrev
STA Object_y_hi,x
StopMoving temp, #$FF, #$00


+notAlreadyInHurtState

+skipHurt

+dontHurtRecoil:
”playerHurt_recoil_MazeBase.asm”
 
Last edited:

Jonny

Well-known member
Could be something related to pushing to the stack but not getting to the end of the script and pulling off the stack again. Try a JMP +skipHirt before your +notzerolives stuff instead of the RTS.
 

BITVADER

Member
Thank you very much.
We fixed it and avoided the crash, but this time there was an issue where it didn't change to action step # 6 when "myLives" went to zero.
 

BITVADER

Member
Hello dale.
For ActionStep #6
Action: StopMoving (Timer6)
EndAction: Gameover
End Animation: Loop
Is set.
EndAction "Gameover" now in "TimerEndScripts.asm"
userEnd1_action:
WarpToScreen warpToMap, #$47, #$01
RTS
It is described as. The destination is the game over screen.
I'm also working on ImputScript
For example, "stopMoving.asm" does this
HTML clipboard ;;;;
TXA
STA temp ;; assumes the object we want to move is in x.
GetActionStep temp
CMP #$07
BNE +notHurt
RTS
+notHurt
CMP #$06
BNE +notGameover
RTS
+notGameover
StopMoving temp, #$FF, #$00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RTS
A similar description is added to "changeActionToStep.asm" etc. so that ActionStep#6 is not interrupted.
 

dale_coop

Moderator
Staff member
The action step and the scripts seem correct.

But... I think I know what's happening.
When your lives is zero, in your handle player hurt script, you do a RTS (you leave the script), it means you don't execute the " PLA TAX" (that you should do, here !).

So.. instead of "RTS", do a :
Code:
JMP +skipHurt
I think it should fix your issue.
 

BITVADER

Member
Thanks dale.
TXA
PHA
LDA gameHandler
AND #%10000000
BEQ +canHurtPlayer
JMP +skipHurt
+canHurtPlayer:
TXA
STA temp
GetActionStep temp
CMP #$07
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
GetActionStep temp
CMP #$06
BNE +PsHurt
JMP +skipHurt
+PsHurt
DEC myLives

PlaySong #song_index_MISSBGM
UpdateHudElement #$01
LDA myLives
BNE +notZeroLives
;;;zero lives
ChangeActionStep player1_object, #$06
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
; LDA xPrev
; STA Object_x_hi,x
; LDA yPrev
; STA Object_y_hi,x
StopMoving temp, #$FF, #$00

;;WarpToScreen warpToMap, #$47, #$01
;; JMP RESET
;;RTS
JMP +skipHurt
+notZeroLives

ChangeActionStep player1_object, #$07
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
; LDA xPrev
; STA Object_x_hi,x
; LDA yPrev
; STA Object_y_hi,x
StopMoving temp, #$FF, #$00




+skipHurt
PLA
TAX
I replaced the "RTS" part with "JMP +skipHurt", but did not move to action step #6 even if myLives became zero.
 

BITVADER

Member
Only when I make a mistake with a monster, myLives seems to fly from the remaining one to -1 instead of zero.
I have no idea why this happens
 

dale_coop

Moderator
Staff member
Just for testing... you could try adding a:
Code:
LDA #$FF
STA gameState
before that JMP +skipHurt you recently modified.

Just to avoid all the physics and inputs scripts when you're in the dead state.
 

BITVADER

Member
Hallo dale.
I added the code but it didn't fix the problem.

Code:
    TXA
    PHA
    LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt
        +canHurtPlayer:
    TXA
    STA temp
    GetActionStep temp
    CMP #$07
    BNE +canHurtPlayer
        JMP +skipHurt
    +canHurtPlayer
    GetActionStep temp
    CMP #$06
    BNE +PsHurt
        JMP +skipHurt
    +PsHurt
    DEC myLives
    
    PlaySong #song_index_MISSBGM
    UpdateHudElement #$01
    LDA myLives
    BNE +notZeroLives
    ;;;zero lives
        ChangeActionStep player1_object, #$06       
    ;; recoil
            LDA #$00
            STA Object_h_speed_hi,x
            STA Object_h_speed_lo,x
            STA Object_v_speed_hi,x
            STA Object_v_speed_lo,x
            ; LDA xPrev
            ; STA Object_x_hi,x
            ; LDA yPrev
            ; STA Object_y_hi,x
            StopMoving temp, #$FF, #$00   
            ;;WarpToScreen warpToMap, #$47, #$01   
        ;;JMP RESET
        ;;RTS
        LDA #$FF
        STA gameState
        JMP +skipHurt
        
    +notZeroLives

    ChangeActionStep player1_object, #$07
            ;; recoil
            LDA #$00
            STA Object_h_speed_hi,x
            STA Object_h_speed_lo,x
            STA Object_v_speed_hi,x
            STA Object_v_speed_lo,x
            ; LDA xPrev
            ; STA Object_x_hi,x
            ; LDA yPrev
            ; STA Object_y_hi,x
            StopMoving temp, #$FF, #$00   



    
+skipHurt
    PLA
    TAX

The decrease in myLives when hitting a monster,
It seems to jump over zero only when it decreases from the last one to zero.
If it decreases from 3 to 2 or from 2 to 1, it will not jump over.

I would like to ask you another basic question.
I changed the position of the numbers in the HUD & Boxes / Tiles / settings, but the image at the original position (0xD0-0xD9) is reflected in the game.
Hud_number.PNG
 

dale_coop

Moderator
Staff member
Strange for the myLives issue... I will need to do some tests on my side.

For the numbers and letters in the HUD... I'd suggest to not change the order or placement. In fact, those are kinda harcoded in NESmaker >_<
 

dale_coop

Moderator
Staff member
Try adding:
Code:
    LDA gameState
    BEQ +continue
        JMP +skipHurt
    +continue:
Around the beginning of the script, just AFTER the "PHA" line.
 

BITVADER

Member
Thank you dale.
The problem has been solved, but when I hit a monster that moves when myLives becomes 0 on the hurttile, myLives becomes 0 or less and the game over process seems to be skipped.
In GetActionStep, which line would be the line to skip whether the action step is 06?
 

dale_coop

Moderator
Staff member
Hmmm...
Could you share your player hurt script ? (I will test it on my project... and see how we could tweak it)
 

Holmfry

Member
Hello! Did you guys figure the myLives issue out? I'm having the same thing, when my lives decrease from 1 to 0, it jumps right over zero and the game over process is skipped.

(Saw this post yesterday, didn't realize the latest entry was posted the same day I hit the same issue! Spooky!)

Here's my code:


Code:
    TXA
    PHA
    LDA gameState
    BEQ +continue
        JMP +skipHurt
    +continue:
    LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt
+canHurtPlayer:
    TXA
    STA temp
    GetActionStep temp
    CMP #$07
    BNE +canHurtPlayer
        JMP +skipHurt
    +canHurtPlayer
   
    DEC myLives
   
    UpdateHudElement #$01
    LDA myLives
    BNE +notZeroLives
        ;;;zero lives
        ChangeActionStep player1_object, #$06
            PlaySong #song_Death
            ;the code for proceeding to game over is in the User 1 action of Player,
            ;should trigger at end of animation
           
            JMP +skipHurt
    +notZeroLives
        ChangeActionStep player1_object, #$07
            ;; recoil
            ;StopSound
            PlaySound #sfx_Hurt
            ;PlaySong #song_Death
            LDA #$00
            STA Object_h_speed_hi,x
            STA Object_h_speed_lo,x
            STA Object_v_speed_hi,x
            STA Object_v_speed_lo,x
            ; LDA xPrev
            ; STA Object_x_hi,x
            ; LDA yPrev
            ; STA Object_y_hi,x
   
   
+skipHurt
    PLA
    TAX
 

kevin81

Active member
I'm not sure, but I think the following is up: when the player gets hurt, his action step is set to 7, which (among other things) prevents the player from getting hurt for some time. When the player has zero lives though, the player's action step is set to 6, to indicate the player is dead. My guess is that in this action state, the player can get hurt again, "decreasing" his number of lives from 0 to -1, or #$FF, setting the action step back to 7.

You might try to edit the player hurt code lines 11-18 into the following:

Code:
+canHurtPlayer:
    TXA
    STA temp
    GetActionStep temp
    CMP #$06
    BMI +canHurtPlayer ;; player can get hurt if action step is below 6
        JMP +skipHurt
    +canHurtPlayer
 

Holmfry

Member
I'm not sure, but I think the following is up: when the player gets hurt, his action step is set to 7, which (among other things) prevents the player from getting hurt for some time. When the player has zero lives though, the player's action step is set to 6, to indicate the player is dead. My guess is that in this action state, the player can get hurt again, "decreasing" his number of lives from 0 to -1, or #$FF, setting the action step back to 7.

You might try to edit the player hurt code lines 11-18 into the following:

Code:
+canHurtPlayer:
    TXA
    STA temp
    GetActionStep temp
    CMP #$06
    BMI +canHurtPlayer ;; player can get hurt if action step is below 6
        JMP +skipHurt
    +canHurtPlayer
Oh my gosh I think you're right!! Man, I was hitting my head against a brick wall for a while here lol. Thank you so much for the fresh eyes and the assist!! :) (TIL about BMI! Thank you!)
 
Last edited:

Holmfry

Member
Update, even with that change, it's still doing the same thing :/ Updated code:

Code:
    TXA
    PHA
    LDA gameState
    BEQ +continue
        JMP +skipHurt
+continue:
    LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt
+canHurtPlayer:
    TXA
    STA temp
    GetActionStep temp
    CMP #$06
    BMI +canHurtPlayer
        JMP +skipHurt
    +canHurtPlayer
    
        DEC myLives
        
        UpdateHudElement #$01
        LDA myLives
        BNE +notZeroLives
        ;;;zero lives
        ChangeActionStep player1_object, #$06
        ;; recoil
        ;StopSound
        
         PlaySong #song_Death
        
        JMP +skipHurt
    +notZeroLives
        ChangeActionStep player1_object, #$07
        ;; recoil
        ;StopSound
        PlaySound #sfx_Hurt
        ;PlaySong #song_Death
        LDA #$00
        STA Object_h_speed_hi,x
        STA Object_h_speed_lo,x
        STA Object_v_speed_hi,x
        STA Object_v_speed_lo,x
 
+skipHurt
    PLA
    TAX
 
Top Bottom