;---------------------------------------------------------------------
;Theme Engine. Artmageddon
;Version:	1.0
;Patch for:	Samsung SGH-D500 mobile phone
;Firmware: 	D500XEEG3
;BinEdit:	2005.5.23
;Coded:		(c) 2006 by Freeman 
;Hello to: 	SergeyL, AlexeyK, -=Asterix=-, Gralexon, cr_az2, Igo, 
;			StepanV, Javer, Black Scorpion, Vadiks  etc...
;---------------------------------------------------------------------
;Place: 	Belarus, Minsk, BPI- Belarussian patchware institute
;Mail to: 	freeman_fa@mail.ru
;---------------------------------------------------------------------

.binid D500XEEG3

.include f:\d500\firmware\D500XEEG3_api.asm

.equ gv_NumThemesInDir 0x18AD2CA4
.equ ga_ThemeBuffer 0x18A72354
.equ CfgDir 0x1
.equ CfgFile 0x18FFDB00
.equ ThemeFileName 0x18FFE306
.equ UsedSoftBg 0x18FFE33B
.equ WapColorTheme 0x18FFE33C
.equ ThemeSize 957117
.equ ThemeIconInfo 0x18FFE340

;-----------------------------Firmware--------------------------------

.start 0x104A5FB0	;NoPopupInTheme freeZone 0x104A5F5E-0x104A5F82
	bcc 0x104A5F82
	
.start 0x109DF898		;Register theme0_6menu as 20 (0x14)
	.word theme0_6menu+1

.start 0x1153ed5c
.mcc mcc_transf 0 0 0 0 mcc_set_select_theme_type

.start 0x10BCEB6C	
	ldr r0,=Fbox1Task+1
	bx r0
.data

.start 0x1132ACA0
	ldr r0,=Fbox0If+1
	bx r0
.data

.start 0x10F57614
	ldr r0,=SetThemeMenuColor+1
	bx r0
.data

.start 0x1134ED4C	
	ldr r7,=0x1898F034
	ldr r3,=0x81b1
	strh r3,[r7]
	sub r3,0xb0
	strh r3,[r7,2]
	add r3,5
	strh r3,[r7,8]
	ldr r3,=0x1f56
	strh r3,[r7,4]
	add r3,4
	strh r3,[r7,6]	
	mov r3,0x15
	strh r3,[r7,0xa]
	b 0x1134EDF4
.data

.start 0x108425AC
	ldr r6,=InfoLineBgDraw+1
	bx r6
.data

.start 0x10a41124
.respack "Иконки для патча"
soft_bg_icon:
.insertdata soft_bg.bin
.respack

.start 0x107D76A6
	bl DrawSoftBg

.start 0x10B8CB88
	ldr r0,=DrawSoftBg2+1
	bx r0
.data

.start 0x10F8EC36	;Email
	blx j_lk_get_sofk
	mov r4,r0
	mov r0,r7
	blx j_lk_get_sofk
	mov r1,0
	mov r3,0
	str r1,[sp]
	str r1,[sp,4]			
	str r1,[sp,8]
	mov r2,r0
	mov r0,r4
	blx j_Reg_Draw_Softkey
	pop {r4-r7,pc}
.data
j_lk_get_sofk: blxx lk_get_sofk+1
j_Reg_Draw_Softkey: blxx Reg_Draw_Softkey+1

.start 0x1134B3F4	;KeyLock
	ldr r0,=DrawSoftBg4+1
	bx r0
.data

.start 0x10854014	;Camera
	bl DrawSoftBg
	
.start 0x10855084	;Camera2
	bl DrawSoftBg
	
.start 0x107D768C
	ldr r0,=InvalidBgCheck+1
	bx r0
.data

.start 0x100CA848
	ldr r3,=InstallSoftBg+1
	bx r3
.data

.start 0x10BF1FF0
	ldr r1,=lk_XtendIconInfo+1
	bx r1
.data

.start 0x100D084C	;rssi
	bx r0
	
.start 0x100D08F4
	.word GetIndicatorRSSI+1

.start 0x100D0856	;offhook
	bx r0
	
.start 0x100D08F8
	.word GetIndicatorOffhook+1

.start 0x100D0860	;nocall
	bx r0
	
.start 0x100D08FC
	.word GetIndicatorNocall+1

.start 0x100D086A	;alarm
	bx r0
	
.start 0x100D0900
	.word GetIndicatorAlarm+1

.start 0x100D0874	;memfull
	bx r0
	
.start 0x100D0904
	.word GetIndicatorMemFull+1

.start 0x100D087E	;NewMMS
	bx r0
	
.start 0x100D0908
	.word GetIndicatorNewMMS+1

.start 0x100D0888	;NewEmail
	bx r0
	
.start 0x100D090C
	.word GetIndicatorNewEmail+1

.start 0x100D0892	;NewSMS
	bx r0
	
.start 0x100D0910
	.word GetIndicatorNewSMS+1

.start 0x100D089C	;NewVoice
	bx r0
	
.start 0x100D0914
	.word GetIndicatorNewVoice+1

.start 0x100D08A6	;Irda
	bx r0
	
.start 0x100D0918
	.word GetIndicatorIrda+1

.start 0x100D08B0	;Bluetooth
	bx r0
	
.start 0x100D091C
	.word GetIndicatorBluetooth+1

.start 0x100D08BA	;Syncml
	bx r0
	
.start 0x100D0920
	.word GetIndicatorSyncml+1

.start 0x100D08C4	;Divert
	bx r0
	
.start 0x100D0924
	.word GetIndicatorDivert+1

.start 0x100D08D8	;Zone
	bx r0
	
.start 0x100D092C
	.word GetIndicatorZone+1
	
.start 0x10483CB0
	ldr r2,=GetFrameIconInfo+1
	bx r2
.data

.start 0x1047FDA0
	ldr r3,=MainMenuBgGet+1
	bx r3
.data

.start 0x1047FCF8	;DontDrawMainBgSides
	b 0x1047FD94
	
.start 0x1134D610
	.word MainMenuIconGet+1

.start 0x1134D5D4
	bx r1

.start 0x10446644
	bl DrawTIconBg
	
.start 0x100D87F0
	ldr r1,=UsedSoftBg
	mov r7,1
	strb r7,[r1]
	ldr r7,=ColorTheme
	ldrb r7,[r7]
	cmp r7,4
	blt q30
	mov r7,0
q30:
	strb r7,[r1,1]
	mov r7,3
	cmp r0,0
	bge 0x100D881A
	b 0x100D8816
.data

.start 0x104C835C
	.word WapColorTheme

.start 0x10C081B4
	bx r1

.start 0x10C0848C	
	.word std_31_task_pre+1
		
;-------------------------------Body----------------------------------
.start 0x105fd02e

theme0_6menu:
	push {r4-r7,lr}
	sub sp,0x100
	mov r4,r0
	ldrh r0,[r4,2]
	ldr r1,=theme_menu_tab
	lsl r0,2
	ldr r0,[r0,r1]
	ldr r7,=0x1898DA6C	;DspMenu
	bx r0
.data

mcc_set_select_theme_type:
.insertbin 0x10a367ec,48
.mcc mcc_menu_config 20 0 2 1
.mcc mcc_display_menu 20 0 0 0x0206 0 0x10
.mcc mcc_menu_select 0 0 0 0 mcc_set_select_std_theme
.mcc mcc_menu_select 0 1 0 0 mcc_set_select_my_theme
.insertbin 0x10a3688c,48

Fbox1Task:
	ldrh r0,[r4,4]
	ldr r1,=theme_task_tab
	lsl r0,2
	ldr r0,[r0,r1]
	bx r0
.data

Fbox0If:
	ldrh r0,[r5,4]
	ldr r1,=theme_if_tab
	lsl r0,2
	ldr r0,[r0,r1]
	bx r0
