pouët.net

Random line of code thread

category: code [glöplog]
@ ptr1 * cosα + c1ms2 @-> ptr1
added on the 2021-11-16 19:37:31 by ltipl ltipl
Code:XMLHttpRequest.prototype.__send = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function ( _data ) { this.__onreadystatechange = this.onreadystatechange; this.onreadystatechange = function () { console.log( "XMLHttpRequest.onreadystatechange" ); console.log( this ); this.__onreadystatechange(); }; this.__send( _data ); };
added on the 2021-11-19 06:59:35 by Salinga Salinga
Code:console.log("ba"+ +"i’ll be gone anyway"+"a")
added on the 2021-11-19 10:03:25 by netro netro
Code:cmp.b #"""",d0
added on the 2021-11-27 19:01:39 by StingRay StingRay
Silly things of why C doesn't have that?

Code: uchar* int myFunction() { return myCharPointer, anInt; }


I know, make it a struct, use tuples or other.
Assembly function would return things in multiple registers. C only 1. Why not upgrade C++ 23?


Second

Code: for (int y = 0; y < 10; ++y) { for (int x = 0; x < 10; ++x) { if (x > 5 && y > 5) break 2; } }


You want to break twice.
Use a goto and see people screeching.
Yeah, put a boolean that you set and check/escape twice. Or rewrite.
Make this loop into a lambda that escapes it self but not the whole function outside.

Finally

Code: int a = 10; int b = 0xABCD; int c = 01234; // octal? int c = 0b101010101010; // doesn't exist


THE low level language and no binary? We have to use defines with hex or bit shifting. When I change flags in hardware and want to put one by one the bits. Someone said make a function that accepts a string and returns back tha value.

But it has octal. Why no binary? Even basic had binary.
added on the 2021-11-28 09:22:34 by Optimus Optimus
They make fun of Basic, but modern scripting languages are like a basic.
added on the 2021-11-28 09:25:28 by Optimus Optimus
python and basic do not have much in common except the interpreter ;)
added on the 2021-11-28 12:24:09 by NR4 NR4
Code:ld a,$f0 ldh [rNR12],a ldh [rNR22],a ldh [rNR42],a ld a,$80 ldh [rNR14],a ldh [rNR24],a ldh [rNR44],a ld a,$18 ldh [rNR12],a ldh [rNR22],a ldh [rNR42],a
added on the 2021-11-30 03:58:31 by DevEd DevEd
Code:cmp.l (a7)+,a0
added on the 2021-12-11 20:35:55 by StingRay StingRay
Code:move.l $400+$af50,$dff080 ; "thank you" Rob Northen.... just a few hours of my time wasted
added on the 2021-12-27 22:43:06 by StingRay StingRay
guess the instruction set, ed. 2:

Code: mov x, #0xaa mov c, #0 3: dec c mov a, [hl+c] xor a, x call !!0xeffa1 cmp0 c bnz $3b
added on the 2021-12-30 17:00:56 by porocyon porocyon
Code:compute_keys_invoice_items( compute_key_invoice_header( ) ).
added on the 2022-01-21 12:46:13 by StingRay StingRay
Code:if ui.button("Save").clicked() { match self.save_sample() { Ok(..) => self.error_string = None, Err(err) => self.error_string = Some(format!("{}", err)), } }
added on the 2022-01-24 19:53:37 by Blueberry Blueberry
Code:let mut genome_item = GenomeItem::new( suggested_instruction_id, target_value, ParameterType::Constant, source_value );
added on the 2022-01-24 20:11:20 by neoneye neoneye
Code: // Fixed byte of value 0x96, followed by unit code which can be freely chosen. // We insert an instruction here that does not bother us and stomp over it. assert(current_pc(a) == ofs_fixed_byte); a.mov(tmp0, 0x96);
added on the 2022-01-26 08:07:12 by Moerder Moerder
Code: mov dx,REG_SND_CH1_PITCH mov si,FreqTable add si,ax add si,ax mov ax,[cs:si] out dx,ax

