Dragon Quest I & II

Page 2 of 2 Previous  1, 2

Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Conn Thu 3 Feb 2022 - 4:01

That is pretty simple, you only need to make a
LDA #$04
STA $2007
before introducing a new theme (sta $2004).
Then the position of the current playing song which you marked with that 2007:04 will resume when it is called again.

So for example I used it in Tales Phantasia:

Code:
cmp #$23 ; is battle theme 1 about to play?
bne $03
jsr resumeMusic
cmp #$41 ; is battle theme 2 about to play?
bne $03
jsr resumeMusic
STA $2004

; if battle themes are about to play, store the current playing theme
; position to resume thereafter when called again
resumeMusic:
PHA
LDA #$04
STA $2007
PLA
RTS

So simply check if another theme interrupts the current playing (battle, level up). If this is the case, simply make a sta $2007:04 before storing the battle, level up interruptings to $2004.
That's all Very Happy
Conn
Conn

Dragon Quest I & II - Page 2 Image212

Since : 2013-06-30

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Cubear Thu 3 Feb 2022 - 13:21

oh good, i was worried it was going to be a nightmare scenario where i had to make a timer for how long a track was playing and then feed the information back into the MSU1 later lol
Cubear
Cubear

Dragon Quest I & II - Page 2 Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Cubear Thu 3 Feb 2022 - 15:57

I've got to say that was a really simple solution to the problem, but now it's kinda glaring when it pops back in at full volume..

i'd like to do a pretty quick "fade-in" to avoid this, so that's what i'll put some effort into today before releasing this patch which quite easily solves the issue @TrueREALigion was having.
Cubear
Cubear

Dragon Quest I & II - Page 2 Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Conn Thu 3 Feb 2022 - 17:05

The easiest code I have for you is that I implemented in the zelda 3 short asm.

Code:
; Zelda ALTTP MSU1 patch by Conn
; no video
; should work on all Zelda versions (PAL, NTSC), no header


;header
lorom


org $0080f3
JSL newTrack
NOP
NOP

org $0080d7
JSL msuBusy
NOP



org $9bb600
newTrack:
STA $0133
cmp #$13
beq fanfare
PHA
LDA $2002      ;check if msu found
CMP #$53    
BEQ msuFound
PLA
STA $2140
RTL
msuFound:
LDA #$01
STA $0129  ; set msu busy
PLA
STA $0127  ;store track number
PHA
AND #$F0
CMP #$F0
BEQ endTrack
PLA
STA $2004
STZ $2005
STZ $2006
PHA
LDA #$F1
STA $2140
PLA
RTL
endTrack:
LDA $2000
AND #$08
BNE playfade
LDA #$F1
STA $2140
PLA
RTL
playfade:
LDA $0127
STA $2140
PLA
RTL
fanfare:
STA $2140
STZ $2007
wait:
LDA $2140
BEQ wait
STZ $0012
wait2:
LDA $0012
BEQ wait2
RTL

msuBusy:
SEP #$30
LDA $4210
LDA $0129
BNE $01
end:
RTL
LDA $0127
cmp #$f1
beq f1
cmp #$f2
beq f2
cmp #$f3
beq f3
bit $2000
bvs end    ; track not ready
STZ $0129  ; clear msu busy flag
LDA $2000
AND #$08
BNE playSPC
LDA $0127
tax
lda $1bb700,x ;load loop value
sta $2007  
lda #$FF   ; lautstärke
sta $2006
sta $012b ; fade
bra end
f1:
lda $012b
dec
dec
dec
cmp #$10
bcs $05
lda #$00
sta $0129
sta $2006
sta $012b
bra end
f2:
lda $012b
dec
dec
dec
cmp #$40
bcs $03
stz $0129
sta $012b
sta $2006
bra end
f3:
lda $012b
inc
inc
inc
cmp #$fb
bcc $05
stz $0129
lda #$FF
sta $2006
sta $012b
bra end

playSPC:
LDA $0127
STA $2140
RTL




