Files
Persona2-PSX-asm-sources/1_IS/charCalcs.asm
2025-11-04 23:06:09 +05:00

104 lines
2.7 KiB
NASM

ReturnCharsInString:
lhu v0,0x0(a0)
nop
srl v0,v0,0xD ;;;;Check 13th bit (1byte system !!!)
bne v0,zero,IsMy1byteString
clear v1
;v1 = charCount
j StartReading
nop
IsMy1byteString:
lhu v0,0x0(a0)
nop
andi v0,v0,0xff ;Clear from cmd flag
andi v1,v0,0x1
beq v1,zero,notAnd1
nop
addiu v0,v0,0x1
notAnd1:
sra v0,v0,1 ;v0/2 (bytes Pairs)
addiu v0,v0,1 ;v0 += = header 2 bytes
jr ra
move v1,v0 ;return v0,v1 - charsNum
GetNewChar:
addiu v1,v1,1
StartReading:
lhu v0,0x0(a0) ;a0 - curTextAddr
nop
sltiu v0,v0,0x1000
bne v0,zero,GetNewChar ;if currentChar<1000 - goto next addr+2b
addiu a0,a0,2
jr ra
move v0,v1 ;return v0,v1 - charsNum
calcNextXCustom:
addiu sp,sp,-0x18
sw ra,0x10(sp)
lhu v0,0x0(a0)
nop
andi v1,v0,0xff ;Clear from cmd flag
srl v0,v0,0xD ;;;;Check 13th bit (1byte system !!!)
beq v0,zero,JapOldText ;if bit 0d = 0 - OldTypeText
nop
j IHaveStringLength
move v0,v1 ;double char count
JapOldText:
jal ReturnCharsInString
nop
IHaveStringLength:
sll v1,v0,0x1
addu v1,v1,v0
lw ra,0x10(sp)
sll v0,v1,0x1 ;*charcount * 6 pix
jr ra
addiu sp,sp,0x18
RetunCharsToCity:
lhu v0,0x0(a0)
nop
srl v0,v0,0xD ;;;;Check 13th bit (1byte system !!!)
bne v0,zero,IsMy1byteCity
clear v1 ;v1 = charCount
j StartReading
nop
IsMy1byteCity:
lhu v0,0x0(a0)
nop
andi v0,v0,0xff ;Clear from cmd flag
jr ra
move v1,v0 ;return v0,v1 - charsNum
RetunCharsToCityDiv2:
lhu v0,0x0(a0)
nop
srl v0,v0,0xD ;;;;Check 13th bit (1byte system !!!)
bne v0,zero,IsMy1byteCityDiv2
clear v1 ;v1 = charCount
j StartReading
nop
IsMy1byteCityDiv2:
lhu v0,0x0(a0)
nop
andi v0,v0,0xff ;Clear from cmd flag
andi v1,v0,0x1
beq v1,zero,notAnd1_2
nop
addiu v0,v0,0x1
notAnd1_2:
sra v0,v0,1 ;v0/2 (bytes Pairs)
; addiu v0,v0,1 ;v0 += = header 2 bytes
jr ra
move v1,v0 ;return v0,v1 - charsNum