It is currently Sun Aug 25, 2019 8:39 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Nes ROM with 5b sound
PostPosted: Tue Jul 16, 2019 12:41 am 
Offline

Joined: Fri Jul 05, 2019 2:29 am
Posts: 10
Hi, i've got a project going on where im planning to make a YM2149 expansion port sound module.
But i can not figure out a way to create a rom file that i would be able to flash to a cartridge.

I do not have a powerpak or similar and neither do i have a gimmick cart.

All i want is a nes rom with 2A03+5b music starting directly. preferrably with mapper 0 or mmc3 (got a modded mother cart i could use)


How do i manage this? :)


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 2:14 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7568
Location: Canada
You have to use mapper 69. That's the 5B mapper. You can't just put 5B mapper sound on a different mapper.

https://wiki.nesdev.com/w/index.php/Sunsoft_FME-7

(Your flash cartridge won't have 5B sound on it either, unless it was made with that hardware.)


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 2:26 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4208
Location: A world gone mad
"But i can not figure out a way to create a rom file that i would be able to flash to a cartridge. I do not have a powerpak or similar and neither do i have a gimmick cart."

There are ways to solve this, but not ways to solve your next dilemma:

"All i want is a nes rom with 2A03+5b music starting directly. preferrably with mapper 0 or mmc3 (got a modded mother cart i could use). How do i manage this? :)"

In short: you can't. The end.


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 2:46 am 
Offline

Joined: Fri Jul 05, 2019 2:29 am
Posts: 10
What i am doing is creating a expansion port sound card/module.
So i am not using the 5B chip per say.

So i am not able to select and write to $C000 and $E000 without a 69 mapper?
because thats all i need to do from what i understand (well ofc write correct info to create sound)


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 3:19 am 
Offline

Joined: Fri Dec 08, 2017 5:12 pm
Posts: 36
Perkka wrote:
What i am doing is creating a expansion port sound card/module.
So i am not using the 5B chip per say.

So i am not able to select and write to $C000 and $E000 without a 69 mapper?
because thats all i need to do from what i understand (well ofc write correct info to create sound)

You mean the NES Expansion Port? https://wiki.nesdev.com/w/index.php/Expansion_port#NES
If you're planning on attaching a YM2149 to the expansion port you will need to create the hardware to connect it. The Sunsoft 5B chip has the hardware inside it to translate writes at C000 and E000 to what the YM2149 inside it expects. If you aren't planning on using an actual 5B, you will need to create this yourself. And whether or not it responds to C000 or E000 will depend on how your circuit is designed (and you will need to route the appropriate signals to the EXP0-9 signals in your cart). If you want to use C000 and E000, for example, you'll probably need to route at least A14/A13 (A15 is already there) and CPU R/W. You will also need to account for bus conflicts if your donor is an MMC0 (MMC3 already has registers throughout 8000-FFFF so you can't use those ranges).


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 3:46 am 
Offline

Joined: Fri Jul 05, 2019 2:29 am
Posts: 10
GreyRogue wrote:
Perkka wrote:
What i am doing is creating a expansion port sound card/module.
So i am not using the 5B chip per say.

So i am not able to select and write to $C000 and $E000 without a 69 mapper?
because thats all i need to do from what i understand (well ofc write correct info to create sound)

You mean the NES Expansion Port? https://wiki.nesdev.com/w/index.php/Expansion_port#NES
If you're planning on attaching a YM2149 to the expansion port you will need to create the hardware to connect it. The Sunsoft 5B chip has the hardware inside it to translate writes at C000 and E000 to what the YM2149 inside it expects. If you aren't planning on using an actual 5B, you will need to create this yourself. And whether or not it responds to C000 or E000 will depend on how your circuit is designed (and you will need to route the appropriate signals to the EXP0-9 signals in your cart). If you want to use C000 and E000, for example, you'll probably need to route at least A14/A13 (A15 is already there) and CPU R/W. You will also need to account for bus conflicts if your donor is an MMC0 (MMC3 already has registers throughout 8000-FFFF so you can't use those ranges).


