// File: 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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x20, %edi
callq 0x3280
movl $0x400, %edi            # imm = 0x400
movl $0x300, %esi            # imm = 0x300
movl $0x20, %edx
leaq 0x318b0(%rip), %rcx     # 0x547e8
leaq 0x318b1(%rip), %r8      # 0x547f0
callq 0x3110
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
movl $0xff, (%rsp)
movl $0xff000000, 0x8(%rsp)  # imm = 0xFF000000
callq 0x33e0
movq %rax, 0x31884(%rip)     # 0x54800
movq 0x3186d(%rip), %rdi     # 0x547f0
movl $0x16362004, %esi       # imm = 0x16362004
movl $0x1, %edx
movl $0x400, %ecx            # imm = 0x400
movl $0x300, %r8d            # imm = 0x300
callq 0x34f0
movq %rax, 0x31854(%rip)     # 0x547f8
movq 0x3183d(%rip), %rdi     # 0x547e8
leaq -0x4(%rbp), %rsi
leaq -0x8(%rbp), %rdx
callq 0x3400
movl 0xc322(%rip), %edi      # 0x2f2e0
shll $0x7, %edi
movl 0xc319(%rip), %esi      # 0x2f2e0
shll $0x8, %esi
movl $0x20, %edx
leaq 0x31832(%rip), %rcx     # 0x54808
leaq 0x31833(%rip), %r8      # 0x54810
callq 0x3110
movl 0xc2f8(%rip), %esi      # 0x2f2e0
shll $0x7, %esi
movl 0xc2ef(%rip), %edx      # 0x2f2e0
shll $0x8, %edx
xorl %edi, %edi
movl $0x20, %ecx
movl $0xff0000, %r8d         # imm = 0xFF0000
movl $0xff00, %r9d           # imm = 0xFF00
movl $0xff, (%rsp)
movl $0xff000000, 0x8(%rsp)  # imm = 0xFF000000
callq 0x33e0
movq %rax, 0x317fe(%rip)     # 0x54820
movq 0x317e7(%rip), %rdi     # 0x54810
movl 0xc2b1(%rip), %ecx      # 0x2f2e0
shll $0x7, %ecx
movl 0xc2a7(%rip), %r8d      # 0x2f2e0
shll $0x8, %r8d
movl $0x16362004, %esi       # imm = 0x16362004
movl $0x1, %edx
callq 0x34f0
movq %rax, 0x317c5(%rip)     # 0x54818
movq 0x317ae(%rip), %rdi     # 0x54808
movl -0x4(%rbp), %esi
addl $0x400, %esi            # imm = 0x400
addl $0xa, %esi
movl -0x8(%rbp), %edx
callq 0x3050
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)