Advertisement
Mastigophoran

MastiDS.avs rev 4

Oct 9th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Avisynth 36.23 KB | None | 0 0
  1. # A collection of avisynth functions to help people animate and position DS screens in an approximate widescreen space.
  2. # It's designed with the idea of working with a 1280x768 area, as this is 5 DS screens wide and 4 DS screens tall,
  3. # allowing you to fit them in in a variety of patterns.
  4. # It's designed to work with the output from DeSmuME, with the 2 256x192 stacked on top of each other
  5. # This was initially thrown together for the Something Awful forums by forums user Mastigophoran
  6. # Got some ideas of stuff to add for R3 from Admiral H. Curtiss, and Captain Flame Guy, and the Tech Support Crowd helped a bit too
  7. # More stuff for R4 from YamiNoSenshi. Thanks YamiNoSenshi!
  8.  
  9. # Temporary Readme can be found here:       http://lpix.org/sslptest/index.php?id=10443
  10.  
  11. # Changelog:
  12.  
  13. # Revision 2:
  14. # Done: Have some way to have frame A drawn before frame B, should be pretty easy to do with an eval/default values
  15. # Nope: Probably add some more examples?
  16. # Done: Make a function to set the variables yourself and then call functions to perform them
  17. # Done: Make some functions that make it easier to perform eg Fades/Dissolves without desyncing the two videos
  18.  
  19. # Revision 3:  (# NB: original Rev 3 has typo, was line 322, has -MDS_QSzY instead of -MDS_QSzX )
  20. # Done: Fixed some stupid bugs with TopO and BottomO
  21. # Done: Added in automated better sizing below 1x scale
  22. # Done: Add 4th param to most 3 param calls to 'undo'
  23. # Done: FlipFlop function?
  24. # Done: Create functions that allow you to change additional filters
  25. # Done: Add in functions for help with custom transitions
  26.  
  27. # Revions 4:
  28. # Done: Added Vertical Mode, just call MDS_SetVerticalMode() And use MDS_SideWays or MDS_SideWaysGap! Technically works with everything else but uses a 3x multiple - use after SetParams
  29. # Done: Added transition effect to go from VertStack to... Vertstack rotated on its side? You probably want to call MDS_SideWaysA afterwards. -
  30. #   MDS_VStackToRotated and MDS_RotatedToVStack. They have an optional param to select which way to rotate which will be remembered across multiple calls.
  31. # Done: Added 'step' params to resize and positioning function, in case this is useful for more advanced functions. Will just be an integer from 0 to 29.
  32. # Done: Fixed resize methods for immediate function to match those used in animated (relevant to lower res videos)
  33. # Done: Changed the way MDS_AnimFunc and MDS_PositionFunc get called, now they let you change the core animation that's at work, which lets you actually accomplish things by changing them, unlike previous attempts.
  34. # Done: Added MDS_DraftSettings and MDS_SmoothSettings, which are some presets for blockpreserve and resize filters so that people who don't actually want
  35. #   to know every detail of this stupid overengineered system can get smoother (but slower to process) results
  36.  
  37. global MDS_LastFrame = 0
  38. global MDS_DrawBFirst = false
  39.  
  40. global AFC = 30 #animation frame count
  41.  
  42. global MDS_AnimResizeFilter = "PointResize"
  43. # These are used when we resize the videos up above 1x or down below 1x
  44. global MDS_FinalResizeUp = "PointResize"
  45. global MDS_FinalResizeDown = "Spline36Resize"
  46.  
  47. global MDS_PositionAnimFunc = "MDS_AnimPosition"
  48. global MDS_PositionOngoingFunc = "MDS_PositionNonAnim"
  49. global MDS_ResizeOngoingFunc = "MDS_ResizeNonAnim"
  50.  
  51. #This is the filter that will be called (the params you have access to are called c, the clip, and val, an angle in degrees
  52. global MDS_RotationPluginCall = "zoom(c,angle = string(val))"
  53.  
  54. # This is the function that is called to resize the vidoes in the regular functions
  55. # If you wanted to, you could change this to something else
  56. global MDS_AnimFunc = "MDS_AnimResizeCore"
  57. global MDS_PositionFunc = "MDS_PositionCore"    #A main manager function for things in general, calls the animation and non animated position methods
  58.  
  59. global MDS_GetTopFunc = "intMDS_GetTop"
  60. global MDS_GetBotFunc = "intMDS_GetBot"
  61.  
  62. # This int will pixel double (well, multiply by MDS_BlockPreserve) inputs before applying the resize to them, in an attempt to preserve blockiness when using a better filter
  63. global MDS_BlockPreserve = 0
  64.  
  65. # These are the base sizes for the input panes
  66. global MDS_basesizeX = 256
  67. global MDS_basesizeY = 192
  68.  
  69. global MDS_MaxX = 1280
  70. global MDS_MaxY = 768
  71. global MDS_SzX = 1024
  72. global MDS_SzY = 768
  73. global MDS_QSzX = 256
  74. global MDS_QSzY = 192
  75. global MDS_SBSX = 512
  76. global MDS_SBSY = 384
  77.  
  78. global MDS_Border = 128
  79.  
  80. # These values are used to keep track of where we last put the video, and where we want to put it next
  81. global LastTopPosX = 0
  82. global LastTopPosY = 0
  83. global LastTopSizeX = 256
  84. global LastTopSizeY = 192
  85. global LastBotPosX = 0
  86. global LastBotPosY = 192
  87. global LastBotSizeX = 256
  88. global LastBotSizeY = 192
  89.  
  90. global newTSX = 0
  91. global newTSY = 0
  92. global newBSX = 256
  93. global newBSY = 192
  94. global newTPX = 0
  95. global newTPY = 192
  96. global newBPX = 256
  97. global newBPY = 192
  98.  
  99. global MDS_MemTSX = LastTopSizeX
  100. global MDS_MemTSY = LastTopSizeY
  101. global MDS_MemBSX = LastBotSizeX
  102. global MDS_MemBSY = LastBotSizeY
  103.  
  104. global MDS_MemTPX = LastTopPosX
  105. global MDS_MemTPY = LastTopPosY
  106. global MDS_MemBPX = LastBotPosX
  107. global MDS_MemBPY = LastBotPosY
  108.  
  109. global MDS_RotatedToRight = false
  110. global MDS_VertStackGapGap = 92
  111. global MDS_SidewaysGapGap = 92
  112. global MDS_OneTimeUseDown = false
  113.  
  114. #And this just makes our video return something if we accidently view it
  115. BlankClip(length=240, width=640, height=480, pixel_type="RGB32", fps=24, fps_denominator=1, audio_rate=44100, stereo=False, sixteen_bit=True, color=$000000)
  116. Subtitle("This is MastiDS.avs! Import this script into your AVS!")
  117. Subtitle("Also, load your avi after you import, because this clip returned by the import line!",y = 50)
  118.  
  119. function MDS_SetAFC(int newAFC)
  120. {
  121.     global AFC = newAFC
  122. }
  123.  
  124. function MDS_SetParams(int "pMaxX", int "pMaxY", int "pSzX", int "pSzY", int "pQSzX", int "pQSzY", int "pSBSX", int "pSBSY")
  125. {
  126.     global MDS_MaxX = Default(pMaxX,MDS_MaxX)
  127.     global MDS_MaxY = Default(pMaxY,MDS_MaxY)
  128.     global MDS_SzX = Default(pSzX,MDS_SzX)
  129.     global MDS_SzY = Default(pSzY,MDS_SzY)
  130.     global MDS_QSzX = Default(pQSzX,floor(MDS_SzX / 4))
  131.     global MDS_QSzY = Default(pQSzY,floor(MDS_SzY / 4))
  132.     global MDS_SBSX = Default(pSBSX,floor(MDS_SzX / 2))
  133.     global MDS_SBSY = Default(pSBSY,floor(MDS_SzY / 2))
  134.    
  135.     global MDS_Border = floor((MDS_MaxX - MDS_SzX) / 2)
  136. }
  137.  
  138. function MDS_SetDefaultParams()
  139. {
  140.     MDS_SetParams(1280,768,1024,768)
  141. }
  142.  
  143. function MDS_SetHalfSizeParams()
  144. {
  145.     MDS_SetParams(640,384,512,384)
  146. }
  147.  
  148. function MDS_SetVertHalfSizeParams()
  149. {
  150.     MDS_SetParams(852,512,384,512)
  151. }
  152.  
  153. function MDS_Set169WideScreen()
  154. {
  155.     MDS_SetParams(1364,768,1024,768)    # needs to be multiple of 4 for Yuv
  156. }
  157.  
  158. function MDS_SetHorizontalMode(bool "NoParamChange")
  159. {
  160.     MDS_ChangeCropWorkers("intMDS_GetTop","intMDS_GetBot")
  161.     NoParamChange = Default(NoParamChange,FALSE)
  162.     l = (NoParamChange == FALSE) ? MDS_SetParams(pSzX = floor(4 * (MDS_SzY / 3))) : 0
  163. }
  164. function MDS_SetVerticalMode(bool "RotateToRight", bool "NoParamChange")
  165. {
  166.     MDS_ChangeCropWorkers("intMDS_GetVertTop","intMDS_GetVertBot")
  167.     NoParamChange = Default(NoParamChange,FALSE)
  168.     l = (NoParamChange == FALSE) ? MDS_SetParams(pSzX = floor(3 * (MDS_SzY / 4))) : 0
  169. }
  170.  
  171. function MDS_DraftSettings()
  172. {
  173.     global MDS_VertStackGapGap = (MDS_VertStackGapGap == -92) ? -92 : 92
  174.     global MDS_SidewaysGapGap = (MDS_SidewaysGapGap == -92) ? -92 : 92
  175.     MDS_SetBlockPreserve(0)
  176.     global MDS_AnimResizeFilter = "PointResize"
  177.     global MDS_FinalResizeUp = "PointResize"
  178.     global MDS_FinalResizeDown = "Spline36Resize"
  179. }
  180. function MDS_SmoothSettings()
  181. {
  182.     global MDS_VertStackGapGap = (MDS_VertStackGapGap == 92) ? -92 : 92
  183.     global MDS_SidewaysGapGap = (MDS_SidewaysGapGap == 92) ? -92 : 92
  184.     MDS_SetBlockPreserve(4)
  185.     global MDS_AnimResizeFilter = "Spline36Resize"
  186.     global MDS_FinalResizeUp = "PointResize"
  187.     global MDS_FinalResizeDown = "Spline36Resize"
  188. }
  189.  
  190. function MDS_ResetLastframe()
  191. {
  192.     global MDS_LastFrame = 0
  193. }
  194.  
  195. function MDS_ChangeResizeFilter(string FilterName)
  196. {
  197.     global MDS_AnimResizeFilter = FilterName
  198. }
  199.  
  200. function MDS_TopOnTop(bool Bfirst)
  201. {
  202.     global MDS_DrawBFirst = Bfirst
  203. }
  204.  
  205. function MDS_SetBlockPreserve(int Factor)
  206. {
  207.     global MDS_BlockPreserve = Factor
  208. }
  209.  
  210. function MDS_SetFinalResizeMethods(string "OneXorMore", string "BelowOneX")
  211. {
  212.     global MDS_FinalResizeUp = Default(OneXorMore,MDS_FinalResizeUp)
  213.     global MDS_FinalResizeDown = Default(BelowOneX,MDS_FinalResizeDown)
  214. }
  215.  
  216. function MDS_SetFinalPositionMethods(string OngoingFunctionName)
  217. {
  218.     global MDS_PositionOngoingFunc = OngoingFunctionName
  219. }
  220.  
  221. function MDS_ChangeAnimationWorker(string FuncName)
  222. {
  223.     global MDS_AnimFunc = FuncName
  224. }
  225.  
  226. function MDS_ChangePositionWorker(string FuncName)
  227. {
  228.     global MDS_PositionFunc = FuncName
  229. }
  230. function MDS_ChangeCropWorkers(string "TopGetter", string "BotGetter")
  231. {
  232.     global MDS_GetTopFunc = Default(TopGetter,MDS_GetTopFunc)
  233.     global MDS_GetBotFunc = Default(BotGetter,MDS_GetBotFunc)
  234. }
  235.  
  236. function MDS_ChangeBaseSizes(int BaseX, int BaseY)
  237. {
  238.     global MDS_basesizeX = BaseX
  239.     global MDS_basesizeY = BaseY
  240. }
  241.  
  242. function MDS_ChangeAnimWorker(string "Worker")
  243. {
  244.     global MDS_RotationPluginCall = Default(Worker,"zoom(c,angle = string(val))")
  245. }
  246.  
  247. # Positioning functions begin:
  248.  
  249. function intMDS_SBS()
  250. {
  251.     global newTSX = MDS_SBSX
  252.     global newTSY = MDS_SBSY
  253.     global newBSX = MDS_SBSX
  254.     global newBSY = MDS_SBSY
  255.     global newTPX = MDS_Border
  256.     global newTPY = floor((MDS_SzY - MDS_SBSY) / 2)
  257.     global newBPX = MDS_Border + MDS_SBSX
  258.     global newBPY = floor((MDS_SzY - MDS_SBSY) / 2)
  259. }
  260. function MDS_SBS(clip raw)
  261. {
  262.     MDS_SameCode(raw,"intMDS_SBS")
  263. }
  264. function MDS_SBS(clip c, clip raw, int frame, int "frame2")
  265. {
  266.     MDS_SameCodeA(c,raw,"MDS_SBS",frame,frame2)
  267. }
  268. function MDS_SBSA(clip raw)
  269. {
  270.     MDS_SameCodeA(raw,"intMDS_SBS")
  271. }
  272. function MDS_SBSA(clip c, clip raw, int frame, int "frame2")
  273. {
  274.     MDS_SameCodeA(c,raw,"MDS_SBSA",frame,frame2)
  275. }
  276.  
  277. function intMDS_SBSL()
  278. {
  279.     global newTSX = floor(MDS_SBSX * 1.5)
  280.     global newTSY = floor(MDS_SBSY * 1.5)
  281.     global newBSX = MDS_SBSX
  282.     global newBSY = MDS_SBSY
  283.     global newTPX = 0
  284.     global newTPY = floor((MDS_SzY - (MDS_SBSY * 1.5)) / 2)
  285.     global newBPX = floor(MDS_SBSX * 1.5)
  286.     global newBPY = floor((MDS_SzY - MDS_SBSY) / 2)
  287. }
  288. function MDS_SBSL(clip raw)
  289. {
  290.     MDS_SameCode(raw,"intMDS_SBSL")
  291. }
  292. function MDS_SBSL(clip c, clip raw, int frame, int "frame2")
  293. {
  294.     MDS_SameCodeA(c,raw,"MDS_SBSL",frame,frame2)
  295. }
  296. function MDS_SBSLA(clip raw)
  297. {
  298.     MDS_SameCodeA(raw,"intMDS_SBSL")
  299. }
  300. function MDS_SBSLA(clip c, clip raw, int frame, int "frame2")
  301. {
  302.     MDS_SameCodeA(c,raw,"MDS_SBSLA",frame,frame2)
  303. }
  304.  
  305. function intMDS_SBSR()
  306. {
  307.     global newTSX = MDS_SBSX
  308.     global newTSY = MDS_SBSY
  309.     global newBSX = floor(MDS_SBSX * 1.5)
  310.     global newBSY = floor(MDS_SBSY * 1.5)
  311.     global newTPX = 0
  312.     global newTPY = floor((MDS_SzY - MDS_SBSY) / 2)
  313.     global newBPX = MDS_SBSX
  314.     global newBPY = floor((MDS_SzY - (MDS_SBSY * 1.5)) / 2)
  315. }
  316. function MDS_SBSR(clip raw)
  317. {
  318.     MDS_SameCode(raw,"intMDS_SBSR")
  319. }
  320. function MDS_SBSR(clip c, clip raw, int frame, int "frame2")
  321. {
  322.     MDS_SameCodeA(c,raw,"MDS_SBSR",frame,frame2)
  323. }
  324. function MDS_SBSRA(clip raw)
  325. {
  326.     MDS_SameCodeA(raw,"intMDS_SBSR")
  327. }
  328. function MDS_SBSRA(clip c, clip raw, int frame, int "frame2")
  329. {
  330.     MDS_SameCodeA(c,raw,"MDS_SBSRA",frame,frame2)
  331. }
  332.  
  333. function intMDS_Top()
  334. {
  335.     global newTSX = MDS_SzX
  336.     global newTSY = MDS_SzY
  337.     global newBSX = MDS_QSzX
  338.     global newBSY = MDS_QSzY
  339.     global newTPX = 0
  340.     global newTPY = 0
  341.     global newBPX = MDS_SzX
  342.     global newBPY = MDS_SzY - MDS_QSzY
  343. }
  344. function MDS_Top(clip raw)
  345. {
  346.     MDS_SameCode(raw,"intMDS_Top")
  347. }
  348. function MDS_Top(clip c, clip raw, int frame, int "frame2")
  349. {
  350.     MDS_SameCodeA(c,raw,"MDS_Top",frame,frame2)
  351. }
  352. function MDS_TopA(clip raw)
  353. {
  354.     MDS_SameCodeA(raw,"intMDS_Top")
  355. }
  356. function MDS_TopA(clip c, clip raw, int frame, int "frame2")
  357. {
  358.     MDS_SameCodeA(c,raw,"MDS_TopA",frame,frame2)
  359. }
  360.  
  361.  
  362. function intMDS_TopO()
  363. {
  364.     global newTSX = MDS_SzX
  365.     global newTSY = MDS_SzY
  366.     global newBSX = MDS_QSzX
  367.     global newBSY = MDS_QSzY
  368.     global newTPX = MDS_Border
  369.     global newTPY = 0
  370.     global newBPX = MDS_MaxX
  371.     global newBPY = MDS_SzY - MDS_QSzY
  372. }
  373. function MDS_TopO(clip raw)
  374. {
  375.     MDS_SameCode(raw,"intMDS_TopO")
  376. }
  377. function MDS_TopO(clip c, clip raw, int frame, int "frame2")
  378. {
  379.     MDS_SameCodeA(c,raw,"MDS_TopO",frame,frame2)
  380. }
  381. function MDS_TopOA(clip raw)
  382. {
  383.     MDS_SameCodeA(raw,"intMDS_TopO")
  384. }
  385. function MDS_TopOA(clip c, clip raw, int frame, int "frame2")
  386. {
  387.     MDS_SameCodeA(c,raw,"MDS_TopOA",frame,frame2)
  388. }
  389.  
  390. function intMDS_BotO()
  391. {
  392.     global newTSX = MDS_QSzX
  393.     global newTSY = MDS_QSzY
  394.     global newBSX = MDS_SzX
  395.     global newBSY = MDS_SzY
  396.     global newTPX = -MDS_QSzX
  397.     global newTPY = 0
  398.     global newBPX = MDS_Border
  399.     global newBPY = 0
  400. }
  401. function MDS_BotO(clip raw)
  402. {
  403.     MDS_SameCode(raw,"intMDS_BotO")
  404. }
  405. function MDS_BotO(clip c, clip raw, int frame, int "frame2")
  406. {
  407.     MDS_SameCodeA(c,raw,"MDS_BotO",frame,frame2)
  408. }
  409. function MDS_BotOA(clip raw)
  410. {
  411.     MDS_SameCodeA(raw,"intMDS_BotO")
  412. }
  413. function MDS_BotOA(clip c, clip raw, int frame, int "frame2")
  414. {
  415.     MDS_SameCodeA(c,raw,"MDS_BotOA",frame,frame2)
  416. }
  417.  
  418.  
  419. function intMDS_Bot()
  420. {
  421.     global newTSX = MDS_QSzX
  422.     global newTSY = MDS_QSzY
  423.     global newBSX = MDS_SzX
  424.     global newBSY = MDS_SzY
  425.     global newTPX = 0
  426.     global newTPY = 0
  427.     global newBPX = MDS_QSzX
  428.     global newBPY = 0
  429. }
  430. function MDS_Bot(clip raw)
  431. {
  432.     MDS_SameCode(raw,"intMDS_Bot")
  433. }
  434. function MDS_Bot(clip c, clip raw, int frame, int "frame2")
  435. {
  436.     MDS_SameCodeA(c,raw,"MDS_Bot",frame,frame2)
  437. }
  438. function MDS_BotA(clip raw)
  439. {
  440.     MDS_SameCodeA(raw,"intMDS_Bot")
  441. }
  442. function MDS_BotA(clip c, clip raw, int frame, int "frame2")
  443. {
  444.     MDS_SameCodeA(c,raw,"MDS_BotA",frame,frame2)
  445. }
  446.  
  447. function intMDS_TopHSlide()
  448. {
  449.     global newTSX = MDS_SzX
  450.     global newTSY = MDS_SzY
  451.     global newBSX = MDS_SzX
  452.     global newBSY = MDS_SzY
  453.     global newTPX = MDS_Border
  454.     global newTPY = 0
  455.     global newBPX = MDS_SzX + MDS_Border
  456.     global newBPY = 0
  457. }
  458. function MDS_TopHSlide(clip raw)
  459. {
  460.     MDS_SameCode(raw,"intMDS_TopHSlide")
  461. }
  462. function MDS_TopHSlide(clip c, clip raw, int frame, int "frame2")
  463. {
  464.     MDS_SameCodeA(c,raw,"MDS_TopHSlide",frame,frame2)
  465. }
  466. function MDS_TopHSlideA(clip raw)
  467. {
  468.     MDS_SameCodeA(raw,"intMDS_TopHSlide")
  469. }
  470. function MDS_TopHSlideA(clip c, clip raw, int frame, int "frame2")
  471. {
  472.     MDS_SameCodeA(c,raw,"MDS_TopHSlideA",frame,frame2)
  473. }
  474.  
  475. function intMDS_BotHSlide()
  476. {
  477.     global newTSX = MDS_SzX
  478.     global newTSY = MDS_SzY
  479.     global newBSX = MDS_SzX
  480.     global newBSY = MDS_SzY
  481.     global newTPX = -MDS_SzX + MDS_Border
  482.     global newTPY = 0
  483.     global newBPX = MDS_Border
  484.     global newBPY = 0
  485. }
  486. function MDS_BotHSlide(clip raw)
  487. {
  488.     MDS_SameCode(raw,"intMDS_BotHSlide")
  489. }
  490. function MDS_BotHSlide(clip c, clip raw, int frame, int "frame2")
  491. {
  492.     MDS_SameCodeA(c,raw,"MDS_BotHSlide",frame,frame2)
  493. }
  494. function MDS_BotHSlideA(clip raw)
  495. {
  496.     MDS_SameCodeA(raw,"intMDS_BotHSlide")
  497. }
  498. function MDS_BotHSlideA(clip c, clip raw, int frame, int "frame2")
  499. {
  500.     MDS_SameCodeA(c,raw,"MDS_BotHSlideA",frame,frame2)
  501. }
  502.  
  503. function intMDS_TopVSlide()
  504. {
  505.     global newTSX = MDS_SzX
  506.     global newTSY = MDS_SzY
  507.     global newBSX = MDS_SzX
  508.     global newBSY = MDS_SzY
  509.     global newTPX = MDS_Border
  510.     global newTPY = 0
  511.     global newBPX = MDS_Border
  512.     global newBPY = MDS_SzY
  513. }
  514. function MDS_TopVSlide(clip raw)
  515. {
  516.     MDS_SameCode(raw,"intMDS_TopVSlide")
  517. }
  518. function MDS_TopVSlide(clip c, clip raw, int frame, int "frame2")
  519. {
  520.     MDS_SameCodeA(c,raw,"MDS_TopVSlide",frame,frame2)
  521. }
  522. function MDS_TopVSlideA(clip raw)
  523. {
  524.     MDS_SameCodeA(raw,"intMDS_TopVSlide")
  525. }
  526. function MDS_TopVSlideA(clip c, clip raw, int frame, int "frame2")
  527. {
  528.     MDS_SameCodeA(c,raw,"MDS_TopVSlideA",frame,frame2)
  529. }
  530.  
  531. function intMDS_BotVSlide()
  532. {
  533.     global newTSX = MDS_SzX
  534.     global newTSY = MDS_SzY
  535.     global newBSX = MDS_SzX
  536.     global newBSY = MDS_SzY
  537.     global newTPX = MDS_Border
  538.     global newTPY = -MDS_SzY
  539.     global newBPX = MDS_Border
  540.     global newBPY = 0
  541. }
  542. function MDS_BotVSlide(clip raw)
  543. {
  544.     MDS_SameCode(raw,"intMDS_BotVSlide")
  545. }
  546. function MDS_BotVSlide(clip c, clip raw, int frame, int "frame2")
  547. {
  548.     MDS_SameCodeA(c,raw,"MDS_BotVSlide",frame,frame2)
  549. }
  550. function MDS_BotVSlideA(clip raw)
  551. {
  552.     MDS_SameCodeA(raw,"intMDS_BotVSlide")
  553. }
  554. function MDS_BotVSlideA(clip c, clip raw, int frame, int "frame2")
  555. {
  556.     MDS_SameCodeA(c,raw,"MDS_BotVSlideA",frame,frame2)
  557. }
  558.  
  559. function intMDS_VertStack()
  560. {
  561.     global newTSX = MDS_SBSX
  562.     global newTSY = MDS_SBSY
  563.     global newBSX = MDS_SBSX
  564.     global newBSY = MDS_SBSY
  565.     global newTPX = MDS_Border + floor((MDS_SzX - MDS_SBSX) / 2)
  566.     global newTPY = 0
  567.     global newBPX = MDS_Border + floor((MDS_SzX - MDS_SBSX) / 2)
  568.     global newBPY = MDS_SBSY
  569. }
  570. function MDS_VertStack(clip raw)
  571. {
  572.     MDS_SameCode(raw,"intMDS_VertStack")
  573. }
  574. function MDS_VertStack(clip c, clip raw, int frame, int "frame2")
  575. {
  576.     MDS_SameCodeA(c,raw,"MDS_VertStack",frame,frame2)
  577. }
  578. function MDS_VertStackA(clip raw)
  579. {
  580.     MDS_SameCodeA(raw,"intMDS_VertStack")
  581. }
  582. function MDS_VertStackA(clip c, clip raw, int frame, int "frame2")
  583. {
  584.     MDS_SameCodeA(c,raw,"MDS_VertStackA",frame,frame2)
  585. }
  586.  
  587. function intMDS_VertStackGap()
  588. {
  589.     # This is adapted from a function from YamiNoSenshi
  590.     # ps this whole weird - business is about using a nice filter for the final resize
  591.     global MDS_OneTimeUseDown = (LeftStr(string(MDS_VertStackGapGap),1) == "-") ? true : false
  592.    
  593.     TempGap = (MDS_VertStackGapGap >= 0) ? MDS_VertStackGapGap : -MDS_VertStackGapGap
  594.    
  595.     totallines = MDS_BaseSizeY * 2 + TempGap
  596.    
  597.     ratio = float(MDS_BaseSizeY) / float(totallines)
  598.    
  599.     NewX = floor(MDS_SzX * ratio)
  600.     NewY = floor(MDS_SzY * ratio)
  601.    
  602.     global newTSX = NewX
  603.     global newTSY = NewY
  604.     global newBSX = NewX
  605.     global newBSY = NewY
  606.     global newTPX = MDS_Border + floor((MDS_SzX - NewX) / 2)
  607.     global newTPY = 0
  608.     global newBPX = MDS_Border + floor((MDS_SzX - NewX) / 2)
  609.     global newBPY = MDS_MaxY - NewY
  610. }
  611. function MDS_VertStackGap(clip raw, string "gap")
  612. {
  613.     gap = default(gap,string(MDS_VertStackGapGap))
  614.     global MDS_VertStackGapGap = Value(gap)
  615.     MDS_SameCode(raw,"intMDS_VertStackGap")
  616. }
  617. function MDS_VertStackGap(clip c, clip raw, int frame, int "frame2", string "gap")
  618. {
  619.     gap = default(gap,string(MDS_VertStackGapGap))
  620.     global MDS_VertStackGapGap = Value(gap)
  621.     MDS_SameCodeA(c,raw,"MDS_VertStackGap",frame,frame2)
  622. }
  623. function MDS_VertStackGapA(clip raw, string "gap")
  624. {
  625.     gap = default(gap,string(MDS_VertStackGapGap))
  626.     global MDS_VertStackGapGap = Value(gap)
  627.     MDS_SameCodeA(raw,"intMDS_VertStackGap")
  628. }
  629. function MDS_VertStackGapA(clip c, clip raw, int frame, int "frame2", string "gap")
  630. {
  631.     gap = default(gap,string(MDS_VertStackGapGap))
  632.     global MDS_VertStackGapGap = Value(gap)
  633.     MDS_SameCodeA(c,raw,"MDS_VertStackGapA",frame,frame2)
  634. }
  635.  
  636.  
  637. function intMDS_SideWays()
  638. {
  639.     ThreeHeight = MDS_SzY
  640.     ThreeWidth = floor(3 * (ThreeHeight / 4))
  641.     global newTSX = ThreeWidth
  642.     global newTSY = ThreeHeight
  643.     global newBSX = ThreeWidth
  644.     global newBSY = ThreeHeight
  645.     global newTPX = (MDS_MaxX / 2) - ThreeWidth
  646.     global newTPY = 0
  647.     global newBPX = (MDS_MaxX / 2)
  648.     global newBPY = 0
  649. }
  650. function MDS_SideWays(clip raw)
  651. {
  652.     MDS_SameCode(raw,"intMDS_SideWays")
  653. }
  654. function MDS_SideWays(clip c, clip raw, int frame, int "frame2")
  655. {
  656.     MDS_SameCodeA(c,raw,"MDS_SideWays",frame,frame2)
  657. }
  658. function MDS_SideWaysA(clip raw)
  659. {
  660.     MDS_SameCodeA(raw,"intMDS_SideWays")
  661. }
  662. function MDS_SideWaysA(clip c, clip raw, int frame, int "frame2")
  663. {
  664.     MDS_SameCodeA(c,raw,"MDS_SideWaysA",frame,frame2)
  665. }
  666.  
  667. function intMDS_SideWaysGap()
  668. {
  669.     # This is adapted from a function from YamiNoSenshi
  670.    
  671.     TempGap = (MDS_SidewaysGapGap >= 0) ? MDS_SidewaysGapGap : -MDS_SidewaysGapGap
  672.    
  673.     totallines = MDS_BaseSizeY * 2 + TempGap
  674.     ratio = float(MDS_BaseSizeY) / float(totallines)
  675.    
  676.     # So if gap is too small, this will accidently zoom into the content, so, if ratio * height > three height, just do it normally?
  677.        
  678.     ThreeHeight = MDS_SzY
  679.     ThreeWidth = floor(3 * (ThreeHeight / 4))
  680.    
  681.     NewX = floor(MDS_MaxX * ratio)
  682.     NewY = floor((NewX * 4) / 3)
  683.    
  684.     # If these would be oversized, don't zoom in
  685.     l = (NewY > MDS_MaxY) ? eval("""
  686.         ScaledGap = floor(float(TempGap) * (float(ThreeWidth) / float(MDS_BaseSizeY))) 
  687.         global newTSX = ThreeWidth
  688.         global newTSY = ThreeHeight
  689.         global newBSX = ThreeWidth
  690.         global newBSY = ThreeHeight
  691.         global newTPX = floor((MDS_MaxX - ScaledGap) / 2) - ThreeWidth
  692.         global newTPY = 0
  693.         global newBPX = floor((MDS_MaxX + ScaledGap) / 2)
  694.         global newBPY = 0
  695.     """) : eval ("""
  696.         # Otherwise scale them down
  697.         global MDS_OneTimeUseDown = (LeftStr(string(MDS_SidewaysGapGap),1) == "-") ? true : false
  698.        
  699.         global newTSX = NewX
  700.         global newTSY = NewY
  701.         global newBSX = NewX
  702.         global newBSY = NewY
  703.         global newTPX = 0
  704.         global newTPY = floor((MDS_MaxY - NewY) / 2)
  705.         global newBPX = MDS_MaxX - NewX
  706.         global newBPY = floor((MDS_MaxY - NewY) / 2)
  707.     """)
  708. }
  709. function MDS_SideWaysGap(clip raw, string "gap")
  710. {
  711.     gap = default(gap,string(MDS_SidewaysGapGap))
  712.     global MDS_SidewaysGapGap = Value(gap)
  713.     MDS_SameCode(raw,"intMDS_SideWaysGap")
  714. }
  715. function MDS_SideWaysGap(clip c, clip raw, int frame, int "frame2", string "gap")
  716. {
  717.     gap = default(gap,string(MDS_SidewaysGapGap))
  718.     global MDS_SidewaysGapGap = Value(gap)
  719.     MDS_SameCodeA(c,raw,"MDS_SideWaysGap",frame,frame2)
  720. }
  721. function MDS_SideWaysGapA(clip raw, string "gap")
  722. {
  723.     gap = default(gap,string(MDS_SidewaysGapGap))
  724.     global MDS_SidewaysGapGap = Value(gap)
  725.     MDS_SameCodeA(raw,"intMDS_SideWaysGap")
  726. }
  727. function MDS_SideWaysGapA(clip c, clip raw, int frame, int "frame2", string "gap")
  728. {
  729.     gap = default(gap,string(MDS_SidewaysGapGap))
  730.     global MDS_SidewaysGapGap = Value(gap)
  731.     MDS_SameCodeA(c,raw,"MDS_SideWaysGapA",frame,frame2)
  732. }
  733.  
  734. function intMDS_SideWaysCGap()
  735. {
  736.     ThreeHeight = MDS_SzY
  737.     ThreeWidth = floor(3 * (ThreeHeight / 4))
  738.     global newTSX = ThreeWidth
  739.     global newTSY = ThreeHeight
  740.     global newBSX = ThreeWidth
  741.     global newBSY = ThreeHeight
  742.     global newTPX = 0
  743.     global newTPY = 0
  744.     global newBPX = MDS_MaxX - ThreeWidth
  745.     global newBPY = 0
  746. }
  747. function MDS_SideWaysCGap(clip raw)
  748. {
  749.     MDS_SameCode(raw,"intMDS_SideWaysCGap")
  750. }
  751. function MDS_SideWaysCGap(clip c, clip raw, int frame, int "frame2")
  752. {
  753.     MDS_SameCodeA(c,raw,"MDS_SideWaysCGap",frame,frame2)
  754. }
  755. function MDS_SideWaysCGapA(clip raw)
  756. {
  757.     MDS_SameCodeA(raw,"intMDS_SideWaysCGap")
  758. }
  759. function MDS_SideWaysCGapA(clip c, clip raw, int frame, int "frame2")
  760. {
  761.     MDS_SameCodeA(c,raw,"MDS_SideWaysCGapA",frame,frame2)
  762. }
  763.  
  764. function intMDS_RotateEffectSub()
  765. {
  766.     FakeNewHeight = floor(4 * (MDS_SBSY / 3))
  767.     global newTSX = MDS_SBSY
  768.     global newTSY = FakeNewHeight
  769.     global newBSX = MDS_SBSY
  770.     global newBSY = FakeNewHeight  
  771.     global newTPX = floor(MDS_MaxX / 2) - MDS_SBSY
  772.     global newTPY = floor((MDS_MaxY - FakeNewHeight) / 2)
  773.     global newBPX = floor(MDS_MaxX / 2)
  774.     global newBPY = floor((MDS_MaxY - FakeNewHeight) / 2)
  775. }
  776. function MDS_RotateEffectSub(clip raw)
  777. {
  778.     MDS_SameCode(raw,"intMDS_RotateEffectSub")
  779. }
  780. function MDS_RotateEffectSub(clip c, clip raw, int frame, int "frame2")
  781. {
  782.     MDS_SameCodeA(c,raw,"MDS_RotateEffectSub",frame,frame2)
  783. }
  784. function MDS_RotateEffectSubA(clip raw)
  785. {
  786.     MDS_SameCodeA(raw,"intMDS_RotateEffectSub")
  787. }
  788. function MDS_RotateEffectSubA(clip c, clip raw, int frame, int "frame2")
  789. {
  790.     MDS_SameCodeA(c,raw,"MDS_RotateEffectSubA",frame,frame2)
  791. }
  792. function MDS_VStackToRotated(clip c, clip raw, int frame, bool "RightInstead")
  793. {
  794.     y = trim(c,frame,frame+AFC)
  795.     global MDS_RotatedToRight = Default(RightInstead,MDS_RotatedToRight)
  796.     direction = (MDS_RotatedToRight == FALSE) ? -90 : 90
  797.     r = trim(c,0,frame - 1) + Animate(y,0,AFC,"intMDS_RotationWrapper",0,direction)
  798.     MDS_SetVerticalMode()
  799.     intMDS_RotateEffectSub()
  800.     MDS_Custom(r,raw,frame + AFC)   # this is a problem!
  801.     # Is it a problem? It doesn't seem like a problem? Maybe this is old me commenting re not having frame2?
  802. }
  803. function MDS_RotatedToVStack(clip c, clip raw, int frame, int "RightInstead")
  804. {
  805.     y = trim(c,frame,frame+AFC)
  806.     global MDS_RotatedToRight = Default(RightInstead,MDS_RotatedToRight)
  807.     direction = (MDS_RotatedToRight == FALSE) ? 90 : -90
  808.     r = trim(c,0,frame - 1) + Animate(y,0,AFC,"intMDS_RotationWrapper",0,direction)
  809.     MDS_SetHorizontalMode()
  810.     intMDS_VertStack()
  811.     MDS_Custom(r,raw,frame + AFC)
  812. }
  813. function intMDS_RotationWrapper(clip c, int val)
  814. {
  815.     try
  816.     {
  817.     eval (MDS_RotationPluginCall)
  818.     }
  819.     catch (err_msg) {
  820.         Assert(0 == 1, """Couldn't perform Zoom? You need to get the Zoom plugin from the avisynth website, or use MDS_ChangeAnimWorker("your filter call here")
  821. """ + err_msg)
  822.     }
  823. }
  824.  
  825. function MDS_Custom_TargetData(int TSX,int TSY,int BSX, int BSY, int TPX, int TPY, int BPX, int BPY)
  826. {
  827.     global newTSX = TSX
  828.     global newTSY = TSY
  829.     global newBSX = BSX
  830.     global newBSY = BSY
  831.     global newTPX = TPX
  832.     global newTPY = TPY
  833.     global newBPX = BPX
  834.     global newBPY = BPY
  835. }
  836. function MDS_Custom(clip raw)
  837. {
  838.     MDS_ExceptionCheck(raw)
  839.     MDS_UpdateGlobals()
  840.     MDS_DoDSImmediate(raw)
  841. }
  842. function MDS_Custom(clip c, clip raw, int frame, int "frame2")
  843. {
  844.     MDS_SameCodeA(c,raw,"MDS_Custom",frame,frame2)
  845. }
  846. function MDS_CustomA(clip raw)
  847. {
  848.     MDS_ExceptionCheck(raw)
  849.     final = MDS_DoDSAnimate(raw)
  850.     MDS_UpdateGlobals()
  851.     return final
  852. }
  853. function MDS_CustomA(clip c, clip raw, int frame, int "frame2")
  854. {
  855.     MDS_SameCodeA(c,raw,"MDS_CustomA",frame,frame2)
  856. }
  857.  
  858. function MDS_Dissolve(clip c, clip raw, int frame, string layout)
  859. {
  860.     MDS_ExceptionCheck(raw,frame)
  861.     try {
  862.     r = Eval(layout + "(raw)")
  863.     }
  864.     catch (err_msg) {
  865.         Assert(0 == 1, """Couldn't perform provided layout function! (probably)
  866. """ + err_msg)
  867.     }
  868.     l = Dissolve(trim(c,frame,frame + AFC), trim(r,frame +1,0),AFC).AudioDub(trim(raw,frame,0))
  869.     Trim(c,0,frame - 1) + l
  870. }
  871.  
  872. function MDS_DissolveToBot(clip c, clip raw, int frame, string "layout")
  873. {
  874.     layout = Default(layout, "MDS_BotVSlide")
  875.     MDS_Dissolve(c, raw, frame, layout)
  876. }
  877. function MDS_DissolveToTop(clip c, clip raw, int frame, string "layout")
  878. {
  879.     layout = Default(layout, "MDS_TopVSlide")
  880.     MDS_Dissolve(c, raw, frame, layout)
  881. }
  882.  
  883. function MDS_Fade(clip c, clip raw, int frame, string layout, bool "fadeaudio")
  884. {
  885.     MDS_ExceptionCheck(raw,frame)
  886.     fadeaudio = Default(fadeaudio, false)
  887.     try {
  888.     r = Eval(layout + "(raw)")
  889.     }
  890.     catch (err_msg) {
  891.         Assert(0 == 1, """Couldn't perform provided layout function! (probably)
  892. """ + err_msg)
  893.     }
  894.     k = floor(AFC/2)
  895.     l = FadeOut(trim(c,frame,frame + k),k) + FadeIn(trim(r,frame + k + 3,0),k)
  896.     l = (fadeaudio == false) ? Eval("""
  897.         l.AudioDub(trim(raw,frame,0))
  898.         """) : l
  899.     Trim(c,0,frame - 1) + l
  900. }
  901.  
  902. function MDS_LongFade(clip c, clip raw, int frame, string layout, bool "fadeaudio")
  903. {
  904.     MDS_ExceptionCheck(raw,frame)
  905.     MDS_ExceptionCheck(raw,frame+AFC)
  906.     fadeaudio = Default(fadeaudio, false)
  907.     try {
  908.     r = Eval(layout + "(raw)")
  909.     }
  910.     catch (err_msg) {
  911.         Assert(0 == 1, """Couldn't perform provided layout function! (probably)
  912. """ + err_msg)
  913.     }
  914.     k = floor(AFC)
  915.     l = FadeOut(trim(c,frame,frame + k),k) + FadeIn(trim(r,frame + k + 3,0),k)
  916.     l = (fadeaudio == false) ? Eval("""
  917.         l.AudioDub(trim(raw,frame,0))
  918.         """) : l
  919.     Trim(c,0,frame - 1) + l
  920. }
  921.  
  922. function MDS_FadeToBot(clip c, clip raw, int frame, string "layout", bool "fadeaudio")
  923. {
  924.     layout = Default(layout, "MDS_BotVSlide")
  925.     fadeaudio = Default(fadeaudio, false)
  926.     MDS_Fade(c,raw,frame,layout,fadeaudio)
  927. }
  928. function MDS_FadeToTop(clip c, clip raw, int frame, string "layout", bool "fadeaudio")
  929. {
  930.     layout = Default(layout, "MDS_TopVSlide")
  931.     fadeaudio = Default(fadeaudio, false)
  932.     MDS_Fade(c,raw,frame,layout,fadeaudio)
  933. }
  934.  
  935. function MDS_CustomTransition(clip c, clip raw, int frame, string layout, string funcname)
  936. {
  937.     MDS_ExceptionCheck(raw,frame)
  938.     try {
  939.     r = Eval(layout + "(raw)")
  940.     }
  941.     catch (err_msg) {
  942.         Assert(0 == 1, """Couldn't perform provided layout function! (probably)
  943. """ + err_msg)
  944.     }
  945.     try {
  946.     l = Eval(funcname + "(trim(c,frame,frame + AFC), trim(r,frame +1,0),AFC).AudioDub(trim(raw,frame,0))")
  947.     }
  948.     catch (err_msg) {
  949.         Assert(0 == 1, """Couldn't perform provided transition function! (probably)
  950. """ + err_msg)
  951.     }
  952.     Trim(c,0,frame - 1) + l
  953. }
  954.  
  955. function MDS_flipflop(clip c, clip raw, string func1, string func2, int f1, int "f2", \
  956. int "f3", int "f4", int "f5", int "f6",\
  957. int "f7", int "f8", int "f9", int "f10",\
  958. int "f11", int "f12", int "f13", int "f14",\
  959. int "f15", int "f16", int "f17", int "f18",\
  960. int "f19", int "f20", int "f21", int "f22",\
  961. int "f23", int "f24", int "f25", int "f26",\
  962. int "f27", int "f28", int "f29", int "f30",\
  963. int "f31", int "f32", int "f33", int "f34",\
  964. int "f35", int "f36", int "f37", int "f38",\
  965. int "f39", int "f40", int "f41", int "f42")
  966. {
  967.         f2 = Default(f2,-100)
  968.         f3 = Default(f3,-100)
  969.         f4 = Default(f4,-100)
  970.        
  971.         r = Eval(func1 + "(c,raw,f1)")
  972.         r = (f2 > -100) ? Eval(func2 + "(r,raw,f2)") : r
  973.        
  974.         i = (f3 > -100) ? Eval("""
  975.             r = MDS_flipflop(r,raw,func1,func2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,\
  976.             f13,f14,f15,f16,f17,f18,f19,f20,f21,f22,f23,f24,f25,f26,\
  977.             f27,f28,f29,f30,f31,f32,f33,f34,f35,f36,f37,f38,f39,f40,f41,f42)
  978.             """) : Eval("")
  979.            
  980.         return r
  981. }
  982.  
  983. # Worker functions:
  984.  
  985. # Code used by basically everything:
  986. function MDS_SameCode(clip raw, string FunctionName)
  987. {
  988.     MDS_ExceptionCheck(raw)
  989.     try {   Eval(FunctionName + "()") }
  990.     catch (err_msg) {
  991.         Assert(0 == 1, """Couldn't perform provided layout function! (probably)
  992. """ + err_msg)
  993.     }
  994.     MDS_UpdateGlobals()
  995.     MDS_DoDSImmediate(raw)
  996. }
  997. function MDS_SameCodeA(clip raw, string FunctionName)
  998. {
  999.     MDS_ExceptionCheck(raw)
  1000.     try {   Eval(FunctionName + "()") }
  1001.     catch (err_msg) {
  1002.         Assert(0 == 1, """Couldn't perform provided layout function! (probably)
  1003. """ + err_msg)
  1004.     }
  1005.     final = MDS_DoDSAnimate(raw)
  1006.     MDS_UpdateGlobals()
  1007.     return final
  1008. }
  1009. function MDS_SameCodeA(clip c, clip raw, string FunctionName, int frame, int "frame2")
  1010. {
  1011.     q = (RightStr(FunctionName,1) == "A") ? MDS_ExceptionCheck(raw,frame) : MDS_ExceptionCheck(raw)
  1012.     frame2 = Default(frame2,-100)
  1013.     l = (frame2 > -100) ? Eval("""
  1014.     MDS_ExceptionCheck(raw,frame2)
  1015.     intMDS_StorePos()
  1016.     """) : 1
  1017.     r = Trim(c,0,frame - 1) + Eval(FunctionName + "(trim(raw,frame,0))")
  1018.     l = (frame2 > -100) ? Eval("""
  1019.     intMDS_RecallPos()
  1020.     r = RightStr(FunctionName,1) == "A" ?   Trim(r,0,frame2-1) + MDS_CustomA(trim(raw,frame2,0)) : Trim(r,0,frame2-1) + MDS_Custom(trim(raw,frame2,0)) """) : r
  1021.     r
  1022. }
  1023.  
  1024. # Cropping functions, includes 2 extra for vert mode:
  1025. function intMDS_GetTop(clip c)
  1026. {
  1027.     crop(c,0,0,0,MDS_basesizeY)
  1028. }
  1029. function intMDS_GetBot(clip c)
  1030. {
  1031.     crop(c,0,MDS_basesizeY,0,0)
  1032. }
  1033. function intMDS_GetVertTop(clip c)
  1034. {
  1035.     l = (MDS_RotatedToRight == FALSE) ? TurnLeft(intMDS_GetTop(c)) : TurnRight(intMDS_GetBot(c))
  1036.     l
  1037. }
  1038. function intMDS_GetVertBot(clip c)
  1039. {
  1040.     l = (MDS_RotatedToRight == FALSE) ? TurnLeft(intMDS_GetBot(c)) : TurnRight(intMDS_GetTop(c))
  1041.     l
  1042. }
  1043.  
  1044. # Primary worker functions, for both instant and animated effects
  1045. function MDS_DoDSImmediate(clip c)
  1046. {
  1047.     a = Eval(MDS_GetTopFunc + "(c)")
  1048.     b = Eval(MDS_GetBotFunc + "(c)")
  1049.    
  1050.     a = Eval(MDS_ResizeOngoingFunc + "(a,newTSX,newTSY,FALSE)")
  1051.     b = Eval(MDS_ResizeOngoingFunc + "(b,newBSX,newBSY,TRUE)")
  1052.     BlankClip(a,width=MDS_MaxX,height=MDS_MaxY).AudioDub(c)
  1053.     final = (MDS_DrawBFirst == false) ? Eval("""
  1054.     """ + MDS_PositionOngoingFunc + """(a,newTPX,newTPY,FALSE)
  1055.     """ + MDS_PositionOngoingFunc + """(b,newBPX,newBPY,TRUE)
  1056.     """) : Eval("""
  1057.     """ + MDS_PositionOngoingFunc + """(b,newBPX,newBPY,TRUE)
  1058.     """ + MDS_PositionOngoingFunc + """(a,newTPX,newTPY,FALSE)
  1059.     """)
  1060.     return final
  1061. }
  1062. function MDS_DoDSAnimate(clip c)
  1063. {
  1064.     a = Eval(MDS_GetTopFunc + "(c)")
  1065.     b = Eval(MDS_GetBotFunc + "(c)")
  1066.     BASE = BlankClip(a,width=MDS_MaxX,height=MDS_MaxY).AudioDub(c)
  1067.     try {
  1068.     q = eval(MDS_AnimFunc + "(a,0,AFC,LastTopSizeX,LastTopSizeY,newTSX,newTSY,FALSE)")
  1069.     r = eval(MDS_AnimFunc + "(b,0,AFC,LastBotSizeX,LastBotSizeY,newBSX,newBSY,TRUE)")
  1070.     final = (MDS_DrawBFirst == false) ? Eval("""
  1071.         BASE.""" + MDS_PositionFunc + """ (q,0,AFC,LastTopPosX,LastTopPosY,newTPX,newTPY,FALSE).""" + MDS_PositionFunc + """(r,0,AFC,LastBotPosX,LastBotPosY,newBPX,newBPY,TRUE)
  1072.         """) : Eval("""
  1073.         BASE.""" + MDS_PositionFunc + """ (r,0,AFC,LastBotPosX,LastBotPosY,newBPX,newBPY,TRUE).""" + MDS_PositionFunc + """(q,0,AFC,LastTopPosX,LastTopPosY,newTPX,newTPY,FALSE)
  1074.         """)
  1075.     }
  1076.     catch (err_msg)
  1077.     {
  1078.         Assert(0 == 1, """Error processing animations, probably bad function name?
  1079. """ + err_msg)
  1080.     }
  1081.        
  1082.     return final
  1083. }
  1084.  
  1085. # Default Position and Resize functions:
  1086. Function MDS_PositionCore(clip Base, clip AddMe, int start, int end, int StartX, int StartY, int EndX, int EndY, bool IsBottom)
  1087. {
  1088.     AnimatedSection = Animate(Base,start,end,MDS_PositionAnimFunc,AddMe,StartX,StartY,0,IsBottom,AddMe,EndX,EndY,AFC,IsBottom)#.trim(start,end)
  1089.     OngoingSection = eval(MDS_PositionOngoingFunc + "(trim(Base,end + 1,0),trim(AddMe,end+1,0),EndX,EndY,IsBottom)")
  1090.     return AnimatedSection + OngoingSection
  1091. }
  1092.  
  1093. Function MDS_AnimPosition(clip Base, clip AddMe, int X, int Y, int step, bool IsBottom)
  1094. {
  1095.     layer(Base,AddMe,"ADD",256,X,Y)
  1096. }
  1097.  
  1098. Function MDS_PositionNonAnim(clip Base, clip AddMe, int X, int Y, bool IsBottom)
  1099. {
  1100.     layer(Base,AddMe,"ADD",256,X,Y)
  1101. }
  1102.  
  1103. Function MDS_AnimResizeCore(clip c, int start, int end, int StartX, int StartY, int EndX, int EndY, bool IsBottom)
  1104. {
  1105.     output = Animate(c,start,end,"MDS_AnimResize",StartX,StartY,MDS_AnimResizeFilter,EndX,EndY,MDS_AnimResizeFilter).trim(start,end)
  1106.     string s = (EndX >= MDS_basesizeX) ? MDS_FinalResizeUp : MDS_FinalResizeDown
  1107.     output = eval("output + c.trim(AFC + 1,0)." + MDS_ResizeOngoingFunc + "(EndX,EndY,IsBottom)")
  1108.     return output
  1109. }
  1110.  
  1111. Function MDS_AnimResize(clip c, int x, int y, string "method")
  1112. {
  1113.     blank = BlankClip(c,width = MDS_SzX,height = MDS_SzY)
  1114.     c = (MDS_BlockPreserve > 1) ? PointResize(c,c.width() * MDS_BlockPreserve,c.height() * MDS_BlockPreserve) : c
  1115.     f = Default(method,"PointResize")
  1116.     try {   q = Eval("c." + f + "(x,y)") }
  1117.     catch (err_msg) {
  1118.         Assert(0 == 1, """Couldn't perform provided resize function! (probably)
  1119. """ + err_msg)
  1120.     }
  1121.     Layer(blank,q)
  1122. }
  1123.  
  1124. Function MDS_ResizeNonAnim(clip c, int x, int y, bool IsBottom)
  1125. {
  1126.     blank = BlankClip(c,width = MDS_SzX,height = MDS_SzY)
  1127.     c = (MDS_BlockPreserve > 1) ? PointResize(c,c.width() * MDS_BlockPreserve,c.height() * MDS_BlockPreserve) : c
  1128.     string s = (x >= MDS_basesizeX) ? MDS_FinalResizeUp : MDS_FinalResizeDown
  1129.     l = (MDS_OneTimeUseDown == true) ? eval("""
  1130.         s = MDS_FinalResizeDown
  1131.         global MDS_OneTimeUseDown = false
  1132.     """) : 0
  1133.     try {   q = Eval("c." + s + "(x,y)") }
  1134.     catch (err_msg) {
  1135.         Assert(0 == 1, """Couldn't perform provided resize function! (probably)
  1136. """ + err_msg)
  1137.     }
  1138.     Layer(blank,q)
  1139. }
  1140.  
  1141. # Global setting functions, extra var set used for new 'back/forth' effects due to custom layout support
  1142. function MDS_UpdateGlobals()
  1143. {
  1144.     global LastTopSizeX = newTSX
  1145.     global LastTopSizeY = newTSY
  1146.     global LastBotSizeX = newBSX
  1147.     global LastBotSizeY = newBSY
  1148.    
  1149.     global LastTopPosX = newTPX
  1150.     global LastTopPosY = newTPY
  1151.     global LastBotPosX = newBPX
  1152.     global LastBotPosY = newBPY
  1153. }
  1154. Function intMDS_StorePos()
  1155. {
  1156.     global MDS_MemTSX = LastTopSizeX
  1157.     global MDS_MemTSY = LastTopSizeY
  1158.     global MDS_MemBSX = LastBotSizeX
  1159.     global MDS_MemBSY = LastBotSizeY
  1160.    
  1161.     global MDS_MemTPX = LastTopPosX
  1162.     global MDS_MemTPY = LastTopPosY
  1163.     global MDS_MemBPX = LastBotPosX
  1164.     global MDS_MemBPY = LastBotPosY
  1165. }
  1166. Function intMDS_RecallPos()
  1167. {
  1168.     global newTSX = MDS_MemTSX
  1169.     global newTSY = MDS_MemTSY
  1170.     global newBSX = MDS_MemBSX
  1171.     global newBSY = MDS_MemBSY
  1172.     global newTPX = MDS_MemTPX
  1173.     global newTPY = MDS_MemTPY
  1174.     global newBPX = MDS_MemBPX
  1175.     global newBPY = MDS_MemBPY
  1176. }
  1177.  
  1178. # Exception Checks:
  1179. Function MDS_ExceptionCheck(clip raw)
  1180. {
  1181.     Assert(width(raw) == MDS_basesizeX, "MDS Error: Raw clip not " + string(MDS_basesizeX) + " pixels wide")
  1182.     Assert(height(raw) == 2 * MDS_basesizeY, "MDS Error: Raw clip not " + string(MDS_basesizeY) + " pixels high")
  1183. }
  1184. Function MDS_ExceptionCheck(clip raw, int frame)
  1185. {
  1186.     MDS_ExceptionCheck(raw)
  1187.     Assert(frame >= MDS_LastFrame, "MDS Error: Frame " + string(frame) + " is smaller than lastframe+AFC (" + string(MDS_LastFrame) + ") - call MDS_ResetLastframe() if not an error")
  1188.     global MDS_LastFrame = frame + AFC
  1189. }
  1190.  
  1191. # Debug function, not very useful
  1192. Function intMDS_DrawDebug(clip c)
  1193. {
  1194.     # Note that this is kind of useless, since it will be applied to all frames regardless of the state things are at the time.
  1195.     c
  1196.     Subtitle("Last: TopS (" + string(LastTopSizeX) + "," + string(LastTopSizeY) + ") BotS (" + \
  1197.     string(LastBotSizeX) + "," + string(LastBotSizeY) + ") TopP (" + string(LastTopPosX) + "," + \
  1198.     string(LastTopPosY) + ") BotP (" + string(LastBotPosX) + "," + \
  1199.     string(LastBotPosY) + ")")
  1200.    
  1201.     Subtitle("New: TopS (" + string(newTSX) + "," + string(newTSY) + ") BotS (" + \
  1202.     string(newBSX) + "," + string(newBSY) + ") TopP (" + string(newTPX) + "," + \
  1203.     string(newTPY) + ") BotP (" + string(newBPX) + "," + \
  1204.     string(newBPY) + ")", y = 100)
  1205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement