## Random line of code thread

**category:**code [glöplog]

please wrap that in a do{ / }while(0) or it'll bork badly after an if without curly braces

but anyway,

but anyway,

**Code:**

```
ld a, $80
ldh [rBCPS], a
ldh a, [rLY]
ldh [rBCPD], a
ldh [rBCPD], a
```

**Code:**

`(_=$=>$<=0?1:$*_($-1))(12)`

**Code:**

`lda $0400+(((ScrollPos+4)*40)+1),y`

Thanks to earok's nice Amiga Blitz Basic2 extension for Visual Studio Code, this 23 years old code is now getting its final touches. Ohhh the touching!

lda #$05

sta $d800,x

sta $d800,x

col = fDesaturate(col, 1.314); // overdoing it gives a nice gold colour

**Code:**

`void draw_line_badly(float x0, float y0, float x1, float y1, float ht)`

sol_hsa: I feel called out

---

---

**Code:**

```
REG_DMA0_ADDR = a0;
REG_DMA1_ADDR = a2; // not a typo, the hardware is borked
REG_DMA2_ADDR = a1;
REG_DMA3_ADDR = a3;
```

**Code:**

`jsr GenSpeedCode`

**Code:**

`call [r11+rcx*8+0x7fef]`

**Code:**

```
\rotatebox{45}{%FFEN {\RU}#1/{\RU}{\RU}
}
```

**Code:**

```
if(direction==FaceDirection::FRONT)
{
faces[fid].normal = glm::dvec3(0.0,0.0,1.0);
unsigned int zOfs = fid/(dims.x*dims.y+2*(dims.x+1)*(dims.y+1)-(dims.x+1)-(dims.y+1));
unsigned int yOfs = (fid%(dims.x*dims.y+2*(dims.x+1)*(dims.y+1)-(dims.x+1)-(dims.y+1)))/(dims.x);
unsigned int xOfs = (fid%(dims.x*dims.y+2*(dims.x+1)*(dims.y+1)-(dims.x+1)-(dims.y+1)))%(dims.x);
faces[fid].e1 = zOfs*(((2*(dims.x+1)*(dims.y+1))-(dims.x+1)-(dims.y+1))+((dims.x+1)*(dims.y+1))) +(yOfs+1)*(2*dims.x+1)+xOfs+(dims.x+1)*(dims.y+1);
faces[fid].e2 = zOfs*(((2*(dims.x+1)*(dims.y+1))-(dims.x+1)-(dims.y+1))+((dims.x+1)*(dims.y+1))) +yOfs*(2*dims.x+1)+(xOfs+1)+dims.x+(dims.x+1)*(dims.y+1);
faces[fid].e3 = zOfs*(((2*(dims.x+1)*(dims.y+1))-(dims.x+1)-(dims.y+1))+((dims.x+1)*(dims.y+1))) +yOfs*(2*dims.x+1)+xOfs+(dims.x+1)*(dims.y+1);
faces[fid].e4 = zOfs*(((2*(dims.x+1)*(dims.y+1))-(dims.x+1)-(dims.y+1))+((dims.x+1)*(dims.y+1))) +yOfs*(2*dims.x+1)+xOfs+dims.x+(dims.x+1)*(dims.y+1);
addEdge(Edge3D((faces[fid].e1)+1,f.v1,f.v2,f.inside));
addEdge(Edge3D((faces[fid].e2)+1,f.v2,f.v3,f.inside));
addEdge(Edge3D((faces[fid].e3)+1,f.v3,f.v4,f.inside));
addEdge(Edge3D((faces[fid].e4)+1,f.v4,f.v1,f.inside));
}
```

**Code:**

```
template<typename T>
void writeData(float **ptr, const T value)
{
const float* dataptr = (float *)&value;
for (int i = 0; i < sizeof(T) / sizeof(float); i++)
{
**ptr = *dataptr++;
(*ptr)++;
}
}
```

This makes me feel positively dirty.

colors .byte vic.COLOR.([DARKGRAY, GRAY, LIGHTGRAY, WHITE][(0, 1, 2, 3, 2, 1, 0)])

**Code:**

`NUMCHARS_LO = (*-TAB_LO)/4`

**Code:**

`f32 remap(f32 x, f32 i0, f32 i1, f32 o0, f32 o1) return o0+(o1-o0)*saturate( (x-i0)/(i1-i0) );`

@Preacher, my C++ is rusty. How is that any different than memcpy'ing the value to a float array?

little bit magic... sinus wave without FSIN

you can use it for bytebeat :)

**Code:**

```
CBW
CWD
ADD AL,AL
CBW
XOR DL,AH
IMUL AH
XOR AH,DL
SHR DL,1
ADD AH,DL
MOV AL,AH
```

you can use it for bytebeat :)

f*ck IMUL AL of course

**Code:**

```
lax xu_shifttab + 1
sbx #-$10
cpx #$60
bcc +
lda #$0f
sbx #-$02
+
stx xu_shifttab + 1
```

**Code:**

`Dest[(SquareW-1-x)*SquareW+y]=Source[y*SquareW+x];`

**Code:**

`move.l #((40-(32/8))<<16)|40-(32/8),$60(a6)`

**Code:**

`Ok(())`

**Code:**

```
@ are we a gba or an nds?
mov r1, #0x42
mov r2, #0
str r1, [r2]
ldr r3, [r2]
cmp r3, r1
bne .Lprolly_gba
```

**Code:**

`if (swiCRC16(0x4b32, NULL, 0) == 0x544e) do_magic();`