diff options
author | James Brown | 2006-07-09 13:10:45 +0000 |
---|---|---|
committer | James Brown | 2006-07-09 13:10:45 +0000 |
commit | 0e66c43c709c81d2f7351f3b53bca74e6896a0be (patch) | |
tree | e50bd67dcf5669b559927b4ddab57ceaa4b1e59d /backends/platform | |
parent | f35f4a4d1c41a8d186621b912b985dd5d796632a (diff) | |
download | scummvm-rg350-0e66c43c709c81d2f7351f3b53bca74e6896a0be.tar.gz scummvm-rg350-0e66c43c709c81d2f7351f3b53bca74e6896a0be.tar.bz2 scummvm-rg350-0e66c43c709c81d2f7351f3b53bca74e6896a0be.zip |
Fix some more duplicated files, and unify case for rpc include
svn-id: r23459
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/ds/arm9/source/cdaudio.cpp | 487 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/dsmain.cpp | 1943 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/dsmain.h | 120 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/gbampsave.cpp | 186 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/osystem_ds.cpp | 484 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/portdefs.cpp | 41 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/ramsave.cpp | 459 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/scummconsole.c | 561 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/scummhelp.cpp | 86 |
9 files changed, 2 insertions, 4365 deletions
diff --git a/backends/platform/ds/arm9/source/cdaudio.cpp b/backends/platform/ds/arm9/source/cdaudio.cpp index a6e4455b22..c2846a0d95 100644 --- a/backends/platform/ds/arm9/source/cdaudio.cpp +++ b/backends/platform/ds/arm9/source/cdaudio.cpp @@ -22,7 +22,7 @@ #include "ds-fs.h" #include "config-manager.h" #include "dsmain.h" -#include "nds/scummvm_ipc.h" +#include "NDS/scummvm_ipc.h" #include "console2.h" #define WAV_FORMAT_IMA_ADPCM 0x14 @@ -481,488 +481,3 @@ bool isPlaying() { } } - -/* ScummVMDS - Scumm Interpreter DS Port - * Copyright (C) 2002-2004 The ScummVM project and Neil Millstone - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include "stdafx.h" -#include "cdaudio.h" -#include "ds-fs.h" -#include "config-manager.h" -#include "dsmain.h" -#include "nds/scummvm_ipc.h" -#include "console2.h" - -#define WAV_FORMAT_IMA_ADPCM 0x14 -#define BUFFER_SIZE 8192 -#define BUFFER_CHUNK_SIZE (BUFFER_SIZE >> 2) - -namespace DS { -namespace CD { - -struct WaveHeader { - - char riff[4]; // 'RIFF' - u32 size; // Size of the file - char wave[4]; // 'WAVE' - - // fmt chunk - char fmt[4]; // 'fmt ' - u32 fmtSize; // Chunk size - u16 fmtFormatTag; // Format of this file - u16 fmtChannels; // Num channels - u32 fmtSamPerSec; // Samples per second - u32 fmtBytesPerSec; // Bytes per second - u16 fmtBlockAlign; // Block alignment - u16 fmtBitsPerSam; // Bits per sample - - u16 fmtExtraData; // Number of extra fmt bytes - u16 fmtExtra; // Samples per block (only for IMA-ADPCM files) -} __attribute__ ((packed)); - -struct chunkHeader { - char name[4]; - u32 size; -} __attribute__ ((packed)); - -struct Header { - s16 firstSample; - char stepTableIndex; - char reserved; -} __attribute__ ((packed)); - -struct decoderFormat { - s16 initial; - unsigned char tableIndex; - unsigned char test; - unsigned char sample[1024]; -} __attribute__ ((packed)); - -bool active = false; -WaveHeader waveHeader; -Header blockHeader; -FILE* file; -int fillPos; -bool isPlayingFlag = false; - -s16* audioBuffer; -u32 sampleNum; -s16* decompressionBuffer; -int numLoops; -int blockCount; -int dataChunkStart; -int blocksLeft; - - -// These are from Microsoft's document on DVI ADPCM -const int stepTab[ 89 ] = { -7, 8, 9, 10, 11, 12, 13, 14, -16, 17, 19, 21, 23, 25, 28, 31, -34, 37, 41, 45, 50, 55, 60, 66, -73, 80, 88, 97, 107, 118, 130, 143, -157, 173, 190, 209, 230, 253, 279, 307, -337, 371, 408, 449, 494, 544, 598, 658, -724, 796, 876, 963, 1060, 1166, 1282, 1411, -1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, -3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, -7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, -15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, -32767 }; - -const int indexTab[ 16 ] = { -1, -1, -1, -1, 2, 4, 6, 8, --1, -1, -1, -1, 2, 4, 6, 8 }; - -void playNextBlock(); -void decompressBlock(); - - -void allocBuffers() { - -} - -void setActive(bool active) { - active = active; -} - -bool getActive() { - return active; -} - -void playTrack(int track, int numLoops, int startFrame, int duration) { - Common::String path = ConfMan.get("path"); - - if (isPlayingFlag) { - stopTrack(); - } - - - - - - char str[100]; - sprintf(str, "/track%d.wav", track); - path = path + str; - - - //1820160 - - file = DS::std_fopen(path.c_str(), "rb"); - - if (!file) { - consolePrintf("Failed to open %s!\n", path.c_str()); - return; - } - - - DS::std_fread((const void *) &waveHeader, sizeof(waveHeader), 1, file); - - consolePrintf("Playing track %d\n", track); - consolePrintf("Format: %d\n", waveHeader.fmtFormatTag); - consolePrintf("Rate : %d\n", waveHeader.fmtSamPerSec); - consolePrintf("Bits : %d\n", waveHeader.fmtBitsPerSam); - consolePrintf("BlkSz : %d\n", waveHeader.fmtExtra); - - if ((waveHeader.fmtFormatTag != 17) && (waveHeader.fmtFormatTag != 20)) { - consolePrintf("Wave file is in the wrong format! You must use IMA-ADPCM 4-bit mono.\n"); - return; - } - - for (int r = 0; r < 8; r++) { - IPC->adpcm.buffer[r] = (u8 * volatile) (decoderFormat *) malloc(waveHeader.fmtBlockAlign); - IPC->adpcm.filled[r] = false; - IPC->adpcm.arm7Dirty[r] = false; - } - - // Skip chunks until we reach the data chunk - chunkHeader chunk; - DS::std_fread((const void *) &chunk, sizeof(chunkHeader), 1, file); - - while (!((chunk.name[0] == 'd') && (chunk.name[1] == 'a') && (chunk.name[2] == 't') && (chunk.name[3] == 'a'))) { - DS::std_fseek(file, chunk.size, SEEK_CUR); - DS::std_fread((const void *) &chunk, sizeof(chunkHeader), 1, file); - } - - dataChunkStart = DS::std_ftell(file); - - - static bool started = false; - sampleNum = 0; - blockCount = 0; - - IPC->streamFillNeeded[0] = true; - IPC->streamFillNeeded[1] = true; - IPC->streamFillNeeded[2] = true; - IPC->streamFillNeeded[3] = true; - if (!started) { - fillPos = 0; - audioBuffer = (s16 *) malloc(BUFFER_SIZE * 2); - decompressionBuffer = (s16 *) malloc(waveHeader.fmtExtra * 2); - started = true; -// consolePrintf("****Starting buffer*****\n"); - memset(audioBuffer, 0, BUFFER_SIZE * 2); - memset(decompressionBuffer, 0, waveHeader.fmtExtra * 2); - DS::playSound(audioBuffer, BUFFER_SIZE * 2, false, false, waveHeader.fmtSamPerSec); - - } - fillPos = (IPC->streamPlayingSection + 1) & 3; - isPlayingFlag = true; - - - // Startframe is a 75Hz timer. Dunno why, since nothing else - // seems to run at that rate. - int tenths = (startFrame * 10) / 75; - - // Seek to the nearest block start to the start time - int samples = (tenths * waveHeader.fmtSamPerSec) / 10; - int block = samples / waveHeader.fmtExtra; - - - if (duration == 0) { - blocksLeft = 0; - } else { - blocksLeft = ((((duration * 100) / 75) * (waveHeader.fmtSamPerSec)) / (waveHeader.fmtExtra) / 100) + 10; - } -// consolePrintf("Playing %d blocks (%d)\n\n", blocksLeft, duration); - - // No need to seek if we're starting from the beginning - if (block != 0) { - DS::std_fseek(file, dataChunkStart + block * waveHeader.fmtBlockAlign, SEEK_SET); -// consolePrintf("Startframe: %d msec: %d (%d,%d)\n", startFrame, tenthssec, samples, block); - } - - - //decompressBlock(); - playNextBlock(); - numLoops = numLoops; -} - -void update() { - playNextBlock(); -} - -void decompressBlock() { - int block[2048]; - bool loop = false; - - blockCount++; - - if (blockCount < 10) return; - - - do { - DS::std_fread((const void *) &blockHeader, sizeof(blockHeader), 1, file); - - DS::std_fread(&block[0], waveHeader.fmtBlockAlign - sizeof(blockHeader), 1, file); - - if (DS::std_feof(file) ) { - // Reached end of file, so loop - - - if ((numLoops == -1) || (numLoops > 1)) { - // Seek file to first packet - if (numLoops != -1) { - numLoops--; - } - DS::std_fseek(file, dataChunkStart, SEEK_SET); - loop = true; - } else { - // Fill decompression buffer with zeros to prevent glitching - for (int r = 0; r < waveHeader.fmtExtra; r++) { - decompressionBuffer[r] = 0; - } -// consolePrintf("Stopping music\n"); - stopTrack(); - return; - } - - } else { - loop = false; - } - - } while (loop); - - - if (blocksLeft > 0) { - blocksLeft--; - // consolePrintf("%d ", blocksLeft); - if (blocksLeft == 0) { - stopTrack(); - return; - } - } - - // First sample is in header - decompressionBuffer[0] = blockHeader.firstSample; - - // Set up initial table indeces - int stepTableIndex = blockHeader.stepTableIndex; - int prevSample = blockHeader.firstSample; - -// consolePrintf("Decompressing block step=%d fs=%d\n", stepTableIndex, prevSample); - - for (int r = 0; r < waveHeader.fmtExtra - 1; r++) { - - int word = block[r >> 3]; - int offset = 0; - - switch (7 - (r & 0x0007)) { - case 0: { - offset = (word & 0xF0000000) >> 28; - break; - } - - case 1: { - offset = (word & 0x0F000000) >> 24; - break; - } - - case 2: { - offset = (word & 0x00F00000) >> 20; - break; - } - - case 3: { - offset = (word & 0x000F0000) >> 16; - break; - } - - case 4: { - offset = (word & 0x0000F000) >> 12; - break; - } - - case 5: { - offset = (word & 0x00000F00) >> 8; - break; - } - - case 6: { - offset = (word & 0x000000F0) >> 4; - break; - } - - case 7: { - offset = (word & 0x0000000F); - break; - } - } - - int diff = 0; - - if (offset & 4) { - diff = diff + stepTab[stepTableIndex]; - } - - if (offset & 2) { - diff = diff + (stepTab[stepTableIndex] >> 1); - } - - if (offset & 1) { - diff = diff + (stepTab[stepTableIndex] >> 2); - } - - diff = diff + (stepTab[stepTableIndex] >> 3); - - if (offset & 8) { - diff = -diff; - } - - int newSample = prevSample + diff; - - if (newSample > 32767) newSample = 32767; - if (newSample < -32768) newSample = -32768; - - decompressionBuffer[r + 1] = newSample; - - prevSample = newSample; - - stepTableIndex += indexTab[offset]; - - if (stepTableIndex > 88) stepTableIndex = 88; - if (stepTableIndex < 0) stepTableIndex = 0; - - - } -} - -void playNextBlock() { - if (!isPlayingFlag) return; - int lastBlockId = -1; - - while (IPC->adpcm.semaphore); // Wait for buffer to become free if needed - IPC->adpcm.semaphore = true; // Lock the buffer structure to prevent clashing with the ARM7 -// DC_FlushAll(); - - //-8644, 25088 - for (int block = fillPos + 1; block < fillPos + 4; block++) { - - int blockId = block & 3; - - if (IPC->streamFillNeeded[blockId]) { - - IPC->streamFillNeeded[blockId] = false; -// DC_FlushAll(); - -/* if (!(REG_KEYINPUT & KEY_R)) { - //consolePrintf("Align: %d First: %d Step:%d Res:%d\n", waveHeader.fmtBlockAlign, blockHeader.firstSample, blockHeader.stepTableIndex, blockHeader.reserved); - consolePrintf("Filling buffer %d\n", blockId); - }*/ - for (int r = blockId * BUFFER_CHUNK_SIZE; r < (blockId + 1) * BUFFER_CHUNK_SIZE; r++) { - if (isPlayingFlag) { - audioBuffer[r] = decompressionBuffer[sampleNum++]; - if (sampleNum >= waveHeader.fmtExtra) { - decompressBlock(); - sampleNum = 0; - } - } - } - - lastBlockId = blockId; - IPC->streamFillNeeded[blockId] = false; -// DC_FlushAll(); - - } - - - - } - - - - if (lastBlockId != -1) { - fillPos = lastBlockId; -/* if (!(REG_KEYINPUT & KEY_R)) { - consolePrintf("Frame fill done\n"); - }*/ - } - IPC->adpcm.semaphore = false; // Release the buffer structure -// DC_FlushAll(); -} - -void stopTrack() { - if (!isPlayingFlag) return; - - DS::std_fclose(file); - - isPlayingFlag = false; - - for (int r = 0; r < BUFFER_SIZE; r++) { - audioBuffer[r] = 0; - } - - for (int r= 0; r < waveHeader.fmtExtra; r++) { - decompressionBuffer[r] = 0; - } -// DS::stopSound(1); - -// free(audioBuffer); -// free(decompressionBuffer); - - DC_FlushAll(); -} - -bool checkCD() { - // Need to check whethe CD audio files are present - do this by trying to open Track1.wav. - consolePrintf("Attempted to open cd drive\n"); - - Common::String path = ConfMan.get("path"); - path = path + "/track2.wav"; - // 6577 153 154 - consolePrintf("Looking for %s...", path.c_str()); - - FILE* file; - if ((file = DS::std_fopen(path.c_str(), "r"))) { - consolePrintf("Success!\n"); - setActive(true); - DS::std_fclose(file); - return true; - } else { - setActive(false); - consolePrintf("Failed!\n"); - return false; - } -} - -bool isPlaying() { - return isPlayingFlag; -} - -} -} - diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index b42d9ed15e..fbe4c08c9a 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -1942,1947 +1942,4 @@ int main(void) int main() { DS::main(); } -/* ScummVMDS - Scumm Interpreter DS Port - * Copyright (C) 2002-2004 The ScummVM project and Neil Millstone - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - - -#include <nds.h> - -#include <ARM9/console.h> //basic print funcionality - -#include <stdlib.h> -#include "dsmain.h" -#include "string.h" -#include "system.h" -#include "osystem_ds.h" -#include "icons_raw.h" -#include "gba_nds_fat.h" -#include "disc_io.h" -#include "config-manager.h" -#include "engines/scumm/scumm.h" -#include "keyboard_raw.h" -#include "keyboard_pal_raw.h" -#define V16(a, b) ((a << 12) | b) -#include "touchkeyboard.h" -#include "registers_alt.h" -//#include "compact_flash.h" -#include "dsoptions.h" - -namespace DS { - -// From console.c in NDSLib - -//location of cursor -extern u8 row; -extern u8 col; - -// Mouse mode -enum MouseMode { - MOUSE_LEFT, MOUSE_RIGHT, MOUSE_HOVER, MOUSE_NUM_MODES -}; - -// Defines -#define FRAME_TIME 17 -#define SCUMM_GAME_HEIGHT 142 -#define SCUMM_GAME_WIDTH 232 - -int textureID; -u16* texture; - -int frameCount; -int currentTimeMillis; - -// Timer Callback -int callbackInterval; -int callbackTimer; -OSystem::TimerProc callback; - -// Scaled -bool scaledMode; -int scX; -int scY; - -int subScX; -int subScY; -int subScTargetX; -int subScTargetY; -int subScreenWidth = SCUMM_GAME_WIDTH; -int subScreenHeight = SCUMM_GAME_HEIGHT; -int subScreenScale = 256; - - - -// Sound -int bufferSize; -s16* soundBuffer; -int bufferFrame; -int bufferRate; -int bufferSamples; -bool soundHiPart; - -// Events -int lastEventFrame; -bool indyFightState; -bool indyFightRight; - -OSystem::SoundProc soundCallback; -void* soundParam; -int lastCallbackFrame; -bool bufferFirstHalf; -bool bufferSecondHalf; - -// Saved buffers -u8* savedBuffer = NULL; -bool highBuffer; -bool displayModeIs8Bit; - -// Game id -u8 gameID; - -bool consoleEnable = true; -bool gameScreenSwap = false; - -MouseMode mouseMode; - -// Sprites -SpriteEntry sprites[128]; -SpriteEntry spritesMain[128]; -int tweak; - -// Shake -int shakePos = 0; - -// Keyboard -bool keyboardEnable = false; -bool leftHandedMode = false; -bool keyboardIcon = false; - -// Touch -int touchScX, touchScY, touchX, touchY; - -// Dragging -int dragStartX, dragStartY; -bool dragging = false; -int dragScX, dragScY; - -// Interface styles -char gameName[32]; - -// 8-bit surface size -int gameWidth = 320; -int gameHeight = 200; - -enum controlType { - CONT_SCUMM_ORIGINAL, - CONT_SCUMM_SAMNMAX, - CONT_SKY, - CONT_SIMON, -}; - -struct gameListType { - char gameId[16]; - controlType control; -}; - -#define NUM_SUPPORTED_GAMES 15 - -gameListType gameList[NUM_SUPPORTED_GAMES] = { - // Unknown game - use normal SCUMM controls - {"unknown", CONT_SCUMM_ORIGINAL}, - - // SCUMM games - {"maniac", CONT_SCUMM_ORIGINAL}, - {"zak", CONT_SCUMM_ORIGINAL}, - {"loom", CONT_SCUMM_ORIGINAL}, - {"indy3", CONT_SCUMM_ORIGINAL}, - {"atlantis", CONT_SCUMM_ORIGINAL}, - {"monkey", CONT_SCUMM_ORIGINAL}, - {"monkey2", CONT_SCUMM_ORIGINAL}, - {"tentacle", CONT_SCUMM_ORIGINAL}, - {"samnmax", CONT_SCUMM_SAMNMAX}, - - // Non-SCUMM games - {"sky", CONT_SKY}, - {"simon1", CONT_SIMON}, - {"simon2", CONT_SIMON}, - {"gob1", CONT_SCUMM_ORIGINAL}, - {"queen", CONT_SCUMM_ORIGINAL} -}; - -gameListType* currentGame = NULL; - -// Stylus -#define ABS(x) ((x)>0?(x):-(x)) - -bool penDown; -bool penHeld; -bool penReleased; -bool penDownLastFrame; -f32 penX, penY; -int keysDownSaved; -int keysReleasedSaved; - -bool penDownSaved; -bool penReleasedSaved; -int penDownFrames; -int touchXOffset = 0; -int touchYOffset = 0; - -u16 savedPalEntry255 = RGB15(31, 31, 31); - - -extern "C" int scummvm_main(int argc, char *argv[]); -void updateStatus(); - -TransferSound soundControl; - -//plays an 8 bit mono sample at 11025Hz -void playSound(const void* data, u32 length, bool loop, bool adpcm, int rate) -{ - - if (!IPC->soundData) { - soundControl.count = 0; - } - - soundControl.data[soundControl.count].data = data; - soundControl.data[soundControl.count].len = length | (loop? 0x80000000: 0x00000000); - soundControl.data[soundControl.count].rate = rate; // 367 samples per frame - soundControl.data[soundControl.count].pan = 64; - soundControl.data[soundControl.count].vol = 127; - soundControl.data[soundControl.count].format = adpcm? 2: 0; - - soundControl.count++; - - DC_FlushAll(); - IPC->soundData = &soundControl; -} - -void stopSound(int channel) { - playSound(NULL, 0, false, false, -channel); -} - -void updateOAM() { - DC_FlushAll(); - dmaCopy(sprites, OAM_SUB, 128 * sizeof(SpriteEntry)); - dmaCopy(spritesMain, OAM, 128 * sizeof(SpriteEntry)); -} - -void setGameSize(int width, int height) { - gameWidth = width; - gameHeight = height; -} - -int getGameWidth() { - return gameWidth; -} - -int getGameHeight() { - return gameHeight; -} - -void initSprites() { - for(int i = 0; i < 128; i++) { - sprites[i].attribute[0] = ATTR0_DISABLED; - sprites[i].attribute[1] = 0; - sprites[i].attribute[2] = 0; - sprites[i].attribute[3] = 0; - } - - for(int i = 0; i < 128; i++) { - spritesMain[i].attribute[0] = ATTR0_DISABLED; - spritesMain[i].attribute[1] = 0; - spritesMain[i].attribute[2] = 0; - spritesMain[i].attribute[3] = 0; - } - - updateOAM(); -} - - -void saveGameBackBuffer() { -#ifdef DISABLE_SCUMM - if (savedBuffer == NULL) savedBuffer = new u8[gameWidth * gameHeight]; - for (int r = 0; r < 200; r++) { - memcpy(savedBuffer + (r * gameWidth), ((u8 *) (get8BitBackBuffer())) + (r * 512), gameWidth); - } -#endif -} - -void restoreGameBackBuffer() { -#ifdef DISABLE_SCUMM - if (savedBuffer) { - for (int r = 0; r < 200; r++) { - memcpy(((u8 *) (BG_GFX_SUB)) + (r * 512), savedBuffer + (r * gameWidth), gameWidth); - memcpy(((u8 *) (get8BitBackBuffer())) + (r * 512), savedBuffer + (r * gameWidth), gameWidth); - } - delete savedBuffer; - savedBuffer = NULL; - } -#endif - -#ifndef DISABLE_SCUMM - memset(get8BitBackBuffer(), 0, 512 * 256); - memset(BG_GFX_SUB, 0, 512 * 256); - if (Scumm::g_scumm) { - Scumm::g_scumm->markRectAsDirty(Scumm::kMainVirtScreen, 0, gameWidth - 1, 0, gameHeight - 1, 1); - Scumm::g_scumm->markRectAsDirty(Scumm::kTextVirtScreen, 0, gameWidth - 1, 0, gameHeight - 1, 1); - Scumm::g_scumm->markRectAsDirty(Scumm::kVerbVirtScreen, 0, gameWidth - 1, 0, gameHeight - 1, 1); - } -#endif - -} - - -void initGame() { - // This is a good time to check for left handed mode since the mode change is done as the game starts. - // There's probably a better way, but hey. -// consolePrintf("initing game\n"); - - setOptions(); - - //strcpy(gameName, ConfMan.getActiveDomain().c_str()); - strcpy(gameName, ConfMan.get("gameid").c_str()); -// consolePrintf("\n\n\n\nCurrent game: '%s' %d\n", gameName, gameName[0]); - - currentGame = &gameList[0]; // Default game - - for (int r = 0; r < NUM_SUPPORTED_GAMES; r++) { - if (!stricmp(gameName, gameList[r].gameId)) { - currentGame = &gameList[r]; -// consolePrintf("Game list num: %d\n", currentGame); - } - } - - -} - -void setLeftHanded(bool enable) { - leftHandedMode = enable; -} - -void setTouchXOffset(int x) { - touchXOffset = x; -} - -void setTouchYOffset(int y) { - touchYOffset = y; -} - -void setUnscaledMode(bool enable) { - scaledMode = !enable; -} - -void displayMode8Bit() { - - u16 buffer[32 * 32]; - - setKeyboardEnable(false); - - if (!displayModeIs8Bit) { - for (int r = 0; r < 32 * 32; r++) { - buffer[r] = ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r]; - } - } - - - - videoSetMode(MODE_5_2D | (consoleEnable? DISPLAY_BG0_ACTIVE: 0) | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); - videoSetModeSub(MODE_3_2D /*| DISPLAY_BG0_ACTIVE*/ | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text - - vramSetBankA(VRAM_A_MAIN_BG_0x6000000); - vramSetBankB(VRAM_B_MAIN_BG_0x6020000); - - vramSetBankC(VRAM_C_SUB_BG_0x6200000); - vramSetBankD(VRAM_D_MAIN_BG_0x6040000); - - vramSetBankH(VRAM_H_LCD); - - BG3_CR = BG_BMP8_512x256 | BG_BMP_BASE(8); - - - - BG3_XDX = (int) (((float) (gameWidth) / 256.0f) * 256); - BG3_XDY = 0; - BG3_YDX = 0; - BG3_YDY = (int) ((200.0f / 192.0f) * 256); - - SUB_BG3_CR = BG_BMP8_512x256; - - - - SUB_BG3_XDX = (int) (subScreenWidth / 256.0f * 256); - SUB_BG3_XDY = 0; - SUB_BG3_YDX = 0; - SUB_BG3_YDY = (int) (subScreenHeight / 192.0f * 256); - - - // Do text stuff - BG0_CR = BG_MAP_BASE(0) | BG_TILE_BASE(1); - BG0_Y0 = 0; - - // Restore palette entry used by text in the front-end - PALETTE_SUB[255] = savedPalEntry255; - - consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(1), 16); - consolePrintSet(0, 23); - - if (!displayModeIs8Bit) { - for (int r = 0; r < 32 * 32; r++) { - ((u16 *) SCREEN_BASE_BLOCK(0))[r] = buffer[r]; - } -// dmaCopyHalfWords(3, (u16 *) SCREEN_BASE_BLOCK(0), buffer, 32 * 32 * 2); - } - - - if (!displayModeIs8Bit) restoreGameBackBuffer(); - displayModeIs8Bit = true; - - POWER_CR &= ~POWER_SWAP_LCDS; - - keyboardEnable = false; - initGame(); - -} - -void setGameID(int id) { - gameID = id; -} - -void dummyHandler() { - REG_IF = IRQ_VBLANK; -} - -void checkSleepMode() { - if (IPC->performArm9SleepMode) { - - consolePrintf("ARM9 Entering sleep mode\n"); - - int intSave = REG_IE; - irqSet(IRQ_VBLANK, dummyHandler); -// int irqHandlerSave = (int) IRQ_HANDLER; - REG_IE = IRQ_VBLANK; - //IRQ_HANDLER = dummyHandler; - - int powerSave = POWER_CR; - POWER_CR &= ~POWER_ALL; - - while (IPC->performArm9SleepMode) { - swiWaitForVBlank(); - } - - POWER_CR = powerSave; -// IRQ_HANDLER = (void (*)()) irqHandlerSave; - irqSet(IRQ_VBLANK, VBlankHandler); - REG_IE = intSave; - - consolePrintf("ARM9 Waking from sleep mode\n"); - } -} - -void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor) { - if (currentGame->control != CONT_SCUMM_SAMNMAX) - return; - - uint16 border = RGB15(24,24,24) | 0x8000; - - - int off = 48*64; - memset(SPRITE_GFX_SUB+off, 0, 64*64*2); - - int pos = 190 - (w+2); - - - - // make border - for (uint i=0; i<w+2; i++) { - SPRITE_GFX_SUB[off+i] = border; - SPRITE_GFX_SUB[off+(31)*64+i] = border; - } - for (uint i=1; i<31; i++) { - SPRITE_GFX_SUB[off+(i*64)] = border; - SPRITE_GFX_SUB[off+(i*64)+(w+1)] = border; - } - - int offset = (32 - h) >> 1; - - for (uint y=0; y<h; y++) { - for (uint x=0; x<w; x++) { - int color = icon[y*w+x]; - if (color == keycolor) { - SPRITE_GFX_SUB[off+(y+1+offset)*64+(x+1)] = 0x8000; // black background - } else { - SPRITE_GFX_SUB[off+(y+1+offset)*64+(x+1)] = BG_PALETTE[color] | 0x8000; - } - } - } - - sprites[1].attribute[0] = ATTR0_BMP | 150; - sprites[1].attribute[1] = ATTR1_SIZE_64 | pos; - sprites[1].attribute[2] = ATTR2_ALPHA(1) | 48; -} - - - - -void displayMode16Bit() { - - u16 buffer[32 * 32 * 2]; - - - if (displayModeIs8Bit) { - saveGameBackBuffer(); - for (int r = 0; r < 32 * 32; r++) { - buffer[r] = ((u16 *) SCREEN_BASE_BLOCK(0))[r]; - } - } - - - videoSetMode(MODE_5_2D | /*DISPLAY_BG0_ACTIVE |*/ DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); - videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE |/* DISPLAY_BG1_ACTIVE |*/ DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text - - vramSetBankA(VRAM_A_MAIN_BG); - vramSetBankB(VRAM_B_MAIN_BG); - vramSetBankC(VRAM_C_MAIN_BG); - vramSetBankD(VRAM_D_MAIN_BG); - vramSetBankH(VRAM_H_SUB_BG); - - BG3_CR = BG_BMP16_512x256; - highBuffer = false; - - BG3_XDX = (int) (1.25f * 256); - BG3_XDY = 0; - BG3_YDX = 0; - BG3_YDY = (int) ((200.0f / 192.0f) * 256); - - memset(BG_GFX, 0, 512 * 256 * 2); - - savedPalEntry255 = PALETTE_SUB[255]; - PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255 - - // Do text stuff - SUB_BG0_CR = BG_MAP_BASE(4) | BG_TILE_BASE(0); - SUB_BG0_Y0 = 0; - - consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(4), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); - - if (displayModeIs8Bit) { - //dmaCopyHalfWords(3, (u16 *) SCREEN_BASE_BLOCK_SUB(0), buffer, 32 * 32 * 2); - for (int r = 0; r < 32 * 32; r++) { - ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r] = buffer[r]; - } - } - - consolePrintSet(0, 23); - consolePrintf("\n"); - - // Show keyboard - SUB_BG1_CR = BG_TILE_BASE(1) | BG_MAP_BASE(12); - //drawKeyboard(1, 12); - - POWER_CR &= ~POWER_SWAP_LCDS; - - - - displayModeIs8Bit = false; -} - - -void displayMode16BitFlipBuffer() { - if (!displayModeIs8Bit) { - u16* back = get16BitBackBuffer(); - -// highBuffer = !highBuffer; -// BG3_CR = BG_BMP16_512x256 | BG_BMP_RAM(highBuffer? 1: 0); - - for (int r = 0; r < 512 * 256; r++) { - *(BG_GFX + r) = *(back + r); - } - } -} - -void setShakePos(int shakePos) { - shakePos = shakePos; -} - - -u16* get16BitBackBuffer() { - return BG_GFX + 0x20000; -} - -u16* get8BitBackBuffer() { - return BG_GFX + 0x10000; // 16bit qty! -} - -void setSoundProc(OSystem::SoundProc proc, void* param) { -// consolePrintf("Set sound callback"); - soundCallback = proc; - soundParam = param; -} - -// The sound system in ScummVM seems to always return stereo interleaved samples. -// Here, I'm treating an 11Khz stereo stream as a 22Khz mono stream, which works sorta ok, but is -// a horrible bodge. Any advice on how to change the engine to output mono would be greatly -// appreciated. -void doSoundCallback() { - if ((soundCallback)) { - lastCallbackFrame = frameCount; - - for (int r = IPC->playingSection; r < IPC->playingSection + 4; r++) { - int chunk = r & 3; - - if (IPC->fillNeeded[chunk]) { - IPC->fillNeeded[chunk] = false; - DC_FlushAll(); - soundCallback(soundParam, (byte *) (soundBuffer + ((bufferSamples >> 2) * chunk)), bufferSamples >> 1); - IPC->fillNeeded[chunk] = false; - DC_FlushAll(); - } - - } - - } -} - -void doTimerCallback() { - if (callback) { - if (callbackTimer <= 0) { - callbackTimer += callbackInterval; - callback(callbackInterval); - } - } -} - -void soundUpdate() { - if ((bufferFrame == 0)) { -// playSound(soundBuffer, (bufferSamples * 2), true); - } -// consolePrintf("%x\n", IPC->test); - - - if (bufferFrame == 0) { -// bufferFirstHalf = true; - } - if (bufferFrame == bufferSize >> 1) { - //bufferSecondHalf = true; - } - - bufferFrame++; - if (bufferFrame == bufferSize) { - bufferFrame = 0; - } -} - -void memoryReport() { - int r = 0; - int* p; - do { - p = (int *) malloc(r * 8192); - free(p); - r++; - } while ((p) && (r < 512)); - - int t = -1; - void* block[1024]; - do { - t++; - block[t] = (int *) malloc(4096); - } while ((t < 1024) && (block[t])); - - for (int q = 0; q < t; q++) { - free(block[q]); - } - - consolePrintf("Free: %dK, Largest: %dK\n", t * 4, r * 8); -} - - -void addIndyFightingKeys() { - OSystem_DS* system = OSystem_DS::instance(); - OSystem::Event event; - - event.type = OSystem::EVENT_KEYDOWN; - event.kbd.flags = 0; - - if ((getKeysDown() & KEY_L)) { - indyFightRight = false; - } - - if ((getKeysDown() & KEY_R)) { - indyFightRight = true; - } - - if ((getKeysDown() & KEY_UP)) { - event.kbd.keycode = '8'; - event.kbd.ascii = '8'; - system->addEvent(event); - } - if ((getKeysDown() & KEY_LEFT)) { - event.kbd.keycode = '4'; - event.kbd.ascii = '4'; - system->addEvent(event); - } - if ((getKeysDown() & KEY_RIGHT)) { - event.kbd.keycode = '6'; - event.kbd.ascii = '6'; - system->addEvent(event); - } - if ((getKeysDown() & KEY_DOWN)) { - event.kbd.keycode = '2'; - event.kbd.ascii = '2'; - system->addEvent(event); - } - - if (indyFightRight) { - - if ((getKeysDown() & KEY_X)) { - event.kbd.keycode = '9'; - event.kbd.ascii = '9'; - system->addEvent(event); - } - if ((getKeysDown() & KEY_A)) { - event.kbd.keycode = '6'; - event.kbd.ascii = '6'; - system->addEvent(event); - } - if ((getKeysDown() & KEY_B)) { - event.kbd.keycode = '3'; - event.kbd.ascii = '3'; - system->addEvent(event); - } - - } else { - - if ((getKeysDown() & KEY_X)) { - event.kbd.keycode = '7'; - event.kbd.ascii = '7'; - system->addEvent(event); - } - if ((getKeysDown() & KEY_A)) { - event.kbd.keycode = '4'; - event.kbd.ascii = '4'; - system->addEvent(event); - } - if ((getKeysDown() & KEY_B)) { - event.kbd.keycode = '1'; - event.kbd.ascii = '1'; - system->addEvent(event); - } - - } - - - if ((getKeysDown() & KEY_Y)) { - event.kbd.keycode = '5'; - event.kbd.ascii = '5'; - system->addEvent(event); - } -} - - -void setKeyboardEnable(bool en) { - if (en == keyboardEnable) return; - keyboardEnable = en; - u16* backupBank = (u16 *) 0x6040000; - - if (keyboardEnable) { - - - DS::drawKeyboard(1, 12, backupBank); - - - SUB_BG1_CR = BG_TILE_BASE(1) | BG_MAP_BASE(12); - - if (displayModeIs8Bit) { - SUB_DISPLAY_CR |= DISPLAY_BG1_ACTIVE; // Turn on keyboard layer - SUB_DISPLAY_CR &= ~DISPLAY_BG3_ACTIVE; // Turn off game layer - } else { - SUB_DISPLAY_CR |= DISPLAY_BG1_ACTIVE; // Turn on keyboard layer - SUB_DISPLAY_CR &= ~DISPLAY_BG0_ACTIVE; // Turn off console layer - } - lcdSwap(); - } else { - - - // Restore the palette that the keyboard has used - for (int r = 0; r < 256; r++) { - BG_PALETTE_SUB[r] = BG_PALETTE[r]; - } - - - //restoreVRAM(1, 12, backupBank); - - if (displayModeIs8Bit) { - // Copy the sub screen VRAM from the top screen - they should always be - // the same. - for (int r = 0; r < (512 * 256) >> 1; r++) { - BG_GFX_SUB[r] = get8BitBackBuffer()[r]; - } - - SUB_DISPLAY_CR &= ~DISPLAY_BG1_ACTIVE; // Turn off keyboard layer - SUB_DISPLAY_CR |= DISPLAY_BG3_ACTIVE; // Turn on game layer - } else { - SUB_DISPLAY_CR &= ~DISPLAY_BG1_ACTIVE; // Turn off keyboard layer - SUB_DISPLAY_CR |= DISPLAY_BG0_ACTIVE; // Turn on console layer - } - - lcdSwap(); - } -} - -bool getKeyboardEnable() { - return keyboardEnable; -} -bool getIsDisplayMode8Bit() { - return displayModeIs8Bit; -} - -void addEventsToQueue() { - OSystem_DS* system = OSystem_DS::instance(); - OSystem::Event event; - - - - - if (system->isEventQueueEmpty()) { - -/* - if (getKeysDown() & KEY_L) { - tweak--; - consolePrintf("Tweak: %d\n", tweak); - IPC->tweakChanged = true; - } - - - if (getKeysDown() & KEY_R) { - tweak++; - consolePrintf("Tweak: %d\n", tweak); - IPC->tweakChanged = true; - } - */ - if ((keysHeld() & KEY_L) && (keysHeld() & KEY_R)) { - memoryReport(); - } - - if (displayModeIs8Bit) { - - if (!indyFightState) { - - - if ((getKeysDown() & KEY_B) && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { - // consolePrintf("Pressing Esc"); - - event.type = OSystem::EVENT_KEYDOWN; - event.kbd.keycode = 27; - event.kbd.ascii = 27; - event.kbd.flags = 0; - system->addEvent(event); - } - - } - - - - if ((!getIndyFightState()) && (getKeysDown() & KEY_Y)) { - consoleEnable = !consoleEnable; - if (displayModeIs8Bit) { - displayMode8Bit(); - } else { - displayMode16Bit(); - } - } - - - if (!((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (!getIndyFightState())) { - - if ((getKeysDown() & KEY_A) && (!indyFightState)) { - gameScreenSwap = !gameScreenSwap; - } - - if (!getPenHeld() || (mouseMode != MOUSE_HOVER)) { - if (getKeysDown() & KEY_LEFT) { - mouseMode = MOUSE_LEFT; - } - if (getKeysDown() & KEY_RIGHT) { - if (currentGame->control != CONT_SCUMM_SAMNMAX) { - mouseMode = MOUSE_RIGHT; - } else { - // If we're playing sam and max, click and release the right mouse - // button to change verb - OSystem::Event event; - - event.type = OSystem::EVENT_RBUTTONDOWN; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - - event.type = OSystem::EVENT_RBUTTONUP; - system->addEvent(event); - } - } - if (getKeysDown() & KEY_UP) { - mouseMode = MOUSE_HOVER; - } - } - - - - } - - if ((getKeysDown() & KEY_SELECT)) { - //scaledMode = !scaledMode; - //scY = 4; - showOptionsDialog(); - } - - - } - - if (!getIndyFightState() && !((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) && (getKeysDown() & KEY_X)) { - setKeyboardEnable(!keyboardEnable); - } - - updateStatus(); - - OSystem::Event event; - - if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { - event.type = OSystem::EVENT_MOUSEMOVE; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - //consolePrintf("x=%d y=%d \n", getPenX(), getPenY()); - } - - if (!keyboardEnable) { - if ((mouseMode != MOUSE_HOVER) || (!displayModeIs8Bit)) { - if (getPenDown() && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) { - event.type = ((mouseMode == MOUSE_LEFT) || (!displayModeIs8Bit))? OSystem::EVENT_LBUTTONDOWN: OSystem::EVENT_RBUTTONDOWN; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - } - - if (getPenReleased()) { - event.type = mouseMode == MOUSE_LEFT? OSystem::EVENT_LBUTTONUP: OSystem::EVENT_RBUTTONUP; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - } - } else { - // In hover mode, D-pad left and right click the mouse when the pen is on the screen - - if (getPenHeld()) { - if (getKeysDown() & KEY_LEFT) { - event.type = OSystem::EVENT_LBUTTONDOWN; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - } - /* if (getKeysReleased() & KEY_LEFT) { - event.type = OSystem::EVENT_LBUTTONUP; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - }*/ - - if (getKeysDown() & KEY_RIGHT) { - event.type = OSystem::EVENT_RBUTTONDOWN; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - } - /*if (getKeysReleased() & KEY_RIGHT) { - event.type = OSystem::EVENT_RBUTTONUP; - event.mouse = Common::Point(getPenX(), getPenY()); - system->addEvent(event); - }*/ - } - } - - if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) && (displayModeIs8Bit)) { - // Controls specific to the control method - - - if (currentGame->control == CONT_SKY) { - // Extra controls for Benieth a Steel Sky - if ((getKeysDown() & KEY_DOWN)) { - penY = 0; - penX = 0; // Show inventory by moving mouse onto top line - } - } - - if (currentGame->control == CONT_SIMON) { - // Extra controls for Simon the Sorcerer - if ((getKeysDown() & KEY_DOWN)) { - OSystem::Event event; - - event.type = OSystem::EVENT_KEYDOWN; - event.kbd.keycode = '#'; // F10 or # - show hotspots - event.kbd.ascii = '#'; - event.kbd.flags = 0; - system->addEvent(event); -// consolePrintf("F10\n"); - } - } - - if (currentGame->control == CONT_SCUMM_ORIGINAL) { - // Extra controls for Scumm v1-5 games - if ((getKeysDown() & KEY_DOWN)) { - OSystem::Event event; - - event.type = OSystem::EVENT_KEYDOWN; - event.kbd.keycode = '.'; // Full stop - skips current dialogue line - event.kbd.ascii = '.'; - event.kbd.flags = 0; - system->addEvent(event); - } - - if (indyFightState) { - addIndyFightingKeys(); - } - - } - - } - } - - if (!displayModeIs8Bit) { - // Front end controls - - if (leftHandedSwap(getKeysDown()) & KEY_UP) { - event.type = OSystem::EVENT_KEYDOWN; - event.kbd.keycode = SDLK_UP; - event.kbd.ascii = 0; - event.kbd.flags = 0; - system->addEvent(event); - - event.type = OSystem::EVENT_KEYUP; - system->addEvent(event); - } - - if (leftHandedSwap(getKeysDown()) & KEY_DOWN) { - event.type = OSystem::EVENT_KEYDOWN; - event.kbd.keycode = SDLK_DOWN; - event.kbd.ascii = 0; - event.kbd.flags = 0; - system->addEvent(event); - - event.type = OSystem::EVENT_KEYUP; - system->addEvent(event); - } - - if (leftHandedSwap(getKeysDown()) & KEY_A) { - event.type = OSystem::EVENT_KEYDOWN; - event.kbd.keycode = SDLK_RETURN; - event.kbd.ascii = 0; - event.kbd.flags = 0; - system->addEvent(event); - - event.type = OSystem::EVENT_KEYUP; - system->addEvent(event); - } - - } - - - if ((getKeysDown() & KEY_START)) { - event.type = OSystem::EVENT_KEYDOWN; - event.kbd.keycode = 319; // F5 - event.kbd.ascii = 319; - event.kbd.flags = 0; - system->addEvent(event); -/* - event.type = OSystem::EVENT_KEYUP; - event.kbd.keycode = 319; // F5 - event.kbd.ascii = 319; - system->addEvent(event);*/ - -// consolePrintf("Pressing F5"); - } - - - if (keyboardEnable) { - DS::addKeyboardEvents(); - } - - consumeKeys(); - - consumePenEvents(); - - } -} - -void updateStatus() { - int offs; - - if (displayModeIs8Bit) { - switch (mouseMode) { - case MOUSE_LEFT: { - offs = 16; - break; - } - case MOUSE_RIGHT: { - offs = 32; - break; - } - case MOUSE_HOVER: { - offs = 0; - break; - } - default: { - // Nothing! - offs = 0; - break; - } - } - - - sprites[0].attribute[0] = ATTR0_BMP | 150; - sprites[0].attribute[1] = ATTR1_SIZE_32 | 208; - sprites[0].attribute[2] = ATTR2_ALPHA(1)| offs; - - if (indyFightState) { - sprites[2].attribute[0] = ATTR0_BMP | 150; - sprites[2].attribute[1] = ATTR1_SIZE_32 | (190 - 32) | (indyFightRight? 0: ATTR1_FLIP_X); - sprites[2].attribute[2] = ATTR2_ALPHA(1)| 48; - } else { - sprites[2].attribute[0] = ATTR0_DISABLED; - sprites[2].attribute[1] = 0; - sprites[2].attribute[2] = 0; - } - } else { - sprites[0].attribute[0] = ATTR0_DISABLED; - sprites[1].attribute[0] = ATTR0_DISABLED; - sprites[2].attribute[0] = ATTR0_DISABLED; - sprites[3].attribute[0] = ATTR0_DISABLED; - } - - if ((keyboardIcon) && (!keyboardEnable) && (!displayModeIs8Bit)) { - spritesMain[0].attribute[0] = ATTR0_BMP | 160; - spritesMain[0].attribute[1] = ATTR1_SIZE_32 | 0; - spritesMain[0].attribute[2] = ATTR2_ALPHA(1) | 64; - } else { - spritesMain[0].attribute[0] = ATTR0_DISABLED; - spritesMain[0].attribute[1] = 0; - spritesMain[0].attribute[2] = 0; - spritesMain[0].attribute[3] = 0; - } - -} - -void soundBufferEmptyHandler() { - REG_IF = IRQ_TIMER2; - - if (soundHiPart) { -// bufferSecondHalf = true; - } else { -// bufferFirstHalf = true; - } - - soundHiPart = !soundHiPart; -} - -void setMainScreenScroll(int x, int y) { - if (gameScreenSwap) { - SUB_BG3_CX = x + (((frameCount & 1) == 0)? 64: 0); - SUB_BG3_CY = y; - } else { - BG3_CX = x + (((frameCount & 1) == 0)? 64: 0); - BG3_CY = y; - - touchX = x >> 8; - touchY = y >> 8; - } -} - -void setMainScreenScale(int x, int y) { - if (gameScreenSwap) { - SUB_BG3_XDX = x; - SUB_BG3_XDY = 0; - SUB_BG3_YDX = 0; - SUB_BG3_YDY = y; - } else { - BG3_XDX = x; - BG3_XDY = 0; - BG3_YDX = 0; - BG3_YDY = y; - - touchScX = x; - touchScY = y; - } -} - -void setZoomedScreenScroll(int x, int y) { - if (gameScreenSwap) { - BG3_CX = x + (((frameCount & 1) == 0)? 64: 0); - BG3_CY = y; - - touchX = x >> 8; - touchY = y >> 8; - } else { - SUB_BG3_CX = x + (((frameCount & 1) == 0)? 64: 0); - SUB_BG3_CY = y; - } -} - -void setZoomedScreenScale(int x, int y) { - if (gameScreenSwap) { - BG3_XDX = x; - BG3_XDY = 0; - BG3_YDX = 0; - BG3_YDY = y; - - touchScX = x; - touchScY = y; - } else { - SUB_BG3_XDX = x; - SUB_BG3_XDY = 0; - SUB_BG3_YDX = 0; - SUB_BG3_YDY = y; - } -} - -void VBlankHandler(void) { -// BG_PALETTE[0] = RGB15(31, 31, 31); -// if (*((int *) (0x023FFF00)) != 0xBEEFCAFE) { - // consolePrintf("Guard band overwritten!"); -// } - -// consolePri ntf("X:%d Y:%d\n", getPenX(), getPenY()); - - - IPC->tweak = tweak; - soundUpdate(); - - - - - if ((!gameScreenSwap) && (!(getKeysHeld() & KEY_L) && !(getKeysHeld() & KEY_R))) { - if (currentGame) { - if (currentGame->control != CONT_SCUMM_SAMNMAX) { - if (getPenHeld() && (getPenY() < SCUMM_GAME_HEIGHT)) { - setTopScreenTarget(getPenX(), getPenY()); - } - } else { - if (getPenHeld()) { - setTopScreenTarget(getPenX(), getPenY()); - } - } - } - } - - - penUpdate(); - keysUpdate(); - - - frameCount++; - - - - if (callback) { - callbackTimer -= FRAME_TIME; - } - - if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) { - - if ((!dragging) && (getPenHeld()) && (penDownFrames > 5)) { - dragging = true; - dragStartX = penX; - dragStartY = penY; - - if (gameScreenSwap) { - dragScX = subScTargetX; - dragScY = subScTargetY; - } else { - dragScX = scX; - dragScY = scY; - } - - - } - - if ((dragging) && (!getPenHeld())) { - dragging = false; - } - - if (dragging) { - - if (gameScreenSwap) { - subScTargetX = dragScX + ((dragStartX - penX) << 8); - subScTargetY = dragScY + ((dragStartY - penY) << 8); - } else { - scX = dragScX + ((dragStartX - penX)); - scY = dragScY + ((dragStartY - penY)); - } - -// consolePrintf("X:%d Y:%d\n", dragStartX - penX, dragStartY - penY); - } - } - - -/* if ((frameCount & 1) == 0) { - SUB_BG3_CX = subScX; - } else { - SUB_BG3_CX = subScX + 64; - } - - SUB_BG3_CY = subScY + (shakePos << 8);*/ - - /*SUB_BG3_XDX = (int) (subScreenWidth / 256.0f * 256); - SUB_BG3_XDY = 0; - SUB_BG3_YDX = 0; - SUB_BG3_YDY = (int) (subScreenHeight / 192.0f * 256);*/ - - - if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) { - if ((getKeysHeld() & KEY_A) && (subScreenScale < 256)) { - subScreenScale += 3; - } - - if ((getKeysHeld() & KEY_B) && (subScreenScale > 128)) { - subScreenScale -=3; - } - - int xCenter = subScTargetX + ((subScreenWidth >> 1) << 8); - int yCenter = subScTargetY + ((subScreenHeight >> 1) << 8); - - subScreenWidth = SCUMM_GAME_WIDTH * subScreenScale >> 8; - subScreenHeight = SCUMM_GAME_HEIGHT * subScreenScale >> 8; - - subScTargetX = xCenter - ((subScreenWidth >> 1) << 8); - subScTargetY = yCenter - ((subScreenHeight >> 1) << 8); - - - - - if (subScTargetX < 0) subScTargetX = 0; - if (subScTargetX > (gameWidth - subScreenWidth) << 8) subScTargetX = (gameWidth - subScreenWidth) << 8; - - if (subScTargetY < 0) subScTargetY = 0; - if (subScTargetY > (gameHeight - subScreenHeight) << 8) subScTargetY = (gameHeight - subScreenHeight) << 8; - } - - subScX += (subScTargetX - subScX) >> 2; - subScY += (subScTargetY - subScY) >> 2; - - if (displayModeIs8Bit) { - - if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) { - - int offsX = 0, offsY = 0; - - - if (getKeysHeld() & KEY_LEFT) { - offsX -= 1; - } - - if (getKeysHeld() & KEY_RIGHT) { - offsX += 1; - } - - if (getKeysHeld() & KEY_UP) { - offsY -= 1; - } - - if (getKeysHeld() & KEY_DOWN) { - offsY += 1; - } - - if (((gameScreenSwap) && (getKeysHeld() & KEY_L)) || ((!gameScreenSwap) && (getKeysHeld() & KEY_R))) { - subScTargetX += offsX << 8; - subScTargetY += offsY << 8; - } else { - scX += offsX; - scY += offsY; - } - } - - if (!scaledMode) { - - if (scX + 256 > gameWidth - 1) { - scX = gameWidth - 1 - 256; - } - - if (scX < 0) { - scX = 0; - } - - if (scY + 192 > gameHeight - 1) { - scY = gameHeight - 1 - 192; - } - - if (scY < 0) { - scY = 0; - } - - setZoomedScreenScroll(subScX, subScY); - setZoomedScreenScale(subScreenWidth, (subScreenHeight * 256) / 192); - - - setMainScreenScroll(scX << 8, (scY << 8) + (shakePos << 8)); - setMainScreenScale(256, 256); // 1:1 scale - - } else { - - if (scY > gameHeight - 192 - 1) { - scY = gameHeight - 192 - 1; - } - - if (scY < 0) { - scY = 0; - } - - setZoomedScreenScroll(subScX, subScY); - setZoomedScreenScale(subScreenWidth, (subScreenHeight * 256) / 192); - - setMainScreenScroll(64, (scY << 8) + (shakePos << 8)); - setMainScreenScale(320, 256); // 1:1 scale - - } - } else { - setZoomedScreenScroll(0, 0); - setZoomedScreenScale(320, 256); - - setMainScreenScroll(0, 0); - setMainScreenScale(320, 256); // 1:1 scale - } - - // Enable on screen keyboard when pen taps icon - if ((keyboardIcon) && (penX < 32) && (penY > 160) && (penHeld)) { - setKeyboardEnable(true); - } - - if (keyboardEnable) { - if (DS::getKeyboardClosed()) { - setKeyboardEnable(false); - } - } - - updateOAM(); - - //PALETTE[0] = RGB15(0, 0, 0); - REG_IF = IRQ_VBLANK; -} - -int getMillis() { - return currentTimeMillis; -// return frameCount * FRAME_TIME; -} - -void setTimerCallback(OSystem::TimerProc proc, int interval) { -// consolePrintf("Set timer proc %x, int %d\n", proc, interval); - callback = proc; - callbackInterval = interval; - callbackTimer = interval; -} - -void timerTickHandler() { - REG_IF = IRQ_TIMER0; - if ((callback) && (callbackTimer > 0)) { - callbackTimer--; - } - currentTimeMillis++; -} - -void setTalkPos(int x, int y) { -// if (gameID != Scumm::GID_SAMNMAX) { -// setTopScreenTarget(x, 0); -// } else { - setTopScreenTarget(x, y); -// } -} - -void setTopScreenTarget(int x, int y) { - subScTargetX = (x - (subScreenWidth >> 1)); - subScTargetY = (y - (subScreenHeight >> 1)); - - if (subScTargetX < 0) subScTargetX = 0; - if (subScTargetX > gameWidth - subScreenWidth) subScTargetX = gameWidth - subScreenWidth; - - if (subScTargetY < 0) subScTargetY = 0; - if (subScTargetY > gameHeight - subScreenHeight) subScTargetY = gameHeight - subScreenHeight; - - subScTargetX <<=8; - subScTargetY <<=8; -} - -void initHardware() { - // Guard band -//((int *) (0x023FFF00)) = 0xBEEFCAFE; - - - penInit(); - - powerON(POWER_ALL); -/* vramSetBankA(VRAM_A_MAIN_BG); - vramSetBankB(VRAM_B_MAIN_BG); - vramSetBankC(VRAM_C_SUB_BG); */ - vramSetBankI(VRAM_I_SUB_SPRITE); - vramSetBankG(VRAM_G_MAIN_SPRITE); - - currentTimeMillis = 0; - - -/* - // Set up a millisecond counter - TIMER0_CR = 0; - TIMER0_DATA = 0xFFFF; - TIMER0_CR = TIMER_ENABLE | TIMER_CASCADE; -*/ - - - - PALETTE[255] = RGB15(0,31,0); - - // Allocate save buffer for game screen -// savedBuffer = new u8[320 * 200]; - displayMode16Bit(); - - memset(BG_GFX, 0, 512 * 256 * 2); - scaledMode = true; - scX = 0; - scY = 0; - subScX = 0; - subScY = 0; - subScTargetX = 0; - subScTargetY = 0; - - //lcdSwap(); - POWER_CR &= ~POWER_SWAP_LCDS; - - frameCount = 0; - callback = NULL; - -// vramSetBankH(VRAM_H_SUB_BG); - - -// // Do text stuff - //BG0_CR = BG_MAP_BASE(0) | BG_TILE_BASE(1); -// BG0_Y0 = 48; - - PALETTE[255] = RGB15(31,31,31);//by default font will be rendered with color 255 - - //consoleInit() is a lot more flexible but this gets you up and running quick -// consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(1), 16); - //consolePrintSet(0, 6); - - //irqs are nice - irqInit(); -// irqInitHandler(); - irqSet(IRQ_VBLANK, VBlankHandler); - irqSet(IRQ_TIMER0, timerTickHandler); - irqSet(IRQ_TIMER2, soundBufferEmptyHandler); - - irqEnable(IRQ_VBLANK); - irqEnable(IRQ_TIMER0); - irqEnable(IRQ_TIMER2); - - - // Set up a millisecond timer - TIMER0_CR = 0; - TIMER0_DATA = (u32) TIMER_FREQ(1000); - TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1 | TIMER_IRQ_REQ; - REG_IME = 1; - - PALETTE[255] = RGB15(0,0,31); - - initSprites(); - -// videoSetModeSub(MODE_3_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D | DISPLAY_SPR_1D_BMP); //sub bg 0 will be used to print text - - // Convert texture from 24bit 888 to 16bit 1555, remembering to set top bit! - u8* srcTex = (u8 *) icons_raw; - for (int r = 32 * 160 ; r >= 0; r--) { - SPRITE_GFX_SUB[r] = 0x8000 | (srcTex[r * 3] >> 3) | ((srcTex[r * 3 + 1] >> 3) << 5) | ((srcTex[r * 3 + 2] >> 3) << 10); - SPRITE_GFX[r] = 0x8000 | (srcTex[r * 3] >> 3) | ((srcTex[r * 3 + 1] >> 3) << 5) | ((srcTex[r * 3 + 2] >> 3) << 10); - } - - WAIT_CR &= ~(0x0080); - REG_WRAM_CNT = 0; - -} - - -void setKeyboardIcon(bool enable) { - keyboardIcon = enable; -} - -bool getKeyboardIcon() { - return keyboardIcon; -} - - -//////////////////// -// Pen stuff -//////////////////// - - -void penInit() { - penDown = false; - penHeld = false; - penReleased = false; - penDownLastFrame = false; - penDownSaved = false; - penReleasedSaved = false; - penDownFrames = 0; - consumeKeys(); -} - -void penUpdate() { - -// if (getKeysHeld() & KEY_L) consolePrintf("%d, %d penX=%d, penY=%d tz=%d\n", IPC->touchXpx, IPC->touchYpx, penX, penY, IPC->touchZ1); - - if ((penDownFrames > 1)) { // Is this right? Dunno, but it works for me. - - if ((penHeld)) { - penHeld = true; - penDown = false; - - if ((IPC->touchZ1 > 0) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0)) { - penX = IPC->touchXpx + touchXOffset; - penY = IPC->touchYpx + touchYOffset; - } - - } else { - penDown = true; - penHeld = true; - penDownSaved = true; - - //if ( (ABS(penX - IPC->touchXpx) < 10) && (ABS(penY - IPC->touchYpx) < 10) ) { - if ((IPC->touchZ1 > 0) && (IPC->touchXpx > 0) && (IPC->touchYpx > 0)) { - penX = IPC->touchXpx; - penY = IPC->touchYpx; - } - //} - } - - } else { - if (penHeld) { - penReleased = true; - penReleasedSaved = true; - } else { - penReleased = false; - } - - penDown = false; - penHeld = false; - } - - - if ((IPC->touchZ1 > 0) || ((penDownFrames == 2)) ) { - penDownLastFrame = true; - penDownFrames++; - } else { - penDownLastFrame = false; - penDownFrames = 0; - } - -} - -int leftHandedSwap(int keys) { - // Start and select are unchanged - if (leftHandedMode) { - int result = keys & (~(KEY_R | KEY_L | KEY_Y | KEY_A | KEY_B | KEY_X | KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN)); - - if (keys & KEY_L) result |= KEY_R; - if (keys & KEY_R) result |= KEY_L; - - if (keys & KEY_LEFT) result |= KEY_Y; - if (keys & KEY_RIGHT) result |= KEY_A; - if (keys & KEY_DOWN) result |= KEY_B; - if (keys & KEY_UP) result |= KEY_X; - - if (keys & KEY_Y) result |= KEY_LEFT; - if (keys & KEY_A) result |= KEY_RIGHT; - if (keys & KEY_B) result |= KEY_DOWN; - if (keys & KEY_X) result |= KEY_UP; - - return result; - } else { - return keys; - } -} - -void keysUpdate() { - scanKeys(); - keysDownSaved |= leftHandedSwap(keysDown()); - keysReleasedSaved |= leftHandedSwap(keysUp()); -} - -int getKeysDown() { - return keysDownSaved; -} - -int getKeysHeld() { - return leftHandedSwap(keysHeld()); -} - -int getKeysReleased() { - return keysReleasedSaved; -} - -void consumeKeys() { - keysDownSaved = 0; - keysReleasedSaved = 0; -} - -bool getPenDown() { - return penDownSaved; -} - -bool getPenHeld() { - return penHeld; -} - -bool getPenReleased() { - return penReleasedSaved; -} - -void consumePenEvents() { - penDownSaved = false; - penReleasedSaved = false; -} - -int getPenX() { - int x = ((penX * touchScX) >> 8) + touchX; - x = x < 0? 0: (x > gameWidth - 1? gameWidth - 1: x); - return x; -} - -int getPenY() { - int y = ((penY * touchScY) >> 8) + touchY; - y = y < 0? 0: (y > gameHeight - 1? gameHeight - 1: y); - return y; -} - -GLvector getPenPos() { - GLvector v; - - v.x = (penX * inttof32(1)) / SCREEN_WIDTH; - v.y = (penY * inttof32(1)) / SCREEN_HEIGHT; - - return v; -} - -void formatSramOption() { - consolePrintf("The following files are present in save RAM:\n"); - DSSaveFileManager::instance()->listFiles(); - - consolePrintf("\nAre you sure you want to\n"); - consolePrintf("DELETE all files?\n"); - consolePrintf("A = Yes, X = No\n"); - - while (true) { - if (keysHeld() & KEY_A) { - DSSaveFileManager::instance()->formatSram(); - consolePrintf("SRAM cleared!\n"); - return; - } - - if (keysHeld() & KEY_X) { - consolePrintf("Whew, that was close!\n"); - return; - } - } -} - - -void setIndyFightState(bool st) { - indyFightState = st; - indyFightRight = true; -} - -bool getIndyFightState() { - return indyFightState; -} - -///////////////// -// GBAMP -///////////////// - -bool GBAMPAvail = false; - -void initGBAMP() { - FAT_InitFiles(); - if (disc_IsInserted()) { - GBAMPAvail = true; - consolePrintf("Found flash card reader!\n"); - } else { - GBAMPAvail = false; - consolePrintf("Flash card reader not found!\n"); - } -} - -bool isGBAMPAvailable() { - return GBAMPAvail; -} - - - -///////////////// -// Main -///////////////// - -static const Common::String test("poo", 1, 16); - - - -int main(void) -{ - soundCallback = NULL; - - - initHardware(); - - // Let arm9 read cartridge - *((u16 *) (0x04000204)) &= ~0x0080; - - lastCallbackFrame = 0; - tweak = 0; - - indyFightState = false; - indyFightRight = true; - - // CPU speed = 67108864 - // 8 frames = 2946 368.5 bytes per fr - -// playSound(stretch, 47619, false); -// playSound(twang, 11010, true); // 18640 - -// bufferSize = 10; - bufferRate = 22050; - bufferFrame = 0; -// bufferSamples = (bufferRate * bufferSize) / 60; - bufferSamples = 4096; - - bufferFirstHalf = false; - bufferSecondHalf = true; - - lastEventFrame = 0; - mouseMode = MOUSE_LEFT; - - - - - int bytes = (2 * (bufferSamples)) + 100; - - soundBuffer = (s16 *) malloc(bytes * 2); - - - soundHiPart = true; -/* - TIMER1_CR = 0; - TIMER1_DATA = TIMER_FREQ(bufferRate); - TIMER1_CR = TIMER_ENABLE | TIMER_DIV_1; - - TIMER2_CR = 0; - TIMER2_DATA = 0xFFFF - (bufferSamples / 2); - TIMER2_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_CASCADE; - */ - // 2945 - 2947 - - - -// for (int r = 2946; r < 3000; r++) { -// soundBuffer[r] = 30000; -// } - - - - consolePrintf("------------------------\n"); - consolePrintf("ScummVM DS\n"); - consolePrintf("Ported by Neil Millstone\n"); -#ifdef DS_SCUMM_BUILD - consolePrintf("Version 0.61 build A\n"); -#else - consolePrintf("Version 0.61 build B\n"); -#endif - consolePrintf("------------------------\n"); - consolePrintf("L/R + D-pad/pen: Scroll view\n"); - consolePrintf("D-pad left: Left mouse button\n"); - consolePrintf("D-pad right: Right mouse button\n"); - consolePrintf("D-pad up: Hover mouse\n"); - consolePrintf("D-pad down: Skip dialog line\n"); - consolePrintf("B button: Skip cutscenes\n"); - consolePrintf("Select: DS Options menu\n"); - consolePrintf("Start: Game menu\n"); - consolePrintf("Y (in game): Toggle console\n"); - consolePrintf("X: Toggle keyboard\n"); - consolePrintf("A: Swap screens\n"); - consolePrintf("L + R on bootup: Clear SRAM\n\n"); - consolePrintf("For a complete poo list see the\n"); - consolePrintf("help screen.\npoo\n"); - - - for (int r = 0; r < bytes; r++) { - soundBuffer[r] = 0; - } - - consolePrintf("length=%d str='%s'\n", test.size(), test.c_str()); - - swiWaitForVBlank(); - swiWaitForVBlank(); - playSound(soundBuffer, (bufferSamples * 2), true); - swiWaitForVBlank(); - swiWaitForVBlank(); - swiWaitForVBlank(); - - - - // Create a file system node to force search for a zip file in GBA rom space - DSFileSystemNode* node = new DSFileSystemNode(); - if (!node->getZip() || (!node->getZip()->isReady())) { - // If not found, init CF/SD driver - initGBAMP(); - } - delete node; - - - - updateStatus(); - - -// OSystem_DS::instance(); - g_system = new OSystem_DS(); - assert(g_system); - - if ((keysHeld() & KEY_L) && (keysHeld() & KEY_R)) { - formatSramOption(); - } - -// printf("'%s'", Common::ConfigManager::kTransientDomain.c_str()); - //printf("'%s'", Common::ConfigManager::kApplicationDomain.c_str()); - - - char* argv[2] = {"/scummvmds", "--config=scummvmb.ini"}; -#ifdef DS_NON_SCUMM_BUILD - - while (1) { - scummvm_main(2, (char **) &argv); - } -#else - while (1) { - scummvm_main(1, (char **) &argv); - } -#endif - - - return 0; -} - -} - -int main() { - DS::main(); -} diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h index 8c81b0f5e6..204f290b0b 100644 --- a/backends/platform/ds/arm9/source/dsmain.h +++ b/backends/platform/ds/arm9/source/dsmain.h @@ -24,125 +24,7 @@ #include "stdafx.h" #include "system.h" #include "scummconsole.h" -#include "nds/scummvm_ipc.h" - -namespace DS { - -// Pen reading functions -void penInit(); -void penUpdate(); -bool getPenDown(); -bool getPenHeld(); -bool getPenReleased(); -int getPenX(); -int getPenY(); -GLvector getPenPos(); -void consumePenEvents(); - -// Pad reading -int getKeysHeld(); -void keysUpdate(); -int getKeysDown(); -int getKeysReleased(); -void consumeKeys(); -int leftHandedSwap(int keys); - -// Video -void displayMode8Bit(); // Switch to 8-bit mode5 -void displayMode16Bit(); // Switch to 16-bit mode5 - -// Flip double buffer -void displayMode16BitFlipBuffer(); - -// Get address of current back buffer -u16* get16BitBackBuffer(); -u16* get8BitBackBuffer(); - -void setTalkPos(int x, int y); -void setTopScreenTarget(int x, int y); - -// Timers -void setTimerCallback(OSystem::TimerProc proc, int interval); // Setup a callback function at a regular interval -int getMillis(); // Return the current runtime in milliseconds -void doTimerCallback(); // Call callback function if required - -// Sound -void setSoundProc(OSystem::SoundProc proc, void* param); // Setup a callback function for sound -void doSoundCallback(); // Call function if sound buffers need more data -void playSound(const void* data, u32 length, bool loop, bool adpcm = false, int rate = 22050); // Start a sound -void stopSound(int channel); - -// Event queue -void addEventsToQueue(); -void VBlankHandler(); - -// Sam and Max Stuff -void setGameID(int id); -void setCursorIcon(const u8* icon, uint w, uint h, byte keycolor); - -// Shake -void setShakePos(int shakePos); - -// Reports -void memoryReport(); - -// GBAMP -bool isGBAMPAvailable(); - -// Sleep (I'd like some of that right now) -void checkSleepMode(); - -// Virtual keyboard -void setKeyboardIcon(bool enable); -bool getKeyboardIcon(); -void setKeyboardEnable(bool en); -bool getKeyboardEnable(); - -// Options -void setLeftHanded(bool enable); -void setTouchXOffset(int x); -void setTouchYOffset(int y); -void setUnscaledMode(bool enable); -void setIndyFightState(bool st); -bool getIndyFightState(); - -// Display -bool getIsDisplayMode8Bit(); -void setGameSize(int width, int height); -int getGameWidth(); -int getGameHeight(); - -} - - -#endif -/* ScummVMDS - Scumm Interpreter DS Port - * Copyright (C) 2002-2004 The ScummVM project and Neil Millstone - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _DSMAIN_H -#define _DSMAIN_H - -#include <nds.h> -#include "stdafx.h" -#include "system.h" -#include "scummconsole.h" -#include "nds/scummvm_ipc.h" +#include "NDS/scummvm_ipc.h" namespace DS { diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index bb5e44e722..e7df457490 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -184,189 +184,3 @@ void GBAMPSaveFileManager::listSavefiles(char const* prefix, bool* marks, int nu FAT_chdir("/"); } -/* ScummVMDS - Scumm Interpreter DS Port - * Copyright (C) 2002-2004 The ScummVM project and Neil Millstone - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include "gbampsave.h" -#include "gba_nds_fat.h" - -///////////////////////// -// GBAMP Save File -///////////////////////// - -GBAMPSaveFile::GBAMPSaveFile(char* name, bool saveOrLoad) { - handle = DS::std_fopen(name, saveOrLoad? "w": "r"); - //consolePrintf("%s handle is %d\n", name, handle); -// consolePrintf("Created %s\n", name); - bufferPos = 0; - saveSize = 0; - flushed = 0; -} - -GBAMPSaveFile::~GBAMPSaveFile() { - flushSaveBuffer(); - DS::std_fclose(handle); -} - -uint32 GBAMPSaveFile::read(void *buf, uint32 size) { - saveSize += size; -// consolePrintf("Read %d %d ", size, saveSize); - return DS::std_fread(buf, 1, size, handle); -} - -bool GBAMPSaveFile::eos() const { - return DS::std_feof(handle); -} - -void GBAMPSaveFile::skip(uint32 bytes) { - DS::std_fseek(handle, bytes, SEEK_CUR); -} - -void GBAMPSaveFile::flushSaveBuffer() { - if (bufferPos != 0) { -// consolePrintf("Flushing %d bytes\n", bufferPos); - flushed += bufferPos; - DS::std_fwrite(buffer, 1, bufferPos, handle); - bufferPos = 0; - } -} - -uint32 GBAMPSaveFile::pos() const { - return DS::std_ftell(handle); -} - -uint32 GBAMPSaveFile::size() const { - int position = pos(); - DS::std_fseek(handle, 0, SEEK_END); - int size = DS::std_ftell(handle); - DS::std_fseek(handle, position, SEEK_SET); - return size; -} - -void GBAMPSaveFile::seek(int32 pos, int whence) { - DS::std_fseek(handle, pos, whence); -} - - -uint32 GBAMPSaveFile::write(const void *buf, uint32 size) { - if (bufferPos + size > SAVE_BUFFER_SIZE) { - flushSaveBuffer(); - saveSize += size; - DS::std_fwrite(buf, 1, size, handle); -/* int pos = 0; - - int rest = SAVE_BUFFER_SIZE - bufferPos; - memcpy(buffer + bufferPos, buf, rest); - bufferPos = 512; - pos += rest; - flushSaveBuffer(); - size -= rest; -// consolePrintf("First section: %d\n", rest); - - while (size >= 512) { - DS::std_fwrite(((char *) (buf)) + pos, 1, 512, handle); - size -= 512; - pos += 512; -// consolePrintf("Full chunk, %d left ", size); - } - - bufferPos = 0; - memcpy(buffer + bufferPos, ((char *) (buf)) + pos, size); - bufferPos += size; -// consolePrintf("%d left in buffer ", bufferPos);*/ - - } else { - - memcpy(buffer + bufferPos, buf, size); - bufferPos += size; - - saveSize += size; - } - -// if ((size > 100) || (size <= 0)) consolePrintf("Write %d bytes\n", size); - return size; -} - - -////////////////////////// -// GBAMP Save File Manager -////////////////////////// - -GBAMPSaveFileManager::GBAMPSaveFileManager() { - -} - -GBAMPSaveFileManager::~GBAMPSaveFileManager() { - -} - -Common::SaveFile* GBAMPSaveFileManager::openSavefile(char const* name, bool saveOrLoad) { - char fileSpec[128]; - - strcpy(fileSpec, getSavePath()); - - if (fileSpec[strlen(fileSpec) - 1] == '/') { - sprintf(fileSpec, "%s%s", getSavePath(), name); - } else { - sprintf(fileSpec, "%s/%s", getSavePath(), name); - } - -// consolePrintf(fileSpec); - - return new GBAMPSaveFile(fileSpec, saveOrLoad); -} - -void GBAMPSaveFileManager::listSavefiles(char const* prefix, bool* marks, int num) { - enum { TYPE_NO_MORE = 0, TYPE_FILE = 1, TYPE_DIR = 2 }; - char name[128]; - char path[128]; - - DS::std_cwd((char *) getSavePath()); - - int fileType = FAT_FindFirstFile(name); - - for (int r = 0; r < num; r++) { - marks[r] = false; - } - - do { - - if (fileType == TYPE_FILE) { - - FAT_GetLongFilename(name); - - for (int r = 0; r < num; r++) { - char str[128]; - - - sprintf(str, "%s%02d", prefix, r); -// consolePrintf("%s != %s", str, name); - if (!stricmp(str, name)) { - marks[r] = true; -// consolePrintf("Matched %d", r); - } - - } - - } - - } while ((fileType = FAT_FindNextFile(name))); - - FAT_chdir("/"); -} diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 37a79728c3..08ecf42142 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -482,487 +482,3 @@ OSystem *OSystem_DS_create() { return new OSystem_DS(); } -/* ScummVMDS - Scumm Interpreter DS Port - * Copyright (C) 2002-2004 The ScummVM project and Neil Millstone - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - -#include "stdafx.h" -#include "common/scummsys.h" -#include "common/system.h" -#include "system.h" - -#include "common/util.h" -#include "common/rect.h" -#include "common/savefile.h" - -#include "osystem_ds.h" -#include "nds.h" -#include "dsmain.h" -#include "nds/registers_alt.h" -#include "config-manager.h" -#include "common/str.h" -#include "cdaudio.h" -#include "graphics/surface.h" - -OSystem_DS* OSystem_DS::_instance = NULL; - -OSystem_DS::OSystem_DS() -{ - eventNum = 0; - lastPenFrame = 0; - queuePos = 0; - _instance = this; -} - -OSystem_DS::~OSystem_DS() { -} - -void OSystem_DS::initBackend() { - ConfMan.setInt("autosave_period", 0); - ConfMan.setBool("FM_medium_quality", true); -} - -bool OSystem_DS::hasFeature(Feature f) { -// consolePrintf("hasfeature\n"); - return (f == kFeatureVirtualKeyboard); -} - -void OSystem_DS::setFeatureState(Feature f, bool enable) { -// consolePrintf("setfeature f=%d e=%d\n", f, enable); - if (f == kFeatureVirtualKeyboard) DS::setKeyboardIcon(enable); -} - -bool OSystem_DS::getFeatureState(Feature f) { -// consolePrintf("getfeat\n"); - if (f == kFeatureVirtualKeyboard) return DS::getKeyboardIcon(); - return false; -} - -const OSystem::GraphicsMode* OSystem_DS::getSupportedGraphicsModes() const { - return s_supportedGraphicsModes; -} - - -int OSystem_DS::getDefaultGraphicsMode() const { - return 0; -} - -bool OSystem_DS::setGraphicsMode(int mode) { - return true; -} - -bool OSystem_DS::setGraphicsMode(const char *name) { -// consolePrintf("Set gfx mode %s\n", name); - return true; -} - -int OSystem_DS::getGraphicsMode() const { - return -1; -} - -void OSystem_DS::initSize(uint width, uint height) { -// consolePrintf("Set gfx mode %d x %d\n", width, height); - DS::setGameSize(width, height); -} - -int16 OSystem_DS::getHeight() { - return 200; -} - -int16 OSystem_DS::getWidth() { - return 320; -} - -void OSystem_DS::setPalette(const byte *colors, uint start, uint num) { -// consolePrintf("Set palette %d, %d colours\n", start, num); - if (!DS::getIsDisplayMode8Bit()) return; - - for (unsigned int r = start; r < start + num; r++) { - int red = *colors; - int green = *(colors + 1); - int blue = *(colors + 2); - - red >>= 3; - green >>= 3; - blue >>= 3; - - BG_PALETTE[r] = red | (green << 5) | (blue << 10); - if (!DS::getKeyboardEnable()) { - BG_PALETTE_SUB[r] = red | (green << 5) | (blue << 10); - } -// if (num == 16) consolePrintf("pal:%d r:%d g:%d b:%d\n", r, red, green, blue); - - colors += 4; - } -} - - -void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) { -// consolePrintf("Grabpalette"); - - for (unsigned int r = start; r < start + num; r++) { - *colors++ = (BG_PALETTE[r] & 0x001F) << 3; - *colors++ = (BG_PALETTE[r] & 0x03E0) >> 5 << 3; - *colors++ = (BG_PALETTE[r] & 0x7C00) >> 10 << 3; - } -} - - -void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) -{ -// consolePrintf("Copy rect %d, %d %d, %d ", x, y, w, h); - - if (w <= 1) return; - if (h < 0) return; - if (!DS::getIsDisplayMode8Bit()) return; - - u16* bgSub = (u16 *) BG_GFX_SUB; - u16* bg = (u16 *) DS::get8BitBackBuffer(); - u16* src = (u16 *) buf; - - if (DS::getKeyboardEnable()) { - - for (int dy = y; dy < y + h; dy++) { - u16* dest = bg + (dy << 8) + (x >> 1); - - DC_FlushRange(src, w << 1); - DC_FlushRange(dest, w << 1); - dmaCopyHalfWords(3, src, dest, w); - - src += pitch >> 1; - } - - } else { - for (int dy = y; dy < y + h; dy++) { - u16* dest1 = bg + (dy << 8) + (x >> 1); - u16* dest2 = bgSub + (dy << 8) + (x >> 1); - - DC_FlushRange(src, w << 1); - DC_FlushRange(dest1, w << 1); - DC_FlushRange(dest2, w << 1); - - dmaCopyHalfWords(3, src, dest1, w); - dmaCopyHalfWords(3, src, dest2, w); - - src += pitch >> 1; - } - } - -// consolePrintf("Done\n"); - - - -} - -void OSystem_DS::updateScreen() -{ - DS::displayMode16BitFlipBuffer(); - DS::doSoundCallback(); -// DS::doTimerCallback(); - DS::addEventsToQueue(); -} - -void OSystem_DS::setShakePos(int shakeOffset) { - DS::setShakePos(shakeOffset); -} - -void OSystem_DS::showOverlay () -{ -// consolePrintf("showovl\n"); - DS::displayMode16Bit(); -} - -void OSystem_DS::hideOverlay () -{ - DS::displayMode8Bit(); -} - -void OSystem_DS::clearOverlay () -{ - memset((u16 *) DS::get16BitBackBuffer(), 0, 512 * 256 * 2); -// consolePrintf("clearovl\n"); -} - -void OSystem_DS::grabOverlay (OverlayColor *buf, int pitch) -{ -// consolePrintf("grabovl\n"); -} - -void OSystem_DS::copyRectToOverlay (const OverlayColor *buf, int pitch, int x, int y, int w, int h) -{ - u16* bg = (u16 *) DS::get16BitBackBuffer(); - u16* src = (u16 *) buf; - -// if (x + w > 256) w = 256 - x; - //if (x + h > 256) h = 256 - y; - -// consolePrintf("Copy rect ovl %d, %d %d, %d %d\n", x, y, w, h, pitch); - - - - for (int dy = y; dy < y + h; dy++) { - - - // Slow but save copy: - for (int dx = x; dx < x + w; dx++) { - - *(bg + (dy * 512) + dx) = *src; - //if ((*src) != 0) consolePrintf("%d,%d: %d ", dx, dy, *src); - //consolePrintf("%d,", *src); - src++; - } - src += (pitch - w); - - // Fast but broken copy: (why?) - /* - REG_IME = 0; - dmaCopy(src, bg + (dy << 9) + x, w * 2); - REG_IME = 1; - - src += pitch;*/ - } - -// consolePrintf("Copy rect ovl done"); - -} - -int16 OSystem_DS::getOverlayHeight() -{ -// consolePrintf("getovlheight\n"); - return getHeight(); -} - -int16 OSystem_DS::getOverlayWidth() -{ -// consolePrintf("getovlwid\n"); - return getWidth(); -} - - -bool OSystem_DS::showMouse(bool visible) -{ - return true; -} - -void OSystem_DS::warpMouse(int x, int y) -{ -} - -void OSystem_DS::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetCursorScale) { - DS::setCursorIcon(buf, w, h, keycolor); -} - -void OSystem_DS::addEvent(Event& e) { - eventQueue[queuePos++] = e; -} - -bool OSystem_DS::pollEvent(Event &event) -{ - - if (lastPenFrame != DS::getMillis()) { - - if (eventNum == queuePos) { - eventNum = 0; - queuePos = 0; - // Bodge - this last event seems to be processed sometimes and not others. - // So we make it something harmless which won't cause any adverse effects. - event.type = EVENT_KEYUP; - event.kbd.ascii = 0; - event.kbd.keycode = 0; - event.kbd.flags = 0; - return false; - } else { - event = eventQueue[eventNum++]; - return true; - } - } - - return false; - -/* if (lastPenFrame != DS::getMillis()) { - if ((eventNum == 0)) { - event.type = EVENT_MOUSEMOVE; - event.mouse = Common::Point(DS::getPenX(), DS::getPenY()); - eventNum = 1; - return true; - } - if (eventNum == 1) { - eventNum = 0; - lastPenFrame = DS::getMillis(); - if (DS::getPenDown()) { - event.type = EVENT_LBUTTONDOWN; - event.mouse = Common::Point(DS::getPenX(), DS::getPenY()); - consolePrintf("Down %d, %d ", event.mouse.x, event.mouse.y); - return true; - } else if (DS::getPenReleased()) { - event.type = EVENT_LBUTTONUP; - event.mouse = Common::Point(DS::getPenX(), DS::getPenY()); - consolePrintf("Up %d, %d ", event.mouse.x, event.mouse.y); - return true; - } else { - return false; - } - } - }*/ - - return false; -} - -uint32 OSystem_DS::getMillis() -{ - return DS::getMillis(); -} - -void OSystem_DS::delayMillis(uint msecs) -{ - int st = getMillis(); - DS::addEventsToQueue(); - DS::CD::update(); - - DS::doSoundCallback(); - while (st + msecs >= getMillis()) { - DS::doSoundCallback(); - } - - DS::doTimerCallback(); - DS::checkSleepMode(); - DS::addEventsToQueue(); -} - -void OSystem_DS::setTimerCallback(TimerProc callback, int interval) -{ -// consolePrintf("Settimercallback interval=%d\n", interval); - DS::setTimerCallback(callback, interval); -} - -OSystem::MutexRef OSystem_DS::createMutex(void) -{ - return NULL; -} - -void OSystem_DS::lockMutex(MutexRef mutex) -{ -} - -void OSystem_DS::unlockMutex(MutexRef mutex) -{ -} - -void OSystem_DS::deleteMutex(MutexRef mutex) -{ -} - -bool OSystem_DS::setSoundCallback(SoundProc proc, void *param) -{ -// consolePrintf("Setsoundcallback"); - DS::setSoundProc(proc, param); - return true; -} - -void OSystem_DS::clearSoundCallback() -{ - consolePrintf("Clearing sound callback"); -// DS::setSoundProc(NULL, NULL); -} - -int OSystem_DS::getOutputSampleRate() const -{ - return 11025; -} - -bool OSystem_DS::openCD(int drive) -{ - return DS::CD::checkCD(); -} - -bool OSystem_DS::pollCD() -{ - return DS::CD::isPlaying(); -} - -void OSystem_DS::playCD(int track, int num_loops, int start_frame, int duration) -{ - DS::CD::playTrack(track, num_loops, start_frame, duration); -} - -void OSystem_DS::stopCD() -{ - DS::CD::stopTrack(); -} - -void OSystem_DS::updateCD() -{ -} - -void OSystem_DS::quit() -{ -/* consolePrintf("Soft resetting..."); - IPC->reset = 1; - REG_IE = 0; - - asm("swi 0x26\n"); - swiSoftReset();*/ -} - -void OSystem_DS::setWindowCaption(const char *caption) -{ -} - -void OSystem_DS::displayMessageOnOSD(const char *msg) -{ -} - -Common::SaveFileManager* OSystem_DS::getSavefileManager() -{ - bool forceSram; - - if (ConfMan.hasKey("forcesramsave", "ds")) { - forceSram = ConfMan.getBool("forcesramsave", "ds"); - } else { - forceSram = false; - } - if (forceSram) { - consolePrintf("Using SRAM save method!\n"); - } - - if (DS::isGBAMPAvailable() && (!forceSram)) { - return &mpSaveManager; - } else { - return &saveManager; - } -} - -bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) { - surf->create(DS::getGameWidth(), DS::getGameHeight(), 1); - memcpy(surf->pixels, DS::get8BitBackBuffer(), DS::getGameWidth() * DS::getGameHeight()); - return true; -} - -void OSystem_DS::setFocusRectangle(Common::Rect& rect) { - DS::setTalkPos(rect.left + rect.width() / 2, rect.top + rect.height() / 2); -} - -void OSystem_DS::clearFocusRectangle() { - -} - - -OSystem *OSystem_DS_create() { - return new OSystem_DS(); -} - diff --git a/backends/platform/ds/arm9/source/portdefs.cpp b/backends/platform/ds/arm9/source/portdefs.cpp index b9d107a4db..cbce3544b0 100644 --- a/backends/platform/ds/arm9/source/portdefs.cpp +++ b/backends/platform/ds/arm9/source/portdefs.cpp @@ -41,44 +41,3 @@ time_t DS_time(long* t) { } } -/* ScummVMDS - Scumm Interpreter DS Port - * Copyright (C) 2002-2004 The ScummVM project and Neil Millstone - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include "portdefs.h" -#include <string.h> -#include "nds/dma.h" -#include "osystem_ds.h" - -time_t DS_time(time_t) { - if (OSystem_DS::instance()) { - return 0xABCD1234 + (OSystem_DS::instance()->getMillis() / 1000); - } else { - return 0xABCD1234; - } -} - -time_t DS_time(long* t) { - if (OSystem_DS::instance()) { - if (t) *t = 0xABCD1234 + (OSystem_DS::instance()->getMillis() / 1000); - return 0xABCD1234 + (OSystem_DS::instance()->getMillis() / 1000); - } else { - if (t) *t = 0xABCD1234; - return 0xABCD1234; - } -} diff --git a/backends/platform/ds/arm9/source/ramsave.cpp b/backends/platform/ds/arm9/source/ramsave.cpp index 8a23baff73..edb4b19079 100644 --- a/backends/platform/ds/arm9/source/ramsave.cpp +++ b/backends/platform/ds/arm9/source/ramsave.cpp @@ -457,462 +457,3 @@ void DSSaveFileManager::flushToSaveRAM() { } // consolePrintf("SRAM free: %d bytes\n", getBytesFree()); } -/* Ramsave - * Copyright (C) 2002-2004 Neil Millstone - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - // Save in order 1,2,3,4,larger 2,5 -#include "stdafx.h" -#include "system.h" -#include "ramsave.h" -#include "nds.h" -#include "compressor/lz.h" - -#define CART_RAM ((vu8 *) (0x0A000000)) - -DSSaveFile::DSSaveFile() { - ptr = 0; - saveCompressed = false; - save.isValid = false; - ownsData = false; - isOpenFlag = true; - isTempFile = false; -} - -DSSaveFile::DSSaveFile(SCUMMSave* s, bool compressed, u8* data) { - save = *s; - saveData = data; - ptr = 0; - saveCompressed = compressed; - isOpenFlag = true; - - if (saveCompressed) { - u8* uncompressed = new unsigned char[save.size]; - if (!uncompressed) consolePrintf("Out of memory allocating %d!\n", save.size); - LZ_Uncompress(saveData, uncompressed, save.compressedSize); - saveData = uncompressed; - ownsData = true; - saveCompressed = false; -// consolePrintf("Decompressed. name=%s size=%d (%d)", save.name, save.size, save.compressedSize); - - } else { - ownsData = false; - origHeader = s; - } - - if (save.magic == (int) 0xBEEFCAFE) { - save.isValid = true; - } else { - save.isValid = false; - } - - isTempFile = false; -} - -DSSaveFile::~DSSaveFile() { - if (!ownsData) { - *origHeader = save; - DSSaveFileManager::instance()->flushToSaveRAM(); - } - if (ownsData) { - delete saveData; - } -} - -bool DSSaveFile::loadFromSaveRAM(vu8* address) { - - SCUMMSave newSave; - - for (int t = 0; t < (int) sizeof(newSave); t++) { - ((char *) (&newSave))[t] = *(address + t); - } - - - if (newSave.magic == 0xBEEFCAFE) { - newSave.isValid = true; - - *((u16 *) (0x4000204)) |= 0x3; - - saveData = new unsigned char[newSave.compressedSize]; - - for (int t = 0; t < (int) newSave.compressedSize; t++) { - ((char *) (saveData))[t] = *(address + t + sizeof(newSave)); - } - - if (ownsData) delete this->saveData; - save = newSave; - saveCompressed = true; - this->saveData = saveData; - ownsData = true; - ptr = 0; - return true; - } - - return false; -} - -void DSSaveFile::compress() { - if (!saveCompressed) { - unsigned char* compBuffer = new unsigned char[(save.size * 110) / 100]; - int compSize = LZ_Compress((u8 *) saveData, compBuffer, save.size); - save.compressedSize = compSize; - - - - delete saveData; - - // Make the save smaller - saveData = (u8 *) realloc(compBuffer, save.compressedSize); - saveCompressed = true; - } -} - -int DSSaveFile::saveToSaveRAM(vu8* address) { - - unsigned char* compBuffer; - bool failed; - - - int compSize; - - compress(); - - compSize = save.compressedSize; - compBuffer = saveData; - - if (DSSaveFileManager::instance()->getBytesFree() >= getRamUsage()) { - - DSSaveFileManager::instance()->addBytesFree(-getRamUsage()); - - // Write header - for (int t = 0; t < sizeof(save); t++) { - while (*(address + t) != ((char *) (&save))[t]) { - *(address + t) = ((char *) (&save))[t]; - } - } - - // Write compressed buffer - for (int t = sizeof(save); t < (int) sizeof(save) + compSize; t++) { - while (*(address + t) != compBuffer[t - sizeof(save)]) { - *(address + t) = compBuffer[t - sizeof(save)]; - } - } - - failed = false; - } else { - failed = true; - } - - - return failed? 0: compSize + sizeof(save); - -} - -void DSSaveFile::reset() { - ptr = 0; -} - -uint32 DSSaveFile::read(void *buf, uint32 size) { - if (ptr + size > save.size) { - size = save.size - ptr; - if (size < 0) size = 0; - } - memcpy(buf, saveData + ptr, size); -// consolePrintf("byte: %d ", ((u8 *) (buf))[0]); - - ptr += size; - return size; -} - -uint32 DSSaveFile::pos() const { - return ptr; -} - -uint32 DSSaveFile::size() const { - return save.size; -} - -void DSSaveFile::seek(int32 pos, int whence) { - switch (whence) { - case SEEK_SET: { - ptr = pos; - break; - } - case SEEK_CUR: { - ptr += pos; - break; - } - case SEEK_END: { - ptr = save.size - pos; - break; - } - } -} - -bool DSSaveFile::eos() const { - return ptr >= (int) save.size; -} - -void DSSaveFile::skip(uint32 bytes) { - ptr = ptr + bytes; - if (ptr > (int) save.size) ptr = save.size; -} - -uint32 DSSaveFile::write(const void *buf, uint32 size) { - - if (ptr + size > DS_MAX_SAVE_SIZE) { - size = DS_MAX_SAVE_SIZE - ptr; - } - - memcpy(saveData + ptr, buf, size); - ptr += size; - save.size += size; - return size; -} - -bool DSSaveFile::matches(char* prefix, int num) { - char str[16]; - if (isValid()) { - sprintf(str, "%s%02d", prefix, num); - if (!strcmp(str, save.name)) { - return true; - } else { - return false; - } - } else { - return false; - } -} - -bool DSSaveFile::matches(char* filename) { - if (isValid()) { - return !strcmp(save.name, filename); - } else { - return false; - } -} - -void DSSaveFile::setName(char *name) { - save.isValid = true; - save.magic = 0xBEEFCAFE; - ownsData = true; - save.size = 0; - save.compressedSize = 0; - saveData = new unsigned char[DS_MAX_SAVE_SIZE]; - strcpy(save.name, name); - - if ((strstr(name, ".s99")) || (strstr(name, ".c"))) { - isTempFile = true; - } else { - isTempFile = false; - } -} - -void DSSaveFile::clearData() { - save.size = 0; - - if (saveCompressed) { - if (ownsData) { - delete saveData; - DSSaveFileManager::instance()->addBytesFree(getRamUsage()); - } - saveData = new unsigned char[DS_MAX_SAVE_SIZE]; - saveCompressed = false; - ownsData = true; - } - -} - -void DSSaveFile::deleteFile() { - if (isValid()) { - if (ownsData) { - DSSaveFileManager::instance()->addBytesFree(getRamUsage()); - delete saveData; - saveData = NULL; - } - ptr = 0; - saveCompressed = false; - save.isValid = false; - ownsData = false; - isOpenFlag = true; - } -} - -DSSaveFileManager::DSSaveFileManager() { - instancePtr = this; - - *((u16 *) (0x4000204)) |= 0x3; - swiWaitForVBlank(); - - loadAllFromSRAM(); -} - -DSSaveFileManager::~DSSaveFileManager() { - instancePtr = NULL; -} - -void DSSaveFileManager::loadAllFromSRAM() { - int addr = 1; - - for (int r = 0; r < 8; r++) { - gbaSave[r].deleteFile(); - } - - sramBytesFree = 65533; - - // Try to find saves in save RAM - for (int r = 0; r < 8; r++) { - if (gbaSave[r].loadFromSaveRAM(CART_RAM + addr)) { - addr += gbaSave[r].getRamUsage(); - sramBytesFree -= gbaSave[r].getRamUsage(); - } - } - -} - -void DSSaveFileManager::formatSram() { - for (int r = 0; r < 65533; r++) { - *(CART_RAM + r) = 0; - } - - loadAllFromSRAM(); -} - -void DSSaveFileManager::listFiles() { - for (int r = 0; r < 8; r++) { - if (gbaSave[r].isValid()) { - consolePrintf("'%s': %d bytes\n", gbaSave[r].getName(), gbaSave[r].getRamUsage()); - } - } - consolePrintf("SRAM free: %d bytes\n", getBytesFree()); -} - -DSSaveFileManager* DSSaveFileManager::instancePtr = NULL; - -Common::SaveFile *DSSaveFileManager::openSavefile(const char* filename, bool saveOrLoad) { - for (int r = 0; r < 8; r++) { - if (gbaSave[r].isValid() && (gbaSave[r].matches((char *) filename))) { -// consolePrintf("Matched save %d (%d)\n", r, gbaSave[r].getSize()); - gbaSave[r].reset(); - //consolePrintf("reset "); - if (saveOrLoad) gbaSave[r].clearData(); -// consolePrintf("cleared "); - return gbaSave[r].clone(); - } - } - - if (saveOrLoad) { - return makeSaveFile(filename, saveOrLoad); - } else { - return NULL; - } -} - - - -DSSaveFile* DSSaveFile::clone() { -// consolePrintf("Clone %s %d\n", save.name, save.size); - return new DSSaveFile(&save, saveCompressed, saveData); -} - -void DSSaveFileManager::deleteFile(char* name) { -// consolePrintf("Deleting %s", name); - for (int r = 0; r < 8; r++) { - if (gbaSave[r].isValid() && (gbaSave[r].matches((char *) name))) { - gbaSave[r].deleteFile(); - } - } - flushToSaveRAM(); -} - -void DSSaveFileManager::listSavefiles(const char *prefix, bool *marks, int num) { - memset(marks, false, num*sizeof(bool)); - - for (int saveNum = 0; saveNum < num; saveNum++) { - for (int r = 0; r < 8; r++) { - if (gbaSave[r].isValid() && (gbaSave[r].matches((char *) prefix, saveNum))) { - marks[saveNum] = true; - } - } - } - -} - -Common::SaveFile *DSSaveFileManager::makeSaveFile(const char *filename, bool saveOrLoad) { - - // Find a free save slot - int r = 0; - - while ((r < 8) && (gbaSave[r].isValid())) { - r++; - } - - if ((r == 8) && (gbaSave[r].isValid())) { - // No more saves - return NULL; - } else { - // Allocate this save -// consolePrintf("Allocated save %d\n", r); - gbaSave[r].setName((char *) filename); - gbaSave[r].reset(); - return gbaSave[r].clone(); - } -} - -void DSSaveFileManager::flushToSaveRAM() { - int cartAddr = 1; - int s; - - *((u16 *) (0x4000204)) |= 0x3; - - swiWaitForVBlank(); - - int size = 0; - for (int r = 0; (r < 8); r++) { - if (gbaSave[r].isValid()) { - gbaSave[r].compress(); - if (!gbaSave[r].isTemp()) size += gbaSave[r].getRamUsage(); - } - } - - if (size <= 65533) { - - for (int r = 0; r < 65533; r++) { - *(CART_RAM + r) = 0; - } - - sramBytesFree = 65533; - - for (int r = 0; (r < 8); r++) { - if (gbaSave[r].isValid() && (!gbaSave[r].isTemp())) { - - cartAddr += s = gbaSave[r].saveToSaveRAM(CART_RAM + cartAddr); - - /* if (s == 0) { - consolePrintf("WARNING: Save didn't fit in cart RAM and has been lost!! Delete files and save again.", gbaSave[r].getName()); - failed = true; - }*/ - } - } - } else { - - consolePrintf("WARNING: Save didn't fit in cart RAM and has been lost!! Delete files and save again."); - loadAllFromSRAM(); - - } -// consolePrintf("SRAM free: %d bytes\n", getBytesFree()); -} diff --git a/backends/platform/ds/arm9/source/scummconsole.c b/backends/platform/ds/arm9/source/scummconsole.c index 7efa43e24c..e526e921e5 100644 --- a/backends/platform/ds/arm9/source/scummconsole.c +++ b/backends/platform/ds/arm9/source/scummconsole.c @@ -559,564 +559,3 @@ void consoleClear(void) consolePrintSet(0,0); } -////////////////////////////////////////////////////////////////////// -// -// console.cpp -- provides basic print functionality -// -// version 0.1, February 14, 2005 -// -// Copyright (C) 2005 Michael Noland (joat) and Jason Rogers (dovoto) -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any -// damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any -// purpose, including commercial applications, and to alter it and -// redistribute it freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you -// must not claim that you wrote the original software. If you use -// this software in a product, an acknowledgment in the product -// documentation would be appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and -// must not be misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source -// distribution. -// -// Changelog: -// 0.1: First version -// 0.2: Fixed sprite mapping bug. 1D mapping should work now. -// Changed some register defines for consistency. -// -////////////////////////////////////////////////////////////////////// - - -#include <NDS.h> -#include "scummconsole.h" - -#include <stdarg.h> - -#include <default_font_bin.h> - -///////////////////////////////////////// -//global console variables - -#define CONSOLE_WIDTH 32 -#define CONSOLE_HEIGHT 24 -#define TAB_SIZE 3 - -//map to print to -u16* fontMap; - -//location of cursor -u8 row, col; - -//font may not start on a character base boundry -u16 fontOffset; - -//the first character in the set (0 if you have a full set) -u16 fontStart; - -//the 16-color palette to use -u16 fontPal; - - - - -/////////////////////////////////////////////////////////// -//consoleInit -// param: -// font: 16 color font -// charBase: the location the font data will be loaded to -// numCharacters: count of characters in the font -// charStart: The ascii number of the first character in the font set -// if you have a full set this will be zero -// map: pointer to the map you will be printing to. -// pal: specifies the 16 color palette to use, if > 15 it will change all non-zero -// entries in the font to use palette index 255 -void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth) -{ - int i; - - row = col = 0; - - fontStart = charStart; - - fontOffset = 0; - - fontMap = map; - - if(bitDepth == 16) - { - if(pal < 16) - { - fontPal = pal << 12; - - for (i = 0; i < numCharacters * 16; i++) - charBase[i] = font[i]; - } - else - { - fontPal = 15 << 12; - - for (i = 0; i < numCharacters * 16; i++) - { - u16 temp = 0; - - if(font[i] & 0xF) - temp |= 0xF; - if(font[i] & 0xF0) - temp |= 0xF0; - if(font[i] & 0xF00) - temp |= 0xF00; - if(font[i] & 0xF000) - temp |= 0xF000; - - charBase[i] = temp; - } - } - }//end if bitdepth - else - { - fontPal = 0; - for(i = 0; i < numCharacters * 16; i++) - { - u32 temp = 0; - - if(font[i] & 0xF) - temp = 255; - if(font[i] & 0xF0) - temp |= 255 << 8; - if(font[i] & 0xF00) - temp |= 255 << 16; - if(font[i] & 0xF000) - temp |= 255 << 24; - - ((u32*)charBase)[i] = temp; - - } - } -} - -void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth) -{ - consoleInit((u16 *) default_font_bin, charBase, 256, 0, map, CONSOLE_USE_COLOR255, bitDepth); -} - -void consolePrintSet(int x, int y) -{ - if(y < CONSOLE_HEIGHT) - row = y; - else - row = CONSOLE_HEIGHT - 1; - - if(x < CONSOLE_WIDTH) - col = x; - else - col = CONSOLE_WIDTH - 1; -} - -void consolePrintChar(char c) -{ - int i; - - if(col >= CONSOLE_WIDTH) - { - col = 0; - - row++; - } - - if(row >= CONSOLE_HEIGHT) - { - row--; - - for(i = CONSOLE_WIDTH; i < CONSOLE_HEIGHT * CONSOLE_WIDTH; i++) - fontMap[i - CONSOLE_WIDTH] = fontMap[i]; - for(i = 0; i < CONSOLE_WIDTH; i++) - fontMap[i + (CONSOLE_HEIGHT-1)*CONSOLE_WIDTH] = fontPal | (u16)(' ' + fontOffset - fontStart); - - - } - - switch(c) - { - - case 10: - case 11: - case 12: - case 13: - row++; - col = 0; - break; - case 9: - col += TAB_SIZE; - break; - default: - fontMap[col + row * CONSOLE_WIDTH] = fontPal | (u16)(c + fontOffset - fontStart); - col++; - break; - - } - - -} - - -void printX(int w, unsigned d) -{ - int loop = 0; - int i = 0; - - char buf[20] = {0}; - - - while(d > 0) - { - buf[loop++] = d & 0xF; - d = d>>4; - } - - for (i = 7; i >= 0; i--) - { - if(buf[i] || i < loop) - { - if(buf[i] < 10) - consolePrintChar(buf[i] + '0'); - else - consolePrintChar(buf[i] + 'A' - 10); - } - else if(i < w) - consolePrintChar(' '); - } -} - -void printx(int w, unsigned int d) -{ - int loop = 0; - int i = 0; - - char buf[20] = {0}; - - while(d > 0) - { - buf[loop++] = d & 0xF; - d = d>>4; - } - - for (i = 7; i >= 0; i--) - { - if(buf[i] || i < loop) - { - if(buf[i] < 10) - consolePrintChar(buf[i] + '0'); - else - consolePrintChar(buf[i] + 'a' - 10); - } - else if(i < w) - consolePrintChar(' '); - } -} - -void printInt(int w, int d) -{ - int loop = 0; - int i = 0; - - char buf[20] = {0}; - - if(d < 0) - { - consolePrintChar('-'); - d *= -1; - } - - if (d == 0) - buf[loop++] = 0; - else while (d > 0) - { - buf[loop++] = d % 10; - d /= 10; - } - - for (i = 7; i >= 0; i--) - { - if(buf[i] || i < loop) - consolePrintChar(buf[i] + '0'); - else if(i < w) - consolePrintChar(' '); - } -} - -void printBin(int w, int d) -{ - int i; - int first = 0; - for (i = 31; i >= 0; i--) - { - if(d & BIT(i)) - { - first = 1; - consolePrintChar('1'); - } - else if (first || i == 0) - consolePrintChar('0'); - else if (i < w) - consolePrintChar(' '); - } -} - -void print0X(int w, unsigned d) -{ - int loop = 0; - int i = 0; - - char buf[] = {0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday - - - while(d > 0) - { - buf[loop++] = d & 0xF; - d = d>>4; - } - - for (i = 7; i >= 0; i--) - { - if(buf[i] || i < w || i < loop) - { - if(buf[i] < 10) - consolePrintChar(buf[i] + '0'); - else - consolePrintChar(buf[i] + 'A' - 10); - } - } -} - -void print0x(int w, unsigned int d) -{ - int loop = 0; - int i = 0; - - char buf[] = {0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday - - - while(d > 0) - { - buf[loop++] = d & 0xF; - d = d>>4; - } - - for (i = 7; i >= 0; i--) - { - if(buf[i] || i < w || i < loop) - { - if(buf[i] < 10) - consolePrintChar(buf[i] + '0'); - else - consolePrintChar(buf[i] + 'a' - 10); - } - } -} - -void print0Int(int w, int d) -{ - int loop = 0; - int i = 0; - - char buf[] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; //set to zero cause I may add formatted output someday - - if(d < 0) - { - consolePrintChar('-'); - d *= -1; - } - - while(d > 0) - { - buf[loop++] = d % 10; - d /= 10; - } - - for (i = 15; i >= 0; i--) - if(buf[i] || i < w || i < loop) - consolePrintChar(buf[i] + '0'); - -} - -void print0Bin(int w, int d) -{ - int i; - int first = 0; - for (i = 31; i >= 0; i--) - { - if(d & BIT(i)) - { - first = 1; - consolePrintChar('1'); - } - else if (first || i == 0) - consolePrintChar('0'); - else if (i < w) - consolePrintChar('0'); - } -} - -void print(const char* s) -{ - for(; *s; s++) consolePrintChar(*s); -} - -void printF(int w, float f) -{ - unsigned int* t = (unsigned int*)&f; - unsigned int fraction = (*t) & 0x007FFFFF; - int exp = ((*t) >> 23) & 0xFF; - - if(*t & BIT(31)) - consolePrintChar('-'); - - - print0Bin(32, fraction); - - printInt(1, fraction); - consolePrintChar('e'); - printInt(1, exp - 127); - - /* - if(exp == 0 && fraction == 0) - { - printInt(1,0); - } - else if(exp == 0xFF && fraction == 0) - { - print("Inifinite"); - } - else - { - printInt(w,fraction); - consolePrintChar('e'); - printInt(1,exp - 127); - } - */ -} - -void consolePrintf(const char* s, ...) -{ - int w = 1, z = 0; - - va_list argp; - - va_start(argp, s); - - - while(*s) - { - w = 1; - z = 0; - - switch(*s) - { - case '%': - s++; - if(*s == '0') - { - z = 1; - s++; - } - if(*s > '0' && *s <= '9') - { - w = *s - '0'; - s++; - } - switch (*s) - { - case 'i': - case 'I': - case 'd': - case 'D': - if(z)print0Int(w, va_arg(argp, int)); - else printInt(w, va_arg(argp, int)); - s++; - break; - case 'X': - if(z)print0X(w, va_arg(argp, int)); - else printX(w, va_arg(argp, int)); - s++; - break; - - case 'x': - if(z)print0x(w, va_arg(argp, int)); - else printx(w, va_arg(argp, int)); - s++; - break; - - case 'b': - case 'B': - if(z)print0Bin(w, va_arg(argp, int)); - else printBin(w, va_arg(argp, int)); - s++; - break; - case 'f': - case 'F': - printF(w,va_arg(argp, double)); - s++; - break; - case 's': - case 'S': - print(va_arg(argp, char*)); - s++; - break; - default: - consolePrintChar('%'); - break; - } - default: - consolePrintChar(*s); - break; - } - - s++; - } - va_end(argp); -} - -void consolePutString(int x, int y, char* s) -{ - consolePrintSet(x, y); - consolePrintf(s); -} - -void consolePutInt(int x, int y, int d) -{ - consolePrintSet(x,y); - printInt(1,d); -} - -void consolePutX(int x, int y, int d) -{ - consolePrintSet(x, y); - printX(1,d); -} - -void consolePutChar(int x, int y, char c) -{ - consolePrintSet(x, y); - consolePrintChar(c); -} - -void consolePutBin(int x, int y, int b) -{ - consolePrintSet(x, y); - printBin(1,b); -} -void consoleClear(void) -{ - int i = 0; - consolePrintSet(0,0); - - while(i++ < CONSOLE_HEIGHT * CONSOLE_WIDTH) - consolePrintChar(' '); - - consolePrintSet(0,0); -} diff --git a/backends/platform/ds/arm9/source/scummhelp.cpp b/backends/platform/ds/arm9/source/scummhelp.cpp index a76e1fa10f..8f50733a4a 100644 --- a/backends/platform/ds/arm9/source/scummhelp.cpp +++ b/backends/platform/ds/arm9/source/scummhelp.cpp @@ -84,89 +84,3 @@ void updateStrings(byte gameId, byte version, Common::Platform platform, #undef ADD_TEXT #undef ADD_LINE -#include "stdafx.h" -#include "scummhelp.h" - -#define ADD_BIND(k,d) do { key[i] = k; dsc[i] = d; i++; } while (0) -#define ADD_TEXT(d) ADD_BIND("",d) -#define ADD_LINE ADD_BIND("","") - -#define HELP_NUM_LINES 15 - -namespace DS { - -void updateStrings(byte gameId, byte version, Common::Platform platform, - int page, Common::String &title, Common::String *&key, Common::String *&dsc) { - key = new Common::String[HELP_NUM_LINES]; - dsc = new Common::String[HELP_NUM_LINES]; - int i = 0; - switch (page) { - case 1: { - title = "DS Controls (right handed):"; - ADD_BIND("Pad Left", "Left mouse button"); - ADD_BIND("Pad Right", "Right mouse button"); - ADD_BIND("Pad Up", "Mouse hover mode (no click)"); - ADD_BIND("Pad Down", "Skip dialog line (some games)"); - ADD_BIND("Start", "Pause/Game menu"); - ADD_BIND("Select", "DS Options menu"); - ADD_BIND("B", "Skip cutscenes"); - ADD_BIND("A", "Switch screens"); - ADD_BIND("Y", "Show/hide debug console"); - ADD_BIND("X", "Show/hide keyboard"); - ADD_BIND("L + Pad", "Scroll current touch screen view"); - ADD_BIND("L + Pen", "Scroll current touch screen view"); - ADD_BIND("L + B", "Zoom in"); - ADD_BIND("L + A", "Zoom out"); - break; - } - - case 2: { - title = "DS Controls (left handed):"; - ADD_BIND("Y", "Left mouse button"); - ADD_BIND("A", "Right mouse button"); - ADD_BIND("X", "Mouse hover mode (no click)"); - ADD_BIND("B", "Skip dialog line (some games)"); - ADD_BIND("Start", "Pause/Game menu"); - ADD_BIND("Select", "DS Options menu"); - ADD_BIND("Pad Down", "Skip cutscenes"); - ADD_BIND("Pad Up", "Show/hide keyboard"); - ADD_BIND("Pad Left", "Show/hide debug console"); - ADD_BIND("Pad Right", "Swap screens"); - ADD_BIND("R + Pad", "Scroll current touch screen view"); - ADD_BIND("R + Pen", "Scroll current touch screen view"); - ADD_BIND("R + B", "Zoom in"); - ADD_BIND("R + A", "Zoom out"); - break; - } - - case 3: { - title = "Indiana Jones Fighting controls:"; - ADD_BIND("Pad Left", "Move left"); - ADD_BIND("Pad Right", "Move right"); - ADD_BIND("Pad Up", "High guard"); - ADD_BIND("Pad Down", "Guard down"); - ADD_BIND("Y", "Guard middle"); - ADD_BIND("X", "Punch high"); - ADD_BIND("A", "Punch middle"); - ADD_BIND("B", "Punch low"); - - ADD_BIND("L+R", "Hold during bootup to clear SRAM"); - ADD_BIND("", "(flash cart only)"); - break; - } - } - - - while (i < HELP_NUM_LINES) { - ADD_LINE; - } - -} - -} - - -#undef ADD_BIND -#undef ADD_TEXT -#undef ADD_LINE - |