pouët.net

Random line of code thread

category: code [glöplog]
actually, c# has AddCube(Size:1) and python AddCube(Size=1).
added on the 2016-10-15 10:18:25 by MsK` MsK`
Code:struct flagbits { BYTE C : 1; BYTE u1 : 1; BYTE P : 1; BYTE u2 : 1; BYTE A : 1; BYTE u3 : 1; BYTE Z : 1; BYTE S : 1; BYTE T : 1; BYTE I : 1; BYTE D : 1; BYTE O : 1; BYTE IOPL : 1; BYTE NT : 1; BYTE u : 1; BYTE RF : 1; }; union Flags { WORD EFLAGS; BYTE low; BYTE high; struct flagbits bits; }; inline BYTE LOADEFLAGS() { BYTE ret; __asm lahf __asm mov ret, ah return ret; } #define PrintEFLAGS(var, flags) printf("%02x: %i%i%i%i%i%c%c%c%c\n", var, flags.bits.C, flags.bits.P, flags.bits.A, flags.bits.Z, flags.bits.S, 'u', 'u', 'u', 'u') void Entrypoint() { //LAHF loads lower byte of the EFLAGS register into AH register. Con("8086 Emulator"); Con::AllowPrintf(); printf("Processor Flags:\n"); printf(" CPAZSTIDO\n"); Flags flags = { 0 }; BYTE v = 0xf7; for (int i = 0; i < 16; i++) { __asm add v, 1; flags.low = LOADEFLAGS(); PrintEFLAGS(v, flags); } system("Pause"); }
added on the 2016-10-16 02:19:47 by rudi rudi
Evolution of one line of code for Mandelbrot tracer

137b, 117b, 115b, 112b
Code:<pre><script>for(n=1950;n;document.write('¯\n_'[--n%75?k&2:1]))for(r=i=k=0;r*r+i*i+k++<99;i=t)t=2*r*i+1-n/975,r=r*r-i*i+1-n/25%3</script> <body onload="for(n=84;n-=1/32;document.write(n%3?6+!k:' '))for(r=i=0,k=99;--k/r;i=t)t=2*r*i+1-n/42,r=r*r-i*i+1-n%3"> <body onload=for(n=84;n-=1/32;document.write(n%3?6+!k:''))for(r=i=0,k=99;--k/r;i=t)t=2*r*i+1-n/42,r=r*r-i*i+1-n%3> <body onload=for(n=84;n-=1/32;document.write(n%3?k:''))for(r=i=0,k=21;--k/r;i=t)t=2*r*i+1-n/42,r=r*r-i*i+1-n%3>


All from some time in September 2008.

101b
Code:<svg onload=for(n=99;n-=1/64;write(n%3?k:-7))for(r=i=0,k=20;--k/r;i=t)t=2*r*i+1-n/49,r=r*r-i*i+1-n%3>

This one is from a couple of days ago. Experience always wins.
added on the 2016-10-16 22:08:52 by p01 p01
Quote:
actually, c# has

That addCube is quite different from what the OP was after. He really wants to look at scene graph supporting frameworks or libraries, but doesn't know it yet. ;)

The closest out-of-the-box thing is probably Processing's box(size) command. P5.js has a more verbose version of that.
added on the 2016-10-17 08:23:42 by tomaes tomaes
Code: goto redo_sort_again;


oops...
added on the 2016-10-24 14:49:57 by Preacher Preacher
Code:6 key(12) on: key(13) on

back to my first programming language. :)
added on the 2016-10-24 16:35:32 by tomaes tomaes
Code:// UyaV Y^Auy avya


This comment actually made sense. :)
added on the 2016-10-24 16:50:42 by kb_ kb_
kb: Video decompressor?
added on the 2016-10-24 17:14:01 by Gargaj Gargaj
yeah. colorspace conversion, and the source is a 6-channel 48-bit CbYACrYA texture that the GPU interprets as 32bit RGBA so I needed to write some pretty weird lookup and swizzling code :)

The comment means: Here are 3 texture samples (yielding 34 pixels) with their contents, the arrow is the sampling position and the stuff in caps is what I want out of it. All four comments for the four pixels look like this:

Code: // UY^AV yauy avya // UyaV Y^Auy avya // uyav yaUY^ AVya // uyav yaUy aVY^A


The lengths we go to avoid one memcpy() :D
added on the 2016-10-24 18:06:55 by kb_ kb_
34 pixels == 4 pixels, damnit.
added on the 2016-10-24 18:07:39 by kb_ kb_
Code:uniform float fuck;
added on the 2016-10-24 18:39:14 by ferris ferris
The sad thing about that kind of sampling-and-swizzling is that the GPU's filtering doesn't work correctly then.
added on the 2016-10-24 18:45:54 by Sesse Sesse
ferris:

HAH! I know that feel!



