Exemple #1
0
def EUDEndLoopN():
    block = ut.EUDPopBlock('loopnblock')[1]
    if not block['contpoint'].IsSet():
        block['contpoint'] << c.NextTrigger()

    vardb = block['vardb']
    c.RawTrigger(actions=c.SetMemory(vardb, c.Subtract, 1))
    EUDJump(block['loopstart'])
    block['loopend'] << c.NextTrigger()
Exemple #2
0
def EUDEndIf():
    lb = ut.EUDPopBlock('ifblock')
    block = lb[1]

    # Finalize
    nei_fw = block['next_elseif']
    if nei_fw:
        nei_fw << c.NextTrigger()

    block['ifend'] << c.NextTrigger()
Exemple #3
0
def EUDEndPlayerLoop():
    block = ut.EUDPopBlock('ploopblock')[1]
    playerv = block['playerv']
    origcp = block['origcp']

    if not cs.EUDIsContinuePointSet():
        cs.EUDSetContinuePoint()

    playerv += 1
    cs.EUDEndWhile()
    f_setcurpl(origcp)
Exemple #4
0
def EUDLoopUnit():
    ut.EUDCreateBlock('unitloop', 0x628430)

    ptr, epd = f_cunitepdread_epd(ut.EPD(0x628430))

    if cs.EUDWhile()(ptr >= 1):
        yield ptr, epd
        cs.EUDSetContinuePoint()
        c.SetVariables([ptr, epd], f_cunitepdread_epd(epd + 1))
    cs.EUDEndWhile()

    ut.EUDPopBlock('unitloop')
Exemple #5
0
def EUDLoopRange(start, end=None):
    ut.EUDCreateBlock('looprangeblock', None)
    if end is None:
        start, end = 0, start

    v = c.EUDVariable()
    v << start
    if EUDWhile()(v < end):
        yield v
        EUDLoopSetContinuePoint()
        v += 1
    EUDEndWhile()
    ut.EUDPopBlock('looprangeblock')
Exemple #6
0
def EUDLoopPlayerUnit(player):
    player = c.EncodePlayer(player)
    first_player_unit = 0x6283F8
    ut.EUDCreateBlock('playerunitloop', first_player_unit)
    ptr, epd = f_cunitepdread_epd(ut.EPD(first_player_unit) + player)

    if cs.EUDWhile()(ptr >= 1):
        yield ptr, epd
        cs.EUDSetContinuePoint()
        # /*0x06C*/ BW::CUnit*  nextPlayerUnit;
        c.SetVariables([ptr, epd], f_cunitepdread_epd(epd + 0x6C // 4))
    cs.EUDEndWhile()

    ut.EUDPopBlock('playerunitloop')
Exemple #7
0
def EUDLoopSprite():
    y_epd = c.EUDVariable()
    y_epd << ut.EPD(0x629688)

    ut.EUDCreateBlock('spriteloop', 'sprlo')

    if cs.EUDWhile()(y_epd < ut.EPD(0x629688) + 256):
        ptr, epd = f_dwepdread_epd(y_epd)
        if cs.EUDWhile()(ptr >= 1):
            yield ptr, epd
            cs.EUDSetContinuePoint()
            c.SetVariables([ptr, epd], f_dwepdread_epd(epd + 1))
        cs.EUDEndWhile()
        y_epd += 1
    cs.EUDEndWhile()

    ut.EUDPopBlock('spriteloop')
Exemple #8
0
def EUDLoopList(header_offset, break_offset=None):
    blockname = 'listloop'
    ut.EUDCreateBlock(blockname, header_offset)

    ptr, epd = f_dwepdread_epd(ut.EPD(header_offset))

    if break_offset is not None:
        cs.EUDWhileNot()(ptr == break_offset)
    else:
        cs.EUDWhile()([ptr > 0, ptr <= 0x7FFFFFFF])

    yield ptr, epd
    cs.EUDSetContinuePoint()
    c.SetVariables([ptr, epd], f_dwepdread_epd(epd + 1))
    cs.EUDEndWhile()

    ut.ep_assert(
        ut.EUDPopBlock(blockname)[1] is header_offset,
        'listloop mismatch'
    )
Exemple #9
0
def EUDEndSwitch():
    lb = ut.EUDPopBlock('swblock')
    block = lb[1]
    swend = block['swend']
    EUDJump(swend)  # Exit switch block
    c.PopTriggerScope()

    # If default block is not specified, skip it
    if not block['defaultbr'].IsSet():
        block['defaultbr'] << swend

    # Create key selector
    casebrlist = block['casebrlist']
    defbranch = block['defaultbr']
    casekeylist = sorted(block['casebrlist'].keys())
    var = block['targetvar']

    def KeySelector(keys):
        # Uses simple binary search
        ret = c.NextTrigger()
        if len(keys) == 1:  # Only one keys on the list
            tg.EUDBranch(var == keys[0], casebrlist[keys[0]], defbranch)

        elif len(keys) >= 2:
            br1 = c.Forward()
            br2 = c.Forward()
            midpos = len(keys) // 2
            midval = keys[midpos]
            EUDJumpIf(var == midval, casebrlist[midval])
            tg.EUDBranch(var <= midval, br1, br2)
            br1 << KeySelector(keys[:midpos])
            br2 << KeySelector(keys[midpos + 1:])

        else:  # len(keys) == 0
            return defbranch

        return ret

    KeySelector(casekeylist)

    swend << c.NextTrigger()
Exemple #10
0
def EUDEndExecuteOnce():
    lb = ut.EUDPopBlock('executeonceblock')
    ut.ep_assert(lb[0] == 'executeonceblock', 'Block start/end mismatch')
    block = lb[1]

    block['blockend'] << c.NextTrigger()
Exemple #11
0
def EUDEndInfLoop():
    block = ut.EUDPopBlock('infloopblock')[1]
    if not block['contpoint'].IsSet():
        block['contpoint'] << block['loopstart']
    EUDJump(block['loopstart'])
    block['loopend'] << c.NextTrigger()
Exemple #12
0
def EUDEndWhile():
    block = ut.EUDPopBlock('whileblock')[1]
    if not block['contpoint'].IsSet():
        block['contpoint'] << block['loopstart']
    EUDJump(block['loopstart'])
    block['loopend'] << c.NextTrigger()