.data

SetThemeMenuColor:
	bl CfgCheckElseCreate
	bl CheckThemePresent
	cmp r0,0
	beq kill_theme
	ldr r4,=CfgFile+1900
	mov r0,r4
	mov r1,0x35
	blx j__rt_memclr
	ldr r6,=ThemeFileName
	mov r0,r6
	mov r1,0x35
	blx j__rt_memclr
	ldr r5,=0x18AD1BA0
	mov r0,r5
	bl strlen
	mov r2,r0
	mov r1,r5
	mov r0,r4
	mov r4,r2
	bl strncpy	
	mov r2,r4
	mov r1,r5
	mov r0,r6
	bl strncpy	
	bl SaveCFG
	ldr r0,=5352
	ldr r1,=411
	bl LoadThemeItem
	ldr r0,=0x1898d9dc
	mov r1,2
	mov r2,0
	bl	SetLoadedColors
	ldr r0,=0x1898ef28
	mov r1,55
	mov r2,2
	bl	SetLoadedColors
	ldr r0,=0x1898f040
	mov r1,80
	mov r2,57
	bl	SetLoadedColors
	ldr r0,=0x10F57DB6+1
	bx r0
kill_theme:	
	mov r0,0
	bl SetCurColorTheme
	ldr r0,=0x10F55EFE+1
	bx r0
.data

;-------------------------------Data----------------------------------


theme_menu_tab:
.word menu20_00_SelectThemeType+1
.word menu20_01_SelectDownloadedTheme+1
.word menu20_02_ThemeOptions+1
.word menu20_03_ThemeProperties+1

theme_task_tab:
.word task_00_OriginalTask+1
.word task_01_GetNumThemesInDir+1
.word task_02_SetupThemeConfirmInfo+1
.word task_03_DeleteThemeReq+1
.word task_04_DeleteAllReq+1
.word task_05_StoreThemeName+1
.word task_06_GetThemeIndexToSend+1
.word task_07_InstallTheme+1

theme_if_tab:
.word if_00_OriginalIf+1
.word if_01_IfThemeFileCorrupt+1

mcc_set_select_std_theme:
.mcc mcc_init_restore
.mcc mcc_transf 0 0 0 0 0x1153ed6c

mcc_set_select_my_theme:
.mcc mcc_init_restore
.mcc mcc_task 0x1e 0x10 0x31
.mcc mcc_set_curmenu
.mcc mcc_menu_start 0 0x0400 0x4100 0 0 0x30
.mcc mcc_task 0x1e 0 1
.mcc mcc_task 0x1e 1 1
.mcc mcc_menu_config 20 1 0 0x12
.mcc mcc_display_menu 20 1 0 0x0206 0 2
.mcc mcc_menu_select 0 0xffff 0 0 mcc_theme_invoke_pre
.mcc mcc_if 9 1 0xf 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 2 0 mcc_lk_return_menu_01
.mcc mcc_exit

mcc_theme_invoke_pre:
.mcc mcc_task 0x1e 1 5
.mcc mcc_if 9 1 0x0e 0 mcc_theme_options
mcc_theme_invoke:
.mcc mcc_if 0x1e 0 1 0 mcc_theme_file_corrupt
.mcc mcc_init_restore
.mcc mcc_task 0x1e 1 2
.mcc mcc_confirm 0x47 6 0xffff 0x0400 0 0x0306
.mcc mcc_if 9 1 0xe 0 mcc_theme_install
.mcc mcc_elseif 9 1 0xd 0 mcc_theme_install
.mcc mcc_return_menu 0 1

mcc_theme_file_corrupt:
.mcc mcc_report 5 2 0x18 0x07aa
.mcc mcc_return_menu 0 1

mcc_theme_options:
.mcc mcc_init_restore
.mcc mcc_set_curmenu
.mcc mcc_menu_start 0 0x0400 0x4100 0 0 0xb0
.mcc mcc_menu_config 20 2 5 5
.mcc mcc_display_menu 20 2 0 0x0206 0 0x10
.mcc mcc_menu_select 0 0 0 0 mcc_theme_invoke
.mcc mcc_menu_select 0 1 0 0 mcc_theme_send
.mcc mcc_menu_select 0 2 0 0 mcc_theme_delete
.mcc mcc_menu_select 0 3 0 0 mcc_theme_delete_all
.mcc mcc_menu_select 0 4 0 0 mcc_theme_properties
.mcc mcc_if 9 1 0xf 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 2 0 mcc_lk_return_menu_01
.mcc mcc_exit

mcc_theme_properties:
.mcc mcc_if 0x1e 0 1 0 mcc_theme_file_corrupt
.mcc mcc_init_restore
.mcc mcc_disp_title 0x1e 0x08d9 0 1
.mcc mcc_set_curfocus
.mcc mcc_focus_start 0 0 0 0 0 0x30
.mcc mcc_softkey 0 0x2b
.mcc mcc_menu_config 20 3 0 3
.mcc mcc_display_focus 20 3 0x400 0x010e
.mcc mcc_focus_select 0 0xffff 0 0 mcc_lk_return_menu_01
.mcc mcc_focus_change 1 0 0x020e 0x02bd mcc_lk_return_menu_01 0x09c4
.mcc mcc_if 9 1 0xe 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 0xd 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 0x2 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 0x1 0 mcc_lk_return_menu_01
mcc_theme_exit:
.mcc mcc_exit


mcc_theme_delete:
.mcc mcc_init_restore
.mcc mcc_question 0x54 0x2a 0x035b 0x0400 0 0x030e
.mcc mcc_if 9 1 0xf 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 0x2 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 0x9 0 mcc_theme_exit
.mcc mcc_task 0x1e 1 3
.mcc mcc_init_restore
.mcc mcc_report 1 2 0x1b 0x035f 
.mcc mcc_reduce_menu_stack 0 1
.mcc mcc_transf 0 0 0 0 mcc_set_select_my_theme

mcc_theme_delete_all:
.mcc mcc_init_restore
.mcc mcc_question 0x54 0x2a 0x0348 0x0400 0 0x030e
.mcc mcc_if 9 1 0xf 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 0x2 0 mcc_lk_return_menu_01
.mcc mcc_elseif 9 1 0x9 0 mcc_theme_exit
.mcc mcc_task 0x1e 1 4
.mcc mcc_init_restore
.mcc mcc_report 1 2 0x1b 0x035D 
.mcc mcc_reduce_menu_stack 0 1
.mcc mcc_transf 0 0 0 0 mcc_set_select_my_theme

mcc_theme_send:
.mcc mcc_task 0x1e 1 6
.mcc mcc_transf 0 0 0 0 0x10718198


mcc_theme_install:
.mcc mcc_task 0x1e 1 7
.mcc mcc_task 0x12 0x0a
.mcc mcc_init_restore
.mcc mcc_report 1 2 0x1b 0x09c6
.mcc mcc_transf 0 0 0 0 mcc_lk_return_menu_01


menu20_00_SelectThemeType:
	mov r0,r7
	mov r1,1
	mov r2,2
	bl lk_CreateMenu
	add r3,sp,0x20
	mov r2,0
	strh r2,[r3]
	mov r0,0x2e
	strh r0,[r3,2]
	mov r0,0xb0
	strh r0,[r3,4]
	mov r0,0x97
	strh r0,[r3,6]
	mov r0,0x19
	str r0,[sp]
	mov r0,r7
	mov r1,r3
	mov r3,1
	bl lk_PutMenuExtInfo
	ldr r0,=0xaac
	bl lk_get_text
	mov r1,0
	mov r2,0
	mov r3,0
	bl Reg_Draw_Title
	mov r0,0x6
	bl lk_get_sofk
	mov r4,r0
	mov r0,0x46
	bl lk_get_sofk
	mov r1,0
	mov r3,0
	str r1,[sp]
	str r1,[sp,4]			
	str r1,[sp,8]
	mov r2,r4
	bl Reg_Draw_Softkey
	ldr r0,=0x32d
	bl lk_get_text
	mov r1,0
	str r1,[sp]
	mov r3,r0
	mov r2,0
	mov r0,r7
	bl lk_AddMenu
	mov r0,0
	bl lk_get_extended_text
	mov r2,0
	str r2,[sp]
	mov r3,r0
	mov r1,1
	mov r0,r7
	bl lk_AddMenu
	ldr r0,=ColorTheme
	ldrb r0,[r0]
	cmp r0,4
	blt PopUpForStdTheme
	mov r4,1
	mov r0,24
	mov r1,16
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer
	ldrb r1,[r0]
	cmp r1,0
	bne m0_ext
	ldr r0,=unk1
	b m0_ext
