Example #1
0
    def create(self):
        self.noeWnd = noewin.NoeUserWindow("Load Ghost Recon qob model",
                                           "openModelWindowClass", 385, 120)
        noeWindowRect = noewin.getNoesisWindowRect()

        if noeWindowRect:
            windowMargin = 100
            self.noeWnd.x = noeWindowRect[0] + windowMargin
            self.noeWnd.y = noeWindowRect[1] + windowMargin

        if self.noeWnd.createWindow():
            self.noeWnd.setFont("Arial", 12)

            self.noeWnd.createStatic("Path to texture folder", 5, 5, 180, 20)
            # choose path to textures
            index = self.noeWnd.createEditBox(5, 28, 275, 20, "", None, False,
                                              False)
            self.texturePathEditBox = self.noeWnd.getControlByIndex(index)

            self.noeWnd.createButton("Open", 290, 27, 80, 21,
                                     self.buttonGetTexturePathOnClick)

            self.noeWnd.createButton("Load", 5, 60, 80, 30,
                                     self.buttonLoadOnClick)
            self.noeWnd.createButton("Cancel", 90, 60, 80, 30,
                                     self.buttonCancelOnClick)

            self.noeWnd.doModal()
Example #2
0
def ToolMethod(toolIndex):
    noeWnd = noewin.NoeUserWindow("Driver San Francisco Importer", "convert",
                                  500, 300)

    noeWindowRect = noewin.getNoesisWindowRect()
    if noeWindowRect:
        windowMargin = 64
        noeWnd.x = noeWindowRect[0] + windowMargin
        noeWnd.y = noeWindowRect[1] + windowMargin
    if not noeWnd.createWindow():
        print("Failed to create window.")
        return 0

    noeWnd.setFont("Arial", 14)

    buttonExportCar = noeWnd.createButton("Export .VEHC", 10, 225, 96, 32,
                                          ExportCar)
    buttonExport = noeWnd.getControlByIndex(buttonExportCar)

    buttonLoadModel = noeWnd.createButton("Load Selected", 252, 225, 126, 32,
                                          LoadModel)
    buttonLoad = noeWnd.getControlByIndex(buttonLoadModel)

    buttonExportAll = noeWnd.createButton("Export All", 116, 225, 126, 32,
                                          ExportAll)
    buttonAll = noeWnd.getControlByIndex(buttonExportAll)

    global listBox
    listIndex = noeWnd.createListBox(10, 22, 480, 220, None, noewin.LBS_NOTIFY)
    listBox = noeWnd.getControlByIndex(listIndex)
    return 0
Example #3
0
def doombaToolMethod(toolIndex):
    noeRoombaPath = noesis.getSelectedFile()
    with open(noeRoombaPath, "rb") as f:
        noeRoombaData = f.read()

    noeWnd = noewin.NoeUserWindow("DOOMBA", "DoombaWindowClass", 1320, 800)
    setDefaultWindowPos(noeWnd)
    noeWnd.noeRoombaPath = noeRoombaPath
    noeWnd.noeRoombaData = noeRoombaData
    if noeWnd.createWindow():
        noeWnd.setFont("Arial", 14)

        startX = 16
        startY = 90
        currentCatType = DOOMBA_CATEGORY_SOURCES[0].catType
        noeWnd.cats = []
        for catSource in DOOMBA_CATEGORY_SOURCES:
            if currentCatType != catSource.catType:
                currentCatType = catSource.catType
                startY += 150
                startX = 16
            noeWnd.cats.append(DoombaCat(noeWnd, catSource, startX, startY))
            startX += 260

        noeWnd.createStatic("Seed:", 16, 48, 40, 20)
        noeWnd.seedBoxIndex = noeWnd.createEditBox(58, 46, 120, 20, "0", None,
                                                   False)

        noeWnd.createButton("Generate", 16, 16, 96, 24, buttonGenerateMethod)

        noeWnd.createStatic("Floors:", 16, 552, 60, 20)
        noeWnd.floorBoxIndex = noeWnd.createEditBox(
            16, 574, 200, 170, " ".join(DOOMBA_DEFAULT_FLOORS))

        noeWnd.createStatic("Ceilings:", 232, 552, 60, 20)
        noeWnd.ceilBoxIndex = noeWnd.createEditBox(
            232, 574, 200, 170, " ".join(DOOMBA_DEFAULT_CEILS))

        noeWnd.createStatic("Walls:", 448, 552, 60, 20)
        noeWnd.wallBoxIndex = noeWnd.createEditBox(
            448, 574, 200, 170, " ".join(DOOMBA_DEFAULT_WALLS))

        defaultGenParams = "FloorMin=-24 FloorMax=0 CeilMin=110 CeilMax=140 ObstacleFloorMin=12 ObstacleFloorMax=30 LightMin=128 LightMax=248 RoomToDoomScale=1.0 RoomToDoomOffset=0,0 LightProb=20 EnforceViewPref=0 ExitRandom=1 WallSwitchExit=0 IslandTeleports=0 IslandCircular=0"
        noeWnd.createStatic("Generation:", 680, 544, 100, 20)
        noeWnd.genBoxIndex = noeWnd.createEditBox(680, 566, 610, 80,
                                                  defaultGenParams)

        defaultAdvParams = "MapName=E1M1 ExitHeight=12 ExitTexture=GATE3 WallSwitchExitTexture=SW1STON1 WallSwitchExitSize=64 ExitSepThresh=150 ExitCloserScale=0.75 ExitSnap=64 ExitSize=32 AreaMin=100000 AreaMax=200000 CollapseDistance=3.0 AltSampling=0 HardeningValue=-1 SampleExponent=2.0 SampleRad=32 MapShift=2 OccShift=2"
        noeWnd.createStatic("Advanced:", 680, 652, 100, 20)
        noeWnd.advBoxIndex = noeWnd.createEditBox(680, 674, 610, 80,
                                                  defaultAdvParams)

        noeWnd.doModal()
    return 0
Example #4
0
    def create(self):
        self.noeWnd = noewin.NoeUserWindow("Import options", "HTRAWWindowClass", \
            286, 180)
        noeWindowRect = noewin.getNoesisWindowRect()

        if noeWindowRect:
            windowMargin = 100
            self.noeWnd.x = noeWindowRect[0] + windowMargin
            self.noeWnd.y = noeWindowRect[1] + windowMargin

        if self.noeWnd.createWindow():
            self.noeWnd.setFont("Arial", 12)

            self.noeWnd.createStatic("Height coefficient:", 5, 7, 120, 20)
            #
            index = self.noeWnd.createEditBox(110, 5, 70, 20, None, 0)
            self.heightEdit = self.noeWnd.getControlByIndex(index)
            self.heightEdit.setText(str(DEFAULT_HEIGHT_COEFF))

            self.noeWnd.createStatic("Sand level:", 43, 32, 120, 20)
            #
            index = self.noeWnd.createEditBox(110, 30, 70, 20, None, 0)
            self.levelEdit = self.noeWnd.getControlByIndex(index)
            self.levelEdit.setText(str(DEFAULT_SAND_LEVEL))

            self.noeWnd.createStatic("Scale:", 69, 57, 120, 20)
            #
            index = self.noeWnd.createEditBox(110, 55, 70, 20, None, 0)
            self.scaleEdit = self.noeWnd.getControlByIndex(index)
            self.scaleEdit.setText(str(DEFAULT_SCALE))

            index = self.noeWnd.createCheckBox("add textures", 5, 80, \
                 135, 20)
            self.texturesCheckBox = self.noeWnd.getControlByIndex(index)
            self.texturesCheckBox.setChecked(1)

            self.noeWnd.createStatic("uTile:", 72, 107, 70, 20)
            self.noeWnd.createStatic("vTile:", 74, 130, 70, 20)
            #
            index = self.noeWnd.createEditBox(110, 105, 70, 20, None, 0)
            self.utileEdit = self.noeWnd.getControlByIndex(index)
            self.utileEdit.setText(str(DEFAULT_UTILE))
            index = self.noeWnd.createEditBox(110, 130, 70, 20, None, 0)
            self.vtileEdit = self.noeWnd.getControlByIndex(index)
            self.vtileEdit.setText(str(DEFAULT_VTILE))

            self.noeWnd.createButton("Import", 190, 5, 80, 30, \
                 self.openOptionsButtonImport)
            self.noeWnd.createButton("Cancel", 190, 40, 80, 30, \
                 self.openOptionsButtonCancel)

            self.noeWnd.doModal()
