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.
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 »

Myself086 wrote: Tue Apr 25, 2023 1:20 pm What do you think of the following? "Something" should result in a 1-liner in assembly.
I like that syntax. I wasn't sure if giving guidance on register use would be clunky or not but this is actually pretty clean looking. I assume that's defining a class named Player that implements (or inherits from) iEntity, and it'd be up to you to make a Player instance somewhere?
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: C-like compiler with devkit?

Post by Myself086 »

NovaSquirrel wrote: Tue Apr 25, 2023 1:58 pm
Myself086 wrote: Tue Apr 25, 2023 1:20 pm What do you think of the following? "Something" should result in a 1-liner in assembly.
I like that syntax. I wasn't sure if giving guidance on register use would be clunky or not but this is actually pretty clean looking. I assume that's defining a class named Player that implements (or inherits from) iEntity, and it'd be up to you to make a Player instance somewhere?
Yes, you'd be able to allocate a new Player somewhere. Making a new instance of Player can sometimes either return null or throw an exception when memory is full.

Each class inheriting from iEntity would have an iEntity ID to be used with JSR (abs,X) or similar. The ID will be a multiple of 2 by default.
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: C-like compiler with devkit?

Post by 93143 »

Myself086 wrote: Tue Apr 25, 2023 7:00 amI 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.
Oh yeah, I remember - we talked about this last year. Good to see you've got it working.

I wonder what the "small issue" is?
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 5:47 pm I wonder what the "small issue" is?
The way the BRR files had to be encoded, they had to be broken down into transfer blocks and "frame" blocks. A frame block must fill the entire HDMA table except for the last one. So there's always unused HDMA data after the end of a BRR file.

To clarify what a "transfer block" is, I had to transfer data in parallel rather than sequential because the timing is too tight on the S-CPU. With parallel pointers and X only incrementing once per scanline, I can transfer more than 256 bytes with just using the X register.

Since I'm sending 4 bytes per scanline, I don't have a communication port dedicated to sending a "ready" signal. I have a 16-bit compare with YA on the first 2 ports. But when the data is the same for 2 scanlines in a row, the S-CPU won't pick up the second one. Because I'm already transferring data in parallel, I can simply reduce the transfer block by 4 bytes and the data on each port will shift by 1 byte, making it possible to find an optimal structure for sending the BRR file while the first 2 bytes in the communication ports always change each scanline.

Because the data structure for the HDMA transfer had to be figured out before writing it to the ROM, each frame is predetermined.
93143 wrote: Tue Apr 25, 2023 5:47 pm Oh yeah, I remember - we talked about this last year. Good to see you've got it working.
I had a small part of the code done last year and abandoned it until January. It was for a different project at the time.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: C-like compiler with devkit?

Post by creaothceann »

Myself086 wrote: Tue Apr 25, 2023 1:20 pm

Code: Select all

this.SomeValue = value;
Is the "this." optional? (assuming there are no ambiguities)
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: C-like compiler with devkit?

Post by 93143 »

Myself086 wrote: Tue Apr 25, 2023 8:04 pma bunch of stuff
Oh, interesting. So you're syncing on data and sacrificing a small amount of bandwidth to work around the repeated-word problem, which means you don't actually need any of the fancy, potentially brittle BS my method uses. (Full disclosure: I still haven't gotten around to implementing it...)

I also like the parallel-pointer idea; it's a clever way to exceed the limits of the index register (as well as allowing the sync workaround). My approach uses sequential writes and is thus limited by X, but since I'm not syncing every line it would be unwise to try to exceed 256 bytes in one data burst anyway.


...also, when you say "S-CPU", do you mean the SPC700? Because technically that's the S-SMP. "S-CPU" was Nintendo's designation for the 5A22 that handles the main program, just like the 5C77 and 5C78 graphics chips are called the S-PPU1 and S-PPU2. You wouldn't be the first person to make this mistake...
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: C-like compiler with devkit?

Post by Myself086 »

creaothceann wrote: Tue Apr 25, 2023 11:12 pm
Myself086 wrote: Tue Apr 25, 2023 1:20 pm

Code: Select all

this.SomeValue = value;
Is the "this." optional? (assuming there are no ambiguities)
It can be. It shouldn't be hard to make it optional.
93143 wrote: Tue Apr 25, 2023 11:56 pm ...also, when you say "S-CPU", do you mean the SPC700? Because technically that's the S-SMP. "S-CPU" was Nintendo's designation for the 5A22 that handles the main program, just like the 5C77 and 5C78 graphics chips are called the S-PPU1 and S-PPU2. You wouldn't be the first person to make this mistake...
I've seen some people refer to it as "S-CPU" so I just assumed it was correct. I meant SPC700.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: C-like compiler with devkit?

Post by Pokun »

The "S" means "super". Super-CPU, Super-APU, Super-WRAM etc.

Also there is no SPC700 chip, as it is the name of the microprocessor core and its assembly instruction set used in the S-SMP chip. It took me many years to understand that as SPC700 and S-SMP are often used interchangeably.

To make it even more confusing, the whole detachable sound daughter board which includes the S-SMP, S-DSP, ARAM, DAC and op-amp is sometimes called the "S-APU", and especially on 1CHIP models where it appears as a single ASIC labeled so.
User avatar
Individualised
Posts: 310
Joined: Mon Sep 05, 2022 6:46 am

Re: C-like compiler with devkit?

Post by Individualised »

The APU was combined into a single chip in 1CHIP models? Thought only the PPU was. So I guess TCT-975 is not an original design?
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: C-like compiler with devkit?

Post by Pokun »

Yep, turning it into an ASIC probably lower costs and makes it run smoother with less power consumption. The 1CHIP models are known for their superb video output. This also means the APU isn't removable on the 1CHIP though, since it's a soldered surface-mount chip.

I don't know when the TCT-975 were released, they may have combined things into ASICs before Nintendo did. Either way those clones are not perfect copies anyway right? They are probably just done approximately after reverse engineering the real chips.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: C-like compiler with devkit?

Post by lidnariq »

( The APU wasn't removable well before the 1chip ASIC. Only the oldest model of mainboard (SHVC-CPU-01) has the separate SHVC-SOUND module; all later ones (SNS-CPU-GPM-nn, SNS-CPU-APU-nn, SNS-CPU-RGB-nn, all PAL models) put the APU components on the mainboard. )
User avatar
Individualised
Posts: 310
Joined: Mon Sep 05, 2022 6:46 am

Re: C-like compiler with devkit?

Post by Individualised »

Pokun wrote: Thu Apr 27, 2023 4:43 pm Yep, turning it into an ASIC probably lower costs and makes it run smoother with less power consumption. The 1CHIP models are known for their superb video output. This also means the APU isn't removable on the 1CHIP though, since it's a soldered surface-mount chip.

I don't know when the TCT-975 were released, they may have combined things into ASICs before Nintendo did. Either way those clones are not perfect copies anyway right? They are probably just done approximately after reverse engineering the real chips.
They show issues similar to some inaccurate emulators. So they were probably done like UMC NES chips rather than being die mask clones. I don't know what company designed them.
Last edited by Individualised on Fri Apr 28, 2023 11:53 am, edited 1 time in total.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: C-like compiler with devkit?

Post by Pokun »

I see, despite having a launch model PAL SNES since release I didn't know the APU wasn't removable in it all this time. You learn new things every day.
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: C-like compiler with devkit?

Post by psycopathicteen »

If somebody is making a C-like compiler, I would like to see something like this:

a = b + c - d | e & f

get assembled as:

lda b
clc
adc c
sec
sbc d
ora e
and f
sta a

Just going left to right and treating the accumulator as whatever the answer to the last arithmetic/logical operator.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: C-like compiler with devkit?

Post by calima »

That's unlikely to happen since math order and range are usually taken into account.
Post Reply