PopUpForStdTheme:	
	mov r4,0
	ldr r1,=0x111EDDD8
	lsl r0,1
	ldrh r0,[r1,r0]
	bl lk_get_text
m0_ext:
	mov r2,0
	str r2,[sp]
	mov r2,3
	mov r3,r0
	mov r1,r4
	mov r0,r7
	bl lk_AddMenu	
	add r7,0x68
	strh r4,[r7]
	add sp,0x100
	pop {r4-r7,pc}
.data

task_00_OriginalTask:
	mov r1,0x18
	add r0,sp,0x1ec
	blx j__rt_memclr_w_0
	mov r3,0
	ldr r0,=0x10BCEB74+1
	bx r0
.data
j__rt_memclr_w_0: bpc __rt_memclr_w_0

lk_get_extended_text:
	push {r1-r5,lr}
	adr r1,LangTab
	lsl r0,2
	ldr r0,[r0,r1]
	ldr r1,=0x18A9919B
	ldrb r1,[r1]
	cmp r1,0
	beq lg_ex
	mov r4,r0
	mov r5,r1
lg_1:
	mov r0,r4
	mov r1,0
	bl strrchr	
	add r4,r0,1
	sub r5,1
	bne lg_1
	mov r0,r4
lg_ex:	
	pop {r1-r5,pc}
.data
LangTab:
.word str_0_DownloadedThemes
.word str_1_File
.word str_2_ThemeName
.word str_3_Author

str_0_DownloadedThemes:
.string "Downloadet skins"	;Deu
.string "Downloaded themes"	;Eng
.string "Skins telecharges"	;Fran
.string "Загруженные темы"	;Rus
.string "Downloaded themes"	;Eesti
.string "Downloaded themes"	;Lat
.string "Downloaded themes"	;Liet
.string "Изтеглени кожи"	;Bgr
.string "Завантаженi схемi"	;UA
.string "Downloaded themes"	;Rom
.string "Downloaded themes"	;Spr
.string "Downloaded themes"	;Mac

str_1_File:
.string "Datei name:"	;Deu
.string "File name:"	;Eng
.string "Nom du fichier:"	;Fran
.string "Имя файла:"	;Rus
.string "File name:"	;Eesti
.string "File name:"	;Lat
.string "File name:"	;Liet
.string "File name:"	;Bgr
.string "Iм'я файла:"	;UA
.string "File name:"	;Rom
.string "File name:"	;Spr
.string "File name:"	;Mac

str_2_ThemeName:
.string "Skin name:"	;Deu
.string "Theme name:"	;Eng
.string "Nom du skin:"	;Fran
.string "Название темы:"	;Rus
.string "Theme name:"	;Eesti
.string "Theme name:"	;Lat
.string "Theme name:"	;Liet
.string "Theme name:"	;Bgr
.string "Iм'я схемi:"	;UA
.string "Theme name:"	;Rom
.string "Theme name:"	;Spr
.string "Theme name:"	;Mac

str_3_Author:
.string "Autor:"	;Deu
.string "Author:"	;Eng
.string "Auteur:"	;Fran
.string "Автор:"	;Rus
.string "Author:"	;Eesti
.string "Author:"	;Lat
.string "Author:"	;Liet
.string "Author:"	;Bgr
.string "Автор:"	;UA
.string "Author:"	;Rom
.string "Author:"	;Spr
.string "Author:"	;Mac

IsThemeByExtension:
	push {r1-r7,lr}
	mov r6,0
	mov r5,r0
	ldr r4,=0x18AD1BA0	
	mov r0,r4
	mov r1,0x35
	blx j__rt_memclr
	mov r0,0x31
	mov r1,r5
	mov r2,r4
	bl mmitfs4_GetFileNameInList
	mov r0,r4
	mov r1,'.'
	bl strrchr
	str r0,[sp,4]
	adr r1,theme_extension
	blx j_strcmp
	cmp r0,0
	beq q4
	ldr r0,[sp,4]
	adr r1,theme_extension2
	blx j_strcmp
	cmp r0,0
	bne q3
q4: mov r6,1	
q3:	mov r0,r6
	pop {r1-r7,pc}
.data
j_strcmp: bpc strcmp
theme_extension: .string ".ssf"
.align 2
theme_extension2: .string ".SSF"

IsThemeByContent:	;r0=0 -not theme
	push {r1-r7,lr}
	sub sp,0x10
	mov r6,0
	ldr r7,=0x18AD1BA0	;FileName
	mov r0,0x31
	mov r1,r7
	add r2,sp,4
	bl mmitfs4_GetFileSize
	ldr r0,[sp,4]
	ldr r3,=ThemeSize
	cmp r0,r3
	blt w1
	mov r0,0x31
	ldr r3,=5352
	mov r1,r7
	ldr r5,=ga_ThemeBuffer
	mov r2,r5
	bl mmitfs4_ReadFile
	mov r0,r5
	adr r1,ThemeId
	adr r2,ThemeIdEnd
q32:
	ldrb r3,[r0]
	ldrb r4,[r1]
	cmp r3,r4
	bne w1
	add r0,1
	add r1,1
	cmp r1,r2
	bne q32		
	mov r6,1
w1: 
	mov r0,r6	
	add sp,0x10
	pop {r1-r7,pc}
.data
ThemeId:
.string "SAMSUNG THEME"
.string "SGH-D500"
.byte 1
ThemeIdEnd:
task_01_GetNumThemesInDir:
	mov r7,0
	ldr r0,=0x18AD1B94	
	ldr r1,[r0]
	cmp r1,0
	beq t01_ext
	mov r6,r1
	mov r5,0
q1:	
	mov r0,r5
	bl IsThemeByExtension
	cmp r0,0
	beq q2
	add r7,1	
q2: add r5,1
	sub r6,1
	bne q1
t01_ext:
	ldr r0,=gv_NumThemesInDir
	str r7,[r0]	
tt_ext:
	mov r0,0x6
	bl lk_get_sofk
	mov r4,r0
	mov r0,0x2c
	cmp r7,0
	bne t5
	mov r0,0
t5:
	bl lk_get_sofk
	mov r1,0
	mov r3,0
	str r1,[sp]
	str r1,[sp,4]			
	str r1,[sp,8]
	mov r2,r4
	bl Reg_Draw_Softkey
	
	add sp,0x1fc
	add sp,0x18
	pop {r4-r7,pc}
.data

menu20_01_SelectDownloadedTheme:
	mov r0,0
	bl lk_get_extended_text
	mov r1,0
	mov r2,0
	mov r3,0
	bl Reg_Draw_Title
	mov r0,r7
	mov r1,0x12
	ldr r2,=gv_NumThemesInDir
	ldr r2,[r2]
	bl lk_CreateMenu
	add r3,sp,0x20
	mov r2,0
	strh r2,[r3]
	mov r0,0x2e
	strh r0,[r3,2]
	mov r0,0xb0
	strh r0,[r3,4]
	mov r0,0x97
	strh r0,[r3,6]
	mov r0,0x32
	str r0,[sp]
	mov r0,r7
	mov r1,r3
	mov r3,1
	bl lk_PutMenuExtInfo
	ldr r1,=Theme0_1GetMenuData+1
	mov r0,r7
	bl lk_RegMenuFuncGetMenuData
	add sp,0x100
	pop {r4-r7,pc}
.data

Theme0_1GetMenuData:
	push {r3-r7,lr}
	ldr r6,=0x18AD1BA0
	mov r4,r0
	mov r5,r1
	cmp r4,0
	beq tget_ext
    mov r0,r5
	bl lk_GetThemeFileNameByIndexInList
    bl IsThemeByContent
	cmp r0,0
	bne q8
	str r0,[r4,0x1c]
	ldr r0,=0x755C
	str r0,[r4,0x18]
	ldr r0,=0x7aa
	bl lk_get_text
	str r0,[r4,0xc]
	str r6,[r4,0x28]
	b tget_ext
	
q8:
	ldr r5,=ga_ThemeBuffer+24
	str r5,[r4,0xc]
	add r5,16
	str r5,[r4,0x28]		
	mov r0,0x10
	bl RtkGetMemory
	str r0,[r4,0x1c]
	add r5,20
	mov r1,42
	strh r1,[r0]
	strh r1,[r0,2]
	ldr r1,=0x14AC
	str r1,[r0,4]
	mov r1,5
	strb r1,[r0,8]
	mov r1,0xb
	strb r1,[r0,9]
	str r5,[r0,0xc]
	add r4,0x58
	str r6,[r4]
	bl IsMyTheme
	bne tget_ext
	mov r0,r6
	ldr r1,=ThemeFileName
	blx j_strcmp
	cmp r0,0
	bne tget_ext
	ldr r0,=0x7563
	strh r0,[r4,4]
	
tget_ext:
	pop {r3-r7,pc}
.data
j__rt_memclr: bpc __rt_memclr
j__rt_memclr_w_0: bpc __rt_memclr_w_0
j_rt_memcpy: bpc rt_memcpy

task_02_SetupThemeConfirmInfo:
	bl IsThemeByContent
	add r0,sp,0x10
	mov r1,0x50
	blx j__rt_memclr
	mov r0,2
	bl lk_get_extended_text
	mov r4,r0
	bl strlen
	mov r1,r4	
	mov r2,r0
	add r0,sp,0x10
	bl strncpy
	mov r0,0x0d
	strb r0,[r3]
	mov r0,0x0a
	strb r0,[r3,1]
	ldr r4,=ga_ThemeBuffer+24
	ldrb r0,[r4]
	cmp r0,0
	bne tt_nn1
	adr r4,unk1
tt_nn1:	
	add r5,r3,2
	mov r0,r4
	bl strlen
	mov r2,r0
 	mov r1,r4
 	mov r0,r5
 	bl strncpy
	mov r0,0x0d
	strb r0,[r3]
	strb r0,[r3,2]
	mov r0,0x0a
	strb r0,[r3,1]
	strb r0,[r3,3]	
	add r5,r3,4
	mov r0,3
	bl lk_get_extended_text
	mov r4,r0
	bl strlen
	mov r1,r4	
	mov r2,r0
	mov r0,r5
	bl strncpy
	mov r0,0x0d
	strb r0,[r3]
	mov r0,0x0a
	strb r0,[r3,1]
	ldr r4,=ga_ThemeBuffer+40
	ldrb r0,[r4]
	cmp r0,0
	bne tt_nn2
	adr r4,unk2
tt_nn2:
	add r5,r3,2
	mov r0,r4
	bl strlen
	mov r2,r0
 	mov r1,r4
 	mov r0,r5
 	bl strncpy
	bl lk3_0InitEditBuffer			
	add r0,sp,0x10
	bl lk3_2WriteEditBuffer
tt_err:	
	add sp,0x1fc
	add sp,0x18
	pop {r4-r7,pc}
.data
unk0: .byte 0x54,0x68,0x65,0x6d,0x65,0x3a,0x0d,0x0a
.align 2
unk1: .string "Noname theme"
.align 2
unk2: .string "Unknown author"
.align 2
unk3: .byte 0x42,0x79,0x3a,0x0d,0x0a

lk_GetThemeFileNameByIndexInList:
	push {r0-r6,lr}
	mov r4,r0
	mov r5,0
	mov r6,0
q5:
	mov r0,r5
	bl IsThemeByExtension
	cmp r0,0
	beq q6
	cmp r6,r4
	beq q7
	add r6,1
q6:	
	add r5,1
	b q5
q7:
	pop {r0-r6,pc}
.data

if_00_OriginalIf:
	mov r0,r6
	bl 0x100677F0
	mov r4,r0
if_ext:
	mov r0,r4
	add sp,0x1fc
	add sp,0x10
	pop {r4-r7,pc}
.data

if_01_IfThemeFileCorrupt:
	bl IsThemeByContent
	cmp r0,0
	bne if_ext
	mov r4,1
	b if_ext
.data

menu20_02_ThemeOptions:
	mov r0,0x6
	bl lk_get_sofk
	mov r4,r0
	mov r0,0x46
	bl lk_get_sofk
	mov r1,0
	mov r3,0
	str r1,[sp]
	str r1,[sp,4]			
	str r1,[sp,8]
	mov r2,r4
	bl Reg_Draw_Softkey
	mov r0,r7
	mov r1,5
	mov r2,5
	bl lk_CreateMenu
	add r3,sp,0x20
	mov r2,0
	strh r2,[r3]
	strh r2,[r3,2]
	mov r0,0xb0
	strh r0,[r3,4]
	mov r0,0xc5
	strh r0,[r3,6]
	mov r0,0x14
	str r0,[sp]
	mov r0,r7
	mov r1,r3
	mov r3,0
	bl lk_PutMenuExtInfo
	adr r6,=ThOptStr
	mov r5,0
	ldrh r0,[r6]
	bl lk_get_text
	str r5,[sp]
	mov r3,r0
	mov r2,0x30
	mov r1,r5
	mov r0,r7
	bl lk_AddMenu
	add r5,1
	add r6,2
	ldrh r0,[r6] 
	bl lk_get_text
	mov r2,0
	str r2,[sp]
	mov r3,r0
	mov r2,0x30
	mov r1,r5
	mov r0,r7
	bl lk_AddMenu
	mov r2,1
	str r2,[sp]
	mov r3,0
	mov r2,0x32
	mov r1,r5
	mov r0,r7
	bl lk_AddMenu
	mov r2,0
	str r2,[sp]
	ldr r3,=mcc_theme_send
	mov r2,0x33
	mov r1,r5
	mov r0,r7
	bl lk_AddMenu
	add r5,1
	add r6,2
	ldrh r0,[r6] 
	bl lk_get_text
	mov r2,0
	str r2,[sp]
	mov r3,r0
	mov r2,0x30
	mov r1,r5
	mov r0,r7
	bl lk_AddMenu
	add r5,1
	add r6,2
	ldrh r0,[r6] 
	bl lk_get_text
	mov r2,0
	str r2,[sp]
	mov r3,r0
	mov r2,0x30
	mov r1,r5
	mov r0,r7
	bl lk_AddMenu
	add r5,1
	add r6,2
	ldrh r0,[r6] 
	bl lk_get_text
	mov r2,0
	str r2,[sp]
	mov r3,r0
	mov r2,0x30
	mov r1,r5
	mov r0,r7
	bl lk_AddMenu
	add sp,0x100
	pop {r4-r7,pc}

.data
ThOptStr: .short 0x0a69,0x0a1c,0x035a,0x0347,0x8d9

menu20_03_ThemeProperties:
	add r3,sp,0x50
	mov r0,0
	strh r0,[r3]
	mov r1,0x2f
	strh r1,[r3,2]
	mov r2,0xb0
	strh r2,[r3,4]
	mov r1,0x96
	strh r1,[r3,6]
	mov r1,r3
	ldrh r2,[r4,6]
	ldr r5,=0x1898DB80
	mov r0,r5
	bl lk_CreateFocus
	mov r7,0
	ldr r6,=0x18AD1BA0
	bl SetPropOneFocus	
	bl IsThemeByContent
	ldr r6,=ga_ThemeBuffer+24
	bl SetPropOneFocus	
	add r6,16
	bl SetPropOneFocus	
	add sp,0x100
	pop {r4-r7,pc}
.data
	
SetPropOneFocus:
	push {lr}
	sub sp,0x20
	mov r2,0
	str r2,[sp]
	mov r2,7
	mov r3,0x32
	mov r1,r7
	mov r0,r5
	bl lk_AddFocus
	add r0,r7,1
	bl lk_get_extended_text
	mov r2,0
	str r2,[sp,4]
	mov r3,0x24
	str r0,[sp]
	mov r0,r5
	mov r1,r7
	bl lk_AddFocusItem
	mov r0,r5
	mov r1,r7
	mov r2,0
	str r2,[sp,4]
	mov r3,0x28
	str r6,[sp]
	bl lk_AddFocusItem
	mov r0,r5
	mov r1,r7
	mov r2,0x2c
	str r2,[sp,4]
	mov r3,0x2a
	mov r2,0
	bl lk_AddFocusItem	
	add r7,1
	add sp,0x20
	pop {pc}
.data


task_03_DeleteThemeReq:
	mov r0,0x31
	ldr r1,=0x18AD1BA0
	bl mmitfs4_DeleteFile 		
	add sp,0x1fc
	add sp,0x18
	pop {r4-r7,pc}
.data

task_04_DeleteAllReq:
	ldr r7,=0x18AD1B94
	ldr r7,[r7]
	mov r6,0
	cmp r6,r7
	beq t2
t1:
	mov r0,r6
	bl IsThemeByExtension
	cmp r0,0
	beq t3
	mov r0,0x31
	ldr r1,=0x18AD1BA0
	bl mmitfs4_DeleteFile 		
	sub r7,1
	b t4
t3:
	add r6,1
t4:	
	cmp r6,r7
	bne t1
t2:		
	add sp,0x1fc
	add sp,0x18
	pop {r4-r7,pc}
.data

task_05_StoreThemeName:
	ldr r0,=0x1898DAD4
	ldrh r0,[r0]
	bl lk_GetThemeFileNameByIndexInList
	b t2

task_06_GetThemeIndexToSend:
	mov r0,0x31
	ldr r1,=0x18AD1BA0
	ldr r2,=0x18AD1B88
	bl mmitfs4_GetFileIndexInList
	b t2

task_07_InstallTheme:
	mov r0,4
	bl SetCurColorTheme
	bl CfgCheckElseCreate
	bl LoadCFG
	ldr r4,=CfgFile+1900
	mov r0,r4
	mov r1,0x35
	blx j__rt_memclr
	ldr r5,=0x18AD1BA0
	mov r0,r5
	bl strlen
	mov r2,r0
	mov r1,r5
	mov r0,r4
	bl strncpy	
	bl SaveCFG
	b t2	
	
CfgName: .string "BlackList.cfg"

SetCurColorTheme:
	push {r0-r7,lr}
	sub sp,0x20
	mov r7,r0
	ldr r6,=0xf5f
	mov r0,r6
	bl hfd2_30ReadBlockNameInRamImage
	mov r1,r0
	add r0,sp,4
	mov r2,8
	blx j_rt_memcpy
	ldr r0,=ColorTheme
	strb r7,[r0]
	add r1,sp,4
	strb r7,[r1]
	mov r0,r6
	bl hfd2_31SaveBlockNameInRamImage
	ldr r0,=WapColorTheme
	cmp r7,4
	blt q31
	mov r7,0
q31:
	strb r7,[r0]
	add sp,0x20		
	pop {r0-r7,pc}
.data

CfgCheckElseCreate:
	push {r0-r7,lr}
	ldr r6,=CfgFile
	mov r0,CfgDir
	ldr r1,=CfgName
	bl mmitfs4_CheckFileExist
	cmp r0,1
	beq cc_comp
	mov r0,r6
	mov r1,0b10000000
	lsl r1,4
	blx j__rt_memclr_w_0
	mov r0,CfgDir
	ldr r1,=CfgName		
	mov r2,r6
	mov r3,0b10000000
	lsl r3,4
	bl mmitfs4_CreateFile
cc_comp:
	pop {r0-r7,pc}
.data

LoadCFG:
	push {r1-r7,lr}
	ldr r6,=CfgFile
	mov r0,CfgDir
	ldr r1,=CfgName
	bl mmitfs4_CheckFileExist
	cmp r0,1
	beq lcfgc_ok
	mov r0,r6
	mov r1,0b10000000
	lsl r1,4
	blx j__rt_memclr_w_0
	mov r0,0
	b q15
lcfgc_ok:	
	mov r0,CfgDir
	ldr r1,=CfgName
	mov r3,0b10000000
	lsl r3,4
	mov r2,r6
	bl mmitfs4_ReadFile
	mov r0,1
q15:
	pop {r1-r7,pc}
.data


SaveCFG:
	push {r0-r3,lr}
	mov r0,CfgDir
	ldr r1,=CfgName
	bl mmitfs4_DeleteFile
	mov r0,CfgDir
	ldr r1,=CfgName
	ldr r2,=CfgFile
	mov r3,0b10000000
	lsl r3,4
	bl mmitfs4_CreateFile
	pop {r0-r3,pc}
.data
 
CheckThemePresent:	;R0=0 -not present
	push {r1-r7,lr}
	bl LoadCFG
	mov r7,0
	ldr r6,=CfgFile+1900
	ldrb r0,[r6]
	cmp r0,0
	beq ch_ext
	mov r0,0x31
	mov r1,r6
	bl mmitfs4_CheckFileExist
	cmp r0,1
	bne ch_ext
	ldr r4,=0x18AD1BA0	
	mov r0,r4
	mov r1,0x35
	blx j__rt_memclr
	mov r1,r6
	mov r0,r4
	mov r2,0x34
	bl strncpy	
	bl IsThemeByContent
	cmp r0,0
	beq ch_ext
	mov r7,1
ch_ext:	
	mov r0,r7
	pop {r1-r7,pc}
.data

LoadThemeItem:	;R0=Offset R1=Size
	PUSH    {R0-R7,LR}
	SUB     SP, SP, #0x1FC
	SUB     SP, SP, #0x1FC
	ldr 	r6,=ThemeFileName
	mov 	r7,r0
	mov 	r5,r1
	SUB     SP, SP, #0x14
	mov		r2,0b10000000
	lsl 	r2,3
	LDR     R1,=0x106D013B
	ADD     R0, SP, #0xC
	BLX     j_rt_memcpy
	ADD     R1, R6, #0
	mov 	r0,0x31
	ADD     R2, SP, #0xC
	BL      mmitfs4_MakeFullPath
	ADD     R1, R6, #0
	mov 	r0,0x31
	ADD     R2, SP, #8
	bl      mmitfs4_GetFileMode
	CMP     R0, #0
	BLT     tfs_exit
	MOV     R1, #2
	ADD     R0, SP, #0xC
	BL      tfs4_open
	ADD     R4, R0, #0
	CMP     R4, #0
	bge 	next_read1
tfs_exit:
	ADD     SP, SP, #0x1FC
	ADD     SP, SP, #0x1FC
	ADD     SP, SP, #0x24
	POP     {R4-R7,PC}
next_read1:
	mov r1,r7
	mov r2,0
	mov r0,r4
	bl	 	tfs4_lseek
	ldr 	r1,=ga_ThemeBuffer	
	ADD     R0, R4, #0
	mov 	r2,r5
	BL      tfs4_read
	mov		r0,r4
	bl 		tfs4_close
	b tfs_exit
.data

SetLoadedColors:
	push {r0-r7,lr}
	mov r6,r0
	mov r4,r1
	mov r0,0
	mov r7,3
	mul r2,r7
	ldr r7,=ga_ThemeBuffer
	add r7,r7,r2	
o2:
	ldrb r1,[r7]
	strb r1,[r6]
	ldrb r1,[r7,1]
	strb r1,[r6,1]
	ldrb r1,[r7,2]
	strb r1,[r6,2]
	strb r0,[r6,3]
	add r6,4
	add r7,3
	sub r4,1
	bne o2	
	pop {r0-r7,pc}
.data

InfoLineBgDraw:
	ldr r0,=ColorTheme
	ldrb r0,[r0]
	cmp r0,4
	beq MyThemeInfoBg
	mov r0,0
	mov r1,0
	mov r2,0xb0
	mov r3,0x11
	ldr r6,=0x108425B4+1
	bx r6
MyThemeInfoBg:	
	ldr r0,=5763
	ldr r1,=8976
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer	
	ldr r1,=MainSubScreen
	ldr r2,=MainSubScreen+176*17*4
	bl lk_DrawThemeBitmap
	ldr r6,=0x108425B8+1
	bx r6
.data
	
lk_DrawThemeBitmap:
	push {r0-r3,lr}	
o6:	ldrb r3,[r0]
	strb r3,[r1,1]
	ldrb r3,[r0,1]
	strb r3,[r1]
	ldrb r3,[r0,2]
	strb r3,[r1,2]
	add r0,3
	add r1,4
	cmp r1,r2
	bne o6
	pop {r0-r3,pc}
.data

lk_DrawTrueBitmap:
	push {r0-r3,lr}	
o16:	ldrb r3,[r0]
	strb r3,[r1]
	ldrb r3,[r0,1]
	strb r3,[r1,1]
	ldrb r3,[r0,2]
	strb r3,[r1,2]
	add r0,3
	add r1,4
	cmp r1,r2
	bne o16
	pop {r0-r3,pc}
.data
ttt: .string "Soff.dat"

InvalidBgCheck:
	ldr r6,=UsedSoftBg
	ldrb r0,[r6]
	cmp r0,1
	beq q11
	cmp r0,2
	beq q11
	bl GetThemeBg
	ldr r1,=0x18C6EC30
	ldr r2,=0x18C71BA0
o22:
	ldrb r5,[r0]
	strb r5,[r1,1]
	ldrb r5,[r0,1]
	strb r5,[r1]
	ldrb r5,[r0,2]
	strb r5,[r1,2]
	add r0,3
	add r1,3
	cmp r1,r2
	bne o22
q11:
	mov r0,1
	strb r0,[r6]
	ldr r0,[sp,0xd8]
	str r0,[sp,0x20]
	ldr r5,[sp,0xe0]
	ldr r6,[sp,0xfc]	
	add r0,sp,0x60
	ldr r0,[r0]
	cmp r0,0x20
	bne o20
	add r0,sp,0x94
	ldr r0,[r0]
	cmp r0,0x20
	bne o20
	mov r0,2
	ldr r1,=UsedSoftBg	
	strb r0,[r1]
	bl GetThemeBg
	bl lk_DrawThemeBitmap
	ldr r0,=0x107D76AA+1
	bx r0
o20:
	ldr r0,=0x107D7694+1
	bx r0
.data	

DrawSoftBg:
	push {r0-r5,lr}
	bl GetSoftBgParam
	beq o17
	bl lk_DrawTrueBitmap
	pop {r0-r5,pc}
o17:
	bl lk_DrawThemeBitmap
	pop {r0-r5,pc}	
.data

GetThemeBg:
	push {lr}
	b dt_std
	
GetSoftBgParam:
	push {lr}
	mov r3,0
	ldr r0,=0x1898F180
	ldrb r1,[r0]
	lsl r1,30
	cmp r1,0
	beq dt_std
	ldrb r1,[r0]
	lsr r1,7
	bcc dt_std
	ldr r0,=0x18C6EC30
	mov r3,1
	b pp_ext
dt_std:	
	ldr r0,=ColorTheme
	ldrb r0,[r0]
	cmp r0,4
	ldr r1,=12144
	beq MyThemeSoftBg
	mul r0,r1
	ldr r1,=soft_bg_icon
	add r0,r0,r1
pp_ext:
	ldr r1,=MainSubScreen+176*197*4
	mov r2,0b11111101
	lsl r2,6
	add r2,r1,r2
	cmp r3,0
	pop {pc}		
MyThemeSoftBg:	
	ldr r0,=14739
	bl LoadThemeItem
	mov r3,0
	ldr r0,=ga_ThemeBuffer	
	b pp_ext
.data

DrawSoftBg2:
	bl DrawSoftBg
	ldr r0,=0x10B8CB90+1
	bx r0
.data

DrawSoftBg4:
	push {r1-r5}
	bl GetSoftBgParam
	ldr r5,=0x4BA00
	add r1,r1,r5
	add r2,r2,r5
	cmp r3,0
	beq o18
	bl lk_DrawTrueBitmap
	b o19
o18:
	bl lk_DrawThemeBitmap
o19:
	pop {r1-r5}	
	ldr r0,=0x1134B3FE+1
	bx r0
.data
	
	
Patch_GetGPRSIcon:
	cmp r5,4
	beq gprs_on
	mov r0,0x43
	bl rrm99_00ReturnUnsignedValue
	cmp r0,0
	beq gprs_not_supported
	ldr r0,=s_dcm_BearersInfos
	ldrb r0,[r0,1]
	cmp r0,1
	bgt gprs_available
	beq gprs_supported
gprs_not_supported:
	ldr r0,=83400+816
	b gprs_ic
gprs_supported:
	ldr r0,=83400+1632
	b gprs_ic
gprs_available:
	ldr r0,=83400
	b gprs_ic
gprs_on:
	ldr r0,=83400+2448
gprs_ic:
	ldr r1,=816
patch_fin:
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer
	pop {r1-r7,pc}
.data 

Patch_GetQuietIcon:	
 ldr r0,=mmi_quiet_mode_onoff
 ldrb r0,[r0]
 cmp r0,1
 beq quet_mode
normal_mode:
 ldr r0,=gv_alert_type
 ldrb r1,[r0]
 ldr r0,=93396;norm_mode_melody_icon 
 cmp r1,0
 beq qq3
 cmp r1,1
 beq qm_vib
 ldr r0,=94263;norm_mode_melody_aftervib_icon
 cmp r1,2
 beq qq3
 ldr r0,=95130;norm_mode_melody_plusvib_icon
 b qq3 
quet_mode:
 ldr r0,=gv_quiet_mode_vib_mute
 ldrb r0,[r0]
 cmp r0,0
 beq qm_vib
qm_mute:
 ldr r0,=91662;mute_mute_icon
 b qq3
qm_vib:
 ldr r0,=92529;mute_vib_icon
qq3:
	ldr r1,=867
	b patch_fin
.data

Patch_GetBatIcon:
	ldr r5,=gv_InCharge
	ldrb r0,[r5]
	cmp r0,1
	beq std_bat
	cmp r0,2
	beq std_bat
	ldrb r0,[r5,1]
	cmp r0,1
	beq std_bat
	bl GetInfoBatIconIndex
	ldr r1,=0x495
	mul r0,r1
	ldr r2,=100689
	add r0,r0,r2
	b patch_fin
std_bat:
	mov r0,r4
	beq no_bat
	lsr r0,r4,2
	ldr r1,=0x495
	mul r0,r1
	ldr r2,=94824
	add r0,r0,r2
	b patch_fin
no_bat:
	pop {r1-r7,pc}
.data
	
GetInfoBatIconIndex:
	push {r1-r7,lr}
	ldr r1,=v_hbat_CurrentVoltage1
	ldr r1,[r1]
	ldr r0,=0x81af	; Current Value for ONLY Li-Polymer battery
	blx j___rt_udiv
	cmp r0,0x69
	bgt okk
	mov r0,0
	b get_bat
okk:
	sub r0,0x6a
	cmp r0,16
	blt get_bat
	mov r0,15
get_bat:
	pop {r1-r7,pc}
.data
j___rt_udiv: bpc __rt_udiv

Patch_GetCallRecIcon:
	ldr r0,=0x18ffffff
	ldrb r0,[r0]
	cmp r0,0
	ldr r0,=934665
	beq cc2
	ldr r0,=935433
cc2:
	ldr r1,=768
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer
	pop {r1-r7,pc}
.data

lk_XtendIconInfo:
	push {r1-r7,lr}
	mov r7,r0
	bl lk_XGetIconInfo
	mov r6,r0
	bl IsMyTheme
	bne y1
	mov r0,0x31
	ldr r1,=ThemeFileName
	bl mmitfs4_CheckFileExist
	cmp r0,1
	beq y2
	mov r0,0
	bl SetCurColorTheme
	bl GetMenuColor
	mov r0,r6
	b y1
y2:
	ldr r0,=0x7551
	cmp r0,r7
	bne patch_check
	bl Patch_GetGPRSIcon
patch_check:
	ldr r0,=0x1f5c
	cmp r0,r7
	bne patch_check2
	bl Patch_GetQuietIcon
patch_check2:	
	ldr r0,=0x754e
	cmp r0,r7
	bne patch_check3
	bl Patch_GetBatIcon
patch_check3:
	add r0,2
	cmp r0,r7
	bne patch_check4
	bl Patch_GetCallRecIcon
patch_check4:
	adr r0,HandIconTab
	ldr r1,=HandIconTabEnd
y3:
	ldr r2,[r0]
	cmp r2,r7
	beq y4
	add r0,12
	cmp r0,r1
	bne y3
	mov r0,r6
y1:	pop {r1-r7,pc}
y4: 
	mov r5,r0
	mov r1,r6
	ldr r4,=ThemeIconInfo
	mov r0,r4
	mov r2,24
	blx j_rt_memcpy
	ldr r0,[r5,4]
	ldr r1,[r5,8]
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer
	str r0,[r4,16]
	mov r0,r4
	b y1
.data

HandIconTab:
.word 0x81b7,26883,17952
.word 0x81b8,59115,672
.word 0x81b9,44835,1428
.word 0x81ba,46263,1428
.word 0x81bb,47691,1428
.word 0x81bc,49119,1428
.word 0x81bd,50547,1428
.word 0x81be,51975,1428
.word 0x81bf,53403,1428
.word 0x81c0,54831,1428
.word 0x81c1,56259,1428
.word 0x81c2,57687,1428
.word 0x754a,119457,867
.word 0x754b,120324,867
.word 0x13d6,121191,768
.word 0x7549,121959,768
.word 0x81DE,122727,11868
.word 0x81e8,134595,1620
.word 0x659F,136215,1650
.word 0x7546,137865,1650
.word 0x659E,137865,1650
.word 0x659D,139515,1650
.word 0x65A0,141165,1650
.word 0x81af,142815,6708
.word 0x81B1,149523,13416
.word 0x81b0,162939,3612
.word 0x8101,166551,765
.word 0x8106,167316,918
.word 0x55f2,168234,918
.word 0x81A8,285312,10980
.word 0x81AA,296292,3456
.word 0x81A9,299748,2400
.word 0x819F,302148,7452
.word 0x81a0,309600,7452
.word 0x81a1,317052,7452
.word 0x81a2,324504,7452
.word 0x81a3,331956,7452
.word 0x81a4,339408,7452
.word 0x81a5,346860,7452
.word 0x81a6,354312,7452
.word 0x81a7,361764,7452
.word 0x81AB,369216,15840
.word 0x81AC,385056,2400
.word 0x81AD,387456,3456
.word 0x81AE,390912,2592
.word 0x81B2,393504,13200
.word 0x1f53,406704,17424
.word 0x1f44,424128,1950
.word 0x1f49,426078,1950
.word 0x1f4e,428028,1386
.word 0x80EC,429414,2850
.word 0x80ED,432264,768
.word 0x80ee,433032,768
.word 0x80ef,433800,768
.word 0x80f0,434568,768
.word 0x80f1,435336,768
.word 0x80f2,436104,768
.word 0x812A,436872,15840
.word 0x812F,452712,2550
.word 0x8134,455262,6426
.word 0x6,899070,3528
.word 0xa,902598,504
.word 0xe,903102,2016
.word 0x16,905118,2838
.word 0x1a,907956,2838
.word 0x12,910794,507
.word 0x28,911301,1380
.word 0x29,912681,1380
.word 0x80F7,914061,432
.word 0x80f6,914493,432
.word 0x8137,915432,507
.word 0x8138,914925,507
.word 0x813D,915939,684
.word 0x813E,917307,684
.word 0x8143,916623,684
.word 0x8148,917991,684
.word 0x8149,918675,1083
.word 0x814E,919758,1083
.word 0x8218,920841,768
.word 0x8219,921609,768
.word 0x1388,922377,768
.word 0x1389,923145,768
.word 0x138a,923913,768
.word 0x138b,924681,768
.word 0x138c,925449,768
.word 0x138d,926217,768
.word 0x138e,926985,768
.word 0x138f,927753,768
.word 0x1390,928521,768
.word 0x1391,929289,768
.word 0x1392,930057,768
.word 0x1393,930825,768
.word 0x13CD,931593,768
.word 0x13CE,932361,768
.word 0x13CF,933129,768
.word 0x13D0,933897,768
.word 0x4652,945567,546
.word 0x4653,946113,546
.word 0x4654,946659,546
.word 0x4655,947205,546
HandIconTabEnd:

lk_XGetIconInfo:
	push {r7,lr}
	mov r1,0b11111010
	lsl r1,2
	cmp r0,r1
	ldr r2,=0x10BF1FF8+1
	bx r2
.data

IsMyTheme:
	push {r0,lr}
	ldr r0,=ColorTheme
	ldrb r0,[r0]
	cmp r0,4
	pop {r0,pc}
.data

GetIndicatorRSSI:
	bl IsMyTheme
	beq MyRSSI
	ldr r0,=0x1800670C
	ldr r0,[r0,r1]
	pop {r4,r5,pc}
MyRSSI:
	ldr r1,=1377
	mov r4,r2
	mul r4,r1
	ldr r0,=59787
	add r0,r0,r4
IndCont:	
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer
	pop {r4,r5,pc}
.data

GetIndicatorOffhook:
	bl IsMyTheme
	beq MyOffhook
gio:	
	ldr r0,=0x180066C4
	ldr r0,[r0,r1]
	pop {r4,r5,pc}
MyOffhook:
	cmp r1,0
	beq gio
	ldr r0,=69426
	ldr r1,=765
	b IndCont
.data

GetIndicatorNocall:
	bl IsMyTheme
	beq MyNocall
gin:
	ldr r0,=0x180066CC
	ldr r0,[r0,r1]
	pop {r4,r5,pc}
MyNocall:
	cmp r1,0
	beq gin
	ldr r0,=70191
	ldr r1,=765
	b IndCont
.data

GetIndicatorAlarm:
	bl IsMyTheme
	beq MyAlarm
gia:
	ldr r0,=0x180066F4
	ldr r0,[r0,r1]
	pop {r4,r5,pc}