Example #5
0
    def show(self):
        self.noeWnd = noewin.NoeUserWindow("Export options", "HTWindowClass", \
            300, 155)
        noeWindowRect = noewin.getNoesisWindowRect()

        if noeWindowRect:
            windowMargin = 64
            self.noeWnd.x = noeWindowRect[0] + windowMargin
            self.noeWnd.y = noeWindowRect[1] + windowMargin

        if self.noeWnd.createWindow():
            self.noeWnd.setFont("Arial", 12)

            self.noeWnd.createStatic("Choose format:", 5, 5, 160, 20)
            # choose game list
            index = self.noeWnd.createListBox(5, 25, 184, 47, None, 0)
            self.typeListBox = self.noeWnd.getControlByIndex(index)

            typeList = ("Format RGB565", "Format RGBA5551")

            for type in typeList:
                self.typeListBox.addString(type)

            self.typeListBox.selectString(typeList[0])

            self.noeWnd.createStatic("Number of 16 bit images:", 5, 70, 169,
                                     20)
            # choose format combobox
            index = self.noeWnd.createComboBox(160, 65, 30, 20)
            self.mmcountComboBox = self.noeWnd.getControlByIndex(index)

            self.noeWnd.createStatic("Number of paletted images:", 5, 98, 169,
                                     20)
            # choose format combobox
            index = self.noeWnd.createComboBox(160, 95, 30, 20)
            self.palcountComboBox = self.noeWnd.getControlByIndex(index)

            countList = ("6", "5", "4", "3", "2", "1", "0")

            for count in countList:
                self.mmcountComboBox.addString(count)
                self.palcountComboBox.addString(count)

            self.mmcountComboBox.selectString(countList[0])
            self.palcountComboBox.selectString(countList[0])

            self.noeWnd.createButton("Export", 210, 25, 80, 30, \
                 self.exportOptionsButtonExport)
            self.noeWnd.createButton("Cancel", 210, 60, 80, 30, \
                 self.exportOptionsButtonCancel)

            self.noeWnd.doModal()
Example #6
0
    def create(self):
        self.noeWnd = noewin.NoeUserWindow( \
            "Hard Truck archive packer (.res, .rmp)", "HTPackerWindowClass", \
            420, 255)
        noeWindowRect = noewin.getNoesisWindowRect()

        if noeWindowRect:
            windowMargin = 100
            self.noeWnd.x = noeWindowRect[0] + windowMargin
            self.noeWnd.y = noeWindowRect[1] + windowMargin

        if self.noeWnd.createWindow():
            self.noeWnd.setFont("Arial", 12)

            self.noeWnd.createStatic("File path:", 5, 5, 50, 20)
            #
            index = self.noeWnd.createEditBox(60, 5, 350, 20, "", None, \
                False, True)
            self.pathEdit = self.noeWnd.getControlByIndex(index)
            self.pathEdit.setText(self.filename)

            self.noeWnd.createStatic("Exten.:", 5, 32, 110, 20)
            #
            index = self.noeWnd.createComboBox(60, 32, 130, 20)
            self.extComboBox = self.noeWnd.getControlByIndex(index)

            extList = ("", "Hard Truck 1 (.rmp)", "Hard Truck 2 (.res)")

            for extension in extList:
                self.extComboBox.addString(extension)

            self.extComboBox.selectString(extList[0])

            self.noeWnd.createStatic("Output:", 5, 65, 60, 20)
            #
            index = self.noeWnd.createEditBox(60, 65, 350, 120, "", None, \
                True, True)
            self.outputEdit = self.noeWnd.getControlByIndex(index)

            self.noeWnd.createButton("Check files", 60, 195, 80, 30, \
                 self.archivePackerButtonCheck)
            self.noeWnd.createButton("Pack archive", 145, 195, 80, 30, \
                 self.archivePackerButtonPack)
            self.noeWnd.createButton("Cancel", 330, 195, 80, 30, \
                 self.archivePackerButtonCancel)

            self.packer = htArchivePacker(self.filename)

            self.noeWnd.doModal()
