Beispiel #1
0
    private static void init()    // throws Exception
    {
        Logger.log("In init!!!!!!!!!!");
        //Class cls = Class.forName("CRunTime");
        Stream isData = Application.GetResourceStream(new Uri("/WazeWP7;component/resources/program.data.bin", UriKind.Relative)).Stream;

        Logger.log("program.data.bin:" + isData);
        CRunTime.init(isData);
        isData.Close();
        CRunTime.publishCallback("Cibyl.atexit");
        int c_start = CibylCallTable.getAddressByName("__start");

        Logger.log("Start: " + c_start);

        /*
         * This is the stack which will be used for all the C calls.
         */
        int c_sp = (CRunTime.memory.Length * 4) - 8;

        Logger.log("c_sp: " + c_sp);
        CibylCallTable.fcall(c_start, c_sp, 0, 0, 0, 0);

        /*
         * The blackberry menu button can be clicked on async when other waze tasks
         * are handled, and we want the response to be immediate. Thus we allocate a special
         * stack for the menu button clicks, to be used by the FreemapMainScreen object.
         */
        int c_malloc_stack = 0;

        try
        {
            c_malloc_stack = CibylCallTable.getAddressByName("roadmap_main_alloc_stack");
        }
        catch (Exception e)
        {
            Logger.log("could not call c_malloc_stack" + e.ToString());
            safe_exit();
            //MessageBox.Show("Exception in c_malloc_stack");
        }
        if (c_malloc_stack != 0)
        {
            int stackAddress = CibylCallTable.fcall(c_malloc_stack, c_sp, 4096, 0, 0, 0);
            GamePage.setStackAddress(stackAddress);
        }
    }