コード例 #1
0
 public static void memoryWriteWordLeft(int address, int rtVal)
 {
     CRunTime.memoryWriteByte(address + 3, (rtVal));
     CRunTime.memoryWriteByte(address + 2, (rtVal >> 8));
     CRunTime.memoryWriteByte(address + 1, (rtVal >> 16));
     CRunTime.memoryWriteByte(address + 0, (rtVal >> 24));
 }
コード例 #2
0
    public static void stringToCharPtr(string str, int address)
    {
        byte[] str_bytes = Encoding.UTF8.GetBytes(str);
        int    length    = str_bytes.Length;

        CRunTime.memcpy(address, str_bytes, 0, length);
        CRunTime.memoryWriteByte(address + length, 0);
    }
コード例 #3
0
ファイル: UIWorker.cs プロジェクト: glennneiger/WazeWP7
    public static void writeMsgToBuffer(String msg)
    {
        byte[] str_bytes = Syscalls.StringToAscii(msg);
        int    length;


        if (str_bytes.Length > msgAddrSize)     // do not overflow size of buffer in roadmap_main
        {
            length = msgAddrSize;
        }
        else
        {
            length = str_bytes.Length;
        }

        CRunTime.memcpy(msgAddr, str_bytes, 0, length);
        CRunTime.memoryWriteByte(msgAddr + length, 0);
    }
コード例 #4
0
ファイル: FreemapApp.cs プロジェクト: glennneiger/WazeWP7
    /*
     *
     * Adds the needed suffix to the url string. The connection Timeout parameter
     *
     * determines how long before a timeout is thrown.
     */
    /*todomt
     * public static string str2Add2Url(bool printInfo){
     * string st = "";
     * st += ";ConnectionTimeout=25000";
     * //The Device is a simultaor --> TCP
     * if (DeviceInfo.isSimulator())
     * {
     * st += ";deviceside=true";
     * }
     * else if ( ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_BIS_B ) == CoverageInfo.COVERAGE_BIS_B )||
     *    ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT ) == CoverageInfo.COVERAGE_DIRECT ) )
     * { //A carrier is providing us with the data service
     * st += getConnectionSuffix(printInfo);
     * }else if (WIFI_ENABLED && _wifiAvailable){
     * st += ";interface=wifi";
     * }else{
     * UIWorker.addUIEventLog("FreemapApp - getConnectionString - No network Coverage");
     * return "";
     * }
     * return st;
     * }
     */

    /*
     * If called with updateAddr 0, don't update the static connection string address
     */
    public static int getConnectionString(int updateAddr, int addr, int size)
    {
        int strSize;

        if (updateAddr != 0)
        {
            connStringAddr = addr;
            connStringSize = size;
        }
        strSize = connStringSize;
        string st = "";

        st += "";  //todomt str2Add2Url(false);
        byte[] bytes = Syscalls.StringToAscii(st);
        strSize--;
        if (strSize > bytes.Length)
        {
            strSize = bytes.Length;
        }
        CRunTime.memcpy(connStringAddr, bytes, 0, strSize);
        CRunTime.memoryWriteByte(connStringAddr + strSize, 0);
        return(0);
    }
コード例 #5
0
    public static void memcpy(int addr, byte[] bytes, int off, int size)
    {
        while (((addr & 0x3) != 0) && (size > 0))
        {
            byte b = bytes[off++];
            CRunTime.memoryWriteByte(addr, b);
            addr++;
            size--;
            if (size == 0)
            {
                return;
            }
        }

        while (size > 3)
        {
            int i = 0;
            for (int j = 0; j < 4; j++)
            {
                i = i << 8;
                int b = bytes[off++] & 0xff;
                i |= b;
            }

            CRunTime.memoryWriteWord(addr, i);
            addr += 4;
            size -= 4;
        }

        while (size > 0)
        {
            byte b = bytes[off++];
            CRunTime.memoryWriteByte(addr, b);
            addr++;
            size--;
        }
    }
コード例 #6
0
ファイル: UIWorker.cs プロジェクト: glennneiger/WazeWP7
    private void runEventQueue(bool forever)
    {
        Item o;

        while (!should_quit)
        {
            o = null;

            lock (lockQueues)
            {
                if (priorityQueue.Count > 0)
                {
                    o = priorityQueue.Dequeue() as Item;
                }
                else if (queue.Count > 0)
                {
                    o = queue.Dequeue() as Item;
                }
                else
                {
                    // Making sure no elements
                    // adds to the queues will querying the queues
                    if (forever)
                    {
                        try
                        {
                            isWaiting = true;

                            // Wait until another thread insert new elements to the queue
                            Monitor.Wait(lockQueues);
                            isWaiting = false;
                        }
                        catch (Exception e)
                        {
                            Logger.log("Exception: " + e.ToString());
                        }
                    }
                }

                //cur_item = o;
                if ((o != null) && o.user_draw)
                {
                    userDrawCount--;
                }
            }

            if (!forever && (o == null))
            {
                return;
            }

            if (o != null)
            {
                try
                {
                    if (o.logString != null)
                    {
                        byte[] str_bytes;
                        int    length;

                        str_bytes = Syscalls.StringToAscii(o.logString);
                        if (str_bytes.Length > msgAddrSize)
                        {
                            // do not overflow size of buffer in roadmap_main
                            length = msgAddrSize;
                        }
                        else
                        {
                            length = str_bytes.Length;
                        }

                        //lock (this)
                        //{
                        CRunTime.memcpy(msgAddr, str_bytes, 0, length);
                        CRunTime.memoryWriteByte(msgAddr + length, 0);
                        try
                        {
                            CibylCallTable.fcall(o.addr, c_sp, o.p1, o.p2, o.p3, o.p4);
                        }
                        catch (Exception e)
                        {
                            Logger.log("UIWORKER - print to log file :  Could not print out to log, message :" + o.logString + " Exception : " + e.ToString());
                        }
                        //}
                    }
                    else if ((o.validity_check == null) || (o.validity_check.isValid()))
                    {
                        //lock (this)
                        //{
                        //long start = DateTime.Now.Ticks;// System.currentTimeMillis();
                        //Logger.log("calling addres "+ Integer.toHexString(o.addr));
                        CibylCallTable.fcall(o.addr, c_sp, o.p1, o.p2, o.p3, o.p4);

                        /* todomt
                         * long end = DateTime.Now.Ticks;// System.currentTimeMillis();
                         * if ((end - start) > 750)
                         * {
                         *  if ((end - start) > 3000)
                         *  {
                         *      Logger.log("UIWorker Callback took too long!!! " + (end - start) + " UIWorker Callback addr:" + o.addr);
                         *      addUIEventLog("UIWorker Callback took too long!!! " + (end - start) + " UIWorker Callback addr:" + o.addr);
                         *  }
                         *  else
                         *  {
                         *      Logger.log("UIWorker Callback took too long!!! " + (end - start));
                         *      Logger.log("UIWorker Callback addr:" + o.addr);
                         *  }
                         * }
                         */

                        //}
                    }
                }
                catch (Exception t)
                {
                    //Console.WriteLine("Exception in UI action: " + t);
                    //t.printStackTrace();
                    String res = "EXCEPTION in UiWorker, cb addr: " + o.addr +
                                 ", toString() : " + t.ToString();
                    Logger.log(res);
                    addUIEventLog(res);
                }
            }
        }
    }
コード例 #7
0
 public static void memoryWriteBytePc(int pc, int address, int ins)
 {
     CRunTime.assertMemoryWrite("1-byte", pc, address, ins);
     CRunTime.memoryWriteByte(address, ins);
 }