Example #7
0
    def show(self):
        self.noeWnd = noewin.NoeUserWindow("Export options", "HTWindowClass", \
            300, 150)
        noeWindowRect = noewin.getNoesisWindowRect()

        if noeWindowRect:
            windowMargin = 64
            self.noeWnd.x = noeWindowRect[0] + windowMargin
            self.noeWnd.y = noeWindowRect[1] + windowMargin

        if self.noeWnd.createWindow():
            self.noeWnd.setFont("Arial", 12)

            self.noeWnd.createStatic("Choose game:", 5, 5, 160, 20)
            # choose game list
            index = self.noeWnd.createListBox(5, 25, 200, 47, None, 0)
            self.gameListBox = self.noeWnd.getControlByIndex(index)

            gameList = ("Hard Truck 1 (1.4)", "Hard Truck 2 (7.0 - 8.0)")

            for game in gameList:
                self.gameListBox.addString(game)

            self.gameListBox.selectString(gameList[1])

            self.noeWnd.createStatic("Choose format:", 5, 70, 110, 20)
            # choose format combobox
            index = self.noeWnd.createComboBox(100, 67, 95, 20)
            self.formatComboBox = self.noeWnd.getControlByIndex(index)

            formatList = ("BGR 565", "BGRA 4444", "BGRA 5551")

            for format in formatList:
                self.formatComboBox.addString(format)

            self.formatComboBox.selectString(formatList[2])

            index = self.noeWnd.createCheckBox("generate mip-maps", 5, 95, \
                 135, 20)
            self.mipmapsCheckBox = self.noeWnd.getControlByIndex(index)
            #self.mipmapsCheckBox.setChecked(1)

            self.noeWnd.createButton("Export", 210, 25, 80, 30, \
                 self.exportOptionsButtonExport)
            self.noeWnd.createButton("Cancel", 210, 60, 80, 30, \
                 self.exportOptionsButtonCancel)

            self.noeWnd.doModal()
Example #8
0
    def create(self):
        self.noeWnd = noewin.NoeUserWindow("Load Ghost Recon character model",
                                           "openModelWindowClass", 430, 405)
        noeWindowRect = noewin.getNoesisWindowRect()

        if noeWindowRect:
            windowMargin = 100
            self.noeWnd.x = noeWindowRect[0] + windowMargin
            self.noeWnd.y = noeWindowRect[1] + windowMargin

        if self.noeWnd.createWindow():
            self.noeWnd.setFont("Arial", 14)

            self.noeWnd.createStatic("Path to texture folder", 5, 5, 140, 20)
            #
            index = self.noeWnd.createEditBox(5, 24, 330, 40, "", None, True)
            self.texturePathEditBox = self.noeWnd.getControlByIndex(index)

            self.noeWnd.createButton("Open", 340, 24, 80, 21,
                                     self.buttonGetTexturePathOnClick)

            self.noeWnd.createStatic("Path to actor (.act) file", 5, 70, 140,
                                     20)
            #
            index = self.noeWnd.createEditBox(5, 90, 330, 40, "", None, True)
            self.actorFileNameEditBox = self.noeWnd.getControlByIndex(index)
            self.noeWnd.createButton("Open", 340, 90, 80, 21,
                                     self.buttonGetActorFileNameOnClick)

            self.noeWnd.createStatic("Path to .bmf files", 5, 140, 140, 20)
            #
            index = self.noeWnd.createEditBox(5, 160, 330, 20, "", None, False,
                                              False)
            self.bmfPathEditBox = self.noeWnd.getControlByIndex(index)
            self.noeWnd.createButton("Open", 340, 160, 80, 21,
                                     self.buttonGetAnimationListOnClick)

            self.noeWnd.createStatic("Animations:", 5, 190, 80, 20)
            index = self.noeWnd.createListBox(5, 210, 330, 175)
            self.animationListBox = self.noeWnd.getControlByIndex(index)

            self.noeWnd.createButton("Load", 340, 310, 80, 30,
                                     self.buttonLoadOnClick)
            self.noeWnd.createButton("Cancel", 340, 345, 80, 30,
                                     self.buttonCancelOnClick)

            self.noeWnd.doModal()
