New splash screen method

Discussion in 'Tutorials Archive' started by Hitaxas, Oct 31, 2014.

Thread Status:
Not open for further replies.
  1. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    This is for replacing the SEGA screen.

    So I retried porting the code with the Retro Graphics Toolkit code and I got better results. Unfortunately, the mappings are screwed up. While the pallette and art look correct, it just shows it garbled up. I tried every compression type for the mappings and I tried changing the code but nothing fixed. Although, I think the problem comes from the code for the dumping location because if I set it to around $FFFFFFFF, the mappings, though still garbled, change. Can someone help?

    My Code:


    ; ============================================================================================
    ; Sega Screen example - This code only works as a replacement for the SEGA screen
    ; For regular Splash screens, read the guide this code comes with!
    ; 2014, Hitaxas
    ; ============================================================================================
    SegaScreen: ; Stop previous music, clear vram and screen to set up this new screen
    move.b #$E4,d0 ; set music ID to stop
    jsr PlaySound_Special.w ; play music ID
    jsr Pal_FadeFrom.w ; fade palette out
    move #$2700,sr ; disable interrupts
    move.w ($FFFFF60C).w,d0 ; load VDP register 81XX data
    andi.b #%10111111,d0 ; set display to "disable"
    move.w d0,($FFC00004).l ; save to VDP
    jsr ClearPLC.w ; clear pattern load cues
    jsr ClearScreen.w ; clear VRAM planes, sprite buffer and scroll buffer
    lea ($FF0000).l,a1 ; load dump location
    lea MAPS_SEGA.l,a0 ; load compressed mappings address
    move.w #320,d0 ; prepare pattern index value to patch to mappings
    jsr EniDec.w ; decompress and dump
    move.l #$60000003,d0 ; prepare VRAM write mode address (Plane B E000)
    moveq #$28-$01,d1 ; set map box draw width
    moveq #$1E-$01,d2 ; set map box draw height
    bsr.w ShowVDPGraphics ; flush mappings to VRAM
    lea ($FFC00006),a6 ; load VDP control port
    move.l #$68000000,(a6) ; set VDP to VRAM write mode (Address 2800)
    lea ART_SEGA.l,a0 ; load compressed art address
    jsr NemDec.w ; decompress and dump to VDP memory
    lea Pal_SEGANew.l,a0 ; load palette address
    lea ($FFFFFB80).w,a1 ; load palette buffer address
    moveq #$F,d0 ; set repeat times

    SegaScreen_PalLoop:
    move.l (a0)+,(a1)+ ; copy colours to buffer
    move.l (a0)+,(a1)+ ; ''
    dbf d0,SegaScreen_PalLoop ; repeat until done
    move.w ($FFFFF60C).w,d0 ; load VDP register 81XX data
    ori.b #%01000000,d0 ; set display to "enable"
    move.w d0,(a6) ; save to VDP
    jsr Pal_FadeTo ; fade palette in
    move.w #3*60,($FFFFF634).w ; set delay time (3 seconds on a 60hz system)

    Sega_MainLoop:
    move.b #2,($FFFFF62A).w ; set V-blank routine to run
    jsr DelayProgram.w ; wait for V-blank (decreases "Demo_Time_left")
    tst.b ($FFFFF605).w ; has player 1 pressed start button?
    bmi.s sega_GotoTitle ; if so, branch
    tst.w ($FFFFF634).w ; has the delay time finished?
    bne.s Sega_MainLoop ; if not, branch

    sega_GotoTitle:
    move.b #$04,($FFFFF600).w ; set the screen mode to Title Screen
    rts ; return
    ; ===========================================================================

    Picture of splash screen:

    (Note: I am using my own image but other images will use the same pattern)

    [​IMG]
     
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Code:
        lea    ($FFC00006),a6  ; load VDP control port
    That should be 04 instead of 06. Hence, the second word of long-word writes will not be collected.
     
  3. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Thank you so much! Now it works exactly as it should!

    Here is the final code for the Sonic 1 2005 Hivebrain Disassembly:


    ; ============================================================================================
    ; Sega Screen example - This code only works as a replacement for the SEGA screen
    ; For regular Splash screens, read the guide this code comes with!
    ; 2014, Hitaxas
    ; ============================================================================================
    SegaScreen: ; Stop previous music, clear vram and screen to set up this new screen
    move.b #$E4,d0 ; set music ID to stop
    jsr PlaySound_Special.w ; play music ID
    jsr Pal_FadeFrom.w ; fade palette out
    move #$2700,sr ; disable interrupts
    move.w ($FFFFF60C).w,d0 ; load VDP register 81XX data
    andi.b #%10111111,d0 ; set display to "disable"
    move.w d0,($FFC00004).l ; save to VDP
    jsr ClearPLC.w ; clear pattern load cues
    jsr ClearScreen.w ; clear VRAM planes, sprite buffer and scroll buffer
    lea ($FF0000).l,a1 ; load dump location
    lea MAPS_SEGA.l,a0 ; load compressed mappings address
    move.w #320,d0 ; prepare pattern index value to patch to mappings
    jsr EniDec.w ; decompress and dump
    move.l #$60000003,d0 ; prepare VRAM write mode address (Plane B E000)
    moveq #$28-$01,d1 ; set map box draw width
    moveq #$1E-$01,d2 ; set map box draw height
    bsr.w ShowVDPGraphics ; flush mappings to VRAM
    lea ($FFC00004),a6 ; load VDP control port
    move.l #$68000000,(a6) ; set VDP to VRAM write mode (Address 2800)
    lea ART_SEGA.l,a0 ; load compressed art address
    jsr NemDec.w ; decompress and dump to VDP memory
    lea Pal_SEGANew.l,a0 ; load palette address
    lea ($FFFFFB80).w,a1 ; load palette buffer address
    moveq #$F,d0 ; set repeat times

    SegaScreen_PalLoop:
    move.l (a0)+,(a1)+ ; copy colours to buffer
    move.l (a0)+,(a1)+ ; ''
    dbf d0,SegaScreen_PalLoop ; repeat until done
    move.w ($FFFFF60C).w,d0 ; load VDP register 81XX data
    ori.b #%01000000,d0 ; set display to "enable"
    move.w d0,(a6) ; save to VDP
    jsr Pal_FadeTo ; fade palette in
    move.w #3*60,($FFFFF634).w ; set delay time (3 seconds on a 60hz system)

    Sega_MainLoop:
    move.b #2,($FFFFF62A).w ; set V-blank routine to run
    jsr DelayProgram.w ; wait for V-blank (decreases "Demo_Time_left")
    tst.b ($FFFFF605).w ; has player 1 pressed start button?
    bmi.s sega_GotoTitle ; if so, branch
    tst.w ($FFFFF634).w ; has the delay time finished?
    bne.s Sega_MainLoop ; if not, branch

    sega_GotoTitle:
    move.b #$04,($FFFFF600).w ; set the screen mode to Title Screen
    rts ; return
    ; ===========================================================================


    Code:
    ART_SEGA:		incbin	"______/______.bin"
    			even
     
    MAPS_SEGA:		incbin	"______/______.bin"
    			even
    
    Pal_SEGANew:		incbin	"______/______.bin"
    
    
    Note: Using this may, for some reason, disable the ring sound effect for doing the level select code or anything else on the title screen.

    I recommend you use this tutorial for creating the files:

    http://sonicresearch.org/forums/index.php?showtopic=4047

    Save the palette as a bin file instead of adding it to your sonic1.asm.
     
  4. Hitaxas

    Hitaxas Retro 80's themed Paladins Twich streamer Member

    Joined:
    Aug 13, 2007
    Messages:
    167
    Edit: Fixed it

    Replacing this line:


    lea ($FFC00004),a6 ; load VDP control port

    With:


    lea ($FFC00004).l,a6 ; load VDP control port

    Allows everything to load correctly for me.

    However, timer never runs out so I had to hit start, changing this address:


    $FFFFF634

    To:


    $FFFFF614

    Solves this issue.

    Full final code that works for me on Sonic 1 2005 Hivebrain:


    ; ============================================================================================
    ; Sega Screen example - This code only works as a replacement for the SEGA screen
    ; For regular Splash screens, read the guide this code comes with!
    ; 2014, Hitaxas
    ; Ported to Sonic 1 2005 Hivebrain Thanks to ProjectFM
    ; ============================================================================================
    SegaScreen: ; Stop previous music, clear vram and screen to set up this new screen
    move.b #$E4,d0 ; set music ID to stop
    jsr PlaySound_Special.w ; play music ID
    jsr Pal_FadeFrom.w ; fade palette out
    move #$2700,sr ; disable interrupts
    move.w ($FFFFF60C).w,d0 ; load VDP register 81XX data
    andi.b #%10111111,d0 ; set display to "disable"
    move.w d0,($FFC00004).l ; save to VDP
    jsr ClearPLC.w ; clear pattern load cues
    jsr ClearScreen.w ; clear VRAM planes, sprite buffer and scroll buffer
    lea ($FF0000).l,a1 ; load dump location
    lea MAPS_SEGA.l,a0 ; load compressed mappings address
    move.w #320,d0 ; prepare pattern index value to patch to mappings
    jsr EniDec.w ; decompress and dump
    move.l #$60000003,d0 ; prepare VRAM write mode address (Plane B E000)
    moveq #$28-$01,d1 ; set map box draw width
    moveq #$1E-$01,d2 ; set map box draw height
    bsr.w ShowVDPGraphics ; flush mappings to VRAM
    lea ($FFC00004).l,a6 ; load VDP control port
    move.l #$68000000,(a6) ; set VDP to VRAM write mode (Address 2800)
    lea ART_SEGA.l,a0 ; load compressed art address
    jsr NemDec.w ; decompress and dump to VDP memory
    lea Pal_SEGANew.l,a0 ; load palette address
    lea ($FFFFFB80).w,a1 ; load palette buffer address
    moveq #$F,d0 ; set repeat times

    SegaScreen_PalLoop:
    move.l (a0)+,(a1)+ ; copy colours to buffer
    move.l (a0)+,(a1)+ ; ''
    dbf d0,SegaScreen_PalLoop ; repeat until done
    move.w ($FFFFF60C).w,d0 ; load VDP register 81XX data
    ori.b #%01000000,d0 ; set display to "enable"
    move.w d0,(a6) ; save to VDP
    jsr Pal_FadeTo ; fade palette in
    move.w #3*60,($FFFFF614).w ; set delay time (3 seconds on a 60hz system)

    Sega_MainLoop:
    move.b #2,($FFFFF62A).w ; set V-blank routine to run
    jsr DelayProgram.w ; wait for V-blank (decreases "Demo_Time_left")
    tst.b ($FFFFF605).w ; has player 1 pressed start button?
    bmi.s sega_GotoTitle ; if so, branch
    tst.w ($FFFFF614).w ; has the delay time finished?
    bne.s Sega_MainLoop ; if not, branch

    sega_GotoTitle:
    move.b #$04,($FFFFF600).w ; set the screen mode to Title Screen
    rts ; return
    ; ===========================================================================

    Either way, Thank you for porting the code mate, saves me the time and will help even more people out!
     
    Last edited by a moderator: Nov 6, 2014
  5. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    You're welcome! Thank you for crediting me in the code. I'm glad I could help.
     
  6. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    I ported the Sonic 1 Hivebrain 2005 disassembly code that loads after the SEGA screen. This is the way I'm using it in my hack.

    Here is the full tutorial:

    This is the tutorial I recommend for creating the files:

    http://sonicresearch.org/forums/index.php?showtopic=4047

    Save the palette file as a bin instead of adding it into sonic1.asm.

    Before adding the code for the new screen, redirect the original screen by changing "Sega_GotoTitle:" on the original code to this:


    Sega_GotoTitle:
    bsr.w SegaScreen2 ; go to next screen
    rts

    Then, add this code after the original code:


    ; ============================================================================================
    ; Sega Screen example
    ; This version is for splash screens that load AFTER the SEGA screen
    ; For A version that replaces the SEGA screen, read the guide this code came from!
    ; 2014, Hitaxas
    ; Ported to Sonic 1 Hivebrain Thanks to ProjectFM
    ; ============================================================================================
    SegaScreen2:
    move.b #$E4,d0 ; set music ID to "stop music"
    jsr Playsound_Special.w ; play ID
    jsr Pal_FadeFrom.w ; fade palettes out
    jsr ClearScreen.w ; clear the plane mappings
    ; load art, mappings and the palette
    lea ($FF0000).l,a1 ; load dump location
    lea MAPS_SEGA.l,a0 ; load compressed mappings address
    move.w #320,d0 ; prepare pattern index value to patch to mappings
    jsr EniDec.w ; decompress and dump
    lea ($FF0000).l,a1
    move.l #$60000003,d0
    moveq #39,d1
    moveq #30,d2
    bsr.w ShowVDPGraphics ; flush mappings to VRAM
    move.l #$68000000,($FFC00004).l ; set vdp loc
    lea ART_SEGA.l,a0 ; load background art
    jsr NemDec ; run NemDec to decompress art for display
    lea Pal_SEGANew.l,a0 ; load this palette
    lea ($FFFFFB80).l,a1 ; set as line 2
    move.w #$F,d0

    SegaScreen_PalLoop2:
    move.l (a0)+,(a1)+ ; copy colours to buffer
    move.l (a0)+,(a1)+ ; ''
    dbf d0,SegaScreen_PalLoop2 ; repeat until done
    jsr Pal_FadeTo ; fade palette in
    move.w #3*60,($FFFFF614).w ; set delay time (3 seconds on a 60hz system)

    Sega_MainLoop2:
    move.b #2,($FFFFF62A).w ; set V-blank routine to run
    jsr DelayProgram.w ; wait for V-blank (decreases "Demo_Time_left")
    tst.b ($FFFFF605).w ; has player 1 pressed start button?
    bmi.s sega_GotoTitle2 ; if so, branch
    tst.w ($FFFFF614).w ; has the delay time finished?
    bne.s Sega_MainLoop2 ; if not, branch

    sega_GotoTitle2:
    move.b #$04,($FFFFF600).w ; set the screen mode to Title Screen
    rts ; return

    And add this to the end of sonic1.asm before "end of 'ROM'":


    ART_SEGA: incbin "______/______.bin"
    even

    MAPS_SEGA: incbin "______/______.bin"
    even

    Pal_SEGANew: incbin "______/______.bin"

    Change the blanks to the file locations.

    And build!
     
  7. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    Would this work in S2? If so, would it work after the existing Sega screen?
     
  8. Hitaxas

    Hitaxas Retro 80's themed Paladins Twich streamer Member

    Joined:
    Aug 13, 2007
    Messages:
    167
    Thank you again ProjectFM for porting over the regular splash screen version, It works perfectly. :)

    @Pacguy, yes it will work following the original SEGA screen, for both S1 and S2.
     
Thread Status:
Not open for further replies.