never done X86 assembly before, still not quite used to it
added on the 2022-02-06 00:48:34 by DevEd DevEd
@DevEd, in that specific sequence, you could do "LODSW" to save a byte.
It does do "mov ax,[si]" + "inc si" + "inc si" ... override with CS is fine =)
added on the 2022-02-06 01:12:35 by HellMood HellMood
Code:; Never seen 7 nested loops, ever!
added on the 2022-02-14 11:24:49 by neoneye neoneye
Code: vec2 uv = (.5/g_tanfov) * (2.*texCoord - 1.) * vec2(float(g_resolution.x) / g_resolution.y, 1.); // uniform rendertarget coords vec3 ray = normalize(vec3(uv, -1.0)); vec4 rrat = vec4(ray, 1.0); rrat *= m_view; ray = rrat.xyz; // am i dumb //ray = rotateXYZ(ray, vec3(0.6*cos(g_time*0.77), 0.8*sin(g_time*0.84), 0.8*sin(g_time*0.4))); vec3 origin = vec3(0, 0, -22); vec3 tt = raymarch(origin, ray);
added on the 2022-02-17 15:02:01 by wbcbz7 wbcbz7
Code:dc.l $180005b,$ac07fffe,$1800fd0,-2
added on the 2022-02-28 21:02:14 by Blueberry Blueberry
Code:CUSTOM set $dff000 ; fun: preferences.i defines paper size "CUSTOM"...
added on the 2022-03-18 09:27:13 by losso losso
Code:$fn=40; HG=0.05; //HalfGap SIZE=15; EDGE=3; IBH=3; //InBetweenHeight TBH=3; //TopAndBottomHeight module Diamond() { union(){ translate([SIZE/2,SIZE/2,TBH-HG+IBH]) linear_extrude(height = TBH, scale = (SIZE-2*HG-2*EDGE)/(SIZE-2*HG)) { offset(EDGE) { square(SIZE-2*EDGE-2*HG, center = true); } } translate([SIZE/2,SIZE/2,0+TBH+HG]) linear_extrude(height = IBH-2*HG, scale = 1) { offset(EDGE) { square(SIZE-2*EDGE-2*HG, center = true); } } translate([SIZE/2,SIZE/2,0+TBH+HG]) rotate([180,0,0]) linear_extrude(height = TBH, scale = (SIZE-2*HG-2*EDGE)/(SIZE-2*HG)) { offset(EDGE) { square(SIZE-2*EDGE-2*HG, center = true); } } } } translate([1*SIZE,2*SIZE,0]) Diamond(); translate([2*SIZE,2*SIZE,0]) Diamond(); translate([0*SIZE,1*SIZE,0]) Diamond(); translate([1*SIZE,1*SIZE,0]) Diamond(); translate([1*SIZE,0*SIZE,0]) Diamond(); translate([2*SIZE-1.5*HG,2*SIZE+EDGE+HG,TBH+HG]) cube([3*HG,SIZE-2*EDGE-2*HG,IBH-2*HG]); translate([1*SIZE-1.5*HG,1*SIZE+EDGE+HG,TBH+HG]) cube([3*HG,SIZE-2*EDGE-2*HG,IBH-2*HG]); translate([1*SIZE+EDGE+HG,2*SIZE-1.5*HG,TBH+HG]) cube([SIZE-2*EDGE-2*HG,3*HG,IBH-2*HG]); translate([1*SIZE+EDGE+HG,1*SIZE-1.5*HG,TBH+HG]) cube([SIZE-2*EDGE-2*HG,3*HG,IBH-2*HG]);
added on the 2022-03-20 13:35:40 by baah baah
Code:k=c.width=160;a=S(t*3)*7;x.F=x.fillRect;with(x)for(i=8;i--;F(9-g*3,g*15,17+g*6,13+g*9))g=i&1,a=-a,F(g*30,16,5,13+a),F(18-g*6,l=38,5,20+a),v=l/(4-(t+i/2)%4),F(0,l+v,k,v/l),fillText('R-1337',l,l)


https://www.dwitter.net/d/24500
added on the 2022-03-20 15:39:40 by MrVainSCL MrVainSCL
Quote:
Code:CUSTOM set $dff000 ; fun: preferences.i defines paper size "CUSTOM"...


Haha, that's a good one. :) However, why do you need to mix OS and hardware code? It usually is not really a good idea.
added on the 2022-03-21 23:14:03 by StingRay StingRay
Synthesizing some guitar-ish sounds (original idea by GM, with a "twist"):
Code:float r1 = (lfsr_randf(&voice->lfsr_1, 2.0f/*max*/) - 1.0f) * voice->mod_seed1scl_cur; float r2 = (lfsr_randf(&voice->lfsr_2, 2.0f/*max*/) - 1.0f) * voice->mod_seed2scl_cur; float r3 = (lfsr_randf(&voice->lfsr_3, 2.0f/*max*/) - 1.0f) * voice->mod_seed3scl_cur; float r1mr2 = (r1 - r2) * voice->mod_scl1_cur; float r2mr3 = (r2 - r3) * voice->mod_scl2_cur; out = r2mr3 - r1mr2;

// now add a HPF to get rid of the DC offset, an env-modulated LPF+DCA, ..and find good params
sound example
(note: I also made a version for my "Cycle" sample precalculator that runs on an A500, w/o floats, of course)
added on the 2022-04-26 22:29:13 by bsp bsp

login