pouët.net

Random line of code thread

category: code [glöplog]
Code: moveq #14,D0 clrsp: clr.l -(SP) dbra D0,clrsp movem.l (SP)+,D0-A6


Shorter anyone ?

added on the 2010-01-24 21:16:00 by lsl lsl
C++ multiple inheritance WTF: c++ vs ...
..fuuuuuuuuu ! :)
added on the 2010-01-24 22:56:22 by xyz xyz
Code:#define BYTESPERPIXEL(fits8bits) (3 << (!fits8bits)) … int main(int argc, char **argv) { in = alloca(width * height * BYTESPERPIXEL(256 > max)); out = alloca(width * height * BYTESPERPIXEL(256 > max)); fread(in, BYTESPERPIXEL(256 > max), width * height, stdin); ptr = out; for(y = 0; y < height; y++) { for(x = 0; x < width; x++) { for(i = 0; i < BYTESPERPIXEL(256 > max); i++) { *ptr++ = *in++ & visibility_mask(x, y, argc, argv); } } } printf(”P6n%d %dn%dn”, width, height, max); fwrite(out, BYTESPERPIXEL(max < 256), width * height, stdout);


Taken from The Underhanded C Contest - a contest for evil code that appears to be harmless.
added on the 2010-01-24 23:01:39 by neoneye neoneye
ah, wasn't this the one that encodes the original bw bits in the number of '0' chars ? :)
added on the 2010-01-24 23:04:13 by xyz xyz
Code:$this->target_type = (($record['target_type']=="Advertisment")?"Advertisement":$record["target_type"]);
added on the 2010-01-28 06:40:09 by jco jco
BYTE idx;
if (!FreeImage_GetPixelIndex(dib, sx + x, sy + y, &idx))
die("failed to read pixel at %d, %d", sx + x, sy + y);
buf[y][0] |= (idx & 1) << (7 - x);
buf[y][1] |= ((idx >> 1) & 1) << (7 - x);
added on the 2010-01-28 16:31:13 by kusma kusma
hermes: get the Stoustrup and read about virtual inheritance, that's probably what you wanted to do there.
added on the 2010-01-28 17:51:43 by pan pan
btst.b #6,$bfe001
added on the 2010-01-28 19:49:40 by bizun_ bizun_
pan: yep. A colleague pointed me to this the next day.

(ooold) RLOC:

lea $dff0a0,a4
added on the 2010-01-28 20:24:20 by xyz xyz
[quote]btst.b

FAIL!
added on the 2010-01-28 20:45:47 by StingRay StingRay
And [/quote] FAIL \o/
added on the 2010-01-28 20:46:17 by StingRay StingRay
Quote:


.if Wav_Slot != -1
invoke Is_Wav_Playing, Wav_Slot
.if eax == TRUE
fld Panning2
fsin
fadd CFLT(1.0)
fmul CFLT(0.5)
fstp Cur_Panning
invoke Set_Wav_Panning, Wav_Slot, Cur_Panning
fld CFLT(1.0)
fmul FrameRate
fadd Panning2
fstp Panning2
.else
mov Wav_Slot, -1
.endif
.endif

invoke DInput_Get_Key, DIK_ESCAPE
test eax, eax
jz Esc_Pressed
invoke Terminate_Application
Esc_Pressed: ret
Update endp
added on the 2010-01-28 21:48:32 by bull bull
ramennumeralweb.html:

<!--
RamenNumeralWeb.html
David Jones
Jan 21 2010
Purpose: convert between different bases
-->
<html>
<head>
<title>Ramen Numerals Web Edition</title>
</head>
<body>
<body onload="document.ramennumerals.txtInput.focus()">
<form name="ramennumerals" id="ramennumerals" action="ramennumeralsweb.asp" method="post" style="margin: 0; text-align: center;">

