Initialization Problems
Moderator: BigEvilCorporation
Initialization Problems
So I'm using the initialization code found here:
viewtopic.php?t=122&highlight=init
I've tried out this code on my US Genesis Model 2 and there is a constant buzzing noise, which (of course) isn't present in Regen and other emulators. I've confirmed that the code is assembled correctly and tested it out with no additional code in order to confirm the problem is with this piece of code.
So, does anyone else have this problem? I'm not familiar at all with the sound hardware (yet), but I'm wondering if there isn't some sort of initialization that the YM2612 has to undergo. Any help would be appreciated.
Thanks.
viewtopic.php?t=122&highlight=init
I've tried out this code on my US Genesis Model 2 and there is a constant buzzing noise, which (of course) isn't present in Regen and other emulators. I've confirmed that the code is assembled correctly and tested it out with no additional code in order to confirm the problem is with this piece of code.
So, does anyone else have this problem? I'm not familiar at all with the sound hardware (yet), but I'm wondering if there isn't some sort of initialization that the YM2612 has to undergo. Any help would be appreciated.
Thanks.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
That init isn't sufficient for turning off the audio. I use this code myself
That absolutely turns off all sound, but when you start the sound back up, FM percussions played FIRST don't sound right the first time they are keyed on for some reason. There's no problem with anything other than percussion that I've seen.
Code: Select all
| halt Z80 and init FM chip
/* Allow the 68k to access the FM chip */
move.w #0x100,0xA11100
move.w #0x100,0xA11200
| reset YM2612
lea FMReset(pc),a5
lea 0xA00000,a0
move.w #0x4000,d1
moveq #26,d2
5:
move.b (a5)+,d1 /* FM reg */
move.b (a5)+,0(a0,d1.w) /* FM data */
nop
nop
dbra d2,5b
moveq #0x30,d0
moveq #0x5F,d2
6:
move.b d0,0x4000(a0) /* FM reg */
nop
nop
move.b #0xFF,0x4001(a0) /* FM data */
nop
nop
move.b d0,0x4002(a0) /* FM reg */
nop
nop
move.b #0xFF,0x4003(a0) /* FM data */
nop
nop
addq.b #1,d0
dbra d2,6b
| reset PSG
lea PSGReset(pc),a5
lea 0xC00000,a0
move.b (a5)+,0x0011(a0)
move.b (a5)+,0x0011(a0)
move.b (a5)+,0x0011(a0)
move.b (a5),0x0011(a0)
<cut>
FMReset:
/* disable LFO */
.byte 0,0x22
.byte 1,0x00
/* disable timer & set channel 6 to normal mode */
.byte 0,0x27
.byte 1,0x00
/* all KEY_OFF */
.byte 0,0x28
.byte 1,0x00
.byte 1,0x04
.byte 1,0x01
.byte 1,0x05
.byte 1,0x02
.byte 1,0x06
/* disable DAC */
.byte 0,0x2A
.byte 1,0x80
.byte 0,0x2B
.byte 1,0x00
/* turn off channels */
.byte 0,0xB4
.byte 1,0x00
.byte 0,0xB5
.byte 1,0x00
.byte 0,0xB6
.byte 1,0x00
.byte 2,0xB4
.byte 3,0x00
.byte 2,0xB5
.byte 3,0x00
.byte 2,0xB6
.byte 3,0x00
| PSG register initialization values
PSGReset:
.byte 0x9f /* set ch0 attenuation to max */
.byte 0xbf /* set ch1 attenuation to max */
.byte 0xdf /* set ch2 attenuation to max */
.byte 0xff /* set ch3 attenuation to max */
.align 4
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
even when I set A to zero, and DSR to max I will still get "trailing noise", only happens on MD1 though, never on MD2... I play dummy silent notes between SFX and music notes to minimize previous config affecting next when note is still playing something etc.
YM2612 is quite buggy, YM3438 has all these things fixed up.
YM2612 is quite buggy, YM3438 has all these things fixed up.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
I don't load a sound driver - the 68000 plays the sound (VGM in this instance). I leave the Z80 reset as shown in the code I posted. The code to disable the audio is run when the rom is initialized or reset, and when the VGM is stopped. I had to experiment with different code that would actually make the sound go off AND still sound okay when restarted. This is the best I've found so far.andlabs wrote:If the drums don't play right the first time, are you running this code before loading the sound driver?
Thanks for the code Chilly. Have you run it on hardware? I included it in my initialization code and it does turn the sound off, but...that's it.
I tried rebuilding a small Hello World demo I made with the new init code and it didn't work correctly. Since it worked using the other init code I linked to in the first post, it has to be with the code you gave me. It runs perfectly in Regen, so I'm not sure what the problem is.
Here's my current initialization code:
http://archive.rpgclassics.com/subsites ... v/init.asm
And the demo archive (I didn't include the few resource files it takes, but I did include the built rom):
http://archive.rpgclassics.com/subsites ... 222011.zip
Thanks for the help.
EDIT: Actually, nevermind. I figured out what the problem was with my original init code. Apparently I forgot to include the 4 values to write to the PSG. I feel so stupid.
It works now though.
I tried rebuilding a small Hello World demo I made with the new init code and it didn't work correctly. Since it worked using the other init code I linked to in the first post, it has to be with the code you gave me. It runs perfectly in Regen, so I'm not sure what the problem is.
Here's my current initialization code:
http://archive.rpgclassics.com/subsites ... v/init.asm
And the demo archive (I didn't include the few resource files it takes, but I did include the built rom):
http://archive.rpgclassics.com/subsites ... 222011.zip
Thanks for the help.
EDIT: Actually, nevermind. I figured out what the problem was with my original init code. Apparently I forgot to include the 4 values to write to the PSG. I feel so stupid.
It works now though.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Yeah, I use my code on hardware. It's part of the NeoMyth menu. It's also used by my VGM player when you stop the VGM playback. All it does it turn off the z80 and sound (both the FM and PSG). That's ALL it does. If you need to load a z80 driver, do it after the code I posted, then deassert reset on the z80.
Good to hear you got your code going. It's easy to forget about the PSG since many folks don't use it. I forgot it in my code at one point to start as well!
Good to hear you got your code going. It's easy to forget about the PSG since many folks don't use it. I forgot it in my code at one point to start as well!
I have been setting SL/RR to FF, then issuing a key off, but here are some various procedures from other games.
Sonic 1 - Key off all channels, set all TL registers to 7F
Sonic 2 - Key off all channels, set all registers to FF (30 through 8F)
Sonic & Knuckles, Sonic 3, Castle of Illusion, World of Illusion, Quackshot, etc. - Set SL/RR to FF, set TL to 7F, key off. Set SSG/EG to 0.
Perhaps it would help to set TL to 7F as well, like these other games do?
Sonic 1 - Key off all channels, set all TL registers to 7F
Sonic 2 - Key off all channels, set all registers to FF (30 through 8F)
Sonic & Knuckles, Sonic 3, Castle of Illusion, World of Illusion, Quackshot, etc. - Set SL/RR to FF, set TL to 7F, key off. Set SSG/EG to 0.
Perhaps it would help to set TL to 7F as well, like these other games do?
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Maybe... I'll try that.Gigasoft wrote:I have been setting SL/RR to FF, then issuing a key off, but here are some various procedures from other games.
Sonic 1 - Key off all channels, set all TL registers to 7F
Sonic 2 - Key off all channels, set all registers to FF (30 through 8F)
Sonic & Knuckles, Sonic 3, Castle of Illusion, World of Illusion, Quackshot, etc. - Set SL/RR to FF, set TL to 7F, key off. Set SSG/EG to 0.
Perhaps it would help to set TL to 7F as well, like these other games do?