this post was submitted on 02 Jul 2023
13 points (100.0% liked)

C Programming Language

993 readers
1 users here now

Welcome to the C community!

C is quirky, flawed, and an enormous success.
... When I read commentary about suggestions for where C should go, I often think back and give thanks that it wasn't developed under the advice of a worldwide crowd.
... The only way to learn a new programming language is by writing programs in it.

© Dennis Ritchie

🌐 https://en.cppreference.com/w/c

founded 1 year ago
MODERATORS
 

Hello fellow developers! I’m new to this community and I am interested in learning more about you all, I have a simple question what is your favorite personal project that you have developed in the C programming language? It doesn’t have to be something mind blowing or extremely complex just something that you’ve enjoyed developing.

top 10 comments
sorted by: hot top controversial new old
[–] [email protected] 6 points 1 year ago
[–] [email protected] 2 points 1 year ago (1 children)

I developed half-assed a NASM wrapper (or transpiler if u will) while ago, It basically just adds some high-level feature like simple condition statements directly against registers, for example:

if (rax == 12)

Then generates appropriate NASM code. Simple really. Most error checkings are done my NASM lol so I dont need to worry much about the prefixes or instruction-operand correctness. I took most of the grammar for the expression from here. I privatized the repo because it is crazy how dirty it is I am ashamed of myself. If anyone wanna do it again, I'm up tho. But i dont wanna use my old code, just code again from start.

[–] [email protected] 1 points 1 year ago

U might be thinking "lol that just C 2.0", no it was not, it is not that advanced lmao

[–] [email protected] 2 points 1 year ago (2 children)

I few years back I wrote a Gameboy emulator in C, it was definitely one of the most fun projects I've done. The Gameboy is simple enough that you can make an emulator for it without crazy amounts is effort, and the result is very satisfying. A lot of the simpler systems people recommend writing emulators for aren't that interesting IMO simply because after you write it the games you can run aren't that great.

[–] [email protected] 2 points 1 year ago (1 children)

A Game Boy emulator is what I want to do next in that realm. I’ve done a CHIP-8 emulator/interpreter, but as you said, the actual games that run on it aren’t too great. I feel Game Boy is a logical next step. Either Game Boy or NES.

[–] [email protected] 1 points 1 year ago

I haven't personally written a NES emulator but I have a friend who did and it seemed like a comparable level of difficulty to the GB. It did sound like emulating the cartridge hardware was harder because games didn't tell you what they used (compared to GB where a cart tells your that info in the header), but I'm guessing you can cover most games by only implementing a small subset of the options anyway.

[–] [email protected] 1 points 1 year ago (1 children)

An emulator is definitely a dream project of mine but I haven't worked up the courage to do it yet, currently I'm working on a webserver but a gameboy emulator something I would like to try out when I have more experience with programming. Did you have any issues with running any specific roms or any performance issues in general?

[–] [email protected] 3 points 1 year ago (1 children)

Starting with Gameboy might be a bit daunting but if you're reasonably comfortable with C then I don't think it's too bad. If you're not too familiar with the hardware side of it then that might be a challenge, but the advantage with the Gameboy is that there's tons of documentation and tutorials out there which can probably help you work though the details. Really the big thing is to just be ready to do lots of reading XD You need to get a base-level of understanding of the system before you start coding. git says it took me around a year to get it functional and playing most ROMs, but that was with some big breaks in-between.

Also, that's a very good question. For performance, it was never an issue. I started it with a focus on keeping the code clean vs. worry about performance and it turned out fine, I've run it on a cheap 1.6GHz machine and it didn't even reach 25% CPU usage, so IMO I wouldn't worry about it. This also doesn't vary that much ROM to ROM.

For the ROMs I tested, for the most part every ROM tended to uncover something new, but the Gameboy has a pretty nice progression of "easy" to "hard" ROMs if you just sort by the MBC type, and also the BIOS is a pretty good test of basic functionality. Additionally there are a few different test suite ROMs out there that are fantastic, they'll run through every instruction or piece of functionality and check for the correct results, they saved me tons of time.

[–] [email protected] 1 points 1 year ago (1 children)

I can definitely see why this project is you favorite, I cant imagine myself working on a 1 year project ever lol, I think my longest project was about 2 weeks and I almost gave up multiple times.

[–] [email protected] 2 points 1 year ago

Lol the funny thing is that this isn't even close to my longest project :P I have one with a first commit close to 10 years ago (and I of course started it a while before the first commit). It's my favorite just for how fun the result is. IMO the best projects tend to be ones you actually like to use when you're done.

That said I also wouldn't put too much stock in that 1 year, I think I worked on it a lot for about a month and then moved onto other things after having trouble with it. I came back about a year later and managed to more or less finish it. It's definitely a long time to devote to a project, but if you stayed focused on it you could do it in a couple months I think.