C-like compiler with devkit?

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

C-like compiler with devkit?

Post by Myself086 »

I was thinking of making a devkit with a C-like compiler for SNES but with some slightly different syntax to be able to optimize some of the low level like short vs long pointers.

I'm also curious as to what people expect from the code's syntax. How similar to C should it be? Is there something you wish was supported at a high level language? What features should the devkit have built-in?

My personal goals for the devkit:
- Automatic convertion of PNG files for tile map, tile chars and sprite sheet
- Automatic convertion of WAV files
- Static and dynamic VRAM allocation for BG and sprite chars
- BRR files streaming from ROM (done)
- Music player supporting common audio formats
- Multi-threading (done)
- Object oriented with garbage collection (almost done)

I have already made an attempt at a compiler but I'm going to rebuild parts of it for the new one.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: C-like compiler with devkit?

Post by dougeff »

My only recommendation.

Have an asm library for communication with the hardware registers. Especially with DMA transfers.

As for high level syntax. It doesn't much matter as long as it compiles to correct code.
nesdoug.com -- blog/tutorial on programming for the NES
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: C-like compiler with devkit?

Post by Oziphantom »

probably better of porting Kick-C to 65816, as it already does what you want but is designed for optimal 6502. Or filling out the 65816 support of MillFork.
C has long and short pointers, hence MS stuff is now LPSTR = Long Pointer STRing. but they are normally implemented as near and far pointers ( implementation specific ) so you have

Code: Select all

int* pDefaultPointer;
int far * pLargePointer;
int near * pShortPointer;
but nobody has needed this since the 286 so most compilers don't support it anymore. The WDC C compiler might still have it though.

what are you converting wav into?
SNES AYE
Posts: 201
Joined: Mon Nov 07, 2022 11:28 am

Re: C-like compiler with devkit?

Post by SNES AYE »

I honestly don't know what it needs, but, as someone who's used stuff like GameMaker (old versions before Studio) and Unity in the past to make some games and do some tests, if the coding part was something along the same lines as that kind of thing, I'd at least be able to use it myself to some degree. And, above anything else, I actually want to be able to use it. I think there's probably a lot of aspiring SNES developers in a similar boat, just waiting for something that's as user-end friendly as that kind of stuff to come along so they can try their hand at making their own SNES games. Whatever way you go, I wish you the very best. :)
User avatar
Individualised
Posts: 310
Joined: Mon Sep 05, 2022 6:46 am

Re: C-like compiler with devkit?

Post by Individualised »

SNES AYE wrote: Mon Apr 24, 2023 10:46 am I honestly don't know what it needs, but, as someone who's used stuff like GameMaker (old versions before Studio) and Unity in the past to make some games and do some tests, if the coding part was something along the same lines as that kind of thing, I'd at least be able to use it myself to some degree. And, above anything else, I actually want to be able to use it. I think there's probably a lot of aspiring SNES developers in a similar boat, just waiting for something that's as user-end friendly as that kind of stuff to come along so they can try their hand at making their own SNES games. Whatever way you go, I wish you the very best. :)
The problem is with that approach you'll end up with pretty limited capabilities. You'd essentially end up with a SNESmaker. Not really good for making games unless you're only interested in making simple games, and not really good for learning how to program the target system as everything is so abstracted.
____
I'd love to see this happen, especially if it happens for NES as well (I know there's now NESFab).
SNES AYE
Posts: 201
Joined: Mon Nov 07, 2022 11:28 am

Re: C-like compiler with devkit?

Post by SNES AYE »

Individualised wrote: Mon Apr 24, 2023 11:13 am
SNES AYE wrote: Mon Apr 24, 2023 10:46 am I honestly don't know what it needs, but, as someone who's used stuff like GameMaker (old versions before Studio) and Unity in the past to make some games and do some tests, if the coding part was something along the same lines as that kind of thing, I'd at least be able to use it myself to some degree. And, above anything else, I actually want to be able to use it. I think there's probably a lot of aspiring SNES developers in a similar boat, just waiting for something that's as user-end friendly as that kind of stuff to come along so they can try their hand at making their own SNES games. Whatever way you go, I wish you the very best. :)
The problem is with that approach you'll end up with pretty limited capabilities. You'd essentially end up with a SNESmaker. Not really good for making games unless you're only interested in making simple games, and not really good for learning how to program the target system as everything is so abstracted.
____
I'd love to see this happen, especially if it happens for NES as well (I know there's now NESFab).
Is there a particular reason why a new SNES game creation devkit or tool can't cater to both more casual game makers who just want to make something simple and the more hardcore game makers who want to code stuff down to the lowest level and push the system to its limits?

