// File: /workspace/github_cpp_makefile_star2_O3/rockytriton[P]dreamsys_emu_gb/src/ui.cpp
// Function: dsemu::ui::init()
void init() {
    SDL_Init(SDL_INIT_VIDEO);


    SDL_CreateWindowAndRenderer(SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_RESIZABLE, &sdlWindow, &sdlRenderer);

    screen = SDL_CreateRGBSurface(0, SCREEN_WIDTH, SCREEN_HEIGHT, 32,
                                            0x00FF0000,
                                            0x0000FF00,
                                            0x000000FF,
                                            0xFF000000);
    sdlTexture = SDL_CreateTexture(sdlRenderer,
                                                SDL_PIXELFORMAT_ARGB8888,
                                                SDL_TEXTUREACCESS_STREAMING,
                                                SCREEN_WIDTH, SCREEN_HEIGHT);

    int x, y;
    SDL_GetWindowPosition(sdlWindow, &x, &y);

    SDL_CreateWindowAndRenderer(16 * 8 * scale, 32 * 8 * scale, SDL_WINDOW_RESIZABLE, &sdlDebugWindow, &sdlDebugRenderer);

    debugScreen = SDL_CreateRGBSurface(0, 16 * 8 * scale, 32 * 8 * scale, 32,
                                            0x00FF0000,
                                            0x0000FF00,
                                            0x000000FF,
                                            0xFF000000);
    sdlDebugTexture = SDL_CreateTexture(sdlDebugRenderer,
                                                SDL_PIXELFORMAT_ARGB8888,
                                                SDL_TEXTUREACCESS_STREAMING,
                                                16 * 8 * scale, 32 * 8 * scale);

    SDL_SetWindowPosition(sdlDebugWindow, x + SCREEN_WIDTH + 10, y);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl $0x20, %edi
callq 0x3250
leaq 0x2bba7(%rip), %rcx     # 0x3d748
leaq 0x2bba8(%rip), %r8      # 0x3d750
movl $0x400, %edi            # imm = 0x400
movl $0x300, %esi            # imm = 0x300
movl $0x20, %edx
callq 0x3100
movl $0xff000000, %r12d      # imm = 0xFF000000
movl $0xff, %r15d
xorl %edi, %edi
movl $0x400, %esi            # imm = 0x400
movl $0x300, %edx            # imm = 0x300
movl $0x20, %ecx
movl $0xff0000, %r8d         # imm = 0xFF0000
movl $0xff00, %r9d           # imm = 0xFF00
pushq %r12
pushq %r15
callq 0x3350
addq $0x10, %rsp
movq %rax, 0x2bb67(%rip)     # 0x3d760
movq 0x2bb50(%rip), %rdi     # 0x3d750
movl $0x16362004, %esi       # imm = 0x16362004
movl $0x1, %edx
movl $0x400, %ecx            # imm = 0x400
movl $0x300, %r8d            # imm = 0x300
callq 0x3460
movq %rax, 0x2bb37(%rip)     # 0x3d758
movq 0x2bb20(%rip), %rdi     # 0x3d748
leaq 0x4(%rsp), %rbx
movq %rsp, %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3370
movl 0x6623(%rip), %esi      # 0x18264
movl %esi, %edi
shll $0x7, %edi
shll $0x8, %esi
leaq 0x2bb18(%rip), %rcx     # 0x3d768
leaq 0x2bb19(%rip), %r8      # 0x3d770
movl $0x20, %edx
callq 0x3100
movl 0x65fd(%rip), %edx      # 0x18264
movl %edx, %esi
shll $0x7, %esi
shll $0x8, %edx
xorl %edi, %edi
movl $0x20, %ecx
movl $0xff0000, %r8d         # imm = 0xFF0000
movl $0xff00, %r9d           # imm = 0xFF00
pushq %r12
pushq %r15
callq 0x3350
addq $0x10, %rsp
movq %rax, 0x2baea(%rip)     # 0x3d780
movq 0x2bad3(%rip), %rdi     # 0x3d770
movl 0x65c0(%rip), %r8d      # 0x18264
movl %r8d, %ecx
shll $0x7, %ecx
shll $0x8, %r8d
movl $0x16362004, %esi       # imm = 0x16362004
movl $0x1, %edx
callq 0x3460
movq %rax, 0x2bab4(%rip)     # 0x3d778
movq 0x2ba9d(%rip), %rdi     # 0x3d768
movl $0x40a, %esi            # imm = 0x40A
addl (%rbx), %esi
movl (%r14), %edx
callq 0x3060
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq