	;---------------------------------------------------------------------
;Caller's Name in SMS
;Version:	1.0
;Patch for:	Samsung SGH-E500 mobile phone
;Firmware: 	E500XEFJ1
;BinEdit:	2008.3.13
;Coded:		(c) 2007 by Freeman
;Adapted for E500:    Mako
;---------------------------------------------------------------------

.binid E500XEFJ1

.include E500XEFJ1_api.asm


.start 0x113C280C ;mcc_messages_cut_address_list+112
.mcc mcc_transf 0 0 0 0 mcc_phb_cut

.start 0x11631704 ;messages0_5task CASE_0x0021
	ldr r0,=Task_23_33_ROOT+1
	bx r0
.data

.start 0x10E1782E ;sms0_4if CASE_0x000C
	ldr r0,=If_08_12_ROOT+1
	bx r0
.data

.start 0x10C2AE98	;Pic TAT_DISPLAY
mcc_phb_cut:
.mcc mcc_if 35 2 0 0 mcc_messages_disp_address_not_found
.mcc mcc_task 35 33
mcc_phb_proc:
.mcc mcc_task 35 33 1
.mcc mcc_call 0 0 0 0 mcc_dir_search_name_for_sms
.mcc mcc_task 35 33 2
mcc_phb_cyc:
.mcc mcc_if 8 12 0 0 mcc_phb_proc
.mcc mcc_transf 0 0 0 0 mcc_messages_cut_address_list+128

If_08_12_ROOT:
	mov r4,1
	ldr r0,=Java_StorageJadFileName
	ldrb r1,[r0]
	add r1,1
	strb r1,[r0]
	ldr r2,=gv_CutAddressListModule
	ldrb r2,[r2,7]
	cmp r1,r2
	blt if_ext
	mov r4,0
if_ext:
	ldr r0,=0x10E175D6+1
	bx r0

Task_23_33_ROOT:
	ldr r5,=gv_CutAddressListModule
	ldr r6,=gv_SmsPhoneNumber	
	ldrh r0,[r4,4]
	cmp r0,0
	beq Task_00_InitProc
	cmp r0,1
	beq Task_01_InitSearchPhone
	
Task_02_StoreCallerName:	
	ldr r4,=gv_SmsName
	ldrb r0,[r4]
	cmp r0,0
	beq task_ext
	ldr r0,=Java_StorageJadFileName
	ldrb r7,[r0]
	lsl r0,r7,3
	ldr r1,[r5,0x30]
	add r0,r0,r1
	ldr r3,[r0,4]
	mov r1,r7
	mov r2,0
	str r2,[sp]
	mov r2,6
	ldr r5,=gs_DspMenu
	mov r0,r5
	bl lk_AddMenu
	mov r3,r4
	mov r1,r7
	mov r0,r5
	mov r2,0
	str r2,[sp]
	bl lk_AddMenu		;<---- Вот тут Freeman затрахался! :)	
	b task_ext
	
Task_01_InitSearchPhone:
	mov r0,r6
	mov r1,0x2b	
	blx	j__rt_memclr_w
	ldr r0,=Java_StorageJadFileName
	ldrb r0,[r0]
	lsl r0,3
	ldr r1,[r5,0x30]
	add r0,r0,r1
	ldr r1,[r0,4]
	mov r0,r6
	mov r2,0x16
	blx j_strncpy
	b task_ext
	
Task_00_InitProc:
	ldr r0,=Java_StorageJadFileName
	mov r1,0
	strb r1,[r0]
	
task_ext:	
	ldr r0,=0x116306EC+1
	bx r0
.data

.equ j__rt_memclr_w	    0x10D0F994
.equ j_strncpy              0x10D10884