Difference between revisions of "Sonic Jam 6/ROM Editing"
From Sonic Retro
m (rm useless heading) |
m (Text replacement - "__NOTOC__ {{SCHG (.*)}} ==" to "{{SCHG $1}} ==") |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{SCHG SJ6}} | ||
==Values== | ==Values== | ||
− | {|class="prettytable" | + | {| class="prettytable" style="width:auto;" |
!Offset||Description||Note | !Offset||Description||Note | ||
|- | |- | ||
Line 11: | Line 12: | ||
| | | | ||
*0 (w), Level map number | *0 (w), Level map number | ||
− | *2 (w), | + | *2 (w), Level scroll page to start from (but the next scroll page won't be the next to this!) |
*4 (w), ??? | *4 (w), ??? | ||
*6 (w), ??? | *6 (w), ??? | ||
− | *8 (w), | + | *8 (w), Player start X position + 128 |
− | *A (w), | + | *A (w), Player start Y position + 128 |
*C (w), ??? | *C (w), ??? | ||
|- | |- | ||
Line 28: | Line 29: | ||
==Functions== | ==Functions== | ||
− | ==Title Screen | + | ===Title Screen functions=== |
− | ==Button check== | + | ====Button check==== |
− | {|class="prettytable" | + | {| class="prettytable" style="width:auto;" |
!Offset||Description | !Offset||Description | ||
|- | |- | ||
Line 63: | Line 64: | ||
|ROM:00000B48 | |ROM:00000B48 | ||
|bra.w locret_B6A ; No button pressed, branch to this other one. | |bra.w locret_B6A ; No button pressed, branch to this other one. | ||
+ | |} | ||
+ | |||
+ | ===Level functions=== | ||
+ | |||
+ | ====Bonus Level==== | ||
+ | {| class="prettytable" style="width:auto;" | ||
+ | !Offset||Instruction||Comment | ||
+ | |- | ||
+ | |ROM:0000780A | ||
+ | |move.w d3,d0 | ||
+ | |- | ||
+ | |ROM:0000780C | ||
+ | |mulu.w #$20,d0 | ||
+ | |- | ||
+ | |ROM:00007810 | ||
+ | |cmpi.w #0,4(a6,d0.w) | ||
+ | |- | ||
+ | |ROM:00007816 | ||
+ | |bne.w loc_792A | ||
+ | |- | ||
+ | |ROM:0000781A | ||
+ | |cmpi.w #2,(word_FF0042).l | ||
+ | |Compare 2 with current level map number | ||
+ | |- | ||
+ | |ROM:00007822 | ||
+ | |beq.w loc_7836 | ||
+ | |If level map number is 2, branch | ||
+ | |- | ||
+ | |ROM:00007826 | ||
+ | |cmpi.w #5,(word_FF0042).l | ||
+ | |Compare 5 with current level map number | ||
+ | |- | ||
+ | |ROM:0000782E | ||
+ | |beq.w loc_7836 | ||
+ | |If level map number is 5, branch | ||
+ | |- | ||
+ | |ROM:00007832 | ||
+ | |bra.w loc_7842 | ||
+ | |} | ||
+ | |||
+ | As you can clearly see, level map number 2 and 5 are respectively the Level 1-1 bonus, and the Level 1-2 bonus. | ||
+ | This makes the level not restart after exiting out of this level and returning to the main one, making it appear as a single level. | ||
+ | Adding another level to the list should be as simple as adding a cmp instruction and branching accordingly. | ||
+ | |||
+ | ===Sound Driver functions=== | ||
+ | |||
+ | The first two routines described below are easy to use subroutines which can be used respectively | ||
+ | to play a background music or a sound effect. They handle calling the sound driver for you. | ||
+ | |||
+ | The BGM one is used by loading a word containing a music number from 0x0000 to 0x00FF into | ||
+ | the address $ff6c00, and by jumping to it with a jump or branch to subroutine. | ||
+ | |||
+ | The SFX one works the same as the BGM one, but a sfx number is loaded into address $ff6c02. | ||
+ | |||
+ | The first line of the functions is their starting address. | ||
+ | |||
+ | ====Play BGM==== | ||
+ | {| class="prettytable" style="width:auto;" | ||
+ | !Offset||Instruction||Comment | ||
+ | |- | ||
+ | |ROM:000EE76C | ||
+ | |move.w d0,-(sp) | ||
+ | |Save d0 onto stack | ||
+ | |- | ||
+ | |ROM:000EE76E | ||
+ | |move.w #0,d0 | ||
+ | |Move 0 into d0 | ||
+ | |- | ||
+ | |ROM:000EE772 | ||
+ | |move.b (word_FF6C00+1).l,d0 | ||
+ | |Move lower byte of word at ff6c00 into lower byte of d0 | ||
+ | |- | ||
+ | |ROM:000EE778 | ||
+ | |move.w d0,(word_FF6D00).l | ||
+ | |Move d0 into address $ff6d00 | ||
+ | |- | ||
+ | |ROM:000EE77E | ||
+ | |jsr sound_driver_play | ||
+ | |Go to sub_F004C subroutine | ||
+ | |- | ||
+ | |ROM:000EE784 | ||
+ | |move.w (sp)+,d0 | ||
+ | |Load d0 from stack | ||
+ | |- | ||
+ | |ROM:000EE786 | ||
+ | |rts | ||
+ | |Return (from this Subroutine) | ||
+ | |} | ||
+ | |||
+ | ====Play SFX==== | ||
+ | {| class="prettytable" style="width:auto;" | ||
+ | !Offset||Instruction||Comment | ||
+ | |- | ||
+ | |ROM:000EE788 | ||
+ | |move.w d0,-(sp) | ||
+ | |Save d0 onto stack | ||
+ | |- | ||
+ | |ROM:000EE78A | ||
+ | |move.w #$8000,d0 | ||
+ | |Move $8000 into d0 | ||
+ | |- | ||
+ | |ROM:000EE78E | ||
+ | |move.b (word_FF6C02+1).l,d0 | ||
+ | |Move lower byte of word at $ff6c02 into lower byte of d0 | ||
+ | |- | ||
+ | |ROM:000EE794 | ||
+ | |move.w d0,(word_FF6D00).l | ||
+ | |Move d0 into word at address $ff6d00 (sound driver related) | ||
+ | |- | ||
+ | |ROM:000EE79A | ||
+ | |jsr sound_driver_play | ||
+ | |Jump to (sound driver play?) subroutine | ||
+ | |- | ||
+ | |ROM:000EE7A0 | ||
+ | |move.w (sp)+,d0 | ||
+ | |Load d0 from stack | ||
+ | |- | ||
+ | |ROM:000EE7A2 | ||
+ | |rts | ||
+ | |Return (from this Subroutine) | ||
|} | |} |
Latest revision as of 04:37, 25 March 2020
SCHG: Sonic Jam 6 |
---|
Main Article |
ROM Editing |
Editing ROM |
RAM Editing |
Editing RAM |
Art Editing |
Editing Art |
Value Reference |
Value Reference |
Contents
Values
Offset | Description | Note |
---|---|---|
0x1430 | Array which contains music numbers for each map (WORD ARRAY). | |
0x0ad2 | Demo properties (structure array, 0xe bytes long). |
|
0x0dde | Level map world-level number (structure array, 0x4 bytes long). |
|
Functions
Title Screen functions
Button check
Level functions
Bonus Level
Offset | Instruction | Comment |
---|---|---|
ROM:0000780A | move.w d3,d0 | |
ROM:0000780C | mulu.w #$20,d0 | |
ROM:00007810 | cmpi.w #0,4(a6,d0.w) | |
ROM:00007816 | bne.w loc_792A | |
ROM:0000781A | cmpi.w #2,(word_FF0042).l | Compare 2 with current level map number |
ROM:00007822 | beq.w loc_7836 | If level map number is 2, branch |
ROM:00007826 | cmpi.w #5,(word_FF0042).l | Compare 5 with current level map number |
ROM:0000782E | beq.w loc_7836 | If level map number is 5, branch |
ROM:00007832 | bra.w loc_7842 |
As you can clearly see, level map number 2 and 5 are respectively the Level 1-1 bonus, and the Level 1-2 bonus. This makes the level not restart after exiting out of this level and returning to the main one, making it appear as a single level. Adding another level to the list should be as simple as adding a cmp instruction and branching accordingly.
Sound Driver functions
The first two routines described below are easy to use subroutines which can be used respectively to play a background music or a sound effect. They handle calling the sound driver for you.
The BGM one is used by loading a word containing a music number from 0x0000 to 0x00FF into the address $ff6c00, and by jumping to it with a jump or branch to subroutine.
The SFX one works the same as the BGM one, but a sfx number is loaded into address $ff6c02.
The first line of the functions is their starting address.
Play BGM
Offset | Instruction | Comment |
---|---|---|
ROM:000EE76C | move.w d0,-(sp) | Save d0 onto stack |
ROM:000EE76E | move.w #0,d0 | Move 0 into d0 |
ROM:000EE772 | move.b (word_FF6C00+1).l,d0 | Move lower byte of word at ff6c00 into lower byte of d0 |
ROM:000EE778 | move.w d0,(word_FF6D00).l | Move d0 into address $ff6d00 |
ROM:000EE77E | jsr sound_driver_play | Go to sub_F004C subroutine |
ROM:000EE784 | move.w (sp)+,d0 | Load d0 from stack |
ROM:000EE786 | rts | Return (from this Subroutine) |
Play SFX
Offset | Instruction | Comment |
---|---|---|
ROM:000EE788 | move.w d0,-(sp) | Save d0 onto stack |
ROM:000EE78A | move.w #$8000,d0 | Move $8000 into d0 |
ROM:000EE78E | move.b (word_FF6C02+1).l,d0 | Move lower byte of word at $ff6c02 into lower byte of d0 |
ROM:000EE794 | move.w d0,(word_FF6D00).l | Move d0 into word at address $ff6d00 (sound driver related) |
ROM:000EE79A | jsr sound_driver_play | Jump to (sound driver play?) subroutine |
ROM:000EE7A0 | move.w (sp)+,d0 | Load d0 from stack |
ROM:000EE7A2 | rts | Return (from this Subroutine) |