// File: Alcaro[P]bridges/game.cpp
// Function: (anonymous namespace)::game_impl::title()
void title()
	{
		background();
		
		out.insert_tile_with_border(150, 65, 340, 150, resources::fg0, 3, 37, 4, 36);
		out.insert(200, 285, resources::fg0);
		out.insert(400, 285, resources::fg0);
		out.insert(200, 375, resources::fg0);
		out.insert(400, 375, resources::fg0);
		out.insert_tile(238, 298, 164, 11, resources::bridgeh);
		out.insert_tile(238, 388, 164, 11, resources::bridgeh);
		out.insert_tile(206, 323, 11, 54, resources::bridgev);
		out.insert_tile(224, 323, 11, 54, resources::bridgev);
		out.insert_tile(406, 323, 11, 54, resources::bridgev);
		out.insert_tile(424, 323, 11, 54, resources::bridgev);
		
		uint32_t titlescale = (16 - title_frame/2);
		if ((int32_t)titlescale < 4) titlescale = 4;
		
		static const uint32_t titlewidth = 63;
		static const uint32_t titleheight = 27;
		int titlex = 319-(63*titlescale)/2; // center it as if it's 28px tall with an extra row of empty pixels at the bottom
		int titley = 144-(28*titlescale)/2;
		
		uint32_t* titlepx = resources::title.pixels32;
		for (uint32_t oy=0;oy<titleheight;oy++)
		for (uint32_t ox=0;ox<titlewidth;ox++)
		{
			uint32_t pix = *titlepx++;
			if (pix < 0x80000000) continue; // known bargb
			
			uint32_t x1 = titlex + ox*titlescale;
			uint32_t y1 = titley + oy*titlescale;
			uint32_t x2 = x1 + titlescale;
			uint32_t y2 = y1 + titlescale;
			
			if ((int32_t)x1 < 0) x1 = 0;
			if ((int32_t)y1 < 0) y1 = 0;
			if (x2 > out.width) x2 = out.width;
			if (y2 > out.height) y2 = out.height;
			x2 -= x1;
			y2 -= y1;
			if (x2 > titlescale || y2 > titlescale) continue;
			
			uint32_t* target = out.pixels32 + y1*out.stride/sizeof(uint32_t) + x1;
			
			for (uint32_t iy=0;iy<y2;iy++)
			{
				for (uint32_t ix=0;ix<x2;ix++)
					target[ix] = pix;
				target += out.stride/sizeof(uint32_t);
			}
		}
		
		if (title_frame > 48)
		{
			int fontscale = (8 - (title_frame-48)/2);
			if (fontscale < 2) fontscale = 2;
			resources::smallfont.scale = fontscale;
			
			int textx = 320 - 25*fontscale;
			int texty = 349 - 9*fontscale/2;
			
			resources::smallfont.color = 0x000000;
			resources::smallfont.render(out, textx  , texty+1, "Play Game");
			resources::smallfont.render(out, textx+1, texty  , "Play Game");
			
			resources::smallfont.color = 0xFFFFFF;
			resources::smallfont.render(out, textx  , texty  , "Play Game");
		}
		
		if (title_frame > 60)
		{
			resources::smallfont.scale = 1;
			resources::smallfont.render(out, 198, 196, "keybol 2010");
			resources::smallfont.render(out, 350, 196, "Alcaro 2018-2020");
			
			if (in.mousex > 238 && in.mousex < 406 && in.mousey > 309 && in.mousey < 388)
			{
				// contrary to what this icon implies, the entire map is clickable
				// but it looks nice, so it stays
				out.insert(257, 344, resources::menuchoice);
			}
		}
		else title_frame++;
		
		resources::smallfont.scale = 2;
		
		if (in_press & 1<<k_confirm) to_menu(true);
		if (in_press & 1<<k_click) to_menu(false);
		
		birdfg.draw(out, resources::bird, 0);
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x4ca10
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0x96, %r8d
movl $0x41, %edx
movl $0x154, %ecx            # imm = 0x154
leaq 0x38353(%rip), %r9      # 0x81104
movl %r8d, %esi
movl $0x3, (%rsp)
movl $0x25, 0x8(%rsp)
movl $0x4, 0x10(%rsp)
movl $0x24, 0x18(%rsp)
callq 0x18bb0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0xc8, %esi
movl $0x11d, %edx            # imm = 0x11D
leaq 0x38310(%rip), %rcx     # 0x81104
callq 0x183f0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0x190, %esi            # imm = 0x190
movl $0x11d, %edx            # imm = 0x11D
leaq 0x382ef(%rip), %rcx     # 0x81104
callq 0x183f0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0xc8, %esi
movl $0x177, %edx            # imm = 0x177
leaq 0x382ce(%rip), %rcx     # 0x81104
callq 0x183f0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0x190, %esi            # imm = 0x190
movl $0x177, %edx            # imm = 0x177
leaq 0x382ad(%rip), %rcx     # 0x81104
callq 0x183f0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0xee, %esi
movl $0x12a, %edx            # imm = 0x12A
movl $0xa4, %ecx
movl $0xb, %r8d
leaq 0x38239(%rip), %r9      # 0x810bc
callq 0x186b0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0xee, %esi
movl $0x184, %edx            # imm = 0x184
movl $0xa4, %ecx
movl $0xb, %r8d
leaq 0x3820d(%rip), %r9      # 0x810bc
callq 0x186b0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0xce, %esi
movl $0x143, %edx            # imm = 0x143
movl $0xb, %ecx
movl $0x36, %r8d
leaq 0x381f9(%rip), %r9      # 0x810d4
callq 0x186b0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0xe0, %esi
movl $0x143, %edx            # imm = 0x143
movl $0xb, %ecx
movl $0x36, %r8d
leaq 0x381cd(%rip), %r9      # 0x810d4
callq 0x186b0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0x196, %esi            # imm = 0x196
movl $0x143, %edx            # imm = 0x143
movl $0xb, %ecx
movl $0x36, %r8d
leaq 0x381a1(%rip), %r9      # 0x810d4
callq 0x186b0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0x1a8, %esi            # imm = 0x1A8
movl $0x143, %edx            # imm = 0x143
movl $0xb, %ecx
movl $0x36, %r8d
leaq 0x38175(%rip), %r9      # 0x810d4
callq 0x186b0
movq -0xb8(%rbp), %rax
movl 0x60(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl $0x10, %eax
subl %ecx, %eax
movl %eax, -0xc(%rbp)
cmpl $0x4, -0xc(%rbp)
jge 0x48f8f
movl $0x4, -0xc(%rbp)
imull $0x3f, -0xc(%rbp), %ecx
shrl %ecx
movl $0x13f, %eax            # imm = 0x13F
subl %ecx, %eax
movl %eax, -0x10(%rbp)
imull $0x1c, -0xc(%rbp), %ecx
shrl %ecx
movl $0x90, %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
leaq 0x382fe(%rip), %rax     # 0x812b4
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x1b, -0x24(%rbp)
jae 0x49157
movl $0x0, -0x28(%rbp)
cmpl $0x3f, -0x28(%rbp)
jae 0x49147
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rbp)
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x80000000, -0x2c(%rbp) # imm = 0x80000000
jae 0x49002
jmp 0x49139
movl -0x10(%rbp), %eax
movl -0x28(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x14(%rbp), %eax
movl -0x24(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
addl -0xc(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x4903f
movl $0x0, -0x30(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x4904c
movl $0x0, -0x34(%rbp)
movq -0xb8(%rbp), %rcx
movl -0x38(%rbp), %eax
cmpl 0x28(%rcx), %eax
jbe 0x49068
movq -0xb8(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0xb8(%rbp), %rcx
movl -0x3c(%rbp), %eax
cmpl 0x2c(%rcx), %eax
jbe 0x49084
movq -0xb8(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x30(%rbp), %ecx
movl -0x38(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %ecx
movl -0x3c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
ja 0x490aa
movl -0x3c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jbe 0x490af
jmp 0x49139
movq -0xb8(%rbp), %rdx
movq 0x38(%rdx), %rax
movl -0x34(%rbp), %ecx
imull 0x34(%rdx), %ecx
movl %ecx, %ecx
shrq $0x2, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movl -0x30(%rbp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x49137
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x49112
movl -0x2c(%rbp), %edx
movq -0x48(%rbp), %rax
movl -0x50(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x490f2
movq -0xb8(%rbp), %rax
movl 0x34(%rax), %eax
shrq $0x2, %rax
shlq $0x2, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x490e3
jmp 0x49139
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x48fd6
jmp 0x49149
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x48fc5
movq -0xb8(%rbp), %rax
cmpl $0x30, 0x60(%rax)
jle 0x49334
movq -0xb8(%rbp), %rax
movl 0x60(%rax), %eax
subl $0x30, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl $0x8, %eax
subl %ecx, %eax
movl %eax, -0x54(%rbp)
cmpl $0x2, -0x54(%rbp)
jge 0x49196
movl $0x2, -0x54(%rbp)
movl -0x54(%rbp), %eax
movb %al, %cl
leaq 0x69286(%rip), %rax     # 0xb2428
movb %cl, 0x488(%rax)
imull $0x19, -0x54(%rbp), %ecx
movl $0x140, %eax            # imm = 0x140
subl %ecx, %eax
movl %eax, -0x58(%rbp)
imull $0x9, -0x54(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
movq -0xb8(%rbp), %rax
movl $0x15d, %ecx            # imm = 0x15D
subl %edx, %ecx
movl %ecx, -0x5c(%rbp)
leaq 0x6924c(%rip), %rcx     # 0xb2428
movl $0x0, 0x484(%rcx)
addq $0x28, %rax
movq %rax, -0xe8(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0xe0(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xdc(%rbp)
leaq -0x70(%rbp), %rdi
leaq 0x1cd77(%rip), %rsi     # 0x65f88
callq 0x58c0
movq -0xe8(%rbp), %rsi
movl -0xe0(%rbp), %edx
movl -0xdc(%rbp), %ecx
movq -0x70(%rbp), %r8
movq -0x68(%rbp), %r9
leaq 0x691f0(%rip), %rdi     # 0xb2428
xorps %xmm0, %xmm0
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x473f0
movq -0xb8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0xd8(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0xcc(%rbp)
leaq -0x80(%rbp), %rdi
leaq 0x1cd0d(%rip), %rsi     # 0x65f88
callq 0x58c0
movq -0xd8(%rbp), %rsi
movl -0xd0(%rbp), %edx
movl -0xcc(%rbp), %ecx
movq -0x80(%rbp), %r8
movq -0x78(%rbp), %r9
leaq 0x69186(%rip), %rdi     # 0xb2428
xorps %xmm0, %xmm0
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x473f0
movq -0xb8(%rbp), %rax
leaq 0x69167(%rip), %rcx     # 0xb2428
movl $0xffffff, 0x484(%rcx)  # imm = 0xFFFFFF
addq $0x28, %rax
movq %rax, -0xc8(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0xc0(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0xbc(%rbp)
leaq -0x90(%rbp), %rdi
leaq 0x1cc92(%rip), %rsi     # 0x65f88
callq 0x58c0
movq -0xc8(%rbp), %rsi
movl -0xc0(%rbp), %edx
movl -0xbc(%rbp), %ecx
movq -0x90(%rbp), %r8
movq -0x88(%rbp), %r9
leaq 0x69105(%rip), %rdi     # 0xb2428
xorps %xmm0, %xmm0
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x473f0
movq -0xb8(%rbp), %rax
cmpl $0x3c, 0x60(%rax)
jle 0x4946e
movq -0xb8(%rbp), %rax
leaq 0x690d5(%rip), %rcx     # 0xb2428
movb $0x1, 0x488(%rcx)
addq $0x28, %rax
movq %rax, -0xf8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq 0x1cc1f(%rip), %rsi     # 0x65f92
callq 0x58c0
movq -0xf8(%rbp), %rsi
movq -0xa0(%rbp), %r8
movq -0x98(%rbp), %r9
leaq 0x69094(%rip), %rdi     # 0xb2428
movl $0xc6, %edx
movl $0xc4, %ecx
xorps %xmm0, %xmm0
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x473f0
movq -0xb8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0xf0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq 0x1cbcf(%rip), %rsi     # 0x65f9e
callq 0x58c0
movq -0xf0(%rbp), %rsi
movq -0xb0(%rbp), %r8
movq -0xa8(%rbp), %r9
leaq 0x69038(%rip), %rdi     # 0xb2428
movl $0x15e, %edx            # imm = 0x15E
movl $0xc4, %ecx
xorps %xmm0, %xmm0
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x473f0
movq -0xb8(%rbp), %rax
cmpl $0xee, 0x8(%rax)
jle 0x4946c
movq -0xb8(%rbp), %rax
cmpl $0x196, 0x8(%rax)       # imm = 0x196
jge 0x4946c
movq -0xb8(%rbp), %rax
cmpl $0x135, 0xc(%rax)       # imm = 0x135
jle 0x4946c
movq -0xb8(%rbp), %rax
cmpl $0x184, 0xc(%rax)       # imm = 0x184
jge 0x4946c
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movl $0x101, %esi            # imm = 0x101
movl $0x158, %edx            # imm = 0x158
leaq 0x37d8d(%rip), %rcx     # 0x811f4
callq 0x183f0
jmp 0x4947e
movq -0xb8(%rbp), %rax
movl 0x60(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x60(%rax)
movq -0xb8(%rbp), %rax
leaq 0x68f9c(%rip), %rcx     # 0xb2428
movb $0x2, 0x488(%rcx)
movzbl 0x20(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x494b0
movq -0xb8(%rbp), %rdi
movl $0x1, %esi
callq 0x4cb30
movq -0xb8(%rbp), %rax
movzbl 0x20(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x494d1
movq -0xb8(%rbp), %rdi
xorl %esi, %esi
callq 0x4cb30
movq -0xb8(%rbp), %rsi
movq %rsi, %rdi
addq $0x50, %rdi
addq $0x28, %rsi
leaq 0x37bba(%rip), %rdx     # 0x810a4
xorl %ecx, %ecx
callq 0x4cb70
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)