Website
Home
Database
News
Submissions queue
Community
Forum
Clubs
Discord
Members
Tools
ROM Patcher
ROM Hasher
Pages
Support us
Learn Romhacking
About
Contact Us
Help & Legal Pages
Guest
Login
Forum
Entries
News
Settings
Community
Tutorials & Guides
[Tutorial] How to create a Simple Scrolling HUD in Sonic 1
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Mildanner" data-source="post: 6520" data-attributes="member: 7577"><p><strong><em>Original Guide by <span style="color: rgb(44, 130, 201)">Mildanner</span> (ft. <span style="color: rgb(29, 19, 232)">RetroKoH</span>)</em></strong></p><p></p><p>In game development, the developers didn't know how to make a simple scrolling HUD and decided to make the HUD pop in the screen without any doubts. In this guide, you will learn how to make a simple scrolling HUD.</p><h3>Hivebrain 2005 (ASM68K)</h3><p>In the Hivebrain 2005, the object for HUD was still in sonic1.asm file. You should find the Obj21_Main label and replace this entire routine with this:</p><p>[CODE]Obj21_Main: ; XREF: Obj21_Main</p><p> addq.b #4,$24(a0) ; Advance to Routine 4 (Obj21_Move) on the next frame</p><p> move.w #0,8(a0) ; Start offscreen (X = 0)</p><p> move.w #$108,$a(a0) ; Set Y coordinate (obScreenY)</p><p> move.l #Map_obj21,4(a0); Set mappings pointer (obMap)</p><p> move.w #$6ca,2(a0) ; Set VRAM art tile (obGfx)</p><p> move.b #0,1(a0) ; Set render settings (obRender)</p><p> move.b #0,$18(a0) ; Set display priority (obPriority)</p><p> rts</p><p></p><p>; ===========================================================================</p><p></p><p>Obj21_Move: ; Routine 4</p><p> move.w 8(a0),d0 ; Load current X position</p><p> cmpi.w #$90,d0 ; Has it reached position $90?</p><p> bge.s @reached ; If greater or equal, finalize movement</p><p></p><p> addq.w #5,d0 ; Move 5 pixels to the right</p><p> move.w d0,8(a0) ; Update X coordinate directly</p><p> jmp DisplaySprite</p><p></p><p>@reached:</p><p> move.b #2,$24(a0) ; Set routine status to Routine 2</p><p> jmp DisplaySprite[/CODE]</p><p>If the code doesn't work, you should go above Obj21_Index and after the line. Insert this (After the Obj21_Move label)</p><p>[CODE] dc.w Obj21_Move-Obj21_Index[/CODE]</p><p>Done! Now your hack has a fellow HUD scrolling.</p><h3><span style="color: rgb(209, 209, 209)"><span style="font-size: 26px"><strong>(OPTIONAL) Adding sound effect if HUD is in the position</strong></span></span></h3><p>Hivebrain 2005 has no macros, so you should modify it simply and paste this in the label you pasted below @reached</p><p>[CODE] move.b #$C5,d0 ; set sound to cash</p><p> jsr (PlaySound_Special).l ; play it[/CODE]</p><p>Okay, now it will play a sound once the HUD scrolling is completed.</p><h3>Hivebrain 2022</h3><p>Also, Hivebrain 2022 is a upgraded version of Hivebrain 2005 but better version and more documented by following the current version of Sonic 1 disassembly from Sonic Retro.</p><p></p><p>In your disassembly, go to the <strong>Objects/HUD.asm</strong> and find the label <strong>HUD_Main:</strong></p><p></p><p>Replace the entire routine with this</p><p>[CODE]HUD_Main: ; Routine 0</p><p> addq.b #4,ost_routine(a0) ; Advance to Routine 4 (HUD_Move)</p><p> move.w #screen_left-80,ost_x_pos(a0) ; Start HUD far off-screen to the left</p><p> move.w #screen_top+136,ost_y_screen(a0) ; Set Y position coordinate</p><p> move.l #Map_HUD,ost_mappings(a0) ; Set mappings pointer</p><p> move.w #tile_Nem_Hud,ost_tile(a0) ; Set art tile pattern index</p><p> move.b #render_abs,ost_render(a0) ; Use absolute rendering screen space</p><p> move.b #0,ost_priority(a0) ; Set sprite layout priority</p><p> rts</p><p></p><p>HUD_Move: ; Routine 4</p><p> move.w ost_x_pos(a0),d0 ; Get current HUD X position</p><p> cmpi.w #screen_left+16,d0 ; Has it reached the classic target position ($10)?</p><p> bge.s .reached ; If yes, branch to lock movement</p><p></p><p> addq.w #5,d0 ; Shift 5 pixels to the right</p><p> move.w d0,ost_x_pos(a0) ; Update object X position</p><p> jmp (DisplaySprite).l</p><p></p><p>.reached:</p><p> move.b #2,ost_routine(a0) ; Set to static state routine (Routine 2 / HUD_Flash)</p><p> jmp (DisplaySprite).l[/CODE]</p><p>If there's a issue and it is not working, you should go below the pointer of <strong>HUD_Flash</strong> and insert this below the line.</p><p>[CODE] ptr HUD_Move[/CODE]</p><p>Done! Now your fellow HUD scrolling is now functional, enjoy your new HUD scrolling.</p><p><span style="color: rgb(209, 209, 209)"><span style="font-size: 26px"><strong>(OPTIONAL) Adding sound effect if HUD is in the position</strong></span></span></p><p><span style="color: rgb(209, 209, 209)">So, if you want a sound effect that simply plays when the HUD is moved at the correct position, just go to the ".reached" label and add this below the label:</span></p><p><span style="color: rgb(209, 209, 209)">[CODE] play.w 1, jsr, sfx_Register ; play "ker-ching" sound[/CODE]</span></p><p><span style="color: rgb(209, 209, 209)">Done! Now your HUD has a sound every time it finishes scrolling, happy hacking! <img class="smilie smilie--emoji" alt="😃" src="https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/1f603.png" title="Grinning face with big eyes :smiley:" data-shortname=":smiley:" loading="lazy" width="72" height="72" /></span></p><h3>GitHub version</h3><p><span style="color: rgb(209, 209, 209)">For getting started, you want to go in the _incObj/21 HUD.asm and go at the routine HUD_Main and replace it entirely with this new routine:</span></p><p><span style="color: rgb(209, 209, 209)">[CODE]HUD_Main: ; Routine 0</span></p><p><span style="color: rgb(209, 209, 209)"> addq.b #4,obRoutine(a0) ; Advances to Routine 4 (HUD_Move) on the next frame</span></p><p><span style="color: rgb(209, 209, 209)"> move.w #0,obX(a0) ; Starts the HUD offscreen (X = 0)</span></p><p><span style="color: rgb(209, 209, 209)"> move.w #$108,obScreenY(a0)</span></p><p><span style="color: rgb(209, 209, 209)"> move.l #Map_HUD,obMap(a0)</span></p><p><span style="color: rgb(209, 209, 209)"> move.w #ArtTile_HUD,obGfx(a0)</span></p><p><span style="color: rgb(209, 209, 209)"> move.b #0,obRender(a0)</span></p><p><span style="color: rgb(209, 209, 209)"> move.b #0,obPriority(a0)</span></p><p><span style="color: rgb(209, 209, 209)"> rts</span></p><p><span style="color: rgb(209, 209, 209)"></span></p><p><span style="color: rgb(209, 209, 209)">HUD_Move: ; Routine 4</span></p><p><span style="color: rgb(209, 209, 209)"> move.w obX(a0),d0 ; Loads the current HUD X position</span></p><p><span style="color: rgb(209, 209, 209)"> cmpi.w #$90,d0 ; Has it reached position $90?</span></p><p><span style="color: rgb(209, 209, 209)"> bge.s .reached ; If greater or equal, finalize the movement</span></p><p> <span style="color: rgb(209, 209, 209)"></span></p><p><span style="color: rgb(209, 209, 209)"> addq.w #5,d0 ; Move 5 pixels to the right</span></p><p><span style="color: rgb(209, 209, 209)"> move.w d0,obX(a0) ; Update the object's X coordinate directly</span></p><p><span style="color: rgb(209, 209, 209)"> jmp DisplaySprite</span></p><p><span style="color: rgb(209, 209, 209)"></span></p><p><span style="color: rgb(209, 209, 209)">.reached:</span></p><p><span style="color: rgb(209, 209, 209)"> move.b #2,obRoutine(a0)</span></p><p><span style="color: rgb(209, 209, 209)"> jmp DisplaySprite</span></p><p><span style="color: rgb(209, 209, 209)">[/CODE]</span></p><p><span style="color: rgb(209, 209, 209)"><strong>Optional:</strong> You can change the scrolling speed to what you want, just simply replace the 5 with the number you think it's better.</span></p><p><span style="color: rgb(209, 209, 209)"></span></p><p><span style="color: rgb(209, 209, 209)">If the code mentioned in particular doesn't work, you did some mistake! Just go ahead in <strong>HUD_Index:</strong> label and insert this line below the HUD_Flash-HUD_Index</span></p><p><span style="color: rgb(209, 209, 209)">[CODE] dc.w HUD_Move-HUD_Index[/CODE]</span></p><p><span style="color: rgb(209, 209, 209)">Did you like it? Now your hack's HUD is scrolling like how it would be.</span></p><p><span style="color: rgb(209, 209, 209)"><span style="font-size: 26px"><strong>(OPTIONAL) Adding sound effect if HUD is in the position</strong></span></span></p><p><span style="color: rgb(209, 209, 209)">So, if you want a sound effect that simply plays when the HUD is moved at the correct position, just go to the ".reached" label and add this below the label:</span></p><p><span style="color: rgb(209, 209, 209)">[CODE] move.b #sfx_Cash,d0 ; set cash sound to be played</span></p><p><span style="color: rgb(209, 209, 209)"> jsr QueueSound2 ; play it[/CODE]</span></p><p><span style="color: rgb(209, 209, 209)">I hope you enjoyed this tutorial, now your hack has a HUD scrolling once the game starts.</span></p></blockquote><p></p>
[QUOTE="Mildanner, post: 6520, member: 7577"] [B][I]Original Guide by [COLOR=rgb(44, 130, 201)]Mildanner[/COLOR] (ft. [COLOR=rgb(29, 19, 232)]RetroKoH[/COLOR])[/I][/B] In game development, the developers didn't know how to make a simple scrolling HUD and decided to make the HUD pop in the screen without any doubts. In this guide, you will learn how to make a simple scrolling HUD. [HEADING=2]Hivebrain 2005 (ASM68K)[/HEADING] In the Hivebrain 2005, the object for HUD was still in sonic1.asm file. You should find the Obj21_Main label and replace this entire routine with this: [CODE]Obj21_Main: ; XREF: Obj21_Main addq.b #4,$24(a0) ; Advance to Routine 4 (Obj21_Move) on the next frame move.w #0,8(a0) ; Start offscreen (X = 0) move.w #$108,$a(a0) ; Set Y coordinate (obScreenY) move.l #Map_obj21,4(a0); Set mappings pointer (obMap) move.w #$6ca,2(a0) ; Set VRAM art tile (obGfx) move.b #0,1(a0) ; Set render settings (obRender) move.b #0,$18(a0) ; Set display priority (obPriority) rts ; =========================================================================== Obj21_Move: ; Routine 4 move.w 8(a0),d0 ; Load current X position cmpi.w #$90,d0 ; Has it reached position $90? bge.s @reached ; If greater or equal, finalize movement addq.w #5,d0 ; Move 5 pixels to the right move.w d0,8(a0) ; Update X coordinate directly jmp DisplaySprite @reached: move.b #2,$24(a0) ; Set routine status to Routine 2 jmp DisplaySprite[/CODE] If the code doesn't work, you should go above Obj21_Index and after the line. Insert this (After the Obj21_Move label) [CODE] dc.w Obj21_Move-Obj21_Index[/CODE] Done! Now your hack has a fellow HUD scrolling. [HEADING=2][COLOR=rgb(209, 209, 209)][SIZE=7][B](OPTIONAL) Adding sound effect if HUD is in the position[/B][/SIZE][/COLOR][/HEADING] Hivebrain 2005 has no macros, so you should modify it simply and paste this in the label you pasted below @reached [CODE] move.b #$C5,d0 ; set sound to cash jsr (PlaySound_Special).l ; play it[/CODE] Okay, now it will play a sound once the HUD scrolling is completed. [HEADING=2]Hivebrain 2022[/HEADING] Also, Hivebrain 2022 is a upgraded version of Hivebrain 2005 but better version and more documented by following the current version of Sonic 1 disassembly from Sonic Retro. In your disassembly, go to the [B]Objects/HUD.asm[/B] and find the label [B]HUD_Main:[/B] Replace the entire routine with this [CODE]HUD_Main: ; Routine 0 addq.b #4,ost_routine(a0) ; Advance to Routine 4 (HUD_Move) move.w #screen_left-80,ost_x_pos(a0) ; Start HUD far off-screen to the left move.w #screen_top+136,ost_y_screen(a0) ; Set Y position coordinate move.l #Map_HUD,ost_mappings(a0) ; Set mappings pointer move.w #tile_Nem_Hud,ost_tile(a0) ; Set art tile pattern index move.b #render_abs,ost_render(a0) ; Use absolute rendering screen space move.b #0,ost_priority(a0) ; Set sprite layout priority rts HUD_Move: ; Routine 4 move.w ost_x_pos(a0),d0 ; Get current HUD X position cmpi.w #screen_left+16,d0 ; Has it reached the classic target position ($10)? bge.s .reached ; If yes, branch to lock movement addq.w #5,d0 ; Shift 5 pixels to the right move.w d0,ost_x_pos(a0) ; Update object X position jmp (DisplaySprite).l .reached: move.b #2,ost_routine(a0) ; Set to static state routine (Routine 2 / HUD_Flash) jmp (DisplaySprite).l[/CODE] If there's a issue and it is not working, you should go below the pointer of [B]HUD_Flash[/B] and insert this below the line. [CODE] ptr HUD_Move[/CODE] Done! Now your fellow HUD scrolling is now functional, enjoy your new HUD scrolling. [COLOR=rgb(209, 209, 209)][SIZE=7][B](OPTIONAL) Adding sound effect if HUD is in the position[/B][/SIZE] So, if you want a sound effect that simply plays when the HUD is moved at the correct position, just go to the ".reached" label and add this below the label: [CODE] play.w 1, jsr, sfx_Register ; play "ker-ching" sound[/CODE] Done! Now your HUD has a sound every time it finishes scrolling, happy hacking! 😃[/COLOR] [HEADING=2]GitHub version[/HEADING] [COLOR=rgb(209, 209, 209)]For getting started, you want to go in the _incObj/21 HUD.asm and go at the routine HUD_Main and replace it entirely with this new routine: [CODE]HUD_Main: ; Routine 0 addq.b #4,obRoutine(a0) ; Advances to Routine 4 (HUD_Move) on the next frame move.w #0,obX(a0) ; Starts the HUD offscreen (X = 0) move.w #$108,obScreenY(a0) move.l #Map_HUD,obMap(a0) move.w #ArtTile_HUD,obGfx(a0) move.b #0,obRender(a0) move.b #0,obPriority(a0) rts HUD_Move: ; Routine 4 move.w obX(a0),d0 ; Loads the current HUD X position cmpi.w #$90,d0 ; Has it reached position $90? bge.s .reached ; If greater or equal, finalize the movement addq.w #5,d0 ; Move 5 pixels to the right move.w d0,obX(a0) ; Update the object's X coordinate directly jmp DisplaySprite .reached: move.b #2,obRoutine(a0) jmp DisplaySprite [/CODE] [B]Optional:[/B] You can change the scrolling speed to what you want, just simply replace the 5 with the number you think it's better. If the code mentioned in particular doesn't work, you did some mistake! Just go ahead in [B]HUD_Index:[/B] label and insert this line below the HUD_Flash-HUD_Index [CODE] dc.w HUD_Move-HUD_Index[/CODE] Did you like it? Now your hack's HUD is scrolling like how it would be. [SIZE=7][B](OPTIONAL) Adding sound effect if HUD is in the position[/B][/SIZE] So, if you want a sound effect that simply plays when the HUD is moved at the correct position, just go to the ".reached" label and add this below the label: [CODE] move.b #sfx_Cash,d0 ; set cash sound to be played jsr QueueSound2 ; play it[/CODE] I hope you enjoyed this tutorial, now your hack has a HUD scrolling once the game starts.[/COLOR] [/QUOTE]
Insert quotes…
Verification
Post reply
Community
Tutorials & Guides
[Tutorial] How to create a Simple Scrolling HUD in Sonic 1
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Back
Top