ORG $1bb700 ; loop table 03:loop, 01 non-loop
db $03,$01,$03,$03,$03,$03,$03,$03,$01,$03,$01,$03,$03,$03,$03,$01 ; themes 00-0f
db $03,$03,$03,$01,$03,$03,$03,$03,$03,$03,$03,$03,$03,$01,$03,$03 ; themes 10-1f
db $03,$01,$01,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03 ; themes 20-2f

So, basically you need to set a fade flag in free ram (so in case of nmi, it branches to fadeup; then hook the nmi. If the fade flag is to set fade-up, increase the volume at a second free ram that mirrors the volume until it is FF.

NMI hook in above zelda asm is:
Code:

msuBusy: ;nmi hook
....
LDA $0127 ;ram that has fade commands, f3 is fade up
cmp #$f1
beq f1  ; fade down zero
cmp #$f2
beq f2 ; fade down half ($40)
cmp #$f3
beq f3 ; fade up


f3 (fade up):
Code:

f3:
lda $012b; free ram that mirrors the current volume
inc
inc
inc ; the number of incs determine the fading velocity
cmp #$fb; if fb, set volume to FF
bcc $05
stz $0129 ;clear fade flag
lda #$FF
sta $2006 ; store volume register
sta $012b ; store volume mirror
bra end
Conn
Conn

Dragon Quest I & II - Page 2 Image212

Since : 2013-06-30

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Cubear Fri 4 Feb 2022 - 1:53

Thanks for the assistance, @Conn. I've implemented something somewhat close to it with good results. I have updated the first post with a new version that fades in the tracks (only after battle) and it's really quite professional feeling.
Cubear
Cubear

Dragon Quest I & II - Page 2 Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Conn Fri 4 Feb 2022 - 6:40

Awesome!!! Very Happy
Out of interest, is an advance of the volume by $11 not a too fast fadeup (just wonder because in my testing experience, already +3/nmi is incredible fast)
Conn
Conn

Dragon Quest I & II - Page 2 Image212

Since : 2013-06-30

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Cubear Fri 4 Feb 2022 - 11:59

lol, well I hooked in a place that is 5 times slower than normal.

the normal code increments $68 until it is 5, then uses a break to set it back to 0 (to what end, i am not sure) but this let me set it up in such a way that my code only runs on every "5" so I can have more factors that multiply evenly into #$FF without going too fast


Last edited by Cubear on Fri 4 Feb 2022 - 19:12; edited 1 time in total
Cubear
Cubear

Dragon Quest I & II - Page 2 Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Conn Fri 4 Feb 2022 - 14:00

that's smart Very Happy I'm impressed by your learning progress Spin
Conn
Conn

Dragon Quest I & II - Page 2 Image212

Since : 2013-06-30

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Cubear Fri 4 Feb 2022 - 14:45

Thank you! As always it would not have been possible without your expert guidance while I was starting out, but every time I overcome a problem I feel a lot stronger Smile
Cubear
Cubear

Dragon Quest I & II - Page 2 Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by TruREALigion Thu 10 Feb 2022 - 22:26

great improvement on the most recent patch!

Bug (not sure if this is the right word at this point) with the music repeating from the beginning:
The level up jingle theme (I believe PCM 22) makes the music (ie. overworld world map, boat ride, cave/dungeon, tower) repeat.  
The Victory theme works great as it does not make the music repeat.

I'll continue reporting as I replay from beginning to end.  Great childhood memories (using the included NES guidebook and map)
TruREALigion
TruREALigion
Bee
Bee

Since : 2022-01-26

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Cubear Fri 11 Feb 2022 - 2:24

Taking a step through my code, it's working fine on leveling up in my emulator, detecting the right track, $1b (track 27,) and sending #$04 to $2007 to set the resume point.

I hate to respond with "works on my machine" but if I can't replicate your track restarts I can't begin to fix it.

I tested this in both dragon quest 1 and dragon quest 2 and in both games it seemed to function exactly as I would expect.

If there is a specific area that seems notably strange, I ask that you attach a zip with a save file or save state close to it so that I may see it for myself. thank you.

Also, if in your play through, you come across other instances where the music should resume instead of restarting, please let me know. There's a track map linked in the OP of this thread where you can see track titles + index numbers if you need some assistance with communicating names/track numbers.
Cubear
Cubear

Dragon Quest I & II - Page 2 Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Conn Fri 11 Feb 2022 - 17:56

Out of my experience @TruREALigion, it sometimes helps if you can send a video that shows how you play to trigger the bug.
Also, it helps if you tell on which emulator you play and such stuff.
Conn
Conn

Dragon Quest I & II - Page 2 Image212

Since : 2013-06-30

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by TruREALigion Sat 12 Feb 2022 - 21:56

I am using SD2SNES (FXPAK) flashcart and a Sandisk 128GB SD Card on the Analogue Super NT console.    

But here is my list of what I found for DQ2 that causes repeats using the Google Sheets track map as a reference.

1. This is a weird one but after a battle, it randomly repeats whatever overworld/dungeon/tower randomly repeats.  There are times it works fine, and other times it repeats from the beginning.  I tried a couple of ways to trigger it but haven't come to a solid conclusion as to why it happens.  
For example:
-I tried in DQ1, just leveling up fast (spamming A button) to see if it triggers the repeating music
-I tried disabling in-game hooks (hotkeys for the SD2SNES (FXPAK) to do things like save state, reset/reboot, enable/disable cheats, etc.)

PCM tracks that I have been testing (mainly on world map):
Filename: dq12_msu-3.pcm  DQ1 world map theme
Filename: dq12_msu-27.pcm Level up jingle
Filename: dq12_msu-11.pcm 3 party world map  
Filename: dq12_msu-22.pcm Battle victory jingle

2. Picking up a special item (ie. Mirror of Ra, Erdrick/Loto's gear, key items, etc.)
Filename: dq12_msu-51.pcm
Good example of this is picking up Mirror of Ra in DQ2 early in the game.  It plays this jingle, and should continue the current song (ie. world map theme).  
Example @5:25:

I'll report back after I spend some time playing on actual SNES hardware, and BSNES.  I'll try Higan too but its tricky to use for a non-technical guy like me.

I can't seem to find the attach button.  Not sure if it will help to attach my save file as I am thinking its because I'm playing on physical hardware instead of an emulator.  
I'll also spend some time making some 1-2 min videos showing the music randomly repeating.

The savestate feature for SD2SNES (FXPAK) is *.state so not sure if that helps.  I haven't spent enough time researching on converting this savestate to BSNES or Higan (apologies I am not too technical Dragon Quest I & II - Page 2 1f647 )
TruREALigion
TruREALigion
Bee
Bee

Since : 2022-01-26

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Cubear Sat 12 Feb 2022 - 23:14

I unfortunately can only test in BSNES (I use BSNES plus v05.88 to make the hacks)
I wouldn't worry about testing in various emulators, I'd rather have you finish a run and we can put this into the releases section. Play however you like.

I can easily add the special item jingle to the list of noloop tracks that should resume play. Maybe a better question is if there are any cases of noloop where it should NOT resume play lol.

I'll go with that idea for now and just make all of the noloop tracks set a resume point and then if anything gets really funky we can remove them systematically.

Updated the first post with a new version to include nearly every noloop track in the resume code
Cubear
Cubear

Dragon Quest I & II - Page 2 Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by Conn Sun 13 Feb 2022 - 4:43

I can't seem to find the attach button.
It should work if you click on the big "postreply" button and not use the quickreply form. Let me know if the problem persists, maybe I need to adjust something in the admin cp.
Conn
Conn

Dragon Quest I & II - Page 2 Image212

Since : 2013-06-30

Back to top Go down

Dragon Quest I & II - Page 2 Empty Re: Dragon Quest I & II

Post by MorganLeah Thu 24 Feb 2022 - 2:03

Dragon Quest I & II - Page 2 Dq12_m10
Dragon Quest I & II - Page 2 Dq122_10

MorganLeah
Bee
Bee

Since : 2022-01-31

Back to top Go down

Page 2 of 2 Previous  1, 2

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum