// File: ticky[P]ps2iconsys/gbLib/src/gbImageLoader.cpp
// Function: GhulbusUtil::gbImageLoader::GetImageData32(unsigned int*) const
void gbImageLoader::GetImageData32(GhulbusGraphics::GBCOLOR* pData) const {
		switch(m_bpp) {
			case 32:
				//32 bit image: one byte per color-channel, one byte alpha:
				for(int i=0; i<(m_width*m_height); i++) {
					pData[i] = GhulbusGraphics::GBCOLOR32::ARGB(m_data[i*4+3], m_data[i*4+2], m_data[i*4+1], m_data[i*4]);
				}
				break;
			case 24:
				//24 bit image: one byte per color-channel, no alpha channel
				for(int i=0; i<(m_width*m_height); i++) {
					pData[i] = GhulbusGraphics::GBCOLOR32::XRGB(m_data[i*3+2], m_data[i*3+1], m_data[i*3]);
				}
				break;
			case 16:
				//16 bit image: 5 bit per color channel, 1 bit alpha channel (unsupported)
				for(int i=0; i<(m_width*m_height); i++) {
					GhulbusGraphics::GBCOLOR_COMPONENT r,g,b,a;
					r =  (m_data[i*2+1] & 0x7C) >> 2;
					g = ((m_data[i*2]   & 0xE0) >> 5) | ((m_data[i*2+1] & 0x03) << 3);
					b =  (m_data[i*2]   & 0x1F);
					a =  (m_data[i*2+1] & 0x80) >> 7;
					a = 1;
					///@todo alpha channel
					///@todo dithering(?)
					pData[i] = GhulbusGraphics::GBCOLOR32::ARGB(a*255,r*8,g*8,b*8);
				}
				break;
			case 8: case 4: case 1:
				//one byte palette index per pixel
				for(int i=0; i<(m_width*m_height); i++) {
					GhulbusGraphics::GBCOLOR_COMPONENT r,g,b,a;
					r = static_cast<GhulbusGraphics::GBCOLOR_COMPONENT>((m_palette[m_data[i]] >> 16) & 0xff);
					g = static_cast<GhulbusGraphics::GBCOLOR_COMPONENT>((m_palette[m_data[i]] >>  8) & 0xff);
					b = static_cast<GhulbusGraphics::GBCOLOR_COMPONENT>((m_palette[m_data[i]])       & 0xff);
					a = static_cast<GhulbusGraphics::GBCOLOR_COMPONENT>((m_palette[m_data[i]] >> 24) & 0xff);
					pData[i] = GhulbusGraphics::GBCOLOR32::ARGB(a, r, g, b);
				}
				///@todo dithering(?)
				break;
			default:
				throw( Ghulbus::gbException( Ghulbus::gbException::GB_FAILED,
					                         "Unable to acquire 32bit image data" ) );
				break;
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl 0x18(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x1f, %eax
ja 0xd73f
movq -0x30(%rbp), %rax
leaq 0x3e79(%rip), %rcx      # 0x112f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x14(%rbp)
movq -0x38(%rbp), %rdx
movl -0x14(%rbp), %eax
movl 0x10(%rdx), %ecx
imull 0x14(%rdx), %ecx
cmpl %ecx, %eax
jge 0xd510
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movl -0x14(%rbp), %edx
shll $0x2, %edx
addl $0x3, %edx
movslq %edx, %rdx
movb (%rcx,%rdx), %dil
movq (%rax), %rcx
movl -0x14(%rbp), %edx
shll $0x2, %edx
addl $0x2, %edx
movslq %edx, %rdx
movb (%rcx,%rdx), %sil
movq (%rax), %rcx
movl -0x14(%rbp), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movb (%rcx,%rdx), %dl
movq (%rax), %rax
movl -0x14(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movzbl %dil, %edi
movzbl %sil, %esi
movzbl %dl, %edx
movzbl (%rax,%rcx), %ecx
callq 0xdc60
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xd487
jmp 0xd778
movl $0x0, -0x18(%rbp)
movq -0x38(%rbp), %rdx
movl -0x18(%rbp), %eax
movl 0x10(%rdx), %ecx
imull 0x14(%rdx), %ecx
cmpl %ecx, %eax
jge 0xd585
movq -0x38(%rbp), %rax
movq (%rax), %rcx
imull $0x3, -0x18(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movb (%rcx,%rdx), %sil
movq (%rax), %rcx
imull $0x3, -0x18(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movb (%rcx,%rdx), %dl
movq (%rax), %rax
imull $0x3, -0x18(%rbp), %ecx
movslq %ecx, %rcx
movzbl %sil, %edi
movzbl %dl, %esi
movzbl (%rax,%rcx), %edx
callq 0xdca0
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xd51c
jmp 0xd778
movl $0x0, -0x1c(%rbp)
movq -0x38(%rbp), %rdx
movl -0x1c(%rbp), %eax
movl 0x10(%rdx), %ecx
imull 0x14(%rdx), %ecx
cmpl %ecx, %eax
jge 0xd670
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movl -0x1c(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
andl $0x7c, %ecx
sarl $0x2, %ecx
movb %cl, -0x1d(%rbp)
movq (%rax), %rcx
movl -0x1c(%rbp), %edx
shll %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
andl $0xe0, %ecx
sarl $0x5, %ecx
movq (%rax), %rdx
movl -0x1c(%rbp), %esi
shll %esi
addl $0x1, %esi
movslq %esi, %rsi
movzbl (%rdx,%rsi), %edx
andl $0x3, %edx
shll $0x3, %edx
orl %edx, %ecx
movb %cl, -0x1e(%rbp)
movq (%rax), %rcx
movl -0x1c(%rbp), %edx
shll %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
andl $0x1f, %ecx
movb %cl, -0x1f(%rbp)
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
andl $0x80, %eax
sarl $0x7, %eax
movb %al, -0x20(%rbp)
movb $0x1, -0x20(%rbp)
movzbl -0x20(%rbp), %eax
imull $0xff, %eax, %edi
movzbl -0x1d(%rbp), %esi
shll $0x3, %esi
movzbl -0x1e(%rbp), %edx
shll $0x3, %edx
movzbl -0x1f(%rbp), %ecx
shll $0x3, %ecx
callq 0xdce0
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd591
jmp 0xd778
movl $0x0, -0x24(%rbp)
movq -0x38(%rbp), %rdx
movl -0x24(%rbp), %eax
movl 0x10(%rdx), %ecx
imull 0x14(%rdx), %ecx
cmpl %ecx, %eax
jge 0xd73d
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
movq (%rcx), %rdx
movslq -0x24(%rbp), %rsi
movzbl (%rdx,%rsi), %edx
movl (%rax,%rdx,4), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, -0x25(%rbp)
movq 0x8(%rcx), %rax
movq (%rcx), %rdx
movslq -0x24(%rbp), %rsi
movzbl (%rdx,%rsi), %edx
movl (%rax,%rdx,4), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, -0x26(%rbp)
movq 0x8(%rcx), %rax
movq (%rcx), %rdx
movslq -0x24(%rbp), %rsi
movzbl (%rdx,%rsi), %edx
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movb %al, -0x27(%rbp)
movq 0x8(%rcx), %rax
movq (%rcx), %rcx
movslq -0x24(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movl (%rax,%rcx,4), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, -0x28(%rbp)
movb -0x28(%rbp), %dl
movb -0x25(%rbp), %cl
movb -0x26(%rbp), %al
movzbl %dl, %edi
movzbl %cl, %esi
movzbl %al, %edx
movzbl -0x27(%rbp), %ecx
callq 0xdc60
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd67c
jmp 0xd778
movl $0x18, %edi
callq 0x20f0
movq %rax, %rdi
movq %rdi, -0x40(%rbp)
movl $0x1, %esi
leaq 0x3c9f(%rip), %rdx      # 0x113fb
callq 0xf0b0
movq -0x40(%rbp), %rdi
leaq 0xa624(%rip), %rsi      # 0x17d90
leaq 0x19dd(%rip), %rdx      # 0xf150
callq 0x2340
addq $0x40, %rsp
popq %rbp
retq
nop