|
Post by scotthuggins on Jul 20, 2018 11:38:20 GMT -5
Hi!
In the code below, no matter what voice I use, it cancels out "some" of the other sounds in my game (Cavern Rescue). What I'm wondering is...can I push onto the stack the register 7 of the sounds chip value before I write to the sound chip and then restore? Just an idea. Any suggestions are appreciated!
Code (you'll notice, by the commented out code, I tried this on all three voices to no avail...I'm cancelling out other sounds)
lda #$07 ; Modify Register 7
ldb $c807 ; Get previous value for reg 7
;andb #$fe ; Turn on Tone on Voice 1
;orb #$08 ; Turn off Noise on Voice 1
andb #$fb ; Turn on Tone on Voice 3
orb #$38 ; Turn off Noise on Voice 3
;andb #$2d ; Turn on Tone on Voice 2
;orb #$10 ; turn off noise on voice 2
jsr BYTE2SNDCHIP ; Set register
It seems the "cancelling" of noise on voices 1-3 is the culprit. So, again, I am wondering after I write the changes to register 7, can I try and do another write to "restore" register 7 back to what it was before?
Thanks for reading and I appreciate any suggestions!
Scott
|
|
|
Post by Malban on Jul 20, 2018 18:16:46 GMT -5
In "general" if you want to enable or disable bits you have to keep the old bits as they are.
Than there is no need to restore values. Even if you would "restore" the old values - the new ones you just wrote would be obsolete and be gone.
Most of what you wrote looks right - I am not sure about the "orb" though. Let me write it a bit differently:
ldb $c807 ; get old value
; enable voice A
andb #%11111110 ; keep all bits as they are except bit 0, Voice is low active so this activates voice A and keeps everything as it was
; disable noise A orb #%00001000; noise is also low active - so setting noise A to 1 disables noise, all other bits stay the same
jsr BYTE2SNDCHIP ; Set register 7
I haven't tried it - but I am certain above is right. (and actually is the same that you wrote for Voice A)
The uncommented "orb #$38" of yours disables noise in all voices though.
But perhaps the culprit lies somewhere else - what exactly do you want to achieve?
Also - you can have noise and voice at the same time on one channel - you do not have to cancel the other... Perhaps you need not cancel out the noise at all?
|
|