33 ms·
IIRC there is a C compiler (cc65) that targets 6502, AFAIK it's a dead project :( Anyone know anything about writing NES programs in C? Writing a NES game real
by sjtgraham 13y ago
IIRC there is a C compiler (cc65) that targets 6502, AFAIK it's a dead project :(
Anyone know anything about writing NES programs in C? Writing a NES game really appeals to me, but 6502 ASM does not!
- whoosy 13y agoActually cc65 is still maintained: https://github.com/oliverschmidt/cc65 https://github.com/oliverschmidt/cc65 Although since of March 2013 it has a new maintainer.
- ANTSANTS 13y agoShiru is the only person I know of that wrote anything interesting in C for the NES. Here are his thoughts on the experience: http://shiru.untergrund.net/articles/programming_nes_games_in_c.htm http://shiru.untergrund.net/articles/programming_nes_games_i... http://forums.nesdev.com/viewtopic.php?f=2&t=8493 http://forums.nesdev.com/viewtopic.php?f=2&t=8493 Take note of the "Optimization" section. The C you have to write for cc65 to generate a somewhat acceptable program is very... unidiomatic. C's machine model does not map well to 8-bit micros at all. You can't write a game for the NES or any of these old consoles entirely in C, some parts simply will not be fast enough to fit into tiny timing windows. At the very least, your interrupt routines (updating sound, graphics, and possibly scanline "raster effects") will have to be written in assembly. Game logic has a bit more leeway, but you'd still run the risk of taking too long and losing frames with an unoptimized program. Given that, it may still be a productivity win to use C to "script" some optimized assembly language to make a simple game (kinda like how modern game engines use languages like Lua to script optimized C++), but I don't think you can get very far if you're just using C as a crutch to avoid understanding the 6502. I think 6502 assembly isn't as hard as it sounds (it's fun!), but if that thought really turns you off, others have been much more successful with the C + optimized assembly libraries approach in the Sega Genesis/Mega Drive scene, where the standard dev tools are an older version of the GNU binutils + gcc for C projects. The 68000 is much more amenable to being targeted by a C compiler than a 6502 is. http://gendev.spritesmind.net/forum/viewtopic.php?t=14 http://gendev.spritesmind.net/forum/viewtopic.php?t=14 http://gendev.spritesmind.net/forum/viewtopic.php?t=1373 http://gendev.spritesmind.net/forum/viewtopic.php?t=1373 EDIT: Also, from experience writing some simple demo programs for the NES, I think understanding the PPU and writing a program that can be bank-switched effectively dwarfs the challenge of learning to program in assembly language.
- jevinskie 13y agoI suppose it depends on the CPU. GCC can generate high quality, compact code for the 8-bit AVR. Of course, AVR was designed for C, it has 32 registers and good indexing modes.
- laaph 13y agoSomeone made a project called nbasic, but I would say it was closer to some macros around assembler (and allowed inline assembly!) more than any basic dialect I imagine many of us are familiar with. http://bobrost.com/nes/files/nbasic_manual.html http://bobrost.com/nes/files/nbasic_manual.html