I don't know about NESmaker, but I would hope that's actually an option there. And, if it doesn't exist there, then I guess a SNESmaker with exactly that additional level of optional functionality is exactly what I'd like to see in an ideal scenario.

But, honestly, for now I'd personally be happy to have the simple high-level SNESmaker-like tool over the alternative if it just means more people can get into SNES development in general, including myself. I'd actually consider that a big and valuable step forward from where things are at currently.
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: C-like compiler with devkit?

Post by Myself086 »

dougeff wrote: Mon Apr 24, 2023 8:46 am My only recommendation.

Have an asm library for communication with the hardware registers. Especially with DMA transfers.

As for high level syntax. It doesn't much matter as long as it compiles to correct code.
100% agree with you.
Oziphantom wrote: Mon Apr 24, 2023 8:55 am what are you converting wav into?
WAV to BRR and into a format compatible to my HDMA transfer code to ARAM.
SNES AYE wrote: Mon Apr 24, 2023 1:35 pm Is there a particular reason why a new SNES game creation devkit or tool can't cater to both more casual game makers who just want to make something simple and the more hardcore game makers who want to code stuff down to the lowest level and push the system to its limits?
This is going to be more casual than pure assembly and can be used to push limits though other tools are already better at that.
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: C-like compiler with devkit?

Post by 93143 »

Myself086 wrote: Mon Apr 24, 2023 3:04 pmmy HDMA transfer code to ARAM.
I missed this somehow.

Are you using the d4s method, or my method? Or did you roll your own from scratch? What does the data rate look like?
SNES AYE
Posts: 201
Joined: Mon Nov 07, 2022 11:28 am

Re: C-like compiler with devkit?

Post by SNES AYE »

Myself086 wrote: Mon Apr 24, 2023 3:04 pm This is going to be more casual than pure assembly and can be used to push limits though other tools are already better at that.
That sounds good to me. :)
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: C-like compiler with devkit?

Post by Oziphantom »

what are you going to use to sequence the samples?
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: C-like compiler with devkit?

Post by Oziphantom »

there is also https://lemonspawn.com/turbo-rascal-syn ... but-begin/ which says it has SNES support, might be able to expand and improve the SNES support for it?

edit : Fixed the link
Last edited by Oziphantom on Tue Apr 25, 2023 7:28 am, edited 1 time in total.
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: C-like compiler with devkit?

Post by Myself086 »

93143 wrote: Tue Apr 25, 2023 12:54 am
Myself086 wrote: Mon Apr 24, 2023 3:04 pmmy HDMA transfer code to ARAM.
I missed this somehow.

Are you using the d4s method, or my method? Or did you roll your own from scratch? What does the data rate look like?
I made my own from scratch, I haven't made it public because I'm using Warcraft II sound effects and music for the demo. The music is just a >1MB BRR file.
Data rate is 832 bytes per frame in 224p (49920 bytes per 60 frames). This is enough to stream 8 channels at 11025 Hz but there's a small issue preventing full transfer all the time, the audio files that I use for my demo lose about 1/16 of the transfer rate to this issue.
Oziphantom wrote: Tue Apr 25, 2023 3:08 am what are you going to use to sequence the samples?
Sorry, I'm not sure I fully understand your question.
Oziphantom wrote: Tue Apr 25, 2023 4:20 am there is also https://lemonspawn.com/turbo-rascal-syn ... egin/which says it has SNES support, might be able to expand and improve the SNES support for it?
"Oops! That page can’t be found."
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: C-like compiler with devkit?

Post by Oziphantom »

fixed the link.
User avatar
NovaSquirrel
Posts: 483
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: C-like compiler with devkit?

Post by NovaSquirrel »

I think that because this compiler would be specifically for game dev, it could help a lot to natively support a concept of a "this" pointer/index. In my experience a lot of game code ends up involving a list of entities, and I've seen cc65 repeatedly load the same "current entity" value into an index register when handwritten assembly would have gone for just keeping it in X or Y. So "this" or some other means of communicating that you want to operate on the same object across a chunk of code sounds really helpful.

I also want to point out the strategy of using an index register as a pointer, instead of as an index since it's not obvious, and it has some speed and code size benefits.

As for friendlier, simpler tools, I feel like a good compiler actually helps a lot with those goals too, because then those sorts of tools can generate code for a higher level language instead of directly being tasked with generating assembly, and that sounds like it'd reduce the effort needed for making a tool like that.
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: C-like compiler with devkit?

Post by Myself086 »

I'm absolutely doing the "this" pointer. Also the ability to force passing arguments in certain registers.

What do you think of the following? "Something" should result in a 1-liner in assembly.

Code: Select all

RegY Class Player : iEntity
{
	u16 SomeValue;
	
	void Something(RegA u16 value)
	{
		this.SomeValue = value;
	}
}
Post Reply