Actions

SCHG How-to Talk

Difference between revisions of "Guide"

From Sonic Retro

Line 59: Line 59:
  
 
:Dynamic music? What's that? Different music on every act? That would certainly be a good guide to make, since the Sonic 1 guide on it is a cheap hack. Good for teaching a noob when to use <i>cmp</i>, but not good at teaching anyone the real way to achieve act-specific music. Such a thing would be a standalone guide, as you can apply it to hacks using either of the S1/S2/S3K drivers. [[User:Clownacy|Clownacy]] 13:06, 25 May 2014 (UTC)
 
:Dynamic music? What's that? Different music on every act? That would certainly be a good guide to make, since the Sonic 1 guide on it is a cheap hack. Good for teaching a noob when to use <i>cmp</i>, but not good at teaching anyone the real way to achieve act-specific music. Such a thing would be a standalone guide, as you can apply it to hacks using either of the S1/S2/S3K drivers. [[User:Clownacy|Clownacy]] 13:06, 25 May 2014 (UTC)
 +
 +
::Yeah, that's what I mean, and what I meant by "the real way" was "not my way" (which doesn't even work yet, and is probably sort of hackish.). Also, I think that it may be a tad bit more complicated with Sonic 2, because it also has a check for multiplayer mode, and I don't understand how Metropolis 3 simply loads the entry after the one for the first act. So, I'd like to post this area of code (where I'm trying to get the code to work) from a fresh Sonic 2 disasm and from my disasm. (The Clone Driver is installed in mine, btw. Also, these references are for the GitHub disasm.)
 +
 +
::The vanilla code from MusicList to the end of Level_PlayBgm:
 +
 +
<asm>;----------------------------------------------------------------------------
 +
; 1P Music Playlist
 +
;----------------------------------------------------------------------------
 +
; byte_3EA0:
 +
MusicList: zoneOrderedTable 1,1
 +
zoneTableEntry.b MusID_EHZ ; 0 ; EHZ
 +
zoneTableEntry.b MusID_EHZ ; 1
 +
zoneTableEntry.b MusID_MTZ ; 2
 +
zoneTableEntry.b MusID_OOZ ; 3
 +
zoneTableEntry.b MusID_MTZ ; 4 ; MTZ1,2
 +
zoneTableEntry.b MusID_MTZ ; 5 ; MTZ3
 +
zoneTableEntry.b MusID_WFZ ; 6 ; WFZ
 +
zoneTableEntry.b MusID_HTZ ; 7 ; HTZ
 +
zoneTableEntry.b MusID_HPZ ; 8
 +
zoneTableEntry.b MusID_SCZ ; 9
 +
zoneTableEntry.b MusID_OOZ ; 10 ; OOZ
 +
zoneTableEntry.b MusID_MCZ ; 11 ; MCZ
 +
zoneTableEntry.b MusID_CNZ ; 12 ; CNZ
 +
zoneTableEntry.b MusID_CPZ ; 13 ; CPZ
 +
zoneTableEntry.b MusID_DEZ ; 14 ; DEZ
 +
zoneTableEntry.b MusID_ARZ ; 15 ; ARZ
 +
zoneTableEntry.b MusID_SCZ ; 16 ; SCZ
 +
    zoneTableEnd
 +
even
 +
;----------------------------------------------------------------------------
 +
; 2P Music Playlist
 +
;----------------------------------------------------------------------------
 +
; byte_3EB2:
 +
MusicList2: zoneOrderedTable 1,1
 +
zoneTableEntry.b MusID_EHZ_2P ; 0  ; EHZ 2P
 +
zoneTableEntry.b MusID_EHZ ; 1
 +
zoneTableEntry.b MusID_MTZ ; 2
 +
zoneTableEntry.b MusID_OOZ ; 3
 +
zoneTableEntry.b MusID_MTZ ; 4
 +
zoneTableEntry.b MusID_MTZ ; 5
 +
zoneTableEntry.b MusID_WFZ ; 6
 +
zoneTableEntry.b MusID_HTZ ; 7
 +
zoneTableEntry.b MusID_HPZ ; 8
 +
zoneTableEntry.b MusID_SCZ ; 9
 +
zoneTableEntry.b MusID_OOZ ; 10
 +
zoneTableEntry.b MusID_MCZ_2P ; 11 ; MCZ 2P
 +
zoneTableEntry.b MusID_CNZ_2P ; 12 ; CNZ 2P
 +
zoneTableEntry.b MusID_CPZ ; 13
 +
zoneTableEntry.b MusID_DEZ ; 14
 +
zoneTableEntry.b MusID_ARZ ; 15
 +
zoneTableEntry.b MusID_SCZ ; 16
 +
    zoneTableEnd
 +
even
 +
; ===========================================================================
 +
 +
; ---------------------------------------------------------------------------
 +
; Level
 +
; DEMO AND ZONE LOOP (MLS values $08, $0C; bit 7 set indicates that load routine is running)
 +
; ---------------------------------------------------------------------------
 +
; loc_3EC4:
 +
Level:
 +
bset #GameModeFlag_TitleCard,(Game_Mode).w ; add $80 to screen mode (for pre level sequence)
 +
tst.w (Demo_mode_flag).w ; test the old flag for the credits demos (now unused)
 +
bmi.s +
 +
move.b #MusID_FadeOut,d0
 +
bsr.w PlaySound ; fade out music
 +
+
 +
bsr.w ClearPLC
 +
bsr.w Pal_FadeFrom
 +
tst.w (Demo_mode_flag).w
 +
bmi.s Level_ClrRam
 +
move #$2700,sr
 +
bsr.w ClearScreen
 +
jsr (LoadTitleCard).l ; load title card patterns
 +
move #$2300,sr
 +
moveq #0,d0
 +
move.w d0,(Timer_frames).w
 +
move.b (Current_Zone).w,d0
 +
 +
; multiply d0 by 12, the size of a level art load block
 +
add.w d0,d0
 +
add.w d0,d0
 +
move.w d0,d1
 +
add.w d0,d0
 +
add.w d1,d0
 +
 +
lea (LevelArtPointers).l,a2
 +
lea (a2,d0.w),a2
 +
moveq #0,d0
 +
move.b (a2),d0 ; PLC1 ID
 +
beq.s +
 +
bsr.w LoadPLC
 +
+
 +
moveq #PLCID_Std2,d0
 +
bsr.w LoadPLC
 +
bsr.w Level_SetPlayerMode
 +
moveq #PLCID_Miles1up,d0
 +
tst.w (Two_player_mode).w
 +
bne.s +
 +
cmpi.w #2,(Player_mode).w
 +
bne.s Level_ClrRam
 +
addq.w #PLCID_MilesLife-PLCID_Miles1up,d0
 +
+
 +
tst.b (Graphics_Flags).w
 +
bpl.s +
 +
addq.w #PLCID_Tails1up-PLCID_Miles1up,d0
 +
+
 +
bsr.w LoadPLC
 +
; loc_3F48:
 +
Level_ClrRam:
 +
clearRAM Sprite_Table_Input,$400
 +
clearRAM Object_RAM,(LevelOnly_Object_RAM_End-Object_RAM) ; clear object RAM
 +
clearRAM MiscLevelVariables,(MiscLevelVariables_End-MiscLevelVariables)
 +
clearRAM Misc_Variables,(Misc_Variables_End-Misc_Variables)
 +
clearRAM Oscillating_Data,(Oscillating_variables_End-Oscillating_variables)
 +
clearRAM CNZ_saucer_data,$100
 +
 +
cmpi.w #chemical_plant_zone_act_2,(Current_ZoneAndAct).w ; CPZ 2
 +
beq.s Level_InitWater
 +
cmpi.b #aquatic_ruin_zone,(Current_Zone).w ; ARZ
 +
beq.s Level_InitWater
 +
cmpi.b #hidden_palace_zone,(Current_Zone).w ; HPZ
 +
bne.s +
 +
 +
Level_InitWater:
 +
move.b #1,(Water_flag).w
 +
move.w #0,(Two_player_mode).w
 +
+
 +
lea (VDP_control_port).l,a6
 +
move.w #$8B03,(a6) ; EXT-INT disabled, V scroll by screen, H scroll by line
 +
move.w #$8230,(a6) ; PNT A base: $C000
 +
move.w #$8407,(a6) ; PNT B base: $E000
 +
move.w #$857C,(a6) ; Sprite attribute table base: $F800
 +
move.w #$9001,(a6) ; Scroll table size: 64x32
 +
move.w #$8004,(a6) ; H-INT disabled
 +
move.w #$8720,(a6) ; Background palette/color: 2/0
 +
move.w #$8C81,(a6) ; H res 40 cells, no interlace
 +
tst.b (Night_mode_flag).w
 +
beq.s ++
 +
btst #button_C,(Ctrl_1_Held).w
 +
beq.s +
 +
move.w #$8C89,(a6) ; H res 40 cells, no interlace, S/H enabled
 +
+
 +
btst #button_A,(Ctrl_1_Held).w
 +
beq.s +
 +
move.b #1,(Debug_mode_flag).w
 +
+
 +
move.w #$8ADF,(Hint_counter_reserve).w ; H-INT every 223rd scanline
 +
tst.w (Two_player_mode).w
 +
beq.s +
 +
move.w #$8A6B,(Hint_counter_reserve).w ; H-INT every 108th scanline
 +
move.w #$8014,(a6) ; H-INT enabled
 +
move.w #$8C87,(a6) ; H res 40 cells, double res interlace
 +
+
 +
move.w (Hint_counter_reserve).w,(a6)
 +
clr.w (VDP_Command_Buffer).w
 +
move.l #VDP_Command_Buffer,(VDP_Command_Buffer_Slot).w
 +
tst.b (Water_flag).w ; does level have water?
 +
beq.s Level_LoadPal ; if not, branch
 +
move.w #$8014,(a6) ; H-INT enabled
 +
moveq #0,d0
 +
move.w (Current_ZoneAndAct).w,d0
 +
    if ~~useFullWaterTables
 +
subi.w #hidden_palace_zone_act_1,d0
 +
    endif
 +
ror.b #1,d0
 +
lsr.w #6,d0
 +
andi.w #$FFFE,d0
 +
lea (WaterHeight).l,a1 ; load water height array
 +
move.w (a1,d0.w),d0
 +
move.w d0,(Water_Level_1).w ; set water heights
 +
move.w d0,(Water_Level_2).w
 +
move.w d0,(Water_Level_3).w
 +
clr.b (Water_routine).w ; clear water routine counter
 +
clr.b (Water_fullscreen_flag).w ; clear water movement
 +
move.b #1,(Water_on).w ; enable water
 +
; loc_407C:
 +
Level_LoadPal:
 +
moveq #PalID_BGND,d0
 +
bsr.w PalLoad2 ; load Sonic's palette line
 +
tst.b (Water_flag).w ; does level have water?
 +
beq.s Level_GetBgm ; if not, branch
 +
moveq #PalID_HPZ_U,d0 ; palette number $15
 +
cmpi.b #hidden_palace_zone,(Current_Zone).w
 +
beq.s Level_WaterPal ; branch if level is HPZ
 +
moveq #PalID_CPZ_U,d0 ; palette number $16
 +
cmpi.b #chemical_plant_zone,(Current_Zone).w
 +
beq.s Level_WaterPal ; branch if level is CPZ
 +
moveq #PalID_ARZ_U,d0 ; palette number $17
 +
; loc_409E:
 +
Level_WaterPal:
 +
bsr.w PalLoad3_Water ; load underwater palette (with d0)
 +
tst.b (Last_star_pole_hit).w ; is it the start of the level?
 +
beq.s Level_GetBgm ; if yes, branch
 +
move.b (Saved_Water_move).w,(Water_fullscreen_flag).w
 +
; loc_40AE:
 +
Level_GetBgm:
 +
tst.w (Demo_mode_flag).w
 +
bmi.s +
 +
moveq #0,d0
 +
move.b (Current_Zone).w,d0
 +
lea MusicList(pc),a1
 +
tst.w (Two_player_mode).w
 +
beq.s Level_PlayBgm
 +
lea MusicList2(pc),a1
 +
; loc_40C8:
 +
Level_PlayBgm:
 +
move.b (a1,d0.w),d0 ; load from music playlist
 +
move.w d0,(Level_Music).w ; store level music
 +
bsr.w PlayMusic ; play level music
 +
move.b #ObjID_TitleCard,(TitleCard+id).w ; load Obj34 (level title card) at $FFFFB080</asm>
 +
 +
::This code from my disasm:
 +
 +
<asm>;----------------------------------------------------------------------------
 +
; 1P Music Playlist
 +
;----------------------------------------------------------------------------
 +
; byte_3EA0:
 +
MusicList: zoneOrderedTable 1,1
 +
zoneTableEntry.b MusID_EHZ ; 0 ; EHZ
 +
zoneTableEntry.b MusID_EHZ ; 1
 +
zoneTableEntry.b MusID_MTZ ; 2
 +
zoneTableEntry.b MusID_OOZ ; 3
 +
zoneTableEntry.b MusID_MTZ ; 4 ; MTZ1,2
 +
zoneTableEntry.b MusID_MTZ ; 5 ; MTZ3
 +
zoneTableEntry.b MusID_WFZ ; 6 ; WFZ
 +
zoneTableEntry.b MusID_HTZ ; 7 ; HTZ
 +
zoneTableEntry.b MusID_HPZ ; 8
 +
zoneTableEntry.b MusID_SCZ ; 9
 +
zoneTableEntry.b MusID_OOZ ; 10 ; OOZ
 +
zoneTableEntry.b MusID_MCZ ; 11 ; MCZ
 +
zoneTableEntry.b MusID_CNZ ; 12 ; CNZ
 +
zoneTableEntry.b MusID_CPZ ; 13 ; CPZ
 +
zoneTableEntry.b MusID_DEZ ; 14 ; DEZ
 +
zoneTableEntry.b MusID_ARZ ; 15 ; ARZ
 +
zoneTableEntry.b MusID_SCZ ; 16 ; SCZ
 +
    zoneTableEnd
 +
even
 +
;----------------------------------------------------------------------------
 +
; 1P Music Playlist (Act 2s)
 +
;----------------------------------------------------------------------------
 +
MusicListAlt:zoneOrderedTable 1,1
 +
zoneTableEntry.b MusID_EHZ_2P ; 0 ; EHZ
 +
zoneTableEntry.b MusID_EHZ ; 1
 +
zoneTableEntry.b MusID_MTZ ; 2
 +
zoneTableEntry.b MusID_OOZ ; 3
 +
zoneTableEntry.b MusID_MTZ ; 4 ; MTZ1,2
 +
zoneTableEntry.b MusID_MTZ ; 5 ; MTZ3
 +
zoneTableEntry.b MusID_WFZ ; 6 ; WFZ
 +
zoneTableEntry.b MusID_HTZ ; 7 ; HTZ
 +
zoneTableEntry.b MusID_HPZ ; 8
 +
zoneTableEntry.b MusID_SCZ ; 9
 +
zoneTableEntry.b MusID_OOZ ; 10 ; OOZ
 +
zoneTableEntry.b MusID_MCZ ; 11 ; MCZ
 +
zoneTableEntry.b MusID_CNZ ; 12 ; CNZ
 +
zoneTableEntry.b MusID_CPZ ; 13 ; CPZ
 +
zoneTableEntry.b MusID_DEZ ; 14 ; DEZ
 +
zoneTableEntry.b MusID_ARZ ; 15 ; ARZ
 +
zoneTableEntry.b MusID_SCZ ; 16 ; SCZ
 +
    zoneTableEnd
 +
even
 +
 +
;----------------------------------------------------------------------------
 +
; 2P Music Playlist
 +
;----------------------------------------------------------------------------
 +
; byte_3EB2:
 +
MusicList2: zoneOrderedTable 1,1
 +
zoneTableEntry.b MusID_EHZ_2P ; 0  ; EHZ 2P
 +
zoneTableEntry.b MusID_EHZ ; 1
 +
zoneTableEntry.b MusID_MTZ ; 2
 +
zoneTableEntry.b MusID_OOZ ; 3
 +
zoneTableEntry.b MusID_MTZ ; 4
 +
zoneTableEntry.b MusID_MTZ ; 5
 +
zoneTableEntry.b MusID_WFZ ; 6
 +
zoneTableEntry.b MusID_HTZ ; 7
 +
zoneTableEntry.b MusID_HPZ ; 8
 +
zoneTableEntry.b MusID_SCZ ; 9
 +
zoneTableEntry.b MusID_OOZ ; 10
 +
zoneTableEntry.b MusID_MCZ_2P ; 11 ; MCZ 2P
 +
zoneTableEntry.b MusID_CNZ_2P ; 12 ; CNZ 2P
 +
zoneTableEntry.b MusID_CPZ ; 13
 +
zoneTableEntry.b MusID_DEZ ; 14
 +
zoneTableEntry.b MusID_ARZ ; 15
 +
zoneTableEntry.b MusID_SCZ ; 16
 +
    zoneTableEnd
 +
even
 +
; ===========================================================================
 +
 +
; ---------------------------------------------------------------------------
 +
; Level
 +
; DEMO AND ZONE LOOP (MLS values $08, $0C; bit 7 set indicates that load routine is running)
 +
; ---------------------------------------------------------------------------
 +
; loc_3EC4:
 +
Level:
 +
bset #GameModeFlag_TitleCard,(Game_Mode).w ; add $80 to screen mode (for pre level sequence)
 +
tst.w (Demo_mode_flag).w ; test the old flag for the credits demos (now unused)
 +
bmi.s +
 +
move.b #MusID_FadeOut,d0
 +
bsr.w PlaySound ; fade out music
 +
+
 +
bsr.w ClearPLC
 +
bsr.w Pal_FadeFrom
 +
tst.w (Demo_mode_flag).w
 +
bmi.s Level_ClrRam
 +
move #$2700,sr
 +
bsr.w ClearScreen
 +
jsr (LoadTitleCard).l ; load title card patterns
 +
move #$2300,sr
 +
moveq #0,d0
 +
move.w d0,(Timer_frames).w
 +
move.b (Current_Zone).w,d0
 +
 +
; multiply d0 by 12, the size of a level art load block
 +
add.w d0,d0
 +
add.w d0,d0
 +
move.w d0,d1
 +
add.w d0,d0
 +
add.w d1,d0
 +
 +
lea (LevelArtPointers).l,a2
 +
lea (a2,d0.w),a2
 +
moveq #0,d0
 +
move.b (a2),d0 ; PLC1 ID
 +
beq.s +
 +
bsr.w LoadPLC
 +
+
 +
moveq #PLCID_Std2,d0
 +
bsr.w LoadPLC
 +
bsr.w Level_SetPlayerMode
 +
moveq #PLCID_Miles1up,d0
 +
tst.w (Two_player_mode).w
 +
bne.s +
 +
cmpi.w #2,(Player_mode).w
 +
bne.s Level_ClrRam
 +
addq.w #PLCID_MilesLife-PLCID_Miles1up,d0
 +
+
 +
tst.b (Graphics_Flags).w
 +
bpl.s +
 +
addq.w #PLCID_Tails1up-PLCID_Miles1up,d0
 +
+
 +
bsr.w LoadPLC
 +
; loc_3F48:
 +
Level_ClrRam:
 +
clearRAM Sprite_Table_Input,$400
 +
clearRAM Object_RAM,(LevelOnly_Object_RAM_End-Object_RAM) ; clear object RAM
 +
clearRAM MiscLevelVariables,(MiscLevelVariables_End-MiscLevelVariables)
 +
clearRAM Misc_Variables,(Misc_Variables_End-Misc_Variables)
 +
clearRAM Oscillating_Data,(Oscillating_variables_End-Oscillating_variables)
 +
clearRAM CNZ_saucer_data,$100
 +
 +
cmpi.w #chemical_plant_zone_act_2,(Current_ZoneAndAct).w ; CPZ 2
 +
beq.s Level_InitWater
 +
cmpi.b #aquatic_ruin_zone,(Current_Zone).w ; ARZ
 +
beq.s Level_InitWater
 +
cmpi.b #hidden_palace_zone,(Current_Zone).w ; HPZ
 +
bne.s +
 +
 +
Level_InitWater:
 +
move.b #1,(Water_flag).w
 +
move.w #0,(Two_player_mode).w
 +
+
 +
lea (VDP_control_port).l,a6
 +
move.w #$8B03,(a6) ; EXT-INT disabled, V scroll by screen, H scroll by line
 +
move.w #$8230,(a6) ; PNT A base: $C000
 +
move.w #$8407,(a6) ; PNT B base: $E000
 +
move.w #$857C,(a6) ; Sprite attribute table base: $F800
 +
move.w #$9001,(a6) ; Scroll table size: 64x32
 +
move.w #$8004,(a6) ; H-INT disabled
 +
move.w #$8720,(a6) ; Background palette/color: 2/0
 +
move.w #$8C81,(a6) ; H res 40 cells, no interlace
 +
tst.b (Night_mode_flag).w
 +
beq.s ++
 +
btst #button_C,(Ctrl_1_Held).w
 +
beq.s +
 +
move.w #$8C89,(a6) ; H res 40 cells, no interlace, S/H enabled
 +
+
 +
btst #button_A,(Ctrl_1_Held).w
 +
beq.s +
 +
move.b #1,(Debug_mode_flag).w
 +
+
 +
move.w #$8ADF,(Hint_counter_reserve).w ; H-INT every 223rd scanline
 +
tst.w (Two_player_mode).w
 +
beq.s +
 +
move.w #$8A6B,(Hint_counter_reserve).w ; H-INT every 108th scanline
 +
move.w #$8014,(a6) ; H-INT enabled
 +
move.w #$8C87,(a6) ; H res 40 cells, double res interlace
 +
+
 +
move.w (Hint_counter_reserve).w,(a6)
 +
clr.w (VDP_Command_Buffer).w
 +
move.l #VDP_Command_Buffer,(VDP_Command_Buffer_Slot).w
 +
tst.b (Water_flag).w ; does level have water?
 +
beq.s Level_LoadPal ; if not, branch
 +
move.w #$8014,(a6) ; H-INT enabled
 +
moveq #0,d0
 +
move.w (Current_ZoneAndAct).w,d0
 +
    if ~~useFullWaterTables
 +
subi.w #hidden_palace_zone_act_1,d0
 +
    endif
 +
ror.b #1,d0
 +
lsr.w #6,d0
 +
andi.w #$FFFE,d0
 +
lea (WaterHeight).l,a1 ; load water height array
 +
move.w (a1,d0.w),d0
 +
move.w d0,(Water_Level_1).w ; set water heights
 +
move.w d0,(Water_Level_2).w
 +
move.w d0,(Water_Level_3).w
 +
clr.b (Water_routine).w ; clear water routine counter
 +
clr.b (Water_fullscreen_flag).w ; clear water movement
 +
move.b #1,(Water_on).w ; enable water
 +
; loc_407C:
 +
Level_LoadPal:
 +
moveq #PalID_BGND,d0
 +
bsr.w PalLoad2 ; load Sonic's palette line
 +
tst.b (Water_flag).w ; does level have water?
 +
beq.s Level_GetBgm ; if not, branch
 +
moveq #PalID_HPZ_U,d0 ; palette number $15
 +
cmpi.b #hidden_palace_zone,(Current_Zone).w
 +
beq.s Level_WaterPal ; branch if level is HPZ
 +
moveq #PalID_CPZ_U,d0 ; palette number $16
 +
cmpi.b #chemical_plant_zone,(Current_Zone).w
 +
beq.s Level_WaterPal ; branch if level is CPZ
 +
moveq #PalID_ARZ_U,d0 ; palette number $17
 +
; loc_409E:
 +
Level_WaterPal:
 +
bsr.w PalLoad3_Water ; load underwater palette (with d0)
 +
tst.b (Last_star_pole_hit).w ; is it the start of the level?
 +
beq.s Level_GetBgm ; if yes, branch
 +
move.b (Saved_Water_move).w,(Water_fullscreen_flag).w
 +
; loc_40AE:
 +
Level_GetBgm:
 +
tst.w (Demo_mode_flag).w
 +
bmi.s +
 +
moveq #0,d0
 +
move.b  (Current_Zone).w,d0
 +
       
 +
        cmpi.b #$0,(Current_Act).w
 +
beq.s Level_GetBgm2
 +
lea    MusicList(pc),a1
 +
        bra.s  Level_PlayBgm
 +
; ---------------------------------------------------------------------------
 +
;        tst.w (Two_player_mode).w
 +
; beq.s Level_PlayBgm
 +
; lea MusicList2(pc),a1
 +
; ---------------------------------------------------------------------------
 +
Level_GetBgm2:
 +
        cmpi.b #$1,(Current_Act).w
 +
beq.s Level_GetBgm2P
 +
lea    MusicListAlt(pc),a1
 +
Level_GetBgm2P:
 +
        tst.w (Two_player_mode).w
 +
beq.s Level_PlayBgm
 +
lea MusicList2(pc),a1
 +
; loc_40C8:
 +
Level_PlayBgm:
 +
move.b (a1,d0.w),d0 ; load from music playlist
 +
move.w d0,(Level_Music).w ; store level music
 +
bsr.w PlayMusic ; play level music
 +
move.b #ObjID_TitleCard,(TitleCard+id).w ; load Obj34 (level title card) at $FFFFB080</asm>
 +
 +
::Notice that in my code, I changed EHZ's song to the 2P song in my alternative playlist, however, it loads that song for EHZ whatsoever. This may sound n00bish, but could you tell me what I'm doing wrong? (Sorry for all that excess code; only the parts about music are relevant.) -- [[User:RetroUser|RetroUser]] 17:16, 25 May 2014 (UTC)

Revision as of 13:16, 25 May 2014

Categorization

After familiarising myself with the 'guide categories', I question why the entries under Sonic 2's Miscellaneous are there, as, to me, they appear to fall under Design Choices.

To be more specific, what makes them 'miscellaneous'? What makes them 'not Design Choice changes'? Why else would you change, say, the Special Stage ring requirements? It's not to fix a bug, and it isn't to allow for custom content, nor would it not have an immediate effect, as the description under S1's Extend category header. It even seems similar to Enable/Disable Tails in Certain Levels in that regard: why change that? They're for the same reasons, customisation of the original game, or for custom Zones/Special Stages.

Actually, it seems that many guides are in the wrong place. Port Knuckles, for example:

"Extending the game

These guides will prepare you to introduce new content in the game. Merely following these guides will usually have no immediate effect in the game; you will need to provide custom content."

UMM...

Also, what of outdated guides? I have a plan for a superior version of Expand the music index from $94 to $9F and Expand the music index to start at $00 instead of $80 that takes no cues from these guides. I don't want to just orphan the guides, and I can't credit their authors in mine since they had no hand whatsoever in it.

So the only logical solution I can think of is creating a separate 'Obsolete' category. I wouldn't say 'Outdated' since at least half of the guides around here are outdated (old disasms). Though I wouldn't argue against such a category for those, it'd give us a reason to update the old things to a level of presentability.

Anyhow, I just wanted to bring this by anyone reading before I go off making any relatively large changes. Anyone have any objections, suggestions? Anything? Clownacy 17:19, 14 April 2014 (UTC)

I did not read the descriptions on the Sonic 1 categories when placing the Knuckles guide, I merely saw that it wasn't a design choice, so I figured it ought to go under extending the game. Perhaps if the "Design Choices & Features" category was split into two like Sonic 1, it would make more sense. MainMemory 17:24, 14 April 2014 (UTC)

Homing Attack Guide

Hey, could somebody please write a homing attack/jump-dash guide for Sonic 1? That would be awesome! RetroUser 20:40, 24 April 2014 (UTC)

Certain people would rather such a guide not exist, as they feel that it would be "too easy". I personally don't feel that way, but I only do Sonic 2. MainMemory 20:45, 24 April 2014 (UTC)
Ok then, Sonic 2 would be fine. RetroUser 21:06, 24 April 2014 (UTC)
Oh, and if a homing attack guide gets written for Sonic 2, it can go under the new "Adding features" category I added. RetroUser 23:12, 25 April 2014 (UTC)
Since when did we make guides on command? I may just be full of pride, but that feels rude. Besides, haven't you looked around? This 'homing attack code' business has been a touchy subject for ages, and many like you have asked this same question many times before, though they've mostly gotten the same answer. It says something, that you haven't noticed, something bad. Also, you missed the Music Index expansion guide under Extending the game, you haven't removed the mention of features from the Design Choices & Features header, there are numerous Adding features-type guides that you haven't moved from Design Choices & Features, and you haven't changed the S2Howtos Template. If this is how you edit a wiki page, I'd hate to see how you edit code. No wonder you need a guide! But these guides aren't here to tell you how to do everything. Many, myself included, used and see these as an introduction. It's where you begin, with adding a basic move, enhancing a certain feature. Not where you reach the peak of Sonic hacking, where you program an alien ability that requires greater knowledge of the Sonic Engine's object system, physics, object status, collision handling, and even 68K Assembly itself! You can't condense that into a guide; instead, it must come from experience, lots of it. The only guide that the homing attack can possibly find itself in is a copy-and-paste guide, and that is unacceptable. Clownacy 03:47, 27 April 2014 (UTC)
Okay, I wasn't demanding that a guide be written, I was simply asking about it and stating that it was a new feature and could go there if it ever did get written, which now isn't going to happen, I can see. I understand now what you mean about the music expansion guide, but the fact that you have to provide your own music was on my mind. RetroUser 15:55, 27 April 2014 (UTC)
If I can say anything, I meant nothing malicious by removing your category, it's nice to see someone making changes around here, but as I was following up on my changes mentioned in the above 'Categorization' section, I had a very difficult time distinguishing feature from alternate design choice. For example, the Air Speed Cap Removal guide, was it a feature that you could exceed a certain speed whilst airborne, or was it changing the design choice of having it limited? One of the few reasons I thought for the Expansion-worthy guide going under Sound Features was that this was the case with the Sonic 1 guide, though looking at it now, there's a sound driver bugfix in the Bugfix category, and not in the Sound Features one. Since the drivers are the same thing, only in different games, I'm thinking of adding a separate group, solely for the 68K sound driver. It'd get very messy having a Sonic 2 variant of every guide for the S1 sound driver thanks to the Clone Driver, and only worsened when I begin adding more guides for the thing. Clownacy 15:41, 28 April 2014 (UTC)
Alright, I guess I wouldn't have many objections (if any) for a section solely on the driver, as things wouldn't have to be spread out as much, and there would be less debate about where a guide for it would go. Also, I'd like to thank you for stating that you meant no harm when removing my category, and I'd like to say that I was only trying to make things easier by adding new sections. I didn't mean to have things so messed up, and I'll try to be more careful in the future. RetroUser 00:29, 29 April 2014 (UTC)

Clone Driver 2.1.2 Setup Guide

Clownancy,

Ok, so I've downloaded and checked out the Sonic 2 Clone Driver 2.1.2, and I find it to be awesome, but is there a setup tutorial out there, or are you working on that? RetroUser 23:46, 9 May 2014 (UTC)

That's being asked here? There's one right on the thread's first post, right underneath the download. At some point, I plan to edit this guide to support it. Right now, I don't really want to. I'll probably have to have the page's name changed and completely rewrite it... Actually, I think I'll just move it to the proposed 'Obsolete' category and make a brand new page. Speaking of obsolete, I'm surprised no one's noticed that the Enigma Credits guide is broken: The download links are external, and the host has long since deleted the files. Flamewing's S2 Special Stage DPLC guide appears to be broken also, but in a different way, in that I can't get it to work, though that could just be me. It's been a while since I last tried, and that was before I got familiar with DPLCs and mappings, so I'll give it another shot. Don't know what to do with the Enigma Credits, I can't find a mirror to the files, which leaves it a dead guide. Wait a minute... Clown-nancy?! Clownacy 18:05, 11 May 2014 (UTC)
Whoops! Guess I saw the name incorrectly...sorry =/ RetroUser 23:45, 11 May 2014 (UTC)
It's Clown + Lunacy, pronounced "Cloonacy". Think "Clown" pronounced with a strong accent (Scottish?). A recent message from a Clone Driver V2 (I need to find a way to abbreviate this thing) user gave me an idea to make the Driver update-friendly, the guide will also contain a 'how to update' section. Going back for a minute, by "setup" you meant "installation", right? How are you signing your posts, anyway? The wiki doesn't seem to like it, I have to keep fixing it. Clownacy 08:15, 12 May 2014 (UTC)
Okay, my signature should be fixed, but before now, I would click on the "Treat signature as wikitext (without an automatic link)" box and use html code or whatever to color it and give it a font (think FrozenNitrogen). What do you mean by the wiki not liking it, though? Would it just show weird code? Also, as for the guide, yes, I mean installation, however, when I went to the topic to download the driver, I didn't remember seeing the guide, so I just had to ask that question without checking it again. RetroUser 19:32, 12 May 2014 (UTC)
Look at the history, "Retro" is highlighted blue, and probably links to something. So, yeah, weird code. Whatever you did this time, it worked, safe for the out-of-place hyphen. Clownacy 20:26, 12 May 2014 (UTC)
Umm, the "Retro" wasn't highlighted blue, I used html code to give it that color; the whole name links to my *missing* user page because I set it to do that. Now, the "User" I colored gray to give my signature something of a cheese factor unique style by having two colors. For example, Frozen Nitrogen's unique signature is like this: Frozen Nitrogen. RetroUser 17:01, 13 May 2014 (UTC)

Dynamic Music in Sonic 2

Umm, does anybody here know about having dynamic music in Sonic 2? I've been trying to do it myself, but I can't seem to get the code to work. This is especially painful now that I've installed the Clone Driver 2.1.2 and have support for MUCH more music. So, Clownacy, if/when you put up a wiki guide on how to install this driver, could you add a section on this? I'm not saying that you have to, and it's fine if you feel that this code shouldn't be in a guide; I'm just putting up a request. And who knows? Maybe I'll end up getting the code to work by myself. Still, it would be nice to see how things are done the real way. =P -- RetroUser 18:03, 24 May 2014 (UTC)

Dynamic music? What's that? Different music on every act? That would certainly be a good guide to make, since the Sonic 1 guide on it is a cheap hack. Good for teaching a noob when to use cmp, but not good at teaching anyone the real way to achieve act-specific music. Such a thing would be a standalone guide, as you can apply it to hacks using either of the S1/S2/S3K drivers. Clownacy 13:06, 25 May 2014 (UTC)
Yeah, that's what I mean, and what I meant by "the real way" was "not my way" (which doesn't even work yet, and is probably sort of hackish.). Also, I think that it may be a tad bit more complicated with Sonic 2, because it also has a check for multiplayer mode, and I don't understand how Metropolis 3 simply loads the entry after the one for the first act. So, I'd like to post this area of code (where I'm trying to get the code to work) from a fresh Sonic 2 disasm and from my disasm. (The Clone Driver is installed in mine, btw. Also, these references are for the GitHub disasm.)
The vanilla code from MusicList to the end of Level_PlayBgm:

<asm>;----------------------------------------------------------------------------

1P Music Playlist
----------------------------------------------------------------------------
byte_3EA0

MusicList: zoneOrderedTable 1,1 zoneTableEntry.b MusID_EHZ ; 0 ; EHZ zoneTableEntry.b MusID_EHZ ; 1 zoneTableEntry.b MusID_MTZ ; 2 zoneTableEntry.b MusID_OOZ ; 3 zoneTableEntry.b MusID_MTZ ; 4 ; MTZ1,2 zoneTableEntry.b MusID_MTZ ; 5 ; MTZ3 zoneTableEntry.b MusID_WFZ ; 6 ; WFZ zoneTableEntry.b MusID_HTZ ; 7 ; HTZ zoneTableEntry.b MusID_HPZ ; 8 zoneTableEntry.b MusID_SCZ ; 9 zoneTableEntry.b MusID_OOZ ; 10 ; OOZ zoneTableEntry.b MusID_MCZ ; 11 ; MCZ zoneTableEntry.b MusID_CNZ ; 12 ; CNZ zoneTableEntry.b MusID_CPZ ; 13 ; CPZ zoneTableEntry.b MusID_DEZ ; 14 ; DEZ zoneTableEntry.b MusID_ARZ ; 15 ; ARZ zoneTableEntry.b MusID_SCZ ; 16 ; SCZ

   zoneTableEnd

even

----------------------------------------------------------------------------
2P Music Playlist
----------------------------------------------------------------------------
byte_3EB2

MusicList2: zoneOrderedTable 1,1 zoneTableEntry.b MusID_EHZ_2P ; 0  ; EHZ 2P zoneTableEntry.b MusID_EHZ ; 1 zoneTableEntry.b MusID_MTZ ; 2 zoneTableEntry.b MusID_OOZ ; 3 zoneTableEntry.b MusID_MTZ ; 4 zoneTableEntry.b MusID_MTZ ; 5 zoneTableEntry.b MusID_WFZ ; 6 zoneTableEntry.b MusID_HTZ ; 7 zoneTableEntry.b MusID_HPZ ; 8 zoneTableEntry.b MusID_SCZ ; 9 zoneTableEntry.b MusID_OOZ ; 10 zoneTableEntry.b MusID_MCZ_2P ; 11 ; MCZ 2P zoneTableEntry.b MusID_CNZ_2P ; 12 ; CNZ 2P zoneTableEntry.b MusID_CPZ ; 13 zoneTableEntry.b MusID_DEZ ; 14 zoneTableEntry.b MusID_ARZ ; 15 zoneTableEntry.b MusID_SCZ ; 16

   zoneTableEnd

even

===========================================================================
---------------------------------------------------------------------------
Level
DEMO AND ZONE LOOP (MLS values $08, $0C; bit 7 set indicates that load routine is running)
---------------------------------------------------------------------------
loc_3EC4

Level: bset #GameModeFlag_TitleCard,(Game_Mode).w ; add $80 to screen mode (for pre level sequence) tst.w (Demo_mode_flag).w ; test the old flag for the credits demos (now unused) bmi.s + move.b #MusID_FadeOut,d0 bsr.w PlaySound ; fade out music + bsr.w ClearPLC bsr.w Pal_FadeFrom tst.w (Demo_mode_flag).w bmi.s Level_ClrRam move #$2700,sr bsr.w ClearScreen jsr (LoadTitleCard).l ; load title card patterns move #$2300,sr moveq #0,d0 move.w d0,(Timer_frames).w move.b (Current_Zone).w,d0

; multiply d0 by 12, the size of a level art load block add.w d0,d0 add.w d0,d0 move.w d0,d1 add.w d0,d0 add.w d1,d0

lea (LevelArtPointers).l,a2 lea (a2,d0.w),a2 moveq #0,d0 move.b (a2),d0 ; PLC1 ID beq.s + bsr.w LoadPLC + moveq #PLCID_Std2,d0 bsr.w LoadPLC bsr.w Level_SetPlayerMode moveq #PLCID_Miles1up,d0 tst.w (Two_player_mode).w bne.s + cmpi.w #2,(Player_mode).w bne.s Level_ClrRam addq.w #PLCID_MilesLife-PLCID_Miles1up,d0 + tst.b (Graphics_Flags).w bpl.s + addq.w #PLCID_Tails1up-PLCID_Miles1up,d0 + bsr.w LoadPLC

loc_3F48

Level_ClrRam: clearRAM Sprite_Table_Input,$400 clearRAM Object_RAM,(LevelOnly_Object_RAM_End-Object_RAM) ; clear object RAM clearRAM MiscLevelVariables,(MiscLevelVariables_End-MiscLevelVariables) clearRAM Misc_Variables,(Misc_Variables_End-Misc_Variables) clearRAM Oscillating_Data,(Oscillating_variables_End-Oscillating_variables) clearRAM CNZ_saucer_data,$100

cmpi.w #chemical_plant_zone_act_2,(Current_ZoneAndAct).w ; CPZ 2 beq.s Level_InitWater cmpi.b #aquatic_ruin_zone,(Current_Zone).w ; ARZ beq.s Level_InitWater cmpi.b #hidden_palace_zone,(Current_Zone).w ; HPZ bne.s +

Level_InitWater: move.b #1,(Water_flag).w move.w #0,(Two_player_mode).w + lea (VDP_control_port).l,a6 move.w #$8B03,(a6) ; EXT-INT disabled, V scroll by screen, H scroll by line move.w #$8230,(a6) ; PNT A base: $C000 move.w #$8407,(a6) ; PNT B base: $E000 move.w #$857C,(a6) ; Sprite attribute table base: $F800 move.w #$9001,(a6) ; Scroll table size: 64x32 move.w #$8004,(a6) ; H-INT disabled move.w #$8720,(a6) ; Background palette/color: 2/0 move.w #$8C81,(a6) ; H res 40 cells, no interlace tst.b (Night_mode_flag).w beq.s ++ btst #button_C,(Ctrl_1_Held).w beq.s + move.w #$8C89,(a6) ; H res 40 cells, no interlace, S/H enabled + btst #button_A,(Ctrl_1_Held).w beq.s + move.b #1,(Debug_mode_flag).w + move.w #$8ADF,(Hint_counter_reserve).w ; H-INT every 223rd scanline tst.w (Two_player_mode).w beq.s + move.w #$8A6B,(Hint_counter_reserve).w ; H-INT every 108th scanline move.w #$8014,(a6) ; H-INT enabled move.w #$8C87,(a6) ; H res 40 cells, double res interlace + move.w (Hint_counter_reserve).w,(a6) clr.w (VDP_Command_Buffer).w move.l #VDP_Command_Buffer,(VDP_Command_Buffer_Slot).w tst.b (Water_flag).w ; does level have water? beq.s Level_LoadPal ; if not, branch move.w #$8014,(a6) ; H-INT enabled moveq #0,d0 move.w (Current_ZoneAndAct).w,d0

   if ~~useFullWaterTables

subi.w #hidden_palace_zone_act_1,d0

   endif

ror.b #1,d0 lsr.w #6,d0 andi.w #$FFFE,d0 lea (WaterHeight).l,a1 ; load water height array move.w (a1,d0.w),d0 move.w d0,(Water_Level_1).w ; set water heights move.w d0,(Water_Level_2).w move.w d0,(Water_Level_3).w clr.b (Water_routine).w ; clear water routine counter clr.b (Water_fullscreen_flag).w ; clear water movement move.b #1,(Water_on).w ; enable water

loc_407C

Level_LoadPal: moveq #PalID_BGND,d0 bsr.w PalLoad2 ; load Sonic's palette line tst.b (Water_flag).w ; does level have water? beq.s Level_GetBgm ; if not, branch moveq #PalID_HPZ_U,d0 ; palette number $15 cmpi.b #hidden_palace_zone,(Current_Zone).w beq.s Level_WaterPal ; branch if level is HPZ moveq #PalID_CPZ_U,d0 ; palette number $16 cmpi.b #chemical_plant_zone,(Current_Zone).w beq.s Level_WaterPal ; branch if level is CPZ moveq #PalID_ARZ_U,d0 ; palette number $17

loc_409E

Level_WaterPal: bsr.w PalLoad3_Water ; load underwater palette (with d0) tst.b (Last_star_pole_hit).w ; is it the start of the level? beq.s Level_GetBgm ; if yes, branch move.b (Saved_Water_move).w,(Water_fullscreen_flag).w

loc_40AE

Level_GetBgm: tst.w (Demo_mode_flag).w bmi.s + moveq #0,d0 move.b (Current_Zone).w,d0 lea MusicList(pc),a1 tst.w (Two_player_mode).w beq.s Level_PlayBgm lea MusicList2(pc),a1

loc_40C8

Level_PlayBgm: move.b (a1,d0.w),d0 ; load from music playlist move.w d0,(Level_Music).w ; store level music bsr.w PlayMusic ; play level music move.b #ObjID_TitleCard,(TitleCard+id).w ; load Obj34 (level title card) at $FFFFB080</asm>

This code from my disasm:

<asm>;----------------------------------------------------------------------------

1P Music Playlist
----------------------------------------------------------------------------
byte_3EA0

MusicList: zoneOrderedTable 1,1 zoneTableEntry.b MusID_EHZ ; 0 ; EHZ zoneTableEntry.b MusID_EHZ ; 1 zoneTableEntry.b MusID_MTZ ; 2 zoneTableEntry.b MusID_OOZ ; 3 zoneTableEntry.b MusID_MTZ ; 4 ; MTZ1,2 zoneTableEntry.b MusID_MTZ ; 5 ; MTZ3 zoneTableEntry.b MusID_WFZ ; 6 ; WFZ zoneTableEntry.b MusID_HTZ ; 7 ; HTZ zoneTableEntry.b MusID_HPZ ; 8 zoneTableEntry.b MusID_SCZ ; 9 zoneTableEntry.b MusID_OOZ ; 10 ; OOZ zoneTableEntry.b MusID_MCZ ; 11 ; MCZ zoneTableEntry.b MusID_CNZ ; 12 ; CNZ zoneTableEntry.b MusID_CPZ ; 13 ; CPZ zoneTableEntry.b MusID_DEZ ; 14 ; DEZ zoneTableEntry.b MusID_ARZ ; 15 ; ARZ zoneTableEntry.b MusID_SCZ ; 16 ; SCZ

   zoneTableEnd

even

----------------------------------------------------------------------------
1P Music Playlist (Act 2s)
----------------------------------------------------------------------------

MusicListAlt:zoneOrderedTable 1,1 zoneTableEntry.b MusID_EHZ_2P ; 0 ; EHZ zoneTableEntry.b MusID_EHZ ; 1 zoneTableEntry.b MusID_MTZ ; 2 zoneTableEntry.b MusID_OOZ ; 3 zoneTableEntry.b MusID_MTZ ; 4 ; MTZ1,2 zoneTableEntry.b MusID_MTZ ; 5 ; MTZ3 zoneTableEntry.b MusID_WFZ ; 6 ; WFZ zoneTableEntry.b MusID_HTZ ; 7 ; HTZ zoneTableEntry.b MusID_HPZ ; 8 zoneTableEntry.b MusID_SCZ ; 9 zoneTableEntry.b MusID_OOZ ; 10 ; OOZ zoneTableEntry.b MusID_MCZ ; 11 ; MCZ zoneTableEntry.b MusID_CNZ ; 12 ; CNZ zoneTableEntry.b MusID_CPZ ; 13 ; CPZ zoneTableEntry.b MusID_DEZ ; 14 ; DEZ zoneTableEntry.b MusID_ARZ ; 15 ; ARZ zoneTableEntry.b MusID_SCZ ; 16 ; SCZ

   zoneTableEnd

even

----------------------------------------------------------------------------
2P Music Playlist
----------------------------------------------------------------------------
byte_3EB2

MusicList2: zoneOrderedTable 1,1 zoneTableEntry.b MusID_EHZ_2P ; 0  ; EHZ 2P zoneTableEntry.b MusID_EHZ ; 1 zoneTableEntry.b MusID_MTZ ; 2 zoneTableEntry.b MusID_OOZ ; 3 zoneTableEntry.b MusID_MTZ ; 4 zoneTableEntry.b MusID_MTZ ; 5 zoneTableEntry.b MusID_WFZ ; 6 zoneTableEntry.b MusID_HTZ ; 7 zoneTableEntry.b MusID_HPZ ; 8 zoneTableEntry.b MusID_SCZ ; 9 zoneTableEntry.b MusID_OOZ ; 10 zoneTableEntry.b MusID_MCZ_2P ; 11 ; MCZ 2P zoneTableEntry.b MusID_CNZ_2P ; 12 ; CNZ 2P zoneTableEntry.b MusID_CPZ ; 13 zoneTableEntry.b MusID_DEZ ; 14 zoneTableEntry.b MusID_ARZ ; 15 zoneTableEntry.b MusID_SCZ ; 16

   zoneTableEnd

even

===========================================================================
---------------------------------------------------------------------------
Level
DEMO AND ZONE LOOP (MLS values $08, $0C; bit 7 set indicates that load routine is running)
---------------------------------------------------------------------------
loc_3EC4

Level: bset #GameModeFlag_TitleCard,(Game_Mode).w ; add $80 to screen mode (for pre level sequence) tst.w (Demo_mode_flag).w ; test the old flag for the credits demos (now unused) bmi.s + move.b #MusID_FadeOut,d0 bsr.w PlaySound ; fade out music + bsr.w ClearPLC bsr.w Pal_FadeFrom tst.w (Demo_mode_flag).w bmi.s Level_ClrRam move #$2700,sr bsr.w ClearScreen jsr (LoadTitleCard).l ; load title card patterns move #$2300,sr moveq #0,d0 move.w d0,(Timer_frames).w move.b (Current_Zone).w,d0

; multiply d0 by 12, the size of a level art load block add.w d0,d0 add.w d0,d0 move.w d0,d1 add.w d0,d0 add.w d1,d0

lea (LevelArtPointers).l,a2 lea (a2,d0.w),a2 moveq #0,d0 move.b (a2),d0 ; PLC1 ID beq.s + bsr.w LoadPLC + moveq #PLCID_Std2,d0 bsr.w LoadPLC bsr.w Level_SetPlayerMode moveq #PLCID_Miles1up,d0 tst.w (Two_player_mode).w bne.s + cmpi.w #2,(Player_mode).w bne.s Level_ClrRam addq.w #PLCID_MilesLife-PLCID_Miles1up,d0 + tst.b (Graphics_Flags).w bpl.s + addq.w #PLCID_Tails1up-PLCID_Miles1up,d0 + bsr.w LoadPLC

loc_3F48

Level_ClrRam: clearRAM Sprite_Table_Input,$400 clearRAM Object_RAM,(LevelOnly_Object_RAM_End-Object_RAM) ; clear object RAM clearRAM MiscLevelVariables,(MiscLevelVariables_End-MiscLevelVariables) clearRAM Misc_Variables,(Misc_Variables_End-Misc_Variables) clearRAM Oscillating_Data,(Oscillating_variables_End-Oscillating_variables) clearRAM CNZ_saucer_data,$100

cmpi.w #chemical_plant_zone_act_2,(Current_ZoneAndAct).w ; CPZ 2 beq.s Level_InitWater cmpi.b #aquatic_ruin_zone,(Current_Zone).w ; ARZ beq.s Level_InitWater cmpi.b #hidden_palace_zone,(Current_Zone).w ; HPZ bne.s +

Level_InitWater: move.b #1,(Water_flag).w move.w #0,(Two_player_mode).w + lea (VDP_control_port).l,a6 move.w #$8B03,(a6) ; EXT-INT disabled, V scroll by screen, H scroll by line move.w #$8230,(a6) ; PNT A base: $C000 move.w #$8407,(a6) ; PNT B base: $E000 move.w #$857C,(a6) ; Sprite attribute table base: $F800 move.w #$9001,(a6) ; Scroll table size: 64x32 move.w #$8004,(a6) ; H-INT disabled move.w #$8720,(a6) ; Background palette/color: 2/0 move.w #$8C81,(a6) ; H res 40 cells, no interlace tst.b (Night_mode_flag).w beq.s ++ btst #button_C,(Ctrl_1_Held).w beq.s + move.w #$8C89,(a6) ; H res 40 cells, no interlace, S/H enabled + btst #button_A,(Ctrl_1_Held).w beq.s + move.b #1,(Debug_mode_flag).w + move.w #$8ADF,(Hint_counter_reserve).w ; H-INT every 223rd scanline tst.w (Two_player_mode).w beq.s + move.w #$8A6B,(Hint_counter_reserve).w ; H-INT every 108th scanline move.w #$8014,(a6) ; H-INT enabled move.w #$8C87,(a6) ; H res 40 cells, double res interlace + move.w (Hint_counter_reserve).w,(a6) clr.w (VDP_Command_Buffer).w move.l #VDP_Command_Buffer,(VDP_Command_Buffer_Slot).w tst.b (Water_flag).w ; does level have water? beq.s Level_LoadPal ; if not, branch move.w #$8014,(a6) ; H-INT enabled moveq #0,d0 move.w (Current_ZoneAndAct).w,d0

   if ~~useFullWaterTables

subi.w #hidden_palace_zone_act_1,d0

   endif

ror.b #1,d0 lsr.w #6,d0 andi.w #$FFFE,d0 lea (WaterHeight).l,a1 ; load water height array move.w (a1,d0.w),d0 move.w d0,(Water_Level_1).w ; set water heights move.w d0,(Water_Level_2).w move.w d0,(Water_Level_3).w clr.b (Water_routine).w ; clear water routine counter clr.b (Water_fullscreen_flag).w ; clear water movement move.b #1,(Water_on).w ; enable water

loc_407C

Level_LoadPal: moveq #PalID_BGND,d0 bsr.w PalLoad2 ; load Sonic's palette line tst.b (Water_flag).w ; does level have water? beq.s Level_GetBgm ; if not, branch moveq #PalID_HPZ_U,d0 ; palette number $15 cmpi.b #hidden_palace_zone,(Current_Zone).w beq.s Level_WaterPal ; branch if level is HPZ moveq #PalID_CPZ_U,d0 ; palette number $16 cmpi.b #chemical_plant_zone,(Current_Zone).w beq.s Level_WaterPal ; branch if level is CPZ moveq #PalID_ARZ_U,d0 ; palette number $17

loc_409E

Level_WaterPal: bsr.w PalLoad3_Water ; load underwater palette (with d0) tst.b (Last_star_pole_hit).w ; is it the start of the level? beq.s Level_GetBgm ; if yes, branch move.b (Saved_Water_move).w,(Water_fullscreen_flag).w

loc_40AE

Level_GetBgm: tst.w (Demo_mode_flag).w bmi.s + moveq #0,d0 move.b (Current_Zone).w,d0

       cmpi.b	#$0,(Current_Act).w

beq.s Level_GetBgm2 lea MusicList(pc),a1

       bra.s   Level_PlayBgm
---------------------------------------------------------------------------
tst.w (Two_player_mode).w
beq.s Level_PlayBgm
lea MusicList2(pc),a1
---------------------------------------------------------------------------

Level_GetBgm2:

       cmpi.b	#$1,(Current_Act).w

beq.s Level_GetBgm2P lea MusicListAlt(pc),a1 Level_GetBgm2P:

       tst.w	(Two_player_mode).w

beq.s Level_PlayBgm lea MusicList2(pc),a1

loc_40C8

Level_PlayBgm: move.b (a1,d0.w),d0 ; load from music playlist move.w d0,(Level_Music).w ; store level music bsr.w PlayMusic ; play level music move.b #ObjID_TitleCard,(TitleCard+id).w ; load Obj34 (level title card) at $FFFFB080</asm>

Notice that in my code, I changed EHZ's song to the 2P song in my alternative playlist, however, it loads that song for EHZ whatsoever. This may sound n00bish, but could you tell me what I'm doing wrong? (Sorry for all that excess code; only the parts about music are relevant.) -- RetroUser 17:16, 25 May 2014 (UTC)