// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1, %eax
je 0x69b7
cmpl $0x4, %eax
je 0x69b7
cmpl $0x8, %eax
je 0x69b7
cmpl $0x20, %eax
je 0x6a1e
cmpl $0x18, %eax
je 0x69e3
cmpl $0x10, %eax
jne 0x6a41
movq (%rdi), %rax
xorl %ecx, %ecx
movslq 0x10(%rdi), %rdx
movslq 0x14(%rdi), %r8
imulq %rdx, %r8
cmpq %r8, %rcx
jge 0x6a3f
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
jmp 0x6959
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
xorl %edx, %edx
movslq 0x10(%rdi), %r8
movslq 0x14(%rdi), %r9
imulq %r8, %r9
cmpq %r9, %rdx
jge 0x6a3f
movzbl (%rax,%rdx), %r8d
movl (%rcx,%r8,4), %r8d
movl %r8d, (%rsi,%rdx,4)
incq %rdx
jmp 0x69c0
movq (%rdi), %rax
incq %rax
xorl %ecx, %ecx
movslq 0x10(%rdi), %rdx
movslq 0x14(%rdi), %r8
imulq %rdx, %r8
cmpq %r8, %rcx
jge 0x6a3f
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
addq $0x3, %rax
jmp 0x69eb
movq (%rdi), %rax
xorl %ecx, %ecx
movslq 0x10(%rdi), %rdx
movslq 0x14(%rdi), %r8
imulq %rdx, %r8
cmpq %r8, %rcx
jge 0x6a3f
movl (%rax,%rcx,4), %edx
movl %edx, (%rsi,%rcx,4)
incq %rcx
jmp 0x6a23
popq %rbx
retq
pushq $0x18
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x29e9(%rip), %rdx      # 0x943c
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x7628
leaq 0x8333(%rip), %rsi      # 0xed98
leaq 0xbe8(%rip), %rdx       # 0x7654
movq %rbx, %rdi
callq 0x22f0