Example #9
0
def roombaToolMethod(toolIndex):
    noeWnd = noewin.NoeUserWindow("Roomba Tracker", "RoombaWindowClass", 644,
                                  750, roombaWindowProc)
    setDefaultWindowPos(noeWnd)
    if not noesis.getWindowHandle():
        #if invoked via ?runtool, we're our own entity
        noeWnd.exStyle = noewin.WS_EX_DLGMODALFRAME
        noeWnd.style |= noewin.WS_MINIMIZEBOX | noewin.WS_MAXIMIZEBOX
        noeWnd.userIcon = user32.LoadIconW(kernel32.GetModuleHandleW(0),
                                           noesis.getResourceHandle(0))
    if noeWnd.createWindow():
        noeWnd.hCanvasBmp = None
        noeWnd.dumpFile = None
        createInterfaceWindow(noeWnd)
        loadWindowPrefs(noeWnd)
        noeWnd.doModal()
        closeDumpFile(noeWnd)
        closeExistingMqtt(noeWnd)
        destroyCanvasObjects(noeWnd)

    return 0
Example #10
0
def neoPickToolMethod(toolIndex):
    filePath = noesis.getSelectedFile()
    nameNoExt, ext = os.path.splitext(filePath)
    neoPickPath = nameNoExt + "_neoPick" + ext

    noeMod = noesis.instantiateModule()
    noesis.setModuleRAPI(noeMod)

    with open(filePath, "rb") as f:
        data = f.read()

    noeWndWidth = 1280
    noeWndHeight = 800
    noeWndPad = 64
    noeWnd = noewin.NoeUserWindow("NEOpicker", "NeoPickerWindowClass",
                                  noeWndWidth + noeWndPad,
                                  noeWndHeight + noeWndPad, neoPickWindowProc)
    noeWnd.showClipped = False
    noeWnd.drawWidth = noeWndWidth
    noeWnd.drawHeight = noeWndHeight
    noeWnd.imgCoordX = 0
    noeWnd.imgCoordY = 0
    noeWnd.clipAddrs = set([])
    noeWnd.pickPath = neoPickPath

    if neoPickAttachNeoToNoeWnd(noeWnd, data):
        noeWnd.originalData = data
        #offset a bit into the noesis window
        noeWindowRect = noewin.getNoesisWindowRect()
        if noeWindowRect:
            windowMargin = 64
            noeWnd.x = noeWindowRect[0] + windowMargin
            noeWnd.y = noeWindowRect[1] + windowMargin
        if noeWnd.createWindow():
            noeWnd.doModal()

    noesis.freeModule(noeMod)

    return 0
Example #11
0
    def create(self):   
        self.noeWnd = noewin.NoeUserWindow( \
            "Load cyclone model file", "openModelWindowClass", 385, 195) 
        noeWindowRect = noewin.getNoesisWindowRect()
        
        if noeWindowRect:
            windowMargin = 100
            self.noeWnd.x = noeWindowRect[0] + windowMargin
            self.noeWnd.y = noeWindowRect[1] + windowMargin   
            
        if self.noeWnd.createWindow():
            self.noeWnd.setFont("Arial", 12)    
            
            self.noeWnd.createStatic("Textures path:", 5, 5, 110, 20)
            # choose path to textures          
            index = self.noeWnd.createEditBox(5, 28, 275, 20, "", None, False, True)
            self.texPathEditBox = self.noeWnd.getControlByIndex(index) 

            # extenstion   
            self.noeWnd.createStatic("extension:", 170, 5, 60, 20)
            index = self.noeWnd.createEditBox(240, 5, 40, 20, "", None, False)
            self.extEditBox = self.noeWnd.getControlByIndex(index) 
            self.extEditBox.setText("tf")            
            
            self.noeWnd.createStatic("Frame:", 5, 57, 80, 20)
            # choose frame number          
            index = self.noeWnd.createEditBox(55, 55, 80, 20, "", None, False)
            self.frameEditBox = self.noeWnd.getControlByIndex(index)
            self.frameEditBox.setText("0") 

            self.noeWnd.createStatic("LOD:", 160, 57, 80, 20)
            # choose lod          
            index = self.noeWnd.createEditBox(200, 55, 80, 20, "", None, False)
            self.lodEditBox = self.noeWnd.getControlByIndex(index)
            self.lodEditBox.setText("0")  

            # model info   
            self.noeWnd.createStatic("lods:", 5, 85, 130, 20)
            index = self.noeWnd.createEditBox(60, 85, 50, 20, "", None, False, True)
            self.lodCountEditBox = self.noeWnd.getControlByIndex(index) 
            self.lodCountEditBox.setText(str(self.model.modelCount))
            
            self.noeWnd.createStatic("textures:", 5, 105, 130, 20) 
            index = self.noeWnd.createEditBox(60, 105, 50, 20, "", None, False, True)
            self.textureCountEditBox = self.noeWnd.getControlByIndex(index)  
            self.textureCountEditBox.setText(str(self.model.textureCount))
            
            self.noeWnd.createStatic("meshes:", 145, 85, 130, 20) 
            index = self.noeWnd.createEditBox(200, 85, 50, 20, "", None, False, True)
            self.meshCountEditBox = self.noeWnd.getControlByIndex(index)  
            self.meshCountEditBox.setText(str(len(self.model.lods[0].meshes)))
            
            self.noeWnd.createStatic("frames:", 145, 105, 130, 20)             
            index = self.noeWnd.createEditBox(200, 105, 50, 20, "", None, False, True)
            self.frameCountEditBox = self.noeWnd.getControlByIndex(index)                    
            self.frameCountEditBox.setText(str(self.model.frameCount))
            
            self.noeWnd.createButton("Open", 290, 27, 80, 21, \
                 self.sdmodelViewButtonGetPath)                     
            self.noeWnd.createButton("Load", 5, 135, 80, 30, \
                 self.sdmodelViewButtonLoad)
            self.noeWnd.createButton("Cancel", 90, 135, 80, 30, \
                 self.sdmodelViewButtonCancel)
                 
            self.noeWnd.doModal()                  
Example #12
0
def f2aToolMethod(toolIndex):
    noesis.logPopup()
    handle = noesis.usbOpenDevice(F2A_DEVINTGUID, F2A_CLASSGUID)

    riskIt = (user32.MessageBoxW(
        noesis.getWindowHandle(),
        "Found what appears to be the target F2A device. However, if this is not the correct device, the device could be damaged. Are you sure you want to continue?",
        "F2A Interface", noewin.MB_YESNO) == noewin.IDYES)
    if riskIt:
        if noesis.usbGetEndpointCount(handle) == 0:
            #try uploading the ez-usb firmware, then reconnect
            print(
                "Endpoint count is 0, attempting vendor-specific EZ-USB FW upload."
            )

            #usbControlTransfer params = handle, data, requestType, request, index, value
            noesis.usbControlTransfer(handle, bytearray([0x01]), 0x40, 0xA0, 0,
                                      0x7F92)

            fw = loadBin(F2A_EZUSBFW)
            chunkSize = 512
            for offset in range(0, len(fw) // chunkSize):
                chunkData = fw[offset * chunkSize:offset * chunkSize +
                               chunkSize]
                noesis.usbControlTransfer(handle, chunkData, 0x40, 0xA0, 0,
                                          offset * chunkSize)

            #upload complete
            noesis.usbControlTransfer(handle, bytearray([0x00]), 0x40, 0xA0, 0,
                                      0x7F92)

            time.sleep(1)
            noesis.usbCloseDevice(handle)
            handle = None

            #spin here for a bit - uploading the firmware effectively reconnects the device with a different interface,
            #so it may take a little while for Windows to prepare it again.
            for attemptCount in range(0, F2A_RECONNECT_LIMIT):
                try:
                    handle = noesis.usbOpenDevice(F2A_DEVINTGUID,
                                                  F2A_CLASSGUID)
                    print("Successfully re-opened device.")
                    break
                except:
                    print(
                        "Cannot re-open device. Waiting before trying again.")
                    time.sleep(3)

        if handle is None:
            noesis.messagePrompt(
                "Could not re-establish connection to device. Aborting.")
        elif noesis.usbGetEndpointCount(handle) != 5:
            noesis.messagePrompt(
                "The device does not have the expected number of endpoints. Aborting."
            )
        else:
            noesis.usbSetEndpointTimeoutId(handle, F2A_EP_WRITE,
                                           F2A_EP_TIMEOUT)
            noesis.usbSetEndpointTimeoutId(handle, F2A_EP_READ, F2A_EP_TIMEOUT)

            response = getDeviceStatus(handle)
            while response[0] != F2A_STATUS_NOTREADY:
                tryAgain = (user32.MessageBoxW(
                    noesis.getWindowHandle(),
                    "Your GBA must be turned off to continue. Ready to try again?",
                    "F2A Interface", noewin.MB_YESNO) == noewin.IDYES)
                if not tryAgain:
                    break
                response = getDeviceStatus(handle)
            if response[0] == F2A_STATUS_NOTREADY:
                mb = loadBin(F2A_MULTIBOOT)

                bootCmd = F2ACommand()

                #if we don't do this bit, the linker gets angry again and stops accepting writes. particular to my hardware/firmware?
                bootCmd.fromBytes(response)
                bootCmd.command |= F2A_CMD_GETINF  #keep the high bytes from the response data
                noesis.usbWriteEndpointId(handle, F2A_EP_WRITE,
                                          bootCmd.getBytes())
                response = noesis.usbReadEndpointId(handle, F2A_EP_READ,
                                                    F2A_RESPONSE_SIZE)

                noesis.usbSetEndpointTimeoutId(handle, F2A_EP_WRITE,
                                               F2A_EP_BOOTWAIT_TIMEOUT)

                readyToGo = (user32.MessageBoxW(
                    noesis.getWindowHandle(),
                    "After continuing (do not turn the GBA on before proceeding), you will connect your GBA, turn it on, and hold start+select during startup. Are you ready?",
                    "F2A Interface", noewin.MB_YESNO) == noewin.IDYES)
                if readyToGo:  #make sure they didn't turn it on prematurely
                    response = getDeviceStatus(handle)
                    if response[0] == F2A_STATUS_READY:
                        readyToGo = False
                        noesis.messagePrompt(
                            "You turned the GBA on prematurely. Aborting.")

                if readyToGo:
                    #spin until we detect the GBA is on, then take a run at it
                    response = getDeviceStatus(handle)
                    while response[0] != F2A_STATUS_READY:
                        time.sleep(0.1)
                        response = getDeviceStatus(handle)

                    bootCmd.command = F2A_CMD_MULTIBOOT1
                    bootCmd.dataSize = 0
                    bootCmd.reserved0 &= ~255
                    noesis.usbWriteEndpointId(handle, F2A_EP_WRITE,
                                              bootCmd.getBytes())
                    bootCmd.command = F2A_CMD_MULTIBOOT2
                    bootCmd.dataSize = len(
                        mb
                    )  #my sniffing reveals this is actually 1024 bytes less than the data sent. writer bug?
                    noesis.usbWriteEndpointId(handle, F2A_EP_WRITE,
                                              bootCmd.getBytes())

                    writeSize = chunkedWrite(handle, mb)

                    print("MB write:", writeSize, "/", len(mb))
                    if writeSize != len(mb):
                        noesis.messagePrompt(
                            "Could not upload multiboot image. Aborting.")
                    else:
                        noesis.usbSetEndpointTimeoutId(handle, F2A_EP_WRITE,
                                                       F2A_EP_TIMEOUT)

                        #just write black to the background. sniffed out the original bg, or we could make our own, but eh.
                        bgCmd = F2ACommand()
                        bgCmd.magic = F2A_MAGIC
                        bgCmd.address = F2A_TARGET_VRAM
                        bgCmd.command = F2A_CMD_WRITEDATA
                        bgCmd.subCommand = F2A_SUBCMD_WRITE
                        bgCmd.dataSize = 76800  #packet sniffing shows this to be size & 0xFFFF, does it matter? (doesn't seem to)
                        bgCmd.dataSizeKb = 76800 // 1024
                        noesis.usbWriteEndpointId(handle, F2A_EP_WRITE,
                                                  bgCmd.getBytes())
                        bgUploadSize = 0
                        for offset in range(0, bgCmd.dataSizeKb):
                            chunkSize = noesis.usbWriteEndpointId(
                                handle, F2A_EP_WRITE, bytearray([0] * 1024))
                            if chunkSize < 0:
                                break
                            bgUploadSize += chunkSize
                        print("BG write:", bgUploadSize)

                        time.sleep(1)

                        noeWnd = noewin.NoeUserWindow("F2A Interface",
                                                      "F2AWindowClass", 644,
                                                      300)
                        #offset a bit into the noesis window
                        noeWindowRect = noewin.getNoesisWindowRect()
                        if noeWindowRect:
                            windowMargin = 64
                            noeWnd.x = noeWindowRect[0] + windowMargin
                            noeWnd.y = noeWindowRect[1] + windowMargin
                        if noeWnd.createWindow():
                            noeWnd.usbHandle = handle
                            createInterfaceWindow(noeWnd)
                            noeWnd.doModal()

    if handle:
        noesis.usbCloseDevice(handle)
    return 0