boolean opcode = false;
boolean opcode = false, endcc = false;
    public CCNode[] getCCsUsed(String str)    {        int ipos = 0;        CCNode activeNode = ccTable, prevNode = null;        SortedSet ccs = new TreeSet();        boolean opcode = false;        int arglevel = 0;        int menulevel = 0;        int curcode = 0;        int ch;        for (int i = 0; i < str.length(); i++)        {            ch = str.charAt(ipos++) & 0xFF;            //len++;            // if there are arguments left to count, decrement arg level and            // continue            if (arglevel > 0)            {                arglevel--;                continue;            }            // if opcode was not previously set            if (!opcode)            {                if (isCC(ch))                {                    curcode = ch;                    opcode = true;                }            }            // do more stuff            // if opcode is true, ...            // note that none of this will happen when there are arguments in            // the queue,            // so the active node will still be the original argument node when            // the arguments            // finally close, so everything will proceed in an orderly fashion.            // (an argument node will just run through a few extra bytes and            // add them to the string,            // whereas other nodes involve adding only one character to the            // string)            if (opcode)            {                // search for a subnode matching the current byte                // (as of initial iteration, activeNode is the root node)                int n = searchNode(activeNode, ch);                if (n == -1)                {                    // if no match was found, this is an invalid code                    opcode = false;                    activeNode = ccTable;                    prevNode = null;                }                else                {                    prevNode = activeNode;                    // set the active node to a subnode of itself                    activeNode = (CCNode) activeNode.nodes.get(n);                }                // okay, now we have a byte from the ROM, and have                // associated                // it                // with a node. depending on the node type, do stuff                if (activeNode.type == TYPE_ARGLIST)                {                    // set arg level to num_arg - 1 because we've already read                    // one of the argument bytes                    arglevel = activeNode.num_arg - 1;                    //if arg multipler, multiply arguments                    if (activeNode.arg_multiplier && ch < MAX_ARG_MULT)                    {                        CCNode t = prevNode;                        while (!t.isTerminator)                            t = (CCNode) t.nodes.get(0);                        arglevel = (t.num_arg * ch) - 1;                    }                }                if (activeNode.type == TYPE_CODE)                {                    // only add a bracketed code if the current code is not a                    // compression code                }                // if the current node is a first-byte code with value 2,                // terminate text block                if (activeNode.level == 0 && activeNode.value == 0x02)                {                    if (menulevel > 0)                        menulevel--;                    else                        break;                }                //                else if (                //                    activeNode.isTerminator                //                        && activeNode.toString().equals("[0A XX XX XX XX]"))                //                {                //                    ccs.add(activeNode);                //                    break;                //                }                // if the active node is a terminator node, stop stuff                if (activeNode.isTerminator)                {                    //don't report compression codes                    if (!(activeNode.toString().startsWith("[15")                        || activeNode.toString().startsWith("[16") || activeNode                        .toString().startsWith("[17"))) ccs.add(activeNode);                    if (activeNode.toString().equals("[19 02]")) menulevel++;                    opcode = false;                    // reset the active node so we start from the                    // beginning                    activeNode = ccTable;                }            }        }        return (CCNode[]) ccs.toArray(new CCNode[0]);    }