How to put a custom background in S1's Level Select

Discussion in 'Tutorials Archive' started by Gardeguey, Sep 1, 2011.

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

    Gardeguey Well-Known Member Member

    Joined:
    Aug 6, 2010
    Messages:
    82
    Location:
    México
    Like this...


    [​IMG][​IMG]


    Well, Hi again, here's another guide from me.


    You'll need:

    1. ImaGenesis
    2. IrfanView
    3. The Sega Data Compressor


    Instructions:


    1. Find a picture, any pic you want (I recommend one which doesn't use much colors, and closest to fit on screen), I'm gonna use this one for example:


    http://i.imgur.com/JEbkh.jpg


    2. Run IrfanView


    Open the picture


    Click on "Image" -> "Resize/Resample"


    Set Width to: 320 and Height to: 224 (don't forget to uncheck: "Peserver aspect ratio")


    Now click "Image" -> "Decrease color Depth..."


    Set to "16 Colors (4BPP)" [And leave "Use Floyd-Steinberg dithering" checked, for better results]


    See if it looks good, then Save the pic, it should look like this:


    [​IMG]


    3. Run ImaGenesis

    • Open the optimized pic
    • Click on "Mode" -> "15 color [...] 8x8 tiles, Optimized" (Second option)
    • Click on "Actions" -> "Quantize Now" (or press F5) [Remember, the Genesis has limited colors]
    • Click on "Actions" again, and save the respective files (Tile data, Pallette data and Tile map)


    I'm gonna put them in a folder called LS_BG (more organized, but you can do it in your style)


    This is what you should have now in "LS_BG":


    GFX_u.bin


    Map_u.bin


    Pal.bin


    The Art and Mappings will be compressed to save space in ROM


    4. Run The Sega Data Compressor


    Click on "Nemesis" set the input file ("GFX_u.bin") and set the output file ("GFX.bin"), click on "Compress"


    Click on "Enigma", do the same thing as the GFX but this time for the Mappings ("Map_u.bin" to "Map.bin", and click "Compress")


    5. Open sonic1.asm


    Replace:



    Code:
    		moveq	#2,d0
    
    		bsr.w	PalLoad2	; load level select pallet
    
    		lea	($FFFFCC00).w,a1
    
    		moveq	#0,d0
    
    		move.w	#$DF,d1
    
     
    
    Title_ClrScroll:
    
    		move.l	d0,(a1)+
    
    		dbf	d1,Title_ClrScroll ; fill scroll data with 0
    
     
    
    		move.l	d0,($FFFFF616).w
    
    		move	#$2700,sr
    
    		lea	($C00000).l,a6
    
    		move.l	#$60000003,($C00004).l
    
    		move.w	#$3FF,d1
    
     
    
    Title_ClrVram:
    
    		move.l	d0,(a6)
    
    		dbf	d1,Title_ClrVram ; fill	VRAM with 0
    
     
    
    		bsr.w	LevSelTextLoad


    With:





    Code:
    	    jsr	Pal_FadeFrom		;Fade-out is necesarry now
    
     
    
    		moveq	#2,d0
    
    		bsr.w	PalLoad1
    
     
    
    		lea	($FFFF0000).l,a1
    
    		lea	(Eni_LevSel).l,a0
    
    		move.w	#1,d0
    
    		jsr	EniDec
    
    			lea	($FFFF0000).l,a1
    
    		move.l	#$40000003,d0
    
    		moveq	#39,d1
    
    		moveq	#29,d2
    
    		jsr	ShowVDPGraphics
    
     
    
    		move.l	#$40200000,($C00004).l
    
    		lea	(Nem_LevSel).l,a0
    
    		jsr	NemDec
    
     
    
    		lea	($FFFFCC00).w,a1
    
    		moveq	#0,d0
    
    		move.w	#$DF,d1
    
     
    
    @ClrScroll:
    
    		move.l	d0,(a1)+
    
    		dbf	d1,@ClrScroll
    
     
    
    		lea	($FFFFD000).w,a1
    
    		moveq	#0,d0
    
    		move.w	#$7FF,d1
    
     
    
    @ClrObjRam:
    
    		move.l	d0,(a1)+
    
    		dbf	d1,@ClrObjRam
    
     
    
    		lea	($FFFFF628).w,a1
    
    		moveq	#0,d0
    
    		move.w	#$15,d1
    
     
    
    @ClrVars:
    
    		move.l	d0,(a1)+
    
    		dbf	d1,@ClrVars
    
     
    
    		lea	($FFFFF700).w,a1
    
    		moveq	#0,d0
    
    		move.w	#$3F,d1
    
     
    
    @ClrVars2:
    
    		move.l	d0,(a1)+
    
    		dbf	d1,@ClrVars2
    
     
    
    		lea	($FFFFFE60).w,a1
    
    		moveq	#0,d0
    
    		move.w	#$47,d1
    
    @ClrVars3:
    
    		move.l	d0,(a1)+
    
    		dbf	d1,@ClrVars3
    
     
    
    		lea	($FFFFF800).w,a1
    
    		moveq	#0,d0
    
    		move.w	#$7F,d1
    
    @ClrSprTable:
    
    		move.l	d0,(a1)+
    
    		dbf	d1,@ClrSprTable
    
     
    
    		move.l	#0,($FFFFF616).w	;Clean VScroll
    
     
    
    		move	#$2700,sr
    
    	
    
    			lea	($C00000).l,a6
    
    		move.l	#$60000003,($C00004).l
    
    		move.w	#$3FF,d1
    
    @ClearBG:
    
    		move.l	d0,(a6)
    
    		dbf	d1,@ClearBG
    
     
    
    		bsr.w	LevSelTextLoad
    
     
    
    		jsr	Pal_FadeTo




    Next:



    add these before "EndOfRom":



    (again, in your style)





    Code:
    Nem_LevSel:		incbin	"LS_BG/GFX.bin"
    
    			even
    
    Eni_LevSel		incbin	"LS_BG/Map.bin"
    
    			even


    Don't forget the pallet, too.



    Find:





    Code:
    Pal_LevelSel:	incbin	pallet\levelsel.bin


    Replace with:





    Code:
    Pal_LevelSel:	incbin	"LS_BG\Pal.bin"
    
    			even


    THE RESULT:


    [​IMG]


    NOTE: results may vary (ex. if takes a lot to show the BG, too much GFX in VRAM and random colors in the font)


    Don't forget to give credit to me for this guide


    ...And the other people who made the tools
     
    Last edited by a moderator: Sep 2, 2011
  2. Guest

    well this looks interesting. though some of the sample pics do look nice, do they all use a 16 color limit or did you find a way to extend it somehow?


    edit: never mind I see that it uses 15 colors.
     
    Last edited: Sep 1, 2011
  3. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Nice guide, is it possible to do this in Sonic 2? I know it's different because it's streched or something in S2.
     
  4. Gardeguey

    Gardeguey Well-Known Member Member

    Joined:
    Aug 6, 2010
    Messages:
    82
    Location:
    México
    Yes. (and it's not streched btw)


    [​IMG]


    Do the same steps exept the last one, here's for Sonic 2:


    Find the label: "MenuScreen_LevelSelect" and add this:



    Code:
       	 lea	($FFFF0000).l,a1
    
    		lea	(Eni_LevSel).l,a0
    
    		move.w	#$2140,d0
    
    		jsr	EniDec
    
    		lea	($FFFF0000).l,a1
    
    		move.l	#$60000003,d0
    
    		moveq	#39,d1
    
    		moveq	#29,d2
    
    		jsr	ShowVDPGraphics
    
     
    
    		move.l	#$68000000,($C00004).l
    
    		lea	(Nem_LevSel).l,a0
    
    		jsr	NemDec


    Next, find:





    Code:
    	moveq	#$26,d0
    
    	bsr.w	PalLoad1


    Add this after "PalLoad1":





    Code:
    			    lea	(Pal_LevSel).l,a0
    
    				lea	(Second_palette_Line2).l,a1
    
    		move.w	#$F,d0
    
    MenuScreen_PalLoop:
    
    		move.w	(a0)+,(a1)+
    
    		dbf	d0,MenuScreen_PalLoop

    Then binclude the files, put these before the comment "; end of 'ROM' "



    Nem_LevSel: binclude "LS_BG/GFX.bin"
    even


    Eni_LevSel: binclude "LS_BG/Map.bin"


    even


    Pal_LevSel: binclude "LS_BG/Pal.bin"


    even
     
    Last edited by a moderator: Sep 2, 2011
  5. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    That's wierd, I tried this, and in ImaGenesis, when tried saving tiles, I got this:

    I downloaded the missing dll file and stuck it in the System32 folder (and the ImaGenesis folder just in case) and I still get the same error.


    Windows 7 problem maybe?


    EDIT: Got it to work, tried Windows XP mode and didn't get the error. Although this didn't work. I loaded my hack and after the SEGA screen, it just sits there at a black screen. Did I follow this right?



    Code:
    
    MenuScreen_LevelSelect:
    
    lea (Metablock_Table).l,a1
    
    lea (MapEng_LevSel).l,a0
    
    move.w #0,d0
    
    jsr EniDec ;was bsr.w
    
    lea (Metablock_Table).l,a1
    
    move.l #$40000003,d0
    
    moveq #$27,d1
    
    moveq #$1B,d2
    
    bsr.w JmpTo_ShowVDPGraphics
    
    moveq #0,d3
    
    bsr.w loc_965A
    
    lea ($FFFF08C0).l,a1
    
    lea (MapEng_LevSelIcon).l,a0
    
    move.w #$90,d0
    
    jsr EniDec ;was bsr.w
    
    bsr.w loc_9688
    
    clr.w (Player_mode).w
    
    clr.w (Results_Screen_2P).w
    
    clr.b (Level_started_flag).w
    
    clr.w ($FFFFF7F0).w
    
    lea (word_87C6).l,a2
    
    bsr.w JmpTo2_Dynamic_Normal
    
    moveq #$26,d0
    
    bsr.w PalLoad1
    
    lea (Normal_palette_line3).w,a1
    
    lea (Second_palette_line3).w,a2
    
    moveq #7,d1
    
    ;
    
    ;===========GenesisFan64's instructions==============
    
    ;
    
    	lea ($FFFF0000).l,a1
    
      lea (Eni_LevSel).l,a0
    
      move.w #$2140,d0
    
      jsr EniDec
    
      lea ($FFFF0000).l,a1
    
      move.l #$60000003,d0
    
      moveq #39,d1
    
      moveq #29,d2
    
      jsr ShowVDPGraphics
    
     
    
      move.l #$68000000,($C00004).l
    
      lea (Nem_LevSel).l,a0
    
      jsr NemDec
    
    ;
    
    ;===========GenesisFan64's instructions==============
    
    ;
    
    loc_9366:




    And:





    Code:
    
    PalLoad1:
    
    ;
    
    ;===========GenesisFan64's instructions==============
    
    ;
    
    	lea (Pal_LevSel).l,a0
    
    	lea (Second_palette_Line2).l,a1
    
      move.w #$F,d0
    
    MenuScreen_PalLoop:
    
      move.w (a0)+,(a1)+
    
      dbf d0,MenuScreen_PalLoop
    
    ;
    
    ;===========GenesisFan64's instructions==============
    
    ;
    
    lea (PalPointers).l,a1
    
    lsl.w #3,d0
    
    adda.w d0,a1
    
    movea.l (a1)+,a2
    
    movea.w (a1)+,a3
    
    adda.w #$80,a3
    
    move.w (a1)+,d7
    
    - move.l (a2)+,(a3)+
    
    dbf d7,-
    
    rts
    
    ; End of function PalLoad1


    You also said to look for


    moveq #$26,d0


    bsr.w PalLoad1


    But you didn't say what to do. Plus there are several of these in my ASM.
     
    Last edited by a moderator: Sep 1, 2011
  6. Gardeguey

    Gardeguey Well-Known Member Member

    Joined:
    Aug 6, 2010
    Messages:
    82
    Location:
    México
    This:



    Code:
    
    ; loc_92F6:
    
    MenuScreen_LevelSelect:
    
    	lea	($FFFF0000).l,a1
    
    	lea	(Eni_LevSel).l,a0
    
    	move.w	#$2140,d0
    
    	jsr	EniDec
    
    	lea	($FFFF0000).l,a1
    
    	move.l	#$60000003,d0
    
    	moveq	#39,d1
    
    	moveq	#29,d2
    
    	jsr	ShowVDPGraphics
    
     
    
    	move.l	#$68000000,($C00004).l
    
    	lea	(Nem_LevSel).l,a0
    
    	jsr	NemDec
    
     
    
    	lea	(Metablock_Table).l,a1
    
    	lea	(MapEng_LevSel).l,a0
    
    	move.w	#0,d0
    
    	bsr.w	EniDec
    
    	lea	(Metablock_Table).l,a1
    
    	move.l	#$40000003,d0
    
    	moveq	#$27,d1
    
    	moveq	#$1B,d2
    
    	bsr.w	JmpTo_ShowVDPGraphics
    
     
    
    	moveq	#0,d3
    
    	bsr.w	loc_965A
    
    	lea	($FFFF08C0).l,a1
    
    	lea	(MapEng_LevSelIcon).l,a0
    
    	move.w	#$90,d0
    
    	bsr.w	EniDec
    
    	bsr.w	loc_9688
    
    	clr.w	(Player_mode).w
    
    	clr.w	(Results_Screen_2P).w
    
    	clr.b	(Level_started_flag).w
    
    	clr.w	($FFFFF7F0).w
    
    	lea	(word_87C6).l,a2
    
    	bsr.w	JmpTo2_Dynamic_Normal
    
    	moveq	#$26,d0
    
    	bsr.w	PalLoad1
    
     
    
    	lea	(Pal_LevSel).l,a0
    
    	lea	(Second_palette_Line2).l,a1
    
    	move.w	#$F,d0
    
    MenuScreen_PalLoop:
    
    	move.w	(a0)+,(a1)+
    
    	dbf	d0,MenuScreen_PalLoop
    
      
    
    	;...

    (also, lol for the "code" tag, i was using "ASM")
     
    Last edited by a moderator: Sep 2, 2011
  7. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Nope, still getting the exact same thing. After the SEGA screen, it goes blank and stays that way.


    I'll have another look tomorrow, I'm off to bed =P


    EDIT: Got it done. The problem was when saving the data in imagens, I had it in BASIC, and not Binary. When you said:

    I literally did, I never thought to change the format bit! You might want to add that bit in =P


    Anyway, thanks for the guide!
     
    Last edited by a moderator: Sep 13, 2011
  8. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Sorry about the bump but would this be possible for the Sonic 2 level select in Sonic 1? I tried but was not to sure about what I was doing.
     
    Last edited by a moderator: Jan 1, 2012
  9. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    It's possible because Psy has done it. But this is for more like adding background to the level select, not porting level selects to a different game.
     
  10. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    I mean putting the background in for this. Would it be similar to the above posts?
     
    Last edited by a moderator: Jan 1, 2012
  11. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Well, Psy followed this guide to put a background in his level select. His level select is Sonic 2 in Sonic 1. IIRC, he just followed the Sonic 2 steps.
     
  12. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Oh now ImaGenesis is playing up the same way yours did. And I tried all the stuff that you tried with no luck.
     
    Last edited by a moderator: Jan 2, 2012
  13. Regeneration

    Regeneration Newcomer Trialist

    Joined:
    Dec 6, 2011
    Messages:
    3
    Location:
    Under your bed ;)
    I would like to thank you for this tutorial. It worked perfectly


    [​IMG]
     
  14. DanielHall

    DanielHall Well-Known Member Member

    Joined:
    Jan 18, 2010
    Messages:
    860
    Location:
    North Wales
    It'd be pretty awesome if the forums had a 'post without bumping' feature.
     
  15. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    I'm curious about this too. I'm using the code of Esrael's... and there's nothing in there that seems to match the code in this tutorial.
     
  16. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
    Esrael used a very old disassembly to port this. It may be worthwhile for somebody to port the screen code from at least the 2007 Sonic 2 disassembly to try and keep some sort of consistency. However, that challenge alone is up to someone to do it if they want to.
     
  17. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    Damn... That puts me out of luck. I haven't had any experience with the S2 disasms.
     
  18. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    I can port a bg for you if you want.
     
  19. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    I think he needs the code to use this guide with the Sonic 2 level select in Sonic 1 like I do.
     
    Last edited by a moderator: Jan 21, 2012
  20. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    That's right. I already have the tiles, maps and palettes... I just need the code.
     
    Last edited by a moderator: Jan 22, 2012
Thread Status:
Not open for further replies.