<table border="1">
<th colspan="2">Ramen Numerals Web Edition By David Jones</th>
<tr>
<td><label for="InputChrSet">Input Character Set</label></td>
<td><input type="text" name="InputChrSet" size="22" title="Enter Characters Here" value="0123456789"/></td>
</tr>
<tr>
<td><label for="txtInput">Input</label></td>
<td><input type="text" name="txtInput" size="22" title="Enter Characters Here" value="0"/></td>
</tr>
<tr>
<td><label for="outputChrSet">Output Character Set</label></td>
<td><input type="text" name="outputChrSet" size="22" title="Enter Characters Here" value="0123456789ABCDEF"/></td>
</tr>
<tr>
<td colspan="2"><center><u>Convert Between Number Bases</u></center></td>
</tr>
<tr>
<td colspan="2"><center>Input Character Set: 0123456789 (Decimal)</center></td>
</tr>
<tr>
<td colspan="2"><center>Input Is The Number In The Input Characterset To Convert</center></td>
</tr>
<tr>
<td colspan="2"><center>Output Character Set: 0123456789ABCDEF (HexaDecimal)</center></td>
</tr>
<tr>
<td colspan="2"><center>Output Will Be In The Specified Output Format</center></td>
</tr>
</table>

<input type="submit" value="Submit"/>
<input type="reset" value="Reset" onclick="document.ramennumerals.txtInput.focus()"/>

</form>
</body>
</html>



ramennumeralsweb.asp:



<%@ Language="VBScript" %>
<% Option Explicit %>

<!--
David Jones
Spring 2010
-->
<%
Dim inputChrSet
Dim txtInput
Dim outputChrSet
Dim PreOutput
Dim output
Dim format1
Dim format2

inputChrSet = Request.Form("InputChrSet")
txtInput = Request.Form("txtInput")
outputChrSet = Request.Form("outputChrSet")
preOutput = ConvAny2Dec2(txtInput, inputChrSet, True)
output = ConvDec2Any(preOutput, outputChrSet)

If inputChrSet = "0123456789" Then
format1 = "Decimal"
ElseIf inputChrSet = "0123456789ABCDEF" Then
format1 = "Hexadecimal"
ElseIf inputChrSet = "01" Then
format1 = "Binary"
ElseIf inputChrSet = "01234567" Then
format1 = "Octal"
Else
format1 = "Custom"
End If

If outputChrSet = "0123456789" Then
format2 = "Decimal"
ElseIf outputChrSet = "0123456789ABCDEF" Then
format2 = "Hexadecimal"
ElseIf outputChrSet = "01" Then
format2 = "Binary"
ElseIf outputChrSet = "01234567" Then
format2 = "Octal"
Else
format2 = "Custom"
End If

Response.Write "<html>"
Response.Write "<head>"
Response.Write "<title>Ramen Numerals Web Edition</title>"
Response.Write "</head>"
Response.Write "<body>"
Response.Write "<center>"
Response.Write "<table border=" & Chr(34) & "1" & Chr(34) & ">"
Response.Write "<th colspan=" & Chr(34) & "2" & Chr(34) & ">" & "Results" & "</th>"
Response.Write "<tr>"
Response.Write "<td>Input Character Set</td>"
Response.Write "<td>" & format1 & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Output Character Set</td>"
Response.Write "<td>" & format2 & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Input Number</td>"
Response.Write "<td>" & txtInput & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Output Number</td>"
Response.Write "<td>" & output & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td colspan=" & Chr(34) & "2" & Chr(34) & ">" & txtInput & " in " & format1 & " is " & output & " in " & format2 & "</td>"
Response.Write "</tr>"
Response.Write "</table>"
Response.Write "</center>"
Response.Write "</body>"
Response.Write "</html>"

Function ConvDec2Any(thenum, thechars)
On Error Resume Next
Err.Clear

Dim remainder
Dim holdbuffer
Dim buffer

Do

thenum = thenum / Len(thechars)

If InStr(thenum, ".") = 0 Then
remainder = 0
Else
remainder = Right(thenum, Len(thenum) - InStr(thenum, ".") + 1) * Len(thechars)
thenum = Left(thenum, InStr(thenum, "."))
End If

holdbuffer = buffer
buffer = Mid(thechars, remainder + 1, 1) & holdbuffer

Loop While thenum > 0