Code: //WorldPosOut = CamToWorld[2]; //WorldPosOut.w = scale; //WorldPosOut.w = projected.z; //DiffuseOut = applyFog(color.xyz,t); //DiffuseOut = vec3(NDC.x, NDC.y,0); //DiffuseOut = vec3(pixelScreenX, pixelScreenY,-1); DiffuseOut = color.xyz; //DiffuseOut = vec3(Pixel.x, Pixel.y,0); //DiffuseOut = rayOriginWorld; //DiffuseOut = rayOriginWorld; //DiffuseOut = rayPWorld; //DiffuseOut = RayDir; //DiffuseOut = worldDir; //DiffuseOut = vec3(PixelNDC.x, PixelNDC.y ,0); //DiffuseOut = vec3(NDC.x, NDC.y,uv.x); //DiffuseOut = vec3(Pixel.x, Pixel.y,0); //NormalOut = CamToWorldTR[0].xzw; NormalOut = normal; //NormalOut = w_p; //NormalOut = PcameraSpace; //NormalOut = vec3(uv.x, uv.y,0); //NormalOut = vec3(eyeHitZ,t,dep); //NormalOut = vec3(PixelScreen.x, PixelScreen.y,0); //NormalOut = vec3(uv.x, uv.y,0); //NormalOut = vec3(PixelNDC.x, PixelNDC.y,0); //NormalOut = vec3(PixelScreen.x, PixelScreen.y,0); //NormalOut = vec3(aspectRatio, scale,0); //NormalOut = (gView*vec4(rayOrigin,1)).xyz; //NormalOut = normalize((gView*vec4(rayOrigin,1)).xyz + (gView*vec4(vec3(Px, Py, -1.0), 0.0)).xyz); //NormalOut = vec3(gl_FragCoord.xy,0); //NormalOut = vec3(PcameraSpace.xy,0); //NormalOut = PcameraSpace.xyz; //NormalOut = rayOriginWorld; //NormalOut = worldDir; //NormalOut = rayPWorld; //NormalOut.y = dot(rd,eyeFwd); //NormalOut.z = eyeHitZ; //NormalOut = rd; //NormalOut = pre_RD; goto gDebugger;


Which is easier? Gluing previous commits to hide the crimescene or faking my death?
added on the 2016-10-25 05:46:03 by Deus Deus
Code:mov al,byte[ds:di+bx+641]
Sesse: True but one blit into a target RT isn't that expensive (still way less than deswizzling in the CPU).

Also the result can be used as texture on anything so we need to generate mipmaps. And not having to throw a bunch of colorspace conversion snippets into the fires of Shader Permutation Hell isn't too bad either :)

On a kinda related note - any plans to create a special version of Snappy that restricts LZ readback and uses a sliding window on depack instead of reading from the output buffer? Asking for a friend :)
added on the 2016-10-25 10:48:53 by kb_ kb_
Sensenstahl: omitting the "DS" might save you a byte ... if the assembler didnt already do this for you ;)
added on the 2016-10-25 10:52:26 by HellMood HellMood
Code: READ TABLE lt_sperm WITH KEY field = 'SPERM' assigning <fs_sperm>.
added on the 2016-10-28 11:39:18 by StingRay StingRay
Code:if(key == "sample" || key == "default_path") { // Sample name may contain spaces... charsRead = s.find_first_of("=\t<", valueStart); if(charsRead != std::string::npos && s[charsRead] == '=') { while(charsRead > valueStart && s[charsRead] != ' ') { charsRead--; } } } else { charsRead = s.find_first_of(" \t<", valueStart); }
sfz is a great file format \o/
Code:mov word[ds:bx+di],1f1fh
Code:AUTO j\q\matrix1\matrix1+4*4*2\tmp\
added on the 2016-11-03 15:05:37 by StingRay StingRay
Code:#define MAX_ATTACK_LENGTH 2001 #define MAX_ATTACK_VALUE (MAX_ATTACK_LENGTH - 1) // 16 bit unsigned max
Code:0 fori=.to7step2:m(i)=i+2:m(i+1)=i+2:next:r=1 1 forj=.to9:fori=.to7:a=int(rnd(.)*8):h=m(i):m(i)=m(a):m(a)=h:nexti,j 2 print"#:"r:fori=.to7:printi;chr$(63+(m(i)<0)):next 3 r=r+1:input"cards";a,b:if(a=b)or((m(a)orm(b))<0)goto3 5 printchr$(13)m(a)m(b)chr$(13):ifm(a)=m(b)thenm(a)=-m(a):m(b)=-m(b) 8 s=.:fori=.to7:s=s+m(i):next:if(s>-40)goto2

You figure it out. ;) Copy, paste by right-clicking into Vice, "run" Soilerz.
added on the 2016-11-06 09:20:01 by tomaes tomaes
Code:main: ;now what? :\
A$=Chr$(16)+Chr$(2)+Chr$(Int(PRT/256))+Chr$(PRT mod 256)+Peek$(Leek(Leek(HOSTENT+16)),4)+String$(C0$,8)
added on the 2016-11-14 22:57:49 by EviL EviL
Code:; Init probabilities ;move.l #NUM_CONTEXTS,d6 ; 2c3c 0000 0600 MOVE.L #$00000600,D6 move.l bbstart-4(pc),d6 ; 2c3a ffe2 MOVE.L (PC,$ffe2)
added on the 2016-11-23 17:23:57 by losso losso

login