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:
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:
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:

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:
In my test this will allow the screen to show up correctly after the stock SEGA screen.
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:
; ============================================================================================
; 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
moveq #$FD,d0 ; set music ID to stop
jsr (PlayMusic).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,(VDP_control_port).l ; save to VDP
jsr (ClearPLC).w ; clear pattern load cues
jsr (ClearScreen).w ; clear VRAM planes, sprite buffer and scroll buffer
lea (Metablock_Table).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 (VDP_control_port).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 (Second_palette).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,(Demo_Time_left).w ; set delay time (3 seconds on a 60hz system)
Sega_MainLoop:
move.b #$02,(Delay_Time).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 (Demo_Time_left).w ; has the delay time finished?
bne.s Sega_MainLoop ; if not, branch
sega_GotoTitle:
move.b #$04,(Game_Mode).w ; set the screen mode to Title Screen
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:
ART_SEGA: binclude "NEWSEGASCREEN/SEGAARTNEM.bin" even MAPS_SEGA: binclude "NEWSEGASCREEN/SEGAMAPSE.bin" even Pal_SEGANew: binclude "NEWSEGASCREEN/SEGAPAL.bin" 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:

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:
; ============================================================================================
; 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
; ============================================================================================
SegaScreen2:
move.b #$FD,d0 ; set music ID to "stop music"
jsr PlayMusic ; play ID
jsr (Pal_FadeFrom).w ; fade palettes out
jsr (ClearScreen).w ; clear the plane mappings
dmaFillVRAM 0,$0000,$10000 ; fill entire VRAM with 0 | macro used in S2 disassemblies
; load art, mappings and the palette
lea (Metablock_Table).l,a1 ; load dump location
lea (MAPS_SEGA).l,a0 ; load background mappings
move.w #320,d0 ; offset the tilemap by n amount of tiles
bsr.w EniDec
lea (Metablock_Table).l,a1
move.l #$60000002,d0
moveq #39,d1
moveq #30,d2
bsr.w ShowVDPGraphics3 ; flush mappings to VRAM
move.l #$68000000,(VDP_control_port).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 (Second_palette).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,(Demo_Time_left).w ; set delay time (3 seconds on a 60hz system)
Sega_MainLoop2:
move.b #$02,(Delay_Time).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 (Demo_Time_left).w ; has the delay time finished?
bne.s Sega_MainLoop2 ; if not, branch
sega_GotoTitle2:
move.b #$04,(Game_Mode).w ; set the screen mode to Title Screen
rts ; return
In my test this will allow the screen to show up correctly after the stock SEGA screen.
This post has been edited by Hitaxas: 05 November 2014 - 11:49 PM


00