| |
Mixer
Registered: Apr 2008 Posts: 460 |
Relocatable music routine
There are plenty of music routines, which can be compiled from source or relocated by self modifying some of the code, but has anyone written a fully relocatable music routine?
Something that you can just load to any address and it'll work.(Obviously the complexity of the player is a factor, but let's say something like GT) |
|
| |
tlr
Registered: Sep 2003 Posts: 1814 |
The song data for Antony Crowther's player (as used by him and Ben Daglish) is fully relocatable, but the player is not. |
| |
Gordian
Registered: May 2022 Posts: 101 |
Quoting MixerThere are plenty of music routines [...] relocated by self modifying some of the code
Did you know Sidreloc tool?
https://www.linusakesson.net/software/sidreloc/index.php |
| |
Krill
Registered: Apr 2002 Posts: 3098 |
Quoting MixerSomething that you can just load to any address and it'll work.(Obviously the complexity of the player is a factor, but let's say something like GT) Not aware of anything like that, but given that there usually is an init call before calling the player itself periodically, that init routine could determine the base address and modify the actual player and song data code (much like a dynamic library loader would do).
There would be no overhead for playing the song itself, but of course some memory overhead for the relocation stuff. |
| |
Mixer
Registered: Apr 2008 Posts: 460 |
@Gordian: Yes.
@Krill: I'd do it pretty much like that as well. The weird thing I'd like to try is to relocate the music many times on the fly, just to be able to use memory more flexibly, and to avoid loading. |
| |
tlr
Registered: Sep 2003 Posts: 1814 |
Quoting MixerThe weird thing I'd like to try is to relocate the music many times on the fly, just to be able to use memory more flexibly, and to avoid loading.
Then you have one more constraint, the code must be relocatable while running, i.e no absolute pointers in the state variables. |
| |
Spinball
Registered: Sep 2002 Posts: 89 |
i am quite shure that nebula implemented selfrelocating on init for some player (JCH?) back in the days. |
| |
Case
Registered: Aug 2002 Posts: 143 |
I am pretty sure that JCH released his own relocation tool, along with one to split the music into 4 or 5 parts that could be spread throught memory.
I also remember there being a relocation tool for sid-chip scratchers.
But as started previously due to the complexity, tables etc. they cannot be just loaded to a memory location and work. |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1424 |
Technically the 103 bytes of code for Rozzo is completely relocatable - the state variables are all in zero page. But there are four instructions that read from the 152 bytes of song data (notes, durations & frequencies) that would need patching if you wanted to move that as well.
(and yes, obviously this is an extremely minimal player - fixed ADSR, only wave $21, no modulation or filters, and gate off three frames before note end) |
| |
ws
Registered: Apr 2012 Posts: 251 |
Just because i asked this myself a while ago briefly and thought scanning memory for my own code would be the simplest: what would be the fastest way to find out the code's own base adress?
Something like briefy writing code to an empty place like the tape buffer, jsr there and read the return adress from stack? |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1424 |
jsr here
here:
pla
tax
pla
will put the address of here-1 into AAXX and restore the stack pointer to the value it had before the JSR was executed. |
... 15 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 - Next |