// File: tjohnman[P]sfxr-sdl2/build/../src/main.cpp
// Function: ddkInit()
void ddkInit()
{
	srand(time(NULL));

	ddkSetMode(640,480, DDK_WINDOW, "sfxr"); // requests window size etc from ddrawkit

	if (LoadTGA(font, "/usr/local/share/sfxr/images/font.tga")) {
        	/* Try again in cwd */
		if (LoadTGA(font, "images/font.tga")) {
			fprintf(stderr,
				"Error could not open /usr/local/share/sfxr/images/font.tga"
				" nor images/font.tga\n");
			exit(1);
		}
	}

	if (LoadTGA(ld48, "/usr/local/share/sfxr/images/ld48.tga")) {
        	/* Try again in cwd */
		if (LoadTGA(ld48, "images/ld48.tga")) {
			fprintf(stderr,
				"Error could not open /usr/local/share/sfxr/images/ld48.tga"
				" nor images/ld48.tga\n");
			exit(1);
		}
	}

	ld48.width=ld48.pitch;

	input=new DPInput;

	strcpy(categories[0].name, "PICKUP/COIN");
	strcpy(categories[1].name, "LASER/SHOOT");
	strcpy(categories[2].name, "EXPLOSION");
	strcpy(categories[3].name, "POWERUP");
	strcpy(categories[4].name, "HIT/HURT");
	strcpy(categories[5].name, "JUMP");
	strcpy(categories[6].name, "BLIP/SELECT");

	ResetParams();

	SDL_AudioSpec des;
	des.freq = 44100;
	des.format = AUDIO_S16SYS;
	des.channels = 1;
	des.samples = 512;
	des.callback = SDLAudioCallback;
	des.userdata = NULL;
	VERIFY(!SDL_OpenAudio(&des, NULL));
	SDL_PauseAudio(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
xorl %eax, %eax
movl %eax, %edi
callq 0x3300
movl %eax, %edi
callq 0x3320
movl $0x280, %edi            # imm = 0x280
movl $0x1e0, %esi            # imm = 0x1E0
xorl %edx, %edx
leaq 0x6423(%rip), %rcx      # 0xe4ee
callq 0x8a80
leaq 0xb291(%rip), %rdi      # 0x13368
leaq 0x6252(%rip), %rsi      # 0xe330
callq 0xca30
cmpl $0x0, %eax
je 0x8124
leaq 0xb279(%rip), %rdi      # 0x13368
leaq 0x6250(%rip), %rsi      # 0xe346
callq 0xca30
cmpl $0x0, %eax
je 0x8122
movq 0xaed1(%rip), %rax      # 0x12fd8
movq (%rax), %rdi
leaq 0x6245(%rip), %rsi      # 0xe356
movb $0x0, %al
callq 0x34d0
movl $0x1, %edi
callq 0x3430
jmp 0x8124
leaq 0xb255(%rip), %rdi      # 0x13380
leaq 0x6274(%rip), %rsi      # 0xe3a6
callq 0xca30
cmpl $0x0, %eax
je 0x8178
leaq 0xb23d(%rip), %rdi      # 0x13380
leaq 0x6272(%rip), %rsi      # 0xe3bc
callq 0xca30
cmpl $0x0, %eax
je 0x8176
movq 0xae7d(%rip), %rax      # 0x12fd8
movq (%rax), %rdi
leaq 0x6267(%rip), %rsi      # 0xe3cc
movb $0x0, %al
callq 0x34d0
movl $0x1, %edi
callq 0x3430
jmp 0x8178
movl 0xb212(%rip), %eax      # 0x13390
movl %eax, 0xb204(%rip)      # 0x13388
movl $0x1, %edi
callq 0x3350
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x38(%rbp)
callq 0x8570
jmp 0x819f
movq -0x38(%rbp), %rax
movq %rax, 0xc4f6(%rip)      # 0x146a0
leaq 0xb1ef(%rip), %rdi      # 0x133a0
leaq 0x6264(%rip), %rsi      # 0xe41c
callq 0x3310
leaq 0xb1fc(%rip), %rdi      # 0x133c0
leaq 0x625d(%rip), %rsi      # 0xe428
callq 0x3310
leaq 0xb209(%rip), %rdi      # 0x133e0
leaq 0x6256(%rip), %rsi      # 0xe434
callq 0x3310
leaq 0xb216(%rip), %rdi      # 0x13400
leaq 0x624d(%rip), %rsi      # 0xe43e
callq 0x3310
leaq 0xb223(%rip), %rdi      # 0x13420
leaq 0x6242(%rip), %rsi      # 0xe446
callq 0x3310
leaq 0xb230(%rip), %rdi      # 0x13440
leaq 0x6238(%rip), %rsi      # 0xe44f
callq 0x3310
leaq 0xb23d(%rip), %rdi      # 0x13460
leaq 0x622a(%rip), %rsi      # 0xe454
callq 0x3310
callq 0x38e0
movl $0xac44, -0x30(%rbp)    # imm = 0xAC44
movw $0x8010, -0x2c(%rbp)    # imm = 0x8010
movb $0x1, -0x2a(%rbp)
movw $0x200, -0x28(%rbp)     # imm = 0x200
leaq 0x6e(%rip), %rax        # 0x82c0
movq %rax, -0x20(%rbp)
movq $0x0, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3540
cmpl $0x0, %eax
je 0x82a6
leaq 0x61e9(%rip), %rdi      # 0xe460
movl $0x557, %esi            # imm = 0x557
leaq 0x61ed(%rip), %rdx      # 0xe470
callq 0x8830
jmp 0x82a6
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x8(%rbp)
movl %eax, -0xc(%rbp)
movl $0x1, %esi
callq 0x3360
jmp 0x82b5
jmp 0x82a8
xorl %edi, %edi
callq 0x3260
addq $0x40, %rsp
popq %rbp
retq
movq -0x8(%rbp), %rdi
callq 0x35c0
nop