Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. GM_Level:
  3.         bset    #7,(v_gamemode).w ; add $80 to screen mode (for pre level sequence)
  4.         tst.w   (f_demo).w
  5.         bmi.s   Level_NoMusicFade
  6.         sfx bgm_Fade,0,1,1 ; fade out music
  7.  
  8.     Level_NoMusicFade:
  9.         bsr.w   ClearPLC
  10.         bsr.w   PaletteFadeOut
  11.         tst.w   (f_demo).w  ; is an ending sequence demo running?
  12.         bmi.s   Level_ClrRam    ; if yes, branch
  13.         disable_ints
  14.         locVRAM $B000
  15.         lea (Nem_TitleCard).l,a0 ; load title card patterns
  16.         bsr.w   NemDec
  17.         enable_ints
  18.         moveq   #0,d0
  19.         move.b  (v_zone).w,d0
  20.         lsl.w   #4,d0
  21.         lea (LevelHeaders).l,a2
  22.         lea (a2,d0.w),a2
  23.         moveq   #0,d0
  24.         move.b  (a2),d0
  25.         beq.s   loc_37FC
  26.         bsr.w   AddPLC      ; load level patterns
  27.  
  28. loc_37FC:
  29.         moveq   #plcid_Main2,d0
  30.         bsr.w   AddPLC      ; load standard patterns
  31.  
  32. Level_ClrRam:
  33.         lea (v_objspace).w,a1
  34.         moveq   #0,d0
  35.         move.w  #$7FF,d1
  36.  
  37.     Level_ClrObjRam:
  38.         move.l  d0,(a1)+
  39.         dbf d1,Level_ClrObjRam ; clear object RAM
  40.  
  41.         lea ($FFFFF628).w,a1
  42.         moveq   #0,d0
  43.         move.w  #$15,d1
  44.  
  45.     Level_ClrVars1:
  46.         move.l  d0,(a1)+
  47.         dbf d1,Level_ClrVars1 ; clear misc variables
  48.  
  49.         lea (v_screenposx).w,a1
  50.         moveq   #0,d0
  51.         move.w  #$3F,d1
  52.  
  53.     Level_ClrVars2:
  54.         move.l  d0,(a1)+
  55.         dbf d1,Level_ClrVars2 ; clear misc variables
  56.  
  57.         lea (v_oscillate+2).w,a1
  58.         moveq   #0,d0
  59.         move.w  #$47,d1
  60.  
  61.     Level_ClrVars3:
  62.         move.l  d0,(a1)+
  63.         dbf d1,Level_ClrVars3 ; clear object variables
  64.  
  65.         disable_ints
  66.         bsr.w   ClearScreen
  67.         lea (vdp_control_port).l,a6
  68.         move.w  #$8B03,(a6) ; line scroll mode
  69.         move.w  #$8200+(vram_fg>>10),(a6) ; set foreground nametable address
  70.         move.w  #$8400+(vram_bg>>13),(a6) ; set background nametable address
  71.         move.w  #$8500+(vram_sprites>>9),(a6) ; set sprite table address
  72.         move.w  #$9001,(a6)     ; 64-cell hscroll size
  73.         move.w  #$8004,(a6)     ; 8-colour mode
  74.         move.w  #$8720,(a6)     ; set background colour (line 3; colour 0)
  75.         move.w  #$8A00+223,(v_hbla_hreg).w ; set palette change position (for water)
  76.         move.w  (v_hbla_hreg).w,(a6)
  77.         cmpi.b  #id_LZ,(v_zone).w ; is level LZ?
  78.         bne.s   Level_LoadPal   ; if not, branch
  79.  
  80.         move.w  #$8014,(a6) ; enable H-interrupts
  81.         moveq   #0,d0
  82.         move.b  (v_act).w,d0
  83.         add.w   d0,d0
  84.         lea (WaterHeight).l,a1 ; load water height array
  85.         move.w  (a1,d0.w),d0
  86.         move.w  d0,(v_waterpos1).w ; set water heights
  87.         move.w  d0,(v_waterpos2).w
  88.         move.w  d0,(v_waterpos3).w
  89.         clr.b   (v_wtr_routine).w ; clear water routine counter
  90.         clr.b   (f_wtr_state).w ; clear water state
  91.         move.b  #1,(f_water).w  ; enable water
  92.  
  93. Level_LoadPal:
  94.         move.w  #30,(v_air).w
  95.         enable_ints
  96.         moveq   #palid_Sonic,d0
  97.         bsr.w   PalLoad2    ; load Sonic's palette
  98.         cmpi.b  #id_LZ,(v_zone).w ; is level LZ?
  99.         bne.s   Level_GetBgm    ; if not, branch
  100.  
  101.         moveq   #palid_LZSonWater,d0 ; palette number $F (LZ)
  102.         cmpi.b  #3,(v_act).w    ; is act number 3?
  103.         bne.s   Level_WaterPal  ; if not, branch
  104.         moveq   #palid_SBZ3SonWat,d0 ; palette number $10 (SBZ3)
  105.  
  106.     Level_WaterPal:
  107.         bsr.w   PalLoad3_Water  ; load underwater palette
  108.         tst.b   (v_lastlamp).w
  109.         beq.s   Level_GetBgm
  110.         move.b  ($FFFFFE53).w,(f_wtr_state).w
  111.  
  112. Level_GetBgm:
  113.         tst.w   (f_demo).w
  114.         bmi.s   Level_SkipTtlCard
  115.         move.b  #bgm_XXXXXXX,d0 ; ++
  116.         bsr.w   PlaySound   ; ++ play title card music
  117.         move.b  #id_TitleCard,(v_objspace+$80).w ; load title card object
  118.  
  119. Level_TtlCardLoop:
  120.         move.b  #$C,(v_vbla_routine).w
  121.         bsr.w   WaitForVBla
  122.         jsr (ExecuteObjects).l
  123.         jsr (BuildSprites).l
  124.         bsr.w   RunPLC
  125.         move.w  (v_objspace+$108).w,d0
  126.         cmp.w   (v_objspace+$130).w,d0 ; has title card sequence finished?
  127.         bne.s   Level_TtlCardLoop ; if not, branch
  128.         tst.l   (v_plc_buffer).w ; are there any items in the pattern load cue?
  129.         bne.s   Level_TtlCardLoop ; if yes, branch
  130.         jsr (Hud_Base).l    ; load basic HUD gfx
  131.  
  132.     Level_SkipTtlCard:
  133.         moveq   #palid_Sonic,d0
  134.         bsr.w   PalLoad1    ; load Sonic's palette
  135.         bsr.w   LevelSizeLoad
  136.         bsr.w   DeformLayers
  137.         bset    #2,(v_bgscroll1).w
  138.         bsr.w   LevelDataLoad ; load block mappings and palettes
  139.         bsr.w   LoadTilesFromStart
  140.         jsr (FloorLog_Unk).l
  141.         bsr.w   ColIndexLoad
  142.         bsr.w   LZWaterFeatures
  143.         move.b  #id_SonicPlayer,(v_player).w ; load Sonic object
  144.         tst.w   (f_demo).w
  145.         bmi.s   Level_ChkDebug
  146.         move.b  #id_HUD,(v_objspace+$40).w ; load HUD object
  147.  
  148. Level_ChkDebug:
  149.         tst.b   (f_debugcheat).w ; has debug cheat been entered?
  150.         beq.s   Level_ChkWater  ; if not, branch
  151.         btst    #bitA,(v_jpadhold1).w ; is A button held?
  152.         beq.s   Level_ChkWater  ; if not, branch
  153.         move.b  #1,(f_debugmode).w ; enable debug mode
  154.  
  155. Level_ChkWater:
  156.         move.w  #0,(v_jpadhold2).w
  157.         move.w  #0,(v_jpadhold1).w
  158.         cmpi.b  #id_LZ,(v_zone).w ; is level LZ?
  159.         bne.s   Level_LoadObj   ; if not, branch
  160.         move.b  #id_WaterSurface,(v_objspace+$780).w ; load water surface object
  161.         move.w  #$60,(v_objspace+$780+obX).w
  162.         move.b  #id_WaterSurface,(v_objspace+$7C0).w
  163.         move.w  #$120,(v_objspace+$7C0+obX).w
  164.  
  165. Level_LoadObj:
  166.         jsr (ObjPosLoad).l
  167.         jsr (ExecuteObjects).l
  168.         jsr (BuildSprites).l
  169.         moveq   #0,d0
  170.         tst.b   (v_lastlamp).w  ; are you starting from a lamppost?
  171.         bne.s   Level_SkipClr   ; if yes, branch
  172.         move.w  d0,(v_rings).w  ; clear rings
  173.         move.l  d0,(v_time).w   ; clear time
  174.         move.b  d0,(v_lifecount).w ; clear lives counter
  175.  
  176.     Level_SkipClr:
  177.         move.b  d0,(f_timeover).w
  178.         move.b  d0,(v_shield).w ; clear shield
  179.         move.b  d0,(v_invinc).w ; clear invincibility
  180.         move.b  d0,(v_shoes).w  ; clear speed shoes
  181.         move.b  d0,($FFFFFE2F).w
  182.         move.w  d0,(v_debuguse).w
  183.         move.w  d0,(f_restart).w
  184.         move.w  d0,(v_framecount).w
  185.         bsr.w   OscillateNumInit
  186.         move.b  #1,(f_scorecount).w ; update score counter
  187.         move.b  #1,(f_ringcount).w ; update rings counter
  188.         move.b  #1,(f_timecount).w ; update time counter
  189.         move.w  #0,(v_btnpushtime1).w
  190.         lea (DemoDataPtr).l,a1 ; load demo data
  191.         moveq   #0,d0
  192.         move.b  (v_zone).w,d0
  193.         lsl.w   #2,d0
  194.         movea.l (a1,d0.w),a1
  195.         tst.w   (f_demo).w  ; is demo mode on?
  196.         bpl.s   Level_Demo  ; if yes, branch
  197.         lea (DemoEndDataPtr).l,a1 ; load ending demo data
  198.         move.w  (v_creditsnum).w,d0
  199.         subq.w  #1,d0
  200.         lsl.w   #2,d0
  201.         movea.l (a1,d0.w),a1
  202.  
  203. Level_Demo:
  204.         move.b  1(a1),(v_btnpushtime2).w ; load key press duration
  205.         subq.b  #1,(v_btnpushtime2).w ; subtract 1 from duration
  206.         move.w  #1800,(v_demolength).w
  207.         tst.w   (f_demo).w
  208.         bpl.s   Level_ChkWaterPal
  209.         move.w  #540,(v_demolength).w
  210.         cmpi.w  #4,(v_creditsnum).w
  211.         bne.s   Level_ChkWaterPal
  212.         move.w  #510,(v_demolength).w
  213.  
  214. Level_ChkWaterPal:
  215.         cmpi.b  #id_LZ,(v_zone).w ; is level LZ/SBZ3?
  216.         bne.s   Level_Delay ; if not, branch
  217.         moveq   #palid_LZWater,d0 ; palette $B (LZ underwater)
  218.         cmpi.b  #3,(v_act).w    ; is level SBZ3?
  219.         bne.s   Level_WtrNotSbz ; if not, branch
  220.         moveq   #palid_SBZ3Water,d0 ; palette $D (SBZ3 underwater)
  221.  
  222.     Level_WtrNotSbz:
  223.         bsr.w   PalLoad4_Water
  224.  
  225. Level_Delay:
  226.         move.w  #3,d1
  227.  
  228.     Level_DelayLoop:
  229.         move.b  #8,(v_vbla_routine).w
  230.         bsr.w   WaitForVBla
  231.         dbf d1,Level_DelayLoop
  232.  
  233.         move.w  #$202F,(v_pfade_start).w ; fade in 2nd, 3rd & 4th palette lines
  234.         bsr.w   PalFadeIn_Alt
  235.         tst.w   (f_demo).w  ; is an ending sequence demo running?
  236.         bmi.s   Level_ClrCardArt ; if yes, branch
  237.         addq.b  #2,(v_objspace+$80+obRoutine).w ; make title card move
  238.         addq.b  #4,(v_objspace+$C0+obRoutine).w
  239.         addq.b  #4,(v_objspace+$100+obRoutine).w
  240.         addq.b  #4,(v_objspace+$140+obRoutine).w
  241.  
  242.  
  243.         ; ++ Moved to here
  244.         moveq   #0,d0
  245.         move.b  (v_zone).w,d0
  246.         cmpi.w  #(id_LZ<<8)+3,(v_zone).w ; is level SBZ3?
  247.         bne.s   Level_BgmNotLZ4 ; if not, branch
  248.         moveq   #5,d0       ; use 5th music (SBZ)
  249.  
  250.     Level_BgmNotLZ4:
  251.         cmpi.w  #(id_SBZ<<8)+2,(v_zone).w ; is level FZ?
  252.         bne.s   Level_PlayBgm   ; if not, branch
  253.         moveq   #6,d0       ; use 6th music (FZ)
  254.  
  255.     Level_PlayBgm:
  256.         lea (MusicList).l,a1 ; load music playlist
  257.         move.b  (a1,d0.w),d0
  258.         bsr PlaySound
  259.  
  260.         bra.s   Level_StartGame
  261. ; ===========================================================================
  262.  
  263. Level_ClrCardArt:
  264.         moveq   #plcid_Explode,d0
  265.         jsr (AddPLC).l  ; load explosion gfx
  266.         moveq   #0,d0
  267.         move.b  (v_zone).w,d0
  268.         addi.w  #plcid_GHZAnimals,d0
  269.         jsr (AddPLC).l  ; load animal gfx (level no. + $15)
  270.  
  271. Level_StartGame:
  272.         bclr    #7,(v_gamemode).w ; subtract $80 from mode to end pre-level stuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement