aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/fs/ds/ds-fs.cpp26
-rw-r--r--backends/fs/ds/ds-fs.h40
-rw-r--r--backends/platform/ds/arm7/Makefile2
-rw-r--r--backends/platform/ds/arm7/source/main.cpp8
-rw-r--r--backends/platform/ds/arm9/makefile36
-rw-r--r--backends/platform/ds/arm9/source/blitters.cpp6
-rw-r--r--backends/platform/ds/arm9/source/cdaudio.cpp35
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp267
-rw-r--r--backends/platform/ds/arm9/source/dsmain.h5
-rw-r--r--backends/platform/ds/arm9/source/fat/disc_io.c4
-rw-r--r--backends/platform/ds/arm9/source/fat/gba_nds_fat.c3
-rw-r--r--backends/platform/ds/arm9/source/fat/io_dldi.h4
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h1
-rw-r--r--backends/platform/ds/arm9/source/portdefs.cpp2
-rw-r--r--backends/platform/ds/arm9/source/portdefs.h32
-rw-r--r--backends/platform/ds/arm9/source/scummconsole.h62
-rw-r--r--backends/platform/ds/arm9/source/touchkeyboard.cpp4
-rw-r--r--common/file.cpp10
-rw-r--r--engines/agi/text.cpp8
20 files changed, 340 insertions, 217 deletions
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp
index 26a95976e6..40d160bbc8 100644
--- a/backends/fs/ds/ds-fs.cpp
+++ b/backends/fs/ds/ds-fs.cpp
@@ -22,7 +22,7 @@
#include "str.h"
#include "fs.h"
#include "common/util.h"
-#include <NDS/ARM9/console.h> //basic print funcionality
+//#include <NDS/ARM9/console.h> //basic print funcionality
#include "ds-fs.h"
#include "dsmain.h"
#include "gba_nds_fat.h"
@@ -30,29 +30,7 @@
namespace DS {
-struct fileHandle {
- int pos;
- bool used;
- char* data;
- int size;
-
- DSSaveFile* sramFile;
-};
-
-#define FILE DS::fileHandle
-
-// FIXME: The following definition for stdin etc. are duplicated in common/util.cpp.
-// This should be fixed, e.g. by moving this (and the declarations of fileHandle,
-// the various functions etc.) into a separate header file which includes by util.cpp,
-// file.cpp and ds-fs.cpp
-
-#undef stderr
-#undef stdout
-#undef stdin
-#define stdout ((DS::fileHandle*) -1)
-#define stderr ((DS::fileHandle*) -2)
-#define stdin ((DS::fileHandle*) -3)
//////////////////////////////////////////////////////////////
@@ -751,7 +729,7 @@ char* std_fgets(char* str, int size, FILE* file) {
p++;
file->sramFile->read((char *) &str[p], 1);
// consolePrintf("%d,", str[p]);
- } while ((str[p] >= 32) && (!feof(file)) && (p < size));
+ } while ((str[p] >= 32) && (!std_feof(file)) && (p < size));
str[p + 1] = 0;
file->pos++;
// consolePrintf("Read:%s\n", str);
diff --git a/backends/fs/ds/ds-fs.h b/backends/fs/ds/ds-fs.h
index bd14f5c795..2830ff61ae 100644
--- a/backends/fs/ds/ds-fs.h
+++ b/backends/fs/ds/ds-fs.h
@@ -21,9 +21,6 @@
#define _DS_FS_H
-#include "stdafx.h"
-#include "common/array.h"
-#include "common/str.h"
//#include <NDS/ARM9/console.h>
#include "fs.h"
@@ -105,13 +102,40 @@ public:
};
-// FIXME: Why is assert redefined ? And why here (this is definitely the wrong place).
-#ifdef assert
-#undef assert
-#endif
-#define assert(s) if (!(s)) consolePrintf("Assertion failed: '##s##' at file %s, line %d\n", __FILE__, __LINE__)
+struct fileHandle {
+ int pos;
+ bool used;
+ char* data;
+ int size;
+
+ DSSaveFile* sramFile;
+};
+
+
+#undef stderr
+#undef stdout
+#undef stdin
+
+#define stdout ((DS::fileHandle*) -1)
+#define stderr ((DS::fileHandle*) -2)
+#define stdin ((DS::fileHandle*) -3)
+
+#define FILE DS::fileHandle
+
+// Please do not remove any of these prototypes that appear not to be required.
+FILE* std_fopen(const char* name, const char* mode);
+void std_fclose(FILE* handle);
+int std_getc(FILE* handle);
+size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle);
+size_t std_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle);
+bool std_feof(FILE* handle);
+long int std_ftell(FILE* handle);
+int std_fseek(FILE* handle, long int offset, int whence);
+void std_clearerr(FILE* handle);
+void std_cwd(char* dir);
+void std_fflush(FILE* handle);
}
diff --git a/backends/platform/ds/arm7/Makefile b/backends/platform/ds/arm7/Makefile
index 5c62d7df58..847b6eea5a 100644
--- a/backends/platform/ds/arm7/Makefile
+++ b/backends/platform/ds/arm7/Makefile
@@ -68,7 +68,7 @@ endif
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
-LIBDIRS := $(DEVKITPRO)/libnds $(DEVKITPRO)/libnds/nds
+LIBDIRS := /home/neil/devkitpro/libnds home/neil/devkitpro/libnds/nds
#---------------------------------------------------------------------------------
diff --git a/backends/platform/ds/arm7/source/main.cpp b/backends/platform/ds/arm7/source/main.cpp
index d36b038e05..e3ecd30fe4 100644
--- a/backends/platform/ds/arm7/source/main.cpp
+++ b/backends/platform/ds/arm7/source/main.cpp
@@ -25,7 +25,7 @@
// -- modified by Darkain and others
//////////////////////////////////////////////////////////////////////
-#define USE_LIBCARTRESET
+//#define USE_LIBCARTRESET
#include <nds.h>
@@ -424,7 +424,6 @@ void InterruptTimer3() {
uint32 temp=0;
uint8 ct[sizeof(IPC->curtime)];
static int heartbeat = 0;
-
// Update the heartbeat
heartbeat++;
@@ -512,8 +511,7 @@ void InterruptTimer3() {
#ifdef USE_DEBUGGER
Wifi_Update(); // update wireless in vblank
#endif
- }
-
+}
//////////////////////////////////////////////////////////////////////
@@ -571,6 +569,7 @@ void reboot() {
int main(int argc, char ** argv) {
+
#ifdef USE_DEBUGGER
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;
@@ -639,6 +638,7 @@ int main(int argc, char ** argv) {
if (IPC->reset) {
powerOff();
}
+
swiWaitForVBlank();
}
return 0;
diff --git a/backends/platform/ds/arm9/makefile b/backends/platform/ds/arm9/makefile
index edf21887ab..f28abd2b77 100644
--- a/backends/platform/ds/arm9/makefile
+++ b/backends/platform/ds/arm9/makefile
@@ -1,12 +1,13 @@
#BUILD_PLUGINS = 1
-libndsdir = $(DEVKITPRO)/libnds
+#libndsdir = $(DEVKITPRO)/libnds
+libndsdir = /home/neil/devkitpro/libnds
# Select the build you want by uncommenting one of the following lines:
DS_BUILD_A = 1
#DS_BUILD_B = 1
#DS_BUILD_C = 1
-
+#DS_BUILD_D = 1
# Uncomment the following line to build in support for MP3 audio
# using libmad:
@@ -42,6 +43,7 @@ ifdef DS_BUILD_A
DISABLE_CINE = 1
DISABLE_AGI = 1
DISABLE_TOUCHE = 1
+ DISABLE_PARALLACTION = 1
BUILD=scummvm-A
endif
@@ -63,6 +65,7 @@ ifdef DS_BUILD_B
DISABLE_CINE = 1
DISABLE_AGI = 1
DISABLE_TOUCHE = 1
+ DISABLE_PARALLACTION = 1
BUILD=scummvm-B
endif
@@ -84,9 +87,32 @@ ifdef DS_BUILD_C
DISABLE_CINE = 1
DISABLE_AGI = 1
DISABLE_TOUCHE = 1
+ DISABLE_PARALLACTION = 1
BUILD=scummvm-C
endif
+ifdef DS_BUILD_D
+ DEFINES = -DDS_NON_SCUMM_BUILD -DDS_BUILD_D
+ LOGO = logoc.bmp
+ DISABLE_HE = 1
+ DISABLE_SCUMM = 1
+ DISABLE_SCUMM_7_8 = 1
+ DISABLE_AGOS = 1
+ DISABLE_SKY = 1
+ DISABLE_SWORD1 = 1
+ DISABLE_SWORD2 = 1
+ DISABLE_QUEEN = 1
+ DISABLE_SAGA = 1
+ DISABLE_KYRA = 1
+ DISABLE_GOB = 1
+ DISABLE_LURE = 1
+ #DISABLE_CINE = 1
+ #DISABLE_AGI = 1
+ DISABLE_TOUCHE = 1
+ DISABLE_PARALLACTION = 1
+ BUILD=scummvm-A
+endif
+
ARM7BIN := -7 $(CURDIR)/../../arm7/arm7.bin
ICON := -b ../../../logo.bmp "ScummVM;By Neil Millstone;"
@@ -108,7 +134,7 @@ CXXFLAGS= $(CFLAGS) -Wno-non-virtual-dtor -Wno-non-virtual-dtor \
-fno-exceptions -fno-rtti
ASFLAGS = -mcpu=arm9tdmi -mthumb-interwork
-DEFINES += -D__DS__ -DNDS -DARM9 -DNONSTANDARD_PORT -DDISABLE_FANCY_THEMES
+DEFINES += -D__DS__ -DNDS -DARM9 -DNONSTANDARD_PORT -DDISABLE_FANCY_THEMES -DDISABLE_DEFAULT_SAVEFILEMANAGER
ifdef USE_MAD
DEFINES += -DUSE_MAD
endif
@@ -156,7 +182,7 @@ PORT_OBJS := $(portdir)/source/blitters.o $(portdir)/source/cdaudio.o $(portdir)
$(portdir)/../../../fs/ds/ds-fs.o $(portdir)/source/gbampsave.o $(portdir)/source/scummhelp.o\
$(portdir)/source/osystem_ds.o $(portdir)/source/portdefs.o $(portdir)/source/ramsave.o\
$(portdir)/source/scummconsole.o $(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\
- $(portdir)/source/dsoptions.o
+ $(portdir)/source/dsoptions.o $(portdir)/source/keys.o
DATA_OBJS := $(portdir)/data/icons.o $(portdir)/data/keyboard.o $(portdir)/data/keyboard_pal.o $(portdir)/data/default_font.o
@@ -252,7 +278,7 @@ ifndef HAVE_GCC3
.cpp.o:
$(MKDIR) $(*D)/$(DEPDIR)
$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d2" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
- $(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d
+# $(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d
$(CAT) "$(*D)/$(DEPDIR)/$(*F).d2" >> "$(*D)/$(DEPDIR)/$(*F).d"
$(RM) "$(*D)/$(DEPDIR)/$(*F).d2"
else
diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp
index 105578e97a..7d1e0e4402 100644
--- a/backends/platform/ds/arm9/source/blitters.cpp
+++ b/backends/platform/ds/arm9/source/blitters.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+
#include "stdafx.h"
#define CHARSET_MASK_TRANSPARENCY 253
@@ -298,8 +298,8 @@ static inline void Rescale_320x1555Scanline_To_256x1555Scanline(u16* dest, const
void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, const u16* palette, int destStride, int srcStride)
{
- u32* fastRam = (u32 *) (0x37F8000 + 16384);
-
+ u32 fastRam[768];
+
// Palette lookup -> 0_888
for(size_t i=0; i<256; ++i)
{
diff --git a/backends/platform/ds/arm9/source/cdaudio.cpp b/backends/platform/ds/arm9/source/cdaudio.cpp
index 7261800802..e5011688b9 100644
--- a/backends/platform/ds/arm9/source/cdaudio.cpp
+++ b/backends/platform/ds/arm9/source/cdaudio.cpp
@@ -85,6 +85,7 @@ int numLoops;
int blockCount;
int dataChunkStart;
int blocksLeft;
+bool trackStartsAt2 = false;
// These are from Microsoft's document on DVI ADPCM
@@ -128,7 +129,9 @@ void playTrack(int track, int numLoops, int startFrame, int duration) {
stopTrack();
}
-
+ if (trackStartsAt2) {
+ track++;
+ }
@@ -460,16 +463,17 @@ void stopTrack() {
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");
-
+bool trackExists(int num) {
Common::String path = ConfMan.get("path");
- // 6577 153 154
+
+ char fname[128];
+
+ sprintf(fname, "track%d.wav", num);
+
if (path[strlen(path.c_str()) - 1] == '/') {
- path = path + "track2.wav";
+ path = path + fname;
} else {
- path = path + "/track2.wav";
+ path = path + "/" + fname;
}
consolePrintf("Looking for %s...", path.c_str());
@@ -486,6 +490,21 @@ bool checkCD() {
}
}
+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");
+
+ if (trackExists(1)) {
+ trackStartsAt2 = false;
+ return true;
+ } else if (trackExists(2)) {
+ trackStartsAt2 = true;
+ return true;
+ } else {
+ 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 1a3d4f7142..f4927743cd 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -42,13 +42,14 @@
// - Delete saves?
// - Software scaler?
// - 100% scale
+// - Find out what's going wrong when you turn the console off
#define USE_LIBCARTRESET
//#define USE_BUILT_IN_DRIVER_SELECTION
#include <nds.h>
-#include <ARM9/console.h> //basic print funcionality
+//#include <ARM9/console.h> //basic print funcionality
#include <stdlib.h>
#include "dsmain.h"
@@ -74,6 +75,7 @@
#include "disc_io.h"
#include "blitters.h"
#include "cartreset_nolibfat.h"
+#include "keys.h"
namespace DS {
@@ -231,9 +233,10 @@ bool penDown;
bool penHeld;
bool penReleased;
bool penDownLastFrame;
-f32 penX, penY;
+s32 penX, penY;
int keysDownSaved;
int keysReleasedSaved;
+int keysChangedSaved;
bool penDownSaved;
bool penReleasedSaved;
@@ -241,11 +244,19 @@ int penDownFrames;
int touchXOffset = 0;
int touchYOffset = 0;
+int triggeredIcon = 0;
+int triggeredIconTimeout = 0;
+
u16 savedPalEntry255 = RGB15(31, 31, 31);
extern "C" int scummvm_main(int argc, char *argv[]);
+Common::EventType getKeyEvent(int key);
+int getKeysChanged();
+
void updateStatus();
+void triggerIcon(int imageNum);
+void setIcon(int num, int x, int y, int imageNum, int flags, bool enable);
TransferSound soundControl;
@@ -469,11 +480,11 @@ void displayMode8Bit() {
videoSetMode(MODE_5_2D | 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);
+ vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
+ vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
- vramSetBankC(VRAM_C_SUB_BG_0x6200000);
- vramSetBankD(VRAM_D_MAIN_BG_0x6040000);
+ vramSetBankC(VRAM_C_SUB_BG_0x06200000);
+ vramSetBankD(VRAM_D_MAIN_BG_0x06040000);
vramSetBankH(VRAM_H_LCD);
@@ -489,11 +500,11 @@ void displayMode8Bit() {
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);
+ vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
+ vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
- vramSetBankC(VRAM_C_SUB_BG_0x6200000);
- vramSetBankD(VRAM_D_MAIN_BG_0x6040000);
+ vramSetBankC(VRAM_C_SUB_BG_0x06200000);
+ vramSetBankD(VRAM_D_MAIN_BG_0x06040000);
vramSetBankH(VRAM_H_LCD);
@@ -855,6 +866,8 @@ void addIndyFightingKeys() {
event.type = Common::EVENT_KEYDOWN;
event.kbd.flags = 0;
+
+ consolePrintf("Fight keys\n");
if ((getKeysDown() & KEY_L)) {
indyFightRight = false;
@@ -864,22 +877,28 @@ void addIndyFightingKeys() {
indyFightRight = true;
}
- if ((getKeysDown() & KEY_UP)) {
+ consolePrintf("ifr:%d\n", indyFightRight);
+
+ if ((getKeysChanged() & KEY_UP)) {
+ event.type = getKeyEvent(KEY_UP);
event.kbd.keycode = '8';
event.kbd.ascii = '8';
system->addEvent(event);
}
- if ((getKeysDown() & KEY_LEFT)) {
+ if ((getKeysChanged() & KEY_LEFT)) {
+ event.type = getKeyEvent(KEY_LEFT);
event.kbd.keycode = '4';
event.kbd.ascii = '4';
system->addEvent(event);
}
- if ((getKeysDown() & KEY_RIGHT)) {
+ if ((getKeysChanged() & KEY_RIGHT)) {
+ event.type = getKeyEvent(KEY_RIGHT);
event.kbd.keycode = '6';
event.kbd.ascii = '6';
system->addEvent(event);
}
- if ((getKeysDown() & KEY_DOWN)) {
+ if ((getKeysChanged() & KEY_DOWN)) {
+ event.type = getKeyEvent(KEY_DOWN);
event.kbd.keycode = '2';
event.kbd.ascii = '2';
system->addEvent(event);
@@ -887,17 +906,20 @@ void addIndyFightingKeys() {
if (indyFightRight) {
- if ((getKeysDown() & KEY_X)) {
+ if ((getKeysChanged() & KEY_X)) {
+ event.type = getKeyEvent(KEY_X);
event.kbd.keycode = '9';
event.kbd.ascii = '9';
system->addEvent(event);
}
- if ((getKeysDown() & KEY_A)) {
+ if ((getKeysChanged() & KEY_A)) {
+ event.type = getKeyEvent(KEY_A);
event.kbd.keycode = '6';
event.kbd.ascii = '6';
system->addEvent(event);
}
- if ((getKeysDown() & KEY_B)) {
+ if ((getKeysChanged() & KEY_B)) {
+ event.type = getKeyEvent(KEY_B);
event.kbd.keycode = '3';
event.kbd.ascii = '3';
system->addEvent(event);
@@ -905,17 +927,20 @@ void addIndyFightingKeys() {
} else {
- if ((getKeysDown() & KEY_X)) {
+ if ((getKeysChanged() & KEY_X)) {
+ event.type = getKeyEvent(KEY_X);
event.kbd.keycode = '7';
event.kbd.ascii = '7';
system->addEvent(event);
}
- if ((getKeysDown() & KEY_A)) {
+ if ((getKeysChanged() & KEY_A)) {
+ event.type = getKeyEvent(KEY_A);
event.kbd.keycode = '4';
event.kbd.ascii = '4';
system->addEvent(event);
}
- if ((getKeysDown() & KEY_B)) {
+ if ((getKeysChanged() & KEY_B)) {
+ event.type = getKeyEvent(KEY_B);
event.kbd.keycode = '1';
event.kbd.ascii = '1';
system->addEvent(event);
@@ -924,7 +949,8 @@ void addIndyFightingKeys() {
}
- if ((getKeysDown() & KEY_Y)) {
+ if ((getKeysChanged() & KEY_Y)) {
+ event.type = getKeyEvent(KEY_Y);
event.kbd.keycode = '5';
event.kbd.ascii = '5';
system->addEvent(event);
@@ -967,8 +993,10 @@ void setKeyboardEnable(bool en) {
if (displayModeIs8Bit) {
// Copy the sub screen VRAM from the top screen - they should always be
// the same.
+ u16* buffer = get8BitBackBuffer();
+
for (int r = 0; r < (512 * 256) >> 1; r++) {
- BG_GFX_SUB[r] = get8BitBackBuffer()[r];
+ BG_GFX_SUB[r] = buffer[r];
}
SUB_DISPLAY_CR &= ~DISPLAY_BG1_ACTIVE; // Turn off keyboard layer
@@ -1024,14 +1052,12 @@ void addEventsToQueue() {
if (!indyFightState) {
-
- if ((getKeysDown() & KEY_B) && (!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
- // consolePrintf("Pressing Esc");
-
- event.type = Common::EVENT_KEYDOWN;
+ if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R))) {
event.kbd.keycode = 27;
event.kbd.ascii = 27;
event.kbd.flags = 0;
+
+ event.type = getKeyEvent(KEY_B);
system->addEvent(event);
}
@@ -1149,7 +1175,7 @@ void addEventsToQueue() {
}
}
- if ((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) && (displayModeIs8Bit)) {
+ if (((!(getKeysHeld() & KEY_L)) && (!(getKeysHeld() & KEY_R)) || (indyFightState)) && (displayModeIs8Bit)) {
// Controls specific to the control method
@@ -1163,10 +1189,10 @@ void addEventsToQueue() {
if (currentGame->control == CONT_SIMON) {
// Extra controls for Simon the Sorcerer
- if ((getKeysDown() & KEY_DOWN)) {
+ if ((getKeysChanged() & KEY_DOWN)) {
Common::Event event;
- event.type = Common::EVENT_KEYDOWN;
+ event.type = getKeyEvent(KEY_DOWN);
event.kbd.keycode = '#'; // F10 or # - show hotspots
event.kbd.ascii = '#';
event.kbd.flags = 0;
@@ -1177,10 +1203,10 @@ void addEventsToQueue() {
if (currentGame->control == CONT_SCUMM_ORIGINAL) {
// Extra controls for Scumm v1-5 games
- if ((getKeysDown() & KEY_DOWN)) {
+ if ((getKeysChanged() & KEY_DOWN)) {
Common::Event event;
- event.type = Common::EVENT_KEYDOWN;
+ event.type = getKeyEvent(KEY_DOWN);
event.kbd.keycode = '.'; // Full stop - skips current dialogue line
event.kbd.ascii = '.';
event.kbd.flags = 0;
@@ -1199,55 +1225,39 @@ void addEventsToQueue() {
if (!displayModeIs8Bit) {
// Front end controls
- if (leftHandedSwap(getKeysDown()) & KEY_UP) {
- event.type = Common::EVENT_KEYDOWN;
+ if (leftHandedSwap(getKeysChanged()) & KEY_UP) {
+ event.type = getKeyEvent(leftHandedSwap(KEY_UP));
event.kbd.keycode = SDLK_UP;
event.kbd.ascii = 0;
event.kbd.flags = 0;
system->addEvent(event);
-
- event.type = Common::EVENT_KEYUP;
- system->addEvent(event);
}
- if (leftHandedSwap(getKeysDown()) & KEY_DOWN) {
- event.type = Common::EVENT_KEYDOWN;
+ if (leftHandedSwap(getKeysChanged()) & KEY_DOWN) {
+ event.type = getKeyEvent(leftHandedSwap(KEY_DOWN));
event.kbd.keycode = SDLK_DOWN;
event.kbd.ascii = 0;
event.kbd.flags = 0;
system->addEvent(event);
-
- event.type = Common::EVENT_KEYUP;
- system->addEvent(event);
}
if (leftHandedSwap(getKeysDown()) & KEY_A) {
- event.type = Common::EVENT_KEYDOWN;
+ event.type = getKeyEvent(leftHandedSwap(KEY_A));
event.kbd.keycode = SDLK_RETURN;
event.kbd.ascii = 0;
event.kbd.flags = 0;
system->addEvent(event);
-
- event.type = Common::EVENT_KEYUP;
- system->addEvent(event);
}
}
- if ((getKeysDown() & KEY_START)) {
- event.type = Common::EVENT_KEYDOWN;
+ if ((getKeysChanged() & KEY_START)) {
+ event.type = getKeyEvent(KEY_START);
event.kbd.keycode = 319; // F5
event.kbd.ascii = 319;
event.kbd.flags = 0;
system->addEvent(event);
-/*
- event.type = Common::EVENT_KEYUP;
- event.kbd.keycode = 319; // F5
- event.kbd.ascii = 319;
- system->addEvent(event);*/
-
-// consolePrintf("Pressing F5");
}
@@ -1262,17 +1272,31 @@ void addEventsToQueue() {
}
}
+
+
+void triggerIcon(int imageNum) {
+ triggeredIcon = imageNum;
+ triggeredIconTimeout = 120;
+}
+
+
+void setIcon(int num, int x, int y, int imageNum, int flags, bool enable) {
+ sprites[num].attribute[0] = ATTR0_BMP | y | (!enable? ATTR0_DISABLED: 0);
+ sprites[num].attribute[1] = ATTR1_SIZE_32 | x | flags;
+ sprites[num].attribute[2] = ATTR2_ALPHA(1)| (imageNum * 16);
+}
+
void updateStatus() {
int offs;
if (displayModeIs8Bit) {
switch (mouseMode) {
case MOUSE_LEFT: {
- offs = 16;
+ offs = 1;
break;
}
case MOUSE_RIGHT: {
- offs = 32;
+ offs = 2;
break;
}
case MOUSE_HOVER: {
@@ -1286,25 +1310,28 @@ void updateStatus() {
}
}
-
- sprites[0].attribute[0] = ATTR0_BMP | 150;
- sprites[0].attribute[1] = ATTR1_SIZE_32 | 208;
- sprites[0].attribute[2] = ATTR2_ALPHA(1)| offs;
+ setIcon(0, 208, 150, offs, 0, true);
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;
+ setIcon(1, (190 - 32), 150, 3, (indyFightRight? 0: ATTR1_FLIP_X), true);
+ consolePrintf("%d\n", indyFightRight);
} else {
- sprites[2].attribute[0] = ATTR0_DISABLED;
- sprites[2].attribute[1] = 0;
- sprites[2].attribute[2] = 0;
+// setIcon(1, 0, 0, 0, 0, false);
}
+
+ if (triggeredIconTimeout > 0) {
+ triggeredIconTimeout--;
+ setIcon(4, 16, 150, triggeredIcon, 0, true);
+ } else {
+ setIcon(4, 0, 0, 0, 0, false);
+ }
+
} 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;
+ setIcon(0, 0, 0, 0, 0, false);
+ setIcon(1, 0, 0, 0, 0, false);
+ setIcon(2, 0, 0, 0, 0, false);
+ setIcon(3, 0, 0, 0, 0, false);
+ setIcon(4, 0, 0, 0, 0, false);
}
if ((keyboardIcon) && (!keyboardEnable) && (!displayModeIs8Bit)) {
@@ -1372,15 +1399,15 @@ void setMainScreenScale(int x, int y) {
}
}
-void setZoomedScreenScroll(int x, int y) {
+void setZoomedScreenScroll(int x, int y, bool shake) {
if (gameScreenSwap) {
- BG3_CX = x + (((frameCount & 1) == 0)? 64: 0);
+ BG3_CX = x + ((shake && ((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_CX = x + ((shake && (frameCount & 1) == 0)? 64: 0);
SUB_BG3_CY = y;
}
}
@@ -1505,29 +1532,62 @@ void VBlankHandler(void) {
static int ratio = ( 320 << 8) / SCUMM_GAME_WIDTH;
+ bool zooming = false;
if ((getKeysHeld() & KEY_L) || (getKeysHeld() & KEY_R)) {
if ((getKeysHeld() & KEY_A) && (subScreenScale < ratio)) {
- subScreenScale += 2;
+ subScreenScale += 1;
+ zooming = true;
}
if ((getKeysHeld() & KEY_B) && (subScreenScale > 128)) {
- subScreenScale -=2;
+ subScreenScale -=1;
+ zooming = true;
}
}
-
+
int xCenter = subScTargetX + ((subScreenWidth >> 1) << 8);
int yCenter = subScTargetY + ((subScreenHeight >> 1) << 8);
+
if (twoHundredPercentFixedScale) {
subScreenWidth = 256 >> 1;
subScreenHeight = 192 >> 1;
} else {
- subScreenWidth = SCUMM_GAME_WIDTH * subScreenScale >> 8;
+ subScreenWidth = (((SCUMM_GAME_HEIGHT * 256) / 192) * subScreenScale) >> 8;
subScreenHeight = SCUMM_GAME_HEIGHT * subScreenScale >> 8;
+
+ if ( ((subScreenWidth) > 256 - 8) && ((subScreenWidth) < 256 + 8) ) {
+ subScreenWidth = 256;
+ subScreenHeight = 192;
+ if (zooming) {
+ subScX = subScTargetX;
+ subScY = subScTargetY;
+ triggerIcon(0);
+ }
+ } else if ( ((subScreenWidth) > 128 - 8) && ((subScreenWidth) < 128 + 8) ) {
+ subScreenWidth = 128;
+ subScreenHeight = 96;
+ if (zooming) {
+ subScX = subScTargetX;
+ subScY = subScTargetY;
+ triggerIcon(1);
+ }
+ } else if (subScreenWidth > 256) {
+ subScreenWidth = 320;
+ subScreenHeight = 200;
+ if (zooming) {
+ subScX = subScTargetX;
+ subScY = subScTargetY;
+ triggerIcon(2);
+ }
+ } else {
+ triggerIcon(-1);
+ }
}
+
subScTargetX = xCenter - ((subScreenWidth >> 1) << 8);
subScTargetY = yCenter - ((subScreenHeight >> 1) << 8);
@@ -1595,8 +1655,8 @@ void VBlankHandler(void) {
scY = 0;
}
- setZoomedScreenScroll(subScX, subScY);
- setZoomedScreenScale(subScreenWidth, (subScreenHeight * 256) / 192);
+ setZoomedScreenScroll(subScX, subScY, (subScreenWidth != 256) && (subScreenWidth != 128));
+ setZoomedScreenScale(subScreenWidth, ((subScreenHeight * (256 << 8)) / 192) >> 8);
setMainScreenScroll(scX << 8, (scY << 8) + (shakePos << 8));
@@ -1612,15 +1672,15 @@ void VBlankHandler(void) {
scY = 0;
}
- setZoomedScreenScroll(subScX, subScY);
- setZoomedScreenScale(subScreenWidth, (subScreenHeight * 256) / 192);
+ setZoomedScreenScroll(subScX, subScY, (subScreenWidth != 256) && (subScreenWidth != 128));
+ setZoomedScreenScale(subScreenWidth, ((subScreenHeight * (256 << 8)) / 192) >> 8);
setMainScreenScroll(64, (scY << 8) + (shakePos << 8));
setMainScreenScale(320, 256); // 1:1 scale
}
} else {
- setZoomedScreenScroll(0, 0);
+ setZoomedScreenScroll(0, 0, true);
setZoomedScreenScale(320, 256);
setMainScreenScroll(0, 0);
@@ -1794,7 +1854,7 @@ void initHardware() {
}
WAIT_CR &= ~(0x0080);
- REG_WRAM_CNT = 0;
+// REG_WRAM_CNT = 0;
}
@@ -1903,6 +1963,7 @@ void keysUpdate() {
scanKeys();
keysDownSaved |= leftHandedSwap(keysDown());
keysReleasedSaved |= leftHandedSwap(keysUp());
+ keysChangedSaved = keysDownSaved | keysReleasedSaved;
}
int getKeysDown() {
@@ -1917,9 +1978,24 @@ int getKeysReleased() {
return keysReleasedSaved;
}
+int getKeysChanged() {
+ return keysChangedSaved;
+}
+
+Common::EventType getKeyEvent(int key) {
+ if (getKeysDown() & key) {
+ return Common::EVENT_KEYDOWN;
+ } else if (getKeysReleased() & key) {
+ return Common::EVENT_KEYUP;
+ } else {
+ return (Common::EventType) 0;
+ }
+}
+
void consumeKeys() {
keysDownSaved = 0;
keysReleasedSaved = 0;
+ keysChangedSaved = 0;
}
bool getPenDown() {
@@ -1992,6 +2068,26 @@ bool getIndyFightState() {
return indyFightState;
}
+///////////////////
+// Fast Ram
+///////////////////
+
+#define FAST_RAM_SIZE (30000)
+
+u8* fastRamPointer;
+u8 fastRamData[FAST_RAM_SIZE] ITCM_DATA;
+
+void* fastRamAlloc(int size) {
+ void* result = (void *) fastRamPointer;
+ fastRamPointer += size;
+ return (void *) (result);
+}
+
+void fastRamReset() {
+ fastRamPointer = fastRamData;
+}
+
+
/////////////////
// GBAMP
/////////////////
@@ -2153,6 +2249,7 @@ int main(void)
indyFightState = false;
indyFightRight = true;
+
// CPU speed = 67108864
// 8 frames = 2946 368.5 bytes per fr
@@ -2358,6 +2455,8 @@ int main(void)
char* argv[2] = {"/scummvmds", "--config=scummvmb.ini"};
#elif defined(DS_BUILD_C)
char* argv[2] = {"/scummvmds", "--config=scummvmc.ini"};
+#elif defined(DS_BUILD_D)
+ char* argv[2] = {"/scummvmds", "--config=scummvmd.ini"};
#endif
diff --git a/backends/platform/ds/arm9/source/dsmain.h b/backends/platform/ds/arm9/source/dsmain.h
index 040e78663a..40ac33528b 100644
--- a/backends/platform/ds/arm9/source/dsmain.h
+++ b/backends/platform/ds/arm9/source/dsmain.h
@@ -116,6 +116,11 @@ void setGameSize(int width, int height);
int getGameWidth();
int getGameHeight();
+// Fast RAM allocation (ITCM)
+void fastRamReset();
+void* fastRamAlloc(int size);
+
+
}
diff --git a/backends/platform/ds/arm9/source/fat/disc_io.c b/backends/platform/ds/arm9/source/fat/disc_io.c
index 006d4f3d0f..3cb70f510b 100644
--- a/backends/platform/ds/arm9/source/fat/disc_io.c
+++ b/backends/platform/ds/arm9/source/fat/disc_io.c
@@ -358,10 +358,10 @@ void disc_getDldiId(char* id) {
bool disc_setDsSlotInterface (void)
{
#ifdef ARM9
- WAIT_CR &= ~(1<<11);
+ REG_EXEMEMCNT &= ~(1<<11);
#endif
#ifdef ARM7
- WAIT_CR |= (1<<11);
+ REG_EXEMEMCNT |= (1<<11);
#endif
active_interface = DLDI_GetInterface();
diff --git a/backends/platform/ds/arm9/source/fat/gba_nds_fat.c b/backends/platform/ds/arm9/source/fat/gba_nds_fat.c
index 21c55cc92b..f343c4b997 100644
--- a/backends/platform/ds/arm9/source/fat/gba_nds_fat.c
+++ b/backends/platform/ds/arm9/source/fat/gba_nds_fat.c
@@ -22,7 +22,8 @@
#include "disc_io.h"
#include <string.h>
#ifdef NDS
- #include <nds/ipc.h> // Time on the NDS
+// #include <nds/ipc.h> // Time on the NDS
+ #include <NDS/scummvm_ipc.h>
#endif
//----------------------------------------------------------------
// Data types
diff --git a/backends/platform/ds/arm9/source/fat/io_dldi.h b/backends/platform/ds/arm9/source/fat/io_dldi.h
index 4ef3625eba..053de3a94c 100644
--- a/backends/platform/ds/arm9/source/fat/io_dldi.h
+++ b/backends/platform/ds/arm9/source/fat/io_dldi.h
@@ -19,6 +19,7 @@
#include "disc_io.h"
#ifdef NDS
#include <nds/memory.h>
+#include <nds.h>
#endif
extern IO_INTERFACE _io_dldi;
@@ -28,7 +29,8 @@ extern u8 _dldi_driver_name;
// export interface
static inline LPIO_INTERFACE DLDI_GetInterface(void) {
#ifdef NDS
- WAIT_CR &= ~(ARM9_OWNS_ROM | ARM9_OWNS_CARD);
+ // NDM: I'm really not sure about this change ARM9 - ARM7
+ REG_EXEMEMCNT &= ~(ARM7_OWNS_ROM | ARM7_OWNS_CARD);
#endif // defined NDS
return &_io_dldi;
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index dff6acad96..36d1e8e032 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -320,9 +320,11 @@ bool OSystem_DS::pollEvent(Common::Event &event)
event.kbd.ascii = 0;
event.kbd.keycode = 0;
event.kbd.flags = 0;
+ consolePrintf("type: %d\n", event.type);
return false;
} else {
event = eventQueue[eventNum++];
+ consolePrintf("type: %d\n", event.type);
return true;
}
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index 3f4e56e000..583ab9a2ba 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -22,6 +22,7 @@
#ifndef _OSYSTEM_DS_H_
#define _OSYSTEM_DS_H_
#include "common/system.h"
+#include "common/events.h"
#include "nds.h"
#include "ramsave.h"
#include "gbampsave.h"
diff --git a/backends/platform/ds/arm9/source/portdefs.cpp b/backends/platform/ds/arm9/source/portdefs.cpp
index 77972ec106..6ef1d575f2 100644
--- a/backends/platform/ds/arm9/source/portdefs.cpp
+++ b/backends/platform/ds/arm9/source/portdefs.cpp
@@ -18,7 +18,7 @@
*
*/
-#include "portdefs.h"
+#include "stdafx.h"
#include <string.h>
#include "nds/dma.h"
#include "osystem_ds.h"
diff --git a/backends/platform/ds/arm9/source/portdefs.h b/backends/platform/ds/arm9/source/portdefs.h
index 02d54d3850..2266a1d986 100644
--- a/backends/platform/ds/arm9/source/portdefs.h
+++ b/backends/platform/ds/arm9/source/portdefs.h
@@ -33,11 +33,32 @@ typedef signed int s32;
//#define double float
+// Somebody removed these from scummsys.h, but they're still required, so I'm adding them here
+// in the hope that they'll stay.
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <math.h>
+#include <time.h>
+
+
#define CT_NO_TRANSPARENCY
+#include "scummconsole.h"
+
+
+//#undef assert
+//#define assert(expr) consolePrintf("Asserted!")
+#define NO_DEBUG_MSGS
+
+#ifdef assert
#undef assert
-#define assert(expr) consolePrintf("Asserted!")
-//#define NO_DEBUG_MSGS
+#endif
+
+#define assert(s) if (!(s)) consolePrintf("Assertion failed: '##s##' at file %s, line %d\n", __FILE__, __LINE__)
+
#include "ds-fs.h"
//#define debug(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__)
@@ -45,6 +66,13 @@ typedef signed int s32;
#define time(t) DS_time(t)
//#define memcpy(dest, src, size) DS_memcpy(dest, src, size)
+#define ITCM_DATA __attribute__((section(".itcm")))
+
+
+
+#include "common/array.h"
+#include "common/str.h"
+
time_t DS_time(time_t* t);
time_t DS_time(long* t);
void* DS_memcpy(void* s1, void const* s2, size_t n);
diff --git a/backends/platform/ds/arm9/source/scummconsole.h b/backends/platform/ds/arm9/source/scummconsole.h
index 6b9a677cc7..0bbb2f85f4 100644
--- a/backends/platform/ds/arm9/source/scummconsole.h
+++ b/backends/platform/ds/arm9/source/scummconsole.h
@@ -38,67 +38,6 @@
extern "C" {
#endif
-void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth);
-void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth);
-
-void consolePrintf(const char* s, ...);
-
-void consolePrintSet(int x, int y);
-
-void consolePrintChar(char c);
-
-void consolePutString(int x, int y, char* s);
-void consolePutInt(int x, int y, int d);
-void consolePutX(int x, int y, int d);
-void consolePutChar(int x, int y, char c);
-void consolePutBin(int x, int y, int b);
-
-void consoleClear(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-//////////////////////////////////////////////////////////////////////
-//
-// consol.h --provides basic consol type 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.
-//
-//////////////////////////////////////////////////////////////////////
-#ifndef CONSOLE_H2
-#define CONSOLE_H2
-
-#define CONSOLE_USE_COLOR255 16
-
-#ifdef __cplusplus
-extern "C" {
-#endif
void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth);
void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth);
@@ -122,3 +61,4 @@ void consoleClear(void);
#endif
#endif
+
diff --git a/backends/platform/ds/arm9/source/touchkeyboard.cpp b/backends/platform/ds/arm9/source/touchkeyboard.cpp
index 82271b0d82..6302a959ff 100644
--- a/backends/platform/ds/arm9/source/touchkeyboard.cpp
+++ b/backends/platform/ds/arm9/source/touchkeyboard.cpp
@@ -131,13 +131,13 @@ bool capsLockState;
bool closed;
void restoreVRAM(int tileBase, int mapBase, u16* saveSpace) {
- for (int r = 0; r < 32 * 32; r++) {
+/* for (int r = 0; r < 32 * 32; r++) {
((u16 *) SCREEN_BASE_BLOCK_SUB(mapBase))[r] = *saveSpace++;
}
for (int r = 0; r < 4096; r++) {
((u16 *) CHAR_BASE_BLOCK_SUB(tileBase))[r] = *saveSpace++;
- }
+ }*/
}
void drawKeyboard(int tileBase, int mapBase, u16* saveSpace) {
diff --git a/common/file.cpp b/common/file.cpp
index af7d227344..9ccfcd85ba 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -70,16 +70,6 @@
//#undef getc
//#undef ferror
- #define FILE void
-
- FILE* std_fopen(const char* name, const char* mode);
- void std_fclose(FILE* handle);
- size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle);
- size_t std_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle);
- bool std_feof(FILE* handle);
- long int std_ftell(FILE* handle);
- int std_fseek(FILE* handle, long int offset, int whence);
- void std_clearerr(FILE* handle);
//void std_fprintf(FILE* handle, const char* fmt, ...); // used in common/util.cpp
//void std_fflush(FILE* handle); // used in common/util.cpp
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 7f4cf1fc54..8f3f0a7a44 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -35,7 +35,14 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
int maxx, minx, ofoff;
int update;
/* Note: Must be unsigned to use AGDS cyrillic characters! */
+#ifdef __DS__
+ // On the DS, a compiler bug causes the text to render incorrectly, because
+ // GCC tries to optimisie out writes to this pointer (tested on DevkitARM v19b and v20)
+ // Making this pointer volatile fixes this.
+ volatile const unsigned char *m;
+#else
const unsigned char *m;
+#endif
/* kludge! */
update = 1;
@@ -81,6 +88,7 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
}
x1++;
+
/* DF: changed the len-1 to len... */
if (x1 == len && m[1] != '\n')
y1++, x1 = foff = 0;