MyAlarm:
	cmp r1,0
	beq gia
	ldr r0,=70956
	ldr r1,=765
	b IndCont
.data

GetIndicatorMemFull:
	ldr r0,=0x180066DC
	bl IsMyIcon
	beq MyMemfull
	pop {r4,r5,pc}
MyMemfull:	
	ldr r0,=71721
mm_cont:
	ldr r4,=714
mm_cc2:
	lsr r1,2
	mul r1,r4
	add r0,r0,r1
	mov r1,r4
	b IndCont
.data

IsMyIcon:
	push {lr}
	bl IsMyTheme
	ldr r0,[r0,r1]
	bne no_mic
	cmp r0,0
	beq no_mic2
	mov r4,r0
	b mic3
no_mic2:
	add r4,r0,1
mic3:	
	cmp r0,r4		
no_mic:	
	pop {pc}
.data

GetIndicatorNewMMS:
	ldr r0,=0x180066D4
	bl IsMyIcon
	beq MyNewMMS
	pop {r4,r5,pc}
MyNewMMS:	
	ldr r0,=73149
	b mm_cont
.data

GetIndicatorNewEmail:
	ldr r0,=0x180066E4
	bl IsMyIcon
	beq MyNewEmail
	pop {r4,r5,pc}
MyNewEmail:	
	ldr r0,=74577
	b mm_cont
.data
	
GetIndicatorNewSMS:
	ldr r0,=0x180066EC
	bl IsMyIcon
	beq MyNewSMS
	pop {r4,r5,pc}
MyNewSMS:	
	ldr r0,=75291
	b mm_cont
.data

GetIndicatorNewVoice:
	ldr r0,=0x18006728
	bl IsMyIcon
	beq MyNewVoice
	pop {r4,r5,pc}
MyNewVoice:	
	ldr r0,=76005
	b mm_cont
.data

mm_cont2:
	ldr r4,=765
	b mm_cc2
.data

GetIndicatorIrda:
	ldr r0,=0x1800673C
	bl IsMyIcon
	beq MyIrda
	pop {r4,r5,pc}
MyIrda:	
	ldr r0,=79575-765
	b mm_cont2
.data

GetIndicatorBluetooth:
	ldr r0,=0x18006748
	bl IsMyIcon
	beq MyBluetooth
	pop {r4,r5,pc}
MyBluetooth:	
	ldr r0,=81105-765
	b mm_cont2
.data
			
GetIndicatorSyncml:
	ldr r0,=0x180066FC
	bl IsMyIcon
	beq MySyncml
	pop {r4,r5,pc}
MySyncml:	
	ldr r0,=82635-765
	b mm_cont2
.data

GetIndicatorDivert:
	ldr r0,=0x18006754
	bl IsMyIcon
	beq MyDivert
	pop {r4,r5,pc}
MyDivert:	
	ldr r0,=86664-867
	ldr r4,=867
	b mm_cc2
.data

GetIndicatorZone:
	ldr r0,=0x18006768
	bl IsMyIcon
	beq MyZone
	pop {r4,r5,pc}
MyZone:	
	ldr r0,=90132-765
	b mm_cont2
.data

GetFrameIconInfo:	
	mov r2,0x18
	add r1,r0,r1
	mov r0,r4
	blx j_rt_memcpy	
	bl IsMyTheme
	beq my_frame_check	
fext:
	mov r0,1
	pop {r4-r6,pc}
my_frame_check:
	adr r0,FrameHandIconTab
	adr r1,EndFrameHandIconTab
	ldr r2,[r4,16]
mf_ch2:	
	ldr r3,[r0]
	cmp r3,r2
	bne mf_ch3
	ldr r1,[r0,8]
	ldr r0,[r0,4]
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer
	str r0,[r4,16]
	b fext
mf_ch3:
	add r0,12
	cmp r1,r0
	bne mf_ch2
	b fext
	
.data

FrameHandIconTab:
.word 0x110deec6,169152,15312	;Org
.word 0x10618b2a,184464,15312
.word 0x101cb10a,199776,15312
.word 0x10621f7a,215088,2550
.word 0x10d43baa,217638,3672
.word 0x101cf6d0,221310,2754
.word 0x10946332,224064,61248
.word 0x110deb30,936201,918
.word 0x11459c47,947751,918
.word 0x10d45eba,937119,8448
.word 0x110d6fb2,948669,8448
EndFrameHandIconTab:

MainMenuBgGet:
	bl IsMyTheme
	beq LoadMainMenuBg
	str r2,[sp,8]
	ldrb r3,[r0]
	mov r2,1
	add r3,0x11
	ldr r0,=0x1047FDA8+1
	bx r0
LoadMainMenuBg:
	ldr r0,=461688
	ldr r1,=79200
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer	
	ldr r1,=MainSubScreen+176*47*4
	ldr r2,=MainSubScreen+176*197*4
	bl lk_DrawThemeBitmap
	ldr r0,=0x1047FDAE+1
	bx r0
.data

MainMenuIconGet:
	bl IsMyTheme		
	beq LoadMainMenuIcon
not_icon:
	lsl r0,r4,2
	ldr r1,=0x18005878
	ldr r0,[r0,r1]
	ldr r1,=0x1134D5D8+1
	bx r1
LoadMainMenuIcon:
	cmp r4,38
	bcc not_icon
	cmp r4,65
	bge not_icon
	mov r0,r4
	ldr r4,=13266
	sub r0,38
	mul r0,r4
	ldr r2,=540888
	add r0,r0,r2
	mov r1,r4
	bl LoadThemeItem
	ldr r0,=ga_ThemeBuffer
	pop {r4-r6,pc}
.data

DrawTIconBg:
	push {r0-r5,lr}
	bl GetSoftBgParam
	mov r5,r3
	ldr r3,=UsedSoftBg
	ldrb r3,[r3]
	cmp r3,2
	bne o21
	bl GetThemeBg
	mov r5,0
o21:
	mov r3,234
	add r2,r1,r3
	add r3,r0,r3
	add r2,78
	mov r1,23

o9:	mov r0,20
	cmp r5,0
	beq o8
o7:	ldrb r4,[r3]
	strb r4,[r2]
	ldrb r4,[r3,1]
	strb r4,[r2,1]
	ldrb r4,[r3,2]
	strb r4,[r2,2]
	add r3,3
	add r2,4
	sub r0,1
	bne o7
o10:
	mov r4,0b11101010
	lsl r4,1
	add r3,r3,r4
	mov r4,0b10011100
	lsl r4,2
	add r2,r2,r4
	sub r1,1
	bne o9
	pop {r0-r5,pc}

o8:	ldrb r4,[r3]
	strb r4,[r2,1]
	ldrb r4,[r3,1]
	strb r4,[r2]
	ldrb r4,[r3,2]
	strb r4,[r2,2]
	add r3,3
	add r2,4
	sub r0,1
	bne o8
	b o10
.data

InstallSoftBg:
	ldr r3,=UsedSoftBg
	mov r4,255
	strb r4,[r3]
.insertbin 0x100CA848,8
	ldr r0,=0x100CA850+1
	bx r0
.data

std_31_task_pre:
	bl IsMyTheme
	bne q35
	bl SetDefaulFirstSkin
	mov r0,r6
	add r0,0x68
	mov r1,0
	strh r1,[r0]
q35:
	ldr r1,=0x107EC51C+1
	mov r0,r6
	ldr r6,=0x10C081B6+1
	bx r6
.data

SetDefaulFirstSkin:
	push {r1-r7,lr}
	mov r0,0
	ldr r1,=0x113014C0+1
	bx r1
.data
	
.pathres  "  <resmap>
.pathres  "   <img offset="%soft_bg_icon%" title="Фон_подписей_софтклавиш_для_стандартных_цветовых_схем" width="176" height="23" bpp="18" count="4">
.pathres  "  </resmap>
