Advertisement
CaptainFlameGuy

Untitled

Aug 10th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Avisynth 22.88 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.      
  7.     # Done: Have some way to have frame A drawn before frame B, should be pretty easy to do with an eval/default values
  8.     # TODO: Probably add some more examples?
  9.     # Done: Make a function to set the variables yourself and then call functions to perform them
  10.     # Done: Make some functions that make it easier to perform eg Fades/Dissolves without desyncing the two videos
  11.      
  12.     # Revision 2
  13.      
  14.     global LastFrame = 0
  15.     global DrawBFirst = false
  16.      
  17.     global AFC = 30 #animation frame count
  18.      
  19.     global AnimResizeFilter = "PointResize"
  20.      
  21.     global basesizeX = 256
  22.     global basesizeY = 192
  23.      
  24.     global MaxX = 1280
  25.     global MaxY = 768
  26.     global SzX = 1024
  27.     global SzY = 768
  28.     global QSzX = 256
  29.     global QSzY = 192
  30.     global SBSX = 512
  31.     global SBSY = 384
  32.      
  33.     # These values are used to keep track of where we last put the video, and where we want to put it next
  34.     global LastTopPosX = 0
  35.     global LastTopPosY = 0
  36.     global LastTopSizeX = 256
  37.     global LastTopSizeY = 192
  38.     global LastBotPosX = 0
  39.     global LastBotPosY = 192
  40.     global LastBotSizeX = 256
  41.     global LastBotSizeY = 192
  42.      
  43.     global newTSX = 0
  44.     global newTSY = 0
  45.     global newBSX = 256
  46.     global newBSY = 192
  47.     global newTPX = 0
  48.     global newTPY = 192
  49.     global newBPX = 256
  50.     global newBPY = 192
  51.      
  52.     #And this just makes our video return something if we accidently view it
  53.     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)
  54.     Subtitle("This is MastiDS.avs! Import this script into your AVS!")
  55.     Subtitle("Also, load your avi after you import, because this clip returned by the import line!",y = 50)
  56.      
  57.     function MDS_SetAFC(int newAFC)
  58.     {
  59.             global AFC = newAFC
  60.     }
  61.      
  62.     function MDS_SetParams(int "pMaxX", int "pMaxY", int "pSzX", int "pSzY", int "pQSzX", int "pQSzY", int "pSBSX", int "pSBSY")
  63.     {
  64.             global MaxX = Default(pMaxX,MaxX)
  65.             global MaxY = Default(pMaxY,MaxY)
  66.             global SzX = Default(pSzX,SzX)
  67.             global SzY = Default(pSzY,SzY)
  68.             global QSzX = Default(pQSzX,floor(SzX / 4))
  69.             global QSzY = Default(pQSzY,floor(SzY / 4))
  70.             global SBSX = Default(pSBSX,floor(SzX / 2))
  71.             global SBSY = Default(pSBSY,floor(SzY / 2))
  72.     }
  73.      
  74.     function MDS_ResetLastframe()
  75.     {
  76.             global LastFrame = 0
  77.     }
  78.      
  79.     function MDS_ChangeResizeFilter(string FilterName)
  80.     {
  81.             global AnimResizeFilter = FilterName
  82.     }
  83.      
  84.     function MDS_TopOnTop(bool Bfirst)
  85.     {
  86.             global DrawBFirst = Bfirst
  87.     }
  88.      
  89.     function intMDS_SBS()
  90.     {
  91.             global newTSX = SBSX
  92.             global newTSY = SBSY
  93.             global newBSX = SBSX
  94.             global newBSY = SBSY
  95.             global newTPX = floor((SzX + QSzX) / 2) - SBSX# - 4
  96.             global newTPY = floor((SzY - SBSY) / 2)
  97.             global newBPX = floor((SzX + QSzX) / 2)# + 4
  98.             global newBPY = floor((SzY - SBSY) / 2)
  99.     }
  100.     function MDS_SBS(clip raw)
  101.     {
  102.             MDS_ExceptionCheck(raw)
  103.             intMDS_SBS()
  104.             UpdateGlobals()
  105.             DoDSImmediate(raw)
  106.     }
  107.     function MDS_SBS(clip c, clip raw, int frame)
  108.     {
  109.             MDS_ExceptionCheck(raw,frame)
  110.             Trim(c,0,frame - 1) + MDS_SBS(trim(raw,frame,0))
  111.     }
  112.     function MDS_SBSA(clip raw)
  113.     {
  114.             MDS_ExceptionCheck(raw)
  115.             intMDS_SBS()
  116.             final = DoDSAnimate(raw)
  117.             UpdateGlobals()
  118.             return final
  119.     }
  120.     function MDS_SBSA(clip c, clip raw, int frame)
  121.     {
  122.             MDS_ExceptionCheck(raw,frame)
  123.             Trim(c,0,frame - 1) + MDS_SBSA(trim(raw,frame,0))
  124.     }
  125.      
  126.     function intMDS_SBSL()
  127.     {
  128.             global newTSX = SBSX + basesizeX
  129.             global newTSY = SBSY + basesizeY
  130.             global newBSX = SBSX
  131.             global newBSY = SBSY
  132.             global newTPX = 0
  133.             global newTPY = floor((SzY - SBSY - basesizeY) / 2)
  134.             global newBPX = SBSX + basesizeX
  135.             global newBPY = floor((SzY - SBSY) / 2)
  136.     }
  137.     function MDS_SBSL(clip raw)
  138.     {
  139.             MDS_ExceptionCheck(raw)
  140.             intMDS_SBSL()
  141.             UpdateGlobals()
  142.             DoDSImmediate(raw)
  143.     }
  144.     function MDS_SBSL(clip c, clip raw, int frame)
  145.     {
  146.             MDS_ExceptionCheck(raw,frame)
  147.             Trim(c,0,frame - 1) + MDS_SBSL(trim(raw,frame,0))
  148.     }
  149.     function MDS_SBSLA(clip raw)
  150.     {
  151.             MDS_ExceptionCheck(raw)
  152.             intMDS_SBSL()
  153.             final = DoDSAnimate(raw)
  154.             UpdateGlobals()
  155.             return final
  156.     }
  157.     function MDS_SBSLA(clip c, clip raw, int frame)
  158.     {
  159.             MDS_ExceptionCheck(raw,frame)
  160.             Trim(c,0,frame - 1) + MDS_SBSLA(trim(raw,frame,0))
  161.     }
  162.      
  163.     function intMDS_SBSR()
  164.     {
  165.             global newTSX = SBSX
  166.             global newTSY = SBSY
  167.             global newBSX = SBSX + basesizeX
  168.             global newBSY = SBSY + basesizeY
  169.             global newTPX = 0
  170.             global newTPY = floor((SzY - SBSY) / 2)
  171.             global newBPX = SBSX
  172.             global newBPY = floor((SzY - SBSY - basesizeY) / 2)
  173.     }
  174.     function MDS_SBSR(clip raw)
  175.     {
  176.             MDS_ExceptionCheck(raw)
  177.             intMDS_SBSR()
  178.             UpdateGlobals()
  179.             DoDSImmediate(raw)
  180.     }
  181.     function MDS_SBSR(clip c, clip raw, int frame)
  182.     {
  183.             MDS_ExceptionCheck(raw,frame)
  184.             Trim(c,0,frame - 1) + MDS_SBSR(trim(raw,frame,0))
  185.     }
  186.     function MDS_SBSRA(clip raw)
  187.     {
  188.             MDS_ExceptionCheck(raw)
  189.             intMDS_SBSR()
  190.             final = DoDSAnimate(raw)
  191.             UpdateGlobals()
  192.             return final
  193.     }
  194.     function MDS_SBSRA(clip c, clip raw, int frame)
  195.     {
  196.             MDS_ExceptionCheck(raw,frame)
  197.             Trim(c,0,frame - 1) + MDS_SBSRA(trim(raw,frame,0))
  198.     }
  199.      
  200.     function intMDS_Top()
  201.     {
  202.             global newTSX = SzX
  203.             global newTSY = SzY
  204.             global newBSX = QSzX
  205.             global newBSY = QSzY
  206.             global newTPX = 0
  207.             global newTPY = 0
  208.             global newBPX = SzX
  209.             global newBPY = SzY - QSzY
  210.     }
  211.     function MDS_Top(clip raw)
  212.     {
  213.             MDS_ExceptionCheck(raw)
  214.             intMDS_Top()
  215.             UpdateGlobals()
  216.             DoDSImmediate(raw)
  217.     }
  218.     function Top(clip c, clip raw, int frame)
  219.     {
  220.             MDS_ExceptionCheck(raw,frame)
  221.             Trim(c,0,frame - 1) + MDS_Top(trim(raw,frame,0))
  222.     }
  223.     function MDS_TopA(clip raw)
  224.     {
  225.             MDS_ExceptionCheck(raw)
  226.             intMDS_Top()
  227.             final = DoDSAnimate(raw)
  228.             UpdateGlobals()
  229.             return final
  230.     }
  231.     function MDS_TopA(clip c, clip raw, int frame)
  232.     {
  233.             MDS_ExceptionCheck(raw,frame)
  234.             Trim(c,0,frame - 1) + MDS_TopA(trim(raw,frame,0))
  235.     }
  236.      
  237.      
  238.     function intMDS_TopO()
  239.     {
  240.             global newTSX = SzX
  241.             global newTSY = SzY
  242.             global newBSX = QSzX
  243.             global newBSY = QSzY
  244.             global newTPX = floor(QSzX / 2)
  245.             global newTPY = 0
  246.             global newBPX = SzX + QSzX
  247.             global newBPY = SzY - QSzY
  248.     }
  249.     function MDS_TopO(clip raw)
  250.     {
  251.             MDS_ExceptionCheck(raw)
  252.             intMDS_TopO()
  253.             UpdateGlobals()
  254.             DoDSImmediate(raw)
  255.     }
  256.     function TopO(clip c, clip raw, int frame)
  257.     {
  258.             MDS_ExceptionCheck(raw,frame)
  259.             Trim(c,0,frame - 1) + MDS_TopO(trim(raw,frame,0))
  260.     }
  261.     function MDS_TopOA(clip raw)
  262.     {
  263.             MDS_ExceptionCheck(raw)
  264.             intMDS_TopO()
  265.             final = DoDSAnimate(raw)
  266.             UpdateGlobals()
  267.             return final
  268.     }
  269.     function MDS_TopOA(clip c, clip raw, int frame)
  270.     {
  271.             MDS_ExceptionCheck(raw,frame)
  272.             Trim(c,0,frame - 1) + MDS_TopOA(trim(raw,frame,0))
  273.     }
  274.      
  275.     function intMDS_BotO()
  276.     {
  277.             global newTSX = QSzX
  278.             global newTSY = QSzY
  279.             global newBSX = SzX
  280.             global newBSY = SzY
  281.             global newTPX = -QSzX
  282.             global newTPY = 0
  283.             global newBPX = floor(QSzX / 2)
  284.             global newBPY = 0
  285.     }
  286.     function MDS_BotO(clip raw)
  287.     {
  288.             MDS_ExceptionCheck(raw)
  289.             intMDS_BotO()
  290.             UpdateGlobals()
  291.             DoDSImmediate(raw)
  292.     }
  293.     function TopO(clip c, clip raw, int frame)
  294.     {
  295.             MDS_ExceptionCheck(raw,frame)
  296.             Trim(c,0,frame - 1) + MDS_BotO(trim(raw,frame,0))
  297.     }
  298.     function MDS_BotOA(clip raw)
  299.     {
  300.             MDS_ExceptionCheck(raw)
  301.             intMDS_BotO()
  302.             final = DoDSAnimate(raw)
  303.             UpdateGlobals()
  304.             return final
  305.     }
  306.     function MDS_TopOA(clip c, clip raw, int frame)
  307.     {
  308.             MDS_ExceptionCheck(raw,frame)
  309.             Trim(c,0,frame - 1) + MDS_BotOA(trim(raw,frame,0))
  310.     }
  311.      
  312.      
  313.     function intMDS_Bot()
  314.     {
  315.             global newTSX = QSzX
  316.             global newTSY = QSzY
  317.             global newBSX = SzX
  318.             global newBSY = SzY
  319.             global newTPX = 0
  320.             global newTPY = 0
  321.             global newBPX = QSzX
  322.             global newBPY = 0
  323.     }
  324.     function MDS_Bot(clip raw)
  325.     {
  326.             MDS_ExceptionCheck(raw)
  327.             intMDS_Bot()
  328.             UpdateGlobals()
  329.             DoDSImmediate(raw)
  330.     }
  331.     function MDS_Bot(clip c, clip raw, int frame)
  332.     {
  333.             MDS_ExceptionCheck(raw,frame)
  334.             Trim(c,0,frame - 1) + MDS_Bot(trim(raw,frame,0))
  335.     }
  336.     function MDS_BotA(clip raw)
  337.     {
  338.             MDS_ExceptionCheck(raw)
  339.             intMDS_Bot()
  340.             final = DoDSAnimate(raw)
  341.             UpdateGlobals()
  342.             return final
  343.     }
  344.     function MDS_BotA(clip c, clip raw, int frame)
  345.     {
  346.             MDS_ExceptionCheck(raw,frame)
  347.             Trim(c,0,frame - 1) + MDS_BotA(trim(raw,frame,0))
  348.     }
  349.      
  350.     function intMDS_TopHSlide()
  351.     {
  352.             global newTSX = SzX
  353.             global newTSY = SzY
  354.             global newBSX = SzX
  355.             global newBSY = SzY
  356.             global newTPX = floor(QSzX / 2)
  357.             global newTPY = 0
  358.             global newBPX = SzX + floor(QSzX / 2)
  359.             global newBPY = 0
  360.     }
  361.     function MDS_TopHSlide(clip raw)
  362.     {
  363.             MDS_ExceptionCheck(raw)
  364.             intMDS_TopHSlide()
  365.             UpdateGlobals()
  366.             DoDSImmediate(raw)
  367.     }
  368.     function MDS_TopHSlide(clip c, clip raw, int frame)
  369.     {
  370.             MDS_ExceptionCheck(raw,frame)
  371.             Trim(c,0,frame - 1) + MDS_TopHSlide(trim(raw,frame,0))
  372.     }
  373.     function MDS_TopHSlideA(clip raw)
  374.     {
  375.             MDS_ExceptionCheck(raw)
  376.             intMDS_TopHSlide()
  377.             final = DoDSAnimate(raw)
  378.             UpdateGlobals()
  379.             return final
  380.     }
  381.     function MDS_TopHSlideA(clip c, clip raw, int frame)
  382.     {
  383.             MDS_ExceptionCheck(raw,frame)
  384.             Trim(c,0,frame - 1) + MDS_TopHSlideA(trim(raw,frame,0))
  385.     }
  386.      
  387.     function intMDS_BotHSlide()
  388.     {
  389.             global newTSX = SzX
  390.             global newTSY = SzY
  391.             global newBSX = SzX
  392.             global newBSY = SzY
  393.             global newTPX = -SzX + floor(QSzX / 2)
  394.             global newTPY = 0
  395.             global newBPX = floor(QSzX / 2)
  396.             global newBPY = 0
  397.     }
  398.     function MDS_BotHSlide(clip raw)
  399.     {
  400.             MDS_ExceptionCheck(raw)
  401.             intMDS_BotHSlide()
  402.             UpdateGlobals()
  403.             DoDSImmediate(raw)
  404.     }
  405.     function MDS_BotHSlide(clip c, clip raw, int frame)
  406.     {
  407.             MDS_ExceptionCheck(raw,frame)
  408.             Trim(c,0,frame - 1) + MDS_BotHSlide(trim(raw,frame,0))
  409.     }
  410.     function MDS_BotHSlideA(clip raw)
  411.     {
  412.             MDS_ExceptionCheck(raw)
  413.             intMDS_BotHSlide()
  414.             final = DoDSAnimate(raw)
  415.             UpdateGlobals()
  416.             return final
  417.     }
  418.     function MDS_BotHSlideA(clip c, clip raw, int frame)
  419.     {
  420.             MDS_ExceptionCheck(raw,frame)
  421.             Trim(c,0,frame - 1) + MDS_BotHSlideA(trim(raw,frame,0))
  422.     }
  423.      
  424.     function intMDS_TopVSlide()
  425.     {
  426.             global newTSX = SzX
  427.             global newTSY = SzY
  428.             global newBSX = SzX
  429.             global newBSY = SzY
  430.             global newTPX = floor(QSzX / 2)
  431.             global newTPY = 0
  432.             global newBPX = floor(QSzX / 2)
  433.             global newBPY = SzY
  434.     }
  435.     function MDS_TopVSlide(clip raw)
  436.     {
  437.             MDS_ExceptionCheck(raw)
  438.             intMDS_TopVSlide()
  439.             UpdateGlobals()
  440.             DoDSImmediate(raw)
  441.     }
  442.     function MDS_TopVSlide(clip c, clip raw, int frame)
  443.     {
  444.             MDS_ExceptionCheck(raw,frame)
  445.             Trim(c,0,frame - 1) + MDS_TopVSlide(trim(raw,frame,0))
  446.     }
  447.     function MDS_TopVSlideA(clip raw)
  448.     {
  449.             MDS_ExceptionCheck(raw)
  450.             intMDS_TopVSlide()
  451.             final = DoDSAnimate(raw)
  452.             UpdateGlobals()
  453.             return final
  454.     }
  455.     function MDS_TopVSlideA(clip c, clip raw, int frame)
  456.     {
  457.             MDS_ExceptionCheck(raw,frame)
  458.             Trim(c,0,frame - 1) + MDS_TopVSlideA(trim(raw,frame,0))
  459.     }
  460.      
  461.     function intMDS_BotVSlide()
  462.     {
  463.             global newTSX = SzX
  464.             global newTSY = SzY
  465.             global newBSX = SzX
  466.             global newBSY = SzY
  467.             global newTPX = floor(QSzX / 2)
  468.             global newTPY = -SzY
  469.             global newBPX = floor(QSzX / 2)
  470.             global newBPY = 0
  471.     }
  472.     function MDS_BotVSlide(clip raw)
  473.     {
  474.             MDS_ExceptionCheck(raw)
  475.             intMDS_BotVSlide()
  476.             UpdateGlobals()
  477.             DoDSImmediate(raw)
  478.     }
  479.     function MDS_BotVSlide(clip c, clip raw, int frame)
  480.     {
  481.             MDS_ExceptionCheck(raw,frame)
  482.             Trim(c,0,frame - 1) + MDS_BotVSlide(trim(raw,frame,0))
  483.     }
  484.     function MDS_BotVSlideA(clip raw)
  485.     {
  486.             MDS_ExceptionCheck(raw)
  487.             intMDS_BotVSlide()
  488.             final = DoDSAnimate(raw)
  489.             UpdateGlobals()
  490.             return final
  491.     }
  492.     function MDS_BotVSlideA(clip c, clip raw, int frame)
  493.     {
  494.             MDS_ExceptionCheck(raw,frame)
  495.             Trim(c,0,frame - 1) + MDS_BotVSlideA(trim(raw,frame,0))
  496.     }
  497.      
  498.     function intMDS_VertStack()
  499.     {
  500.             global newTSX = SBSX
  501.             global newTSY = SBSY
  502.             global newBSX = SBSX
  503.             global newBSY = SBSY
  504.             global newTPX = floor ((SzX + QSzX - SBSX) / 2)
  505.             global newTPY = 0
  506.             global newBPX = floor ((SzX + QSzX - SBSX) / 2)
  507.             global newBPY = SBSY
  508.     }
  509.     function MDS_VertStack(clip raw)
  510.     {
  511.             MDS_ExceptionCheck(raw)
  512.             intMDS_VertStack()
  513.             UpdateGlobals()
  514.             DoDSImmediate(raw)
  515.     }
  516.     function MDS_VertStack(clip c, clip raw, int frame)
  517.     {
  518.             MDS_ExceptionCheck(raw,frame)
  519.             Trim(c,0,frame - 1) + MDS_VertStack(trim(raw,frame,0))
  520.     }
  521.     function MDS_VertStackA(clip raw)
  522.     {
  523.             MDS_ExceptionCheck(raw)
  524.             intMDS_VertStack()
  525.             final = DoDSAnimate(raw)
  526.             UpdateGlobals()
  527.             return final
  528.     }
  529.     function MDS_VertStackA(clip c, clip raw, int frame)
  530.     {
  531.             MDS_ExceptionCheck(raw,frame)
  532.             Trim(c,0,frame - 1) + MDS_VertStackA(trim(raw,frame,0))
  533.     }
  534.      
  535.     function MDS_Dissolve(clip c, clip raw, int frame, string layout)
  536.     {
  537.             MDS_ExceptionCheck(raw,frame)
  538.             try {
  539.             r = Eval(layout + "(raw)")
  540.             }
  541.             catch (err_msg) {
  542.                     Assert(0 == 1, """Couldn't perform provided layout function! (probably)
  543.    """ + err_msg)
  544.             }
  545.             l = Dissolve(trim(c,frame,frame + AFC), trim(r,frame +1,0),AFC).AudioDub(trim(raw,frame,0))
  546.             Trim(c,0,frame - 1) + l
  547.     }
  548.      
  549.     function MDS_DissolveToBot(clip c, clip raw, int frame, string "layout")
  550.     {
  551.             layout = Default(layout, "MDS_BotHSlide")
  552.             MDS_Dissolve(c, raw, frame, layout)
  553.     }
  554.     function MDS_DissolveToTop(clip c, clip raw, int frame, string "layout")
  555.     {
  556.             layout = Default(layout, "MDS_TopHSlide")
  557.             MDS_Dissolve(c, raw, frame, layout)
  558.     }
  559.      
  560.     function MDS_Fade(clip c, clip raw, int frame, string layout, bool "fadeaudio")
  561.     {
  562.             MDS_ExceptionCheck(raw,frame)
  563.             fadeaudio = Default(fadeaudio, false)
  564.             try {
  565.             r = Eval(layout + "(raw)")
  566.             }
  567.             catch (err_msg) {
  568.                     Assert(0 == 1, """Couldn't perform provided layout function! (probably)
  569.    """ + err_msg)
  570.             }
  571.             k = floor(AFC/2)
  572.             l = FadeOut(trim(c,frame,frame + k),k) + FadeIn(trim(r,frame + k + 3,0),k)
  573.             l = fadeaudio == false ? Eval("""
  574.                    l.AudioDub(trim(raw,frame,0))
  575.                    """) : l
  576.             Trim(c,0,frame - 1) + l
  577.     }
  578.      
  579.     function MDS_FadeToBot(clip c, clip raw, int frame, string "layout", bool "fadeaudio")
  580.     {
  581.             layout = Default(layout, "MDS_BotHSlide")
  582.             fadeaudio = Default(fadeaudio, false)
  583.             MDS_Fade(c,raw,frame,layout,fadeaudio)
  584.     }
  585.     function MDS_FadeToTop(clip c, clip raw, int frame, string "layout", bool "fadeaudio")
  586.     {
  587.             layout = Default(layout, "MDS_TopHSlide")
  588.             fadeaudio = Default(fadeaudio, false)
  589.             MDS_Fade(c,raw,frame,layout,fadeaudio)
  590.     }
  591.      
  592.      
  593.     function MDS_Custom_TargetData(int TSX,int TSY,int BSX, int BSY, int TPX, int TPY, int BPX, int BPY)
  594.     {
  595.             global newTSX = TSX
  596.             global newTSY = TSY
  597.             global newBSX = BSX
  598.             global newBSY = BSY
  599.             global newTPX = TPX
  600.             global newTPY = TPY
  601.             global newBPX = BPX
  602.             global newBPY = BPY
  603.     }
  604.     function MDS_Custom(clip raw)
  605.     {
  606.             MDS_ExceptionCheck(raw)
  607.             UpdateGlobals()
  608.             DoDSImmediate(raw)
  609.     }
  610.     function MDS_Custom(clip c, clip raw, int frame)
  611.     {
  612.             MDS_ExceptionCheck(raw,frame)
  613.             Trim(c,0,frame - 1) + MDS_Custom(trim(raw,frame,0))
  614.     }
  615.     function MDS_CustomA(clip raw)
  616.     {
  617.             MDS_ExceptionCheck(raw)
  618.             final = DoDSAnimate(raw)
  619.             UpdateGlobals()
  620.             return final
  621.     }
  622.     function MDS_CustomA(clip c, clip raw, int frame)
  623.     {
  624.             MDS_ExceptionCheck(raw,frame)
  625.             Trim(c,0,frame - 1) + MDS_CustomA(trim(raw,frame,0))
  626.     }
  627.      
  628.     # Worker functions:
  629.     function DoDSImmediate(clip c)
  630.     {
  631.             a = c.crop(0,0,0,192).PointResize(newTSX,newTSY)
  632.             b = c.crop(0,192,0,0).PointResize(newBSX,newBSY)
  633.             BlankClip(a,width = MaxX,height=MaxY).AudioDub(c)
  634.             final = DrawBFirst == false ? Eval("""
  635.            layer(a,"ADD",256,newTPX,newTPY)
  636.            layer(b,"ADD",256,newBPX,newBPY)
  637.            """) : Eval("""
  638.            layer(b,"ADD",256,newBPX,newBPY)
  639.            layer(a,"ADD",256,newTPX,newTPY)
  640.            """)
  641.             return final
  642.     }
  643.     function DoDSAnimate(clip c)
  644.     {
  645.             a = c.crop(0,0,0,192)
  646.             b = c.crop(0,192,0,0)
  647.             BASE = BlankClip(a,width = MaxX,height=MaxY).AudioDub(c)
  648.             q = a.Animate(0,AFC,"AnimResize",LastTopSizeX,LastTopSizeY,AnimResizeFilter,newTSX,newTSY,AnimResizeFilter).trim(0,AFC)
  649.             q = q + a.trim(AFC + 1,0).AnimResize(newTSX,newTSY,"PointResize")
  650.             r = b.Animate(0,AFC,"AnimResize",LastBotSizeX,LastBotSizeY,AnimResizeFilter,newBSX,newBSY,AnimResizeFilter).trim(0,AFC)
  651.             r = r + b.trim(AFC + 1,0).AnimResize(newBSX,newBSY,"PointResize")
  652.             final = DrawBFirst == false ? Eval("""
  653.                    BASE.Animate(0,AFC,"layer",q,"ADD",256,LastTopPosX,LastTopPosY,q,"ADD",256,newTPX,newTPY).Animate(0,AFC,"layer",r,"ADD",256,LastBotPosX,LastBotPosY,r,"ADD",256,newBPX,newBPY)
  654.                    """) : Eval("""
  655.                    BASE.Animate(0,AFC,"layer",r,"ADD",256,LastBotPosX,LastBotPosY,r,"ADD",256,newBPX,newBPY).Animate(0,AFC,"layer",q,"ADD",256,LastTopPosX,LastTopPosY,q,"ADD",256,newTPX,newTPY)
  656.                    """)
  657.             return final
  658.     }
  659.     function UpdateGlobals()
  660.     {
  661.             global LastTopSizeX = newTSX
  662.             global LastTopSizeY = newTSY
  663.             global LastBotSizeX = newBSX
  664.             global LastBotSizeY = newBSY
  665.            
  666.             global LastTopPosX = newTPX
  667.             global LastTopPosY = newTPY
  668.             global LastBotPosX = newBPX
  669.             global LastBotPosY = newBPY
  670.     }
  671.     Function AnimResize(clip c, int x, int y,string "method")
  672.     {
  673.             blank = BlankClip(c,width = SzX,height = SzY)
  674.             f = Default(method,"PointResize")
  675.             q = Eval("c." + f + "(x,y)")
  676.             Layer(blank,q)
  677.     }
  678.      
  679.     Function MDS_ExceptionCheck(clip raw)
  680.     {
  681.             Assert(width(raw) == 256, "MDS Error: Raw clip not 256 pixels wide")
  682.             Assert(height(raw) == 384, "MDS Error: Raw clip not 384 pixels high")
  683.     }
  684.      
  685.     Function MDS_ExceptionCheck(clip raw, int frame)
  686.     {
  687.             MDS_ExceptionCheck(raw)
  688.             Assert(frame >= LastFrame, "MDS Error: Frame " + string(frame) + " is smaller than lastframe+AFC (" + string(LastFrame) + ") - call MDS_ResetLastframe() if not an error")
  689.             global LastFrame = frame + AFC
  690.     }
  691.      
  692.     Function intMDS_DrawDebug(clip c)
  693.     {
  694.             # Note that this is kind of useless, since it will be applied to all frames regardless of the state things are at the time.
  695.             c
  696.             Subtitle("Last: TopS (" + string(LastTopSizeX) + "," + string(LastTopSizeY) + ") BotS (" + \
  697.             string(LastBotSizeX) + "," + string(LastBotSizeY) + ") TopP (" + string(LastTopPosX) + "," + \
  698.             string(LastTopPosY) + ") BotP (" + string(LastBotPosX) + "," + \
  699.             string(LastBotPosY) + ")")
  700.            
  701.             Subtitle("New: TopS (" + string(newTSX) + "," + string(newTSY) + ") BotS (" + \
  702.             string(newBSX) + "," + string(newBSY) + ") TopP (" + string(newTPX) + "," + \
  703.             string(newTPY) + ") BotP (" + string(newBPX) + "," + \
  704.             string(newBPY) + ")", y = 100)
  705.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement