void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep,
			    int arraynum, bool tri, bool bussed, int msb, int lsb) {
    if (!code) { vl_fatal(__FILE__,__LINE__,"","Internal: internal trace problem, code 0 is illegal"); }

    int bits = ((msb>lsb)?(msb-lsb):(lsb-msb))+1;
    int codesNeeded = 1+int(bits/32);
    if (tri) codesNeeded *= 2;   // Space in change array for __en signals

    // Make sure array is large enough
    m_nextCode = max(nextCode(), code+codesNeeded);
    if (m_sigs.capacity() <= m_nextCode) {
	m_sigs.reserve(m_nextCode*2);	// Power-of-2 allocation speeds things up
    }

    // Save declaration info
    VerilatedVcdSig sig = VerilatedVcdSig(code, bits);
    m_sigs.push_back(sig);

    // Split name into basename
    // Spaces and tabs aren't legal in VCD signal names, so:
    // Space separates each level of scope
    // Tab separates final scope from signal name
    // Tab sorts before spaces, so signals nicely will print before scopes
    // Note the hiername may be nothing, if so we'll add "\t{name}"
    string nameasstr = name;
    if (m_modName!="") { nameasstr = m_modName+m_scopeEscape+nameasstr; }  // Optional ->module prefix
    string hiername;
    string basename;
    for (const char* cp=nameasstr.c_str(); *cp; cp++) {
	if (isScopeEscape(*cp)) {
	    // Ahh, we've just read a scope, not a basename
	    if (hiername!="") hiername += " ";
	    hiername += basename;
	    basename = "";
	} else {
	    basename += *cp;
	}
    }
    hiername += "\t"+basename;

    // Print reference
    string decl = "$var ";
    if (m_evcd) decl += "port"; else decl += wirep;  // usually "wire"
    char buf [1000];
    sprintf(buf, " %2d ", bits);
    decl += buf;
    if (m_evcd) {
	sprintf(buf, "<%d", code);
	decl += buf;
    } else {
	decl += stringCode(code);
    }
    decl += " ";
    decl += basename;
    if (arraynum>=0) {
	sprintf(buf, "(%d)", arraynum);
	decl += buf;
	hiername += buf;
    }
    if (bussed) {
	sprintf(buf, " [%d:%d]", msb, lsb);
	decl += buf;
    }
    decl += " $end\n";
    m_namemapp->insert(make_pair(hiername,decl));
}
Esempio n. 2
0
//-------------------------------------------------------------------------------------
// This is the init callback function. You should load and create your in-game
// resources here.
//
//-------------------------------------------------------------------------------------
void GameApp::Create()
{
    JLOG("GameApp:Create 1");
    JFileSystem::init("./"); //to avoid having subfolders
    JLOG("GameApp:Create 2");
    JRenderer* renderer = JRenderer::GetInstance();
    JLOG("GameApp:Create 3");
    loadWalls(".");
    if (wallpapers.size()) {
        JLOG("GameApp:Create 4");
        int rnd = (rand() % wallpapers.size());
        backTex=renderer->LoadTexture(wallpapers[rnd].c_str());
        if (backTex) backQuad = new JQuad(backTex, 0, 0, 480, 272);
    }
    JLOG("GameApp:Create 5");
    // Load a font
    mFont=new JLBFont("font", 11);
    JLOG("GameApp:Create 6");
    scroller = new TextScroller(mFont, SCREEN_WIDTH/2 - 190 , SCREEN_HEIGHT-20,380);
    const char * const CreditsText[] = {
        "Thanks to n00b81, Tyranid, devs of the PSPSDK, Hitmen, Fanjita & Noobz, psp-hacks.com",
        "wMenu uses the JGE++ library ( http://code.google.com/p/wagic )"
    };

    menu = NULL;

#ifdef WIN32
    strcpy(dummy, "D:/Stuff/Programming/wmenu/projects/wmenu/bin/samples");
#else
    strcpy(dummy, "ms0:/PSP/GAME");
#endif
    ebootPath = dummy;
    JLOG("GameApp:Create 7");
    JGE* engine = JGE::GetInstance();
    vector<string>argv = engine->GetARGV();
    int settingsAddr = 0;
    JLOG("GameApp:Create 8");
    if (argv.size() > 1) {
        string hex = argv[1];
        hex[8] = 0; //bug in HBL ?
        fprintf(stderr, "Location: 0x %s\n", hex.c_str());
        settingsAddr = xstrtoi(hex.c_str(), 8);
    }
    fprintf(stderr, " settingsAddr : %d\n", settingsAddr);
    if (settingsAddr) {
        settings = (tMenuApi *) settingsAddr;
        ebootPath = (void *) settings->filename;
    }

    int size = sizeof(CreditsText) / sizeof(CreditsText[0]);
    string scroll = "wMenu 0.4 by Wololo  http://wololo.net    ";
    stringCode(scroll);
    scroll.append("--- HBL Info ---");

    if (settings) {
        scroll.append(settings->VersionName);
        scroll.append(" by ");
        scroll.append(settings->Credits);
        scroll.append("     ");
    }

    for (int i = 0; i < size; i++) {
        scroll.append(CreditsText[i]);
        scroll.append("     ");
    }
    scroller->Add(scroll);
    JLOG("GameApp:Create 9");
    loadFiles((char *)ebootPath);
    if (fileExists("menu.wav")) {
        menuSfx = JSoundSystem::GetInstance()->LoadSample("menu.wav");
        //runSfx = JSoundSystem::GetInstance()->LoadSample("run.wav");

        JSoundSystem::GetInstance()->SetSfxVolume(100);
    }
    JLOG("GameApp:Create 10");

    currentGameState = GAME_STATE_NONE;
}