Guest User

tablet.c

a guest
Aug 26th, 2020
142
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Manual RE of Terminal Data Systems (TDS) tablet firmware for Quantel devices
  2.  
  3. uint8_t regs[0x100];
  4. uint8_t mem[0x80];
  5.  
  6. label4e1:
  7. enable_interrupts();
  8. mem[0x1f] &= ~1;
  9. if (P2.6 == 0)
  10.     mem[0x1f] |= 1;
  11. if (P2.5 == 0)
  12. {
  13.     // 4f2
  14.     if (mem[0x4f] & 1)
  15.     {
  16.         // 4f7
  17.         P3.5 = 0;
  18.     }
  19.     else
  20.     {
  21.         // 4fc
  22.         P3.5 = 1;
  23.     }
  24.     goto label052d;
  25. }
  26. else
  27. {
  28.     // 501
  29.     P3.5 = 1;
  30.     mem[0x2d] = 0;
  31.     if (mem[0x38] != 0x03)
  32.     {
  33.         // 50b
  34.         mem[0x3b] = 0;
  35.         mem[0x3c] = 0;
  36.         mem[0x3d] = 0;
  37.         mem[0x3e] = 0;
  38.         mem[0x3f] = 0;
  39.         goto label0615;
  40.     }
  41.     else
  42.     {
  43.         // 518
  44.         if (mem[0x3a] == 0)
  45.         {
  46.             // 51e
  47.             if (BIT(mem[0x4f], 0))
  48.             {
  49.                 // 524
  50.                 if (!BIT(mem[0x4f], 7))
  51.                 {
  52.                     goto label05d5;
  53.                 }
  54.                 else
  55.                 {
  56.                     goto label0615;
  57.                 }
  58.             }
  59.             else
  60.             {
  61.                 goto label0615;
  62.             }
  63.         }
  64.         else
  65.         {
  66.             goto label0615;
  67.         }
  68.     }
  69. }
  70.  
  71. label052d:
  72.     regs[0x3e] = regs[0x3d];
  73.     if (--mem[0x67])
  74.     {
  75.         // 537
  76.         mem[0x67] = 0x40;
  77.         disable_interrupts();
  78.         regs[0x30] = *(uint8_t *)0x6005;
  79.         regs[0x30] = ~((regs[0x30] >> 4) | (regs[0x30] << 4));
  80.         if (BIT(mem[0x7e], 2))
  81.         {
  82.             // 548
  83.             uint8_t regs[0x31] = regs[0x30];
  84.             regs[0x30] &= 0x05;
  85.             if (BIT(regs[0x31], 1))
  86.             {
  87.                 regs[0x30] |= (1 << 3);
  88.             }
  89.             if (BIT(regs[0x31], 3))
  90.             {
  91.                 regs[0x30] |= (1 << 1);
  92.             }
  93.         }
  94.         regs[0x30] &= 0x0f;
  95.         if (regs[0x30] == regs[0x3b] &&
  96.             regs[0x30] == regs[0x3c])
  97.         {
  98.             regs[0x3d] = regs[0x30];
  99.         }
  100.         // 56a
  101.         regs[0x3c] = regs[0x3b];
  102.         regs[0x3b] = regs[0x30];
  103.         enable_interrupts();
  104.     }
  105.  
  106.     // 0571
RAW Paste Data