main( void)
{
    initEX16();
    initLCD();
    putsLCD( "Insert card...\n");
    while ( !getCD());
    Delayms( 100);
    
    if ( !mount())
        putsLCD("Mount Failed");
    else
    {  
        clrLCD();
        putsLCD("Playing...");
        if ( !playWAV( "NELLY.WAV"))
        {
            clrLCD();
            putsLCD("File not found");
        }
    } 

    while( 1)
    {
    } // main loop

} //main 
示例#2
0
/**
 * Returns the address of a resource. Loads if not in memory. Retains a count.
 */
byte *ResourceManager::openResource(uint32 res, bool dump) {
    assert(res < _totalResFiles);


    // FIXME: In PSX edition, not all top menu icons are present (TOP menu is not used).
    // Though, at present state, the engine still ask for the resources.
    if (Sword2Engine::isPsx()) { // We need to "rewire" missing icons
        if (res == 342) res = 364; // Rewire RESTORE ICON to SAVE ICON
    }

    // Is the resource in memory already? If not, load it.

    if (!_resList[res].ptr) {
        // Fetch the correct file and read in the correct portion.
        uint16 cluFileNum = _resConvTable[res * 2]; // points to the number of the ascii filename

        assert(cluFileNum != 0xffff);

        // Relative resource within the file
        // First we have to find the file via the _resConvTable
        uint16 actual_res = _resConvTable[(res * 2) + 1];

        debug(5, "openResource %s res %d", _resFiles[cluFileNum].fileName, res);

        // If we're loading a cluster that's only available from one
        // of the CDs, remember which one so that we can play the
        // correct speech and music.

        if (Sword2Engine::isPsx()) // We have only one disk in PSX version
            setCD(CD1);
        else
            setCD(_resFiles[cluFileNum].cd);

        // Actually, as long as the file can be found we don't really
        // care which CD it's on. But if we can't find it, keep asking
        // for the CD until we do.

        Common::File *file = openCluFile(cluFileNum);

        if (_resFiles[cluFileNum].entryTab == NULL) {
            // we didn't read from this file before, get its index table
            readCluIndex(cluFileNum, file);
        }

        assert(_resFiles[cluFileNum].entryTab);

        uint32 pos = _resFiles[cluFileNum].entryTab[actual_res * 2 + 0];
        uint32 len = _resFiles[cluFileNum].entryTab[actual_res * 2 + 1];

        file->seek(pos, SEEK_SET);

        debug(6, "res len %d", len);

        // Ok, we know the length so try and allocate the memory.
        _resList[res].ptr = _vm->_memory->memAlloc(len, res);
        _resList[res].size = len;
        _resList[res].refCount = 0;

        file->read(_resList[res].ptr, len);

        debug(3, "Loaded resource '%s' (%d) from '%s' on CD %d (%d)", fetchName(_resList[res].ptr), res, _resFiles[cluFileNum].fileName, getCD(), _resFiles[cluFileNum].cd);

        if (dump) {
            char buf[256];
            const char *tag;

            switch (fetchType(_resList[res].ptr)) {
            case ANIMATION_FILE:
                tag = "anim";
                break;
            case SCREEN_FILE:
                tag = "layer";
                break;
            case GAME_OBJECT:
                tag = "object";
                break;
            case WALK_GRID_FILE:
                tag = "walkgrid";
                break;
            case GLOBAL_VAR_FILE:
                tag = "globals";
                break;
            case PARALLAX_FILE_null:
                tag = "parallax";	// Not used!
                break;
            case RUN_LIST:
                tag = "runlist";
                break;
            case TEXT_FILE:
                tag = "text";
                break;
            case SCREEN_MANAGER:
                tag = "screen";
                break;
            case MOUSE_FILE:
                tag = "mouse";
                break;
            case WAV_FILE:
                tag = "wav";
                break;
            case ICON_FILE:
                tag = "icon";
                break;
            case PALETTE_FILE:
                tag = "palette";
                break;
            default:
                tag = "unknown";
                break;
            }

            sprintf(buf, "dumps/%s-%d.dmp", tag, res);

            if (!Common::File::exists(buf)) {
                Common::DumpFile out;
                if (out.open(buf))
                    out.write(_resList[res].ptr, len);
            }
        }

        // close the cluster
        file->close();
        delete file;

        _usedMem += len;
        checkMemUsage();
    } else if (_resList[res].refCount == 0)
        removeFromCacheList(_resList + res);

    _resList[res].refCount++;

    return _resList[res].ptr;
}