Editing Template:Ps2configrev

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 69: Line 69:
== hex2dec conversion way around 16 bits ==
== hex2dec conversion way around 16 bits ==
This trick would allow to pass the value in hex format to this template
This trick would allow to pass the value in hex format to this template
*Formula: #expr: '''W'''*16^3 + '''X'''*16^2 + '''Y'''*16^1 + '''Z'''*16^0
* #expr: W*16^3 + X*16^2 + Y*16^1 + Z*16^0
*Example 0x5555 = <code><nowiki>{{#expr: 5*16^3 + 5*16^2 + 5*16^1 + 5*16^0}}</nowiki></code> = {{#expr: 5*16^3 + 5*16^2 + 5*16^1 + 5*16^0}}
 
*Example 0x5555 (21845 dec)
** <nowiki>{{#expr: 5*16^3 + 5*16^2 + 5*16^1 + 5*16^0}}</nowiki> = {{#expr: 5*16^3 + 5*16^2 + 5*16^1 + 5*16^0}}
** 5*16^3 + 5*16^2 + 5*16^1 + 5*16^0
** 5*16^3 + 5*16^2 + 5*16^1 + 5*16^0
** 5*4096 + 5*256 + 5*16 + 5*1
** 5*4096 + 5*256 + 5*16 + 5*1
** 20480 + 1280 + 80 + 5
** 20480 + 1280 + 80 + 5
** 21845
** 21845
For this to work it would be needed also to split the original hex value in digits (4 bits, or half a byte). And pass the digits individually to another template containing a "switch" statement that should return 16 posible values in decimal (if 0=0, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6, 7=7, 8=8, 9=9, A=10, B=11, C=12, D=13, E=14, F=15)<br>
The endianess is something trivial and easy to implement as an additional parameter when calling the template, but i think is better to simplify the usage as most as posible so the candidate template names by now are: <nowiki>{{hex2dec1byte}}, {{hex2dec2bytesLE}}, {{hex2dec2bytesBE}}</nowiki>
*Not working in psdevwiki, see: [https://www.mediawiki.org/wiki/Module:String 1] and [https://www.mediawiki.org/wiki/Extension:StringFunctions 2]
**{{#invoke:String|pos|target_string|index_value}}<br>
**{{#invoke:String|pos|target=target_string|pos=index_value}}<br>
**{{#pos|target=target_string|pos=index_value}}<br>
**{{#len:string}}<br>
**{{#sub:QWERTY|3|1}}<br>
[[Category:Games]]</noinclude>
[[Category:Games]]</noinclude>
Please note that all contributions to PS3 Developer wiki are considered to be released under the GNU Free Documentation License 1.2 (see PS3 Developer wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)

Template used on this page: