Difference between revisions of "Talk:PIC"
(→Challenge code: new section) |
(No difference)
|
Latest revision as of 11:24, 21 June 2017
Challenge code
[1:06 PM] JayFoxRox: but the handshake page should also be moved to our wiki [but I'd keep it on the SMC article probably and shorten it a bit] [1:06 PM] JayFoxRox: there is also some ambiguity wether it's 200ms or 250ms [1:08 PM] JayFoxRox: like.. that PIC Challenge article has full code listings for communicating with the PIC, which is entirely unrelated to the challenge lol. it's probably even unrelated to the PIC and just smbus related [1:09 PM] JayFoxRox: also the behaviour is not explained anywhere, but just hidden in the example source code [which uses arguments from @ARGV instead of using the SMBUS read/write routine] lol [1:10 PM] JayFoxRox: really that entire article boils down to: 200ms +
$t1 = ($res_1c << 2) ^ ($res_1d + hex('039')) ^ ($res_1e >> 2) ^ ($res_1f + hex('063')); $t2 = ($res_1c + hex('0b')) ^ ($res_1d >> 2) ^ ($res_1e + hex('1b'));
[1:10 PM] JayFoxRox: and unfortunately perl is not the most readable language for this purpose :stuck_out_tongue: [1:17 PM] JayFoxRox: I'd just have used:
uint8_t a = smc_in(0x1C); uint8_t b = smc_in(0x1D); uint8_t c = smc_in(0x1E); uint8_t d = smc_in(0x1F); uint8_t t1 = (a << 2) ^ (b + 0x39) ^ (c >> 2) ^ (d + 0x63); uint8_t t2 = (a + 0x0B) ^ (b >> 2) ^ (d + 0x1B); uint8_t x = 0x33; uint8_t y = 0xED; for (unsigned int i = 0; i < 4; i++) { x += y ^ t1; y += x ^ t2; } smc_out(0x20, x); smc_out(0x21, y); smc_out(0x01, 0x00);
(edited) [1:18 PM] JayFoxRox: the a-d and x-y things could also be described in a comment, and it could also be rewritten without the datatypes and just a comment like: "All datatypes are unsigned bytes!" [1:19 PM] JayFoxRox: [the out portion might even be bad, I have a hard time understanding that code on the xbox-linux wiki] [1:20 PM] JayFoxRox: like.. "The above is repeated 0x21 and byte2, and 0x01 and data 0x00." what does that even mean?