Poll of the Day > God damn people are so fucking bad at writing legible code

Topic List
Page List: 1
Yellow
05/27/18 5:52:56 AM
#1:


I mean, what is this garbage?

https://github.com/TASVideos/fceux/blob/master/src/cart.cpp

void setprg8r(int r, uint32 A, uint32 V) {
if (PRGsize[r] >= 8192) {
V &= PRGmask8[r];
setpageptr(8, A, PRGptr[r] ? (&PRGptr[r][V << 13]) : 0, PRGram[r]);
} else {
uint32 VA = V << 2;
int x;
for (x = 0; x < 4; x++)
setpageptr(2, A + (x << 11), PRGptr[r] ? (&PRGptr[r][((VA + x) & PRGmask2[r]) << 11]) : 0, PRGram[r]);
}
}


What is it doing? What is r, A, V? No explanation. Why would you make something open source if it's completely unreadable? That's the whole fucking thing, cryptic nonsense.

My code for comparison;

private void LoadRom(String file)
{
// http://wiki.nesdev.com/w/index.php/INES

Console.WriteLine("Loading " + file);
byte[] nesFile = System.IO.File.ReadAllBytes(file);

int file_pos = 0;

// Load header:
rom_header = new byte[16];
Buffer.BlockCopy(nesFile, file_pos, rom_header, 0, 16);
file_pos += 16;
...


You tell what I'm doing here, or at least make a good guess. I make use of the English language.

Sigh. Of course, PotD can tell me where I'm supposed to map my NES CHR ROM to my CPU mapper using NROM cartridge rips in my NES emulator, right? It's not telling me here, looking under the "Banks" section.

https://wiki.nesdev.com/w/index.php/NROM

Actually, I just figured it out, it's a little hidden. I'm honestly curious if anyone else will. This is like a really hard puzzle, but it's rewarding.
---
... Copied to Clipboard!
Grendel
05/27/18 9:31:17 AM
#2:


Yellow posted...
int file_pos = 0;


ewwww snake case
... Copied to Clipboard!
Yellow
05/27/18 10:28:24 AM
#3:


whichOneOfTheseSentencesIsEasiestToRead

thats_just_my_personal_preference

If_You_Really_Wanted_To_Do_Both_You_Could_Do_This
---
... Copied to Clipboard!
kind9
05/27/18 11:54:18 AM
#4:


The use of so many hard-coded constants kind of annoys me too. What is the significance of 8192, 13 and 11? It looks like it's almost all straight C code so I wonder why they used C++?
---
... Copied to Clipboard!
Yellow
05/27/18 12:55:38 PM
#5:


No clue.

I think it's also really poorly coded as in tons of things are being repeated for no reason. I think this code is loading code from ROM into RAM, but hard coded for code that's 8 Kb long.
---
... Copied to Clipboard!
Greenfox111
05/27/18 1:02:36 PM
#6:


yeah yeah yeah youre perfect everyone else sucks
---
Don't ask.
... Copied to Clipboard!
Grendel
05/27/18 2:27:18 PM
#7:


Yellow posted...
whichOneOfTheseSentencesIsEasiestToRead

thats_just_my_personal_preference

If_You_Really_Wanted_To_Do_Both_You_Could_Do_This


You should avoid making 40-character variable names. A variable should not be a full sentence description of its purpose.
... Copied to Clipboard!
Topic List
Page List: 1