Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; =================================================
- ; BEGIN eboot.asm
- ; -- translate game menus to english
- ; -- fix menu alignment bug in original game code
- ; =================================================
- .psp
- .open "EBOOT-orig.BIN","EBOOT-temp.BIN",0x08804000
- .headersize 0x8803f40
- ; Set sceImposeSetLanguageMode()'s first argument to 0x1 (English)
- .org 0x8832670
- li $a1, 1
- ; Set the language field in the struct parameter to sceUtilitySavedataInitStart() to 0x1 (English)
- .org 0x8832334
- li $at, 1
- .org 0x8832350
- sw $at, 4($s2)
- ; Change the embedded disc IDs region to "ES" (Europe)
- .org 0x8889A5A
- .ascii "ES"
- .org 0x8889FD6
- .ascii "ES"
- .org 0x888A166
- .ascii "ES"
- ; Fix pause menu alignment offset in two ways:
- ; * Add a constant 10 pixels. This shows mis-aligned in the original too.
- ; * Make the calculation work for single-width characters by counting using a simple strlen();
- ; This works because halfwidth characters are always one byte, while fullwidth are two.
- ; Also replace the resulting calculation by multiplying for the amount of space for a halfwidth.
- .org 0x88157A8
- jal 0x888B1CC
- move $t0, $zero
- sll $a0, $v0, 3
- addu $a0, $v0, $a0
- jal 0x888A2F8
- sra $a0, $a0, 1
- .org 0x888A2F8
- subu $a0, $zero, $a0
- jr $ra
- addi $a0, $a0, 10
- .org 0x888B1CC
- addi $sp, -8
- sw $ra, 4($sp)
- move $t1, $a2
- li $v0, 0
- l: lb $t2, ($t1)
- beqz $t2, e
- addi $t1, 1
- j l
- addi $v0, 1
- e: jal 0x8838794
- sw $v0, ($sp)
- lw $v0, ($sp)
- lw $ra, 4($sp)
- jr $ra
- addi $sp, 8
- .org 0x88A339C
- .word 0
- .close
- ; =================================================
- ; BEGIN varwidth.asm
- ; -- replaces letter positioning code
- ; so text is not monospace anymore
- ; =================================================
- .psp
- .open "EBOOT-temp.BIN","EBOOT.BIN",0x08804000
- .headersize 0x08803f40
- ; adjust text speed
- ; fade ticks is always 0x1E or 0. >> 3 gives 3, &0x2 gives 2, >> 4 gives 1.
- .org 0x088389A4
- sll $s1, $a3, 1 ; fade in twice as fast
- sra $s0, $a2, 4 ; and divide fade ticks by 4.
- andi $s2, $t0, 0x00 ; ignore newchar overrides.
- ; make sure the function behaves okay with a delay of 1
- .org 0x08838A50
- li $a1, 0
- ; varwidth code
- .org 0x08838428
- ; this is normally a branch which checks if alpha == 0.0 and then does not push the character to the drawlist
- ; as we need the intermediate characters for the width calculation, we don't do this.
- beqz $a0, continue ; note: this is the target of a reloc so we don't get away that easy.
- nop
- continue:
- ; rotation.x = disp->rot.x
- lw $a0, 0($s3)
- sw $a0, 0x60-0x5C($sp)
- ; rotation.y = disp->rot.y
- lw $a1, 4($s3)
- sw $a1, 0x60-0x58($sp)
- ; rotation.z = disp->rot.z + curchar.rotation
- lwc1 $f12, 8($s3)
- lwc1 $f13, 0xC($s0)
- add.s $f12, $f13
- swc1 $f12, 0x60-0x54($sp)
- ; scale.x = curchar.scale
- ; scale.y = curchar.scale
- lw $a2, 8($s0)
- sw $a2, 0x60-0x50($sp)
- sw $a2, 0x60-0x4C($sp)
- ; accumulator update
- lb $a0, 0x4($s0) ; curchar.column
- li $a1, 1 ; 1
- beqz $a0, reset
- subu $a0, $t8 ; as this would just leave some random trash in the other case we leave it here.
- j accum_update
- nop
- nop
- reset:
- mtc1 $zero, $f0
- rejoin:
- lbu $t8, 0x4($s0) ;curchar.column
- lhu $t9, 0x0($s0) ;curchar.code
- ; position.x = (float)disp->xpos + accumulator
- lh $a1, 0x28($s1) ; disp->xpos
- mtc1 $a1, $f12
- cvt.s.w $f12, $f12
- add.s $f12, $f0
- swc1 $f12, 0x60-0x44($sp)
- ; position.y = (float)disp->ypos - (float)curchar.line * render->yspacing // y = ystart - line * spacing
- lb $a0, 0x5($s0) ; curchar.line
- mtc1 $a0, $f12
- cvt.s.w $f12, $f12
- lwc1 $f13, 0x14($s4) ; render.yspacing
- mul.s $f12, $f13
- lh $a1, 0x2A($s1) ; disp->ypos
- mtc1 $a1, $f13
- cvt.s.w $f13, $f13
- sub.s $f12, $f13, $f12
- swc1 $f12, 0x60-0x40($sp)
- .org 0x888CF80
- accum_update:
- beq $a0, $a1, halfwidth ; branch if a0 == 1
- mtc1 $a0, $f12 ; only used by fullwidth
- fullwidth:
- cvt.s.w $f12, $f12
- lwc1 $f13, 0x10($s4) ; render.xspacing
- mul.s $f12, $f13
- j rejoin
- add.s $f0, $f12
- .org 0x888CFA8
- halfwidth:
- ; obtain the key
- lh $a0, 0x0($s0) ; current char
- slti $a1, $a0, 0x100
- beqz $a1, table ; bail out if current char is fullwidth
- ; binary search setup, key
- sll $a0, 8
- or $a0, $t9
- ; top/bottom of the table
- lui $t0, (KERNING_TABLE >> 16) + 1 ; top of pointer to the kerning table
- addi $t0, (KERNING_TABLE & 0xFFFF) - 0x10000 ; bottom of pointer to the binary search table
- addi $t1, $t0, (KERNING_TABLE_END - KERNING_TABLE - 0x4) ; top of binary search table
- kernloop: ; binary search loop. optimized for speed.
- add $a1, $t0, $t1 ; pos = (top - bot) >> 1 & ~0x3
- srl $a1, 3
- sll $a1, 2
- lhu $a2, 0x0($a1) ; posval = *pos
- beq $a0, $a2, result ; if posval == target
- slt $a2, $a0, $a2
- bnez $a2, smaller ; if target < posval
- slt $a2, $t1, $t0
- beqz $a2, kernloop ; if top >= bottom
- addi $t0, $a1, 4
- smaller:
- beqz $a2, kernloop ; if top >= bottom
- addi $t1, $a1, -4
- table: ; we didn't get a hit, do a lookup in the table
- lui $a1, (WIDTH_TABLE >> 16) + 1
- addu $a1, $t9
- addiu $a1, (WIDTH_TABLE & 0xFFFF) - 0x10000 - 0x20 - 0x2 ; bottom 16 bits of address - overflow correction - offset of visible ascii characters - correction for other path
- result: ; we've got an address, load it
- lbu $a0, 0x2($a1)
- lui $a1, 0x3F00 ; 0.5
- ; do the math to update the accumulator
- mtc1 $a0, $f12
- mtc1 $a1, $f13
- cvt.s.w $f12, $f12
- mul.s $f12, $f13
- j rejoin
- add.s $f0, $f12 ; accumulator update
- .org 0x0888CEE0
- WIDTH_TABLE:
- .area 0x60b
- ; ! " # $ % & ' ( ) * + , - . /
- .byte 8, 10, 17, 17, 17, 17, 17, 10, 14, 14, 14, 14, 10, 14, 10, 17
- ; 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
- .byte 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 10, 10, 14, 14, 14, 14
- ; @ A B C D E F G H I J K L M N O
- .byte 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17
- ; P Q R S T U V W X Y Z [ \ ] ^ _
- .byte 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 14, 17, 14, 14, 17
- ; ` a b c d e f g h i j k l m n o
- .byte 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 14, 14
- ; p q r s t u v w x y z { | } ~
- .byte 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 17
- .endarea
- KERNING_TABLE:
- .area 0x40b
- ; sorted list of combinations for the binary search tree
- ; note: low values first, high values last.
- ; note2: there should at least be one item in this list
- ; mapping: 0xcurprev pixels
- ; example entry: capital A followed by a capital V
- .halfword 0x5641, 14 ; AV
- ;.halfword 0x7a65, 30 ; ez
- .endarea
- KERNING_TABLE_END:
- .close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement