pouët.net

Go to bottom

Random line of code thread

category: code [glöplog]
Code: // Secret ninja action time! OM_U8 *pNinja = (OM_U8 *) ppptctb + 12; __asm__("# %0" : "+r"(pNinja)); ppptctb = (PPTC_TRIBLOCK *) (pNinja - 12);
added on the 2011-03-10 04:27:22 by ryg ryg
Code: ;>>>> routine to extract the squareroot of a number, 2005jul27 ;in: d0.l=value ;out: d1.l=sqrt(value) ; d2.l,d3.l killed ;approx 5 times slower than a div squareroot: moveq.l #0,d1 ;d1=root move.l #$40000000,d2 ;d2=2^2n for n=15 downto 0 cmp.l d2,d0 ;flags=value-2^2n dc.w $6d04 ;"bLT.s +4" sub.l d2,d0 ;value-=2^2n add.l d2,d1 ;root+=2^2n rept 15 lsr.l #2,d2 ;n-=1, thus 2^2n>>1 move.l d2,d3 add.l d1,d3 ;d3=root+2^2n lsr.l #1,d1 ;root=root>>1 cmp.l d3,d0 ;flags=value-(root+2^2n) dc.w $6d04 ;"bLT.s +4" sub.l d3,d0 ;value-=root+2^2n add.l d2,d1 ;root+=2^2n endr cmp.w d1,d0 ;flags=value-root bLT.s .sqrt_noround addq.l #1,d1 ;round to nearest integer .sqrt_noround: rts
added on the 2011-05-16 20:43:40 by baah baah
Code:if ($yourehappyAndYouKnowIt) {clapyourhands;}
added on the 2011-06-24 23:39:58 by Defiance Defiance
Code:hierhinja: lea ficktabelle,a1


Code: move.l #$73708,fuckstartblitt


Code: move.w #0,countmich


Sources of old Thrust intros are quite entertaining.
added on the 2011-07-10 00:46:14 by StingRay StingRay
Found this in some of my old sources (atsou code :)

Code: if (kk<1000) blob_toing(blobx,bloby,xs,ys,vx,vy,f,nb); else if (kk<1200) blob_tremble(blobx,bloby,nb,2,2); else if (kk<1201) morph_precalcs(blobx,bloby,xs,ys,dx,dy,diasx,episx,diasy,episy,nb,kk,100,0,0); else if (kk<1301) blob_morph(blobx,bloby,xs,ys,dx,dy,nb); else if (kk<1302) blob_tremble(blobx,bloby,nb,0,0); else if (kk<1500) blob_tremble(blobx,bloby,nb,1,1); else if (kk<1501) morph_precalcs(blobx,bloby,xs,ys,dx,dy,diasx,episx,diasy,episy,nb,kk,50,1,0); else if (kk<1551) blob_morph(blobx,bloby,xs,ys,dx,dy,nb); else if (kk<1900) blob_sinemove(blobx,bloby,diasx,episx,diasy,episy,nb,kk); else if (kk<1901) morph_precalcs(blobx,bloby,xs,ys,dx,dy,diasx,episx,diasy,episy,nb,kk,100,0,1); else if (kk<2001) blob_morph(blobx,bloby,xs,ys,dx,dy,nb); else if (kk<2002) blob_tremble(blobx,bloby,nb,0,0); else if (kk<2200) blob_tremble(blobx,bloby,nb,1,2); else if (kk<2201) morph_precalcs(blobx,bloby,xs,ys,dx,dy,diasx,episx,diasy,episy,nb,kk,50,1,0); else if (kk<2251) blob_morph(blobx,bloby,xs,ys,dx,dy,nb); else if (kk<2700) blob_sinemove(blobx,bloby,diasx,episx,diasy,episy,nb,kk); else if (kk<2701) morph_precalcs(blobx,bloby,xs,ys,dx,dy,diasx,episx,diasy,episy,nb,kk,100,0,2); else if (kk<2801) blob_morph(blobx,bloby,xs,ys,dx,dy,nb); else if (kk<2802) blob_tremble(blobx,bloby,nb,0,0); else if (kk<2951) blob_tremble(blobx,bloby,nb,1,1); else if (kk<3250) blob_tremble(blobx,bloby,nb,2,2); else if (kk<3251) blob_rotate(blobx,bloby,xs,ys,nb,rk,.99,0); else if (kk<3550) {blob_rotate(blobx,bloby,xs,ys,nb,rk,.99,1); rk++;} else if (kk<3551) toing_precalcs(blobx,bloby,xs,ys,vx,vy,f,nb,1); else if (kk<4000) blob_toing(blobx,bloby,xs,ys,vx,vy,f,nb); else if (kk<4001) for (n=0;n<nb;n++) f[n]=-.025; else if (kk<4400) blob_toing(blobx,bloby,xs,ys,vx,vy,f,nb); else {return;}
added on the 2011-08-03 16:02:37 by Optimus Optimus
ret
Code: function CheckProfile($page_id) { // on recupere le user level ID $userlevel_id = $_SESSION['level']; // on recupere les droits de ce user level $get_rights = 'SELECT * FROM user_levels WHERE user_level_id = "'.$userlevel_id.'"'; $exec_get_rights = mysql_query($get_rights); while ($data = mysql_fetch_assoc($exec_get_rights)) { // on cree des tableaux contenant les ID des modules de ce user level $read = explode(" ", $data['read_modules']); $update = explode(" ", $data['update_modules']); $delete = explode(" ", $data['delete_modules']); } // on initialise des variables a no $rights_read = 'no'; $rights_update = 'no'; $rights_delete = 'no'; // on choppe le module_id dans la base correspondant a l'ID de la page actuelle $query_modidpage = 'SELECT module_id FROM inv_modules WHERE module_files REGEXP "[[:<:]]'.$page_id.'[[:>:]]"'; $exec_modidpage = mysql_query($query_modidpage); $result_modidpage = mysql_result($exec_modidpage, 0); // on regarde si le user a accès à ce module avec un quelconque droit if (in_array($result_modidpage, $read)) { $rights_read = 'yes'; } if (in_array($result_modidpage, $update)) { $rights_update = 'yes'; } if (in_array($result_modidpage, $delete)) { $rights_delete = 'yes'; } // si le user level n'a aucun droit, on exit la page if (($rights_read == 'no') && ($rights_update == 'no') && ($rights_delete == 'no')) { echo '<br><font size="2">Your User Level is not authorized to access this page</font><br>'; exit; } // on renvoie les 3 variables return array($rights_read, $rights_update, $rights_delete); }
added on the 2011-09-06 22:12:47 by bull bull
Code: // Check whether the edge has already generated a vertex bool unhandled = true; int h = 0; for (; (unhandled = (visitedEdges[h][0] != e[0] || visitedEdges[h][1] != e[1])) && h < nVisitedEdges; ++h) {}
added on the 2011-09-07 10:28:36 by las las
Code:mainloop: lea $bfe001,a0 bset #1,(a0) btst #6,(a0) bne.b mainloop moveq #0,d0 rts
added on the 2011-09-07 10:55:58 by scicco scicco
Code: #ifndef __BYTE_STREAM_HPP #define __BYTE_STREAM_HPP class EOFException {}; class ByteInputStream { public: ByteInputStream(void *data, int length); ByteInputStream(FILE * file); ~ByteInputStream(); template <typename T> ByteInputStream &operator |(T &value); char * readAsciiz(); int readColor(); int readSmartInteger(); float readSmartFloat(int style); private: void checkEOF(int v) { if (pos+v>length) throw EOFException(); }; int length; int pos; void * data; }; template <typename T> ByteInputStream &ByteInputStream::operator |(T &value) { checkEOF(sizeof(T)); unsigned char * data=(unsigned char *)this->data+pos; value=*(T *)data; pos+=sizeof(T); return *this; } #endif
added on the 2011-09-26 21:04:27 by Sauron Sauron
echo SHOW US YOUR
Code: '**** Check if the Hero is on a platform or not x=HeroX#/PlatformW x2=(HeroX#+HeroW)/PlatformW y=PlatformY HeroFalling=True For z=0 To PlatformTilesH-1 If (OldHeroY#<=y) And (HeroY#>=y) Then If (PlatformTiles[x,z]<>0) Or (PlatformTiles[x2,z]<>0) Then HeroFalling=False HeroY#=y HeroVY#=0 EndIf EndIf y=y+PlatformGap Next
added on the 2011-09-26 22:55:35 by baah baah
Code: /** * Returns the number of one-bits in the two's complement binary * representation of the specified <tt>int</tt> value. This function is * sometimes referred to as the <i>population count</i>. * * @return the number of one-bits in the two's complement binary * representation of the specified <tt>int</tt> value. * @since 1.5 */ public static int bitCount(int i) { // HD, Figure 5-2 i = i - ((i >>> 1) & 0x55555555); i = (i & 0x33333333) + ((i >>> 2) & 0x33333333); i = (i + (i >>> 4)) & 0x0f0f0f0f; i = i + (i >>> 8); i = i + (i >>> 16); return i & 0x3f; } /** * Returns the value obtained by reversing the order of the bits in the * two's complement binary representation of the specified <tt>int</tt> * value. * * @return the value obtained by reversing order of the bits in the * specified <tt>int</tt> value. * @since 1.5 */ public static int reverse(int i) { // HD, Figure 7-1 i = (i & 0x55555555) << 1 | (i >>> 1) & 0x55555555; i = (i & 0x33333333) << 2 | (i >>> 2) & 0x33333333; i = (i & 0x0f0f0f0f) << 4 | (i >>> 4) & 0x0f0f0f0f; i = (i << 24) | ((i & 0xff00) << 8) | ((i >>> 8) & 0xff00) | (i >>> 24); return i; }
added on the 2011-09-26 23:21:47 by Joghurt Joghurt
Code: '**** Compute vertical movement of Hero 'For every speed we compute velocity and acceleration using the formulaes: ' v(0)=0 ' v(n+1)=v(n)*k + a with 0<k<1 'This serie converges to the fixed point of f(x)=x*k+a 'Thus velocity converges to a/(1-k) which is MaxSpeed 'If we know MaxSpeed then a=MaxSpeed*(1-k) HeroY#=HeroY#+DeltaY OldHeroY#=HeroY# HeroAY#=HeroMaxSpeedY*(1-0.9) HeroVY#=HeroVY#*0.9+HeroAY# HeroY#=HeroY#+HeroVY#*DeltaTime/1000
added on the 2011-09-27 12:35:42 by baah baah
Code:int bankAccount = 45000; for (int numGF = 0; bankAccount; bankAccount -= (numGF * 10), numGF++);
added on the 2011-09-28 08:56:50 by LovCAPONE LovCAPONE
@LovCAPONE: numGF can get HUGE this way :)
added on the 2011-09-28 14:34:40 by baah baah
The velocity calculus above is lousy, because if the machine runs faster the code is called more, then the absorption (0.9) is used more. The following tries to assess the problem:
Code: '**** Compute vertical movement of Hero 'k is Absorption 'For every speed we compute velocity and acceleration using the formulaes: ' v(0)=0 ' v(n+1)=v(n)*k + a with 0<k<1 'Thus v(n+p)=v(n)*k^p + a*(1+k+k^2+...+k^(p-1)) ' v(n+p)=v(n)*k^p + a*(1-k^p)/(1-k) 'This serie converges to the fixed point of f(x)=x*k+a 'Thus velocity converges to a/(1-k) which is MaxSpeed 'If we know MaxSpeed then a=MaxSpeed*(1-k) Absorption#=0.993 Absorption_power#=Absorption#^DeltaTime HeroAY#=HeroMaxSpeedY*(1-Absorption) HeroVY#=HeroVY#*Absorption_power#+HeroAY#*(1-Absorption_power#)/(1-Absorption) HeroY#=HeroY#+HeroVY#*DeltaTime/1000
added on the 2011-09-28 21:23:24 by baah baah
lda $666
added on the 2011-09-28 21:24:21 by Frost Frost
POP CS
added on the 2011-09-28 21:31:39 by Joghurt Joghurt
Move.l $1,d0
added on the 2011-09-30 22:22:49 by djh0ffman djh0ffman
not a random "line" but a random snapshot of a VPL state ;)

Just implemented colored beziers for connections.. nothing new I know, but still works well in realtime when zooming out. a lot better than my previous straight white lines for sure!

This is about half of the stuff open in the luna:reactivation demo.
Of course one zooms in and closes most of these boxes when working, but I wanted to see how well the bezier drawing stuff performed, and it's good enough.. red pipes are render, green is float values, blue is textures, orange is unit quaternions (rotations) etc.

BB Image
added on the 2011-10-07 00:41:32 by jaw jaw
Code: scroll: move.w howlong,d0 add.w #4,nutte move.w nutte,d1 cmp.w d0,d1 bhi geschlechtsverkehr rts geschlechtsverkehr: move.w #0,nutte jsr buchstabe rts

Found in the source of an old Mygon intro.
added on the 2011-10-24 15:24:19 by StingRay StingRay
Code:#include <stdio.h>
added on the 2011-10-25 09:24:17 by zerkman zerkman

login

Go to top