@Extended SmsMenuTitle By NeO_2kX(c)


@Var
.equ gv_NbInboxList				0x016F500C @(sint) Inbox num
.equ gv_NbOutboxList 			0x016F5010 @(sint) Outbox num
.equ ga_sms_InboxMenuTable 		0x016E867C
.equ ga_sms_OutboxMenuTable 	0x016ED0B4
@String
.equ GetString					0x000A9564
.equ _sprintf					0x003E1710 @(char *buffer, const char *format[, argument, ...])
.equ strcmp 					0x003E1690
.equ strchr						0x003E228C
.equ lk_get_text				0x002BE700 @char *lk_get_text(int ID)
.equ strcat						0x003E2188
.equ strlen						0x003E1758
@Mem
.equ memset						0x003E13E0	@*s memset(void *s, int c, size_t n)
.equ memcpy						0x003E1444	@*dest memcpy(void *dest, const void *src, size_t n)
.equ MemMgr_Allocate			0x00395FEA
.equ MemMgr_Deallocate			0x003960B2	@void memset(void *s, int c, size_t n)
.equ RtkGetMemory				0x002C9760
.equ RtkReleaseMemory			0x002C9768
.equ memcmp						0x003E214C
@Other
.equ mms1_00SetFileSizeToSizeString		0x0002940C
.equ lk2_12start_menu_edit_fsm  		0x00098060
.equ Reg_Draw_Title						0x000B1A18 	@void Reg_Draw_Title(char *str, ?(0), ?(0))
.equ lk_SetMenuType 					0x000B9124  @void lk_SetMenuType(int MenuId)
.equ sms3_43GetSimAbsPos 				0x000CFD80

@Inbox
.start 0x000C9C82
	BL		DrawSmsListTitle			@void DrawSmsListTitle(int ID, int ListType(0-Inbox, 1-Outbox))

@Outbox	
.start 0x000C9CFC
	MOV		R1, #1
	BL		DrawSmsListTitle			@void DrawSmsListTitle(int ID, int ListType(0-Inbox, 1-Outbox))

@Оптимизация функции для освобождения места
@int sms3_43GetSimAbsPos(*struct, int ListType(0-Inbox, 1-outbox))
sms3_43GetSimAbsPos:
	PUSH	{R3,R4,R7,LR}
	MOV		R4, R0
	MOV		R7, R1
	
	MOV		R0, #0x4C
	MUL		R0, R4
	CMP		R7, #0
	BNE		GSAP_Outbox
	
	LDR		R1, =ga_sms_InboxMenuTable
	B		GSAP_Continue

GSAP_Outbox:	
	LDR		R1, =ga_sms_OutboxMenuTable

GSAP_Continue:	
	ADD		R4, R0, R1
	LDR		R7, =0x0000FFFF
	LDR 	R0, [R4, #0x48]
	CMP		R0, #0
	BNE		loc_000CFE02
	
	LDRH	R7, [R4, #0]
	B		Exit_sms3_43GetSimAbsPos

loc_000CFE02:	
	LDR 	R1, [R4, #0x48]
	MOV		R0, #0				;Count
	LDRB	R2, [R1, #0x1A]
	B		loc_000CFE44

GSAP_Loop:	
	LDR 	R3, [R1, #0x20]
	LSL		R4, R0, #2
	ADD		R3, R3, R4
	LDRB	R3, [R3, #2]
	CMP		R3, #0
	BNE		loc_000CFE3E
	LDR 	R1, [R1, #0x20]
	LSL		R0, R0, #2
	LDRH	R7, [R1, R0]
	B		Exit_sms3_43GetSimAbsPos

loc_000CFE3E:	
	ADD		R0, #1				;Count++

loc_000CFE44:	
	CMP		R2, R0
	BGT		GSAP_Loop

Exit_sms3_43GetSimAbsPos:	
	MOV		R0, R7
	POP		{R3,R4,R7, PC}
.data

.align 1
@void DrawSmsListTitle(int ID, int ListType(0-Inbox, 1-Outbox))
DrawSmsListTitle:
PUSH	{R0,R3,R5, LR}
SUB		SP, SP, #96
	MOV		R5, R1

@Проверка строки на коррекность	
	BL		strlen
	CMP		R0, #95
	BGT		DSLT_Error

@Очистка памяти	
	MOV		R2, #96
	MOV		R1, #0
	MOV		R0, SP
	BL		memset						@*s memset(void *s, int c, size_t n)

@Форматирование строки	
	CMP		R5, #1
	BEQ		DSLT_Outbox
	
	LDR		R3, =gv_NbInboxList
	
DSLT_Continue:	
	LDRH	R3, [R3]
	LDR		R2, [SP, #96]
	ADR		R1, ="%s [%d]"
	MOV		R0, SP
	BL		_sprintf					@(char *buffer, const char *format[, argument, ...])
	
	MOV		R0, SP
@Вывод заголовка
DSLT_DrawTitle:	
	MOV		R2, #0
	MOV		R1, #0
	BL		Reg_Draw_Title				@void Reg_Draw_Title(char *str, ?(0), ?(0))

Exit_DrawSmsListTitle:
ADD		SP, SP, #96
POP		{R0,R3,R5, PC}

DSLT_Outbox:
	LDR		R3, =gv_NbOutboxList
	B		DSLT_Continue

DSLT_Error:
	ADR		R0, ="Error"
	B		DSLT_DrawTitle
.data
.setbyte 0x000CFE70





