Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GM_Level:
- bset #7,(v_gamemode).w ; add $80 to screen mode (for pre level sequence)
- tst.w (f_demo).w
- bmi.s Level_NoMusicFade
- sfx bgm_Fade,0,1,1 ; fade out music
- Level_NoMusicFade:
- bsr.w ClearPLC
- bsr.w PaletteFadeOut
- tst.w (f_demo).w ; is an ending sequence demo running?
- bmi.s Level_ClrRam ; if yes, branch
- disable_ints
- locVRAM $B000
- lea (Nem_TitleCard).l,a0 ; load title card patterns
- bsr.w NemDec
- enable_ints
- moveq #0,d0
- move.b (v_zone).w,d0
- lsl.w #4,d0
- lea (LevelHeaders).l,a2
- lea (a2,d0.w),a2
- moveq #0,d0
- move.b (a2),d0
- beq.s loc_37FC
- bsr.w AddPLC ; load level patterns
- loc_37FC:
- moveq #plcid_Main2,d0
- bsr.w AddPLC ; load standard patterns
- Level_ClrRam:
- lea (v_objspace).w,a1
- moveq #0,d0
- move.w #$7FF,d1
- Level_ClrObjRam:
- move.l d0,(a1)+
- dbf d1,Level_ClrObjRam ; clear object RAM
- lea ($FFFFF628).w,a1
- moveq #0,d0
- move.w #$15,d1
- Level_ClrVars1:
- move.l d0,(a1)+
- dbf d1,Level_ClrVars1 ; clear misc variables
- lea (v_screenposx).w,a1
- moveq #0,d0
- move.w #$3F,d1
- Level_ClrVars2:
- move.l d0,(a1)+
- dbf d1,Level_ClrVars2 ; clear misc variables
- lea (v_oscillate+2).w,a1
- moveq #0,d0
- move.w #$47,d1
- Level_ClrVars3:
- move.l d0,(a1)+
- dbf d1,Level_ClrVars3 ; clear object variables
- disable_ints
- bsr.w ClearScreen
- lea (vdp_control_port).l,a6
- move.w #$8B03,(a6) ; line scroll mode
- move.w #$8200+(vram_fg>>10),(a6) ; set foreground nametable address
- move.w #$8400+(vram_bg>>13),(a6) ; set background nametable address
- move.w #$8500+(vram_sprites>>9),(a6) ; set sprite table address
- move.w #$9001,(a6) ; 64-cell hscroll size
- move.w #$8004,(a6) ; 8-colour mode
- move.w #$8720,(a6) ; set background colour (line 3; colour 0)
- move.w #$8A00+223,(v_hbla_hreg).w ; set palette change position (for water)
- move.w (v_hbla_hreg).w,(a6)
- cmpi.b #id_LZ,(v_zone).w ; is level LZ?
- bne.s Level_LoadPal ; if not, branch
- move.w #$8014,(a6) ; enable H-interrupts
- moveq #0,d0
- move.b (v_act).w,d0
- add.w d0,d0
- lea (WaterHeight).l,a1 ; load water height array
- move.w (a1,d0.w),d0
- move.w d0,(v_waterpos1).w ; set water heights
- move.w d0,(v_waterpos2).w
- move.w d0,(v_waterpos3).w
- clr.b (v_wtr_routine).w ; clear water routine counter
- clr.b (f_wtr_state).w ; clear water state
- move.b #1,(f_water).w ; enable water
- Level_LoadPal:
- move.w #30,(v_air).w
- enable_ints
- moveq #palid_Sonic,d0
- bsr.w PalLoad2 ; load Sonic's palette
- cmpi.b #id_LZ,(v_zone).w ; is level LZ?
- bne.s Level_GetBgm ; if not, branch
- moveq #palid_LZSonWater,d0 ; palette number $F (LZ)
- cmpi.b #3,(v_act).w ; is act number 3?
- bne.s Level_WaterPal ; if not, branch
- moveq #palid_SBZ3SonWat,d0 ; palette number $10 (SBZ3)
- Level_WaterPal:
- bsr.w PalLoad3_Water ; load underwater palette
- tst.b (v_lastlamp).w
- beq.s Level_GetBgm
- move.b ($FFFFFE53).w,(f_wtr_state).w
- Level_GetBgm:
- tst.w (f_demo).w
- bmi.s Level_SkipTtlCard
- move.b #bgm_XXXXXXX,d0 ; ++
- bsr.w PlaySound ; ++ play title card music
- move.b #id_TitleCard,(v_objspace+$80).w ; load title card object
- Level_TtlCardLoop:
- move.b #$C,(v_vbla_routine).w
- bsr.w WaitForVBla
- jsr (ExecuteObjects).l
- jsr (BuildSprites).l
- bsr.w RunPLC
- move.w (v_objspace+$108).w,d0
- cmp.w (v_objspace+$130).w,d0 ; has title card sequence finished?
- bne.s Level_TtlCardLoop ; if not, branch
- tst.l (v_plc_buffer).w ; are there any items in the pattern load cue?
- bne.s Level_TtlCardLoop ; if yes, branch
- jsr (Hud_Base).l ; load basic HUD gfx
- Level_SkipTtlCard:
- moveq #palid_Sonic,d0
- bsr.w PalLoad1 ; load Sonic's palette
- bsr.w LevelSizeLoad
- bsr.w DeformLayers
- bset #2,(v_bgscroll1).w
- bsr.w LevelDataLoad ; load block mappings and palettes
- bsr.w LoadTilesFromStart
- jsr (FloorLog_Unk).l
- bsr.w ColIndexLoad
- bsr.w LZWaterFeatures
- move.b #id_SonicPlayer,(v_player).w ; load Sonic object
- tst.w (f_demo).w
- bmi.s Level_ChkDebug
- move.b #id_HUD,(v_objspace+$40).w ; load HUD object
- Level_ChkDebug:
- tst.b (f_debugcheat).w ; has debug cheat been entered?
- beq.s Level_ChkWater ; if not, branch
- btst #bitA,(v_jpadhold1).w ; is A button held?
- beq.s Level_ChkWater ; if not, branch
- move.b #1,(f_debugmode).w ; enable debug mode
- Level_ChkWater:
- move.w #0,(v_jpadhold2).w
- move.w #0,(v_jpadhold1).w
- cmpi.b #id_LZ,(v_zone).w ; is level LZ?
- bne.s Level_LoadObj ; if not, branch
- move.b #id_WaterSurface,(v_objspace+$780).w ; load water surface object
- move.w #$60,(v_objspace+$780+obX).w
- move.b #id_WaterSurface,(v_objspace+$7C0).w
- move.w #$120,(v_objspace+$7C0+obX).w
- Level_LoadObj:
- jsr (ObjPosLoad).l
- jsr (ExecuteObjects).l
- jsr (BuildSprites).l
- moveq #0,d0
- tst.b (v_lastlamp).w ; are you starting from a lamppost?
- bne.s Level_SkipClr ; if yes, branch
- move.w d0,(v_rings).w ; clear rings
- move.l d0,(v_time).w ; clear time
- move.b d0,(v_lifecount).w ; clear lives counter
- Level_SkipClr:
- move.b d0,(f_timeover).w
- move.b d0,(v_shield).w ; clear shield
- move.b d0,(v_invinc).w ; clear invincibility
- move.b d0,(v_shoes).w ; clear speed shoes
- move.b d0,($FFFFFE2F).w
- move.w d0,(v_debuguse).w
- move.w d0,(f_restart).w
- move.w d0,(v_framecount).w
- bsr.w OscillateNumInit
- move.b #1,(f_scorecount).w ; update score counter
- move.b #1,(f_ringcount).w ; update rings counter
- move.b #1,(f_timecount).w ; update time counter
- move.w #0,(v_btnpushtime1).w
- lea (DemoDataPtr).l,a1 ; load demo data
- moveq #0,d0
- move.b (v_zone).w,d0
- lsl.w #2,d0
- movea.l (a1,d0.w),a1
- tst.w (f_demo).w ; is demo mode on?
- bpl.s Level_Demo ; if yes, branch
- lea (DemoEndDataPtr).l,a1 ; load ending demo data
- move.w (v_creditsnum).w,d0
- subq.w #1,d0
- lsl.w #2,d0
- movea.l (a1,d0.w),a1
- Level_Demo:
- move.b 1(a1),(v_btnpushtime2).w ; load key press duration
- subq.b #1,(v_btnpushtime2).w ; subtract 1 from duration
- move.w #1800,(v_demolength).w
- tst.w (f_demo).w
- bpl.s Level_ChkWaterPal
- move.w #540,(v_demolength).w
- cmpi.w #4,(v_creditsnum).w
- bne.s Level_ChkWaterPal
- move.w #510,(v_demolength).w
- Level_ChkWaterPal:
- cmpi.b #id_LZ,(v_zone).w ; is level LZ/SBZ3?
- bne.s Level_Delay ; if not, branch
- moveq #palid_LZWater,d0 ; palette $B (LZ underwater)
- cmpi.b #3,(v_act).w ; is level SBZ3?
- bne.s Level_WtrNotSbz ; if not, branch
- moveq #palid_SBZ3Water,d0 ; palette $D (SBZ3 underwater)
- Level_WtrNotSbz:
- bsr.w PalLoad4_Water
- Level_Delay:
- move.w #3,d1
- Level_DelayLoop:
- move.b #8,(v_vbla_routine).w
- bsr.w WaitForVBla
- dbf d1,Level_DelayLoop
- move.w #$202F,(v_pfade_start).w ; fade in 2nd, 3rd & 4th palette lines
- bsr.w PalFadeIn_Alt
- tst.w (f_demo).w ; is an ending sequence demo running?
- bmi.s Level_ClrCardArt ; if yes, branch
- addq.b #2,(v_objspace+$80+obRoutine).w ; make title card move
- addq.b #4,(v_objspace+$C0+obRoutine).w
- addq.b #4,(v_objspace+$100+obRoutine).w
- addq.b #4,(v_objspace+$140+obRoutine).w
- ; ++ Moved to here
- moveq #0,d0
- move.b (v_zone).w,d0
- cmpi.w #(id_LZ<<8)+3,(v_zone).w ; is level SBZ3?
- bne.s Level_BgmNotLZ4 ; if not, branch
- moveq #5,d0 ; use 5th music (SBZ)
- Level_BgmNotLZ4:
- cmpi.w #(id_SBZ<<8)+2,(v_zone).w ; is level FZ?
- bne.s Level_PlayBgm ; if not, branch
- moveq #6,d0 ; use 6th music (FZ)
- Level_PlayBgm:
- lea (MusicList).l,a1 ; load music playlist
- move.b (a1,d0.w),d0
- bsr PlaySound
- bra.s Level_StartGame
- ; ===========================================================================
- Level_ClrCardArt:
- moveq #plcid_Explode,d0
- jsr (AddPLC).l ; load explosion gfx
- moveq #0,d0
- move.b (v_zone).w,d0
- addi.w #plcid_GHZAnimals,d0
- jsr (AddPLC).l ; load animal gfx (level no. + $15)
- Level_StartGame:
- bclr #7,(v_gamemode).w ; subtract $80 from mode to end pre-level stuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement