// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
movl 0x18(%rdi), %eax
cmpl $0xf, %eax
jg 0x75bc
cmpl $0x1, %eax
je 0x757e
cmpl $0x4, %eax
je 0x757e
cmpl $0x8, %eax
jne 0x76b3
movl 0x14(%rdi), %eax
imull 0x10(%rdi), %eax
testl %eax, %eax
jle 0x76b1
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
xorl %edx, %edx
movzbl (%rax,%rdx), %r8d
movl (%rcx,%r8,4), %r8d
movl %r8d, (%rsi,%rdx,4)
incq %rdx
movslq 0x10(%rdi), %r8
movslq 0x14(%rdi), %r9
imulq %r8, %r9
cmpq %r9, %rdx
jl 0x7596
jmp 0x76b1
cmpl $0x20, %eax
je 0x7687
cmpl $0x18, %eax
je 0x7641
cmpl $0x10, %eax
jne 0x76b3
movl 0x14(%rdi), %eax
imull 0x10(%rdi), %eax
testl %eax, %eax
jle 0x76b1
movq (%rdi), %rax
xorl %ecx, %ecx
movzbl 0x1(%rax,%rcx,2), %edx
movb (%rax,%rcx,2), %r8b
movl %r8d, %r9d
shrb $0x2, %r9b
movl %edx, %r10d
shlb $0x6, %r10b
orb %r9b, %r10b
andb $-0x8, %r10b
movzbl %r10b, %r9d
shlb $0x3, %r8b
movzbl %r8b, %r8d
andl $0x7c, %edx
shll $0x11, %edx
shll $0x8, %r9d
orl %edx, %r9d
leal (%r8,%r9), %edx
addl $0xff000000, %edx       # imm = 0xFF000000
movl %edx, (%rsi,%rcx,4)
incq %rcx
movslq 0x10(%rdi), %rdx
movslq 0x14(%rdi), %r8
imulq %rdx, %r8
cmpq %r8, %rcx
jl 0x75e7
jmp 0x76b1
movl 0x14(%rdi), %eax
imull 0x10(%rdi), %eax
testl %eax, %eax
jle 0x76b1
movq (%rdi), %rax
incq %rax
xorl %ecx, %ecx
movzwl (%rax), %edx
shll $0x8, %edx
movzbl -0x1(%rax), %r8d
orl %edx, %r8d
orl $0xff000000, %r8d       # imm = 0xFF000000
movl %r8d, (%rsi,%rcx,4)
incq %rcx
movslq 0x10(%rdi), %rdx
movslq 0x14(%rdi), %r8
imulq %rdx, %r8
addq $0x3, %rax
cmpq %r8, %rcx
jl 0x7654
jmp 0x76b1
movl 0x14(%rdi), %eax
imull 0x10(%rdi), %eax
testl %eax, %eax
jle 0x76b1
movq (%rdi), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
movl %edx, (%rsi,%rcx,4)
incq %rcx
movslq 0x10(%rdi), %rdx
movslq 0x14(%rdi), %r8
imulq %rdx, %r8
cmpq %r8, %rcx
jl 0x7697
popq %rbx
retq
movl $0x18, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x2d75(%rip), %rdx      # 0xa43c
movq %rax, %rdi
movl $0x1, %esi
callq 0x8330
leaq 0x76b5(%rip), %rsi      # 0xed90
leaq 0xc7a(%rip), %rdx       # 0x835c
movq %rbx, %rdi
callq 0x2320