Basic Questions and Answers Thread

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

  1. Sinkdude

    Sinkdude He looked much leaner on TV Member

    Joined:
    May 6, 2008
    Messages:
    40
    Location:
    Michigan
    I'm currently reworking on the Sonic 2 ROM hack project (with a new fresh disassembly to work with) and I'm working on adding FireRat's reworked generic Sega Screen to it. I need to make sure I'm porting this right, as the code was originally prepared for Sonic 1's GIt disassembly when he wrote it and I'm translating the variables and constants to those of Sonic 2's.

    Anything you need to point out on this, let me know and I'll see what I can do.

    The code itself is under the spoiler.
    Code:
    ; ---------------------------------------------------------------------------
    ; Sega screen
    ; ---------------------------------------------------------------------------
    
    GM_Sega:
                    move.b    #MusID_Stop,d0
                bsr.w    PlayMusic ; stop music
            bsr.w    ClearPLC
            bsr.w    Pal_FadeToBlack
            lea    ($C00004).l,a6
            move.w    #$8004,(a6)
            move.w    #$8200+(VRAM_SegaScr_Plane_A_Name_Table>>10),(a6)    ; set foreground nametable address
            move.w    #$8400+(VRAM_SegaScr_Plane_B_Name_Table>>13),(a6)    ; set background nametable address
            move.w    #$8700,(a6)            ; set background colour (palette entry 0)
            move.w    #$8B00,(a6)            ; full-screen vertical scrolling
            move.w    #$8134,(a6)            ; disable display
            clr.b    (Water_fullscreen_flag).w
            move    #$2700,sr
            bsr.w    ClearScreen
            dmaFillVRAM    $20
            lea    (Nem_NewSegaLogo).l,a0        ; load Sega logo patterns on tile #1
            bsr.w    NemDec
            lea    ($FF0000).l,a1
            lea    (Eni_NewSegaLogo).l,a0        ; load Sega logo mappings
            moveq    #1,d0                ; start from tile #1
            bsr.w    EniDec
            copyTilemap    $FF0000,(vram_bg+$61E),((96/8)-1),((32/8)-1)
    
            tst.b   (Graphics_Flags).w            ; is console Japanese?
            bpl.s   NewSega_jmp0                ; if yes, branch
            dmaFillVRAM    (VRAM_SegaScr_Plane_A_Name_Table+$634),4(a6)        ; set position to write to..
            move.l    #$00310032,(a6)            ; and write "TM"
    NewSega_jmp0:        move.w    #$EEE,v_pal_dry+$02+$80
            move.w    #-2,PalCycle_Frame        ; minus size of an entry
            move.w    #1,(PalCycle_Timer).w
    
            lea    Normal_palette+$04+$80,a1
            bsr    Palcycle_Sega
            move.w    #$8174,$C00004            ; enable display
            bsr.w    PaletteFadeIn
                move.b    #SndID_SegaSound,d0
                    bsr.w    PlaySound    ; play "SEGA" sound
            move.w    #3*60,(Demo_Time_left).w        ; stay for 3 seconds
    
    NewSega_WaitEnd:
            move.b    #2,(Vint_Routine).w
            bsr.w    WaitForVint
            lea    Normal_palette+$04,a1
            bsr    Palcycle_Sega
            tst.w    (Demo_Time_left).w
            beq.s    Sega_GotoTitle
                move.b    (Ctrl_1_Press).w,d0    ; is Start button pressed?
                or.b    (Ctrl_2_Press).w,d0    ; (either player)
                andi.b    #button_start_mask,d0
            beq.s    NewSega_WaitEnd            ; if not, branch
    
    NewSega_GotoTitle:
            move.b    #GameModeID_SSRGScreen,(Game_Mode).w
            rts
    
    Palcycle_Sega:
            subq.w    #1,PalCycle_Timer
            bne.s    Palcycle_Sega_return
            move.w    #3,PalCycle_Timer
            addq.w    #2,PalCycle_Frame
            cmpi.w    #Palcycle_Sega_cycle_size,PalCycle_Frame    ; past cycle's size?
            bne.s    Palcycle_Sega_jmp0                ; if not, branch
            move.w    #0,PalCycle_Frame            ; if yes, reset
    Palcycle_Sega_jmp0:
            move.w    PalCycle_Frame,d0
            lea    Palcycle_Sega_cycle(pc,d0.w),a0
            rept    4                ; repeat next line 4 times        ; --> transfer 9 colors in total
                move.l    (a0)+,(a1)+        ; copy 2 colors and increment pointers
            endr
            move.w    (a0),(a1)            ; copy last color
    Palcycle_Sega_return:    rts
    
    Palcycle_Sega_cycle:        dc.w    $EC0
            dc.w    $EA0, $E80, $E60, $E40, $E20, $E00
            dc.w    $C00
            dc.w    $E00, $E20, $E40, $E60, $E80, $EA0
    Palcycle_Sega_cycle_end:    ; remaining half copy before loop. Making it CPU-friendly
            dc.w    $EC0
            dc.w    $EA0, $E80, $E60, $E40, $E20, $E00
            dc.w    $C00
    Palcycle_Sega_cycle_size:=    Palcycle_Sega_cycle_end-Palcycle_Sega_cycle
     
  2. EpsilionDubwool

    EpsilionDubwool I am the danger. Member

    Joined:
    Aug 7, 2019
    Messages:
    363
    Hey there,

    Is there an easy way to port Sonic 3's elemental shields to Sonic 1 using the 2005 Hivebrain disassembly?
     
  3. Sinkdude

    Sinkdude He looked much leaner on TV Member

    Joined:
    May 6, 2008
    Messages:
    40
    Location:
    Michigan
    ProjectFM and Inferno like this.
  4. Chainspike

    Chainspike Newcomer Trialist

    Joined:
    May 9, 2017
    Messages:
    8
    Hello. I have a problem after adding vladikcomper's error handler in the Sonic 3 (alone) Github disassembly:
    [​IMG]
    I followed the steps for adding the error handler to S3K while making the relevant changes for sonic 3. The result is that the error handler does work, but gives an illegal instruction instantly upon loading the game. I know that there isn't an issue with loc_1FA6 as the game will load and play on real hardware without the error handler. The problem might be caused by Sonic 3's inability to read any data past ROM address $200000. Most emulators will ignore this but the problem persists on original hardware (Ex. levels and graphics located over this address fail to load). Part of the code for error handler is located at the end of ROM pointer (over $200000) which leads me to believe that this is the case.

    I usually don't ask questions, but I have not been able to solve this.

    EDIT: After disabling SRAM access (allowing $200000+ to read) the error handler still crashes the same way.
     
    Last edited: Jan 22, 2020
    Inferno and vladikcomper like this.
  5. penPhobic

    penPhobic Everything's all topsy-turvy now. Member

    Joined:
    Dec 11, 2016
    Messages:
    64
    Location:
    Basement
    Speaking of the error handler, I can't find it because the Dropbox link is dead. Is everybody have it?