Basic Questions and Answers Thread

Discussion in 'Discussion & Q&A' started by Malevolence, Jul 7, 2009.

  1. Matt

    Matt Active Member Member

    Joined:
    Jan 31, 2021
    Messages:
    47
    Location:
    Italy
    Maybe it is a issue in terms of palette matches, but there are tons of issues regarding your game crash
     
  2. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Hi guys, I noticed a bug? I noticed that in Star Light Zone, the Pylons disappear when you reappear from a lamppost. That's like the art or the object itself won't load if we start from a checkpoint. Why???
     
    Deactivated Account likes this.
  3. Deactivated Account

    Deactivated Account Well-Known Member Exiled

    Joined:
    Aug 26, 2016
    Messages:
    244
    I always wanted to know about that bug, especially in SLZ 2 and 3 happened to me.
     
    Ashuro likes this.
  4. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    132
    Location:
    Sky Base Zone, South Island
    The pylon object is in the level layout and therefore isn't loaded if you're too far from it. Fix it by loading it at 0,0 upon level init manually.
     
  5. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    132
    Location:
    Sky Base Zone, South Island
    Uggghhhh, I've hit another dead end.

    So, I've been working on a Bonus Stage, and it's mostly functional... excluding one small thing.
    Compare what happens in these two videos:



    I have no clue what the garbage sprite is, but I have traced down the code at hand for causing the issue, first, the routine itself:

    Code:
    ; ---------------------------------------------------------------------------
    ; Subroutine to    update the HUD
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    HUD_UpdateBS:
            tst.b    (f_ringcount).w    ; does the ring    counter    need updating?
            beq.s    @chktime    ; if not, branch
            bpl.s    @notzero
            bsr.w    Hud_LoadZero    ; reset rings to 0 if Sonic is hit
    
        @notzero:
            clr.b    (f_ringcount).w
            hudVRAM    $DF40        ; set VRAM address
            moveq    #0,d1
            move.w    (v_rings).w,d1    ; load number of rings
            bsr.w    Hud_Rings
    
        @chktime:
            tst.b    (f_timecount).w    ; does the time    need updating?
            beq.w    @chklives    ; if not, branch
            tst.w    (f_pause).w    ; is the game paused?
            bne.w    @chklives    ; if yes, branch
            lea    (v_time).w,a1
            tst.l    (a1)+ ; is the time 9:59:59?
            beq.w    TimeOverBS    ; if yes, branch
    
            addq.b    #1,-(a1)    ; increment 1/60s counter
            cmpi.b    #60,(a1)    ; check if passed 60
            bcs.s    @chklives
            move.b    #0,(a1)
            subq.b    #1,-(a1)    ; increment second counter
            cmpi.b    #60,(a1)    ; check if passed 60
            bcs.s    @updatetime
            move.b    #0,(a1)
            subq.b    #1,-(a1)    ; increment minute counter
            cmpi.b    #9,(a1)        ; check if passed 9
            bcs.s    @BS_UpdateTime
            move.b    #9,(a1)        ; keep as 9
            
        @BS_UpdateTime:
            cmpi.w    #0,(v_timesec).w
            move.w #$3C3C,(v_timesec).w
    
        @updatetime:
            hudVRAM    $DE40
            moveq    #0,d1
            move.b    (v_timemin).w,d1 ; load    minutes
            bsr.w    Hud_Mins
            hudVRAM    $DEC0
            moveq    #0,d1
            move.b    (v_timesec).w,d1 ; load    seconds
            bsr.w    Hud_Secs
    
        @chklives:
            tst.b    (f_lifecount).w ; does the lives counter need updating?
            beq.s    @chkbonus    ; if not, branch
            clr.b    (f_lifecount).w
            bsr.w    Hud_Lives
    
        @chkbonus:
            tst.b    (f_endactbonus).w ; do time/ring bonus counters need updating?
            beq.s    @finish        ; if not, branch
            clr.b    (f_endactbonus).w
            locVRAM    $AE00
            moveq    #0,d1
            move.w    (v_timebonus).w,d1 ; load time bonus
            bsr.w    Hud_TimeRingBonus
            moveq    #0,d1
            move.w    (v_ringbonus).w,d1 ; load ring bonus
            bsr.w    Hud_TimeRingBonus
    
        @finish:
            rts   
    ; ===========================================================================
    
    TimeOverBS:
            clr.b    (f_timecount).w
            lea    (v_player).w,a0
            movea.l    a0,a2
            bsr.w    KillSonic
            move.b    #1,(f_timeover).w
            rts   
    ; ===========================================================================

    But, here's the exact subroutine I've traced it down to:

    Code:
        @chktime:
            tst.b    (f_timecount).w    ; does the time    need updating?
            beq.w    @chklives    ; if not, branch
            tst.w    (f_pause).w    ; is the game paused?
            bne.w    @chklives    ; if yes, branch
            lea    (v_time).w,a1
            tst.l    (a1)+ ; is the time 9:59:59?
            beq.w    TimeOverBS    ; if yes, branch
    
            addq.b    #1,-(a1)    ; increment 1/60s counter
            cmpi.b    #60,(a1)    ; check if passed 60
            bcs.s    @chklives
            move.b    #0,(a1)
            subq.b    #1,-(a1)    ; increment second counter
            cmpi.b    #60,(a1)    ; check if passed 60
            bcs.s    @updatetime
            move.b    #0,(a1)
            subq.b    #1,-(a1)    ; increment minute counter
            cmpi.b    #9,(a1)        ; check if passed 9
            bcs.s    @BS_UpdateTime
            move.b    #9,(a1)        ; keep as 9
            
        @BS_UpdateTime:
            cmpi.w    #0,(v_timesec).w
            move.w #$3C3C,(v_timesec).w 
    Specficially, just making it tick backwards time wise is all that is needed to trigger the bug.
    I've tried pretty much everything, and have established some things:
    - The time is indeed being properly set.
    - @BS_UpdateTime is not responsible. Neither is the time over check.
    - An address error occurs, but the code causing it is not responsible and is just a check for the bonus stage swapping out HUD mappings.
    This is the code in question:

    Code:
    @norings:
            cmpi.b    #id_BS,(v_zone).w
            beq.s   @alternatetimer
            cmpi.b    #9,(v_timemin).w ; have    9 minutes elapsed?
            bne.s    @display    ; if not, branch
            addq.w    #2,d0        ; make time counter flash red
    
        @display:
            move.b    d0,obFrame(a0)
            jmp    DisplaySprite
            
    @alternatetimer:
            cmpi.w    #0010,(v_timemin).w ; have    9 minutes elapsed?
            bgt.s    @display    ; if not, branch
            addq.w    #2,d0        ; make time counter flash red
            bra.s    @display
    And the address error which occurred with a slightly earlier version of the code above:
    [​IMG]
    - You don't even need to enter via checkpoint. Seeing a level at all is enough.
    - Debug HUD is not involved.
    Here's some other pieces of code related to the attempts to make the timer in the Bonus Stage start at 1:30 and tick towards 0.
    VBla_0C (bypassing vanilla HUD update):

    Code:
    VBla_0C:
    ;        stopZ80
    ;        waitZ80
            bsr.w    ReadJoypads
            tst.b    (f_wtr_state).w
            bne.s    @waterabove
    
            writeCRAM    v_pal_dry,$80,0
            bra.s    @waterbelow
    
    @waterabove:
            writeCRAM    v_pal_water,$80,0
    
        @waterbelow:
            move.w    (v_hbla_hreg).w,(a5)
            move.b   (v_hbla_line).w,(v_cramwaterpos).w
            writeVRAM    v_hscrolltablebuffer,$380,vram_hscroll
            writeVRAM    v_spritetablebuffer,$280,vram_sprites
            jsr    (ProcessDMAQueue).l
    
        @nochg:
            startZ80
            movem.l    (v_screenposx).w,d0-d7
            movem.l    d0-d7,(v_screenposx_dup).w
            movem.l    (v_fg_scroll_flags).w,d0-d1
            movem.l    d0-d1,(v_fg_scroll_flags_dup).w
            bsr.w    LoadTilesAsYouMove
            jsr    (AnimateLevelGfx).l
            cmpi.b #id_BS,(v_zone).w
            bne.s  @normal
            jsr    (HUD_UpdateBS).l
            bra.s @cont
            
    @normal:
            jsr    (HUD_Update).l
    @cont:
            bsr.w    sub_1642
            rts    
    Setting the base timer time:

    Code:
    Level_LoadObj:
            cmpi.b  #id_BS,(v_zone).w
            bne.s   @cont1
            move.l #(1*$10000)+(31*$100)+59,(v_time).w ; set the timer to maximum possible time
            
        @cont1:
            move.b    #0,(Rings_manager_routine).w
            jsr    RingsManager
            jsr    (ObjPosLoad).l
            jsr    (ExecuteObjects).l
            jsr    (BuildSprites).l
            moveq    #0,d0
            tst.b    (v_lastlamp).w    ; are you starting from    a lamppost?
            bne.s    Level_SkipClr    ; if yes, branch
            move.w    d0,(v_rings).w    ; clear rings
            cmpi.b  #id_BS,(v_zone).w
            beq.s   @cont
           
            move.l    d0,(v_time).w    ; clear time
        @cont:
            moveq    #0,d0
    
    I'm completely baffled. Is there something I should be clearing?
     
  6. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Resolved!
     
    Inferno likes this.
  7. Speems

    Speems Well-Known Member Member

    Joined:
    Mar 14, 2017
    Messages:
    83
    Location:
    Rochester Hills, MI
    How can you adjust the Debug Mode in Sonic 1 to function a bit more like Sonic 2's? Mainly like how you aren't immortal and you can enter object placement before the death animation leaves the screen boundaries, allowing you to resume the game as if nothing happened. I know of the ring/monitor fixes and the S3K esque display thing, but not the mortality and entering object placement to avoid death.
     
  8. badnest

    badnest Newcomer Member

    Joined:
    Dec 3, 2019
    Messages:
    20
    Location:
    Brazil Bad Future
    I don't wanna reveal anything about my project, so I'm gonna ask a theoretical question that's in principle similar to what I'm concerned with.

    Suppose romhacker A clones a clean git s1disasm, then adds a lot of tiles to artunc/sonic.bin. Sonic spindashing, walljumping, peel-outing, skateboarding, watching TV, skydiving, climbing a tree, lots more, 12 full frames of animation each.

    He then makes the pattern load cues and the sprite mappings for these, just like the stock tiles. At which point is he going to run out of RAM, and what will happen then? How can he know how much will "fit" and plan ahead for what to leave out? Any guides on what's been done in order to free more RAM for that?

    I'm assuming here that all of Sonic's sprites are loaded from ROM to RAM at once in the start of the game, I'm not sure that this is how it works so if someone can point out somewhere I can read more about this in specific that would be great.
     
  9. yami

    yami the homing attack addict Member

    Joined:
    Sep 24, 2020
    Messages:
    34
    I don't really have answers for the first two questions, but I think the last one I might have an answer for.

    I don't think there are any guides on freeing RAM, however, there is a guide showing how to extend the limit of animations, mappings, and art. (if you've got 12 frames of animation each you're definitely going to need it)
    It should work in the GitHub disassembly, although the guide is targeted towards the Hivebrain disassembly. As long as you can find the equivalent files and labels for stuff you should be okay for the most part.
     
  10. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    132
    Location:
    Sky Base Zone, South Island
    And if the concern is the size of Sonic's art buffer in RAM... just switch over to using the DMA queue, it should make things easier.
     
  11. Chron Dafter

    Chron Dafter Newcomer Member

    Joined:
    May 8, 2020
    Messages:
    16
    So, I added in custom title cards to Sonic 1, but now the HUD won't load in. How do I fix this?
    [​IMG]
     
  12. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    424
    Location:
    Western New York, USA
    You should give a bit more contextual information about what exactly was changed in terms of code and whatnot. It might be kinda hard to identify the issue otherwise...
     
  13. SuperSayian Zrise

    SuperSayian Zrise Well-Known Member Exiled

    Joined:
    May 10, 2021
    Messages:
    78
    I tried to port hidden palace but for some reason the background does a weird thing. I think it has something to do with the deformation.
     
  14. DeltaWooloo

    DeltaWooloo The noob next door Member

    Joined:
    Aug 7, 2019
    Messages:
    373
    My instincts tell me either you haven't ported the background deformation correctly or you haven't set the chunks correctly regarding the background. Open up the level in SonLVL and see if you have any missing chunks for the background. If not, then send the background deformation code. Otherwise, there's not much to show for me to find a preferable solution.
     
    SuperSayian Zrise likes this.
  15. SuperSayian Zrise

    SuperSayian Zrise Well-Known Member Exiled

    Joined:
    May 10, 2021
    Messages:
    78
  16. Chron Dafter

    Chron Dafter Newcomer Member

    Joined:
    May 8, 2020
    Messages:
    16
    TheInvisibleSun
    I replaced the entire file in github "34 Title Cards". On top of that, now there's an whenever I get a game over
    upload_2021-6-23_21-9-27.png
    I can DM you the file title card if you'd like a closer look
     

    Attached Files:

  17. TheInvisibleSun

    TheInvisibleSun Visible Member

    Joined:
    Jul 2, 2013
    Messages:
    424
    Location:
    Western New York, USA
    Sorry, I didn't mean to imply that I could (or had the time to) help fix the issue. I'm saying that giving more information helps people help you; even saying that you replaced the title card file doesn't offer much info, because it doesn't show specifically what was modified and how. If you are afraid of openly releasing your code (or someone else's code) to the public, I understand your reluctance. Otherwise, I suggest elaborating with your actual modified code if you want help in this thread (or DM someone you know who might be able to solve it).
     
  18. SuperSayian Zrise

    SuperSayian Zrise Well-Known Member Exiled

    Joined:
    May 10, 2021
    Messages:
    78
    Really sorry but I got a different problem.
    This time its this:
    Code:
    Sonic_JumpHeight:
        tst.b    jumping(a0)    ; is Sonic jumping?
        beq.s    Sonic_UpVelCap    ; if not, branch
    
        move.w    #-$400,d1
        btst    #6,status(a0)    ; is Sonic underwater?
        beq.s    +        ; if not, branch
        move.w    #-$200,d1
    +
        cmp.w    y_vel(a0),d1    ; is Sonic going up faster than d1?
        ble.s    Sonic_InstaAndShieldMoves        ; if not, branch
        move.b    (Ctrl_1_Held_Logical).w,d0
        andi.b    #button_B_mask|button_C_mask|button_A_mask,d0 ; is a jump button pressed?
        bne.s    +        ; if yes, branch
        move.w    d1,y_vel(a0)    ; immediately reduce Sonic's upward speed to d1
    +
        tst.b    y_vel(a0)        ; is Sonic exactly at the height of his jump?
        beq.s    Sonic_CheckGoSuper    ; if yes, test for turning into Super Sonic
        rts
    ; ---------------------------------------------------------------------------
    ; loc_1AB22:
    Sonic_UpVelCap:
        tst.b    pinball_mode(a0)    ; is Sonic charging a spindash or in a rolling-only area?
        bne.s    return_1AB36        ; if yes, return
        cmpi.w    #-$FC0,y_vel(a0)    ; is Sonic moving up really fast?
        bge.s    return_1AB36        ; if not, return
        move.w    #-$FC0,y_vel(a0)    ; cap upward speed
    
    return_1AB36:
        rts
    ; ---------------------------------------------------------------------------
    Sonic_InstaAndShieldMoves:
            move.b    (Ctrl_1_Press_Logical).w,d0
            andi.b    #$70,d0                ; are buttons A, B, or C being pressed?
            beq.s    locret_11A14            ; if not, branch
            bset    #4,status(a0)    ; set the rolling+jumping flag
            tst.b    (Super_Sonic_flag).w
            beq.s    locret_11A14        ; if not in a super-state, branch
            bset    #status_sec_isInvincible,status_secondary(a1)    ; give invincibility status
                       move.w    #6*60,invincibility_time(a1)                                   ; 6 seconds   
            move.w    x_pos(a0),d2                ; Get player's x_pos
            move.w    y_pos(a0),d3                ; Get player's y_pos
            addi.w    #$18,d2                    ; Add width of Insta-Shield
            addi.w    #$18,d3                    ; Add height of Insta-Shield
            move.w    #$30,d4                    ; Player's width
            move.w    #$30,d5       
            rts
    ; ---------------------------------------------------------------------------
    
    locret_11A14:
            rts
    ; ---------------------------------------------------------------------------
    ; ---------------------------------------------------------------------------
    ; End of subroutine Sonic_JumpHeight
    
    
    Now there isn't any crash or building problems of what I have seen. its that I can't seem to get the distance of the insta shield to work. Yes it works and gives a quick invincibility its the distance doesn't do anything.
    I'm trying to say that I go near an enemy and use the shield to hit it (not directly.) And it doesn't work like how it does in Sonic 3 & Knuckles. I don't care if I do or don't have the insta shield graphic that's for another time.
     
  19. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    416
    Location:
    Town Creek, AL
    Hope someone can help
    https://www.youtube.com/watch?v=H3aVyxYsbu4
    as seen here, the "Play Sonic 1" , "Ending", and "Credits" bugs out like this. It doesn't seem to work as intended, instead it goes back to the Options. However going to the "Level Select" works as it should when you choose a level. you game over, it goes back to the sega screen.
    here is the code for reference

    Code:
    LevSel_PlaySonic1:
            cmpi.b    #2,(LevelSelectRam)
            beq    Character_Selector
            tst.b    (LevelSelectRam)
            bne    LevSel_NoMove
            cmpi.w    #$04,($FFFFFF82).w ; is    item $14 selected?
            bne    LevSel_Ending    ; if not, branch
            move.b    ($FFFFF605).w,d1
            andi.b    #ButtonStart,d1        ; is left/right    pressed?
            beq    LevSel_NoMove
          
          
            move.b    #$C,($FFFFF600).w ; set    screen mode to $0C (level)
            move.b    #3,($FFFFFE12).w ; set lives to    3
            moveq    #0,d0
            move.w    d0,($FFFFFE20).w ; clear rings
            move.l    d0,($FFFFFE22).w ; clear time
            move.l    d0,($FFFFFE26).w ; clear score
            move.b    d0,($FFFFFE16).w ; clear special stage number
            move.b    d0,($FFFFFE57).w ; clear emeralds
            move.l    d0,($FFFFFE58).w ; clear emeralds
            move.l    d0,($FFFFFE5C).w ; clear emeralds
            move.b    d0,($FFFFFE18).w ; clear continues
            move.b    #$E0,d0
            bsr.w    PlaySound_Special ; fade out music
          
            jmp    Level_LSPL
    ; ===========================================================================
    LevSel_Ending:    cmpi.b    #2,(LevelSelectRam)
            beq    Character_Selector
            tst.b    (LevelSelectRam)    ; the Level Select
            bne    LevSel_NoMove        ; don't need this
            cmpi.w    #$05,($FFFFFF82).w ; is    item $05 selected?
            bne    LevSel_Credits    ; if not, branch
            move.b    ($FFFFF605).w,d1    ; save buttons to d1
            andi.b    #ButtonStart,d1        ; is left/right    pressed?
            beq    LevSel_NoMove        ; branch if not
                            ; I need to move this
                            ; XREF: LevelSelect
            move.b    #$18,($FFFFF600).w ; set screen    mode to    $18 (Ending)
            move.w    #$600,($FFFFFE10).w ; set level    to 0600    (Ending)
            jmp    EndingSequence
            rts      
    ; ===========================================================================
    
    LevSel_Credits:    cmpi.b    #2,(LevelSelectRam)
            beq    Character_Selector
            tst.b    (LevelSelectRam)
            bne    LevSel_NoMove
            cmpi.w    #$06,($FFFFFF82).w ; is    item $14 selected?
            bne    LevSel_Special    ; if not, branch
            move.b    ($FFFFF605).w,d1
            andi.b    #ButtonStart,d1        ; is left/right    pressed?
            beq    LevSel_NoMove
    
            move.b    #$1C,($FFFFF600).w ; set    screen mode to $0C (level)
          
            move.b    #3,($FFFFFE12).w ; set lives to    3
            moveq    #0,d0
            move.w    d0,($FFFFFE20).w ; clear rings
            move.l    d0,($FFFFFE22).w ; clear time
            move.l    d0,($FFFFFE22).w ; clear time
                move.l    d0,($FFFFFE26).w ; clear score
            move.b    d0,($FFFFFE30).w ; clear lamppost count
            subq.b    #1,($FFFFFE18).w ; subtract 1 from continues
            jmp    Credits  
    
    with the Ending, it tries to go to the credits, but instead, the Options.
    with Credits, it'll show the first, then back to Options
     
  20. Speems

    Speems Well-Known Member Member

    Joined:
    Mar 14, 2017
    Messages:
    83
    Location:
    Rochester Hills, MI
    So uh, has there been an attempt to port the leaderboard system from the Mega Play version of Sonic 1 into the main version? That tidbit for the darker GHZ palette being similar to the Mega Play leaderboard screen and the theories of co-existing development (being developed alongside the Genesis version or having it also intended for that system) makes me ask this question, curiosity has struck me big time.