Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] spcPause(), spcResume(), spcGetStartPos() #213

Open
malayli opened this issue May 7, 2023 · 5 comments
Open

[Feature] spcPause(), spcResume(), spcGetStartPos() #213

malayli opened this issue May 7, 2023 · 5 comments
Assignees

Comments

@malayli
Copy link
Collaborator

malayli commented May 7, 2023

Feature request

Creating these 2 functions will allow a better control on a music IT file:

  • spcPause(): This function pauses a played music (started with spcPlay(0))
  • spcResume(): This function resumes a paused music (paused with spcPause())

Advanced Feature request

Creating this function will help developers to simply get the current startPos value:

  • spcGetStartPos()

So they can pass it to spcPlay(startPos) after stopping a music with spcStop().

Notes

These are the explanation of KungFuFurby that might help you to implement this feature:

startpos refers to an orderlist ID. You can retrieve the orderlist ID directly from $2143/$F7... but of course, the ASM I ported over way back when didn't include this function for whatever reason on the 65816 side.

Copy over this snippet of code, giving it a different name:

;**********************************************************************
; read status register
;**********************************************************************
spcReadStatus:
ldx #5 ; read PORT2 with stability checks
lda REG_APUIO2 ;
@loop: ;
cmp REG_APUIO2 ;
bne spcReadStatus ;
dex ;
bne @loop ;
rts ;

Replace all instances of REG_APUIO2 with REG_APUIO3.
I'd say put your modified function somewhere in https://github.com/alekmaul/pvsneslib/blob/master/pvsneslib/include/snes/sound.h ...but I don't see a good return type example from here. I'm thinking a u8

@malayli malayli changed the title [Feature] spcPause() and spcResume() [Feature] spcPause(), spcResume(), spcGetStartPos() May 7, 2023
@KungFuFurby
Copy link
Contributor

KungFuFurby commented May 7, 2023

A little bit of fine print: Pause and resume won't restart exactly from where you left off in the song: this is because the orderlist position is used. There may be some carryover problems because the song is reinitialized anyways the way things currently are handled, meaning we still have some resetting going on... I may want to do something different.

I also haven't looked at the way TCC handles its parameters yet to properly integrate with its C++-side code.

@malayli
Copy link
Collaborator Author

malayli commented May 9, 2023

@KungFuFurby Therefore, is it impossible to implement this feature?
Or does it need refactoring or new development?

@KungFuFurby
Copy link
Contributor

It's not impossible. Within the context of the methodology that would be used, it would have some limitations... in its earliest iteration, due to carryover problems. Later iterations can customize the SPC700 side so that it can resume exactly where it left off (spcGetStartPos(), which I am considering renaming to spcGetPos() for more generalized reasons, can stay since it still serves a purpose).

@malayli
Copy link
Collaborator Author

malayli commented Aug 12, 2023

@KungFuFurby Ok thank you! (sorry for late reply!).
@alekmaul Can we add this feature request to next major version of PVSnesLib? (5.0.0?)

@alekmaul
Copy link
Owner

yes, why not :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants