View Full Version : MasterPatch (technical)
Hello!
I've searched for serveral hours now and found not a bit I understood (that is: not russian...):
I just want to know how to write own patches using MasterPatch.. that is:
* Do I sort of "register" my patch with MP?
* How does is enable/disable the patch? Does it restore the entry point?
* How to use the configuraton-parts?
(Alternatively, I think a source code of any patch written for MP would be enough...)
Can somebody provide some information in english? ;-)
TIA, KKaul
PS: Btw, where (which forum) is the current development of MP going on? [The actual answer please, can be russian]
I think that siemens-club, see: http://forum.siemens-club.org/viewtopic.php?TopicID=56798
WBR
>Do I sort of "register" my patch with MP?
No, you don't have to "register" your patch. But your patch must have section like this:
0FC1080: 0xB1C2D3E4,0x0000AB01,0000000000000000,"\
{patch=BottomDate ver=8 cp=avkiev id=AB01 mem=20}\
{1 cb ShowComma v=1}\
",00
where 0xB1C2D3E4 - magic constant, 0x0000AB01 - PatchID
In this case MasterMidlet can control your patch.
>How does is enable/disable the patch? Does it restore the entry point?
No, MasterMidlet doesn't restore entry-point.
In example above patch needs 20 byte of RAM as its own buffer.
MasterMidlet just switch high bit of byte #0.
In patch we have code like this:
LoadReg 0, config+4 ; r0=PatchID
bl GetBuffer ; Getting buffer for Patch
beq exit ; If no patch or patch disabled - exit
>How to use the configuraton-parts?
In example above we will have checkbox (cb) in MasterMidlet. User can check or uncheck it...
hi, the "mem" token in:
{patch=BottomDate ver=8 cp=avkiev id=AB01 mem=20}
i have a patch with some 100 bytes config ram. but it runs also WITHOUT mem=100. what is the purpose of "mem"?
another question: if i have e.g. such thin in config:
{sm Profile1}","\
{1 cb `screen output` v=00}","\
{endsm}","\
....
{sm Profile7}","\
{7 cb `screen output` v=00}","\
{endsm}","\
the masterpatch doesnt recognize string "Profile7" as a profile token, it's just a string. so i have to do "GetProfile" in patch to find out the current profile.
could be the token "pf" for any use for me? how i could use it? could you give me an example, please?
what is the purpose of "mem"?
Example:
{patch=BottomDate ver=8 cp=avkiev id=AB01 mem=20}\
{1 cb ShowComma v=1}
In this example I use byte#1 as checkbox.
But I too use bytes 2-19 for my own purposes. So, I have to write "mem=20". Size of buffer is 20 bytes.
In this example:
{patch=BottomDate ver=8 cp=avkiev id=AB01}\
{1 cb ShowComma v=1}
I will have buffer, which size is just 2 bytes.
So, we have to write "mem=..." if we use some area of buffer as a internal RAM for patch...
the masterpatch doesnt recognize string "Profile7" as a profile token, it's just a string. so i have to do "GetProfile" in patch to find out the current profile.
could be the token "pf" for any use for me? how i could use it? could you give me an example, please?
Yes, in this example: Profile7 - just string.
We have to use command PROFILES=Y if we want to have ability check/uncheck patch in some profiles. Default value of PROFILES is Y, so we can omit it.
But, if you want do some complex check in patch - you have to call GetProfile...
See example:
"{patch=KeyLightTrg id=EA01}\
{sm Bright.}\
{1 b(7) r=0..100}\
{endsm}\
{sm Delay}\
{8 b(7)}\
{endsm}",00
could you give me an example
You can find some sources of MP-patches here:
http://forum.siemens-club.org/viewtopic.php?TopicID=57987
PS. Sorry for my keeping silence, I was very busy
thx, this is very helpful.
...
where 0xB1C2D3E4 - magic constant
...How about the other constants
0xA1234504 - onStartup, адрес процедуры, вызываемой при старте телефона
0xA1234508 - onConfigChange, адрес процедуры, вызываемой при изменении конфигурации
Are they supported in some way?
How about the other constants
0xA1234504 - onStartup, адрес процедуры, вызываемой при старте телефона
0xA1234508 - onConfigChange, адрес процедуры, вызываемой при изменении конфигурации
Are they supported in some way?
Yes. If onStartup <> 0 - MasterPatch.ConfigScaner will call this procedure during creating PatchTable.
But I didn't see any patch, which use it. :)
Also, I didn't see any patch which use onConfigChange...
onConfigChange ... could one call the refresher? :)
and:
would i replace the "magic" address, or is it like this (first config-line):
adress: magic,id,onStartup,onConfigChange
e.g.
0FD1000: 0xB1C2D3E4,0x0000CCCC,0xA1234567,0xA1234589,"\
?
onStartup works. that's nice, so for normal patches you dont need anymore any entrypoint, but you can start a CallAfterTimer thread, which cycles the patch body in an interval you like.
but unfortunetly onConfigChange seems to have absolutly no effect ...
--------------------
maybe in this context the "call after time" parametrers are for some coders interesting:
R0=pointer to 8 bytes free ram for timer internal purposes
R1=time value (approx. 216 units = 1 sec.)
R2=destination address
attention, all register are killed by CallAfterTimer
onStartup works
but unfortunetly onConfigChange seems to have absolutly no effect ...
attention, all register are killed by CallAfterTimer
Of course, onStartup works. I call it in Scaner.
But MasterPatch doesn't call onConfigChange - I don't see any reason for it.
PS. AFAIK, CallAfterTimer kills only R0-R3...
CallAfterTimer kills only R0-R3...Interesting. But how it works? So with CallAfterTimer, you dont call directly the function in R2, but it's called by the CallAfterTimer-Function. So there is no direct register- and stack- pass-through. Also, the LR of the called function is somehow "invalid".
Actually I did'nt see any use of CallAfterTimer in patches outside of Blinker [/offtopic]
So there is no direct register- and stack- pass-through
...
Actually I did'nt see any use of CallAfterTimer in patches outside of Blinker
I use CallAfterTimer in my patch "Talking Phone".
I pass arguments via RAM of this patch.
Okay, now I understand. Sure CallAfterTimer kills not all registers in the function calling it. But one cannot pass-thru regs to the function called by timer. So same do I, pass the arguments to destination func by ram.
-----------
Next question: the token "ms" like in:
{2 ms `Milisekunden` v=2167}",00
is damaged. Everytime you open then config in the midlet, close it, and open it again, it looses 4 ms ! So is smelts to zero :)
I dont have contact address to chaos. Could you pass him this midlet error, the shift from 1000ms to internal 216,7... is nice, but due this error now unusable :(
I dont have contact address to chaos. Could you pass him this midlet error
Discussion about MasterMidlet on Siemens-club.org (http://forum.siemens-club.org/viewtopic.php?TopicID=57688&page=0#409781)
E-mail to chaos (http://forum.siemens-club.org/member.php?Action=email&username=chaos)
thanx for quoting me there
But MasterPatch doesn't call onConfigChange - I don't see any reason for it.I could need it very well in the moment. Could you add it, please?
I could need it very well in the moment. Could you add it, please?
OnConfigChange ?
When MasterPatch should call it ?
1nvisible calls it in the refresher. Take a look into his code. ;)
I've found another solution for it, so it's not so important for me anymore. But in general I think, it would be nice to have all the functions implemented in the MasterPatch, that are intended for the MasterPatch/Master midlet concept. Maybe someone absolutely needs it in the future. Would be too bad, when it's not implemented in this case. ;)
Yes, I need it, too. You said sometime before, that you think it's not necessary. I have a patch idea, that doesn't need an own entrypoint. It would be enough to run patch body after config has changed, to just copy some bytes from config to other places in RAM.
Another issue: if refresher changes the buffer address, it would be really nice if the content of the old buffer would be copied to the new buffer. In case one stores some internal patch data in that buffer, which one need to communicate the runtime patch body with itself.