Yes this is what i was planning to do. And yes i were aware of the rerouting needed to be done, i believe i need to reroute 4 lines. A14, A13,R/W and CE.
I had missed the part with bus conflicts though. What would happen if i wrote to those on an MMC3 mapper if i had the sound chip connected?
And do you know what mappers that would not conflict?

I want to make this as compatible as possible with existing hardware and emus.

my plans started when i stumbled over this: https://mikejmoffitt.com/articles/0043- ... mmick.html
i wanted to create an expansion port sound card that could be used without the need of a chip in the cartridge.


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 3:57 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4208
Location: A world gone mad
Perkka wrote:
And do you know what mappers that would not conflict?

Start going through the mapper list one by one: https://wiki.nesdev.com/w/index.php/Mapper . Sometimes there will be an infobox in the upper right listing off bus conflicts, other times not, but you will most likely have to read the descriptions to get a full understanding.

Do not rely on https://wiki.nesdev.com/w/index.php/Cat ... _conflicts as it is incomplete (many mappers are missing the proper Category to place them there). Above paragraph is what needs to be done.


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 4:44 am 
Offline

Joined: Fri Dec 08, 2017 5:12 pm
Posts: 36
Perkka wrote:
Yes this is what i was planning to do. And yes i were aware of the rerouting needed to be done, i believe i need to reroute 4 lines. A14, A13,R/W and CE.
I had missed the part with bus conflicts though. What would happen if i wrote to those on an MMC3 mapper if i had the sound chip connected?
And do you know what mappers that would not conflict?

Actually, looking a little closer, you might be able to get away with MMC3. As long as your code doesn't need IRQs, and you ensure you only write to even addresses (e.g. C000 and E000 and not E001), it should work without bus conflicts. The writes to c000 and e000 will update the irq registers on the MMC3, but as long as you don't enable them, it shouldn't matter.


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 5:13 am 
Offline

Joined: Fri Jul 05, 2019 2:29 am
Posts: 10
koitsu wrote:
Perkka wrote:
And do you know what mappers that would not conflict?

Start going through the mapper list one by one: https://wiki.nesdev.com/w/index.php/Mapper . Sometimes there will be an infobox in the upper right listing off bus conflicts, other times not, but you will most likely have to read the descriptions to get a full understanding.

Do not rely on https://wiki.nesdev.com/w/index.php/Cat ... _conflicts as it is incomplete (many mappers are missing the proper Category to place them there). Above paragraph is what needs to be done.

What exactly do i look for, i am sadly not very knowledgeable in how this works.

GreyRogue wrote:
Perkka wrote:
Yes this is what i was planning to do. And yes i were aware of the rerouting needed to be done, i believe i need to reroute 4 lines. A14, A13,R/W and CE.
I had missed the part with bus conflicts though. What would happen if i wrote to those on an MMC3 mapper if i had the sound chip connected?
And do you know what mappers that would not conflict?

Actually, looking a little closer, you might be able to get away with MMC3. As long as your code doesn't need IRQs, and you ensure you only write to even addresses (e.g. C000 and E000 and not E001), it should work without bus conflicts. The writes to c000 and e000 will update the irq registers on the MMC3, but as long as you don't enable them, it shouldn't matter.


Ok, that sounds promising i guess :)
I guess Mapper 0 would work without issues also?

still i have no knowledge at all with programming to the nes etc. But i felt that building the circuit to make it all work looked really simple and it would be fun if it somehow could benefit people to make games with extra sound channels.

I have seen rainwarriors sound test roms ans were thinking i could flash them to a cart of some kind. but i do not know, especially when i suspected it to work in an emu to begin with and it feels like it's not.
Then i do not know if i simply have issues with the rom or if it's my circuit when testing.

I have not built anything yet for it, just ordered the YM2149 and waiting for it to arrive.


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 6:20 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21564
Location: NE Indiana, USA (NTSC)
For mapper 0, it might be helpful to make a ROM that runs correctly as either mapper 0 with a YM2149 or mapper 69. That can be done by adding a bit of code to the reset process somewhere above $E000:
Code:
; Poke in the values to make mapper 69 map PRG and CHR ROM
; the same way as to mapper 0
sunsoft5_init_nrom:
  ldx #13
  loop:
    stx $8000
    lda sunsoft5_nrom_values,x
    sta $A000
    dex
    bpl loop
  jmp old_reset

sunsoft5_nrom_values:
  .byte 0, 1, 2, 3, 4, 5, 6, 7  ; CHR banks
  .byte $C0, 0, 1, 2            ; PRG banks
  .byte 0, 0                    ; Mirroring/IRQ

Once you work through a few 6502 tutorials, what this does will make sense.

_________________
Pin Eight | Twitter | GitHub | Patreon


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 11:07 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8539
Location: Seattle
There's a simple definition that is compatible with every existing mapper, and requires only signals that are already on the expansion port.

Note that top-loading NESes don't have an expansion port.

In the NES, writes to $4016 keep track of the bottom three bits, but only the bottom one bit is normally accessible. The other two bits are only on the expansion port, and could be used as a signal to latch the upper five bits.

So a simple design, using the other major PSG of the era (the SN76494) might latch D7-D4 on a rising edge of OUT2, latch D7-D4 (save as the lower half byte) on a falling edge of OUT2, and connect OUT1 to /WE and /CE. A game would do something like

Code:
lda #$76 ; 1789773Hz÷110Hz = 508 = 0b0111_1111_00 ; four msbits here, out2 rising edge, out1 high
sta $4016
lda #$10 ; select register 0, "tone 1 frequency", and out2 and out1 falling edges
sta $4016
ldx #6
delay1: dex
bpl delay1
lda #$F6 ; four middle bits of period here, out2 rising edge, out1 high
sta $4016
lda #0 ; two lsbits here, and out2 and out1 falling edges
sta $4016
ldx #6
delay2: dex
bpl delay2
lda #2 ; prevent re-write of register
sta $4016


The AY-3-8910 requires nine bits, not eight, but a similar division is possible. The expansion port even provides the user with access to the 4MHz CIC clock, but it's a low-quality clock source and probably wouldn't be in tune with the crystal used by the NES itself.

Some existing games that were also released in Japan might already use OUT1 and OUT2 for other purposes.


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 1:01 pm 
Offline

Joined: Fri Jul 05, 2019 2:29 am
Posts: 10
I managed to get a NES rom with 5b sound after searching a lot more, got it by using eznsf.
the rom seem to call the right addresses but it wont output sound on the 5b chip (atleast not in mesen). This led me to think, it will never work with other mappers then 69 in emulators if not custom support is added.
The rom will most likely work on the real hardware once i built it. but it sort of defeats the purpose that i wanted to build something that would have good support from the get go.

Now if i create this maybe i should take an other approach of some kind. sure i still think YM2149 is a good choice because of famitracker support. maybe still the best choice.
should i still try to make it using the same addresses for example, and other things to consider?

lidnariq wrote:
There's a simple definition that is compatible with every existing mapper, and requires only signals that are already on the expansion port.

Note that top-loading NESes don't have an expansion port.

In the NES, writes to $4016 keep track of the bottom three bits, but only the bottom one bit is normally accessible. The other two bits are only on the expansion port, and could be used as a signal to latch the upper five bits.

So a simple design, using the other major PSG of the era (the SN76494) might latch D7-D4 on a rising edge of OUT2, latch D7-D4 (save as the lower half byte) on a falling edge of OUT2, and connect OUT1 to /WE and /CE. A game would do something like

Code:
lda #$76 ; 1789773Hz÷110Hz = 508 = 0b0111_1111_00 ; four msbits here, out2 rising edge, out1 high
sta $4016
lda #$10 ; select register 0, "tone 1 frequency", and out2 and out1 falling edges
sta $4016
ldx #6
delay1: dex
bpl delay1
lda #$F6 ; four middle bits of period here, out2 rising edge, out1 high
sta $4016
lda #0 ; two lsbits here, and out2 and out1 falling edges
sta $4016
ldx #6
delay2: dex
bpl delay2
lda #2 ; prevent re-write of register
sta $4016


The AY-3-8910 requires nine bits, not eight, but a similar division is possible. The expansion port even provides the user with access to the 4MHz CIC clock, but it's a low-quality clock source and probably wouldn't be in tune with the crystal used by the NES itself.

Some existing games that were also released in Japan might already use OUT1 and OUT2 for other purposes.



So that solution wouldnt need hardware modifications to cartridges at all? just work OOB if the software support it?
I were planning to use the 4mhz clock the port uses. trying to minimize the hardware needed. but if a crystal is needed then I'll add it.


Top
 Profile  
 
PostPosted: Tue Jul 16, 2019 1:55 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8539
Location: Seattle
Perkka wrote:
but it sort of defeats the purpose that i wanted to build something that would have good support from the get go.
You're not going to get expansion audio on anything other than NSFs and the mappers that originally had that specific expansion audio.

Quote:
should i still try to make it using the same addresses for example, and other things to consider?
There are too many variables here, really. You can attempt to come up with something that'll be compatible with most known hardware, but there's always going to be the oddball exceptions.

Quote:
So that solution wouldn't need hardware modifications to cartridges at all? just work OOB if the software support it?
Yeah. Personally, I think I'd rather attach a global volume control to the expansion port instead of more square waves.

But the SN76494 is also the only major tone generator from the era that didn't see its way into a Famicom cart, so I also have a soft spot for trying to fit it in.

And it probably needs some kind of mute, so that games that do do something with the upper bits written to $4016 don't break things.

Quote:
I were planning to use the 4mhz clock the port uses. trying to minimize the hardware needed. but if a crystal is needed then I'll add it.
I'd add a crystal or other clock generator. The 4MHz CIC clock will vary from console to console, and with time.


Top
 Profile  
 
PostPosted: Wed Jul 17, 2019 12:00 am 
Offline

Joined: Fri Jul 05, 2019 2:29 am
Posts: 10
lidnariq wrote:
Perkka wrote:
So that solution wouldn't need hardware modifications to cartridges at all? just work OOB if the software support it?
Yeah. Personally, I think I'd rather attach a global volume control to the expansion port instead of more square waves.

But the SN76494 is also the only major tone generator from the era that didn't see its way into a Famicom cart, so I also have a soft spot for trying to fit it in.

And it probably needs some kind of mute, so that games that do do something with the upper bits written to $4016 don't break things.

Perkka wrote:
I were planning to use the 4mhz clock the port uses. trying to minimize the hardware needed. but if a crystal is needed then I'll add it.
I'd add a crystal or other clock generator. The 4MHz CIC clock will vary from console to console, and with time.

The SN76494 does not look to be in abundance, there seems to be a lot of one of the derivatives though, namely the SN76489.
I still think i want to do something with the YM2149, just waiting for it to arrive by post.

About the volume control, were you thinking a software controlled one? or simply a knob on the console?

I were also planning to not use the RCA outputs on the NES for sound but to have 2 of the on the expansion module, mainly because then i could reroute sound trough famicom cartridges the correct way which i guess would help with having sound levels the way it was intended. i guess it will make a difference atleast.


Last edited by Perkka on Wed Jul 17, 2019 12:02 am, edited 2 times in total.

Top
 Profile  
 
PostPosted: Wed Jul 17, 2019 12:01 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8539
Location: Seattle
Perkka wrote:
About the volume control, were you thinking a software controlled one?
Yes, software controlled.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group