ThomasSpeedrunner

Some code

Jul 22nd, 2014
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; the thing I'm having issues with
  2. loc_42C8:
  3.     tst.b   (Water_flag).w
  4.     beq.s   loc_42E8
  5.     moveq   #$15,d0
  6.     cmpi.b  #8,(Current_Zone).w
  7.     beq.s   loc_42E4
  8.     moveq   #$16,d0
  9.     cmpi.b  #$D,(Current_Zone).w
  10.     beq.s   loc_42E4
  11.     moveq   #$17,d0
  12.     cmpi.b  #$F,(Current_Zone).w
  13.     beq.s   loc_42E4
  14.     moveq   #$30,d0
  15.  
  16. loc_42E4:
  17.     bsr.w   PalLoad4_Water
  18.  
  19. ; everything else, just in case it's important
  20. ; water height
  21. loc_402C:
  22.     move.w  (Hint_counter_reserve).w,(a6)
  23.     clr.w   (VDP_Command_Buffer).w
  24.     move.l  #VDP_Command_Buffer,(VDP_Command_Buffer_Slot).w
  25.     tst.b   (Water_flag).w  ; does level have water?
  26.     beq.s   Level_LoadPal   ; if not, branch
  27.     move.w  #$8014,(a6)
  28.     moveq   #0,d0
  29.     move.w  (Current_ZoneAndAct).w,d0
  30.     lsl.b   #6,d0
  31.     lsr.w   #4,d0
  32.     andi.w  #$FFFE,d0
  33.     lea (WaterHeight).l,a1  ; load water height array
  34.     move.w  (a1,d0.w),d0
  35.     move.w  d0,(Water_Level_1).w ; set water heights
  36.     move.w  d0,(Water_Level_2).w
  37.     move.w  d0,(Water_Level_3).w
  38.     clr.b   (Water_routine).w   ; clear water routine counter
  39.     clr.b   (Water_move).w  ; clear water movement
  40.     move.b  #1,(Water_on).w ; enable water
  41.  
  42. ; dynamic water
  43. ; sub_45A4: ; LZDynamicWater:
  44. DynamicWater:
  45.     moveq   #0,d0
  46.     move.w  (Current_ZoneAndAct).w,d0
  47.     lsl.b   #6,d0
  48.     lsr.w   #4,d0
  49.     andi.w  #$FFFE,d0
  50.     move.w  (Dynamic_water_routine_table,pc,d0.w),d0
  51.     jsr (Dynamic_water_routine_table,pc,d0.w)
  52.     moveq   #0,d1
  53.     move.b  (Water_on).w,d1
  54.     move.w  (Water_Level_3).w,d0
  55.     sub.w   (Water_Level_2).w,d0
  56.     beq.s   return_45D6
  57.     bcc.s   loc_45D2
  58.     neg.w   d1
  59.  
  60. loc_45D2:
  61.     add.w   d1,(Water_Level_2).w
  62.  
  63. return_45D6:
  64.     rts                     ; Return to whatever code was running before this routine was run.
  65. ; End of function DynamicWater
  66.  
  67. ; level end type
  68. ; sub_4BD2:
  69. SetLevelEndType:
  70.     move.w  #0,(Level_Has_Signpost).w   ; set level type to non-signpost
  71.     tst.w   (Two_player_mode).w ; is it two-player competitive mode?
  72.     bne.w   LevelEnd_SetSignpost    ; if yes, branch
  73.     cmpi.w  #$0003,(Current_ZoneAndAct).w
  74.     beq.w   return_4C46
  75.  
  76. ; loc_4C40:
  77. LevelEnd_SetSignpost:
  78.     move.w  #1,(Level_Has_Signpost).w   ; set level type to signpost
  79.  
  80. return_4C46:
  81.     rts                     ; Return to whatever code was running before this routine was run.
  82. ; End of function SetLevelEndType
  83.  
  84. ; level size and start location
  85. ; sub_BFBC:
  86. LevelSizeLoad:
  87.     clr.w   ($FFFFEE50).w
  88.     clr.w   ($FFFFEE52).w
  89.     clr.w   ($FFFFEE54).w
  90.     clr.w   ($FFFFEE56).w
  91.     clr.w   ($FFFFEE58).w
  92.     clr.w   ($FFFFEE5A).w
  93.     clr.w   ($FFFFEE5C).w
  94.     clr.w   ($FFFFEE5E).w
  95.     clr.w   ($FFFFEEA0).w
  96.     clr.w   ($FFFFEEA2).w
  97.     clr.w   ($FFFFEEA4).w
  98.     clr.w   ($FFFFEEA6).w
  99.     clr.w   ($FFFFEEA8).w
  100.     clr.w   ($FFFFEEAA).w
  101.     clr.w   ($FFFFEEAC).w
  102.     clr.w   ($FFFFEEAE).w
  103.     clr.b   ($FFFFEEDC).w
  104.     clr.b   ($FFFFEEBC).w
  105.     clr.b   ($FFFFEEBD).w
  106.     clr.b   ($FFFFEEBE).w
  107.     clr.b   ($FFFFEEBF).w
  108.     moveq   #0,d0
  109.     move.b  d0,(Dynamic_Resize_Routine).w   ; Prepare to load the level boundaries by resetting the dynamic resize routine.
  110.     move.w  (Current_ZoneAndAct).w,d0
  111.     lsl.b   #6,d0
  112.     lsr.w   #4,d0
  113.     add.w   d0,d0
  114.     lea WrdArr_LvlSize(pc,d0.w),a0
  115.     move.l  (a0)+,d0
  116.     move.l  d0,(Camera_Min_X_pos).w
  117.     move.l  d0,($FFFFEEC0).w        ; unused besides this one write...
  118.     move.l  d0,(Tails_Min_X_pos).w
  119.     move.l  (a0)+,d0
  120.     move.l  d0,(Camera_Min_Y_pos).w
  121.     move.l  d0,($FFFFEEC4).w        ; unused besides this one write...
  122.     move.l  d0,($FFFFEEFC).w
  123.     move.w  #$1010,($FFFFEE40).w
  124.     move.w  #$60,(Camera_Y_pos_bias).w
  125.     move.w  #$60,(Camera_Y_pos_bias_2P).w
  126.     bra.w   loc_C164
  127. ; ===========================================================================
  128. ; ----------------------------------------------------------------------------
  129. ; LEVEL SIZE ARRAY
  130.  
  131. ; This array defines the screen boundaries for each act in the game.
  132. ; ----------------------------------------------------------------------------
  133. ;       xstart  xend    ystart  yend    ; Zone ID   ; Zone
  134. WrdArr_LvlSize:
  135.     dc.w    $0, $2600$80,    $720    ; $00       ; Frosty Dusk Zone Act 1.
  136.     dc.w    $0, $1980$80,    $720            ; Frosty Dusk Zone Act 2.
  137.     dc.w    $0, $3FFF$0, $720    ; $01
  138.     dc.w    $0, $3FFF$0, $720
  139.     dc.w    $0, $3FFF$0, $720    ; $02
  140.     dc.w    $0, $3FFF$0, $720
  141.     dc.w    $0, $3FFF$0, $720    ; $03
  142.     dc.w    $0, $3FFF$0, $720
  143.     dc.w    $0, $2280-$100$800    ; $04 ; MTZ act 1
  144.     dc.w    $0, $1E80-$100$800        ; MTZ act 2
  145.     dc.w    $0, $2A80-$100$800    ; $05 ; MTZ act 3
  146.     dc.w    $0, $3FFF-$100$800
  147.     dc.w    $0, $3FFF$0, $720    ; $06 ; WFZ
  148.     dc.w    $0, $3FFF$0, $720
  149.     dc.w    $0, $2800$0, $720    ; $07 ; HTZ act 1
  150.     dc.w    $0, $3280$0, $720        ; HTZ act 2
  151.     dc.w    $0, $3FFF$0, $720    ; $08
  152.     dc.w    $0, $3FFF$0, $720
  153.     dc.w    $0, $3FFF$0, $720    ; $09
  154.     dc.w    $0, $3FFF$0, $720
  155.     dc.w    $0, $2F80$0, $680    ; $0A ; OOZ act 1
  156.     dc.w    $0, $2D00$0, $680        ; OOZ act 2
  157.     dc.w    $0, $2380$3C0,   $720    ; $0B ; MCZ act 1
  158.     dc.w    $0, $3FFF$60,    $720        ; MCZ act 2
  159.     dc.w    $0, $27A0$0, $720    ; $0C ; CNZ act 1
  160.     dc.w    $0, $2A80$0, $720        ; CNZ act 2
  161.     dc.w    $0, $2780$0, $720    ; $0D ; CPZ act 1
  162.     dc.w    $0, $2A80$0, $720        ; CPZ act 2
  163.     dc.w    $0, $1000$C8,     $C8    ; $0F ; DEZ
  164.     dc.w    $0, $1000,  $C8,     $C8
  165.     dc.w    $0, $28C0$200,   $600    ; $10 ; ARZ act 1
  166.     dc.w    $0, $3FFF$180,   $710        ; ARZ act 2
  167.     dc.w    $0, $3FFF$0, $000    ; $11 ; SCZ
  168.     dc.w    $0, $3FFF$0, $720
  169.  
  170. ; ===========================================================================
  171.  
  172. loc_C164:
  173.     tst.b   (Last_star_pole_hit).w
  174.     beq.s   loc_C17A
  175.     jsr (Obj79_LoadData).l
  176.     move.w  (MainCharacter+x_pos).w,d1
  177.     move.w  (MainCharacter+y_pos).w,d0
  178.     bra.s   loc_C196
  179. ; ===========================================================================
  180.  
  181. loc_C17A:
  182.     move.w  (Current_ZoneAndAct).w,d0
  183.     lsl.b   #6,d0
  184.     lsr.w   #4,d0
  185.     lea WrdArr_StartLoc(pc,d0.w),a1
  186.     moveq   #0,d1
  187.     move.w  (a1)+,d1
  188.     move.w  d1,(MainCharacter+x_pos).w
  189.     moveq   #0,d0
  190.     move.w  (a1),d0
  191.     move.w  d0,(MainCharacter+y_pos).w
  192.  
  193. loc_C196:
  194.     subi.w  #$A0,d1
  195.     bcc.s   loc_C19E
  196.     moveq   #0,d1
  197.  
  198. loc_C19E:
  199.     move.w  (Camera_Max_X_pos).w,d2
  200.     cmp.w   d2,d1
  201.     bcs.s   loc_C1A8
  202.     move.w  d2,d1
  203.  
  204. loc_C1A8:
  205.     move.w  d1,(Camera_X_pos).w
  206.     move.w  d1,($FFFFEE20).w
  207.     subi.w  #$60,d0
  208.     bcc.s   loc_C1B8
  209.     moveq   #0,d0
  210.  
  211. loc_C1B8:
  212.     cmp.w   (Camera_Max_Y_pos_now).w,d0
  213.     blt.s   loc_C1C2
  214.     move.w  (Camera_Max_Y_pos_now).w,d0
  215.  
  216. loc_C1C2:
  217.     move.w  d0,(Camera_Y_pos).w
  218.     move.w  d0,($FFFFEE24).w
  219.     bsr.w   sub_C258
  220.     rts                     ; Return to whatever code was running before this routine was run.
  221. ; End of function LevelSizeLoad
  222.  
  223. ; ===========================================================================
  224. ; --------------------------------------------------------------------------------------
  225. ; CHARACTER START LOCATION ARRAY
  226.  
  227. ; 2 entries per act, corresponding to the X and Y locations that you want the player to
  228. ; appear at when the level starts.
  229. ; --------------------------------------------------------------------------------------
  230. WrdArr_StartLoc:
  231.     dc.w    $40,    $46C    ; $00
  232.     dc.w    $28,    $4EC
  233.     dc.w    $28,    $4EC    ; $01
  234.     dc.w    $60,    $2AF
  235.     dc.w    $60,    $1AC    ; $02
  236.     dc.w    $60,    $1AC
  237.     dc.w    $60,    $28F    ; $03
  238.     dc.w    $60,    $2AF
  239.     dc.w    $60,    $28C    ; $04
  240.     dc.w    $60,    $5EC
  241.     dc.w    $60,    $20C    ; $05
  242.     dc.w    $60,    $2AF
  243.     dc.w    $60,    $4CC    ; $06
  244.     dc.w    $1E0,   $4CC
  245.     dc.w    $60,    $3EF    ; $07
  246.     dc.w    $60,    $6AF
  247.     dc.w    $230,   $1AC    ; $08
  248.     dc.w    $230,   $1AC
  249.     dc.w    $60,    $28F    ; $09
  250.     dc.w    $60,    $2AF
  251.     dc.w    $60,    $6AC    ; $0A
  252.     dc.w    $60,    $56C
  253.     dc.w    $60,    $6AC    ; $0B
  254.     dc.w    $60,    $5AC
  255.     dc.w    $60,    $2AC    ; $0C
  256.     dc.w    $60,    $58C
  257.     dc.w    $60,    $1EC    ; $0D
  258.     dc.w    $60,    $12C
  259.     dc.w    $60,    $12D    ; $0E
  260.     dc.w    $60,    $12D
  261.     dc.w    $60,    $37E    ; $0F
  262.     dc.w    $60,    $37E
  263.     dc.w    $120,   $70 ; $10
  264.     dc.w    $140,   $70
  265.  
  266. ; level layout loading
  267. loadLevelLayout:
  268.     moveq   #0,d0           ; XREF: LevelLayoutLoad
  269.     move.w  (Current_ZoneAndAct).w,d0
  270.     lsl.b   #6,d0
  271.     lsr.w   #5,d0
  272.     lea (Off_Level).l,a0
  273.     move.w  (a0,d0.w),d0
  274.     lea (a0,d0.l),a0
  275.     lea (Level_Layout).w,a1
  276.     bra.w   JmpTo_KosDec
  277. ; End of function loadLevelLayout
  278.  
  279. ; level order stuff (after end-of-level results screen)
  280. loc_14270:
  281.     moveq   #0,d0
  282.     move.w  (Current_ZoneAndAct).w,d0
  283.     lsl.b   #6,d0
  284.     lsr.w   #4,d0
  285.     lea LevelOrder(pc),a1
  286.  
  287.     move.w  (a1,d0.w),d2
  288.     tst.w   d0
  289.     bpl.s   loc_1429C
  290.     move.b  #0,(Game_Mode).w    ; => SegaScreen
  291.     rts                     ; Return to whatever code was running before this routine was run.
  292.  
  293. ; ===========================================================================
  294. ; ---------------------------------------------------------------------------
  295. ; Main game level order
  296.  
  297. ; One value per act. That value is the level/act number of the level to load
  298. ; when that act finishes.
  299. ; ---------------------------------------------------------------------------
  300. ; word_142F8:
  301. LevelOrder:
  302.     dc.w     1  ; $0000 -> $0001    ; Frosty Dusk Zone Act 1 --> Frosty Dusk Zone Act 2
  303.     dc.w     2  ; $0001 -> $0002    ; Frosty Dusk Zone Act 2 --> Frosty Dusk Zone Act 3
  304.     dc.w $FFFF  ; $0002 -> SegaScreen   ; Frosty Dusk Zone Act 3 --> SEGA Screen for the time being
  305.     dc.w  $D00  ; $0003 -> $0D00    ; Frosty Dusk Zone Boss Act --> Corrosive Factory Zone Act 1
  306.     dc.w     0  ; $0100 -> $0000    ; Zone $01 Act 1 --> Frosty Dusk Zone Act 1
  307.     dc.w     0  ; $0101 -> $0000    ; Zone $01 Act 2 --> Frosty Dusk Zone Act 1
  308.     dc.w     0  ; $0102 -> $0000    ; Zone $01 Act 3 --> Frosty Dusk Zone Act 1
  309.     dc.w     0  ; $0103 -> $0000    ; Zone $01 Act 4 --> Frosty Dusk Zone Act 1
  310.     dc.w  $201  ; 4
  311.     dc.w  $400  ; 5
  312.     dc.w     0  ; 2
  313.     dc.w     0  ; 3
  314.     dc.w     0  ; 6
  315.     dc.w     0  ; 7
  316.     dc.w     0  ; 2
  317.     dc.w     0  ; 3
  318.     dc.w  $401  ; 8
  319.     dc.w  $500  ; 9
  320.     dc.w     0  ; 2
  321.     dc.w     0  ; 3
  322.     dc.w $1000  ; 10
  323.     dc.w     0  ; 11
  324.     dc.w     0  ; 2
  325.     dc.w     0  ; 3
  326.     dc.w  $E00  ; 12
  327.     dc.w     0  ; 13
  328.     dc.w     0  ; 2
  329.     dc.w     0  ; 3
  330.     dc.w  $701  ; 14
  331.     dc.w  $B00  ; 15
  332.     dc.w     0  ; 2
  333.     dc.w     0  ; 3
  334.     dc.w  $801  ; 16
  335.     dc.w  $A00  ; 17
  336.     dc.w     0  ; 2
  337.     dc.w     0  ; 3
  338.     dc.w     0  ; 18
  339.     dc.w     0  ; 19
  340.     dc.w     0  ; 2
  341.     dc.w     0  ; 3
  342.     dc.w  $A01  ; 20
  343.     dc.w  $400  ; 21
  344.     dc.w     0  ; 2
  345.     dc.w     0  ; 3
  346.     dc.w  $B01  ; 22
  347.     dc.w  $A00  ; 23
  348.     dc.w     0  ; 2
  349.     dc.w     0  ; 3
  350.     dc.w  $C01  ; 24
  351.     dc.w  $700  ; 25
  352.     dc.w     0  ; 2
  353.     dc.w     0  ; 3
  354.     dc.w  $D01  ; 26
  355.     dc.w  $F00  ; 27
  356.     dc.w     0  ; 2
  357.     dc.w     0  ; 3
  358.     dc.w $FFFF  ; 28
  359.     dc.w     0  ; 29
  360.     dc.w     0  ; 2
  361.     dc.w     0  ; 3
  362.     dc.w  $F01  ; 30
  363.     dc.w  $C00  ; 31
  364.     dc.w     0  ; 2
  365.     dc.w     0  ; 3
  366.     dc.w  $600  ; 32
  367.     dc.w     0  ; 33
  368.     dc.w     0  ; 2
  369.     dc.w     0  ; 3
  370.  
  371. ; rings manager setup (mind you, I've ported the S3K rings manager)
  372. RingsManager_Setup:
  373.     clearRAM Ring_Positions,Rings_Space
  374.     ; d0 = 0
  375.     lea ($FFFFEF80).w,a1
  376.     move.w  #bytesToLcnt($80),d1
  377. -   move.l  d0,(a1)+
  378.     dbf d1,-
  379.  
  380.     moveq   #0,d5
  381.     moveq   #0,d0
  382.     move.w  (Current_ZoneAndAct).w,d0
  383.     lsl.b   #6,d0
  384.     lsr.w   #5,d0
  385.     lea (Off_Rings).l,a1
  386.     move.w  (a1,d0.w),d0
  387.     lea (a1,d0.w),a1
  388.     move.l  a1,(Ring_start_addr_ROM).w
  389.     addq.w  #4,a1
  390.     moveq   #0,d5
  391.     move.w  #(Max_Rings-1),d0  
  392. -
  393.     tst.l   (a1)+
  394.     bmi.s   +
  395.     addq.w  #1,d5
  396.     dbf d0,-
  397. +
  398.     move.w  d5,(Perfect_rings_left).w
  399.     move.w  #0,($FFFFFF42).w    ; no idea what this is
  400.     rts                     ; Return to whatever code was running before this routine was run.
  401.  
  402. ; object layout loading
  403. loc_17AB8:
  404.     addq.b  #2,(Obj_placement_routine).w
  405.     move.w  (Current_ZoneAndAct).w,d0
  406.     lsl.b   #6,d0
  407.     lsr.w   #5,d0
  408.     lea (Off_Objects).l,a0  ; Next, load the first pointer in the object layout list pointer index.
  409.     movea.l a0,a1           ; Now copy it for quicker use later.
  410.     adda.w  (a0,d0.w),a0        ; (Point1 * 2) + $0002
  411.     move.l  a0,(Obj_load_addr_0).w  ; set object placement list
  412.     move.l  a0,(Obj_load_addr_1).w
  413.     move.l  a0,(Obj_load_addr_2).w
  414.     move.l  a0,(Obj_load_addr_3).w
  415.     lea (Object_Respawn_Table).w,a2 ; load respawn list
  416.     move.w  #$101,(a2)+ ; $01 $01
  417.     move.w  #$5E,d0     ; set loop counter
Advertisement