thenum = thenum / Len(thechars)

If InStr(thenum, ".") = 0 Then
remainder = 0
Else
remainder = Right(thenum, Len(thenum) - InStr(thenum, ".") + 1) * Len(thechars)
thenum = Left(thenum, InStr(thenum, "."))
End If

if Err.Number <> 0 then
ConvDec2Any = "Error!"
Exit Function
end if

ConvDec2Any = buffer
End Function

Function ConvAny2Dec2(thenum,thechars,CaseSensitive)
On Error Resume Next
Err.Clear

Dim b
Dim I
Dim HeXeN
Dim hexen2

If thenum = vbNullString Then
ConvAny2Dec2 = "Error!"
Exit Function
End If

For I = 1 To Len(thenum) + 1
If CaseSensitive = True Then
HeXeN = InStr(thechars, Mid(thenum, I, 1)) - 1
Else
HeXeN = InStr(UCase(thechars), Mid(UCase(thenum), I, 1)) - 1
End If

If HeXeN < 0 Then
If thenum > 0 Then
ConvAny2Dec2 = "Error!"
Exit Function
End If
End If

b = Len(thenum) - I
hexen2 = hexen2 + Len(thechars) ^ CLng(b) * CLng(HeXeN)
Next

if Err.Number <> 0 then
ConvAny2Dec2 = "Error!"
Exit Function
end if

ConvAny2Dec2 = hexen2
End Function
%>


added on the 2010-01-29 03:20:09 by hexen hexen
Code: template <typename Constant, Constant constant> struct IntegralConstant { typedef Constant Value; typedef IntegralConstant<Constant, constant> Type; static Constant const value = constant; }; typedef IntegralConstant<bool, false> False; typedef IntegralConstant<bool, true> True; template <typename First, typename Second> struct Equal : public False { }; template <typename Type> struct Equal<Type, Type> : public True { }; template <typename First, typename Second> struct And : public Equal<typename Equal<First, Second>::Type, True>::Type { };


Hacked it right now out of boredom, untested but should work. Though, it's 5:37 AM :).
added on the 2010-01-29 04:35:07 by decipher decipher
signal data_clk_slow, data_clk_sync, data_clk_fast : std_logic := '0';
attribute maxdelay of data_clk_slow : signal is c_maxdelay;
added on the 2010-01-29 05:07:27 by jix jix
wow, another VHDL coder :)
added on the 2010-01-29 21:57:23 by pan pan
use IEEE.std_logic_arith.all;
added on the 2010-01-29 23:15:53 by trc_wm trc_wm
Code: move.b psg_select.w,$ffff8800.w
added on the 2010-02-10 22:02:04 by lsl lsl
sta outa+$01
stx outx+$01
sty outy+$01

; code some mega fx here

lda $dd0d
outa lda #$00
outx ldx #$00
outy ldy #$00
rti
added on the 2010-02-11 03:14:35 by 4mat 4mat
if;
import (python.tutorial.for.programming.beginner.that.makes.sense)

then; (gratify.demoscene)

else; (PANTS.OFF)
added on the 2010-02-11 03:24:21 by wWales wWales
afdsofpidhf BIG KAHUNA BURGER flasfhasuifhirhg958248tj
if (lazy) then crazy;
if (crazy) then sleepy;
if (sleepy) then printf("I am le tired\n");
if (tired) then call goto_bed_and_fire_ze_misiles(illegal telepathy);
added on the 2010-02-11 08:02:29 by Optimus Optimus
Quote:

Code:

moveq #14,D0
clrsp: clr.l -(SP)
dbra D0,clrsp
movem.l (SP)+,D0-A6

Shorter anyone ?


Code: lea zeroedMemory,a0 movem.l (a0),d0-a6


:)
added on the 2010-02-11 09:48:08 by sasq sasq
Add to that the 28 zero bytes and you're left with a much bigger version :)
added on the 2010-02-11 10:14:22 by すすれ すすれ
60 bytes you mean (15*4). ;)
added on the 2010-02-11 11:58:44 by StingRay StingRay

login