Random line of code thread
category: code [glöplog]
Code:
text-shadow:-0.06em 0 red,0.06em 0 cyan;
Code:
subq.w #4,(a0) ; $4e75->$4e71; rts->nop
Code:
addq.w #1,a2 ; bgt
This line of code helped me to save quite a few bytes \o/
Code:
jmp loop
Quote:
Code:subq.w #4,(a0) ; $4e75->$4e71; rts->nop
Love it :D
I sense devilry ;D
This is quite an evil size optimisation used in the boot intro I planned to release at FAP. For now I have to admit defeat though as I didn't manage to cut it down to 1024 bytes despite lots of such tricks, the code is nearly unreadable! :D Let's see if I can make it for FAP 2014. :) For the 2013 edition I have a plan C intro ready. :)
Code:
} else {
Code:
int ReturnValueFromType(const void *address, string type)
{
char *c=(char*)address;
unsigned char *uc=(unsigned char*)address;
short *s=(short*)address;
unsigned short *us=(unsigned short*)address;
int *i=(int*)address;
unsigned int *ui=(unsigned int*)address;
float *f=(float*)address;
return type == "char *" ? *c :
type == "unsigned char *" ? *uc :
type == "short *" ? *s :
type == "unsigned short *" ? *us :
type == "int *" ? *i :
type == "unsigned int *" ? *ui :
type == "float *" ? *f : 0;
}
Code:
#define SIZEOF_BITFIELD(class, member, out) \
{ \
class classtmp; \
classtmp.member = ~0; \
unsigned int tmpint = classtmp.member; \
++ tmpint; \
out = log2(tmpint); \
}
unsigned int log2(unsigned int x)
{
if(!x) return sizeof(unsigned int) * CHAR_BIT;
float f = (float)x;
return (*(unsigned int *)&f >> 23) - 0x7f;
}
struct Test
{
unsigned field1 : 4;
unsigned field2 : 8;
unsigned field3 : 1;
unsigned field4 : 3;
unsigned field5 : 16;
int normal_member;
};
main() {
size_t size[5];
SIZEOF_BITFIELD(Test, field1, size[0]);
SIZEOF_BITFIELD(Test, field2, size[1]);
SIZEOF_BITFIELD(Test, field3, size[2]);
SIZEOF_BITFIELD(Test, field4, size[3]);
SIZEOF_BITFIELD(Test, field5, size[4]);
for (int i=0; i<5; i++) printf("%d\n", size[i]);
Code:
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST);
*hint* :)
soy un programmador!
Apparently competing for ioccc?
Apparently competing for ioccc?
Code:
void interruptsCallback()
{
#ifdef PROJECT_CPC
__asm
di
ld (arwstia),hl
pop hl
ld (arwstokode+1),hl
ld hl,0:push hl
pop hl
ld hl,(arwstia)
ld (sp_save),sp
ld sp,&F800
push af
push bc
push de
push hl
push ix
push iy
exx
push hl
push de
push bc
exx
ex af,af'
push af
ex af,af'
ld a,(_halt_num)
inc a
ld (_halt_num),a
cp 1
jr nz,no_halt1
ld a,&44
jr palvale
no_halt1:
cp 2
jr nz,no_halt2
ld a,&55
jr palvale
no_halt2:
cp 3
jr nz,no_halt3
ld a,&5c
jr palvale
no_halt3:
cp 4
jr nz,no_halt4
ld a,&58
jr palvale
no_halt4:
cp 5
jr nz,no_halt5
ld a,14
kourasi1:
dec a
jr nz,kourasi1
ld a,&5d
jr palvale
no_halt5:
cp 6
jr nz,no_halt_loop
ld a,8
kourasi2:
dec a
jr nz,kourasi2
call _playMusic
xor a
ld (_halt_num),a
ld a,&54
no_halt_loop:
palvale:
ld c,11
kourasi0:
dec c
jr nz,kourasi0
ld bc,&7f00:out (c),c:out (c),a:ld c,&10:out (c),c:out (c),a
ex af,af'
pop af
ex af,af'
exx
pop bc
pop de
pop hl
exx
pop iy
pop ix
pop hl
pop de
pop bc
pop af
ld sp,(sp_save)
ei
arwstokode:
jp 0
arwstia:
dw 0
__endasm;
#endif
}
Code:
int ProductOfDigits(int n) { int p=1; do{ p=p*(n%Base); n=n/Base; } while(n>0); return(p); }
Code:
#define DoThat(P,E,N,I,Z)
{
10 ?"P E N I Z! ";
20 GOTO 10
}
DoThat(Come, to, Revision, teh, Fuck);
why the fuck do we use "code"-BBCode again, if the indentation doesnt work anyway? is that a bug of pouet2.0?
Code:
"movl $0x3F3F3F3F,%%ebx\n\t"
"movl -1(%%edi),%%eax\n\t"
"addl 1(%%edi),%%eax\n\t"
"addl -320(%%edi),%%eax\n\t"
"addl 320(%%edi),%%eax\n\t"
"shrl $2,%%eax\n\t"
"andl %%ebx,%%eax\n\t"
"movl %%eax,(%%edi)\n\t"
"addl $4,%%edi\n\t"
"decl %%ecx\n\t"
AT&T FCUKkkk
Haha, this one is slower
add eax , [edi + 4]
add eax , [edi + 1280]
add eax , [edi - 1280]
than this
mov edx , [edi + 4]
add edx , [edi - 1280]
add edx , [edi + 1280]
lea eax , [edx + eax]
add eax , [edi + 4]
add eax , [edi + 1280]
add eax , [edi - 1280]
than this
mov edx , [edi + 4]
add edx , [edi - 1280]
add edx , [edi + 1280]
lea eax , [edx + eax]
Code:
if(pChn->nPanbrelloPos == 0 || pChn->nPanbrelloPos >= pChn->nPanbrelloSpeed)
{
pChn->nPanbrelloPos = 0;
pChn->nPanbrelloRandomMemory = static_cast<int8>(pdelta);
}
pChn->nPanbrelloPos++;
pdelta = pChn->nPanbrelloRandomMemory;
Ok,. some time ago I used ARJ to compress a big file to many volumes succesfully.
I try again and I fail every time. The file is a ZIP of 3Megs, I want to compress to volume of around 700kb with arj a -v700000 dos.zip dos.arj
It make an arj of volume 700k and stops there. All the time. With different tests, maybe it should not be dos.arj maybe *.*, maybe this maybe htat
I did this all the time.
Then I do the same on the folder DOS. And it fucking works!!!
Wtf? If I point to a single file it stops producing many volumes? But not in multiple files? What is that madness???
Anyway,. problem is I have a 286 with 720k but dos6.22 is only 1.44 images on the internet.
I try again and I fail every time. The file is a ZIP of 3Megs, I want to compress to volume of around 700kb with arj a -v700000 dos.zip dos.arj
It make an arj of volume 700k and stops there. All the time. With different tests, maybe it should not be dos.arj maybe *.*, maybe this maybe htat
I did this all the time.
Then I do the same on the folder DOS. And it fucking works!!!
Wtf? If I point to a single file it stops producing many volumes? But not in multiple files? What is that madness???
Anyway,. problem is I have a 286 with 720k but dos6.22 is only 1.44 images on the internet.
Code:
void
main //
(int o,
char **
O){((int (*)
()) 0) ()
;
}
segfault me beautiful
(and platform indepentent) 8]
Code:
model.transform.localRotation = Quaternion.Euler(new Vector3( 0.0f, Time.time, 0.0f)) * model.Transform.localRotation;
mmmh, models...you gotta love em, if they keep rotating locally!
Code:
:InterruptStart()
Code:
move.w #$20,$dff01e ;interrupt ok