Page 1 of 2

C compiler for the C64 and other 65xx machines.

Posted: Fri May 16, 2014 7:54 pm
by Shaun_B
I gave cc65 a quick blast a couple of year ago (I think), but didn't get very far with it mostly due to a lack of time, but it did what it was supposed to. It's available here:

http://cc65.github.io/cc65/

There are some samples to look through as well. Enjoy!

Regards,

Shaun.

Re: C compiler for the C64 and other 65xx machines.

Posted: Fri Oct 03, 2014 1:49 am
by onlineprof2010
I started looking at cc65. Definitely slower than assembly but a bit faster than BASIC which is good for games. But programming timewise I think I was able to whip up something faster than basic or assembly.

UFO attack .prg file (v1.1)
https://drive.google.com/file/d/0BxrxBh ... sp=sharing
youtube preview
[video]https://www.youtube.com/watch?v=VrvEdKqHkKo[/video]

Looter .prg file (v2.2)
https://drive.google.com/file/d/0BxrxBh ... sp=sharing
youtube preview
[video]https://www.youtube.com/watch?v=uTVfDOk3xxc[/video]

I know, the games are simplistic but considering I never actually completed making a game as a kid I am happy so far.

Re: C compiler for the C64 and other 65xx machines.

Posted: Fri Oct 03, 2014 9:57 am
by Shaun_B
Now I have slightly improved my BASIC programming skills, I'll have a look again into C for the C64. I think the Mine Sweeper program that I wrote should be easy enough to convert to C and I'd be happy enough if I could manage it as I'm not 1337.

Regards,

Shaun.

Re: C compiler for the C64 and other 65xx machines.

Posted: Fri Oct 03, 2014 11:41 am
by dudz
Definitely slower than assembly but a bit faster than BASIC
you should carefully look at the generated code, then you'll quickly notice what the compiler is good at and what doesnt work so great - its surely not quite as good as plain assembly, but you can certainly use it to write *much* faster code than in basic :)

Re: C compiler for the C64 and other 65xx machines.

Posted: Sat Oct 04, 2014 12:10 am
by onlineprof2010
Thanks for the thoughts guys. I think exploring c with c64 is worthwhile. It is a language that follows a standard and it just may be possible to write portable code for the c64 (simple tile based windows games or ones with less than 9 sprites). Like in my game loop, I call a check_collision or update_sprites c function which goes to a c64 layer peeking/poking the sprite locations. But adding these function calls slows things down so I might try making some "inline". I still want to keep them though as I can conceivably replace the c64 layer with another system.

Re: C compiler for the C64 and other 65xx machines.

Posted: Sat Oct 04, 2014 8:50 pm
by onlineprof2010
I spent this Saturday morning tweaking the UFO game into an air sea battle game.
[video]https://www.youtube.com/watch?v=G8YHrVt7By4[/video]

Air Sea Battle PRG download
https://drive.google.com/file/d/0BxrxBh ... sp=sharing

Re: C compiler for the C64 and other 65xx machines.

Posted: Sun Oct 05, 2014 8:04 pm
by Prime
Thanks for sharing onlineprof2010 it's always great to see what others are up too.

Re: C compiler for the C64 and other 65xx machines.

Posted: Sat Oct 11, 2014 8:56 pm
by onlineprof2010
I decided to do another quick game before I take on something much bigger like my super mario game. I did a PETSCII centipede clone. Some have asked to see 'C' code for learning purposes so I am posting here:

[video]http://www.youtube.com/watch?v=yMx-HyvEKxI[/video]

C Code
https://drive.google.com/file/d/0BxrxBh ... sp=sharing

PRG File to play v2.1
https://drive.google.com/file/d/0BxrxBh ... sp=sharing

Re: C compiler for the C64 and other 65xx machines.

Posted: Wed Dec 03, 2014 4:43 am
by onlineprof2010
I know there are probably plenty of tools out there for sprites, but I decided to make my own in excel. After creating the sprite in an excel grid, it spits out data which you can paste into your c code.

Image

Here is the excel spreadsheet:
https://drive.google.com/file/d/0BxrxBh ... sp=sharing
clicking the link will display the spreadsheet through google but there is a download button which makes it easier to view and edit in excel itself.

I used it to do a basic update of my UFO game:
https://drive.google.com/file/d/0BxrxBh ... sp=sharing

On a side note also made some quick updates to my looter and centipede game:
https://drive.google.com/file/d/0BxrxBh ... sp=sharing
https://drive.google.com/file/d/0BxrxBh ... sp=sharing

Wish I had more time to do this fun stuff!

Re: C compiler for the C64 and other 65xx machines.

Posted: Thu Dec 04, 2014 2:53 pm
by Heart
I always find it faster and easier to bload sprite data in rather than repoke/recompile/ressemble data statements.