// File: ticky[P]ps2iconsys/src/ps2_iconsys.cpp
// Function: IconSys::IconSys(char const*)
IconSys::IconSys(const char* fname)
{
	std::ifstream fin(fname, std::ios_base::in | std::ios_base::binary);
	if(fin.fail()) { throw( Ghulbus::gbException(Ghulbus::gbException::GB_FAILED,
	                                             "Could not open icon file for read") ); }

	fin.read( reinterpret_cast<char*>(&File), sizeof(File) );
	if(fin.fail()) {
		fin.close();
		throw( Ghulbus::gbException(Ghulbus::gbException::GB_FAILED,
			                        "File read error") ); 
	}
	fin.close();

	/*if(!CheckValidity(File)) { 
		throw( Ghulbus::gbException(Ghulbus::gbException::GB_FAILED,
			                        "File seems to be corrupted") ); 
	}*/

	DecodeTitle(File.title, decoded_title);
	GetTitleString(decoded_title, File.offset_2nd_line, title_str);
	strcpy(title_str_single_line, title_str);
	char* tmp = strchr(title_str_single_line, '\n');
	if(tmp) { *tmp = ' '; }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x248(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x240(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x9de0
movq -0x240(%rbp), %rsi
movl %eax, %edx
leaq -0x218(%rbp), %rdi
callq 0x2390
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x2030
movb %al, -0x231(%rbp)
jmp 0x831d
movb -0x231(%rbp), %al
testb $0x1, %al
jne 0x8329
jmp 0x8390
movl $0x18, %edi
callq 0x20f0
movq %rax, %rdi
movq %rdi, -0x250(%rbp)
leaq 0x8e40(%rip), %rdx      # 0x11184
movl $0x1, %esi
callq 0xf0b0
movq -0x250(%rbp), %rdi
leaq 0xfa34(%rip), %rsi      # 0x17d90
leaq 0x6ded(%rip), %rdx      # 0xf150
callq 0x2340
jmp 0x84e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x2070
jmp 0x84d9
movq -0x248(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0x3c4, %edx            # imm = 0x3C4
callq 0x2260
jmp 0x83aa
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x2030
movb %al, -0x251(%rbp)
jmp 0x83ca
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0x83d6
jmp 0x8428
leaq -0x218(%rbp), %rdi
callq 0x2060
jmp 0x83e4
movl $0x18, %edi
callq 0x20f0
movq %rax, %rdi
movq %rdi, -0x260(%rbp)
leaq 0x8da7(%rip), %rdx      # 0x111a6
movl $0x1, %esi
callq 0xf0b0
movq -0x260(%rbp), %rdi
leaq 0xf979(%rip), %rsi      # 0x17d90
leaq 0x6d32(%rip), %rdx      # 0xf150
callq 0x2340
jmp 0x84e5
leaq -0x218(%rbp), %rdi
callq 0x2060
jmp 0x8436
movq -0x248(%rbp), %rsi
movq %rsi, %rdi
addq $0xc0, %rdi
addq $0x3c4, %rsi            # imm = 0x3C4
callq 0x7940
movq -0x248(%rbp), %rdx
movq %rdx, %rdi
addq $0x3c4, %rdi            # imm = 0x3C4
movzwl 0x6(%rdx), %esi
addq $0x3e6, %rdx            # imm = 0x3E6
callq 0x7f30
movq -0x248(%rbp), %rsi
movq %rsi, %rdi
addq $0x409, %rdi            # imm = 0x409
addq $0x3e6, %rsi            # imm = 0x3E6
callq 0x21a0
movq -0x248(%rbp), %rdi
addq $0x409, %rdi            # imm = 0x409
movl $0xa, %esi
callq 0x20b0
movq %rax, -0x230(%rbp)
cmpq $0x0, -0x230(%rbp)
je 0x84c4
movq -0x230(%rbp), %rax
movb $0x20, (%rax)
leaq -0x218(%rbp), %rdi
callq 0x2070
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq -0x220(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)