don't click here

Static Splash Screen Guide

Discussion in 'Engineering & Reverse Engineering' started by Hitaxas, Oct 31, 2014.

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

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    As of November 3rd, I have changed a lot of this guide to work with Retro Graphics Toolkit, which required a slight edit of the code.

    Time for something I've been wanting to post up for a little while.

    I recently sat down and thought to myself "Splash screens are neat and all. However most of them are rather lengthy in code and almost all come with something complete they can just slap in there and call it a day. Not all, but most I've seen."

    From there I proceeded to write my own, using as few lines as I could.

    So today (or tonight for me!) I figured I would release this code. Yes, the code is complete and could simply be slapped into a ROM. BUT there is a difference here, I will provide example files for the code and a compiled ROM for it as well. HOWEVER, this example is purely that. Replacing the art/mappings and palette for the screen will be necessary due to the disclaimer the screen has. =P
    This screen is also static, and does not use any fancy effects or objects, that is up to whoever uses that to do on their own.

    ALSO, this was made with Xenowhirl's 2007 disassembly of Sonic 2, and that is what this tutorial will cover. It should be fairly easy to port to any other version of Sonic 2 or Sonic 3 & Knuckles, if you know basic assembly. For a version that works with Hivebrain's 2005 disassembly of Sonic 1, click HERE!

    But enough about that, lets get down to it!
    For this example I will be replacing the SEGA screen, you do not need to implement it this way if you know how to correctly add screen modes and set the code to go the the correct one next.

    First open S2.asm then search and locate the original sega screen at this label:
    segascreen:
    Once you have located this replace everything (including the original label) with this:

    Code (ASM):
    1.  
    2. ; ============================================================================================
    3. ; Sega Screen example - This code only works as a replacement for the SEGA screen
    4. ; For regular Splash screens, read the guide this code comes with!
    5. ; 2014, Hitaxas
    6. ; ============================================================================================
    7. SegaScreen: ; Stop previous music, clear vram and screen to set up this new screen
    8.     moveq  #$FD,d0                  ; set music ID to stop
    9.     jsr    (PlayMusic).w            ; play music ID
    10.     jsr    (Pal_FadeFrom).w         ; fade palette out
    11.     move   #$2700,sr                ; disable interrupts
    12.     move.w ($FFFFF60C).w,d0         ; load VDP register 81XX data
    13.     andi.b #%10111111,d0            ; set display to "disable"
    14.     move.w d0,(VDP_control_port).l  ; save to VDP
    15.     jsr    (ClearPLC).w             ; clear pattern load cues
    16.     jsr    (ClearScreen).w          ; clear VRAM planes, sprite buffer and scroll buffer
    17.     lea    (Metablock_Table).l,a1   ; load dump location
    18.     lea    (MAPS_SEGA).l,a0         ; load compressed mappings address
    19.     move.w #320,d0                  ; prepare pattern index value to patch to mappings
    20.     jsr    (EniDec).w               ; decompress and dump
    21.     move.l #$60000003,d0            ; prepare VRAM write mode address (Plane B E000)
    22.     moveq  #$28-$01,d1              ; set map box draw width
    23.     moveq  #$1E-$01,d2              ; set map box draw height
    24.     bsr.w  ShowVDPGraphics          ; flush mappings to VRAM
    25.     lea    (VDP_control_port).l,a6  ; load VDP control port
    26.     move.l #$68000000,(a6)          ; set VDP to VRAM write mode (Address 2800)
    27.     lea    (ART_SEGA).l,a0          ; load compressed art address
    28.     jsr    (NemDec).w               ; decompress and dump to VDP memory
    29.     lea    (Pal_SEGANew).l,a0          ; load palette address
    30.     lea    (Second_palette).w,a1    ; load palette buffer address
    31.     moveq  #$F,d0                   ; set repeat times
    32.  
    33. SegaScreen_PalLoop:
    34.     move.l (a0)+,(a1)+              ; copy colours to buffer
    35.     move.l (a0)+,(a1)+              ; ''
    36.     dbf    d0,SegaScreen_PalLoop    ; repeat until done
    37.     move.w ($FFFFF60C).w,d0         ; load VDP register 81XX data
    38.     ori.b  #%01000000,d0            ; set display to "enable"
    39.     move.w d0,(a6)                  ; save to VDP
    40.     jsr    Pal_FadeTo               ; fade palette in
    41.     move.w #3*60,(Demo_Time_left).w ; set delay time (3 seconds on a 60hz system)
    42.  
    43. Sega_MainLoop:
    44.     move.b #$02,(Delay_Time).w      ; set V-blank routine to run
    45.     jsr    (DelayProgram).w         ; wait for V-blank (decreases "Demo_Time_left")
    46.     tst.b  ($FFFFF605).w            ; has player 1 pressed start button?
    47.     bmi.s  sega_GotoTitle           ; if so, branch
    48.     tst.w  (Demo_Time_left).w       ; has the delay time finished?
    49.     bne.s  Sega_MainLoop            ; if not, branch
    50.  
    51. sega_GotoTitle:
    52.     move.b #$04,(Game_Mode).w       ; set the screen mode to Title Screen
    53.     rts                             ; return
    This is already completely written for this purpose. All that is left is to binclude the files I have provided here

    Put these files in a folder in the root of you hack with the name NEWSEGASCREEN

    To get these files to load into the game go to the bottom of your S2.ASM and just before the ; end of 'ROM' add these lines:

    Code (ASM):
    1. ART_SEGA:       binclude    "NEWSEGASCREEN/SEGAARTNEM.bin"
    2.             even
    3.  
    4. MAPS_SEGA:      binclude    "NEWSEGASCREEN/SEGAMAPSE.bin"
    5.             even
    6.  
    7. Pal_SEGANew:        binclude    "NEWSEGASCREEN/SEGAPAL.bin"
    8.             even
    Now save the asm file and build your ROM, everything should be in working order.

    You will be greeted with a screen that looks almost like this:

    [​IMG]

    However you will notice a slight difference with which you want to change. You will notice it if you've followed through with this guide.

    If you would like to download an already compiled ROM with this screen in it and see what it would look like when you implement it on your own click HERE

    From here it is up to you to change the art/mappings/palette. I suggest using a combination of Retro Graphics toolkit and Photoshop to do this, if you know how to use those programs. I will not be walking you through how to do this here.

    If you are looking to use this code as a splash screen rather than a replacement for the SEGA screen, you need to make a few changes.

    However, since I am too lazy right now, here is the complete code that allows for splash screens AFTER the SEGA screen:

    Code (ASM):
    1.  
    2.  ; ============================================================================================
    3. ; Sega Screen example
    4. ; This version is for splash screens that load AFTER the SEGA screen
    5. ; For A version that replaces the SEGA screen, read the guide this code came from!
    6. ; 2014, Hitaxas
    7. ; ============================================================================================
    8. SegaScreen2:
    9.         move.b  #$FD,d0                         ; set music ID to "stop music"
    10.         jsr     PlayMusic                       ; play ID
    11.         jsr     (Pal_FadeFrom).w                ; fade palettes out
    12.         jsr     (ClearScreen).w                 ; clear the plane mappings
    13.         dmaFillVRAM 0,$0000,$10000              ; fill entire VRAM with 0 | macro used in S2 disassemblies
    14.         ; load art, mappings and the palette
    15.         lea     (Metablock_Table).l,a1          ; load dump location
    16.         lea     (MAPS_SEGA).l,a0                ; load background mappings
    17.     move.w #320,d0                          ; offset the tilemap by n amount of tiles
    18.     bsr.w   EniDec
    19.     lea (Metablock_Table).l,a1
    20.     move.l  #$60000002,d0
    21.     moveq   #39,d1
    22.     moveq   #30,d2
    23.         bsr.w   ShowVDPGraphics3                ; flush mappings to VRAM
    24.         move.l  #$68000000,(VDP_control_port).l ; set vdp loc
    25.         lea     (ART_SEGA).l,a0                 ; load background art
    26.         jsr     NemDec                          ; run NemDec to decompress art for display
    27.     lea (Pal_SEGANEW).l,a0                 ; load this palette
    28.     lea (Second_palette).l,a1           ; set as line 2
    29.     move.w  #$F,d0
    30.  
    31. SegaScreen_PalLoop2:
    32.     move.l  (a0)+,(a1)+         ; copy colours to buffer
    33.     move.l  (a0)+,(a1)+         ; ''
    34.     dbf d0,SegaScreen_PalLoop2      ; repeat until done
    35.     jsr Pal_FadeTo          ; fade palette in
    36.         move.w  #3*60,(Demo_Time_left).w    ; set delay time (3 seconds on a 60hz system)
    37.  
    38. Sega_MainLoop2:
    39.         move.b  #$02,(Delay_Time).w     ; set V-blank routine to run
    40.     jsr (DelayProgram).w        ; wait for V-blank (decreases "Demo_Time_left")
    41.     tst.b   ($FFFFF605).w           ; has player 1 pressed start button?
    42.     bmi.s   sega_GotoTitle2         ; if so, branch
    43.     tst.w   (Demo_Time_left).w      ; has the delay time finished?
    44.     bne.s   Sega_MainLoop2          ; if not, branch
    45.  
    46. sega_GotoTitle2:
    47.     move.b  #$04,(Game_Mode).w      ; set the screen mode to Title Screen
    48.     rts                 ; return
    In my test this will allow the screen to show up correctly after the stock SEGA screen.
     
  2. SupaNeo

    SupaNeo

    Member
    11
    0
    1
    Great Britain
    LSL Scripting
    Looks good! The logo reminds me of the Sonic 4 promotional trailers. Possible bug though. I tried your compiled room and noticed the splash screen becomes garbled after the demo has finished. Results differ depending on the demo.
     
  3. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Updated the original post with the cleaned up code Markey provided, and a fix at the bottom of the post for those looking to use this for a splash screen that follows after the stock SEGA screen.

    Edit: I have changed the original post, along with the example picture and the files to work with Retro Graphics toolkit. That is what I will be personally using from now on, as it does a much better job at converting images for use with the Genesis.
     
  4. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Bumping this topic to let people that may be interested that this code has been ported over for use with Hivebrain's 2005 disassembly of Sonic 1 thanks to ProjectFM over at SSRG:

    For SEGA screen replacement:
    Code (ASM):
    1. ; ============================================================================================
    2. ; Sega Screen example - This code only works as a replacement for the SEGA screen
    3. ; For regular Splash screens, read the guide this code comes with!
    4. ; 2014, Hitaxas
    5. ; Ported to Sonic 1 2005 Hivebrain Thanks to ProjectFM
    6. ; ============================================================================================
    7. SegaScreen: ; Stop previous music, clear vram and screen to set up this new screen
    8.     move.b  #$E4,d0                 ; set music ID to stop
    9.     jsr    PlaySound_Special.w      ; play music ID
    10.     jsr    Pal_FadeFrom.w           ; fade palette out
    11.     move   #$2700,sr                ; disable interrupts
    12.     move.w ($FFFFF60C).w,d0         ; load VDP register 81XX data
    13.     andi.b #%10111111,d0            ; set display to "disable"
    14.     move.w d0,($FFC00004).l         ; save to VDP
    15.     jsr    ClearPLC.w               ; clear pattern load cues
    16.     jsr    ClearScreen.w            ; clear VRAM planes, sprite buffer and scroll buffer
    17.     lea    ($FF0000).l,a1           ; load dump location
    18.     lea    MAPS_SEGA.l,a0           ; load compressed mappings address
    19.     move.w #320,d0                  ; prepare pattern index value to patch to mappings
    20.     jsr    EniDec.w                 ; decompress and dump
    21.     move.l #$60000003,d0            ; prepare VRAM write mode address (Plane B E000)
    22.     moveq  #$28-$01,d1              ; set map box draw width
    23.     moveq  #$1E-$01,d2              ; set map box draw height
    24.     bsr.w  ShowVDPGraphics          ; flush mappings to VRAM
    25.     lea    ($FFC00004).l,a6         ; load VDP control port
    26.     move.l #$68000000,(a6)          ; set VDP to VRAM write mode (Address 2800)
    27.     lea    ART_SEGA.l,a0            ; load compressed art address
    28.     jsr    NemDec.w                 ; decompress and dump to VDP memory
    29.     lea    Pal_SEGANew.l,a0         ; load palette address
    30.     lea    ($FFFFFB80).w,a1         ; load palette buffer address
    31.     moveq  #$F,d0                   ; set repeat times
    32.  
    33. SegaScreen_PalLoop:
    34.     move.l (a0)+,(a1)+              ; copy colours to buffer
    35.     move.l (a0)+,(a1)+              ; ''
    36.     dbf    d0,SegaScreen_PalLoop    ; repeat until done
    37.     move.w ($FFFFF60C).w,d0         ; load VDP register 81XX data
    38.     ori.b  #%01000000,d0            ; set display to "enable"
    39.     move.w d0,(a6)                  ; save to VDP
    40.     jsr    Pal_FadeTo               ; fade palette in
    41.     move.w #3*60,($FFFFF614).w      ; set delay time (3 seconds on a 60hz system)
    42.  
    43. Sega_MainLoop:
    44.     move.b #2,($FFFFF62A).w         ; set V-blank routine to run
    45.     jsr    DelayProgram.w           ; wait for V-blank (decreases "Demo_Time_left")
    46.     tst.b  ($FFFFF605).w            ; has player 1 pressed start button?
    47.     bmi.s  sega_GotoTitle           ; if so, branch
    48.     tst.w  ($FFFFF614).w            ; has the delay time finished?
    49.     bne.s  Sega_MainLoop            ; if not, branch
    50.  
    51. sega_GotoTitle:
    52.     move.b #$04,($FFFFF600).w       ; set the screen mode to Title Screen
    53.     rts                             ; return   
    54. ; ===========================================================================
    For a splash screen that follows after the SEGA screen:
    Code (ASM):
    1. ; ============================================================================================
    2. ; Sega Screen example
    3. ; This version is for splash screens that load AFTER the SEGA screen
    4. ; For A version that replaces the SEGA screen, read the guide this code came from!
    5. ; 2014, Hitaxas
    6. ; Ported to Sonic 1 Hivebrain 2005 Thanks to ProjectFM
    7. ; ============================================================================================
    8. SegaScreen2:
    9.     move.b  #$E4,d0             ; set music ID to "stop music"
    10.     jsr     Playsound_Special.w     ; play ID
    11.     jsr     Pal_FadeFrom.w          ; fade palettes out
    12.     jsr     ClearScreen.w           ; clear the plane mappings
    13.     ; load art, mappings and the palette
    14.     lea     ($FF0000).l,a1          ; load dump location
    15.     lea     MAPS_SEGA.l,a0          ; load compressed mappings address
    16.     move.w  #320,d0             ; prepare pattern index value to patch to mappings
    17.     jsr     EniDec.w            ; decompress and dump
    18.     lea     ($FF0000).l,a1
    19.     move.l  #$60000003,d0
    20.     moveq   #39,d1
    21.     moveq   #30,d2
    22.     bsr.w   ShowVDPGraphics         ; flush mappings to VRAM
    23.     move.l  #$68000000,($FFC00004).l    ; set vdp loc
    24.     lea     ART_SEGA.l,a0           ; load background art
    25.     jsr     NemDec              ; run NemDec to decompress art for display
    26.     lea Pal_SEGANew.l,a0        ; load this palette
    27.     lea ($FFFFFB80).l,a1        ; set as line 2
    28.     move.w  #$F,d0
    29.  
    30. SegaScreen_PalLoop2:
    31.     move.l  (a0)+,(a1)+         ; copy colours to buffer
    32.     move.l  (a0)+,(a1)+         ; ''
    33.     dbf d0,SegaScreen_PalLoop2      ; repeat until done
    34.     jsr Pal_FadeTo          ; fade palette in
    35.     move.w  #3*60,($FFFFF614).w     ; set delay time (3 seconds on a 60hz system)
    36.  
    37. Sega_MainLoop2:
    38.     move.b  #2,($FFFFF62A).w        ; set V-blank routine to run
    39.     jsr DelayProgram.w          ; wait for V-blank (decreases "Demo_Time_left")
    40.     tst.b   ($FFFFF605).w           ; has player 1 pressed start button?
    41.     bmi.s   sega_GotoTitle2         ; if so, branch
    42.     tst.w   ($FFFFF614).w           ; has the delay time finished?
    43.     bne.s   Sega_MainLoop2          ; if not, branch
    44.  
    45. sega_GotoTitle2:
    46.     move.b  #$04,($FFFFF600).w      ; set the screen mode to Title Screen
    47.     rts                     ; return
    If you use both, you will need to replace this part of the code in the routine that replaces the SEGA screen:
    Code (ASM):
    1. sega_GotoTitle:
    2.     move.b #$04,($FFFFF600).w       ; set the screen mode to Title Screen
    3.     rts                             ; return
    with this:
    Code (ASM):
    1. Sega_GotoTitle:
    2.         bsr.w   SegaScreen2 ; go to next screen
    3.         rts
     
Thread Status:
Not open for further replies.