Advertisement
mkv

psp vn assembly patch

mkv
Sep 4th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; =================================================
  2. ; BEGIN eboot.asm
  3. ; -- translate game menus to english
  4. ; -- fix menu alignment bug in original game code
  5. ; =================================================
  6.  
  7. .psp
  8. .open "EBOOT-orig.BIN","EBOOT-temp.BIN",0x08804000
  9. .headersize 0x8803f40
  10.  
  11. ; Set sceImposeSetLanguageMode()'s first argument to 0x1 (English)
  12. .org 0x8832670
  13.    li    $a1, 1
  14.  
  15. ; Set the language field in the struct parameter to sceUtilitySavedataInitStart() to 0x1 (English)
  16. .org 0x8832334
  17.    li    $at, 1
  18. .org 0x8832350
  19.    sw    $at, 4($s2)
  20.  
  21. ; Change the embedded disc IDs region to "ES" (Europe)
  22. .org 0x8889A5A
  23.    .ascii "ES"
  24. .org 0x8889FD6
  25.    .ascii "ES"
  26. .org 0x888A166
  27.    .ascii "ES"
  28.  
  29. ; Fix pause menu alignment offset in two ways:
  30. ;   * Add a constant 10 pixels. This shows mis-aligned in the original too.
  31. ;   * Make the calculation work for single-width characters by counting using a simple strlen();
  32. ;     This works because halfwidth characters are always one byte, while fullwidth are two.
  33. ;     Also replace the resulting calculation by multiplying for the amount of space for a halfwidth.
  34. .org 0x88157A8
  35.    jal   0x888B1CC
  36.    move  $t0, $zero
  37.    sll   $a0, $v0, 3
  38.    addu  $a0, $v0, $a0
  39.    jal   0x888A2F8
  40.     sra  $a0, $a0, 1
  41.  
  42. .org 0x888A2F8
  43.    subu  $a0, $zero, $a0
  44.    jr    $ra
  45.     addi $a0, $a0, 10
  46.  
  47. .org 0x888B1CC
  48.    addi  $sp, -8
  49.    sw    $ra, 4($sp)
  50.    move  $t1, $a2
  51.    li    $v0, 0
  52. l: lb    $t2, ($t1)
  53.    beqz  $t2, e
  54.     addi $t1, 1
  55.    j     l
  56.     addi $v0, 1
  57. e: jal   0x8838794
  58.     sw   $v0, ($sp)
  59.    lw    $v0, ($sp)
  60.    lw    $ra, 4($sp)
  61.    jr    $ra
  62.     addi $sp, 8
  63.  
  64. .org 0x88A339C
  65.    .word 0
  66.  
  67. .close
  68.  
  69. ; =================================================
  70. ; BEGIN varwidth.asm
  71. ; -- replaces letter positioning code
  72. ;    so text is not monospace anymore
  73. ; =================================================
  74.  
  75. .psp
  76. .open "EBOOT-temp.BIN","EBOOT.BIN",0x08804000
  77. .headersize 0x08803f40
  78.  
  79.  
  80. ; adjust text speed
  81. ; fade ticks is always 0x1E or 0. >> 3 gives 3, &0x2 gives 2, >> 4 gives 1.
  82. .org 0x088389A4
  83.     sll     $s1, $a3, 1 ; fade in twice as fast
  84.     sra     $s0, $a2, 4 ; and divide fade ticks by 4.
  85.     andi    $s2, $t0, 0x00 ; ignore newchar overrides.
  86.  
  87. ; make sure the function behaves okay with a delay of 1
  88. .org 0x08838A50
  89.     li      $a1, 0
  90.  
  91. ; varwidth code
  92. .org 0x08838428
  93.     ; this is normally a branch which checks if alpha == 0.0 and then does not push the character to the drawlist
  94.     ; as we need the intermediate characters for the width calculation, we don't do this.
  95.     beqz    $a0,  continue ; note: this is the target of a reloc so we don't get away that easy.
  96.      nop
  97. continue:
  98.     ; rotation.x = disp->rot.x
  99.     lw      $a0,  0($s3)
  100.     sw      $a0,  0x60-0x5C($sp)
  101.     ; rotation.y = disp->rot.y
  102.     lw      $a1,  4($s3)
  103.     sw      $a1,  0x60-0x58($sp)
  104.     ; rotation.z = disp->rot.z + curchar.rotation
  105.     lwc1    $f12, 8($s3)
  106.     lwc1    $f13, 0xC($s0)
  107.     add.s   $f12, $f13
  108.     swc1    $f12, 0x60-0x54($sp)
  109.     ; scale.x = curchar.scale
  110.     ; scale.y = curchar.scale
  111.     lw      $a2,  8($s0)
  112.     sw      $a2,  0x60-0x50($sp)
  113.     sw      $a2,  0x60-0x4C($sp)
  114.     ; accumulator update
  115.     lb      $a0,  0x4($s0) ; curchar.column
  116.     li      $a1,  1        ; 1
  117.     beqz    $a0,  reset
  118.      subu   $a0,  $t8 ; as this would just leave some random trash in the other case we leave it here.
  119.     j accum_update
  120.      nop
  121.     nop
  122. reset:
  123.     mtc1    $zero, $f0
  124. rejoin:
  125.     lbu     $t8,  0x4($s0) ;curchar.column
  126.     lhu     $t9,  0x0($s0) ;curchar.code
  127.     ; position.x = (float)disp->xpos + accumulator
  128.     lh      $a1,  0x28($s1) ; disp->xpos
  129.     mtc1    $a1,  $f12
  130.     cvt.s.w $f12, $f12
  131.     add.s   $f12, $f0
  132.     swc1    $f12, 0x60-0x44($sp)
  133.     ; position.y = (float)disp->ypos - (float)curchar.line * render->yspacing // y = ystart - line * spacing
  134.     lb      $a0,  0x5($s0) ; curchar.line
  135.     mtc1    $a0,  $f12
  136.     cvt.s.w $f12, $f12
  137.     lwc1    $f13, 0x14($s4) ; render.yspacing
  138.     mul.s   $f12, $f13
  139.     lh      $a1,  0x2A($s1) ; disp->ypos
  140.     mtc1    $a1,  $f13
  141.     cvt.s.w $f13, $f13
  142.     sub.s   $f12, $f13, $f12
  143.     swc1    $f12, 0x60-0x40($sp)
  144.  
  145. .org 0x888CF80
  146. accum_update:
  147.     beq     $a0,  $a1, halfwidth ; branch if a0 == 1
  148.      mtc1   $a0,  $f12 ; only used by fullwidth
  149. fullwidth:
  150.     cvt.s.w $f12, $f12
  151.     lwc1    $f13, 0x10($s4) ; render.xspacing
  152.     mul.s   $f12, $f13
  153.     j rejoin
  154.      add.s  $f0, $f12
  155.  
  156. .org 0x888CFA8
  157. halfwidth:
  158.     ; obtain the key
  159.     lh      $a0,  0x0($s0)   ; current char
  160.     slti    $a1,  $a0, 0x100
  161.     beqz    $a1,  table     ; bail out if current char is fullwidth
  162.     ; binary search setup, key
  163.      sll    $a0,  8
  164.     or      $a0,  $t9
  165.     ; top/bottom of the table
  166.     lui     $t0,  (KERNING_TABLE >> 16) + 1                      ; top of pointer to the kerning table
  167.     addi    $t0,  (KERNING_TABLE & 0xFFFF) - 0x10000             ; bottom of pointer to the binary search table
  168.     addi    $t1,  $t0, (KERNING_TABLE_END - KERNING_TABLE - 0x4) ; top of binary search table
  169. kernloop: ; binary search loop. optimized for speed.
  170.     add    $a1, $t0, $t1     ; pos = (top - bot) >> 1 & ~0x3
  171.     srl     $a1, 3
  172.     sll     $a1, 2
  173.     lhu     $a2, 0x0($a1)    ; posval = *pos
  174.     beq     $a0, $a2, result ; if posval == target
  175.      slt    $a2, $a0, $a2
  176.     bnez    $a2, smaller     ; if target < posval
  177.      slt    $a2, $t1, $t0
  178.     beqz    $a2, kernloop    ; if top >= bottom
  179.      addi   $t0, $a1, 4
  180. smaller:
  181.     beqz    $a2, kernloop    ; if top >= bottom
  182.      addi   $t1, $a1, -4
  183. table: ; we didn't get a hit, do a lookup in the table
  184.     lui     $a1,  (WIDTH_TABLE >> 16) + 1
  185.     addu    $a1,  $t9
  186.     addiu   $a1,  (WIDTH_TABLE & 0xFFFF) - 0x10000 - 0x20 - 0x2 ; bottom 16 bits of address - overflow correction - offset of visible ascii characters - correction for other path
  187. result: ; we've got an address, load it
  188.     lbu     $a0, 0x2($a1)
  189.     lui     $a1,  0x3F00 ; 0.5
  190.     ; do the math to update the accumulator
  191.     mtc1    $a0,  $f12
  192.     mtc1    $a1,  $f13
  193.     cvt.s.w $f12, $f12
  194.     mul.s   $f12, $f13
  195.     j rejoin
  196.      add.s  $f0,  $f12 ; accumulator update
  197.  
  198. .org 0x0888CEE0
  199. WIDTH_TABLE:
  200. .area 0x60b
  201. ;              !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /
  202.     .byte 8,  10, 17, 17, 17, 17, 17, 10, 14, 14, 14, 14, 10, 14, 10, 17
  203. ;          0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
  204.     .byte 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 10, 10, 14, 14, 14, 14
  205. ;          @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O
  206.     .byte 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17
  207. ;          P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _
  208.     .byte 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 14, 17, 14, 14, 17
  209. ;          `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o
  210.     .byte 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 14, 14
  211. ;          p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  
  212.     .byte 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 17
  213. .endarea
  214.  
  215. KERNING_TABLE:
  216. .area 0x40b
  217.     ; sorted list of combinations for the binary search tree
  218.     ; note: low values first, high values last.
  219.     ; note2: there should at least be one item in this list
  220.     ; mapping: 0xcurprev pixels
  221.     ; example entry: capital A followed by a capital V
  222.     .halfword 0x5641, 14 ; AV
  223.     ;.halfword 0x7a65, 30 ; ez
  224. .endarea
  225. KERNING_TABLE_END:
  226.  
  227. .close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement