// File: tjohnman[P]sfxr-sdl2/build/../src/sdlkit.cpp
// Function: select_file(char*, bool)
bool select_file (char *buf, bool showNewButton)
{
	// FIXME: Needs directory browsing
	
	bool gotFile = false;
	using namespace std;
	list<string> files;
	files = ioList(".", false, true);
	
	for(list<string>::iterator e = files.begin(); e != files.end();)
	{
		if(e->find(".sfxr") == string::npos)
		{
			e = files.erase(e);
			continue;
		}
		
		e++;
	}
	
	bool done = false;
	SDL_Event e;
	while (!done)
	{
		SDL_PollEvent(&e);
		switch (e.type)
		{
			case SDL_QUIT:
				exit(0);
	
			case SDL_KEYDOWN:
				keys[e.key.keysym.sym] = true;
	
			default: break;
		}
		sdlupdate();
		
		DrawFileSelectScreen(files, buf, gotFile, done, showNewButton);

		SDL_Delay(5);
		
		SDL_UpdateWindowSurface(window);
	}
	return gotFile;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movb $0x0, -0xa(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x9c60
leaq -0x61(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x35d0
movq -0xe8(%rbp), %rdx
leaq 0x4d61(%rip), %rsi      # 0xe4f3
leaq -0x60(%rbp), %rdi
callq 0x84b0
jmp 0x979d
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8b90
jmp 0x97b3
leaq -0x28(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xa320
leaq -0x40(%rbp), %rdi
callq 0xa150
leaq -0x60(%rbp), %rdi
callq 0x31e0
leaq -0x61(%rbp), %rdi
callq 0x33b0
leaq -0x28(%rbp), %rdi
callq 0xa100
movq %rax, -0x80(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xa250
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0xa220
testb $0x1, %al
jne 0x9811
jmp 0x98af
leaq -0x80(%rbp), %rdi
callq 0xa2a0
movq %rax, %rdi
leaq 0x4cc9(%rip), %rsi      # 0xe4ed
xorl %eax, %eax
movl %eax, %edx
callq 0x3630
cmpq $-0x1, %rax
jne 0x9898
leaq -0x98(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xa130
movq -0x98(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xa350
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x97e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x988a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x31e0
leaq -0x61(%rbp), %rdi
callq 0x33b0
jmp 0x99a5
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0xa2c0
movq %rax, -0xa0(%rbp)
jmp 0x97e8
movb $0x0, -0xa1(%rbp)
movb -0xa1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x98c7
jmp 0x9982
leaq -0xe0(%rbp), %rdi
callq 0x31d0
jmp 0x98d5
movl -0xe0(%rbp), %eax
movl %eax, -0xec(%rbp)
subl $0x100, %eax            # imm = 0x100
je 0x990a
jmp 0x98ea
movl -0xec(%rbp), %eax
subl $0x300, %eax            # imm = 0x300
je 0x9911
jmp 0x9937
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x99a5
xorl %edi, %edi
callq 0x3430
leaq -0xcc(%rbp), %rsi
leaq 0xada9(%rip), %rdi      # 0x146c8
callq 0x9b80
movq %rax, -0xf8(%rbp)
jmp 0x992d
movq -0xf8(%rbp), %rax
movb $0x1, (%rax)
jmp 0x9939
callq 0x88b0
jmp 0x9940
movq -0x8(%rbp), %rsi
movzbl -0x9(%rbp), %r8d
andl $0x1, %r8d
leaq -0x28(%rbp), %rdi
leaq -0xa(%rbp), %rdx
leaq -0xa1(%rbp), %rcx
callq 0x92a0
jmp 0x9963
movl $0x5, %edi
callq 0x3240
jmp 0x996f
movq 0xadba(%rip), %rdi      # 0x14730
callq 0x33f0
jmp 0x997d
jmp 0x98b6
movb -0xa(%rbp), %al
movb %al, -0xf9(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xa150
movb -0xf9(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0xa150
movq -0x70(%rbp), %rdi
callq 0x35c0
nopw (%rax,%rax)