Brutkey

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

I know programmers who don't use copy paste and they're all cowards


Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

the only difference between the code is if it ANDs the result against 0x10 (button 1) or 0x20 (button 2).

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

years ago I asked for the source for this game in the hopes of building a modernized version. I think I'm starting to see why I never got the source: it's slightly crap

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

this code does the following:
sets joy_left to false
sets joy_right to false
reads the state of the joystick
if this fails, it sets joy_left to false, joy_right to false, then returns.

YOU DID THAT TWICE. IT'S ALWAYS FALSE

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

this is in the function read_joystick_analog_x, which is the same as read_joystick_analog_y with one byte changed

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

it keeps track of how many enemies/planets are on screen by adding 2 to a global variable in the render_enemies_and_missiles function.

but why two? suspicious.

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

on 16-bit system, 2 is a very suspicious number

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

yep there's an array of pointers!

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

this file loading code is broken. it tries to load the file in 64kb chunks but it only saves the size as a 16bit variable, so a 64kb file will be recorded as 0, and any bigger file will break.

but fortunately the file is only 11kb so it works, as the read-second-chunk behavior never triggers

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

at least this is a compression algorithm that isn't too complicated: it's simple RLE.

0xFF is a marker, and is followed by a byte of repeat count(-1) and a byte of value.

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

although technically this is the second time I hacked this compression, I did figure this out already back in, like, 2013?

Foone🏳️‍⚧️🏳️‍⚧️
@foone@digipres.club

this game uses a ton of hardcoded offsets into data files. I wonder if this was done with linker nonsense or if they had to be manually hardcoded in.

the latter is frighteningly possible

Kevin Karhan :verified:
@kkarhan@infosec.space

@foone@digipres.club that's good, I guess...