0,]']>S}Wup8d%qy)6o;]AsVl333===3===3333M3MCDCMCD44C3===C3L4>>3L=C=33==3==LMNDD>CDDC33333333333333333333==3CMD=D 3=M3L>MN3?30 <0<3=4? D<>MDC3>34=3= 3 0333O4DM4=C=33?>3C33DM3=?4?4==34?>3D=>>33>?3CC>3=343=3M3>3?D>3>>>>?O3?=>?>==3333333?3333>=4>?>33>?>NNLDMMD4DDMLM?33333>CC>=>MD>?4>=>4<3?>>3>433333333334M3>3>434C44>33>=>C333>333>333333333333333333333333333333333333333333333333333333333333ND333<33<33<333L33C3=333=3=3<3D3<3<3?3>333>>333>3=33<33<333<3<33<3<3?>>3LLLLLLL?LD?<3333L3<<=33=33=33=33=3343343343333<>333?<3<33=3333<3333<33>3333333333333333333333333333333333333333333333333333333L3<3>3L>3N333L3M333333C<43333433433433333333333=3<<<3<<3M333333333?3<3<3333LN3MDC33333>3334=3><333333333>333333333333333333333333333333<3<33333333333333333333333 N<3C3>34C343333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333>333>333333333333333333333333333330333333333333333333333333333333333333333333333333333333333333<333 3333<303030330303 33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333N=3>333333==3===3M33C=3DC=4DC3=C3L4>>3L=C=3333333333<333333333333333333333333333343DDD3DMMMMMDDD33333333D43=3C343C3333=3C3333 3==3==LMNDD>CDDC=3333333=333M333=33M333D=33D3==343C===333C3=3C3=CM33D3=MDLLOD 43 33N=CDL4CDDD4DDDCDDC33CL4C333334333D33>3>3=>> ?3=3?<4DD43CD333D43CD333DL3CDDCLDDCC44C<=D>=< LL33D43333=4333>4=3LM3>44333ND<>>343333D4CD3== OL?>4 3  L433DM?3?>=3=3=C=MM?L3CL3D?MD?DLLL<4 0LML D3>>L>>N3LC4M33>=M4CND4343333L>D433 +bT L:JJJJJJJJJJJJJJJJJ:M E b1  C1'6t 0000000000000 D E :# !21#!"#   C560C!t  <:000000000000:JJ:= DCD E : !# s  E 6t DDs005()6005'56t F0 :M 0000000000000J000: !"2#!a::Ms0000000t / 0E 0 &D 060'0 #./000 :; 000:JJJ:0000?000K !"2""""21#a0000000000 E b 00EFt  005)5)'6E6  000 L: 0000  0000O000K !"# !# !2A 0gi000000 EF1"2 s0FE F000 CD 00E F5)'6E' J:J% F1"#<;=0000 M 0000000000000J000:  ! 00: 00 0:12 000  00F0  :::  T:hi:$00 0000000000000:JJ:M 1# 0000K= 00g 0)600K!#! ;056:J: D c00d  -00000000000ű.E *+Et Cey:i000 000000:000000 s5(((((6 # 000K; 0 E00K  L:060jK= :JJJ:  #c00000000000F 6 Hi0 \ \lL9  pDF.>}|:1:k?><6<=75:06768799743955 ;4<81 40p2   2  t  & C   \|  8%8%8%F'F'8%8%8%F'F'8%8%8%F'F'D)D)D)D)F'F'AAAAAAAAAA""BB   """BB  " ""B   " " " B "  " B " #a #a #a #a #a #a #a # # #a #a #a #a #a #a #a # # #4' ``;'P` @9' ``PP@@@@6'D `@ @N'dN'd4'4'4'4';';'N'dN'dAAAAAAAAAAAAAAAAAAADDDdDD $$$D$$DDDdDD $$$D$$AAAAAAAAAAAAAAAAAAAAAAADDDdDD $$$D$$DDDdDD4'4'4'4'4'4'4'4';';';'N'N'N'N'N'4'4'4'4'4'4'4'4';';';'N'N'N'N'N'$D$D$$D$ $ D $$D$D$$D$D$$D$ $ D $$D$D$     t, @ @ @@@        DdDdDdDd $ D $ D $ D $ D$D$D$D$D $ D $ D $ D $ D #a #a #a #a #a #a #a # # # # # # # # # # # # # # # # # # # # ###C C c #a #a #a #a #a #a #a # # #a #a #a #a # # # # # # # #CC#)#9#I#Y#i#y######### # # # #a #a #a #a #a #a #a # # #a #a #aCaCacacCCCt,   4'4'4'4';'=' I'N'AAAAAAAAA ##)#I#y#### ##CƁFD́@NHLTX́@NHLTXppppƁFƁr0?UPUPP_UPP__UPPP____UU__PP_PP_P_UP__P_U_UUUPP_P__PP_UU_P_P_PP__PU_U_U__UP__UPP_P_PP_U_U_UU_UPU_P___PU_PUPUUPPPPUUP____P____UUU_PPP_UUP__U_UUP__UPUP_PU_UP___UPUPUU__UP___PU_PPP_UPUPUPPPUPUUPUUP_UPPP_UPPUPPPPPPPPUP_____PP_PPUP_PUU_PP_P____UPUU__PPPU_U_PUP__P__UPUP__P__UPP__U_U_UPUP_P_PPUPPPPUUPPUUPPPU__PPUUPUPP_PP_UUPPP_PPP_PUUP_U_U_UU_PUUPUPU_PUP_P_PP__U_PPUPP_UPU_U__P_UP_P_PPPPUPPU___UUP_U_UPPPUPPP_U_UPUUP___PP_UP_U__U___PU__PU_U_PP_PUUP_PPP_P_P_P_PPUUP___PPU_P_PU_P____UPPP_P_P_PPU_PPUP__U_U_P_UPUU__U__P__PU_U_UUP_UPUPUU_PU__UP__PUUPPU_U__PPUP_PPU_UP_U__U_U_PPUUPUPUP____UUPP_UP_P___PU_P_P_P__U_UUP_UUP_UPPUUUU_PPPP__P_P_UUUUU_PU_P___PUUPPUUU_UUP__UP_PPPP_PUPPUP__UP___PUPU_P___UPUPP_PPPU_U_UP_UPP_PP_UUP__PU_PUUPU_UPPPUPP___PPPPU_PPU__UPPPPP_P__UUPUU__UPUP_U__P_PU__PPPP_UUPP_P_PU_PP_PPU_U_PUU_U__P_PPUUUU___UUU__PU_PPU_UPUUUUUPUUUUU__P_U_U_UU_P_PUUUPP_P_UPU_UUUPUPP_PUPUPUU_UUPUU_UUPPP___UPUUPU_UP_P_P__P_UPPPPUUP_UPU__P___PUP_PPUUPUU_UU_UPUUUUP_PPPU_UPUUP_PPPPUUP_UP__PPUUUU___P_UP__P____U_U__UU_PP_UU__P_UPUUP___PPPU____PPU_U_UPPP_UPPPPPU_UPPPUUUPPUPUPPPU____U_____P_PPUUPUUU_U_UUUUU__P__P_UUUUPUUPPP_P_PUUUPUUUPPP_PU___U_PUUUUPPU__UUP]]__U_P_PU_PP_P_UPUP_UPPPPUUPU_PPUUP_PP P_UPPPUP_PPPUP_PUP_UUPPPUUP PUUU__UU_UUU_UUUU_P_PPP_P_UPPPPP_PP_____PPPUUPPUUPUPPUUUPP`PPPPP_PPU_U_P_PPU__U_U_PPU__P__PPP_UUU_U_UU_P_PU__U_UPPUPPP_UP_PUPUUU _PPUPUP___U___UPPUPUUUUUPPPP_UUPU__P_P_UUPUUP_P__UPP_U_PPP_U__UP_P__UUPPPU__P____UU_PP__P]_UUU_PPU_PUP__U____PU__U__UU_PUPP_PPP_UUUP__PUPUPPU___UU_UP_UUUP__UU__PPPPUUPPP_UPPUU__UP__P]U_U_P_UPUU_PPPPUPUU_U_PPP__U_P_P]]UUU_UPPPPUPUU___U_PPUP_P_P__U_UUUPUUUU_UUU_UUUUPUU_P_UUUUPUP_PU_UU_PUPPPU__UUU_UU_UUU_PUU_UU_PPU_PUUPP____UUUPPPU_P_U_UU____ U____P_UPUU_PUPP_UPPP__PPUU UUP_UP__UPU__PU_UP__PP_P__PU_PP PUP___UPU__P_PUU_PPP_P UP_PUU__P_U_U___PU__PPU_P__PU___ PUP__UU_UPUU_PU__P_PU__P]PP_P___UPP__UU_P_____UU_PUUUU_PP_PPP_PPP__P_P__PU_UP___U]PPPP_UPUP____UP_UU__PUUP__PP_UP__P_P_PPUPPP_P__P___PUUPPPPUPU_]UUP___UPPUPUPPPP_P__U_UP_U__UUPPUP_P_PP_____UU_P_P___PUP_PPU_PU_PP__UPPPPP__UUP_ ]PUPUPUU_PPP_PUUUU_P__U_PPUUU_ ]PU_PPPU_PP__PPU_PPUPUPPUU ] PUPUPPU__UP_P_P UU__P__UP____U_UUPP_PUU__P_PUUPUUPP_P UUP_PUPU_P___U__UPP__PPUPP _PP_UUU_UP_PUU_PUPUPPPU P_PUU__P_P__UP_U__P U_UUUUU__P_PP__UPPPU_U P_P_UP_P_U__PUPPU_PP_P__ ]P__U_PPU_PPUP_UP____ UUPPPPUP_PP_PPPPUPUP P_UPUPUP_PU_UP____U PPPPUU_UUPP_P_PUU  PU_U_UP_PPUUPP _UUPUP_PPP__U___ P_UU_U_PPU_UUPUPP_PUP PP_PU_PP_PPPUPUUUPP ] ____U__P_P_U_P ] __P___P_UPUUUP __UPUP_U_PUUP_P_ PU_UPP_P__U _P_PU_PP_UPUPP__U_P_ ]U_PU_PU_UP ]]UPUPP_UU_UPP_U__ _P_U_UUPUP__UUP UU__PPPPUPPP_] _UU_PUPPPPUPPU UPU_UPUPU__P __P___UP_P]PPP____]UPP_UU__UPPUPPUPUU]PPPU_UUPP_P_UPUPUUUPP_UP_P]_U_PUP_PPUP_PUUUP_PUP__UPP_PP_P_PPPUP_]_PP___UPUUUPPP__PUPPPPPUP____U_UP_PP_PPUP__PUPU__UPPPP_P_P__ PUPPP____PU_P_PP_P_UU]___PP_PUUUUUPUUP_PUPUP___PPUU_PPP_PPUUPP_PPPU___P__PPUUU__PPPUPPU_PP_PUUUPUP_PPPPU__P P____PUU_UPPPU_UPU_PUP PP_PPPU_UU___PU_PP_PU_PP___U__P_U_UPPUP_UUUPP_P_UU_UUU_PUP]PU_PU_UU_PUUP_PPUUP_PPPUPUPPPU PU_UUPU__PP_P_UUPPPPUPPPP_PUUUUP_PPP_U___PPP___UPP_U_PUUP__UPP_P_PU_PUPPPUPUP_PPUPU_P_PPPUUP]_PPPUU_U_PU_P_P__U__UPUP__PP_U__UU__PU_]UUUUPP_UPUUPU_PUPPP___P_P__P_UUU_U_P]P_UP__PP_PUPPU_P_P_P__UPUUPUPUUU_PPP_PUU_______U__UU_UP_UUP__P__PU_UPUU_UUUUUU__P_PPPPU_U _U__UU_UPP_U_U_PUPUUUUPU_UUPU__UPUPPUPPU__UUP__UUUUUPU__P_U_U_UPPPP_U_PU_PPPUPPPP_PPU_PUPUPUUP__PUU_PU_PU__U_UPPPP___P_UPUU_U_PUP__PUP__U__UPUUP_PUPPUUPP_P__PPP_P_UPPP_PU_UP_PPUU_UP__PP___P__PP_PP_PUPPPPU___UPPUPUP___P_U_UPUPP_PPUU__UUPPP__U_UUP__U___P__PUUUPP_P_U_P_UU_PUUPUPUP__PPPUP___PPPP__UPP__UU_UU__P_U___PPPUUUUUU_P_PPPU__PPPU_UUUPUP_PP_UU_U__U__P_UP_P_U_PP_UPUPP_PU_P_UP_P__UPP_U_UUU_U___PUUUPU____U_PPUU_UP_P_UPPPPU_U__PUP_P_U_U_P_PUPUP_PUU__UUPUP_PU_UU__U_PP_PUPUU_UPUU__UU___UP__PPUU_P____PUUUP_PUPP__UP__PP_UPUPP_U_UP_P_PUU__PPPU___P_PP_UUPUU_UUPUUUP_P_UU_UU_PP__PUUPU__PU_PP_PPP__U_PP_P_UUP_UUUPPPUPPPPUUP_PUUUPU_U__P_PPPU_PUP_UPPU_PUPUP__UPPUU_P__UP_U_UUUPP_U__PUPP___P__U_P_UP_UPP__UU_PU_U_U__UUP_U_PPUU_U_PUPPPPP_U_U_PP_PP_UPUU_UP_U___UUUUUPPUP_P_P_UP_U_P_P__PU__UPP_____P___PPUPUPP_UPUPU_U_PPUPP_-- title: many corruptions -- author: nice data swapping -- desc: yess -- script: lua -- early orange style intro: noise on bg (dark) / far polygons / noise (med) / mid polys / noise (sprites?)/ near polys -- * 4 bit -> 1 bit gf convertor -- * one of the rift fonts.. -- * flength(string) : return pixel length of string for fprint -- * better cube points and triangles -- * translatep (takes point) etc -- * test translatep etc -- * music sync timing -- * noisy redraw function (no cls and lots of noise) -- * slowly change the palette hue, pulse intensity -- * effect data, split main and overlay -- TODO 3D -- make normal detection in update work -- more 3d objects -- optomise rotatet (ax*57 once, do all points at once etc) -- remove 3d arrays -- wireframe overlay/alt -- TODO MAIN -- test speed of instance at start -> how much noise etc (type title char by char as progress bar) -- wavetabling (reuse for visuals) -- TODO PATTERNS -- rotating triangles for pattern effect? skewed in 3d -- saskia freeke style @sasj_nl -- -- or use the map for effect/pattern/sprite/text?? --[[ ++ add yellow palette ++ seperate out cube/rectangle/etc from draw +- a couple of overlay spriteblocks +- mirror and random patterns ++ tusk circle thing -- twister triangles -- wedges variations -- two cubes etc variations -- re add fbevs effect -- tunnel/drop pattern ]] --[[ all your oink belong to us [pouet pig for oink, flashing] origins of the oink photo sensitivity warning codec killer threat dutch colour scheme promise we are sorry for your eyeballs. for Jimmy Kelly, 1953-2020, who loved words and tea ]] debug = 0 texts={ {" "}, {"Tea Lovers Committee"}, {"Presents"}, {"MANY HOGS"}, --4 {"MANY HOGS","MEAN","MANY BOGS"}, {"STRIPPED LOGS","NO TOGS"}, {"MANY HOGS","KNOW YOU ATE BACON"}, {"MANY HOGS","DONT YOU BE FAKON"}, --8 {"MANY HOGS","FROM ANCIENT FOGS"}, {"HOGS RIDDEN","BY ANGRY FROGS"}, {"FERAL FROGS ON FERAL HOGS"}, {"CRUSH UPRIGHT SHIELDS"}, {"BURY MANY MEN"}, {"OUT ON OPEN FIELDS"}, --14 {"TUSKS LEAVE HUSKS"}, {"TUSKS DIG UP BORDERS"}, {"TUSKS LEAVE HOLES"}, {"IN NIGEL'S ORDERS"}, {"MANY TUSKS KNACKER","REBEL HORSES"}, {"SHOULDNT HAVE ASKED","FOR EQUAL QUARTERS"}, --20 {"SHORT HUNTS LONG","HEARS UNHEEDED ORDERS"}, {"SOFT SILLY FEET","TASTY 2 LEG TREAT"}, {"THEIR SNOUT FULL OF TROUT", "THEIR SNOUTS TO THE TROUGH"}, {"THEIR BORIS WILL FIT","WE'LL EAT THE TOFF"}, --24 --{"WE FORAGE IN FOREST","WE BATH IN THE MUD"}, -- we forage in forest, we bath in the mud --{"FOR/TOWARD THE THREAT", "THEN TRAMPLING AS FLOOD"}, {""}, {""}, --26 {"SWINE SCROLLING","TROTTERS ROLLING"}, --{"PORKO ROSSO", "NO PORKO RISSOTTO"}, {"TAILS UP AND TWISTING","AND HORRORS UNFOLDING"}, {"SWINE ON THE TWINE", "ALL MINE ALL SWINE"}, {"FOUR TO THE BOAR","2 LEGS TO THE FLOOR"}, {"THE FARMER NO MORE","= FOUR LEGS MOAR"}, -- the farmer no more, and four legs {ever]moar --31 {"porkgramming","MANTRATRONIC","ALDROID","FBEV"}, {"trackling", "FBEV"}, {"pigsels", "MANTRATRONIC","BOSSMAN","DECCA"}, --34 {"Poork Brain", "TPLOM", "Lamp Ninja", "Praximo"}, {"Matt Voltage", "Huamalauta", "Nuanse", "Edsire"}, {"Hogicoma", "Titanass", "TIRS", "Bendbitaz"}, {"Hooy-Porkramming","Slopstream","Sithbifters","Quidriga"}, {"sNESBOX", "S711", "AYCE", "FCCF", "RaFT"}, --39 {"for Jimmy Kelly", "1953-2020", "who loved words and tea"}, --40 {"the end"}, {"2"}, {"3"}, {"4"} } t=0 foo_data={} function foo_init() end function foo_update(ft) end function foo_draw(ft) end cube={ 1,1,1, 1,1,-1, 1,-1,1, 1,-1,-6, -1,1,1, -1,1,-3, -1,-1,1, -1,-1,-2} cubet={{1,4,2},{1,3,4},{5,6,8},{5,8,7},{1,2,6},{1,6,5},{3,8,4},{3,7,8},{1,5,7},{1,7,3},{2,8,6},{2,4,8}} pt3da = {} --pt3dad = {} -- PolyTest 3d Polys pt3dp = {} -- p1,p2,p3,normal pt3dpd = {} -- p1,p2,p3,normal - moved to screen -- PolyTest 2d Polys pt2dp = {} -- "" function polytest_init() -- put data into proper 3d point format pt3da = into3dpointarray(cube) -- build triangle array from 3d points for i=1,#cubet do holda = cubet[i] holdt = {p1 = pt3da[holda[1]],p2 = pt3da[holda[2]],p3 = pt3da[holda[3]]} table.insert(pt3dp,holdt) end -- get normals? end function polytest_update(ft) pt3dpd = {} for i=1,#pt3dp do -- rotate by time ps = scalet(pt3dp[i],1,2,1) pt = translatet(ps,0,2,0)--((ft/100) % 10)-5,0,0) pr = rotatet(pt, pivot, (ft/1000), (ft/900), (ft/800)) ps = scalet(pr,20,20,20) pt = translatet(ps,0,0,100)--((ft/100) % 10)-5,0,0) pr = pt--rotatet(pt, pivot, 0, (ft/8000),0) -- get normals pr.n = normalt(pr) table.insert(pt3dpd,pr) end end function rect3_update(ft) pt3dpd = {} local cp = {x=0,y=4,z=0,n=0} local ccp = {} for j = 1,3 do for i=1,#pt3dp do -- rotate by time ps = scalet(pt3dp[i],1,2,1) ccp = rotate(cp,pivot,j/3,0,0) pr = rotatet(ps, pivot, j/3, 0.125,0) pt = translatet(pr,ccp.x,ccp.y,ccp.z)--((ft/100) % 10)-5,0,0) --prr = rotatet(pt, pivot, j/3, 0,0) pr = rotatet(pt, pivot, (ft/400), (ft/3000), (ft/2000)) ps = scalet(pr,20,16,20) pt = translatet(ps,0,0,100)--((ft/100) % 10)-5,0,0) pr = pt--rotatet(pt, pivot, 0, (ft/8000),0) -- get normals pr.n = normalt(pr) table.insert(pt3dpd,pr) end end end function cube_update(ft) pt3dpd = {} for i=1,#pt3dp do -- rotate by time pr = rotatet(pt3dp[i], pivot, (ft/1000), (ft/900), (ft/800)) ps = scalet(pr,30,30,30) pt = translatet(ps,0,0,100)--((ft/100) % 10)-5,0,0) -- get normals pt.n = normalt(pt) table.insert(pt3dpd,pt) end end function cubepulse_update(ft) pt3dpd = {} -- pulse by beat local cubescale = 30 + 10 * math.sin(.25 + mscurrent/(msperbeat*4)) for i=1,#pt3dp do -- rotate by time pr = rotatet(pt3dp[i], pivot, (ft/1000), (ft/900), (ft/800)) ps = scalet(pr,cubescale,cubescale,cubescale) pt = translatet(ps,0,0,100)--((ft/100) % 10)-5,0,0) -- get normals pt.n = normalt(pt) table.insert(pt3dpd,pt) end end function cube2_update(ft) pt3dpd = {} for i=1,#pt3dp do -- rotate by time pt = translatet(pt3dp[i],3,0,0)--((ft/100) % 10)-5,0,0) pr = rotatet(pt, pivot, (ft/500), (ft/900), (ft/800)) ps = scalet(pr,30,30,30) pt = translatet(ps,0,0,100)--((ft/100) % 10)-5,0,0) -- get normals pt.n = normalt(pt) table.insert(pt3dpd,pt) end for i=1,#pt3dp do -- rotate by time pt = translatet(pt3dp[i],-3,0,0)--((ft/100) % 10)-5,0,0) pr = rotatet(pt, pivot, (ft/500), (ft/900), (ft/800)) ps = scalet(pr,30,30,30) pt = translatet(ps,0,0,100)--((ft/100) % 10)-5,0,0) -- get normals pt.n = normalt(pt) table.insert(pt3dpd,pt) end end function polytest_draw(ft) -- zsort zsort(pt3dpd) -- put into 2d array pt2dp={} for i=1, #pt3dpd do h3d = pt3dpd[i] -- backface culling off normal TODO MAKE FUCKING WORK if h3d.n.z < -0.2 then h2d = {p1=p2d(h3d.p1),p2=p2d(h3d.p2),p3=p2d(h3d.p3),c=dprod(h3d.n, light)} table.insert(pt2dp, h2d) end end -- draw for i=1,#pt2dp do h2d = pt2dp[i] tri(h2d.p1.x,h2d.p1.y,h2d.p2.x,h2d.p2.y,h2d.p3.x,h2d.p3.y,math.floor(h2d.c*16)%16) end --print("pt:"..#pt3dad..":"..#pt3dpd..":"..#pt2dp,0,100) --print("t1:"..math.floor(pt2dp[1].p1.x)..":"..math.floor(pt2dp[1].p1.y)..":"..math.floor(pt2dp[1].p2.x)..":"..math.floor(pt2dp[1].p2.y)..":"..math.floor(pt2dp[1].p3.x)..":"..math.floor(pt2dp[1].p3.y)..":"..pt2dp[1].c,0,110) end ts_num=50 ts3dp = {} function trispiral2_init() end function trispiral2_init() end function trispiral2_draw(ft) local x,y,p1,p2,p3,cpnt, rotater local scaler = 20 for i=1, ts_num do p1={} p2={} p3={} -- get centre x,y x = 0+80*(i/ts_num) y = 0 -- get poly p1.x = x - 2 - scaler*(i/ts_num) p1.y = y - 2 - scaler*(i/ts_num) p2.x = x + 2 + scaler*(i/ts_num) p2.y = y - 2 - scaler*(i/ts_num) p3.x = x p3.y = y + 2 + scaler*(i/ts_num) rotater = STSIZE * (i/ts_num + ft/100) * (1 + sint[math.floor(STSIZE*ft/2000)%STSIZE]) -- get rotation by centre cpnt = rotate2d(x,y,rotater) p1 = rotate2d(p1.x,p1.y,rotater) p2 = rotate2d(p2.x,p2.y,rotater) p3 = rotate2d(p3.x,p3.y,rotater) -- display tri(p1.x + cpnt.x + cx,p1.y + cpnt.y +cy,p2.x + cpnt.x + cx,p2.y + cpnt.y + cy,p3.x + cpnt.x + cx,p3.y + cpnt.y + cy, math.floor(16*i/ts_num)%16) --tri(10,10,15,15,10,15,15) end end function trispiral3_draw(ft) local x,y,p1,p2,p3,cpnt local scaler = 15 for i=1, ts_num do p1={} p2={} p3={} -- get centre x,y x = 0+120*(i/ts_num) y = 0 -- get poly p1.x = x - 2 - scaler*(i/ts_num) p1.y = y - 2 - scaler*(i/ts_num) p2.x = x + 2 + scaler*(i/ts_num) p2.y = y - 3 - scaler*(i/ts_num) p3.x = x p3.y = y + 2 + scaler*(i/ts_num) -- get rotation by centre cpnt = rotate2d(x,y,STSIZE * (i/ts_num + ft/100)) p1 = rotate2d(p1.x,p1.y,STSIZE * (i/ts_num + ft/100)) -- display tri(p1.x + cpnt.x + cx,p1.y + cpnt.y +cy,p2.x + cpnt.x + cx,p2.y + cpnt.y + cy,p3.x + cpnt.x + cx,p3.y + cpnt.y + cy, math.floor(16*i/ts_num)%16) --tri(10,10,15,15,10,15,15) end end function trispiral_init() -- set 3 starting points add to array local cpnt1 = {x=10,y=0,z=0} local cpnt2 = {x=15,y=0,z=0} local cpnt3 = {x=12.5,y=5,z=0} local holdpoint = {} local ctri = {p1 = cpnt1, p2=cpnt2, p3=cpnt3, n=cpnt1} local ltri = {} table.insert(ts3dp, ctri) -- take two of the previous points, gen 3rd, add to array for i=2,ts_num do ltri = ctri ctri = {} ctri.p1 = ltri.p2 ctri.p2 = ltri.p3 -- gen 3rd point --holdpoint.x = (ctri.p1.x + ctri.p2.x)/2 --holdpoint.y = (ctri.p1.y + ctri.p2.y)/2 --holdpoint.z = (ctri.p1.z + ctri.p2.z)/2 holdpoint.x = ctri.p2.x holdpoint.y = (ctri.p1.y + ctri.p2.y)/2 holdpoint.z = -i -- (ctri.p1.z + ctri.p2.z)/2 ctri.p3 = rotate(holdpoint, pivot, 0, 0, 0.3) ctri.p3.z = ctri.p3.z + 2 table.insert(ts3dp, ctri) end end function trispiral_update(ft) -- rotate the lot? pt3dpd = {} for i=1,#ts3dp do -- rotate by time pr = rotatet(ts3dp[i], pivot, 0.75, ft/100, 0) ps = scalet(pr,10,10,10) pt = translatet(ps,0,0,200)--((ft/100) % 10)-5,0,0) -- get normals pt.n = normalt(pt) table.insert(pt3dpd,pt) end end function trispiral_draw(ft) -- zsort zsort(pt3dpd) -- put into 2d array pt2dp={} for i=1, #pt3dpd do h3d = pt3dpd[i] -- backface culling off normal TODO MAKE FUCKING WORK --if h3d.n.z < -0.1 then h2d = {p1=p2d(h3d.p1),p2=p2d(h3d.p2),p3=p2d(h3d.p3),c=dprod(h3d.n, light)} table.insert(pt2dp, h2d) --end end -- draw for i=1,#pt2dp do h2d = pt2dp[i] tri(h2d.p1.x,h2d.p1.y,h2d.p2.x,h2d.p2.y,h2d.p3.x,h2d.p3.y,math.floor(i)%16) end --print("pt:"..#pt3dad..":"..#pt3dpd..":"..#pt2dp,0,100) --print("t1:"..math.floor(pt2dp[1].p1.x)..":"..math.floor(pt2dp[1].p1.y)..":"..math.floor(pt2dp[1].p2.x)..":"..math.floor(pt2dp[1].p2.y)..":"..math.floor(pt2dp[1].p3.x)..":"..math.floor(pt2dp[1].p3.y)..":"..pt2dp[1].c,0,110) end wedgep = { -1,0,-1, 1,0,-1, 0,1,0, 0,0,1 } wedget = { {2,3,1}, {1,4,2}, {4,3,2}, {1,3,4} } w3da = {} w3dp = {} function wedge_init() w3da = into3dpointarray(wedgep) -- build triangle array from 3d points for i=1,#wedget do holda = wedget[i] holdt = {p1 = w3da[holda[1]],p2 = w3da[holda[2]],p3 = w3da[holda[3]]} table.insert(w3dp,holdt) end end w3dpd = {} w2dp={} nwedges = 10 function wedge_update(ft) w3dpd = {} local dist = {x=40+60*((mscurrent/(msperbeat*64))%1),y=0,z=0} -- make a circle of wedges, pointing out for i=1,#w3dp do for j=1,nwedges do -- rotate by time pr={} ps={} pt={} pr = rotatet(w3dp[i], pivot,(ft/50)*j,(ft/80)*j,(j+5)/nwedges)-- (ft/1000), (ft/900), (ft/800)) ps = scalet(pr,10,10,10) pdist = rotate(dist, pivot,0, (j/nwedges)+(ft/10),0)-- + (ft/100)) pt = translatet(ps,pdist.x,pdist.y,pdist.z+50)--((ft/100) % 10)-5,0,0) prr = pt--rotatet(pt, pivot, 0,0,2*j/nwedges) -- get normals pt.n = normalt(pt) table.insert(w3dpd,pt) end end end function wedge2_update(ft) w3dpd = {} local dist = {x=30,y=0,z=0} -- make a circle of wedges, pointing out for i=1,#w3dp do for j=1,nwedges do -- rotate by time pr={} ps={} pt={} prr={} pr = rotatet(w3dp[i], pivot,ft/2+j/nwedges,ft/3+(j+3)/nwedges,(j+5)/nwedges)-- (ft/1000), (ft/900), (ft/800)) ps = scalet(pr,10,10,10) pdist = rotate(dist, pivot,0, (j/nwedges),0)-- + (ft/100)) pt = translatet(ps,pdist.x,pdist.y,pdist.z)--((ft/100) % 10)-5,0,0) prr = rotatet(pt, pivot, ft/5,0,ft/7) -- get normals prr.n = normalt(prr) table.insert(w3dpd,prr) end end end function wedge_draw(ft) --wedge_update(ft/1000) -- for each poly, check -- zsort zsort(w3dpd) -- put into 2d array w2dp={} for i=1, #w3dpd do h3d = w3dpd[i] -- backface culling off normal TODO MAKE FUCKING WORK if h3d.n.z < 0 then h2d = {p1=p2d(h3d.p1),p2=p2d(h3d.p2),p3=p2d(h3d.p3),c=dprod(h3d.n, light)} table.insert(w2dp, h2d) end end -- draw for i=1,#w2dp do h2d = w2dp[i] tri(h2d.p1.x,h2d.p1.y,h2d.p2.x,h2d.p2.y,h2d.p3.x,h2d.p3.y,math.floor(h2d.c*16)%16) end end -- bees and bombs inpired -- grid of pigs, each square moving independantly, rotating around centre -- colour cycle - https://github.com/nesbox/TIC-80/wiki/Advanced-Drawing-Techniques -- vary size, zoom?, motion, transform to circles/triangles/etc, diagonal lines, pig images piggrid_data={} function piggrid_init() end function piggrid_update(ft) end function piggrid_draw(ft) -- select method poke4(2*0x03ffc,12) for i=0,3 do for j=0,3 do poke4(2*0x03FF0 + 1, i+j) spr(0,40+(20*i),40+(16*j),0,1,0,0,2,2) end end end texstartx = 0 texstarty = 0x80 function texrec(x0,y0,dx1, dy1, dx2,dy2) textri(x0 ,y0 , x0+dx1,y0+dy1, x0+dx2,y0+dy2, texstartx,texstarty, texstartx + 16, texstarty, texstartx, texstarty+ 16) textri(x0+dx2,y0+dy2, x0+dx1,y0+dy1, x0+dx1+dx2,y0+dy1+dy2, texstartx,texstarty+16, texstartx+16,texstarty, texstartx+16,texstarty+16) end function fillvert(sx, sy, dxx, dxy, dyx, dyy) repeat texrec(sx, sy, dxx, dxy, dyx, dyy) sx = sx + dyx sy = sy + dyy until sy > 178 or sy < -42 -- magic numbers = screen size + fudge factor for drawing any half-visible sprites end function fillhoriz(sx, sy, dxx, dxy, dyx, dyy) repeat fillvert(sx, sy, dxx, dxy, dyx, dyy) sx = sx + dxx sy = sy + dxy until sx > 282 or sx < -42 end function cheese_draw(t) rotzoom = 2.5+math.sin(t/11) rottime = t/32 offsetx = 120+80 * math.sin(t/40) offsety = 68+ 80 * math.sin(t/56) dxx = 32*math.cos(rottime)*rotzoom dxy = 32*math.sin(rottime)*rotzoom dyx =-32*math.sin(rottime)*rotzoom dyy = 32*math.cos(rottime)*rotzoom -- switch the colour poke4(2*0x03FF0 + 1, 8) fillhoriz(offsetx, offsety,dxx, dxy, dyx, dyy) fillhoriz(offsetx, offsety,-dxx, -dxy, dyx, dyy) fillhoriz(offsetx, offsety,dxx, dxy, -dyx, -dyy) fillhoriz(offsetx, offsety,-dxx, -dxy, -dyx, -dyy) poke4(2*0x03FF0 + 1, 1) end function drawcurve(k,a,p,d,g) --magic numbers to be passed --vertical offset --k = 50 --vertical amp --a = 20 --pal --p = 2 --division factor --d = 30 local i = 1 local j = 1 line = {} for i=1,120,1 do line[i] = 2 + (sint[math.floor(STSIZE*i/d)%STSIZE] * a) end for j=1,120,1 do for gap=0,g,1 do rect(119+j,line[j] + k + gap,1,1,p) rect(120-j,line[j] + k + gap,1,1,p) end end end function newcurve(num_curve) mc[num_curve] = {} mc[num_curve][1] = math.random(500) mc[num_curve][2] = 30*num_curve mc[num_curve][3] = math.random(10)+10 mc[num_curve][4] = num_curve*nc mc[num_curve][5] = math.random(10)+4 mc[num_curve][6] = math.random(50) mc[num_curve][7] = math.random(10) mc[num_curve][8] = math.random(10) mc[num_curve][9] = math.random(10) end mc = {} nc = 3 function curves_init() for nm=1,nc,1 do newcurve(nm) end end function curves_draw(ft) local k,a,p,d,g,tick,slowtick tick = ft slowtick=tick / 50; for n=1,nc,1 do if tick % mc[n][1] == 0 then --newcurve(n) end csin = sint[math.floor(STSIZE*(slowtick%30)%STSIZE)] k=mc[n][2] a=mc[n][3]+(csin*2*mc[n][9]) p=mc[n][4] d=mc[n][5]+(csin*mc[n][7]) g=mc[n][6]+(csin*mc[n][8]) drawcurve(k,a,p,d,g) end end cd_num = 120 cd_circs={} --x,y,c set format function circdance_init() local c = {} for i=1,cd_num do cd_circs[i] = {x=60+(i),y=67,c=(i/8)%16} end end function circdance_update(ft) local c, rc for i=1,cd_num do c = cd_circs[i] rc = rotate2d(c.x-120, c.y-67, 5) c.x = rc.x +120 c.y = rc.y + 67 cd_circs[i] = c end end function circdance_draw(ft) local c = {} circdance_update(ft) for i=1,cd_num do c = cd_circs[i] circb(c.x,c.y,30+(i/10),c.c) end circ(c.x,c.y,30+(cd_num/10),c.c) end tusk_num = 120 tusk_circs={} -- x, y, c, s function tusks_init() local c = {} local rc for i=1,tusk_num/2 do rc = rotate2d(0-1.5*i, -20-i, 1.2*QSTS + QSTS/(tusk_num/2)*i) --tusk_circs[i] = {x=cx + math.sin(i/(tusk_num/2)),y=67,c=(i/8)%16} --tusk_circs[i+tusk_num/2] = {x=cx - math.sin(i/(tusk_num/2)),y=67,c=(16 - i/8)%16} tusk_circs[i] = {x=120+rc.x,y=68+rc.y, c=(16* i/(tusk_num/2))%16 -1, s=i/2} tusk_circs[i+tusk_num/2] = {x=120-rc.x,y=68+rc.y, c=(16* i/(tusk_num/2))%16 -1, s=i/2} end end function tusks2_update(ft) local c = {} local rc tusk_circs={} for i=1,tusk_num/2 do -- rc = rotate2d(60, 0, STSIZE*rott + QSTS/(tusk_num/2)*i) rc = rotate2d(60, 0, STSIZE*(ft/32) + 0.8*HSTS/(tusk_num/2)*i) tusk_circs[i] = {x=120+rc.x,y=120+rc.y, c=(8* i/(tusk_num/2))%9 +3, s=i/2} tusk_circs[i+tusk_num/2] = {x=120-rc.x,y=120-rc.y, c=(8* i/(tusk_num/2))%9+3 , s=i/2} end end function tusks_update(ft) local rc -- get most forward circle, work back? cnum = (tusk_num/2) fc = math.floor(ft)%cnum rott = math.sin(ft/8) count = 1 if (fc > cnum/2) then -- we are closer to the end then beginning for i=1,fc do rc = rotate2d(0-1.4*i, -20-i, (1.1+.1*rott)*QSTS + QSTS/cnum*i) dc = 1 - (math.abs(fc-i) / cnum) tusk_circs[count] = {x=120+rc.x,y=68+rc.y, c=8*dc +6, s=i/2} tusk_circs[count+cnum] = {x=120-rc.x,y=68+rc.y, c=8*dc +6, s=i/2} -- tusk_circs[i+cnum] = {x=120-rc.x,y=68+rc.y, c=(8* (i+ft*2)/cnum)%8+4, s=i/2} count = count + 1 end for i=cnum, fc, -1 do rc = rotate2d(0-1.4*i, -20-i, (1.1+.1*rott)*QSTS + QSTS/cnum*i) dc = 1 - (math.abs(fc-i) / cnum) tusk_circs[count] = {x=120+rc.x,y=68+rc.y, c=8*dc +6, s=i/2} tusk_circs[count+cnum] = {x=120-rc.x,y=68+rc.y, c=8*dc +6, s=i/2} count = count + 1 end else -- we are closer to the beginning then end for i=cnum, fc, -1 do rc = rotate2d(0-1.4*i, -20-i, (1.1+.1*rott)*QSTS + QSTS/cnum*i) dc = 1 - (math.abs(fc-i) / cnum) tusk_circs[count] = {x=120+rc.x,y=68+rc.y, c=8*dc+6, s=i/2} tusk_circs[count+cnum] = {x=120-rc.x,y=68+rc.y, c=8*dc +6, s=i/2} count = count + 1 end for i=1,fc do rc = rotate2d(0-1.4*i, -20-i, (1.1+.1*rott)*QSTS + QSTS/cnum*i) dc = 1 - (math.abs(fc-i) / cnum) tusk_circs[count] = {x=120+rc.x,y=68+rc.y, c=8*dc+6, s=i/2} tusk_circs[count+cnum] = {x=120-rc.x,y=68+rc.y, c=8*dc +6, s=i/2} -- tusk_circs[i+cnum] = {x=120-rc.x,y=68+rc.y, c=(8* (i+ft*2)/cnum)%8+4, s=i/2} count = count + 1 end end end function tusks_draw(ft) local c = {} --circdance_update(ft) for i=1,#tusk_circs do c = tusk_circs[i] circ(c.x,c.y-50,c.s,c.c) end --c = tusk_circs[tusk_num/2] --circ(c.x,c.y,c.s,c.c) --c = tusk_circs[tusk_num] --circ(c.x,c.y,c.s,c.c) end -- font data {"A", sprite number, page?, num sprites x, y, width (px), height} fontd={ {0,0,1,2,8,16},{1,0,1,2,8,16},{2,0,1,2,8,16},{3,0,1,2,8,16},{4,0,1,2,8,16},{5,0,1,2,8,16},{6,0,1,2,8,16},{7,0,1,2,8,16},{8,0,1,2,3,16},{9,0,1,2,4,16},{10,0,1,2,8,16},{11,0,1,2,8,16},{12,0,2,2,13,16},{14,0,1,2,8,16},{15,0,1,2,8,16}, {128,0,1,2,8,16},{129,0,1,2,8,16},{130,0,1,2,8,16},{131,0,1,2,8,16},{132,0,1,2,7,16},{133,0,1,2,8,16},{134,0,1,2,8,16},{135,0,2,2,13,16},{137,0,1,2,8,16},{138,0,1,2,7,16},{139,0,1,2,8,16},{140,0,1,2,8,16},{141,0,1,2,8,16},{142,0,1,2,8,16},{143,0,1,2,8,16}, {256,0,1,2,8,16},{257,0,1,2,6,16},{258,0,1,3,8,19},{259,0,1,2,8,16},{260,0,1,2,3,16},{261,0,1,3,4,19},{262,0,1,2,8,16},{263,0,1,2,3,16},{264,0,2,2,13,16},{266,0,1,2,8,16},{267,0,1,2,8,16},{268,0,1,3,8,19},{269,0,1,3,8,19},{270,0,1,2,5,16},{271,0,1,2,8,16}, {448,0,1,2,6,16},{449,0,1,2,8,16},{450,0,1,2,8,16},{451,0,2,2,13,16},{453,0,1,2,8,16},{454,0,1,3,8,19},{455,0,1,2,8,16},{456,0,1,2,3,16},{457,0,1,2,6,16},{458,0,1,2,3,16},{459,0,1,2,6,16},{460,0,1,2,3,16},{461,0,1,2,6,16},{462,0,1,2,2,16},{463,0,1,2,8,16}, {640,0,1,2,8,16},{641,0,1,2,8,16},{642,0,1,2,8,16},{643,0,1,2,8,16},{644,0,1,2,8,16},{645,0,1,2,8,16},{646,0,1,2,8,16},{647,0,1,2,8,16},{648,0,1,2,8,16},{649,0,1,2,8,16},{650,0,1,2,2,16},{651,0,1,2,6,16},{652,0,2,2,9,16},{654,0,2,2,15,16}, {768,0,1,2,8,16} } -- this could be useful for compression later font = {} chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!\"\'+,-./0123456789:=?@ " function font_init() for i=1,#fontd do font[string.sub(chars,i,i)] = fontd[i] end end function flength(txt,kx) kx = kx or 1 pcx = 0 letter ={} for i=1,string.len(txt) do letter = font[string.sub(txt,i,i)] -- update kerning pcx = pcx + letter[5] + kx end return pcx end -- fprint ("text", x, y, [x kerning = 1],[y kerning = 1], [colour = 15]) function fprint(txt,tx,ty,kx,ky,tc) kx = kx or 1 ky = ky or 1 tc = tc or 15 pcx = 0 pcy = 0 letter ={} -- set to blit segment (8 = BG-1) poke4(2*0x03ffc,8) -- set colour poke4(2*0x03FF0 + 1, tc) -- print each letter for i=1,string.len(txt) do letter = font[string.sub(txt,i,i)] spr(letter[1],tx+pcx,ty+pcy,0,1,0,0,letter[3],letter[4]) -- update kerning pcx = pcx + letter[5] + kx end end ------------------------- -- p3d.tic demo code ---- cx=120 cy=68 cz=100 pivot={x=0,y=0,z=0} light={x=0,y=0,z=1} angle=0 function p2d(p3d) local fov = 180 local x0 = p3d.x-- + cx local y0 = p3d.y-- + cy local z0 = p3d.z + cz local x2d = fov * x0 / z0 local y2d = fov * y0 / z0 local po = {} x2d = x2d + cx --center w y2d = y2d + cy --center h po = {x = x2d, y = y2d} return po end function into3dpointarray(flatpoints) out3dpa = {} out3dp = {} for i=1,#flatpoints/3 do out3dp = {} start = ((i-1) * 3) + 1 out3dp.x = flatpoints[start] out3dp.y = flatpoints[start+1] out3dp.z = flatpoints[start+2] table.insert(out3dpa,out3dp) end return out3dpa end -- with my optimizing function rotate(p3d,center,ax,ay,az) local a,b,c local a1,b1,c1 local a2,b2,c2 local a3,b2,c3 local ac,as,bc,bs,cc,cs local np3d={x=0,y=0,z=0,c=0} a = p3d.x-center.x b = p3d.y-center.y c = p3d.z-center.z as = sint[math.floor(STSIZE*az)%STSIZE] ac = sint[(QSTS+math.floor(STSIZE*az))%STSIZE] a1 = a*ac-b*as b1 = a*as+b*ac c1 = c bs = sint[math.floor(STSIZE*ay)%STSIZE] bc = sint[(QSTS+math.floor(STSIZE*ay))%STSIZE] c2 = c1*bc-a1*bs a2 = c1*bs+a1*bc b2 = b1 cs = sint[math.floor(STSIZE*ax)%STSIZE] cc = sint[(QSTS+math.floor(STSIZE*ax))%STSIZE] b3 = b2*cc-c2*cs c3 = b2*cs+c2*cc a3 = a2 np3d.x=a3-center.x np3d.y=b3-center.y np3d.z=c3-center.z np3d.c=p3d.c return np3d end function rotatet(t3d,center,ax,ay,az) local nt3d={p1={},p2={},p3={},n={}} nt3d.p1 = rotate(t3d.p1,center,ax,ay,az) nt3d.p2 = rotate(t3d.p2,center,ax,ay,az) nt3d.p3 = rotate(t3d.p3,center,ax,ay,az) nt3d.n = t3d.n return nt3d end function zsort(p1,p2) return p1.z>p2.z end ------------------------- -- mine from p3d function translate(p3d,ax,ay,az) local np3d={x=0,y=0,z=0,c=0} np3d.x=p3d.x+ax np3d.y=p3d.y+ay np3d.z=p3d.z+az np3d.c=p3d.c return np3d end function translatet(t3d,ax,ay,az) local nt3d={p1={},p2={},p3={},n={}} nt3d.p1 = translate(t3d.p1,ax,ay,az) nt3d.p2 = translate(t3d.p2,ax,ay,az) nt3d.p3 = translate(t3d.p3,ax,ay,az) nt3d.n = t3d.n return nt3d end function scale(p3d,ax,ay,az) local np3d={x=0,y=0,z=0,c=0} np3d.x=p3d.x * ax np3d.y=p3d.y * ay np3d.z=p3d.z * az np3d.c=p3d.c return np3d end function scalet(t3d,ax,ay,az) local nt3d={p1={},p2={},p3={},n={}} nt3d.p1 = scale(t3d.p1,ax,ay,az) nt3d.p2 = scale(t3d.p2,ax,ay,az) nt3d.p3 = scale(t3d.p3,ax,ay,az) nt3d.n = t3d.n return nt3d end ------------------ useful math -- take in an array of tri's {x,y,z,m}, return an function zsort(ps) for i=1,#ps do local j = i while j > 1 and zsortp(ps[j-1],ps[j]) do ps[j-1],ps[j] = ps[j],ps[j-1] j = j-1 end end end function zsortp(t1,t2) return (t1.p1.z+t1.p2.z+t1.p3.z)<(t2.p1.z+t2.p2.z+t2.p3.z) end -- TODO standardize to cprod(a,b) function cprod(ax,ay,az,bx,by,bz) r = {x=(ay*bz)-(az*by),y=(ax*bz)-(az*bx),z=(ax*by)-(ay*bx)} return r end function dprod(a,b) return math.abs(a.x * b.x) + math.abs(a.y * b.y) + math.abs(a.z * b.z) end function normalize(v) local nv,sum sum = math.sqrt(v.x*v.x + v.y*v.y + v.z*v.z) nv = {x=v.x/sum,y=v.y/sum,z=v.z/sum} return nv end function normalt(t3d) ax = t3d.p2.x - t3d.p1.x ay = t3d.p2.y - t3d.p1.y az = t3d.p2.z - t3d.p1.z bx = t3d.p3.x - t3d.p1.x by = t3d.p3.y - t3d.p1.y bz = t3d.p3.z - t3d.p1.z return normalize(cprod(ax,ay,az,bx,by,bz)) end ------------------------- --- utils --------PALETTE CRAP function palspread(sr,sg,sb,er,eg,eb,twist) twist = twist or 0 -- 0: no twist, 1: twist red, 2: twist green, 4: twist blue dr = (er - sr)/16 dg = (eg - sg)/16 db = (eb - sb)/16 if twist == 0 then for i=0,15 do i3=i*3 currentP[(i*3)+1]=sr+(dr*i) --poke(0x3fc0+(i*3),sr+(dr*i)) currentP[(i*3)+2]=sg+(dg*i) --poke(0x3fc0+(i*3)+1,sg+(dg*i)) currentP[(i*3)+3]=sb+(db*i) --poke(0x3fc0+(i*3)+2,sb+(db*i)) end else for i=0,15 do iexp=(i/15)*(i/15)*(i/15)*15--(math.exp(i)) ctwist=twist if ctwist >= 4 then ib = db * iexp ctwist = ctwist-4 else ib = (db*i) end if ctwist >= 2 then ig = dg * iexp ctwist = ctwist-2 else ig = (dg*i) end if ctwist >= 1 then ir = dr * iexp else ir = (dr*i) end currentP[(i*3)+1]=sr+ir--poke(0x3fc0+(i*3),sr+ir) currentP[(i*3)+2]=sg+ig--poke(0x3fc0+(i*3)+1,sg+ig) currentP[(i*3)+3]=sb+ib--poke(0x3fc0+(i*3)+2,sb+ib) end end end function palmid(mr,mg,mb) dr = mr/8 dg = mg/8 db = mb/8 for i=0,7 do i3=i*3 currentP[(i*3)+1]=dr*i currentP[(i*3)+2]=dg*i currentP[(i*3)+3]=db*i end dr = (255-mr)/8 dg = (255-mg)/8 db = (255-mb)/8 for i=8,15 do i3=i*3 currentP[(i*3)+1]=mr+(dr*(i-8)) currentP[(i*3)+2]=mg+(dg*(i-8)) currentP[(i*3)+3]=mb+(db*(i-8)) end end function mixPalette(a,b,ratio) outP = {} ap = palettes[a] bp = palettes[b] for i=1,48 do outP[i]=ap[i]*(1-ratio) + bp[i]*ratio end return outP end function invertP(a) outP = {} ap = palettes[a] for i=1,48 do outP[i]=255-ap[i] end return outP end function setPalette(p) --currentP = p for i=0,15 do for j=0,2 do poke(0x03FC0 + (i*3) + j,p[(i*3) + j+1]) end end end function putPalette(p,s,n) for i=0,n do for j=0,2 do poke(0x03FC0 + ((i+s)*3) + j,p[(i*3) + j +1]) end end end -- aqua palette aqua = {0,0,0, 0,16,32, 0,32,64, 0,48,96, 0,64,128, 0,80,160, 0,96,192, 0,112,224, 0,128,255, 32,144,255, 64,160,255, 96,176,255, 128,192,255, 160,208,255, 192,224,255, 255,255,255} gray = {} palettes={} function noise(freq,col) local x,y for i=0,freq*5 do x =math.random(240)-1 y =math.random(136)-1 pix(x,y,col) end end function rotate2d(ix,iy,r) -- switch to p2d format? returns that already.. sina = sint[math.floor(r)%STSIZE] cosa = sint[(QSTS+math.floor(r))%STSIZE] rp= { x = (ix * cosa) - (iy * sina), y = (iy * cosa) + (ix * sina)} return rp end -- which sheet, width, height, images psrs1 = {9,2,2,{16,144,272,400,528,656,784,912}} -- note you have to -16 * (8-seg) to the shown sprite number PTRNS = { {9,2,2,{0,128,256,384,512,640,768,896}}, -- fattening lines {9,2,2,{2,130}}, -- waves {9,2,2,{4}}, -- waves 2 {9,2,2,{6,134,262,390,518,646,774}}, -- 2 curves {9,2,2,{0,8,136,264,392,520,648,776,904,906}}, -- morph to grid {10,2,2,{0,128,256,384,512,640,768,896}}, -- circles {9,2,2,{0,512,6,518,264,904,16,400}} -- random stuff } function prot(seg, wid, hei, pims, c, s) local ns, sw, sh, ix, iy -- target the blit segment poke4(2*0x03ffc,seg) -- switch the colour poke4(2*0x03FF0 + 1, c) ns = pims[(1+math.floor(beatcurrent/s))%(#pims+1)] --ns = pims[1] sw = math.ceil(240 / (8 * wid)) +1 sh = math.ceil(136 / (8 * hei)) +1 for ix=1,sw do for iy=1,sh do spr(ns,(ix-1)*16-((ts/25)%16),(iy-1)*16,0,1,0,0,wid,hei) end end end function pbou(seg, wid, hei, pims, c, s) local ns, sw, sh, ix, iy, temo -- target the blit segment poke4(2*0x03ffc,seg) -- switch the colour poke4(2*0x03FF0 + 1, c) temp = (1+math.floor(beatcurrent/s))%(2*#pims) --temp = ((beatcurrent/s)%(#pims+1)) if temp > #pims then temp = 2*#pims - temp end ns = pims[temp] --ns = pims[1] sw = math.ceil(240 / (8 * wid)) +1 sh = math.ceil(136 / (8 * hei)) +1 for ix=1,sw do for iy=1,sh do spr(ns,(ix-1)*16,(iy-1)*16,0,1,0,0,wid,hei) end end end function pmirror1(seg,wid,hei,pims,c,s) local ns, sw, sh, ix, iy -- target the blit segment poke4(2*0x03ffc,seg) -- switch the colour poke4(2*0x03FF0 + 1, c) ns = pims[(1+math.floor(beatcurrent/s))%(#pims+1)] --ns = pims[1] sw = math.ceil(240 / (8 * wid)) +1 sh = math.ceil(136 / (8 * hei)) +1 for ix=1,sw/2 do for iy=1,sh do spr(ns,(ix-1)*16-8,(iy-1)*16-((ts/25)%16),0,1,0,0,wid,hei) end end for ix=(sw/2), sw do for iy=1,sh do spr(ns,8+(ix-1)*16,(iy-1)*16-((ts/25)%16),0,1,1,0,wid,hei) end end end function pmirror2(seg,wid,hei,pims,c,s) local ns, sw, sh, ix, iy -- target the blit segment poke4(2*0x03ffc,seg) -- switch the colour poke4(2*0x03FF0 + 1, c) ns = pims[(1+math.floor(beatcurrent/s))%(#pims+1)] --ns = pims[1] sw = math.ceil(240 / (8 * wid)) +1 sh = math.ceil(136 / (8 * hei)) +1 for ix=1,sw/2 do for iy=1,sh/2 do spr(ns,(ix-1)*16-8,(iy-1)*16-8,0,1,0,0,wid,hei) end for iy=sh/2,sh do spr(ns,(ix-1)*16-8,(iy-1)*16+8,0,1,2,0,wid,hei) end end for ix=(sw/2), sw do for iy=1,sh/2 do spr(ns,8+(ix-1)*16,(iy-1)*16-8,0,1,1,0,wid,hei) end for iy=sh/2,sh do spr(ns,8+(ix-1)*16,(iy-1)*16+8,0,1,3,0,wid,hei) end end end hash = 13 hashtime = 0 function prandom2(seg,wid,hei,pims,c,s) local ns, sw, sh, ix, iy,fp,ro,shash -- target the blit segment poke4(2*0x03ffc,seg) -- switch the colour poke4(2*0x03FF0 + 1, c) if hashtime ~= (1+math.floor(beatcurrent/s))%(#pims+1) then hashtime = (1+math.floor(beatcurrent/s))%(#pims+1) hash = 10 + math.random(90) end --ns = pims[(1+math.floor(beatcurrent/s))%(#pims+1)] --ns = pims[1] sw = math.ceil(240 / (8 * wid)) +1 sh = math.ceil(136 / (8 * hei)) +1 for ix=1,sw do for iy=1,sh do shash = (hash*ix*iy) fp = shash % 4 ro = (shash * 3) % 4 ns = pims[hash%(#pims+1)] spr(ns,(ix-1)*16,(iy-1)*16,0,1,fp,ro,wid,hei) end end end function prandom(seg,wid,hei,pims,c,s) local ns, sw, sh, ix, iy,fp,ro,shash -- target the blit segment poke4(2*0x03ffc,seg) -- switch the colour poke4(2*0x03FF0 + 1, c) if hashtime ~= (1+math.floor(beatcurrent/s))%(#pims+1) then hashtime = (1+math.floor(beatcurrent/s))%(#pims+1) hash = 10 + math.random(90) end --ns = pims[(1+math.floor(beatcurrent/s))%(#pims+1)] --ns = pims[1] sw = math.ceil(240 / (8 * wid)) +1 sh = math.ceil(136 / (8 * hei)) +1 for ix=1,sw do for iy=1,sh do shash = (hash*ix*iy) fp = shash % 4 ro = (shash * 3) % 4 ns = pims[shash%(#pims+1)] spr(ns,(ix-1)*16,(iy-1)*16,0,1,fp,ro,wid,hei) end end end function ptunnel(seg,wid,hei,pims,c,s) local ns, sw, sh, ix, iy,ds -- target the blit segment poke4(2*0x03ffc,seg) -- switch the colour poke4(2*0x03FF0 + 1, c) ns = pims[(1+math.floor(beatcurrent/s))%(#pims+1)] --ns = pims[1] sw = math.ceil(240 / (8 * wid)) +1 sh = math.ceil(136 / (8 * hei)) +1 --ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) for ix=1,sw/2 do for iy=1,sh/2 do ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) ns = pims[(1+math.floor(beatcurrent/s - ds))%(#pims+1)] spr(ns,(ix-1)*16-8,(iy-1)*16-8,0,1,0,0,wid,hei) end for iy=sh/2,sh do ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) ns = pims[(1+math.floor(beatcurrent/s - ds))%(#pims+1)] spr(ns,(ix-1)*16-8,(iy-1)*16+8,0,1,2,0,wid,hei) end end for ix=(sw/2), sw do for iy=1,sh/2 do ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) ns = pims[(1+math.floor(beatcurrent/s - ds))%(#pims+1)] spr(ns,8+(ix-1)*16,(iy-1)*16-8,0,1,1,0,wid,hei) end for iy=sh/2,sh do ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) ns = pims[(1+math.floor(beatcurrent/s - ds))%(#pims+1)] spr(ns,8+(ix-1)*16,(iy-1)*16+8,0,1,3,0,wid,hei) end end end function ptunnel2(seg,wid,hei,pims,c,s) local ns, sw, sh, ix, iy,ds -- target the blit segment poke4(2*0x03ffc,seg) -- switch the colour poke4(2*0x03FF0 + 1, c) ns = pims[(1+math.floor(beatcurrent/s))%(#pims+1)] --ns = pims[1] sw = math.ceil(240 / (8 * wid)) +1 sh = math.ceil(136 / (8 * hei)) +1 --ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) for ix=1,sw/2 do for iy=1,sh/2 do ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) ns = pims[(1+math.floor(beatcurrent/s + ds))%(#pims+1)] spr(ns,(ix-1)*16-8,(iy-1)*16-8,0,1,0,0,wid,hei) end for iy=sh/2,sh do ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) ns = pims[(1+math.floor(beatcurrent/s + ds))%(#pims+1)] spr(ns,(ix-1)*16-8,(iy-1)*16+8,0,1,2,0,wid,hei) end end for ix=(sw/2), sw do for iy=1,sh/2 do ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) ns = pims[(1+math.floor(beatcurrent/s + ds))%(#pims+1)] spr(ns,8+(ix-1)*16,(iy-1)*16-8,0,1,1,0,wid,hei) end for iy=sh/2,sh do ds = math.sqrt((sh/2 - iy)*(sh/2 - iy) + (sw/2 - ix) * (sw/2 - ix)) ns = pims[(1+math.floor(beatcurrent/s + ds))%(#pims+1)] spr(ns,8+(ix-1)*16,(iy-1)*16+8,0,1,3,0,wid,hei) end end end function pattern1() local ns -- target the blit segment poke4(2*0x03ffc,9) -- switch the colour poke4(2*0x03FF0 + 1, 2) for ix=1,16 do for iy=1,9 do if ((ix+iy)%2)>0 then --ns=0 ns=2 else --ns=128 ns=130 end spr(ns,(ix-1)*16-((ts/25)%16),(iy-1)*16,0,1,0,0,2,2) end end end --sprite = #,blit segment, width, height sprites={ {896,8,1,1}, -- 1 blank {0,12,2,2}, -- 2 small pig face {2,12,2,2}, -- 3 piglet {136,12,8,8}, -- 4 big ugly pig face {0,13,8,8}, -- 5 medieval boar {640,12,8,6}, -- 6 down facing pig {0,11,16,11}, -- 7 logo {648,12,8,6}, -- 8 up facing pig {8,13,8,8} -- 9 pig rampant } --spriteblock = #sprite, colour, x, y, flip, rotate, move x, move y -- move x,y -- 0 no move -- 1-10 move left at speed -- 11-20 move right at speed -- 21-30 bounce at speed spriteblocks={ {{1,0,0,0,0,0,0,0}}, {{2,12,100,80,0,0,0,0}}, {{5,0,88,16,0,0,0,21}}, -- just the med boar {{7,15,57,16,0,0,0,0}}, {{5,0,88,16,0,0,0,21},{6,0,40,66,0,0,11,0},{6,0,134,66,1,0,1,0}}, -- moar boar {{4,8,120,46,0,0,0,11},{4,8,56,46,1,0,0,11}}, -- uplifting heads {{8,12,88,10,0,0,1,0},{8,12,88,78,1,0,11,0}}, {{9,15,88,40,0,0,0,0}}, -- rampant to the left {{9,15,88,40,1,0,0,0}}, -- rampant to the right {{9,15,56,40,1,0,0,0},{9,15,120,40,0,0,0,0}}, -- two rampant {{6,3,57,46,0,0,14,0},{6,7,58,46,0,0,13,0},{6,11,59,46,0,0,12,0},{6,15,60,46,0,0,11,0},{6,3,117,46,1,0,4,0},{6,7,116,46,1,0,3,0},{6,11,115,46,1,0,2,0},{6,15,114,46,1,0,1,0}} } opd = {sprites={{0,13,88,16,8,8,8}},text={"BOAR TO THE FLOOR","4 BOARS MORE"}} function opig() local sprs = opd.sprites local tl = opd.text local tlg local sprb,sprt,dx,dy -- draw sprites for i=1,#sprs do -- get sprite block sprb = sprs[i] -- get sprite sprt = sprites[sprb[1] ] -- target the blit segment poke4(2*0x03ffc,sprt[2]) -- switch the colour poke4(2*0x03FF0 + 1, sprb[2]) -- do the movement dx = 0 if (sprb[7] > 0) and (sprb[7] < 11) then dx = sprb[7]/2 * (mscurrent / msperbeat) elseif (sprb[7] > 10) and (sprb[7] < 21) then dx = - (sprb[7]-10)/2 * (mscurrent / msperbeat) elseif (sprb[7] > 20) and (sprb[7] < 31) then dx = 10 * sint[math.floor(10*(sprb[7]-20)*(mscurrent / msperbeat))%STSIZE] end dy = 0 if (sprb[8] == 0) then elseif (sprb[8] < 11) then dy = sprb[8]/2 * (mscurrent / msperbeat) elseif (sprb[8] > 10) and (sprb[8] < 21) then dy= - (sprb[8]-10)/2 * (mscurrent / msperbeat) elseif (sprb[8] > 20) and (sprb[8] < 31) then dy = 10 * sint[math.floor(4*(sprb[8]-20)*(mscurrent / msperbeat))%STSIZE] end -- draw the sprite spr(sprt[1],sprb[3] + dx,sprb[4] + dy,0,1,sprb[5],sprb[6],sprt[3],sprt[4]) end for i=1,#sprs do sprt = sprs[i] -- target the blit segment poke4(2*0x03ffc,sprt[2]) -- switch the colour poke4(2*0x03FF0 + 1, sprt[7]) -- draw the sprite spr(sprt[1],sprt[3],sprt[4]+10*sint[math.floor(ts)%STSIZE],0,1,0,0,sprt[5],sprt[6]) end -- draw text for i=1,#tl do -- get length tlg = flength(tl[i]) -- draw line of text fprint(tl[i],120-(tlg/2),50+(20*(i-#tl/2))) end poke4(2*0x03FF0 + 1, 1) end currentOP={} function OVR() setPalette(currentOP) rendero() if debug ==1 then te=time() ttt = ((ttt/10)*9)+((to-ts)/10) --print("TIC rt="..ttt,0,0,12) tto = ((tto/10)*9)+((te-to)/10) --print("OVR rt="..tto,0,10,12) tt = ((tt/10)*9)+((te-ts)/10) --print("rt="..tt,0,20,12) print("hz="..math.floor(1000/tt),0,0,12) tracktempo=peek(0x13e94) -- print("bpm:"..(tracktempo+150).." msperbeat:"..((1/peek(0x13e94))*1000),0,40,15) print("beat:"..beattime.."beatstart:"..beatstart.." beatcurrent:"..beatcurrent,0,40,15) -- print("scene:"..scenecurrent.."beatstart:"..beatstart.." beatcurrent:"..beatcurrent,0,40,15) end end currentP={} function SCN(l) if (l==0) then setPalette(currentP) end end scene={} -- cut out num effects data? overlay={} -- take the effects where id > 127 function loadscene(s) scene={} overlay={} scene[1] = s[1] for i=2,#s do sc = s[i] if sc[1] < 128 then table.insert(scene,sc) else table.insert(overlay,sc) end end end -- vary noise levels and amounts -- more palettes that dont go to white -- bigger gaps between stanzas, then to credits and greets -- extend length of greets on screen/flash them scenes={ -- time clear palette back noise mid noise effect front noise OPal pattern overlay scene -- cheese test -- {64, {2,3}, {30}, {210,3,5} } -- curves test -- {64, {0,0}, {2,3}, {40}, {210,3,5} } -- my test -- {640, {0,0}, {2,6}, {17}, {210,1,1} } --[[]] {64, {210,1,1} }, --1 {64, {0,0}, {3,4,1,256},{1,100,4}, {1,100,8}, {10}, {1,100,12}, {210,1,1} }, --1 {64, {0,0}, {1,100,4}, {1,100,8}, {10}, {1,100,12}, {210,4,1} }, -- logo {32, {3,1,3,32}, {1,100,4}, {1,100,8}, {10}, {1,100,12}, {210,1,1} }, {32, {0,0}, {1,100,4}, {1,100,8}, {10}, {1,100,12}, {210,3,4} }, -- title {32, {1,100,4}, {1,100,8}, {10}, {1,100,12}, {210,5,4} }, {32, {3,3,1,32}, {1,100,4}, {1,100,8}, {14}, {1,100,12}, {210,5,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {10}, {9,4}, {1,100,12}, {140,1,0,1}, {210,1,5} }, -- mhmb {16, {0,0}, {3,1,6,32}, {1,100,4}, {1,100,8}, {9,2}, {11}, {1,100,12}, {210,1,1} }, {16, {1,100,4}, {1,100,8}, {11}, {210,1,6} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {12}, {1,100,12}, {141,5,1,1}, {210,1,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {13}, {1,100,12}, {210,6,7} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,4}, {12}, {1,100,12}, {141,6,0,0.5}, {210,1,1} }, {16, {0,0}, {3,1,5,32}, {1,100,4}, {1,100,8}, {20}, {1,100,12}, {142,6,0,1}, {210,6,8} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,1}, {20}, {1,100,12}, {142,5,0,1}, {210,1,1} }, {16, {0,0}, {5,5}, {1,100,4}, {1,100,8}, {20}, {1,100,12}, {135,2},{143,5,0,1}, {210,1,9} }, {16, {0,0}, {5,1}, {1,100,4}, {1,100,8}, {9,1}, {20}, {1,100,12}, {143,1,0,2}, {210,1,1} }, {16, {0,0}, {3,1,3,32}, {30}, {1,50,12}, {132,2}, {210,1,10} }, {16, {0,0}, {3,3,7,32}, {9,4}, {30}, {1,50,12}, {210,1,1} }, {16, {0,0}, {3,7,8,32}, {30}, {1,50,12}, {210,1,11} }, {16, {0,0}, {3,8,6,32}, {9,4}, {30}, {1,50,12}, {140,1,0,2}, {210,1,12} }, {16, {0,15}, {10}, {135,2}, {210,7,13} }, {16, {1,50,4}, {13}, {210,7,14} }, {16, {0,0}, {5,6}, {1,50,4}, {21}, {132,2},{141,6,0,0.5}, {210,1,1} }, {16, {0,15}, {1,100,4}, {21}, {141,6,0,1}, {210,1,15} }, {16, {0,0}, {2,6}, {1,100,4}, {9,1}, {21}, {1,100,12}, {132,2},{143,5,0,1}, {210,1,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {21}, {1,100,12}, {143,5,0,1}, {210,1,16} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {21}, {1,100,12}, {145,7,15,2}, {210,1,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {21}, {1,100,12}, {145,7,0,2}, {210,1,17} }, {16, {0,0}, {2,7}, {1,100,4}, {1,100,8}, {9,1}, {21}, {1,100,12}, {140,4,0,1}, {210,1,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {21}, {1,100,12}, {140,5,0,1}, {210,1,18} }, {16, {0,0}, {1,100,4}, {1,100,8}, {14}, {1,100,12}, {132,2},{146,1,0,1}, {210,1,1} },-- {16, {0,0}, {3,7,3,32}, {1,100,4}, {1,100,8}, {14}, {1,100,12}, {147,1,0,1}, {210,1,19} }, {16, {0,0}, {1,100,8}, {40}, {210,11,1} }, {16, {0,0}, {3,3,8,32}, {1,100,8}, {9,4}, {40}, {132,2}, {210,1,20} }, {16, {0,0}, {1,100,4}, {1,100,8}, {11}, {1,100,12}, {138}, {210,7,1} }, {16, {0,0}, {3,8,6,32}, {1,100,4}, {1,100,8}, {9,1}, {11}, {1,100,12}, {140,1,0,4}, {210,1,21} }, {16, {0,0}, {1,100,4}, {1,100,8}, {15}, {1,100,12}, {210,10,1} }, {16, {0,0}, {3,6,1,32}, {1,100,4}, {1,100,8}, {9,2}, {15}, {1,100,12}, {142,6,0,1}, {210,1,22} }, {16, {0,0}, {1,100,4}, {1,100,8}, {16}, {1,100,12}, {210,1,23} }, {16, {0,0}, {3,1,7,32}, {1,100,4}, {1,100,8}, {9,1}, {16}, {1,100,12}, {142,1,0,2}, {210,1,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {15}, {1,100,12}, {210,1,24} }, {16, {0,0}, {3,7,9,32}, {1,100,4}, {1,100,8}, {9,2}, {15}, {1,100,12}, {143,1,0,1}, {210,1,1} }, {16, {0,0}, {1,100,4}, {22}, {210,1,25} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,4}, {22}, {210,8,1} }, {16, {0,0}, {3,9,1,32}, {1,100,4}, {1,100,8}, {31}, {1,100,12}, {210,1,26} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {31}, {1,100,12}, {146,6,0,4}, {210,9,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {17}, {1,100,12}, {144,6,0,4}, {210,1,27} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,1}, {17}, {1,100,12}, {144,1,0,4}, {210,1,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {17}, {1,100,12}, {210,1,28} }, {16, {0,0}, {2,6}, {1,100,4}, {1,100,8}, {9,2}, {17}, {1,100,12}, {144,7,0,4}, {210,1,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {17}, {1,100,12}, {210,1,29} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {21}, {1,100,12}, {210,5,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {21}, {1,100,12}, {210,1,30} }, {16, {0,0}, {2,8}, {1,100,4}, {1,100,8}, {9,2}, {14}, {1,100,12}, {142,5,0,1}, {210,1,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {14}, {1,100,12}, {210,11,1} }, {16, {0,0}, {1,100,4}, {1,100,8}, {15}, {1,100,12}, {210,1,32} },-- {16, {0,0}, {1,100,4}, {1,100,8}, {9,4}, {15}, {1,100,12}, {210,1,32} }, {16, {0,0}, {2,7}, {1,100,4}, {1,100,8}, {40}, {1,100,12}, {210,1,33} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,4}, {40}, {1,100,12}, {210,1,33} }, {16, {0,0}, {1,100,4}, {1,100,8}, {16}, {1,100,12}, {210,1,34} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,4}, {16}, {1,100,12}, {210,1,34} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {16}, {1,100,12}, {210,1,1} }, {32, {0,0}, {2,1}, {1,100,4}, {1,100,8}, {15}, {1,100,12}, {210,1,35} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,4}, {15}, {1,100,12}, {147,5,0,4}, {210,1,35} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {15}, {1,100,12}, {147,5,0,1}, {210,1,1} }, {32, {0,0}, {2,6}, {1,100,4}, {1,100,8}, {20}, {1,100,12}, {210,1,36} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {20}, {1,100,12}, {145,7,0,4}, {210,1,36} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {20}, {1,100,12}, {145,7,0,1}, {210,1,1} }, {32, {0,0}, {2,3}, {1,100,4}, {1,100,8}, {16}, {1,100,12}, {210,1,37} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {16}, {1,100,12}, {143,4,0,4}, {210,1,37} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {16}, {1,100,12}, {143,4,0,1}, {210,1,1} }, {32, {0,0}, {2,7}, {1,100,4}, {1,100,8}, {31}, {1,100,12}, {210,1,38} }, {16, {0,0}, {3,7,1,32}, {1,100,4}, {1,100,8}, {9,2}, {30}, {1,100,12}, {142,1,0,4}, {210,1,38} }, {16, {0,0}, {3,7,8,32}, {1,100,4}, {1,100,8}, {9,2}, {30}, {1,100,12}, {142,1,0,1}, {210,1,1} }, {32, {0,0}, {2,8}, {1,100,4}, {1,100,8}, {17}, {1,100,12}, {210,1,39} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {17}, {1,100,12}, {143,5,0,4}, {210,1,39} }, {16, {0,0}, {1,100,4}, {1,100,8}, {9,2}, {17}, {1,100,12}, {143,5,0,1}, {210,1,1} }, {32, {0,0}, {2,5}, {1,100,4}, {1,100,8}, {20}, {1,100,12}, {138}, {210,1,40} }, {16, {0,0}, {1,100,4}, {1,100,8}, {20}, {1,100,12}, {138}, {210,1,1} }, {16, {0,0}, {5,1}, {1,100,4}, {1,100,8}, {10}, {1,100,12}, {138}, {210,1,41} } --]] } -- scene {duration in beats, num effects, [effect, effect param ..], .. } -- effect {id, num parameters} effects = { {clearscreen = 0, 1}, -- clear screen, 1 param (color) {noise = 1, 2}, -- noise, 2 params, (amount,colour level) {palettebg = 2,1}, -- change palette (which palette) {palettefadebg = 3,3}, -- change palette (start,end palettes,beats) -- palette pulse to white (palette, amount, beats) {paletteinvert = 5,1}, -- (palette) {flashbg = 9,1}, -- flash on (how many beats) {cube = 10,0}, -- rotating cube {wedge = 11,0}, -- circle of wedges {rectangle = 12,0}, -- rotating rectangle {cubepulse = 13,0}, -- rotating pulsing cube {cube2 = 14,0}, -- rotating 2 cubes {rect3 = 15,0}, -- rotating 3 rectangles {wedge2= 16,0}, -- wedges {spiral= 17,0}, -- spiral {circdance = 20,0}, -- circle dance thing {tusks = 21,0}, -- tusks! {tusks2 = 22,0}, -- not tusks! {cheese = 30,0}, -- rotozoomer {curves = 40,0}, -- sine curves {noisefg = 131, 2}, -- noise, 2 params, (amount,colour level) {palettefg = 132,1}, -- change palette (which palette) {palettefadefg = 133,3}, -- change palette (start,end palettes,beats) {paletteinvert = 135,1}, -- (palette) {pattern1 = 138,0}, -- pattern 1:basic lines {prot = 140,3}, -- pattern: rot (which image set, colour, speed) {pbou = 141,3}, -- pattern: bounce (which image set, colour, speed) {pmirror1 = 142,3}, -- pattern: mirror horizontal (which image set, colour, speed) {pmirror2 = 143,3}, -- pattern: mirror both (which image set, colour, speed) {prandom = 144,3}, -- pattern: random each sprite (which image set, colour, speed) {prandom2 = 145,3}, -- pattern: random all sprites (which image set, colour, speed) {ptunnel = 146,3}, -- pattern: sprites change from centre (which image set, colour, speed) {ptunnel2 = 147,3}, -- pattern: sprites change from centre (which image set, colour, speed) {skpattern = 150,0}, -- saski style pattern array (do one on bg, one on foreground, with different squares in each?) {overlay = 210,2} -- overlay, (sprites id, text id) } function render() for i=2,#scene do fect = scene[i] if fect[1] == 0 then cls(fect[2]) elseif fect[1] == 1 then noise(fect[2],fect[3]) elseif fect[1] == 2 then currentP=palettes[fect[2]] elseif fect[1] == 3 then local ratio = mscurrent / (fect[4] * msperbeat) if ratio > 1 then ratio = 1 end currentP=mixPalette(fect[2],fect[3],ratio) elseif fect[1] == 5 then currentP=invertP(fect[2]) elseif fect[1] == 9 then if((beatcurrent)%fect[2] == 0) and (mscurrent%msperbeat < msperbeat/2) then cls(15) end elseif fect[1] == 10 then cube_update(ts/10) polytest_draw(ts/10) elseif fect[1] == 11 then wedge_update(mscurrent/1000) wedge_draw(mscurrent) elseif fect[1] == 12 then polytest_update(ts/10) polytest_draw(ts/10) elseif fect[1] == 13 then cubepulse_update(ts/10) polytest_draw(ts/10) elseif fect[1] == 14 then cube2_update(ts/10) polytest_draw(ts/10) elseif fect[1] == 15 then rect3_update(ts/10) polytest_draw(ts/10) elseif fect[1] == 16 then wedge2_update(ts/500) wedge_draw(mscurrent) elseif fect[1] == 17 then --trispiral_update(ts/10) trispiral2_draw(mscurrent/msperbeat) elseif fect[1] == 20 then circdance_draw(ts) elseif fect[1] == 21 then tusks_update(mscurrent/msperbeat) tusks_draw(mscurrent/msperbeat) elseif fect[1] == 22 then tusks2_update(mscurrent/msperbeat) tusks_draw(mscurrent/msperbeat) elseif fect[1] == 30 then texstartx=0x00 cheese_draw(ts/16) elseif fect[1] == 31 then texstartx=0x0f cheese_draw(ts/16) elseif fect[1] == 40 then curves_draw(math.floor(ts/16)) else end end end function rendero() for i=1,#overlay do fect = overlay[i] if fect[1] == 131 then noise(fect[2],fect[3]) elseif fect[1] == 132 then currentOP=palettes[fect[2]] elseif fect[1] == 133 then local ratio = mscurrent / (fect[4] * msperbeat) if ratio > 1 then ratio = 1 end currentOP=mixPalette(fect[2],fect[3],ratio) elseif fect[1] == 135 then currentOP=invertP(fect[2]) elseif fect[1] == 138 then pattern1() elseif fect[1] == 140 then local ims = PTRNS[fect[2]] prot(ims[1],ims[2],ims[3],ims[4],fect[3],fect[4]) elseif fect[1] == 141 then local ims = PTRNS[fect[2]] pbou(ims[1],ims[2],ims[3],ims[4],fect[3],fect[4]) elseif fect[1] == 142 then local ims = PTRNS[fect[2]] pmirror1(ims[1],ims[2],ims[3],ims[4],fect[3],fect[4]) elseif fect[1] == 143 then local ims = PTRNS[fect[2]] pmirror2(ims[1],ims[2],ims[3],ims[4],fect[3],fect[4]) elseif fect[1] == 144 then local ims = PTRNS[fect[2]] prandom(ims[1],ims[2],ims[3],ims[4],fect[3],fect[4]) elseif fect[1] == 145 then local ims = PTRNS[fect[2]] prandom2(ims[1],ims[2],ims[3],ims[4],fect[3],fect[4]) elseif fect[1] == 146 then local ims = PTRNS[fect[2]] ptunnel(ims[1],ims[2],ims[3],ims[4],fect[3],fect[4]) elseif fect[1] == 147 then local ims = PTRNS[fect[2]] ptunnel(ims[1],ims[2],ims[3],ims[4],fect[3],fect[4]) elseif fect[1] == 210 then -- update overlay opd=opd opd={sprites = spriteblocks[fect[2] ],text= texts[fect[3] ]} opig() else end end end -- debug timing tt=1 ttt=1 tto=1 ts=0 te=0 to=0 mstime = 0 beattime = 0 mscurrent = 0 beatcurrent = 0 msstart = 0 beatstart = 0 msperbeat=0 scenecurrent=1 trackcurrent=-1 loop = 0 warntime = 0 function TIC() if (time() - warntime) < 12000 then cls(0) print("sjdidifhfudududududyd", 10, 40) print("This demo corrrrrrrrrr", 10, 50) print("Press Escape nowsuqoiywhjey", 10, 60) return end -- check music playing if peek(0x13ffc) == 255 then trackcurrent = trackcurrent + 1 music(trackcurrent,0,0,false) end if peek(0x13ffd) == 15 then poke(0x13ffd, 5) loop = loop + 1 end -- update timing (ms + beat) mstime = time() - 15000-- use only ts later ts=time() - 15000 beattime=(peek(0x13ffd)+loop*10)*64+peek(0x13ffe) msperbeat=(1/peek(0x13e94))*1000 if beatstart == 255 then beatstart=0 end --beattime = beattime + (trackcurrent*16*64) beatcurrent=beattime - beatstart -- if we are in the same scene, render if(beatcurrent >= scene[1]) then -- load new scene into scene/overlay if scenecurrent < #scenes then scenecurrent = scenecurrent +1 else exit() end loadscene(scenes[scenecurrent]) -- update start timings beatstart = beattime beatcurrent = 0 msstart = time() - 15000 end mscurrent = mstime - msstart -- render render() --[[ for i=0,15 do rect(0,(i)*10,240,10,i) end--]] --cls(0) --noise(2000,4) -- circdance_draw(ts) --noise(2000,8) -- piggrid_draw(ts) --polytest_draw(ts) --noise(2000,12) to=time() end sint={} STSIZE = 1000 HSTS = math.floor(STSIZE/2) QSTS = math.floor(STSIZE/4) function init() math.randomseed(1337) local col -- precalc sine table for i=0,STSIZE do sint[i]=math.sin((i/HSTS)*math.pi) end -- make some palettes for i=0,16 do col=i*16 gray[1+(i*3)]=col gray[1+(i*3)+1]=col gray[1+(i*3)+2]=col end table.insert(palettes,aqua) table.insert(palettes,gray) palspread(0,0,0,255,255,255,5) table.insert(palettes,currentP) currentP={} palspread(0,0,0,0,0,0,0) table.insert(palettes,currentP) currentP={} palspread(0,0,0,0,128,255,0) table.insert(palettes,currentP) currentP={} palmid(255,0,128) table.insert(palettes,currentP) currentP={} palmid(128,255,0) table.insert(palettes,currentP) currentP={} palmid(255,128,0) table.insert(palettes,currentP) currentP={} palmid(192,192,0) table.insert(palettes,currentP) currentP={} currentP=palettes[1] currentOP=palettes[2] -- init the effects font_init() circdance_init() polytest_init() --cheese_init() curves_init() wedge_init() tusks_init() trispiral_init() -- unload timing from map loadscene(scenes[1]) -- start music --beatstart=0 --music(0) warntine = time() end init()